@neuralsea/workspace-indexer 0.3.6 → 0.4.0
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/{chunk-FUUQXFJQ.js → chunk-77UJJ6YQ.js} +512 -395
- package/dist/chunk-MCKGQKYU.js +15 -0
- package/dist/cli.cjs +2580 -374
- package/dist/cli.js +2 -1
- package/dist/index.cjs +2588 -373
- package/dist/index.d.cts +57 -3
- package/dist/index.d.ts +57 -3
- package/dist/index.js +10 -1
- package/dist/sql-wasm-LT2WFO7Q.js +2097 -0
- package/package.json +6 -3
package/dist/cli.cjs
CHANGED
|
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
9
12
|
var __copyProps = (to, from, except, desc) => {
|
|
10
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
14
|
for (let key of __getOwnPropNames(from))
|
|
@@ -23,13 +26,2106 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
26
|
mod
|
|
24
27
|
));
|
|
25
28
|
|
|
29
|
+
// node_modules/sql.js/dist/sql-wasm.js
|
|
30
|
+
var require_sql_wasm = __commonJS({
|
|
31
|
+
"node_modules/sql.js/dist/sql-wasm.js"(exports2, module2) {
|
|
32
|
+
"use strict";
|
|
33
|
+
var initSqlJsPromise = void 0;
|
|
34
|
+
var initSqlJs = function(moduleConfig) {
|
|
35
|
+
if (initSqlJsPromise) {
|
|
36
|
+
return initSqlJsPromise;
|
|
37
|
+
}
|
|
38
|
+
initSqlJsPromise = new Promise(function(resolveModule, reject) {
|
|
39
|
+
var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
|
|
40
|
+
var originalOnAbortFunction = Module["onAbort"];
|
|
41
|
+
Module["onAbort"] = function(errorThatCausedAbort) {
|
|
42
|
+
reject(new Error(errorThatCausedAbort));
|
|
43
|
+
if (originalOnAbortFunction) {
|
|
44
|
+
originalOnAbortFunction(errorThatCausedAbort);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Module["postRun"] = Module["postRun"] || [];
|
|
48
|
+
Module["postRun"].push(function() {
|
|
49
|
+
resolveModule(Module);
|
|
50
|
+
});
|
|
51
|
+
module2 = void 0;
|
|
52
|
+
var f;
|
|
53
|
+
f ||= typeof Module != "undefined" ? Module : {};
|
|
54
|
+
var aa = "object" == typeof window, ba = "undefined" != typeof WorkerGlobalScope, ca = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node && "renderer" != process.type;
|
|
55
|
+
"use strict";
|
|
56
|
+
f.onRuntimeInitialized = function() {
|
|
57
|
+
function a(g, l) {
|
|
58
|
+
switch (typeof l) {
|
|
59
|
+
case "boolean":
|
|
60
|
+
dc(g, l ? 1 : 0);
|
|
61
|
+
break;
|
|
62
|
+
case "number":
|
|
63
|
+
ec(g, l);
|
|
64
|
+
break;
|
|
65
|
+
case "string":
|
|
66
|
+
fc(g, l, -1, -1);
|
|
67
|
+
break;
|
|
68
|
+
case "object":
|
|
69
|
+
if (null === l) lb(g);
|
|
70
|
+
else if (null != l.length) {
|
|
71
|
+
var n = da(l, ea);
|
|
72
|
+
gc(g, n, l.length, -1);
|
|
73
|
+
fa(n);
|
|
74
|
+
} else va(g, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
lb(g);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function b(g, l) {
|
|
81
|
+
for (var n = [], r = 0; r < g; r += 1) {
|
|
82
|
+
var t = m(l + 4 * r, "i32"), y = hc(t);
|
|
83
|
+
if (1 === y || 2 === y) t = ic(t);
|
|
84
|
+
else if (3 === y) t = jc(t);
|
|
85
|
+
else if (4 === y) {
|
|
86
|
+
y = t;
|
|
87
|
+
t = kc(y);
|
|
88
|
+
y = lc(y);
|
|
89
|
+
for (var L = new Uint8Array(t), J = 0; J < t; J += 1) L[J] = p[y + J];
|
|
90
|
+
t = L;
|
|
91
|
+
} else t = null;
|
|
92
|
+
n.push(t);
|
|
93
|
+
}
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
function c(g, l) {
|
|
97
|
+
this.Qa = g;
|
|
98
|
+
this.db = l;
|
|
99
|
+
this.Oa = 1;
|
|
100
|
+
this.lb = [];
|
|
101
|
+
}
|
|
102
|
+
function d(g, l) {
|
|
103
|
+
this.db = l;
|
|
104
|
+
l = ha(g) + 1;
|
|
105
|
+
this.eb = ia(l);
|
|
106
|
+
if (null === this.eb) throw Error("Unable to allocate memory for the SQL string");
|
|
107
|
+
u(g, x, this.eb, l);
|
|
108
|
+
this.kb = this.eb;
|
|
109
|
+
this.Za = this.pb = null;
|
|
110
|
+
}
|
|
111
|
+
function e(g) {
|
|
112
|
+
this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
|
|
113
|
+
if (null != g) {
|
|
114
|
+
var l = this.filename, n = "/", r = l;
|
|
115
|
+
n && (n = "string" == typeof n ? n : ja(n), r = l ? ka(n + "/" + l) : n);
|
|
116
|
+
l = la(true, true);
|
|
117
|
+
r = ma(r, l);
|
|
118
|
+
if (g) {
|
|
119
|
+
if ("string" == typeof g) {
|
|
120
|
+
n = Array(g.length);
|
|
121
|
+
for (var t = 0, y = g.length; t < y; ++t) n[t] = g.charCodeAt(t);
|
|
122
|
+
g = n;
|
|
123
|
+
}
|
|
124
|
+
na(r, l | 146);
|
|
125
|
+
n = oa(r, 577);
|
|
126
|
+
pa(n, g, 0, g.length, 0);
|
|
127
|
+
qa(n);
|
|
128
|
+
na(r, l);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
this.handleError(q(this.filename, h));
|
|
132
|
+
this.db = m(h, "i32");
|
|
133
|
+
ob(this.db);
|
|
134
|
+
this.fb = {};
|
|
135
|
+
this.Sa = {};
|
|
136
|
+
}
|
|
137
|
+
var h = z(4), k = f.cwrap, q = k("sqlite3_open", "number", ["string", "number"]), w = k("sqlite3_close_v2", "number", ["number"]), v = k("sqlite3_exec", "number", ["number", "string", "number", "number", "number"]), C = k("sqlite3_changes", "number", ["number"]), G = k("sqlite3_prepare_v2", "number", ["number", "string", "number", "number", "number"]), pb = k("sqlite3_sql", "string", ["number"]), nc = k("sqlite3_normalized_sql", "string", ["number"]), qb = k("sqlite3_prepare_v2", "number", ["number", "number", "number", "number", "number"]), oc = k("sqlite3_bind_text", "number", ["number", "number", "number", "number", "number"]), rb = k("sqlite3_bind_blob", "number", ["number", "number", "number", "number", "number"]), pc = k("sqlite3_bind_double", "number", ["number", "number", "number"]), qc = k(
|
|
138
|
+
"sqlite3_bind_int",
|
|
139
|
+
"number",
|
|
140
|
+
["number", "number", "number"]
|
|
141
|
+
), rc = k("sqlite3_bind_parameter_index", "number", ["number", "string"]), sc = k("sqlite3_step", "number", ["number"]), tc = k("sqlite3_errmsg", "string", ["number"]), uc = k("sqlite3_column_count", "number", ["number"]), vc = k("sqlite3_data_count", "number", ["number"]), wc = k("sqlite3_column_double", "number", ["number", "number"]), sb = k("sqlite3_column_text", "string", ["number", "number"]), xc = k("sqlite3_column_blob", "number", ["number", "number"]), yc = k("sqlite3_column_bytes", "number", [
|
|
142
|
+
"number",
|
|
143
|
+
"number"
|
|
144
|
+
]), zc = k("sqlite3_column_type", "number", ["number", "number"]), Ac = k("sqlite3_column_name", "string", ["number", "number"]), Bc = k("sqlite3_reset", "number", ["number"]), Cc = k("sqlite3_clear_bindings", "number", ["number"]), Dc = k("sqlite3_finalize", "number", ["number"]), tb = k("sqlite3_create_function_v2", "number", "number string number number number number number number number".split(" ")), hc = k("sqlite3_value_type", "number", ["number"]), kc = k("sqlite3_value_bytes", "number", ["number"]), jc = k(
|
|
145
|
+
"sqlite3_value_text",
|
|
146
|
+
"string",
|
|
147
|
+
["number"]
|
|
148
|
+
), lc = k("sqlite3_value_blob", "number", ["number"]), ic = k("sqlite3_value_double", "number", ["number"]), ec = k("sqlite3_result_double", "", ["number", "number"]), lb = k("sqlite3_result_null", "", ["number"]), fc = k("sqlite3_result_text", "", ["number", "string", "number", "number"]), gc = k("sqlite3_result_blob", "", ["number", "number", "number", "number"]), dc = k("sqlite3_result_int", "", ["number", "number"]), va = k("sqlite3_result_error", "", ["number", "string", "number"]), ub = k(
|
|
149
|
+
"sqlite3_aggregate_context",
|
|
150
|
+
"number",
|
|
151
|
+
["number", "number"]
|
|
152
|
+
), ob = k("RegisterExtensionFunctions", "number", ["number"]), vb = k("sqlite3_update_hook", "number", ["number", "number", "number"]);
|
|
153
|
+
c.prototype.bind = function(g) {
|
|
154
|
+
if (!this.Qa) throw "Statement closed";
|
|
155
|
+
this.reset();
|
|
156
|
+
return Array.isArray(g) ? this.Cb(g) : null != g && "object" === typeof g ? this.Db(g) : true;
|
|
157
|
+
};
|
|
158
|
+
c.prototype.step = function() {
|
|
159
|
+
if (!this.Qa) throw "Statement closed";
|
|
160
|
+
this.Oa = 1;
|
|
161
|
+
var g = sc(this.Qa);
|
|
162
|
+
switch (g) {
|
|
163
|
+
case 100:
|
|
164
|
+
return true;
|
|
165
|
+
case 101:
|
|
166
|
+
return false;
|
|
167
|
+
default:
|
|
168
|
+
throw this.db.handleError(g);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
c.prototype.wb = function(g) {
|
|
172
|
+
null == g && (g = this.Oa, this.Oa += 1);
|
|
173
|
+
return wc(this.Qa, g);
|
|
174
|
+
};
|
|
175
|
+
c.prototype.Gb = function(g) {
|
|
176
|
+
null == g && (g = this.Oa, this.Oa += 1);
|
|
177
|
+
g = sb(this.Qa, g);
|
|
178
|
+
if ("function" !== typeof BigInt) throw Error("BigInt is not supported");
|
|
179
|
+
return BigInt(g);
|
|
180
|
+
};
|
|
181
|
+
c.prototype.Hb = function(g) {
|
|
182
|
+
null == g && (g = this.Oa, this.Oa += 1);
|
|
183
|
+
return sb(this.Qa, g);
|
|
184
|
+
};
|
|
185
|
+
c.prototype.getBlob = function(g) {
|
|
186
|
+
null == g && (g = this.Oa, this.Oa += 1);
|
|
187
|
+
var l = yc(this.Qa, g);
|
|
188
|
+
g = xc(this.Qa, g);
|
|
189
|
+
for (var n = new Uint8Array(l), r = 0; r < l; r += 1) n[r] = p[g + r];
|
|
190
|
+
return n;
|
|
191
|
+
};
|
|
192
|
+
c.prototype.get = function(g, l) {
|
|
193
|
+
l = l || {};
|
|
194
|
+
null != g && this.bind(g) && this.step();
|
|
195
|
+
g = [];
|
|
196
|
+
for (var n = vc(this.Qa), r = 0; r < n; r += 1) switch (zc(this.Qa, r)) {
|
|
197
|
+
case 1:
|
|
198
|
+
var t = l.useBigInt ? this.Gb(r) : this.wb(r);
|
|
199
|
+
g.push(t);
|
|
200
|
+
break;
|
|
201
|
+
case 2:
|
|
202
|
+
g.push(this.wb(r));
|
|
203
|
+
break;
|
|
204
|
+
case 3:
|
|
205
|
+
g.push(this.Hb(r));
|
|
206
|
+
break;
|
|
207
|
+
case 4:
|
|
208
|
+
g.push(this.getBlob(r));
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
g.push(null);
|
|
212
|
+
}
|
|
213
|
+
return g;
|
|
214
|
+
};
|
|
215
|
+
c.prototype.getColumnNames = function() {
|
|
216
|
+
for (var g = [], l = uc(this.Qa), n = 0; n < l; n += 1) g.push(Ac(this.Qa, n));
|
|
217
|
+
return g;
|
|
218
|
+
};
|
|
219
|
+
c.prototype.getAsObject = function(g, l) {
|
|
220
|
+
g = this.get(g, l);
|
|
221
|
+
l = this.getColumnNames();
|
|
222
|
+
for (var n = {}, r = 0; r < l.length; r += 1) n[l[r]] = g[r];
|
|
223
|
+
return n;
|
|
224
|
+
};
|
|
225
|
+
c.prototype.getSQL = function() {
|
|
226
|
+
return pb(this.Qa);
|
|
227
|
+
};
|
|
228
|
+
c.prototype.getNormalizedSQL = function() {
|
|
229
|
+
return nc(this.Qa);
|
|
230
|
+
};
|
|
231
|
+
c.prototype.run = function(g) {
|
|
232
|
+
null != g && this.bind(g);
|
|
233
|
+
this.step();
|
|
234
|
+
return this.reset();
|
|
235
|
+
};
|
|
236
|
+
c.prototype.sb = function(g, l) {
|
|
237
|
+
null == l && (l = this.Oa, this.Oa += 1);
|
|
238
|
+
g = ra(g);
|
|
239
|
+
var n = da(g, ea);
|
|
240
|
+
this.lb.push(n);
|
|
241
|
+
this.db.handleError(oc(this.Qa, l, n, g.length - 1, 0));
|
|
242
|
+
};
|
|
243
|
+
c.prototype.Bb = function(g, l) {
|
|
244
|
+
null == l && (l = this.Oa, this.Oa += 1);
|
|
245
|
+
var n = da(g, ea);
|
|
246
|
+
this.lb.push(n);
|
|
247
|
+
this.db.handleError(rb(
|
|
248
|
+
this.Qa,
|
|
249
|
+
l,
|
|
250
|
+
n,
|
|
251
|
+
g.length,
|
|
252
|
+
0
|
|
253
|
+
));
|
|
254
|
+
};
|
|
255
|
+
c.prototype.rb = function(g, l) {
|
|
256
|
+
null == l && (l = this.Oa, this.Oa += 1);
|
|
257
|
+
this.db.handleError((g === (g | 0) ? qc : pc)(this.Qa, l, g));
|
|
258
|
+
};
|
|
259
|
+
c.prototype.Eb = function(g) {
|
|
260
|
+
null == g && (g = this.Oa, this.Oa += 1);
|
|
261
|
+
rb(this.Qa, g, 0, 0, 0);
|
|
262
|
+
};
|
|
263
|
+
c.prototype.tb = function(g, l) {
|
|
264
|
+
null == l && (l = this.Oa, this.Oa += 1);
|
|
265
|
+
switch (typeof g) {
|
|
266
|
+
case "string":
|
|
267
|
+
this.sb(g, l);
|
|
268
|
+
return;
|
|
269
|
+
case "number":
|
|
270
|
+
this.rb(g, l);
|
|
271
|
+
return;
|
|
272
|
+
case "bigint":
|
|
273
|
+
this.sb(g.toString(), l);
|
|
274
|
+
return;
|
|
275
|
+
case "boolean":
|
|
276
|
+
this.rb(g + 0, l);
|
|
277
|
+
return;
|
|
278
|
+
case "object":
|
|
279
|
+
if (null === g) {
|
|
280
|
+
this.Eb(l);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (null != g.length) {
|
|
284
|
+
this.Bb(
|
|
285
|
+
g,
|
|
286
|
+
l
|
|
287
|
+
);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
throw "Wrong API use : tried to bind a value of an unknown type (" + g + ").";
|
|
292
|
+
};
|
|
293
|
+
c.prototype.Db = function(g) {
|
|
294
|
+
var l = this;
|
|
295
|
+
Object.keys(g).forEach(function(n) {
|
|
296
|
+
var r = rc(l.Qa, n);
|
|
297
|
+
0 !== r && l.tb(g[n], r);
|
|
298
|
+
});
|
|
299
|
+
return true;
|
|
300
|
+
};
|
|
301
|
+
c.prototype.Cb = function(g) {
|
|
302
|
+
for (var l = 0; l < g.length; l += 1) this.tb(g[l], l + 1);
|
|
303
|
+
return true;
|
|
304
|
+
};
|
|
305
|
+
c.prototype.reset = function() {
|
|
306
|
+
this.freemem();
|
|
307
|
+
return 0 === Cc(this.Qa) && 0 === Bc(this.Qa);
|
|
308
|
+
};
|
|
309
|
+
c.prototype.freemem = function() {
|
|
310
|
+
for (var g; void 0 !== (g = this.lb.pop()); ) fa(g);
|
|
311
|
+
};
|
|
312
|
+
c.prototype.free = function() {
|
|
313
|
+
this.freemem();
|
|
314
|
+
var g = 0 === Dc(this.Qa);
|
|
315
|
+
delete this.db.fb[this.Qa];
|
|
316
|
+
this.Qa = 0;
|
|
317
|
+
return g;
|
|
318
|
+
};
|
|
319
|
+
d.prototype.next = function() {
|
|
320
|
+
if (null === this.eb) return { done: true };
|
|
321
|
+
null !== this.Za && (this.Za.free(), this.Za = null);
|
|
322
|
+
if (!this.db.db) throw this.mb(), Error("Database closed");
|
|
323
|
+
var g = sa(), l = z(4);
|
|
324
|
+
ta(h);
|
|
325
|
+
ta(l);
|
|
326
|
+
try {
|
|
327
|
+
this.db.handleError(qb(this.db.db, this.kb, -1, h, l));
|
|
328
|
+
this.kb = m(l, "i32");
|
|
329
|
+
var n = m(h, "i32");
|
|
330
|
+
if (0 === n) return this.mb(), { done: true };
|
|
331
|
+
this.Za = new c(n, this.db);
|
|
332
|
+
this.db.fb[n] = this.Za;
|
|
333
|
+
return { value: this.Za, done: false };
|
|
334
|
+
} catch (r) {
|
|
335
|
+
throw this.pb = ua(this.kb), this.mb(), r;
|
|
336
|
+
} finally {
|
|
337
|
+
wa(g);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
d.prototype.mb = function() {
|
|
341
|
+
fa(this.eb);
|
|
342
|
+
this.eb = null;
|
|
343
|
+
};
|
|
344
|
+
d.prototype.getRemainingSQL = function() {
|
|
345
|
+
return null !== this.pb ? this.pb : ua(this.kb);
|
|
346
|
+
};
|
|
347
|
+
"function" === typeof Symbol && "symbol" === typeof Symbol.iterator && (d.prototype[Symbol.iterator] = function() {
|
|
348
|
+
return this;
|
|
349
|
+
});
|
|
350
|
+
e.prototype.run = function(g, l) {
|
|
351
|
+
if (!this.db) throw "Database closed";
|
|
352
|
+
if (l) {
|
|
353
|
+
g = this.prepare(g, l);
|
|
354
|
+
try {
|
|
355
|
+
g.step();
|
|
356
|
+
} finally {
|
|
357
|
+
g.free();
|
|
358
|
+
}
|
|
359
|
+
} else this.handleError(v(this.db, g, 0, 0, h));
|
|
360
|
+
return this;
|
|
361
|
+
};
|
|
362
|
+
e.prototype.exec = function(g, l, n) {
|
|
363
|
+
if (!this.db) throw "Database closed";
|
|
364
|
+
var r = sa(), t = null;
|
|
365
|
+
try {
|
|
366
|
+
var y = xa(g), L = z(4);
|
|
367
|
+
for (g = []; 0 !== m(y, "i8"); ) {
|
|
368
|
+
ta(h);
|
|
369
|
+
ta(L);
|
|
370
|
+
this.handleError(qb(this.db, y, -1, h, L));
|
|
371
|
+
var J = m(h, "i32");
|
|
372
|
+
y = m(L, "i32");
|
|
373
|
+
if (0 !== J) {
|
|
374
|
+
var I = null;
|
|
375
|
+
t = new c(J, this);
|
|
376
|
+
for (null != l && t.bind(l); t.step(); ) null === I && (I = { columns: t.getColumnNames(), values: [] }, g.push(I)), I.values.push(t.get(null, n));
|
|
377
|
+
t.free();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return g;
|
|
381
|
+
} catch (M) {
|
|
382
|
+
throw t && t.free(), M;
|
|
383
|
+
} finally {
|
|
384
|
+
wa(r);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
e.prototype.each = function(g, l, n, r, t) {
|
|
388
|
+
"function" === typeof l && (r = n, n = l, l = void 0);
|
|
389
|
+
g = this.prepare(g, l);
|
|
390
|
+
try {
|
|
391
|
+
for (; g.step(); ) n(g.getAsObject(
|
|
392
|
+
null,
|
|
393
|
+
t
|
|
394
|
+
));
|
|
395
|
+
} finally {
|
|
396
|
+
g.free();
|
|
397
|
+
}
|
|
398
|
+
if ("function" === typeof r) return r();
|
|
399
|
+
};
|
|
400
|
+
e.prototype.prepare = function(g, l) {
|
|
401
|
+
ta(h);
|
|
402
|
+
this.handleError(G(this.db, g, -1, h, 0));
|
|
403
|
+
g = m(h, "i32");
|
|
404
|
+
if (0 === g) throw "Nothing to prepare";
|
|
405
|
+
var n = new c(g, this);
|
|
406
|
+
null != l && n.bind(l);
|
|
407
|
+
return this.fb[g] = n;
|
|
408
|
+
};
|
|
409
|
+
e.prototype.iterateStatements = function(g) {
|
|
410
|
+
return new d(g, this);
|
|
411
|
+
};
|
|
412
|
+
e.prototype["export"] = function() {
|
|
413
|
+
Object.values(this.fb).forEach(function(l) {
|
|
414
|
+
l.free();
|
|
415
|
+
});
|
|
416
|
+
Object.values(this.Sa).forEach(A);
|
|
417
|
+
this.Sa = {};
|
|
418
|
+
this.handleError(w(this.db));
|
|
419
|
+
var g = ya(this.filename);
|
|
420
|
+
this.handleError(q(
|
|
421
|
+
this.filename,
|
|
422
|
+
h
|
|
423
|
+
));
|
|
424
|
+
this.db = m(h, "i32");
|
|
425
|
+
ob(this.db);
|
|
426
|
+
return g;
|
|
427
|
+
};
|
|
428
|
+
e.prototype.close = function() {
|
|
429
|
+
null !== this.db && (Object.values(this.fb).forEach(function(g) {
|
|
430
|
+
g.free();
|
|
431
|
+
}), Object.values(this.Sa).forEach(A), this.Sa = {}, this.Ya && (A(this.Ya), this.Ya = void 0), this.handleError(w(this.db)), za("/" + this.filename), this.db = null);
|
|
432
|
+
};
|
|
433
|
+
e.prototype.handleError = function(g) {
|
|
434
|
+
if (0 === g) return null;
|
|
435
|
+
g = tc(this.db);
|
|
436
|
+
throw Error(g);
|
|
437
|
+
};
|
|
438
|
+
e.prototype.getRowsModified = function() {
|
|
439
|
+
return C(this.db);
|
|
440
|
+
};
|
|
441
|
+
e.prototype.create_function = function(g, l) {
|
|
442
|
+
Object.prototype.hasOwnProperty.call(
|
|
443
|
+
this.Sa,
|
|
444
|
+
g
|
|
445
|
+
) && (A(this.Sa[g]), delete this.Sa[g]);
|
|
446
|
+
var n = Aa(function(r, t, y) {
|
|
447
|
+
t = b(t, y);
|
|
448
|
+
try {
|
|
449
|
+
var L = l.apply(null, t);
|
|
450
|
+
} catch (J) {
|
|
451
|
+
va(r, J, -1);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
a(r, L);
|
|
455
|
+
}, "viii");
|
|
456
|
+
this.Sa[g] = n;
|
|
457
|
+
this.handleError(tb(this.db, g, l.length, 1, 0, n, 0, 0, 0));
|
|
458
|
+
return this;
|
|
459
|
+
};
|
|
460
|
+
e.prototype.create_aggregate = function(g, l) {
|
|
461
|
+
var n = l.init || function() {
|
|
462
|
+
return null;
|
|
463
|
+
}, r = l.finalize || function(I) {
|
|
464
|
+
return I;
|
|
465
|
+
}, t = l.step;
|
|
466
|
+
if (!t) throw "An aggregate function must have a step function in " + g;
|
|
467
|
+
var y = {};
|
|
468
|
+
Object.hasOwnProperty.call(this.Sa, g) && (A(this.Sa[g]), delete this.Sa[g]);
|
|
469
|
+
l = g + "__finalize";
|
|
470
|
+
Object.hasOwnProperty.call(this.Sa, l) && (A(this.Sa[l]), delete this.Sa[l]);
|
|
471
|
+
var L = Aa(function(I, M, Ra) {
|
|
472
|
+
var X = ub(I, 1);
|
|
473
|
+
Object.hasOwnProperty.call(y, X) || (y[X] = n());
|
|
474
|
+
M = b(M, Ra);
|
|
475
|
+
M = [y[X]].concat(M);
|
|
476
|
+
try {
|
|
477
|
+
y[X] = t.apply(null, M);
|
|
478
|
+
} catch (Fc) {
|
|
479
|
+
delete y[X], va(I, Fc, -1);
|
|
480
|
+
}
|
|
481
|
+
}, "viii"), J = Aa(function(I) {
|
|
482
|
+
var M = ub(I, 1);
|
|
483
|
+
try {
|
|
484
|
+
var Ra = r(y[M]);
|
|
485
|
+
} catch (X) {
|
|
486
|
+
delete y[M];
|
|
487
|
+
va(I, X, -1);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
a(I, Ra);
|
|
491
|
+
delete y[M];
|
|
492
|
+
}, "vi");
|
|
493
|
+
this.Sa[g] = L;
|
|
494
|
+
this.Sa[l] = J;
|
|
495
|
+
this.handleError(tb(this.db, g, t.length - 1, 1, 0, 0, L, J, 0));
|
|
496
|
+
return this;
|
|
497
|
+
};
|
|
498
|
+
e.prototype.updateHook = function(g) {
|
|
499
|
+
this.Ya && (vb(this.db, 0, 0), A(this.Ya), this.Ya = void 0);
|
|
500
|
+
g && (this.Ya = Aa(function(l, n, r, t, y) {
|
|
501
|
+
switch (n) {
|
|
502
|
+
case 18:
|
|
503
|
+
l = "insert";
|
|
504
|
+
break;
|
|
505
|
+
case 23:
|
|
506
|
+
l = "update";
|
|
507
|
+
break;
|
|
508
|
+
case 9:
|
|
509
|
+
l = "delete";
|
|
510
|
+
break;
|
|
511
|
+
default:
|
|
512
|
+
throw "unknown operationCode in updateHook callback: " + n;
|
|
513
|
+
}
|
|
514
|
+
r = r ? B(x, r) : "";
|
|
515
|
+
t = t ? B(x, t) : "";
|
|
516
|
+
if (y > Number.MAX_SAFE_INTEGER) throw "rowId too big to fit inside a Number";
|
|
517
|
+
g(l, r, t, Number(y));
|
|
518
|
+
}, "viiiij"), vb(this.db, this.Ya, 0));
|
|
519
|
+
};
|
|
520
|
+
f.Database = e;
|
|
521
|
+
};
|
|
522
|
+
var Ba = { ...f }, Ca = "./this.program", Da = (a, b) => {
|
|
523
|
+
throw b;
|
|
524
|
+
}, D = "", Ea, Fa;
|
|
525
|
+
if (ca) {
|
|
526
|
+
var fs18 = require("fs");
|
|
527
|
+
require("path");
|
|
528
|
+
D = __dirname + "/";
|
|
529
|
+
Fa = (a) => {
|
|
530
|
+
a = Ga(a) ? new URL(a) : a;
|
|
531
|
+
return fs18.readFileSync(a);
|
|
532
|
+
};
|
|
533
|
+
Ea = async (a) => {
|
|
534
|
+
a = Ga(a) ? new URL(a) : a;
|
|
535
|
+
return fs18.readFileSync(a, void 0);
|
|
536
|
+
};
|
|
537
|
+
!f.thisProgram && 1 < process.argv.length && (Ca = process.argv[1].replace(/\\/g, "/"));
|
|
538
|
+
process.argv.slice(2);
|
|
539
|
+
"undefined" != typeof module2 && (module2.exports = f);
|
|
540
|
+
Da = (a, b) => {
|
|
541
|
+
process.exitCode = a;
|
|
542
|
+
throw b;
|
|
543
|
+
};
|
|
544
|
+
} else if (aa || ba) ba ? D = self.location.href : "undefined" != typeof document && document.currentScript && (D = document.currentScript.src), D = D.startsWith("blob:") ? "" : D.slice(0, D.replace(/[?#].*/, "").lastIndexOf("/") + 1), ba && (Fa = (a) => {
|
|
545
|
+
var b = new XMLHttpRequest();
|
|
546
|
+
b.open("GET", a, false);
|
|
547
|
+
b.responseType = "arraybuffer";
|
|
548
|
+
b.send(null);
|
|
549
|
+
return new Uint8Array(b.response);
|
|
550
|
+
}), Ea = async (a) => {
|
|
551
|
+
if (Ga(a)) return new Promise((c, d) => {
|
|
552
|
+
var e = new XMLHttpRequest();
|
|
553
|
+
e.open("GET", a, true);
|
|
554
|
+
e.responseType = "arraybuffer";
|
|
555
|
+
e.onload = () => {
|
|
556
|
+
200 == e.status || 0 == e.status && e.response ? c(e.response) : d(e.status);
|
|
557
|
+
};
|
|
558
|
+
e.onerror = d;
|
|
559
|
+
e.send(null);
|
|
560
|
+
});
|
|
561
|
+
var b = await fetch(a, { credentials: "same-origin" });
|
|
562
|
+
if (b.ok) return b.arrayBuffer();
|
|
563
|
+
throw Error(b.status + " : " + b.url);
|
|
564
|
+
};
|
|
565
|
+
var Ha = f.print || console.log.bind(console), Ia = f.printErr || console.error.bind(console);
|
|
566
|
+
Object.assign(f, Ba);
|
|
567
|
+
Ba = null;
|
|
568
|
+
f.thisProgram && (Ca = f.thisProgram);
|
|
569
|
+
var Ja = f.wasmBinary, Ka, La = false, Ma, p, x, Na, E, F, Oa, H, Pa, Ga = (a) => a.startsWith("file://");
|
|
570
|
+
function Qa() {
|
|
571
|
+
var a = Ka.buffer;
|
|
572
|
+
f.HEAP8 = p = new Int8Array(a);
|
|
573
|
+
f.HEAP16 = Na = new Int16Array(a);
|
|
574
|
+
f.HEAPU8 = x = new Uint8Array(a);
|
|
575
|
+
f.HEAPU16 = new Uint16Array(a);
|
|
576
|
+
f.HEAP32 = E = new Int32Array(a);
|
|
577
|
+
f.HEAPU32 = F = new Uint32Array(a);
|
|
578
|
+
f.HEAPF32 = Oa = new Float32Array(a);
|
|
579
|
+
f.HEAPF64 = Pa = new Float64Array(a);
|
|
580
|
+
f.HEAP64 = H = new BigInt64Array(a);
|
|
581
|
+
f.HEAPU64 = new BigUint64Array(a);
|
|
582
|
+
}
|
|
583
|
+
var K = 0, Sa = null;
|
|
584
|
+
function Ta(a) {
|
|
585
|
+
f.onAbort?.(a);
|
|
586
|
+
a = "Aborted(" + a + ")";
|
|
587
|
+
Ia(a);
|
|
588
|
+
La = true;
|
|
589
|
+
throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
|
|
590
|
+
}
|
|
591
|
+
var Ua;
|
|
592
|
+
async function Va(a) {
|
|
593
|
+
if (!Ja) try {
|
|
594
|
+
var b = await Ea(a);
|
|
595
|
+
return new Uint8Array(b);
|
|
596
|
+
} catch {
|
|
597
|
+
}
|
|
598
|
+
if (a == Ua && Ja) a = new Uint8Array(Ja);
|
|
599
|
+
else if (Fa) a = Fa(a);
|
|
600
|
+
else throw "both async and sync fetching of the wasm failed";
|
|
601
|
+
return a;
|
|
602
|
+
}
|
|
603
|
+
async function Wa(a, b) {
|
|
604
|
+
try {
|
|
605
|
+
var c = await Va(a);
|
|
606
|
+
return await WebAssembly.instantiate(c, b);
|
|
607
|
+
} catch (d) {
|
|
608
|
+
Ia(`failed to asynchronously prepare wasm: ${d}`), Ta(d);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
async function Xa(a) {
|
|
612
|
+
var b = Ua;
|
|
613
|
+
if (!Ja && "function" == typeof WebAssembly.instantiateStreaming && !Ga(b) && !ca) try {
|
|
614
|
+
var c = fetch(b, { credentials: "same-origin" });
|
|
615
|
+
return await WebAssembly.instantiateStreaming(c, a);
|
|
616
|
+
} catch (d) {
|
|
617
|
+
Ia(`wasm streaming compile failed: ${d}`), Ia("falling back to ArrayBuffer instantiation");
|
|
618
|
+
}
|
|
619
|
+
return Wa(b, a);
|
|
620
|
+
}
|
|
621
|
+
class Ya {
|
|
622
|
+
name = "ExitStatus";
|
|
623
|
+
constructor(a) {
|
|
624
|
+
this.message = `Program terminated with exit(${a})`;
|
|
625
|
+
this.status = a;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
var Za = (a) => {
|
|
629
|
+
for (; 0 < a.length; ) a.shift()(f);
|
|
630
|
+
}, $a = [], ab = [], bb = () => {
|
|
631
|
+
var a = f.preRun.shift();
|
|
632
|
+
ab.unshift(a);
|
|
633
|
+
};
|
|
634
|
+
function m(a, b = "i8") {
|
|
635
|
+
b.endsWith("*") && (b = "*");
|
|
636
|
+
switch (b) {
|
|
637
|
+
case "i1":
|
|
638
|
+
return p[a];
|
|
639
|
+
case "i8":
|
|
640
|
+
return p[a];
|
|
641
|
+
case "i16":
|
|
642
|
+
return Na[a >> 1];
|
|
643
|
+
case "i32":
|
|
644
|
+
return E[a >> 2];
|
|
645
|
+
case "i64":
|
|
646
|
+
return H[a >> 3];
|
|
647
|
+
case "float":
|
|
648
|
+
return Oa[a >> 2];
|
|
649
|
+
case "double":
|
|
650
|
+
return Pa[a >> 3];
|
|
651
|
+
case "*":
|
|
652
|
+
return F[a >> 2];
|
|
653
|
+
default:
|
|
654
|
+
Ta(`invalid type for getValue: ${b}`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
var cb = f.noExitRuntime || true;
|
|
658
|
+
function ta(a) {
|
|
659
|
+
var b = "i32";
|
|
660
|
+
b.endsWith("*") && (b = "*");
|
|
661
|
+
switch (b) {
|
|
662
|
+
case "i1":
|
|
663
|
+
p[a] = 0;
|
|
664
|
+
break;
|
|
665
|
+
case "i8":
|
|
666
|
+
p[a] = 0;
|
|
667
|
+
break;
|
|
668
|
+
case "i16":
|
|
669
|
+
Na[a >> 1] = 0;
|
|
670
|
+
break;
|
|
671
|
+
case "i32":
|
|
672
|
+
E[a >> 2] = 0;
|
|
673
|
+
break;
|
|
674
|
+
case "i64":
|
|
675
|
+
H[a >> 3] = BigInt(0);
|
|
676
|
+
break;
|
|
677
|
+
case "float":
|
|
678
|
+
Oa[a >> 2] = 0;
|
|
679
|
+
break;
|
|
680
|
+
case "double":
|
|
681
|
+
Pa[a >> 3] = 0;
|
|
682
|
+
break;
|
|
683
|
+
case "*":
|
|
684
|
+
F[a >> 2] = 0;
|
|
685
|
+
break;
|
|
686
|
+
default:
|
|
687
|
+
Ta(`invalid type for setValue: ${b}`);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
var db = "undefined" != typeof TextDecoder ? new TextDecoder() : void 0, B = (a, b = 0, c = NaN) => {
|
|
691
|
+
var d = b + c;
|
|
692
|
+
for (c = b; a[c] && !(c >= d); ) ++c;
|
|
693
|
+
if (16 < c - b && a.buffer && db) return db.decode(a.subarray(b, c));
|
|
694
|
+
for (d = ""; b < c; ) {
|
|
695
|
+
var e = a[b++];
|
|
696
|
+
if (e & 128) {
|
|
697
|
+
var h = a[b++] & 63;
|
|
698
|
+
if (192 == (e & 224)) d += String.fromCharCode((e & 31) << 6 | h);
|
|
699
|
+
else {
|
|
700
|
+
var k = a[b++] & 63;
|
|
701
|
+
e = 224 == (e & 240) ? (e & 15) << 12 | h << 6 | k : (e & 7) << 18 | h << 12 | k << 6 | a[b++] & 63;
|
|
702
|
+
65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
|
|
703
|
+
}
|
|
704
|
+
} else d += String.fromCharCode(e);
|
|
705
|
+
}
|
|
706
|
+
return d;
|
|
707
|
+
}, ua = (a, b) => a ? B(x, a, b) : "", eb = (a, b) => {
|
|
708
|
+
for (var c = 0, d = a.length - 1; 0 <= d; d--) {
|
|
709
|
+
var e = a[d];
|
|
710
|
+
"." === e ? a.splice(d, 1) : ".." === e ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
|
|
711
|
+
}
|
|
712
|
+
if (b) for (; c; c--) a.unshift("..");
|
|
713
|
+
return a;
|
|
714
|
+
}, ka = (a) => {
|
|
715
|
+
var b = "/" === a.charAt(0), c = "/" === a.slice(-1);
|
|
716
|
+
(a = eb(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
|
|
717
|
+
a && c && (a += "/");
|
|
718
|
+
return (b ? "/" : "") + a;
|
|
719
|
+
}, fb = (a) => {
|
|
720
|
+
var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
|
|
721
|
+
a = b[0];
|
|
722
|
+
b = b[1];
|
|
723
|
+
if (!a && !b) return ".";
|
|
724
|
+
b &&= b.slice(0, -1);
|
|
725
|
+
return a + b;
|
|
726
|
+
}, gb = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], hb = () => {
|
|
727
|
+
if (ca) {
|
|
728
|
+
var a = require("crypto");
|
|
729
|
+
return (b) => a.randomFillSync(b);
|
|
730
|
+
}
|
|
731
|
+
return (b) => crypto.getRandomValues(b);
|
|
732
|
+
}, ib = (a) => {
|
|
733
|
+
(ib = hb())(a);
|
|
734
|
+
}, jb = (...a) => {
|
|
735
|
+
for (var b = "", c = false, d = a.length - 1; -1 <= d && !c; d--) {
|
|
736
|
+
c = 0 <= d ? a[d] : "/";
|
|
737
|
+
if ("string" != typeof c) throw new TypeError("Arguments to path.resolve must be strings");
|
|
738
|
+
if (!c) return "";
|
|
739
|
+
b = c + "/" + b;
|
|
740
|
+
c = "/" === c.charAt(0);
|
|
741
|
+
}
|
|
742
|
+
b = eb(b.split("/").filter((e) => !!e), !c).join("/");
|
|
743
|
+
return (c ? "/" : "") + b || ".";
|
|
744
|
+
}, kb = [], ha = (a) => {
|
|
745
|
+
for (var b = 0, c = 0; c < a.length; ++c) {
|
|
746
|
+
var d = a.charCodeAt(c);
|
|
747
|
+
127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
|
|
748
|
+
}
|
|
749
|
+
return b;
|
|
750
|
+
}, u = (a, b, c, d) => {
|
|
751
|
+
if (!(0 < d)) return 0;
|
|
752
|
+
var e = c;
|
|
753
|
+
d = c + d - 1;
|
|
754
|
+
for (var h = 0; h < a.length; ++h) {
|
|
755
|
+
var k = a.charCodeAt(h);
|
|
756
|
+
if (55296 <= k && 57343 >= k) {
|
|
757
|
+
var q = a.charCodeAt(++h);
|
|
758
|
+
k = 65536 + ((k & 1023) << 10) | q & 1023;
|
|
759
|
+
}
|
|
760
|
+
if (127 >= k) {
|
|
761
|
+
if (c >= d) break;
|
|
762
|
+
b[c++] = k;
|
|
763
|
+
} else {
|
|
764
|
+
if (2047 >= k) {
|
|
765
|
+
if (c + 1 >= d) break;
|
|
766
|
+
b[c++] = 192 | k >> 6;
|
|
767
|
+
} else {
|
|
768
|
+
if (65535 >= k) {
|
|
769
|
+
if (c + 2 >= d) break;
|
|
770
|
+
b[c++] = 224 | k >> 12;
|
|
771
|
+
} else {
|
|
772
|
+
if (c + 3 >= d) break;
|
|
773
|
+
b[c++] = 240 | k >> 18;
|
|
774
|
+
b[c++] = 128 | k >> 12 & 63;
|
|
775
|
+
}
|
|
776
|
+
b[c++] = 128 | k >> 6 & 63;
|
|
777
|
+
}
|
|
778
|
+
b[c++] = 128 | k & 63;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
b[c] = 0;
|
|
782
|
+
return c - e;
|
|
783
|
+
}, ra = (a, b) => {
|
|
784
|
+
var c = Array(ha(a) + 1);
|
|
785
|
+
a = u(a, c, 0, c.length);
|
|
786
|
+
b && (c.length = a);
|
|
787
|
+
return c;
|
|
788
|
+
}, mb = [];
|
|
789
|
+
function nb(a, b) {
|
|
790
|
+
mb[a] = { input: [], output: [], cb: b };
|
|
791
|
+
wb(a, xb);
|
|
792
|
+
}
|
|
793
|
+
var xb = { open(a) {
|
|
794
|
+
var b = mb[a.node.rdev];
|
|
795
|
+
if (!b) throw new N(43);
|
|
796
|
+
a.tty = b;
|
|
797
|
+
a.seekable = false;
|
|
798
|
+
}, close(a) {
|
|
799
|
+
a.tty.cb.fsync(a.tty);
|
|
800
|
+
}, fsync(a) {
|
|
801
|
+
a.tty.cb.fsync(a.tty);
|
|
802
|
+
}, read(a, b, c, d) {
|
|
803
|
+
if (!a.tty || !a.tty.cb.xb) throw new N(60);
|
|
804
|
+
for (var e = 0, h = 0; h < d; h++) {
|
|
805
|
+
try {
|
|
806
|
+
var k = a.tty.cb.xb(a.tty);
|
|
807
|
+
} catch (q) {
|
|
808
|
+
throw new N(29);
|
|
809
|
+
}
|
|
810
|
+
if (void 0 === k && 0 === e) throw new N(6);
|
|
811
|
+
if (null === k || void 0 === k) break;
|
|
812
|
+
e++;
|
|
813
|
+
b[c + h] = k;
|
|
814
|
+
}
|
|
815
|
+
e && (a.node.atime = Date.now());
|
|
816
|
+
return e;
|
|
817
|
+
}, write(a, b, c, d) {
|
|
818
|
+
if (!a.tty || !a.tty.cb.qb) throw new N(60);
|
|
819
|
+
try {
|
|
820
|
+
for (var e = 0; e < d; e++) a.tty.cb.qb(a.tty, b[c + e]);
|
|
821
|
+
} catch (h) {
|
|
822
|
+
throw new N(29);
|
|
823
|
+
}
|
|
824
|
+
d && (a.node.mtime = a.node.ctime = Date.now());
|
|
825
|
+
return e;
|
|
826
|
+
} }, yb = { xb() {
|
|
827
|
+
a: {
|
|
828
|
+
if (!kb.length) {
|
|
829
|
+
var a = null;
|
|
830
|
+
if (ca) {
|
|
831
|
+
var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
|
|
832
|
+
try {
|
|
833
|
+
c = fs18.readSync(d, b, 0, 256);
|
|
834
|
+
} catch (e) {
|
|
835
|
+
if (e.toString().includes("EOF")) c = 0;
|
|
836
|
+
else throw e;
|
|
837
|
+
}
|
|
838
|
+
0 < c && (a = b.slice(0, c).toString("utf-8"));
|
|
839
|
+
} else "undefined" != typeof window && "function" == typeof window.prompt && (a = window.prompt("Input: "), null !== a && (a += "\n"));
|
|
840
|
+
if (!a) {
|
|
841
|
+
a = null;
|
|
842
|
+
break a;
|
|
843
|
+
}
|
|
844
|
+
kb = ra(a, true);
|
|
845
|
+
}
|
|
846
|
+
a = kb.shift();
|
|
847
|
+
}
|
|
848
|
+
return a;
|
|
849
|
+
}, qb(a, b) {
|
|
850
|
+
null === b || 10 === b ? (Ha(B(a.output)), a.output = []) : 0 != b && a.output.push(b);
|
|
851
|
+
}, fsync(a) {
|
|
852
|
+
0 < a.output?.length && (Ha(B(a.output)), a.output = []);
|
|
853
|
+
}, Tb() {
|
|
854
|
+
return { Ob: 25856, Qb: 5, Nb: 191, Pb: 35387, Mb: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
|
|
855
|
+
}, Ub() {
|
|
856
|
+
return 0;
|
|
857
|
+
}, Vb() {
|
|
858
|
+
return [24, 80];
|
|
859
|
+
} }, zb = { qb(a, b) {
|
|
860
|
+
null === b || 10 === b ? (Ia(B(a.output)), a.output = []) : 0 != b && a.output.push(b);
|
|
861
|
+
}, fsync(a) {
|
|
862
|
+
0 < a.output?.length && (Ia(B(a.output)), a.output = []);
|
|
863
|
+
} }, O = { Wa: null, Xa() {
|
|
864
|
+
return O.createNode(null, "/", 16895, 0);
|
|
865
|
+
}, createNode(a, b, c, d) {
|
|
866
|
+
if (24576 === (c & 61440) || 4096 === (c & 61440)) throw new N(63);
|
|
867
|
+
O.Wa || (O.Wa = { dir: { node: { Ta: O.La.Ta, Ua: O.La.Ua, lookup: O.La.lookup, hb: O.La.hb, rename: O.La.rename, unlink: O.La.unlink, rmdir: O.La.rmdir, readdir: O.La.readdir, symlink: O.La.symlink }, stream: { Va: O.Ma.Va } }, file: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: { Va: O.Ma.Va, read: O.Ma.read, write: O.Ma.write, ib: O.Ma.ib, jb: O.Ma.jb } }, link: { node: { Ta: O.La.Ta, Ua: O.La.Ua, readlink: O.La.readlink }, stream: {} }, ub: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: Ab } });
|
|
868
|
+
c = Bb(a, b, c, d);
|
|
869
|
+
P(c.mode) ? (c.La = O.Wa.dir.node, c.Ma = O.Wa.dir.stream, c.Na = {}) : 32768 === (c.mode & 61440) ? (c.La = O.Wa.file.node, c.Ma = O.Wa.file.stream, c.Ra = 0, c.Na = null) : 40960 === (c.mode & 61440) ? (c.La = O.Wa.link.node, c.Ma = O.Wa.link.stream) : 8192 === (c.mode & 61440) && (c.La = O.Wa.ub.node, c.Ma = O.Wa.ub.stream);
|
|
870
|
+
c.atime = c.mtime = c.ctime = Date.now();
|
|
871
|
+
a && (a.Na[b] = c, a.atime = a.mtime = a.ctime = c.atime);
|
|
872
|
+
return c;
|
|
873
|
+
}, Sb(a) {
|
|
874
|
+
return a.Na ? a.Na.subarray ? a.Na.subarray(0, a.Ra) : new Uint8Array(a.Na) : new Uint8Array(0);
|
|
875
|
+
}, La: { Ta(a) {
|
|
876
|
+
var b = {};
|
|
877
|
+
b.dev = 8192 === (a.mode & 61440) ? a.id : 1;
|
|
878
|
+
b.ino = a.id;
|
|
879
|
+
b.mode = a.mode;
|
|
880
|
+
b.nlink = 1;
|
|
881
|
+
b.uid = 0;
|
|
882
|
+
b.gid = 0;
|
|
883
|
+
b.rdev = a.rdev;
|
|
884
|
+
P(a.mode) ? b.size = 4096 : 32768 === (a.mode & 61440) ? b.size = a.Ra : 40960 === (a.mode & 61440) ? b.size = a.link.length : b.size = 0;
|
|
885
|
+
b.atime = new Date(a.atime);
|
|
886
|
+
b.mtime = new Date(a.mtime);
|
|
887
|
+
b.ctime = new Date(a.ctime);
|
|
888
|
+
b.blksize = 4096;
|
|
889
|
+
b.blocks = Math.ceil(b.size / b.blksize);
|
|
890
|
+
return b;
|
|
891
|
+
}, Ua(a, b) {
|
|
892
|
+
for (var c of ["mode", "atime", "mtime", "ctime"]) null != b[c] && (a[c] = b[c]);
|
|
893
|
+
void 0 !== b.size && (b = b.size, a.Ra != b && (0 == b ? (a.Na = null, a.Ra = 0) : (c = a.Na, a.Na = new Uint8Array(b), c && a.Na.set(c.subarray(0, Math.min(b, a.Ra))), a.Ra = b)));
|
|
894
|
+
}, lookup() {
|
|
895
|
+
throw O.vb;
|
|
896
|
+
}, hb(a, b, c, d) {
|
|
897
|
+
return O.createNode(a, b, c, d);
|
|
898
|
+
}, rename(a, b, c) {
|
|
899
|
+
try {
|
|
900
|
+
var d = Q(b, c);
|
|
901
|
+
} catch (h) {
|
|
902
|
+
}
|
|
903
|
+
if (d) {
|
|
904
|
+
if (P(a.mode)) for (var e in d.Na) throw new N(55);
|
|
905
|
+
Cb(d);
|
|
906
|
+
}
|
|
907
|
+
delete a.parent.Na[a.name];
|
|
908
|
+
b.Na[c] = a;
|
|
909
|
+
a.name = c;
|
|
910
|
+
b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
|
|
911
|
+
}, unlink(a, b) {
|
|
912
|
+
delete a.Na[b];
|
|
913
|
+
a.ctime = a.mtime = Date.now();
|
|
914
|
+
}, rmdir(a, b) {
|
|
915
|
+
var c = Q(a, b), d;
|
|
916
|
+
for (d in c.Na) throw new N(55);
|
|
917
|
+
delete a.Na[b];
|
|
918
|
+
a.ctime = a.mtime = Date.now();
|
|
919
|
+
}, readdir(a) {
|
|
920
|
+
return [".", "..", ...Object.keys(a.Na)];
|
|
921
|
+
}, symlink(a, b, c) {
|
|
922
|
+
a = O.createNode(a, b, 41471, 0);
|
|
923
|
+
a.link = c;
|
|
924
|
+
return a;
|
|
925
|
+
}, readlink(a) {
|
|
926
|
+
if (40960 !== (a.mode & 61440)) throw new N(28);
|
|
927
|
+
return a.link;
|
|
928
|
+
} }, Ma: { read(a, b, c, d, e) {
|
|
929
|
+
var h = a.node.Na;
|
|
930
|
+
if (e >= a.node.Ra) return 0;
|
|
931
|
+
a = Math.min(a.node.Ra - e, d);
|
|
932
|
+
if (8 < a && h.subarray) b.set(h.subarray(e, e + a), c);
|
|
933
|
+
else for (d = 0; d < a; d++) b[c + d] = h[e + d];
|
|
934
|
+
return a;
|
|
935
|
+
}, write(a, b, c, d, e, h) {
|
|
936
|
+
b.buffer === p.buffer && (h = false);
|
|
937
|
+
if (!d) return 0;
|
|
938
|
+
a = a.node;
|
|
939
|
+
a.mtime = a.ctime = Date.now();
|
|
940
|
+
if (b.subarray && (!a.Na || a.Na.subarray)) {
|
|
941
|
+
if (h) return a.Na = b.subarray(c, c + d), a.Ra = d;
|
|
942
|
+
if (0 === a.Ra && 0 === e) return a.Na = b.slice(c, c + d), a.Ra = d;
|
|
943
|
+
if (e + d <= a.Ra) return a.Na.set(b.subarray(
|
|
944
|
+
c,
|
|
945
|
+
c + d
|
|
946
|
+
), e), d;
|
|
947
|
+
}
|
|
948
|
+
h = e + d;
|
|
949
|
+
var k = a.Na ? a.Na.length : 0;
|
|
950
|
+
k >= h || (h = Math.max(h, k * (1048576 > k ? 2 : 1.125) >>> 0), 0 != k && (h = Math.max(h, 256)), k = a.Na, a.Na = new Uint8Array(h), 0 < a.Ra && a.Na.set(k.subarray(0, a.Ra), 0));
|
|
951
|
+
if (a.Na.subarray && b.subarray) a.Na.set(b.subarray(c, c + d), e);
|
|
952
|
+
else for (h = 0; h < d; h++) a.Na[e + h] = b[c + h];
|
|
953
|
+
a.Ra = Math.max(a.Ra, e + d);
|
|
954
|
+
return d;
|
|
955
|
+
}, Va(a, b, c) {
|
|
956
|
+
1 === c ? b += a.position : 2 === c && 32768 === (a.node.mode & 61440) && (b += a.node.Ra);
|
|
957
|
+
if (0 > b) throw new N(28);
|
|
958
|
+
return b;
|
|
959
|
+
}, ib(a, b, c, d, e) {
|
|
960
|
+
if (32768 !== (a.node.mode & 61440)) throw new N(43);
|
|
961
|
+
a = a.node.Na;
|
|
962
|
+
if (e & 2 || !a || a.buffer !== p.buffer) {
|
|
963
|
+
e = true;
|
|
964
|
+
d = 65536 * Math.ceil(b / 65536);
|
|
965
|
+
var h = Db(65536, d);
|
|
966
|
+
h && x.fill(0, h, h + d);
|
|
967
|
+
d = h;
|
|
968
|
+
if (!d) throw new N(48);
|
|
969
|
+
if (a) {
|
|
970
|
+
if (0 < c || c + b < a.length) a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
|
|
971
|
+
p.set(a, d);
|
|
972
|
+
}
|
|
973
|
+
} else e = false, d = a.byteOffset;
|
|
974
|
+
return { Kb: d, Ab: e };
|
|
975
|
+
}, jb(a, b, c, d) {
|
|
976
|
+
O.Ma.write(a, b, 0, d, c, false);
|
|
977
|
+
return 0;
|
|
978
|
+
} } }, la = (a, b) => {
|
|
979
|
+
var c = 0;
|
|
980
|
+
a && (c |= 365);
|
|
981
|
+
b && (c |= 146);
|
|
982
|
+
return c;
|
|
983
|
+
}, Eb = null, Fb = {}, Gb = [], Hb = 1, R = null, Ib = false, Jb = true, Kb = {}, N = class {
|
|
984
|
+
name = "ErrnoError";
|
|
985
|
+
constructor(a) {
|
|
986
|
+
this.Pa = a;
|
|
987
|
+
}
|
|
988
|
+
}, Lb = class {
|
|
989
|
+
gb = {};
|
|
990
|
+
node = null;
|
|
991
|
+
get flags() {
|
|
992
|
+
return this.gb.flags;
|
|
993
|
+
}
|
|
994
|
+
set flags(a) {
|
|
995
|
+
this.gb.flags = a;
|
|
996
|
+
}
|
|
997
|
+
get position() {
|
|
998
|
+
return this.gb.position;
|
|
999
|
+
}
|
|
1000
|
+
set position(a) {
|
|
1001
|
+
this.gb.position = a;
|
|
1002
|
+
}
|
|
1003
|
+
}, Mb = class {
|
|
1004
|
+
La = {};
|
|
1005
|
+
Ma = {};
|
|
1006
|
+
ab = null;
|
|
1007
|
+
constructor(a, b, c, d) {
|
|
1008
|
+
a ||= this;
|
|
1009
|
+
this.parent = a;
|
|
1010
|
+
this.Xa = a.Xa;
|
|
1011
|
+
this.id = Hb++;
|
|
1012
|
+
this.name = b;
|
|
1013
|
+
this.mode = c;
|
|
1014
|
+
this.rdev = d;
|
|
1015
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
1016
|
+
}
|
|
1017
|
+
get read() {
|
|
1018
|
+
return 365 === (this.mode & 365);
|
|
1019
|
+
}
|
|
1020
|
+
set read(a) {
|
|
1021
|
+
a ? this.mode |= 365 : this.mode &= -366;
|
|
1022
|
+
}
|
|
1023
|
+
get write() {
|
|
1024
|
+
return 146 === (this.mode & 146);
|
|
1025
|
+
}
|
|
1026
|
+
set write(a) {
|
|
1027
|
+
a ? this.mode |= 146 : this.mode &= -147;
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
function S(a, b = {}) {
|
|
1031
|
+
if (!a) throw new N(44);
|
|
1032
|
+
b.nb ?? (b.nb = true);
|
|
1033
|
+
"/" === a.charAt(0) || (a = "//" + a);
|
|
1034
|
+
var c = 0;
|
|
1035
|
+
a: for (; 40 > c; c++) {
|
|
1036
|
+
a = a.split("/").filter((q) => !!q);
|
|
1037
|
+
for (var d = Eb, e = "/", h = 0; h < a.length; h++) {
|
|
1038
|
+
var k = h === a.length - 1;
|
|
1039
|
+
if (k && b.parent) break;
|
|
1040
|
+
if ("." !== a[h]) if (".." === a[h]) e = fb(e), d = d.parent;
|
|
1041
|
+
else {
|
|
1042
|
+
e = ka(e + "/" + a[h]);
|
|
1043
|
+
try {
|
|
1044
|
+
d = Q(d, a[h]);
|
|
1045
|
+
} catch (q) {
|
|
1046
|
+
if (44 === q?.Pa && k && b.Jb) return { path: e };
|
|
1047
|
+
throw q;
|
|
1048
|
+
}
|
|
1049
|
+
!d.ab || k && !b.nb || (d = d.ab.root);
|
|
1050
|
+
if (40960 === (d.mode & 61440) && (!k || b.$a)) {
|
|
1051
|
+
if (!d.La.readlink) throw new N(52);
|
|
1052
|
+
d = d.La.readlink(d);
|
|
1053
|
+
"/" === d.charAt(0) || (d = fb(e) + "/" + d);
|
|
1054
|
+
a = d + "/" + a.slice(h + 1).join("/");
|
|
1055
|
+
continue a;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return { path: e, node: d };
|
|
1060
|
+
}
|
|
1061
|
+
throw new N(32);
|
|
1062
|
+
}
|
|
1063
|
+
function ja(a) {
|
|
1064
|
+
for (var b; ; ) {
|
|
1065
|
+
if (a === a.parent) return a = a.Xa.zb, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
|
|
1066
|
+
b = b ? `${a.name}/${b}` : a.name;
|
|
1067
|
+
a = a.parent;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function Nb(a, b) {
|
|
1071
|
+
for (var c = 0, d = 0; d < b.length; d++) c = (c << 5) - c + b.charCodeAt(d) | 0;
|
|
1072
|
+
return (a + c >>> 0) % R.length;
|
|
1073
|
+
}
|
|
1074
|
+
function Cb(a) {
|
|
1075
|
+
var b = Nb(a.parent.id, a.name);
|
|
1076
|
+
if (R[b] === a) R[b] = a.bb;
|
|
1077
|
+
else for (b = R[b]; b; ) {
|
|
1078
|
+
if (b.bb === a) {
|
|
1079
|
+
b.bb = a.bb;
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
b = b.bb;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function Q(a, b) {
|
|
1086
|
+
var c = P(a.mode) ? (c = Ob(a, "x")) ? c : a.La.lookup ? 0 : 2 : 54;
|
|
1087
|
+
if (c) throw new N(c);
|
|
1088
|
+
for (c = R[Nb(a.id, b)]; c; c = c.bb) {
|
|
1089
|
+
var d = c.name;
|
|
1090
|
+
if (c.parent.id === a.id && d === b) return c;
|
|
1091
|
+
}
|
|
1092
|
+
return a.La.lookup(a, b);
|
|
1093
|
+
}
|
|
1094
|
+
function Bb(a, b, c, d) {
|
|
1095
|
+
a = new Mb(a, b, c, d);
|
|
1096
|
+
b = Nb(a.parent.id, a.name);
|
|
1097
|
+
a.bb = R[b];
|
|
1098
|
+
return R[b] = a;
|
|
1099
|
+
}
|
|
1100
|
+
function P(a) {
|
|
1101
|
+
return 16384 === (a & 61440);
|
|
1102
|
+
}
|
|
1103
|
+
function Pb(a) {
|
|
1104
|
+
var b = ["r", "w", "rw"][a & 3];
|
|
1105
|
+
a & 512 && (b += "w");
|
|
1106
|
+
return b;
|
|
1107
|
+
}
|
|
1108
|
+
function Ob(a, b) {
|
|
1109
|
+
if (Jb) return 0;
|
|
1110
|
+
if (!b.includes("r") || a.mode & 292) {
|
|
1111
|
+
if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73)) return 2;
|
|
1112
|
+
} else return 2;
|
|
1113
|
+
return 0;
|
|
1114
|
+
}
|
|
1115
|
+
function Qb(a, b) {
|
|
1116
|
+
if (!P(a.mode)) return 54;
|
|
1117
|
+
try {
|
|
1118
|
+
return Q(a, b), 20;
|
|
1119
|
+
} catch (c) {
|
|
1120
|
+
}
|
|
1121
|
+
return Ob(a, "wx");
|
|
1122
|
+
}
|
|
1123
|
+
function Rb(a, b, c) {
|
|
1124
|
+
try {
|
|
1125
|
+
var d = Q(a, b);
|
|
1126
|
+
} catch (e) {
|
|
1127
|
+
return e.Pa;
|
|
1128
|
+
}
|
|
1129
|
+
if (a = Ob(a, "wx")) return a;
|
|
1130
|
+
if (c) {
|
|
1131
|
+
if (!P(d.mode)) return 54;
|
|
1132
|
+
if (d === d.parent || "/" === ja(d)) return 10;
|
|
1133
|
+
} else if (P(d.mode)) return 31;
|
|
1134
|
+
return 0;
|
|
1135
|
+
}
|
|
1136
|
+
function Sb(a) {
|
|
1137
|
+
if (!a) throw new N(63);
|
|
1138
|
+
return a;
|
|
1139
|
+
}
|
|
1140
|
+
function T(a) {
|
|
1141
|
+
a = Gb[a];
|
|
1142
|
+
if (!a) throw new N(8);
|
|
1143
|
+
return a;
|
|
1144
|
+
}
|
|
1145
|
+
function Tb(a, b = -1) {
|
|
1146
|
+
a = Object.assign(new Lb(), a);
|
|
1147
|
+
if (-1 == b) a: {
|
|
1148
|
+
for (b = 0; 4096 >= b; b++) if (!Gb[b]) break a;
|
|
1149
|
+
throw new N(33);
|
|
1150
|
+
}
|
|
1151
|
+
a.fd = b;
|
|
1152
|
+
return Gb[b] = a;
|
|
1153
|
+
}
|
|
1154
|
+
function Ub(a, b = -1) {
|
|
1155
|
+
a = Tb(a, b);
|
|
1156
|
+
a.Ma?.Rb?.(a);
|
|
1157
|
+
return a;
|
|
1158
|
+
}
|
|
1159
|
+
function Vb(a, b, c) {
|
|
1160
|
+
var d = a?.Ma.Ua;
|
|
1161
|
+
a = d ? a : b;
|
|
1162
|
+
d ??= b.La.Ua;
|
|
1163
|
+
Sb(d);
|
|
1164
|
+
d(a, c);
|
|
1165
|
+
}
|
|
1166
|
+
var Ab = { open(a) {
|
|
1167
|
+
a.Ma = Fb[a.node.rdev].Ma;
|
|
1168
|
+
a.Ma.open?.(a);
|
|
1169
|
+
}, Va() {
|
|
1170
|
+
throw new N(70);
|
|
1171
|
+
} };
|
|
1172
|
+
function wb(a, b) {
|
|
1173
|
+
Fb[a] = { Ma: b };
|
|
1174
|
+
}
|
|
1175
|
+
function Wb(a, b) {
|
|
1176
|
+
var c = "/" === b;
|
|
1177
|
+
if (c && Eb) throw new N(10);
|
|
1178
|
+
if (!c && b) {
|
|
1179
|
+
var d = S(b, { nb: false });
|
|
1180
|
+
b = d.path;
|
|
1181
|
+
d = d.node;
|
|
1182
|
+
if (d.ab) throw new N(10);
|
|
1183
|
+
if (!P(d.mode)) throw new N(54);
|
|
1184
|
+
}
|
|
1185
|
+
b = { type: a, Wb: {}, zb: b, Ib: [] };
|
|
1186
|
+
a = a.Xa(b);
|
|
1187
|
+
a.Xa = b;
|
|
1188
|
+
b.root = a;
|
|
1189
|
+
c ? Eb = a : d && (d.ab = b, d.Xa && d.Xa.Ib.push(b));
|
|
1190
|
+
}
|
|
1191
|
+
function Xb(a, b, c) {
|
|
1192
|
+
var d = S(a, { parent: true }).node;
|
|
1193
|
+
a = gb(a);
|
|
1194
|
+
if (!a) throw new N(28);
|
|
1195
|
+
if ("." === a || ".." === a) throw new N(20);
|
|
1196
|
+
var e = Qb(d, a);
|
|
1197
|
+
if (e) throw new N(e);
|
|
1198
|
+
if (!d.La.hb) throw new N(63);
|
|
1199
|
+
return d.La.hb(d, a, b, c);
|
|
1200
|
+
}
|
|
1201
|
+
function ma(a, b = 438) {
|
|
1202
|
+
return Xb(a, b & 4095 | 32768, 0);
|
|
1203
|
+
}
|
|
1204
|
+
function U(a, b = 511) {
|
|
1205
|
+
return Xb(a, b & 1023 | 16384, 0);
|
|
1206
|
+
}
|
|
1207
|
+
function Yb(a, b, c) {
|
|
1208
|
+
"undefined" == typeof c && (c = b, b = 438);
|
|
1209
|
+
Xb(a, b | 8192, c);
|
|
1210
|
+
}
|
|
1211
|
+
function Zb(a, b) {
|
|
1212
|
+
if (!jb(a)) throw new N(44);
|
|
1213
|
+
var c = S(b, { parent: true }).node;
|
|
1214
|
+
if (!c) throw new N(44);
|
|
1215
|
+
b = gb(b);
|
|
1216
|
+
var d = Qb(c, b);
|
|
1217
|
+
if (d) throw new N(d);
|
|
1218
|
+
if (!c.La.symlink) throw new N(63);
|
|
1219
|
+
c.La.symlink(c, b, a);
|
|
1220
|
+
}
|
|
1221
|
+
function $b(a) {
|
|
1222
|
+
var b = S(a, { parent: true }).node;
|
|
1223
|
+
a = gb(a);
|
|
1224
|
+
var c = Q(b, a), d = Rb(b, a, true);
|
|
1225
|
+
if (d) throw new N(d);
|
|
1226
|
+
if (!b.La.rmdir) throw new N(63);
|
|
1227
|
+
if (c.ab) throw new N(10);
|
|
1228
|
+
b.La.rmdir(b, a);
|
|
1229
|
+
Cb(c);
|
|
1230
|
+
}
|
|
1231
|
+
function za(a) {
|
|
1232
|
+
var b = S(a, { parent: true }).node;
|
|
1233
|
+
if (!b) throw new N(44);
|
|
1234
|
+
a = gb(a);
|
|
1235
|
+
var c = Q(b, a), d = Rb(b, a, false);
|
|
1236
|
+
if (d) throw new N(d);
|
|
1237
|
+
if (!b.La.unlink) throw new N(63);
|
|
1238
|
+
if (c.ab) throw new N(10);
|
|
1239
|
+
b.La.unlink(b, a);
|
|
1240
|
+
Cb(c);
|
|
1241
|
+
}
|
|
1242
|
+
function ac(a, b) {
|
|
1243
|
+
a = S(a, { $a: !b }).node;
|
|
1244
|
+
return Sb(a.La.Ta)(a);
|
|
1245
|
+
}
|
|
1246
|
+
function bc(a, b, c, d) {
|
|
1247
|
+
Vb(a, b, { mode: c & 4095 | b.mode & -4096, ctime: Date.now(), Fb: d });
|
|
1248
|
+
}
|
|
1249
|
+
function na(a, b) {
|
|
1250
|
+
a = "string" == typeof a ? S(a, { $a: true }).node : a;
|
|
1251
|
+
bc(null, a, b);
|
|
1252
|
+
}
|
|
1253
|
+
function cc(a, b, c) {
|
|
1254
|
+
if (P(b.mode)) throw new N(31);
|
|
1255
|
+
if (32768 !== (b.mode & 61440)) throw new N(28);
|
|
1256
|
+
var d = Ob(b, "w");
|
|
1257
|
+
if (d) throw new N(d);
|
|
1258
|
+
Vb(a, b, { size: c, timestamp: Date.now() });
|
|
1259
|
+
}
|
|
1260
|
+
function oa(a, b, c = 438) {
|
|
1261
|
+
if ("" === a) throw new N(44);
|
|
1262
|
+
if ("string" == typeof b) {
|
|
1263
|
+
var d = { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }[b];
|
|
1264
|
+
if ("undefined" == typeof d) throw Error(`Unknown file open mode: ${b}`);
|
|
1265
|
+
b = d;
|
|
1266
|
+
}
|
|
1267
|
+
c = b & 64 ? c & 4095 | 32768 : 0;
|
|
1268
|
+
if ("object" == typeof a) d = a;
|
|
1269
|
+
else {
|
|
1270
|
+
var e = a.endsWith("/");
|
|
1271
|
+
a = S(a, { $a: !(b & 131072), Jb: true });
|
|
1272
|
+
d = a.node;
|
|
1273
|
+
a = a.path;
|
|
1274
|
+
}
|
|
1275
|
+
var h = false;
|
|
1276
|
+
if (b & 64) if (d) {
|
|
1277
|
+
if (b & 128) throw new N(20);
|
|
1278
|
+
} else {
|
|
1279
|
+
if (e) throw new N(31);
|
|
1280
|
+
d = Xb(a, c | 511, 0);
|
|
1281
|
+
h = true;
|
|
1282
|
+
}
|
|
1283
|
+
if (!d) throw new N(44);
|
|
1284
|
+
8192 === (d.mode & 61440) && (b &= -513);
|
|
1285
|
+
if (b & 65536 && !P(d.mode)) throw new N(54);
|
|
1286
|
+
if (!h && (e = d ? 40960 === (d.mode & 61440) ? 32 : P(d.mode) && ("r" !== Pb(b) || b & 576) ? 31 : Ob(d, Pb(b)) : 44)) throw new N(e);
|
|
1287
|
+
b & 512 && !h && (e = d, e = "string" == typeof e ? S(e, { $a: true }).node : e, cc(null, e, 0));
|
|
1288
|
+
b &= -131713;
|
|
1289
|
+
e = Tb({ node: d, path: ja(d), flags: b, seekable: true, position: 0, Ma: d.Ma, Lb: [], error: false });
|
|
1290
|
+
e.Ma.open && e.Ma.open(e);
|
|
1291
|
+
h && na(d, c & 511);
|
|
1292
|
+
!f.logReadFiles || b & 1 || a in Kb || (Kb[a] = 1);
|
|
1293
|
+
return e;
|
|
1294
|
+
}
|
|
1295
|
+
function qa(a) {
|
|
1296
|
+
if (null === a.fd) throw new N(8);
|
|
1297
|
+
a.ob && (a.ob = null);
|
|
1298
|
+
try {
|
|
1299
|
+
a.Ma.close && a.Ma.close(a);
|
|
1300
|
+
} catch (b) {
|
|
1301
|
+
throw b;
|
|
1302
|
+
} finally {
|
|
1303
|
+
Gb[a.fd] = null;
|
|
1304
|
+
}
|
|
1305
|
+
a.fd = null;
|
|
1306
|
+
}
|
|
1307
|
+
function mc(a, b, c) {
|
|
1308
|
+
if (null === a.fd) throw new N(8);
|
|
1309
|
+
if (!a.seekable || !a.Ma.Va) throw new N(70);
|
|
1310
|
+
if (0 != c && 1 != c && 2 != c) throw new N(28);
|
|
1311
|
+
a.position = a.Ma.Va(a, b, c);
|
|
1312
|
+
a.Lb = [];
|
|
1313
|
+
}
|
|
1314
|
+
function Ec(a, b, c, d, e) {
|
|
1315
|
+
if (0 > d || 0 > e) throw new N(28);
|
|
1316
|
+
if (null === a.fd) throw new N(8);
|
|
1317
|
+
if (1 === (a.flags & 2097155)) throw new N(8);
|
|
1318
|
+
if (P(a.node.mode)) throw new N(31);
|
|
1319
|
+
if (!a.Ma.read) throw new N(28);
|
|
1320
|
+
var h = "undefined" != typeof e;
|
|
1321
|
+
if (!h) e = a.position;
|
|
1322
|
+
else if (!a.seekable) throw new N(70);
|
|
1323
|
+
b = a.Ma.read(a, b, c, d, e);
|
|
1324
|
+
h || (a.position += b);
|
|
1325
|
+
return b;
|
|
1326
|
+
}
|
|
1327
|
+
function pa(a, b, c, d, e) {
|
|
1328
|
+
if (0 > d || 0 > e) throw new N(28);
|
|
1329
|
+
if (null === a.fd) throw new N(8);
|
|
1330
|
+
if (0 === (a.flags & 2097155)) throw new N(8);
|
|
1331
|
+
if (P(a.node.mode)) throw new N(31);
|
|
1332
|
+
if (!a.Ma.write) throw new N(28);
|
|
1333
|
+
a.seekable && a.flags & 1024 && mc(a, 0, 2);
|
|
1334
|
+
var h = "undefined" != typeof e;
|
|
1335
|
+
if (!h) e = a.position;
|
|
1336
|
+
else if (!a.seekable) throw new N(70);
|
|
1337
|
+
b = a.Ma.write(a, b, c, d, e, void 0);
|
|
1338
|
+
h || (a.position += b);
|
|
1339
|
+
return b;
|
|
1340
|
+
}
|
|
1341
|
+
function ya(a) {
|
|
1342
|
+
var b = "binary";
|
|
1343
|
+
if ("utf8" !== b && "binary" !== b) throw Error(`Invalid encoding type "${b}"`);
|
|
1344
|
+
var c;
|
|
1345
|
+
var d = oa(a, d || 0);
|
|
1346
|
+
a = ac(a).size;
|
|
1347
|
+
var e = new Uint8Array(a);
|
|
1348
|
+
Ec(d, e, 0, a, 0);
|
|
1349
|
+
"utf8" === b ? c = B(e) : "binary" === b && (c = e);
|
|
1350
|
+
qa(d);
|
|
1351
|
+
return c;
|
|
1352
|
+
}
|
|
1353
|
+
function V(a, b, c) {
|
|
1354
|
+
a = ka("/dev/" + a);
|
|
1355
|
+
var d = la(!!b, !!c);
|
|
1356
|
+
V.yb ?? (V.yb = 64);
|
|
1357
|
+
var e = V.yb++ << 8 | 0;
|
|
1358
|
+
wb(e, { open(h) {
|
|
1359
|
+
h.seekable = false;
|
|
1360
|
+
}, close() {
|
|
1361
|
+
c?.buffer?.length && c(10);
|
|
1362
|
+
}, read(h, k, q, w) {
|
|
1363
|
+
for (var v = 0, C = 0; C < w; C++) {
|
|
1364
|
+
try {
|
|
1365
|
+
var G = b();
|
|
1366
|
+
} catch (pb) {
|
|
1367
|
+
throw new N(29);
|
|
1368
|
+
}
|
|
1369
|
+
if (void 0 === G && 0 === v) throw new N(6);
|
|
1370
|
+
if (null === G || void 0 === G) break;
|
|
1371
|
+
v++;
|
|
1372
|
+
k[q + C] = G;
|
|
1373
|
+
}
|
|
1374
|
+
v && (h.node.atime = Date.now());
|
|
1375
|
+
return v;
|
|
1376
|
+
}, write(h, k, q, w) {
|
|
1377
|
+
for (var v = 0; v < w; v++) try {
|
|
1378
|
+
c(k[q + v]);
|
|
1379
|
+
} catch (C) {
|
|
1380
|
+
throw new N(29);
|
|
1381
|
+
}
|
|
1382
|
+
w && (h.node.mtime = h.node.ctime = Date.now());
|
|
1383
|
+
return v;
|
|
1384
|
+
} });
|
|
1385
|
+
Yb(a, d, e);
|
|
1386
|
+
}
|
|
1387
|
+
var W = {};
|
|
1388
|
+
function Gc(a, b, c) {
|
|
1389
|
+
if ("/" === b.charAt(0)) return b;
|
|
1390
|
+
a = -100 === a ? "/" : T(a).path;
|
|
1391
|
+
if (0 == b.length) {
|
|
1392
|
+
if (!c) throw new N(44);
|
|
1393
|
+
return a;
|
|
1394
|
+
}
|
|
1395
|
+
return a + "/" + b;
|
|
1396
|
+
}
|
|
1397
|
+
function Hc(a, b) {
|
|
1398
|
+
E[a >> 2] = b.dev;
|
|
1399
|
+
E[a + 4 >> 2] = b.mode;
|
|
1400
|
+
F[a + 8 >> 2] = b.nlink;
|
|
1401
|
+
E[a + 12 >> 2] = b.uid;
|
|
1402
|
+
E[a + 16 >> 2] = b.gid;
|
|
1403
|
+
E[a + 20 >> 2] = b.rdev;
|
|
1404
|
+
H[a + 24 >> 3] = BigInt(b.size);
|
|
1405
|
+
E[a + 32 >> 2] = 4096;
|
|
1406
|
+
E[a + 36 >> 2] = b.blocks;
|
|
1407
|
+
var c = b.atime.getTime(), d = b.mtime.getTime(), e = b.ctime.getTime();
|
|
1408
|
+
H[a + 40 >> 3] = BigInt(Math.floor(c / 1e3));
|
|
1409
|
+
F[a + 48 >> 2] = c % 1e3 * 1e6;
|
|
1410
|
+
H[a + 56 >> 3] = BigInt(Math.floor(d / 1e3));
|
|
1411
|
+
F[a + 64 >> 2] = d % 1e3 * 1e6;
|
|
1412
|
+
H[a + 72 >> 3] = BigInt(Math.floor(e / 1e3));
|
|
1413
|
+
F[a + 80 >> 2] = e % 1e3 * 1e6;
|
|
1414
|
+
H[a + 88 >> 3] = BigInt(b.ino);
|
|
1415
|
+
return 0;
|
|
1416
|
+
}
|
|
1417
|
+
var Ic = void 0, Jc = () => {
|
|
1418
|
+
var a = E[+Ic >> 2];
|
|
1419
|
+
Ic += 4;
|
|
1420
|
+
return a;
|
|
1421
|
+
}, Kc = 0, Lc = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], Mc = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], Nc = {}, Oc = (a) => {
|
|
1422
|
+
Ma = a;
|
|
1423
|
+
cb || 0 < Kc || (f.onExit?.(a), La = true);
|
|
1424
|
+
Da(a, new Ya(a));
|
|
1425
|
+
}, Pc = (a) => {
|
|
1426
|
+
if (!La) try {
|
|
1427
|
+
if (a(), !(cb || 0 < Kc)) try {
|
|
1428
|
+
Ma = a = Ma, Oc(a);
|
|
1429
|
+
} catch (b) {
|
|
1430
|
+
b instanceof Ya || "unwind" == b || Da(1, b);
|
|
1431
|
+
}
|
|
1432
|
+
} catch (b) {
|
|
1433
|
+
b instanceof Ya || "unwind" == b || Da(1, b);
|
|
1434
|
+
}
|
|
1435
|
+
}, Qc = {}, Sc = () => {
|
|
1436
|
+
if (!Rc) {
|
|
1437
|
+
var a = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: ("object" == typeof navigator && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", _: Ca || "./this.program" }, b;
|
|
1438
|
+
for (b in Qc) void 0 === Qc[b] ? delete a[b] : a[b] = Qc[b];
|
|
1439
|
+
var c = [];
|
|
1440
|
+
for (b in a) c.push(`${b}=${a[b]}`);
|
|
1441
|
+
Rc = c;
|
|
1442
|
+
}
|
|
1443
|
+
return Rc;
|
|
1444
|
+
}, Rc, xa = (a) => {
|
|
1445
|
+
var b = ha(a) + 1, c = z(b);
|
|
1446
|
+
u(a, x, c, b);
|
|
1447
|
+
return c;
|
|
1448
|
+
}, Tc = (a, b, c, d) => {
|
|
1449
|
+
var e = { string: (v) => {
|
|
1450
|
+
var C = 0;
|
|
1451
|
+
null !== v && void 0 !== v && 0 !== v && (C = xa(v));
|
|
1452
|
+
return C;
|
|
1453
|
+
}, array: (v) => {
|
|
1454
|
+
var C = z(v.length);
|
|
1455
|
+
p.set(v, C);
|
|
1456
|
+
return C;
|
|
1457
|
+
} };
|
|
1458
|
+
a = f["_" + a];
|
|
1459
|
+
var h = [], k = 0;
|
|
1460
|
+
if (d) for (var q = 0; q < d.length; q++) {
|
|
1461
|
+
var w = e[c[q]];
|
|
1462
|
+
w ? (0 === k && (k = sa()), h[q] = w(d[q])) : h[q] = d[q];
|
|
1463
|
+
}
|
|
1464
|
+
c = a(...h);
|
|
1465
|
+
return c = (function(v) {
|
|
1466
|
+
0 !== k && wa(k);
|
|
1467
|
+
return "string" === b ? v ? B(x, v) : "" : "boolean" === b ? !!v : v;
|
|
1468
|
+
})(c);
|
|
1469
|
+
}, ea = 0, da = (a, b) => {
|
|
1470
|
+
b = 1 == b ? z(a.length) : ia(a.length);
|
|
1471
|
+
a.subarray || a.slice || (a = new Uint8Array(a));
|
|
1472
|
+
x.set(a, b);
|
|
1473
|
+
return b;
|
|
1474
|
+
}, Uc, Vc = [], Y, A = (a) => {
|
|
1475
|
+
Uc.delete(Y.get(a));
|
|
1476
|
+
Y.set(a, null);
|
|
1477
|
+
Vc.push(a);
|
|
1478
|
+
}, Aa = (a, b) => {
|
|
1479
|
+
if (!Uc) {
|
|
1480
|
+
Uc = /* @__PURE__ */ new WeakMap();
|
|
1481
|
+
var c = Y.length;
|
|
1482
|
+
if (Uc) for (var d = 0; d < 0 + c; d++) {
|
|
1483
|
+
var e = Y.get(d);
|
|
1484
|
+
e && Uc.set(e, d);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (c = Uc.get(a) || 0) return c;
|
|
1488
|
+
if (Vc.length) c = Vc.pop();
|
|
1489
|
+
else {
|
|
1490
|
+
try {
|
|
1491
|
+
Y.grow(1);
|
|
1492
|
+
} catch (w) {
|
|
1493
|
+
if (!(w instanceof RangeError)) throw w;
|
|
1494
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
1495
|
+
}
|
|
1496
|
+
c = Y.length - 1;
|
|
1497
|
+
}
|
|
1498
|
+
try {
|
|
1499
|
+
Y.set(c, a);
|
|
1500
|
+
} catch (w) {
|
|
1501
|
+
if (!(w instanceof TypeError)) throw w;
|
|
1502
|
+
if ("function" == typeof WebAssembly.Function) {
|
|
1503
|
+
var h = WebAssembly.Function;
|
|
1504
|
+
d = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" };
|
|
1505
|
+
e = { parameters: [], results: "v" == b[0] ? [] : [d[b[0]]] };
|
|
1506
|
+
for (var k = 1; k < b.length; ++k) e.parameters.push(d[b[k]]);
|
|
1507
|
+
b = new h(e, a);
|
|
1508
|
+
} else {
|
|
1509
|
+
d = [1];
|
|
1510
|
+
e = b.slice(0, 1);
|
|
1511
|
+
b = b.slice(1);
|
|
1512
|
+
k = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
1513
|
+
d.push(96);
|
|
1514
|
+
var q = b.length;
|
|
1515
|
+
128 > q ? d.push(q) : d.push(q % 128 | 128, q >> 7);
|
|
1516
|
+
for (h of b) d.push(k[h]);
|
|
1517
|
+
"v" == e ? d.push(0) : d.push(1, k[e]);
|
|
1518
|
+
b = [0, 97, 115, 109, 1, 0, 0, 0, 1];
|
|
1519
|
+
h = d.length;
|
|
1520
|
+
128 > h ? b.push(h) : b.push(h % 128 | 128, h >> 7);
|
|
1521
|
+
b.push(...d);
|
|
1522
|
+
b.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
1523
|
+
b = new WebAssembly.Module(new Uint8Array(b));
|
|
1524
|
+
b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
|
|
1525
|
+
}
|
|
1526
|
+
Y.set(c, b);
|
|
1527
|
+
}
|
|
1528
|
+
Uc.set(a, c);
|
|
1529
|
+
return c;
|
|
1530
|
+
};
|
|
1531
|
+
R = Array(4096);
|
|
1532
|
+
Wb(O, "/");
|
|
1533
|
+
U("/tmp");
|
|
1534
|
+
U("/home");
|
|
1535
|
+
U("/home/web_user");
|
|
1536
|
+
(function() {
|
|
1537
|
+
U("/dev");
|
|
1538
|
+
wb(259, { read: () => 0, write: (d, e, h, k) => k, Va: () => 0 });
|
|
1539
|
+
Yb("/dev/null", 259);
|
|
1540
|
+
nb(1280, yb);
|
|
1541
|
+
nb(1536, zb);
|
|
1542
|
+
Yb("/dev/tty", 1280);
|
|
1543
|
+
Yb("/dev/tty1", 1536);
|
|
1544
|
+
var a = new Uint8Array(1024), b = 0, c = () => {
|
|
1545
|
+
0 === b && (ib(a), b = a.byteLength);
|
|
1546
|
+
return a[--b];
|
|
1547
|
+
};
|
|
1548
|
+
V("random", c);
|
|
1549
|
+
V("urandom", c);
|
|
1550
|
+
U("/dev/shm");
|
|
1551
|
+
U("/dev/shm/tmp");
|
|
1552
|
+
})();
|
|
1553
|
+
(function() {
|
|
1554
|
+
U("/proc");
|
|
1555
|
+
var a = U("/proc/self");
|
|
1556
|
+
U("/proc/self/fd");
|
|
1557
|
+
Wb({ Xa() {
|
|
1558
|
+
var b = Bb(a, "fd", 16895, 73);
|
|
1559
|
+
b.Ma = { Va: O.Ma.Va };
|
|
1560
|
+
b.La = { lookup(c, d) {
|
|
1561
|
+
c = +d;
|
|
1562
|
+
var e = T(c);
|
|
1563
|
+
c = { parent: null, Xa: { zb: "fake" }, La: { readlink: () => e.path }, id: c + 1 };
|
|
1564
|
+
return c.parent = c;
|
|
1565
|
+
}, readdir() {
|
|
1566
|
+
return Array.from(Gb.entries()).filter(([, c]) => c).map(([c]) => c.toString());
|
|
1567
|
+
} };
|
|
1568
|
+
return b;
|
|
1569
|
+
} }, "/proc/self/fd");
|
|
1570
|
+
})();
|
|
1571
|
+
O.vb = new N(44);
|
|
1572
|
+
O.vb.stack = "<generic error, no stack>";
|
|
1573
|
+
var Xc = { a: (a, b, c, d) => Ta(`Assertion failed: ${a ? B(x, a) : ""}, at: ` + [b ? b ? B(x, b) : "" : "unknown filename", c, d ? d ? B(x, d) : "" : "unknown function"]), i: function(a, b) {
|
|
1574
|
+
try {
|
|
1575
|
+
return a = a ? B(x, a) : "", na(a, b), 0;
|
|
1576
|
+
} catch (c) {
|
|
1577
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1578
|
+
return -c.Pa;
|
|
1579
|
+
}
|
|
1580
|
+
}, L: function(a, b, c) {
|
|
1581
|
+
try {
|
|
1582
|
+
b = b ? B(x, b) : "";
|
|
1583
|
+
b = Gc(a, b);
|
|
1584
|
+
if (c & -8) return -28;
|
|
1585
|
+
var d = S(b, { $a: true }).node;
|
|
1586
|
+
if (!d) return -44;
|
|
1587
|
+
a = "";
|
|
1588
|
+
c & 4 && (a += "r");
|
|
1589
|
+
c & 2 && (a += "w");
|
|
1590
|
+
c & 1 && (a += "x");
|
|
1591
|
+
return a && Ob(d, a) ? -2 : 0;
|
|
1592
|
+
} catch (e) {
|
|
1593
|
+
if ("undefined" == typeof W || "ErrnoError" !== e.name) throw e;
|
|
1594
|
+
return -e.Pa;
|
|
1595
|
+
}
|
|
1596
|
+
}, j: function(a, b) {
|
|
1597
|
+
try {
|
|
1598
|
+
var c = T(a);
|
|
1599
|
+
bc(c, c.node, b, false);
|
|
1600
|
+
return 0;
|
|
1601
|
+
} catch (d) {
|
|
1602
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1603
|
+
return -d.Pa;
|
|
1604
|
+
}
|
|
1605
|
+
}, h: function(a) {
|
|
1606
|
+
try {
|
|
1607
|
+
var b = T(a);
|
|
1608
|
+
Vb(b, b.node, { timestamp: Date.now(), Fb: false });
|
|
1609
|
+
return 0;
|
|
1610
|
+
} catch (c) {
|
|
1611
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1612
|
+
return -c.Pa;
|
|
1613
|
+
}
|
|
1614
|
+
}, b: function(a, b, c) {
|
|
1615
|
+
Ic = c;
|
|
1616
|
+
try {
|
|
1617
|
+
var d = T(a);
|
|
1618
|
+
switch (b) {
|
|
1619
|
+
case 0:
|
|
1620
|
+
var e = Jc();
|
|
1621
|
+
if (0 > e) break;
|
|
1622
|
+
for (; Gb[e]; ) e++;
|
|
1623
|
+
return Ub(d, e).fd;
|
|
1624
|
+
case 1:
|
|
1625
|
+
case 2:
|
|
1626
|
+
return 0;
|
|
1627
|
+
case 3:
|
|
1628
|
+
return d.flags;
|
|
1629
|
+
case 4:
|
|
1630
|
+
return e = Jc(), d.flags |= e, 0;
|
|
1631
|
+
case 12:
|
|
1632
|
+
return e = Jc(), Na[e + 0 >> 1] = 2, 0;
|
|
1633
|
+
case 13:
|
|
1634
|
+
case 14:
|
|
1635
|
+
return 0;
|
|
1636
|
+
}
|
|
1637
|
+
return -28;
|
|
1638
|
+
} catch (h) {
|
|
1639
|
+
if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
|
|
1640
|
+
return -h.Pa;
|
|
1641
|
+
}
|
|
1642
|
+
}, g: function(a, b) {
|
|
1643
|
+
try {
|
|
1644
|
+
var c = T(a), d = c.node, e = c.Ma.Ta;
|
|
1645
|
+
a = e ? c : d;
|
|
1646
|
+
e ??= d.La.Ta;
|
|
1647
|
+
Sb(e);
|
|
1648
|
+
var h = e(a);
|
|
1649
|
+
return Hc(b, h);
|
|
1650
|
+
} catch (k) {
|
|
1651
|
+
if ("undefined" == typeof W || "ErrnoError" !== k.name) throw k;
|
|
1652
|
+
return -k.Pa;
|
|
1653
|
+
}
|
|
1654
|
+
}, H: function(a, b) {
|
|
1655
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
1656
|
+
try {
|
|
1657
|
+
if (isNaN(b)) return 61;
|
|
1658
|
+
var c = T(a);
|
|
1659
|
+
if (0 > b || 0 === (c.flags & 2097155)) throw new N(28);
|
|
1660
|
+
cc(c, c.node, b);
|
|
1661
|
+
return 0;
|
|
1662
|
+
} catch (d) {
|
|
1663
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1664
|
+
return -d.Pa;
|
|
1665
|
+
}
|
|
1666
|
+
}, G: function(a, b) {
|
|
1667
|
+
try {
|
|
1668
|
+
if (0 === b) return -28;
|
|
1669
|
+
var c = ha("/") + 1;
|
|
1670
|
+
if (b < c) return -68;
|
|
1671
|
+
u("/", x, a, b);
|
|
1672
|
+
return c;
|
|
1673
|
+
} catch (d) {
|
|
1674
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1675
|
+
return -d.Pa;
|
|
1676
|
+
}
|
|
1677
|
+
}, K: function(a, b) {
|
|
1678
|
+
try {
|
|
1679
|
+
return a = a ? B(x, a) : "", Hc(b, ac(a, true));
|
|
1680
|
+
} catch (c) {
|
|
1681
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1682
|
+
return -c.Pa;
|
|
1683
|
+
}
|
|
1684
|
+
}, C: function(a, b, c) {
|
|
1685
|
+
try {
|
|
1686
|
+
return b = b ? B(x, b) : "", b = Gc(a, b), U(b, c), 0;
|
|
1687
|
+
} catch (d) {
|
|
1688
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1689
|
+
return -d.Pa;
|
|
1690
|
+
}
|
|
1691
|
+
}, J: function(a, b, c, d) {
|
|
1692
|
+
try {
|
|
1693
|
+
b = b ? B(x, b) : "";
|
|
1694
|
+
var e = d & 256;
|
|
1695
|
+
b = Gc(a, b, d & 4096);
|
|
1696
|
+
return Hc(c, e ? ac(b, true) : ac(b));
|
|
1697
|
+
} catch (h) {
|
|
1698
|
+
if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
|
|
1699
|
+
return -h.Pa;
|
|
1700
|
+
}
|
|
1701
|
+
}, x: function(a, b, c, d) {
|
|
1702
|
+
Ic = d;
|
|
1703
|
+
try {
|
|
1704
|
+
b = b ? B(x, b) : "";
|
|
1705
|
+
b = Gc(a, b);
|
|
1706
|
+
var e = d ? Jc() : 0;
|
|
1707
|
+
return oa(b, c, e).fd;
|
|
1708
|
+
} catch (h) {
|
|
1709
|
+
if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
|
|
1710
|
+
return -h.Pa;
|
|
1711
|
+
}
|
|
1712
|
+
}, v: function(a, b, c, d) {
|
|
1713
|
+
try {
|
|
1714
|
+
b = b ? B(x, b) : "";
|
|
1715
|
+
b = Gc(a, b);
|
|
1716
|
+
if (0 >= d) return -28;
|
|
1717
|
+
var e = S(b).node;
|
|
1718
|
+
if (!e) throw new N(44);
|
|
1719
|
+
if (!e.La.readlink) throw new N(28);
|
|
1720
|
+
var h = e.La.readlink(e);
|
|
1721
|
+
var k = Math.min(d, ha(h)), q = p[c + k];
|
|
1722
|
+
u(h, x, c, d + 1);
|
|
1723
|
+
p[c + k] = q;
|
|
1724
|
+
return k;
|
|
1725
|
+
} catch (w) {
|
|
1726
|
+
if ("undefined" == typeof W || "ErrnoError" !== w.name) throw w;
|
|
1727
|
+
return -w.Pa;
|
|
1728
|
+
}
|
|
1729
|
+
}, u: function(a) {
|
|
1730
|
+
try {
|
|
1731
|
+
return a = a ? B(x, a) : "", $b(a), 0;
|
|
1732
|
+
} catch (b) {
|
|
1733
|
+
if ("undefined" == typeof W || "ErrnoError" !== b.name) throw b;
|
|
1734
|
+
return -b.Pa;
|
|
1735
|
+
}
|
|
1736
|
+
}, f: function(a, b) {
|
|
1737
|
+
try {
|
|
1738
|
+
return a = a ? B(x, a) : "", Hc(b, ac(a));
|
|
1739
|
+
} catch (c) {
|
|
1740
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1741
|
+
return -c.Pa;
|
|
1742
|
+
}
|
|
1743
|
+
}, r: function(a, b, c) {
|
|
1744
|
+
try {
|
|
1745
|
+
return b = b ? B(x, b) : "", b = Gc(a, b), 0 === c ? za(b) : 512 === c ? $b(b) : Ta("Invalid flags passed to unlinkat"), 0;
|
|
1746
|
+
} catch (d) {
|
|
1747
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1748
|
+
return -d.Pa;
|
|
1749
|
+
}
|
|
1750
|
+
}, q: function(a, b, c) {
|
|
1751
|
+
try {
|
|
1752
|
+
b = b ? B(x, b) : "";
|
|
1753
|
+
b = Gc(a, b, true);
|
|
1754
|
+
var d = Date.now(), e, h;
|
|
1755
|
+
if (c) {
|
|
1756
|
+
var k = F[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
|
|
1757
|
+
1073741823 == q ? e = d : 1073741822 == q ? e = null : e = 1e3 * k + q / 1e6;
|
|
1758
|
+
c += 16;
|
|
1759
|
+
k = F[c >> 2] + 4294967296 * E[c + 4 >> 2];
|
|
1760
|
+
q = E[c + 8 >> 2];
|
|
1761
|
+
1073741823 == q ? h = d : 1073741822 == q ? h = null : h = 1e3 * k + q / 1e6;
|
|
1762
|
+
} else h = e = d;
|
|
1763
|
+
if (null !== (h ?? e)) {
|
|
1764
|
+
a = e;
|
|
1765
|
+
var w = S(b, { $a: true }).node;
|
|
1766
|
+
Sb(w.La.Ua)(w, { atime: a, mtime: h });
|
|
1767
|
+
}
|
|
1768
|
+
return 0;
|
|
1769
|
+
} catch (v) {
|
|
1770
|
+
if ("undefined" == typeof W || "ErrnoError" !== v.name) throw v;
|
|
1771
|
+
return -v.Pa;
|
|
1772
|
+
}
|
|
1773
|
+
}, m: () => Ta(""), l: () => {
|
|
1774
|
+
cb = false;
|
|
1775
|
+
Kc = 0;
|
|
1776
|
+
}, A: function(a, b) {
|
|
1777
|
+
a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
|
|
1778
|
+
a = new Date(1e3 * a);
|
|
1779
|
+
E[b >> 2] = a.getSeconds();
|
|
1780
|
+
E[b + 4 >> 2] = a.getMinutes();
|
|
1781
|
+
E[b + 8 >> 2] = a.getHours();
|
|
1782
|
+
E[b + 12 >> 2] = a.getDate();
|
|
1783
|
+
E[b + 16 >> 2] = a.getMonth();
|
|
1784
|
+
E[b + 20 >> 2] = a.getFullYear() - 1900;
|
|
1785
|
+
E[b + 24 >> 2] = a.getDay();
|
|
1786
|
+
var c = a.getFullYear();
|
|
1787
|
+
E[b + 28 >> 2] = (0 !== c % 4 || 0 === c % 100 && 0 !== c % 400 ? Mc : Lc)[a.getMonth()] + a.getDate() - 1 | 0;
|
|
1788
|
+
E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
|
|
1789
|
+
c = new Date(
|
|
1790
|
+
a.getFullYear(),
|
|
1791
|
+
6,
|
|
1792
|
+
1
|
|
1793
|
+
).getTimezoneOffset();
|
|
1794
|
+
var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
|
|
1795
|
+
E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
|
|
1796
|
+
}, y: function(a, b, c, d, e, h, k) {
|
|
1797
|
+
e = -9007199254740992 > e || 9007199254740992 < e ? NaN : Number(e);
|
|
1798
|
+
try {
|
|
1799
|
+
if (isNaN(e)) return 61;
|
|
1800
|
+
var q = T(d);
|
|
1801
|
+
if (0 !== (b & 2) && 0 === (c & 2) && 2 !== (q.flags & 2097155)) throw new N(2);
|
|
1802
|
+
if (1 === (q.flags & 2097155)) throw new N(2);
|
|
1803
|
+
if (!q.Ma.ib) throw new N(43);
|
|
1804
|
+
if (!a) throw new N(28);
|
|
1805
|
+
var w = q.Ma.ib(q, a, e, b, c);
|
|
1806
|
+
var v = w.Kb;
|
|
1807
|
+
E[h >> 2] = w.Ab;
|
|
1808
|
+
F[k >> 2] = v;
|
|
1809
|
+
return 0;
|
|
1810
|
+
} catch (C) {
|
|
1811
|
+
if ("undefined" == typeof W || "ErrnoError" !== C.name) throw C;
|
|
1812
|
+
return -C.Pa;
|
|
1813
|
+
}
|
|
1814
|
+
}, z: function(a, b, c, d, e, h) {
|
|
1815
|
+
h = -9007199254740992 > h || 9007199254740992 < h ? NaN : Number(h);
|
|
1816
|
+
try {
|
|
1817
|
+
var k = T(e);
|
|
1818
|
+
if (c & 2) {
|
|
1819
|
+
c = h;
|
|
1820
|
+
if (32768 !== (k.node.mode & 61440)) throw new N(43);
|
|
1821
|
+
if (!(d & 2)) {
|
|
1822
|
+
var q = x.slice(a, a + b);
|
|
1823
|
+
k.Ma.jb && k.Ma.jb(k, q, c, b, d);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
} catch (w) {
|
|
1827
|
+
if ("undefined" == typeof W || "ErrnoError" !== w.name) throw w;
|
|
1828
|
+
return -w.Pa;
|
|
1829
|
+
}
|
|
1830
|
+
}, n: (a, b) => {
|
|
1831
|
+
Nc[a] && (clearTimeout(Nc[a].id), delete Nc[a]);
|
|
1832
|
+
if (!b) return 0;
|
|
1833
|
+
var c = setTimeout(() => {
|
|
1834
|
+
delete Nc[a];
|
|
1835
|
+
Pc(() => Wc(a, performance.now()));
|
|
1836
|
+
}, b);
|
|
1837
|
+
Nc[a] = {
|
|
1838
|
+
id: c,
|
|
1839
|
+
Xb: b
|
|
1840
|
+
};
|
|
1841
|
+
return 0;
|
|
1842
|
+
}, B: (a, b, c, d) => {
|
|
1843
|
+
var e = (/* @__PURE__ */ new Date()).getFullYear(), h = new Date(e, 0, 1).getTimezoneOffset();
|
|
1844
|
+
e = new Date(e, 6, 1).getTimezoneOffset();
|
|
1845
|
+
F[a >> 2] = 60 * Math.max(h, e);
|
|
1846
|
+
E[b >> 2] = Number(h != e);
|
|
1847
|
+
b = (k) => {
|
|
1848
|
+
var q = Math.abs(k);
|
|
1849
|
+
return `UTC${0 <= k ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
|
|
1850
|
+
};
|
|
1851
|
+
a = b(h);
|
|
1852
|
+
b = b(e);
|
|
1853
|
+
e < h ? (u(a, x, c, 17), u(b, x, d, 17)) : (u(a, x, d, 17), u(b, x, c, 17));
|
|
1854
|
+
}, d: () => Date.now(), s: () => 2147483648, c: () => performance.now(), o: (a) => {
|
|
1855
|
+
var b = x.length;
|
|
1856
|
+
a >>>= 0;
|
|
1857
|
+
if (2147483648 < a) return false;
|
|
1858
|
+
for (var c = 1; 4 >= c; c *= 2) {
|
|
1859
|
+
var d = b * (1 + 0.2 / c);
|
|
1860
|
+
d = Math.min(d, a + 100663296);
|
|
1861
|
+
a: {
|
|
1862
|
+
d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ka.buffer.byteLength + 65535) / 65536 | 0;
|
|
1863
|
+
try {
|
|
1864
|
+
Ka.grow(d);
|
|
1865
|
+
Qa();
|
|
1866
|
+
var e = 1;
|
|
1867
|
+
break a;
|
|
1868
|
+
} catch (h) {
|
|
1869
|
+
}
|
|
1870
|
+
e = void 0;
|
|
1871
|
+
}
|
|
1872
|
+
if (e) return true;
|
|
1873
|
+
}
|
|
1874
|
+
return false;
|
|
1875
|
+
}, E: (a, b) => {
|
|
1876
|
+
var c = 0;
|
|
1877
|
+
Sc().forEach((d, e) => {
|
|
1878
|
+
var h = b + c;
|
|
1879
|
+
e = F[a + 4 * e >> 2] = h;
|
|
1880
|
+
for (h = 0; h < d.length; ++h) p[e++] = d.charCodeAt(h);
|
|
1881
|
+
p[e] = 0;
|
|
1882
|
+
c += d.length + 1;
|
|
1883
|
+
});
|
|
1884
|
+
return 0;
|
|
1885
|
+
}, F: (a, b) => {
|
|
1886
|
+
var c = Sc();
|
|
1887
|
+
F[a >> 2] = c.length;
|
|
1888
|
+
var d = 0;
|
|
1889
|
+
c.forEach((e) => d += e.length + 1);
|
|
1890
|
+
F[b >> 2] = d;
|
|
1891
|
+
return 0;
|
|
1892
|
+
}, e: function(a) {
|
|
1893
|
+
try {
|
|
1894
|
+
var b = T(a);
|
|
1895
|
+
qa(b);
|
|
1896
|
+
return 0;
|
|
1897
|
+
} catch (c) {
|
|
1898
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1899
|
+
return c.Pa;
|
|
1900
|
+
}
|
|
1901
|
+
}, p: function(a, b) {
|
|
1902
|
+
try {
|
|
1903
|
+
var c = T(a);
|
|
1904
|
+
p[b] = c.tty ? 2 : P(c.mode) ? 3 : 40960 === (c.mode & 61440) ? 7 : 4;
|
|
1905
|
+
Na[b + 2 >> 1] = 0;
|
|
1906
|
+
H[b + 8 >> 3] = BigInt(0);
|
|
1907
|
+
H[b + 16 >> 3] = BigInt(0);
|
|
1908
|
+
return 0;
|
|
1909
|
+
} catch (d) {
|
|
1910
|
+
if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
|
|
1911
|
+
return d.Pa;
|
|
1912
|
+
}
|
|
1913
|
+
}, w: function(a, b, c, d) {
|
|
1914
|
+
try {
|
|
1915
|
+
a: {
|
|
1916
|
+
var e = T(a);
|
|
1917
|
+
a = b;
|
|
1918
|
+
for (var h, k = b = 0; k < c; k++) {
|
|
1919
|
+
var q = F[a >> 2], w = F[a + 4 >> 2];
|
|
1920
|
+
a += 8;
|
|
1921
|
+
var v = Ec(e, p, q, w, h);
|
|
1922
|
+
if (0 > v) {
|
|
1923
|
+
var C = -1;
|
|
1924
|
+
break a;
|
|
1925
|
+
}
|
|
1926
|
+
b += v;
|
|
1927
|
+
if (v < w) break;
|
|
1928
|
+
"undefined" != typeof h && (h += v);
|
|
1929
|
+
}
|
|
1930
|
+
C = b;
|
|
1931
|
+
}
|
|
1932
|
+
F[d >> 2] = C;
|
|
1933
|
+
return 0;
|
|
1934
|
+
} catch (G) {
|
|
1935
|
+
if ("undefined" == typeof W || "ErrnoError" !== G.name) throw G;
|
|
1936
|
+
return G.Pa;
|
|
1937
|
+
}
|
|
1938
|
+
}, D: function(a, b, c, d) {
|
|
1939
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
1940
|
+
try {
|
|
1941
|
+
if (isNaN(b)) return 61;
|
|
1942
|
+
var e = T(a);
|
|
1943
|
+
mc(e, b, c);
|
|
1944
|
+
H[d >> 3] = BigInt(e.position);
|
|
1945
|
+
e.ob && 0 === b && 0 === c && (e.ob = null);
|
|
1946
|
+
return 0;
|
|
1947
|
+
} catch (h) {
|
|
1948
|
+
if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
|
|
1949
|
+
return h.Pa;
|
|
1950
|
+
}
|
|
1951
|
+
}, I: function(a) {
|
|
1952
|
+
try {
|
|
1953
|
+
var b = T(a);
|
|
1954
|
+
return b.Ma?.fsync ? b.Ma.fsync(b) : 0;
|
|
1955
|
+
} catch (c) {
|
|
1956
|
+
if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
|
|
1957
|
+
return c.Pa;
|
|
1958
|
+
}
|
|
1959
|
+
}, t: function(a, b, c, d) {
|
|
1960
|
+
try {
|
|
1961
|
+
a: {
|
|
1962
|
+
var e = T(a);
|
|
1963
|
+
a = b;
|
|
1964
|
+
for (var h, k = b = 0; k < c; k++) {
|
|
1965
|
+
var q = F[a >> 2], w = F[a + 4 >> 2];
|
|
1966
|
+
a += 8;
|
|
1967
|
+
var v = pa(e, p, q, w, h);
|
|
1968
|
+
if (0 > v) {
|
|
1969
|
+
var C = -1;
|
|
1970
|
+
break a;
|
|
1971
|
+
}
|
|
1972
|
+
b += v;
|
|
1973
|
+
if (v < w) break;
|
|
1974
|
+
"undefined" != typeof h && (h += v);
|
|
1975
|
+
}
|
|
1976
|
+
C = b;
|
|
1977
|
+
}
|
|
1978
|
+
F[d >> 2] = C;
|
|
1979
|
+
return 0;
|
|
1980
|
+
} catch (G) {
|
|
1981
|
+
if ("undefined" == typeof W || "ErrnoError" !== G.name) throw G;
|
|
1982
|
+
return G.Pa;
|
|
1983
|
+
}
|
|
1984
|
+
}, k: Oc }, Z;
|
|
1985
|
+
(async function() {
|
|
1986
|
+
function a(c) {
|
|
1987
|
+
Z = c.exports;
|
|
1988
|
+
Ka = Z.M;
|
|
1989
|
+
Qa();
|
|
1990
|
+
Y = Z.O;
|
|
1991
|
+
K--;
|
|
1992
|
+
f.monitorRunDependencies?.(K);
|
|
1993
|
+
0 == K && Sa && (c = Sa, Sa = null, c());
|
|
1994
|
+
return Z;
|
|
1995
|
+
}
|
|
1996
|
+
K++;
|
|
1997
|
+
f.monitorRunDependencies?.(K);
|
|
1998
|
+
var b = { a: Xc };
|
|
1999
|
+
if (f.instantiateWasm) return new Promise((c) => {
|
|
2000
|
+
f.instantiateWasm(b, (d, e) => {
|
|
2001
|
+
a(d, e);
|
|
2002
|
+
c(d.exports);
|
|
2003
|
+
});
|
|
2004
|
+
});
|
|
2005
|
+
Ua ??= f.locateFile ? f.locateFile("sql-wasm.wasm", D) : D + "sql-wasm.wasm";
|
|
2006
|
+
return a((await Xa(b)).instance);
|
|
2007
|
+
})();
|
|
2008
|
+
f._sqlite3_free = (a) => (f._sqlite3_free = Z.P)(a);
|
|
2009
|
+
f._sqlite3_value_text = (a) => (f._sqlite3_value_text = Z.Q)(a);
|
|
2010
|
+
f._sqlite3_prepare_v2 = (a, b, c, d, e) => (f._sqlite3_prepare_v2 = Z.R)(a, b, c, d, e);
|
|
2011
|
+
f._sqlite3_step = (a) => (f._sqlite3_step = Z.S)(a);
|
|
2012
|
+
f._sqlite3_reset = (a) => (f._sqlite3_reset = Z.T)(a);
|
|
2013
|
+
f._sqlite3_exec = (a, b, c, d, e) => (f._sqlite3_exec = Z.U)(a, b, c, d, e);
|
|
2014
|
+
f._sqlite3_finalize = (a) => (f._sqlite3_finalize = Z.V)(a);
|
|
2015
|
+
f._sqlite3_column_name = (a, b) => (f._sqlite3_column_name = Z.W)(a, b);
|
|
2016
|
+
f._sqlite3_column_text = (a, b) => (f._sqlite3_column_text = Z.X)(a, b);
|
|
2017
|
+
f._sqlite3_column_type = (a, b) => (f._sqlite3_column_type = Z.Y)(a, b);
|
|
2018
|
+
f._sqlite3_errmsg = (a) => (f._sqlite3_errmsg = Z.Z)(a);
|
|
2019
|
+
f._sqlite3_clear_bindings = (a) => (f._sqlite3_clear_bindings = Z._)(a);
|
|
2020
|
+
f._sqlite3_value_blob = (a) => (f._sqlite3_value_blob = Z.$)(a);
|
|
2021
|
+
f._sqlite3_value_bytes = (a) => (f._sqlite3_value_bytes = Z.aa)(a);
|
|
2022
|
+
f._sqlite3_value_double = (a) => (f._sqlite3_value_double = Z.ba)(a);
|
|
2023
|
+
f._sqlite3_value_int = (a) => (f._sqlite3_value_int = Z.ca)(a);
|
|
2024
|
+
f._sqlite3_value_type = (a) => (f._sqlite3_value_type = Z.da)(a);
|
|
2025
|
+
f._sqlite3_result_blob = (a, b, c, d) => (f._sqlite3_result_blob = Z.ea)(a, b, c, d);
|
|
2026
|
+
f._sqlite3_result_double = (a, b) => (f._sqlite3_result_double = Z.fa)(a, b);
|
|
2027
|
+
f._sqlite3_result_error = (a, b, c) => (f._sqlite3_result_error = Z.ga)(a, b, c);
|
|
2028
|
+
f._sqlite3_result_int = (a, b) => (f._sqlite3_result_int = Z.ha)(a, b);
|
|
2029
|
+
f._sqlite3_result_int64 = (a, b) => (f._sqlite3_result_int64 = Z.ia)(a, b);
|
|
2030
|
+
f._sqlite3_result_null = (a) => (f._sqlite3_result_null = Z.ja)(a);
|
|
2031
|
+
f._sqlite3_result_text = (a, b, c, d) => (f._sqlite3_result_text = Z.ka)(a, b, c, d);
|
|
2032
|
+
f._sqlite3_aggregate_context = (a, b) => (f._sqlite3_aggregate_context = Z.la)(a, b);
|
|
2033
|
+
f._sqlite3_column_count = (a) => (f._sqlite3_column_count = Z.ma)(a);
|
|
2034
|
+
f._sqlite3_data_count = (a) => (f._sqlite3_data_count = Z.na)(a);
|
|
2035
|
+
f._sqlite3_column_blob = (a, b) => (f._sqlite3_column_blob = Z.oa)(a, b);
|
|
2036
|
+
f._sqlite3_column_bytes = (a, b) => (f._sqlite3_column_bytes = Z.pa)(a, b);
|
|
2037
|
+
f._sqlite3_column_double = (a, b) => (f._sqlite3_column_double = Z.qa)(a, b);
|
|
2038
|
+
f._sqlite3_bind_blob = (a, b, c, d, e) => (f._sqlite3_bind_blob = Z.ra)(a, b, c, d, e);
|
|
2039
|
+
f._sqlite3_bind_double = (a, b, c) => (f._sqlite3_bind_double = Z.sa)(a, b, c);
|
|
2040
|
+
f._sqlite3_bind_int = (a, b, c) => (f._sqlite3_bind_int = Z.ta)(a, b, c);
|
|
2041
|
+
f._sqlite3_bind_text = (a, b, c, d, e) => (f._sqlite3_bind_text = Z.ua)(a, b, c, d, e);
|
|
2042
|
+
f._sqlite3_bind_parameter_index = (a, b) => (f._sqlite3_bind_parameter_index = Z.va)(a, b);
|
|
2043
|
+
f._sqlite3_sql = (a) => (f._sqlite3_sql = Z.wa)(a);
|
|
2044
|
+
f._sqlite3_normalized_sql = (a) => (f._sqlite3_normalized_sql = Z.xa)(a);
|
|
2045
|
+
f._sqlite3_changes = (a) => (f._sqlite3_changes = Z.ya)(a);
|
|
2046
|
+
f._sqlite3_close_v2 = (a) => (f._sqlite3_close_v2 = Z.za)(a);
|
|
2047
|
+
f._sqlite3_create_function_v2 = (a, b, c, d, e, h, k, q, w) => (f._sqlite3_create_function_v2 = Z.Aa)(a, b, c, d, e, h, k, q, w);
|
|
2048
|
+
f._sqlite3_update_hook = (a, b, c) => (f._sqlite3_update_hook = Z.Ba)(a, b, c);
|
|
2049
|
+
f._sqlite3_open = (a, b) => (f._sqlite3_open = Z.Ca)(a, b);
|
|
2050
|
+
var ia = f._malloc = (a) => (ia = f._malloc = Z.Da)(a), fa = f._free = (a) => (fa = f._free = Z.Ea)(a);
|
|
2051
|
+
f._RegisterExtensionFunctions = (a) => (f._RegisterExtensionFunctions = Z.Fa)(a);
|
|
2052
|
+
var Db = (a, b) => (Db = Z.Ga)(a, b), Wc = (a, b) => (Wc = Z.Ha)(a, b), wa = (a) => (wa = Z.Ia)(a), z = (a) => (z = Z.Ja)(a), sa = () => (sa = Z.Ka)();
|
|
2053
|
+
f.stackSave = () => sa();
|
|
2054
|
+
f.stackRestore = (a) => wa(a);
|
|
2055
|
+
f.stackAlloc = (a) => z(a);
|
|
2056
|
+
f.cwrap = (a, b, c, d) => {
|
|
2057
|
+
var e = !c || c.every((h) => "number" === h || "boolean" === h);
|
|
2058
|
+
return "string" !== b && e && !d ? f["_" + a] : (...h) => Tc(a, b, c, h);
|
|
2059
|
+
};
|
|
2060
|
+
f.addFunction = Aa;
|
|
2061
|
+
f.removeFunction = A;
|
|
2062
|
+
f.UTF8ToString = ua;
|
|
2063
|
+
f.ALLOC_NORMAL = ea;
|
|
2064
|
+
f.allocate = da;
|
|
2065
|
+
f.allocateUTF8OnStack = xa;
|
|
2066
|
+
function Yc() {
|
|
2067
|
+
function a() {
|
|
2068
|
+
f.calledRun = true;
|
|
2069
|
+
if (!La) {
|
|
2070
|
+
if (!f.noFSInit && !Ib) {
|
|
2071
|
+
var b, c;
|
|
2072
|
+
Ib = true;
|
|
2073
|
+
d ??= f.stdin;
|
|
2074
|
+
b ??= f.stdout;
|
|
2075
|
+
c ??= f.stderr;
|
|
2076
|
+
d ? V("stdin", d) : Zb("/dev/tty", "/dev/stdin");
|
|
2077
|
+
b ? V("stdout", null, b) : Zb("/dev/tty", "/dev/stdout");
|
|
2078
|
+
c ? V("stderr", null, c) : Zb("/dev/tty1", "/dev/stderr");
|
|
2079
|
+
oa("/dev/stdin", 0);
|
|
2080
|
+
oa("/dev/stdout", 1);
|
|
2081
|
+
oa("/dev/stderr", 1);
|
|
2082
|
+
}
|
|
2083
|
+
Z.N();
|
|
2084
|
+
Jb = false;
|
|
2085
|
+
f.onRuntimeInitialized?.();
|
|
2086
|
+
if (f.postRun) for ("function" == typeof f.postRun && (f.postRun = [f.postRun]); f.postRun.length; ) {
|
|
2087
|
+
var d = f.postRun.shift();
|
|
2088
|
+
$a.unshift(d);
|
|
2089
|
+
}
|
|
2090
|
+
Za($a);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
if (0 < K) Sa = Yc;
|
|
2094
|
+
else {
|
|
2095
|
+
if (f.preRun) for ("function" == typeof f.preRun && (f.preRun = [f.preRun]); f.preRun.length; ) bb();
|
|
2096
|
+
Za(ab);
|
|
2097
|
+
0 < K ? Sa = Yc : f.setStatus ? (f.setStatus("Running..."), setTimeout(() => {
|
|
2098
|
+
setTimeout(() => f.setStatus(""), 1);
|
|
2099
|
+
a();
|
|
2100
|
+
}, 1)) : a();
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
if (f.preInit) for ("function" == typeof f.preInit && (f.preInit = [f.preInit]); 0 < f.preInit.length; ) f.preInit.pop()();
|
|
2104
|
+
Yc();
|
|
2105
|
+
return Module;
|
|
2106
|
+
});
|
|
2107
|
+
return initSqlJsPromise;
|
|
2108
|
+
};
|
|
2109
|
+
if (typeof exports2 === "object" && typeof module2 === "object") {
|
|
2110
|
+
module2.exports = initSqlJs;
|
|
2111
|
+
module2.exports.default = initSqlJs;
|
|
2112
|
+
} else if (typeof define === "function" && define["amd"]) {
|
|
2113
|
+
define([], function() {
|
|
2114
|
+
return initSqlJs;
|
|
2115
|
+
});
|
|
2116
|
+
} else if (typeof exports2 === "object") {
|
|
2117
|
+
exports2["Module"] = initSqlJs;
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
});
|
|
2121
|
+
|
|
26
2122
|
// src/cli.ts
|
|
27
2123
|
var import_yargs = __toESM(require("yargs"), 1);
|
|
28
2124
|
var import_helpers = require("yargs/helpers");
|
|
29
|
-
var
|
|
2125
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
30
2126
|
|
|
31
2127
|
// src/indexer/workspaceIndexer.ts
|
|
32
|
-
var
|
|
2128
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
33
2129
|
|
|
34
2130
|
// src/util.ts
|
|
35
2131
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
@@ -2560,63 +4656,6 @@ var RepoIndexer = class {
|
|
|
2560
4656
|
}
|
|
2561
4657
|
};
|
|
2562
4658
|
|
|
2563
|
-
// src/profiles.ts
|
|
2564
|
-
var DEFAULT_PROFILES = {
|
|
2565
|
-
search: {
|
|
2566
|
-
name: "search",
|
|
2567
|
-
k: 10,
|
|
2568
|
-
weights: { vector: 0.65, lexical: 0.35, recency: 0 },
|
|
2569
|
-
expand: { adjacentChunks: 0, followImports: 0, includeFileSynopsis: false },
|
|
2570
|
-
candidates: { vectorK: 25, lexicalK: 25, maxMergedCandidates: 60 }
|
|
2571
|
-
},
|
|
2572
|
-
refactor: {
|
|
2573
|
-
name: "refactor",
|
|
2574
|
-
k: 15,
|
|
2575
|
-
weights: { vector: 0.55, lexical: 0.35, recency: 0.1 },
|
|
2576
|
-
expand: { adjacentChunks: 1, followImports: 2, includeFileSynopsis: true },
|
|
2577
|
-
candidates: { vectorK: 60, lexicalK: 40, maxMergedCandidates: 140 }
|
|
2578
|
-
},
|
|
2579
|
-
review: {
|
|
2580
|
-
name: "review",
|
|
2581
|
-
k: 20,
|
|
2582
|
-
weights: { vector: 0.45, lexical: 0.35, recency: 0.2 },
|
|
2583
|
-
expand: { adjacentChunks: 1, followImports: 1, includeFileSynopsis: true },
|
|
2584
|
-
candidates: { vectorK: 80, lexicalK: 60, maxMergedCandidates: 180 }
|
|
2585
|
-
},
|
|
2586
|
-
architecture: {
|
|
2587
|
-
name: "architecture",
|
|
2588
|
-
k: 20,
|
|
2589
|
-
weights: { vector: 0.7, lexical: 0.2, recency: 0.1 },
|
|
2590
|
-
expand: { adjacentChunks: 0, followImports: 3, includeFileSynopsis: true },
|
|
2591
|
-
candidates: { vectorK: 120, lexicalK: 40, maxMergedCandidates: 220 }
|
|
2592
|
-
},
|
|
2593
|
-
rca: {
|
|
2594
|
-
name: "rca",
|
|
2595
|
-
k: 25,
|
|
2596
|
-
weights: { vector: 0.5, lexical: 0.25, recency: 0.25 },
|
|
2597
|
-
expand: { adjacentChunks: 2, followImports: 1, includeFileSynopsis: true },
|
|
2598
|
-
candidates: { vectorK: 140, lexicalK: 80, maxMergedCandidates: 260 }
|
|
2599
|
-
},
|
|
2600
|
-
custom: {
|
|
2601
|
-
name: "custom",
|
|
2602
|
-
k: 10,
|
|
2603
|
-
weights: { vector: 0.65, lexical: 0.35, recency: 0 },
|
|
2604
|
-
expand: { adjacentChunks: 0, followImports: 0, includeFileSynopsis: false },
|
|
2605
|
-
candidates: { vectorK: 25, lexicalK: 25, maxMergedCandidates: 60 }
|
|
2606
|
-
}
|
|
2607
|
-
};
|
|
2608
|
-
function deepMergeProfile(base, patch) {
|
|
2609
|
-
if (!patch) return base;
|
|
2610
|
-
const merged = {
|
|
2611
|
-
...base,
|
|
2612
|
-
...patch,
|
|
2613
|
-
weights: { ...base.weights, ...patch.weights ?? {} },
|
|
2614
|
-
expand: { ...base.expand, ...patch.expand ?? {} },
|
|
2615
|
-
candidates: { ...base.candidates, ...patch.candidates ?? {} }
|
|
2616
|
-
};
|
|
2617
|
-
return merged;
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
4659
|
// src/indexer/repoDiscovery.ts
|
|
2621
4660
|
var import_node_fs10 = __toESM(require("fs"), 1);
|
|
2622
4661
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
@@ -2780,8 +4819,8 @@ function mergeIndexerConfig(target, patch) {
|
|
|
2780
4819
|
}
|
|
2781
4820
|
|
|
2782
4821
|
// src/store/workspaceStore.ts
|
|
2783
|
-
var
|
|
2784
|
-
var
|
|
4822
|
+
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
4823
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
2785
4824
|
|
|
2786
4825
|
// src/store/workspace/unitOfWork.ts
|
|
2787
4826
|
var UnitOfWork = class {
|
|
@@ -3001,15 +5040,35 @@ var RepoLinksRepository = class {
|
|
|
3001
5040
|
};
|
|
3002
5041
|
|
|
3003
5042
|
// src/store/workspace/factory.ts
|
|
3004
|
-
var
|
|
3005
|
-
var
|
|
5043
|
+
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
5044
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
3006
5045
|
|
|
3007
5046
|
// src/store/workspace/db.ts
|
|
3008
5047
|
var import_better_sqlite33 = __toESM(require("better-sqlite3"), 1);
|
|
5048
|
+
var import_node_fs11 = __toESM(require("fs"), 1);
|
|
5049
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
5050
|
+
function detectFts5Support(db) {
|
|
5051
|
+
try {
|
|
5052
|
+
const rows = db.prepare(`PRAGMA compile_options`).all();
|
|
5053
|
+
if (rows.some((r) => String(r.compile_options ?? "").includes("ENABLE_FTS5"))) return true;
|
|
5054
|
+
} catch {
|
|
5055
|
+
}
|
|
5056
|
+
try {
|
|
5057
|
+
db.exec(`
|
|
5058
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS __fts5_probe USING fts5(x);
|
|
5059
|
+
DROP TABLE __fts5_probe;
|
|
5060
|
+
`);
|
|
5061
|
+
return true;
|
|
5062
|
+
} catch {
|
|
5063
|
+
return false;
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
3009
5066
|
var BetterSqlite3Adapter = class {
|
|
3010
5067
|
db;
|
|
5068
|
+
capabilities;
|
|
3011
5069
|
constructor(dbPath) {
|
|
3012
5070
|
this.db = new import_better_sqlite33.default(dbPath);
|
|
5071
|
+
this.capabilities = { supportsFts5: detectFts5Support(this.db) };
|
|
3013
5072
|
}
|
|
3014
5073
|
pragma(sql) {
|
|
3015
5074
|
this.db.pragma(sql);
|
|
@@ -3027,6 +5086,17 @@ var BetterSqlite3Adapter = class {
|
|
|
3027
5086
|
this.db.close();
|
|
3028
5087
|
}
|
|
3029
5088
|
};
|
|
5089
|
+
var betterSqlite3Adapter = {
|
|
5090
|
+
open(dbPath) {
|
|
5091
|
+
import_node_fs11.default.mkdirSync(import_node_path14.default.dirname(dbPath), { recursive: true });
|
|
5092
|
+
const db = new BetterSqlite3Adapter(dbPath);
|
|
5093
|
+
db.pragma("journal_mode = WAL");
|
|
5094
|
+
return db;
|
|
5095
|
+
}
|
|
5096
|
+
};
|
|
5097
|
+
|
|
5098
|
+
// src/store/workspace/fts5.sql
|
|
5099
|
+
var fts5_default = "CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(\n id UNINDEXED,\n repo_id UNINDEXED,\n repo_root UNINDEXED,\n path,\n language,\n kind,\n text,\n tokenize='unicode61'\n);\n\n";
|
|
3030
5100
|
|
|
3031
5101
|
// src/store/workspace/fts.ts
|
|
3032
5102
|
var NoopFtsStrategy = class {
|
|
@@ -3050,18 +5120,7 @@ var Fts5Strategy = class {
|
|
|
3050
5120
|
enabled = true;
|
|
3051
5121
|
ins = null;
|
|
3052
5122
|
init(db) {
|
|
3053
|
-
db.exec(
|
|
3054
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
|
|
3055
|
-
id UNINDEXED,
|
|
3056
|
-
repo_id UNINDEXED,
|
|
3057
|
-
repo_root UNINDEXED,
|
|
3058
|
-
path,
|
|
3059
|
-
language,
|
|
3060
|
-
kind,
|
|
3061
|
-
text,
|
|
3062
|
-
tokenize='unicode61'
|
|
3063
|
-
);
|
|
3064
|
-
`);
|
|
5123
|
+
db.exec(fts5_default);
|
|
3065
5124
|
}
|
|
3066
5125
|
clearRepo(repoId) {
|
|
3067
5126
|
this.db.prepare(`DELETE FROM chunks_fts WHERE repo_id = ?`).run(repoId);
|
|
@@ -3145,109 +5204,26 @@ var WorkspaceMigrator = class {
|
|
|
3145
5204
|
}
|
|
3146
5205
|
};
|
|
3147
5206
|
|
|
5207
|
+
// src/store/workspace/baseSchema.sql
|
|
5208
|
+
var baseSchema_default = "CREATE TABLE IF NOT EXISTS meta (\n k TEXT PRIMARY KEY,\n v TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS repos (\n repo_id TEXT PRIMARY KEY,\n repo_root TEXT NOT NULL,\n head_commit TEXT NOT NULL,\n head_branch TEXT NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS idx_repos_root ON repos(repo_root);\n\nCREATE TABLE IF NOT EXISTS files (\n repo_id TEXT NOT NULL,\n path TEXT NOT NULL,\n hash TEXT NOT NULL,\n mtime INTEGER NOT NULL,\n language TEXT NOT NULL,\n size INTEGER NOT NULL,\n PRIMARY KEY(repo_id, path)\n);\n\nCREATE INDEX IF NOT EXISTS idx_files_repo ON files(repo_id);\n\nCREATE TABLE IF NOT EXISTS chunks (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n repo_root TEXT NOT NULL,\n path TEXT NOT NULL,\n language TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'chunk',\n start_line INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n content_hash TEXT NOT NULL,\n tokens INTEGER NOT NULL,\n file_mtime INTEGER NOT NULL,\n text TEXT NOT NULL,\n embedding BLOB NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_chunks_repo_path ON chunks(repo_id, path);\nCREATE INDEX IF NOT EXISTS idx_chunks_kind_repo_path ON chunks(kind, repo_id, path);\n\nCREATE TABLE IF NOT EXISTS edges (\n repo_id TEXT NOT NULL,\n from_path TEXT NOT NULL,\n kind TEXT NOT NULL,\n value TEXT NOT NULL,\n PRIMARY KEY(repo_id, from_path, kind, value)\n);\n\nCREATE INDEX IF NOT EXISTS idx_edges_repo_from ON edges(repo_id, from_path);\n\nCREATE TABLE IF NOT EXISTS symbols (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n repo_root TEXT NOT NULL,\n path TEXT NOT NULL,\n language TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL,\n start_line INTEGER NOT NULL,\n start_char INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n end_char INTEGER NOT NULL,\n container_name TEXT NOT NULL DEFAULT '',\n detail TEXT NOT NULL DEFAULT ''\n);\n\nCREATE INDEX IF NOT EXISTS idx_symbols_repo_path ON symbols(repo_id, path);\nCREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);\n\nCREATE TABLE IF NOT EXISTS symbol_edges (\n repo_id TEXT NOT NULL,\n from_id TEXT NOT NULL,\n to_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n from_path TEXT NOT NULL,\n to_path TEXT NOT NULL,\n PRIMARY KEY(repo_id, from_id, to_id, kind)\n);\n\nCREATE INDEX IF NOT EXISTS idx_symbol_edges_from ON symbol_edges(repo_id, from_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_edges_paths ON symbol_edges(repo_id, from_path);\n\n";
|
|
5209
|
+
|
|
3148
5210
|
// src/store/workspace/factory.ts
|
|
3149
|
-
function createWorkspaceDb(dbPath) {
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
db.pragma("journal_mode = WAL");
|
|
3153
|
-
return db;
|
|
5211
|
+
function createWorkspaceDb(dbPath, opts = {}) {
|
|
5212
|
+
import_node_fs12.default.mkdirSync(import_node_path15.default.dirname(dbPath), { recursive: true });
|
|
5213
|
+
return (opts.db ?? betterSqlite3Adapter).open(dbPath);
|
|
3154
5214
|
}
|
|
3155
5215
|
function createWorkspaceBaseSchema(db) {
|
|
3156
|
-
db.exec(
|
|
3157
|
-
CREATE TABLE IF NOT EXISTS meta (
|
|
3158
|
-
k TEXT PRIMARY KEY,
|
|
3159
|
-
v TEXT NOT NULL
|
|
3160
|
-
);
|
|
3161
|
-
|
|
3162
|
-
CREATE TABLE IF NOT EXISTS repos (
|
|
3163
|
-
repo_id TEXT PRIMARY KEY,
|
|
3164
|
-
repo_root TEXT NOT NULL,
|
|
3165
|
-
head_commit TEXT NOT NULL,
|
|
3166
|
-
head_branch TEXT NOT NULL,
|
|
3167
|
-
updated_at INTEGER NOT NULL
|
|
3168
|
-
);
|
|
3169
|
-
|
|
3170
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_repos_root ON repos(repo_root);
|
|
3171
|
-
|
|
3172
|
-
CREATE TABLE IF NOT EXISTS files (
|
|
3173
|
-
repo_id TEXT NOT NULL,
|
|
3174
|
-
path TEXT NOT NULL,
|
|
3175
|
-
hash TEXT NOT NULL,
|
|
3176
|
-
mtime INTEGER NOT NULL,
|
|
3177
|
-
language TEXT NOT NULL,
|
|
3178
|
-
size INTEGER NOT NULL,
|
|
3179
|
-
PRIMARY KEY(repo_id, path)
|
|
3180
|
-
);
|
|
3181
|
-
|
|
3182
|
-
CREATE INDEX IF NOT EXISTS idx_files_repo ON files(repo_id);
|
|
3183
|
-
|
|
3184
|
-
CREATE TABLE IF NOT EXISTS chunks (
|
|
3185
|
-
id TEXT PRIMARY KEY,
|
|
3186
|
-
repo_id TEXT NOT NULL,
|
|
3187
|
-
repo_root TEXT NOT NULL,
|
|
3188
|
-
path TEXT NOT NULL,
|
|
3189
|
-
language TEXT NOT NULL,
|
|
3190
|
-
kind TEXT NOT NULL DEFAULT 'chunk',
|
|
3191
|
-
start_line INTEGER NOT NULL,
|
|
3192
|
-
end_line INTEGER NOT NULL,
|
|
3193
|
-
content_hash TEXT NOT NULL,
|
|
3194
|
-
tokens INTEGER NOT NULL,
|
|
3195
|
-
file_mtime INTEGER NOT NULL,
|
|
3196
|
-
text TEXT NOT NULL,
|
|
3197
|
-
embedding BLOB NOT NULL
|
|
3198
|
-
);
|
|
3199
|
-
|
|
3200
|
-
CREATE INDEX IF NOT EXISTS idx_chunks_repo_path ON chunks(repo_id, path);
|
|
3201
|
-
CREATE INDEX IF NOT EXISTS idx_chunks_kind_repo_path ON chunks(kind, repo_id, path);
|
|
3202
|
-
|
|
3203
|
-
CREATE TABLE IF NOT EXISTS edges (
|
|
3204
|
-
repo_id TEXT NOT NULL,
|
|
3205
|
-
from_path TEXT NOT NULL,
|
|
3206
|
-
kind TEXT NOT NULL,
|
|
3207
|
-
value TEXT NOT NULL,
|
|
3208
|
-
PRIMARY KEY(repo_id, from_path, kind, value)
|
|
3209
|
-
);
|
|
3210
|
-
|
|
3211
|
-
CREATE INDEX IF NOT EXISTS idx_edges_repo_from ON edges(repo_id, from_path);
|
|
3212
|
-
|
|
3213
|
-
CREATE TABLE IF NOT EXISTS symbols (
|
|
3214
|
-
id TEXT PRIMARY KEY,
|
|
3215
|
-
repo_id TEXT NOT NULL,
|
|
3216
|
-
repo_root TEXT NOT NULL,
|
|
3217
|
-
path TEXT NOT NULL,
|
|
3218
|
-
language TEXT NOT NULL,
|
|
3219
|
-
name TEXT NOT NULL,
|
|
3220
|
-
kind TEXT NOT NULL,
|
|
3221
|
-
start_line INTEGER NOT NULL,
|
|
3222
|
-
start_char INTEGER NOT NULL,
|
|
3223
|
-
end_line INTEGER NOT NULL,
|
|
3224
|
-
end_char INTEGER NOT NULL,
|
|
3225
|
-
container_name TEXT NOT NULL DEFAULT '',
|
|
3226
|
-
detail TEXT NOT NULL DEFAULT ''
|
|
3227
|
-
);
|
|
3228
|
-
|
|
3229
|
-
CREATE INDEX IF NOT EXISTS idx_symbols_repo_path ON symbols(repo_id, path);
|
|
3230
|
-
CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
|
|
3231
|
-
|
|
3232
|
-
CREATE TABLE IF NOT EXISTS symbol_edges (
|
|
3233
|
-
repo_id TEXT NOT NULL,
|
|
3234
|
-
from_id TEXT NOT NULL,
|
|
3235
|
-
to_id TEXT NOT NULL,
|
|
3236
|
-
kind TEXT NOT NULL,
|
|
3237
|
-
from_path TEXT NOT NULL,
|
|
3238
|
-
to_path TEXT NOT NULL,
|
|
3239
|
-
PRIMARY KEY(repo_id, from_id, to_id, kind)
|
|
3240
|
-
);
|
|
3241
|
-
|
|
3242
|
-
CREATE INDEX IF NOT EXISTS idx_symbol_edges_from ON symbol_edges(repo_id, from_id);
|
|
3243
|
-
CREATE INDEX IF NOT EXISTS idx_symbol_edges_paths ON symbol_edges(repo_id, from_path);
|
|
3244
|
-
`);
|
|
5216
|
+
db.exec(baseSchema_default);
|
|
3245
5217
|
}
|
|
3246
5218
|
function createWorkspaceFts(db, meta, opts = {}) {
|
|
3247
5219
|
if (opts.fts === "off") {
|
|
3248
5220
|
meta.set("fts", "0");
|
|
3249
5221
|
return new NoopFtsStrategy();
|
|
3250
5222
|
}
|
|
5223
|
+
if (!db.capabilities.supportsFts5) {
|
|
5224
|
+
meta.set("fts", "0");
|
|
5225
|
+
return new NoopFtsStrategy();
|
|
5226
|
+
}
|
|
3251
5227
|
try {
|
|
3252
5228
|
const fts = new Fts5Strategy(db);
|
|
3253
5229
|
fts.init(db);
|
|
@@ -3263,17 +5239,131 @@ function migrateWorkspaceDb(db, meta) {
|
|
|
3263
5239
|
migrator.migrateToLatest();
|
|
3264
5240
|
}
|
|
3265
5241
|
|
|
5242
|
+
// src/store/workspace/sqlJsAdapter.ts
|
|
5243
|
+
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
5244
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
5245
|
+
function detectFts5Support2(db) {
|
|
5246
|
+
try {
|
|
5247
|
+
db.exec(`
|
|
5248
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS __fts5_probe USING fts5(x);
|
|
5249
|
+
DROP TABLE __fts5_probe;
|
|
5250
|
+
`);
|
|
5251
|
+
return true;
|
|
5252
|
+
} catch {
|
|
5253
|
+
return false;
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
var SqlJsStatement = class {
|
|
5257
|
+
constructor(stmt) {
|
|
5258
|
+
this.stmt = stmt;
|
|
5259
|
+
}
|
|
5260
|
+
run(...args) {
|
|
5261
|
+
this.stmt.run(args);
|
|
5262
|
+
return void 0;
|
|
5263
|
+
}
|
|
5264
|
+
get(...args) {
|
|
5265
|
+
this.stmt.bind(args);
|
|
5266
|
+
const hasRow = this.stmt.step();
|
|
5267
|
+
if (!hasRow) {
|
|
5268
|
+
this.stmt.reset();
|
|
5269
|
+
return void 0;
|
|
5270
|
+
}
|
|
5271
|
+
const row = this.stmt.getAsObject();
|
|
5272
|
+
this.stmt.reset();
|
|
5273
|
+
return row;
|
|
5274
|
+
}
|
|
5275
|
+
all(...args) {
|
|
5276
|
+
this.stmt.bind(args);
|
|
5277
|
+
const rows = [];
|
|
5278
|
+
while (this.stmt.step()) rows.push(this.stmt.getAsObject());
|
|
5279
|
+
this.stmt.reset();
|
|
5280
|
+
return rows;
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
var SqlJsDbAdapter = class {
|
|
5284
|
+
constructor(db, dbPath) {
|
|
5285
|
+
this.db = db;
|
|
5286
|
+
this.dbPath = dbPath;
|
|
5287
|
+
this.capabilities = { supportsFts5: detectFts5Support2(db) };
|
|
5288
|
+
}
|
|
5289
|
+
capabilities;
|
|
5290
|
+
pragma(sql) {
|
|
5291
|
+
this.exec(`PRAGMA ${sql}`);
|
|
5292
|
+
}
|
|
5293
|
+
exec(sql) {
|
|
5294
|
+
this.db.exec(sql);
|
|
5295
|
+
}
|
|
5296
|
+
prepare(sql) {
|
|
5297
|
+
return new SqlJsStatement(this.db.prepare(sql));
|
|
5298
|
+
}
|
|
5299
|
+
transaction(fn) {
|
|
5300
|
+
return () => {
|
|
5301
|
+
this.db.exec("BEGIN");
|
|
5302
|
+
try {
|
|
5303
|
+
const out = fn();
|
|
5304
|
+
this.db.exec("COMMIT");
|
|
5305
|
+
return out;
|
|
5306
|
+
} catch (e) {
|
|
5307
|
+
try {
|
|
5308
|
+
this.db.exec("ROLLBACK");
|
|
5309
|
+
} catch {
|
|
5310
|
+
}
|
|
5311
|
+
throw e;
|
|
5312
|
+
}
|
|
5313
|
+
};
|
|
5314
|
+
}
|
|
5315
|
+
close() {
|
|
5316
|
+
if (this.dbPath && this.dbPath !== ":memory:") {
|
|
5317
|
+
import_node_fs13.default.mkdirSync(import_node_path16.default.dirname(this.dbPath), { recursive: true });
|
|
5318
|
+
const bytes = this.db.export();
|
|
5319
|
+
import_node_fs13.default.writeFileSync(this.dbPath, Buffer.from(bytes));
|
|
5320
|
+
}
|
|
5321
|
+
this.db.close();
|
|
5322
|
+
}
|
|
5323
|
+
};
|
|
5324
|
+
async function sqlJsAdapter(opts = {}) {
|
|
5325
|
+
let init;
|
|
5326
|
+
try {
|
|
5327
|
+
const mod = await Promise.resolve().then(() => __toESM(require_sql_wasm(), 1));
|
|
5328
|
+
init = mod?.default ?? mod;
|
|
5329
|
+
} catch (e) {
|
|
5330
|
+
throw new Error(`sqlJsAdapter requires optional dependency 'sql.js' (install it to use this adapter): ${String(e?.message ?? e)}`);
|
|
5331
|
+
}
|
|
5332
|
+
const SQL = await init({ locateFile: opts.locateFile, wasmBinary: opts.wasmBinary });
|
|
5333
|
+
return {
|
|
5334
|
+
open(dbPath) {
|
|
5335
|
+
const abs = import_node_path16.default.resolve(dbPath);
|
|
5336
|
+
const exists = import_node_fs13.default.existsSync(abs);
|
|
5337
|
+
const bytes = exists ? new Uint8Array(import_node_fs13.default.readFileSync(abs)) : void 0;
|
|
5338
|
+
const db = bytes ? new SQL.Database(bytes) : new SQL.Database();
|
|
5339
|
+
return new SqlJsDbAdapter(db, abs);
|
|
5340
|
+
}
|
|
5341
|
+
};
|
|
5342
|
+
}
|
|
5343
|
+
|
|
3266
5344
|
// src/store/workspaceStore.ts
|
|
5345
|
+
async function defaultWorkspaceDbFactory() {
|
|
5346
|
+
try {
|
|
5347
|
+
return await sqlJsAdapter();
|
|
5348
|
+
} catch {
|
|
5349
|
+
return betterSqlite3Adapter;
|
|
5350
|
+
}
|
|
5351
|
+
}
|
|
5352
|
+
async function createWorkspaceStoreAsync(dbPath, opts = {}) {
|
|
5353
|
+
const dbFactory = opts.db ? await Promise.resolve(opts.db) : await defaultWorkspaceDbFactory();
|
|
5354
|
+
return new WorkspaceStore(dbPath, { ...opts, db: dbFactory });
|
|
5355
|
+
}
|
|
3267
5356
|
var WorkspaceStore = class {
|
|
3268
5357
|
constructor(dbPath, opts = {}) {
|
|
3269
5358
|
this.dbPath = dbPath;
|
|
3270
5359
|
this.opts = opts;
|
|
3271
|
-
this.db = createWorkspaceDb(dbPath);
|
|
5360
|
+
this.db = createWorkspaceDb(dbPath, { db: opts.db });
|
|
3272
5361
|
this.uow = new UnitOfWork(this.db);
|
|
3273
5362
|
createWorkspaceBaseSchema(this.db);
|
|
3274
5363
|
this.meta = new MetaRepository(this.db);
|
|
3275
5364
|
migrateWorkspaceDb(this.db, this.meta);
|
|
3276
5365
|
const fts = createWorkspaceFts(this.db, this.meta, opts);
|
|
5366
|
+
this.ftsEnabledInternal = fts.enabled;
|
|
3277
5367
|
this.repoHeads = new RepoHeadsRepository(this.db);
|
|
3278
5368
|
this.files = new FilesRepository(this.db);
|
|
3279
5369
|
this.edges = new EdgesRepository(this.db);
|
|
@@ -3283,6 +5373,7 @@ var WorkspaceStore = class {
|
|
|
3283
5373
|
}
|
|
3284
5374
|
db;
|
|
3285
5375
|
uow;
|
|
5376
|
+
ftsEnabledInternal;
|
|
3286
5377
|
meta;
|
|
3287
5378
|
repoHeads;
|
|
3288
5379
|
files;
|
|
@@ -3291,6 +5382,9 @@ var WorkspaceStore = class {
|
|
|
3291
5382
|
symbols;
|
|
3292
5383
|
chunks;
|
|
3293
5384
|
opts;
|
|
5385
|
+
get ftsEnabled() {
|
|
5386
|
+
return this.ftsEnabledInternal;
|
|
5387
|
+
}
|
|
3294
5388
|
setMeta(k, v) {
|
|
3295
5389
|
this.meta.set(k, v);
|
|
3296
5390
|
}
|
|
@@ -3374,9 +5468,9 @@ var WorkspaceStore = class {
|
|
|
3374
5468
|
* The chunk boundaries are approximate; the stored row includes start/end line.
|
|
3375
5469
|
*/
|
|
3376
5470
|
getChunkTextFallback(row) {
|
|
3377
|
-
const abs =
|
|
5471
|
+
const abs = import_node_path17.default.join(row.repo_root, row.path.split("/").join(import_node_path17.default.sep));
|
|
3378
5472
|
try {
|
|
3379
|
-
const raw =
|
|
5473
|
+
const raw = import_node_fs14.default.readFileSync(abs, "utf8");
|
|
3380
5474
|
const lines = raw.split(/\r?\n/);
|
|
3381
5475
|
const start = Math.max(1, row.start_line);
|
|
3382
5476
|
const end = Math.max(start, row.end_line);
|
|
@@ -3847,11 +5941,11 @@ ${hint}`);
|
|
|
3847
5941
|
}
|
|
3848
5942
|
|
|
3849
5943
|
// src/indexer/workspaceLinker.ts
|
|
3850
|
-
var
|
|
3851
|
-
var
|
|
5944
|
+
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
5945
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
3852
5946
|
function readText(absPath) {
|
|
3853
5947
|
try {
|
|
3854
|
-
return
|
|
5948
|
+
return import_node_fs15.default.readFileSync(absPath, "utf8");
|
|
3855
5949
|
} catch {
|
|
3856
5950
|
return null;
|
|
3857
5951
|
}
|
|
@@ -3881,7 +5975,7 @@ var NestedRepoLinkStrategy = class {
|
|
|
3881
5975
|
for (const child of sorted) {
|
|
3882
5976
|
for (const parent of sorted) {
|
|
3883
5977
|
if (child.repoId === parent.repoId) continue;
|
|
3884
|
-
if (child.absRoot.startsWith(parent.absRoot +
|
|
5978
|
+
if (child.absRoot.startsWith(parent.absRoot + import_node_path18.default.sep)) {
|
|
3885
5979
|
out.push({
|
|
3886
5980
|
fromRepoId: child.repoId,
|
|
3887
5981
|
toRepoId: parent.repoId,
|
|
@@ -3901,7 +5995,7 @@ var NpmDependencyLinkStrategy = class {
|
|
|
3901
5995
|
const out = [];
|
|
3902
5996
|
const depSections = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
3903
5997
|
for (const r of ctx.repos) {
|
|
3904
|
-
const pkg = readJson(
|
|
5998
|
+
const pkg = readJson(import_node_path18.default.join(r.absRoot, "package.json"));
|
|
3905
5999
|
if (!pkg) continue;
|
|
3906
6000
|
for (const sec of depSections) {
|
|
3907
6001
|
const deps = pkg?.[sec];
|
|
@@ -3919,13 +6013,13 @@ var NpmDependencyLinkStrategy = class {
|
|
|
3919
6013
|
}
|
|
3920
6014
|
};
|
|
3921
6015
|
function parseGoModule(absRepoRoot) {
|
|
3922
|
-
const raw = readText(
|
|
6016
|
+
const raw = readText(import_node_path18.default.join(absRepoRoot, "go.mod"));
|
|
3923
6017
|
if (!raw) return null;
|
|
3924
6018
|
const m = raw.match(/^\s*module\s+(.+)\s*$/m);
|
|
3925
6019
|
return m ? String(m[1]).trim() : null;
|
|
3926
6020
|
}
|
|
3927
6021
|
function parseGoRequires(absRepoRoot) {
|
|
3928
|
-
const raw = readText(
|
|
6022
|
+
const raw = readText(import_node_path18.default.join(absRepoRoot, "go.mod"));
|
|
3929
6023
|
if (!raw) return [];
|
|
3930
6024
|
const out = [];
|
|
3931
6025
|
for (const line of raw.split(/\r?\n/)) {
|
|
@@ -3965,13 +6059,13 @@ function walkFiles(root, opts, onFile) {
|
|
|
3965
6059
|
if (depth > maxDepth) return;
|
|
3966
6060
|
let ents = [];
|
|
3967
6061
|
try {
|
|
3968
|
-
ents =
|
|
6062
|
+
ents = import_node_fs15.default.readdirSync(dir, { withFileTypes: true });
|
|
3969
6063
|
} catch {
|
|
3970
6064
|
return;
|
|
3971
6065
|
}
|
|
3972
6066
|
for (const e of ents) {
|
|
3973
6067
|
if (seen >= maxFiles) return;
|
|
3974
|
-
const abs =
|
|
6068
|
+
const abs = import_node_path18.default.join(dir, e.name);
|
|
3975
6069
|
if (opts.shouldVisit && !opts.shouldVisit(abs, e)) continue;
|
|
3976
6070
|
if (e.isDirectory()) {
|
|
3977
6071
|
if (isSkippableDir(e.name)) continue;
|
|
@@ -3995,7 +6089,7 @@ function collectVsCodeLanguagesForRepo(absRepoRoot) {
|
|
|
3995
6089
|
shouldVisit: (_abs, dirent) => !(dirent.isDirectory() && isSkippableDir(dirent.name))
|
|
3996
6090
|
},
|
|
3997
6091
|
(absPath) => {
|
|
3998
|
-
if (
|
|
6092
|
+
if (import_node_path18.default.basename(absPath) !== "package.json") return;
|
|
3999
6093
|
const pkg = readJson(absPath);
|
|
4000
6094
|
const langs = pkg?.contributes?.languages;
|
|
4001
6095
|
if (!Array.isArray(langs)) return;
|
|
@@ -4024,7 +6118,7 @@ function repoUsedExtensions(absRepoRoot, exts) {
|
|
|
4024
6118
|
shouldVisit: (_abs, dirent) => !(dirent.isDirectory() && isSkippableDir(dirent.name))
|
|
4025
6119
|
},
|
|
4026
6120
|
(absPath) => {
|
|
4027
|
-
const ext =
|
|
6121
|
+
const ext = import_node_path18.default.extname(absPath).toLowerCase();
|
|
4028
6122
|
if (!ext) return;
|
|
4029
6123
|
if (exts.has(ext)) used.add(ext);
|
|
4030
6124
|
}
|
|
@@ -4096,12 +6190,12 @@ var WorkspaceLinker = class _WorkspaceLinker {
|
|
|
4096
6190
|
const repos = repoRoots.map((repoRoot) => ({
|
|
4097
6191
|
repoRoot,
|
|
4098
6192
|
repoId: repoIdFromRoot(repoRoot),
|
|
4099
|
-
absRoot:
|
|
6193
|
+
absRoot: import_node_path18.default.resolve(repoRoot)
|
|
4100
6194
|
}));
|
|
4101
6195
|
const npmNameToRepoId = /* @__PURE__ */ new Map();
|
|
4102
6196
|
const goModuleToRepoId = /* @__PURE__ */ new Map();
|
|
4103
6197
|
for (const r of repos) {
|
|
4104
|
-
const pkg = readJson(
|
|
6198
|
+
const pkg = readJson(import_node_path18.default.join(r.absRoot, "package.json"));
|
|
4105
6199
|
const name = typeof pkg?.name === "string" ? pkg.name : null;
|
|
4106
6200
|
if (name) npmNameToRepoId.set(name, r.repoId);
|
|
4107
6201
|
const mod = parseGoModule(r.absRoot);
|
|
@@ -4145,13 +6239,264 @@ async function linkWorkspaceRepos(args) {
|
|
|
4145
6239
|
return { repos: ctx.repos, links };
|
|
4146
6240
|
}
|
|
4147
6241
|
|
|
4148
|
-
// src/indexer/
|
|
6242
|
+
// src/indexer/workspaceRetrieveCandidates.ts
|
|
6243
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
6244
|
+
|
|
6245
|
+
// src/profiles.ts
|
|
6246
|
+
var DEFAULT_PROFILES = {
|
|
6247
|
+
search: {
|
|
6248
|
+
name: "search",
|
|
6249
|
+
k: 10,
|
|
6250
|
+
weights: { vector: 0.65, lexical: 0.35, recency: 0 },
|
|
6251
|
+
expand: { adjacentChunks: 0, followImports: 0, includeFileSynopsis: false },
|
|
6252
|
+
candidates: { vectorK: 25, lexicalK: 25, maxMergedCandidates: 60 }
|
|
6253
|
+
},
|
|
6254
|
+
refactor: {
|
|
6255
|
+
name: "refactor",
|
|
6256
|
+
k: 15,
|
|
6257
|
+
weights: { vector: 0.55, lexical: 0.35, recency: 0.1 },
|
|
6258
|
+
expand: { adjacentChunks: 1, followImports: 2, includeFileSynopsis: true },
|
|
6259
|
+
candidates: { vectorK: 60, lexicalK: 40, maxMergedCandidates: 140 }
|
|
6260
|
+
},
|
|
6261
|
+
review: {
|
|
6262
|
+
name: "review",
|
|
6263
|
+
k: 20,
|
|
6264
|
+
weights: { vector: 0.45, lexical: 0.35, recency: 0.2 },
|
|
6265
|
+
expand: { adjacentChunks: 1, followImports: 1, includeFileSynopsis: true },
|
|
6266
|
+
candidates: { vectorK: 80, lexicalK: 60, maxMergedCandidates: 180 }
|
|
6267
|
+
},
|
|
6268
|
+
architecture: {
|
|
6269
|
+
name: "architecture",
|
|
6270
|
+
k: 20,
|
|
6271
|
+
weights: { vector: 0.7, lexical: 0.2, recency: 0.1 },
|
|
6272
|
+
expand: { adjacentChunks: 0, followImports: 3, includeFileSynopsis: true },
|
|
6273
|
+
candidates: { vectorK: 120, lexicalK: 40, maxMergedCandidates: 220 }
|
|
6274
|
+
},
|
|
6275
|
+
rca: {
|
|
6276
|
+
name: "rca",
|
|
6277
|
+
k: 25,
|
|
6278
|
+
weights: { vector: 0.5, lexical: 0.25, recency: 0.25 },
|
|
6279
|
+
expand: { adjacentChunks: 2, followImports: 1, includeFileSynopsis: true },
|
|
6280
|
+
candidates: { vectorK: 140, lexicalK: 80, maxMergedCandidates: 260 }
|
|
6281
|
+
},
|
|
6282
|
+
custom: {
|
|
6283
|
+
name: "custom",
|
|
6284
|
+
k: 10,
|
|
6285
|
+
weights: { vector: 0.65, lexical: 0.35, recency: 0 },
|
|
6286
|
+
expand: { adjacentChunks: 0, followImports: 0, includeFileSynopsis: false },
|
|
6287
|
+
candidates: { vectorK: 25, lexicalK: 25, maxMergedCandidates: 60 }
|
|
6288
|
+
}
|
|
6289
|
+
};
|
|
6290
|
+
function deepMergeProfile(base, patch) {
|
|
6291
|
+
if (!patch) return base;
|
|
6292
|
+
const merged = {
|
|
6293
|
+
...base,
|
|
6294
|
+
...patch,
|
|
6295
|
+
weights: { ...base.weights, ...patch.weights ?? {} },
|
|
6296
|
+
expand: { ...base.expand, ...patch.expand ?? {} },
|
|
6297
|
+
candidates: { ...base.candidates, ...patch.candidates ?? {} }
|
|
6298
|
+
};
|
|
6299
|
+
return merged;
|
|
6300
|
+
}
|
|
6301
|
+
|
|
6302
|
+
// src/indexer/workspaceRetrieveCandidates.ts
|
|
6303
|
+
function resolveWorkspaceProfile(config, opts) {
|
|
6304
|
+
const name = opts?.profile ?? "search";
|
|
6305
|
+
const base = DEFAULT_PROFILES[name] ?? DEFAULT_PROFILES.search;
|
|
6306
|
+
const configPatch = config.profiles?.[name] ?? {};
|
|
6307
|
+
const merged1 = deepMergeProfile(base, configPatch);
|
|
6308
|
+
const merged2 = deepMergeProfile(merged1, opts?.profileOverrides);
|
|
6309
|
+
const w = merged2.weights;
|
|
6310
|
+
const sum = Math.max(1e-6, w.vector + w.lexical + w.recency);
|
|
6311
|
+
merged2.weights = { vector: w.vector / sum, lexical: w.lexical / sum, recency: w.recency / sum };
|
|
6312
|
+
return merged2;
|
|
6313
|
+
}
|
|
4149
6314
|
function halfLifeDaysForProfile(profileName) {
|
|
4150
6315
|
if (profileName === "rca") return 7;
|
|
4151
6316
|
if (profileName === "review") return 14;
|
|
4152
6317
|
if (profileName === "refactor") return 21;
|
|
4153
6318
|
return 30;
|
|
4154
6319
|
}
|
|
6320
|
+
function buildWorkspaceLexByRepoRoot(args) {
|
|
6321
|
+
const { workspaceStore, repos, query, lexicalK, repoFilters } = args;
|
|
6322
|
+
const ftq = ftsQueryFromText(query);
|
|
6323
|
+
if (!ftq) return { lexByRepoRoot: /* @__PURE__ */ new Map(), count: 0 };
|
|
6324
|
+
const allowRoots = repoFilters ? new Set(repoFilters.map((r) => import_node_path19.default.resolve(r))) : null;
|
|
6325
|
+
const repoIds = allowRoots ? repos.filter((r) => allowRoots.has(import_node_path19.default.resolve(r.repoRoot))).map((r) => r.repoId) : void 0;
|
|
6326
|
+
const rows = workspaceStore.searchFts(ftq, lexicalK, repoIds);
|
|
6327
|
+
const lexByRepoRoot = /* @__PURE__ */ new Map();
|
|
6328
|
+
for (const r of rows) {
|
|
6329
|
+
const row = workspaceStore.getChunkById(r.id);
|
|
6330
|
+
if (!row) continue;
|
|
6331
|
+
const rootKey = import_node_path19.default.resolve(row.repo_root);
|
|
6332
|
+
const arr = lexByRepoRoot.get(rootKey) ?? [];
|
|
6333
|
+
arr.push({ id: r.id, score: bm25ToScore01(r.bm25) });
|
|
6334
|
+
lexByRepoRoot.set(rootKey, arr);
|
|
6335
|
+
}
|
|
6336
|
+
return { lexByRepoRoot, count: rows.length };
|
|
6337
|
+
}
|
|
6338
|
+
async function collectWorkspaceCandidates(args) {
|
|
6339
|
+
const { repos, qVec, query, vectorK, lexicalK, profile, opts, lexByRepoRoot, canUseWorkspaceLex } = args;
|
|
6340
|
+
const repoFilters = opts.filters?.repoRoots;
|
|
6341
|
+
const langFilter = opts.filters?.language;
|
|
6342
|
+
const pathPrefix = opts.filters?.pathPrefix;
|
|
6343
|
+
const candidates = [];
|
|
6344
|
+
let vecCount = 0;
|
|
6345
|
+
let lexCount = 0;
|
|
6346
|
+
for (const repo of repos) {
|
|
6347
|
+
if (repoFilters && !repoFilters.includes(repo.repoRoot)) continue;
|
|
6348
|
+
let includePaths = opts.scope?.includePaths?.slice();
|
|
6349
|
+
if (opts.scope?.changedOnly) {
|
|
6350
|
+
try {
|
|
6351
|
+
const changed = await listChangedFiles(repo.repoRoot, opts.scope.baseRef ?? "HEAD~1");
|
|
6352
|
+
includePaths = includePaths ? includePaths.filter((p) => changed.includes(p)) : changed;
|
|
6353
|
+
} catch {
|
|
6354
|
+
}
|
|
6355
|
+
}
|
|
6356
|
+
const [vHits, lHits] = await Promise.all([
|
|
6357
|
+
repo.vectorCandidates(qVec, vectorK, includePaths),
|
|
6358
|
+
canUseWorkspaceLex ? Promise.resolve(lexByRepoRoot?.get(import_node_path19.default.resolve(repo.repoRoot)) ?? []) : repo.lexicalCandidates(query, lexicalK, includePaths)
|
|
6359
|
+
]);
|
|
6360
|
+
vecCount += vHits.length;
|
|
6361
|
+
if (!canUseWorkspaceLex) lexCount += lHits.length;
|
|
6362
|
+
const m = /* @__PURE__ */ new Map();
|
|
6363
|
+
for (const vh of vHits) {
|
|
6364
|
+
const id = vh.id;
|
|
6365
|
+
const vector01 = vectorCosineToScore01(vh.score);
|
|
6366
|
+
m.set(id, { repo, id, vector01, combined: 0 });
|
|
6367
|
+
}
|
|
6368
|
+
for (const lh of lHits) {
|
|
6369
|
+
const id = lh.id;
|
|
6370
|
+
const prev = m.get(id);
|
|
6371
|
+
if (prev) prev.lexical01 = lh.score;
|
|
6372
|
+
else m.set(id, { repo, id, lexical01: lh.score, combined: 0 });
|
|
6373
|
+
}
|
|
6374
|
+
const halfLife = halfLifeDaysForProfile(profile.name);
|
|
6375
|
+
for (const c of m.values()) {
|
|
6376
|
+
const meta = repo.getChunkMeta(c.id);
|
|
6377
|
+
if (!meta) continue;
|
|
6378
|
+
if (langFilter && meta.language !== langFilter) continue;
|
|
6379
|
+
if (pathPrefix && !meta.path.startsWith(pathPrefix)) continue;
|
|
6380
|
+
c.recency01 = profile.weights.recency > 0 ? recencyScore(meta.fileMtimeMs, halfLife) : 0;
|
|
6381
|
+
let kindFactor = 1;
|
|
6382
|
+
if (meta.kind === "synopsis" && profile.name === "search") kindFactor = 0.85;
|
|
6383
|
+
if (meta.kind === "synopsis" && profile.name === "architecture") kindFactor = 1.05;
|
|
6384
|
+
const v = c.vector01 ?? 0;
|
|
6385
|
+
const l = c.lexical01 ?? 0;
|
|
6386
|
+
const r = c.recency01 ?? 0;
|
|
6387
|
+
c.combined = clamp(kindFactor * (profile.weights.vector * v + profile.weights.lexical * l + profile.weights.recency * r), 0, 1);
|
|
6388
|
+
candidates.push(c);
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
return { candidates, vecCount, lexCount };
|
|
6392
|
+
}
|
|
6393
|
+
function rankWorkspaceCandidates(args) {
|
|
6394
|
+
const { candidates, maxMerged, k } = args;
|
|
6395
|
+
candidates.sort((a, b) => b.combined - a.combined);
|
|
6396
|
+
const merged = candidates.slice(0, maxMerged);
|
|
6397
|
+
const top = merged.slice(0, k);
|
|
6398
|
+
const hits = top.map((c) => {
|
|
6399
|
+
const meta = c.repo.getChunkMeta(c.id);
|
|
6400
|
+
const preview = makePreview(c.repo.getChunkText(c.id));
|
|
6401
|
+
return {
|
|
6402
|
+
score: c.combined,
|
|
6403
|
+
scoreBreakdown: { vector: c.vector01, lexical: c.lexical01, recency: c.recency01 },
|
|
6404
|
+
chunk: { ...meta, preview }
|
|
6405
|
+
};
|
|
6406
|
+
});
|
|
6407
|
+
return { merged, hits };
|
|
6408
|
+
}
|
|
6409
|
+
|
|
6410
|
+
// src/indexer/workspaceRetrieveContext.ts
|
|
6411
|
+
async function warmSymbolGraphForHits(repos, hits) {
|
|
6412
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
6413
|
+
for (const h of hits) {
|
|
6414
|
+
const s = byRepo.get(h.chunk.repoRoot) ?? /* @__PURE__ */ new Set();
|
|
6415
|
+
s.add(h.chunk.path);
|
|
6416
|
+
byRepo.set(h.chunk.repoRoot, s);
|
|
6417
|
+
}
|
|
6418
|
+
for (const [repoRoot, paths] of byRepo) {
|
|
6419
|
+
const repo = repos.find((r) => r.repoRoot === repoRoot);
|
|
6420
|
+
if (!repo) continue;
|
|
6421
|
+
await repo.warmSymbolGraphEdges(Array.from(paths), { maxFiles: 6 });
|
|
6422
|
+
}
|
|
6423
|
+
}
|
|
6424
|
+
async function fetchGraphNeighborFiles(args) {
|
|
6425
|
+
const { graphStore, repos, hits, profile, workspaceRoot, emitProgress } = args;
|
|
6426
|
+
if (!graphStore?.neighborFiles) return [];
|
|
6427
|
+
const seeds = [];
|
|
6428
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6429
|
+
for (const h of hits) {
|
|
6430
|
+
const repo = repos.find((r) => r.repoRoot === h.chunk.repoRoot);
|
|
6431
|
+
if (!repo) continue;
|
|
6432
|
+
const key = `${repo.repoId}:${h.chunk.path}`;
|
|
6433
|
+
if (seen.has(key)) continue;
|
|
6434
|
+
seen.add(key);
|
|
6435
|
+
seeds.push({ repoId: repo.repoId, path: h.chunk.path });
|
|
6436
|
+
if (seeds.length >= 4) break;
|
|
6437
|
+
}
|
|
6438
|
+
if (seeds.length === 0) return [];
|
|
6439
|
+
const startedAt = Date.now();
|
|
6440
|
+
emitProgress({ type: "workspace/retrieve/graph/start", workspaceRoot, seeds: seeds.length });
|
|
6441
|
+
try {
|
|
6442
|
+
const neighbors = await graphStore.neighborFiles({
|
|
6443
|
+
seeds,
|
|
6444
|
+
limit: profile.name === "architecture" ? 16 : 10,
|
|
6445
|
+
kinds: ["definition", "reference", "implementation", "typeDefinition"]
|
|
6446
|
+
});
|
|
6447
|
+
emitProgress({ type: "workspace/retrieve/graph/done", workspaceRoot, neighbors: neighbors.length, ms: Date.now() - startedAt });
|
|
6448
|
+
return neighbors;
|
|
6449
|
+
} catch {
|
|
6450
|
+
return [];
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6453
|
+
async function buildContextBlocks(args) {
|
|
6454
|
+
const { repos, hits, graphNeighborFiles, profile } = args;
|
|
6455
|
+
const contextBlocks = [];
|
|
6456
|
+
const seenKey = /* @__PURE__ */ new Set();
|
|
6457
|
+
const addBlock = (repoRoot, filePath, startLine, endLine, text, reason) => {
|
|
6458
|
+
const key = `${repoRoot}:${filePath}:${startLine}:${endLine}:${text.length}:${reason}`;
|
|
6459
|
+
if (seenKey.has(key)) return;
|
|
6460
|
+
seenKey.add(key);
|
|
6461
|
+
if (!text.trim()) return;
|
|
6462
|
+
contextBlocks.push({ repoRoot, path: filePath, startLine, endLine, text, reason });
|
|
6463
|
+
};
|
|
6464
|
+
try {
|
|
6465
|
+
const byRepoId = /* @__PURE__ */ new Map();
|
|
6466
|
+
for (const r of repos) byRepoId.set(r.repoId, r);
|
|
6467
|
+
for (const n of graphNeighborFiles.slice(0, 10)) {
|
|
6468
|
+
const repo = byRepoId.get(n.repoId);
|
|
6469
|
+
if (!repo) continue;
|
|
6470
|
+
const chunkId = await repo.getRepresentativeChunkIdForFile(n.path, true);
|
|
6471
|
+
if (!chunkId) continue;
|
|
6472
|
+
const meta = repo.getChunkMeta(chunkId);
|
|
6473
|
+
if (!meta) continue;
|
|
6474
|
+
const text = repo.getChunkText(chunkId);
|
|
6475
|
+
addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, `graph neighbor (${n.weight})`);
|
|
6476
|
+
}
|
|
6477
|
+
} catch {
|
|
6478
|
+
}
|
|
6479
|
+
for (const h of hits) {
|
|
6480
|
+
const repo = repos.find((r) => r.repoRoot === h.chunk.repoRoot);
|
|
6481
|
+
if (!repo) continue;
|
|
6482
|
+
const hitText = repo.getChunkText(h.chunk.id);
|
|
6483
|
+
addBlock(h.chunk.repoRoot, h.chunk.path, h.chunk.startLine, h.chunk.endLine, hitText, "primary hit");
|
|
6484
|
+
const expanded = await repo.expandContext(h.chunk.id, {
|
|
6485
|
+
adjacentChunks: profile.expand.adjacentChunks ?? 0,
|
|
6486
|
+
followImports: profile.expand.followImports ?? 0,
|
|
6487
|
+
includeFileSynopsis: profile.expand.includeFileSynopsis ?? false
|
|
6488
|
+
});
|
|
6489
|
+
for (const ex of expanded) {
|
|
6490
|
+
const meta = repo.getChunkMeta(ex.id);
|
|
6491
|
+
if (!meta) continue;
|
|
6492
|
+
const text = repo.getChunkText(ex.id);
|
|
6493
|
+
addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, ex.reason);
|
|
6494
|
+
}
|
|
6495
|
+
}
|
|
6496
|
+
return contextBlocks;
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6499
|
+
// src/indexer/workspaceIndexer.ts
|
|
4155
6500
|
var WorkspaceIndexer = class {
|
|
4156
6501
|
constructor(workspaceRoot, embedder, config = {}) {
|
|
4157
6502
|
this.workspaceRoot = workspaceRoot;
|
|
@@ -4159,23 +6504,30 @@ var WorkspaceIndexer = class {
|
|
|
4159
6504
|
this.config = { ...config };
|
|
4160
6505
|
if (!this.config.cacheDir) this.config.cacheDir = defaultCacheDir();
|
|
4161
6506
|
this.progress = asProgressSink(this.config.progress);
|
|
4162
|
-
const wsId = sha256Hex(
|
|
4163
|
-
|
|
4164
|
-
this.workspaceStore = new WorkspaceStore(dbPath);
|
|
4165
|
-
this.workspaceStore.setMeta("workspaceRoot", import_node_path17.default.resolve(this.workspaceRoot));
|
|
6507
|
+
const wsId = sha256Hex(import_node_path20.default.resolve(this.workspaceRoot)).slice(0, 16);
|
|
6508
|
+
this.workspaceDbPath = import_node_path20.default.join(this.config.cacheDir, "workspace", wsId, "workspace.sqlite");
|
|
4166
6509
|
}
|
|
4167
6510
|
repos = [];
|
|
4168
6511
|
config;
|
|
4169
6512
|
progress = asProgressSink();
|
|
4170
6513
|
workspaceStore = null;
|
|
4171
6514
|
graphStore = null;
|
|
6515
|
+
workspaceDbPath;
|
|
4172
6516
|
emitProgress(event) {
|
|
4173
6517
|
try {
|
|
4174
6518
|
this.progress?.emit(event);
|
|
4175
6519
|
} catch {
|
|
4176
6520
|
}
|
|
4177
6521
|
}
|
|
6522
|
+
async ensureWorkspaceStore() {
|
|
6523
|
+
if (this.workspaceStore) return this.workspaceStore;
|
|
6524
|
+
const ws = await createWorkspaceStoreAsync(this.workspaceDbPath, { db: this.config.workspace?.db });
|
|
6525
|
+
ws.setMeta("workspaceRoot", import_node_path20.default.resolve(this.workspaceRoot));
|
|
6526
|
+
this.workspaceStore = ws;
|
|
6527
|
+
return ws;
|
|
6528
|
+
}
|
|
4178
6529
|
async open() {
|
|
6530
|
+
await this.ensureWorkspaceStore();
|
|
4179
6531
|
if (!this.graphStore && this.config.workspace?.graph?.provider === "neo4j") {
|
|
4180
6532
|
try {
|
|
4181
6533
|
const n = this.config.workspace.graph.neo4j;
|
|
@@ -4247,195 +6599,49 @@ var WorkspaceIndexer = class {
|
|
|
4247
6599
|
getRepoIndexers() {
|
|
4248
6600
|
return this.repos.slice();
|
|
4249
6601
|
}
|
|
4250
|
-
resolveProfile(opts) {
|
|
4251
|
-
const name = opts?.profile ?? "search";
|
|
4252
|
-
const base = DEFAULT_PROFILES[name] ?? DEFAULT_PROFILES.search;
|
|
4253
|
-
const configPatch = this.config.profiles?.[name] ?? {};
|
|
4254
|
-
const merged1 = deepMergeProfile(base, configPatch);
|
|
4255
|
-
const merged2 = deepMergeProfile(merged1, opts?.profileOverrides);
|
|
4256
|
-
const w = merged2.weights;
|
|
4257
|
-
const sum = Math.max(1e-6, w.vector + w.lexical + w.recency);
|
|
4258
|
-
merged2.weights = { vector: w.vector / sum, lexical: w.lexical / sum, recency: w.recency / sum };
|
|
4259
|
-
return merged2;
|
|
4260
|
-
}
|
|
4261
6602
|
async retrieve(query, opts = {}) {
|
|
4262
6603
|
if (this.repos.length === 0) await this.open();
|
|
4263
|
-
const profile = this.
|
|
6604
|
+
const profile = resolveWorkspaceProfile(this.config, opts);
|
|
4264
6605
|
const startedAt = Date.now();
|
|
4265
6606
|
this.emitProgress({ type: "workspace/retrieve/start", workspaceRoot: this.workspaceRoot, profile: profile.name, query });
|
|
4266
6607
|
const qVec = (await this.embedder.embed([query]))[0];
|
|
4267
6608
|
const vectorK = profile.candidates?.vectorK ?? Math.max(profile.k * 3, 30);
|
|
4268
6609
|
const lexicalK = profile.candidates?.lexicalK ?? Math.max(profile.k * 3, 30);
|
|
4269
6610
|
const maxMerged = profile.candidates?.maxMergedCandidates ?? Math.max(profile.k * 8, 120);
|
|
4270
|
-
const
|
|
4271
|
-
const
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
const rootKey = import_node_path17.default.resolve(row.repo_root);
|
|
4289
|
-
const arr = workspaceLexByRepoRoot.get(rootKey) ?? [];
|
|
4290
|
-
arr.push({ id: r.id, score: bm25ToScore01(r.bm25) });
|
|
4291
|
-
workspaceLexByRepoRoot.set(rootKey, arr);
|
|
4292
|
-
}
|
|
4293
|
-
}
|
|
4294
|
-
}
|
|
4295
|
-
for (const repo of this.repos) {
|
|
4296
|
-
if (repoFilters && !repoFilters.includes(repo.repoRoot)) continue;
|
|
4297
|
-
let includePaths = opts.scope?.includePaths?.slice();
|
|
4298
|
-
if (opts.scope?.changedOnly) {
|
|
4299
|
-
try {
|
|
4300
|
-
const changed = await listChangedFiles(repo.repoRoot, opts.scope.baseRef ?? "HEAD~1");
|
|
4301
|
-
includePaths = includePaths ? includePaths.filter((p) => changed.includes(p)) : changed;
|
|
4302
|
-
} catch {
|
|
4303
|
-
}
|
|
4304
|
-
}
|
|
4305
|
-
const [vHits, lHits] = await Promise.all([
|
|
4306
|
-
repo.vectorCandidates(qVec, vectorK, includePaths),
|
|
4307
|
-
canUseWorkspaceLex ? Promise.resolve(workspaceLexByRepoRoot.get(import_node_path17.default.resolve(repo.repoRoot)) ?? []) : repo.lexicalCandidates(query, lexicalK, includePaths)
|
|
4308
|
-
]);
|
|
4309
|
-
vecCount += vHits.length;
|
|
4310
|
-
if (!canUseWorkspaceLex) lexCount += lHits.length;
|
|
4311
|
-
const m = /* @__PURE__ */ new Map();
|
|
4312
|
-
for (const vh of vHits) {
|
|
4313
|
-
const id = vh.id;
|
|
4314
|
-
const vector01 = vectorCosineToScore01(vh.score);
|
|
4315
|
-
m.set(id, { repo, id, vector01, combined: 0 });
|
|
4316
|
-
}
|
|
4317
|
-
for (const lh of lHits) {
|
|
4318
|
-
const id = lh.id;
|
|
4319
|
-
const prev = m.get(id);
|
|
4320
|
-
if (prev) prev.lexical01 = lh.score;
|
|
4321
|
-
else m.set(id, { repo, id, lexical01: lh.score, combined: 0 });
|
|
4322
|
-
}
|
|
4323
|
-
const halfLife = halfLifeDaysForProfile(profile.name);
|
|
4324
|
-
for (const c of m.values()) {
|
|
4325
|
-
const meta = repo.getChunkMeta(c.id);
|
|
4326
|
-
if (!meta) continue;
|
|
4327
|
-
if (langFilter && meta.language !== langFilter) continue;
|
|
4328
|
-
if (pathPrefix && !meta.path.startsWith(pathPrefix)) continue;
|
|
4329
|
-
c.recency01 = profile.weights.recency > 0 ? recencyScore(meta.fileMtimeMs, halfLife) : 0;
|
|
4330
|
-
let kindFactor = 1;
|
|
4331
|
-
if (meta.kind === "synopsis" && profile.name === "search") kindFactor = 0.85;
|
|
4332
|
-
if (meta.kind === "synopsis" && profile.name === "architecture") kindFactor = 1.05;
|
|
4333
|
-
const v = c.vector01 ?? 0;
|
|
4334
|
-
const l = c.lexical01 ?? 0;
|
|
4335
|
-
const r = c.recency01 ?? 0;
|
|
4336
|
-
c.combined = clamp(
|
|
4337
|
-
kindFactor * (profile.weights.vector * v + profile.weights.lexical * l + profile.weights.recency * r),
|
|
4338
|
-
0,
|
|
4339
|
-
1
|
|
4340
|
-
);
|
|
4341
|
-
candidates.push(c);
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
candidates.sort((a, b) => b.combined - a.combined);
|
|
4345
|
-
const merged = candidates.slice(0, maxMerged);
|
|
4346
|
-
const top = merged.slice(0, profile.k);
|
|
4347
|
-
const hits = top.map((c) => {
|
|
4348
|
-
const meta = c.repo.getChunkMeta(c.id);
|
|
4349
|
-
const preview = makePreview(c.repo.getChunkText(c.id));
|
|
4350
|
-
return {
|
|
4351
|
-
score: c.combined,
|
|
4352
|
-
scoreBreakdown: { vector: c.vector01, lexical: c.lexical01, recency: c.recency01 },
|
|
4353
|
-
chunk: { ...meta, preview }
|
|
4354
|
-
};
|
|
6611
|
+
const canUseWorkspaceLex = !!this.workspaceStore && this.workspaceStore.ftsEnabled && this.config.storage?.ftsMode !== "off" && !opts.scope?.includePaths && !opts.scope?.changedOnly;
|
|
6612
|
+
const { lexByRepoRoot, count: workspaceLexCount } = canUseWorkspaceLex && profile.weights.lexical > 0 && this.workspaceStore ? buildWorkspaceLexByRepoRoot({
|
|
6613
|
+
workspaceStore: this.workspaceStore,
|
|
6614
|
+
repos: this.repos,
|
|
6615
|
+
query,
|
|
6616
|
+
lexicalK,
|
|
6617
|
+
repoFilters: opts.filters?.repoRoots
|
|
6618
|
+
}) : { lexByRepoRoot: void 0, count: 0 };
|
|
6619
|
+
const { candidates, vecCount, lexCount } = await collectWorkspaceCandidates({
|
|
6620
|
+
repos: this.repos,
|
|
6621
|
+
qVec,
|
|
6622
|
+
query,
|
|
6623
|
+
vectorK,
|
|
6624
|
+
lexicalK,
|
|
6625
|
+
profile,
|
|
6626
|
+
opts,
|
|
6627
|
+
lexByRepoRoot,
|
|
6628
|
+
canUseWorkspaceLex
|
|
4355
6629
|
});
|
|
6630
|
+
const { merged, hits } = rankWorkspaceCandidates({ candidates, maxMerged, k: profile.k });
|
|
6631
|
+
const totalLexCount = (canUseWorkspaceLex ? workspaceLexCount : 0) + lexCount;
|
|
4356
6632
|
try {
|
|
4357
|
-
|
|
4358
|
-
for (const h of hits) {
|
|
4359
|
-
const s = byRepo.get(h.chunk.repoRoot) ?? /* @__PURE__ */ new Set();
|
|
4360
|
-
s.add(h.chunk.path);
|
|
4361
|
-
byRepo.set(h.chunk.repoRoot, s);
|
|
4362
|
-
}
|
|
4363
|
-
for (const [repoRoot, paths] of byRepo) {
|
|
4364
|
-
const repo = this.repos.find((r) => r.repoRoot === repoRoot);
|
|
4365
|
-
if (!repo) continue;
|
|
4366
|
-
await repo.warmSymbolGraphEdges(Array.from(paths), { maxFiles: 6 });
|
|
4367
|
-
}
|
|
6633
|
+
await warmSymbolGraphForHits(this.repos, hits);
|
|
4368
6634
|
} catch {
|
|
4369
6635
|
}
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
if (seen.has(key)) continue;
|
|
4380
|
-
seen.add(key);
|
|
4381
|
-
seeds.push({ repoId: repo.repoId, path: h.chunk.path });
|
|
4382
|
-
if (seeds.length >= 4) break;
|
|
4383
|
-
}
|
|
4384
|
-
if (seeds.length > 0) {
|
|
4385
|
-
const gs = Date.now();
|
|
4386
|
-
this.emitProgress({ type: "workspace/retrieve/graph/start", workspaceRoot: this.workspaceRoot, seeds: seeds.length });
|
|
4387
|
-
graphNeighborFiles = await this.graphStore.neighborFiles({
|
|
4388
|
-
seeds,
|
|
4389
|
-
limit: profile.name === "architecture" ? 16 : 10,
|
|
4390
|
-
kinds: ["definition", "reference", "implementation", "typeDefinition"]
|
|
4391
|
-
});
|
|
4392
|
-
this.emitProgress({ type: "workspace/retrieve/graph/done", workspaceRoot: this.workspaceRoot, neighbors: graphNeighborFiles.length, ms: Date.now() - gs });
|
|
4393
|
-
}
|
|
4394
|
-
}
|
|
4395
|
-
} catch {
|
|
4396
|
-
graphNeighborFiles = [];
|
|
4397
|
-
}
|
|
4398
|
-
const contextBlocks = [];
|
|
4399
|
-
const seenKey = /* @__PURE__ */ new Set();
|
|
4400
|
-
const addBlock = (repoRoot, path19, startLine, endLine, text, reason) => {
|
|
4401
|
-
const key = `${repoRoot}:${path19}:${startLine}:${endLine}:${text.length}:${reason}`;
|
|
4402
|
-
if (seenKey.has(key)) return;
|
|
4403
|
-
seenKey.add(key);
|
|
4404
|
-
if (!text.trim()) return;
|
|
4405
|
-
contextBlocks.push({ repoRoot, path: path19, startLine, endLine, text, reason });
|
|
4406
|
-
};
|
|
4407
|
-
try {
|
|
4408
|
-
const byRepoId = /* @__PURE__ */ new Map();
|
|
4409
|
-
for (const r of this.repos) byRepoId.set(r.repoId, r);
|
|
4410
|
-
for (const n of graphNeighborFiles.slice(0, 10)) {
|
|
4411
|
-
const repo = byRepoId.get(n.repoId);
|
|
4412
|
-
if (!repo) continue;
|
|
4413
|
-
const chunkId = await repo.getRepresentativeChunkIdForFile(n.path, true);
|
|
4414
|
-
if (!chunkId) continue;
|
|
4415
|
-
const meta = repo.getChunkMeta(chunkId);
|
|
4416
|
-
if (!meta) continue;
|
|
4417
|
-
const text = repo.getChunkText(chunkId);
|
|
4418
|
-
addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, `graph neighbor (${n.weight})`);
|
|
4419
|
-
}
|
|
4420
|
-
} catch {
|
|
4421
|
-
}
|
|
4422
|
-
for (const h of hits) {
|
|
4423
|
-
const repo = this.repos.find((r) => r.repoRoot === h.chunk.repoRoot);
|
|
4424
|
-
if (!repo) continue;
|
|
4425
|
-
const text = repo.getChunkText(h.chunk.id);
|
|
4426
|
-
addBlock(h.chunk.repoRoot, h.chunk.path, h.chunk.startLine, h.chunk.endLine, text, "primary hit");
|
|
4427
|
-
const expanded = await repo.expandContext(h.chunk.id, {
|
|
4428
|
-
adjacentChunks: profile.expand.adjacentChunks ?? 0,
|
|
4429
|
-
followImports: profile.expand.followImports ?? 0,
|
|
4430
|
-
includeFileSynopsis: profile.expand.includeFileSynopsis ?? false
|
|
4431
|
-
});
|
|
4432
|
-
for (const ex of expanded) {
|
|
4433
|
-
const meta = repo.getChunkMeta(ex.id);
|
|
4434
|
-
if (!meta) continue;
|
|
4435
|
-
const t = repo.getChunkText(ex.id);
|
|
4436
|
-
addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, t, ex.reason);
|
|
4437
|
-
}
|
|
4438
|
-
}
|
|
6636
|
+
const graphNeighborFiles = await fetchGraphNeighborFiles({
|
|
6637
|
+
graphStore: this.graphStore,
|
|
6638
|
+
repos: this.repos,
|
|
6639
|
+
hits,
|
|
6640
|
+
profile,
|
|
6641
|
+
workspaceRoot: this.workspaceRoot,
|
|
6642
|
+
emitProgress: (e) => this.emitProgress(e)
|
|
6643
|
+
});
|
|
6644
|
+
const contextBlocks = await buildContextBlocks({ repos: this.repos, hits, graphNeighborFiles, profile });
|
|
4439
6645
|
const bundle = {
|
|
4440
6646
|
hits,
|
|
4441
6647
|
context: contextBlocks,
|
|
@@ -4444,7 +6650,7 @@ var WorkspaceIndexer = class {
|
|
|
4444
6650
|
reposSearched: this.repos.length,
|
|
4445
6651
|
candidates: {
|
|
4446
6652
|
vector: vecCount,
|
|
4447
|
-
lexical:
|
|
6653
|
+
lexical: totalLexCount,
|
|
4448
6654
|
merged: merged.length,
|
|
4449
6655
|
returned: hits.length
|
|
4450
6656
|
}
|
|
@@ -4456,7 +6662,7 @@ var WorkspaceIndexer = class {
|
|
|
4456
6662
|
profile: profile.name,
|
|
4457
6663
|
ms: Date.now() - startedAt,
|
|
4458
6664
|
hits: hits.length,
|
|
4459
|
-
candidates: { vector: vecCount, lexical:
|
|
6665
|
+
candidates: { vector: vecCount, lexical: totalLexCount, merged: merged.length }
|
|
4460
6666
|
});
|
|
4461
6667
|
return bundle;
|
|
4462
6668
|
}
|
|
@@ -4593,11 +6799,11 @@ var HashEmbeddingsProvider = class {
|
|
|
4593
6799
|
};
|
|
4594
6800
|
|
|
4595
6801
|
// src/config.ts
|
|
4596
|
-
var
|
|
4597
|
-
var
|
|
6802
|
+
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
6803
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
4598
6804
|
function loadConfigFile(filePath) {
|
|
4599
|
-
const abs =
|
|
4600
|
-
const raw =
|
|
6805
|
+
const abs = import_node_path21.default.resolve(filePath);
|
|
6806
|
+
const raw = import_node_fs16.default.readFileSync(abs, "utf8");
|
|
4601
6807
|
const json = JSON.parse(raw);
|
|
4602
6808
|
const cfg = { ...json };
|
|
4603
6809
|
if (json.redact?.patterns && Array.isArray(json.redact.patterns)) {
|
|
@@ -4633,7 +6839,7 @@ function makeEmbedder(argv) {
|
|
|
4633
6839
|
function loadConfig(argv) {
|
|
4634
6840
|
const cfgPath = argv.config;
|
|
4635
6841
|
if (!cfgPath) return {};
|
|
4636
|
-
if (!
|
|
6842
|
+
if (!import_node_fs17.default.existsSync(cfgPath)) throw new Error(`Config file not found: ${cfgPath}`);
|
|
4637
6843
|
return loadConfigFile(cfgPath);
|
|
4638
6844
|
}
|
|
4639
6845
|
async function main() {
|