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/stop-hook.js
CHANGED
|
@@ -68,1446 +68,858 @@ var init_log = __esm({
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
71
|
+
// src/paths.ts
|
|
72
|
+
function recallRoot() {
|
|
73
|
+
if (rootOverride)
|
|
74
|
+
return rootOverride;
|
|
75
|
+
const envRoot = process.env["RECALL_HOME"];
|
|
76
|
+
if (envRoot && envRoot.length > 0)
|
|
77
|
+
return envRoot;
|
|
78
|
+
return (0, import_node_path.join)((0, import_node_os.homedir)(), ".recall");
|
|
79
|
+
}
|
|
80
|
+
function dbPath() {
|
|
81
|
+
return (0, import_node_path.join)(recallRoot(), "recall.db");
|
|
82
|
+
}
|
|
83
|
+
function binDir() {
|
|
84
|
+
return (0, import_node_path.join)(recallRoot(), "bin");
|
|
85
|
+
}
|
|
86
|
+
function logsDir() {
|
|
87
|
+
return (0, import_node_path.join)(recallRoot(), "logs");
|
|
88
|
+
}
|
|
89
|
+
function ensureDir() {
|
|
90
|
+
(0, import_node_fs.mkdirSync)(recallRoot(), { recursive: true });
|
|
91
|
+
}
|
|
92
|
+
var import_node_fs, import_node_os, import_node_path, rootOverride;
|
|
93
|
+
var init_paths = __esm({
|
|
94
|
+
"src/paths.ts"() {
|
|
95
|
+
"use strict";
|
|
96
|
+
import_node_fs = require("node:fs");
|
|
97
|
+
import_node_os = require("node:os");
|
|
98
|
+
import_node_path = require("node:path");
|
|
99
|
+
rootOverride = null;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// node_modules/better-sqlite3/lib/util.js
|
|
104
|
+
var require_util = __commonJS({
|
|
105
|
+
"node_modules/better-sqlite3/lib/util.js"(exports2) {
|
|
106
|
+
"use strict";
|
|
107
|
+
exports2.getBooleanOption = (options, key) => {
|
|
108
|
+
let value = false;
|
|
109
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
110
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
111
111
|
}
|
|
112
|
+
return value;
|
|
112
113
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (Number.isSafeInteger(result)) {
|
|
169
|
-
if (result >= INT32_MIN && result <= INT32_MAX) {
|
|
170
|
-
sqlite3.result_int(cx, result);
|
|
171
|
-
} else {
|
|
172
|
-
sqlite3.result_int64(cx, BigInt(result));
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
sqlite3.result_double(cx, result);
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
case "bigint":
|
|
179
|
-
sqlite3.result_int64(cx, result);
|
|
180
|
-
break;
|
|
181
|
-
case "string":
|
|
182
|
-
const tempPtr = stringToHeap(result);
|
|
183
|
-
sqlite3.result_text(cx, tempPtr, -1, SQLITE_TRANSIENT);
|
|
184
|
-
_free(tempPtr);
|
|
185
|
-
break;
|
|
186
|
-
case "object":
|
|
187
|
-
if (result === null) {
|
|
188
|
-
sqlite3.result_null(cx);
|
|
189
|
-
} else if (result instanceof Uint8Array) {
|
|
190
|
-
const tempPtr2 = arrayToHeap(result);
|
|
191
|
-
if (result.byteLength <= INT32_MAX) {
|
|
192
|
-
sqlite3.result_blob(cx, tempPtr2, result.byteLength, SQLITE_TRANSIENT);
|
|
193
|
-
} else {
|
|
194
|
-
sqlite3.result_blob64(cx, tempPtr2, BigInt(result.byteLength), SQLITE_TRANSIENT);
|
|
195
|
-
}
|
|
196
|
-
_free(tempPtr2);
|
|
197
|
-
} else {
|
|
198
|
-
throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`);
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`);
|
|
114
|
+
exports2.cppdb = Symbol();
|
|
115
|
+
exports2.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
120
|
+
var require_sqlite_error = __commonJS({
|
|
121
|
+
"node_modules/better-sqlite3/lib/sqlite-error.js"(exports2, module2) {
|
|
122
|
+
"use strict";
|
|
123
|
+
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
124
|
+
function SqliteError(message, code) {
|
|
125
|
+
if (new.target !== SqliteError) {
|
|
126
|
+
return new SqliteError(message, code);
|
|
127
|
+
}
|
|
128
|
+
if (typeof code !== "string") {
|
|
129
|
+
throw new TypeError("Expected second argument to be a string");
|
|
130
|
+
}
|
|
131
|
+
Error.call(this, message);
|
|
132
|
+
descriptor.value = "" + message;
|
|
133
|
+
Object.defineProperty(this, "message", descriptor);
|
|
134
|
+
Error.captureStackTrace(this, SqliteError);
|
|
135
|
+
this.code = code;
|
|
136
|
+
}
|
|
137
|
+
Object.setPrototypeOf(SqliteError, Error);
|
|
138
|
+
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
139
|
+
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
140
|
+
module2.exports = SqliteError;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// node_modules/file-uri-to-path/index.js
|
|
145
|
+
var require_file_uri_to_path = __commonJS({
|
|
146
|
+
"node_modules/file-uri-to-path/index.js"(exports2, module2) {
|
|
147
|
+
var sep = require("path").sep || "/";
|
|
148
|
+
module2.exports = fileUriToPath;
|
|
149
|
+
function fileUriToPath(uri) {
|
|
150
|
+
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
151
|
+
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
152
|
+
}
|
|
153
|
+
var rest = decodeURI(uri.substring(7));
|
|
154
|
+
var firstSlash = rest.indexOf("/");
|
|
155
|
+
var host = rest.substring(0, firstSlash);
|
|
156
|
+
var path2 = rest.substring(firstSlash + 1);
|
|
157
|
+
if ("localhost" == host)
|
|
158
|
+
host = "";
|
|
159
|
+
if (host) {
|
|
160
|
+
host = sep + sep + host;
|
|
161
|
+
}
|
|
162
|
+
path2 = path2.replace(/^(.+)\|/, "$1:");
|
|
163
|
+
if (sep == "\\") {
|
|
164
|
+
path2 = path2.replace(/\//g, "\\");
|
|
165
|
+
}
|
|
166
|
+
if (/^.+\:/.test(path2)) {
|
|
167
|
+
} else {
|
|
168
|
+
path2 = sep + path2;
|
|
203
169
|
}
|
|
170
|
+
return host + path2;
|
|
204
171
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
this._functions = /* @__PURE__ */ new Map();
|
|
223
|
-
}
|
|
224
|
-
get isOpen() {
|
|
225
|
-
return this._ptr !== null;
|
|
226
|
-
}
|
|
227
|
-
get inTransaction() {
|
|
228
|
-
this._assertOpen();
|
|
229
|
-
return sqlite3.get_autocommit(this._ptr) === 0;
|
|
230
|
-
}
|
|
231
|
-
close() {
|
|
232
|
-
this._assertOpen();
|
|
233
|
-
for (const func of this._functions.values())
|
|
234
|
-
removeFunction(func);
|
|
235
|
-
this._functions.clear();
|
|
236
|
-
this._handleError(sqlite3.close_v2(this._ptr));
|
|
237
|
-
this._ptr = null;
|
|
238
|
-
}
|
|
239
|
-
function(name, func, { deterministic = false } = {}) {
|
|
240
|
-
this._assertOpen();
|
|
241
|
-
function wrappedFunc(cx, argc, argv) {
|
|
242
|
-
const args = parseFunctionArguments(argc, argv);
|
|
243
|
-
let result;
|
|
244
|
-
try {
|
|
245
|
-
result = func.apply(null, args);
|
|
246
|
-
} catch (err2) {
|
|
247
|
-
const tempPtr = stringToHeap(err2.toString());
|
|
248
|
-
sqlite3.result_error(cx, tempPtr, -1);
|
|
249
|
-
_free(tempPtr);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
setFunctionResult(cx, result);
|
|
253
|
-
}
|
|
254
|
-
if (this._functions.has(name)) {
|
|
255
|
-
removeFunction(this._functions.get(name));
|
|
256
|
-
this._functions.delete(name);
|
|
257
|
-
}
|
|
258
|
-
const funcPtr = addFunction(wrappedFunc, "viii");
|
|
259
|
-
this._functions.set(name, funcPtr);
|
|
260
|
-
let eTextRep = SQLITE_UTF8;
|
|
261
|
-
if (deterministic)
|
|
262
|
-
eTextRep |= SQLITE_DETERMINISTIC;
|
|
263
|
-
this._handleError(sqlite3.create_function_v2(this._ptr, name, func.length, eTextRep, NULL, funcPtr, NULL, NULL, NULL));
|
|
264
|
-
return this;
|
|
265
|
-
}
|
|
266
|
-
exec(sql) {
|
|
267
|
-
this._assertOpen();
|
|
268
|
-
const tempPtr = stringToHeap(sql);
|
|
269
|
-
try {
|
|
270
|
-
this._handleError(sqlite3.exec(this._ptr, tempPtr, NULL, NULL, NULL));
|
|
271
|
-
} finally {
|
|
272
|
-
_free(tempPtr);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
prepare(sql) {
|
|
276
|
-
this._assertOpen();
|
|
277
|
-
return new Statement(this, sql);
|
|
278
|
-
}
|
|
279
|
-
run(sql, values) {
|
|
280
|
-
const stmt = this.prepare(sql);
|
|
281
|
-
try {
|
|
282
|
-
return stmt.run(values);
|
|
283
|
-
} finally {
|
|
284
|
-
stmt.finalize();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
all(sql, values, { expand = false } = {}) {
|
|
288
|
-
return this._query(sql, values, false, expand);
|
|
289
|
-
}
|
|
290
|
-
get(sql, values, { expand = false } = {}) {
|
|
291
|
-
return this._query(sql, values, true, expand);
|
|
292
|
-
}
|
|
293
|
-
_query(sql, values, single, expand) {
|
|
294
|
-
const stmt = this.prepare(sql);
|
|
295
|
-
try {
|
|
296
|
-
if (single) {
|
|
297
|
-
return stmt.get(values, { expand });
|
|
298
|
-
} else {
|
|
299
|
-
return stmt.all(values, { expand });
|
|
300
|
-
}
|
|
301
|
-
} finally {
|
|
302
|
-
stmt.finalize();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
_assertOpen() {
|
|
306
|
-
if (!this.isOpen)
|
|
307
|
-
throw new SQLite3Error("Database already closed");
|
|
308
|
-
}
|
|
309
|
-
_handleError(returnCode) {
|
|
310
|
-
if (returnCode !== SQLITE_OK)
|
|
311
|
-
throw new SQLite3Error(sqlite3.errmsg(this._ptr));
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// node_modules/bindings/bindings.js
|
|
176
|
+
var require_bindings = __commonJS({
|
|
177
|
+
"node_modules/bindings/bindings.js"(exports2, module2) {
|
|
178
|
+
var fs3 = require("fs");
|
|
179
|
+
var path2 = require("path");
|
|
180
|
+
var fileURLToPath = require_file_uri_to_path();
|
|
181
|
+
var join5 = path2.join;
|
|
182
|
+
var dirname2 = path2.dirname;
|
|
183
|
+
var exists = fs3.accessSync && function(path3) {
|
|
184
|
+
try {
|
|
185
|
+
fs3.accessSync(path3);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
return false;
|
|
312
188
|
}
|
|
189
|
+
return true;
|
|
190
|
+
} || fs3.existsSync || path2.existsSync;
|
|
191
|
+
var defaults = {
|
|
192
|
+
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
193
|
+
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
194
|
+
platform: process.platform,
|
|
195
|
+
arch: process.arch,
|
|
196
|
+
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
197
|
+
version: process.versions.node,
|
|
198
|
+
bindings: "bindings.node",
|
|
199
|
+
try: [
|
|
200
|
+
// node-gyp's linked version in the "build" dir
|
|
201
|
+
["module_root", "build", "bindings"],
|
|
202
|
+
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
203
|
+
["module_root", "build", "Debug", "bindings"],
|
|
204
|
+
["module_root", "build", "Release", "bindings"],
|
|
205
|
+
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
206
|
+
["module_root", "out", "Debug", "bindings"],
|
|
207
|
+
["module_root", "Debug", "bindings"],
|
|
208
|
+
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
209
|
+
["module_root", "out", "Release", "bindings"],
|
|
210
|
+
["module_root", "Release", "bindings"],
|
|
211
|
+
// Legacy from node-waf, node <= 0.4.x
|
|
212
|
+
["module_root", "build", "default", "bindings"],
|
|
213
|
+
// Production "Release" buildtype binary (meh...)
|
|
214
|
+
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
215
|
+
// node-qbs builds
|
|
216
|
+
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
217
|
+
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
218
|
+
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
219
|
+
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
220
|
+
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
221
|
+
]
|
|
313
222
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return this._queryRows(values, expand);
|
|
341
|
-
}
|
|
342
|
-
all(values, { expand = false } = {}) {
|
|
343
|
-
return Array.from(this.iterate(values, { expand }));
|
|
344
|
-
}
|
|
345
|
-
get(values, { expand = false } = {}) {
|
|
346
|
-
const result = this._queryRows(values, expand).next();
|
|
347
|
-
return result.done ? null : result.value;
|
|
348
|
-
}
|
|
349
|
-
finalize() {
|
|
350
|
-
if (this.isFinalized)
|
|
351
|
-
throw new SQLite3Error("Statement already finalized");
|
|
223
|
+
function bindings(opts) {
|
|
224
|
+
if (typeof opts == "string") {
|
|
225
|
+
opts = { bindings: opts };
|
|
226
|
+
} else if (!opts) {
|
|
227
|
+
opts = {};
|
|
228
|
+
}
|
|
229
|
+
Object.keys(defaults).map(function(i2) {
|
|
230
|
+
if (!(i2 in opts))
|
|
231
|
+
opts[i2] = defaults[i2];
|
|
232
|
+
});
|
|
233
|
+
if (!opts.module_root) {
|
|
234
|
+
opts.module_root = exports2.getRoot(exports2.getFileName());
|
|
235
|
+
}
|
|
236
|
+
if (path2.extname(opts.bindings) != ".node") {
|
|
237
|
+
opts.bindings += ".node";
|
|
238
|
+
}
|
|
239
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
240
|
+
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
241
|
+
for (; i < l; i++) {
|
|
242
|
+
n = join5.apply(
|
|
243
|
+
null,
|
|
244
|
+
opts.try[i].map(function(p) {
|
|
245
|
+
return opts[p] || p;
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
tries.push(n);
|
|
352
249
|
try {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
_reset() {
|
|
359
|
-
return sqlite3.clear_bindings(this._ptr) === SQLITE_OK && sqlite3.reset(this._ptr) === SQLITE_OK;
|
|
360
|
-
}
|
|
361
|
-
*_queryRows(values, expand) {
|
|
362
|
-
this._assertReady();
|
|
363
|
-
this._bind(values);
|
|
364
|
-
const columns = this._getColumnNames();
|
|
365
|
-
while (this._step())
|
|
366
|
-
yield this._getRow(columns, expand);
|
|
367
|
-
}
|
|
368
|
-
_bind(values) {
|
|
369
|
-
if (!this._reset()) {
|
|
370
|
-
throw new SQLite3Error("Could not reset statement prior to binding new values");
|
|
371
|
-
}
|
|
372
|
-
if (Array.isArray(values)) {
|
|
373
|
-
this._bindArray(values);
|
|
374
|
-
} else if (values != null && typeof values === "object") {
|
|
375
|
-
this._bindObject(values);
|
|
376
|
-
} else if (typeof values !== "undefined") {
|
|
377
|
-
this._bindValue(values, 1);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
_step() {
|
|
381
|
-
const ret = sqlite3.step(this._ptr);
|
|
382
|
-
switch (ret) {
|
|
383
|
-
case SQLITE_ROW:
|
|
384
|
-
return true;
|
|
385
|
-
case SQLITE_DONE:
|
|
386
|
-
return false;
|
|
387
|
-
default:
|
|
388
|
-
this._db._handleError(ret);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
_getRow(columns, expand) {
|
|
392
|
-
const row = {};
|
|
393
|
-
for (let i = 0; i < columns.length; i++) {
|
|
394
|
-
let v;
|
|
395
|
-
const colType = sqlite3.column_type(this._ptr, i);
|
|
396
|
-
switch (colType) {
|
|
397
|
-
case SQLITE_INTEGER:
|
|
398
|
-
v = toNumberOrNot(sqlite3.column_int64(this._ptr, i));
|
|
399
|
-
break;
|
|
400
|
-
case SQLITE_FLOAT:
|
|
401
|
-
v = sqlite3.column_double(this._ptr, i);
|
|
402
|
-
break;
|
|
403
|
-
case SQLITE_TEXT:
|
|
404
|
-
v = sqlite3.column_text(this._ptr, i);
|
|
405
|
-
break;
|
|
406
|
-
case SQLITE_BLOB:
|
|
407
|
-
const p = sqlite3.column_blob(this._ptr, i);
|
|
408
|
-
if (p != NULL) {
|
|
409
|
-
v = HEAPU8.slice(p, p + sqlite3.column_bytes(this._ptr, i));
|
|
410
|
-
} else {
|
|
411
|
-
v = new Uint8Array();
|
|
412
|
-
}
|
|
413
|
-
break;
|
|
414
|
-
case SQLITE_NULL:
|
|
415
|
-
v = null;
|
|
416
|
-
break;
|
|
250
|
+
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
251
|
+
if (!opts.path) {
|
|
252
|
+
b.path = n;
|
|
417
253
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
if (Object.hasOwn(row, table)) {
|
|
423
|
-
row[table][column] = v;
|
|
424
|
-
} else {
|
|
425
|
-
row[table] = { [column]: v };
|
|
426
|
-
}
|
|
427
|
-
} else {
|
|
428
|
-
row[column] = v;
|
|
254
|
+
return b;
|
|
255
|
+
} catch (e) {
|
|
256
|
+
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
257
|
+
throw e;
|
|
429
258
|
}
|
|
430
259
|
}
|
|
431
|
-
return row;
|
|
432
260
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
_bindValue(value, position) {
|
|
453
|
-
let ret;
|
|
454
|
-
switch (typeof value) {
|
|
455
|
-
case "string":
|
|
456
|
-
const tempPtr = stringToHeap(value);
|
|
457
|
-
ret = sqlite3.bind_text(this._ptr, position, tempPtr, -1, SQLITE_TRANSIENT);
|
|
458
|
-
_free(tempPtr);
|
|
459
|
-
break;
|
|
460
|
-
case "number":
|
|
461
|
-
if (Number.isSafeInteger(value)) {
|
|
462
|
-
if (value >= INT32_MIN && value <= INT32_MAX) {
|
|
463
|
-
ret = sqlite3.bind_int(this._ptr, position, value);
|
|
464
|
-
} else {
|
|
465
|
-
ret = sqlite3.bind_int64(this._ptr, position, BigInt(value));
|
|
466
|
-
}
|
|
467
|
-
} else {
|
|
468
|
-
ret = sqlite3.bind_double(this._ptr, position, value);
|
|
469
|
-
}
|
|
470
|
-
break;
|
|
471
|
-
case "bigint":
|
|
472
|
-
ret = sqlite3.bind_int64(this._ptr, position, value);
|
|
473
|
-
break;
|
|
474
|
-
case "boolean":
|
|
475
|
-
ret = sqlite3.bind_int(this._ptr, position, value ? 1 : 0);
|
|
476
|
-
break;
|
|
477
|
-
case "object":
|
|
478
|
-
if (value === null) {
|
|
479
|
-
ret = sqlite3.bind_null(this._ptr, position);
|
|
480
|
-
} else if (value instanceof Uint8Array) {
|
|
481
|
-
const tempPtr2 = arrayToHeap(value);
|
|
482
|
-
if (value.byteLength <= INT32_MAX) {
|
|
483
|
-
ret = sqlite3.bind_blob(this._ptr, position, tempPtr2, value.byteLength, SQLITE_TRANSIENT);
|
|
484
|
-
} else {
|
|
485
|
-
ret = sqlite3.bind_blob64(this._ptr, position, tempPtr2, BigInt(value.byteLength), SQLITE_TRANSIENT);
|
|
261
|
+
err = new Error(
|
|
262
|
+
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
263
|
+
return opts.arrow + a;
|
|
264
|
+
}).join("\n")
|
|
265
|
+
);
|
|
266
|
+
err.tries = tries;
|
|
267
|
+
throw err;
|
|
268
|
+
}
|
|
269
|
+
module2.exports = exports2 = bindings;
|
|
270
|
+
exports2.getFileName = function getFileName(calling_file) {
|
|
271
|
+
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
272
|
+
Error.stackTraceLimit = 10;
|
|
273
|
+
Error.prepareStackTrace = function(e, st) {
|
|
274
|
+
for (var i = 0, l = st.length; i < l; i++) {
|
|
275
|
+
fileName = st[i].getFileName();
|
|
276
|
+
if (fileName !== __filename) {
|
|
277
|
+
if (calling_file) {
|
|
278
|
+
if (fileName !== calling_file) {
|
|
279
|
+
return;
|
|
486
280
|
}
|
|
487
|
-
_free(tempPtr2);
|
|
488
281
|
} else {
|
|
489
|
-
|
|
282
|
+
return;
|
|
490
283
|
}
|
|
491
|
-
|
|
492
|
-
default:
|
|
493
|
-
throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`);
|
|
284
|
+
}
|
|
494
285
|
}
|
|
495
|
-
if (ret !== SQLITE_OK)
|
|
496
|
-
this._db._handleError(ret);
|
|
497
|
-
}
|
|
498
|
-
_assertReady() {
|
|
499
|
-
if (this.isFinalized)
|
|
500
|
-
throw new SQLite3Error("Statement already finalized");
|
|
501
|
-
if (!this._db.isOpen)
|
|
502
|
-
throw new SQLite3Error("Database is closed");
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
Module.Database = Database;
|
|
506
|
-
Module.SQLite3Error = SQLite3Error;
|
|
507
|
-
var path2 = require("node:path");
|
|
508
|
-
var crypto = require("node:crypto");
|
|
509
|
-
var SQLITE_CANTOPEN = 14;
|
|
510
|
-
var SQLITE_IOERR_READ = 266;
|
|
511
|
-
var SQLITE_IOERR_SHORT_READ = 522;
|
|
512
|
-
var SQLITE_IOERR_FSYNC = 1034;
|
|
513
|
-
var SQLITE_IOERR_WRITE = 778;
|
|
514
|
-
var SQLITE_IOERR_DELETE = 2570;
|
|
515
|
-
var SQLITE_IOERR_CLOSE = 4106;
|
|
516
|
-
var SQLITE_IOERR_TRUNCATE = 1546;
|
|
517
|
-
var SQLITE_IOERR_FSTAT = 1802;
|
|
518
|
-
var SQLITE_IOERR_LOCK = 3850;
|
|
519
|
-
var SQLITE_IOERR_UNLOCK = 2058;
|
|
520
|
-
var SQLITE_OPEN_READONLY = 1;
|
|
521
|
-
var SQLITE_OPEN_READWRITE = 2;
|
|
522
|
-
var SQLITE_OPEN_CREATE = 4;
|
|
523
|
-
var SQLITE_OPEN_EXCLUSIVE = 16;
|
|
524
|
-
var SQLITE_ACCESS_READWRITE = 1;
|
|
525
|
-
var SQLITE_ACCESS_READ = 2;
|
|
526
|
-
var SQLITE_LOCK_NONE = 0;
|
|
527
|
-
var SQLITE_BUSY = 5;
|
|
528
|
-
function _fd(fileInfo) {
|
|
529
|
-
return getValue(fileInfo + 4, "i32");
|
|
530
|
-
}
|
|
531
|
-
function _isLocked(fileInfo) {
|
|
532
|
-
return getValue(fileInfo + 8, "i32") != 0;
|
|
533
|
-
}
|
|
534
|
-
function _setLocked(fileInfo, locked) {
|
|
535
|
-
setValue(fileInfo + 8, locked ? 1 : 0, "i32");
|
|
536
|
-
}
|
|
537
|
-
function _path(fileInfo) {
|
|
538
|
-
return UTF8ToString(getValue(fileInfo + 12, "i32"));
|
|
539
|
-
}
|
|
540
|
-
function _safeInt(bigInt) {
|
|
541
|
-
if (bigInt < Number.MIN_SAFE_INTEGER || bigInt > Number.MAX_SAFE_INTEGER)
|
|
542
|
-
throw 0;
|
|
543
|
-
return Number(bigInt);
|
|
544
|
-
}
|
|
545
|
-
var arguments_ = [];
|
|
546
|
-
var thisProgram = "./this.program";
|
|
547
|
-
var quit_ = (status, toThrow) => {
|
|
548
|
-
throw toThrow;
|
|
549
|
-
};
|
|
550
|
-
var _scriptName;
|
|
551
|
-
if (typeof __filename != "undefined") {
|
|
552
|
-
_scriptName = __filename;
|
|
553
|
-
} else {
|
|
554
|
-
}
|
|
555
|
-
var scriptDirectory = "";
|
|
556
|
-
function locateFile(path3) {
|
|
557
|
-
if (Module["locateFile"]) {
|
|
558
|
-
return Module["locateFile"](path3, scriptDirectory);
|
|
559
|
-
}
|
|
560
|
-
return scriptDirectory + path3;
|
|
561
|
-
}
|
|
562
|
-
var readAsync;
|
|
563
|
-
var readBinary;
|
|
564
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
565
|
-
fs3 = require("node:fs");
|
|
566
|
-
scriptDirectory = __dirname + "/";
|
|
567
|
-
readBinary = (filename) => {
|
|
568
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
569
|
-
var ret = fs3.readFileSync(filename);
|
|
570
|
-
return ret;
|
|
571
|
-
};
|
|
572
|
-
readAsync = async (filename, binary = true) => {
|
|
573
|
-
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
574
|
-
var ret = fs3.readFileSync(filename, binary ? void 0 : "utf8");
|
|
575
|
-
return ret;
|
|
576
|
-
};
|
|
577
|
-
if (process.argv.length > 1) {
|
|
578
|
-
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
579
|
-
}
|
|
580
|
-
arguments_ = process.argv.slice(2);
|
|
581
|
-
if (typeof module2 != "undefined") {
|
|
582
|
-
module2["exports"] = Module;
|
|
583
|
-
}
|
|
584
|
-
quit_ = (status, toThrow) => {
|
|
585
|
-
process.exitCode = status;
|
|
586
|
-
throw toThrow;
|
|
587
286
|
};
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
function
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
HEAPU16 = new Uint16Array(b);
|
|
604
|
-
HEAP32 = new Int32Array(b);
|
|
605
|
-
HEAPU32 = new Uint32Array(b);
|
|
606
|
-
HEAPF32 = new Float32Array(b);
|
|
607
|
-
HEAPF64 = new Float64Array(b);
|
|
608
|
-
HEAP64 = new BigInt64Array(b);
|
|
609
|
-
HEAPU64 = new BigUint64Array(b);
|
|
610
|
-
}
|
|
611
|
-
function preRun() {
|
|
612
|
-
if (Module["preRun"]) {
|
|
613
|
-
if (typeof Module["preRun"] == "function")
|
|
614
|
-
Module["preRun"] = [Module["preRun"]];
|
|
615
|
-
while (Module["preRun"].length) {
|
|
616
|
-
addOnPreRun(Module["preRun"].shift());
|
|
287
|
+
Error.captureStackTrace(dummy);
|
|
288
|
+
dummy.stack;
|
|
289
|
+
Error.prepareStackTrace = origPST;
|
|
290
|
+
Error.stackTraceLimit = origSTL;
|
|
291
|
+
var fileSchema = "file://";
|
|
292
|
+
if (fileName.indexOf(fileSchema) === 0) {
|
|
293
|
+
fileName = fileURLToPath(fileName);
|
|
294
|
+
}
|
|
295
|
+
return fileName;
|
|
296
|
+
};
|
|
297
|
+
exports2.getRoot = function getRoot(file) {
|
|
298
|
+
var dir = dirname2(file), prev;
|
|
299
|
+
while (true) {
|
|
300
|
+
if (dir === ".") {
|
|
301
|
+
dir = process.cwd();
|
|
617
302
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
function initRuntime() {
|
|
622
|
-
runtimeInitialized = true;
|
|
623
|
-
wasmExports["z"]();
|
|
624
|
-
}
|
|
625
|
-
function postRun() {
|
|
626
|
-
if (Module["postRun"]) {
|
|
627
|
-
if (typeof Module["postRun"] == "function")
|
|
628
|
-
Module["postRun"] = [Module["postRun"]];
|
|
629
|
-
while (Module["postRun"].length) {
|
|
630
|
-
addOnPostRun(Module["postRun"].shift());
|
|
303
|
+
if (exists(join5(dir, "package.json")) || exists(join5(dir, "node_modules"))) {
|
|
304
|
+
return dir;
|
|
631
305
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
ABORT = true;
|
|
640
|
-
what += ". Build with -sASSERTIONS for more info.";
|
|
641
|
-
var e = new WebAssembly.RuntimeError(what);
|
|
642
|
-
throw e;
|
|
643
|
-
}
|
|
644
|
-
var wasmBinaryFile;
|
|
645
|
-
function findWasmBinary() {
|
|
646
|
-
return locateFile("node-sqlite3-wasm.wasm");
|
|
647
|
-
}
|
|
648
|
-
function getBinarySync(file) {
|
|
649
|
-
if (file == wasmBinaryFile && wasmBinary) {
|
|
650
|
-
return new Uint8Array(wasmBinary);
|
|
651
|
-
}
|
|
652
|
-
if (readBinary) {
|
|
653
|
-
return readBinary(file);
|
|
654
|
-
}
|
|
655
|
-
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)';
|
|
656
|
-
}
|
|
657
|
-
function instantiateSync(file, info) {
|
|
658
|
-
var module3;
|
|
659
|
-
var binary = getBinarySync(file);
|
|
660
|
-
module3 = new WebAssembly.Module(binary);
|
|
661
|
-
var instance = new WebAssembly.Instance(module3, info);
|
|
662
|
-
return [instance, module3];
|
|
663
|
-
}
|
|
664
|
-
function getWasmImports() {
|
|
665
|
-
var imports = { a: wasmImports };
|
|
666
|
-
return imports;
|
|
667
|
-
}
|
|
668
|
-
function createWasm() {
|
|
669
|
-
function receiveInstance(instance, module3) {
|
|
670
|
-
wasmExports = instance.exports;
|
|
671
|
-
assignWasmExports(wasmExports);
|
|
672
|
-
updateMemoryViews();
|
|
673
|
-
return wasmExports;
|
|
674
|
-
}
|
|
675
|
-
var info = getWasmImports();
|
|
676
|
-
if (Module["instantiateWasm"]) {
|
|
677
|
-
return new Promise((resolve, reject) => {
|
|
678
|
-
Module["instantiateWasm"](info, (inst, mod) => {
|
|
679
|
-
resolve(receiveInstance(inst, mod));
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
wasmBinaryFile ??= findWasmBinary();
|
|
684
|
-
var result = instantiateSync(wasmBinaryFile, info);
|
|
685
|
-
return receiveInstance(result[0]);
|
|
686
|
-
}
|
|
687
|
-
var ExitStatus = class {
|
|
688
|
-
name = "ExitStatus";
|
|
689
|
-
constructor(status) {
|
|
690
|
-
this.message = `Program terminated with exit(${status})`;
|
|
691
|
-
this.status = status;
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
var HEAP16;
|
|
695
|
-
var HEAP32;
|
|
696
|
-
var HEAP64;
|
|
697
|
-
var HEAP8;
|
|
698
|
-
var HEAPF32;
|
|
699
|
-
var HEAPF64;
|
|
700
|
-
var HEAPU16;
|
|
701
|
-
var HEAPU32;
|
|
702
|
-
var HEAPU64;
|
|
703
|
-
var HEAPU8;
|
|
704
|
-
var callRuntimeCallbacks = (callbacks) => {
|
|
705
|
-
while (callbacks.length > 0) {
|
|
706
|
-
callbacks.shift()(Module);
|
|
306
|
+
if (prev === dir) {
|
|
307
|
+
throw new Error(
|
|
308
|
+
'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
prev = dir;
|
|
312
|
+
dir = join5(dir, "..");
|
|
707
313
|
}
|
|
708
314
|
};
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
case "i8":
|
|
720
|
-
return HEAP8[ptr];
|
|
721
|
-
case "i16":
|
|
722
|
-
return HEAP16[ptr >> 1];
|
|
723
|
-
case "i32":
|
|
724
|
-
return HEAP32[ptr >> 2];
|
|
725
|
-
case "i64":
|
|
726
|
-
return HEAP64[ptr >> 3];
|
|
727
|
-
case "float":
|
|
728
|
-
return HEAPF32[ptr >> 2];
|
|
729
|
-
case "double":
|
|
730
|
-
return HEAPF64[ptr >> 3];
|
|
731
|
-
case "*":
|
|
732
|
-
return HEAPU32[ptr >> 2];
|
|
733
|
-
default:
|
|
734
|
-
abort(`invalid type for getValue: ${type}`);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
var noExitRuntime = true;
|
|
738
|
-
function setValue(ptr, value, type = "i8") {
|
|
739
|
-
if (type.endsWith("*"))
|
|
740
|
-
type = "*";
|
|
741
|
-
switch (type) {
|
|
742
|
-
case "i1":
|
|
743
|
-
HEAP8[ptr] = value;
|
|
744
|
-
break;
|
|
745
|
-
case "i8":
|
|
746
|
-
HEAP8[ptr] = value;
|
|
747
|
-
break;
|
|
748
|
-
case "i16":
|
|
749
|
-
HEAP16[ptr >> 1] = value;
|
|
750
|
-
break;
|
|
751
|
-
case "i32":
|
|
752
|
-
HEAP32[ptr >> 2] = value;
|
|
753
|
-
break;
|
|
754
|
-
case "i64":
|
|
755
|
-
HEAP64[ptr >> 3] = BigInt(value);
|
|
756
|
-
break;
|
|
757
|
-
case "float":
|
|
758
|
-
HEAPF32[ptr >> 2] = value;
|
|
759
|
-
break;
|
|
760
|
-
case "double":
|
|
761
|
-
HEAPF64[ptr >> 3] = value;
|
|
762
|
-
break;
|
|
763
|
-
case "*":
|
|
764
|
-
HEAPU32[ptr >> 2] = value;
|
|
765
|
-
break;
|
|
766
|
-
default:
|
|
767
|
-
abort(`invalid type for setValue: ${type}`);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
771
|
-
var stackSave = () => _emscripten_stack_get_current();
|
|
772
|
-
var __abort_js = () => abort("");
|
|
773
|
-
var runtimeKeepaliveCounter = 0;
|
|
774
|
-
var __emscripten_runtime_keepalive_clear = () => {
|
|
775
|
-
noExitRuntime = false;
|
|
776
|
-
runtimeKeepaliveCounter = 0;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
319
|
+
var require_wrappers = __commonJS({
|
|
320
|
+
"node_modules/better-sqlite3/lib/methods/wrappers.js"(exports2) {
|
|
321
|
+
"use strict";
|
|
322
|
+
var { cppdb } = require_util();
|
|
323
|
+
exports2.prepare = function prepare(sql) {
|
|
324
|
+
return this[cppdb].prepare(sql, this, false);
|
|
777
325
|
};
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
var ydayFromDate = (date) => {
|
|
782
|
-
var leap = isLeapYear(date.getFullYear());
|
|
783
|
-
var monthDaysCumulative = leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE;
|
|
784
|
-
var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
|
|
785
|
-
return yday;
|
|
326
|
+
exports2.exec = function exec(sql) {
|
|
327
|
+
this[cppdb].exec(sql);
|
|
328
|
+
return this;
|
|
786
329
|
};
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
function __localtime_js(time, tmPtr) {
|
|
791
|
-
time = bigintToI53Checked(time);
|
|
792
|
-
var date = new Date(time * 1e3);
|
|
793
|
-
HEAP32[tmPtr >> 2] = date.getSeconds();
|
|
794
|
-
HEAP32[tmPtr + 4 >> 2] = date.getMinutes();
|
|
795
|
-
HEAP32[tmPtr + 8 >> 2] = date.getHours();
|
|
796
|
-
HEAP32[tmPtr + 12 >> 2] = date.getDate();
|
|
797
|
-
HEAP32[tmPtr + 16 >> 2] = date.getMonth();
|
|
798
|
-
HEAP32[tmPtr + 20 >> 2] = date.getFullYear() - 1900;
|
|
799
|
-
HEAP32[tmPtr + 24 >> 2] = date.getDay();
|
|
800
|
-
var yday = ydayFromDate(date) | 0;
|
|
801
|
-
HEAP32[tmPtr + 28 >> 2] = yday;
|
|
802
|
-
HEAP32[tmPtr + 36 >> 2] = -(date.getTimezoneOffset() * 60);
|
|
803
|
-
var start = new Date(date.getFullYear(), 0, 1);
|
|
804
|
-
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
|
|
805
|
-
var winterOffset = start.getTimezoneOffset();
|
|
806
|
-
var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
|
|
807
|
-
HEAP32[tmPtr + 32 >> 2] = dst;
|
|
808
|
-
}
|
|
809
|
-
var timers = {};
|
|
810
|
-
var handleException = (e) => {
|
|
811
|
-
if (e instanceof ExitStatus || e == "unwind") {
|
|
812
|
-
return EXITSTATUS;
|
|
813
|
-
}
|
|
814
|
-
quit_(1, e);
|
|
330
|
+
exports2.close = function close() {
|
|
331
|
+
this[cppdb].close();
|
|
332
|
+
return this;
|
|
815
333
|
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
if (!keepRuntimeAlive()) {
|
|
820
|
-
Module["onExit"]?.(code);
|
|
821
|
-
ABORT = true;
|
|
822
|
-
}
|
|
823
|
-
quit_(code, new ExitStatus(code));
|
|
334
|
+
exports2.loadExtension = function loadExtension(...args) {
|
|
335
|
+
this[cppdb].loadExtension(...args);
|
|
336
|
+
return this;
|
|
824
337
|
};
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
338
|
+
exports2.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
339
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
340
|
+
return this;
|
|
828
341
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
try {
|
|
833
|
-
_exit(EXITSTATUS);
|
|
834
|
-
} catch (e) {
|
|
835
|
-
handleException(e);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
342
|
+
exports2.unsafeMode = function unsafeMode(...args) {
|
|
343
|
+
this[cppdb].unsafeMode(...args);
|
|
344
|
+
return this;
|
|
838
345
|
};
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
346
|
+
exports2.getters = {
|
|
347
|
+
name: {
|
|
348
|
+
get: function name() {
|
|
349
|
+
return this[cppdb].name;
|
|
350
|
+
},
|
|
351
|
+
enumerable: true
|
|
352
|
+
},
|
|
353
|
+
open: {
|
|
354
|
+
get: function open() {
|
|
355
|
+
return this[cppdb].open;
|
|
356
|
+
},
|
|
357
|
+
enumerable: true
|
|
358
|
+
},
|
|
359
|
+
inTransaction: {
|
|
360
|
+
get: function inTransaction() {
|
|
361
|
+
return this[cppdb].inTransaction;
|
|
362
|
+
},
|
|
363
|
+
enumerable: true
|
|
364
|
+
},
|
|
365
|
+
readonly: {
|
|
366
|
+
get: function readonly() {
|
|
367
|
+
return this[cppdb].readonly;
|
|
368
|
+
},
|
|
369
|
+
enumerable: true
|
|
370
|
+
},
|
|
371
|
+
memory: {
|
|
372
|
+
get: function memory() {
|
|
373
|
+
return this[cppdb].memory;
|
|
374
|
+
},
|
|
375
|
+
enumerable: true
|
|
849
376
|
}
|
|
850
377
|
};
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// node_modules/better-sqlite3/lib/methods/transaction.js
|
|
382
|
+
var require_transaction = __commonJS({
|
|
383
|
+
"node_modules/better-sqlite3/lib/methods/transaction.js"(exports2, module2) {
|
|
384
|
+
"use strict";
|
|
385
|
+
var { cppdb } = require_util();
|
|
386
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
387
|
+
module2.exports = function transaction(fn) {
|
|
388
|
+
if (typeof fn !== "function")
|
|
389
|
+
throw new TypeError("Expected first argument to be a function");
|
|
390
|
+
const db3 = this[cppdb];
|
|
391
|
+
const controller = getController(db3, this);
|
|
392
|
+
const { apply } = Function.prototype;
|
|
393
|
+
const properties = {
|
|
394
|
+
default: { value: wrapTransaction(apply, fn, db3, controller.default) },
|
|
395
|
+
deferred: { value: wrapTransaction(apply, fn, db3, controller.deferred) },
|
|
396
|
+
immediate: { value: wrapTransaction(apply, fn, db3, controller.immediate) },
|
|
397
|
+
exclusive: { value: wrapTransaction(apply, fn, db3, controller.exclusive) },
|
|
398
|
+
database: { value: this, enumerable: true }
|
|
399
|
+
};
|
|
400
|
+
Object.defineProperties(properties.default.value, properties);
|
|
401
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
402
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
403
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
404
|
+
return properties.default.value;
|
|
865
405
|
};
|
|
866
|
-
var
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
} else if (u <= 65535) {
|
|
883
|
-
if (outIdx + 2 >= endIdx)
|
|
884
|
-
break;
|
|
885
|
-
heap[outIdx++] = 224 | u >> 12;
|
|
886
|
-
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
887
|
-
heap[outIdx++] = 128 | u & 63;
|
|
888
|
-
} else {
|
|
889
|
-
if (outIdx + 3 >= endIdx)
|
|
890
|
-
break;
|
|
891
|
-
heap[outIdx++] = 240 | u >> 18;
|
|
892
|
-
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
893
|
-
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
894
|
-
heap[outIdx++] = 128 | u & 63;
|
|
895
|
-
i++;
|
|
896
|
-
}
|
|
406
|
+
var getController = (db3, self) => {
|
|
407
|
+
let controller = controllers.get(db3);
|
|
408
|
+
if (!controller) {
|
|
409
|
+
const shared = {
|
|
410
|
+
commit: db3.prepare("COMMIT", self, false),
|
|
411
|
+
rollback: db3.prepare("ROLLBACK", self, false),
|
|
412
|
+
savepoint: db3.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
413
|
+
release: db3.prepare("RELEASE ` _bs3. `", self, false),
|
|
414
|
+
rollbackTo: db3.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
415
|
+
};
|
|
416
|
+
controllers.set(db3, controller = {
|
|
417
|
+
default: Object.assign({ begin: db3.prepare("BEGIN", self, false) }, shared),
|
|
418
|
+
deferred: Object.assign({ begin: db3.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
419
|
+
immediate: Object.assign({ begin: db3.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
420
|
+
exclusive: Object.assign({ begin: db3.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
421
|
+
});
|
|
897
422
|
}
|
|
898
|
-
|
|
899
|
-
return outIdx - startIdx;
|
|
423
|
+
return controller;
|
|
900
424
|
};
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
var summerOffset = summer.getTimezoneOffset();
|
|
908
|
-
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
|
|
909
|
-
HEAPU32[timezone >> 2] = stdTimezoneOffset * 60;
|
|
910
|
-
HEAP32[daylight >> 2] = Number(winterOffset != summerOffset);
|
|
911
|
-
var extractZone = (timezoneOffset) => {
|
|
912
|
-
var sign = timezoneOffset >= 0 ? "-" : "+";
|
|
913
|
-
var absOffset = Math.abs(timezoneOffset);
|
|
914
|
-
var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
|
|
915
|
-
var minutes = String(absOffset % 60).padStart(2, "0");
|
|
916
|
-
return `UTC${sign}${hours}${minutes}`;
|
|
917
|
-
};
|
|
918
|
-
var winterName = extractZone(winterOffset);
|
|
919
|
-
var summerName = extractZone(summerOffset);
|
|
920
|
-
if (summerOffset < winterOffset) {
|
|
921
|
-
stringToUTF8(winterName, std_name, 17);
|
|
922
|
-
stringToUTF8(summerName, dst_name, 17);
|
|
425
|
+
var wrapTransaction = (apply, fn, db3, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
426
|
+
let before, after, undo;
|
|
427
|
+
if (db3.inTransaction) {
|
|
428
|
+
before = savepoint;
|
|
429
|
+
after = release;
|
|
430
|
+
undo = rollbackTo;
|
|
923
431
|
} else {
|
|
924
|
-
|
|
925
|
-
|
|
432
|
+
before = begin;
|
|
433
|
+
after = commit;
|
|
434
|
+
undo = rollback;
|
|
926
435
|
}
|
|
927
|
-
|
|
928
|
-
var _emscripten_date_now = () => Date.now();
|
|
929
|
-
var getHeapMax = () => 2147483648;
|
|
930
|
-
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
|
|
931
|
-
var growMemory = (size) => {
|
|
932
|
-
var oldHeapSize = wasmMemory.buffer.byteLength;
|
|
933
|
-
var pages = (size - oldHeapSize + 65535) / 65536 | 0;
|
|
436
|
+
before.run();
|
|
934
437
|
try {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
948
|
-
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
949
|
-
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
950
|
-
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
951
|
-
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
952
|
-
var replacement = growMemory(newSize);
|
|
953
|
-
if (replacement) {
|
|
954
|
-
return true;
|
|
438
|
+
const result = apply.call(fn, this, arguments);
|
|
439
|
+
if (result && typeof result.then === "function") {
|
|
440
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
441
|
+
}
|
|
442
|
+
after.run();
|
|
443
|
+
return result;
|
|
444
|
+
} catch (ex) {
|
|
445
|
+
if (db3.inTransaction) {
|
|
446
|
+
undo.run();
|
|
447
|
+
if (undo !== rollback)
|
|
448
|
+
after.run();
|
|
955
449
|
}
|
|
450
|
+
throw ex;
|
|
956
451
|
}
|
|
957
|
-
return false;
|
|
958
452
|
};
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// node_modules/better-sqlite3/lib/methods/pragma.js
|
|
457
|
+
var require_pragma = __commonJS({
|
|
458
|
+
"node_modules/better-sqlite3/lib/methods/pragma.js"(exports2, module2) {
|
|
459
|
+
"use strict";
|
|
460
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
461
|
+
module2.exports = function pragma(source, options) {
|
|
462
|
+
if (options == null)
|
|
463
|
+
options = {};
|
|
464
|
+
if (typeof source !== "string")
|
|
465
|
+
throw new TypeError("Expected first argument to be a string");
|
|
466
|
+
if (typeof options !== "object")
|
|
467
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
468
|
+
const simple = getBooleanOption(options, "simple");
|
|
469
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
470
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
967
471
|
};
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// node_modules/better-sqlite3/lib/methods/backup.js
|
|
476
|
+
var require_backup = __commonJS({
|
|
477
|
+
"node_modules/better-sqlite3/lib/methods/backup.js"(exports2, module2) {
|
|
478
|
+
"use strict";
|
|
479
|
+
var fs3 = require("fs");
|
|
480
|
+
var path2 = require("path");
|
|
481
|
+
var { promisify } = require("util");
|
|
482
|
+
var { cppdb } = require_util();
|
|
483
|
+
var fsAccess = promisify(fs3.access);
|
|
484
|
+
module2.exports = async function backup(filename, options) {
|
|
485
|
+
if (options == null)
|
|
486
|
+
options = {};
|
|
487
|
+
if (typeof filename !== "string")
|
|
488
|
+
throw new TypeError("Expected first argument to be a string");
|
|
489
|
+
if (typeof options !== "object")
|
|
490
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
491
|
+
filename = filename.trim();
|
|
492
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
493
|
+
const handler = "progress" in options ? options.progress : null;
|
|
494
|
+
if (!filename)
|
|
495
|
+
throw new TypeError("Backup filename cannot be an empty string");
|
|
496
|
+
if (filename === ":memory:")
|
|
497
|
+
throw new TypeError('Invalid backup filename ":memory:"');
|
|
498
|
+
if (typeof attachedName !== "string")
|
|
499
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
500
|
+
if (!attachedName)
|
|
501
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
502
|
+
if (handler != null && typeof handler !== "function")
|
|
503
|
+
throw new TypeError('Expected the "progress" option to be a function');
|
|
504
|
+
await fsAccess(path2.dirname(filename)).catch(() => {
|
|
505
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
506
|
+
});
|
|
507
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
508
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
999
509
|
};
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
let
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
if (flags == SQLITE_ACCESS_READ)
|
|
1006
|
-
aflags = fs3.constants.R_OK;
|
|
1007
|
-
try {
|
|
1008
|
-
fs3.accessSync(UTF8ToString(filePath), aflags);
|
|
1009
|
-
setValue(outResult, 1, "i32");
|
|
1010
|
-
} catch {
|
|
1011
|
-
setValue(outResult, 0, "i32");
|
|
1012
|
-
}
|
|
1013
|
-
return SQLITE_OK;
|
|
1014
|
-
}
|
|
1015
|
-
function _nodejsCheckReservedLock(fi, outResult) {
|
|
1016
|
-
try {
|
|
1017
|
-
fs3.accessSync(`${_path(fi)}.lock`, fs3.constants.F_OK);
|
|
1018
|
-
setValue(outResult, 1, "i32");
|
|
1019
|
-
} catch {
|
|
1020
|
-
setValue(outResult, 0, "i32");
|
|
1021
|
-
}
|
|
1022
|
-
return SQLITE_OK;
|
|
1023
|
-
}
|
|
1024
|
-
function _nodejsClose(fi) {
|
|
1025
|
-
_nodejsUnlock(fi, SQLITE_LOCK_NONE);
|
|
1026
|
-
try {
|
|
1027
|
-
fs3.closeSync(_fd(fi));
|
|
1028
|
-
} catch {
|
|
1029
|
-
return SQLITE_IOERR_CLOSE;
|
|
1030
|
-
}
|
|
1031
|
-
return SQLITE_OK;
|
|
1032
|
-
}
|
|
1033
|
-
function _nodejsDelete(vfs, filePath, dirSync) {
|
|
1034
|
-
const pathStr = UTF8ToString(filePath);
|
|
1035
|
-
try {
|
|
1036
|
-
fs3.unlinkSync(pathStr);
|
|
1037
|
-
} catch (err2) {
|
|
1038
|
-
if (err2.code != "ENOENT")
|
|
1039
|
-
return SQLITE_IOERR_DELETE;
|
|
1040
|
-
}
|
|
1041
|
-
if (dirSync) {
|
|
1042
|
-
let fd = -1;
|
|
1043
|
-
try {
|
|
1044
|
-
fd = fs3.openSync(path2.dirname(pathStr), "r");
|
|
1045
|
-
fs3.fsyncSync(fd);
|
|
1046
|
-
} catch {
|
|
1047
|
-
return SQLITE_IOERR_FSYNC;
|
|
1048
|
-
} finally {
|
|
510
|
+
var runBackup = (backup, handler) => {
|
|
511
|
+
let rate = 0;
|
|
512
|
+
let useDefault = true;
|
|
513
|
+
return new Promise((resolve, reject) => {
|
|
514
|
+
setImmediate(function step() {
|
|
1049
515
|
try {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
516
|
+
const progress = backup.transfer(rate);
|
|
517
|
+
if (!progress.remainingPages) {
|
|
518
|
+
backup.close();
|
|
519
|
+
resolve(progress);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (useDefault) {
|
|
523
|
+
useDefault = false;
|
|
524
|
+
rate = 100;
|
|
525
|
+
}
|
|
526
|
+
if (handler) {
|
|
527
|
+
const ret = handler(progress);
|
|
528
|
+
if (ret !== void 0) {
|
|
529
|
+
if (typeof ret === "number" && ret === ret)
|
|
530
|
+
rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
531
|
+
else
|
|
532
|
+
throw new TypeError("Expected progress callback to return a number or undefined");
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
setImmediate(step);
|
|
536
|
+
} catch (err) {
|
|
537
|
+
backup.close();
|
|
538
|
+
reject(err);
|
|
1053
539
|
}
|
|
1054
|
-
}
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// node_modules/better-sqlite3/lib/methods/serialize.js
|
|
547
|
+
var require_serialize = __commonJS({
|
|
548
|
+
"node_modules/better-sqlite3/lib/methods/serialize.js"(exports2, module2) {
|
|
549
|
+
"use strict";
|
|
550
|
+
var { cppdb } = require_util();
|
|
551
|
+
module2.exports = function serialize(options) {
|
|
552
|
+
if (options == null)
|
|
553
|
+
options = {};
|
|
554
|
+
if (typeof options !== "object")
|
|
555
|
+
throw new TypeError("Expected first argument to be an options object");
|
|
556
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
557
|
+
if (typeof attachedName !== "string")
|
|
558
|
+
throw new TypeError('Expected the "attached" option to be a string');
|
|
559
|
+
if (!attachedName)
|
|
560
|
+
throw new TypeError('The "attached" option cannot be an empty string');
|
|
561
|
+
return this[cppdb].serialize(attachedName);
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// node_modules/better-sqlite3/lib/methods/function.js
|
|
567
|
+
var require_function = __commonJS({
|
|
568
|
+
"node_modules/better-sqlite3/lib/methods/function.js"(exports2, module2) {
|
|
569
|
+
"use strict";
|
|
570
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
571
|
+
module2.exports = function defineFunction(name, options, fn) {
|
|
572
|
+
if (options == null)
|
|
573
|
+
options = {};
|
|
574
|
+
if (typeof options === "function") {
|
|
575
|
+
fn = options;
|
|
576
|
+
options = {};
|
|
577
|
+
}
|
|
578
|
+
if (typeof name !== "string")
|
|
579
|
+
throw new TypeError("Expected first argument to be a string");
|
|
580
|
+
if (typeof fn !== "function")
|
|
581
|
+
throw new TypeError("Expected last argument to be a function");
|
|
582
|
+
if (typeof options !== "object")
|
|
583
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
584
|
+
if (!name)
|
|
585
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
586
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
587
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
588
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
589
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
590
|
+
let argCount = -1;
|
|
591
|
+
if (!varargs) {
|
|
592
|
+
argCount = fn.length;
|
|
593
|
+
if (!Number.isInteger(argCount) || argCount < 0)
|
|
594
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
595
|
+
if (argCount > 100)
|
|
596
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
597
|
+
}
|
|
598
|
+
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
599
|
+
return this;
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
605
|
+
var require_aggregate = __commonJS({
|
|
606
|
+
"node_modules/better-sqlite3/lib/methods/aggregate.js"(exports2, module2) {
|
|
607
|
+
"use strict";
|
|
608
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
609
|
+
module2.exports = function defineAggregate(name, options) {
|
|
610
|
+
if (typeof name !== "string")
|
|
611
|
+
throw new TypeError("Expected first argument to be a string");
|
|
612
|
+
if (typeof options !== "object" || options === null)
|
|
613
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
614
|
+
if (!name)
|
|
615
|
+
throw new TypeError("User-defined function name cannot be an empty string");
|
|
616
|
+
const start = "start" in options ? options.start : null;
|
|
617
|
+
const step = getFunctionOption(options, "step", true);
|
|
618
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
619
|
+
const result = getFunctionOption(options, "result", false);
|
|
620
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
621
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
622
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
623
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
624
|
+
let argCount = -1;
|
|
625
|
+
if (!varargs) {
|
|
626
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
627
|
+
if (argCount > 0)
|
|
628
|
+
argCount -= 1;
|
|
629
|
+
if (argCount > 100)
|
|
630
|
+
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
631
|
+
}
|
|
632
|
+
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
633
|
+
return this;
|
|
634
|
+
};
|
|
635
|
+
var getFunctionOption = (options, key, required) => {
|
|
636
|
+
const value = key in options ? options[key] : null;
|
|
637
|
+
if (typeof value === "function")
|
|
638
|
+
return value;
|
|
639
|
+
if (value != null)
|
|
640
|
+
throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
641
|
+
if (required)
|
|
642
|
+
throw new TypeError(`Missing required option "${key}"`);
|
|
643
|
+
return null;
|
|
644
|
+
};
|
|
645
|
+
var getLength = ({ length }) => {
|
|
646
|
+
if (Number.isInteger(length) && length >= 0)
|
|
647
|
+
return length;
|
|
648
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// node_modules/better-sqlite3/lib/methods/table.js
|
|
654
|
+
var require_table = __commonJS({
|
|
655
|
+
"node_modules/better-sqlite3/lib/methods/table.js"(exports2, module2) {
|
|
656
|
+
"use strict";
|
|
657
|
+
var { cppdb } = require_util();
|
|
658
|
+
module2.exports = function defineTable(name, factory) {
|
|
659
|
+
if (typeof name !== "string")
|
|
660
|
+
throw new TypeError("Expected first argument to be a string");
|
|
661
|
+
if (!name)
|
|
662
|
+
throw new TypeError("Virtual table module name cannot be an empty string");
|
|
663
|
+
let eponymous = false;
|
|
664
|
+
if (typeof factory === "object" && factory !== null) {
|
|
665
|
+
eponymous = true;
|
|
666
|
+
factory = defer(parseTableDefinition(factory, "used", name));
|
|
667
|
+
} else {
|
|
668
|
+
if (typeof factory !== "function")
|
|
669
|
+
throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
670
|
+
factory = wrapFactory(factory);
|
|
1055
671
|
}
|
|
1056
|
-
|
|
672
|
+
this[cppdb].table(factory, name, eponymous);
|
|
673
|
+
return this;
|
|
674
|
+
};
|
|
675
|
+
function wrapFactory(factory) {
|
|
676
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
677
|
+
const thisObject = {
|
|
678
|
+
module: moduleName,
|
|
679
|
+
database: databaseName,
|
|
680
|
+
table: tableName
|
|
681
|
+
};
|
|
682
|
+
const def = apply.call(factory, thisObject, args);
|
|
683
|
+
if (typeof def !== "object" || def === null) {
|
|
684
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
685
|
+
}
|
|
686
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
687
|
+
};
|
|
1057
688
|
}
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
} catch {
|
|
1062
|
-
return SQLITE_IOERR_FSTAT;
|
|
689
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
690
|
+
if (!hasOwnProperty.call(def, "rows")) {
|
|
691
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
1063
692
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
function _nodejsFullPathname(vfs, relPath, sizeFullPath, outFullPath) {
|
|
1067
|
-
const full = path2.resolve(UTF8ToString(relPath));
|
|
1068
|
-
stringToUTF8(full, outFullPath, sizeFullPath);
|
|
1069
|
-
return full.length < sizeFullPath ? SQLITE_OK : SQLITE_CANTOPEN;
|
|
1070
|
-
}
|
|
1071
|
-
function _nodejsLock(fi, level) {
|
|
1072
|
-
if (!_isLocked(fi)) {
|
|
1073
|
-
try {
|
|
1074
|
-
fs3.mkdirSync(`${_path(fi)}.lock`);
|
|
1075
|
-
} catch (err2) {
|
|
1076
|
-
return err2.code == "EEXIST" ? SQLITE_BUSY : SQLITE_IOERR_LOCK;
|
|
1077
|
-
}
|
|
1078
|
-
_setLocked(fi, true);
|
|
693
|
+
if (!hasOwnProperty.call(def, "columns")) {
|
|
694
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
1079
695
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
const buf = HEAPU8.subarray(outBuffer, outBuffer + bytes);
|
|
1084
|
-
crypto.randomFillSync(buf);
|
|
1085
|
-
return bytes;
|
|
1086
|
-
}
|
|
1087
|
-
function _nodejsRead(fi, outBuffer, bytes, offset) {
|
|
1088
|
-
const buf = HEAPU8.subarray(outBuffer, outBuffer + bytes);
|
|
1089
|
-
let bytesRead;
|
|
1090
|
-
try {
|
|
1091
|
-
bytesRead = fs3.readSync(_fd(fi), buf, 0, bytes, offset);
|
|
1092
|
-
} catch {
|
|
1093
|
-
return SQLITE_IOERR_READ;
|
|
696
|
+
const rows = def.rows;
|
|
697
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
698
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
1094
699
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
if (bytesRead < bytes) {
|
|
1099
|
-
try {
|
|
1100
|
-
buf.fill(0, bytesRead);
|
|
1101
|
-
} catch {
|
|
1102
|
-
return SQLITE_IOERR_READ;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
return SQLITE_IOERR_SHORT_READ;
|
|
700
|
+
let columns = def.columns;
|
|
701
|
+
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
702
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
1106
703
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
function _nodejsSync(fi, flags) {
|
|
1110
|
-
try {
|
|
1111
|
-
fs3.fsyncSync(_fd(fi));
|
|
1112
|
-
} catch {
|
|
1113
|
-
return SQLITE_IOERR_FSYNC;
|
|
704
|
+
if (columns.length !== new Set(columns).size) {
|
|
705
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
1114
706
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
function _nodejsTruncate(fi, size) {
|
|
1118
|
-
try {
|
|
1119
|
-
fs3.ftruncateSync(_fd(fi), _safeInt(size));
|
|
1120
|
-
} catch {
|
|
1121
|
-
return SQLITE_IOERR_TRUNCATE;
|
|
707
|
+
if (!columns.length) {
|
|
708
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
1122
709
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
fs3.rmdirSync(`${_path(fi)}.lock`);
|
|
1129
|
-
} catch (err2) {
|
|
1130
|
-
if (err2.code != "ENOENT")
|
|
1131
|
-
return SQLITE_IOERR_UNLOCK;
|
|
710
|
+
let parameters;
|
|
711
|
+
if (hasOwnProperty.call(def, "parameters")) {
|
|
712
|
+
parameters = def.parameters;
|
|
713
|
+
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
714
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
1132
715
|
}
|
|
1133
|
-
|
|
716
|
+
} else {
|
|
717
|
+
parameters = inferParameters(rows);
|
|
1134
718
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
function _nodejsWrite(fi, buffer, bytes, offset) {
|
|
1138
|
-
try {
|
|
1139
|
-
const bytesWritten = fs3.writeSync(_fd(fi), HEAPU8.subarray(buffer, buffer + bytes), 0, bytes, _safeInt(offset));
|
|
1140
|
-
return bytesWritten != bytes ? SQLITE_IOERR_WRITE : SQLITE_OK;
|
|
1141
|
-
} catch {
|
|
1142
|
-
return SQLITE_IOERR_WRITE;
|
|
719
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
720
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
1143
721
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
return process.platform == "win32" ? 260 : 4096;
|
|
1147
|
-
}
|
|
1148
|
-
function _nodejs_open(filePath, flags, mode) {
|
|
1149
|
-
let oflags = 0;
|
|
1150
|
-
if (flags & SQLITE_OPEN_EXCLUSIVE)
|
|
1151
|
-
oflags |= fs3.constants.O_EXCL;
|
|
1152
|
-
if (flags & SQLITE_OPEN_CREATE)
|
|
1153
|
-
oflags |= fs3.constants.O_CREAT;
|
|
1154
|
-
if (flags & SQLITE_OPEN_READONLY)
|
|
1155
|
-
oflags |= fs3.constants.O_RDONLY;
|
|
1156
|
-
if (flags & SQLITE_OPEN_READWRITE)
|
|
1157
|
-
oflags |= fs3.constants.O_RDWR;
|
|
1158
|
-
try {
|
|
1159
|
-
return fs3.openSync(UTF8ToString(filePath), oflags, mode);
|
|
1160
|
-
} catch {
|
|
1161
|
-
return -1;
|
|
722
|
+
if (parameters.length > 32) {
|
|
723
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
1162
724
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
return func;
|
|
1167
|
-
};
|
|
1168
|
-
var writeArrayToMemory = (array, buffer) => {
|
|
1169
|
-
HEAP8.set(array, buffer);
|
|
1170
|
-
};
|
|
1171
|
-
var lengthBytesUTF8 = (str) => {
|
|
1172
|
-
var len = 0;
|
|
1173
|
-
for (var i = 0; i < str.length; ++i) {
|
|
1174
|
-
var c = str.charCodeAt(i);
|
|
1175
|
-
if (c <= 127) {
|
|
1176
|
-
len++;
|
|
1177
|
-
} else if (c <= 2047) {
|
|
1178
|
-
len += 2;
|
|
1179
|
-
} else if (c >= 55296 && c <= 57343) {
|
|
1180
|
-
len += 4;
|
|
1181
|
-
++i;
|
|
1182
|
-
} else {
|
|
1183
|
-
len += 3;
|
|
725
|
+
for (const parameter of parameters) {
|
|
726
|
+
if (columns.includes(parameter)) {
|
|
727
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
1184
728
|
}
|
|
1185
729
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
var ret = stackAlloc(size);
|
|
1192
|
-
stringToUTF8(str, ret, size);
|
|
1193
|
-
return ret;
|
|
1194
|
-
};
|
|
1195
|
-
var ccall = (ident, returnType, argTypes, args, opts) => {
|
|
1196
|
-
var toC = { string: (str) => {
|
|
1197
|
-
var ret2 = 0;
|
|
1198
|
-
if (str !== null && str !== void 0 && str !== 0) {
|
|
1199
|
-
ret2 = stringToUTF8OnStack(str);
|
|
730
|
+
let safeIntegers = 2;
|
|
731
|
+
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
732
|
+
const bool = def.safeIntegers;
|
|
733
|
+
if (typeof bool !== "boolean") {
|
|
734
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
1200
735
|
}
|
|
1201
|
-
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
if (returnType === "string") {
|
|
1209
|
-
return UTF8ToString(ret2);
|
|
736
|
+
safeIntegers = +bool;
|
|
737
|
+
}
|
|
738
|
+
let directOnly = false;
|
|
739
|
+
if (hasOwnProperty.call(def, "directOnly")) {
|
|
740
|
+
directOnly = def.directOnly;
|
|
741
|
+
if (typeof directOnly !== "boolean") {
|
|
742
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
1210
743
|
}
|
|
1211
|
-
if (returnType === "boolean")
|
|
1212
|
-
return Boolean(ret2);
|
|
1213
|
-
return ret2;
|
|
1214
744
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
745
|
+
const columnDefinitions = [
|
|
746
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
747
|
+
...columns.map(identifier)
|
|
748
|
+
];
|
|
749
|
+
return [
|
|
750
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
751
|
+
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
752
|
+
parameters,
|
|
753
|
+
safeIntegers,
|
|
754
|
+
directOnly
|
|
755
|
+
];
|
|
756
|
+
}
|
|
757
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
758
|
+
return function* virtualTable(...args) {
|
|
759
|
+
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
760
|
+
for (let i = 0; i < columnMap.size; ++i) {
|
|
761
|
+
output.push(null);
|
|
762
|
+
}
|
|
763
|
+
for (const row of generator(...args)) {
|
|
764
|
+
if (Array.isArray(row)) {
|
|
765
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
766
|
+
yield output;
|
|
767
|
+
} else if (typeof row === "object" && row !== null) {
|
|
768
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
769
|
+
yield output;
|
|
1225
770
|
} else {
|
|
1226
|
-
|
|
771
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
1227
772
|
}
|
|
1228
773
|
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
777
|
+
if (row.length !== columnCount) {
|
|
778
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
1229
779
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
stackRestore(stack);
|
|
1234
|
-
return convertReturnValue(ret2);
|
|
1235
|
-
}
|
|
1236
|
-
ret = onDone(ret);
|
|
1237
|
-
return ret;
|
|
1238
|
-
};
|
|
1239
|
-
var cwrap = (ident, returnType, argTypes, opts) => {
|
|
1240
|
-
var numericArgs = !argTypes || argTypes.every((type) => type === "number" || type === "boolean");
|
|
1241
|
-
var numericRet = returnType !== "string";
|
|
1242
|
-
if (numericRet && numericArgs && !opts) {
|
|
1243
|
-
return getCFunc(ident);
|
|
1244
|
-
}
|
|
1245
|
-
return (...args) => ccall(ident, returnType, argTypes, args, opts);
|
|
1246
|
-
};
|
|
1247
|
-
var wasmTableMirror = [];
|
|
1248
|
-
var getWasmTableEntry = (funcPtr) => {
|
|
1249
|
-
var func = wasmTableMirror[funcPtr];
|
|
1250
|
-
if (!func) {
|
|
1251
|
-
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
780
|
+
const offset = output.length - columnCount;
|
|
781
|
+
for (let i = 0; i < columnCount; ++i) {
|
|
782
|
+
output[i + offset] = row[i];
|
|
1252
783
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
functionsInTableMap.set(item, i);
|
|
1261
|
-
}
|
|
784
|
+
}
|
|
785
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
786
|
+
let count = 0;
|
|
787
|
+
for (const key of Object.keys(row)) {
|
|
788
|
+
const index = columnMap.get(key);
|
|
789
|
+
if (index === void 0) {
|
|
790
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
1262
791
|
}
|
|
792
|
+
output[index] = row[key];
|
|
793
|
+
count += 1;
|
|
1263
794
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
var getFunctionAddress = (func) => {
|
|
1267
|
-
if (!functionsInTableMap) {
|
|
1268
|
-
functionsInTableMap = /* @__PURE__ */ new WeakMap();
|
|
1269
|
-
updateTableMap(0, wasmTable.length);
|
|
1270
|
-
}
|
|
1271
|
-
return functionsInTableMap.get(func) || 0;
|
|
1272
|
-
};
|
|
1273
|
-
var freeTableIndexes = [];
|
|
1274
|
-
var getEmptyTableSlot = () => {
|
|
1275
|
-
if (freeTableIndexes.length) {
|
|
1276
|
-
return freeTableIndexes.pop();
|
|
795
|
+
if (count !== columnMap.size) {
|
|
796
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
1277
797
|
}
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
1283
|
-
};
|
|
1284
|
-
var uleb128EncodeWithLen = (arr) => {
|
|
1285
|
-
const n = arr.length;
|
|
1286
|
-
return [n % 128 | 128, n >> 7, ...arr];
|
|
1287
|
-
};
|
|
1288
|
-
var wasmTypeCodes = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
1289
|
-
var generateTypePack = (types) => uleb128EncodeWithLen(Array.from(types, (type) => {
|
|
1290
|
-
var code = wasmTypeCodes[type];
|
|
1291
|
-
return code;
|
|
1292
|
-
}));
|
|
1293
|
-
var convertJsFunctionToWasm = (func, sig) => {
|
|
1294
|
-
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);
|
|
1295
|
-
var module3 = new WebAssembly.Module(bytes);
|
|
1296
|
-
var instance = new WebAssembly.Instance(module3, { e: { f: func } });
|
|
1297
|
-
var wrappedFunc = instance.exports["f"];
|
|
1298
|
-
return wrappedFunc;
|
|
1299
|
-
};
|
|
1300
|
-
var addFunction = (func, sig) => {
|
|
1301
|
-
var rtn = getFunctionAddress(func);
|
|
1302
|
-
if (rtn) {
|
|
1303
|
-
return rtn;
|
|
798
|
+
}
|
|
799
|
+
function inferParameters({ length }) {
|
|
800
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
801
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
1304
802
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
} catch (err2) {
|
|
1309
|
-
if (!(err2 instanceof TypeError)) {
|
|
1310
|
-
throw err2;
|
|
1311
|
-
}
|
|
1312
|
-
var wrapped = convertJsFunctionToWasm(func, sig);
|
|
1313
|
-
setWasmTableEntry(ret, wrapped);
|
|
803
|
+
const params = [];
|
|
804
|
+
for (let i = 0; i < length; ++i) {
|
|
805
|
+
params.push(`$${i + 1}`);
|
|
1314
806
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
807
|
+
return params;
|
|
808
|
+
}
|
|
809
|
+
var { hasOwnProperty } = Object.prototype;
|
|
810
|
+
var { apply } = Function.prototype;
|
|
811
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
812
|
+
});
|
|
813
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
814
|
+
var defer = (x) => () => x;
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
819
|
+
var require_inspect = __commonJS({
|
|
820
|
+
"node_modules/better-sqlite3/lib/methods/inspect.js"(exports2, module2) {
|
|
821
|
+
"use strict";
|
|
822
|
+
var DatabaseInspection = function Database2() {
|
|
1317
823
|
};
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
setWasmTableEntry(index, null);
|
|
1321
|
-
freeTableIndexes.push(index);
|
|
824
|
+
module2.exports = function inspect(depth, opts) {
|
|
825
|
+
return Object.assign(new DatabaseInspection(), this);
|
|
1322
826
|
};
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// node_modules/better-sqlite3/lib/database.js
|
|
831
|
+
var require_database = __commonJS({
|
|
832
|
+
"node_modules/better-sqlite3/lib/database.js"(exports2, module2) {
|
|
833
|
+
"use strict";
|
|
834
|
+
var fs3 = require("fs");
|
|
835
|
+
var path2 = require("path");
|
|
836
|
+
var util = require_util();
|
|
837
|
+
var SqliteError = require_sqlite_error();
|
|
838
|
+
var DEFAULT_ADDON;
|
|
839
|
+
function Database2(filenameGiven, options) {
|
|
840
|
+
if (new.target == null) {
|
|
841
|
+
return new Database2(filenameGiven, options);
|
|
842
|
+
}
|
|
843
|
+
let buffer;
|
|
844
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
845
|
+
buffer = filenameGiven;
|
|
846
|
+
filenameGiven = ":memory:";
|
|
847
|
+
}
|
|
848
|
+
if (filenameGiven == null)
|
|
849
|
+
filenameGiven = "";
|
|
850
|
+
if (options == null)
|
|
851
|
+
options = {};
|
|
852
|
+
if (typeof filenameGiven !== "string")
|
|
853
|
+
throw new TypeError("Expected first argument to be a string");
|
|
854
|
+
if (typeof options !== "object")
|
|
855
|
+
throw new TypeError("Expected second argument to be an options object");
|
|
856
|
+
if ("readOnly" in options)
|
|
857
|
+
throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
858
|
+
if ("memory" in options)
|
|
859
|
+
throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
860
|
+
const filename = filenameGiven.trim();
|
|
861
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
862
|
+
const readonly = util.getBooleanOption(options, "readonly");
|
|
863
|
+
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
864
|
+
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
865
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
866
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
867
|
+
if (readonly && anonymous && !buffer)
|
|
868
|
+
throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
869
|
+
if (!Number.isInteger(timeout) || timeout < 0)
|
|
870
|
+
throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
871
|
+
if (timeout > 2147483647)
|
|
872
|
+
throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
873
|
+
if (verbose != null && typeof verbose !== "function")
|
|
874
|
+
throw new TypeError('Expected the "verbose" option to be a function');
|
|
875
|
+
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
|
|
876
|
+
throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
877
|
+
let addon;
|
|
878
|
+
if (nativeBinding == null) {
|
|
879
|
+
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
880
|
+
} else if (typeof nativeBinding === "string") {
|
|
881
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
882
|
+
addon = requireFunc(path2.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
883
|
+
} else {
|
|
884
|
+
addon = nativeBinding;
|
|
1342
885
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
Module["removeFunction"] = removeFunction;
|
|
1347
|
-
var _sqlite3_finalize;
|
|
1348
|
-
var _sqlite3_reset;
|
|
1349
|
-
var _sqlite3_clear_bindings;
|
|
1350
|
-
var _sqlite3_value_blob;
|
|
1351
|
-
var _sqlite3_value_text;
|
|
1352
|
-
var _sqlite3_value_bytes;
|
|
1353
|
-
var _sqlite3_value_double;
|
|
1354
|
-
var _sqlite3_value_int64;
|
|
1355
|
-
var _sqlite3_value_type;
|
|
1356
|
-
var _sqlite3_result_blob;
|
|
1357
|
-
var _sqlite3_result_blob64;
|
|
1358
|
-
var _sqlite3_result_double;
|
|
1359
|
-
var _sqlite3_result_error;
|
|
1360
|
-
var _sqlite3_result_int;
|
|
1361
|
-
var _sqlite3_result_int64;
|
|
1362
|
-
var _sqlite3_result_null;
|
|
1363
|
-
var _sqlite3_result_text;
|
|
1364
|
-
var _sqlite3_step;
|
|
1365
|
-
var _sqlite3_column_count;
|
|
1366
|
-
var _sqlite3_column_blob;
|
|
1367
|
-
var _sqlite3_column_bytes;
|
|
1368
|
-
var _sqlite3_column_double;
|
|
1369
|
-
var _sqlite3_column_int64;
|
|
1370
|
-
var _sqlite3_column_text;
|
|
1371
|
-
var _sqlite3_column_type;
|
|
1372
|
-
var _sqlite3_column_name;
|
|
1373
|
-
var _sqlite3_column_table_name;
|
|
1374
|
-
var _sqlite3_bind_blob;
|
|
1375
|
-
var _sqlite3_bind_blob64;
|
|
1376
|
-
var _sqlite3_bind_double;
|
|
1377
|
-
var _sqlite3_bind_int;
|
|
1378
|
-
var _sqlite3_bind_int64;
|
|
1379
|
-
var _sqlite3_bind_null;
|
|
1380
|
-
var _sqlite3_bind_text;
|
|
1381
|
-
var _sqlite3_bind_parameter_index;
|
|
1382
|
-
var _sqlite3_exec;
|
|
1383
|
-
var _sqlite3_prepare_v2;
|
|
1384
|
-
var _sqlite3_errmsg;
|
|
1385
|
-
var _sqlite3_last_insert_rowid;
|
|
1386
|
-
var _sqlite3_changes;
|
|
1387
|
-
var _sqlite3_close_v2;
|
|
1388
|
-
var _sqlite3_create_function_v2;
|
|
1389
|
-
var _sqlite3_open_v2;
|
|
1390
|
-
var _sqlite3_get_autocommit;
|
|
1391
|
-
var _malloc;
|
|
1392
|
-
var _free;
|
|
1393
|
-
var __emscripten_timeout;
|
|
1394
|
-
var __emscripten_stack_restore;
|
|
1395
|
-
var __emscripten_stack_alloc;
|
|
1396
|
-
var _emscripten_stack_get_current;
|
|
1397
|
-
var memory;
|
|
1398
|
-
var __indirect_function_table;
|
|
1399
|
-
var wasmMemory;
|
|
1400
|
-
var wasmTable;
|
|
1401
|
-
function assignWasmExports(wasmExports2) {
|
|
1402
|
-
_sqlite3_finalize = Module["_sqlite3_finalize"] = wasmExports2["A"];
|
|
1403
|
-
_sqlite3_reset = Module["_sqlite3_reset"] = wasmExports2["B"];
|
|
1404
|
-
_sqlite3_clear_bindings = Module["_sqlite3_clear_bindings"] = wasmExports2["C"];
|
|
1405
|
-
_sqlite3_value_blob = Module["_sqlite3_value_blob"] = wasmExports2["D"];
|
|
1406
|
-
_sqlite3_value_text = Module["_sqlite3_value_text"] = wasmExports2["E"];
|
|
1407
|
-
_sqlite3_value_bytes = Module["_sqlite3_value_bytes"] = wasmExports2["F"];
|
|
1408
|
-
_sqlite3_value_double = Module["_sqlite3_value_double"] = wasmExports2["G"];
|
|
1409
|
-
_sqlite3_value_int64 = Module["_sqlite3_value_int64"] = wasmExports2["H"];
|
|
1410
|
-
_sqlite3_value_type = Module["_sqlite3_value_type"] = wasmExports2["I"];
|
|
1411
|
-
_sqlite3_result_blob = Module["_sqlite3_result_blob"] = wasmExports2["J"];
|
|
1412
|
-
_sqlite3_result_blob64 = Module["_sqlite3_result_blob64"] = wasmExports2["K"];
|
|
1413
|
-
_sqlite3_result_double = Module["_sqlite3_result_double"] = wasmExports2["L"];
|
|
1414
|
-
_sqlite3_result_error = Module["_sqlite3_result_error"] = wasmExports2["M"];
|
|
1415
|
-
_sqlite3_result_int = Module["_sqlite3_result_int"] = wasmExports2["N"];
|
|
1416
|
-
_sqlite3_result_int64 = Module["_sqlite3_result_int64"] = wasmExports2["O"];
|
|
1417
|
-
_sqlite3_result_null = Module["_sqlite3_result_null"] = wasmExports2["P"];
|
|
1418
|
-
_sqlite3_result_text = Module["_sqlite3_result_text"] = wasmExports2["Q"];
|
|
1419
|
-
_sqlite3_step = Module["_sqlite3_step"] = wasmExports2["R"];
|
|
1420
|
-
_sqlite3_column_count = Module["_sqlite3_column_count"] = wasmExports2["S"];
|
|
1421
|
-
_sqlite3_column_blob = Module["_sqlite3_column_blob"] = wasmExports2["T"];
|
|
1422
|
-
_sqlite3_column_bytes = Module["_sqlite3_column_bytes"] = wasmExports2["U"];
|
|
1423
|
-
_sqlite3_column_double = Module["_sqlite3_column_double"] = wasmExports2["V"];
|
|
1424
|
-
_sqlite3_column_int64 = Module["_sqlite3_column_int64"] = wasmExports2["W"];
|
|
1425
|
-
_sqlite3_column_text = Module["_sqlite3_column_text"] = wasmExports2["X"];
|
|
1426
|
-
_sqlite3_column_type = Module["_sqlite3_column_type"] = wasmExports2["Y"];
|
|
1427
|
-
_sqlite3_column_name = Module["_sqlite3_column_name"] = wasmExports2["Z"];
|
|
1428
|
-
_sqlite3_column_table_name = Module["_sqlite3_column_table_name"] = wasmExports2["_"];
|
|
1429
|
-
_sqlite3_bind_blob = Module["_sqlite3_bind_blob"] = wasmExports2["$"];
|
|
1430
|
-
_sqlite3_bind_blob64 = Module["_sqlite3_bind_blob64"] = wasmExports2["aa"];
|
|
1431
|
-
_sqlite3_bind_double = Module["_sqlite3_bind_double"] = wasmExports2["ba"];
|
|
1432
|
-
_sqlite3_bind_int = Module["_sqlite3_bind_int"] = wasmExports2["ca"];
|
|
1433
|
-
_sqlite3_bind_int64 = Module["_sqlite3_bind_int64"] = wasmExports2["da"];
|
|
1434
|
-
_sqlite3_bind_null = Module["_sqlite3_bind_null"] = wasmExports2["ea"];
|
|
1435
|
-
_sqlite3_bind_text = Module["_sqlite3_bind_text"] = wasmExports2["fa"];
|
|
1436
|
-
_sqlite3_bind_parameter_index = Module["_sqlite3_bind_parameter_index"] = wasmExports2["ga"];
|
|
1437
|
-
_sqlite3_exec = Module["_sqlite3_exec"] = wasmExports2["ha"];
|
|
1438
|
-
_sqlite3_prepare_v2 = Module["_sqlite3_prepare_v2"] = wasmExports2["ia"];
|
|
1439
|
-
_sqlite3_errmsg = Module["_sqlite3_errmsg"] = wasmExports2["ja"];
|
|
1440
|
-
_sqlite3_last_insert_rowid = Module["_sqlite3_last_insert_rowid"] = wasmExports2["ka"];
|
|
1441
|
-
_sqlite3_changes = Module["_sqlite3_changes"] = wasmExports2["la"];
|
|
1442
|
-
_sqlite3_close_v2 = Module["_sqlite3_close_v2"] = wasmExports2["ma"];
|
|
1443
|
-
_sqlite3_create_function_v2 = Module["_sqlite3_create_function_v2"] = wasmExports2["na"];
|
|
1444
|
-
_sqlite3_open_v2 = Module["_sqlite3_open_v2"] = wasmExports2["oa"];
|
|
1445
|
-
_sqlite3_get_autocommit = Module["_sqlite3_get_autocommit"] = wasmExports2["pa"];
|
|
1446
|
-
_malloc = Module["_malloc"] = wasmExports2["qa"];
|
|
1447
|
-
_free = Module["_free"] = wasmExports2["ra"];
|
|
1448
|
-
__emscripten_timeout = wasmExports2["ta"];
|
|
1449
|
-
__emscripten_stack_restore = wasmExports2["ua"];
|
|
1450
|
-
__emscripten_stack_alloc = wasmExports2["va"];
|
|
1451
|
-
_emscripten_stack_get_current = wasmExports2["wa"];
|
|
1452
|
-
memory = wasmMemory = wasmExports2["y"];
|
|
1453
|
-
__indirect_function_table = wasmTable = wasmExports2["sa"];
|
|
1454
|
-
}
|
|
1455
|
-
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 };
|
|
1456
|
-
function run() {
|
|
1457
|
-
preRun();
|
|
1458
|
-
function doRun() {
|
|
1459
|
-
Module["calledRun"] = true;
|
|
1460
|
-
if (ABORT)
|
|
1461
|
-
return;
|
|
1462
|
-
initRuntime();
|
|
1463
|
-
Module["onRuntimeInitialized"]?.();
|
|
1464
|
-
postRun();
|
|
886
|
+
if (!addon.isInitialized) {
|
|
887
|
+
addon.setErrorConstructor(SqliteError);
|
|
888
|
+
addon.isInitialized = true;
|
|
1465
889
|
}
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
1468
|
-
setTimeout(() => {
|
|
1469
|
-
setTimeout(() => Module["setStatus"](""), 1);
|
|
1470
|
-
doRun();
|
|
1471
|
-
}, 1);
|
|
1472
|
-
} else {
|
|
1473
|
-
doRun();
|
|
890
|
+
if (!anonymous && !filename.startsWith("file:") && !fs3.existsSync(path2.dirname(filename))) {
|
|
891
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
1474
892
|
}
|
|
893
|
+
Object.defineProperties(this, {
|
|
894
|
+
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
895
|
+
...wrappers.getters
|
|
896
|
+
});
|
|
1475
897
|
}
|
|
1476
|
-
var
|
|
1477
|
-
|
|
1478
|
-
|
|
898
|
+
var wrappers = require_wrappers();
|
|
899
|
+
Database2.prototype.prepare = wrappers.prepare;
|
|
900
|
+
Database2.prototype.transaction = require_transaction();
|
|
901
|
+
Database2.prototype.pragma = require_pragma();
|
|
902
|
+
Database2.prototype.backup = require_backup();
|
|
903
|
+
Database2.prototype.serialize = require_serialize();
|
|
904
|
+
Database2.prototype.function = require_function();
|
|
905
|
+
Database2.prototype.aggregate = require_aggregate();
|
|
906
|
+
Database2.prototype.table = require_table();
|
|
907
|
+
Database2.prototype.loadExtension = wrappers.loadExtension;
|
|
908
|
+
Database2.prototype.exec = wrappers.exec;
|
|
909
|
+
Database2.prototype.close = wrappers.close;
|
|
910
|
+
Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
911
|
+
Database2.prototype.unsafeMode = wrappers.unsafeMode;
|
|
912
|
+
Database2.prototype[util.inspect] = require_inspect();
|
|
913
|
+
module2.exports = Database2;
|
|
1479
914
|
}
|
|
1480
915
|
});
|
|
1481
916
|
|
|
1482
|
-
//
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return rootOverride;
|
|
1486
|
-
const envRoot = process.env["RECALL_HOME"];
|
|
1487
|
-
if (envRoot && envRoot.length > 0)
|
|
1488
|
-
return envRoot;
|
|
1489
|
-
return (0, import_node_path2.join)((0, import_node_os.homedir)(), ".recall");
|
|
1490
|
-
}
|
|
1491
|
-
function dbPath() {
|
|
1492
|
-
return (0, import_node_path2.join)(recallRoot(), "recall.db");
|
|
1493
|
-
}
|
|
1494
|
-
function binDir() {
|
|
1495
|
-
return (0, import_node_path2.join)(recallRoot(), "bin");
|
|
1496
|
-
}
|
|
1497
|
-
function logsDir() {
|
|
1498
|
-
return (0, import_node_path2.join)(recallRoot(), "logs");
|
|
1499
|
-
}
|
|
1500
|
-
function ensureDir() {
|
|
1501
|
-
(0, import_node_fs2.mkdirSync)(recallRoot(), { recursive: true });
|
|
1502
|
-
}
|
|
1503
|
-
var import_node_fs2, import_node_os, import_node_path2, rootOverride;
|
|
1504
|
-
var init_paths = __esm({
|
|
1505
|
-
"src/paths.ts"() {
|
|
917
|
+
// node_modules/better-sqlite3/lib/index.js
|
|
918
|
+
var require_lib = __commonJS({
|
|
919
|
+
"node_modules/better-sqlite3/lib/index.js"(exports2, module2) {
|
|
1506
920
|
"use strict";
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
import_node_path2 = require("node:path");
|
|
1510
|
-
rootOverride = null;
|
|
921
|
+
module2.exports = require_database();
|
|
922
|
+
module2.exports.SqliteError = require_sqlite_error();
|
|
1511
923
|
}
|
|
1512
924
|
});
|
|
1513
925
|
|
|
@@ -1554,10 +966,35 @@ function stripToolContent(entries) {
|
|
|
1554
966
|
}
|
|
1555
967
|
|
|
1556
968
|
// src/db.ts
|
|
1557
|
-
var
|
|
1558
|
-
var
|
|
969
|
+
var import_node_fs2 = require("node:fs");
|
|
970
|
+
var import_node_path2 = require("node:path");
|
|
971
|
+
var import_node_module = require("node:module");
|
|
1559
972
|
init_log();
|
|
1560
|
-
|
|
973
|
+
init_paths();
|
|
974
|
+
var import_better_sqlite3 = __toESM(require_lib());
|
|
975
|
+
var BindingLoadError = class extends Error {
|
|
976
|
+
constructor(dbPath2, cause) {
|
|
977
|
+
super(
|
|
978
|
+
`recall: failed to load the better-sqlite3 native binding while opening ${dbPath2}: ${cause.message}
|
|
979
|
+
The binding is ABI-locked to the Node it was built for \u2014 run \`recall doctor\` (usually fixed by re-running \`recall install\`).`
|
|
980
|
+
);
|
|
981
|
+
this.dbPath = dbPath2;
|
|
982
|
+
this.cause = cause;
|
|
983
|
+
this.name = "BindingLoadError";
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
function isBindingLoadError(e) {
|
|
987
|
+
if (!e || typeof e !== "object")
|
|
988
|
+
return false;
|
|
989
|
+
const err = e;
|
|
990
|
+
const code = typeof err.code === "string" ? err.code : "";
|
|
991
|
+
if (code === "ERR_DLOPEN_FAILED" || code === "MODULE_NOT_FOUND")
|
|
992
|
+
return true;
|
|
993
|
+
const msg = typeof err.message === "string" ? err.message : "";
|
|
994
|
+
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(
|
|
995
|
+
msg
|
|
996
|
+
);
|
|
997
|
+
}
|
|
1561
998
|
var db = null;
|
|
1562
999
|
var currentDbPath = null;
|
|
1563
1000
|
function getDb(dbPath2) {
|
|
@@ -1566,16 +1003,17 @@ function getDb(dbPath2) {
|
|
|
1566
1003
|
if (db) {
|
|
1567
1004
|
closeDb();
|
|
1568
1005
|
}
|
|
1569
|
-
(0,
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1006
|
+
(0, import_node_fs2.mkdirSync)((0, import_node_path2.dirname)(dbPath2), { recursive: true });
|
|
1007
|
+
cleanupWasmArtifacts(dbPath2);
|
|
1008
|
+
const raw = openDatabase(dbPath2);
|
|
1009
|
+
try {
|
|
1010
|
+
configurePragmas(raw, dbPath2);
|
|
1011
|
+
} catch (e) {
|
|
1012
|
+
raw.close();
|
|
1013
|
+
throw e;
|
|
1014
|
+
}
|
|
1015
|
+
db = createAdapter(raw);
|
|
1573
1016
|
currentDbPath = dbPath2;
|
|
1574
|
-
db.exec("PRAGMA busy_timeout = 5000");
|
|
1575
|
-
db.exec("PRAGMA journal_mode = WAL");
|
|
1576
|
-
db.exec("PRAGMA synchronous = NORMAL");
|
|
1577
|
-
db.exec("PRAGMA wal_autocheckpoint = 1000");
|
|
1578
|
-
db.exec("PRAGMA foreign_keys = ON");
|
|
1579
1017
|
ensureSchema(db);
|
|
1580
1018
|
log({ source: "db", level: "info", summary: `DB: initialized at ${dbPath2}` });
|
|
1581
1019
|
return db;
|
|
@@ -1583,84 +1021,111 @@ function getDb(dbPath2) {
|
|
|
1583
1021
|
function closeDb() {
|
|
1584
1022
|
if (db) {
|
|
1585
1023
|
db.close();
|
|
1586
|
-
if (currentDbPath)
|
|
1587
|
-
removeOwnerFile(currentDbPath);
|
|
1588
1024
|
db = null;
|
|
1589
1025
|
currentDbPath = null;
|
|
1590
1026
|
}
|
|
1591
1027
|
}
|
|
1592
|
-
function
|
|
1593
|
-
|
|
1594
|
-
}
|
|
1595
|
-
function processStartToken(pid) {
|
|
1596
|
-
if (process.platform !== "linux")
|
|
1597
|
-
return "";
|
|
1028
|
+
function openDatabase(dbPath2) {
|
|
1029
|
+
const nativeBinding = resolveNativeBinding();
|
|
1598
1030
|
try {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
if (
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const starttime = rest[19];
|
|
1605
|
-
return starttime ?? "";
|
|
1606
|
-
} catch {
|
|
1607
|
-
return "";
|
|
1031
|
+
return nativeBinding ? new import_better_sqlite3.default(dbPath2, { nativeBinding }) : new import_better_sqlite3.default(dbPath2);
|
|
1032
|
+
} catch (e) {
|
|
1033
|
+
if (isBindingLoadError(e))
|
|
1034
|
+
throw new BindingLoadError(dbPath2, e);
|
|
1035
|
+
throw e;
|
|
1608
1036
|
}
|
|
1609
1037
|
}
|
|
1610
|
-
function
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1038
|
+
function resolveNativeBinding() {
|
|
1039
|
+
const sibling = (0, import_node_path2.join)(__dirname, "better_sqlite3.node");
|
|
1040
|
+
if ((0, import_node_fs2.existsSync)(sibling))
|
|
1041
|
+
return sibling;
|
|
1042
|
+
const resolved = resolveInstalledBinding();
|
|
1043
|
+
if (resolved)
|
|
1044
|
+
return resolved;
|
|
1045
|
+
const staged = (0, import_node_path2.join)(binDir(), "better_sqlite3.node");
|
|
1046
|
+
if ((0, import_node_fs2.existsSync)(staged))
|
|
1047
|
+
return staged;
|
|
1048
|
+
return null;
|
|
1616
1049
|
}
|
|
1617
|
-
function
|
|
1050
|
+
function resolveInstalledBinding() {
|
|
1618
1051
|
try {
|
|
1619
|
-
(0,
|
|
1052
|
+
const pkgJson = (0, import_node_module.createRequire)(__filename).resolve("better-sqlite3/package.json");
|
|
1053
|
+
return findNativeBinding((0, import_node_path2.dirname)(pkgJson));
|
|
1620
1054
|
} catch {
|
|
1055
|
+
return null;
|
|
1621
1056
|
}
|
|
1622
1057
|
}
|
|
1623
|
-
function
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1058
|
+
function findNativeBinding(baseDir) {
|
|
1059
|
+
for (const c of [
|
|
1060
|
+
(0, import_node_path2.join)(baseDir, "build", "Release", "better_sqlite3.node"),
|
|
1061
|
+
(0, import_node_path2.join)(baseDir, "build", "Debug", "better_sqlite3.node")
|
|
1062
|
+
]) {
|
|
1063
|
+
try {
|
|
1064
|
+
if ((0, import_node_fs2.statSync)(c).isFile())
|
|
1065
|
+
return c;
|
|
1066
|
+
} catch {
|
|
1067
|
+
}
|
|
1629
1068
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
return;
|
|
1635
|
-
const ownerFile = ownerFilePath(dbPath2);
|
|
1636
|
-
if ((0, import_node_fs.existsSync)(ownerFile)) {
|
|
1069
|
+
const stack = [baseDir];
|
|
1070
|
+
while (stack.length) {
|
|
1071
|
+
const dir = stack.pop();
|
|
1072
|
+
let entries;
|
|
1637
1073
|
try {
|
|
1638
|
-
|
|
1639
|
-
const sep = raw.indexOf(":");
|
|
1640
|
-
const pidStr = sep === -1 ? raw : raw.slice(0, sep);
|
|
1641
|
-
const storedToken = sep === -1 ? "" : raw.slice(sep + 1);
|
|
1642
|
-
const pid = parseInt(pidStr, 10);
|
|
1643
|
-
if (!isNaN(pid) && isProcessAlive(pid)) {
|
|
1644
|
-
if (storedToken === "" || storedToken === processStartToken(pid)) {
|
|
1645
|
-
return;
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1074
|
+
entries = (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true });
|
|
1648
1075
|
} catch {
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
for (const e of entries) {
|
|
1079
|
+
const p = (0, import_node_path2.join)(dir, e.name);
|
|
1080
|
+
if (e.isDirectory())
|
|
1081
|
+
stack.push(p);
|
|
1082
|
+
else if (e.name.endsWith(".node"))
|
|
1083
|
+
return p;
|
|
1649
1084
|
}
|
|
1650
1085
|
}
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
function createAdapter(raw) {
|
|
1089
|
+
return {
|
|
1090
|
+
all: (sql, params) => raw.prepare(sql).all(...params ?? []),
|
|
1091
|
+
get: (sql, params) => raw.prepare(sql).get(...params ?? []),
|
|
1092
|
+
run: (sql, params) => raw.prepare(sql).run(...params ?? []),
|
|
1093
|
+
exec: (sql) => {
|
|
1094
|
+
raw.exec(sql);
|
|
1095
|
+
},
|
|
1096
|
+
prepare: (sql) => {
|
|
1097
|
+
const st = raw.prepare(sql);
|
|
1098
|
+
return {
|
|
1099
|
+
run: (p) => st.run(...p ?? []),
|
|
1100
|
+
all: (p) => st.all(...p ?? []),
|
|
1101
|
+
get: (p) => st.get(...p ?? [])
|
|
1102
|
+
};
|
|
1103
|
+
},
|
|
1104
|
+
close: () => raw.close()
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
function configurePragmas(raw, dbPath2) {
|
|
1108
|
+
const isMemory = dbPath2 === ":memory:" || dbPath2.includes(":memory:") || dbPath2.startsWith("file::memory:");
|
|
1109
|
+
raw.pragma("busy_timeout = 5000");
|
|
1110
|
+
const mode = raw.pragma("journal_mode = WAL", { simple: true });
|
|
1111
|
+
if (!isMemory && mode !== "wal") {
|
|
1112
|
+
throw new Error(
|
|
1113
|
+
`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\`.`
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
raw.pragma("synchronous = NORMAL");
|
|
1117
|
+
raw.pragma("wal_autocheckpoint = 1000");
|
|
1118
|
+
raw.pragma("foreign_keys = ON");
|
|
1119
|
+
}
|
|
1120
|
+
function cleanupWasmArtifacts(dbPath2) {
|
|
1651
1121
|
try {
|
|
1652
|
-
(0,
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
} catch
|
|
1659
|
-
log({
|
|
1660
|
-
source: "db",
|
|
1661
|
-
level: "error",
|
|
1662
|
-
summary: `DB: failed to remove stale lock directory: ${err}`
|
|
1663
|
-
});
|
|
1122
|
+
(0, import_node_fs2.rmSync)(`${dbPath2}.lock`, { recursive: true, force: true });
|
|
1123
|
+
} catch {
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
if ((0, import_node_fs2.existsSync)(`${dbPath2}.owner`))
|
|
1127
|
+
(0, import_node_fs2.unlinkSync)(`${dbPath2}.owner`);
|
|
1128
|
+
} catch {
|
|
1664
1129
|
}
|
|
1665
1130
|
}
|
|
1666
1131
|
function ensureSchema(db3) {
|
|
@@ -1678,6 +1143,12 @@ function ensureSchema(db3) {
|
|
|
1678
1143
|
|
|
1679
1144
|
CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id, created_at);
|
|
1680
1145
|
CREATE INDEX IF NOT EXISTS idx_messages_project ON messages(project_id);
|
|
1146
|
+
-- getUnembeddedMessages() orders the whole table by created_at DESC (LIMIT N).
|
|
1147
|
+
-- Without a standalone created_at index SQLite full-scans messages and builds
|
|
1148
|
+
-- a TEMP B-TREE to sort on every call \u2014 a ~4s/batch cost that dominates the
|
|
1149
|
+
-- embed drain and every Stop-hook catch-up. This index serves the ORDER BY so
|
|
1150
|
+
-- the planner walks it and early-terminates at LIMIT instead.
|
|
1151
|
+
CREATE INDEX IF NOT EXISTS idx_messages_created_at ON messages(created_at);
|
|
1681
1152
|
`);
|
|
1682
1153
|
db3.exec(`
|
|
1683
1154
|
CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts USING fts5(
|
|
@@ -1718,9 +1189,19 @@ function ensureSchema(db3) {
|
|
|
1718
1189
|
message_id TEXT PRIMARY KEY REFERENCES messages(message_id) ON DELETE CASCADE,
|
|
1719
1190
|
embedding_q8 BLOB NOT NULL,
|
|
1720
1191
|
norm REAL NOT NULL,
|
|
1721
|
-
quant_scale REAL NOT NULL
|
|
1192
|
+
quant_scale REAL NOT NULL,
|
|
1193
|
+
embed_version INTEGER NOT NULL DEFAULT 1
|
|
1722
1194
|
);
|
|
1723
1195
|
`);
|
|
1196
|
+
const hasEmbedVersion = () => db3.all(`PRAGMA table_info(message_vectors)`).some((c) => c.name === "embed_version");
|
|
1197
|
+
if (!hasEmbedVersion()) {
|
|
1198
|
+
try {
|
|
1199
|
+
db3.exec(`ALTER TABLE message_vectors ADD COLUMN embed_version INTEGER NOT NULL DEFAULT 1`);
|
|
1200
|
+
} catch (e) {
|
|
1201
|
+
if (!hasEmbedVersion())
|
|
1202
|
+
throw e;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1724
1205
|
db3.exec(`
|
|
1725
1206
|
CREATE TABLE IF NOT EXISTS ingest_watermark (
|
|
1726
1207
|
transcript_path TEXT PRIMARY KEY,
|
|
@@ -1756,7 +1237,7 @@ function insertMessages(messages, opts) {
|
|
|
1756
1237
|
return;
|
|
1757
1238
|
ensureDir2();
|
|
1758
1239
|
const d = db2();
|
|
1759
|
-
d.exec("BEGIN");
|
|
1240
|
+
d.exec("BEGIN IMMEDIATE");
|
|
1760
1241
|
try {
|
|
1761
1242
|
if (opts?.replaceSessionId) {
|
|
1762
1243
|
d.run(
|
|
@@ -1771,20 +1252,16 @@ function insertMessages(messages, opts) {
|
|
|
1771
1252
|
(message_id, session_id, message_seq, message_text, project_id, created_at, message_role)
|
|
1772
1253
|
VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
1773
1254
|
);
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
]);
|
|
1785
|
-
}
|
|
1786
|
-
} finally {
|
|
1787
|
-
stmt.finalize();
|
|
1255
|
+
for (const m of messages) {
|
|
1256
|
+
stmt.run([
|
|
1257
|
+
m.message_id,
|
|
1258
|
+
m.session_id,
|
|
1259
|
+
m.message_seq,
|
|
1260
|
+
m.message_text,
|
|
1261
|
+
m.project_id,
|
|
1262
|
+
m.created_at,
|
|
1263
|
+
m.message_role
|
|
1264
|
+
]);
|
|
1788
1265
|
}
|
|
1789
1266
|
d.exec("COMMIT");
|
|
1790
1267
|
} catch (e) {
|
|
@@ -2765,7 +2242,7 @@ async function runStopHook() {
|
|
|
2765
2242
|
if (payload.stop_hook_active)
|
|
2766
2243
|
process.exit(0);
|
|
2767
2244
|
try {
|
|
2768
|
-
getDb(dbPath()).exec("PRAGMA busy_timeout =
|
|
2245
|
+
getDb(dbPath()).exec("PRAGMA busy_timeout = 5000;");
|
|
2769
2246
|
const vendor = vendorForTranscript(payload.transcript_path);
|
|
2770
2247
|
const result = await ingestSessionMessages(
|
|
2771
2248
|
payload.session_id,
|