@wrongstack/tools 0.283.0 → 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 +25 -6
- 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.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/pack.js +25 -6
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
package/dist/pack.js
CHANGED
|
@@ -2675,6 +2675,24 @@ var IndexStore = class {
|
|
|
2675
2675
|
* When false, ranked search falls back to the LIKE + in-process BM25 path.
|
|
2676
2676
|
*/
|
|
2677
2677
|
ftsAvailable = false;
|
|
2678
|
+
/**
|
|
2679
|
+
* Cache of prepared statements keyed by their SQL text. `DatabaseSync`
|
|
2680
|
+
* compiles SQL on every `.prepare()` call; for the fixed-SQL methods
|
|
2681
|
+
* (upsertFile, getFileMeta, deleteFile, insertRefs, …) that runs thousands
|
|
2682
|
+
* of times during a full reindex. `StatementSync` objects are reusable
|
|
2683
|
+
* across calls on the same connection, so we compile each distinct SQL once
|
|
2684
|
+
* and reuse it. Cleared in {@link close} when the connection is torn down.
|
|
2685
|
+
*/
|
|
2686
|
+
stmtCache = /* @__PURE__ */ new Map();
|
|
2687
|
+
/** Prepare-once helper: compile `sql` on first use, reuse thereafter. */
|
|
2688
|
+
stmt(sql) {
|
|
2689
|
+
let s = this.stmtCache.get(sql);
|
|
2690
|
+
if (s === void 0) {
|
|
2691
|
+
s = this.db.prepare(sql);
|
|
2692
|
+
this.stmtCache.set(sql, s);
|
|
2693
|
+
}
|
|
2694
|
+
return s;
|
|
2695
|
+
}
|
|
2678
2696
|
/**
|
|
2679
2697
|
* Execute a SQLite write operation with automatic retry on lock conflicts.
|
|
2680
2698
|
*
|
|
@@ -2844,9 +2862,9 @@ var IndexStore = class {
|
|
|
2844
2862
|
deleteSymbolsForFile(file) {
|
|
2845
2863
|
this.runWithRetry(() => {
|
|
2846
2864
|
if (this.ftsAvailable) {
|
|
2847
|
-
this.
|
|
2865
|
+
this.stmt("DELETE FROM symbols_fts WHERE rowid IN (SELECT id FROM symbols WHERE file_fk = ?)").run(file);
|
|
2848
2866
|
}
|
|
2849
|
-
this.
|
|
2867
|
+
this.stmt("DELETE FROM symbols WHERE file_fk = ?").run(file);
|
|
2850
2868
|
});
|
|
2851
2869
|
}
|
|
2852
2870
|
/**
|
|
@@ -2858,13 +2876,13 @@ var IndexStore = class {
|
|
|
2858
2876
|
this.runWithRetry(() => {
|
|
2859
2877
|
this.deleteRefsForFile(file);
|
|
2860
2878
|
this.deleteSymbolsForFile(file);
|
|
2861
|
-
this.
|
|
2879
|
+
this.stmt("DELETE FROM files WHERE file = ?").run(file);
|
|
2862
2880
|
});
|
|
2863
2881
|
}
|
|
2864
2882
|
// ─── File metadata ──────────────────────────────────────────────────────────
|
|
2865
2883
|
upsertFile(meta) {
|
|
2866
2884
|
this.runWithRetry(() => {
|
|
2867
|
-
this.
|
|
2885
|
+
this.stmt(
|
|
2868
2886
|
`INSERT INTO files(file, lang, mtime_ms, symbol_count, last_indexed)
|
|
2869
2887
|
VALUES (?, ?, ?, ?, ?)
|
|
2870
2888
|
ON CONFLICT(file) DO UPDATE SET
|
|
@@ -2876,7 +2894,7 @@ var IndexStore = class {
|
|
|
2876
2894
|
});
|
|
2877
2895
|
}
|
|
2878
2896
|
getFileMeta(file) {
|
|
2879
|
-
const rows = this.
|
|
2897
|
+
const rows = this.stmt(
|
|
2880
2898
|
"SELECT file, lang, mtime_ms, symbol_count, last_indexed FROM files WHERE file = ?"
|
|
2881
2899
|
).all(file);
|
|
2882
2900
|
if (!rows.length) return null;
|
|
@@ -3099,7 +3117,7 @@ var IndexStore = class {
|
|
|
3099
3117
|
*/
|
|
3100
3118
|
insertRefs(fromId, refs) {
|
|
3101
3119
|
this.runWithRetry(() => {
|
|
3102
|
-
this.
|
|
3120
|
+
this.stmt("DELETE FROM refs WHERE from_id = ?").run(fromId);
|
|
3103
3121
|
if (refs.length === 0) return;
|
|
3104
3122
|
const stmt = this.db.prepare(
|
|
3105
3123
|
`INSERT INTO refs(from_id, to_name, to_id, call_type, line)
|
|
@@ -3300,6 +3318,7 @@ var IndexStore = class {
|
|
|
3300
3318
|
}
|
|
3301
3319
|
}
|
|
3302
3320
|
close() {
|
|
3321
|
+
this.stmtCache.clear();
|
|
3303
3322
|
try {
|
|
3304
3323
|
this.db.close();
|
|
3305
3324
|
} catch {
|