cursor-history-mcp 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.js → index.cjs} +2014 -1716
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/package.json +5 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var
|
|
10
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
-
}) : x)(function(x) {
|
|
12
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
-
});
|
|
15
|
-
var __esm = (fn, res) => function __init() {
|
|
16
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
19
10
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
20
11
|
};
|
|
21
12
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -35,1459 +26,652 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
26
|
mod
|
|
36
27
|
));
|
|
37
28
|
|
|
38
|
-
// node_modules/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var init_esm_shims = __esm({
|
|
42
|
-
"node_modules/tsup/assets/esm_shims.js"() {
|
|
43
|
-
"use strict";
|
|
44
|
-
getFilename = () => fileURLToPath(import.meta.url);
|
|
45
|
-
__filename = /* @__PURE__ */ getFilename();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// node_modules/better-sqlite3/lib/util.js
|
|
50
|
-
var require_util = __commonJS({
|
|
51
|
-
"node_modules/better-sqlite3/lib/util.js"(exports) {
|
|
29
|
+
// node_modules/adm-zip/util/constants.js
|
|
30
|
+
var require_constants = __commonJS({
|
|
31
|
+
"node_modules/adm-zip/util/constants.js"(exports2, module2) {
|
|
52
32
|
"use strict";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
module2.exports = {
|
|
34
|
+
/* The local file header */
|
|
35
|
+
LOCHDR: 30,
|
|
36
|
+
// LOC header size
|
|
37
|
+
LOCSIG: 67324752,
|
|
38
|
+
// "PK\003\004"
|
|
39
|
+
LOCVER: 4,
|
|
40
|
+
// version needed to extract
|
|
41
|
+
LOCFLG: 6,
|
|
42
|
+
// general purpose bit flag
|
|
43
|
+
LOCHOW: 8,
|
|
44
|
+
// compression method
|
|
45
|
+
LOCTIM: 10,
|
|
46
|
+
// modification time (2 bytes time, 2 bytes date)
|
|
47
|
+
LOCCRC: 14,
|
|
48
|
+
// uncompressed file crc-32 value
|
|
49
|
+
LOCSIZ: 18,
|
|
50
|
+
// compressed size
|
|
51
|
+
LOCLEN: 22,
|
|
52
|
+
// uncompressed size
|
|
53
|
+
LOCNAM: 26,
|
|
54
|
+
// filename length
|
|
55
|
+
LOCEXT: 28,
|
|
56
|
+
// extra field length
|
|
57
|
+
/* The Data descriptor */
|
|
58
|
+
EXTSIG: 134695760,
|
|
59
|
+
// "PK\007\008"
|
|
60
|
+
EXTHDR: 16,
|
|
61
|
+
// EXT header size
|
|
62
|
+
EXTCRC: 4,
|
|
63
|
+
// uncompressed file crc-32 value
|
|
64
|
+
EXTSIZ: 8,
|
|
65
|
+
// compressed size
|
|
66
|
+
EXTLEN: 12,
|
|
67
|
+
// uncompressed size
|
|
68
|
+
/* The central directory file header */
|
|
69
|
+
CENHDR: 46,
|
|
70
|
+
// CEN header size
|
|
71
|
+
CENSIG: 33639248,
|
|
72
|
+
// "PK\001\002"
|
|
73
|
+
CENVEM: 4,
|
|
74
|
+
// version made by
|
|
75
|
+
CENVER: 6,
|
|
76
|
+
// version needed to extract
|
|
77
|
+
CENFLG: 8,
|
|
78
|
+
// encrypt, decrypt flags
|
|
79
|
+
CENHOW: 10,
|
|
80
|
+
// compression method
|
|
81
|
+
CENTIM: 12,
|
|
82
|
+
// modification time (2 bytes time, 2 bytes date)
|
|
83
|
+
CENCRC: 16,
|
|
84
|
+
// uncompressed file crc-32 value
|
|
85
|
+
CENSIZ: 20,
|
|
86
|
+
// compressed size
|
|
87
|
+
CENLEN: 24,
|
|
88
|
+
// uncompressed size
|
|
89
|
+
CENNAM: 28,
|
|
90
|
+
// filename length
|
|
91
|
+
CENEXT: 30,
|
|
92
|
+
// extra field length
|
|
93
|
+
CENCOM: 32,
|
|
94
|
+
// file comment length
|
|
95
|
+
CENDSK: 34,
|
|
96
|
+
// volume number start
|
|
97
|
+
CENATT: 36,
|
|
98
|
+
// internal file attributes
|
|
99
|
+
CENATX: 38,
|
|
100
|
+
// external file attributes (host system dependent)
|
|
101
|
+
CENOFF: 42,
|
|
102
|
+
// LOC header offset
|
|
103
|
+
/* The entries in the end of central directory */
|
|
104
|
+
ENDHDR: 22,
|
|
105
|
+
// END header size
|
|
106
|
+
ENDSIG: 101010256,
|
|
107
|
+
// "PK\005\006"
|
|
108
|
+
ENDSUB: 8,
|
|
109
|
+
// number of entries on this disk
|
|
110
|
+
ENDTOT: 10,
|
|
111
|
+
// total number of entries
|
|
112
|
+
ENDSIZ: 12,
|
|
113
|
+
// central directory size in bytes
|
|
114
|
+
ENDOFF: 16,
|
|
115
|
+
// offset of first CEN header
|
|
116
|
+
ENDCOM: 20,
|
|
117
|
+
// zip file comment length
|
|
118
|
+
END64HDR: 20,
|
|
119
|
+
// zip64 END header size
|
|
120
|
+
END64SIG: 117853008,
|
|
121
|
+
// zip64 Locator signature, "PK\006\007"
|
|
122
|
+
END64START: 4,
|
|
123
|
+
// number of the disk with the start of the zip64
|
|
124
|
+
END64OFF: 8,
|
|
125
|
+
// relative offset of the zip64 end of central directory
|
|
126
|
+
END64NUMDISKS: 16,
|
|
127
|
+
// total number of disks
|
|
128
|
+
ZIP64SIG: 101075792,
|
|
129
|
+
// zip64 signature, "PK\006\006"
|
|
130
|
+
ZIP64HDR: 56,
|
|
131
|
+
// zip64 record minimum size
|
|
132
|
+
ZIP64LEAD: 12,
|
|
133
|
+
// leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
|
|
134
|
+
ZIP64SIZE: 4,
|
|
135
|
+
// zip64 size of the central directory record
|
|
136
|
+
ZIP64VEM: 12,
|
|
137
|
+
// zip64 version made by
|
|
138
|
+
ZIP64VER: 14,
|
|
139
|
+
// zip64 version needed to extract
|
|
140
|
+
ZIP64DSK: 16,
|
|
141
|
+
// zip64 number of this disk
|
|
142
|
+
ZIP64DSKDIR: 20,
|
|
143
|
+
// number of the disk with the start of the record directory
|
|
144
|
+
ZIP64SUB: 24,
|
|
145
|
+
// number of entries on this disk
|
|
146
|
+
ZIP64TOT: 32,
|
|
147
|
+
// total number of entries
|
|
148
|
+
ZIP64SIZB: 40,
|
|
149
|
+
// zip64 central directory size in bytes
|
|
150
|
+
ZIP64OFF: 48,
|
|
151
|
+
// offset of start of central directory with respect to the starting disk number
|
|
152
|
+
ZIP64EXTRA: 56,
|
|
153
|
+
// extensible data sector
|
|
154
|
+
/* Compression methods */
|
|
155
|
+
STORED: 0,
|
|
156
|
+
// no compression
|
|
157
|
+
SHRUNK: 1,
|
|
158
|
+
// shrunk
|
|
159
|
+
REDUCED1: 2,
|
|
160
|
+
// reduced with compression factor 1
|
|
161
|
+
REDUCED2: 3,
|
|
162
|
+
// reduced with compression factor 2
|
|
163
|
+
REDUCED3: 4,
|
|
164
|
+
// reduced with compression factor 3
|
|
165
|
+
REDUCED4: 5,
|
|
166
|
+
// reduced with compression factor 4
|
|
167
|
+
IMPLODED: 6,
|
|
168
|
+
// imploded
|
|
169
|
+
// 7 reserved for Tokenizing compression algorithm
|
|
170
|
+
DEFLATED: 8,
|
|
171
|
+
// deflated
|
|
172
|
+
ENHANCED_DEFLATED: 9,
|
|
173
|
+
// enhanced deflated
|
|
174
|
+
PKWARE: 10,
|
|
175
|
+
// PKWare DCL imploded
|
|
176
|
+
// 11 reserved by PKWARE
|
|
177
|
+
BZIP2: 12,
|
|
178
|
+
// compressed using BZIP2
|
|
179
|
+
// 13 reserved by PKWARE
|
|
180
|
+
LZMA: 14,
|
|
181
|
+
// LZMA
|
|
182
|
+
// 15-17 reserved by PKWARE
|
|
183
|
+
IBM_TERSE: 18,
|
|
184
|
+
// compressed using IBM TERSE
|
|
185
|
+
IBM_LZ77: 19,
|
|
186
|
+
// IBM LZ77 z
|
|
187
|
+
AES_ENCRYPT: 99,
|
|
188
|
+
// WinZIP AES encryption method
|
|
189
|
+
/* General purpose bit flag */
|
|
190
|
+
// values can obtained with expression 2**bitnr
|
|
191
|
+
FLG_ENC: 1,
|
|
192
|
+
// Bit 0: encrypted file
|
|
193
|
+
FLG_COMP1: 2,
|
|
194
|
+
// Bit 1, compression option
|
|
195
|
+
FLG_COMP2: 4,
|
|
196
|
+
// Bit 2, compression option
|
|
197
|
+
FLG_DESC: 8,
|
|
198
|
+
// Bit 3, data descriptor
|
|
199
|
+
FLG_ENH: 16,
|
|
200
|
+
// Bit 4, enhanced deflating
|
|
201
|
+
FLG_PATCH: 32,
|
|
202
|
+
// Bit 5, indicates that the file is compressed patched data.
|
|
203
|
+
FLG_STR: 64,
|
|
204
|
+
// Bit 6, strong encryption (patented)
|
|
205
|
+
// Bits 7-10: Currently unused.
|
|
206
|
+
FLG_EFS: 2048,
|
|
207
|
+
// Bit 11: Language encoding flag (EFS)
|
|
208
|
+
// Bit 12: Reserved by PKWARE for enhanced compression.
|
|
209
|
+
// Bit 13: encrypted the Central Directory (patented).
|
|
210
|
+
// Bits 14-15: Reserved by PKWARE.
|
|
211
|
+
FLG_MSK: 4096,
|
|
212
|
+
// mask header values
|
|
213
|
+
/* Load type */
|
|
214
|
+
FILE: 2,
|
|
215
|
+
BUFFER: 1,
|
|
216
|
+
NONE: 0,
|
|
217
|
+
/* 4.5 Extensible data fields */
|
|
218
|
+
EF_ID: 0,
|
|
219
|
+
EF_SIZE: 2,
|
|
220
|
+
/* Header IDs */
|
|
221
|
+
ID_ZIP64: 1,
|
|
222
|
+
ID_AVINFO: 7,
|
|
223
|
+
ID_PFS: 8,
|
|
224
|
+
ID_OS2: 9,
|
|
225
|
+
ID_NTFS: 10,
|
|
226
|
+
ID_OPENVMS: 12,
|
|
227
|
+
ID_UNIX: 13,
|
|
228
|
+
ID_FORK: 14,
|
|
229
|
+
ID_PATCH: 15,
|
|
230
|
+
ID_X509_PKCS7: 20,
|
|
231
|
+
ID_X509_CERTID_F: 21,
|
|
232
|
+
ID_X509_CERTID_C: 22,
|
|
233
|
+
ID_STRONGENC: 23,
|
|
234
|
+
ID_RECORD_MGT: 24,
|
|
235
|
+
ID_X509_PKCS7_RL: 25,
|
|
236
|
+
ID_IBM1: 101,
|
|
237
|
+
ID_IBM2: 102,
|
|
238
|
+
ID_POSZIP: 18064,
|
|
239
|
+
EF_ZIP64_OR_32: 4294967295,
|
|
240
|
+
EF_ZIP64_OR_16: 65535,
|
|
241
|
+
EF_ZIP64_SUNCOMP: 0,
|
|
242
|
+
EF_ZIP64_SCOMP: 8,
|
|
243
|
+
EF_ZIP64_RHO: 16,
|
|
244
|
+
EF_ZIP64_DSN: 24
|
|
60
245
|
};
|
|
61
|
-
exports.cppdb = Symbol();
|
|
62
|
-
exports.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
67
|
-
var require_sqlite_error = __commonJS({
|
|
68
|
-
"node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
|
|
69
|
-
"use strict";
|
|
70
|
-
init_esm_shims();
|
|
71
|
-
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
72
|
-
function SqliteError(message, code) {
|
|
73
|
-
if (new.target !== SqliteError) {
|
|
74
|
-
return new SqliteError(message, code);
|
|
75
|
-
}
|
|
76
|
-
if (typeof code !== "string") {
|
|
77
|
-
throw new TypeError("Expected second argument to be a string");
|
|
78
|
-
}
|
|
79
|
-
Error.call(this, message);
|
|
80
|
-
descriptor.value = "" + message;
|
|
81
|
-
Object.defineProperty(this, "message", descriptor);
|
|
82
|
-
Error.captureStackTrace(this, SqliteError);
|
|
83
|
-
this.code = code;
|
|
84
|
-
}
|
|
85
|
-
Object.setPrototypeOf(SqliteError, Error);
|
|
86
|
-
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
87
|
-
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
88
|
-
module.exports = SqliteError;
|
|
89
246
|
}
|
|
90
247
|
});
|
|
91
248
|
|
|
92
|
-
// node_modules/
|
|
93
|
-
var
|
|
94
|
-
"node_modules/
|
|
249
|
+
// node_modules/adm-zip/util/errors.js
|
|
250
|
+
var require_errors = __commonJS({
|
|
251
|
+
"node_modules/adm-zip/util/errors.js"(exports2) {
|
|
95
252
|
"use strict";
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
253
|
+
var errors = {
|
|
254
|
+
/* Header error messages */
|
|
255
|
+
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
256
|
+
INVALID_CEN: "Invalid CEN header (bad signature)",
|
|
257
|
+
INVALID_END: "Invalid END header (bad signature)",
|
|
258
|
+
/* Descriptor */
|
|
259
|
+
DESCRIPTOR_NOT_EXIST: "No descriptor present",
|
|
260
|
+
DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
|
|
261
|
+
DESCRIPTOR_FAULTY: "Descriptor data is malformed",
|
|
262
|
+
/* ZipEntry error messages*/
|
|
263
|
+
NO_DATA: "Nothing to decompress",
|
|
264
|
+
BAD_CRC: "CRC32 checksum failed {0}",
|
|
265
|
+
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
266
|
+
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
267
|
+
/* Inflater error messages */
|
|
268
|
+
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
|
269
|
+
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
|
270
|
+
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
|
271
|
+
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
|
272
|
+
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
|
273
|
+
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
|
274
|
+
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
|
275
|
+
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
|
276
|
+
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
|
277
|
+
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
|
278
|
+
/* ADM-ZIP error messages */
|
|
279
|
+
CANT_EXTRACT_FILE: "Could not extract the file",
|
|
280
|
+
CANT_OVERRIDE: "Target file already exists",
|
|
281
|
+
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
282
|
+
NO_ZIP: "No zip file was loaded",
|
|
283
|
+
NO_ENTRY: "Entry doesn't exist",
|
|
284
|
+
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
285
|
+
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
286
|
+
NOT_IMPLEMENTED: "Not implemented",
|
|
287
|
+
INVALID_FILENAME: "Invalid filename",
|
|
288
|
+
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
289
|
+
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
290
|
+
WRONG_PASSWORD: "Wrong Password",
|
|
291
|
+
/* ADM-ZIP */
|
|
292
|
+
COMMENT_TOO_LONG: "Comment is too long",
|
|
293
|
+
// Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
|
|
294
|
+
EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
|
|
295
|
+
};
|
|
296
|
+
function E(message) {
|
|
297
|
+
return function(...args) {
|
|
298
|
+
if (args.length) {
|
|
299
|
+
message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
|
|
300
|
+
}
|
|
301
|
+
return new Error("ADM-ZIP: " + message);
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
for (const msg of Object.keys(errors)) {
|
|
305
|
+
exports2[msg] = E(errors[msg]);
|
|
120
306
|
}
|
|
121
307
|
}
|
|
122
308
|
});
|
|
123
309
|
|
|
124
|
-
// node_modules/
|
|
125
|
-
var
|
|
126
|
-
"node_modules/
|
|
310
|
+
// node_modules/adm-zip/util/utils.js
|
|
311
|
+
var require_utils = __commonJS({
|
|
312
|
+
"node_modules/adm-zip/util/utils.js"(exports2, module2) {
|
|
127
313
|
"use strict";
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
var
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} || fs.existsSync || path.existsSync;
|
|
142
|
-
var defaults = {
|
|
143
|
-
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
144
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
145
|
-
platform: process.platform,
|
|
146
|
-
arch: process.arch,
|
|
147
|
-
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
148
|
-
version: process.versions.node,
|
|
149
|
-
bindings: "bindings.node",
|
|
150
|
-
try: [
|
|
151
|
-
// node-gyp's linked version in the "build" dir
|
|
152
|
-
["module_root", "build", "bindings"],
|
|
153
|
-
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
154
|
-
["module_root", "build", "Debug", "bindings"],
|
|
155
|
-
["module_root", "build", "Release", "bindings"],
|
|
156
|
-
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
157
|
-
["module_root", "out", "Debug", "bindings"],
|
|
158
|
-
["module_root", "Debug", "bindings"],
|
|
159
|
-
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
160
|
-
["module_root", "out", "Release", "bindings"],
|
|
161
|
-
["module_root", "Release", "bindings"],
|
|
162
|
-
// Legacy from node-waf, node <= 0.4.x
|
|
163
|
-
["module_root", "build", "default", "bindings"],
|
|
164
|
-
// Production "Release" buildtype binary (meh...)
|
|
165
|
-
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
166
|
-
// node-qbs builds
|
|
167
|
-
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
168
|
-
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
169
|
-
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
170
|
-
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
171
|
-
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
172
|
-
]
|
|
173
|
-
};
|
|
174
|
-
function bindings(opts) {
|
|
175
|
-
if (typeof opts == "string") {
|
|
176
|
-
opts = { bindings: opts };
|
|
177
|
-
} else if (!opts) {
|
|
178
|
-
opts = {};
|
|
179
|
-
}
|
|
180
|
-
Object.keys(defaults).map(function(i2) {
|
|
181
|
-
if (!(i2 in opts)) opts[i2] = defaults[i2];
|
|
182
|
-
});
|
|
183
|
-
if (!opts.module_root) {
|
|
184
|
-
opts.module_root = exports.getRoot(exports.getFileName());
|
|
185
|
-
}
|
|
186
|
-
if (path.extname(opts.bindings) != ".node") {
|
|
187
|
-
opts.bindings += ".node";
|
|
314
|
+
var fsystem = require("fs");
|
|
315
|
+
var pth = require("path");
|
|
316
|
+
var Constants = require_constants();
|
|
317
|
+
var Errors = require_errors();
|
|
318
|
+
var isWin = typeof process === "object" && "win32" === process.platform;
|
|
319
|
+
var is_Obj = (obj) => typeof obj === "object" && obj !== null;
|
|
320
|
+
var crcTable = new Uint32Array(256).map((t, c) => {
|
|
321
|
+
for (let k = 0; k < 8; k++) {
|
|
322
|
+
if ((c & 1) !== 0) {
|
|
323
|
+
c = 3988292384 ^ c >>> 1;
|
|
324
|
+
} else {
|
|
325
|
+
c >>>= 1;
|
|
326
|
+
}
|
|
188
327
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
198
|
-
tries.push(n);
|
|
199
|
-
try {
|
|
200
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
201
|
-
if (!opts.path) {
|
|
202
|
-
b.path = n;
|
|
203
|
-
}
|
|
204
|
-
return b;
|
|
205
|
-
} catch (e) {
|
|
206
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
207
|
-
throw e;
|
|
208
|
-
}
|
|
328
|
+
return c >>> 0;
|
|
329
|
+
});
|
|
330
|
+
function Utils(opts) {
|
|
331
|
+
this.sep = pth.sep;
|
|
332
|
+
this.fs = fsystem;
|
|
333
|
+
if (is_Obj(opts)) {
|
|
334
|
+
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
|
|
335
|
+
this.fs = opts.fs;
|
|
209
336
|
}
|
|
210
337
|
}
|
|
211
|
-
err = new Error(
|
|
212
|
-
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
213
|
-
return opts.arrow + a;
|
|
214
|
-
}).join("\n")
|
|
215
|
-
);
|
|
216
|
-
err.tries = tries;
|
|
217
|
-
throw err;
|
|
218
338
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
339
|
+
module2.exports = Utils;
|
|
340
|
+
Utils.prototype.makeDir = function(folder) {
|
|
341
|
+
const self = this;
|
|
342
|
+
function mkdirSync2(fpath) {
|
|
343
|
+
let resolvedPath = fpath.split(self.sep)[0];
|
|
344
|
+
fpath.split(self.sep).forEach(function(name) {
|
|
345
|
+
if (!name || name.substr(-1, 1) === ":") return;
|
|
346
|
+
resolvedPath += self.sep + name;
|
|
347
|
+
var stat;
|
|
348
|
+
try {
|
|
349
|
+
stat = self.fs.statSync(resolvedPath);
|
|
350
|
+
} catch (e) {
|
|
351
|
+
self.fs.mkdirSync(resolvedPath);
|
|
234
352
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
Error.captureStackTrace(dummy);
|
|
238
|
-
dummy.stack;
|
|
239
|
-
Error.prepareStackTrace = origPST;
|
|
240
|
-
Error.stackTraceLimit = origSTL;
|
|
241
|
-
var fileSchema = "file://";
|
|
242
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
243
|
-
fileName = fileURLToPath2(fileName);
|
|
353
|
+
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
354
|
+
});
|
|
244
355
|
}
|
|
245
|
-
|
|
356
|
+
mkdirSync2(folder);
|
|
246
357
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return dir;
|
|
358
|
+
Utils.prototype.writeFileTo = function(path, content, overwrite, attr) {
|
|
359
|
+
const self = this;
|
|
360
|
+
if (self.fs.existsSync(path)) {
|
|
361
|
+
if (!overwrite) return false;
|
|
362
|
+
var stat = self.fs.statSync(path);
|
|
363
|
+
if (stat.isDirectory()) {
|
|
364
|
+
return false;
|
|
255
365
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
366
|
+
}
|
|
367
|
+
var folder = pth.dirname(path);
|
|
368
|
+
if (!self.fs.existsSync(folder)) {
|
|
369
|
+
self.makeDir(folder);
|
|
370
|
+
}
|
|
371
|
+
var fd;
|
|
372
|
+
try {
|
|
373
|
+
fd = self.fs.openSync(path, "w", 438);
|
|
374
|
+
} catch (e) {
|
|
375
|
+
self.fs.chmodSync(path, 438);
|
|
376
|
+
fd = self.fs.openSync(path, "w", 438);
|
|
377
|
+
}
|
|
378
|
+
if (fd) {
|
|
379
|
+
try {
|
|
380
|
+
self.fs.writeSync(fd, content, 0, content.length, 0);
|
|
381
|
+
} finally {
|
|
382
|
+
self.fs.closeSync(fd);
|
|
260
383
|
}
|
|
261
|
-
prev = dir;
|
|
262
|
-
dir = join5(dir, "..");
|
|
263
384
|
}
|
|
385
|
+
self.fs.chmodSync(path, attr || 438);
|
|
386
|
+
return true;
|
|
264
387
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
388
|
+
Utils.prototype.writeFileToAsync = function(path, content, overwrite, attr, callback) {
|
|
389
|
+
if (typeof attr === "function") {
|
|
390
|
+
callback = attr;
|
|
391
|
+
attr = void 0;
|
|
392
|
+
}
|
|
393
|
+
const self = this;
|
|
394
|
+
self.fs.exists(path, function(exist) {
|
|
395
|
+
if (exist && !overwrite) return callback(false);
|
|
396
|
+
self.fs.stat(path, function(err, stat) {
|
|
397
|
+
if (exist && stat.isDirectory()) {
|
|
398
|
+
return callback(false);
|
|
399
|
+
}
|
|
400
|
+
var folder = pth.dirname(path);
|
|
401
|
+
self.fs.exists(folder, function(exists) {
|
|
402
|
+
if (!exists) self.makeDir(folder);
|
|
403
|
+
self.fs.open(path, "w", 438, function(err2, fd) {
|
|
404
|
+
if (err2) {
|
|
405
|
+
self.fs.chmod(path, 438, function() {
|
|
406
|
+
self.fs.open(path, "w", 438, function(err3, fd2) {
|
|
407
|
+
self.fs.write(fd2, content, 0, content.length, 0, function() {
|
|
408
|
+
self.fs.close(fd2, function() {
|
|
409
|
+
self.fs.chmod(path, attr || 438, function() {
|
|
410
|
+
callback(true);
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
} else if (fd) {
|
|
417
|
+
self.fs.write(fd, content, 0, content.length, 0, function() {
|
|
418
|
+
self.fs.close(fd, function() {
|
|
419
|
+
self.fs.chmod(path, attr || 438, function() {
|
|
420
|
+
callback(true);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
} else {
|
|
425
|
+
self.fs.chmod(path, attr || 438, function() {
|
|
426
|
+
callback(true);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
});
|
|
276
433
|
};
|
|
277
|
-
|
|
278
|
-
this
|
|
279
|
-
|
|
434
|
+
Utils.prototype.findFiles = function(path) {
|
|
435
|
+
const self = this;
|
|
436
|
+
function findSync(dir, pattern, recursive) {
|
|
437
|
+
if (typeof pattern === "boolean") {
|
|
438
|
+
recursive = pattern;
|
|
439
|
+
pattern = void 0;
|
|
440
|
+
}
|
|
441
|
+
let files = [];
|
|
442
|
+
self.fs.readdirSync(dir).forEach(function(file) {
|
|
443
|
+
const path2 = pth.join(dir, file);
|
|
444
|
+
const stat = self.fs.statSync(path2);
|
|
445
|
+
if (!pattern || pattern.test(path2)) {
|
|
446
|
+
files.push(pth.normalize(path2) + (stat.isDirectory() ? self.sep : ""));
|
|
447
|
+
}
|
|
448
|
+
if (stat.isDirectory() && recursive) files = files.concat(findSync(path2, pattern, recursive));
|
|
449
|
+
});
|
|
450
|
+
return files;
|
|
451
|
+
}
|
|
452
|
+
return findSync(path, void 0, true);
|
|
280
453
|
};
|
|
281
|
-
|
|
282
|
-
this
|
|
283
|
-
|
|
454
|
+
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
455
|
+
const self = this;
|
|
456
|
+
let results = [];
|
|
457
|
+
self.fs.readdir(dir, function(err, list) {
|
|
458
|
+
if (err) return cb(err);
|
|
459
|
+
let list_length = list.length;
|
|
460
|
+
if (!list_length) return cb(null, results);
|
|
461
|
+
list.forEach(function(file) {
|
|
462
|
+
file = pth.join(dir, file);
|
|
463
|
+
self.fs.stat(file, function(err2, stat) {
|
|
464
|
+
if (err2) return cb(err2);
|
|
465
|
+
if (stat) {
|
|
466
|
+
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
467
|
+
if (stat.isDirectory()) {
|
|
468
|
+
self.findFilesAsync(file, function(err3, res) {
|
|
469
|
+
if (err3) return cb(err3);
|
|
470
|
+
results = results.concat(res);
|
|
471
|
+
if (!--list_length) cb(null, results);
|
|
472
|
+
});
|
|
473
|
+
} else {
|
|
474
|
+
if (!--list_length) cb(null, results);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
});
|
|
284
480
|
};
|
|
285
|
-
|
|
286
|
-
this[cppdb].loadExtension(...args);
|
|
287
|
-
return this;
|
|
481
|
+
Utils.prototype.getAttributes = function() {
|
|
288
482
|
};
|
|
289
|
-
|
|
290
|
-
this[cppdb].defaultSafeIntegers(...args);
|
|
291
|
-
return this;
|
|
483
|
+
Utils.prototype.setAttributes = function() {
|
|
292
484
|
};
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return this;
|
|
485
|
+
Utils.crc32update = function(crc, byte) {
|
|
486
|
+
return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
296
487
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return this[cppdb].name;
|
|
301
|
-
},
|
|
302
|
-
enumerable: true
|
|
303
|
-
},
|
|
304
|
-
open: {
|
|
305
|
-
get: function open() {
|
|
306
|
-
return this[cppdb].open;
|
|
307
|
-
},
|
|
308
|
-
enumerable: true
|
|
309
|
-
},
|
|
310
|
-
inTransaction: {
|
|
311
|
-
get: function inTransaction() {
|
|
312
|
-
return this[cppdb].inTransaction;
|
|
313
|
-
},
|
|
314
|
-
enumerable: true
|
|
315
|
-
},
|
|
316
|
-
readonly: {
|
|
317
|
-
get: function readonly() {
|
|
318
|
-
return this[cppdb].readonly;
|
|
319
|
-
},
|
|
320
|
-
enumerable: true
|
|
321
|
-
},
|
|
322
|
-
memory: {
|
|
323
|
-
get: function memory() {
|
|
324
|
-
return this[cppdb].memory;
|
|
325
|
-
},
|
|
326
|
-
enumerable: true
|
|
488
|
+
Utils.crc32 = function(buf) {
|
|
489
|
+
if (typeof buf === "string") {
|
|
490
|
+
buf = Buffer.from(buf, "utf8");
|
|
327
491
|
}
|
|
492
|
+
let len = buf.length;
|
|
493
|
+
let crc = ~0;
|
|
494
|
+
for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
|
|
495
|
+
return ~crc >>> 0;
|
|
328
496
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
var { cppdb } = require_util();
|
|
338
|
-
var controllers = /* @__PURE__ */ new WeakMap();
|
|
339
|
-
module.exports = function transaction(fn) {
|
|
340
|
-
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
341
|
-
const db = this[cppdb];
|
|
342
|
-
const controller = getController(db, this);
|
|
343
|
-
const { apply } = Function.prototype;
|
|
344
|
-
const properties = {
|
|
345
|
-
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
346
|
-
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
347
|
-
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
348
|
-
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
349
|
-
database: { value: this, enumerable: true }
|
|
350
|
-
};
|
|
351
|
-
Object.defineProperties(properties.default.value, properties);
|
|
352
|
-
Object.defineProperties(properties.deferred.value, properties);
|
|
353
|
-
Object.defineProperties(properties.immediate.value, properties);
|
|
354
|
-
Object.defineProperties(properties.exclusive.value, properties);
|
|
355
|
-
return properties.default.value;
|
|
356
|
-
};
|
|
357
|
-
var getController = (db, self) => {
|
|
358
|
-
let controller = controllers.get(db);
|
|
359
|
-
if (!controller) {
|
|
360
|
-
const shared = {
|
|
361
|
-
commit: db.prepare("COMMIT", self, false),
|
|
362
|
-
rollback: db.prepare("ROLLBACK", self, false),
|
|
363
|
-
savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
364
|
-
release: db.prepare("RELEASE ` _bs3. `", self, false),
|
|
365
|
-
rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
366
|
-
};
|
|
367
|
-
controllers.set(db, controller = {
|
|
368
|
-
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
369
|
-
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
370
|
-
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
371
|
-
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
372
|
-
});
|
|
497
|
+
Utils.methodToString = function(method) {
|
|
498
|
+
switch (method) {
|
|
499
|
+
case Constants.STORED:
|
|
500
|
+
return "STORED (" + method + ")";
|
|
501
|
+
case Constants.DEFLATED:
|
|
502
|
+
return "DEFLATED (" + method + ")";
|
|
503
|
+
default:
|
|
504
|
+
return "UNSUPPORTED (" + method + ")";
|
|
373
505
|
}
|
|
374
|
-
return controller;
|
|
375
506
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
after.run();
|
|
394
|
-
return result;
|
|
395
|
-
} catch (ex) {
|
|
396
|
-
if (db.inTransaction) {
|
|
397
|
-
undo.run();
|
|
398
|
-
if (undo !== rollback) after.run();
|
|
507
|
+
Utils.canonical = function(path) {
|
|
508
|
+
if (!path) return "";
|
|
509
|
+
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
510
|
+
return pth.join(".", safeSuffix);
|
|
511
|
+
};
|
|
512
|
+
Utils.zipnamefix = function(path) {
|
|
513
|
+
if (!path) return "";
|
|
514
|
+
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
515
|
+
return pth.posix.join(".", safeSuffix);
|
|
516
|
+
};
|
|
517
|
+
Utils.findLast = function(arr, callback) {
|
|
518
|
+
if (!Array.isArray(arr)) throw new TypeError("arr is not array");
|
|
519
|
+
const len = arr.length >>> 0;
|
|
520
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
521
|
+
if (callback(arr[i], i, arr)) {
|
|
522
|
+
return arr[i];
|
|
399
523
|
}
|
|
400
|
-
throw ex;
|
|
401
524
|
}
|
|
525
|
+
return void 0;
|
|
402
526
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if (options == null) options = {};
|
|
414
|
-
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
415
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
416
|
-
const simple = getBooleanOption(options, "simple");
|
|
417
|
-
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
418
|
-
return simple ? stmt.pluck().get() : stmt.all();
|
|
527
|
+
Utils.sanitize = function(prefix, name) {
|
|
528
|
+
prefix = pth.resolve(pth.normalize(prefix));
|
|
529
|
+
var parts = name.split("/");
|
|
530
|
+
for (var i = 0, l = parts.length; i < l; i++) {
|
|
531
|
+
var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
532
|
+
if (path.indexOf(prefix) === 0) {
|
|
533
|
+
return path;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return pth.normalize(pth.join(prefix, pth.basename(name)));
|
|
419
537
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
var fs = __require("fs");
|
|
429
|
-
var path = __require("path");
|
|
430
|
-
var { promisify } = __require("util");
|
|
431
|
-
var { cppdb } = require_util();
|
|
432
|
-
var fsAccess = promisify(fs.access);
|
|
433
|
-
module.exports = async function backup(filename, options) {
|
|
434
|
-
if (options == null) options = {};
|
|
435
|
-
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
436
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
437
|
-
filename = filename.trim();
|
|
438
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
439
|
-
const handler = "progress" in options ? options.progress : null;
|
|
440
|
-
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
441
|
-
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
442
|
-
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
443
|
-
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
444
|
-
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
445
|
-
await fsAccess(path.dirname(filename)).catch(() => {
|
|
446
|
-
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
447
|
-
});
|
|
448
|
-
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
449
|
-
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
538
|
+
Utils.toBuffer = function toBuffer(input, encoder) {
|
|
539
|
+
if (Buffer.isBuffer(input)) {
|
|
540
|
+
return input;
|
|
541
|
+
} else if (input instanceof Uint8Array) {
|
|
542
|
+
return Buffer.from(input);
|
|
543
|
+
} else {
|
|
544
|
+
return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
|
|
545
|
+
}
|
|
450
546
|
};
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
if (handler) {
|
|
468
|
-
const ret = handler(progress);
|
|
469
|
-
if (ret !== void 0) {
|
|
470
|
-
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
471
|
-
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
setImmediate(step);
|
|
475
|
-
} catch (err) {
|
|
476
|
-
backup.close();
|
|
477
|
-
reject(err);
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
});
|
|
547
|
+
Utils.readBigUInt64LE = function(buffer, index) {
|
|
548
|
+
var slice = Buffer.from(buffer.slice(index, index + 8));
|
|
549
|
+
slice.swap64();
|
|
550
|
+
return parseInt(`0x${slice.toString("hex")}`);
|
|
551
|
+
};
|
|
552
|
+
Utils.fromDOS2Date = function(val) {
|
|
553
|
+
return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
|
|
554
|
+
};
|
|
555
|
+
Utils.fromDate2DOS = function(val) {
|
|
556
|
+
let date = 0;
|
|
557
|
+
let time = 0;
|
|
558
|
+
if (val.getFullYear() > 1979) {
|
|
559
|
+
date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
|
|
560
|
+
time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
|
|
561
|
+
}
|
|
562
|
+
return date << 16 | time;
|
|
481
563
|
};
|
|
564
|
+
Utils.isWin = isWin;
|
|
565
|
+
Utils.crcTable = crcTable;
|
|
482
566
|
}
|
|
483
567
|
});
|
|
484
568
|
|
|
485
|
-
// node_modules/
|
|
486
|
-
var
|
|
487
|
-
"node_modules/
|
|
569
|
+
// node_modules/adm-zip/util/fattr.js
|
|
570
|
+
var require_fattr = __commonJS({
|
|
571
|
+
"node_modules/adm-zip/util/fattr.js"(exports2, module2) {
|
|
488
572
|
"use strict";
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
573
|
+
var pth = require("path");
|
|
574
|
+
module2.exports = function(path, { fs }) {
|
|
575
|
+
var _path = path || "", _obj = newAttr(), _stat = null;
|
|
576
|
+
function newAttr() {
|
|
577
|
+
return {
|
|
578
|
+
directory: false,
|
|
579
|
+
readonly: false,
|
|
580
|
+
hidden: false,
|
|
581
|
+
executable: false,
|
|
582
|
+
mtime: 0,
|
|
583
|
+
atime: 0
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (_path && fs.existsSync(_path)) {
|
|
587
|
+
_stat = fs.statSync(_path);
|
|
588
|
+
_obj.directory = _stat.isDirectory();
|
|
589
|
+
_obj.mtime = _stat.mtime;
|
|
590
|
+
_obj.atime = _stat.atime;
|
|
591
|
+
_obj.executable = (73 & _stat.mode) !== 0;
|
|
592
|
+
_obj.readonly = (128 & _stat.mode) === 0;
|
|
593
|
+
_obj.hidden = pth.basename(_path)[0] === ".";
|
|
594
|
+
} else {
|
|
595
|
+
console.warn("Invalid path: " + _path);
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
get directory() {
|
|
599
|
+
return _obj.directory;
|
|
600
|
+
},
|
|
601
|
+
get readOnly() {
|
|
602
|
+
return _obj.readonly;
|
|
603
|
+
},
|
|
604
|
+
get hidden() {
|
|
605
|
+
return _obj.hidden;
|
|
606
|
+
},
|
|
607
|
+
get mtime() {
|
|
608
|
+
return _obj.mtime;
|
|
609
|
+
},
|
|
610
|
+
get atime() {
|
|
611
|
+
return _obj.atime;
|
|
612
|
+
},
|
|
613
|
+
get executable() {
|
|
614
|
+
return _obj.executable;
|
|
615
|
+
},
|
|
616
|
+
decodeAttributes: function() {
|
|
617
|
+
},
|
|
618
|
+
encodeAttributes: function() {
|
|
619
|
+
},
|
|
620
|
+
toJSON: function() {
|
|
621
|
+
return {
|
|
622
|
+
path: _path,
|
|
623
|
+
isDirectory: _obj.directory,
|
|
624
|
+
isReadOnly: _obj.readonly,
|
|
625
|
+
isHidden: _obj.hidden,
|
|
626
|
+
isExecutable: _obj.executable,
|
|
627
|
+
mTime: _obj.mtime,
|
|
628
|
+
aTime: _obj.atime
|
|
629
|
+
};
|
|
630
|
+
},
|
|
631
|
+
toString: function() {
|
|
632
|
+
return JSON.stringify(this.toJSON(), null, " ");
|
|
633
|
+
}
|
|
634
|
+
};
|
|
498
635
|
};
|
|
499
636
|
}
|
|
500
637
|
});
|
|
501
638
|
|
|
502
|
-
// node_modules/
|
|
503
|
-
var
|
|
504
|
-
"node_modules/
|
|
639
|
+
// node_modules/adm-zip/util/decoder.js
|
|
640
|
+
var require_decoder = __commonJS({
|
|
641
|
+
"node_modules/adm-zip/util/decoder.js"(exports2, module2) {
|
|
505
642
|
"use strict";
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
if (typeof options === "function") {
|
|
511
|
-
fn = options;
|
|
512
|
-
options = {};
|
|
513
|
-
}
|
|
514
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
515
|
-
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
516
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
517
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
518
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
519
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
520
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
521
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
522
|
-
let argCount = -1;
|
|
523
|
-
if (!varargs) {
|
|
524
|
-
argCount = fn.length;
|
|
525
|
-
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
526
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
527
|
-
}
|
|
528
|
-
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
529
|
-
return this;
|
|
643
|
+
module2.exports = {
|
|
644
|
+
efs: true,
|
|
645
|
+
encode: (data) => Buffer.from(data, "utf8"),
|
|
646
|
+
decode: (data) => data.toString("utf8")
|
|
530
647
|
};
|
|
531
648
|
}
|
|
532
649
|
});
|
|
533
650
|
|
|
534
|
-
// node_modules/
|
|
535
|
-
var
|
|
536
|
-
"node_modules/
|
|
651
|
+
// node_modules/adm-zip/util/index.js
|
|
652
|
+
var require_util = __commonJS({
|
|
653
|
+
"node_modules/adm-zip/util/index.js"(exports2, module2) {
|
|
537
654
|
"use strict";
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
544
|
-
const start = "start" in options ? options.start : null;
|
|
545
|
-
const step = getFunctionOption(options, "step", true);
|
|
546
|
-
const inverse = getFunctionOption(options, "inverse", false);
|
|
547
|
-
const result = getFunctionOption(options, "result", false);
|
|
548
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
549
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
550
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
551
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
552
|
-
let argCount = -1;
|
|
553
|
-
if (!varargs) {
|
|
554
|
-
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
555
|
-
if (argCount > 0) argCount -= 1;
|
|
556
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
557
|
-
}
|
|
558
|
-
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
559
|
-
return this;
|
|
560
|
-
};
|
|
561
|
-
var getFunctionOption = (options, key, required) => {
|
|
562
|
-
const value = key in options ? options[key] : null;
|
|
563
|
-
if (typeof value === "function") return value;
|
|
564
|
-
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
565
|
-
if (required) throw new TypeError(`Missing required option "${key}"`);
|
|
566
|
-
return null;
|
|
567
|
-
};
|
|
568
|
-
var getLength = ({ length }) => {
|
|
569
|
-
if (Number.isInteger(length) && length >= 0) return length;
|
|
570
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
571
|
-
};
|
|
655
|
+
module2.exports = require_utils();
|
|
656
|
+
module2.exports.Constants = require_constants();
|
|
657
|
+
module2.exports.Errors = require_errors();
|
|
658
|
+
module2.exports.FileAttr = require_fattr();
|
|
659
|
+
module2.exports.decoder = require_decoder();
|
|
572
660
|
}
|
|
573
661
|
});
|
|
574
662
|
|
|
575
|
-
// node_modules/
|
|
576
|
-
var
|
|
577
|
-
"node_modules/
|
|
663
|
+
// node_modules/adm-zip/headers/entryHeader.js
|
|
664
|
+
var require_entryHeader = __commonJS({
|
|
665
|
+
"node_modules/adm-zip/headers/entryHeader.js"(exports2, module2) {
|
|
578
666
|
"use strict";
|
|
579
|
-
|
|
580
|
-
var
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
factory = defer(parseTableDefinition(factory, "used", name));
|
|
588
|
-
} else {
|
|
589
|
-
if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
590
|
-
factory = wrapFactory(factory);
|
|
591
|
-
}
|
|
592
|
-
this[cppdb].table(factory, name, eponymous);
|
|
593
|
-
return this;
|
|
594
|
-
};
|
|
595
|
-
function wrapFactory(factory) {
|
|
596
|
-
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
597
|
-
const thisObject = {
|
|
598
|
-
module: moduleName,
|
|
599
|
-
database: databaseName,
|
|
600
|
-
table: tableName
|
|
601
|
-
};
|
|
602
|
-
const def = apply.call(factory, thisObject, args);
|
|
603
|
-
if (typeof def !== "object" || def === null) {
|
|
604
|
-
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
605
|
-
}
|
|
606
|
-
return parseTableDefinition(def, "returned", moduleName);
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function parseTableDefinition(def, verb, moduleName) {
|
|
610
|
-
if (!hasOwnProperty.call(def, "rows")) {
|
|
611
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
612
|
-
}
|
|
613
|
-
if (!hasOwnProperty.call(def, "columns")) {
|
|
614
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
615
|
-
}
|
|
616
|
-
const rows = def.rows;
|
|
617
|
-
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
618
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
619
|
-
}
|
|
620
|
-
let columns = def.columns;
|
|
621
|
-
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
622
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
623
|
-
}
|
|
624
|
-
if (columns.length !== new Set(columns).size) {
|
|
625
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
626
|
-
}
|
|
627
|
-
if (!columns.length) {
|
|
628
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
629
|
-
}
|
|
630
|
-
let parameters;
|
|
631
|
-
if (hasOwnProperty.call(def, "parameters")) {
|
|
632
|
-
parameters = def.parameters;
|
|
633
|
-
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
634
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
635
|
-
}
|
|
636
|
-
} else {
|
|
637
|
-
parameters = inferParameters(rows);
|
|
638
|
-
}
|
|
639
|
-
if (parameters.length !== new Set(parameters).size) {
|
|
640
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
641
|
-
}
|
|
642
|
-
if (parameters.length > 32) {
|
|
643
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
644
|
-
}
|
|
645
|
-
for (const parameter of parameters) {
|
|
646
|
-
if (columns.includes(parameter)) {
|
|
647
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
let safeIntegers = 2;
|
|
651
|
-
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
652
|
-
const bool = def.safeIntegers;
|
|
653
|
-
if (typeof bool !== "boolean") {
|
|
654
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
655
|
-
}
|
|
656
|
-
safeIntegers = +bool;
|
|
657
|
-
}
|
|
658
|
-
let directOnly = false;
|
|
659
|
-
if (hasOwnProperty.call(def, "directOnly")) {
|
|
660
|
-
directOnly = def.directOnly;
|
|
661
|
-
if (typeof directOnly !== "boolean") {
|
|
662
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
const columnDefinitions = [
|
|
666
|
-
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
667
|
-
...columns.map(identifier)
|
|
668
|
-
];
|
|
669
|
-
return [
|
|
670
|
-
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
671
|
-
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
672
|
-
parameters,
|
|
673
|
-
safeIntegers,
|
|
674
|
-
directOnly
|
|
675
|
-
];
|
|
676
|
-
}
|
|
677
|
-
function wrapGenerator(generator, columnMap, moduleName) {
|
|
678
|
-
return function* virtualTable(...args) {
|
|
679
|
-
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
680
|
-
for (let i = 0; i < columnMap.size; ++i) {
|
|
681
|
-
output.push(null);
|
|
682
|
-
}
|
|
683
|
-
for (const row of generator(...args)) {
|
|
684
|
-
if (Array.isArray(row)) {
|
|
685
|
-
extractRowArray(row, output, columnMap.size, moduleName);
|
|
686
|
-
yield output;
|
|
687
|
-
} else if (typeof row === "object" && row !== null) {
|
|
688
|
-
extractRowObject(row, output, columnMap, moduleName);
|
|
689
|
-
yield output;
|
|
690
|
-
} else {
|
|
691
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
function extractRowArray(row, output, columnCount, moduleName) {
|
|
697
|
-
if (row.length !== columnCount) {
|
|
698
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
699
|
-
}
|
|
700
|
-
const offset = output.length - columnCount;
|
|
701
|
-
for (let i = 0; i < columnCount; ++i) {
|
|
702
|
-
output[i + offset] = row[i];
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function extractRowObject(row, output, columnMap, moduleName) {
|
|
706
|
-
let count = 0;
|
|
707
|
-
for (const key of Object.keys(row)) {
|
|
708
|
-
const index = columnMap.get(key);
|
|
709
|
-
if (index === void 0) {
|
|
710
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
711
|
-
}
|
|
712
|
-
output[index] = row[key];
|
|
713
|
-
count += 1;
|
|
714
|
-
}
|
|
715
|
-
if (count !== columnMap.size) {
|
|
716
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
function inferParameters({ length }) {
|
|
720
|
-
if (!Number.isInteger(length) || length < 0) {
|
|
721
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
722
|
-
}
|
|
723
|
-
const params = [];
|
|
724
|
-
for (let i = 0; i < length; ++i) {
|
|
725
|
-
params.push(`$${i + 1}`);
|
|
726
|
-
}
|
|
727
|
-
return params;
|
|
728
|
-
}
|
|
729
|
-
var { hasOwnProperty } = Object.prototype;
|
|
730
|
-
var { apply } = Function.prototype;
|
|
731
|
-
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
732
|
-
});
|
|
733
|
-
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
734
|
-
var defer = (x) => () => x;
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
739
|
-
var require_inspect = __commonJS({
|
|
740
|
-
"node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
|
|
741
|
-
"use strict";
|
|
742
|
-
init_esm_shims();
|
|
743
|
-
var DatabaseInspection = function Database4() {
|
|
744
|
-
};
|
|
745
|
-
module.exports = function inspect(depth, opts) {
|
|
746
|
-
return Object.assign(new DatabaseInspection(), this);
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
// node_modules/better-sqlite3/lib/database.js
|
|
752
|
-
var require_database = __commonJS({
|
|
753
|
-
"node_modules/better-sqlite3/lib/database.js"(exports, module) {
|
|
754
|
-
"use strict";
|
|
755
|
-
init_esm_shims();
|
|
756
|
-
var fs = __require("fs");
|
|
757
|
-
var path = __require("path");
|
|
758
|
-
var util2 = require_util();
|
|
759
|
-
var SqliteError = require_sqlite_error();
|
|
760
|
-
var DEFAULT_ADDON;
|
|
761
|
-
function Database4(filenameGiven, options) {
|
|
762
|
-
if (new.target == null) {
|
|
763
|
-
return new Database4(filenameGiven, options);
|
|
764
|
-
}
|
|
765
|
-
let buffer;
|
|
766
|
-
if (Buffer.isBuffer(filenameGiven)) {
|
|
767
|
-
buffer = filenameGiven;
|
|
768
|
-
filenameGiven = ":memory:";
|
|
769
|
-
}
|
|
770
|
-
if (filenameGiven == null) filenameGiven = "";
|
|
771
|
-
if (options == null) options = {};
|
|
772
|
-
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
773
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
774
|
-
if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
775
|
-
if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
776
|
-
const filename = filenameGiven.trim();
|
|
777
|
-
const anonymous = filename === "" || filename === ":memory:";
|
|
778
|
-
const readonly = util2.getBooleanOption(options, "readonly");
|
|
779
|
-
const fileMustExist = util2.getBooleanOption(options, "fileMustExist");
|
|
780
|
-
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
781
|
-
const verbose = "verbose" in options ? options.verbose : null;
|
|
782
|
-
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
783
|
-
if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
784
|
-
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
785
|
-
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
786
|
-
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
787
|
-
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
788
|
-
let addon;
|
|
789
|
-
if (nativeBinding == null) {
|
|
790
|
-
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
791
|
-
} else if (typeof nativeBinding === "string") {
|
|
792
|
-
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
793
|
-
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
794
|
-
} else {
|
|
795
|
-
addon = nativeBinding;
|
|
796
|
-
}
|
|
797
|
-
if (!addon.isInitialized) {
|
|
798
|
-
addon.setErrorConstructor(SqliteError);
|
|
799
|
-
addon.isInitialized = true;
|
|
800
|
-
}
|
|
801
|
-
if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
|
|
802
|
-
throw new TypeError("Cannot open database because the directory does not exist");
|
|
803
|
-
}
|
|
804
|
-
Object.defineProperties(this, {
|
|
805
|
-
[util2.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
806
|
-
...wrappers.getters
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
var wrappers = require_wrappers();
|
|
810
|
-
Database4.prototype.prepare = wrappers.prepare;
|
|
811
|
-
Database4.prototype.transaction = require_transaction();
|
|
812
|
-
Database4.prototype.pragma = require_pragma();
|
|
813
|
-
Database4.prototype.backup = require_backup();
|
|
814
|
-
Database4.prototype.serialize = require_serialize();
|
|
815
|
-
Database4.prototype.function = require_function();
|
|
816
|
-
Database4.prototype.aggregate = require_aggregate();
|
|
817
|
-
Database4.prototype.table = require_table();
|
|
818
|
-
Database4.prototype.loadExtension = wrappers.loadExtension;
|
|
819
|
-
Database4.prototype.exec = wrappers.exec;
|
|
820
|
-
Database4.prototype.close = wrappers.close;
|
|
821
|
-
Database4.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
822
|
-
Database4.prototype.unsafeMode = wrappers.unsafeMode;
|
|
823
|
-
Database4.prototype[util2.inspect] = require_inspect();
|
|
824
|
-
module.exports = Database4;
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
// node_modules/better-sqlite3/lib/index.js
|
|
829
|
-
var require_lib = __commonJS({
|
|
830
|
-
"node_modules/better-sqlite3/lib/index.js"(exports, module) {
|
|
831
|
-
"use strict";
|
|
832
|
-
init_esm_shims();
|
|
833
|
-
module.exports = require_database();
|
|
834
|
-
module.exports.SqliteError = require_sqlite_error();
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
// node_modules/adm-zip/util/constants.js
|
|
839
|
-
var require_constants = __commonJS({
|
|
840
|
-
"node_modules/adm-zip/util/constants.js"(exports, module) {
|
|
841
|
-
"use strict";
|
|
842
|
-
init_esm_shims();
|
|
843
|
-
module.exports = {
|
|
844
|
-
/* The local file header */
|
|
845
|
-
LOCHDR: 30,
|
|
846
|
-
// LOC header size
|
|
847
|
-
LOCSIG: 67324752,
|
|
848
|
-
// "PK\003\004"
|
|
849
|
-
LOCVER: 4,
|
|
850
|
-
// version needed to extract
|
|
851
|
-
LOCFLG: 6,
|
|
852
|
-
// general purpose bit flag
|
|
853
|
-
LOCHOW: 8,
|
|
854
|
-
// compression method
|
|
855
|
-
LOCTIM: 10,
|
|
856
|
-
// modification time (2 bytes time, 2 bytes date)
|
|
857
|
-
LOCCRC: 14,
|
|
858
|
-
// uncompressed file crc-32 value
|
|
859
|
-
LOCSIZ: 18,
|
|
860
|
-
// compressed size
|
|
861
|
-
LOCLEN: 22,
|
|
862
|
-
// uncompressed size
|
|
863
|
-
LOCNAM: 26,
|
|
864
|
-
// filename length
|
|
865
|
-
LOCEXT: 28,
|
|
866
|
-
// extra field length
|
|
867
|
-
/* The Data descriptor */
|
|
868
|
-
EXTSIG: 134695760,
|
|
869
|
-
// "PK\007\008"
|
|
870
|
-
EXTHDR: 16,
|
|
871
|
-
// EXT header size
|
|
872
|
-
EXTCRC: 4,
|
|
873
|
-
// uncompressed file crc-32 value
|
|
874
|
-
EXTSIZ: 8,
|
|
875
|
-
// compressed size
|
|
876
|
-
EXTLEN: 12,
|
|
877
|
-
// uncompressed size
|
|
878
|
-
/* The central directory file header */
|
|
879
|
-
CENHDR: 46,
|
|
880
|
-
// CEN header size
|
|
881
|
-
CENSIG: 33639248,
|
|
882
|
-
// "PK\001\002"
|
|
883
|
-
CENVEM: 4,
|
|
884
|
-
// version made by
|
|
885
|
-
CENVER: 6,
|
|
886
|
-
// version needed to extract
|
|
887
|
-
CENFLG: 8,
|
|
888
|
-
// encrypt, decrypt flags
|
|
889
|
-
CENHOW: 10,
|
|
890
|
-
// compression method
|
|
891
|
-
CENTIM: 12,
|
|
892
|
-
// modification time (2 bytes time, 2 bytes date)
|
|
893
|
-
CENCRC: 16,
|
|
894
|
-
// uncompressed file crc-32 value
|
|
895
|
-
CENSIZ: 20,
|
|
896
|
-
// compressed size
|
|
897
|
-
CENLEN: 24,
|
|
898
|
-
// uncompressed size
|
|
899
|
-
CENNAM: 28,
|
|
900
|
-
// filename length
|
|
901
|
-
CENEXT: 30,
|
|
902
|
-
// extra field length
|
|
903
|
-
CENCOM: 32,
|
|
904
|
-
// file comment length
|
|
905
|
-
CENDSK: 34,
|
|
906
|
-
// volume number start
|
|
907
|
-
CENATT: 36,
|
|
908
|
-
// internal file attributes
|
|
909
|
-
CENATX: 38,
|
|
910
|
-
// external file attributes (host system dependent)
|
|
911
|
-
CENOFF: 42,
|
|
912
|
-
// LOC header offset
|
|
913
|
-
/* The entries in the end of central directory */
|
|
914
|
-
ENDHDR: 22,
|
|
915
|
-
// END header size
|
|
916
|
-
ENDSIG: 101010256,
|
|
917
|
-
// "PK\005\006"
|
|
918
|
-
ENDSUB: 8,
|
|
919
|
-
// number of entries on this disk
|
|
920
|
-
ENDTOT: 10,
|
|
921
|
-
// total number of entries
|
|
922
|
-
ENDSIZ: 12,
|
|
923
|
-
// central directory size in bytes
|
|
924
|
-
ENDOFF: 16,
|
|
925
|
-
// offset of first CEN header
|
|
926
|
-
ENDCOM: 20,
|
|
927
|
-
// zip file comment length
|
|
928
|
-
END64HDR: 20,
|
|
929
|
-
// zip64 END header size
|
|
930
|
-
END64SIG: 117853008,
|
|
931
|
-
// zip64 Locator signature, "PK\006\007"
|
|
932
|
-
END64START: 4,
|
|
933
|
-
// number of the disk with the start of the zip64
|
|
934
|
-
END64OFF: 8,
|
|
935
|
-
// relative offset of the zip64 end of central directory
|
|
936
|
-
END64NUMDISKS: 16,
|
|
937
|
-
// total number of disks
|
|
938
|
-
ZIP64SIG: 101075792,
|
|
939
|
-
// zip64 signature, "PK\006\006"
|
|
940
|
-
ZIP64HDR: 56,
|
|
941
|
-
// zip64 record minimum size
|
|
942
|
-
ZIP64LEAD: 12,
|
|
943
|
-
// leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
|
|
944
|
-
ZIP64SIZE: 4,
|
|
945
|
-
// zip64 size of the central directory record
|
|
946
|
-
ZIP64VEM: 12,
|
|
947
|
-
// zip64 version made by
|
|
948
|
-
ZIP64VER: 14,
|
|
949
|
-
// zip64 version needed to extract
|
|
950
|
-
ZIP64DSK: 16,
|
|
951
|
-
// zip64 number of this disk
|
|
952
|
-
ZIP64DSKDIR: 20,
|
|
953
|
-
// number of the disk with the start of the record directory
|
|
954
|
-
ZIP64SUB: 24,
|
|
955
|
-
// number of entries on this disk
|
|
956
|
-
ZIP64TOT: 32,
|
|
957
|
-
// total number of entries
|
|
958
|
-
ZIP64SIZB: 40,
|
|
959
|
-
// zip64 central directory size in bytes
|
|
960
|
-
ZIP64OFF: 48,
|
|
961
|
-
// offset of start of central directory with respect to the starting disk number
|
|
962
|
-
ZIP64EXTRA: 56,
|
|
963
|
-
// extensible data sector
|
|
964
|
-
/* Compression methods */
|
|
965
|
-
STORED: 0,
|
|
966
|
-
// no compression
|
|
967
|
-
SHRUNK: 1,
|
|
968
|
-
// shrunk
|
|
969
|
-
REDUCED1: 2,
|
|
970
|
-
// reduced with compression factor 1
|
|
971
|
-
REDUCED2: 3,
|
|
972
|
-
// reduced with compression factor 2
|
|
973
|
-
REDUCED3: 4,
|
|
974
|
-
// reduced with compression factor 3
|
|
975
|
-
REDUCED4: 5,
|
|
976
|
-
// reduced with compression factor 4
|
|
977
|
-
IMPLODED: 6,
|
|
978
|
-
// imploded
|
|
979
|
-
// 7 reserved for Tokenizing compression algorithm
|
|
980
|
-
DEFLATED: 8,
|
|
981
|
-
// deflated
|
|
982
|
-
ENHANCED_DEFLATED: 9,
|
|
983
|
-
// enhanced deflated
|
|
984
|
-
PKWARE: 10,
|
|
985
|
-
// PKWare DCL imploded
|
|
986
|
-
// 11 reserved by PKWARE
|
|
987
|
-
BZIP2: 12,
|
|
988
|
-
// compressed using BZIP2
|
|
989
|
-
// 13 reserved by PKWARE
|
|
990
|
-
LZMA: 14,
|
|
991
|
-
// LZMA
|
|
992
|
-
// 15-17 reserved by PKWARE
|
|
993
|
-
IBM_TERSE: 18,
|
|
994
|
-
// compressed using IBM TERSE
|
|
995
|
-
IBM_LZ77: 19,
|
|
996
|
-
// IBM LZ77 z
|
|
997
|
-
AES_ENCRYPT: 99,
|
|
998
|
-
// WinZIP AES encryption method
|
|
999
|
-
/* General purpose bit flag */
|
|
1000
|
-
// values can obtained with expression 2**bitnr
|
|
1001
|
-
FLG_ENC: 1,
|
|
1002
|
-
// Bit 0: encrypted file
|
|
1003
|
-
FLG_COMP1: 2,
|
|
1004
|
-
// Bit 1, compression option
|
|
1005
|
-
FLG_COMP2: 4,
|
|
1006
|
-
// Bit 2, compression option
|
|
1007
|
-
FLG_DESC: 8,
|
|
1008
|
-
// Bit 3, data descriptor
|
|
1009
|
-
FLG_ENH: 16,
|
|
1010
|
-
// Bit 4, enhanced deflating
|
|
1011
|
-
FLG_PATCH: 32,
|
|
1012
|
-
// Bit 5, indicates that the file is compressed patched data.
|
|
1013
|
-
FLG_STR: 64,
|
|
1014
|
-
// Bit 6, strong encryption (patented)
|
|
1015
|
-
// Bits 7-10: Currently unused.
|
|
1016
|
-
FLG_EFS: 2048,
|
|
1017
|
-
// Bit 11: Language encoding flag (EFS)
|
|
1018
|
-
// Bit 12: Reserved by PKWARE for enhanced compression.
|
|
1019
|
-
// Bit 13: encrypted the Central Directory (patented).
|
|
1020
|
-
// Bits 14-15: Reserved by PKWARE.
|
|
1021
|
-
FLG_MSK: 4096,
|
|
1022
|
-
// mask header values
|
|
1023
|
-
/* Load type */
|
|
1024
|
-
FILE: 2,
|
|
1025
|
-
BUFFER: 1,
|
|
1026
|
-
NONE: 0,
|
|
1027
|
-
/* 4.5 Extensible data fields */
|
|
1028
|
-
EF_ID: 0,
|
|
1029
|
-
EF_SIZE: 2,
|
|
1030
|
-
/* Header IDs */
|
|
1031
|
-
ID_ZIP64: 1,
|
|
1032
|
-
ID_AVINFO: 7,
|
|
1033
|
-
ID_PFS: 8,
|
|
1034
|
-
ID_OS2: 9,
|
|
1035
|
-
ID_NTFS: 10,
|
|
1036
|
-
ID_OPENVMS: 12,
|
|
1037
|
-
ID_UNIX: 13,
|
|
1038
|
-
ID_FORK: 14,
|
|
1039
|
-
ID_PATCH: 15,
|
|
1040
|
-
ID_X509_PKCS7: 20,
|
|
1041
|
-
ID_X509_CERTID_F: 21,
|
|
1042
|
-
ID_X509_CERTID_C: 22,
|
|
1043
|
-
ID_STRONGENC: 23,
|
|
1044
|
-
ID_RECORD_MGT: 24,
|
|
1045
|
-
ID_X509_PKCS7_RL: 25,
|
|
1046
|
-
ID_IBM1: 101,
|
|
1047
|
-
ID_IBM2: 102,
|
|
1048
|
-
ID_POSZIP: 18064,
|
|
1049
|
-
EF_ZIP64_OR_32: 4294967295,
|
|
1050
|
-
EF_ZIP64_OR_16: 65535,
|
|
1051
|
-
EF_ZIP64_SUNCOMP: 0,
|
|
1052
|
-
EF_ZIP64_SCOMP: 8,
|
|
1053
|
-
EF_ZIP64_RHO: 16,
|
|
1054
|
-
EF_ZIP64_DSN: 24
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
|
|
1059
|
-
// node_modules/adm-zip/util/errors.js
|
|
1060
|
-
var require_errors = __commonJS({
|
|
1061
|
-
"node_modules/adm-zip/util/errors.js"(exports) {
|
|
1062
|
-
"use strict";
|
|
1063
|
-
init_esm_shims();
|
|
1064
|
-
var errors = {
|
|
1065
|
-
/* Header error messages */
|
|
1066
|
-
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
1067
|
-
INVALID_CEN: "Invalid CEN header (bad signature)",
|
|
1068
|
-
INVALID_END: "Invalid END header (bad signature)",
|
|
1069
|
-
/* Descriptor */
|
|
1070
|
-
DESCRIPTOR_NOT_EXIST: "No descriptor present",
|
|
1071
|
-
DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
|
|
1072
|
-
DESCRIPTOR_FAULTY: "Descriptor data is malformed",
|
|
1073
|
-
/* ZipEntry error messages*/
|
|
1074
|
-
NO_DATA: "Nothing to decompress",
|
|
1075
|
-
BAD_CRC: "CRC32 checksum failed {0}",
|
|
1076
|
-
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
1077
|
-
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
1078
|
-
/* Inflater error messages */
|
|
1079
|
-
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
|
1080
|
-
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
|
1081
|
-
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
|
1082
|
-
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
|
1083
|
-
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
|
1084
|
-
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
|
1085
|
-
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
|
1086
|
-
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
|
1087
|
-
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
|
1088
|
-
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
|
1089
|
-
/* ADM-ZIP error messages */
|
|
1090
|
-
CANT_EXTRACT_FILE: "Could not extract the file",
|
|
1091
|
-
CANT_OVERRIDE: "Target file already exists",
|
|
1092
|
-
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
1093
|
-
NO_ZIP: "No zip file was loaded",
|
|
1094
|
-
NO_ENTRY: "Entry doesn't exist",
|
|
1095
|
-
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
1096
|
-
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
1097
|
-
NOT_IMPLEMENTED: "Not implemented",
|
|
1098
|
-
INVALID_FILENAME: "Invalid filename",
|
|
1099
|
-
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
1100
|
-
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
1101
|
-
WRONG_PASSWORD: "Wrong Password",
|
|
1102
|
-
/* ADM-ZIP */
|
|
1103
|
-
COMMENT_TOO_LONG: "Comment is too long",
|
|
1104
|
-
// Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
|
|
1105
|
-
EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
|
|
1106
|
-
};
|
|
1107
|
-
function E(message) {
|
|
1108
|
-
return function(...args) {
|
|
1109
|
-
if (args.length) {
|
|
1110
|
-
message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
|
|
1111
|
-
}
|
|
1112
|
-
return new Error("ADM-ZIP: " + message);
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
for (const msg of Object.keys(errors)) {
|
|
1116
|
-
exports[msg] = E(errors[msg]);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
|
|
1121
|
-
// node_modules/adm-zip/util/utils.js
|
|
1122
|
-
var require_utils = __commonJS({
|
|
1123
|
-
"node_modules/adm-zip/util/utils.js"(exports, module) {
|
|
1124
|
-
"use strict";
|
|
1125
|
-
init_esm_shims();
|
|
1126
|
-
var fsystem = __require("fs");
|
|
1127
|
-
var pth = __require("path");
|
|
1128
|
-
var Constants = require_constants();
|
|
1129
|
-
var Errors = require_errors();
|
|
1130
|
-
var isWin = typeof process === "object" && "win32" === process.platform;
|
|
1131
|
-
var is_Obj = (obj) => typeof obj === "object" && obj !== null;
|
|
1132
|
-
var crcTable = new Uint32Array(256).map((t, c) => {
|
|
1133
|
-
for (let k = 0; k < 8; k++) {
|
|
1134
|
-
if ((c & 1) !== 0) {
|
|
1135
|
-
c = 3988292384 ^ c >>> 1;
|
|
1136
|
-
} else {
|
|
1137
|
-
c >>>= 1;
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
return c >>> 0;
|
|
1141
|
-
});
|
|
1142
|
-
function Utils(opts) {
|
|
1143
|
-
this.sep = pth.sep;
|
|
1144
|
-
this.fs = fsystem;
|
|
1145
|
-
if (is_Obj(opts)) {
|
|
1146
|
-
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
|
|
1147
|
-
this.fs = opts.fs;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
module.exports = Utils;
|
|
1152
|
-
Utils.prototype.makeDir = function(folder) {
|
|
1153
|
-
const self = this;
|
|
1154
|
-
function mkdirSync2(fpath) {
|
|
1155
|
-
let resolvedPath = fpath.split(self.sep)[0];
|
|
1156
|
-
fpath.split(self.sep).forEach(function(name) {
|
|
1157
|
-
if (!name || name.substr(-1, 1) === ":") return;
|
|
1158
|
-
resolvedPath += self.sep + name;
|
|
1159
|
-
var stat;
|
|
1160
|
-
try {
|
|
1161
|
-
stat = self.fs.statSync(resolvedPath);
|
|
1162
|
-
} catch (e) {
|
|
1163
|
-
self.fs.mkdirSync(resolvedPath);
|
|
1164
|
-
}
|
|
1165
|
-
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
mkdirSync2(folder);
|
|
1169
|
-
};
|
|
1170
|
-
Utils.prototype.writeFileTo = function(path, content, overwrite, attr) {
|
|
1171
|
-
const self = this;
|
|
1172
|
-
if (self.fs.existsSync(path)) {
|
|
1173
|
-
if (!overwrite) return false;
|
|
1174
|
-
var stat = self.fs.statSync(path);
|
|
1175
|
-
if (stat.isDirectory()) {
|
|
1176
|
-
return false;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
var folder = pth.dirname(path);
|
|
1180
|
-
if (!self.fs.existsSync(folder)) {
|
|
1181
|
-
self.makeDir(folder);
|
|
1182
|
-
}
|
|
1183
|
-
var fd;
|
|
1184
|
-
try {
|
|
1185
|
-
fd = self.fs.openSync(path, "w", 438);
|
|
1186
|
-
} catch (e) {
|
|
1187
|
-
self.fs.chmodSync(path, 438);
|
|
1188
|
-
fd = self.fs.openSync(path, "w", 438);
|
|
1189
|
-
}
|
|
1190
|
-
if (fd) {
|
|
1191
|
-
try {
|
|
1192
|
-
self.fs.writeSync(fd, content, 0, content.length, 0);
|
|
1193
|
-
} finally {
|
|
1194
|
-
self.fs.closeSync(fd);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
self.fs.chmodSync(path, attr || 438);
|
|
1198
|
-
return true;
|
|
1199
|
-
};
|
|
1200
|
-
Utils.prototype.writeFileToAsync = function(path, content, overwrite, attr, callback) {
|
|
1201
|
-
if (typeof attr === "function") {
|
|
1202
|
-
callback = attr;
|
|
1203
|
-
attr = void 0;
|
|
1204
|
-
}
|
|
1205
|
-
const self = this;
|
|
1206
|
-
self.fs.exists(path, function(exist) {
|
|
1207
|
-
if (exist && !overwrite) return callback(false);
|
|
1208
|
-
self.fs.stat(path, function(err, stat) {
|
|
1209
|
-
if (exist && stat.isDirectory()) {
|
|
1210
|
-
return callback(false);
|
|
1211
|
-
}
|
|
1212
|
-
var folder = pth.dirname(path);
|
|
1213
|
-
self.fs.exists(folder, function(exists) {
|
|
1214
|
-
if (!exists) self.makeDir(folder);
|
|
1215
|
-
self.fs.open(path, "w", 438, function(err2, fd) {
|
|
1216
|
-
if (err2) {
|
|
1217
|
-
self.fs.chmod(path, 438, function() {
|
|
1218
|
-
self.fs.open(path, "w", 438, function(err3, fd2) {
|
|
1219
|
-
self.fs.write(fd2, content, 0, content.length, 0, function() {
|
|
1220
|
-
self.fs.close(fd2, function() {
|
|
1221
|
-
self.fs.chmod(path, attr || 438, function() {
|
|
1222
|
-
callback(true);
|
|
1223
|
-
});
|
|
1224
|
-
});
|
|
1225
|
-
});
|
|
1226
|
-
});
|
|
1227
|
-
});
|
|
1228
|
-
} else if (fd) {
|
|
1229
|
-
self.fs.write(fd, content, 0, content.length, 0, function() {
|
|
1230
|
-
self.fs.close(fd, function() {
|
|
1231
|
-
self.fs.chmod(path, attr || 438, function() {
|
|
1232
|
-
callback(true);
|
|
1233
|
-
});
|
|
1234
|
-
});
|
|
1235
|
-
});
|
|
1236
|
-
} else {
|
|
1237
|
-
self.fs.chmod(path, attr || 438, function() {
|
|
1238
|
-
callback(true);
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
});
|
|
1242
|
-
});
|
|
1243
|
-
});
|
|
1244
|
-
});
|
|
1245
|
-
};
|
|
1246
|
-
Utils.prototype.findFiles = function(path) {
|
|
1247
|
-
const self = this;
|
|
1248
|
-
function findSync(dir, pattern, recursive) {
|
|
1249
|
-
if (typeof pattern === "boolean") {
|
|
1250
|
-
recursive = pattern;
|
|
1251
|
-
pattern = void 0;
|
|
1252
|
-
}
|
|
1253
|
-
let files = [];
|
|
1254
|
-
self.fs.readdirSync(dir).forEach(function(file) {
|
|
1255
|
-
const path2 = pth.join(dir, file);
|
|
1256
|
-
const stat = self.fs.statSync(path2);
|
|
1257
|
-
if (!pattern || pattern.test(path2)) {
|
|
1258
|
-
files.push(pth.normalize(path2) + (stat.isDirectory() ? self.sep : ""));
|
|
1259
|
-
}
|
|
1260
|
-
if (stat.isDirectory() && recursive) files = files.concat(findSync(path2, pattern, recursive));
|
|
1261
|
-
});
|
|
1262
|
-
return files;
|
|
1263
|
-
}
|
|
1264
|
-
return findSync(path, void 0, true);
|
|
1265
|
-
};
|
|
1266
|
-
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
1267
|
-
const self = this;
|
|
1268
|
-
let results = [];
|
|
1269
|
-
self.fs.readdir(dir, function(err, list) {
|
|
1270
|
-
if (err) return cb(err);
|
|
1271
|
-
let list_length = list.length;
|
|
1272
|
-
if (!list_length) return cb(null, results);
|
|
1273
|
-
list.forEach(function(file) {
|
|
1274
|
-
file = pth.join(dir, file);
|
|
1275
|
-
self.fs.stat(file, function(err2, stat) {
|
|
1276
|
-
if (err2) return cb(err2);
|
|
1277
|
-
if (stat) {
|
|
1278
|
-
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
1279
|
-
if (stat.isDirectory()) {
|
|
1280
|
-
self.findFilesAsync(file, function(err3, res) {
|
|
1281
|
-
if (err3) return cb(err3);
|
|
1282
|
-
results = results.concat(res);
|
|
1283
|
-
if (!--list_length) cb(null, results);
|
|
1284
|
-
});
|
|
1285
|
-
} else {
|
|
1286
|
-
if (!--list_length) cb(null, results);
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
});
|
|
1292
|
-
};
|
|
1293
|
-
Utils.prototype.getAttributes = function() {
|
|
1294
|
-
};
|
|
1295
|
-
Utils.prototype.setAttributes = function() {
|
|
1296
|
-
};
|
|
1297
|
-
Utils.crc32update = function(crc, byte) {
|
|
1298
|
-
return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
1299
|
-
};
|
|
1300
|
-
Utils.crc32 = function(buf) {
|
|
1301
|
-
if (typeof buf === "string") {
|
|
1302
|
-
buf = Buffer.from(buf, "utf8");
|
|
1303
|
-
}
|
|
1304
|
-
let len = buf.length;
|
|
1305
|
-
let crc = ~0;
|
|
1306
|
-
for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
|
|
1307
|
-
return ~crc >>> 0;
|
|
1308
|
-
};
|
|
1309
|
-
Utils.methodToString = function(method) {
|
|
1310
|
-
switch (method) {
|
|
1311
|
-
case Constants.STORED:
|
|
1312
|
-
return "STORED (" + method + ")";
|
|
1313
|
-
case Constants.DEFLATED:
|
|
1314
|
-
return "DEFLATED (" + method + ")";
|
|
1315
|
-
default:
|
|
1316
|
-
return "UNSUPPORTED (" + method + ")";
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
Utils.canonical = function(path) {
|
|
1320
|
-
if (!path) return "";
|
|
1321
|
-
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
1322
|
-
return pth.join(".", safeSuffix);
|
|
1323
|
-
};
|
|
1324
|
-
Utils.zipnamefix = function(path) {
|
|
1325
|
-
if (!path) return "";
|
|
1326
|
-
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
1327
|
-
return pth.posix.join(".", safeSuffix);
|
|
1328
|
-
};
|
|
1329
|
-
Utils.findLast = function(arr, callback) {
|
|
1330
|
-
if (!Array.isArray(arr)) throw new TypeError("arr is not array");
|
|
1331
|
-
const len = arr.length >>> 0;
|
|
1332
|
-
for (let i = len - 1; i >= 0; i--) {
|
|
1333
|
-
if (callback(arr[i], i, arr)) {
|
|
1334
|
-
return arr[i];
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
return void 0;
|
|
1338
|
-
};
|
|
1339
|
-
Utils.sanitize = function(prefix, name) {
|
|
1340
|
-
prefix = pth.resolve(pth.normalize(prefix));
|
|
1341
|
-
var parts = name.split("/");
|
|
1342
|
-
for (var i = 0, l = parts.length; i < l; i++) {
|
|
1343
|
-
var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
1344
|
-
if (path.indexOf(prefix) === 0) {
|
|
1345
|
-
return path;
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
return pth.normalize(pth.join(prefix, pth.basename(name)));
|
|
1349
|
-
};
|
|
1350
|
-
Utils.toBuffer = function toBuffer(input, encoder) {
|
|
1351
|
-
if (Buffer.isBuffer(input)) {
|
|
1352
|
-
return input;
|
|
1353
|
-
} else if (input instanceof Uint8Array) {
|
|
1354
|
-
return Buffer.from(input);
|
|
1355
|
-
} else {
|
|
1356
|
-
return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
|
|
1357
|
-
}
|
|
1358
|
-
};
|
|
1359
|
-
Utils.readBigUInt64LE = function(buffer, index) {
|
|
1360
|
-
var slice = Buffer.from(buffer.slice(index, index + 8));
|
|
1361
|
-
slice.swap64();
|
|
1362
|
-
return parseInt(`0x${slice.toString("hex")}`);
|
|
1363
|
-
};
|
|
1364
|
-
Utils.fromDOS2Date = function(val) {
|
|
1365
|
-
return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
|
|
1366
|
-
};
|
|
1367
|
-
Utils.fromDate2DOS = function(val) {
|
|
1368
|
-
let date = 0;
|
|
1369
|
-
let time = 0;
|
|
1370
|
-
if (val.getFullYear() > 1979) {
|
|
1371
|
-
date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
|
|
1372
|
-
time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
|
|
1373
|
-
}
|
|
1374
|
-
return date << 16 | time;
|
|
1375
|
-
};
|
|
1376
|
-
Utils.isWin = isWin;
|
|
1377
|
-
Utils.crcTable = crcTable;
|
|
1378
|
-
}
|
|
1379
|
-
});
|
|
1380
|
-
|
|
1381
|
-
// node_modules/adm-zip/util/fattr.js
|
|
1382
|
-
var require_fattr = __commonJS({
|
|
1383
|
-
"node_modules/adm-zip/util/fattr.js"(exports, module) {
|
|
1384
|
-
"use strict";
|
|
1385
|
-
init_esm_shims();
|
|
1386
|
-
var pth = __require("path");
|
|
1387
|
-
module.exports = function(path, { fs }) {
|
|
1388
|
-
var _path = path || "", _obj = newAttr(), _stat = null;
|
|
1389
|
-
function newAttr() {
|
|
1390
|
-
return {
|
|
1391
|
-
directory: false,
|
|
1392
|
-
readonly: false,
|
|
1393
|
-
hidden: false,
|
|
1394
|
-
executable: false,
|
|
1395
|
-
mtime: 0,
|
|
1396
|
-
atime: 0
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
if (_path && fs.existsSync(_path)) {
|
|
1400
|
-
_stat = fs.statSync(_path);
|
|
1401
|
-
_obj.directory = _stat.isDirectory();
|
|
1402
|
-
_obj.mtime = _stat.mtime;
|
|
1403
|
-
_obj.atime = _stat.atime;
|
|
1404
|
-
_obj.executable = (73 & _stat.mode) !== 0;
|
|
1405
|
-
_obj.readonly = (128 & _stat.mode) === 0;
|
|
1406
|
-
_obj.hidden = pth.basename(_path)[0] === ".";
|
|
1407
|
-
} else {
|
|
1408
|
-
console.warn("Invalid path: " + _path);
|
|
1409
|
-
}
|
|
1410
|
-
return {
|
|
1411
|
-
get directory() {
|
|
1412
|
-
return _obj.directory;
|
|
1413
|
-
},
|
|
1414
|
-
get readOnly() {
|
|
1415
|
-
return _obj.readonly;
|
|
1416
|
-
},
|
|
1417
|
-
get hidden() {
|
|
1418
|
-
return _obj.hidden;
|
|
1419
|
-
},
|
|
1420
|
-
get mtime() {
|
|
1421
|
-
return _obj.mtime;
|
|
1422
|
-
},
|
|
1423
|
-
get atime() {
|
|
1424
|
-
return _obj.atime;
|
|
1425
|
-
},
|
|
1426
|
-
get executable() {
|
|
1427
|
-
return _obj.executable;
|
|
1428
|
-
},
|
|
1429
|
-
decodeAttributes: function() {
|
|
1430
|
-
},
|
|
1431
|
-
encodeAttributes: function() {
|
|
1432
|
-
},
|
|
1433
|
-
toJSON: function() {
|
|
1434
|
-
return {
|
|
1435
|
-
path: _path,
|
|
1436
|
-
isDirectory: _obj.directory,
|
|
1437
|
-
isReadOnly: _obj.readonly,
|
|
1438
|
-
isHidden: _obj.hidden,
|
|
1439
|
-
isExecutable: _obj.executable,
|
|
1440
|
-
mTime: _obj.mtime,
|
|
1441
|
-
aTime: _obj.atime
|
|
1442
|
-
};
|
|
1443
|
-
},
|
|
1444
|
-
toString: function() {
|
|
1445
|
-
return JSON.stringify(this.toJSON(), null, " ");
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
};
|
|
1449
|
-
}
|
|
1450
|
-
});
|
|
1451
|
-
|
|
1452
|
-
// node_modules/adm-zip/util/decoder.js
|
|
1453
|
-
var require_decoder = __commonJS({
|
|
1454
|
-
"node_modules/adm-zip/util/decoder.js"(exports, module) {
|
|
1455
|
-
"use strict";
|
|
1456
|
-
init_esm_shims();
|
|
1457
|
-
module.exports = {
|
|
1458
|
-
efs: true,
|
|
1459
|
-
encode: (data) => Buffer.from(data, "utf8"),
|
|
1460
|
-
decode: (data) => data.toString("utf8")
|
|
1461
|
-
};
|
|
1462
|
-
}
|
|
1463
|
-
});
|
|
1464
|
-
|
|
1465
|
-
// node_modules/adm-zip/util/index.js
|
|
1466
|
-
var require_util2 = __commonJS({
|
|
1467
|
-
"node_modules/adm-zip/util/index.js"(exports, module) {
|
|
1468
|
-
"use strict";
|
|
1469
|
-
init_esm_shims();
|
|
1470
|
-
module.exports = require_utils();
|
|
1471
|
-
module.exports.Constants = require_constants();
|
|
1472
|
-
module.exports.Errors = require_errors();
|
|
1473
|
-
module.exports.FileAttr = require_fattr();
|
|
1474
|
-
module.exports.decoder = require_decoder();
|
|
1475
|
-
}
|
|
1476
|
-
});
|
|
1477
|
-
|
|
1478
|
-
// node_modules/adm-zip/headers/entryHeader.js
|
|
1479
|
-
var require_entryHeader = __commonJS({
|
|
1480
|
-
"node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
|
|
1481
|
-
"use strict";
|
|
1482
|
-
init_esm_shims();
|
|
1483
|
-
var Utils = require_util2();
|
|
1484
|
-
var Constants = Utils.Constants;
|
|
1485
|
-
module.exports = function() {
|
|
1486
|
-
var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
|
|
1487
|
-
_verMade |= Utils.isWin ? 2560 : 768;
|
|
1488
|
-
_flags |= Constants.FLG_EFS;
|
|
1489
|
-
const _localHeader = {
|
|
1490
|
-
extraLen: 0
|
|
667
|
+
var Utils = require_util();
|
|
668
|
+
var Constants = Utils.Constants;
|
|
669
|
+
module2.exports = function() {
|
|
670
|
+
var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
|
|
671
|
+
_verMade |= Utils.isWin ? 2560 : 768;
|
|
672
|
+
_flags |= Constants.FLG_EFS;
|
|
673
|
+
const _localHeader = {
|
|
674
|
+
extraLen: 0
|
|
1491
675
|
};
|
|
1492
676
|
const uint32 = (val) => Math.max(0, val) >>> 0;
|
|
1493
677
|
const uint16 = (val) => Math.max(0, val) & 65535;
|
|
@@ -1747,12 +931,11 @@ var require_entryHeader = __commonJS({
|
|
|
1747
931
|
|
|
1748
932
|
// node_modules/adm-zip/headers/mainHeader.js
|
|
1749
933
|
var require_mainHeader = __commonJS({
|
|
1750
|
-
"node_modules/adm-zip/headers/mainHeader.js"(
|
|
934
|
+
"node_modules/adm-zip/headers/mainHeader.js"(exports2, module2) {
|
|
1751
935
|
"use strict";
|
|
1752
|
-
|
|
1753
|
-
var Utils = require_util2();
|
|
936
|
+
var Utils = require_util();
|
|
1754
937
|
var Constants = Utils.Constants;
|
|
1755
|
-
|
|
938
|
+
module2.exports = function() {
|
|
1756
939
|
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
1757
940
|
return {
|
|
1758
941
|
get diskEntries() {
|
|
@@ -1842,21 +1025,19 @@ var require_mainHeader = __commonJS({
|
|
|
1842
1025
|
|
|
1843
1026
|
// node_modules/adm-zip/headers/index.js
|
|
1844
1027
|
var require_headers = __commonJS({
|
|
1845
|
-
"node_modules/adm-zip/headers/index.js"(
|
|
1028
|
+
"node_modules/adm-zip/headers/index.js"(exports2) {
|
|
1846
1029
|
"use strict";
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
exports.MainHeader = require_mainHeader();
|
|
1030
|
+
exports2.EntryHeader = require_entryHeader();
|
|
1031
|
+
exports2.MainHeader = require_mainHeader();
|
|
1850
1032
|
}
|
|
1851
1033
|
});
|
|
1852
1034
|
|
|
1853
1035
|
// node_modules/adm-zip/methods/deflater.js
|
|
1854
1036
|
var require_deflater = __commonJS({
|
|
1855
|
-
"node_modules/adm-zip/methods/deflater.js"(
|
|
1037
|
+
"node_modules/adm-zip/methods/deflater.js"(exports2, module2) {
|
|
1856
1038
|
"use strict";
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
var zlib = __require("zlib");
|
|
1039
|
+
module2.exports = function(inbuf) {
|
|
1040
|
+
var zlib = require("zlib");
|
|
1860
1041
|
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
1861
1042
|
return {
|
|
1862
1043
|
deflate: function() {
|
|
@@ -1887,12 +1068,11 @@ var require_deflater = __commonJS({
|
|
|
1887
1068
|
|
|
1888
1069
|
// node_modules/adm-zip/methods/inflater.js
|
|
1889
1070
|
var require_inflater = __commonJS({
|
|
1890
|
-
"node_modules/adm-zip/methods/inflater.js"(
|
|
1071
|
+
"node_modules/adm-zip/methods/inflater.js"(exports2, module2) {
|
|
1891
1072
|
"use strict";
|
|
1892
|
-
init_esm_shims();
|
|
1893
1073
|
var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
|
|
1894
|
-
|
|
1895
|
-
var zlib =
|
|
1074
|
+
module2.exports = function(inbuf, expectedLength) {
|
|
1075
|
+
var zlib = require("zlib");
|
|
1896
1076
|
const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
|
|
1897
1077
|
return {
|
|
1898
1078
|
inflate: function() {
|
|
@@ -1923,10 +1103,9 @@ var require_inflater = __commonJS({
|
|
|
1923
1103
|
|
|
1924
1104
|
// node_modules/adm-zip/methods/zipcrypto.js
|
|
1925
1105
|
var require_zipcrypto = __commonJS({
|
|
1926
|
-
"node_modules/adm-zip/methods/zipcrypto.js"(
|
|
1106
|
+
"node_modules/adm-zip/methods/zipcrypto.js"(exports2, module2) {
|
|
1927
1107
|
"use strict";
|
|
1928
|
-
|
|
1929
|
-
var { randomFillSync } = __require("crypto");
|
|
1108
|
+
var { randomFillSync } = require("crypto");
|
|
1930
1109
|
var Errors = require_errors();
|
|
1931
1110
|
var crctable = new Uint32Array(256).map((t, crc) => {
|
|
1932
1111
|
for (let j = 0; j < 8; j++) {
|
|
@@ -2034,31 +1213,29 @@ var require_zipcrypto = __commonJS({
|
|
|
2034
1213
|
encrypter(salt, result);
|
|
2035
1214
|
return encrypter(data, result, 12);
|
|
2036
1215
|
}
|
|
2037
|
-
|
|
1216
|
+
module2.exports = { decrypt, encrypt, _salter };
|
|
2038
1217
|
}
|
|
2039
1218
|
});
|
|
2040
1219
|
|
|
2041
1220
|
// node_modules/adm-zip/methods/index.js
|
|
2042
1221
|
var require_methods = __commonJS({
|
|
2043
|
-
"node_modules/adm-zip/methods/index.js"(
|
|
1222
|
+
"node_modules/adm-zip/methods/index.js"(exports2) {
|
|
2044
1223
|
"use strict";
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
exports.ZipCrypto = require_zipcrypto();
|
|
1224
|
+
exports2.Deflater = require_deflater();
|
|
1225
|
+
exports2.Inflater = require_inflater();
|
|
1226
|
+
exports2.ZipCrypto = require_zipcrypto();
|
|
2049
1227
|
}
|
|
2050
1228
|
});
|
|
2051
1229
|
|
|
2052
1230
|
// node_modules/adm-zip/zipEntry.js
|
|
2053
1231
|
var require_zipEntry = __commonJS({
|
|
2054
|
-
"node_modules/adm-zip/zipEntry.js"(
|
|
1232
|
+
"node_modules/adm-zip/zipEntry.js"(exports2, module2) {
|
|
2055
1233
|
"use strict";
|
|
2056
|
-
|
|
2057
|
-
var Utils = require_util2();
|
|
1234
|
+
var Utils = require_util();
|
|
2058
1235
|
var Headers = require_headers();
|
|
2059
1236
|
var Constants = Utils.Constants;
|
|
2060
1237
|
var Methods = require_methods();
|
|
2061
|
-
|
|
1238
|
+
module2.exports = function(options, input) {
|
|
2062
1239
|
var _centralHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
|
|
2063
1240
|
const opts = options;
|
|
2064
1241
|
const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
|
|
@@ -2384,13 +1561,12 @@ var require_zipEntry = __commonJS({
|
|
|
2384
1561
|
|
|
2385
1562
|
// node_modules/adm-zip/zipFile.js
|
|
2386
1563
|
var require_zipFile = __commonJS({
|
|
2387
|
-
"node_modules/adm-zip/zipFile.js"(
|
|
1564
|
+
"node_modules/adm-zip/zipFile.js"(exports2, module2) {
|
|
2388
1565
|
"use strict";
|
|
2389
|
-
init_esm_shims();
|
|
2390
1566
|
var ZipEntry = require_zipEntry();
|
|
2391
1567
|
var Headers = require_headers();
|
|
2392
|
-
var Utils =
|
|
2393
|
-
|
|
1568
|
+
var Utils = require_util();
|
|
1569
|
+
module2.exports = function(inBuffer, options) {
|
|
2394
1570
|
var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
|
|
2395
1571
|
var password = null;
|
|
2396
1572
|
const temporary = /* @__PURE__ */ new Set();
|
|
@@ -2732,11 +1908,10 @@ var require_zipFile = __commonJS({
|
|
|
2732
1908
|
|
|
2733
1909
|
// node_modules/adm-zip/adm-zip.js
|
|
2734
1910
|
var require_adm_zip = __commonJS({
|
|
2735
|
-
"node_modules/adm-zip/adm-zip.js"(
|
|
1911
|
+
"node_modules/adm-zip/adm-zip.js"(exports2, module2) {
|
|
2736
1912
|
"use strict";
|
|
2737
|
-
|
|
2738
|
-
var
|
|
2739
|
-
var pth = __require("path");
|
|
1913
|
+
var Utils = require_util();
|
|
1914
|
+
var pth = require("path");
|
|
2740
1915
|
var ZipEntry = require_zipEntry();
|
|
2741
1916
|
var ZipFile = require_zipFile();
|
|
2742
1917
|
var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
|
|
@@ -2752,7 +1927,7 @@ var require_adm_zip = __commonJS({
|
|
|
2752
1927
|
// file system
|
|
2753
1928
|
fs: null
|
|
2754
1929
|
};
|
|
2755
|
-
|
|
1930
|
+
module2.exports = function(input, options) {
|
|
2756
1931
|
let inBuffer = null;
|
|
2757
1932
|
const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
|
|
2758
1933
|
if (input && "object" === typeof input) {
|
|
@@ -3463,79 +2638,840 @@ var require_adm_zip = __commonJS({
|
|
|
3463
2638
|
targetFileName = "";
|
|
3464
2639
|
}
|
|
3465
2640
|
}
|
|
3466
|
-
if (!targetFileName && opts.filename) {
|
|
3467
|
-
targetFileName = opts.filename;
|
|
2641
|
+
if (!targetFileName && opts.filename) {
|
|
2642
|
+
targetFileName = opts.filename;
|
|
2643
|
+
}
|
|
2644
|
+
if (!targetFileName) return;
|
|
2645
|
+
var zipData = _zip.compressToBuffer();
|
|
2646
|
+
if (zipData) {
|
|
2647
|
+
var ok = filetools.writeFileTo(targetFileName, zipData, true);
|
|
2648
|
+
if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
|
|
2649
|
+
}
|
|
2650
|
+
},
|
|
2651
|
+
/**
|
|
2652
|
+
*
|
|
2653
|
+
* @param {string} targetFileName
|
|
2654
|
+
* @param {object} [props]
|
|
2655
|
+
* @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
|
|
2656
|
+
* @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
|
|
2657
|
+
|
|
2658
|
+
* @returns {Promise<void>}
|
|
2659
|
+
*/
|
|
2660
|
+
writeZipPromise: function(targetFileName, props) {
|
|
2661
|
+
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
|
2662
|
+
return new Promise((resolve2, reject) => {
|
|
2663
|
+
if (!targetFileName && opts.filename) targetFileName = opts.filename;
|
|
2664
|
+
if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
|
|
2665
|
+
this.toBufferPromise().then((zipData) => {
|
|
2666
|
+
const ret = (done) => done ? resolve2(done) : reject("ADM-ZIP: Wasn't able to write zip file");
|
|
2667
|
+
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
|
2668
|
+
}, reject);
|
|
2669
|
+
});
|
|
2670
|
+
},
|
|
2671
|
+
/**
|
|
2672
|
+
* @returns {Promise<Buffer>} A promise to the Buffer.
|
|
2673
|
+
*/
|
|
2674
|
+
toBufferPromise: function() {
|
|
2675
|
+
return new Promise((resolve2, reject) => {
|
|
2676
|
+
_zip.toAsyncBuffer(resolve2, reject);
|
|
2677
|
+
});
|
|
2678
|
+
},
|
|
2679
|
+
/**
|
|
2680
|
+
* Returns the content of the entire zip file as a Buffer object
|
|
2681
|
+
*
|
|
2682
|
+
* @prop {function} [onSuccess]
|
|
2683
|
+
* @prop {function} [onFail]
|
|
2684
|
+
* @prop {function} [onItemStart]
|
|
2685
|
+
* @prop {function} [onItemEnd]
|
|
2686
|
+
* @returns {Buffer}
|
|
2687
|
+
*/
|
|
2688
|
+
toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
2689
|
+
if (typeof onSuccess === "function") {
|
|
2690
|
+
_zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
|
|
2691
|
+
return null;
|
|
2692
|
+
}
|
|
2693
|
+
return _zip.compressToBuffer();
|
|
2694
|
+
}
|
|
2695
|
+
};
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
});
|
|
2699
|
+
|
|
2700
|
+
// node_modules/better-sqlite3/lib/util.js
|
|
2701
|
+
var require_util2 = __commonJS({
|
|
2702
|
+
"node_modules/better-sqlite3/lib/util.js"(exports2) {
|
|
2703
|
+
"use strict";
|
|
2704
|
+
exports2.getBooleanOption = (options, key) => {
|
|
2705
|
+
let value = false;
|
|
2706
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
2707
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
2708
|
+
}
|
|
2709
|
+
return value;
|
|
2710
|
+
};
|
|
2711
|
+
exports2.cppdb = Symbol();
|
|
2712
|
+
exports2.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
|
|
2716
|
+
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
2717
|
+
var require_sqlite_error = __commonJS({
|
|
2718
|
+
"node_modules/better-sqlite3/lib/sqlite-error.js"(exports2, module2) {
|
|
2719
|
+
"use strict";
|
|
2720
|
+
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
2721
|
+
function SqliteError(message, code) {
|
|
2722
|
+
if (new.target !== SqliteError) {
|
|
2723
|
+
return new SqliteError(message, code);
|
|
2724
|
+
}
|
|
2725
|
+
if (typeof code !== "string") {
|
|
2726
|
+
throw new TypeError("Expected second argument to be a string");
|
|
2727
|
+
}
|
|
2728
|
+
Error.call(this, message);
|
|
2729
|
+
descriptor.value = "" + message;
|
|
2730
|
+
Object.defineProperty(this, "message", descriptor);
|
|
2731
|
+
Error.captureStackTrace(this, SqliteError);
|
|
2732
|
+
this.code = code;
|
|
2733
|
+
}
|
|
2734
|
+
Object.setPrototypeOf(SqliteError, Error);
|
|
2735
|
+
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
2736
|
+
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
2737
|
+
module2.exports = SqliteError;
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
|
|
2741
|
+
// node_modules/file-uri-to-path/index.js
|
|
2742
|
+
var require_file_uri_to_path = __commonJS({
|
|
2743
|
+
"node_modules/file-uri-to-path/index.js"(exports2, module2) {
|
|
2744
|
+
"use strict";
|
|
2745
|
+
var sep2 = require("path").sep || "/";
|
|
2746
|
+
module2.exports = fileUriToPath;
|
|
2747
|
+
function fileUriToPath(uri) {
|
|
2748
|
+
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
2749
|
+
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
2750
|
+
}
|
|
2751
|
+
var rest = decodeURI(uri.substring(7));
|
|
2752
|
+
var firstSlash = rest.indexOf("/");
|
|
2753
|
+
var host = rest.substring(0, firstSlash);
|
|
2754
|
+
var path = rest.substring(firstSlash + 1);
|
|
2755
|
+
if ("localhost" == host) host = "";
|
|
2756
|
+
if (host) {
|
|
2757
|
+
host = sep2 + sep2 + host;
|
|
2758
|
+
}
|
|
2759
|
+
path = path.replace(/^(.+)\|/, "$1:");
|
|
2760
|
+
if (sep2 == "\\") {
|
|
2761
|
+
path = path.replace(/\//g, "\\");
|
|
2762
|
+
}
|
|
2763
|
+
if (/^.+\:/.test(path)) {
|
|
2764
|
+
} else {
|
|
2765
|
+
path = sep2 + path;
|
|
2766
|
+
}
|
|
2767
|
+
return host + path;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
});
|
|
2771
|
+
|
|
2772
|
+
// node_modules/bindings/bindings.js
|
|
2773
|
+
var require_bindings = __commonJS({
|
|
2774
|
+
"node_modules/bindings/bindings.js"(exports2, module2) {
|
|
2775
|
+
"use strict";
|
|
2776
|
+
var fs = require("fs");
|
|
2777
|
+
var path = require("path");
|
|
2778
|
+
var fileURLToPath = require_file_uri_to_path();
|
|
2779
|
+
var join5 = path.join;
|
|
2780
|
+
var dirname2 = path.dirname;
|
|
2781
|
+
var exists = fs.accessSync && function(path2) {
|
|
2782
|
+
try {
|
|
2783
|
+
fs.accessSync(path2);
|
|
2784
|
+
} catch (e) {
|
|
2785
|
+
return false;
|
|
2786
|
+
}
|
|
2787
|
+
return true;
|
|
2788
|
+
} || fs.existsSync || path.existsSync;
|
|
2789
|
+
var defaults = {
|
|
2790
|
+
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
2791
|
+
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
2792
|
+
platform: process.platform,
|
|
2793
|
+
arch: process.arch,
|
|
2794
|
+
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
2795
|
+
version: process.versions.node,
|
|
2796
|
+
bindings: "bindings.node",
|
|
2797
|
+
try: [
|
|
2798
|
+
// node-gyp's linked version in the "build" dir
|
|
2799
|
+
["module_root", "build", "bindings"],
|
|
2800
|
+
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
2801
|
+
["module_root", "build", "Debug", "bindings"],
|
|
2802
|
+
["module_root", "build", "Release", "bindings"],
|
|
2803
|
+
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
2804
|
+
["module_root", "out", "Debug", "bindings"],
|
|
2805
|
+
["module_root", "Debug", "bindings"],
|
|
2806
|
+
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
2807
|
+
["module_root", "out", "Release", "bindings"],
|
|
2808
|
+
["module_root", "Release", "bindings"],
|
|
2809
|
+
// Legacy from node-waf, node <= 0.4.x
|
|
2810
|
+
["module_root", "build", "default", "bindings"],
|
|
2811
|
+
// Production "Release" buildtype binary (meh...)
|
|
2812
|
+
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
2813
|
+
// node-qbs builds
|
|
2814
|
+
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
2815
|
+
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
2816
|
+
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
2817
|
+
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
2818
|
+
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
2819
|
+
]
|
|
2820
|
+
};
|
|
2821
|
+
function bindings(opts) {
|
|
2822
|
+
if (typeof opts == "string") {
|
|
2823
|
+
opts = { bindings: opts };
|
|
2824
|
+
} else if (!opts) {
|
|
2825
|
+
opts = {};
|
|
2826
|
+
}
|
|
2827
|
+
Object.keys(defaults).map(function(i2) {
|
|
2828
|
+
if (!(i2 in opts)) opts[i2] = defaults[i2];
|
|
2829
|
+
});
|
|
2830
|
+
if (!opts.module_root) {
|
|
2831
|
+
opts.module_root = exports2.getRoot(exports2.getFileName());
|
|
2832
|
+
}
|
|
2833
|
+
if (path.extname(opts.bindings) != ".node") {
|
|
2834
|
+
opts.bindings += ".node";
|
|
2835
|
+
}
|
|
2836
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
2837
|
+
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
2838
|
+
for (; i < l; i++) {
|
|
2839
|
+
n = join5.apply(
|
|
2840
|
+
null,
|
|
2841
|
+
opts.try[i].map(function(p) {
|
|
2842
|
+
return opts[p] || p;
|
|
2843
|
+
})
|
|
2844
|
+
);
|
|
2845
|
+
tries.push(n);
|
|
2846
|
+
try {
|
|
2847
|
+
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
2848
|
+
if (!opts.path) {
|
|
2849
|
+
b.path = n;
|
|
2850
|
+
}
|
|
2851
|
+
return b;
|
|
2852
|
+
} catch (e) {
|
|
2853
|
+
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
2854
|
+
throw e;
|
|
3468
2855
|
}
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
err = new Error(
|
|
2859
|
+
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
2860
|
+
return opts.arrow + a;
|
|
2861
|
+
}).join("\n")
|
|
2862
|
+
);
|
|
2863
|
+
err.tries = tries;
|
|
2864
|
+
throw err;
|
|
2865
|
+
}
|
|
2866
|
+
module2.exports = exports2 = bindings;
|
|
2867
|
+
exports2.getFileName = function getFileName(calling_file) {
|
|
2868
|
+
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
2869
|
+
Error.stackTraceLimit = 10;
|
|
2870
|
+
Error.prepareStackTrace = function(e, st) {
|
|
2871
|
+
for (var i = 0, l = st.length; i < l; i++) {
|
|
2872
|
+
fileName = st[i].getFileName();
|
|
2873
|
+
if (fileName !== __filename) {
|
|
2874
|
+
if (calling_file) {
|
|
2875
|
+
if (fileName !== calling_file) {
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
} else {
|
|
2879
|
+
return;
|
|
2880
|
+
}
|
|
3474
2881
|
}
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
Error.captureStackTrace(dummy);
|
|
2885
|
+
dummy.stack;
|
|
2886
|
+
Error.prepareStackTrace = origPST;
|
|
2887
|
+
Error.stackTraceLimit = origSTL;
|
|
2888
|
+
var fileSchema = "file://";
|
|
2889
|
+
if (fileName.indexOf(fileSchema) === 0) {
|
|
2890
|
+
fileName = fileURLToPath(fileName);
|
|
2891
|
+
}
|
|
2892
|
+
return fileName;
|
|
2893
|
+
};
|
|
2894
|
+
exports2.getRoot = function getRoot(file) {
|
|
2895
|
+
var dir = dirname2(file), prev;
|
|
2896
|
+
while (true) {
|
|
2897
|
+
if (dir === ".") {
|
|
2898
|
+
dir = process.cwd();
|
|
2899
|
+
}
|
|
2900
|
+
if (exists(join5(dir, "package.json")) || exists(join5(dir, "node_modules"))) {
|
|
2901
|
+
return dir;
|
|
2902
|
+
}
|
|
2903
|
+
if (prev === dir) {
|
|
2904
|
+
throw new Error(
|
|
2905
|
+
'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
|
|
2906
|
+
);
|
|
2907
|
+
}
|
|
2908
|
+
prev = dir;
|
|
2909
|
+
dir = join5(dir, "..");
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
});
|
|
2914
|
+
|
|
2915
|
+
// node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
2916
|
+
var require_wrappers = __commonJS({
|
|
2917
|
+
"node_modules/better-sqlite3/lib/methods/wrappers.js"(exports2) {
|
|
2918
|
+
"use strict";
|
|
2919
|
+
var { cppdb } = require_util2();
|
|
2920
|
+
exports2.prepare = function prepare(sql) {
|
|
2921
|
+
return this[cppdb].prepare(sql, this, false);
|
|
2922
|
+
};
|
|
2923
|
+
exports2.exec = function exec(sql) {
|
|
2924
|
+
this[cppdb].exec(sql);
|
|
2925
|
+
return this;
|
|
2926
|
+
};
|
|
2927
|
+
exports2.close = function close() {
|
|
2928
|
+
this[cppdb].close();
|
|
2929
|
+
return this;
|
|
2930
|
+
};
|
|
2931
|
+
exports2.loadExtension = function loadExtension(...args) {
|
|
2932
|
+
this[cppdb].loadExtension(...args);
|
|
2933
|
+
return this;
|
|
2934
|
+
};
|
|
2935
|
+
exports2.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
2936
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
2937
|
+
return this;
|
|
2938
|
+
};
|
|
2939
|
+
exports2.unsafeMode = function unsafeMode(...args) {
|
|
2940
|
+
this[cppdb].unsafeMode(...args);
|
|
2941
|
+
return this;
|
|
2942
|
+
};
|
|
2943
|
+
exports2.getters = {
|
|
2944
|
+
name: {
|
|
2945
|
+
get: function name() {
|
|
2946
|
+
return this[cppdb].name;
|
|
3475
2947
|
},
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
* @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
|
|
3482
|
-
|
|
3483
|
-
* @returns {Promise<void>}
|
|
3484
|
-
*/
|
|
3485
|
-
writeZipPromise: function(targetFileName, props) {
|
|
3486
|
-
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
|
3487
|
-
return new Promise((resolve2, reject) => {
|
|
3488
|
-
if (!targetFileName && opts.filename) targetFileName = opts.filename;
|
|
3489
|
-
if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
|
|
3490
|
-
this.toBufferPromise().then((zipData) => {
|
|
3491
|
-
const ret = (done) => done ? resolve2(done) : reject("ADM-ZIP: Wasn't able to write zip file");
|
|
3492
|
-
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
|
3493
|
-
}, reject);
|
|
3494
|
-
});
|
|
2948
|
+
enumerable: true
|
|
2949
|
+
},
|
|
2950
|
+
open: {
|
|
2951
|
+
get: function open() {
|
|
2952
|
+
return this[cppdb].open;
|
|
3495
2953
|
},
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
return
|
|
3501
|
-
_zip.toAsyncBuffer(resolve2, reject);
|
|
3502
|
-
});
|
|
2954
|
+
enumerable: true
|
|
2955
|
+
},
|
|
2956
|
+
inTransaction: {
|
|
2957
|
+
get: function inTransaction() {
|
|
2958
|
+
return this[cppdb].inTransaction;
|
|
3503
2959
|
},
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
2960
|
+
enumerable: true
|
|
2961
|
+
},
|
|
2962
|
+
readonly: {
|
|
2963
|
+
get: function readonly() {
|
|
2964
|
+
return this[cppdb].readonly;
|
|
2965
|
+
},
|
|
2966
|
+
enumerable: true
|
|
2967
|
+
},
|
|
2968
|
+
memory: {
|
|
2969
|
+
get: function memory() {
|
|
2970
|
+
return this[cppdb].memory;
|
|
2971
|
+
},
|
|
2972
|
+
enumerable: true
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
});
|
|
2977
|
+
|
|
2978
|
+
// node_modules/better-sqlite3/lib/methods/transaction.js
|
|
2979
|
+
var require_transaction = __commonJS({
|
|
2980
|
+
"node_modules/better-sqlite3/lib/methods/transaction.js"(exports2, module2) {
|
|
2981
|
+
"use strict";
|
|
2982
|
+
var { cppdb } = require_util2();
|
|
2983
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
2984
|
+
module2.exports = function transaction(fn) {
|
|
2985
|
+
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
2986
|
+
const db = this[cppdb];
|
|
2987
|
+
const controller = getController(db, this);
|
|
2988
|
+
const { apply } = Function.prototype;
|
|
2989
|
+
const properties = {
|
|
2990
|
+
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
2991
|
+
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
2992
|
+
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
2993
|
+
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
2994
|
+
database: { value: this, enumerable: true }
|
|
2995
|
+
};
|
|
2996
|
+
Object.defineProperties(properties.default.value, properties);
|
|
2997
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
2998
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
2999
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
3000
|
+
return properties.default.value;
|
|
3001
|
+
};
|
|
3002
|
+
var getController = (db, self) => {
|
|
3003
|
+
let controller = controllers.get(db);
|
|
3004
|
+
if (!controller) {
|
|
3005
|
+
const shared = {
|
|
3006
|
+
commit: db.prepare("COMMIT", self, false),
|
|
3007
|
+
rollback: db.prepare("ROLLBACK", self, false),
|
|
3008
|
+
savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
3009
|
+
release: db.prepare("RELEASE ` _bs3. `", self, false),
|
|
3010
|
+
rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
3011
|
+
};
|
|
3012
|
+
controllers.set(db, controller = {
|
|
3013
|
+
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
3014
|
+
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
3015
|
+
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
3016
|
+
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
return controller;
|
|
3020
|
+
};
|
|
3021
|
+
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
3022
|
+
let before, after, undo;
|
|
3023
|
+
if (db.inTransaction) {
|
|
3024
|
+
before = savepoint;
|
|
3025
|
+
after = release;
|
|
3026
|
+
undo = rollbackTo;
|
|
3027
|
+
} else {
|
|
3028
|
+
before = begin;
|
|
3029
|
+
after = commit;
|
|
3030
|
+
undo = rollback;
|
|
3031
|
+
}
|
|
3032
|
+
before.run();
|
|
3033
|
+
try {
|
|
3034
|
+
const result = apply.call(fn, this, arguments);
|
|
3035
|
+
if (result && typeof result.then === "function") {
|
|
3036
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
3037
|
+
}
|
|
3038
|
+
after.run();
|
|
3039
|
+
return result;
|
|
3040
|
+
} catch (ex) {
|
|
3041
|
+
if (db.inTransaction) {
|
|
3042
|
+
undo.run();
|
|
3043
|
+
if (undo !== rollback) after.run();
|
|
3044
|
+
}
|
|
3045
|
+
throw ex;
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
});
|
|
3050
|
+
|
|
3051
|
+
// node_modules/better-sqlite3/lib/methods/pragma.js
|
|
3052
|
+
var require_pragma = __commonJS({
|
|
3053
|
+
"node_modules/better-sqlite3/lib/methods/pragma.js"(exports2, module2) {
|
|
3054
|
+
"use strict";
|
|
3055
|
+
var { getBooleanOption, cppdb } = require_util2();
|
|
3056
|
+
module2.exports = function pragma(source, options) {
|
|
3057
|
+
if (options == null) options = {};
|
|
3058
|
+
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3059
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
3060
|
+
const simple = getBooleanOption(options, "simple");
|
|
3061
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
3062
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
|
|
3067
|
+
// node_modules/better-sqlite3/lib/methods/backup.js
|
|
3068
|
+
var require_backup = __commonJS({
|
|
3069
|
+
"node_modules/better-sqlite3/lib/methods/backup.js"(exports2, module2) {
|
|
3070
|
+
"use strict";
|
|
3071
|
+
var fs = require("fs");
|
|
3072
|
+
var path = require("path");
|
|
3073
|
+
var { promisify } = require("util");
|
|
3074
|
+
var { cppdb } = require_util2();
|
|
3075
|
+
var fsAccess = promisify(fs.access);
|
|
3076
|
+
module2.exports = async function backup(filename, options) {
|
|
3077
|
+
if (options == null) options = {};
|
|
3078
|
+
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3079
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
3080
|
+
filename = filename.trim();
|
|
3081
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
3082
|
+
const handler = "progress" in options ? options.progress : null;
|
|
3083
|
+
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
3084
|
+
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
3085
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
3086
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
3087
|
+
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
3088
|
+
await fsAccess(path.dirname(filename)).catch(() => {
|
|
3089
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
3090
|
+
});
|
|
3091
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
3092
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
3093
|
+
};
|
|
3094
|
+
var runBackup = (backup, handler) => {
|
|
3095
|
+
let rate = 0;
|
|
3096
|
+
let useDefault = true;
|
|
3097
|
+
return new Promise((resolve2, reject) => {
|
|
3098
|
+
setImmediate(function step() {
|
|
3099
|
+
try {
|
|
3100
|
+
const progress = backup.transfer(rate);
|
|
3101
|
+
if (!progress.remainingPages) {
|
|
3102
|
+
backup.close();
|
|
3103
|
+
resolve2(progress);
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
if (useDefault) {
|
|
3107
|
+
useDefault = false;
|
|
3108
|
+
rate = 100;
|
|
3109
|
+
}
|
|
3110
|
+
if (handler) {
|
|
3111
|
+
const ret = handler(progress);
|
|
3112
|
+
if (ret !== void 0) {
|
|
3113
|
+
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
3114
|
+
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
setImmediate(step);
|
|
3118
|
+
} catch (err) {
|
|
3119
|
+
backup.close();
|
|
3120
|
+
reject(err);
|
|
3517
3121
|
}
|
|
3518
|
-
|
|
3122
|
+
});
|
|
3123
|
+
});
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
|
|
3128
|
+
// node_modules/better-sqlite3/lib/methods/serialize.js
|
|
3129
|
+
var require_serialize = __commonJS({
|
|
3130
|
+
"node_modules/better-sqlite3/lib/methods/serialize.js"(exports2, module2) {
|
|
3131
|
+
"use strict";
|
|
3132
|
+
var { cppdb } = require_util2();
|
|
3133
|
+
module2.exports = function serialize(options) {
|
|
3134
|
+
if (options == null) options = {};
|
|
3135
|
+
if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
|
|
3136
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
3137
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
3138
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
3139
|
+
return this[cppdb].serialize(attachedName);
|
|
3140
|
+
};
|
|
3141
|
+
}
|
|
3142
|
+
});
|
|
3143
|
+
|
|
3144
|
+
// node_modules/better-sqlite3/lib/methods/function.js
|
|
3145
|
+
var require_function = __commonJS({
|
|
3146
|
+
"node_modules/better-sqlite3/lib/methods/function.js"(exports2, module2) {
|
|
3147
|
+
"use strict";
|
|
3148
|
+
var { getBooleanOption, cppdb } = require_util2();
|
|
3149
|
+
module2.exports = function defineFunction(name, options, fn) {
|
|
3150
|
+
if (options == null) options = {};
|
|
3151
|
+
if (typeof options === "function") {
|
|
3152
|
+
fn = options;
|
|
3153
|
+
options = {};
|
|
3154
|
+
}
|
|
3155
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3156
|
+
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
3157
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
3158
|
+
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
3159
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
3160
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
3161
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
3162
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
3163
|
+
let argCount = -1;
|
|
3164
|
+
if (!varargs) {
|
|
3165
|
+
argCount = fn.length;
|
|
3166
|
+
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
3167
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
3168
|
+
}
|
|
3169
|
+
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
3170
|
+
return this;
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
|
|
3175
|
+
// node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
3176
|
+
var require_aggregate = __commonJS({
|
|
3177
|
+
"node_modules/better-sqlite3/lib/methods/aggregate.js"(exports2, module2) {
|
|
3178
|
+
"use strict";
|
|
3179
|
+
var { getBooleanOption, cppdb } = require_util2();
|
|
3180
|
+
module2.exports = function defineAggregate(name, options) {
|
|
3181
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3182
|
+
if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
|
|
3183
|
+
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
3184
|
+
const start = "start" in options ? options.start : null;
|
|
3185
|
+
const step = getFunctionOption(options, "step", true);
|
|
3186
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
3187
|
+
const result = getFunctionOption(options, "result", false);
|
|
3188
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
3189
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
3190
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
3191
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
3192
|
+
let argCount = -1;
|
|
3193
|
+
if (!varargs) {
|
|
3194
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
3195
|
+
if (argCount > 0) argCount -= 1;
|
|
3196
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
3197
|
+
}
|
|
3198
|
+
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
3199
|
+
return this;
|
|
3200
|
+
};
|
|
3201
|
+
var getFunctionOption = (options, key, required) => {
|
|
3202
|
+
const value = key in options ? options[key] : null;
|
|
3203
|
+
if (typeof value === "function") return value;
|
|
3204
|
+
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
3205
|
+
if (required) throw new TypeError(`Missing required option "${key}"`);
|
|
3206
|
+
return null;
|
|
3207
|
+
};
|
|
3208
|
+
var getLength = ({ length }) => {
|
|
3209
|
+
if (Number.isInteger(length) && length >= 0) return length;
|
|
3210
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
|
|
3215
|
+
// node_modules/better-sqlite3/lib/methods/table.js
|
|
3216
|
+
var require_table = __commonJS({
|
|
3217
|
+
"node_modules/better-sqlite3/lib/methods/table.js"(exports2, module2) {
|
|
3218
|
+
"use strict";
|
|
3219
|
+
var { cppdb } = require_util2();
|
|
3220
|
+
module2.exports = function defineTable(name, factory) {
|
|
3221
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3222
|
+
if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
|
|
3223
|
+
let eponymous = false;
|
|
3224
|
+
if (typeof factory === "object" && factory !== null) {
|
|
3225
|
+
eponymous = true;
|
|
3226
|
+
factory = defer(parseTableDefinition(factory, "used", name));
|
|
3227
|
+
} else {
|
|
3228
|
+
if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
3229
|
+
factory = wrapFactory(factory);
|
|
3230
|
+
}
|
|
3231
|
+
this[cppdb].table(factory, name, eponymous);
|
|
3232
|
+
return this;
|
|
3233
|
+
};
|
|
3234
|
+
function wrapFactory(factory) {
|
|
3235
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
3236
|
+
const thisObject = {
|
|
3237
|
+
module: moduleName,
|
|
3238
|
+
database: databaseName,
|
|
3239
|
+
table: tableName
|
|
3240
|
+
};
|
|
3241
|
+
const def = apply.call(factory, thisObject, args);
|
|
3242
|
+
if (typeof def !== "object" || def === null) {
|
|
3243
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
3519
3244
|
}
|
|
3245
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
3520
3246
|
};
|
|
3521
|
-
}
|
|
3247
|
+
}
|
|
3248
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
3249
|
+
if (!hasOwnProperty.call(def, "rows")) {
|
|
3250
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
3251
|
+
}
|
|
3252
|
+
if (!hasOwnProperty.call(def, "columns")) {
|
|
3253
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
3254
|
+
}
|
|
3255
|
+
const rows = def.rows;
|
|
3256
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
3257
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
3258
|
+
}
|
|
3259
|
+
let columns = def.columns;
|
|
3260
|
+
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
3261
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
3262
|
+
}
|
|
3263
|
+
if (columns.length !== new Set(columns).size) {
|
|
3264
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
3265
|
+
}
|
|
3266
|
+
if (!columns.length) {
|
|
3267
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
3268
|
+
}
|
|
3269
|
+
let parameters;
|
|
3270
|
+
if (hasOwnProperty.call(def, "parameters")) {
|
|
3271
|
+
parameters = def.parameters;
|
|
3272
|
+
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
3273
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
3274
|
+
}
|
|
3275
|
+
} else {
|
|
3276
|
+
parameters = inferParameters(rows);
|
|
3277
|
+
}
|
|
3278
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
3279
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
3280
|
+
}
|
|
3281
|
+
if (parameters.length > 32) {
|
|
3282
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
3283
|
+
}
|
|
3284
|
+
for (const parameter of parameters) {
|
|
3285
|
+
if (columns.includes(parameter)) {
|
|
3286
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
let safeIntegers = 2;
|
|
3290
|
+
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
3291
|
+
const bool = def.safeIntegers;
|
|
3292
|
+
if (typeof bool !== "boolean") {
|
|
3293
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
3294
|
+
}
|
|
3295
|
+
safeIntegers = +bool;
|
|
3296
|
+
}
|
|
3297
|
+
let directOnly = false;
|
|
3298
|
+
if (hasOwnProperty.call(def, "directOnly")) {
|
|
3299
|
+
directOnly = def.directOnly;
|
|
3300
|
+
if (typeof directOnly !== "boolean") {
|
|
3301
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
const columnDefinitions = [
|
|
3305
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
3306
|
+
...columns.map(identifier)
|
|
3307
|
+
];
|
|
3308
|
+
return [
|
|
3309
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
3310
|
+
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
3311
|
+
parameters,
|
|
3312
|
+
safeIntegers,
|
|
3313
|
+
directOnly
|
|
3314
|
+
];
|
|
3315
|
+
}
|
|
3316
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
3317
|
+
return function* virtualTable(...args) {
|
|
3318
|
+
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
3319
|
+
for (let i = 0; i < columnMap.size; ++i) {
|
|
3320
|
+
output.push(null);
|
|
3321
|
+
}
|
|
3322
|
+
for (const row of generator(...args)) {
|
|
3323
|
+
if (Array.isArray(row)) {
|
|
3324
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
3325
|
+
yield output;
|
|
3326
|
+
} else if (typeof row === "object" && row !== null) {
|
|
3327
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
3328
|
+
yield output;
|
|
3329
|
+
} else {
|
|
3330
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
3336
|
+
if (row.length !== columnCount) {
|
|
3337
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
3338
|
+
}
|
|
3339
|
+
const offset = output.length - columnCount;
|
|
3340
|
+
for (let i = 0; i < columnCount; ++i) {
|
|
3341
|
+
output[i + offset] = row[i];
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
3345
|
+
let count = 0;
|
|
3346
|
+
for (const key of Object.keys(row)) {
|
|
3347
|
+
const index = columnMap.get(key);
|
|
3348
|
+
if (index === void 0) {
|
|
3349
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
3350
|
+
}
|
|
3351
|
+
output[index] = row[key];
|
|
3352
|
+
count += 1;
|
|
3353
|
+
}
|
|
3354
|
+
if (count !== columnMap.size) {
|
|
3355
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
function inferParameters({ length }) {
|
|
3359
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
3360
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
3361
|
+
}
|
|
3362
|
+
const params = [];
|
|
3363
|
+
for (let i = 0; i < length; ++i) {
|
|
3364
|
+
params.push(`$${i + 1}`);
|
|
3365
|
+
}
|
|
3366
|
+
return params;
|
|
3367
|
+
}
|
|
3368
|
+
var { hasOwnProperty } = Object.prototype;
|
|
3369
|
+
var { apply } = Function.prototype;
|
|
3370
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
3371
|
+
});
|
|
3372
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
3373
|
+
var defer = (x) => () => x;
|
|
3522
3374
|
}
|
|
3523
3375
|
});
|
|
3524
3376
|
|
|
3525
|
-
//
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3377
|
+
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
3378
|
+
var require_inspect = __commonJS({
|
|
3379
|
+
"node_modules/better-sqlite3/lib/methods/inspect.js"(exports2, module2) {
|
|
3380
|
+
"use strict";
|
|
3381
|
+
var DatabaseInspection = function Database() {
|
|
3382
|
+
};
|
|
3383
|
+
module2.exports = function inspect(depth, opts) {
|
|
3384
|
+
return Object.assign(new DatabaseInspection(), this);
|
|
3385
|
+
};
|
|
3386
|
+
}
|
|
3387
|
+
});
|
|
3530
3388
|
|
|
3531
|
-
// node_modules
|
|
3532
|
-
|
|
3389
|
+
// node_modules/better-sqlite3/lib/database.js
|
|
3390
|
+
var require_database = __commonJS({
|
|
3391
|
+
"node_modules/better-sqlite3/lib/database.js"(exports2, module2) {
|
|
3392
|
+
"use strict";
|
|
3393
|
+
var fs = require("fs");
|
|
3394
|
+
var path = require("path");
|
|
3395
|
+
var util2 = require_util2();
|
|
3396
|
+
var SqliteError = require_sqlite_error();
|
|
3397
|
+
var DEFAULT_ADDON;
|
|
3398
|
+
function Database(filenameGiven, options) {
|
|
3399
|
+
if (new.target == null) {
|
|
3400
|
+
return new Database(filenameGiven, options);
|
|
3401
|
+
}
|
|
3402
|
+
let buffer;
|
|
3403
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
3404
|
+
buffer = filenameGiven;
|
|
3405
|
+
filenameGiven = ":memory:";
|
|
3406
|
+
}
|
|
3407
|
+
if (filenameGiven == null) filenameGiven = "";
|
|
3408
|
+
if (options == null) options = {};
|
|
3409
|
+
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
3410
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
3411
|
+
if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
3412
|
+
if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
3413
|
+
const filename = filenameGiven.trim();
|
|
3414
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
3415
|
+
const readonly = util2.getBooleanOption(options, "readonly");
|
|
3416
|
+
const fileMustExist = util2.getBooleanOption(options, "fileMustExist");
|
|
3417
|
+
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
3418
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
3419
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
3420
|
+
if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
3421
|
+
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
3422
|
+
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
3423
|
+
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
3424
|
+
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
3425
|
+
let addon;
|
|
3426
|
+
if (nativeBinding == null) {
|
|
3427
|
+
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
3428
|
+
} else if (typeof nativeBinding === "string") {
|
|
3429
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
3430
|
+
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
3431
|
+
} else {
|
|
3432
|
+
addon = nativeBinding;
|
|
3433
|
+
}
|
|
3434
|
+
if (!addon.isInitialized) {
|
|
3435
|
+
addon.setErrorConstructor(SqliteError);
|
|
3436
|
+
addon.isInitialized = true;
|
|
3437
|
+
}
|
|
3438
|
+
if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
|
|
3439
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
3440
|
+
}
|
|
3441
|
+
Object.defineProperties(this, {
|
|
3442
|
+
[util2.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
3443
|
+
...wrappers.getters
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
var wrappers = require_wrappers();
|
|
3447
|
+
Database.prototype.prepare = wrappers.prepare;
|
|
3448
|
+
Database.prototype.transaction = require_transaction();
|
|
3449
|
+
Database.prototype.pragma = require_pragma();
|
|
3450
|
+
Database.prototype.backup = require_backup();
|
|
3451
|
+
Database.prototype.serialize = require_serialize();
|
|
3452
|
+
Database.prototype.function = require_function();
|
|
3453
|
+
Database.prototype.aggregate = require_aggregate();
|
|
3454
|
+
Database.prototype.table = require_table();
|
|
3455
|
+
Database.prototype.loadExtension = wrappers.loadExtension;
|
|
3456
|
+
Database.prototype.exec = wrappers.exec;
|
|
3457
|
+
Database.prototype.close = wrappers.close;
|
|
3458
|
+
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
3459
|
+
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
|
3460
|
+
Database.prototype[util2.inspect] = require_inspect();
|
|
3461
|
+
module2.exports = Database;
|
|
3462
|
+
}
|
|
3463
|
+
});
|
|
3533
3464
|
|
|
3534
|
-
// node_modules
|
|
3535
|
-
|
|
3465
|
+
// node_modules/better-sqlite3/lib/index.js
|
|
3466
|
+
var require_lib = __commonJS({
|
|
3467
|
+
"node_modules/better-sqlite3/lib/index.js"(exports2, module2) {
|
|
3468
|
+
"use strict";
|
|
3469
|
+
module2.exports = require_database();
|
|
3470
|
+
module2.exports.SqliteError = require_sqlite_error();
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3536
3473
|
|
|
3537
3474
|
// node_modules/zod/lib/index.mjs
|
|
3538
|
-
init_esm_shims();
|
|
3539
3475
|
var util;
|
|
3540
3476
|
(function(util2) {
|
|
3541
3477
|
util2.assertEqual = (val) => val;
|
|
@@ -8716,11 +8652,9 @@ var Server = class extends Protocol {
|
|
|
8716
8652
|
};
|
|
8717
8653
|
|
|
8718
8654
|
// node_modules/@modelcontextprotocol/sdk/dist/server/stdio.js
|
|
8719
|
-
|
|
8720
|
-
import process2 from "node:process";
|
|
8655
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
8721
8656
|
|
|
8722
8657
|
// node_modules/@modelcontextprotocol/sdk/dist/shared/stdio.js
|
|
8723
|
-
init_esm_shims();
|
|
8724
8658
|
var ReadBuffer = class {
|
|
8725
8659
|
append(chunk) {
|
|
8726
8660
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
@@ -8750,7 +8684,7 @@ function serializeMessage(message) {
|
|
|
8750
8684
|
|
|
8751
8685
|
// node_modules/@modelcontextprotocol/sdk/dist/server/stdio.js
|
|
8752
8686
|
var StdioServerTransport = class {
|
|
8753
|
-
constructor(_stdin =
|
|
8687
|
+
constructor(_stdin = import_node_process.default.stdin, _stdout = import_node_process.default.stdout) {
|
|
8754
8688
|
this._stdin = _stdin;
|
|
8755
8689
|
this._stdout = _stdout;
|
|
8756
8690
|
this._readBuffer = new ReadBuffer();
|
|
@@ -8808,14 +8742,7 @@ var StdioServerTransport = class {
|
|
|
8808
8742
|
}
|
|
8809
8743
|
};
|
|
8810
8744
|
|
|
8811
|
-
// src/tools/list-sessions.ts
|
|
8812
|
-
init_esm_shims();
|
|
8813
|
-
|
|
8814
|
-
// node_modules/cursor-history/dist/lib/index.js
|
|
8815
|
-
init_esm_shims();
|
|
8816
|
-
|
|
8817
8745
|
// node_modules/cursor-history/dist/lib/errors.js
|
|
8818
|
-
init_esm_shims();
|
|
8819
8746
|
var DatabaseLockedError = class _DatabaseLockedError extends Error {
|
|
8820
8747
|
name = "DatabaseLockedError";
|
|
8821
8748
|
/** Path to locked database file */
|
|
@@ -8961,13 +8888,9 @@ function isInvalidBackupError(error) {
|
|
|
8961
8888
|
return error instanceof InvalidBackupError;
|
|
8962
8889
|
}
|
|
8963
8890
|
|
|
8964
|
-
// node_modules/cursor-history/dist/lib/utils.js
|
|
8965
|
-
init_esm_shims();
|
|
8966
|
-
|
|
8967
8891
|
// node_modules/cursor-history/dist/lib/platform.js
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
import { join } from "node:path";
|
|
8892
|
+
var import_node_os = require("os");
|
|
8893
|
+
var import_node_path = require("path");
|
|
8971
8894
|
function detectPlatform() {
|
|
8972
8895
|
switch (process.platform) {
|
|
8973
8896
|
case "win32":
|
|
@@ -8982,11 +8905,11 @@ function getDefaultCursorDataPath(platform) {
|
|
|
8982
8905
|
const p = platform ?? detectPlatform();
|
|
8983
8906
|
switch (p) {
|
|
8984
8907
|
case "windows":
|
|
8985
|
-
return join(process.env["APPDATA"] ?? join(homedir(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
8908
|
+
return (0, import_node_path.join)(process.env["APPDATA"] ?? (0, import_node_path.join)((0, import_node_os.homedir)(), "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
8986
8909
|
case "macos":
|
|
8987
|
-
return join(homedir(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
8910
|
+
return (0, import_node_path.join)((0, import_node_os.homedir)(), "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
8988
8911
|
case "linux":
|
|
8989
|
-
return join(homedir(), ".config", "Cursor", "User", "workspaceStorage");
|
|
8912
|
+
return (0, import_node_path.join)((0, import_node_os.homedir)(), ".config", "Cursor", "User", "workspaceStorage");
|
|
8990
8913
|
}
|
|
8991
8914
|
}
|
|
8992
8915
|
function getCursorDataPath(customPath) {
|
|
@@ -9001,12 +8924,12 @@ function getCursorDataPath(customPath) {
|
|
|
9001
8924
|
}
|
|
9002
8925
|
function expandPath(path) {
|
|
9003
8926
|
if (path.startsWith("~")) {
|
|
9004
|
-
return join(homedir(), path.slice(1));
|
|
8927
|
+
return (0, import_node_path.join)((0, import_node_os.homedir)(), path.slice(1));
|
|
9005
8928
|
}
|
|
9006
8929
|
return path;
|
|
9007
8930
|
}
|
|
9008
8931
|
function contractPath(path) {
|
|
9009
|
-
const home = homedir();
|
|
8932
|
+
const home = (0, import_node_os.homedir)();
|
|
9010
8933
|
if (path.startsWith(home)) {
|
|
9011
8934
|
return "~" + path.slice(home.length);
|
|
9012
8935
|
}
|
|
@@ -9015,7 +8938,7 @@ function contractPath(path) {
|
|
|
9015
8938
|
function normalizePath(filePath) {
|
|
9016
8939
|
let normalized = filePath;
|
|
9017
8940
|
if (normalized.startsWith("~")) {
|
|
9018
|
-
normalized = join(homedir(), normalized.slice(1));
|
|
8941
|
+
normalized = (0, import_node_path.join)((0, import_node_os.homedir)(), normalized.slice(1));
|
|
9019
8942
|
}
|
|
9020
8943
|
while (normalized.length > 1 && normalized.endsWith("/")) {
|
|
9021
8944
|
normalized = normalized.slice(0, -1);
|
|
@@ -9035,8 +8958,9 @@ function pathsEqual(path1, path2) {
|
|
|
9035
8958
|
}
|
|
9036
8959
|
|
|
9037
8960
|
// node_modules/cursor-history/dist/lib/config.js
|
|
9038
|
-
|
|
9039
|
-
|
|
8961
|
+
var import_node_fs = require("fs");
|
|
8962
|
+
var import_node_path2 = require("path");
|
|
8963
|
+
var VALID_SQLITE_DRIVERS = ["better-sqlite3", "node:sqlite"];
|
|
9040
8964
|
function validateConfig(config) {
|
|
9041
8965
|
if (!config)
|
|
9042
8966
|
return;
|
|
@@ -9059,13 +8983,18 @@ function validateConfig(config) {
|
|
|
9059
8983
|
if (typeof config.workspace !== "string") {
|
|
9060
8984
|
throw new InvalidConfigError("workspace", config.workspace, "must be a string");
|
|
9061
8985
|
}
|
|
9062
|
-
if (!isAbsolute(config.workspace)) {
|
|
8986
|
+
if (!(0, import_node_path2.isAbsolute)(config.workspace)) {
|
|
9063
8987
|
throw new InvalidConfigError("workspace", config.workspace, "must be an absolute path");
|
|
9064
8988
|
}
|
|
9065
8989
|
}
|
|
9066
8990
|
if (config.dataPath !== void 0 && typeof config.dataPath !== "string") {
|
|
9067
8991
|
throw new InvalidConfigError("dataPath", config.dataPath, "must be a string");
|
|
9068
8992
|
}
|
|
8993
|
+
if (config.sqliteDriver !== void 0) {
|
|
8994
|
+
if (!VALID_SQLITE_DRIVERS.includes(config.sqliteDriver)) {
|
|
8995
|
+
throw new InvalidConfigError("sqliteDriver", config.sqliteDriver, `must be one of: ${VALID_SQLITE_DRIVERS.join(", ")}`);
|
|
8996
|
+
}
|
|
8997
|
+
}
|
|
9069
8998
|
}
|
|
9070
8999
|
function mergeWithDefaults(config) {
|
|
9071
9000
|
validateConfig(config);
|
|
@@ -9076,20 +9005,387 @@ function mergeWithDefaults(config) {
|
|
|
9076
9005
|
limit: config?.limit ?? Number.MAX_SAFE_INTEGER,
|
|
9077
9006
|
offset: config?.offset ?? 0,
|
|
9078
9007
|
context: config?.context ?? 0,
|
|
9079
|
-
backupPath: config?.backupPath
|
|
9008
|
+
backupPath: config?.backupPath,
|
|
9009
|
+
sqliteDriver: config?.sqliteDriver
|
|
9080
9010
|
};
|
|
9081
9011
|
}
|
|
9082
9012
|
|
|
9083
9013
|
// node_modules/cursor-history/dist/core/storage.js
|
|
9084
|
-
|
|
9085
|
-
var
|
|
9014
|
+
var import_node_fs3 = require("fs");
|
|
9015
|
+
var import_node_path4 = require("path");
|
|
9016
|
+
var import_node_os3 = require("os");
|
|
9086
9017
|
var import_adm_zip2 = __toESM(require_adm_zip(), 1);
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9018
|
+
|
|
9019
|
+
// node_modules/cursor-history/dist/core/database/errors.js
|
|
9020
|
+
var NoDriverAvailableError = class extends Error {
|
|
9021
|
+
constructor() {
|
|
9022
|
+
super("No SQLite driver available. Either install better-sqlite3 (npm install better-sqlite3) or use Node.js 22.5+ with --experimental-sqlite flag.");
|
|
9023
|
+
this.name = "NoDriverAvailableError";
|
|
9024
|
+
}
|
|
9025
|
+
};
|
|
9026
|
+
var DriverNotAvailableError = class extends Error {
|
|
9027
|
+
constructor(driverName, availableDrivers) {
|
|
9028
|
+
const available = availableDrivers.length > 0 ? `Available drivers: ${availableDrivers.join(", ")}` : "No drivers are currently available.";
|
|
9029
|
+
super(`Driver "${driverName}" is not available. ${available}`);
|
|
9030
|
+
this.name = "DriverNotAvailableError";
|
|
9031
|
+
}
|
|
9032
|
+
};
|
|
9033
|
+
var ReadonlyDatabaseError = class extends Error {
|
|
9034
|
+
constructor() {
|
|
9035
|
+
super("Cannot write to a read-only database connection.");
|
|
9036
|
+
this.name = "ReadonlyDatabaseError";
|
|
9037
|
+
}
|
|
9038
|
+
};
|
|
9039
|
+
|
|
9040
|
+
// node_modules/cursor-history/dist/core/database/debug.js
|
|
9041
|
+
function debugLog(message) {
|
|
9042
|
+
if (process.env["DEBUG"] || process.env["CURSOR_HISTORY_DEBUG"]) {
|
|
9043
|
+
console.error(`[cursor-history:sqlite] ${message}`);
|
|
9044
|
+
}
|
|
9045
|
+
}
|
|
9046
|
+
|
|
9047
|
+
// node_modules/cursor-history/dist/core/database/registry.js
|
|
9048
|
+
var DriverRegistry = class {
|
|
9049
|
+
drivers = /* @__PURE__ */ new Map();
|
|
9050
|
+
currentDriver = null;
|
|
9051
|
+
initialized = false;
|
|
9052
|
+
/**
|
|
9053
|
+
* Register a driver with the registry
|
|
9054
|
+
*/
|
|
9055
|
+
register(driver) {
|
|
9056
|
+
this.drivers.set(driver.name, driver);
|
|
9057
|
+
debugLog(`Registered driver: ${driver.name}`);
|
|
9058
|
+
}
|
|
9059
|
+
/**
|
|
9060
|
+
* Get all registered driver names
|
|
9061
|
+
*/
|
|
9062
|
+
getRegisteredDrivers() {
|
|
9063
|
+
return Array.from(this.drivers.keys());
|
|
9064
|
+
}
|
|
9065
|
+
/**
|
|
9066
|
+
* Check which drivers are currently available
|
|
9067
|
+
*/
|
|
9068
|
+
async getAvailableDrivers() {
|
|
9069
|
+
const available = [];
|
|
9070
|
+
for (const [name, driver] of this.drivers) {
|
|
9071
|
+
if (await driver.isAvailable()) {
|
|
9072
|
+
available.push(name);
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9075
|
+
return available;
|
|
9076
|
+
}
|
|
9077
|
+
/**
|
|
9078
|
+
* Auto-detect and select the best available driver
|
|
9079
|
+
*
|
|
9080
|
+
* Priority:
|
|
9081
|
+
* 1. User-specified via CURSOR_HISTORY_SQLITE_DRIVER env var
|
|
9082
|
+
* 2. node:sqlite (no native bindings, ESM compatible)
|
|
9083
|
+
* 3. better-sqlite3 (fallback)
|
|
9084
|
+
*/
|
|
9085
|
+
async autoSelect() {
|
|
9086
|
+
const envDriver = process.env["CURSOR_HISTORY_SQLITE_DRIVER"];
|
|
9087
|
+
if (envDriver) {
|
|
9088
|
+
debugLog(`Environment override: CURSOR_HISTORY_SQLITE_DRIVER=${envDriver}`);
|
|
9089
|
+
const driver = this.drivers.get(envDriver);
|
|
9090
|
+
if (driver && await driver.isAvailable()) {
|
|
9091
|
+
this.currentDriver = driver;
|
|
9092
|
+
this.initialized = true;
|
|
9093
|
+
debugLog(`Using driver from env var: ${driver.name}`);
|
|
9094
|
+
return driver;
|
|
9095
|
+
}
|
|
9096
|
+
const available = await this.getAvailableDrivers();
|
|
9097
|
+
throw new DriverNotAvailableError(envDriver, available);
|
|
9098
|
+
}
|
|
9099
|
+
const nodeSqlite = this.drivers.get("node:sqlite");
|
|
9100
|
+
if (nodeSqlite && await nodeSqlite.isAvailable()) {
|
|
9101
|
+
this.currentDriver = nodeSqlite;
|
|
9102
|
+
this.initialized = true;
|
|
9103
|
+
debugLog(`Auto-selected driver: node:sqlite`);
|
|
9104
|
+
return nodeSqlite;
|
|
9105
|
+
}
|
|
9106
|
+
const betterSqlite = this.drivers.get("better-sqlite3");
|
|
9107
|
+
if (betterSqlite && await betterSqlite.isAvailable()) {
|
|
9108
|
+
this.currentDriver = betterSqlite;
|
|
9109
|
+
this.initialized = true;
|
|
9110
|
+
debugLog(`Auto-selected driver: better-sqlite3`);
|
|
9111
|
+
return betterSqlite;
|
|
9112
|
+
}
|
|
9113
|
+
throw new NoDriverAvailableError();
|
|
9114
|
+
}
|
|
9115
|
+
/**
|
|
9116
|
+
* Manually set the active driver by name
|
|
9117
|
+
*/
|
|
9118
|
+
async setDriver(name) {
|
|
9119
|
+
const driver = this.drivers.get(name);
|
|
9120
|
+
if (!driver) {
|
|
9121
|
+
const available = await this.getAvailableDrivers();
|
|
9122
|
+
throw new DriverNotAvailableError(name, available);
|
|
9123
|
+
}
|
|
9124
|
+
if (!await driver.isAvailable()) {
|
|
9125
|
+
const available = await this.getAvailableDrivers();
|
|
9126
|
+
throw new DriverNotAvailableError(name, available);
|
|
9127
|
+
}
|
|
9128
|
+
this.currentDriver = driver;
|
|
9129
|
+
this.initialized = true;
|
|
9130
|
+
debugLog(`Manually set driver: ${name}`);
|
|
9131
|
+
}
|
|
9132
|
+
/**
|
|
9133
|
+
* Get the name of the currently active driver
|
|
9134
|
+
*/
|
|
9135
|
+
getActiveDriver() {
|
|
9136
|
+
if (!this.currentDriver) {
|
|
9137
|
+
throw new Error("No driver is currently active. Call autoSelect() or setDriver() first.");
|
|
9138
|
+
}
|
|
9139
|
+
return this.currentDriver.name;
|
|
9140
|
+
}
|
|
9141
|
+
/**
|
|
9142
|
+
* Check if a driver has been selected
|
|
9143
|
+
*/
|
|
9144
|
+
hasActiveDriver() {
|
|
9145
|
+
return this.currentDriver !== null;
|
|
9146
|
+
}
|
|
9147
|
+
/**
|
|
9148
|
+
* Get the current driver, auto-selecting if needed
|
|
9149
|
+
*/
|
|
9150
|
+
async ensureDriver() {
|
|
9151
|
+
if (!this.initialized || !this.currentDriver) {
|
|
9152
|
+
return this.autoSelect();
|
|
9153
|
+
}
|
|
9154
|
+
return this.currentDriver;
|
|
9155
|
+
}
|
|
9156
|
+
/**
|
|
9157
|
+
* Open a database in read-only mode
|
|
9158
|
+
*/
|
|
9159
|
+
async openDatabase(path) {
|
|
9160
|
+
const driver = await this.ensureDriver();
|
|
9161
|
+
return driver.open(path, { readonly: true });
|
|
9162
|
+
}
|
|
9163
|
+
/**
|
|
9164
|
+
* Open a database in read-write mode
|
|
9165
|
+
*/
|
|
9166
|
+
async openDatabaseReadWrite(path) {
|
|
9167
|
+
const driver = await this.ensureDriver();
|
|
9168
|
+
return driver.open(path, { readonly: false });
|
|
9169
|
+
}
|
|
9170
|
+
/**
|
|
9171
|
+
* Synchronous database open (requires driver to already be selected)
|
|
9172
|
+
*
|
|
9173
|
+
* This is used by backup module which needs synchronous access.
|
|
9174
|
+
* Auto-selection must have happened before calling this.
|
|
9175
|
+
*/
|
|
9176
|
+
openSync(path, options) {
|
|
9177
|
+
if (!this.currentDriver) {
|
|
9178
|
+
throw new Error("No driver is currently active. Auto-selection must complete before using openSync(). Call a database operation first to trigger auto-selection.");
|
|
9179
|
+
}
|
|
9180
|
+
return this.currentDriver.open(path, options);
|
|
9181
|
+
}
|
|
9182
|
+
/**
|
|
9183
|
+
* Backup a database file to another location
|
|
9184
|
+
*
|
|
9185
|
+
* Uses the native SQLite backup API for consistent snapshots.
|
|
9186
|
+
*/
|
|
9187
|
+
async backupDatabase(sourcePath, destPath) {
|
|
9188
|
+
const driver = await this.ensureDriver();
|
|
9189
|
+
return driver.backup(sourcePath, destPath);
|
|
9190
|
+
}
|
|
9191
|
+
/**
|
|
9192
|
+
* Reset the registry (mainly for testing)
|
|
9193
|
+
*/
|
|
9194
|
+
reset() {
|
|
9195
|
+
this.currentDriver = null;
|
|
9196
|
+
this.initialized = false;
|
|
9197
|
+
debugLog("Registry reset");
|
|
9198
|
+
}
|
|
9199
|
+
};
|
|
9200
|
+
var registry = new DriverRegistry();
|
|
9201
|
+
|
|
9202
|
+
// node_modules/cursor-history/dist/core/database/drivers/better-sqlite3.js
|
|
9203
|
+
var BetterSqlite3 = null;
|
|
9204
|
+
var BetterSqlite3Statement = class {
|
|
9205
|
+
stmt;
|
|
9206
|
+
constructor(stmt) {
|
|
9207
|
+
this.stmt = stmt;
|
|
9208
|
+
}
|
|
9209
|
+
get(...params) {
|
|
9210
|
+
return this.stmt.get(...params);
|
|
9211
|
+
}
|
|
9212
|
+
all(...params) {
|
|
9213
|
+
return this.stmt.all(...params);
|
|
9214
|
+
}
|
|
9215
|
+
run(...params) {
|
|
9216
|
+
const result = this.stmt.run(...params);
|
|
9217
|
+
return {
|
|
9218
|
+
changes: result.changes,
|
|
9219
|
+
lastInsertRowid: result.lastInsertRowid
|
|
9220
|
+
};
|
|
9221
|
+
}
|
|
9222
|
+
};
|
|
9223
|
+
var BetterSqlite3Database = class {
|
|
9224
|
+
nativeDb;
|
|
9225
|
+
constructor(db) {
|
|
9226
|
+
this.nativeDb = db;
|
|
9227
|
+
}
|
|
9228
|
+
prepare(sql) {
|
|
9229
|
+
return new BetterSqlite3Statement(this.nativeDb.prepare(sql));
|
|
9230
|
+
}
|
|
9231
|
+
runSQL(sql) {
|
|
9232
|
+
this.nativeDb.exec(sql);
|
|
9233
|
+
}
|
|
9234
|
+
close() {
|
|
9235
|
+
this.nativeDb.close();
|
|
9236
|
+
}
|
|
9237
|
+
};
|
|
9238
|
+
var betterSqlite3Driver = {
|
|
9239
|
+
name: "better-sqlite3",
|
|
9240
|
+
async isAvailable() {
|
|
9241
|
+
try {
|
|
9242
|
+
if (!BetterSqlite3) {
|
|
9243
|
+
const module2 = await Promise.resolve().then(() => __toESM(require_lib(), 1));
|
|
9244
|
+
BetterSqlite3 = module2.default;
|
|
9245
|
+
}
|
|
9246
|
+
debugLog("better-sqlite3 is available");
|
|
9247
|
+
return true;
|
|
9248
|
+
} catch {
|
|
9249
|
+
debugLog("better-sqlite3 is not available");
|
|
9250
|
+
return false;
|
|
9251
|
+
}
|
|
9252
|
+
},
|
|
9253
|
+
open(path, options) {
|
|
9254
|
+
if (!BetterSqlite3) {
|
|
9255
|
+
throw new Error("better-sqlite3 is not loaded. Call isAvailable() first.");
|
|
9256
|
+
}
|
|
9257
|
+
const db = new BetterSqlite3(path, { readonly: options.readonly });
|
|
9258
|
+
debugLog(`Opened database with better-sqlite3: ${path} (readonly: ${options.readonly})`);
|
|
9259
|
+
return new BetterSqlite3Database(db);
|
|
9260
|
+
},
|
|
9261
|
+
async backup(sourcePath, destPath) {
|
|
9262
|
+
if (!BetterSqlite3) {
|
|
9263
|
+
throw new Error("better-sqlite3 is not loaded. Call isAvailable() first.");
|
|
9264
|
+
}
|
|
9265
|
+
const sourceDb = new BetterSqlite3(sourcePath, { readonly: true });
|
|
9266
|
+
try {
|
|
9267
|
+
debugLog(`Backing up database with better-sqlite3: ${sourcePath} -> ${destPath}`);
|
|
9268
|
+
await sourceDb.backup(destPath);
|
|
9269
|
+
debugLog(`Backup completed: ${destPath}`);
|
|
9270
|
+
} finally {
|
|
9271
|
+
sourceDb.close();
|
|
9272
|
+
}
|
|
9273
|
+
}
|
|
9274
|
+
};
|
|
9275
|
+
|
|
9276
|
+
// node_modules/cursor-history/dist/core/database/drivers/node-sqlite.js
|
|
9277
|
+
var nodeSqliteModule = null;
|
|
9278
|
+
var NodeSqliteStatementWrapper = class {
|
|
9279
|
+
stmt;
|
|
9280
|
+
isReadonly;
|
|
9281
|
+
constructor(stmt, isReadonly) {
|
|
9282
|
+
this.stmt = stmt;
|
|
9283
|
+
this.isReadonly = isReadonly;
|
|
9284
|
+
}
|
|
9285
|
+
get(...params) {
|
|
9286
|
+
return this.stmt.get(...params);
|
|
9287
|
+
}
|
|
9288
|
+
all(...params) {
|
|
9289
|
+
return this.stmt.all(...params);
|
|
9290
|
+
}
|
|
9291
|
+
run(...params) {
|
|
9292
|
+
if (this.isReadonly) {
|
|
9293
|
+
throw new ReadonlyDatabaseError();
|
|
9294
|
+
}
|
|
9295
|
+
const result = this.stmt.run(...params);
|
|
9296
|
+
return {
|
|
9297
|
+
changes: Number(result.changes),
|
|
9298
|
+
lastInsertRowid: result.lastInsertRowid
|
|
9299
|
+
};
|
|
9300
|
+
}
|
|
9301
|
+
};
|
|
9302
|
+
var NodeSqliteDatabaseWrapper = class {
|
|
9303
|
+
nativeDb;
|
|
9304
|
+
isReadonly;
|
|
9305
|
+
constructor(db, readonly) {
|
|
9306
|
+
this.nativeDb = db;
|
|
9307
|
+
this.isReadonly = readonly;
|
|
9308
|
+
}
|
|
9309
|
+
prepare(sql) {
|
|
9310
|
+
if (this.isReadonly) {
|
|
9311
|
+
const upperSql = sql.trim().toUpperCase();
|
|
9312
|
+
if (upperSql.startsWith("INSERT") || upperSql.startsWith("UPDATE") || upperSql.startsWith("DELETE") || upperSql.startsWith("DROP") || upperSql.startsWith("CREATE") || upperSql.startsWith("ALTER")) {
|
|
9313
|
+
throw new ReadonlyDatabaseError();
|
|
9314
|
+
}
|
|
9315
|
+
}
|
|
9316
|
+
return new NodeSqliteStatementWrapper(this.nativeDb.prepare(sql), this.isReadonly);
|
|
9317
|
+
}
|
|
9318
|
+
runSQL(sql) {
|
|
9319
|
+
if (this.isReadonly) {
|
|
9320
|
+
throw new ReadonlyDatabaseError();
|
|
9321
|
+
}
|
|
9322
|
+
const nativeMethod = "exec";
|
|
9323
|
+
const db = this.nativeDb;
|
|
9324
|
+
if (typeof db[nativeMethod] === "function") {
|
|
9325
|
+
db[nativeMethod](sql);
|
|
9326
|
+
} else {
|
|
9327
|
+
this.nativeDb.prepare(sql).run();
|
|
9328
|
+
}
|
|
9329
|
+
}
|
|
9330
|
+
close() {
|
|
9331
|
+
this.nativeDb.close();
|
|
9332
|
+
}
|
|
9333
|
+
};
|
|
9334
|
+
var nodeSqliteDriver = {
|
|
9335
|
+
name: "node:sqlite",
|
|
9336
|
+
async isAvailable() {
|
|
9337
|
+
try {
|
|
9338
|
+
if (!nodeSqliteModule) {
|
|
9339
|
+
const module2 = await import("sqlite");
|
|
9340
|
+
nodeSqliteModule = module2;
|
|
9341
|
+
}
|
|
9342
|
+
debugLog("node:sqlite is available");
|
|
9343
|
+
return true;
|
|
9344
|
+
} catch {
|
|
9345
|
+
debugLog("node:sqlite is not available");
|
|
9346
|
+
return false;
|
|
9347
|
+
}
|
|
9348
|
+
},
|
|
9349
|
+
open(path, options) {
|
|
9350
|
+
if (!nodeSqliteModule) {
|
|
9351
|
+
throw new Error("node:sqlite is not loaded. Call isAvailable() first.");
|
|
9352
|
+
}
|
|
9353
|
+
const db = new nodeSqliteModule.DatabaseSync(path);
|
|
9354
|
+
debugLog(`Opened database with node:sqlite: ${path} (readonly: ${options.readonly})`);
|
|
9355
|
+
return new NodeSqliteDatabaseWrapper(db, options.readonly);
|
|
9356
|
+
},
|
|
9357
|
+
async backup(sourcePath, destPath) {
|
|
9358
|
+
if (!nodeSqliteModule) {
|
|
9359
|
+
throw new Error("node:sqlite is not loaded. Call isAvailable() first.");
|
|
9360
|
+
}
|
|
9361
|
+
const sourceDb = new nodeSqliteModule.DatabaseSync(sourcePath);
|
|
9362
|
+
try {
|
|
9363
|
+
debugLog(`Backing up database with node:sqlite: ${sourcePath} -> ${destPath}`);
|
|
9364
|
+
await nodeSqliteModule.backup(sourceDb, destPath);
|
|
9365
|
+
debugLog(`Backup completed: ${destPath}`);
|
|
9366
|
+
} finally {
|
|
9367
|
+
sourceDb.close();
|
|
9368
|
+
}
|
|
9369
|
+
}
|
|
9370
|
+
};
|
|
9371
|
+
|
|
9372
|
+
// node_modules/cursor-history/dist/core/database/index.js
|
|
9373
|
+
registry.register(nodeSqliteDriver);
|
|
9374
|
+
registry.register(betterSqlite3Driver);
|
|
9375
|
+
async function openDatabase(path) {
|
|
9376
|
+
return registry.openDatabase(path);
|
|
9377
|
+
}
|
|
9378
|
+
async function openDatabaseReadWrite(path) {
|
|
9379
|
+
return registry.openDatabaseReadWrite(path);
|
|
9380
|
+
}
|
|
9381
|
+
async function ensureDriver() {
|
|
9382
|
+
await registry.ensureDriver();
|
|
9383
|
+
}
|
|
9384
|
+
async function backupDatabase(sourcePath, destPath) {
|
|
9385
|
+
return registry.backupDatabase(sourcePath, destPath);
|
|
9386
|
+
}
|
|
9090
9387
|
|
|
9091
9388
|
// node_modules/cursor-history/dist/core/parser.js
|
|
9092
|
-
init_esm_shims();
|
|
9093
9389
|
function parseChatData(jsonString, bundle) {
|
|
9094
9390
|
let data;
|
|
9095
9391
|
try {
|
|
@@ -9327,20 +9623,18 @@ function exportToJson(session, workspacePath) {
|
|
|
9327
9623
|
}
|
|
9328
9624
|
|
|
9329
9625
|
// node_modules/cursor-history/dist/core/backup.js
|
|
9330
|
-
|
|
9331
|
-
var
|
|
9626
|
+
var import_node_crypto = require("crypto");
|
|
9627
|
+
var import_node_fs2 = require("fs");
|
|
9628
|
+
var import_node_os2 = require("os");
|
|
9629
|
+
var import_node_path3 = require("path");
|
|
9332
9630
|
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
9333
|
-
|
|
9334
|
-
import { existsSync, mkdirSync, readdirSync, statSync, unlinkSync, readFileSync, writeFileSync, rmdirSync } from "node:fs";
|
|
9335
|
-
import { homedir as homedir2, tmpdir } from "node:os";
|
|
9336
|
-
import { join as join2, basename, dirname, sep } from "node:path";
|
|
9337
|
-
var CURSOR_HISTORY_VERSION = "0.8.0";
|
|
9631
|
+
var CURSOR_HISTORY_VERSION = "0.9.1";
|
|
9338
9632
|
var MANIFEST_VERSION = "1.0.0";
|
|
9339
9633
|
function getDefaultBackupDir() {
|
|
9340
|
-
return
|
|
9634
|
+
return (0, import_node_path3.join)((0, import_node_os2.homedir)(), "cursor-history-backups");
|
|
9341
9635
|
}
|
|
9342
9636
|
function computeChecksum(buffer) {
|
|
9343
|
-
return `sha256:${createHash("sha256").update(buffer).digest("hex")}`;
|
|
9637
|
+
return `sha256:${(0, import_node_crypto.createHash)("sha256").update(buffer).digest("hex")}`;
|
|
9344
9638
|
}
|
|
9345
9639
|
function generateBackupFilename() {
|
|
9346
9640
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -9354,10 +9648,10 @@ function generateBackupFilename() {
|
|
|
9354
9648
|
}
|
|
9355
9649
|
function scanDatabaseFiles(dataPath) {
|
|
9356
9650
|
const files = [];
|
|
9357
|
-
const userDir = dirname(dataPath);
|
|
9358
|
-
const globalDbPath =
|
|
9359
|
-
if (existsSync(globalDbPath)) {
|
|
9360
|
-
const stat = statSync(globalDbPath);
|
|
9651
|
+
const userDir = (0, import_node_path3.dirname)(dataPath);
|
|
9652
|
+
const globalDbPath = (0, import_node_path3.join)(userDir, "globalStorage", "state.vscdb");
|
|
9653
|
+
if ((0, import_node_fs2.existsSync)(globalDbPath)) {
|
|
9654
|
+
const stat = (0, import_node_fs2.statSync)(globalDbPath);
|
|
9361
9655
|
files.push({
|
|
9362
9656
|
absolutePath: globalDbPath,
|
|
9363
9657
|
relativePath: "globalStorage/state.vscdb",
|
|
@@ -9366,15 +9660,15 @@ function scanDatabaseFiles(dataPath) {
|
|
|
9366
9660
|
});
|
|
9367
9661
|
}
|
|
9368
9662
|
const workspaceStorageDir = dataPath;
|
|
9369
|
-
if (existsSync(workspaceStorageDir)) {
|
|
9663
|
+
if ((0, import_node_fs2.existsSync)(workspaceStorageDir)) {
|
|
9370
9664
|
try {
|
|
9371
|
-
const entries = readdirSync(workspaceStorageDir, { withFileTypes: true });
|
|
9665
|
+
const entries = (0, import_node_fs2.readdirSync)(workspaceStorageDir, { withFileTypes: true });
|
|
9372
9666
|
for (const entry of entries) {
|
|
9373
9667
|
if (entry.isDirectory()) {
|
|
9374
|
-
const workspaceDir =
|
|
9375
|
-
const workspaceDbPath =
|
|
9376
|
-
if (existsSync(workspaceDbPath)) {
|
|
9377
|
-
const stat = statSync(workspaceDbPath);
|
|
9668
|
+
const workspaceDir = (0, import_node_path3.join)(workspaceStorageDir, entry.name);
|
|
9669
|
+
const workspaceDbPath = (0, import_node_path3.join)(workspaceDir, "state.vscdb");
|
|
9670
|
+
if ((0, import_node_fs2.existsSync)(workspaceDbPath)) {
|
|
9671
|
+
const stat = (0, import_node_fs2.statSync)(workspaceDbPath);
|
|
9378
9672
|
files.push({
|
|
9379
9673
|
absolutePath: workspaceDbPath,
|
|
9380
9674
|
relativePath: `workspaceStorage/${entry.name}/state.vscdb`,
|
|
@@ -9383,9 +9677,9 @@ function scanDatabaseFiles(dataPath) {
|
|
|
9383
9677
|
workspaceId: entry.name
|
|
9384
9678
|
});
|
|
9385
9679
|
}
|
|
9386
|
-
const workspaceJsonPath =
|
|
9387
|
-
if (existsSync(workspaceJsonPath)) {
|
|
9388
|
-
const stat = statSync(workspaceJsonPath);
|
|
9680
|
+
const workspaceJsonPath = (0, import_node_path3.join)(workspaceDir, "workspace.json");
|
|
9681
|
+
if ((0, import_node_fs2.existsSync)(workspaceJsonPath)) {
|
|
9682
|
+
const stat = (0, import_node_fs2.statSync)(workspaceJsonPath);
|
|
9389
9683
|
files.push({
|
|
9390
9684
|
absolutePath: workspaceJsonPath,
|
|
9391
9685
|
relativePath: `workspaceStorage/${entry.name}/workspace.json`,
|
|
@@ -9414,7 +9708,7 @@ function createManifest(files, stats) {
|
|
|
9414
9708
|
}
|
|
9415
9709
|
function countSessions(dbPath) {
|
|
9416
9710
|
try {
|
|
9417
|
-
const db =
|
|
9711
|
+
const db = registry.openSync(dbPath, { readonly: true });
|
|
9418
9712
|
try {
|
|
9419
9713
|
const row = db.prepare("SELECT value FROM ItemTable WHERE key = 'composer.composerData'").get();
|
|
9420
9714
|
if (row) {
|
|
@@ -9434,19 +9728,11 @@ function countSessions(dbPath) {
|
|
|
9434
9728
|
return 0;
|
|
9435
9729
|
}
|
|
9436
9730
|
}
|
|
9437
|
-
async function backupDatabase(sourcePath, destPath) {
|
|
9438
|
-
const sourceDb = new import_better_sqlite3.default(sourcePath, { readonly: true });
|
|
9439
|
-
try {
|
|
9440
|
-
await sourceDb.backup(destPath);
|
|
9441
|
-
} finally {
|
|
9442
|
-
sourceDb.close();
|
|
9443
|
-
}
|
|
9444
|
-
}
|
|
9445
9731
|
function checkDiskSpace(outputPath, requiredBytes) {
|
|
9446
|
-
const dir = dirname(outputPath);
|
|
9732
|
+
const dir = (0, import_node_path3.dirname)(outputPath);
|
|
9447
9733
|
try {
|
|
9448
|
-
if (!existsSync(dir)) {
|
|
9449
|
-
mkdirSync(dir, { recursive: true });
|
|
9734
|
+
if (!(0, import_node_fs2.existsSync)(dir)) {
|
|
9735
|
+
(0, import_node_fs2.mkdirSync)(dir, { recursive: true });
|
|
9450
9736
|
}
|
|
9451
9737
|
return {
|
|
9452
9738
|
available: Number.MAX_SAFE_INTEGER,
|
|
@@ -9464,14 +9750,14 @@ function checkDiskSpace(outputPath, requiredBytes) {
|
|
|
9464
9750
|
async function createBackup(config) {
|
|
9465
9751
|
const startTime = Date.now();
|
|
9466
9752
|
const sourcePath = config?.sourcePath ?? getDefaultCursorDataPath2();
|
|
9467
|
-
const outputDir = config?.outputPath ? dirname(config.outputPath) : getDefaultBackupDir();
|
|
9468
|
-
const outputPath = config?.outputPath ??
|
|
9753
|
+
const outputDir = config?.outputPath ? (0, import_node_path3.dirname)(config.outputPath) : getDefaultBackupDir();
|
|
9754
|
+
const outputPath = config?.outputPath ?? (0, import_node_path3.join)(outputDir, generateBackupFilename());
|
|
9469
9755
|
const force = config?.force ?? false;
|
|
9470
9756
|
const onProgress = config?.onProgress;
|
|
9471
|
-
if (!existsSync(outputDir)) {
|
|
9472
|
-
mkdirSync(outputDir, { recursive: true });
|
|
9757
|
+
if (!(0, import_node_fs2.existsSync)(outputDir)) {
|
|
9758
|
+
(0, import_node_fs2.mkdirSync)(outputDir, { recursive: true });
|
|
9473
9759
|
}
|
|
9474
|
-
if (existsSync(outputPath) && !force) {
|
|
9760
|
+
if ((0, import_node_fs2.existsSync)(outputPath) && !force) {
|
|
9475
9761
|
return {
|
|
9476
9762
|
success: false,
|
|
9477
9763
|
backupPath: outputPath,
|
|
@@ -9508,8 +9794,8 @@ async function createBackup(config) {
|
|
|
9508
9794
|
error: `Insufficient disk space`
|
|
9509
9795
|
};
|
|
9510
9796
|
}
|
|
9511
|
-
const tempDir =
|
|
9512
|
-
mkdirSync(tempDir, { recursive: true });
|
|
9797
|
+
const tempDir = (0, import_node_path3.join)(outputDir, `.backup_temp_${Date.now()}`);
|
|
9798
|
+
(0, import_node_fs2.mkdirSync)(tempDir, { recursive: true });
|
|
9513
9799
|
try {
|
|
9514
9800
|
const fileEntries = [];
|
|
9515
9801
|
let bytesCompleted = 0;
|
|
@@ -9525,15 +9811,15 @@ async function createBackup(config) {
|
|
|
9525
9811
|
bytesCompleted,
|
|
9526
9812
|
totalBytes
|
|
9527
9813
|
});
|
|
9528
|
-
const tempFilePath =
|
|
9529
|
-
mkdirSync(dirname(tempFilePath), { recursive: true });
|
|
9814
|
+
const tempFilePath = (0, import_node_path3.join)(tempDir, dbFile.relativePath);
|
|
9815
|
+
(0, import_node_fs2.mkdirSync)((0, import_node_path3.dirname)(tempFilePath), { recursive: true });
|
|
9530
9816
|
if (dbFile.type === "global-db" || dbFile.type === "workspace-db") {
|
|
9531
9817
|
await backupDatabase(dbFile.absolutePath, tempFilePath);
|
|
9532
9818
|
} else {
|
|
9533
|
-
const content = readFileSync(dbFile.absolutePath);
|
|
9534
|
-
writeFileSync(tempFilePath, content);
|
|
9819
|
+
const content = (0, import_node_fs2.readFileSync)(dbFile.absolutePath);
|
|
9820
|
+
(0, import_node_fs2.writeFileSync)(tempFilePath, content);
|
|
9535
9821
|
}
|
|
9536
|
-
const buffer = readFileSync(tempFilePath);
|
|
9822
|
+
const buffer = (0, import_node_fs2.readFileSync)(tempFilePath);
|
|
9537
9823
|
const checksum = computeChecksum(buffer);
|
|
9538
9824
|
fileEntries.push({
|
|
9539
9825
|
path: dbFile.relativePath,
|
|
@@ -9558,9 +9844,9 @@ async function createBackup(config) {
|
|
|
9558
9844
|
});
|
|
9559
9845
|
const zip = new import_adm_zip.default();
|
|
9560
9846
|
for (const entry of fileEntries) {
|
|
9561
|
-
const filePath =
|
|
9562
|
-
const zipPath = entry.path.split(sep).join("/");
|
|
9563
|
-
zip.addLocalFile(filePath, dirname(zipPath), basename(zipPath));
|
|
9847
|
+
const filePath = (0, import_node_path3.join)(tempDir, entry.path);
|
|
9848
|
+
const zipPath = entry.path.split(import_node_path3.sep).join("/");
|
|
9849
|
+
zip.addLocalFile(filePath, (0, import_node_path3.dirname)(zipPath), (0, import_node_path3.basename)(zipPath));
|
|
9564
9850
|
}
|
|
9565
9851
|
const stats = {
|
|
9566
9852
|
totalSize: fileEntries.reduce((sum, f) => sum + f.size, 0),
|
|
@@ -9576,8 +9862,8 @@ async function createBackup(config) {
|
|
|
9576
9862
|
bytesCompleted: totalBytes,
|
|
9577
9863
|
totalBytes
|
|
9578
9864
|
});
|
|
9579
|
-
if (existsSync(outputPath)) {
|
|
9580
|
-
unlinkSync(outputPath);
|
|
9865
|
+
if ((0, import_node_fs2.existsSync)(outputPath)) {
|
|
9866
|
+
(0, import_node_fs2.unlinkSync)(outputPath);
|
|
9581
9867
|
}
|
|
9582
9868
|
zip.writeZip(outputPath);
|
|
9583
9869
|
return {
|
|
@@ -9589,47 +9875,67 @@ async function createBackup(config) {
|
|
|
9589
9875
|
} finally {
|
|
9590
9876
|
try {
|
|
9591
9877
|
const cleanupDir = (dir) => {
|
|
9592
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
9878
|
+
const entries = (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true });
|
|
9593
9879
|
for (const entry of entries) {
|
|
9594
|
-
const fullPath =
|
|
9880
|
+
const fullPath = (0, import_node_path3.join)(dir, entry.name);
|
|
9595
9881
|
if (entry.isDirectory()) {
|
|
9596
9882
|
cleanupDir(fullPath);
|
|
9597
9883
|
} else {
|
|
9598
|
-
unlinkSync(fullPath);
|
|
9884
|
+
(0, import_node_fs2.unlinkSync)(fullPath);
|
|
9599
9885
|
}
|
|
9600
9886
|
}
|
|
9601
9887
|
try {
|
|
9602
|
-
rmdirSync(dir);
|
|
9888
|
+
(0, import_node_fs2.rmdirSync)(dir);
|
|
9603
9889
|
} catch {
|
|
9604
9890
|
}
|
|
9605
9891
|
};
|
|
9606
|
-
if (existsSync(tempDir)) {
|
|
9892
|
+
if ((0, import_node_fs2.existsSync)(tempDir)) {
|
|
9607
9893
|
cleanupDir(tempDir);
|
|
9608
9894
|
}
|
|
9609
9895
|
} catch {
|
|
9610
9896
|
}
|
|
9611
9897
|
}
|
|
9612
9898
|
}
|
|
9899
|
+
var TempFileCleanupWrapper = class {
|
|
9900
|
+
innerDb;
|
|
9901
|
+
tempFilePath;
|
|
9902
|
+
constructor(innerDb, tempFilePath) {
|
|
9903
|
+
this.innerDb = innerDb;
|
|
9904
|
+
this.tempFilePath = tempFilePath;
|
|
9905
|
+
}
|
|
9906
|
+
prepare(sql) {
|
|
9907
|
+
return this.innerDb.prepare(sql);
|
|
9908
|
+
}
|
|
9909
|
+
runSQL(sql) {
|
|
9910
|
+
this.innerDb.runSQL(sql);
|
|
9911
|
+
}
|
|
9912
|
+
close() {
|
|
9913
|
+
this.innerDb.close();
|
|
9914
|
+
try {
|
|
9915
|
+
(0, import_node_fs2.unlinkSync)(this.tempFilePath);
|
|
9916
|
+
} catch {
|
|
9917
|
+
}
|
|
9918
|
+
}
|
|
9919
|
+
};
|
|
9613
9920
|
function openBackupDatabase(backupPath, dbPath) {
|
|
9614
9921
|
const zip = new import_adm_zip.default(backupPath);
|
|
9615
9922
|
const buffer = zip.readFile(dbPath);
|
|
9616
9923
|
if (!buffer) {
|
|
9617
9924
|
throw new Error(`Database not found in backup: ${dbPath}`);
|
|
9618
9925
|
}
|
|
9619
|
-
const tempFile =
|
|
9620
|
-
writeFileSync(tempFile, buffer);
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
const result = originalClose();
|
|
9926
|
+
const tempFile = (0, import_node_path3.join)((0, import_node_os2.tmpdir)(), `cursor_history_backup_${Date.now()}_${Math.random().toString(36).slice(2)}.vscdb`);
|
|
9927
|
+
(0, import_node_fs2.writeFileSync)(tempFile, buffer);
|
|
9928
|
+
let db = null;
|
|
9929
|
+
try {
|
|
9930
|
+
db = registry.openSync(tempFile, { readonly: true });
|
|
9931
|
+
} catch (err) {
|
|
9626
9932
|
try {
|
|
9627
|
-
unlinkSync(tempFile);
|
|
9933
|
+
(0, import_node_fs2.unlinkSync)(tempFile);
|
|
9628
9934
|
} catch {
|
|
9629
9935
|
}
|
|
9630
|
-
|
|
9631
|
-
}
|
|
9632
|
-
return db;
|
|
9936
|
+
throw err;
|
|
9937
|
+
}
|
|
9938
|
+
return new TempFileCleanupWrapper(db, tempFile);
|
|
9633
9939
|
}
|
|
9634
9940
|
function readBackupManifest(backupPath) {
|
|
9635
9941
|
try {
|
|
@@ -9648,7 +9954,7 @@ function validateBackup(backupPath) {
|
|
|
9648
9954
|
const validFiles = [];
|
|
9649
9955
|
const corruptedFiles = [];
|
|
9650
9956
|
const missingFiles = [];
|
|
9651
|
-
if (!existsSync(backupPath)) {
|
|
9957
|
+
if (!(0, import_node_fs2.existsSync)(backupPath)) {
|
|
9652
9958
|
return {
|
|
9653
9959
|
status: "invalid",
|
|
9654
9960
|
validFiles: [],
|
|
@@ -9751,9 +10057,9 @@ function restoreBackup(config) {
|
|
|
9751
10057
|
};
|
|
9752
10058
|
}
|
|
9753
10059
|
const manifest = validation.manifest;
|
|
9754
|
-
const userDir = dirname(targetPath);
|
|
9755
|
-
const globalDbPath =
|
|
9756
|
-
if (!force && existsSync(globalDbPath)) {
|
|
10060
|
+
const userDir = (0, import_node_path3.dirname)(targetPath);
|
|
10061
|
+
const globalDbPath = (0, import_node_path3.join)(userDir, "globalStorage", "state.vscdb");
|
|
10062
|
+
if (!force && (0, import_node_fs2.existsSync)(globalDbPath)) {
|
|
9757
10063
|
return {
|
|
9758
10064
|
success: false,
|
|
9759
10065
|
targetPath,
|
|
@@ -9788,10 +10094,10 @@ function restoreBackup(config) {
|
|
|
9788
10094
|
if (!buffer) {
|
|
9789
10095
|
continue;
|
|
9790
10096
|
}
|
|
9791
|
-
const platformPath = fileEntry.path.split("/").join(sep);
|
|
9792
|
-
const destPath =
|
|
9793
|
-
mkdirSync(dirname(destPath), { recursive: true });
|
|
9794
|
-
writeFileSync(destPath, buffer);
|
|
10097
|
+
const platformPath = fileEntry.path.split("/").join(import_node_path3.sep);
|
|
10098
|
+
const destPath = (0, import_node_path3.join)(userDir, platformPath);
|
|
10099
|
+
(0, import_node_fs2.mkdirSync)((0, import_node_path3.dirname)(destPath), { recursive: true });
|
|
10100
|
+
(0, import_node_fs2.writeFileSync)(destPath, buffer);
|
|
9795
10101
|
restoredFiles.push(fileEntry.path);
|
|
9796
10102
|
}
|
|
9797
10103
|
onProgress?.({
|
|
@@ -9810,10 +10116,10 @@ function restoreBackup(config) {
|
|
|
9810
10116
|
} catch (e) {
|
|
9811
10117
|
for (const filePath of restoredFiles) {
|
|
9812
10118
|
try {
|
|
9813
|
-
const platformPath = filePath.split("/").join(sep);
|
|
9814
|
-
const destPath =
|
|
9815
|
-
if (existsSync(destPath)) {
|
|
9816
|
-
unlinkSync(destPath);
|
|
10119
|
+
const platformPath = filePath.split("/").join(import_node_path3.sep);
|
|
10120
|
+
const destPath = (0, import_node_path3.join)(userDir, platformPath);
|
|
10121
|
+
if ((0, import_node_fs2.existsSync)(destPath)) {
|
|
10122
|
+
(0, import_node_fs2.unlinkSync)(destPath);
|
|
9817
10123
|
}
|
|
9818
10124
|
} catch {
|
|
9819
10125
|
}
|
|
@@ -9829,14 +10135,14 @@ function restoreBackup(config) {
|
|
|
9829
10135
|
}
|
|
9830
10136
|
}
|
|
9831
10137
|
function getDefaultCursorDataPath2() {
|
|
9832
|
-
const home =
|
|
10138
|
+
const home = (0, import_node_os2.homedir)();
|
|
9833
10139
|
switch (process.platform) {
|
|
9834
10140
|
case "win32":
|
|
9835
|
-
return
|
|
10141
|
+
return (0, import_node_path3.join)(process.env["APPDATA"] ?? (0, import_node_path3.join)(home, "AppData", "Roaming"), "Cursor", "User", "workspaceStorage");
|
|
9836
10142
|
case "darwin":
|
|
9837
|
-
return
|
|
10143
|
+
return (0, import_node_path3.join)(home, "Library", "Application Support", "Cursor", "User", "workspaceStorage");
|
|
9838
10144
|
default:
|
|
9839
|
-
return
|
|
10145
|
+
return (0, import_node_path3.join)(home, ".config", "Cursor", "User", "workspaceStorage");
|
|
9840
10146
|
}
|
|
9841
10147
|
}
|
|
9842
10148
|
|
|
@@ -9853,20 +10159,20 @@ var PROMPTS_KEY = "aiService.prompts";
|
|
|
9853
10159
|
var GENERATIONS_KEY = "aiService.generations";
|
|
9854
10160
|
function getGlobalStoragePath() {
|
|
9855
10161
|
const platform = process.platform;
|
|
9856
|
-
const home =
|
|
10162
|
+
const home = (0, import_node_os3.homedir)();
|
|
9857
10163
|
if (platform === "win32") {
|
|
9858
|
-
return
|
|
10164
|
+
return (0, import_node_path4.join)(process.env["APPDATA"] ?? (0, import_node_path4.join)(home, "AppData", "Roaming"), "Cursor", "User", "globalStorage");
|
|
9859
10165
|
} else if (platform === "darwin") {
|
|
9860
|
-
return
|
|
10166
|
+
return (0, import_node_path4.join)(home, "Library", "Application Support", "Cursor", "User", "globalStorage");
|
|
9861
10167
|
} else {
|
|
9862
|
-
return
|
|
10168
|
+
return (0, import_node_path4.join)(home, ".config", "Cursor", "User", "globalStorage");
|
|
9863
10169
|
}
|
|
9864
10170
|
}
|
|
9865
|
-
function
|
|
9866
|
-
return
|
|
10171
|
+
async function openDatabase2(dbPath) {
|
|
10172
|
+
return openDatabase(dbPath);
|
|
9867
10173
|
}
|
|
9868
|
-
function
|
|
9869
|
-
return
|
|
10174
|
+
async function openDatabaseReadWrite2(dbPath) {
|
|
10175
|
+
return openDatabaseReadWrite(dbPath);
|
|
9870
10176
|
}
|
|
9871
10177
|
function readWorkspaceJsonFromBackup(backupPath, workspaceId) {
|
|
9872
10178
|
try {
|
|
@@ -9886,11 +10192,12 @@ function readWorkspaceJsonFromBackup(backupPath, workspaceId) {
|
|
|
9886
10192
|
return null;
|
|
9887
10193
|
}
|
|
9888
10194
|
}
|
|
9889
|
-
function findWorkspacesFromBackup(backupPath) {
|
|
10195
|
+
async function findWorkspacesFromBackup(backupPath) {
|
|
9890
10196
|
const manifest = readBackupManifest(backupPath);
|
|
9891
10197
|
if (!manifest) {
|
|
9892
10198
|
return [];
|
|
9893
10199
|
}
|
|
10200
|
+
await ensureDriver();
|
|
9894
10201
|
const workspaces = [];
|
|
9895
10202
|
for (const file of manifest.files) {
|
|
9896
10203
|
if (file.type !== "workspace-db")
|
|
@@ -9925,12 +10232,12 @@ function findWorkspacesFromBackup(backupPath) {
|
|
|
9925
10232
|
return workspaces;
|
|
9926
10233
|
}
|
|
9927
10234
|
function readWorkspaceJson(workspaceDir) {
|
|
9928
|
-
const jsonPath =
|
|
9929
|
-
if (!
|
|
10235
|
+
const jsonPath = (0, import_node_path4.join)(workspaceDir, "workspace.json");
|
|
10236
|
+
if (!(0, import_node_fs3.existsSync)(jsonPath)) {
|
|
9930
10237
|
return null;
|
|
9931
10238
|
}
|
|
9932
10239
|
try {
|
|
9933
|
-
const content =
|
|
10240
|
+
const content = (0, import_node_fs3.readFileSync)(jsonPath, "utf-8");
|
|
9934
10241
|
const data = JSON.parse(content);
|
|
9935
10242
|
if (data.folder) {
|
|
9936
10243
|
return data.folder.replace(/^file:\/\//, "").replace(/%20/g, " ");
|
|
@@ -9940,30 +10247,30 @@ function readWorkspaceJson(workspaceDir) {
|
|
|
9940
10247
|
return null;
|
|
9941
10248
|
}
|
|
9942
10249
|
}
|
|
9943
|
-
function findWorkspaces(customDataPath, backupPath) {
|
|
10250
|
+
async function findWorkspaces(customDataPath, backupPath) {
|
|
9944
10251
|
if (backupPath) {
|
|
9945
|
-
return findWorkspacesFromBackup(backupPath);
|
|
10252
|
+
return await findWorkspacesFromBackup(backupPath);
|
|
9946
10253
|
}
|
|
9947
10254
|
const basePath = getCursorDataPath(customDataPath);
|
|
9948
|
-
if (!
|
|
10255
|
+
if (!(0, import_node_fs3.existsSync)(basePath)) {
|
|
9949
10256
|
return [];
|
|
9950
10257
|
}
|
|
9951
10258
|
const workspaces = [];
|
|
9952
10259
|
try {
|
|
9953
|
-
const entries =
|
|
10260
|
+
const entries = (0, import_node_fs3.readdirSync)(basePath, { withFileTypes: true });
|
|
9954
10261
|
for (const entry of entries) {
|
|
9955
10262
|
if (!entry.isDirectory())
|
|
9956
10263
|
continue;
|
|
9957
|
-
const workspaceDir =
|
|
9958
|
-
const dbPath =
|
|
9959
|
-
if (!
|
|
10264
|
+
const workspaceDir = (0, import_node_path4.join)(basePath, entry.name);
|
|
10265
|
+
const dbPath = (0, import_node_path4.join)(workspaceDir, "state.vscdb");
|
|
10266
|
+
if (!(0, import_node_fs3.existsSync)(dbPath))
|
|
9960
10267
|
continue;
|
|
9961
10268
|
const workspacePath = readWorkspaceJson(workspaceDir);
|
|
9962
10269
|
if (!workspacePath)
|
|
9963
10270
|
continue;
|
|
9964
10271
|
let sessionCount = 0;
|
|
9965
10272
|
try {
|
|
9966
|
-
const db =
|
|
10273
|
+
const db = await openDatabase2(dbPath);
|
|
9967
10274
|
const result = getChatDataFromDb(db);
|
|
9968
10275
|
if (result) {
|
|
9969
10276
|
const parsed = parseChatData(result.data, result.bundle);
|
|
@@ -10023,13 +10330,13 @@ function getChatDataFromDb(db) {
|
|
|
10023
10330
|
}
|
|
10024
10331
|
return { data: mainData, bundle };
|
|
10025
10332
|
}
|
|
10026
|
-
function listSessions(options, customDataPath, backupPath) {
|
|
10027
|
-
const workspaces = findWorkspaces(customDataPath, backupPath);
|
|
10333
|
+
async function listSessions(options, customDataPath, backupPath) {
|
|
10334
|
+
const workspaces = await findWorkspaces(customDataPath, backupPath);
|
|
10028
10335
|
const filteredWorkspaces = options.workspacePath ? workspaces.filter((w) => w.path === options.workspacePath || w.path.endsWith(options.workspacePath ?? "")) : workspaces;
|
|
10029
10336
|
const allSessions = [];
|
|
10030
10337
|
for (const workspace of filteredWorkspaces) {
|
|
10031
10338
|
try {
|
|
10032
|
-
const db = backupPath ? openBackupDatabase(backupPath, workspace.dbPath) :
|
|
10339
|
+
const db = backupPath ? openBackupDatabase(backupPath, workspace.dbPath) : await openDatabase2(workspace.dbPath);
|
|
10033
10340
|
const result = getChatDataFromDb(db);
|
|
10034
10341
|
db.close();
|
|
10035
10342
|
if (!result)
|
|
@@ -10062,8 +10369,8 @@ function listSessions(options, customDataPath, backupPath) {
|
|
|
10062
10369
|
}
|
|
10063
10370
|
return allSessions;
|
|
10064
10371
|
}
|
|
10065
|
-
function getSession(index, customDataPath, backupPath) {
|
|
10066
|
-
const summaries = listSessions({ limit: 0, all: true }, customDataPath, backupPath);
|
|
10372
|
+
async function getSession(index, customDataPath, backupPath) {
|
|
10373
|
+
const summaries = await listSessions({ limit: 0, all: true }, customDataPath, backupPath);
|
|
10067
10374
|
const summary = summaries.find((s) => s.index === index);
|
|
10068
10375
|
if (!summary) {
|
|
10069
10376
|
return null;
|
|
@@ -10078,9 +10385,9 @@ function getSession(index, customDataPath, backupPath) {
|
|
|
10078
10385
|
}
|
|
10079
10386
|
} else {
|
|
10080
10387
|
const globalPath = getGlobalStoragePath();
|
|
10081
|
-
const globalDbPath =
|
|
10082
|
-
if (
|
|
10083
|
-
db =
|
|
10388
|
+
const globalDbPath = (0, import_node_path4.join)(globalPath, "state.vscdb");
|
|
10389
|
+
if ((0, import_node_fs3.existsSync)(globalDbPath)) {
|
|
10390
|
+
db = await openDatabase2(globalDbPath);
|
|
10084
10391
|
}
|
|
10085
10392
|
}
|
|
10086
10393
|
if (db) {
|
|
@@ -10125,13 +10432,13 @@ function getSession(index, customDataPath, backupPath) {
|
|
|
10125
10432
|
}
|
|
10126
10433
|
} catch {
|
|
10127
10434
|
}
|
|
10128
|
-
const workspaces = findWorkspaces(customDataPath, backupPath);
|
|
10435
|
+
const workspaces = await findWorkspaces(customDataPath, backupPath);
|
|
10129
10436
|
const workspace = workspaces.find((w) => w.id === summary.workspaceId);
|
|
10130
10437
|
if (!workspace) {
|
|
10131
10438
|
return null;
|
|
10132
10439
|
}
|
|
10133
10440
|
try {
|
|
10134
|
-
const db = backupPath ? openBackupDatabase(backupPath, workspace.dbPath) :
|
|
10441
|
+
const db = backupPath ? openBackupDatabase(backupPath, workspace.dbPath) : await openDatabase2(workspace.dbPath);
|
|
10135
10442
|
const result = getChatDataFromDb(db);
|
|
10136
10443
|
db.close();
|
|
10137
10444
|
if (!result)
|
|
@@ -10150,12 +10457,12 @@ function getSession(index, customDataPath, backupPath) {
|
|
|
10150
10457
|
return null;
|
|
10151
10458
|
}
|
|
10152
10459
|
}
|
|
10153
|
-
function searchSessions(query, options, customDataPath, backupPath) {
|
|
10154
|
-
const summaries = listSessions({ limit: 0, all: true, workspacePath: options.workspacePath }, customDataPath, backupPath);
|
|
10460
|
+
async function searchSessions(query, options, customDataPath, backupPath) {
|
|
10461
|
+
const summaries = await listSessions({ limit: 0, all: true, workspacePath: options.workspacePath }, customDataPath, backupPath);
|
|
10155
10462
|
const results = [];
|
|
10156
10463
|
const lowerQuery = query.toLowerCase();
|
|
10157
10464
|
for (const summary of summaries) {
|
|
10158
|
-
const session = getSession(summary.index, customDataPath, backupPath);
|
|
10465
|
+
const session = await getSession(summary.index, customDataPath, backupPath);
|
|
10159
10466
|
if (!session)
|
|
10160
10467
|
continue;
|
|
10161
10468
|
const snippets = getSearchSnippets(session.messages, lowerQuery, options.contextChars);
|
|
@@ -10485,11 +10792,11 @@ ${best}`;
|
|
|
10485
10792
|
}
|
|
10486
10793
|
return best;
|
|
10487
10794
|
}
|
|
10488
|
-
function findWorkspaceForSession(sessionId, customDataPath) {
|
|
10489
|
-
const workspaces = findWorkspaces(customDataPath);
|
|
10795
|
+
async function findWorkspaceForSession(sessionId, customDataPath) {
|
|
10796
|
+
const workspaces = await findWorkspaces(customDataPath);
|
|
10490
10797
|
for (const workspace of workspaces) {
|
|
10491
10798
|
try {
|
|
10492
|
-
const db =
|
|
10799
|
+
const db = await openDatabase2(workspace.dbPath);
|
|
10493
10800
|
const result = getChatDataFromDb(db);
|
|
10494
10801
|
db.close();
|
|
10495
10802
|
if (!result)
|
|
@@ -10513,8 +10820,8 @@ function findWorkspaceForSession(sessionId, customDataPath) {
|
|
|
10513
10820
|
}
|
|
10514
10821
|
return null;
|
|
10515
10822
|
}
|
|
10516
|
-
function findWorkspaceByPath(workspacePath, customDataPath) {
|
|
10517
|
-
const workspaces = findWorkspaces(customDataPath);
|
|
10823
|
+
async function findWorkspaceByPath(workspacePath, customDataPath) {
|
|
10824
|
+
const workspaces = await findWorkspaces(customDataPath);
|
|
10518
10825
|
const normalizedPath = normalizePath(workspacePath);
|
|
10519
10826
|
for (const workspace of workspaces) {
|
|
10520
10827
|
if (pathsEqual(workspace.path, normalizedPath)) {
|
|
@@ -10564,7 +10871,7 @@ function updateComposerData(db, composers, isNewFormat, originalRawData) {
|
|
|
10564
10871
|
const jsonValue = JSON.stringify(dataToWrite);
|
|
10565
10872
|
db.prepare("UPDATE ItemTable SET value = ? WHERE key = ?").run(jsonValue, "composer.composerData");
|
|
10566
10873
|
}
|
|
10567
|
-
function resolveSessionIdentifiers(input, customDataPath) {
|
|
10874
|
+
async function resolveSessionIdentifiers(input, customDataPath) {
|
|
10568
10875
|
let identifiers;
|
|
10569
10876
|
if (Array.isArray(input)) {
|
|
10570
10877
|
identifiers = input;
|
|
@@ -10573,7 +10880,7 @@ function resolveSessionIdentifiers(input, customDataPath) {
|
|
|
10573
10880
|
} else {
|
|
10574
10881
|
identifiers = [input];
|
|
10575
10882
|
}
|
|
10576
|
-
const summaries = listSessions({ limit: 0, all: true }, customDataPath);
|
|
10883
|
+
const summaries = await listSessions({ limit: 0, all: true }, customDataPath);
|
|
10577
10884
|
const resolvedIds = [];
|
|
10578
10885
|
for (const identifier of identifiers) {
|
|
10579
10886
|
let sessionId;
|
|
@@ -10594,11 +10901,10 @@ function resolveSessionIdentifiers(input, customDataPath) {
|
|
|
10594
10901
|
}
|
|
10595
10902
|
|
|
10596
10903
|
// node_modules/cursor-history/dist/core/migrate.js
|
|
10597
|
-
|
|
10598
|
-
var
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
import { homedir as homedir4 } from "node:os";
|
|
10904
|
+
var import_node_fs4 = require("fs");
|
|
10905
|
+
var import_node_path5 = require("path");
|
|
10906
|
+
var import_node_os4 = require("os");
|
|
10907
|
+
var import_better_sqlite32 = __toESM(require_lib(), 1);
|
|
10602
10908
|
function generateSessionId() {
|
|
10603
10909
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
10604
10910
|
const r = Math.random() * 16 | 0;
|
|
@@ -10608,13 +10914,13 @@ function generateSessionId() {
|
|
|
10608
10914
|
}
|
|
10609
10915
|
function getGlobalStoragePath2() {
|
|
10610
10916
|
const platform = process.platform;
|
|
10611
|
-
const home =
|
|
10917
|
+
const home = (0, import_node_os4.homedir)();
|
|
10612
10918
|
if (platform === "win32") {
|
|
10613
|
-
return
|
|
10919
|
+
return (0, import_node_path5.join)(process.env["APPDATA"] ?? (0, import_node_path5.join)(home, "AppData", "Roaming"), "Cursor", "User", "globalStorage");
|
|
10614
10920
|
} else if (platform === "darwin") {
|
|
10615
|
-
return
|
|
10921
|
+
return (0, import_node_path5.join)(home, "Library", "Application Support", "Cursor", "User", "globalStorage");
|
|
10616
10922
|
} else {
|
|
10617
|
-
return
|
|
10923
|
+
return (0, import_node_path5.join)(home, ".config", "Cursor", "User", "globalStorage");
|
|
10618
10924
|
}
|
|
10619
10925
|
}
|
|
10620
10926
|
function transformPath(path, sourcePrefix, destPrefix) {
|
|
@@ -10736,12 +11042,12 @@ function isNestedPath(source, destination) {
|
|
|
10736
11042
|
return normalizedDest.startsWith(normalizedSource + "/");
|
|
10737
11043
|
}
|
|
10738
11044
|
function copyBubbleDataInGlobalStorage(oldComposerId, newComposerId, sourceWorkspace, destWorkspace, debug = false) {
|
|
10739
|
-
const globalDbPath =
|
|
10740
|
-
if (!
|
|
11045
|
+
const globalDbPath = (0, import_node_path5.join)(getGlobalStoragePath2(), "state.vscdb");
|
|
11046
|
+
if (!(0, import_node_fs4.existsSync)(globalDbPath)) {
|
|
10741
11047
|
return /* @__PURE__ */ new Map();
|
|
10742
11048
|
}
|
|
10743
11049
|
const bubbleIdMap = /* @__PURE__ */ new Map();
|
|
10744
|
-
const db = new
|
|
11050
|
+
const db = new import_better_sqlite32.default(globalDbPath, { readonly: false });
|
|
10745
11051
|
const sourcePrefix = normalizePath(sourceWorkspace).replace(/\/+$/, "");
|
|
10746
11052
|
const destPrefix = normalizePath(destWorkspace).replace(/\/+$/, "");
|
|
10747
11053
|
try {
|
|
@@ -10790,11 +11096,11 @@ function copyBubbleDataInGlobalStorage(oldComposerId, newComposerId, sourceWorks
|
|
|
10790
11096
|
}
|
|
10791
11097
|
}
|
|
10792
11098
|
function updateBubblePathsInGlobalStorage(composerId, sourceWorkspace, destWorkspace, debug = false) {
|
|
10793
|
-
const globalDbPath =
|
|
10794
|
-
if (!
|
|
11099
|
+
const globalDbPath = (0, import_node_path5.join)(getGlobalStoragePath2(), "state.vscdb");
|
|
11100
|
+
if (!(0, import_node_fs4.existsSync)(globalDbPath)) {
|
|
10795
11101
|
return;
|
|
10796
11102
|
}
|
|
10797
|
-
const db = new
|
|
11103
|
+
const db = new import_better_sqlite32.default(globalDbPath, { readonly: false });
|
|
10798
11104
|
const sourcePrefix = normalizePath(sourceWorkspace).replace(/\/+$/, "");
|
|
10799
11105
|
const destPrefix = normalizePath(destWorkspace).replace(/\/+$/, "");
|
|
10800
11106
|
try {
|
|
@@ -10814,10 +11120,10 @@ function updateBubblePathsInGlobalStorage(composerId, sourceWorkspace, destWorks
|
|
|
10814
11120
|
db.close();
|
|
10815
11121
|
}
|
|
10816
11122
|
}
|
|
10817
|
-
function migrateSession(sessionId, options) {
|
|
11123
|
+
async function migrateSession(sessionId, options) {
|
|
10818
11124
|
const { destination, mode, dryRun, dataPath, debug = false } = options;
|
|
10819
11125
|
const normalizedDest = normalizePath(destination);
|
|
10820
|
-
const sourceInfo = findWorkspaceForSession(sessionId, dataPath);
|
|
11126
|
+
const sourceInfo = await findWorkspaceForSession(sessionId, dataPath);
|
|
10821
11127
|
if (!sourceInfo) {
|
|
10822
11128
|
throw new SessionNotFoundError(sessionId);
|
|
10823
11129
|
}
|
|
@@ -10828,7 +11134,7 @@ function migrateSession(sessionId, options) {
|
|
|
10828
11134
|
if (isNestedPath(sourceWorkspace, normalizedDest)) {
|
|
10829
11135
|
throw new NestedPathError(sourceWorkspace, normalizedDest);
|
|
10830
11136
|
}
|
|
10831
|
-
const destInfo = findWorkspaceByPath(normalizedDest, dataPath);
|
|
11137
|
+
const destInfo = await findWorkspaceByPath(normalizedDest, dataPath);
|
|
10832
11138
|
if (!destInfo) {
|
|
10833
11139
|
throw new WorkspaceNotFoundError(normalizedDest);
|
|
10834
11140
|
}
|
|
@@ -10844,8 +11150,8 @@ function migrateSession(sessionId, options) {
|
|
|
10844
11150
|
};
|
|
10845
11151
|
}
|
|
10846
11152
|
try {
|
|
10847
|
-
const sourceDb =
|
|
10848
|
-
const destDb =
|
|
11153
|
+
const sourceDb = await openDatabaseReadWrite2(sourceInfo.dbPath);
|
|
11154
|
+
const destDb = await openDatabaseReadWrite2(destInfo.dbPath);
|
|
10849
11155
|
try {
|
|
10850
11156
|
const sourceResult = getComposerData(sourceDb);
|
|
10851
11157
|
const destResult = getComposerData(destDb);
|
|
@@ -10906,12 +11212,12 @@ function migrateSession(sessionId, options) {
|
|
|
10906
11212
|
};
|
|
10907
11213
|
}
|
|
10908
11214
|
}
|
|
10909
|
-
function migrateSessions(options) {
|
|
11215
|
+
async function migrateSessions(options) {
|
|
10910
11216
|
const { sessionIds, ...sessionOptions } = options;
|
|
10911
11217
|
const results = [];
|
|
10912
11218
|
for (const sessionId of sessionIds) {
|
|
10913
11219
|
try {
|
|
10914
|
-
const result = migrateSession(sessionId, sessionOptions);
|
|
11220
|
+
const result = await migrateSession(sessionId, sessionOptions);
|
|
10915
11221
|
results.push(result);
|
|
10916
11222
|
} catch (error) {
|
|
10917
11223
|
results.push({
|
|
@@ -10929,7 +11235,6 @@ function migrateSessions(options) {
|
|
|
10929
11235
|
}
|
|
10930
11236
|
|
|
10931
11237
|
// node_modules/cursor-history/dist/lib/backup.js
|
|
10932
|
-
init_esm_shims();
|
|
10933
11238
|
async function createBackup2(config) {
|
|
10934
11239
|
return createBackup(config);
|
|
10935
11240
|
}
|
|
@@ -10957,10 +11262,10 @@ function convertToLibrarySession(coreSession) {
|
|
|
10957
11262
|
}
|
|
10958
11263
|
};
|
|
10959
11264
|
}
|
|
10960
|
-
function listSessions2(config) {
|
|
11265
|
+
async function listSessions2(config) {
|
|
10961
11266
|
try {
|
|
10962
11267
|
const resolved = mergeWithDefaults(config);
|
|
10963
|
-
const coreSessions = listSessions({
|
|
11268
|
+
const coreSessions = await listSessions({
|
|
10964
11269
|
limit: -1,
|
|
10965
11270
|
// Get all, we'll paginate ourselves
|
|
10966
11271
|
all: true,
|
|
@@ -10970,13 +11275,14 @@ function listSessions2(config) {
|
|
|
10970
11275
|
const start = resolved.offset;
|
|
10971
11276
|
const end = Math.min(start + resolved.limit, total);
|
|
10972
11277
|
const paginatedSessions = coreSessions.slice(start, end);
|
|
10973
|
-
const sessions =
|
|
10974
|
-
|
|
11278
|
+
const sessions = [];
|
|
11279
|
+
for (const summary of paginatedSessions) {
|
|
11280
|
+
const fullSession = await getSession(summary.index, resolved.dataPath, resolved.backupPath);
|
|
10975
11281
|
if (!fullSession) {
|
|
10976
11282
|
throw new DatabaseNotFoundError(`Session ${summary.index} not found`);
|
|
10977
11283
|
}
|
|
10978
|
-
|
|
10979
|
-
}
|
|
11284
|
+
sessions.push(convertToLibrarySession(fullSession));
|
|
11285
|
+
}
|
|
10980
11286
|
return {
|
|
10981
11287
|
data: sessions,
|
|
10982
11288
|
pagination: {
|
|
@@ -10999,11 +11305,11 @@ function listSessions2(config) {
|
|
|
10999
11305
|
throw new Error(`Failed to list sessions: ${err instanceof Error ? err.message : String(err)}`);
|
|
11000
11306
|
}
|
|
11001
11307
|
}
|
|
11002
|
-
function getSession2(index, config) {
|
|
11308
|
+
async function getSession2(index, config) {
|
|
11003
11309
|
try {
|
|
11004
11310
|
const resolved = mergeWithDefaults(config);
|
|
11005
11311
|
const coreIndex = index + 1;
|
|
11006
|
-
const coreSession = getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11312
|
+
const coreSession = await getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11007
11313
|
if (!coreSession) {
|
|
11008
11314
|
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
11009
11315
|
}
|
|
@@ -11021,17 +11327,18 @@ function getSession2(index, config) {
|
|
|
11021
11327
|
throw new Error(`Failed to get session: ${err instanceof Error ? err.message : String(err)}`);
|
|
11022
11328
|
}
|
|
11023
11329
|
}
|
|
11024
|
-
function searchSessions2(query, config) {
|
|
11330
|
+
async function searchSessions2(query, config) {
|
|
11025
11331
|
try {
|
|
11026
11332
|
const resolved = mergeWithDefaults(config);
|
|
11027
|
-
const coreResults = searchSessions(query, {
|
|
11333
|
+
const coreResults = await searchSessions(query, {
|
|
11028
11334
|
limit: resolved.limit === Number.MAX_SAFE_INTEGER ? 0 : resolved.limit,
|
|
11029
11335
|
contextChars: resolved.context * 80,
|
|
11030
11336
|
// Rough estimate: 1 line = 80 chars
|
|
11031
11337
|
workspacePath: resolved.workspace
|
|
11032
11338
|
}, resolved.dataPath, resolved.backupPath);
|
|
11033
|
-
|
|
11034
|
-
|
|
11339
|
+
const results = [];
|
|
11340
|
+
for (const coreResult of coreResults) {
|
|
11341
|
+
const fullSession = await getSession(coreResult.index, resolved.dataPath, resolved.backupPath);
|
|
11035
11342
|
if (!fullSession) {
|
|
11036
11343
|
throw new DatabaseNotFoundError(`Session ${coreResult.index} not found`);
|
|
11037
11344
|
}
|
|
@@ -11063,7 +11370,7 @@ function searchSessions2(query, config) {
|
|
|
11063
11370
|
contextAfter.push(line);
|
|
11064
11371
|
}
|
|
11065
11372
|
}
|
|
11066
|
-
|
|
11373
|
+
results.push({
|
|
11067
11374
|
session: convertToLibrarySession(fullSession),
|
|
11068
11375
|
match: lines[matchLineIndex] ?? match,
|
|
11069
11376
|
messageIndex: 0,
|
|
@@ -11071,8 +11378,9 @@ function searchSessions2(query, config) {
|
|
|
11071
11378
|
offset,
|
|
11072
11379
|
contextBefore: contextBefore.length > 0 ? contextBefore : void 0,
|
|
11073
11380
|
contextAfter: contextAfter.length > 0 ? contextAfter : void 0
|
|
11074
|
-
};
|
|
11075
|
-
}
|
|
11381
|
+
});
|
|
11382
|
+
}
|
|
11383
|
+
return results;
|
|
11076
11384
|
} catch (err) {
|
|
11077
11385
|
if (err instanceof Error && err.message.includes("SQLITE_BUSY")) {
|
|
11078
11386
|
throw new DatabaseLockedError(config?.dataPath ?? "default path");
|
|
@@ -11086,11 +11394,11 @@ function searchSessions2(query, config) {
|
|
|
11086
11394
|
throw new Error(`Failed to search sessions: ${err instanceof Error ? err.message : String(err)}`);
|
|
11087
11395
|
}
|
|
11088
11396
|
}
|
|
11089
|
-
function exportSessionToJson(index, config) {
|
|
11397
|
+
async function exportSessionToJson(index, config) {
|
|
11090
11398
|
try {
|
|
11091
11399
|
const resolved = mergeWithDefaults(config);
|
|
11092
11400
|
const coreIndex = index + 1;
|
|
11093
|
-
const coreSession = getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11401
|
+
const coreSession = await getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11094
11402
|
if (!coreSession) {
|
|
11095
11403
|
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
11096
11404
|
}
|
|
@@ -11102,11 +11410,11 @@ function exportSessionToJson(index, config) {
|
|
|
11102
11410
|
throw new Error(`Failed to export session to JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
11103
11411
|
}
|
|
11104
11412
|
}
|
|
11105
|
-
function exportSessionToMarkdown(index, config) {
|
|
11413
|
+
async function exportSessionToMarkdown(index, config) {
|
|
11106
11414
|
try {
|
|
11107
11415
|
const resolved = mergeWithDefaults(config);
|
|
11108
11416
|
const coreIndex = index + 1;
|
|
11109
|
-
const coreSession = getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11417
|
+
const coreSession = await getSession(coreIndex, resolved.dataPath, resolved.backupPath);
|
|
11110
11418
|
if (!coreSession) {
|
|
11111
11419
|
throw new DatabaseNotFoundError(`Session at index ${index} not found`);
|
|
11112
11420
|
}
|
|
@@ -11118,10 +11426,10 @@ function exportSessionToMarkdown(index, config) {
|
|
|
11118
11426
|
throw new Error(`Failed to export session to Markdown: ${err instanceof Error ? err.message : String(err)}`);
|
|
11119
11427
|
}
|
|
11120
11428
|
}
|
|
11121
|
-
function migrateSession2(config) {
|
|
11122
|
-
const sessionIds = resolveSessionIdentifiers(config.sessions, config.dataPath);
|
|
11429
|
+
async function migrateSession2(config) {
|
|
11430
|
+
const sessionIds = await resolveSessionIdentifiers(config.sessions, config.dataPath);
|
|
11123
11431
|
const destination = expandPath(config.destination);
|
|
11124
|
-
return migrateSessions({
|
|
11432
|
+
return await migrateSessions({
|
|
11125
11433
|
sessionIds,
|
|
11126
11434
|
destination,
|
|
11127
11435
|
mode: config.mode ?? "move",
|
|
@@ -11131,11 +11439,7 @@ function migrateSession2(config) {
|
|
|
11131
11439
|
});
|
|
11132
11440
|
}
|
|
11133
11441
|
|
|
11134
|
-
// src/errors.ts
|
|
11135
|
-
init_esm_shims();
|
|
11136
|
-
|
|
11137
11442
|
// src/types.ts
|
|
11138
|
-
init_esm_shims();
|
|
11139
11443
|
var MCP_ERROR_CODES = {
|
|
11140
11444
|
DATABASE_NOT_FOUND: -32001,
|
|
11141
11445
|
DATABASE_LOCKED: -32002,
|
|
@@ -11293,7 +11597,6 @@ async function handleListSessions(args) {
|
|
|
11293
11597
|
}
|
|
11294
11598
|
|
|
11295
11599
|
// src/tools/show-session.ts
|
|
11296
|
-
init_esm_shims();
|
|
11297
11600
|
var ShowInputSchema = z.object({
|
|
11298
11601
|
sessionIndex: z.number().int().min(1)
|
|
11299
11602
|
});
|
|
@@ -11362,7 +11665,6 @@ async function handleShowSession(args) {
|
|
|
11362
11665
|
}
|
|
11363
11666
|
|
|
11364
11667
|
// src/tools/search.ts
|
|
11365
|
-
init_esm_shims();
|
|
11366
11668
|
var SearchInputSchema = z.object({
|
|
11367
11669
|
query: z.string().min(1),
|
|
11368
11670
|
limit: z.number().int().min(1).max(100).default(10).optional(),
|
|
@@ -11431,7 +11733,6 @@ async function handleSearch(args) {
|
|
|
11431
11733
|
}
|
|
11432
11734
|
|
|
11433
11735
|
// src/tools/export.ts
|
|
11434
|
-
init_esm_shims();
|
|
11435
11736
|
var ExportInputSchema = z.object({
|
|
11436
11737
|
sessionIndex: z.number().int().min(1),
|
|
11437
11738
|
format: z.enum(["markdown", "json"]).default("markdown").optional()
|
|
@@ -11480,7 +11781,6 @@ async function handleExport(args) {
|
|
|
11480
11781
|
}
|
|
11481
11782
|
|
|
11482
11783
|
// src/tools/backup.ts
|
|
11483
|
-
init_esm_shims();
|
|
11484
11784
|
var BackupInputSchema = z.object({
|
|
11485
11785
|
outputPath: z.string().optional(),
|
|
11486
11786
|
force: z.boolean().default(false).optional()
|
|
@@ -11540,7 +11840,6 @@ function formatBytes(bytes) {
|
|
|
11540
11840
|
}
|
|
11541
11841
|
|
|
11542
11842
|
// src/tools/restore.ts
|
|
11543
|
-
init_esm_shims();
|
|
11544
11843
|
var RestoreInputSchema = z.object({
|
|
11545
11844
|
backupPath: z.string(),
|
|
11546
11845
|
force: z.boolean().default(false).optional()
|
|
@@ -11598,7 +11897,6 @@ async function handleRestore(args) {
|
|
|
11598
11897
|
}
|
|
11599
11898
|
|
|
11600
11899
|
// src/tools/migrate.ts
|
|
11601
|
-
init_esm_shims();
|
|
11602
11900
|
var MigrateInputSchema = z.object({
|
|
11603
11901
|
sessionIndexes: z.array(z.number().int().min(1)).min(1),
|
|
11604
11902
|
destination: z.string(),
|
|
@@ -11765,4 +12063,4 @@ main().catch((error) => {
|
|
|
11765
12063
|
console.error("Fatal error:", error);
|
|
11766
12064
|
process.exit(1);
|
|
11767
12065
|
});
|
|
11768
|
-
//# sourceMappingURL=index.
|
|
12066
|
+
//# sourceMappingURL=index.cjs.map
|