@maiyunnet/kebab 2.0.14 → 2.0.16

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.
Files changed (73) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -1
  3. package/lib/buffer.js +3 -9
  4. package/lib/captcha.js +2 -2
  5. package/lib/consistent.js +1 -1
  6. package/lib/core.d.ts +42 -18
  7. package/lib/core.js +147 -152
  8. package/lib/crypto.js +2 -2
  9. package/lib/db.d.ts +3 -3
  10. package/lib/db.js +32 -73
  11. package/lib/dns.d.ts +1 -1
  12. package/lib/dns.js +5 -5
  13. package/lib/fs.js +17 -9
  14. package/lib/jwt.d.ts +3 -3
  15. package/lib/jwt.js +5 -5
  16. package/lib/kv.d.ts +2 -2
  17. package/lib/kv.js +2 -2
  18. package/lib/lan.js +1 -1
  19. package/lib/net/formdata.js +2 -2
  20. package/lib/net/request.d.ts +1 -1
  21. package/lib/net/request.js +1 -1
  22. package/lib/net/response.d.ts +1 -1
  23. package/lib/net.d.ts +2 -2
  24. package/lib/net.js +4 -4
  25. package/lib/s3.d.ts +1 -1
  26. package/lib/s3.js +5 -5
  27. package/lib/scan.d.ts +3 -3
  28. package/lib/scan.js +6 -6
  29. package/lib/session.d.ts +3 -3
  30. package/lib/session.js +7 -7
  31. package/lib/sql.d.ts +3 -3
  32. package/lib/sql.js +7 -37
  33. package/lib/ssh/sftp.js +2 -2
  34. package/lib/ssh/shell.js +1 -1
  35. package/lib/text.d.ts +6 -1
  36. package/lib/text.js +9 -1
  37. package/lib/time.d.ts +1 -1
  38. package/lib/time.js +1 -1
  39. package/lib/turnstile.d.ts +1 -1
  40. package/lib/turnstile.js +2 -2
  41. package/lib/ws.d.ts +10 -2
  42. package/lib/ws.js +62 -3
  43. package/lib/zip.d.ts +1 -1
  44. package/lib/zip.js +5 -11
  45. package/lib/zlib.js +7 -21
  46. package/package.json +5 -4
  47. package/sys/child.js +43 -84
  48. package/sys/cmd.js +7 -6
  49. package/sys/ctr.d.ts +2 -2
  50. package/sys/ctr.js +2 -2
  51. package/sys/master.js +131 -9
  52. package/sys/mod.d.ts +4 -4
  53. package/sys/mod.js +24 -176
  54. package/sys/route.d.ts +1 -1
  55. package/sys/route.js +22 -20
  56. package/www/example/ctr/main.d.ts +1 -1
  57. package/www/example/ctr/main.js +1 -1
  58. package/www/example/ctr/middle.d.ts +2 -2
  59. package/www/example/ctr/middle.js +1 -1
  60. package/www/example/ctr/test.d.ts +3 -2
  61. package/www/example/ctr/test.js +83 -30
  62. package/www/example/mod/test.d.ts +2 -2
  63. package/www/example/mod/test.js +2 -2
  64. package/www/example/mod/testdata.d.ts +1 -1
  65. package/www/example/mod/testdata.js +1 -1
  66. package/www/example/ws/mproxy.d.ts +1 -1
  67. package/www/example/ws/mproxy.js +2 -2
  68. package/www/example/ws/rproxy.d.ts +1 -1
  69. package/www/example/ws/rproxy.js +2 -2
  70. package/www/example/ws/rsocket.d.ts +4 -0
  71. package/www/example/ws/rsocket.js +47 -0
  72. package/www/example/ws/test.d.ts +6 -1
  73. package/www/example/ws/test.js +10 -3
package/lib/db.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Project: Kebab, User: JianSuoQiYue
4
4
  * Date: 2019-4-15 13:40
5
- * Last: 2020-4-13 15:34:45, 2022-09-12 13:10:34, 2023-5-24 18:29:38, 2024-7-11 14:37:54, 2024-8-25 00:32:53, 2024-9-22 17:30:47
5
+ * Last: 2020-4-13 15:34:45, 2022-09-12 13:10:34, 2023-5-24 18:29:38, 2024-7-11 14:37:54, 2024-8-25 00:32:53, 2024-9-22 17:30:47, 2025-8-3 20:24:03
6
6
  */
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
8
  if (k2 === undefined) k2 = k;
