crispy-recall 0.1.6 → 0.2.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/README.md +88 -1
- package/dist/embed-pending.js +961 -1452
- package/dist/recall.js +2217 -1630
- package/dist/stop-hook.js +928 -1451
- package/package.json +7 -3
- package/dist/node-sqlite3-wasm.wasm +0 -0
package/dist/embed-pending.js
CHANGED
|
@@ -105,1414 +105,826 @@ var init_log = __esm({
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
// node_modules/
|
|
109
|
-
var
|
|
110
|
-
"node_modules/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var SQLITE_OK = 0;
|
|
117
|
-
var SQLITE_ROW = 100;
|
|
118
|
-
var SQLITE_DONE = 101;
|
|
119
|
-
var SQLITE_INTEGER = 1;
|
|
120
|
-
var SQLITE_FLOAT = 2;
|
|
121
|
-
var SQLITE_TEXT = 3;
|
|
122
|
-
var SQLITE_BLOB = 4;
|
|
123
|
-
var SQLITE_NULL = 5;
|
|
124
|
-
var SQLITE_UTF8 = 1;
|
|
125
|
-
var SQLITE_TRANSIENT = -1;
|
|
126
|
-
var SQLITE_DETERMINISTIC = 2048;
|
|
127
|
-
var temp;
|
|
128
|
-
var sqlite3 = {};
|
|
129
|
-
Module.onRuntimeInitialized = () => {
|
|
130
|
-
temp = stackAlloc(4);
|
|
131
|
-
const v = null;
|
|
132
|
-
const n = "number";
|
|
133
|
-
const s = "string";
|
|
134
|
-
const n1 = [n];
|
|
135
|
-
const n2 = [n, ...n1];
|
|
136
|
-
const n3 = [n, ...n2];
|
|
137
|
-
const n4 = [n, ...n3];
|
|
138
|
-
const n5 = [n, ...n4];
|
|
139
|
-
const signatures = { open_v2: [n, [s, n, n, s]], exec: [n, n5], errmsg: [s, n1], prepare_v2: [n, n5], close_v2: [n, n1], finalize: [n, n1], reset: [n, n1], clear_bindings: [n, n1], bind_int: [n, n3], bind_int64: [n, n3], bind_double: [n, n3], bind_text: [n, n5], bind_blob: [n, n5], bind_blob64: [n, n5], bind_null: [n, n2], bind_parameter_index: [n, [n, s]], step: [n, n1], column_int64: [n, n2], column_double: [n, n2], column_text: [s, n2], column_blob: [n, n2], column_type: [n, n2], column_name: [s, n2], column_count: [n, n1], column_bytes: [n, n2], last_insert_rowid: [n, n1], changes: [n, n1], create_function_v2: [n, [n, s, n, n, n, n, n, n, n]], value_type: [n, n1], value_text: [s, n1], value_blob: [n, n1], value_int64: [n, n1], value_double: [n, n1], value_bytes: [n, n1], result_double: [v, n2], result_null: [v, n1], result_text: [v, n4], result_blob: [v, n4], result_blob64: [v, n4], result_int: [v, n2], result_int64: [v, n2], result_error: [v, n3], column_table_name: [s, n2], get_autocommit: [n, n1] };
|
|
140
|
-
for (const [name, sig] of Object.entries(signatures)) {
|
|
141
|
-
sqlite3[name] = cwrap(`sqlite3_${name}`, sig[0], sig[1]);
|
|
108
|
+
// node_modules/better-sqlite3/lib/util.js
|
|
109
|
+
var require_util = __commonJS({
|
|
110
|
+
"node_modules/better-sqlite3/lib/util.js"(exports2) {
|
|
111
|
+
"use strict";
|
|
112
|
+
exports2.getBooleanOption = (options, key) => {
|
|
113
|
+
let value = false;
|
|
114
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
115
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
142
116
|
}
|
|
117
|
+
return value;
|
|
143
118
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
119
|
+
exports2.cppdb = Symbol();
|
|
120
|
+
exports2.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
125
|
+
var require_sqlite_error = __commonJS({
|
|
126
|
+
"node_modules/better-sqlite3/lib/sqlite-error.js"(exports2, module2) {
|
|
127
|
+
"use strict";
|
|
128
|
+
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
129
|
+
function SqliteError(message, code) {
|
|
130
|
+
if (new.target !== SqliteError) {
|
|
131
|
+
return new SqliteError(message, code);
|
|
148
132
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const ptr = _malloc(array.byteLength);
|
|
152
|
-
HEAPU8.set(array, ptr);
|
|
153
|
-
return ptr;
|
|
154
|
-
}
|
|
155
|
-
function stringToHeap(str) {
|
|
156
|
-
const size = lengthBytesUTF8(str) + 1;
|
|
157
|
-
const ptr = _malloc(size);
|
|
158
|
-
stringToUTF8(str, ptr, size);
|
|
159
|
-
return ptr;
|
|
160
|
-
}
|
|
161
|
-
function toNumberOrNot(bigInt) {
|
|
162
|
-
if (bigInt >= Number.MIN_SAFE_INTEGER && bigInt <= Number.MAX_SAFE_INTEGER) {
|
|
163
|
-
return Number(bigInt);
|
|
164
|
-
}
|
|
165
|
-
return bigInt;
|
|
166
|
-
}
|
|
167
|
-
function parseFunctionArguments(argc, argv) {
|
|
168
|
-
const args = [];
|
|
169
|
-
for (let i = 0; i < argc; i++) {
|
|
170
|
-
const ptr = getValue(argv + 4 * i, "i32");
|
|
171
|
-
const type = sqlite3.value_type(ptr);
|
|
172
|
-
let arg;
|
|
173
|
-
switch (type) {
|
|
174
|
-
case SQLITE_INTEGER:
|
|
175
|
-
arg = toNumberOrNot(sqlite3.value_int64(ptr));
|
|
176
|
-
break;
|
|
177
|
-
case SQLITE_FLOAT:
|
|
178
|
-
arg = sqlite3.value_double(ptr);
|
|
179
|
-
break;
|
|
180
|
-
case SQLITE_TEXT:
|
|
181
|
-
arg = sqlite3.value_text(ptr);
|
|
182
|
-
break;
|
|
183
|
-
case SQLITE_BLOB:
|
|
184
|
-
const p = sqlite3.value_blob(ptr);
|
|
185
|
-
if (p != NULL) {
|
|
186
|
-
arg = HEAPU8.slice(p, p + sqlite3.value_bytes(ptr));
|
|
187
|
-
} else {
|
|
188
|
-
arg = new Uint8Array();
|
|
189
|
-
}
|
|
190
|
-
break;
|
|
191
|
-
case SQLITE_NULL:
|
|
192
|
-
arg = null;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
args.push(arg);
|
|
133
|
+
if (typeof code !== "string") {
|
|
134
|
+
throw new TypeError("Expected second argument to be a string");
|
|
196
135
|
}
|
|
197
|
-
|
|
136
|
+
Error.call(this, message);
|
|
137
|
+
descriptor.value = "" + message;
|
|
138
|
+
Object.defineProperty(this, "message", descriptor);
|
|
139
|
+
Error.captureStackTrace(this, SqliteError);
|
|
140
|
+
this.code = code;
|
|
198
141
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
sqlite3.result_blob64(cx, tempPtr2, BigInt(result.byteLength), SQLITE_TRANSIENT);
|
|
232
|
-
}
|
|
233
|
-
_free(tempPtr2);
|
|
234
|
-
} else {
|
|
235
|
-
throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`);
|
|
236
|
-
}
|
|
237
|
-
break;
|
|
238
|
-
default:
|
|
239
|
-
throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`);
|
|
142
|
+
Object.setPrototypeOf(SqliteError, Error);
|
|
143
|
+
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
144
|
+
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
145
|
+
module2.exports = SqliteError;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// node_modules/file-uri-to-path/index.js
|
|
150
|
+
var require_file_uri_to_path = __commonJS({
|
|
151
|
+
"node_modules/file-uri-to-path/index.js"(exports2, module2) {
|
|
152
|
+
var sep2 = require("path").sep || "/";
|
|
153
|
+
module2.exports = fileUriToPath;
|
|
154
|
+
function fileUriToPath(uri) {
|
|
155
|
+
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
156
|
+
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
157
|
+
}
|
|
158
|
+
var rest = decodeURI(uri.substring(7));
|
|
159
|
+
var firstSlash = rest.indexOf("/");
|
|
160
|
+
var host = rest.substring(0, firstSlash);
|
|
161
|
+
var path3 = rest.substring(firstSlash + 1);
|
|
162
|
+
if ("localhost" == host)
|
|
163
|
+
host = "";
|
|
164
|
+
if (host) {
|
|
165
|
+
host = sep2 + sep2 + host;
|
|
166
|
+
}
|
|
167
|
+
path3 = path3.replace(/^(.+)\|/, "$1:");
|
|
168
|
+
if (sep2 == "\\") {
|
|
169
|
+
path3 = path3.replace(/\//g, "\\");
|
|
170
|
+
}
|
|
171
|
+
if (/^.+\:/.test(path3)) {
|
|
172
|
+
} else {
|
|
173
|
+
path3 = sep2 + path3;
|
|
240
174
|
}
|
|
175
|
+
return host + path3;
|
|
241
176
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
this._functions = /* @__PURE__ */ new Map();
|
|
260
|
-
}
|
|
261
|
-
get isOpen() {
|
|
262
|
-
return this._ptr !== null;
|
|
263
|
-
}
|
|
264
|
-
get inTransaction() {
|
|
265
|
-
this._assertOpen();
|
|
266
|
-
return sqlite3.get_autocommit(this._ptr) === 0;
|
|
267
|
-
}
|
|
268
|
-
close() {
|
|
269
|
-
this._assertOpen();
|
|
270
|
-
for (const func of this._functions.values())
|
|
271
|
-
removeFunction(func);
|
|
272
|
-
this._functions.clear();
|
|
273
|
-
this._handleError(sqlite3.close_v2(this._ptr));
|
|
274
|
-
this._ptr = null;
|
|
275
|
-
}
|
|
276
|
-
function(name, func, { deterministic = false } = {}) {
|
|
277
|
-
this._assertOpen();
|
|
278
|
-
function wrappedFunc(cx, argc, argv) {
|
|
279
|
-
const args = parseFunctionArguments(argc, argv);
|
|
280
|
-
let result;
|
|
281
|
-
try {
|
|
282
|
-
result = func.apply(null, args);
|
|
283
|
-
} catch (err2) {
|
|
284
|
-
const tempPtr = stringToHeap(err2.toString());
|
|
285
|
-
sqlite3.result_error(cx, tempPtr, -1);
|
|
286
|
-
_free(tempPtr);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
setFunctionResult(cx, result);
|
|
290
|
-
}
|
|
291
|
-
if (this._functions.has(name)) {
|
|
292
|
-
removeFunction(this._functions.get(name));
|
|
293
|
-
this._functions.delete(name);
|
|
294
|
-
}
|
|
295
|
-
const funcPtr = addFunction(wrappedFunc, "viii");
|
|
296
|
-
this._functions.set(name, funcPtr);
|
|
297
|
-
let eTextRep = SQLITE_UTF8;
|
|
298
|
-
if (deterministic)
|
|
299
|
-
eTextRep |= SQLITE_DETERMINISTIC;
|
|
300
|
-
this._handleError(sqlite3.create_function_v2(this._ptr, name, func.length, eTextRep, NULL, funcPtr, NULL, NULL, NULL));
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
exec(sql) {
|
|
304
|
-
this._assertOpen();
|
|
305
|
-
const tempPtr = stringToHeap(sql);
|
|
306
|
-
try {
|
|
307
|
-
this._handleError(sqlite3.exec(this._ptr, tempPtr, NULL, NULL, NULL));
|
|
308
|
-
} finally {
|
|
309
|
-
_free(tempPtr);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
prepare(sql) {
|
|
313
|
-
this._assertOpen();
|
|
314
|
-
return new Statement(this, sql);
|
|
315
|
-
}
|
|
316
|
-
run(sql, values) {
|
|
317
|
-
const stmt = this.prepare(sql);
|
|
318
|
-
try {
|
|
319
|
-
return stmt.run(values);
|
|
320
|
-
} finally {
|
|
321
|
-
stmt.finalize();
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
all(sql, values, { expand: expand2 = false } = {}) {
|
|
325
|
-
return this._query(sql, values, false, expand2);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// node_modules/bindings/bindings.js
|
|
181
|
+
var require_bindings = __commonJS({
|
|
182
|
+
"node_modules/bindings/bindings.js"(exports2, module2) {
|
|
183
|
+
var fs3 = require("fs");
|
|
184
|
+
var path3 = require("path");
|
|
185
|
+
var fileURLToPath3 = require_file_uri_to_path();
|
|
186
|
+
var join8 = path3.join;
|
|
187
|
+
var dirname3 = path3.dirname;
|
|
188
|
+
var exists = fs3.accessSync && function(path4) {
|
|
189
|
+
try {
|
|
190
|
+
fs3.accessSync(path4);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
return false;
|
|
326
193
|
}
|
|
327
|
-
|
|
328
|
-
|
|
194
|
+
return true;
|
|
195
|
+
} || fs3.existsSync || path3.existsSync;
|
|
196
|
+
var defaults2 = {
|
|
197
|
+
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
198
|
+
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
199
|
+
platform: process.platform,
|
|
200
|
+
arch: process.arch,
|
|
201
|
+
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
202
|
+
version: process.versions.node,
|
|
203
|
+
bindings: "bindings.node",
|
|
204
|
+
try: [
|
|
205
|
+
// node-gyp's linked version in the "build" dir
|
|
206
|
+
["module_root", "build", "bindings"],
|
|
207
|
+
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
208
|
+
["module_root", "build", "Debug", "bindings"],
|
|
209
|
+
["module_root", "build", "Release", "bindings"],
|
|
210
|
+
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
211
|
+
["module_root", "out", "Debug", "bindings"],
|
|
212
|
+
["module_root", "Debug", "bindings"],
|
|
213
|
+
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
214
|
+
["module_root", "out", "Release", "bindings"],
|
|
215
|
+
["module_root", "Release", "bindings"],
|
|
216
|
+
// Legacy from node-waf, node <= 0.4.x
|
|
217
|
+
["module_root", "build", "default", "bindings"],
|
|
218
|
+
// Production "Release" buildtype binary (meh...)
|
|
219
|
+
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
220
|
+
// node-qbs builds
|
|
221
|
+
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
222
|
+
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
223
|
+
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
224
|
+
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
225
|
+
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
226
|
+
]
|
|
227
|
+
};
|
|
228
|
+
function bindings(opts) {
|
|
229
|
+
if (typeof opts == "string") {
|
|
230
|
+
opts = { bindings: opts };
|
|
231
|
+
} else if (!opts) {
|
|
232
|
+
opts = {};
|
|
329
233
|
}
|
|
330
|
-
|
|
331
|
-
|
|
234
|
+
Object.keys(defaults2).map(function(i2) {
|
|
235
|
+
if (!(i2 in opts))
|
|
236
|
+
opts[i2] = defaults2[i2];
|
|
237
|
+
});
|
|
238
|
+
if (!opts.module_root) {
|
|
239
|
+
opts.module_root = exports2.getRoot(exports2.getFileName());
|
|
240
|
+
}
|
|
241
|
+
if (path3.extname(opts.bindings) != ".node") {
|
|
242
|
+
opts.bindings += ".node";
|
|
243
|
+
}
|
|
244
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
245
|
+
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
246
|
+
for (; i < l; i++) {
|
|
247
|
+
n = join8.apply(
|
|
248
|
+
null,
|
|
249
|
+
opts.try[i].map(function(p) {
|
|
250
|
+
return opts[p] || p;
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
tries.push(n);
|
|
332
254
|
try {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
255
|
+
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
256
|
+
if (!opts.path) {
|
|
257
|
+
b.path = n;
|
|
258
|
+
}
|
|
259
|
+
return b;
|
|
260
|
+
} catch (e) {
|
|
261
|
+
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
262
|
+
throw e;
|
|
337
263
|
}
|
|
338
|
-
} finally {
|
|
339
|
-
stmt.finalize();
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
_assertOpen() {
|
|
343
|
-
if (!this.isOpen)
|
|
344
|
-
throw new SQLite3Error("Database already closed");
|
|
345
|
-
}
|
|
346
|
-
_handleError(returnCode) {
|
|
347
|
-
if (returnCode !== SQLITE_OK)
|
|
348
|
-
throw new SQLite3Error(sqlite3.errmsg(this._ptr));
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
var Statement = class {
|
|
352
|
-
constructor(db3, sql) {
|
|
353
|
-
const tempPtr = stringToHeap(sql);
|
|
354
|
-
try {
|
|
355
|
-
db3._handleError(sqlite3.prepare_v2(db3._ptr, tempPtr, -1, temp, NULL));
|
|
356
|
-
} finally {
|
|
357
|
-
_free(tempPtr);
|
|
358
|
-
}
|
|
359
|
-
this._ptr = getValue(temp, "i32");
|
|
360
|
-
if (this._ptr === NULL)
|
|
361
|
-
throw new SQLite3Error("Nothing to prepare");
|
|
362
|
-
this._db = db3;
|
|
363
|
-
}
|
|
364
|
-
get database() {
|
|
365
|
-
return this._db;
|
|
366
|
-
}
|
|
367
|
-
get isFinalized() {
|
|
368
|
-
return this._ptr === null;
|
|
369
|
-
}
|
|
370
|
-
run(values) {
|
|
371
|
-
this._assertReady();
|
|
372
|
-
this._bind(values);
|
|
373
|
-
this._step();
|
|
374
|
-
return { changes: sqlite3.changes(this._db._ptr), lastInsertRowid: toNumberOrNot(sqlite3.last_insert_rowid(this._db._ptr)) };
|
|
375
|
-
}
|
|
376
|
-
iterate(values, { expand: expand2 = false } = {}) {
|
|
377
|
-
return this._queryRows(values, expand2);
|
|
378
|
-
}
|
|
379
|
-
all(values, { expand: expand2 = false } = {}) {
|
|
380
|
-
return Array.from(this.iterate(values, { expand: expand2 }));
|
|
381
|
-
}
|
|
382
|
-
get(values, { expand: expand2 = false } = {}) {
|
|
383
|
-
const result = this._queryRows(values, expand2).next();
|
|
384
|
-
return result.done ? null : result.value;
|
|
385
|
-
}
|
|
386
|
-
finalize() {
|
|
387
|
-
if (this.isFinalized)
|
|
388
|
-
throw new SQLite3Error("Statement already finalized");
|
|
389
|
-
try {
|
|
390
|
-
this._db._handleError(sqlite3.finalize(this._ptr));
|
|
391
|
-
} finally {
|
|
392
|
-
this._ptr = null;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
_reset() {
|
|
396
|
-
return sqlite3.clear_bindings(this._ptr) === SQLITE_OK && sqlite3.reset(this._ptr) === SQLITE_OK;
|
|
397
|
-
}
|
|
398
|
-
*_queryRows(values, expand2) {
|
|
399
|
-
this._assertReady();
|
|
400
|
-
this._bind(values);
|
|
401
|
-
const columns = this._getColumnNames();
|
|
402
|
-
while (this._step())
|
|
403
|
-
yield this._getRow(columns, expand2);
|
|
404
|
-
}
|
|
405
|
-
_bind(values) {
|
|
406
|
-
if (!this._reset()) {
|
|
407
|
-
throw new SQLite3Error("Could not reset statement prior to binding new values");
|
|
408
|
-
}
|
|
409
|
-
if (Array.isArray(values)) {
|
|
410
|
-
this._bindArray(values);
|
|
411
|
-
} else if (values != null && typeof values === "object") {
|
|
412
|
-
this._bindObject(values);
|
|
413
|
-
} else if (typeof values !== "undefined") {
|
|
414
|
-
this._bindValue(values, 1);
|
|
415
264
|
}
|
|
416
265
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
for (
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
break;
|
|
437
|
-
case SQLITE_FLOAT:
|
|
438
|
-
v = sqlite3.column_double(this._ptr, i);
|
|
439
|
-
break;
|
|
440
|
-
case SQLITE_TEXT:
|
|
441
|
-
v = sqlite3.column_text(this._ptr, i);
|
|
442
|
-
break;
|
|
443
|
-
case SQLITE_BLOB:
|
|
444
|
-
const p = sqlite3.column_blob(this._ptr, i);
|
|
445
|
-
if (p != NULL) {
|
|
446
|
-
v = HEAPU8.slice(p, p + sqlite3.column_bytes(this._ptr, i));
|
|
447
|
-
} else {
|
|
448
|
-
v = new Uint8Array();
|
|
266
|
+
err = new Error(
|
|
267
|
+
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
268
|
+
return opts.arrow + a;
|
|
269
|
+
}).join("\n")
|
|
270
|
+
);
|
|
271
|
+
err.tries = tries;
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
module2.exports = exports2 = bindings;
|
|
275
|
+
exports2.getFileName = function getFileName(calling_file) {
|
|
276
|
+
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
277
|
+
Error.stackTraceLimit = 10;
|
|
278
|
+
Error.prepareStackTrace = function(e, st) {
|
|
279
|
+
for (var i = 0, l = st.length; i < l; i++) {
|
|
280
|
+
fileName = st[i].getFileName();
|
|
281
|
+
if (fileName !== __filename) {
|
|
282
|
+
if (calling_file) {
|
|
283
|
+
if (fileName !== calling_file) {
|
|
284
|
+
return;
|
|
449
285
|
}
|
|
450
|
-
break;
|
|
451
|
-
case SQLITE_NULL:
|
|
452
|
-
v = null;
|
|
453
|
-
break;
|
|
454
|
-
}
|
|
455
|
-
const column = columns[i];
|
|
456
|
-
if (expand2) {
|
|
457
|
-
let table = sqlite3.column_table_name(this._ptr, i);
|
|
458
|
-
table = table === "" ? "$" : table;
|
|
459
|
-
if (Object.hasOwn(row, table)) {
|
|
460
|
-
row[table][column] = v;
|
|
461
286
|
} else {
|
|
462
|
-
|
|
287
|
+
return;
|
|
463
288
|
}
|
|
464
|
-
} else {
|
|
465
|
-
row[column] = v;
|
|
466
289
|
}
|
|
467
290
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (i === 0)
|
|
485
|
-
throw new SQLite3Error(`Unknown binding parameter: "${param}"`);
|
|
486
|
-
this._bindValue(value, i);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
_bindValue(value, position) {
|
|
490
|
-
let ret;
|
|
491
|
-
switch (typeof value) {
|
|
492
|
-
case "string":
|
|
493
|
-
const tempPtr = stringToHeap(value);
|
|
494
|
-
ret = sqlite3.bind_text(this._ptr, position, tempPtr, -1, SQLITE_TRANSIENT);
|
|
495
|
-
_free(tempPtr);
|
|
496
|
-
break;
|
|
497
|
-
case "number":
|
|
498
|
-
if (Number.isSafeInteger(value)) {
|
|
499
|
-
if (value >= INT32_MIN && value <= INT32_MAX) {
|
|
500
|
-
ret = sqlite3.bind_int(this._ptr, position, value);
|
|
501
|
-
} else {
|
|
502
|
-
ret = sqlite3.bind_int64(this._ptr, position, BigInt(value));
|
|
503
|
-
}
|
|
504
|
-
} else {
|
|
505
|
-
ret = sqlite3.bind_double(this._ptr, position, value);
|
|
506
|
-
}
|
|
507
|
-
break;
|
|
508
|
-
case "bigint":
|
|
509
|
-
ret = sqlite3.bind_int64(this._ptr, position, value);
|
|
510
|
-
break;
|
|
511
|
-
case "boolean":
|
|
512
|
-
ret = sqlite3.bind_int(this._ptr, position, value ? 1 : 0);
|
|
513
|
-
break;
|
|
514
|
-
case "object":
|
|
515
|
-
if (value === null) {
|
|
516
|
-
ret = sqlite3.bind_null(this._ptr, position);
|
|
517
|
-
} else if (value instanceof Uint8Array) {
|
|
518
|
-
const tempPtr2 = arrayToHeap(value);
|
|
519
|
-
if (value.byteLength <= INT32_MAX) {
|
|
520
|
-
ret = sqlite3.bind_blob(this._ptr, position, tempPtr2, value.byteLength, SQLITE_TRANSIENT);
|
|
521
|
-
} else {
|
|
522
|
-
ret = sqlite3.bind_blob64(this._ptr, position, tempPtr2, BigInt(value.byteLength), SQLITE_TRANSIENT);
|
|
523
|
-
}
|
|
524
|
-
_free(tempPtr2);
|
|
525
|
-
} else {
|
|
526
|
-
throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`);
|
|
527
|
-
}
|
|
528
|
-
break;
|
|
529
|
-
default:
|
|
530
|
-
throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`);
|
|
291
|
+
};
|
|
292
|
+
Error.captureStackTrace(dummy);
|
|
293
|
+
dummy.stack;
|
|
294
|
+
Error.prepareStackTrace = origPST;
|
|
295
|
+
Error.stackTraceLimit = origSTL;
|
|
296
|
+
var fileSchema = "file://";
|
|
297
|
+
if (fileName.indexOf(fileSchema) === 0) {
|
|
298
|
+
fileName = fileURLToPath3(fileName);
|
|
299
|
+
}
|
|
300
|
+
return fileName;
|
|
301
|
+
};
|
|
302
|
+
exports2.getRoot = function getRoot(file) {
|
|
303
|
+
var dir = dirname3(file), prev;
|
|
304
|
+
while (true) {
|
|
305
|
+
if (dir === ".") {
|
|
306
|
+
dir = process.cwd();
|
|
531
307
|
}
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
308
|
+
if (exists(join8(dir, "package.json")) || exists(join8(dir, "node_modules"))) {
|
|
309
|
+
return dir;
|
|
310
|
+
}
|
|
311
|
+
if (prev === dir) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
prev = dir;
|
|
317
|
+
dir = join8(dir, "..");
|
|
540
318
|
}
|
|
541
319
|
};
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
var
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
var SQLITE_IOERR_CLOSE = 4106;
|
|
553
|
-
var SQLITE_IOERR_TRUNCATE = 1546;
|
|
554
|
-
var SQLITE_IOERR_FSTAT = 1802;
|
|
555
|
-
var SQLITE_IOERR_LOCK = 3850;
|
|
556
|
-
var SQLITE_IOERR_UNLOCK = 2058;
|
|
557
|
-
var SQLITE_OPEN_READONLY = 1;
|
|
558
|
-
var SQLITE_OPEN_READWRITE = 2;
|
|
559
|
-
var SQLITE_OPEN_CREATE = 4;
|
|
560
|
-
var SQLITE_OPEN_EXCLUSIVE = 16;
|
|
561
|
-
var SQLITE_ACCESS_READWRITE = 1;
|
|
562
|
-
var SQLITE_ACCESS_READ = 2;
|
|
563
|
-
var SQLITE_LOCK_NONE = 0;
|
|
564
|
-
var SQLITE_BUSY = 5;
|
|
565
|
-
function _fd(fileInfo) {
|
|
566
|
-
return getValue(fileInfo + 4, "i32");
|
|
567
|
-
}
|
|
568
|
-
function _isLocked(fileInfo) {
|
|
569
|
-
return getValue(fileInfo + 8, "i32") != 0;
|
|
570
|
-
}
|
|
571
|
-
function _setLocked(fileInfo, locked) {
|
|
572
|
-
setValue(fileInfo + 8, locked ? 1 : 0, "i32");
|
|
573
|
-
}
|
|
574
|
-
function _path(fileInfo) {
|
|
575
|
-
return UTF8ToString(getValue(fileInfo + 12, "i32"));
|
|
576
|
-
}
|
|
577
|
-
function _safeInt(bigInt) {
|
|
578
|
-
if (bigInt < Number.MIN_SAFE_INTEGER || bigInt > Number.MAX_SAFE_INTEGER)
|
|
579
|
-
throw 0;
|
|
580
|
-
return Number(bigInt);
|
|
581
|
-
}
|
|
582
|
-
var arguments_ = [];
|
|
583
|
-
var thisProgram = "./this.program";
|
|
584
|
-
var quit_ = (status, toThrow) => {
|
|
585
|
-
throw toThrow;
|
|
586
|
-
};
|
|
587
|
-
var _scriptName;
|
|
588
|
-
if (typeof __filename != "undefined") {
|
|
589
|
-
_scriptName = __filename;
|
|
590
|
-
} else {
|
|
591
|
-
}
|
|
592
|
-
var scriptDirectory = "";
|
|
593
|
-
function locateFile(path4) {
|
|
594
|
-
if (Module["locateFile"]) {
|
|
595
|
-
return Module["locateFile"](path4, scriptDirectory);
|
|
596
|
-
}
|
|
597
|
-
return scriptDirectory + path4;
|
|
598
|
-
}
|
|
599
|
-
var readAsync;
|
|
600
|
-
var readBinary;
|
|
601
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
602
|
-
fs3 = require("node:fs");
|
|
603
|
-
scriptDirectory = __dirname + "/";
|
|
604
|
-
readBinary = (filename) => {
|
|
605
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
606
|
-
var ret = fs3.readFileSync(filename);
|
|
607
|
-
return ret;
|
|
608
|
-
};
|
|
609
|
-
readAsync = async (filename, binary = true) => {
|
|
610
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
611
|
-
var ret = fs3.readFileSync(filename, binary ? void 0 : "utf8");
|
|
612
|
-
return ret;
|
|
613
|
-
};
|
|
614
|
-
if (process.argv.length > 1) {
|
|
615
|
-
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
616
|
-
}
|
|
617
|
-
arguments_ = process.argv.slice(2);
|
|
618
|
-
if (typeof module2 != "undefined") {
|
|
619
|
-
module2["exports"] = Module;
|
|
620
|
-
}
|
|
621
|
-
quit_ = (status, toThrow) => {
|
|
622
|
-
process.exitCode = status;
|
|
623
|
-
throw toThrow;
|
|
624
|
-
};
|
|
625
|
-
} else {
|
|
626
|
-
}
|
|
627
|
-
var fs3;
|
|
628
|
-
var out = console.log.bind(console);
|
|
629
|
-
var err = console.error.bind(console);
|
|
630
|
-
var wasmBinary;
|
|
631
|
-
var ABORT2 = false;
|
|
632
|
-
var EXITSTATUS;
|
|
633
|
-
var isFileURI = (filename) => filename.startsWith("file://");
|
|
634
|
-
var runtimeInitialized = false;
|
|
635
|
-
function updateMemoryViews() {
|
|
636
|
-
var b = wasmMemory.buffer;
|
|
637
|
-
HEAP8 = new Int8Array(b);
|
|
638
|
-
HEAP16 = new Int16Array(b);
|
|
639
|
-
HEAPU8 = new Uint8Array(b);
|
|
640
|
-
HEAPU16 = new Uint16Array(b);
|
|
641
|
-
HEAP32 = new Int32Array(b);
|
|
642
|
-
HEAPU32 = new Uint32Array(b);
|
|
643
|
-
HEAPF32 = new Float32Array(b);
|
|
644
|
-
HEAPF64 = new Float64Array(b);
|
|
645
|
-
HEAP64 = new BigInt64Array(b);
|
|
646
|
-
HEAPU64 = new BigUint64Array(b);
|
|
647
|
-
}
|
|
648
|
-
function preRun() {
|
|
649
|
-
if (Module["preRun"]) {
|
|
650
|
-
if (typeof Module["preRun"] == "function")
|
|
651
|
-
Module["preRun"] = [Module["preRun"]];
|
|
652
|
-
while (Module["preRun"].length) {
|
|
653
|
-
addOnPreRun(Module["preRun"].shift());
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
callRuntimeCallbacks(onPreRuns);
|
|
657
|
-
}
|
|
658
|
-
function initRuntime() {
|
|
659
|
-
runtimeInitialized = true;
|
|
660
|
-
wasmExports["z"]();
|
|
661
|
-
}
|
|
662
|
-
function postRun() {
|
|
663
|
-
if (Module["postRun"]) {
|
|
664
|
-
if (typeof Module["postRun"] == "function")
|
|
665
|
-
Module["postRun"] = [Module["postRun"]];
|
|
666
|
-
while (Module["postRun"].length) {
|
|
667
|
-
addOnPostRun(Module["postRun"].shift());
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
callRuntimeCallbacks(onPostRuns);
|
|
671
|
-
}
|
|
672
|
-
function abort(what) {
|
|
673
|
-
Module["onAbort"]?.(what);
|
|
674
|
-
what = `Aborted(${what})`;
|
|
675
|
-
err(what);
|
|
676
|
-
ABORT2 = true;
|
|
677
|
-
what += ". Build with -sASSERTIONS for more info.";
|
|
678
|
-
var e = new WebAssembly.RuntimeError(what);
|
|
679
|
-
throw e;
|
|
680
|
-
}
|
|
681
|
-
var wasmBinaryFile;
|
|
682
|
-
function findWasmBinary() {
|
|
683
|
-
return locateFile("node-sqlite3-wasm.wasm");
|
|
684
|
-
}
|
|
685
|
-
function getBinarySync(file) {
|
|
686
|
-
if (file == wasmBinaryFile && wasmBinary) {
|
|
687
|
-
return new Uint8Array(wasmBinary);
|
|
688
|
-
}
|
|
689
|
-
if (readBinary) {
|
|
690
|
-
return readBinary(file);
|
|
691
|
-
}
|
|
692
|
-
throw 'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)';
|
|
693
|
-
}
|
|
694
|
-
function instantiateSync(file, info) {
|
|
695
|
-
var module3;
|
|
696
|
-
var binary = getBinarySync(file);
|
|
697
|
-
module3 = new WebAssembly.Module(binary);
|
|
698
|
-
var instance = new WebAssembly.Instance(module3, info);
|
|
699
|
-
return [instance, module3];
|
|
700
|
-
}
|
|
701
|
-
function getWasmImports() {
|
|
702
|
-
var imports = { a: wasmImports };
|
|
703
|
-
return imports;
|
|
704
|
-
}
|
|
705
|
-
function createWasm() {
|
|
706
|
-
function receiveInstance(instance, module3) {
|
|
707
|
-
wasmExports = instance.exports;
|
|
708
|
-
assignWasmExports(wasmExports);
|
|
709
|
-
updateMemoryViews();
|
|
710
|
-
return wasmExports;
|
|
711
|
-
}
|
|
712
|
-
var info = getWasmImports();
|
|
713
|
-
if (Module["instantiateWasm"]) {
|
|
714
|
-
return new Promise((resolve, reject) => {
|
|
715
|
-
Module["instantiateWasm"](info, (inst, mod) => {
|
|
716
|
-
resolve(receiveInstance(inst, mod));
|
|
717
|
-
});
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
wasmBinaryFile ??= findWasmBinary();
|
|
721
|
-
var result = instantiateSync(wasmBinaryFile, info);
|
|
722
|
-
return receiveInstance(result[0]);
|
|
723
|
-
}
|
|
724
|
-
var ExitStatus = class {
|
|
725
|
-
name = "ExitStatus";
|
|
726
|
-
constructor(status) {
|
|
727
|
-
this.message = `Program terminated with exit(${status})`;
|
|
728
|
-
this.status = status;
|
|
729
|
-
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
324
|
+
var require_wrappers = __commonJS({
|
|
325
|
+
"node_modules/better-sqlite3/lib/methods/wrappers.js"(exports2) {
|
|
326
|
+
"use strict";
|
|
327
|
+
var { cppdb } = require_util();
|
|
328
|
+
exports2.prepare = function prepare(sql) {
|
|
329
|
+
return this[cppdb].prepare(sql, this, false);
|
|
730
330
|
};
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
var HEAP8;
|
|
735
|
-
var HEAPF32;
|
|
736
|
-
var HEAPF64;
|
|
737
|
-
var HEAPU16;
|
|
738
|
-
var HEAPU32;
|
|
739
|
-
var HEAPU64;
|
|
740
|
-
var HEAPU8;
|
|
741
|
-
var callRuntimeCallbacks = (callbacks) => {
|
|
742
|
-
while (callbacks.length > 0) {
|
|
743
|
-
callbacks.shift()(Module);
|
|
744
|
-
}
|
|
331
|
+
exports2.exec = function exec(sql) {
|
|
332
|
+
this[cppdb].exec(sql);
|
|
333
|
+
return this;
|
|
745
334
|
};
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
750
|
-
function getValue(ptr, type = "i8") {
|
|
751
|
-
if (type.endsWith("*"))
|
|
752
|
-
type = "*";
|
|
753
|
-
switch (type) {
|
|
754
|
-
case "i1":
|
|
755
|
-
return HEAP8[ptr];
|
|
756
|
-
case "i8":
|
|
757
|
-
return HEAP8[ptr];
|
|
758
|
-
case "i16":
|
|
759
|
-
return HEAP16[ptr >> 1];
|
|
760
|
-
case "i32":
|
|
761
|
-
return HEAP32[ptr >> 2];
|
|
762
|
-
case "i64":
|
|
763
|
-
return HEAP64[ptr >> 3];
|
|
764
|
-
case "float":
|
|
765
|
-
return HEAPF32[ptr >> 2];
|
|
766
|
-
case "double":
|
|
767
|
-
return HEAPF64[ptr >> 3];
|
|
768
|
-
case "*":
|
|
769
|
-
return HEAPU32[ptr >> 2];
|
|
770
|
-
default:
|
|
771
|
-
abort(`invalid type for getValue: ${type}`);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
var noExitRuntime = true;
|
|
775
|
-
function setValue(ptr, value, type = "i8") {
|
|
776
|
-
if (type.endsWith("*"))
|
|
777
|
-
type = "*";
|
|
778
|
-
switch (type) {
|
|
779
|
-
case "i1":
|
|
780
|
-
HEAP8[ptr] = value;
|
|
781
|
-
break;
|
|
782
|
-
case "i8":
|
|
783
|
-
HEAP8[ptr] = value;
|
|
784
|
-
break;
|
|
785
|
-
case "i16":
|
|
786
|
-
HEAP16[ptr >> 1] = value;
|
|
787
|
-
break;
|
|
788
|
-
case "i32":
|
|
789
|
-
HEAP32[ptr >> 2] = value;
|
|
790
|
-
break;
|
|
791
|
-
case "i64":
|
|
792
|
-
HEAP64[ptr >> 3] = BigInt(value);
|
|
793
|
-
break;
|
|
794
|
-
case "float":
|
|
795
|
-
HEAPF32[ptr >> 2] = value;
|
|
796
|
-
break;
|
|
797
|
-
case "double":
|
|
798
|
-
HEAPF64[ptr >> 3] = value;
|
|
799
|
-
break;
|
|
800
|
-
case "*":
|
|
801
|
-
HEAPU32[ptr >> 2] = value;
|
|
802
|
-
break;
|
|
803
|
-
default:
|
|
804
|
-
abort(`invalid type for setValue: ${type}`);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
808
|
-
var stackSave = () => _emscripten_stack_get_current();
|
|
809
|
-
var __abort_js = () => abort("");
|
|
810
|
-
var runtimeKeepaliveCounter = 0;
|
|
811
|
-
var __emscripten_runtime_keepalive_clear = () => {
|
|
812
|
-
noExitRuntime = false;
|
|
813
|
-
runtimeKeepaliveCounter = 0;
|
|
335
|
+
exports2.close = function close() {
|
|
336
|
+
this[cppdb].close();
|
|
337
|
+
return this;
|
|
814
338
|
};
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
var ydayFromDate = (date) => {
|
|
819
|
-
var leap = isLeapYear(date.getFullYear());
|
|
820
|
-
var monthDaysCumulative = leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE;
|
|
821
|
-
var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
|
|
822
|
-
return yday;
|
|
339
|
+
exports2.loadExtension = function loadExtension(...args) {
|
|
340
|
+
this[cppdb].loadExtension(...args);
|
|
341
|
+
return this;
|
|
823
342
|
};
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
function __localtime_js(time, tmPtr) {
|
|
828
|
-
time = bigintToI53Checked(time);
|
|
829
|
-
var date = new Date(time * 1e3);
|
|
830
|
-
HEAP32[tmPtr >> 2] = date.getSeconds();
|
|
831
|
-
HEAP32[tmPtr + 4 >> 2] = date.getMinutes();
|
|
832
|
-
HEAP32[tmPtr + 8 >> 2] = date.getHours();
|
|
833
|
-
HEAP32[tmPtr + 12 >> 2] = date.getDate();
|
|
834
|
-
HEAP32[tmPtr + 16 >> 2] = date.getMonth();
|
|
835
|
-
HEAP32[tmPtr + 20 >> 2] = date.getFullYear() - 1900;
|
|
836
|
-
HEAP32[tmPtr + 24 >> 2] = date.getDay();
|
|
837
|
-
var yday = ydayFromDate(date) | 0;
|
|
838
|
-
HEAP32[tmPtr + 28 >> 2] = yday;
|
|
839
|
-
HEAP32[tmPtr + 36 >> 2] = -(date.getTimezoneOffset() * 60);
|
|
840
|
-
var start = new Date(date.getFullYear(), 0, 1);
|
|
841
|
-
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
|
|
842
|
-
var winterOffset = start.getTimezoneOffset();
|
|
843
|
-
var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
|
|
844
|
-
HEAP32[tmPtr + 32 >> 2] = dst;
|
|
845
|
-
}
|
|
846
|
-
var timers = {};
|
|
847
|
-
var handleException = (e) => {
|
|
848
|
-
if (e instanceof ExitStatus || e == "unwind") {
|
|
849
|
-
return EXITSTATUS;
|
|
850
|
-
}
|
|
851
|
-
quit_(1, e);
|
|
343
|
+
exports2.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
344
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
345
|
+
return this;
|
|
852
346
|
};
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
if (!keepRuntimeAlive()) {
|
|
857
|
-
Module["onExit"]?.(code);
|
|
858
|
-
ABORT2 = true;
|
|
859
|
-
}
|
|
860
|
-
quit_(code, new ExitStatus(code));
|
|
347
|
+
exports2.unsafeMode = function unsafeMode(...args) {
|
|
348
|
+
this[cppdb].unsafeMode(...args);
|
|
349
|
+
return this;
|
|
861
350
|
};
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
351
|
+
exports2.getters = {
|
|
352
|
+
name: {
|
|
353
|
+
get: function name() {
|
|
354
|
+
return this[cppdb].name;
|
|
355
|
+
},
|
|
356
|
+
enumerable: true
|
|
357
|
+
},
|
|
358
|
+
open: {
|
|
359
|
+
get: function open() {
|
|
360
|
+
return this[cppdb].open;
|
|
361
|
+
},
|
|
362
|
+
enumerable: true
|
|
363
|
+
},
|
|
364
|
+
inTransaction: {
|
|
365
|
+
get: function inTransaction() {
|
|
366
|
+
return this[cppdb].inTransaction;
|
|
367
|
+
},
|
|
368
|
+
enumerable: true
|
|
369
|
+
},
|
|
370
|
+
readonly: {
|
|
371
|
+
get: function readonly() {
|
|
372
|
+
return this[cppdb].readonly;
|
|
373
|
+
},
|
|
374
|
+
enumerable: true
|
|
375
|
+
},
|
|
376
|
+
memory: {
|
|
377
|
+
get: function memory() {
|
|
378
|
+
return this[cppdb].memory;
|
|
379
|
+
},
|
|
380
|
+
enumerable: true
|
|
381
|
+
}
|
|
865
382
|
};
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// node_modules/better-sqlite3/lib/methods/transaction.js
|
|
387
|
+
var require_transaction = __commonJS({
|
|
388
|
+
"node_modules/better-sqlite3/lib/methods/transaction.js"(exports2, module2) {
|
|
389
|
+
"use strict";
|
|
390
|
+
var { cppdb } = require_util();
|
|
391
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
392
|
+
module2.exports = function transaction(fn) {
|
|
393
|
+
if (typeof fn !== "function")
|
|
394
|
+
throw new TypeError("Expected first argument to be a function");
|
|
395
|
+
const db3 = this[cppdb];
|
|
396
|
+
const controller = getController(db3, this);
|
|
397
|
+
const { apply } = Function.prototype;
|
|
398
|
+
const properties = {
|
|
399
|
+
default: { value: wrapTransaction(apply, fn, db3, controller.default) },
|
|
400
|
+
deferred: { value: wrapTransaction(apply, fn, db3, controller.deferred) },
|
|
401
|
+
immediate: { value: wrapTransaction(apply, fn, db3, controller.immediate) },
|
|
402
|
+
exclusive: { value: wrapTransaction(apply, fn, db3, controller.exclusive) },
|
|
403
|
+
database: { value: this, enumerable: true }
|
|
404
|
+
};
|
|
405
|
+
Object.defineProperties(properties.default.value, properties);
|
|
406
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
407
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
408
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
409
|
+
return properties.default.value;
|
|
410
|
+
};
|
|
411
|
+
var getController = (db3, self) => {
|
|
412
|
+
let controller = controllers.get(db3);
|
|
413
|
+
if (!controller) {
|
|
414
|
+
const shared = {
|
|
415
|
+
commit: db3.prepare("COMMIT", self, false),
|
|
416
|
+
rollback: db3.prepare("ROLLBACK", self, false),
|
|
417
|
+
savepoint: db3.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
418
|
+
release: db3.prepare("RELEASE ` _bs3. `", self, false),
|
|
419
|
+
rollbackTo: db3.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
420
|
+
};
|
|
421
|
+
controllers.set(db3, controller = {
|
|
422
|
+
default: Object.assign({ begin: db3.prepare("BEGIN", self, false) }, shared),
|
|
423
|
+
deferred: Object.assign({ begin: db3.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
424
|
+
immediate: Object.assign({ begin: db3.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
425
|
+
exclusive: Object.assign({ begin: db3.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
426
|
+
});
|
|
874
427
|
}
|
|
428
|
+
return controller;
|
|
875
429
|
};
|
|
876
|
-
var
|
|
877
|
-
|
|
878
|
-
|
|
430
|
+
var wrapTransaction = (apply, fn, db3, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
431
|
+
let before, after, undo;
|
|
432
|
+
if (db3.inTransaction) {
|
|
433
|
+
before = savepoint;
|
|
434
|
+
after = release;
|
|
435
|
+
undo = rollbackTo;
|
|
436
|
+
} else {
|
|
437
|
+
before = begin;
|
|
438
|
+
after = commit;
|
|
439
|
+
undo = rollback;
|
|
879
440
|
}
|
|
441
|
+
before.run();
|
|
880
442
|
try {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
443
|
+
const result = apply.call(fn, this, arguments);
|
|
444
|
+
if (result && typeof result.then === "function") {
|
|
445
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
446
|
+
}
|
|
447
|
+
after.run();
|
|
448
|
+
return result;
|
|
449
|
+
} catch (ex) {
|
|
450
|
+
if (db3.inTransaction) {
|
|
451
|
+
undo.run();
|
|
452
|
+
if (undo !== rollback)
|
|
453
|
+
after.run();
|
|
454
|
+
}
|
|
455
|
+
throw ex;
|
|
886
456
|
}
|
|
887
457
|
};
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// node_modules/better-sqlite3/lib/methods/pragma.js
|
|
462
|
+
var require_pragma = __commonJS({
|
|
463
|
+
"node_modules/better-sqlite3/lib/methods/pragma.js"(exports2, module2) {
|
|
464
|
+
"use strict";
|
|
465
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
466
|
+
module2.exports = function pragma(source, options) {
|
|
467
|
+
if (options == null)
|
|
468
|
+
options = {};
|
|
469
|
+
if (typeof source !== "string")
|
|
470
|
+
throw new TypeError("Expected first argument to be a string");
|
|
471
|
+
if (typeof options !== "object")
|
|
472
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
473
|
+
const simple = getBooleanOption(options, "simple");
|
|
474
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
475
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
902
476
|
};
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// node_modules/better-sqlite3/lib/methods/backup.js
|
|
481
|
+
var require_backup = __commonJS({
|
|
482
|
+
"node_modules/better-sqlite3/lib/methods/backup.js"(exports2, module2) {
|
|
483
|
+
"use strict";
|
|
484
|
+
var fs3 = require("fs");
|
|
485
|
+
var path3 = require("path");
|
|
486
|
+
var { promisify: promisify2 } = require("util");
|
|
487
|
+
var { cppdb } = require_util();
|
|
488
|
+
var fsAccess = promisify2(fs3.access);
|
|
489
|
+
module2.exports = async function backup(filename, options) {
|
|
490
|
+
if (options == null)
|
|
491
|
+
options = {};
|
|
492
|
+
if (typeof filename !== "string")
|
|
493
|
+
throw new TypeError("Expected first argument to be a string");
|
|
494
|
+
if (typeof options !== "object")
|
|
495
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
496
|
+
filename = filename.trim();
|
|
497
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
498
|
+
const handler = "progress" in options ? options.progress : null;
|
|
499
|
+
if (!filename)
|
|
500
|
+
throw new TypeError("Backup filename cannot be an empty string");
|
|
501
|
+
if (filename === ":memory:")
|
|
502
|
+
throw new TypeError('Invalid backup filename ":memory:"');
|
|
503
|
+
if (typeof attachedName !== "string")
|
|
504
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
505
|
+
if (!attachedName)
|
|
506
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
507
|
+
if (handler != null && typeof handler !== "function")
|
|
508
|
+
throw new TypeError('Expected the "progress" option to be a function');
|
|
509
|
+
await fsAccess(path3.dirname(filename)).catch(() => {
|
|
510
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
511
|
+
});
|
|
512
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
513
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
514
|
+
};
|
|
515
|
+
var runBackup = (backup, handler) => {
|
|
516
|
+
let rate = 0;
|
|
517
|
+
let useDefault = true;
|
|
518
|
+
return new Promise((resolve, reject) => {
|
|
519
|
+
setImmediate(function step() {
|
|
520
|
+
try {
|
|
521
|
+
const progress = backup.transfer(rate);
|
|
522
|
+
if (!progress.remainingPages) {
|
|
523
|
+
backup.close();
|
|
524
|
+
resolve(progress);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (useDefault) {
|
|
528
|
+
useDefault = false;
|
|
529
|
+
rate = 100;
|
|
530
|
+
}
|
|
531
|
+
if (handler) {
|
|
532
|
+
const ret = handler(progress);
|
|
533
|
+
if (ret !== void 0) {
|
|
534
|
+
if (typeof ret === "number" && ret === ret)
|
|
535
|
+
rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
536
|
+
else
|
|
537
|
+
throw new TypeError("Expected progress callback to return a number or undefined");
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
setImmediate(step);
|
|
541
|
+
} catch (err) {
|
|
542
|
+
backup.close();
|
|
543
|
+
reject(err);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
937
547
|
};
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
if (summerOffset < winterOffset) {
|
|
958
|
-
stringToUTF8(winterName, std_name, 17);
|
|
959
|
-
stringToUTF8(summerName, dst_name, 17);
|
|
960
|
-
} else {
|
|
961
|
-
stringToUTF8(winterName, dst_name, 17);
|
|
962
|
-
stringToUTF8(summerName, std_name, 17);
|
|
963
|
-
}
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// node_modules/better-sqlite3/lib/methods/serialize.js
|
|
552
|
+
var require_serialize = __commonJS({
|
|
553
|
+
"node_modules/better-sqlite3/lib/methods/serialize.js"(exports2, module2) {
|
|
554
|
+
"use strict";
|
|
555
|
+
var { cppdb } = require_util();
|
|
556
|
+
module2.exports = function serialize(options) {
|
|
557
|
+
if (options == null)
|
|
558
|
+
options = {};
|
|
559
|
+
if (typeof options !== "object")
|
|
560
|
+
throw new TypeError("Expected first argument to be an options object");
|
|
561
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
562
|
+
if (typeof attachedName !== "string")
|
|
563
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
564
|
+
if (!attachedName)
|
|
565
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
566
|
+
return this[cppdb].serialize(attachedName);
|
|
964
567
|
};
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// node_modules/better-sqlite3/lib/methods/function.js
|
|
572
|
+
var require_function = __commonJS({
|
|
573
|
+
"node_modules/better-sqlite3/lib/methods/function.js"(exports2, module2) {
|
|
574
|
+
"use strict";
|
|
575
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
576
|
+
module2.exports = function defineFunction(name, options, fn) {
|
|
577
|
+
if (options == null)
|
|
578
|
+
options = {};
|
|
579
|
+
if (typeof options === "function") {
|
|
580
|
+
fn = options;
|
|
581
|
+
options = {};
|
|
976
582
|
}
|
|
583
|
+
if (typeof name !== "string")
|
|
584
|
+
throw new TypeError("Expected first argument to be a string");
|
|
585
|
+
if (typeof fn !== "function")
|
|
586
|
+
throw new TypeError("Expected last argument to be a function");
|
|
587
|
+
if (typeof options !== "object")
|
|
588
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
589
|
+
if (!name)
|
|
590
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
591
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
592
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
593
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
594
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
595
|
+
let argCount = -1;
|
|
596
|
+
if (!varargs) {
|
|
597
|
+
argCount = fn.length;
|
|
598
|
+
if (!Number.isInteger(argCount) || argCount < 0)
|
|
599
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
600
|
+
if (argCount > 100)
|
|
601
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
602
|
+
}
|
|
603
|
+
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
604
|
+
return this;
|
|
977
605
|
};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
610
|
+
var require_aggregate = __commonJS({
|
|
611
|
+
"node_modules/better-sqlite3/lib/methods/aggregate.js"(exports2, module2) {
|
|
612
|
+
"use strict";
|
|
613
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
614
|
+
module2.exports = function defineAggregate(name, options) {
|
|
615
|
+
if (typeof name !== "string")
|
|
616
|
+
throw new TypeError("Expected first argument to be a string");
|
|
617
|
+
if (typeof options !== "object" || options === null)
|
|
618
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
619
|
+
if (!name)
|
|
620
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
621
|
+
const start = "start" in options ? options.start : null;
|
|
622
|
+
const step = getFunctionOption(options, "step", true);
|
|
623
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
624
|
+
const result = getFunctionOption(options, "result", false);
|
|
625
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
626
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
627
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
628
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
629
|
+
let argCount = -1;
|
|
630
|
+
if (!varargs) {
|
|
631
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
632
|
+
if (argCount > 0)
|
|
633
|
+
argCount -= 1;
|
|
634
|
+
if (argCount > 100)
|
|
635
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
636
|
+
}
|
|
637
|
+
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
638
|
+
return this;
|
|
995
639
|
};
|
|
996
|
-
var
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
640
|
+
var getFunctionOption = (options, key, required) => {
|
|
641
|
+
const value = key in options ? options[key] : null;
|
|
642
|
+
if (typeof value === "function")
|
|
643
|
+
return value;
|
|
644
|
+
if (value != null)
|
|
645
|
+
throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
646
|
+
if (required)
|
|
647
|
+
throw new TypeError(`Missing required option "${key}"`);
|
|
648
|
+
return null;
|
|
1004
649
|
};
|
|
1005
|
-
var
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
1010
|
-
var str = "";
|
|
1011
|
-
while (idx < endPtr) {
|
|
1012
|
-
var u0 = heapOrArray[idx++];
|
|
1013
|
-
if (!(u0 & 128)) {
|
|
1014
|
-
str += String.fromCharCode(u0);
|
|
1015
|
-
continue;
|
|
1016
|
-
}
|
|
1017
|
-
var u1 = heapOrArray[idx++] & 63;
|
|
1018
|
-
if ((u0 & 224) == 192) {
|
|
1019
|
-
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
1020
|
-
continue;
|
|
1021
|
-
}
|
|
1022
|
-
var u2 = heapOrArray[idx++] & 63;
|
|
1023
|
-
if ((u0 & 240) == 224) {
|
|
1024
|
-
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
1025
|
-
} else {
|
|
1026
|
-
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
1027
|
-
}
|
|
1028
|
-
if (u0 < 65536) {
|
|
1029
|
-
str += String.fromCharCode(u0);
|
|
1030
|
-
} else {
|
|
1031
|
-
var ch = u0 - 65536;
|
|
1032
|
-
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
return str;
|
|
650
|
+
var getLength = ({ length }) => {
|
|
651
|
+
if (Number.isInteger(length) && length >= 0)
|
|
652
|
+
return length;
|
|
653
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
1036
654
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
// node_modules/better-sqlite3/lib/methods/table.js
|
|
659
|
+
var require_table = __commonJS({
|
|
660
|
+
"node_modules/better-sqlite3/lib/methods/table.js"(exports2, module2) {
|
|
661
|
+
"use strict";
|
|
662
|
+
var { cppdb } = require_util();
|
|
663
|
+
module2.exports = function defineTable(name, factory) {
|
|
664
|
+
if (typeof name !== "string")
|
|
665
|
+
throw new TypeError("Expected first argument to be a string");
|
|
666
|
+
if (!name)
|
|
667
|
+
throw new TypeError("Virtual table module name cannot be an empty string");
|
|
668
|
+
let eponymous = false;
|
|
669
|
+
if (typeof factory === "object" && factory !== null) {
|
|
670
|
+
eponymous = true;
|
|
671
|
+
factory = defer2(parseTableDefinition(factory, "used", name));
|
|
672
|
+
} else {
|
|
673
|
+
if (typeof factory !== "function")
|
|
674
|
+
throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
675
|
+
factory = wrapFactory(factory);
|
|
1058
676
|
}
|
|
1059
|
-
|
|
677
|
+
this[cppdb].table(factory, name, eponymous);
|
|
678
|
+
return this;
|
|
679
|
+
};
|
|
680
|
+
function wrapFactory(factory) {
|
|
681
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
682
|
+
const thisObject = {
|
|
683
|
+
module: moduleName,
|
|
684
|
+
database: databaseName,
|
|
685
|
+
table: tableName
|
|
686
|
+
};
|
|
687
|
+
const def = apply.call(factory, thisObject, args);
|
|
688
|
+
if (typeof def !== "object" || def === null) {
|
|
689
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
690
|
+
}
|
|
691
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
692
|
+
};
|
|
1060
693
|
}
|
|
1061
|
-
function
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
fs3.closeSync(_fd(fi));
|
|
1065
|
-
} catch {
|
|
1066
|
-
return SQLITE_IOERR_CLOSE;
|
|
694
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
695
|
+
if (!hasOwnProperty.call(def, "rows")) {
|
|
696
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
1067
697
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
function _nodejsDelete(vfs, filePath, dirSync) {
|
|
1071
|
-
const pathStr = UTF8ToString(filePath);
|
|
1072
|
-
try {
|
|
1073
|
-
fs3.unlinkSync(pathStr);
|
|
1074
|
-
} catch (err2) {
|
|
1075
|
-
if (err2.code != "ENOENT")
|
|
1076
|
-
return SQLITE_IOERR_DELETE;
|
|
698
|
+
if (!hasOwnProperty.call(def, "columns")) {
|
|
699
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
1077
700
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
fd = fs3.openSync(path3.dirname(pathStr), "r");
|
|
1082
|
-
fs3.fsyncSync(fd);
|
|
1083
|
-
} catch {
|
|
1084
|
-
return SQLITE_IOERR_FSYNC;
|
|
1085
|
-
} finally {
|
|
1086
|
-
try {
|
|
1087
|
-
fs3.closeSync(fd);
|
|
1088
|
-
} catch {
|
|
1089
|
-
return SQLITE_IOERR_FSYNC;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
701
|
+
const rows = def.rows;
|
|
702
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
703
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
1092
704
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
try {
|
|
1097
|
-
setValue(outSize, fs3.fstatSync(_fd(fi)).size, "i64");
|
|
1098
|
-
} catch {
|
|
1099
|
-
return SQLITE_IOERR_FSTAT;
|
|
705
|
+
let columns = def.columns;
|
|
706
|
+
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
707
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
1100
708
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
function _nodejsFullPathname(vfs, relPath, sizeFullPath, outFullPath) {
|
|
1104
|
-
const full = path3.resolve(UTF8ToString(relPath));
|
|
1105
|
-
stringToUTF8(full, outFullPath, sizeFullPath);
|
|
1106
|
-
return full.length < sizeFullPath ? SQLITE_OK : SQLITE_CANTOPEN;
|
|
1107
|
-
}
|
|
1108
|
-
function _nodejsLock(fi, level) {
|
|
1109
|
-
if (!_isLocked(fi)) {
|
|
1110
|
-
try {
|
|
1111
|
-
fs3.mkdirSync(`${_path(fi)}.lock`);
|
|
1112
|
-
} catch (err2) {
|
|
1113
|
-
return err2.code == "EEXIST" ? SQLITE_BUSY : SQLITE_IOERR_LOCK;
|
|
1114
|
-
}
|
|
1115
|
-
_setLocked(fi, true);
|
|
709
|
+
if (columns.length !== new Set(columns).size) {
|
|
710
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
1116
711
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
function _nodejsRandomness(vfs, bytes, outBuffer) {
|
|
1120
|
-
const buf = HEAPU8.subarray(outBuffer, outBuffer + bytes);
|
|
1121
|
-
crypto.randomFillSync(buf);
|
|
1122
|
-
return bytes;
|
|
1123
|
-
}
|
|
1124
|
-
function _nodejsRead(fi, outBuffer, bytes, offset) {
|
|
1125
|
-
const buf = HEAPU8.subarray(outBuffer, outBuffer + bytes);
|
|
1126
|
-
let bytesRead;
|
|
1127
|
-
try {
|
|
1128
|
-
bytesRead = fs3.readSync(_fd(fi), buf, 0, bytes, offset);
|
|
1129
|
-
} catch {
|
|
1130
|
-
return SQLITE_IOERR_READ;
|
|
712
|
+
if (!columns.length) {
|
|
713
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
1131
714
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1137
|
-
buf.fill(0, bytesRead);
|
|
1138
|
-
} catch {
|
|
1139
|
-
return SQLITE_IOERR_READ;
|
|
1140
|
-
}
|
|
715
|
+
let parameters;
|
|
716
|
+
if (hasOwnProperty.call(def, "parameters")) {
|
|
717
|
+
parameters = def.parameters;
|
|
718
|
+
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
719
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
1141
720
|
}
|
|
1142
|
-
|
|
721
|
+
} else {
|
|
722
|
+
parameters = inferParameters(rows);
|
|
1143
723
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
function _nodejsSync(fi, flags) {
|
|
1147
|
-
try {
|
|
1148
|
-
fs3.fsyncSync(_fd(fi));
|
|
1149
|
-
} catch {
|
|
1150
|
-
return SQLITE_IOERR_FSYNC;
|
|
724
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
725
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
1151
726
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
function _nodejsTruncate(fi, size) {
|
|
1155
|
-
try {
|
|
1156
|
-
fs3.ftruncateSync(_fd(fi), _safeInt(size));
|
|
1157
|
-
} catch {
|
|
1158
|
-
return SQLITE_IOERR_TRUNCATE;
|
|
727
|
+
if (parameters.length > 32) {
|
|
728
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
1159
729
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
if (level == SQLITE_LOCK_NONE && _isLocked(fi)) {
|
|
1164
|
-
try {
|
|
1165
|
-
fs3.rmdirSync(`${_path(fi)}.lock`);
|
|
1166
|
-
} catch (err2) {
|
|
1167
|
-
if (err2.code != "ENOENT")
|
|
1168
|
-
return SQLITE_IOERR_UNLOCK;
|
|
730
|
+
for (const parameter of parameters) {
|
|
731
|
+
if (columns.includes(parameter)) {
|
|
732
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
1169
733
|
}
|
|
1170
|
-
_setLocked(fi, false);
|
|
1171
734
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
return SQLITE_IOERR_WRITE;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
function _nodejs_max_path_length() {
|
|
1183
|
-
return process.platform == "win32" ? 260 : 4096;
|
|
1184
|
-
}
|
|
1185
|
-
function _nodejs_open(filePath, flags, mode) {
|
|
1186
|
-
let oflags = 0;
|
|
1187
|
-
if (flags & SQLITE_OPEN_EXCLUSIVE)
|
|
1188
|
-
oflags |= fs3.constants.O_EXCL;
|
|
1189
|
-
if (flags & SQLITE_OPEN_CREATE)
|
|
1190
|
-
oflags |= fs3.constants.O_CREAT;
|
|
1191
|
-
if (flags & SQLITE_OPEN_READONLY)
|
|
1192
|
-
oflags |= fs3.constants.O_RDONLY;
|
|
1193
|
-
if (flags & SQLITE_OPEN_READWRITE)
|
|
1194
|
-
oflags |= fs3.constants.O_RDWR;
|
|
1195
|
-
try {
|
|
1196
|
-
return fs3.openSync(UTF8ToString(filePath), oflags, mode);
|
|
1197
|
-
} catch {
|
|
1198
|
-
return -1;
|
|
735
|
+
let safeIntegers = 2;
|
|
736
|
+
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
737
|
+
const bool = def.safeIntegers;
|
|
738
|
+
if (typeof bool !== "boolean") {
|
|
739
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
740
|
+
}
|
|
741
|
+
safeIntegers = +bool;
|
|
1199
742
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
var writeArrayToMemory = (array, buffer) => {
|
|
1206
|
-
HEAP8.set(array, buffer);
|
|
1207
|
-
};
|
|
1208
|
-
var lengthBytesUTF8 = (str) => {
|
|
1209
|
-
var len = 0;
|
|
1210
|
-
for (var i = 0; i < str.length; ++i) {
|
|
1211
|
-
var c = str.charCodeAt(i);
|
|
1212
|
-
if (c <= 127) {
|
|
1213
|
-
len++;
|
|
1214
|
-
} else if (c <= 2047) {
|
|
1215
|
-
len += 2;
|
|
1216
|
-
} else if (c >= 55296 && c <= 57343) {
|
|
1217
|
-
len += 4;
|
|
1218
|
-
++i;
|
|
1219
|
-
} else {
|
|
1220
|
-
len += 3;
|
|
743
|
+
let directOnly = false;
|
|
744
|
+
if (hasOwnProperty.call(def, "directOnly")) {
|
|
745
|
+
directOnly = def.directOnly;
|
|
746
|
+
if (typeof directOnly !== "boolean") {
|
|
747
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
1221
748
|
}
|
|
1222
749
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
if (returnType === "boolean")
|
|
1249
|
-
return Boolean(ret2);
|
|
1250
|
-
return ret2;
|
|
1251
|
-
}
|
|
1252
|
-
var func = getCFunc(ident);
|
|
1253
|
-
var cArgs = [];
|
|
1254
|
-
var stack = 0;
|
|
1255
|
-
if (args) {
|
|
1256
|
-
for (var i = 0; i < args.length; i++) {
|
|
1257
|
-
var converter = toC[argTypes[i]];
|
|
1258
|
-
if (converter) {
|
|
1259
|
-
if (stack === 0)
|
|
1260
|
-
stack = stackSave();
|
|
1261
|
-
cArgs[i] = converter(args[i]);
|
|
750
|
+
const columnDefinitions = [
|
|
751
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
752
|
+
...columns.map(identifier)
|
|
753
|
+
];
|
|
754
|
+
return [
|
|
755
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
756
|
+
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
757
|
+
parameters,
|
|
758
|
+
safeIntegers,
|
|
759
|
+
directOnly
|
|
760
|
+
];
|
|
761
|
+
}
|
|
762
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
763
|
+
return function* virtualTable(...args) {
|
|
764
|
+
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
765
|
+
for (let i = 0; i < columnMap.size; ++i) {
|
|
766
|
+
output.push(null);
|
|
767
|
+
}
|
|
768
|
+
for (const row of generator(...args)) {
|
|
769
|
+
if (Array.isArray(row)) {
|
|
770
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
771
|
+
yield output;
|
|
772
|
+
} else if (typeof row === "object" && row !== null) {
|
|
773
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
774
|
+
yield output;
|
|
1262
775
|
} else {
|
|
1263
|
-
|
|
776
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
1264
777
|
}
|
|
1265
778
|
}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
782
|
+
if (row.length !== columnCount) {
|
|
783
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
1266
784
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
stackRestore(stack);
|
|
1271
|
-
return convertReturnValue(ret2);
|
|
1272
|
-
}
|
|
1273
|
-
ret = onDone(ret);
|
|
1274
|
-
return ret;
|
|
1275
|
-
};
|
|
1276
|
-
var cwrap = (ident, returnType, argTypes, opts) => {
|
|
1277
|
-
var numericArgs = !argTypes || argTypes.every((type) => type === "number" || type === "boolean");
|
|
1278
|
-
var numericRet = returnType !== "string";
|
|
1279
|
-
if (numericRet && numericArgs && !opts) {
|
|
1280
|
-
return getCFunc(ident);
|
|
785
|
+
const offset = output.length - columnCount;
|
|
786
|
+
for (let i = 0; i < columnCount; ++i) {
|
|
787
|
+
output[i + offset] = row[i];
|
|
1281
788
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
}
|
|
1290
|
-
return func;
|
|
1291
|
-
};
|
|
1292
|
-
var updateTableMap = (offset, count) => {
|
|
1293
|
-
if (functionsInTableMap) {
|
|
1294
|
-
for (var i = offset; i < offset + count; i++) {
|
|
1295
|
-
var item = getWasmTableEntry(i);
|
|
1296
|
-
if (item) {
|
|
1297
|
-
functionsInTableMap.set(item, i);
|
|
1298
|
-
}
|
|
789
|
+
}
|
|
790
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
791
|
+
let count = 0;
|
|
792
|
+
for (const key of Object.keys(row)) {
|
|
793
|
+
const index = columnMap.get(key);
|
|
794
|
+
if (index === void 0) {
|
|
795
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
1299
796
|
}
|
|
797
|
+
output[index] = row[key];
|
|
798
|
+
count += 1;
|
|
1300
799
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
var getFunctionAddress = (func) => {
|
|
1304
|
-
if (!functionsInTableMap) {
|
|
1305
|
-
functionsInTableMap = /* @__PURE__ */ new WeakMap();
|
|
1306
|
-
updateTableMap(0, wasmTable.length);
|
|
1307
|
-
}
|
|
1308
|
-
return functionsInTableMap.get(func) || 0;
|
|
1309
|
-
};
|
|
1310
|
-
var freeTableIndexes = [];
|
|
1311
|
-
var getEmptyTableSlot = () => {
|
|
1312
|
-
if (freeTableIndexes.length) {
|
|
1313
|
-
return freeTableIndexes.pop();
|
|
800
|
+
if (count !== columnMap.size) {
|
|
801
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
1314
802
|
}
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
1320
|
-
};
|
|
1321
|
-
var uleb128EncodeWithLen = (arr) => {
|
|
1322
|
-
const n = arr.length;
|
|
1323
|
-
return [n % 128 | 128, n >> 7, ...arr];
|
|
1324
|
-
};
|
|
1325
|
-
var wasmTypeCodes = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
1326
|
-
var generateTypePack = (types2) => uleb128EncodeWithLen(Array.from(types2, (type) => {
|
|
1327
|
-
var code = wasmTypeCodes[type];
|
|
1328
|
-
return code;
|
|
1329
|
-
}));
|
|
1330
|
-
var convertJsFunctionToWasm = (func, sig) => {
|
|
1331
|
-
var bytes = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...uleb128EncodeWithLen([1, 96, ...generateTypePack(sig.slice(1)), ...generateTypePack(sig[0] === "v" ? "" : sig[0])]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
1332
|
-
var module3 = new WebAssembly.Module(bytes);
|
|
1333
|
-
var instance = new WebAssembly.Instance(module3, { e: { f: func } });
|
|
1334
|
-
var wrappedFunc = instance.exports["f"];
|
|
1335
|
-
return wrappedFunc;
|
|
1336
|
-
};
|
|
1337
|
-
var addFunction = (func, sig) => {
|
|
1338
|
-
var rtn = getFunctionAddress(func);
|
|
1339
|
-
if (rtn) {
|
|
1340
|
-
return rtn;
|
|
803
|
+
}
|
|
804
|
+
function inferParameters({ length }) {
|
|
805
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
806
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
1341
807
|
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
} catch (err2) {
|
|
1346
|
-
if (!(err2 instanceof TypeError)) {
|
|
1347
|
-
throw err2;
|
|
1348
|
-
}
|
|
1349
|
-
var wrapped = convertJsFunctionToWasm(func, sig);
|
|
1350
|
-
setWasmTableEntry(ret, wrapped);
|
|
808
|
+
const params = [];
|
|
809
|
+
for (let i = 0; i < length; ++i) {
|
|
810
|
+
params.push(`$${i + 1}`);
|
|
1351
811
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
812
|
+
return params;
|
|
813
|
+
}
|
|
814
|
+
var { hasOwnProperty } = Object.prototype;
|
|
815
|
+
var { apply } = Function.prototype;
|
|
816
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
817
|
+
});
|
|
818
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
819
|
+
var defer2 = (x) => () => x;
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
824
|
+
var require_inspect = __commonJS({
|
|
825
|
+
"node_modules/better-sqlite3/lib/methods/inspect.js"(exports2, module2) {
|
|
826
|
+
"use strict";
|
|
827
|
+
var DatabaseInspection = function Database2() {
|
|
1354
828
|
};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
setWasmTableEntry(index, null);
|
|
1358
|
-
freeTableIndexes.push(index);
|
|
829
|
+
module2.exports = function inspect(depth, opts) {
|
|
830
|
+
return Object.assign(new DatabaseInspection(), this);
|
|
1359
831
|
};
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
if (
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
var _sqlite3_bind_null;
|
|
1417
|
-
var _sqlite3_bind_text;
|
|
1418
|
-
var _sqlite3_bind_parameter_index;
|
|
1419
|
-
var _sqlite3_exec;
|
|
1420
|
-
var _sqlite3_prepare_v2;
|
|
1421
|
-
var _sqlite3_errmsg;
|
|
1422
|
-
var _sqlite3_last_insert_rowid;
|
|
1423
|
-
var _sqlite3_changes;
|
|
1424
|
-
var _sqlite3_close_v2;
|
|
1425
|
-
var _sqlite3_create_function_v2;
|
|
1426
|
-
var _sqlite3_open_v2;
|
|
1427
|
-
var _sqlite3_get_autocommit;
|
|
1428
|
-
var _malloc;
|
|
1429
|
-
var _free;
|
|
1430
|
-
var __emscripten_timeout;
|
|
1431
|
-
var __emscripten_stack_restore;
|
|
1432
|
-
var __emscripten_stack_alloc;
|
|
1433
|
-
var _emscripten_stack_get_current;
|
|
1434
|
-
var memory;
|
|
1435
|
-
var __indirect_function_table;
|
|
1436
|
-
var wasmMemory;
|
|
1437
|
-
var wasmTable;
|
|
1438
|
-
function assignWasmExports(wasmExports2) {
|
|
1439
|
-
_sqlite3_finalize = Module["_sqlite3_finalize"] = wasmExports2["A"];
|
|
1440
|
-
_sqlite3_reset = Module["_sqlite3_reset"] = wasmExports2["B"];
|
|
1441
|
-
_sqlite3_clear_bindings = Module["_sqlite3_clear_bindings"] = wasmExports2["C"];
|
|
1442
|
-
_sqlite3_value_blob = Module["_sqlite3_value_blob"] = wasmExports2["D"];
|
|
1443
|
-
_sqlite3_value_text = Module["_sqlite3_value_text"] = wasmExports2["E"];
|
|
1444
|
-
_sqlite3_value_bytes = Module["_sqlite3_value_bytes"] = wasmExports2["F"];
|
|
1445
|
-
_sqlite3_value_double = Module["_sqlite3_value_double"] = wasmExports2["G"];
|
|
1446
|
-
_sqlite3_value_int64 = Module["_sqlite3_value_int64"] = wasmExports2["H"];
|
|
1447
|
-
_sqlite3_value_type = Module["_sqlite3_value_type"] = wasmExports2["I"];
|
|
1448
|
-
_sqlite3_result_blob = Module["_sqlite3_result_blob"] = wasmExports2["J"];
|
|
1449
|
-
_sqlite3_result_blob64 = Module["_sqlite3_result_blob64"] = wasmExports2["K"];
|
|
1450
|
-
_sqlite3_result_double = Module["_sqlite3_result_double"] = wasmExports2["L"];
|
|
1451
|
-
_sqlite3_result_error = Module["_sqlite3_result_error"] = wasmExports2["M"];
|
|
1452
|
-
_sqlite3_result_int = Module["_sqlite3_result_int"] = wasmExports2["N"];
|
|
1453
|
-
_sqlite3_result_int64 = Module["_sqlite3_result_int64"] = wasmExports2["O"];
|
|
1454
|
-
_sqlite3_result_null = Module["_sqlite3_result_null"] = wasmExports2["P"];
|
|
1455
|
-
_sqlite3_result_text = Module["_sqlite3_result_text"] = wasmExports2["Q"];
|
|
1456
|
-
_sqlite3_step = Module["_sqlite3_step"] = wasmExports2["R"];
|
|
1457
|
-
_sqlite3_column_count = Module["_sqlite3_column_count"] = wasmExports2["S"];
|
|
1458
|
-
_sqlite3_column_blob = Module["_sqlite3_column_blob"] = wasmExports2["T"];
|
|
1459
|
-
_sqlite3_column_bytes = Module["_sqlite3_column_bytes"] = wasmExports2["U"];
|
|
1460
|
-
_sqlite3_column_double = Module["_sqlite3_column_double"] = wasmExports2["V"];
|
|
1461
|
-
_sqlite3_column_int64 = Module["_sqlite3_column_int64"] = wasmExports2["W"];
|
|
1462
|
-
_sqlite3_column_text = Module["_sqlite3_column_text"] = wasmExports2["X"];
|
|
1463
|
-
_sqlite3_column_type = Module["_sqlite3_column_type"] = wasmExports2["Y"];
|
|
1464
|
-
_sqlite3_column_name = Module["_sqlite3_column_name"] = wasmExports2["Z"];
|
|
1465
|
-
_sqlite3_column_table_name = Module["_sqlite3_column_table_name"] = wasmExports2["_"];
|
|
1466
|
-
_sqlite3_bind_blob = Module["_sqlite3_bind_blob"] = wasmExports2["$"];
|
|
1467
|
-
_sqlite3_bind_blob64 = Module["_sqlite3_bind_blob64"] = wasmExports2["aa"];
|
|
1468
|
-
_sqlite3_bind_double = Module["_sqlite3_bind_double"] = wasmExports2["ba"];
|
|
1469
|
-
_sqlite3_bind_int = Module["_sqlite3_bind_int"] = wasmExports2["ca"];
|
|
1470
|
-
_sqlite3_bind_int64 = Module["_sqlite3_bind_int64"] = wasmExports2["da"];
|
|
1471
|
-
_sqlite3_bind_null = Module["_sqlite3_bind_null"] = wasmExports2["ea"];
|
|
1472
|
-
_sqlite3_bind_text = Module["_sqlite3_bind_text"] = wasmExports2["fa"];
|
|
1473
|
-
_sqlite3_bind_parameter_index = Module["_sqlite3_bind_parameter_index"] = wasmExports2["ga"];
|
|
1474
|
-
_sqlite3_exec = Module["_sqlite3_exec"] = wasmExports2["ha"];
|
|
1475
|
-
_sqlite3_prepare_v2 = Module["_sqlite3_prepare_v2"] = wasmExports2["ia"];
|
|
1476
|
-
_sqlite3_errmsg = Module["_sqlite3_errmsg"] = wasmExports2["ja"];
|
|
1477
|
-
_sqlite3_last_insert_rowid = Module["_sqlite3_last_insert_rowid"] = wasmExports2["ka"];
|
|
1478
|
-
_sqlite3_changes = Module["_sqlite3_changes"] = wasmExports2["la"];
|
|
1479
|
-
_sqlite3_close_v2 = Module["_sqlite3_close_v2"] = wasmExports2["ma"];
|
|
1480
|
-
_sqlite3_create_function_v2 = Module["_sqlite3_create_function_v2"] = wasmExports2["na"];
|
|
1481
|
-
_sqlite3_open_v2 = Module["_sqlite3_open_v2"] = wasmExports2["oa"];
|
|
1482
|
-
_sqlite3_get_autocommit = Module["_sqlite3_get_autocommit"] = wasmExports2["pa"];
|
|
1483
|
-
_malloc = Module["_malloc"] = wasmExports2["qa"];
|
|
1484
|
-
_free = Module["_free"] = wasmExports2["ra"];
|
|
1485
|
-
__emscripten_timeout = wasmExports2["ta"];
|
|
1486
|
-
__emscripten_stack_restore = wasmExports2["ua"];
|
|
1487
|
-
__emscripten_stack_alloc = wasmExports2["va"];
|
|
1488
|
-
_emscripten_stack_get_current = wasmExports2["wa"];
|
|
1489
|
-
memory = wasmMemory = wasmExports2["y"];
|
|
1490
|
-
__indirect_function_table = wasmTable = wasmExports2["sa"];
|
|
1491
|
-
}
|
|
1492
|
-
var wasmImports = { n: __abort_js, l: __emscripten_runtime_keepalive_clear, o: __localtime_js, i: __setitimer_js, p: __tzset_js, q: _emscripten_date_now, a: _emscripten_get_now, j: _emscripten_resize_heap, w: _nodejsAccess, s: _nodejsCheckReservedLock, f: _nodejsClose, x: _nodejsDelete, v: _nodejsFileSize, m: _nodejsFullPathname, u: _nodejsLock, h: _nodejsRandomness, e: _nodejsRead, b: _nodejsSync, c: _nodejsTruncate, t: _nodejsUnlock, d: _nodejsWrite, g: _nodejs_max_path_length, r: _nodejs_open, k: _proc_exit };
|
|
1493
|
-
function run() {
|
|
1494
|
-
preRun();
|
|
1495
|
-
function doRun() {
|
|
1496
|
-
Module["calledRun"] = true;
|
|
1497
|
-
if (ABORT2)
|
|
1498
|
-
return;
|
|
1499
|
-
initRuntime();
|
|
1500
|
-
Module["onRuntimeInitialized"]?.();
|
|
1501
|
-
postRun();
|
|
1502
|
-
}
|
|
1503
|
-
if (Module["setStatus"]) {
|
|
1504
|
-
Module["setStatus"]("Running...");
|
|
1505
|
-
setTimeout(() => {
|
|
1506
|
-
setTimeout(() => Module["setStatus"](""), 1);
|
|
1507
|
-
doRun();
|
|
1508
|
-
}, 1);
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
// node_modules/better-sqlite3/lib/database.js
|
|
836
|
+
var require_database = __commonJS({
|
|
837
|
+
"node_modules/better-sqlite3/lib/database.js"(exports2, module2) {
|
|
838
|
+
"use strict";
|
|
839
|
+
var fs3 = require("fs");
|
|
840
|
+
var path3 = require("path");
|
|
841
|
+
var util = require_util();
|
|
842
|
+
var SqliteError = require_sqlite_error();
|
|
843
|
+
var DEFAULT_ADDON;
|
|
844
|
+
function Database2(filenameGiven, options) {
|
|
845
|
+
if (new.target == null) {
|
|
846
|
+
return new Database2(filenameGiven, options);
|
|
847
|
+
}
|
|
848
|
+
let buffer;
|
|
849
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
850
|
+
buffer = filenameGiven;
|
|
851
|
+
filenameGiven = ":memory:";
|
|
852
|
+
}
|
|
853
|
+
if (filenameGiven == null)
|
|
854
|
+
filenameGiven = "";
|
|
855
|
+
if (options == null)
|
|
856
|
+
options = {};
|
|
857
|
+
if (typeof filenameGiven !== "string")
|
|
858
|
+
throw new TypeError("Expected first argument to be a string");
|
|
859
|
+
if (typeof options !== "object")
|
|
860
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
861
|
+
if ("readOnly" in options)
|
|
862
|
+
throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
863
|
+
if ("memory" in options)
|
|
864
|
+
throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
865
|
+
const filename = filenameGiven.trim();
|
|
866
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
867
|
+
const readonly = util.getBooleanOption(options, "readonly");
|
|
868
|
+
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
869
|
+
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
870
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
871
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
872
|
+
if (readonly && anonymous && !buffer)
|
|
873
|
+
throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
874
|
+
if (!Number.isInteger(timeout) || timeout < 0)
|
|
875
|
+
throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
876
|
+
if (timeout > 2147483647)
|
|
877
|
+
throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
878
|
+
if (verbose != null && typeof verbose !== "function")
|
|
879
|
+
throw new TypeError('Expected the "verbose" option to be a function');
|
|
880
|
+
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
|
|
881
|
+
throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
882
|
+
let addon;
|
|
883
|
+
if (nativeBinding == null) {
|
|
884
|
+
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
885
|
+
} else if (typeof nativeBinding === "string") {
|
|
886
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
887
|
+
addon = requireFunc(path3.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
1509
888
|
} else {
|
|
1510
|
-
|
|
889
|
+
addon = nativeBinding;
|
|
1511
890
|
}
|
|
891
|
+
if (!addon.isInitialized) {
|
|
892
|
+
addon.setErrorConstructor(SqliteError);
|
|
893
|
+
addon.isInitialized = true;
|
|
894
|
+
}
|
|
895
|
+
if (!anonymous && !filename.startsWith("file:") && !fs3.existsSync(path3.dirname(filename))) {
|
|
896
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
897
|
+
}
|
|
898
|
+
Object.defineProperties(this, {
|
|
899
|
+
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
900
|
+
...wrappers.getters
|
|
901
|
+
});
|
|
1512
902
|
}
|
|
1513
|
-
var
|
|
1514
|
-
|
|
1515
|
-
|
|
903
|
+
var wrappers = require_wrappers();
|
|
904
|
+
Database2.prototype.prepare = wrappers.prepare;
|
|
905
|
+
Database2.prototype.transaction = require_transaction();
|
|
906
|
+
Database2.prototype.pragma = require_pragma();
|
|
907
|
+
Database2.prototype.backup = require_backup();
|
|
908
|
+
Database2.prototype.serialize = require_serialize();
|
|
909
|
+
Database2.prototype.function = require_function();
|
|
910
|
+
Database2.prototype.aggregate = require_aggregate();
|
|
911
|
+
Database2.prototype.table = require_table();
|
|
912
|
+
Database2.prototype.loadExtension = wrappers.loadExtension;
|
|
913
|
+
Database2.prototype.exec = wrappers.exec;
|
|
914
|
+
Database2.prototype.close = wrappers.close;
|
|
915
|
+
Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
916
|
+
Database2.prototype.unsafeMode = wrappers.unsafeMode;
|
|
917
|
+
Database2.prototype[util.inspect] = require_inspect();
|
|
918
|
+
module2.exports = Database2;
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
// node_modules/better-sqlite3/lib/index.js
|
|
923
|
+
var require_lib = __commonJS({
|
|
924
|
+
"node_modules/better-sqlite3/lib/index.js"(exports2, module2) {
|
|
925
|
+
"use strict";
|
|
926
|
+
module2.exports = require_database();
|
|
927
|
+
module2.exports.SqliteError = require_sqlite_error();
|
|
1516
928
|
}
|
|
1517
929
|
});
|
|
1518
930
|
|
|
@@ -4469,7 +3881,7 @@ async function downloadFile(url, destPath) {
|
|
|
4469
3881
|
});
|
|
4470
3882
|
});
|
|
4471
3883
|
}
|
|
4472
|
-
function
|
|
3884
|
+
function isProcessAlive(pid) {
|
|
4473
3885
|
try {
|
|
4474
3886
|
process.kill(pid, 0);
|
|
4475
3887
|
return true;
|
|
@@ -4509,8 +3921,8 @@ function cleanupStalePidFiles() {
|
|
|
4509
3921
|
try {
|
|
4510
3922
|
const data = JSON.parse((0, import_node_fs4.readFileSync)(pidFile, "utf-8"));
|
|
4511
3923
|
const ownerPid = data.ownerPid ?? data.pid;
|
|
4512
|
-
if (!
|
|
4513
|
-
if (data.pid &&
|
|
3924
|
+
if (!isProcessAlive(ownerPid)) {
|
|
3925
|
+
if (data.pid && isProcessAlive(data.pid)) {
|
|
4514
3926
|
try {
|
|
4515
3927
|
process.kill(data.pid, "SIGTERM");
|
|
4516
3928
|
} catch {
|
|
@@ -5261,8 +4673,33 @@ function stripToolContent(entries) {
|
|
|
5261
4673
|
// src/db.ts
|
|
5262
4674
|
var import_node_fs2 = require("node:fs");
|
|
5263
4675
|
var import_node_path2 = require("node:path");
|
|
4676
|
+
var import_node_module = require("node:module");
|
|
5264
4677
|
init_log();
|
|
5265
|
-
|
|
4678
|
+
init_paths();
|
|
4679
|
+
var import_better_sqlite3 = __toESM(require_lib());
|
|
4680
|
+
var BindingLoadError = class extends Error {
|
|
4681
|
+
constructor(dbPath2, cause) {
|
|
4682
|
+
super(
|
|
4683
|
+
`recall: failed to load the better-sqlite3 native binding while opening ${dbPath2}: ${cause.message}
|
|
4684
|
+
The binding is ABI-locked to the Node it was built for \u2014 run \`recall doctor\` (usually fixed by re-running \`recall install\`).`
|
|
4685
|
+
);
|
|
4686
|
+
this.dbPath = dbPath2;
|
|
4687
|
+
this.cause = cause;
|
|
4688
|
+
this.name = "BindingLoadError";
|
|
4689
|
+
}
|
|
4690
|
+
};
|
|
4691
|
+
function isBindingLoadError(e) {
|
|
4692
|
+
if (!e || typeof e !== "object")
|
|
4693
|
+
return false;
|
|
4694
|
+
const err = e;
|
|
4695
|
+
const code = typeof err.code === "string" ? err.code : "";
|
|
4696
|
+
if (code === "ERR_DLOPEN_FAILED" || code === "MODULE_NOT_FOUND")
|
|
4697
|
+
return true;
|
|
4698
|
+
const msg = typeof err.message === "string" ? err.message : "";
|
|
4699
|
+
return /NODE_MODULE_VERSION|different Node\.?js version|dlopen|invalid ELF|not a valid Win32 application|better_sqlite3\.node|Could not locate the bindings|was compiled against/i.test(
|
|
4700
|
+
msg
|
|
4701
|
+
);
|
|
4702
|
+
}
|
|
5266
4703
|
var db = null;
|
|
5267
4704
|
var currentDbPath = null;
|
|
5268
4705
|
function getDb(dbPath2) {
|
|
@@ -5272,15 +4709,16 @@ function getDb(dbPath2) {
|
|
|
5272
4709
|
closeDb();
|
|
5273
4710
|
}
|
|
5274
4711
|
(0, import_node_fs2.mkdirSync)((0, import_node_path2.dirname)(dbPath2), { recursive: true });
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
4712
|
+
cleanupWasmArtifacts(dbPath2);
|
|
4713
|
+
const raw = openDatabase(dbPath2);
|
|
4714
|
+
try {
|
|
4715
|
+
configurePragmas(raw, dbPath2);
|
|
4716
|
+
} catch (e) {
|
|
4717
|
+
raw.close();
|
|
4718
|
+
throw e;
|
|
4719
|
+
}
|
|
4720
|
+
db = createAdapter(raw);
|
|
5278
4721
|
currentDbPath = dbPath2;
|
|
5279
|
-
db.exec("PRAGMA busy_timeout = 5000");
|
|
5280
|
-
db.exec("PRAGMA journal_mode = WAL");
|
|
5281
|
-
db.exec("PRAGMA synchronous = NORMAL");
|
|
5282
|
-
db.exec("PRAGMA wal_autocheckpoint = 1000");
|
|
5283
|
-
db.exec("PRAGMA foreign_keys = ON");
|
|
5284
4722
|
ensureSchema(db);
|
|
5285
4723
|
log({ source: "db", level: "info", summary: `DB: initialized at ${dbPath2}` });
|
|
5286
4724
|
return db;
|
|
@@ -5288,84 +4726,111 @@ function getDb(dbPath2) {
|
|
|
5288
4726
|
function closeDb() {
|
|
5289
4727
|
if (db) {
|
|
5290
4728
|
db.close();
|
|
5291
|
-
if (currentDbPath)
|
|
5292
|
-
removeOwnerFile(currentDbPath);
|
|
5293
4729
|
db = null;
|
|
5294
4730
|
currentDbPath = null;
|
|
5295
4731
|
}
|
|
5296
4732
|
}
|
|
5297
|
-
function
|
|
5298
|
-
|
|
5299
|
-
}
|
|
5300
|
-
function processStartToken(pid) {
|
|
5301
|
-
if (process.platform !== "linux")
|
|
5302
|
-
return "";
|
|
4733
|
+
function openDatabase(dbPath2) {
|
|
4734
|
+
const nativeBinding = resolveNativeBinding();
|
|
5303
4735
|
try {
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
if (
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
const starttime = rest[19];
|
|
5310
|
-
return starttime ?? "";
|
|
5311
|
-
} catch {
|
|
5312
|
-
return "";
|
|
4736
|
+
return nativeBinding ? new import_better_sqlite3.default(dbPath2, { nativeBinding }) : new import_better_sqlite3.default(dbPath2);
|
|
4737
|
+
} catch (e) {
|
|
4738
|
+
if (isBindingLoadError(e))
|
|
4739
|
+
throw new BindingLoadError(dbPath2, e);
|
|
4740
|
+
throw e;
|
|
5313
4741
|
}
|
|
5314
4742
|
}
|
|
5315
|
-
function
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
4743
|
+
function resolveNativeBinding() {
|
|
4744
|
+
const sibling = (0, import_node_path2.join)(__dirname, "better_sqlite3.node");
|
|
4745
|
+
if ((0, import_node_fs2.existsSync)(sibling))
|
|
4746
|
+
return sibling;
|
|
4747
|
+
const resolved = resolveInstalledBinding();
|
|
4748
|
+
if (resolved)
|
|
4749
|
+
return resolved;
|
|
4750
|
+
const staged = (0, import_node_path2.join)(binDir(), "better_sqlite3.node");
|
|
4751
|
+
if ((0, import_node_fs2.existsSync)(staged))
|
|
4752
|
+
return staged;
|
|
4753
|
+
return null;
|
|
5321
4754
|
}
|
|
5322
|
-
function
|
|
4755
|
+
function resolveInstalledBinding() {
|
|
5323
4756
|
try {
|
|
5324
|
-
(0,
|
|
4757
|
+
const pkgJson = (0, import_node_module.createRequire)(__filename).resolve("better-sqlite3/package.json");
|
|
4758
|
+
return findNativeBinding((0, import_node_path2.dirname)(pkgJson));
|
|
5325
4759
|
} catch {
|
|
4760
|
+
return null;
|
|
5326
4761
|
}
|
|
5327
4762
|
}
|
|
5328
|
-
function
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
4763
|
+
function findNativeBinding(baseDir) {
|
|
4764
|
+
for (const c of [
|
|
4765
|
+
(0, import_node_path2.join)(baseDir, "build", "Release", "better_sqlite3.node"),
|
|
4766
|
+
(0, import_node_path2.join)(baseDir, "build", "Debug", "better_sqlite3.node")
|
|
4767
|
+
]) {
|
|
4768
|
+
try {
|
|
4769
|
+
if ((0, import_node_fs2.statSync)(c).isFile())
|
|
4770
|
+
return c;
|
|
4771
|
+
} catch {
|
|
4772
|
+
}
|
|
5334
4773
|
}
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
return;
|
|
5340
|
-
const ownerFile = ownerFilePath(dbPath2);
|
|
5341
|
-
if ((0, import_node_fs2.existsSync)(ownerFile)) {
|
|
4774
|
+
const stack = [baseDir];
|
|
4775
|
+
while (stack.length) {
|
|
4776
|
+
const dir = stack.pop();
|
|
4777
|
+
let entries;
|
|
5342
4778
|
try {
|
|
5343
|
-
|
|
5344
|
-
const sep2 = raw.indexOf(":");
|
|
5345
|
-
const pidStr = sep2 === -1 ? raw : raw.slice(0, sep2);
|
|
5346
|
-
const storedToken = sep2 === -1 ? "" : raw.slice(sep2 + 1);
|
|
5347
|
-
const pid = parseInt(pidStr, 10);
|
|
5348
|
-
if (!isNaN(pid) && isProcessAlive(pid)) {
|
|
5349
|
-
if (storedToken === "" || storedToken === processStartToken(pid)) {
|
|
5350
|
-
return;
|
|
5351
|
-
}
|
|
5352
|
-
}
|
|
4779
|
+
entries = (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true });
|
|
5353
4780
|
} catch {
|
|
4781
|
+
continue;
|
|
4782
|
+
}
|
|
4783
|
+
for (const e of entries) {
|
|
4784
|
+
const p = (0, import_node_path2.join)(dir, e.name);
|
|
4785
|
+
if (e.isDirectory())
|
|
4786
|
+
stack.push(p);
|
|
4787
|
+
else if (e.name.endsWith(".node"))
|
|
4788
|
+
return p;
|
|
5354
4789
|
}
|
|
5355
4790
|
}
|
|
4791
|
+
return null;
|
|
4792
|
+
}
|
|
4793
|
+
function createAdapter(raw) {
|
|
4794
|
+
return {
|
|
4795
|
+
all: (sql, params) => raw.prepare(sql).all(...params ?? []),
|
|
4796
|
+
get: (sql, params) => raw.prepare(sql).get(...params ?? []),
|
|
4797
|
+
run: (sql, params) => raw.prepare(sql).run(...params ?? []),
|
|
4798
|
+
exec: (sql) => {
|
|
4799
|
+
raw.exec(sql);
|
|
4800
|
+
},
|
|
4801
|
+
prepare: (sql) => {
|
|
4802
|
+
const st = raw.prepare(sql);
|
|
4803
|
+
return {
|
|
4804
|
+
run: (p) => st.run(...p ?? []),
|
|
4805
|
+
all: (p) => st.all(...p ?? []),
|
|
4806
|
+
get: (p) => st.get(...p ?? [])
|
|
4807
|
+
};
|
|
4808
|
+
},
|
|
4809
|
+
close: () => raw.close()
|
|
4810
|
+
};
|
|
4811
|
+
}
|
|
4812
|
+
function configurePragmas(raw, dbPath2) {
|
|
4813
|
+
const isMemory = dbPath2 === ":memory:" || dbPath2.includes(":memory:") || dbPath2.startsWith("file::memory:");
|
|
4814
|
+
raw.pragma("busy_timeout = 5000");
|
|
4815
|
+
const mode = raw.pragma("journal_mode = WAL", { simple: true });
|
|
4816
|
+
if (!isMemory && mode !== "wal") {
|
|
4817
|
+
throw new Error(
|
|
4818
|
+
`recall: expected WAL journal_mode, got '${String(mode)}' \u2014 refusing to run on a non-WAL DB (${dbPath2}). A native build on a delete-mode DB is drift; run \`recall doctor\`.`
|
|
4819
|
+
);
|
|
4820
|
+
}
|
|
4821
|
+
raw.pragma("synchronous = NORMAL");
|
|
4822
|
+
raw.pragma("wal_autocheckpoint = 1000");
|
|
4823
|
+
raw.pragma("foreign_keys = ON");
|
|
4824
|
+
}
|
|
4825
|
+
function cleanupWasmArtifacts(dbPath2) {
|
|
5356
4826
|
try {
|
|
5357
|
-
(0, import_node_fs2.rmSync)(
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
} catch
|
|
5364
|
-
log({
|
|
5365
|
-
source: "db",
|
|
5366
|
-
level: "error",
|
|
5367
|
-
summary: `DB: failed to remove stale lock directory: ${err}`
|
|
5368
|
-
});
|
|
4827
|
+
(0, import_node_fs2.rmSync)(`${dbPath2}.lock`, { recursive: true, force: true });
|
|
4828
|
+
} catch {
|
|
4829
|
+
}
|
|
4830
|
+
try {
|
|
4831
|
+
if ((0, import_node_fs2.existsSync)(`${dbPath2}.owner`))
|
|
4832
|
+
(0, import_node_fs2.unlinkSync)(`${dbPath2}.owner`);
|
|
4833
|
+
} catch {
|
|
5369
4834
|
}
|
|
5370
4835
|
}
|
|
5371
4836
|
function ensureSchema(db3) {
|
|
@@ -5383,6 +4848,12 @@ function ensureSchema(db3) {
|
|
|
5383
4848
|
|
|
5384
4849
|
CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id, created_at);
|
|
5385
4850
|
CREATE INDEX IF NOT EXISTS idx_messages_project ON messages(project_id);
|
|
4851
|
+
-- getUnembeddedMessages() orders the whole table by created_at DESC (LIMIT N).
|
|
4852
|
+
-- Without a standalone created_at index SQLite full-scans messages and builds
|
|
4853
|
+
-- a TEMP B-TREE to sort on every call \u2014 a ~4s/batch cost that dominates the
|
|
4854
|
+
-- embed drain and every Stop-hook catch-up. This index serves the ORDER BY so
|
|
4855
|
+
-- the planner walks it and early-terminates at LIMIT instead.
|
|
4856
|
+
CREATE INDEX IF NOT EXISTS idx_messages_created_at ON messages(created_at);
|
|
5386
4857
|
`);
|
|
5387
4858
|
db3.exec(`
|
|
5388
4859
|
CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts USING fts5(
|
|
@@ -5423,9 +4894,19 @@ function ensureSchema(db3) {
|
|
|
5423
4894
|
message_id TEXT PRIMARY KEY REFERENCES messages(message_id) ON DELETE CASCADE,
|
|
5424
4895
|
embedding_q8 BLOB NOT NULL,
|
|
5425
4896
|
norm REAL NOT NULL,
|
|
5426
|
-
quant_scale REAL NOT NULL
|
|
4897
|
+
quant_scale REAL NOT NULL,
|
|
4898
|
+
embed_version INTEGER NOT NULL DEFAULT 1
|
|
5427
4899
|
);
|
|
5428
4900
|
`);
|
|
4901
|
+
const hasEmbedVersion = () => db3.all(`PRAGMA table_info(message_vectors)`).some((c) => c.name === "embed_version");
|
|
4902
|
+
if (!hasEmbedVersion()) {
|
|
4903
|
+
try {
|
|
4904
|
+
db3.exec(`ALTER TABLE message_vectors ADD COLUMN embed_version INTEGER NOT NULL DEFAULT 1`);
|
|
4905
|
+
} catch (e) {
|
|
4906
|
+
if (!hasEmbedVersion())
|
|
4907
|
+
throw e;
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
5429
4910
|
db3.exec(`
|
|
5430
4911
|
CREATE TABLE IF NOT EXISTS ingest_watermark (
|
|
5431
4912
|
transcript_path TEXT PRIMARY KEY,
|
|
@@ -5446,6 +4927,20 @@ init_log();
|
|
|
5446
4927
|
|
|
5447
4928
|
// src/recall/message-store.ts
|
|
5448
4929
|
init_quantize();
|
|
4930
|
+
|
|
4931
|
+
// src/recall/embed-config.ts
|
|
4932
|
+
var DOC_PREFIX = "search_document: ";
|
|
4933
|
+
var EMBED_VERSION = 3;
|
|
4934
|
+
var ENRICH_MAX_CHARS = 200;
|
|
4935
|
+
var ENRICH_PREV_CHARS = 512;
|
|
4936
|
+
var ENRICH_SEP = "\n";
|
|
4937
|
+
function buildEmbedText(messageText, prevText) {
|
|
4938
|
+
if (messageText.length >= ENRICH_MAX_CHARS || !prevText)
|
|
4939
|
+
return messageText;
|
|
4940
|
+
return prevText.slice(-ENRICH_PREV_CHARS) + ENRICH_SEP + messageText;
|
|
4941
|
+
}
|
|
4942
|
+
|
|
4943
|
+
// src/recall/message-store.ts
|
|
5449
4944
|
var dirEnsured = false;
|
|
5450
4945
|
function db2() {
|
|
5451
4946
|
return getDb(dbPath());
|
|
@@ -5461,7 +4956,7 @@ function insertMessages(messages, opts) {
|
|
|
5461
4956
|
return;
|
|
5462
4957
|
ensureDir2();
|
|
5463
4958
|
const d = db2();
|
|
5464
|
-
d.exec("BEGIN");
|
|
4959
|
+
d.exec("BEGIN IMMEDIATE");
|
|
5465
4960
|
try {
|
|
5466
4961
|
if (opts?.replaceSessionId) {
|
|
5467
4962
|
d.run(
|
|
@@ -5476,20 +4971,16 @@ function insertMessages(messages, opts) {
|
|
|
5476
4971
|
(message_id, session_id, message_seq, message_text, project_id, created_at, message_role)
|
|
5477
4972
|
VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
5478
4973
|
);
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
]);
|
|
5490
|
-
}
|
|
5491
|
-
} finally {
|
|
5492
|
-
stmt.finalize();
|
|
4974
|
+
for (const m of messages) {
|
|
4975
|
+
stmt.run([
|
|
4976
|
+
m.message_id,
|
|
4977
|
+
m.session_id,
|
|
4978
|
+
m.message_seq,
|
|
4979
|
+
m.message_text,
|
|
4980
|
+
m.project_id,
|
|
4981
|
+
m.created_at,
|
|
4982
|
+
m.message_role
|
|
4983
|
+
]);
|
|
5493
4984
|
}
|
|
5494
4985
|
d.exec("COMMIT");
|
|
5495
4986
|
} catch (e) {
|
|
@@ -5502,24 +4993,21 @@ function insertMessageVectors(records) {
|
|
|
5502
4993
|
return;
|
|
5503
4994
|
ensureDir2();
|
|
5504
4995
|
const d = db2();
|
|
5505
|
-
d.exec("BEGIN");
|
|
4996
|
+
d.exec("BEGIN IMMEDIATE");
|
|
5506
4997
|
try {
|
|
5507
4998
|
const stmt = d.prepare(
|
|
5508
4999
|
`INSERT OR REPLACE INTO message_vectors
|
|
5509
|
-
(message_id, embedding_q8, norm, quant_scale)
|
|
5510
|
-
VALUES (?, ?, ?, ?)`
|
|
5000
|
+
(message_id, embedding_q8, norm, quant_scale, embed_version)
|
|
5001
|
+
VALUES (?, ?, ?, ?, ?)`
|
|
5511
5002
|
);
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
}
|
|
5521
|
-
} finally {
|
|
5522
|
-
stmt.finalize();
|
|
5003
|
+
for (const r of records) {
|
|
5004
|
+
stmt.run([
|
|
5005
|
+
r.messageId,
|
|
5006
|
+
Buffer.from(r.embeddingQ8.buffer, r.embeddingQ8.byteOffset, r.embeddingQ8.byteLength),
|
|
5007
|
+
r.norm,
|
|
5008
|
+
r.quantScale,
|
|
5009
|
+
EMBED_VERSION
|
|
5010
|
+
]);
|
|
5523
5011
|
}
|
|
5524
5012
|
d.exec("COMMIT");
|
|
5525
5013
|
} catch (e) {
|
|
@@ -5531,19 +5019,29 @@ var MIN_EMBED_CHARS = 50;
|
|
|
5531
5019
|
function getUnembeddedMessages(limit) {
|
|
5532
5020
|
try {
|
|
5533
5021
|
const rows = db2().all(
|
|
5534
|
-
`SELECT m.message_id, m.session_id, m.message_text
|
|
5022
|
+
`SELECT m.message_id, m.session_id, m.message_text,
|
|
5023
|
+
(SELECT p.message_text FROM messages p
|
|
5024
|
+
WHERE p.session_id = m.session_id AND p.message_seq < m.message_seq
|
|
5025
|
+
ORDER BY p.message_seq DESC LIMIT 1) AS prev_text
|
|
5026
|
+
FROM messages m
|
|
5535
5027
|
WHERE m.message_text != ''
|
|
5536
|
-
AND LENGTH(m.message_text) >= ${MIN_EMBED_CHARS}
|
|
5537
|
-
|
|
5028
|
+
AND (LENGTH(m.message_text) >= ${MIN_EMBED_CHARS}
|
|
5029
|
+
OR EXISTS (SELECT 1 FROM messages p2 WHERE p2.session_id = m.session_id AND p2.message_seq < m.message_seq))
|
|
5030
|
+
AND NOT EXISTS (SELECT 1 FROM message_vectors mv WHERE mv.message_id = m.message_id AND mv.embed_version = ?)
|
|
5538
5031
|
ORDER BY m.created_at DESC
|
|
5539
5032
|
LIMIT ?`,
|
|
5540
|
-
[limit]
|
|
5033
|
+
[EMBED_VERSION, limit]
|
|
5541
5034
|
);
|
|
5542
|
-
return rows.map((r) =>
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5035
|
+
return rows.map((r) => {
|
|
5036
|
+
const message_text = r.message_text;
|
|
5037
|
+
const prev_text = r.prev_text ?? null;
|
|
5038
|
+
return {
|
|
5039
|
+
message_id: r.message_id,
|
|
5040
|
+
session_id: r.session_id,
|
|
5041
|
+
message_text,
|
|
5042
|
+
embed_text: buildEmbedText(message_text, prev_text)
|
|
5043
|
+
};
|
|
5044
|
+
});
|
|
5547
5045
|
} catch {
|
|
5548
5046
|
return [];
|
|
5549
5047
|
}
|
|
@@ -6495,6 +5993,7 @@ var SAFE_EMBED_CHARS = 6e3;
|
|
|
6495
5993
|
async function embedRowsResilient(rows) {
|
|
6496
5994
|
const { embedBatch: embedBatch2 } = await Promise.resolve().then(() => (init_embedder(), embedder_exports));
|
|
6497
5995
|
const { quantizeToQ8: quantizeToQ82, computeNorm: computeNorm2 } = await Promise.resolve().then(() => (init_quantize(), quantize_exports));
|
|
5996
|
+
rows = rows.map((r) => ({ messageId: r.messageId, text: DOC_PREFIX + r.text }));
|
|
6498
5997
|
const toRecord = (messageId, f32) => {
|
|
6499
5998
|
const { q8, scale } = quantizeToQ82(f32);
|
|
6500
5999
|
return { messageId, embeddingQ8: q8, norm: computeNorm2(f32), quantScale: scale };
|
|
@@ -6527,20 +6026,30 @@ async function embedRowsResilient(rows) {
|
|
|
6527
6026
|
async function embedSessionMessages(sessionId, force) {
|
|
6528
6027
|
const d = getDb(dbPath());
|
|
6529
6028
|
const rows = d.all(
|
|
6530
|
-
force ? `SELECT
|
|
6029
|
+
force ? `SELECT m.message_id, m.message_text,
|
|
6030
|
+
(SELECT p.message_text FROM messages p
|
|
6031
|
+
WHERE p.session_id = m.session_id AND p.message_seq < m.message_seq
|
|
6032
|
+
ORDER BY p.message_seq DESC LIMIT 1) AS prev_text
|
|
6033
|
+
FROM messages m WHERE m.session_id = ? ORDER BY m.message_seq ASC` : `SELECT m.message_id, m.message_text,
|
|
6034
|
+
(SELECT p.message_text FROM messages p
|
|
6035
|
+
WHERE p.session_id = m.session_id AND p.message_seq < m.message_seq
|
|
6036
|
+
ORDER BY p.message_seq DESC LIMIT 1) AS prev_text
|
|
6037
|
+
FROM messages m
|
|
6531
6038
|
WHERE m.session_id = ?
|
|
6532
|
-
AND NOT EXISTS (SELECT 1 FROM message_vectors mv WHERE mv.message_id = m.message_id)
|
|
6039
|
+
AND NOT EXISTS (SELECT 1 FROM message_vectors mv WHERE mv.message_id = m.message_id AND mv.embed_version = ?)
|
|
6533
6040
|
ORDER BY m.message_seq ASC`,
|
|
6534
|
-
[sessionId]
|
|
6041
|
+
force ? [sessionId] : [sessionId, EMBED_VERSION]
|
|
6535
6042
|
);
|
|
6536
6043
|
const validRows = [];
|
|
6537
6044
|
for (const r of rows) {
|
|
6538
|
-
const
|
|
6539
|
-
if (!
|
|
6045
|
+
const messageText = r.message_text.trim();
|
|
6046
|
+
if (!messageText)
|
|
6540
6047
|
continue;
|
|
6048
|
+
const prevText = r.prev_text ?? null;
|
|
6049
|
+
const embedText = buildEmbedText(messageText, prevText);
|
|
6541
6050
|
validRows.push({
|
|
6542
6051
|
messageId: r.message_id,
|
|
6543
|
-
text:
|
|
6052
|
+
text: embedText.length > MAX_EMBED_CHARS ? embedText.slice(0, MAX_EMBED_CHARS) : embedText
|
|
6544
6053
|
});
|
|
6545
6054
|
}
|
|
6546
6055
|
if (validRows.length === 0)
|
|
@@ -6557,7 +6066,7 @@ async function embedMessageBatch(messages) {
|
|
|
6557
6066
|
return 0;
|
|
6558
6067
|
const truncated = [];
|
|
6559
6068
|
for (const m of messages) {
|
|
6560
|
-
const text = m.message_text.trim();
|
|
6069
|
+
const text = (m.embed_text ?? m.message_text).trim();
|
|
6561
6070
|
if (!text)
|
|
6562
6071
|
continue;
|
|
6563
6072
|
truncated.push({
|