@@ -45,11 +45,11 @@ exports.getConnectionList = getConnectionList;
45
45
  // --- 第三方 ---
46
46
  const mysql2 = __importStar(require("mysql2/promise"));
47
47
  // --- 库和定义 ---
48
- const time = __importStar(require("../lib/time"));
49
- const lSql = __importStar(require("../lib/sql"));
50
- const core = __importStar(require("../lib/core"));
51
- const text = __importStar(require("../lib/text"));
52
- const ctr = __importStar(require("../sys/ctr"));
48
+ const time = __importStar(require("~/lib/time"));
49
+ const lSql = __importStar(require("~/lib/sql"));
50
+ const lCore = __importStar(require("~/lib/core"));
51
+ const lText = __importStar(require("~/lib/text"));
52
+ const ctr = __importStar(require("~/sys/ctr"));
53
53
  /** --- 连接列表池 --- */
54
54
  const connections = [];
55
55
  /**
@@ -71,23 +71,14 @@ async function checkConnection() {
71
71
  if (connection.getLast() <= now - 60) {
72
72
  // --- 1 分钟之前开始的 ---
73
73
  const ls = connection.getLastSql();
74
- const sql = ls[1] ?? ls[0];
75
- console.log(`[child] [db] [error] There is a transactional connection[${i}] that is not closed, last sql: ${sql?.sql ?? 'undefined'}.`);
76
74
  const newarr = ls.map(item => {
77
75
  if (!item.values) {
78
76
  return item.sql;
79
77
  }
80
78
  return lSql.format(item.sql, item.values);
81
79
  });
82
- await core.log({
83
- 'path': '',
84
- 'urlFull': '',
85
- 'hostname': '',
86
- 'req': null,
87
- 'get': {},
88
- 'cookie': {},
89
- 'headers': {}
90
- }, `(db.checkConnection)There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`, '-error');
80
+ lCore.display(`[DB][error] There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`);
81
+ lCore.log({}, `[DB][checkConnection] There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`, '-error');
91
82
  await connection.rollback();
92
83
  }
93
84
  continue;
@@ -103,12 +94,12 @@ async function checkConnection() {
103
94
  --i;
104
95
  }
105
96
  setTimeout(function () {
106
- checkConnection().catch(e => { console.log('[DB]', e); });
107
- }, 30000);
97
+ checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
98
+ }, 30_000);
108
99
  }
109
100
  setTimeout(function () {
110
- checkConnection().catch(e => { console.log('[DB]', e); });
111
- }, 30000);
101
+ checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
102
+ }, 30_000);
112
103
  /** --- 数据库连接池对象 --- */
113
104
  class Pool {
114
105
  constructor(etc) {
@@ -209,7 +200,7 @@ class Pool {
209
200
  c.using();
210
201
  link.on('error', function (err) {
211
202
  if (err.code !== 'PROTOCOL_CONNECTION_LOST') {
212
- console.log(err);
203
+ lCore.display('[DB][_getConnection]', err);
213
204
  }
214
205
  c.setLost();
215
206
  }).on('end', function () {
@@ -219,15 +210,7 @@ class Pool {
219
210
  connections.push(conn);
220
211
  }
221
212
  catch (e) {
222
- await core.log({
223
- 'path': '',
224
- 'urlFull': '',
225
- 'hostname': '',
226
- 'req': null,
227
- 'get': {},
228
- 'cookie': {},
229
- 'headers': {}
230
- }, '(db._getConnection)' + text.stringifyJson(e.stack).slice(1, -1), '-error');
213
+ lCore.log({}, '[DB][Pool][_getConnection]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
231
214
  }
232
215
  }
233
216
  return conn;
@@ -260,12 +243,12 @@ class Transaction {
260
243
  const warning = opts.warning ?? 1_500;
261
244
  this._timer.warning = setTimeout(() => {
262
245
  this._timer.warning = undefined;
263
- console.log('[WARNING][DB][Transaction] time too long, ms:', warning, this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
246
+ lCore.display('[WARNING][DB][Transaction] time too long, ms: ' + warning + ' ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
264
247
  }, warning);
265
248
  const danger = opts.danger ?? 5_000;
266
249
  this._timer.danger = setTimeout(() => {
267
250
  this._timer.danger = undefined;
268
- console.log('[DANGER][DB][Transaction] time too long, ms:', danger, this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
251
+ lCore.display('[DANGER][DB][Transaction] time too long, ms:', danger, this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
269
252
  }, danger);
270
253
  }
271
254
  /**
@@ -276,16 +259,8 @@ class Transaction {
276
259
  async query(sql, values) {
277
260
  if (!this._conn) {
278
261
  // --- 当前连接已不可用 ---
279
- console.log('[ERROR][DB][Transaction.query] has been closed.', this._ctr?.getPrototype('_config').const.path ?? 'no ctr', sql);
280
- await core.log({
281
- 'path': '',
282
- 'urlFull': '',
283
- 'hostname': '',
284
- 'req': null,
285
- 'get': {},
286
- 'cookie': {},
287
- 'headers': {}
288
- }, '(db.Transaction.query) has been closed, ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
262
+ lCore.display('[DB][Transaction][query] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql);
263
+ lCore.log({}, '[DB][Transaction][query] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
289
264
  return {
290
265
  'rows': null,
291
266
  'fields': [],
@@ -306,16 +281,8 @@ class Transaction {
306
281
  async execute(sql, values) {
307
282
  if (!this._conn) {
308
283
  // --- 当前连接已不可用 ---
309
- console.log('[ERROR][DB][Transaction.execute] has been closed.', this._ctr?.getPrototype('_config').const.path ?? 'no ctr', sql);
310
- await core.log({
311
- 'path': '',
312
- 'urlFull': '',
313
- 'hostname': '',
314
- 'req': null,
315
- 'get': {},
316
- 'cookie': {},
317
- 'headers': {}
318
- }, '(db.Transaction.execute) has been closed, ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
284
+ lCore.display('[DB][Transaction][execute] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql);
285
+ lCore.log({}, '(db.Transaction.execute) has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
319
286
  return {
320
287
  'packet': null,
321
288
  'fields': [],
@@ -331,16 +298,8 @@ class Transaction {
331
298
  async commit() {
332
299
  if (!this._conn) {
333
300
  // --- 当前连接已不可用 ---
334
- console.log('[ERROR][DB][Transaction.commit] has been closed.', this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
335
- await core.log({
336
- 'path': '',
337
- 'urlFull': '',
338
- 'hostname': '',
339
- 'req': null,
340
- 'get': {},
341
- 'cookie': {},
342
- 'headers': {}
343
- }, '(db.Transaction.commit) has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
301
+ lCore.display('[DB][Transaction][commit] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
302
+ lCore.log({}, '[DB][Transaction][commit] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
344
303
  return false;
345
304
  }
346
305
  const r = await this._conn.commit();
@@ -360,16 +319,8 @@ class Transaction {
360
319
  async rollback() {
361
320
  if (!this._conn) {
362
321
  // --- 当前连接已不可用 ---
363
- console.log('[ERROR][DB][Transaction.rollback] has been closed.', this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
364
- await core.log({
365
- 'path': '',
366
- 'urlFull': '',
367
- 'hostname': '',
368
- 'req': null,
369
- 'get': {},
370
- 'cookie': {},
371
- 'headers': {}
372
- }, '(db.Transaction.rollback) has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
322
+ lCore.display('[DB][Transaction][rollback] has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
323
+ lCore.log({}, '[DB][Transaction][rollback] has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
373
324
  return false;
374
325
  }
375
326
  const r = await this._conn.rollback();
@@ -501,7 +452,11 @@ class Connection {
501
452
  'sql': sql,
502
453
  'values': values
503
454
  });
455
+ const time = Date.now();
504
456
  res = await this._link.query(sql, values);
457
+ if (Date.now() - time > 200) {
458
+ lCore.log({}, '[WARNING][DB][Connection][query] slow sql 200ms: ' + sql, '-warning');
459
+ }
505
460
  }
506
461
  catch (e) {
507
462
  if (!this._transaction) {
@@ -539,7 +494,11 @@ class Connection {
539
494
  'sql': sql,
540
495
  'values': values
541
496
  });
497
+ const time = Date.now();
542
498
  res = await this._link.execute(sql, values);
499
+ if (Date.now() - time > 200) {
500
+ lCore.log({}, '[WARNING][DB][Connection][execute] slow sql 200ms: ' + sql, '-warning');
501
+ }
543
502
  }
544
503
  catch (e) {
545
504
  if (!this._transaction) {
package/lib/dns.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Date: 2019-6-19
4
4
  * Last: 2022-09-12 20:58:07, 2024-2-21 17:55:54, 2025-6-13 19:08:56
5
5
  */
6
- import * as ctr from '../sys/ctr';
6
+ import * as ctr from '~/sys/ctr';
7
7
  /**
8
8
  * 0.DNSPod:https://www.dnspod.cn/docs/index.html(腾讯云也请使用 DNSPod 的 API)
9
9
  * 1.阿里云:https://help.aliyun.com/document_detail/29745.html
package/lib/dns.js CHANGED
@@ -41,11 +41,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.Dns = exports.ERecordLine = exports.RECORD_TYPE = exports.ESERVICE = void 0;
42
42
  exports.get = get;
43
43
  // --- 库和定义 ---
44
- const net = __importStar(require("../lib/net"));
45
- const core = __importStar(require("../lib/core"));
46
- const text = __importStar(require("../lib/text"));
47
- const crypto = __importStar(require("../lib/crypto"));
48
- const response = __importStar(require("../lib/net/response"));
44
+ const net = __importStar(require("~/lib/net"));
45
+ const core = __importStar(require("~/lib/core"));
46
+ const text = __importStar(require("~/lib/text"));
47
+ const crypto = __importStar(require("~/lib/crypto"));
48
+ const response = __importStar(require("~/lib/net/response"));
49
49
  /**
50
50
  * 0.DNSPod:https://www.dnspod.cn/docs/index.html(腾讯云也请使用 DNSPod 的 API)
51
51
  * 1.阿里云:https://help.aliyun.com/document_detail/29745.html
package/lib/fs.js CHANGED
@@ -75,8 +75,8 @@ async function getContent(path, options) {
75
75
  'encoding': options
76
76
  };
77
77
  }
78
- else if (!options) {
79
- options = {};
78
+ else {
79
+ options ??= {};
80
80
  }
81
81
  const encoding = options.encoding;
82
82
  const start = options.start;
@@ -337,6 +337,16 @@ async function readDir(path, encoding) {
337
337
  }
338
338
  list.push(item);
339
339
  }
340
+ // --- 将 list 根据先目录后文件排序,如果是同是目录或文件,则以名称排序 ---
341
+ list.sort((a, b) => {
342
+ // --- 目录排在文件前面 ---
343
+ if (a.isDirectory() && !b.isDirectory())
344
+ return -1;
345
+ if (!a.isDirectory() && b.isDirectory())
346
+ return 1;
347
+ // --- 同类型按名称排序 ---
348
+ return a.name.localeCompare(b.name);
349
+ });
340
350
  return list;
341
351
  }
342
352
  catch {
@@ -413,8 +423,8 @@ function createReadStream(path, options) {
413
423
  'encoding': options
414
424
  };
415
425
  }
416
- else if (!options) {
417
- options = {};
426
+ else {
427
+ options ??= {};
418
428
  }
419
429
  return fs.createReadStream(path, {
420
430
  'flags': options.flags,
@@ -450,8 +460,8 @@ function createWriteStream(path, options) {
450
460
  'encoding': options
451
461
  };
452
462
  }
453
- else if (!options) {
454
- options = {};
463
+ else {
464
+ options ??= {};
455
465
  }
456
466
  return fs.createWriteStream(path, {
457
467
  'flags': options.flags,
@@ -469,9 +479,7 @@ function createWriteStream(path, options) {
469
479
  * @param stat 文件的 stat(如果有)
470
480
  */
471
481
  async function readToResponse(path, req, res, stat) {
472
- if (!stat) {
473
- stat = await stats(path);
474
- }
482
+ stat ??= await stats(path);
475
483
  if (!stat) {
476
484
  res.setHeader('content-length', 22);
477
485
  res.writeHead(404);
package/lib/jwt.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Date: 2023-1-31 20:34:47
4
4
  * Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
5
5
  */
6
- import * as kv from '../lib/kv';
7
- import * as ctr from '../sys/ctr';
8
- import * as types from '../types';
6
+ import * as kv from '~/lib/kv';
7
+ import * as ctr from '~/sys/ctr';
8
+ import * as types from '~/types';
9
9
  export interface IOptions {
10
10
  'name'?: string;
11
11
  'ttl'?: number;
package/lib/jwt.js CHANGED
@@ -44,10 +44,10 @@ exports.decode = decode;
44
44
  exports.block = block;
45
45
  exports.get = get;
46
46
  // --- 库和定义 ---
47
- const lCore = __importStar(require("../lib/core"));
48
- const lTime = __importStar(require("../lib/time"));
49
- const lText = __importStar(require("../lib/text"));
50
- const lCrypto = __importStar(require("../lib/crypto"));
47
+ const lCore = __importStar(require("~/lib/core"));
48
+ const lTime = __importStar(require("~/lib/time"));
49
+ const lText = __importStar(require("~/lib/text"));
50
+ const lCrypto = __importStar(require("~/lib/crypto"));
51
51
  class Jwt {
52
52
  /**
53
53
  * --- 初始化函数,相当于 construct ---
@@ -98,7 +98,7 @@ class Jwt {
98
98
  renew() {
99
99
  const time = lTime.stamp();
100
100
  const data = this._ctr.getPrototype('_jwt');
101
- const token = data['token'] ? data['token'] : lCore.random(16, lCore.RANDOM_LUN);
101
+ const token = lText.isFalsy(data['token']) ? lCore.random(16, lCore.RANDOM_LUN) : data['token'];
102
102
  data['exp'] = time + this._ttl;
103
103
  data['token'] = token;
104
104
  // --- 拼装 ---
package/lib/kv.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * Last: 2020-3-28 18:54:04, 2022-09-12 23:24:45, 2022-09-22 01:06:22, 2024-2-21 13:32:56, 2024-8-21 16:59:57
5
5
  */
6
6
  import * as redis from '@litert/redis';
7
- import * as ctr from '../sys/ctr';
8
- import * as types from '../types';
7
+ import * as ctr from '~/sys/ctr';
8
+ import * as types from '~/types';
9
9
  /** --- 连接信息 --- */
10
10
  export interface IConnectionInfo {
11
11
  'id': number;
package/lib/kv.js CHANGED
@@ -46,8 +46,8 @@ exports.getConnectionList = getConnectionList;
46
46
  // --- 第三方 ---
47
47
  const redis = __importStar(require("@litert/redis"));
48
48
  // --- 库和定义 ---
49
- const time = __importStar(require("../lib/time"));
50
- const text = __importStar(require("../lib/text"));
49
+ const time = __importStar(require("~/lib/time"));
50
+ const text = __importStar(require("~/lib/text"));
51
51
  /** --- 连接列表(同一个 host、port、index、auth 只有一个连接) --- */
52
52
  const connections = [];
53
53
  /**
package/lib/lan.js CHANGED
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.card = card;
37
37
  exports.scan = scan;
38
38
  const os = __importStar(require("os"));
39
- const lCore = __importStar(require("../lib/core"));
39
+ const lCore = __importStar(require("~/lib/core"));
40
40
  /**
41
41
  * --- 获取当前网卡的 IP、MAC 信息 ---
42
42
  */
@@ -41,8 +41,8 @@ exports.FormData = void 0;
41
41
  */
42
42
  const stream = __importStar(require("stream"));
43
43
  const mime = __importStar(require("@litert/mime"));
44
- const core = __importStar(require("../../lib/core"));
45
- const fs = __importStar(require("../../lib/fs"));
44
+ const core = __importStar(require("~/lib/core"));
45
+ const fs = __importStar(require("~/lib/fs"));
46
46
  class FormData extends stream.Readable {
47
47
  constructor() {
48
48
  super(...arguments);
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import * as stream from 'stream';
7
7
  import * as response from './response';
8
- import * as types from '../../types';
8
+ import * as types from '~/types';
9
9
  export declare class Request {
10
10
  /** --- get 或 post 的数据 --- */
11
11
  private _data;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Request = void 0;
37
- const net = __importStar(require("../../lib/net"));
37
+ const net = __importStar(require("~/lib/net"));
38
38
  class Request {
39
39
  constructor(url) {
40
40
  /** --- get 或 post 的数据 --- */
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import * as hc from '@litert/http-client';
7
7
  import * as nStream from 'stream';
8
- import * as types from '../../types';
8
+ import * as types from '~/types';
9
9
  export declare class Response {
10
10
  /** --- httpClient 请求对象 --- */
11
11
  private readonly _req;
package/lib/net.d.ts CHANGED
@@ -7,8 +7,8 @@
7
7
  import * as stream from 'stream';
8
8
  import * as http from 'http';
9
9
  import * as http2 from 'http2';
10
- import * as ctr from '../sys/ctr';
11
- import * as types from '../types';
10
+ import * as ctr from '~/sys/ctr';
11
+ import * as types from '~/types';
12
12
  import * as fd from './net/formdata';
13
13
  import * as lRequest from './net/request';
14
14
  import * as response from './net/response';
package/lib/net.js CHANGED
@@ -57,10 +57,10 @@ const stream = __importStar(require("stream"));
57
57
  // --- 第三方 ---
58
58
  const hc = __importStar(require("@litert/http-client"));
59
59
  // --- 库和定义 ---
60
- const fs = __importStar(require("../lib/fs"));
61
- const text = __importStar(require("../lib/text"));
62
- const time = __importStar(require("../lib/time"));
63
- const kebab = __importStar(require("../index"));
60
+ const fs = __importStar(require("~/lib/fs"));
61
+ const text = __importStar(require("~/lib/text"));
62
+ const time = __importStar(require("~/lib/time"));
63
+ const kebab = __importStar(require("~/index"));
64
64
  // --- 自己 ---
65
65
  const fd = __importStar(require("./net/formdata"));
66
66
  const lRequest = __importStar(require("./net/request"));
package/lib/s3.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import * as s3 from '@aws-sdk/client-s3';
7
7
  import * as stream from 'stream';
8
- import * as sCtr from '../sys/ctr';
8
+ import * as sCtr from '~/sys/ctr';
9
9
  /**
10
10
  * s3 文档:https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
11
11
  */
package/lib/s3.js CHANGED
@@ -43,8 +43,8 @@ exports.get = get;
43
43
  // --- 库和定义 ---
44
44
  const s3 = __importStar(require("@aws-sdk/client-s3"));
45
45
  const ls = __importStar(require("@aws-sdk/lib-storage"));
46
- const lCore = __importStar(require("../lib/core"));
47
- const lText = __importStar(require("../lib/text"));
46
+ const lCore = __importStar(require("~/lib/core"));
47
+ const lText = __importStar(require("~/lib/text"));
48
48
  /**
49
49
  * s3 文档:https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
50
50
  */
@@ -136,7 +136,7 @@ class S3 {
136
136
  return (res.Location && res.Bucket && res.Key) ? res : false;
137
137
  }
138
138
  catch (e) {
139
- await lCore.log(this._ctr, '[putObject, s3] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
139
+ lCore.log(this._ctr, '[S3][putObject] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
140
140
  return false;
141
141
  }
142
142
  }
@@ -196,7 +196,7 @@ class S3 {
196
196
  return true;
197
197
  }
198
198
  catch (e) {
199
- await lCore.log(this._ctr, '[deleteObjects, s3] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
199
+ lCore.log(this._ctr, '[S3][deleteObjects] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
200
200
  return false;
201
201
  }
202
202
  }
@@ -215,7 +215,7 @@ class S3 {
215
215
  }
216
216
  catch (e) {
217
217
  if (e.$metadata?.httpStatusCode !== 404) {
218
- await lCore.log(this._ctr, '[headObject, s3] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
218
+ lCore.log(this._ctr, '[S3][headObject] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
219
219
  }
220
220
  return false;
221
221
  }
package/lib/scan.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Date: 2022-09-24 15:23:25
4
4
  * Last: 2022-09-24 15:23:25, 2022-9-26 12:37:01, 2022-12-29 00:11:16
5
5
  */
6
- import * as lDb from '../lib/db';
7
- import * as lKv from '../lib/kv';
8
- import * as sCtr from '../sys/ctr';
6
+ import * as lDb from '~/lib/db';
7
+ import * as lKv from '~/lib/kv';
8
+ import * as sCtr from '~/sys/ctr';
9
9
  /** --- Scan 设置的选项 --- */
10
10
  export interface IOptions {
11
11
  'ttl'?: number;
package/lib/scan.js CHANGED
@@ -56,12 +56,12 @@ CREATE TABLE IF NOT EXISTS `scan` (
56
56
  KEY `time_exp` (`time_exp`)
57
57
  ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
58
58
  */
59
- const lCore = __importStar(require("../lib/core"));
60
- const lDb = __importStar(require("../lib/db"));
61
- const lKv = __importStar(require("../lib/kv"));
62
- const lSql = __importStar(require("../lib/sql"));
63
- const lTime = __importStar(require("../lib/time"));
64
- const lText = __importStar(require("../lib/text"));
59
+ const lCore = __importStar(require("~/lib/core"));
60
+ const lDb = __importStar(require("~/lib/db"));
61
+ const lKv = __importStar(require("~/lib/kv"));
62
+ const lSql = __importStar(require("~/lib/sql"));
63
+ const lTime = __importStar(require("~/lib/time"));
64
+ const lText = __importStar(require("~/lib/text"));
65
65
  class Scan {
66
66
  constructor(link, token, opt = {}) {
67
67
  this._sql = null;
package/lib/session.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Date: 2019-6-5 22:01:40
4
4
  * Last: 2020-3-30 00:11:15, 2022-12-29 00:10:28, 2023-5-24 18:59:27
5
5
  */
6
- import * as db from '../lib/db';
7
- import * as kv from '../lib/kv';
8
- import * as ctr from '../sys/ctr';
6
+ import * as db from '~/lib/db';
7
+ import * as kv from '~/lib/kv';
8
+ import * as ctr from '~/sys/ctr';
9
9
  export interface IOptions {
10
10
  'name'?: string;
11
11
  'ttl'?: number;
package/lib/session.js CHANGED
@@ -53,12 +53,12 @@ CREATE TABLE `session` (
53
53
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
54
54
  */
55
55
  // --- 库和定义 ---
56
- const core = __importStar(require("../lib/core"));
57
- const time = __importStar(require("../lib/time"));
58
- const db = __importStar(require("../lib/db"));
59
- const kv = __importStar(require("../lib/kv"));
60
- const sql = __importStar(require("../lib/sql"));
61
- const text = __importStar(require("../lib/text"));
56
+ const core = __importStar(require("~/lib/core"));
57
+ const time = __importStar(require("~/lib/time"));
58
+ const db = __importStar(require("~/lib/db"));
59
+ const kv = __importStar(require("~/lib/kv"));
60
+ const sql = __importStar(require("~/lib/sql"));
61
+ const text = __importStar(require("~/lib/text"));
62
62
  class Session {
63
63
  constructor() {
64
64
  /** --- 当前 Session 的 token --- */
@@ -93,7 +93,7 @@ class Session {
93
93
  }
94
94
  this._link = link;
95
95
  if (link instanceof db.Pool) {
96
- this._sql = sql.get(pre ? pre : ctr);
96
+ this._sql = sql.get(pre ?? ctr);
97
97
  await this._gc(); // --- 执行 gc ---
98
98
  }
99
99
  // --- 初始化 Session 数组 ---
package/lib/sql.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-5-27 20:18:50
4
- * Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28
4
+ * Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28, 2025-8-3 21:28:18
5
5
  */
6
- import * as ctr from '../sys/ctr';
7
- import * as types from '../types';
6
+ import * as ctr from '~/sys/ctr';
7
+ import * as types from '~/types';
8
8
  export declare class Sql {
9
9
  /** --- 前置 --- */
10
10
  private readonly _pre;