@kevisual/cli 0.1.1 → 0.1.3

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.
@@ -43,11 +43,11 @@ var __export = (target, all) => {
43
43
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
44
44
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
45
45
 
46
- // ../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
46
+ // ../node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.json
47
47
  var require_package = __commonJS((exports, module) => {
48
48
  module.exports = {
49
49
  name: "dotenv",
50
- version: "17.2.3",
50
+ version: "17.3.1",
51
51
  description: "Loads environment variables from .env file",
52
52
  main: "lib/main.js",
53
53
  types: "lib/main.d.ts",
@@ -109,7 +109,7 @@ var require_package = __commonJS((exports, module) => {
109
109
  };
110
110
  });
111
111
 
112
- // ../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
112
+ // ../node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.js
113
113
  var require_main = __commonJS((exports, module) => {
114
114
  var fs2 = __require("fs");
115
115
  var path = __require("path");
@@ -121,12 +121,9 @@ var require_main = __commonJS((exports, module) => {
121
121
  "\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
122
122
  "\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
123
123
  "\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
124
- "\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
125
- "\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
126
- "\uD83D\uDDC2backup and recover secrets: https://dotenvx.com/ops",
127
- "✅ audit secrets and track compliance: https://dotenvx.com/ops",
128
- "\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
129
- "\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
124
+ "\uD83E\uDD16 agentic secret storage: https://dotenvx.com/as2",
125
+ "⚡️ secrets for agents: https://dotenvx.com/as2",
126
+ "\uD83D\uDEE1auth for agents: https://vestauth.com",
130
127
  "\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
131
128
  "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
132
129
  "⚙️ enable debug logging with { debug: true }",
@@ -11435,17 +11432,6 @@ var require_db = __commonJS((exports, module) => {
11435
11432
  };
11436
11433
  });
11437
11434
 
11438
- // ../node_modules/.pnpm/mime-db@1.54.0/node_modules/mime-db/index.js
11439
- var require_mime_db = __commonJS((exports, module) => {
11440
- /*!
11441
- * mime-db
11442
- * Copyright(c) 2014 Jonathan Ong
11443
- * Copyright(c) 2015-2022 Douglas Christopher Wilson
11444
- * MIT Licensed
11445
- */
11446
- module.exports = require_db();
11447
- });
11448
-
11449
11435
  // ../node_modules/.pnpm/mime-types@3.0.2/node_modules/mime-types/mimeScore.js
11450
11436
  var require_mimeScore = __commonJS((exports, module) => {
11451
11437
  var FACET_SCORES = {
@@ -11490,7 +11476,7 @@ var require_mime_types = __commonJS((exports) => {
11490
11476
  * Copyright(c) 2015 Douglas Christopher Wilson
11491
11477
  * MIT Licensed
11492
11478
  */
11493
- var db = require_mime_db();
11479
+ var db = require_db();
11494
11480
  var extname = __require("path").extname;
11495
11481
  var mimeScore = require_mimeScore();
11496
11482
  var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
@@ -11900,7 +11886,7 @@ var require_send = __commonJS((exports, module) => {
11900
11886
  this._root = opts.root ? resolve(opts.root) : null;
11901
11887
  }
11902
11888
  util.inherits(SendStream, Stream);
11903
- SendStream.prototype.error = function error(status, err) {
11889
+ SendStream.prototype.error = function error2(status, err) {
11904
11890
  if (hasListeners(this, "error")) {
11905
11891
  return this.emit("error", createHttpError(status, err));
11906
11892
  }
@@ -12015,7 +12001,7 @@ var require_send = __commonJS((exports, module) => {
12015
12001
  res.setHeader("Location", loc);
12016
12002
  res.end(doc);
12017
12003
  };
12018
- SendStream.prototype.pipe = function pipe(res) {
12004
+ SendStream.prototype.pipe = function pipe2(res) {
12019
12005
  var root = this._root;
12020
12006
  this.res = res;
12021
12007
  var path5 = decode2(this.path);
@@ -12069,7 +12055,7 @@ var require_send = __commonJS((exports, module) => {
12069
12055
  this.sendFile(path5);
12070
12056
  return res;
12071
12057
  };
12072
- SendStream.prototype.send = function send(path5, stat) {
12058
+ SendStream.prototype.send = function send2(path5, stat) {
12073
12059
  var len = stat.size;
12074
12060
  var options = this.options;
12075
12061
  var opts = {};
@@ -12191,21 +12177,21 @@ var require_send = __commonJS((exports, module) => {
12191
12177
  }
12192
12178
  next();
12193
12179
  };
12194
- SendStream.prototype.stream = function stream(path5, options) {
12180
+ SendStream.prototype.stream = function stream2(path5, options) {
12195
12181
  var self2 = this;
12196
12182
  var res = this.res;
12197
- var stream2 = fs5.createReadStream(path5, options);
12198
- this.emit("stream", stream2);
12199
- stream2.pipe(res);
12183
+ var stream3 = fs5.createReadStream(path5, options);
12184
+ this.emit("stream", stream3);
12185
+ stream3.pipe(res);
12200
12186
  function cleanup() {
12201
- stream2.destroy();
12187
+ stream3.destroy();
12202
12188
  }
12203
12189
  onFinished(res, cleanup);
12204
- stream2.on("error", function onerror(err) {
12190
+ stream3.on("error", function onerror(err) {
12205
12191
  cleanup();
12206
12192
  self2.onStatError(err);
12207
12193
  });
12208
- stream2.on("end", function onend() {
12194
+ stream3.on("end", function onend() {
12209
12195
  self2.emit("end");
12210
12196
  });
12211
12197
  };
@@ -12214,9 +12200,9 @@ var require_send = __commonJS((exports, module) => {
12214
12200
  if (res.getHeader("Content-Type"))
12215
12201
  return;
12216
12202
  var ext = extname(path5);
12217
- var type = mime.contentType(ext) || "application/octet-stream";
12218
- debug("content-type %s", type);
12219
- res.setHeader("Content-Type", type);
12203
+ var type2 = mime.contentType(ext) || "application/octet-stream";
12204
+ debug("content-type %s", type2);
12205
+ res.setHeader("Content-Type", type2);
12220
12206
  };
12221
12207
  SendStream.prototype.setHeader = function setHeader(path5, stat) {
12222
12208
  var res = this.res;
@@ -12463,7 +12449,7 @@ var require_is_extglob = __commonJS((exports, module) => {
12463
12449
  * Copyright (c) 2014-2016, Jon Schlinkert.
12464
12450
  * Licensed under the MIT License.
12465
12451
  */
12466
- module.exports = function isExtglob(str) {
12452
+ module.exports = function isExtglob2(str) {
12467
12453
  if (typeof str !== "string" || str === "") {
12468
12454
  return false;
12469
12455
  }
@@ -12597,7 +12583,7 @@ var require_is_glob = __commonJS((exports, module) => {
12597
12583
  }
12598
12584
  return false;
12599
12585
  };
12600
- module.exports = function isGlob(str, options) {
12586
+ module.exports = function isGlob2(str, options) {
12601
12587
  if (typeof str !== "string" || str === "") {
12602
12588
  return false;
12603
12589
  }
@@ -12622,7 +12608,7 @@ var require_glob_parent = __commonJS((exports, module) => {
12622
12608
  var enclosure = /[\{\[].*[\}\]]$/;
12623
12609
  var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
12624
12610
  var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
12625
- module.exports = function globParent(str, opts) {
12611
+ module.exports = function globParent2(str, opts) {
12626
12612
  var options = Object.assign({ flipBackslashes: true }, opts);
12627
12613
  if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
12628
12614
  str = str.replace(backslash, slash);
@@ -17807,13 +17793,6 @@ var require_cli_width = __commonJS((exports, module) => {
17807
17793
  }
17808
17794
  });
17809
17795
 
17810
- // ../node_modules/.pnpm/emoji-regex@10.6.0/node_modules/emoji-regex/index.js
17811
- var require_emoji_regex = __commonJS((exports, module) => {
17812
- module.exports = () => {
17813
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
17814
- };
17815
- });
17816
-
17817
17796
  // ../node_modules/.pnpm/mute-stream@3.0.0/node_modules/mute-stream/lib/index.js
17818
17797
  var require_lib = __commonJS((exports, module) => {
17819
17798
  var Stream = __require("stream");
@@ -38888,7 +38867,7 @@ function requireStream() {
38888
38867
  if (!duplex.push(data))
38889
38868
  ws.pause();
38890
38869
  });
38891
- ws.once("error", function error(err) {
38870
+ ws.once("error", function error2(err) {
38892
38871
  if (duplex.destroyed)
38893
38872
  return;
38894
38873
  terminateOnDestroy = false;
@@ -38906,7 +38885,7 @@ function requireStream() {
38906
38885
  return;
38907
38886
  }
38908
38887
  let called = false;
38909
- ws.once("error", function error(err2) {
38888
+ ws.once("error", function error2(err2) {
38910
38889
  called = true;
38911
38890
  callback(err2);
38912
38891
  });
@@ -39915,12 +39894,12 @@ function requireDist() {
39915
39894
  const { encode: encode2 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
39916
39895
  const data = typeof path === "object" ? path : parse2(path, options);
39917
39896
  const fn = tokensToFunction(data.tokens, delimiter, encode2);
39918
- return function path(params = {}) {
39919
- const [path2, ...missing] = fn(params);
39897
+ return function path2(params = {}) {
39898
+ const [path3, ...missing] = fn(params);
39920
39899
  if (missing.length) {
39921
39900
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
39922
39901
  }
39923
- return path2;
39902
+ return path3;
39924
39903
  };
39925
39904
  }
39926
39905
  function tokensToFunction(tokens, delimiter, encode2) {
@@ -39986,7 +39965,7 @@ function requireDist() {
39986
39965
  return decode2;
39987
39966
  return (value) => value.split(delimiter).map(decode2);
39988
39967
  });
39989
- return function match(input) {
39968
+ return function match2(input) {
39990
39969
  const m = regexp.exec(input);
39991
39970
  if (!m)
39992
39971
  return false;
@@ -40607,14 +40586,15 @@ var parseHomeArg = (homedir2) => {
40607
40586
  const isOpencode = checkUrl.some((item) => execPath.includes(item));
40608
40587
  let isServer = false;
40609
40588
  const checkArgs = process.argv.slice(1);
40610
- const isArgsServer = checkArgs.some((item) => item === "server" || item.includes("asst-server") || item.includes("run-server.ts"));
40611
40589
  const isDev = checkArgs.some((item) => item.includes("run-server.ts"));
40590
+ const isPm2 = checkArgs.some((item) => item.includes("pm2"));
40591
+ const isArgsServer = checkArgs.some((item) => item === "server" || item.includes("asst-server") || item.includes("assistant-server") || item.includes("run-server.ts"));
40612
40592
  let isDaemon = false;
40613
- if (isArgsServer) {
40593
+ if (isArgsServer || isPm2) {
40614
40594
  if (checkArgs.includes("--daemon") || checkArgs.includes("-d")) {
40615
40595
  isDaemon = true;
40616
40596
  }
40617
- if (checkArgs.includes("-s") || checkArgs.includes("--start")) {
40597
+ if (checkArgs.includes("-s") || checkArgs.includes("--start") || isPm2) {
40618
40598
  isServer = true;
40619
40599
  }
40620
40600
  }
@@ -40634,7 +40614,7 @@ var getFileConfig = (filePath) => {
40634
40614
  return JSON.parse(fs2.readFileSync(filePath, "utf8"));
40635
40615
  };
40636
40616
 
40637
- // ../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
40617
+ // ../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.3.1/node_modules/@kevisual/use-config/dist/app.js
40638
40618
  import { createRequire as createRequire2 } from "node:module";
40639
40619
  import fs3 from "node:fs";
40640
40620
  import path2 from "node:path";
@@ -42936,7 +42916,7 @@ function requireIsExtglob() {
42936
42916
  if (hasRequiredIsExtglob)
42937
42917
  return isExtglob;
42938
42918
  hasRequiredIsExtglob = 1;
42939
- isExtglob = function isExtglob(str) {
42919
+ isExtglob = function isExtglob2(str) {
42940
42920
  if (typeof str !== "string" || str === "") {
42941
42921
  return false;
42942
42922
  }
@@ -43074,7 +43054,7 @@ function requireIsGlob() {
43074
43054
  }
43075
43055
  return false;
43076
43056
  };
43077
- isGlob = function isGlob(str, options) {
43057
+ isGlob = function isGlob2(str, options) {
43078
43058
  if (typeof str !== "string" || str === "") {
43079
43059
  return false;
43080
43060
  }
@@ -43103,7 +43083,7 @@ function requireGlobParent() {
43103
43083
  var enclosure = /[\{\[].*[\}\]]$/;
43104
43084
  var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
43105
43085
  var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
43106
- globParent = function globParent(str, opts) {
43086
+ globParent = function globParent2(str, opts) {
43107
43087
  var options = Object.assign({ flipBackslashes: true }, opts);
43108
43088
  if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
43109
43089
  str = str.replace(backslash, slash);
@@ -49680,6 +49660,14 @@ class RemoteApp {
49680
49660
  ws;
49681
49661
  remoteIsConnected;
49682
49662
  isError = false;
49663
+ autoReconnect;
49664
+ maxReconnectAttempts;
49665
+ reconnectDelay;
49666
+ maxReconnectDelay;
49667
+ enableBackoff;
49668
+ reconnectAttempts = 0;
49669
+ reconnectTimer = null;
49670
+ isManuallyClosed = false;
49683
49671
  constructor(opts) {
49684
49672
  this.mainApp = opts?.app;
49685
49673
  const token = opts.token;
@@ -49693,6 +49681,11 @@ class RemoteApp {
49693
49681
  _url2.searchParams.set("id", id2);
49694
49682
  this.url = _url2.toString();
49695
49683
  this.id = id2;
49684
+ this.autoReconnect = opts?.autoReconnect ?? true;
49685
+ this.maxReconnectAttempts = opts?.maxReconnectAttempts ?? Infinity;
49686
+ this.reconnectDelay = opts?.reconnectDelay ?? 1000;
49687
+ this.maxReconnectDelay = opts?.maxReconnectDelay ?? 30000;
49688
+ this.enableBackoff = opts?.enableBackoff ?? true;
49696
49689
  this.init();
49697
49690
  }
49698
49691
  async isConnect() {
@@ -49700,6 +49693,9 @@ class RemoteApp {
49700
49693
  if (this.isConnected) {
49701
49694
  return true;
49702
49695
  }
49696
+ if (this.reconnectTimer !== null) {
49697
+ console.log(`远程应用 ${this.id} 正在重连中...`);
49698
+ }
49703
49699
  return new Promise((resolve) => {
49704
49700
  const timeout = setTimeout(() => {
49705
49701
  resolve(false);
@@ -49716,6 +49712,9 @@ class RemoteApp {
49716
49712
  }
49717
49713
  getWsURL(url3) {
49718
49714
  const { protocol } = new URL(url3);
49715
+ if (protocol.startsWith("ws")) {
49716
+ return url3.toString();
49717
+ }
49719
49718
  const wsProtocol = protocol === "https:" ? "wss:" : "ws:";
49720
49719
  const wsURL = url3.toString().replace(protocol, wsProtocol);
49721
49720
  return wsURL;
@@ -49736,6 +49735,7 @@ class RemoteApp {
49736
49735
  ws.onopen = function() {
49737
49736
  that.isConnected = true;
49738
49737
  that.onOpen();
49738
+ console.log("[remote-app] WebSocket connection opened");
49739
49739
  };
49740
49740
  ws.onclose = function() {
49741
49741
  that.isConnected = false;
@@ -49750,12 +49750,71 @@ class RemoteApp {
49750
49750
  this.ws = ws;
49751
49751
  }
49752
49752
  onOpen() {
49753
+ this.isError = false;
49754
+ this.reconnectAttempts = 0;
49755
+ if (this.reconnectTimer) {
49756
+ clearTimeout(this.reconnectTimer);
49757
+ this.reconnectTimer = null;
49758
+ }
49753
49759
  this.emitter.emit("open", this.id);
49754
49760
  }
49755
49761
  onClose() {
49756
49762
  console.log("远程应用关闭:", this.id);
49757
- this.emitter.emit("close", this.id);
49758
49763
  this.isConnected = false;
49764
+ this.emitter.emit("close", this.id);
49765
+ if (this.autoReconnect && !this.isManuallyClosed) {
49766
+ this.scheduleReconnect();
49767
+ }
49768
+ }
49769
+ calculateReconnectDelay() {
49770
+ if (!this.enableBackoff) {
49771
+ return this.reconnectDelay;
49772
+ }
49773
+ const delay = this.reconnectDelay * Math.pow(2, this.reconnectAttempts);
49774
+ return Math.min(delay, this.maxReconnectDelay);
49775
+ }
49776
+ scheduleReconnect() {
49777
+ if (this.reconnectAttempts >= this.maxReconnectAttempts) {
49778
+ console.error(`远程应用 ${this.id} 已达到最大重连次数 ${this.maxReconnectAttempts},停止重连`);
49779
+ this.emitter.emit("maxReconnectAttemptsReached", this.id);
49780
+ return;
49781
+ }
49782
+ if (this.reconnectTimer) {
49783
+ clearTimeout(this.reconnectTimer);
49784
+ }
49785
+ const delay = this.calculateReconnectDelay();
49786
+ this.reconnectAttempts++;
49787
+ console.log(`远程应用 ${this.id} 将在 ${delay}ms 后尝试第 ${this.reconnectAttempts} 次重连`);
49788
+ this.reconnectTimer = setTimeout(() => {
49789
+ this.reconnectTimer = null;
49790
+ try {
49791
+ this.init();
49792
+ } catch (error3) {
49793
+ console.error(`远程应用 ${this.id} 重连失败:`, error3);
49794
+ this.emitter.emit("reconnectFailed", { id: this.id, attempt: this.reconnectAttempts, error: error3 });
49795
+ this.scheduleReconnect();
49796
+ }
49797
+ }, delay);
49798
+ }
49799
+ disconnect() {
49800
+ this.isManuallyClosed = true;
49801
+ this.autoReconnect = false;
49802
+ if (this.reconnectTimer) {
49803
+ clearTimeout(this.reconnectTimer);
49804
+ this.reconnectTimer = null;
49805
+ }
49806
+ if (this.ws) {
49807
+ this.ws.close();
49808
+ }
49809
+ }
49810
+ reconnect() {
49811
+ this.isManuallyClosed = false;
49812
+ this.reconnectAttempts = 0;
49813
+ if (this.reconnectTimer) {
49814
+ clearTimeout(this.reconnectTimer);
49815
+ this.reconnectTimer = null;
49816
+ }
49817
+ this.init();
49759
49818
  }
49760
49819
  onMessage(data) {
49761
49820
  this.emitter.emit("message", data);
@@ -49771,7 +49830,6 @@ class RemoteApp {
49771
49830
  this.emitter.off(event, listener);
49772
49831
  };
49773
49832
  }
49774
- sendData(data) {}
49775
49833
  json(data) {
49776
49834
  this.ws.send(JSON.stringify(data));
49777
49835
  }
@@ -49782,7 +49840,9 @@ class RemoteApp {
49782
49840
  try {
49783
49841
  const data = event.toString();
49784
49842
  const body = JSON.parse(data);
49785
- const message = body.data || {};
49843
+ const bodyData = body?.data;
49844
+ const message = bodyData?.message || {};
49845
+ const context = bodyData?.context || {};
49786
49846
  if (body?.code === 401) {
49787
49847
  console.error("远程应用认证失败,请检查 token 是否正确");
49788
49848
  this.isError = true;
@@ -49800,12 +49860,12 @@ class RemoteApp {
49800
49860
  });
49801
49861
  return;
49802
49862
  }
49803
- const res = await app.call(message);
49863
+ const res = await app.run(message, context);
49804
49864
  remoteApp.json({
49805
49865
  id: body.id,
49806
49866
  data: {
49807
49867
  code: res.code,
49808
- data: res.body,
49868
+ data: res.data,
49809
49869
  message: res.message
49810
49870
  }
49811
49871
  });
@@ -49836,7 +49896,7 @@ var getEnvToken = () => {
49836
49896
  return envTokne;
49837
49897
  };
49838
49898
 
49839
- // ../node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
49899
+ // ../node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query-browser.js
49840
49900
  var isTextForContentType = (contentType) => {
49841
49901
  if (!contentType)
49842
49902
  return false;
@@ -49865,12 +49925,12 @@ var adapter = async (opts = {}, overloadOpts) => {
49865
49925
  url3 = new URL(opts.url);
49866
49926
  } else {
49867
49927
  origin = window?.location?.origin || "http://localhost:51515";
49868
- url3 = new URL(opts.url, origin);
49928
+ url3 = new URL(opts?.url || "", origin);
49869
49929
  }
49870
49930
  const isGet = method === "GET";
49871
49931
  const oldSearchParams = url3.searchParams;
49872
49932
  if (isGet) {
49873
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
49933
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
49874
49934
  url3.search = searchParams.toString();
49875
49935
  } else {
49876
49936
  const params = {
@@ -49895,11 +49955,13 @@ var adapter = async (opts = {}, overloadOpts) => {
49895
49955
  } else if (isPostFile) {
49896
49956
  body = opts.body;
49897
49957
  } else {
49898
- headers = {
49899
- "Content-Type": "application/json",
49900
- ...headers
49901
- };
49902
- body = JSON.stringify(opts.body);
49958
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
49959
+ headers = {
49960
+ "Content-Type": "application/json",
49961
+ ...headers
49962
+ };
49963
+ body = JSON.stringify(opts.body);
49964
+ }
49903
49965
  }
49904
49966
  return fetch(url3, {
49905
49967
  method: method.toUpperCase(),
@@ -49969,7 +50031,7 @@ class Query {
49969
50031
  "Content-Type": "application/json"
49970
50032
  };
49971
50033
  this.timeout = opts?.timeout || 60000 * 3;
49972
- if (opts.beforeRequest) {
50034
+ if (opts?.beforeRequest) {
49973
50035
  this.beforeRequest = opts.beforeRequest;
49974
50036
  } else {
49975
50037
  this.beforeRequest = async (opts2) => {
@@ -57084,7 +57146,7 @@ function filter(data, query) {
57084
57146
  return executor.execute(ast, data);
57085
57147
  }
57086
57148
 
57087
- // ../node_modules/.pnpm/@kevisual+api@0.0.44/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
57149
+ // ../node_modules/.pnpm/@kevisual+api@0.0.50_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
57088
57150
  var initApi = async (opts) => {
57089
57151
  const router = opts?.router;
57090
57152
  const item = opts?.item;
@@ -57112,6 +57174,7 @@ var initApi = async (opts) => {
57112
57174
  let metadata = r.metadata || {};
57113
57175
  metadata.viewItem = item;
57114
57176
  metadata.url = query.url;
57177
+ metadata.source = "query-proxy-api";
57115
57178
  router.route({
57116
57179
  path: r.path,
57117
57180
  key: r.key || "",
@@ -71026,7 +71089,6 @@ class AssistantApp extends Manager2 {
71026
71089
  config;
71027
71090
  pagesPath;
71028
71091
  remoteIsConnected = false;
71029
- attemptedConnectTimes = 0;
71030
71092
  remoteApp = null;
71031
71093
  remoteUrl = null;
71032
71094
  resolver;
@@ -71094,7 +71156,7 @@ class AssistantApp extends Manager2 {
71094
71156
  const enabled = opts?.enabled ?? share?.enabled ?? false;
71095
71157
  if (share && enabled !== false) {
71096
71158
  if (this.remoteApp) {
71097
- this.remoteApp.ws?.close();
71159
+ this.remoteApp.disconnect();
71098
71160
  this.remoteApp = null;
71099
71161
  this.remoteIsConnected = false;
71100
71162
  }
@@ -71106,31 +71168,31 @@ class AssistantApp extends Manager2 {
71106
71168
  url: url5.toString(),
71107
71169
  token,
71108
71170
  id: id2,
71109
- app: this.mainApp
71171
+ app: this.mainApp,
71172
+ autoReconnect: true,
71173
+ reconnectDelay: 5000,
71174
+ maxReconnectAttempts: Infinity,
71175
+ enableBackoff: true
71110
71176
  });
71111
- const isConnect = await remoteApp.isConnect();
71112
- if (isConnect) {
71113
- remoteApp.listenProxy();
71177
+ remoteApp.isConnect();
71178
+ this.remoteIsConnected = true;
71179
+ remoteApp.on("open", () => {
71114
71180
  this.remoteIsConnected = true;
71115
- remoteApp.emitter.removeAllListeners("close");
71116
- remoteApp.emitter.on("close", () => {
71117
- setTimeout(() => {
71118
- if (remoteApp.isError) {
71119
- console.error("远程应用发生错误,不重连");
71120
- } else {
71121
- this.reconnectRemoteApp();
71122
- }
71123
- }, 5 * 1000);
71124
- });
71125
- logger.debug("链接到了远程应用服务器");
71126
71181
  const appId = id2;
71127
71182
  const username = config4?.auth.username || "unknown";
71128
71183
  const url6 = new URL(`/${username}/v1/${appId}`, config4?.registry || "https://kevisual.cn/");
71129
71184
  this.remoteUrl = url6.toString();
71130
- console.log("远程地址", this.remoteUrl);
71131
- } else {
71132
- console.log("Not connected to remote app server");
71133
- }
71185
+ logger.info("[remote-app] 远程地址", this.remoteUrl);
71186
+ logger.debug("链接到了远程应用服务器");
71187
+ remoteApp.listenProxy();
71188
+ });
71189
+ remoteApp.on("close", () => {
71190
+ this.remoteIsConnected = false;
71191
+ logger.info("[remote-app] 远程连接已关闭,自动重连机制正在处理...");
71192
+ });
71193
+ remoteApp.on("maxReconnectAttemptsReached", () => {
71194
+ logger.error("远程应用重连达到最大次数,停止重连");
71195
+ });
71134
71196
  this.remoteApp = remoteApp;
71135
71197
  } else {
71136
71198
  if (!token) {
@@ -71213,28 +71275,6 @@ class AssistantApp extends Manager2 {
71213
71275
  }
71214
71276
  }
71215
71277
  }
71216
- async reconnectRemoteApp() {
71217
- console.log("重新连接到远程应用服务器...", this.attemptedConnectTimes);
71218
- const remoteApp = this.remoteApp;
71219
- if (remoteApp) {
71220
- if (remoteApp.ws) {
71221
- remoteApp.ws.close();
71222
- }
71223
- remoteApp.init();
71224
- this.attemptedConnectTimes += 1;
71225
- const isConnect = await remoteApp.isConnect();
71226
- if (isConnect) {
71227
- remoteApp.listenProxy();
71228
- this.attemptedConnectTimes = 0;
71229
- console.log("重新连接到了远程应用服务器");
71230
- } else {
71231
- this.reconnectRemoteApp();
71232
- setTimeout(() => {
71233
- this.initRouterApp();
71234
- }, 30 * 1000 + this.attemptedConnectTimes * 10 * 1000);
71235
- }
71236
- }
71237
- }
71238
71278
  async initRoutes() {
71239
71279
  const routes = this.config.getConfig().routes || [];
71240
71280
  for (const route of routes) {
@@ -71249,7 +71289,7 @@ class AssistantApp extends Manager2 {
71249
71289
  }
71250
71290
  }
71251
71291
  }
71252
- // ../node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query.js
71292
+ // ../node_modules/.pnpm/@kevisual+query@0.0.40/node_modules/@kevisual/query/dist/query.js
71253
71293
  var isTextForContentType2 = (contentType) => {
71254
71294
  if (!contentType)
71255
71295
  return false;
@@ -71278,12 +71318,12 @@ var adapter2 = async (opts = {}, overloadOpts) => {
71278
71318
  url5 = new URL(opts.url);
71279
71319
  } else {
71280
71320
  origin = window?.location?.origin || "http://localhost:51515";
71281
- url5 = new URL(opts.url, origin);
71321
+ url5 = new URL(opts?.url || "", origin);
71282
71322
  }
71283
71323
  const isGet = method === "GET";
71284
71324
  const oldSearchParams = url5.searchParams;
71285
71325
  if (isGet) {
71286
- let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
71326
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
71287
71327
  url5.search = searchParams.toString();
71288
71328
  } else {
71289
71329
  const params = {
@@ -71308,11 +71348,13 @@ var adapter2 = async (opts = {}, overloadOpts) => {
71308
71348
  } else if (isPostFile) {
71309
71349
  body = opts.body;
71310
71350
  } else {
71311
- headers = {
71312
- "Content-Type": "application/json",
71313
- ...headers
71314
- };
71315
- body = JSON.stringify(opts.body);
71351
+ if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
71352
+ headers = {
71353
+ "Content-Type": "application/json",
71354
+ ...headers
71355
+ };
71356
+ body = JSON.stringify(opts.body);
71357
+ }
71316
71358
  }
71317
71359
  return fetch(url5, {
71318
71360
  method: method.toUpperCase(),
@@ -71382,7 +71424,7 @@ class Query2 {
71382
71424
  "Content-Type": "application/json"
71383
71425
  };
71384
71426
  this.timeout = opts?.timeout || 60000 * 3;
71385
- if (opts.beforeRequest) {
71427
+ if (opts?.beforeRequest) {
71386
71428
  this.beforeRequest = opts.beforeRequest;
71387
71429
  } else {
71388
71430
  this.beforeRequest = async (opts2) => {
@@ -72283,7 +72325,7 @@ var assistantQuery = useContextKey("assistantQuery", () => {
72283
72325
  return new AssistantQuery(assistantConfig2);
72284
72326
  });
72285
72327
  var runtime = useContextKey("runtime", () => {
72286
- console.log("Runtime detected:", manualParse.isDev);
72328
+ console.log("Runtime detected:", "isDev:", manualParse.isDev, "isServer:", manualParse.isServer);
72287
72329
  return {
72288
72330
  type: "client",
72289
72331
  isServer: manualParse.isServer
@@ -87070,10 +87112,10 @@ import os4 from "node:os";
87070
87112
  import path12 from "path";
87071
87113
  import fs14 from "fs";
87072
87114
 
87073
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/key.js
87115
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/key.js
87074
87116
  var isTabKey = (key) => key.name === "tab";
87075
87117
  var isEnterKey = (key) => key.name === "enter" || key.name === "return";
87076
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/errors.js
87118
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/errors.js
87077
87119
  class AbortPromptError extends Error {
87078
87120
  name = "AbortPromptError";
87079
87121
  message = "Prompt was aborted";
@@ -87099,10 +87141,10 @@ class HookError extends Error {
87099
87141
  class ValidationError extends Error {
87100
87142
  name = "ValidationError";
87101
87143
  }
87102
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-state.js
87144
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-state.js
87103
87145
  import { AsyncResource as AsyncResource2 } from "node:async_hooks";
87104
87146
 
87105
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
87147
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/hook-engine.js
87106
87148
  import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
87107
87149
  var hookStorage = new AsyncLocalStorage;
87108
87150
  function createStore(rl) {
@@ -87207,10 +87249,10 @@ var effectScheduler = {
87207
87249
  }
87208
87250
  };
87209
87251
 
87210
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-state.js
87252
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-state.js
87211
87253
  function useState(defaultValue) {
87212
87254
  return withPointer((pointer) => {
87213
- const setState = AsyncResource2.bind(function setState(newValue) {
87255
+ const setState = AsyncResource2.bind(function setState2(newValue) {
87214
87256
  if (pointer.get() !== newValue) {
87215
87257
  pointer.set(newValue);
87216
87258
  handleChange();
@@ -87225,7 +87267,7 @@ function useState(defaultValue) {
87225
87267
  });
87226
87268
  }
87227
87269
 
87228
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-effect.js
87270
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-effect.js
87229
87271
  function useEffect(cb, depArray) {
87230
87272
  withPointer((pointer) => {
87231
87273
  const oldDeps = pointer.get();
@@ -87237,7 +87279,7 @@ function useEffect(cb, depArray) {
87237
87279
  });
87238
87280
  }
87239
87281
 
87240
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/theme.js
87282
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/theme.js
87241
87283
  import { styleText } from "node:util";
87242
87284
 
87243
87285
  // ../node_modules/.pnpm/@inquirer+figures@2.0.3/node_modules/@inquirer/figures/dist/index.js
@@ -87529,7 +87571,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
87529
87571
  var dist_default = figures;
87530
87572
  var replacements = Object.entries(specialMainSymbols);
87531
87573
 
87532
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/theme.js
87574
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/theme.js
87533
87575
  var defaultTheme = {
87534
87576
  prefix: {
87535
87577
  idle: styleText("blue", "?"),
@@ -87550,7 +87592,7 @@ var defaultTheme = {
87550
87592
  }
87551
87593
  };
87552
87594
 
87553
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/make-theme.js
87595
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/make-theme.js
87554
87596
  function isPlainObject7(value) {
87555
87597
  if (typeof value !== "object" || value === null)
87556
87598
  return false;
@@ -87578,7 +87620,7 @@ function makeTheme(...themes) {
87578
87620
  return deepMerge(...themesToMerge);
87579
87621
  }
87580
87622
 
87581
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
87623
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-prefix.js
87582
87624
  function usePrefix({ status = "idle", theme }) {
87583
87625
  const [showLoader, setShowLoader] = useState(false);
87584
87626
  const [tick, setTick] = useState(0);
@@ -87608,12 +87650,12 @@ function usePrefix({ status = "idle", theme }) {
87608
87650
  const iconName = status === "loading" ? "idle" : status;
87609
87651
  return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
87610
87652
  }
87611
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-ref.js
87653
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-ref.js
87612
87654
  function useRef(val) {
87613
87655
  return useState({ current: val })[0];
87614
87656
  }
87615
87657
 
87616
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
87658
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/use-keypress.js
87617
87659
  function useKeypress(userHandler) {
87618
87660
  const signal = useRef(userHandler);
87619
87661
  signal.current = userHandler;
@@ -87631,309 +87673,196 @@ function useKeypress(userHandler) {
87631
87673
  };
87632
87674
  }, []);
87633
87675
  }
87634
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/utils.js
87676
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/utils.js
87635
87677
  var import_cli_width = __toESM(require_cli_width(), 1);
87636
87678
 
87637
- // ../node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
87638
- function ansiRegex({ onlyFirst = false } = {}) {
87639
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
87640
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
87641
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
87642
- const pattern2 = `${osc}|${csi}`;
87643
- return new RegExp(pattern2, onlyFirst ? undefined : "g");
87644
- }
87645
-
87646
- // ../node_modules/.pnpm/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
87647
- var regex = ansiRegex();
87648
- function stripAnsi(string7) {
87649
- if (typeof string7 !== "string") {
87650
- throw new TypeError(`Expected a \`string\`, got \`${typeof string7}\``);
87651
- }
87652
- return string7.replace(regex, "");
87653
- }
87654
-
87655
- // ../node_modules/.pnpm/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
87656
- function isAmbiguous(x) {
87657
- return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
87658
- }
87659
- function isFullWidth(x) {
87679
+ // ../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
87680
+ var getCodePointsLength = (() => {
87681
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
87682
+ return (input) => {
87683
+ let surrogatePairsNr = 0;
87684
+ SURROGATE_PAIR_RE.lastIndex = 0;
87685
+ while (SURROGATE_PAIR_RE.test(input)) {
87686
+ surrogatePairsNr += 1;
87687
+ }
87688
+ return input.length - surrogatePairsNr;
87689
+ };
87690
+ })();
87691
+ var isFullWidth = (x) => {
87660
87692
  return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
87661
- }
87662
- function isWide(x) {
87663
- return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
87664
- }
87665
-
87666
- // ../node_modules/.pnpm/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
87667
- function validate(codePoint) {
87668
- if (!Number.isSafeInteger(codePoint)) {
87669
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
87670
- }
87671
- }
87672
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
87673
- validate(codePoint);
87674
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
87675
- return 2;
87676
- }
87677
- return 1;
87678
- }
87693
+ };
87694
+ var isWideNotCJKTNotEmoji = (x) => {
87695
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
87696
+ };
87679
87697
 
87680
- // ../node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js
87681
- var import_emoji_regex = __toESM(require_emoji_regex(), 1);
87682
- var segmenter = new Intl.Segmenter;
87683
- var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
87684
- function stringWidth(string7, options = {}) {
87685
- if (typeof string7 !== "string" || string7.length === 0) {
87686
- return 0;
87687
- }
87688
- const {
87689
- ambiguousIsNarrow = true,
87690
- countAnsiEscapeCodes = false
87691
- } = options;
87692
- if (!countAnsiEscapeCodes) {
87693
- string7 = stripAnsi(string7);
87694
- }
87695
- if (string7.length === 0) {
87696
- return 0;
87697
- }
87698
+ // ../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
87699
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
87700
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
87701
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
87702
+ var TAB_RE = /\t{1,1000}/y;
87703
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
87704
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
87705
+ var MODIFIER_RE = /\p{M}+/gu;
87706
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
87707
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
87708
+ const LIMIT = truncationOptions.limit ?? Infinity;
87709
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
87710
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
87711
+ const ANSI_WIDTH = 0;
87712
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
87713
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
87714
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
87715
+ const FULL_WIDTH_WIDTH = 2;
87716
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
87717
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
87718
+ const PARSE_BLOCKS = [
87719
+ [LATIN_RE, REGULAR_WIDTH],
87720
+ [ANSI_RE, ANSI_WIDTH],
87721
+ [CONTROL_RE, CONTROL_WIDTH],
87722
+ [TAB_RE, TAB_WIDTH],
87723
+ [EMOJI_RE, EMOJI_WIDTH],
87724
+ [CJKT_WIDE_RE, WIDE_WIDTH]
87725
+ ];
87726
+ let indexPrev = 0;
87727
+ let index3 = 0;
87728
+ let length = input.length;
87729
+ let lengthExtra = 0;
87730
+ let truncationEnabled = false;
87731
+ let truncationIndex = length;
87732
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
87733
+ let unmatchedStart = 0;
87734
+ let unmatchedEnd = 0;
87698
87735
  let width = 0;
87699
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
87700
- for (const { segment: character } of segmenter.segment(string7)) {
87701
- const codePoint = character.codePointAt(0);
87702
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
87703
- continue;
87704
- }
87705
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
87706
- continue;
87707
- }
87708
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
87709
- continue;
87710
- }
87711
- if (codePoint >= 55296 && codePoint <= 57343) {
87712
- continue;
87713
- }
87714
- if (codePoint >= 65024 && codePoint <= 65039) {
87715
- continue;
87716
- }
87717
- if (defaultIgnorableCodePointRegex.test(character)) {
87718
- continue;
87719
- }
87720
- if (import_emoji_regex.default().test(character)) {
87721
- width += 2;
87722
- continue;
87723
- }
87724
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
87725
- }
87726
- return width;
87727
- }
87728
-
87729
- // ../node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js
87730
- var ANSI_BACKGROUND_OFFSET2 = 10;
87731
- var wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
87732
- var wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
87733
- var wrapAnsi16m2 = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
87734
- var styles3 = {
87735
- modifier: {
87736
- reset: [0, 0],
87737
- bold: [1, 22],
87738
- dim: [2, 22],
87739
- italic: [3, 23],
87740
- underline: [4, 24],
87741
- overline: [53, 55],
87742
- inverse: [7, 27],
87743
- hidden: [8, 28],
87744
- strikethrough: [9, 29]
87745
- },
87746
- color: {
87747
- black: [30, 39],
87748
- red: [31, 39],
87749
- green: [32, 39],
87750
- yellow: [33, 39],
87751
- blue: [34, 39],
87752
- magenta: [35, 39],
87753
- cyan: [36, 39],
87754
- white: [37, 39],
87755
- blackBright: [90, 39],
87756
- gray: [90, 39],
87757
- grey: [90, 39],
87758
- redBright: [91, 39],
87759
- greenBright: [92, 39],
87760
- yellowBright: [93, 39],
87761
- blueBright: [94, 39],
87762
- magentaBright: [95, 39],
87763
- cyanBright: [96, 39],
87764
- whiteBright: [97, 39]
87765
- },
87766
- bgColor: {
87767
- bgBlack: [40, 49],
87768
- bgRed: [41, 49],
87769
- bgGreen: [42, 49],
87770
- bgYellow: [43, 49],
87771
- bgBlue: [44, 49],
87772
- bgMagenta: [45, 49],
87773
- bgCyan: [46, 49],
87774
- bgWhite: [47, 49],
87775
- bgBlackBright: [100, 49],
87776
- bgGray: [100, 49],
87777
- bgGrey: [100, 49],
87778
- bgRedBright: [101, 49],
87779
- bgGreenBright: [102, 49],
87780
- bgYellowBright: [103, 49],
87781
- bgBlueBright: [104, 49],
87782
- bgMagentaBright: [105, 49],
87783
- bgCyanBright: [106, 49],
87784
- bgWhiteBright: [107, 49]
87785
- }
87786
- };
87787
- var modifierNames2 = Object.keys(styles3.modifier);
87788
- var foregroundColorNames2 = Object.keys(styles3.color);
87789
- var backgroundColorNames2 = Object.keys(styles3.bgColor);
87790
- var colorNames2 = [...foregroundColorNames2, ...backgroundColorNames2];
87791
- function assembleStyles2() {
87792
- const codes = new Map;
87793
- for (const [groupName, group] of Object.entries(styles3)) {
87794
- for (const [styleName, style] of Object.entries(group)) {
87795
- styles3[styleName] = {
87796
- open: `\x1B[${style[0]}m`,
87797
- close: `\x1B[${style[1]}m`
87798
- };
87799
- group[styleName] = styles3[styleName];
87800
- codes.set(style[0], style[1]);
87801
- }
87802
- Object.defineProperty(styles3, groupName, {
87803
- value: group,
87804
- enumerable: false
87805
- });
87806
- }
87807
- Object.defineProperty(styles3, "codes", {
87808
- value: codes,
87809
- enumerable: false
87810
- });
87811
- styles3.color.close = "\x1B[39m";
87812
- styles3.bgColor.close = "\x1B[49m";
87813
- styles3.color.ansi = wrapAnsi162();
87814
- styles3.color.ansi256 = wrapAnsi2562();
87815
- styles3.color.ansi16m = wrapAnsi16m2();
87816
- styles3.bgColor.ansi = wrapAnsi162(ANSI_BACKGROUND_OFFSET2);
87817
- styles3.bgColor.ansi256 = wrapAnsi2562(ANSI_BACKGROUND_OFFSET2);
87818
- styles3.bgColor.ansi16m = wrapAnsi16m2(ANSI_BACKGROUND_OFFSET2);
87819
- Object.defineProperties(styles3, {
87820
- rgbToAnsi256: {
87821
- value(red, green, blue) {
87822
- if (red === green && green === blue) {
87823
- if (red < 8) {
87824
- return 16;
87736
+ let widthExtra = 0;
87737
+ outer:
87738
+ while (true) {
87739
+ if (unmatchedEnd > unmatchedStart || index3 >= length && index3 > indexPrev) {
87740
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index3);
87741
+ lengthExtra = 0;
87742
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
87743
+ const codePoint = char.codePointAt(0) || 0;
87744
+ if (isFullWidth(codePoint)) {
87745
+ widthExtra = FULL_WIDTH_WIDTH;
87746
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
87747
+ widthExtra = WIDE_WIDTH;
87748
+ } else {
87749
+ widthExtra = REGULAR_WIDTH;
87825
87750
  }
87826
- if (red > 248) {
87827
- return 231;
87751
+ if (width + widthExtra > truncationLimit) {
87752
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
87828
87753
  }
87829
- return Math.round((red - 8) / 247 * 24) + 232;
87830
- }
87831
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
87832
- },
87833
- enumerable: false
87834
- },
87835
- hexToRgb: {
87836
- value(hex6) {
87837
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex6.toString(16));
87838
- if (!matches) {
87839
- return [0, 0, 0];
87840
- }
87841
- let [colorString] = matches;
87842
- if (colorString.length === 3) {
87843
- colorString = [...colorString].map((character) => character + character).join("");
87844
- }
87845
- const integer5 = Number.parseInt(colorString, 16);
87846
- return [
87847
- integer5 >> 16 & 255,
87848
- integer5 >> 8 & 255,
87849
- integer5 & 255
87850
- ];
87851
- },
87852
- enumerable: false
87853
- },
87854
- hexToAnsi256: {
87855
- value: (hex6) => styles3.rgbToAnsi256(...styles3.hexToRgb(hex6)),
87856
- enumerable: false
87857
- },
87858
- ansi256ToAnsi: {
87859
- value(code) {
87860
- if (code < 8) {
87861
- return 30 + code;
87862
- }
87863
- if (code < 16) {
87864
- return 90 + (code - 8);
87865
- }
87866
- let red;
87867
- let green;
87868
- let blue;
87869
- if (code >= 232) {
87870
- red = ((code - 232) * 10 + 8) / 255;
87871
- green = red;
87872
- blue = red;
87873
- } else {
87874
- code -= 16;
87875
- const remainder = code % 36;
87876
- red = Math.floor(code / 36) / 5;
87877
- green = Math.floor(remainder / 6) / 5;
87878
- blue = remainder % 6 / 5;
87879
- }
87880
- const value = Math.max(red, green, blue) * 2;
87881
- if (value === 0) {
87882
- return 30;
87883
- }
87884
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
87885
- if (value === 2) {
87886
- result += 60;
87754
+ if (width + widthExtra > LIMIT) {
87755
+ truncationEnabled = true;
87756
+ break outer;
87757
+ }
87758
+ lengthExtra += char.length;
87759
+ width += widthExtra;
87760
+ }
87761
+ unmatchedStart = unmatchedEnd = 0;
87762
+ }
87763
+ if (index3 >= length) {
87764
+ break outer;
87765
+ }
87766
+ for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
87767
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
87768
+ BLOCK_RE.lastIndex = index3;
87769
+ if (BLOCK_RE.test(input)) {
87770
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index3, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index3;
87771
+ widthExtra = lengthExtra * BLOCK_WIDTH;
87772
+ if (width + widthExtra > truncationLimit) {
87773
+ truncationIndex = Math.min(truncationIndex, index3 + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
87774
+ }
87775
+ if (width + widthExtra > LIMIT) {
87776
+ truncationEnabled = true;
87777
+ break outer;
87778
+ }
87779
+ width += widthExtra;
87780
+ unmatchedStart = indexPrev;
87781
+ unmatchedEnd = index3;
87782
+ index3 = indexPrev = BLOCK_RE.lastIndex;
87783
+ continue outer;
87887
87784
  }
87888
- return result;
87889
- },
87890
- enumerable: false
87891
- },
87892
- rgbToAnsi: {
87893
- value: (red, green, blue) => styles3.ansi256ToAnsi(styles3.rgbToAnsi256(red, green, blue)),
87894
- enumerable: false
87895
- },
87896
- hexToAnsi: {
87897
- value: (hex6) => styles3.ansi256ToAnsi(styles3.hexToAnsi256(hex6)),
87898
- enumerable: false
87785
+ }
87786
+ index3 += 1;
87899
87787
  }
87900
- });
87901
- return styles3;
87902
- }
87903
- var ansiStyles2 = assembleStyles2();
87904
- var ansi_styles_default2 = ansiStyles2;
87788
+ return {
87789
+ width: truncationEnabled ? truncationLimit : width,
87790
+ index: truncationEnabled ? truncationIndex : length,
87791
+ truncated: truncationEnabled,
87792
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
87793
+ };
87794
+ };
87795
+ var dist_default2 = getStringTruncatedWidth;
87905
87796
 
87906
- // ../node_modules/.pnpm/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js
87907
- var ESCAPES = new Set([
87908
- "\x1B",
87909
- "›"
87910
- ]);
87797
+ // ../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
87798
+ var NO_TRUNCATION2 = {
87799
+ limit: Infinity,
87800
+ ellipsis: "",
87801
+ ellipsisWidth: 0
87802
+ };
87803
+ var fastStringWidth = (input, options = {}) => {
87804
+ return dist_default2(input, NO_TRUNCATION2, options).width;
87805
+ };
87806
+ var dist_default3 = fastStringWidth;
87807
+
87808
+ // ../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
87809
+ var ESC = "\x1B";
87810
+ var CSI = "›";
87911
87811
  var END_CODE = 39;
87912
87812
  var ANSI_ESCAPE_BELL = "\x07";
87913
87813
  var ANSI_CSI = "[";
87914
87814
  var ANSI_OSC = "]";
87915
87815
  var ANSI_SGR_TERMINATOR = "m";
87916
87816
  var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
87917
- var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
87918
- var wrapAnsiHyperlink = (url6) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url6}${ANSI_ESCAPE_BELL}`;
87919
- var wordLengths = (string7) => string7.split(" ").map((character) => stringWidth(character));
87817
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
87818
+ var getClosingCode = (openingCode) => {
87819
+ if (openingCode >= 30 && openingCode <= 37)
87820
+ return 39;
87821
+ if (openingCode >= 90 && openingCode <= 97)
87822
+ return 39;
87823
+ if (openingCode >= 40 && openingCode <= 47)
87824
+ return 49;
87825
+ if (openingCode >= 100 && openingCode <= 107)
87826
+ return 49;
87827
+ if (openingCode === 1 || openingCode === 2)
87828
+ return 22;
87829
+ if (openingCode === 3)
87830
+ return 23;
87831
+ if (openingCode === 4)
87832
+ return 24;
87833
+ if (openingCode === 7)
87834
+ return 27;
87835
+ if (openingCode === 8)
87836
+ return 28;
87837
+ if (openingCode === 9)
87838
+ return 29;
87839
+ if (openingCode === 0)
87840
+ return 0;
87841
+ return;
87842
+ };
87843
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
87844
+ var wrapAnsiHyperlink = (url6) => `${ESC}${ANSI_ESCAPE_LINK}${url6}${ANSI_ESCAPE_BELL}`;
87920
87845
  var wrapWord = (rows, word, columns) => {
87921
- const characters = [...word];
87846
+ const characters = word[Symbol.iterator]();
87922
87847
  let isInsideEscape = false;
87923
87848
  let isInsideLinkEscape = false;
87924
- let visible = stringWidth(stripAnsi(rows.at(-1)));
87925
- for (const [index3, character] of characters.entries()) {
87926
- const characterLength = stringWidth(character);
87849
+ let lastRow = rows.at(-1);
87850
+ let visible = lastRow === undefined ? 0 : dist_default3(lastRow);
87851
+ let currentCharacter = characters.next();
87852
+ let nextCharacter = characters.next();
87853
+ let rawCharacterIndex = 0;
87854
+ while (!currentCharacter.done) {
87855
+ const character = currentCharacter.value;
87856
+ const characterLength = dist_default3(character);
87927
87857
  if (visible + characterLength <= columns) {
87928
87858
  rows[rows.length - 1] += character;
87929
87859
  } else {
87930
87860
  rows.push(character);
87931
87861
  visible = 0;
87932
87862
  }
87933
- if (ESCAPES.has(character)) {
87863
+ if (character === ESC || character === CSI) {
87934
87864
  isInsideEscape = true;
87935
- const ansiEscapeLinkCandidate = characters.slice(index3 + 1, index3 + 1 + ANSI_ESCAPE_LINK.length).join("");
87936
- isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
87865
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
87937
87866
  }
87938
87867
  if (isInsideEscape) {
87939
87868
  if (isInsideLinkEscape) {
@@ -87944,23 +87873,27 @@ var wrapWord = (rows, word, columns) => {
87944
87873
  } else if (character === ANSI_SGR_TERMINATOR) {
87945
87874
  isInsideEscape = false;
87946
87875
  }
87947
- continue;
87948
- }
87949
- visible += characterLength;
87950
- if (visible === columns && index3 < characters.length - 1) {
87951
- rows.push("");
87952
- visible = 0;
87876
+ } else {
87877
+ visible += characterLength;
87878
+ if (visible === columns && !nextCharacter.done) {
87879
+ rows.push("");
87880
+ visible = 0;
87881
+ }
87953
87882
  }
87883
+ currentCharacter = nextCharacter;
87884
+ nextCharacter = characters.next();
87885
+ rawCharacterIndex += character.length;
87954
87886
  }
87955
- if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
87887
+ lastRow = rows.at(-1);
87888
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
87956
87889
  rows[rows.length - 2] += rows.pop();
87957
87890
  }
87958
87891
  };
87959
87892
  var stringVisibleTrimSpacesRight = (string7) => {
87960
87893
  const words = string7.split(" ");
87961
87894
  let last = words.length;
87962
- while (last > 0) {
87963
- if (stringWidth(words[last - 1]) > 0) {
87895
+ while (last) {
87896
+ if (dist_default3(words[last - 1])) {
87964
87897
  break;
87965
87898
  }
87966
87899
  last--;
@@ -87977,95 +87910,114 @@ var exec = (string7, columns, options = {}) => {
87977
87910
  let returnValue = "";
87978
87911
  let escapeCode;
87979
87912
  let escapeUrl;
87980
- const lengths = wordLengths(string7);
87913
+ const words = string7.split(" ");
87981
87914
  let rows = [""];
87982
- for (const [index3, word] of string7.split(" ").entries()) {
87915
+ let rowLength = 0;
87916
+ for (let index3 = 0;index3 < words.length; index3++) {
87917
+ const word = words[index3];
87983
87918
  if (options.trim !== false) {
87984
- rows[rows.length - 1] = rows.at(-1).trimStart();
87919
+ const row = rows.at(-1) ?? "";
87920
+ const trimmed = row.trimStart();
87921
+ if (row.length !== trimmed.length) {
87922
+ rows[rows.length - 1] = trimmed;
87923
+ rowLength = dist_default3(trimmed);
87924
+ }
87985
87925
  }
87986
- let rowLength = stringWidth(rows.at(-1));
87987
87926
  if (index3 !== 0) {
87988
87927
  if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
87989
87928
  rows.push("");
87990
87929
  rowLength = 0;
87991
87930
  }
87992
- if (rowLength > 0 || options.trim === false) {
87931
+ if (rowLength || options.trim === false) {
87993
87932
  rows[rows.length - 1] += " ";
87994
87933
  rowLength++;
87995
87934
  }
87996
87935
  }
87997
- if (options.hard && lengths[index3] > columns) {
87936
+ const wordLength = dist_default3(word);
87937
+ if (options.hard && wordLength > columns) {
87998
87938
  const remainingColumns = columns - rowLength;
87999
- const breaksStartingThisLine = 1 + Math.floor((lengths[index3] - remainingColumns - 1) / columns);
88000
- const breaksStartingNextLine = Math.floor((lengths[index3] - 1) / columns);
87939
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
87940
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
88001
87941
  if (breaksStartingNextLine < breaksStartingThisLine) {
88002
87942
  rows.push("");
88003
87943
  }
88004
87944
  wrapWord(rows, word, columns);
87945
+ rowLength = dist_default3(rows.at(-1) ?? "");
88005
87946
  continue;
88006
87947
  }
88007
- if (rowLength + lengths[index3] > columns && rowLength > 0 && lengths[index3] > 0) {
87948
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
88008
87949
  if (options.wordWrap === false && rowLength < columns) {
88009
87950
  wrapWord(rows, word, columns);
87951
+ rowLength = dist_default3(rows.at(-1) ?? "");
88010
87952
  continue;
88011
87953
  }
88012
87954
  rows.push("");
87955
+ rowLength = 0;
88013
87956
  }
88014
- if (rowLength + lengths[index3] > columns && options.wordWrap === false) {
87957
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
88015
87958
  wrapWord(rows, word, columns);
87959
+ rowLength = dist_default3(rows.at(-1) ?? "");
88016
87960
  continue;
88017
87961
  }
88018
87962
  rows[rows.length - 1] += word;
87963
+ rowLength += wordLength;
88019
87964
  }
88020
87965
  if (options.trim !== false) {
88021
87966
  rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
88022
87967
  }
88023
87968
  const preString = rows.join(`
88024
87969
  `);
88025
- const pre = [...preString];
88026
- let preStringIndex = 0;
88027
- for (const [index3, character] of pre.entries()) {
87970
+ let inSurrogate = false;
87971
+ for (let i = 0;i < preString.length; i++) {
87972
+ const character = preString[i];
88028
87973
  returnValue += character;
88029
- if (ESCAPES.has(character)) {
88030
- const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
88031
- if (groups.code !== undefined) {
88032
- const code2 = Number.parseFloat(groups.code);
88033
- escapeCode = code2 === END_CODE ? undefined : code2;
88034
- } else if (groups.uri !== undefined) {
87974
+ if (!inSurrogate) {
87975
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
87976
+ if (inSurrogate) {
87977
+ continue;
87978
+ }
87979
+ } else {
87980
+ inSurrogate = false;
87981
+ }
87982
+ if (character === ESC || character === CSI) {
87983
+ GROUP_REGEX.lastIndex = i + 1;
87984
+ const groupsResult = GROUP_REGEX.exec(preString);
87985
+ const groups = groupsResult?.groups;
87986
+ if (groups?.code !== undefined) {
87987
+ const code = Number.parseFloat(groups.code);
87988
+ escapeCode = code === END_CODE ? undefined : code;
87989
+ } else if (groups?.uri !== undefined) {
88035
87990
  escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
88036
87991
  }
88037
87992
  }
88038
- const code = ansi_styles_default2.codes.get(Number(escapeCode));
88039
- if (pre[index3 + 1] === `
87993
+ if (preString[i + 1] === `
88040
87994
  `) {
88041
87995
  if (escapeUrl) {
88042
87996
  returnValue += wrapAnsiHyperlink("");
88043
87997
  }
88044
- if (escapeCode && code) {
88045
- returnValue += wrapAnsiCode(code);
87998
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
87999
+ if (escapeCode && closingCode) {
88000
+ returnValue += wrapAnsiCode(closingCode);
88046
88001
  }
88047
88002
  } else if (character === `
88048
88003
  `) {
88049
- if (escapeCode && code) {
88004
+ if (escapeCode && getClosingCode(escapeCode)) {
88050
88005
  returnValue += wrapAnsiCode(escapeCode);
88051
88006
  }
88052
88007
  if (escapeUrl) {
88053
88008
  returnValue += wrapAnsiHyperlink(escapeUrl);
88054
88009
  }
88055
88010
  }
88056
- preStringIndex += character.length;
88057
88011
  }
88058
88012
  return returnValue;
88059
88013
  };
88014
+ var CRLF_OR_LF = /\r?\n/;
88060
88015
  function wrapAnsi(string7, columns, options) {
88061
- return String(string7).normalize().replaceAll(`\r
88062
- `, `
88063
- `).split(`
88064
- `).map((line) => exec(line, columns, options)).join(`
88016
+ return String(string7).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
88065
88017
  `);
88066
88018
  }
88067
88019
 
88068
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/utils.js
88020
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/utils.js
88069
88021
  function breakLines(content, width) {
88070
88022
  return content.split(`
88071
88023
  `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
@@ -88076,7 +88028,7 @@ function readlineWidth() {
88076
88028
  return import_cli_width.default({ defaultWidth: 80, output: readline().output });
88077
88029
  }
88078
88030
 
88079
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
88031
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/create-prompt.js
88080
88032
  var import_mute_stream = __toESM(require_lib(), 1);
88081
88033
  import * as readline2 from "node:readline";
88082
88034
  import { AsyncResource as AsyncResource3 } from "node:async_hooks";
@@ -88289,26 +88241,26 @@ var {
88289
88241
  unload
88290
88242
  } = signalExitWrap(processOk(process9) ? new SignalExit(process9) : new SignalExitFallback);
88291
88243
 
88292
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
88244
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/screen-manager.js
88293
88245
  import { stripVTControlCharacters } from "node:util";
88294
88246
 
88295
88247
  // ../node_modules/.pnpm/@inquirer+ansi@2.0.3/node_modules/@inquirer/ansi/dist/index.js
88296
- var ESC = "\x1B[";
88297
- var cursorLeft = ESC + "G";
88298
- var cursorHide = ESC + "?25l";
88299
- var cursorShow = ESC + "?25h";
88300
- var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
88301
- var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
88248
+ var ESC2 = "\x1B[";
88249
+ var cursorLeft = ESC2 + "G";
88250
+ var cursorHide = ESC2 + "?25l";
88251
+ var cursorShow = ESC2 + "?25h";
88252
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
88253
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
88302
88254
  var cursorTo = (x, y) => {
88303
88255
  if (typeof y === "number" && !Number.isNaN(y)) {
88304
- return `${ESC}${y + 1};${x + 1}H`;
88256
+ return `${ESC2}${y + 1};${x + 1}H`;
88305
88257
  }
88306
- return `${ESC}${x + 1}G`;
88258
+ return `${ESC2}${x + 1}G`;
88307
88259
  };
88308
- var eraseLine = ESC + "2K";
88260
+ var eraseLine = ESC2 + "2K";
88309
88261
  var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
88310
88262
 
88311
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
88263
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/screen-manager.js
88312
88264
  var height = (content) => content.split(`
88313
88265
  `).length;
88314
88266
  var lastLine = (content) => content.split(`
@@ -88373,7 +88325,7 @@ class ScreenManager {
88373
88325
  }
88374
88326
  }
88375
88327
 
88376
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
88328
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
88377
88329
  class PromisePolyfill extends Promise {
88378
88330
  static withResolver() {
88379
88331
  let resolve;
@@ -88386,7 +88338,7 @@ class PromisePolyfill extends Promise {
88386
88338
  }
88387
88339
  }
88388
88340
 
88389
- // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.2.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
88341
+ // ../node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.2.3/node_modules/@inquirer/core/dist/lib/create-prompt.js
88390
88342
  function getCallSites() {
88391
88343
  const _prepareStackTrace = Error.prepareStackTrace;
88392
88344
  let result = [];
@@ -88472,7 +88424,7 @@ function createPrompt(view) {
88472
88424
  };
88473
88425
  return prompt;
88474
88426
  }
88475
- // ../node_modules/.pnpm/@inquirer+confirm@6.0.4_@types+node@25.2.0/node_modules/@inquirer/confirm/dist/index.js
88427
+ // ../node_modules/.pnpm/@inquirer+confirm@6.0.6_@types+node@25.2.3/node_modules/@inquirer/confirm/dist/index.js
88476
88428
  function getBooleanValue(value, defaultValue) {
88477
88429
  let answer = defaultValue !== false;
88478
88430
  if (/^(y|yes)/i.test(value))
@@ -88484,7 +88436,7 @@ function getBooleanValue(value, defaultValue) {
88484
88436
  function boolToString(value) {
88485
88437
  return value ? "Yes" : "No";
88486
88438
  }
88487
- var dist_default2 = createPrompt((config7, done) => {
88439
+ var dist_default4 = createPrompt((config7, done) => {
88488
88440
  const { transformer = boolToString } = config7;
88489
88441
  const [status, setStatus] = useState("idle");
88490
88442
  const [value, setValue] = useState("");
@@ -88574,7 +88526,7 @@ class AppDownload {
88574
88526
  return runCommand(command, args2);
88575
88527
  }
88576
88528
  async confirm(message) {
88577
- return await dist_default2({
88529
+ return await dist_default4({
88578
88530
  message: message || "是否继续删除应用?",
88579
88531
  default: false
88580
88532
  });
@@ -95468,7 +95420,7 @@ var init_crypto = __esm2(() => {
95468
95420
  } catch (e) {
95469
95421
  errorProto = getProto(getProto(e)), INTRINSICS["%Error.prototype%"] = errorProto;
95470
95422
  }
95471
- var errorProto, doEval = function doEval(name) {
95423
+ var errorProto, doEval = function doEval2(name) {
95472
95424
  var value;
95473
95425
  if (name === "%AsyncFunction%")
95474
95426
  value = getEvalledConstructor("async function () {}");
@@ -95477,11 +95429,11 @@ var init_crypto = __esm2(() => {
95477
95429
  else if (name === "%AsyncGeneratorFunction%")
95478
95430
  value = getEvalledConstructor("async function* () {}");
95479
95431
  else if (name === "%AsyncGenerator%") {
95480
- var fn = doEval("%AsyncGeneratorFunction%");
95432
+ var fn = doEval2("%AsyncGeneratorFunction%");
95481
95433
  if (fn)
95482
95434
  value = fn.prototype;
95483
95435
  } else if (name === "%AsyncIteratorPrototype%") {
95484
- var gen = doEval("%AsyncGenerator%");
95436
+ var gen = doEval2("%AsyncGenerator%");
95485
95437
  if (gen && getProto)
95486
95438
  value = getProto(gen.prototype);
95487
95439
  }
@@ -108318,14 +108270,14 @@ class AIUtils {
108318
108270
  }
108319
108271
  extractCodeFromMarkdown(str, language) {
108320
108272
  if (language) {
108321
- const regex22 = new RegExp(`\`\`\`${language}\\s*([\\s\\S]*?)\\s*\`\`\``, "g");
108322
- const matches2 = str.match(regex22);
108273
+ const regex2 = new RegExp(`\`\`\`${language}\\s*([\\s\\S]*?)\\s*\`\`\``, "g");
108274
+ const matches2 = str.match(regex2);
108323
108275
  if (!matches2)
108324
108276
  return null;
108325
108277
  return matches2.map((m) => m.replace(new RegExp(`\`\`\`${language}\\s*|\\s*\`\`\``, "g"), "").trim());
108326
108278
  }
108327
- const regex2 = /```[\w]*\s*([\s\S]*?)\s*```/g;
108328
- const matches = [...str.matchAll(regex2)];
108279
+ const regex = /```[\w]*\s*([\s\S]*?)\s*```/g;
108280
+ const matches = [...str.matchAll(regex)];
108329
108281
  if (matches.length === 0)
108330
108282
  return null;
108331
108283
  return matches.map((m) => m[1].trim());
@@ -108871,7 +108823,7 @@ app.route({
108871
108823
  }).addTo(app, {
108872
108824
  overwrite: false
108873
108825
  });
108874
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
108826
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
108875
108827
  var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url6, ...options }) => {
108876
108828
  let lastEventId;
108877
108829
  const sleep = sseSleepFn ?? ((ms3) => new Promise((resolve) => setTimeout(resolve, ms3)));
@@ -108980,7 +108932,7 @@ var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseVa
108980
108932
  return { stream: stream3 };
108981
108933
  };
108982
108934
 
108983
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/auth.gen.js
108935
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/auth.gen.js
108984
108936
  var getAuthToken = async (auth, callback) => {
108985
108937
  const token = typeof callback === "function" ? await callback(auth) : callback;
108986
108938
  if (!token) {
@@ -108995,12 +108947,12 @@ var getAuthToken = async (auth, callback) => {
108995
108947
  return token;
108996
108948
  };
108997
108949
 
108998
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
108950
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
108999
108951
  var jsonBodySerializer = {
109000
108952
  bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
109001
108953
  };
109002
108954
 
109003
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
108955
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
109004
108956
  var separatorArrayExplode = (style) => {
109005
108957
  switch (style) {
109006
108958
  case "label":
@@ -109103,7 +109055,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
109103
109055
  return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
109104
109056
  };
109105
109057
 
109106
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
109058
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
109107
109059
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
109108
109060
  var defaultPathSerializer = ({ path: path13, url: _url5 }) => {
109109
109061
  let url6 = _url5;
@@ -109171,7 +109123,7 @@ var getUrl = ({ baseUrl, path: path13, query: query3, querySerializer, url: _url
109171
109123
  return url6;
109172
109124
  };
109173
109125
 
109174
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
109126
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
109175
109127
  var createQuerySerializer = ({ allowReserved, array: array6, object: object5 } = {}) => {
109176
109128
  const querySerializer = (queryParams) => {
109177
109129
  const search = [];
@@ -109379,7 +109331,7 @@ var createConfig = (override = {}) => ({
109379
109331
  ...override
109380
109332
  });
109381
109333
 
109382
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
109334
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
109383
109335
  var createClient = (config7 = {}) => {
109384
109336
  let _config = mergeConfigs(createConfig(), config7);
109385
109337
  const getConfig2 = () => ({ ..._config });
@@ -109526,7 +109478,7 @@ var createClient = (config7 = {}) => {
109526
109478
  trace: makeMethod("TRACE")
109527
109479
  };
109528
109480
  };
109529
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
109481
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
109530
109482
  var extraPrefixesMap = {
109531
109483
  $body_: "body",
109532
109484
  $headers_: "headers",
@@ -109534,12 +109486,12 @@ var extraPrefixesMap = {
109534
109486
  $query_: "query"
109535
109487
  };
109536
109488
  var extraPrefixes = Object.entries(extraPrefixesMap);
109537
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/client.gen.js
109489
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/client.gen.js
109538
109490
  var client = createClient(createConfig({
109539
109491
  baseUrl: "http://localhost:4096"
109540
109492
  }));
109541
109493
 
109542
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
109494
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
109543
109495
  class _HeyApiClient {
109544
109496
  _client = client;
109545
109497
  constructor(args2) {
@@ -110209,7 +110161,7 @@ class OpencodeClient extends _HeyApiClient {
110209
110161
  event = new Event({ client: this._client });
110210
110162
  }
110211
110163
 
110212
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/client.js
110164
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/client.js
110213
110165
  function createOpencodeClient(config7) {
110214
110166
  if (!config7?.fetch) {
110215
110167
  const customFetch = (req) => {
@@ -110224,13 +110176,13 @@ function createOpencodeClient(config7) {
110224
110176
  if (config7?.directory) {
110225
110177
  config7.headers = {
110226
110178
  ...config7.headers,
110227
- "x-opencode-directory": config7.directory
110179
+ "x-opencode-directory": encodeURIComponent(config7.directory)
110228
110180
  };
110229
110181
  }
110230
110182
  const client2 = createClient(config7);
110231
110183
  return new OpencodeClient({ client: client2 });
110232
110184
  }
110233
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/server.js
110185
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/server.js
110234
110186
  import { spawn as spawn3 } from "node:child_process";
110235
110187
  async function createOpencodeServer(options) {
110236
110188
  options = Object.assign({
@@ -110299,7 +110251,7 @@ Server output: ${output}`;
110299
110251
  }
110300
110252
  };
110301
110253
  }
110302
- // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.49/node_modules/@opencode-ai/sdk/dist/index.js
110254
+ // ../node_modules/.pnpm/@opencode-ai+sdk@1.2.4/node_modules/@opencode-ai/sdk/dist/index.js
110303
110255
  async function createOpencode(options) {
110304
110256
  const server2 = await createOpencodeServer({
110305
110257
  ...options
@@ -110677,8 +110629,7 @@ app.route({
110677
110629
  }
110678
110630
  }).addTo(app);
110679
110631
 
110680
- // ../node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
110681
- var isBrowser3 = typeof window !== "undefined" && typeof window.document !== "undefined";
110632
+ // ../node_modules/.pnpm/@kevisual+context@0.0.6/node_modules/@kevisual/context/dist/app.js
110682
110633
  function getDefaultExportFromCjs5(x) {
110683
110634
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
110684
110635
  }
@@ -111211,6 +111162,7 @@ var useConfigKey3 = (key, init, isNew) => {
111211
111162
  }
111212
111163
  return useEnvKey3(key, init, "config");
111213
111164
  };
111165
+
111214
111166
  class InitEnv3 {
111215
111167
  static isInit = false;
111216
111168
  static init(opts) {
@@ -111278,100 +111230,86 @@ app.route({
111278
111230
  });
111279
111231
  }).addTo(app);
111280
111232
 
111281
- // ../node_modules/.pnpm/lru-cache@11.2.5/node_modules/lru-cache/dist/esm/index.js
111282
- var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
111283
- var warned = new Set;
111284
- var PROCESS = typeof process === "object" && !!process ? process : {};
111285
- var emitWarning = (msg, type, code2, fn) => {
111286
- typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code2, fn) : console.error(`[${code2}] ${type}: ${msg}`);
111287
- };
111288
- var AC = globalThis.AbortController;
111289
- var AS = globalThis.AbortSignal;
111290
- if (typeof AC === "undefined") {
111291
- AS = class AbortSignal {
111233
+ // ../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/esm/index.min.js
111234
+ var M = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
111235
+ var I = new Set;
111236
+ var R = typeof process == "object" && process ? process : {};
111237
+ var x = (a, t, e, i2) => {
111238
+ typeof R.emitWarning == "function" ? R.emitWarning(a, t, e, i2) : console.error(`[${e}] ${t}: ${a}`);
111239
+ };
111240
+ var C = globalThis.AbortController;
111241
+ var D = globalThis.AbortSignal;
111242
+ if (typeof C > "u") {
111243
+ D = class {
111292
111244
  onabort;
111293
111245
  _onabort = [];
111294
111246
  reason;
111295
111247
  aborted = false;
111296
- addEventListener(_, fn) {
111297
- this._onabort.push(fn);
111248
+ addEventListener(i2, s) {
111249
+ this._onabort.push(s);
111298
111250
  }
111299
- };
111300
- AC = class AbortController2 {
111251
+ }, C = class {
111301
111252
  constructor() {
111302
- warnACPolyfill();
111253
+ t();
111303
111254
  }
111304
- signal = new AS;
111305
- abort(reason) {
111306
- if (this.signal.aborted)
111307
- return;
111308
- this.signal.reason = reason;
111309
- this.signal.aborted = true;
111310
- for (const fn of this.signal._onabort) {
111311
- fn(reason);
111255
+ signal = new D;
111256
+ abort(i2) {
111257
+ if (!this.signal.aborted) {
111258
+ this.signal.reason = i2, this.signal.aborted = true;
111259
+ for (let s of this.signal._onabort)
111260
+ s(i2);
111261
+ this.signal.onabort?.(i2);
111312
111262
  }
111313
- this.signal.onabort?.(reason);
111314
111263
  }
111315
111264
  };
111316
- let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
111317
- const warnACPolyfill = () => {
111318
- if (!printACPolyfillWarning)
111319
- return;
111320
- printACPolyfillWarning = false;
111321
- emitWarning("AbortController is not defined. If using lru-cache in " + "node 14, load an AbortController polyfill from the " + "`node-abort-controller` package. A minimal polyfill is " + "provided for use by LRUCache.fetch(), but it should not be " + "relied upon in other contexts (eg, passing it to other APIs that " + "use AbortController/AbortSignal might have undesirable effects). " + "You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
111265
+ let a = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
111266
+ a && (a = false, x("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
111322
111267
  };
111323
111268
  }
111324
- var shouldWarn = (code2) => !warned.has(code2);
111325
- var TYPE = Symbol("type");
111326
- var isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
111327
- var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
111328
-
111329
- class ZeroArray extends Array {
111330
- constructor(size) {
111331
- super(size);
111332
- this.fill(0);
111269
+ var G = (a) => !I.has(a);
111270
+ var H = Symbol("type");
111271
+ var y = (a) => a && a === Math.floor(a) && a > 0 && isFinite(a);
111272
+ var U = (a) => y(a) ? a <= Math.pow(2, 8) ? Uint8Array : a <= Math.pow(2, 16) ? Uint16Array : a <= Math.pow(2, 32) ? Uint32Array : a <= Number.MAX_SAFE_INTEGER ? z4 : null : null;
111273
+ var z4 = class extends Array {
111274
+ constructor(t) {
111275
+ super(t), this.fill(0);
111333
111276
  }
111334
- }
111335
-
111336
- class Stack2 {
111277
+ };
111278
+ var W = class a {
111337
111279
  heap;
111338
111280
  length;
111339
- static #constructing = false;
111340
- static create(max) {
111341
- const HeapCls = getUintArray(max);
111342
- if (!HeapCls)
111281
+ static #o = false;
111282
+ static create(t) {
111283
+ let e = U(t);
111284
+ if (!e)
111343
111285
  return [];
111344
- Stack2.#constructing = true;
111345
- const s = new Stack2(max, HeapCls);
111346
- Stack2.#constructing = false;
111347
- return s;
111286
+ a.#o = true;
111287
+ let i2 = new a(t, e);
111288
+ return a.#o = false, i2;
111348
111289
  }
111349
- constructor(max, HeapCls) {
111350
- if (!Stack2.#constructing) {
111290
+ constructor(t, e) {
111291
+ if (!a.#o)
111351
111292
  throw new TypeError("instantiate Stack using Stack.create(n)");
111352
- }
111353
- this.heap = new HeapCls(max);
111354
- this.length = 0;
111293
+ this.heap = new e(t), this.length = 0;
111355
111294
  }
111356
- push(n) {
111357
- this.heap[this.length++] = n;
111295
+ push(t) {
111296
+ this.heap[this.length++] = t;
111358
111297
  }
111359
111298
  pop() {
111360
111299
  return this.heap[--this.length];
111361
111300
  }
111362
- }
111363
-
111364
- class LRUCache {
111365
- #max;
111366
- #maxSize;
111367
- #dispose;
111368
- #onInsert;
111369
- #disposeAfter;
111370
- #fetchMethod;
111371
- #memoMethod;
111372
- #perf;
111301
+ };
111302
+ var L = class a2 {
111303
+ #o;
111304
+ #c;
111305
+ #w;
111306
+ #C;
111307
+ #S;
111308
+ #L;
111309
+ #I;
111310
+ #m;
111373
111311
  get perf() {
111374
- return this.#perf;
111312
+ return this.#m;
111375
111313
  }
111376
111314
  ttl;
111377
111315
  ttlResolution;
@@ -111388,1057 +111326,521 @@ class LRUCache {
111388
111326
  allowStaleOnFetchAbort;
111389
111327
  allowStaleOnFetchRejection;
111390
111328
  ignoreFetchAbort;
111391
- #size;
111392
- #calculatedSize;
111393
- #keyMap;
111394
- #keyList;
111395
- #valList;
111396
- #next;
111397
- #prev;
111398
- #head;
111399
- #tail;
111400
- #free;
111401
- #disposed;
111402
- #sizes;
111403
- #starts;
111404
- #ttls;
111405
- #autopurgeTimers;
111406
- #hasDispose;
111407
- #hasFetchMethod;
111408
- #hasDisposeAfter;
111409
- #hasOnInsert;
111410
- static unsafeExposeInternals(c) {
111411
- return {
111412
- starts: c.#starts,
111413
- ttls: c.#ttls,
111414
- autopurgeTimers: c.#autopurgeTimers,
111415
- sizes: c.#sizes,
111416
- keyMap: c.#keyMap,
111417
- keyList: c.#keyList,
111418
- valList: c.#valList,
111419
- next: c.#next,
111420
- prev: c.#prev,
111421
- get head() {
111422
- return c.#head;
111423
- },
111424
- get tail() {
111425
- return c.#tail;
111426
- },
111427
- free: c.#free,
111428
- isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
111429
- backgroundFetch: (k, index3, options, context) => c.#backgroundFetch(k, index3, options, context),
111430
- moveToTail: (index3) => c.#moveToTail(index3),
111431
- indexes: (options) => c.#indexes(options),
111432
- rindexes: (options) => c.#rindexes(options),
111433
- isStale: (index3) => c.#isStale(index3)
111434
- };
111329
+ #n;
111330
+ #_;
111331
+ #s;
111332
+ #i;
111333
+ #t;
111334
+ #a;
111335
+ #u;
111336
+ #l;
111337
+ #h;
111338
+ #b;
111339
+ #r;
111340
+ #y;
111341
+ #A;
111342
+ #d;
111343
+ #g;
111344
+ #T;
111345
+ #v;
111346
+ #f;
111347
+ #x;
111348
+ static unsafeExposeInternals(t) {
111349
+ return { starts: t.#A, ttls: t.#d, autopurgeTimers: t.#g, sizes: t.#y, keyMap: t.#s, keyList: t.#i, valList: t.#t, next: t.#a, prev: t.#u, get head() {
111350
+ return t.#l;
111351
+ }, get tail() {
111352
+ return t.#h;
111353
+ }, free: t.#b, isBackgroundFetch: (e) => t.#e(e), backgroundFetch: (e, i2, s, h) => t.#G(e, i2, s, h), moveToTail: (e) => t.#D(e), indexes: (e) => t.#F(e), rindexes: (e) => t.#O(e), isStale: (e) => t.#p(e) };
111435
111354
  }
111436
111355
  get max() {
111437
- return this.#max;
111356
+ return this.#o;
111438
111357
  }
111439
111358
  get maxSize() {
111440
- return this.#maxSize;
111359
+ return this.#c;
111441
111360
  }
111442
111361
  get calculatedSize() {
111443
- return this.#calculatedSize;
111362
+ return this.#_;
111444
111363
  }
111445
111364
  get size() {
111446
- return this.#size;
111365
+ return this.#n;
111447
111366
  }
111448
111367
  get fetchMethod() {
111449
- return this.#fetchMethod;
111368
+ return this.#L;
111450
111369
  }
111451
111370
  get memoMethod() {
111452
- return this.#memoMethod;
111371
+ return this.#I;
111453
111372
  }
111454
111373
  get dispose() {
111455
- return this.#dispose;
111374
+ return this.#w;
111456
111375
  }
111457
111376
  get onInsert() {
111458
- return this.#onInsert;
111377
+ return this.#C;
111459
111378
  }
111460
111379
  get disposeAfter() {
111461
- return this.#disposeAfter;
111380
+ return this.#S;
111462
111381
  }
111463
- constructor(options) {
111464
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
111465
- if (perf !== undefined) {
111466
- if (typeof perf?.now !== "function") {
111467
- throw new TypeError("perf option must have a now() method if specified");
111468
- }
111469
- }
111470
- this.#perf = perf ?? defaultPerf;
111471
- if (max !== 0 && !isPosInt(max)) {
111382
+ constructor(t) {
111383
+ let { max: e = 0, ttl: i2, ttlResolution: s = 1, ttlAutopurge: h, updateAgeOnGet: n, updateAgeOnHas: o, allowStale: r, dispose: f, onInsert: m, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: g, maxSize: A = 0, maxEntrySize: p = 0, sizeCalculation: _, fetchMethod: l, memoMethod: w, noDeleteOnFetchRejection: b, noDeleteOnStaleGet: S, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: T, ignoreFetchAbort: F, perf: v } = t;
111384
+ if (v !== undefined && typeof v?.now != "function")
111385
+ throw new TypeError("perf option must have a now() method if specified");
111386
+ if (this.#m = v ?? M, e !== 0 && !y(e))
111472
111387
  throw new TypeError("max option must be a nonnegative integer");
111473
- }
111474
- const UintArray = max ? getUintArray(max) : Array;
111475
- if (!UintArray) {
111476
- throw new Error("invalid max value: " + max);
111477
- }
111478
- this.#max = max;
111479
- this.#maxSize = maxSize;
111480
- this.maxEntrySize = maxEntrySize || this.#maxSize;
111481
- this.sizeCalculation = sizeCalculation;
111482
- if (this.sizeCalculation) {
111483
- if (!this.#maxSize && !this.maxEntrySize) {
111388
+ let O = e ? U(e) : Array;
111389
+ if (!O)
111390
+ throw new Error("invalid max value: " + e);
111391
+ if (this.#o = e, this.#c = A, this.maxEntrySize = p || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
111392
+ if (!this.#c && !this.maxEntrySize)
111484
111393
  throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
111485
- }
111486
- if (typeof this.sizeCalculation !== "function") {
111394
+ if (typeof this.sizeCalculation != "function")
111487
111395
  throw new TypeError("sizeCalculation set to non-function");
111488
- }
111489
111396
  }
111490
- if (memoMethod !== undefined && typeof memoMethod !== "function") {
111397
+ if (w !== undefined && typeof w != "function")
111491
111398
  throw new TypeError("memoMethod must be a function if defined");
111492
- }
111493
- this.#memoMethod = memoMethod;
111494
- if (fetchMethod !== undefined && typeof fetchMethod !== "function") {
111399
+ if (this.#I = w, l !== undefined && typeof l != "function")
111495
111400
  throw new TypeError("fetchMethod must be a function if specified");
111496
- }
111497
- this.#fetchMethod = fetchMethod;
111498
- this.#hasFetchMethod = !!fetchMethod;
111499
- this.#keyMap = new Map;
111500
- this.#keyList = new Array(max).fill(undefined);
111501
- this.#valList = new Array(max).fill(undefined);
111502
- this.#next = new UintArray(max);
111503
- this.#prev = new UintArray(max);
111504
- this.#head = 0;
111505
- this.#tail = 0;
111506
- this.#free = Stack2.create(max);
111507
- this.#size = 0;
111508
- this.#calculatedSize = 0;
111509
- if (typeof dispose === "function") {
111510
- this.#dispose = dispose;
111511
- }
111512
- if (typeof onInsert === "function") {
111513
- this.#onInsert = onInsert;
111514
- }
111515
- if (typeof disposeAfter === "function") {
111516
- this.#disposeAfter = disposeAfter;
111517
- this.#disposed = [];
111518
- } else {
111519
- this.#disposeAfter = undefined;
111520
- this.#disposed = undefined;
111521
- }
111522
- this.#hasDispose = !!this.#dispose;
111523
- this.#hasOnInsert = !!this.#onInsert;
111524
- this.#hasDisposeAfter = !!this.#disposeAfter;
111525
- this.noDisposeOnSet = !!noDisposeOnSet;
111526
- this.noUpdateTTL = !!noUpdateTTL;
111527
- this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
111528
- this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
111529
- this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
111530
- this.ignoreFetchAbort = !!ignoreFetchAbort;
111531
- if (this.maxEntrySize !== 0) {
111532
- if (this.#maxSize !== 0) {
111533
- if (!isPosInt(this.#maxSize)) {
111534
- throw new TypeError("maxSize must be a positive integer if specified");
111535
- }
111536
- }
111537
- if (!isPosInt(this.maxEntrySize)) {
111401
+ if (this.#L = l, this.#v = !!l, this.#s = new Map, this.#i = new Array(e).fill(undefined), this.#t = new Array(e).fill(undefined), this.#a = new O(e), this.#u = new O(e), this.#l = 0, this.#h = 0, this.#b = W.create(e), this.#n = 0, this.#_ = 0, typeof f == "function" && (this.#w = f), typeof m == "function" && (this.#C = m), typeof c == "function" ? (this.#S = c, this.#r = []) : (this.#S = undefined, this.#r = undefined), this.#T = !!this.#w, this.#x = !!this.#C, this.#f = !!this.#S, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!g, this.noDeleteOnFetchRejection = !!b, this.allowStaleOnFetchRejection = !!u, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!F, this.maxEntrySize !== 0) {
111402
+ if (this.#c !== 0 && !y(this.#c))
111403
+ throw new TypeError("maxSize must be a positive integer if specified");
111404
+ if (!y(this.maxEntrySize))
111538
111405
  throw new TypeError("maxEntrySize must be a positive integer if specified");
111539
- }
111540
- this.#initializeSizeTracking();
111541
- }
111542
- this.allowStale = !!allowStale;
111543
- this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
111544
- this.updateAgeOnGet = !!updateAgeOnGet;
111545
- this.updateAgeOnHas = !!updateAgeOnHas;
111546
- this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
111547
- this.ttlAutopurge = !!ttlAutopurge;
111548
- this.ttl = ttl || 0;
111549
- if (this.ttl) {
111550
- if (!isPosInt(this.ttl)) {
111406
+ this.#B();
111407
+ }
111408
+ if (this.allowStale = !!r, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!n, this.updateAgeOnHas = !!o, this.ttlResolution = y(s) || s === 0 ? s : 1, this.ttlAutopurge = !!h, this.ttl = i2 || 0, this.ttl) {
111409
+ if (!y(this.ttl))
111551
111410
  throw new TypeError("ttl must be a positive integer if specified");
111552
- }
111553
- this.#initializeTTLTracking();
111411
+ this.#j();
111554
111412
  }
111555
- if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
111413
+ if (this.#o === 0 && this.ttl === 0 && this.#c === 0)
111556
111414
  throw new TypeError("At least one of max, maxSize, or ttl is required");
111557
- }
111558
- if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
111559
- const code2 = "LRU_CACHE_UNBOUNDED";
111560
- if (shouldWarn(code2)) {
111561
- warned.add(code2);
111562
- const msg = "TTL caching without ttlAutopurge, max, or maxSize can " + "result in unbounded memory consumption.";
111563
- emitWarning(msg, "UnboundedCacheWarning", code2, LRUCache);
111564
- }
111565
- }
111566
- }
111567
- getRemainingTTL(key) {
111568
- return this.#keyMap.has(key) ? Infinity : 0;
111569
- }
111570
- #initializeTTLTracking() {
111571
- const ttls = new ZeroArray(this.#max);
111572
- const starts = new ZeroArray(this.#max);
111573
- this.#ttls = ttls;
111574
- this.#starts = starts;
111575
- const purgeTimers = this.ttlAutopurge ? new Array(this.#max) : undefined;
111576
- this.#autopurgeTimers = purgeTimers;
111577
- this.#setItemTTL = (index3, ttl, start4 = this.#perf.now()) => {
111578
- starts[index3] = ttl !== 0 ? start4 : 0;
111579
- ttls[index3] = ttl;
111580
- if (purgeTimers?.[index3]) {
111581
- clearTimeout(purgeTimers[index3]);
111582
- purgeTimers[index3] = undefined;
111583
- }
111584
- if (ttl !== 0 && purgeTimers) {
111585
- const t = setTimeout(() => {
111586
- if (this.#isStale(index3)) {
111587
- this.#delete(this.#keyList[index3], "expire");
111588
- }
111589
- }, ttl + 1);
111590
- if (t.unref) {
111591
- t.unref();
111592
- }
111593
- purgeTimers[index3] = t;
111594
- }
111595
- };
111596
- this.#updateItemAge = (index3) => {
111597
- starts[index3] = ttls[index3] !== 0 ? this.#perf.now() : 0;
111598
- };
111599
- this.#statusTTL = (status, index3) => {
111600
- if (ttls[index3]) {
111601
- const ttl = ttls[index3];
111602
- const start4 = starts[index3];
111603
- if (!ttl || !start4)
111415
+ if (!this.ttlAutopurge && !this.#o && !this.#c) {
111416
+ let E2 = "LRU_CACHE_UNBOUNDED";
111417
+ G(E2) && (I.add(E2), x("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E2, a2));
111418
+ }
111419
+ }
111420
+ getRemainingTTL(t) {
111421
+ return this.#s.has(t) ? 1 / 0 : 0;
111422
+ }
111423
+ #j() {
111424
+ let t = new z4(this.#o), e = new z4(this.#o);
111425
+ this.#d = t, this.#A = e;
111426
+ let i2 = this.ttlAutopurge ? new Array(this.#o) : undefined;
111427
+ this.#g = i2, this.#N = (n, o, r = this.#m.now()) => {
111428
+ if (e[n] = o !== 0 ? r : 0, t[n] = o, i2?.[n] && (clearTimeout(i2[n]), i2[n] = undefined), o !== 0 && i2) {
111429
+ let f = setTimeout(() => {
111430
+ this.#p(n) && this.#E(this.#i[n], "expire");
111431
+ }, o + 1);
111432
+ f.unref && f.unref(), i2[n] = f;
111433
+ }
111434
+ }, this.#R = (n) => {
111435
+ e[n] = t[n] !== 0 ? this.#m.now() : 0;
111436
+ }, this.#z = (n, o) => {
111437
+ if (t[o]) {
111438
+ let r = t[o], f = e[o];
111439
+ if (!r || !f)
111604
111440
  return;
111605
- status.ttl = ttl;
111606
- status.start = start4;
111607
- status.now = cachedNow || getNow();
111608
- const age = status.now - start4;
111609
- status.remainingTTL = ttl - age;
111441
+ n.ttl = r, n.start = f, n.now = s || h();
111442
+ let m = n.now - f;
111443
+ n.remainingTTL = r - m;
111610
111444
  }
111611
111445
  };
111612
- let cachedNow = 0;
111613
- const getNow = () => {
111614
- const n = this.#perf.now();
111446
+ let s = 0, h = () => {
111447
+ let n = this.#m.now();
111615
111448
  if (this.ttlResolution > 0) {
111616
- cachedNow = n;
111617
- const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
111618
- if (t.unref) {
111619
- t.unref();
111620
- }
111449
+ s = n;
111450
+ let o = setTimeout(() => s = 0, this.ttlResolution);
111451
+ o.unref && o.unref();
111621
111452
  }
111622
111453
  return n;
111623
111454
  };
111624
- this.getRemainingTTL = (key) => {
111625
- const index3 = this.#keyMap.get(key);
111626
- if (index3 === undefined) {
111455
+ this.getRemainingTTL = (n) => {
111456
+ let o = this.#s.get(n);
111457
+ if (o === undefined)
111627
111458
  return 0;
111628
- }
111629
- const ttl = ttls[index3];
111630
- const start4 = starts[index3];
111631
- if (!ttl || !start4) {
111632
- return Infinity;
111633
- }
111634
- const age = (cachedNow || getNow()) - start4;
111635
- return ttl - age;
111636
- };
111637
- this.#isStale = (index3) => {
111638
- const s = starts[index3];
111639
- const t = ttls[index3];
111640
- return !!t && !!s && (cachedNow || getNow()) - s > t;
111641
- };
111642
- }
111643
- #updateItemAge = () => {};
111644
- #statusTTL = () => {};
111645
- #setItemTTL = () => {};
111646
- #isStale = () => false;
111647
- #initializeSizeTracking() {
111648
- const sizes = new ZeroArray(this.#max);
111649
- this.#calculatedSize = 0;
111650
- this.#sizes = sizes;
111651
- this.#removeItemSize = (index3) => {
111652
- this.#calculatedSize -= sizes[index3];
111653
- sizes[index3] = 0;
111654
- };
111655
- this.#requireSize = (k, v, size, sizeCalculation) => {
111656
- if (this.#isBackgroundFetch(v)) {
111459
+ let r = t[o], f = e[o];
111460
+ if (!r || !f)
111461
+ return 1 / 0;
111462
+ let m = (s || h()) - f;
111463
+ return r - m;
111464
+ }, this.#p = (n) => {
111465
+ let o = e[n], r = t[n];
111466
+ return !!r && !!o && (s || h()) - o > r;
111467
+ };
111468
+ }
111469
+ #R = () => {};
111470
+ #z = () => {};
111471
+ #N = () => {};
111472
+ #p = () => false;
111473
+ #B() {
111474
+ let t = new z4(this.#o);
111475
+ this.#_ = 0, this.#y = t, this.#W = (e) => {
111476
+ this.#_ -= t[e], t[e] = 0;
111477
+ }, this.#P = (e, i2, s, h) => {
111478
+ if (this.#e(i2))
111657
111479
  return 0;
111658
- }
111659
- if (!isPosInt(size)) {
111660
- if (sizeCalculation) {
111661
- if (typeof sizeCalculation !== "function") {
111480
+ if (!y(s))
111481
+ if (h) {
111482
+ if (typeof h != "function")
111662
111483
  throw new TypeError("sizeCalculation must be a function");
111663
- }
111664
- size = sizeCalculation(v, k);
111665
- if (!isPosInt(size)) {
111484
+ if (s = h(i2, e), !y(s))
111666
111485
  throw new TypeError("sizeCalculation return invalid (expect positive integer)");
111667
- }
111668
- } else {
111669
- throw new TypeError("invalid size value (must be positive integer). " + "When maxSize or maxEntrySize is used, sizeCalculation " + "or size must be set.");
111670
- }
111671
- }
111672
- return size;
111673
- };
111674
- this.#addItemSize = (index3, size, status) => {
111675
- sizes[index3] = size;
111676
- if (this.#maxSize) {
111677
- const maxSize = this.#maxSize - sizes[index3];
111678
- while (this.#calculatedSize > maxSize) {
111679
- this.#evict(true);
111680
- }
111681
- }
111682
- this.#calculatedSize += sizes[index3];
111683
- if (status) {
111684
- status.entrySize = size;
111685
- status.totalCalculatedSize = this.#calculatedSize;
111486
+ } else
111487
+ throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
111488
+ return s;
111489
+ }, this.#U = (e, i2, s) => {
111490
+ if (t[e] = i2, this.#c) {
111491
+ let h = this.#c - t[e];
111492
+ for (;this.#_ > h; )
111493
+ this.#M(true);
111686
111494
  }
111495
+ this.#_ += t[e], s && (s.entrySize = i2, s.totalCalculatedSize = this.#_);
111687
111496
  };
111688
111497
  }
111689
- #removeItemSize = (_i) => {};
111690
- #addItemSize = (_i, _s, _st) => {};
111691
- #requireSize = (_k, _v, size, sizeCalculation) => {
111692
- if (size || sizeCalculation) {
111498
+ #W = (t) => {};
111499
+ #U = (t, e, i2) => {};
111500
+ #P = (t, e, i2, s) => {
111501
+ if (i2 || s)
111693
111502
  throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
111694
- }
111695
111503
  return 0;
111696
111504
  };
111697
- *#indexes({ allowStale = this.allowStale } = {}) {
111698
- if (this.#size) {
111699
- for (let i2 = this.#tail;; ) {
111700
- if (!this.#isValidIndex(i2)) {
111701
- break;
111702
- }
111703
- if (allowStale || !this.#isStale(i2)) {
111704
- yield i2;
111705
- }
111706
- if (i2 === this.#head) {
111707
- break;
111708
- } else {
111709
- i2 = this.#prev[i2];
111710
- }
111711
- }
111712
- }
111505
+ *#F({ allowStale: t = this.allowStale } = {}) {
111506
+ if (this.#n)
111507
+ for (let e = this.#h;!(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#l)); )
111508
+ e = this.#u[e];
111713
111509
  }
111714
- *#rindexes({ allowStale = this.allowStale } = {}) {
111715
- if (this.#size) {
111716
- for (let i2 = this.#head;; ) {
111717
- if (!this.#isValidIndex(i2)) {
111718
- break;
111719
- }
111720
- if (allowStale || !this.#isStale(i2)) {
111721
- yield i2;
111722
- }
111723
- if (i2 === this.#tail) {
111724
- break;
111725
- } else {
111726
- i2 = this.#next[i2];
111727
- }
111728
- }
111729
- }
111510
+ *#O({ allowStale: t = this.allowStale } = {}) {
111511
+ if (this.#n)
111512
+ for (let e = this.#l;!(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#h)); )
111513
+ e = this.#a[e];
111730
111514
  }
111731
- #isValidIndex(index3) {
111732
- return index3 !== undefined && this.#keyMap.get(this.#keyList[index3]) === index3;
111515
+ #H(t) {
111516
+ return t !== undefined && this.#s.get(this.#i[t]) === t;
111733
111517
  }
111734
111518
  *entries() {
111735
- for (const i2 of this.#indexes()) {
111736
- if (this.#valList[i2] !== undefined && this.#keyList[i2] !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111737
- yield [this.#keyList[i2], this.#valList[i2]];
111738
- }
111739
- }
111519
+ for (let t of this.#F())
111520
+ this.#t[t] !== undefined && this.#i[t] !== undefined && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
111740
111521
  }
111741
111522
  *rentries() {
111742
- for (const i2 of this.#rindexes()) {
111743
- if (this.#valList[i2] !== undefined && this.#keyList[i2] !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111744
- yield [this.#keyList[i2], this.#valList[i2]];
111745
- }
111746
- }
111523
+ for (let t of this.#O())
111524
+ this.#t[t] !== undefined && this.#i[t] !== undefined && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
111747
111525
  }
111748
111526
  *keys() {
111749
- for (const i2 of this.#indexes()) {
111750
- const k = this.#keyList[i2];
111751
- if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111752
- yield k;
111753
- }
111527
+ for (let t of this.#F()) {
111528
+ let e = this.#i[t];
111529
+ e !== undefined && !this.#e(this.#t[t]) && (yield e);
111754
111530
  }
111755
111531
  }
111756
111532
  *rkeys() {
111757
- for (const i2 of this.#rindexes()) {
111758
- const k = this.#keyList[i2];
111759
- if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111760
- yield k;
111761
- }
111533
+ for (let t of this.#O()) {
111534
+ let e = this.#i[t];
111535
+ e !== undefined && !this.#e(this.#t[t]) && (yield e);
111762
111536
  }
111763
111537
  }
111764
111538
  *values() {
111765
- for (const i2 of this.#indexes()) {
111766
- const v = this.#valList[i2];
111767
- if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111768
- yield this.#valList[i2];
111769
- }
111770
- }
111539
+ for (let t of this.#F())
111540
+ this.#t[t] !== undefined && !this.#e(this.#t[t]) && (yield this.#t[t]);
111771
111541
  }
111772
111542
  *rvalues() {
111773
- for (const i2 of this.#rindexes()) {
111774
- const v = this.#valList[i2];
111775
- if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i2])) {
111776
- yield this.#valList[i2];
111777
- }
111778
- }
111543
+ for (let t of this.#O())
111544
+ this.#t[t] !== undefined && !this.#e(this.#t[t]) && (yield this.#t[t]);
111779
111545
  }
111780
111546
  [Symbol.iterator]() {
111781
111547
  return this.entries();
111782
111548
  }
111783
111549
  [Symbol.toStringTag] = "LRUCache";
111784
- find(fn, getOptions = {}) {
111785
- for (const i2 of this.#indexes()) {
111786
- const v = this.#valList[i2];
111787
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
111788
- if (value === undefined)
111789
- continue;
111790
- if (fn(value, this.#keyList[i2], this)) {
111791
- return this.get(this.#keyList[i2], getOptions);
111792
- }
111550
+ find(t, e = {}) {
111551
+ for (let i2 of this.#F()) {
111552
+ let s = this.#t[i2], h = this.#e(s) ? s.__staleWhileFetching : s;
111553
+ if (h !== undefined && t(h, this.#i[i2], this))
111554
+ return this.get(this.#i[i2], e);
111793
111555
  }
111794
111556
  }
111795
- forEach(fn, thisp = this) {
111796
- for (const i2 of this.#indexes()) {
111797
- const v = this.#valList[i2];
111798
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
111799
- if (value === undefined)
111800
- continue;
111801
- fn.call(thisp, value, this.#keyList[i2], this);
111557
+ forEach(t, e = this) {
111558
+ for (let i2 of this.#F()) {
111559
+ let s = this.#t[i2], h = this.#e(s) ? s.__staleWhileFetching : s;
111560
+ h !== undefined && t.call(e, h, this.#i[i2], this);
111802
111561
  }
111803
111562
  }
111804
- rforEach(fn, thisp = this) {
111805
- for (const i2 of this.#rindexes()) {
111806
- const v = this.#valList[i2];
111807
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
111808
- if (value === undefined)
111809
- continue;
111810
- fn.call(thisp, value, this.#keyList[i2], this);
111563
+ rforEach(t, e = this) {
111564
+ for (let i2 of this.#O()) {
111565
+ let s = this.#t[i2], h = this.#e(s) ? s.__staleWhileFetching : s;
111566
+ h !== undefined && t.call(e, h, this.#i[i2], this);
111811
111567
  }
111812
111568
  }
111813
111569
  purgeStale() {
111814
- let deleted = false;
111815
- for (const i2 of this.#rindexes({ allowStale: true })) {
111816
- if (this.#isStale(i2)) {
111817
- this.#delete(this.#keyList[i2], "expire");
111818
- deleted = true;
111819
- }
111820
- }
111821
- return deleted;
111822
- }
111823
- info(key) {
111824
- const i2 = this.#keyMap.get(key);
111825
- if (i2 === undefined)
111570
+ let t = false;
111571
+ for (let e of this.#O({ allowStale: true }))
111572
+ this.#p(e) && (this.#E(this.#i[e], "expire"), t = true);
111573
+ return t;
111574
+ }
111575
+ info(t) {
111576
+ let e = this.#s.get(t);
111577
+ if (e === undefined)
111826
111578
  return;
111827
- const v = this.#valList[i2];
111828
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
111829
- if (value === undefined)
111579
+ let i2 = this.#t[e], s = this.#e(i2) ? i2.__staleWhileFetching : i2;
111580
+ if (s === undefined)
111830
111581
  return;
111831
- const entry2 = { value };
111832
- if (this.#ttls && this.#starts) {
111833
- const ttl = this.#ttls[i2];
111834
- const start4 = this.#starts[i2];
111835
- if (ttl && start4) {
111836
- const remain = ttl - (this.#perf.now() - start4);
111837
- entry2.ttl = remain;
111838
- entry2.start = Date.now();
111582
+ let h = { value: s };
111583
+ if (this.#d && this.#A) {
111584
+ let n = this.#d[e], o = this.#A[e];
111585
+ if (n && o) {
111586
+ let r = n - (this.#m.now() - o);
111587
+ h.ttl = r, h.start = Date.now();
111839
111588
  }
111840
111589
  }
111841
- if (this.#sizes) {
111842
- entry2.size = this.#sizes[i2];
111843
- }
111844
- return entry2;
111590
+ return this.#y && (h.size = this.#y[e]), h;
111845
111591
  }
111846
111592
  dump() {
111847
- const arr = [];
111848
- for (const i2 of this.#indexes({ allowStale: true })) {
111849
- const key = this.#keyList[i2];
111850
- const v = this.#valList[i2];
111851
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
111852
- if (value === undefined || key === undefined)
111593
+ let t = [];
111594
+ for (let e of this.#F({ allowStale: true })) {
111595
+ let i2 = this.#i[e], s = this.#t[e], h = this.#e(s) ? s.__staleWhileFetching : s;
111596
+ if (h === undefined || i2 === undefined)
111853
111597
  continue;
111854
- const entry2 = { value };
111855
- if (this.#ttls && this.#starts) {
111856
- entry2.ttl = this.#ttls[i2];
111857
- const age = this.#perf.now() - this.#starts[i2];
111858
- entry2.start = Math.floor(Date.now() - age);
111598
+ let n = { value: h };
111599
+ if (this.#d && this.#A) {
111600
+ n.ttl = this.#d[e];
111601
+ let o = this.#m.now() - this.#A[e];
111602
+ n.start = Math.floor(Date.now() - o);
111859
111603
  }
111860
- if (this.#sizes) {
111861
- entry2.size = this.#sizes[i2];
111862
- }
111863
- arr.unshift([key, entry2]);
111604
+ this.#y && (n.size = this.#y[e]), t.unshift([i2, n]);
111864
111605
  }
111865
- return arr;
111606
+ return t;
111866
111607
  }
111867
- load(arr) {
111608
+ load(t) {
111868
111609
  this.clear();
111869
- for (const [key, entry2] of arr) {
111870
- if (entry2.start) {
111871
- const age = Date.now() - entry2.start;
111872
- entry2.start = this.#perf.now() - age;
111873
- }
111874
- this.set(key, entry2.value, entry2);
111875
- }
111876
- }
111877
- set(k, v, setOptions = {}) {
111878
- if (v === undefined) {
111879
- this.delete(k);
111880
- return this;
111881
- }
111882
- const { ttl = this.ttl, start: start4, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
111883
- let { noUpdateTTL = this.noUpdateTTL } = setOptions;
111884
- const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
111885
- if (this.maxEntrySize && size > this.maxEntrySize) {
111886
- if (status) {
111887
- status.set = "miss";
111888
- status.maxEntrySizeExceeded = true;
111889
- }
111890
- this.#delete(k, "set");
111891
- return this;
111892
- }
111893
- let index3 = this.#size === 0 ? undefined : this.#keyMap.get(k);
111894
- if (index3 === undefined) {
111895
- index3 = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
111896
- this.#keyList[index3] = k;
111897
- this.#valList[index3] = v;
111898
- this.#keyMap.set(k, index3);
111899
- this.#next[this.#tail] = index3;
111900
- this.#prev[index3] = this.#tail;
111901
- this.#tail = index3;
111902
- this.#size++;
111903
- this.#addItemSize(index3, size, status);
111904
- if (status)
111905
- status.set = "add";
111906
- noUpdateTTL = false;
111907
- if (this.#hasOnInsert) {
111908
- this.#onInsert?.(v, k, "add");
111909
- }
111910
- } else {
111911
- this.#moveToTail(index3);
111912
- const oldVal = this.#valList[index3];
111913
- if (v !== oldVal) {
111914
- if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
111915
- oldVal.__abortController.abort(new Error("replaced"));
111916
- const { __staleWhileFetching: s } = oldVal;
111917
- if (s !== undefined && !noDisposeOnSet) {
111918
- if (this.#hasDispose) {
111919
- this.#dispose?.(s, k, "set");
111920
- }
111921
- if (this.#hasDisposeAfter) {
111922
- this.#disposed?.push([s, k, "set"]);
111923
- }
111924
- }
111925
- } else if (!noDisposeOnSet) {
111926
- if (this.#hasDispose) {
111927
- this.#dispose?.(oldVal, k, "set");
111928
- }
111929
- if (this.#hasDisposeAfter) {
111930
- this.#disposed?.push([oldVal, k, "set"]);
111931
- }
111932
- }
111933
- this.#removeItemSize(index3);
111934
- this.#addItemSize(index3, size, status);
111935
- this.#valList[index3] = v;
111936
- if (status) {
111937
- status.set = "replace";
111938
- const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
111939
- if (oldValue !== undefined)
111940
- status.oldValue = oldValue;
111610
+ for (let [e, i2] of t) {
111611
+ if (i2.start) {
111612
+ let s = Date.now() - i2.start;
111613
+ i2.start = this.#m.now() - s;
111614
+ }
111615
+ this.set(e, i2.value, i2);
111616
+ }
111617
+ }
111618
+ set(t, e, i2 = {}) {
111619
+ if (e === undefined)
111620
+ return this.delete(t), this;
111621
+ let { ttl: s = this.ttl, start: h, noDisposeOnSet: n = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: r } = i2, { noUpdateTTL: f = this.noUpdateTTL } = i2, m = this.#P(t, e, i2.size || 0, o);
111622
+ if (this.maxEntrySize && m > this.maxEntrySize)
111623
+ return r && (r.set = "miss", r.maxEntrySizeExceeded = true), this.#E(t, "set"), this;
111624
+ let c = this.#n === 0 ? undefined : this.#s.get(t);
111625
+ if (c === undefined)
111626
+ c = this.#n === 0 ? this.#h : this.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#M(false) : this.#n, this.#i[c] = t, this.#t[c] = e, this.#s.set(t, c), this.#a[this.#h] = c, this.#u[c] = this.#h, this.#h = c, this.#n++, this.#U(c, m, r), r && (r.set = "add"), f = false, this.#x && this.#C?.(e, t, "add");
111627
+ else {
111628
+ this.#D(c);
111629
+ let d = this.#t[c];
111630
+ if (e !== d) {
111631
+ if (this.#v && this.#e(d)) {
111632
+ d.__abortController.abort(new Error("replaced"));
111633
+ let { __staleWhileFetching: g } = d;
111634
+ g !== undefined && !n && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([g, t, "set"]));
111635
+ } else
111636
+ n || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([d, t, "set"]));
111637
+ if (this.#W(c), this.#U(c, m, r), this.#t[c] = e, r) {
111638
+ r.set = "replace";
111639
+ let g = d && this.#e(d) ? d.__staleWhileFetching : d;
111640
+ g !== undefined && (r.oldValue = g);
111941
111641
  }
111942
- } else if (status) {
111943
- status.set = "update";
111944
- }
111945
- if (this.#hasOnInsert) {
111946
- this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
111947
- }
111948
- }
111949
- if (ttl !== 0 && !this.#ttls) {
111950
- this.#initializeTTLTracking();
111951
- }
111952
- if (this.#ttls) {
111953
- if (!noUpdateTTL) {
111954
- this.#setItemTTL(index3, ttl, start4);
111955
- }
111956
- if (status)
111957
- this.#statusTTL(status, index3);
111642
+ } else
111643
+ r && (r.set = "update");
111644
+ this.#x && this.onInsert?.(e, t, e === d ? "update" : "replace");
111958
111645
  }
111959
- if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
111960
- const dt = this.#disposed;
111961
- let task;
111962
- while (task = dt?.shift()) {
111963
- this.#disposeAfter?.(...task);
111964
- }
111646
+ if (s !== 0 && !this.#d && this.#j(), this.#d && (f || this.#N(c, s, h), r && this.#z(r, c)), !n && this.#f && this.#r) {
111647
+ let d = this.#r, g;
111648
+ for (;g = d?.shift(); )
111649
+ this.#S?.(...g);
111965
111650
  }
111966
111651
  return this;
111967
111652
  }
111968
111653
  pop() {
111969
111654
  try {
111970
- while (this.#size) {
111971
- const val = this.#valList[this.#head];
111972
- this.#evict(true);
111973
- if (this.#isBackgroundFetch(val)) {
111974
- if (val.__staleWhileFetching) {
111975
- return val.__staleWhileFetching;
111976
- }
111977
- } else if (val !== undefined) {
111978
- return val;
111979
- }
111655
+ for (;this.#n; ) {
111656
+ let t = this.#t[this.#l];
111657
+ if (this.#M(true), this.#e(t)) {
111658
+ if (t.__staleWhileFetching)
111659
+ return t.__staleWhileFetching;
111660
+ } else if (t !== undefined)
111661
+ return t;
111980
111662
  }
111981
111663
  } finally {
111982
- if (this.#hasDisposeAfter && this.#disposed) {
111983
- const dt = this.#disposed;
111984
- let task;
111985
- while (task = dt?.shift()) {
111986
- this.#disposeAfter?.(...task);
111987
- }
111664
+ if (this.#f && this.#r) {
111665
+ let t = this.#r, e;
111666
+ for (;e = t?.shift(); )
111667
+ this.#S?.(...e);
111988
111668
  }
111989
111669
  }
111990
111670
  }
111991
- #evict(free) {
111992
- const head = this.#head;
111993
- const k = this.#keyList[head];
111994
- const v = this.#valList[head];
111995
- if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
111996
- v.__abortController.abort(new Error("evicted"));
111997
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
111998
- if (this.#hasDispose) {
111999
- this.#dispose?.(v, k, "evict");
112000
- }
112001
- if (this.#hasDisposeAfter) {
112002
- this.#disposed?.push([v, k, "evict"]);
112003
- }
112004
- }
112005
- this.#removeItemSize(head);
112006
- if (this.#autopurgeTimers?.[head]) {
112007
- clearTimeout(this.#autopurgeTimers[head]);
112008
- this.#autopurgeTimers[head] = undefined;
112009
- }
112010
- if (free) {
112011
- this.#keyList[head] = undefined;
112012
- this.#valList[head] = undefined;
112013
- this.#free.push(head);
112014
- }
112015
- if (this.#size === 1) {
112016
- this.#head = this.#tail = 0;
112017
- this.#free.length = 0;
112018
- } else {
112019
- this.#head = this.#next[head];
112020
- }
112021
- this.#keyMap.delete(k);
112022
- this.#size--;
112023
- return head;
112024
- }
112025
- has(k, hasOptions = {}) {
112026
- const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
112027
- const index3 = this.#keyMap.get(k);
112028
- if (index3 !== undefined) {
112029
- const v = this.#valList[index3];
112030
- if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === undefined) {
111671
+ #M(t) {
111672
+ let e = this.#l, i2 = this.#i[e], s = this.#t[e];
111673
+ return this.#v && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i2, "evict"), this.#f && this.#r?.push([s, i2, "evict"])), this.#W(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = undefined), t && (this.#i[e] = undefined, this.#t[e] = undefined, this.#b.push(e)), this.#n === 1 ? (this.#l = this.#h = 0, this.#b.length = 0) : this.#l = this.#a[e], this.#s.delete(i2), this.#n--, e;
111674
+ }
111675
+ has(t, e = {}) {
111676
+ let { updateAgeOnHas: i2 = this.updateAgeOnHas, status: s } = e, h = this.#s.get(t);
111677
+ if (h !== undefined) {
111678
+ let n = this.#t[h];
111679
+ if (this.#e(n) && n.__staleWhileFetching === undefined)
112031
111680
  return false;
112032
- }
112033
- if (!this.#isStale(index3)) {
112034
- if (updateAgeOnHas) {
112035
- this.#updateItemAge(index3);
112036
- }
112037
- if (status) {
112038
- status.has = "hit";
112039
- this.#statusTTL(status, index3);
112040
- }
112041
- return true;
112042
- } else if (status) {
112043
- status.has = "stale";
112044
- this.#statusTTL(status, index3);
112045
- }
112046
- } else if (status) {
112047
- status.has = "miss";
112048
- }
111681
+ if (this.#p(h))
111682
+ s && (s.has = "stale", this.#z(s, h));
111683
+ else
111684
+ return i2 && this.#R(h), s && (s.has = "hit", this.#z(s, h)), true;
111685
+ } else
111686
+ s && (s.has = "miss");
112049
111687
  return false;
112050
111688
  }
112051
- peek(k, peekOptions = {}) {
112052
- const { allowStale = this.allowStale } = peekOptions;
112053
- const index3 = this.#keyMap.get(k);
112054
- if (index3 === undefined || !allowStale && this.#isStale(index3)) {
111689
+ peek(t, e = {}) {
111690
+ let { allowStale: i2 = this.allowStale } = e, s = this.#s.get(t);
111691
+ if (s === undefined || !i2 && this.#p(s))
112055
111692
  return;
112056
- }
112057
- const v = this.#valList[index3];
112058
- return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
112059
- }
112060
- #backgroundFetch(k, index3, options, context) {
112061
- const v = index3 === undefined ? undefined : this.#valList[index3];
112062
- if (this.#isBackgroundFetch(v)) {
112063
- return v;
112064
- }
112065
- const ac = new AC;
112066
- const { signal } = options;
112067
- signal?.addEventListener("abort", () => ac.abort(signal.reason), {
112068
- signal: ac.signal
112069
- });
112070
- const fetchOpts = {
112071
- signal: ac.signal,
112072
- options,
112073
- context
112074
- };
112075
- const cb = (v2, updateCache = false) => {
112076
- const { aborted: aborted5 } = ac.signal;
112077
- const ignoreAbort = options.ignoreFetchAbort && v2 !== undefined;
112078
- const proceed = options.ignoreFetchAbort || !!(options.allowStaleOnFetchAbort && v2 !== undefined);
112079
- if (options.status) {
112080
- if (aborted5 && !updateCache) {
112081
- options.status.fetchAborted = true;
112082
- options.status.fetchError = ac.signal.reason;
112083
- if (ignoreAbort)
112084
- options.status.fetchAbortIgnored = true;
112085
- } else {
112086
- options.status.fetchResolved = true;
112087
- }
112088
- }
112089
- if (aborted5 && !ignoreAbort && !updateCache) {
112090
- return fetchFail(ac.signal.reason, proceed);
112091
- }
112092
- const bf2 = p;
112093
- const vl = this.#valList[index3];
112094
- if (vl === p || ignoreAbort && updateCache && vl === undefined) {
112095
- if (v2 === undefined) {
112096
- if (bf2.__staleWhileFetching !== undefined) {
112097
- this.#valList[index3] = bf2.__staleWhileFetching;
112098
- } else {
112099
- this.#delete(k, "fetch");
112100
- }
112101
- } else {
112102
- if (options.status)
112103
- options.status.fetchUpdated = true;
112104
- this.set(k, v2, fetchOpts.options);
112105
- }
112106
- }
112107
- return v2;
112108
- };
112109
- const eb = (er) => {
112110
- if (options.status) {
112111
- options.status.fetchRejected = true;
112112
- options.status.fetchError = er;
112113
- }
112114
- return fetchFail(er, false);
112115
- };
112116
- const fetchFail = (er, proceed) => {
112117
- const { aborted: aborted5 } = ac.signal;
112118
- const allowStaleAborted = aborted5 && options.allowStaleOnFetchAbort;
112119
- const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
112120
- const noDelete = allowStale || options.noDeleteOnFetchRejection;
112121
- const bf2 = p;
112122
- if (this.#valList[index3] === p) {
112123
- const del = !noDelete || !proceed && bf2.__staleWhileFetching === undefined;
112124
- if (del) {
112125
- this.#delete(k, "fetch");
112126
- } else if (!allowStaleAborted) {
112127
- this.#valList[index3] = bf2.__staleWhileFetching;
112128
- }
112129
- }
112130
- if (allowStale) {
112131
- if (options.status && bf2.__staleWhileFetching !== undefined) {
112132
- options.status.returnedStale = true;
112133
- }
112134
- return bf2.__staleWhileFetching;
112135
- } else if (bf2.__returned === bf2) {
112136
- throw er;
112137
- }
112138
- };
112139
- const pcall = (res, rej) => {
112140
- const fmp = this.#fetchMethod?.(k, v, fetchOpts);
112141
- if (fmp && fmp instanceof Promise) {
112142
- fmp.then((v2) => res(v2 === undefined ? undefined : v2), rej);
112143
- }
112144
- ac.signal.addEventListener("abort", () => {
112145
- if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
112146
- res(undefined);
112147
- if (options.allowStaleOnFetchAbort) {
112148
- res = (v2) => cb(v2, true);
112149
- }
112150
- }
111693
+ let h = this.#t[s];
111694
+ return this.#e(h) ? h.__staleWhileFetching : h;
111695
+ }
111696
+ #G(t, e, i2, s) {
111697
+ let h = e === undefined ? undefined : this.#t[e];
111698
+ if (this.#e(h))
111699
+ return h;
111700
+ let n = new C, { signal: o } = i2;
111701
+ o?.addEventListener("abort", () => n.abort(o.reason), { signal: n.signal });
111702
+ let r = { signal: n.signal, options: i2, context: s }, f = (p, _ = false) => {
111703
+ let { aborted: l } = n.signal, w = i2.ignoreFetchAbort && p !== undefined, b = i2.ignoreFetchAbort || !!(i2.allowStaleOnFetchAbort && p !== undefined);
111704
+ if (i2.status && (l && !_ ? (i2.status.fetchAborted = true, i2.status.fetchError = n.signal.reason, w && (i2.status.fetchAbortIgnored = true)) : i2.status.fetchResolved = true), l && !w && !_)
111705
+ return c(n.signal.reason, b);
111706
+ let S = g, u = this.#t[e];
111707
+ return (u === g || w && _ && u === undefined) && (p === undefined ? S.__staleWhileFetching !== undefined ? this.#t[e] = S.__staleWhileFetching : this.#E(t, "fetch") : (i2.status && (i2.status.fetchUpdated = true), this.set(t, p, r.options))), p;
111708
+ }, m = (p) => (i2.status && (i2.status.fetchRejected = true, i2.status.fetchError = p), c(p, false)), c = (p, _) => {
111709
+ let { aborted: l } = n.signal, w = l && i2.allowStaleOnFetchAbort, b = w || i2.allowStaleOnFetchRejection, S = b || i2.noDeleteOnFetchRejection, u = g;
111710
+ if (this.#t[e] === g && (!S || !_ && u.__staleWhileFetching === undefined ? this.#E(t, "fetch") : w || (this.#t[e] = u.__staleWhileFetching)), b)
111711
+ return i2.status && u.__staleWhileFetching !== undefined && (i2.status.returnedStale = true), u.__staleWhileFetching;
111712
+ if (u.__returned === u)
111713
+ throw p;
111714
+ }, d = (p, _) => {
111715
+ let l = this.#L?.(t, h, r);
111716
+ l && l instanceof Promise && l.then((w) => p(w === undefined ? undefined : w), _), n.signal.addEventListener("abort", () => {
111717
+ (!i2.ignoreFetchAbort || i2.allowStaleOnFetchAbort) && (p(undefined), i2.allowStaleOnFetchAbort && (p = (w) => f(w, true)));
112151
111718
  });
112152
111719
  };
112153
- if (options.status)
112154
- options.status.fetchDispatched = true;
112155
- const p = new Promise(pcall).then(cb, eb);
112156
- const bf = Object.assign(p, {
112157
- __abortController: ac,
112158
- __staleWhileFetching: v,
112159
- __returned: undefined
112160
- });
112161
- if (index3 === undefined) {
112162
- this.set(k, bf, { ...fetchOpts.options, status: undefined });
112163
- index3 = this.#keyMap.get(k);
112164
- } else {
112165
- this.#valList[index3] = bf;
112166
- }
112167
- return bf;
111720
+ i2.status && (i2.status.fetchDispatched = true);
111721
+ let g = new Promise(d).then(f, m), A = Object.assign(g, { __abortController: n, __staleWhileFetching: h, __returned: undefined });
111722
+ return e === undefined ? (this.set(t, A, { ...r.options, status: undefined }), e = this.#s.get(t)) : this.#t[e] = A, A;
112168
111723
  }
112169
- #isBackgroundFetch(p) {
112170
- if (!this.#hasFetchMethod)
111724
+ #e(t) {
111725
+ if (!this.#v)
112171
111726
  return false;
112172
- const b = p;
112173
- return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
112174
- }
112175
- async fetch(k, fetchOptions = {}) {
112176
- const {
112177
- allowStale = this.allowStale,
112178
- updateAgeOnGet = this.updateAgeOnGet,
112179
- noDeleteOnStaleGet = this.noDeleteOnStaleGet,
112180
- ttl = this.ttl,
112181
- noDisposeOnSet = this.noDisposeOnSet,
112182
- size = 0,
112183
- sizeCalculation = this.sizeCalculation,
112184
- noUpdateTTL = this.noUpdateTTL,
112185
- noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
112186
- allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
112187
- ignoreFetchAbort = this.ignoreFetchAbort,
112188
- allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
112189
- context,
112190
- forceRefresh = false,
112191
- status,
112192
- signal
112193
- } = fetchOptions;
112194
- if (!this.#hasFetchMethod) {
112195
- if (status)
112196
- status.fetch = "get";
112197
- return this.get(k, {
112198
- allowStale,
112199
- updateAgeOnGet,
112200
- noDeleteOnStaleGet,
112201
- status
112202
- });
112203
- }
112204
- const options = {
112205
- allowStale,
112206
- updateAgeOnGet,
112207
- noDeleteOnStaleGet,
112208
- ttl,
112209
- noDisposeOnSet,
112210
- size,
112211
- sizeCalculation,
112212
- noUpdateTTL,
112213
- noDeleteOnFetchRejection,
112214
- allowStaleOnFetchRejection,
112215
- allowStaleOnFetchAbort,
112216
- ignoreFetchAbort,
112217
- status,
112218
- signal
112219
- };
112220
- let index3 = this.#keyMap.get(k);
112221
- if (index3 === undefined) {
112222
- if (status)
112223
- status.fetch = "miss";
112224
- const p = this.#backgroundFetch(k, index3, options, context);
112225
- return p.__returned = p;
111727
+ let e = t;
111728
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof C;
111729
+ }
111730
+ async fetch(t, e = {}) {
111731
+ let { allowStale: i2 = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, ttl: n = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: r = 0, sizeCalculation: f = this.sizeCalculation, noUpdateTTL: m = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: g = this.ignoreFetchAbort, allowStaleOnFetchAbort: A = this.allowStaleOnFetchAbort, context: p, forceRefresh: _ = false, status: l, signal: w } = e;
111732
+ if (!this.#v)
111733
+ return l && (l.fetch = "get"), this.get(t, { allowStale: i2, updateAgeOnGet: s, noDeleteOnStaleGet: h, status: l });
111734
+ let b = { allowStale: i2, updateAgeOnGet: s, noDeleteOnStaleGet: h, ttl: n, noDisposeOnSet: o, size: r, sizeCalculation: f, noUpdateTTL: m, noDeleteOnFetchRejection: c, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: g, status: l, signal: w }, S = this.#s.get(t);
111735
+ if (S === undefined) {
111736
+ l && (l.fetch = "miss");
111737
+ let u = this.#G(t, S, b, p);
111738
+ return u.__returned = u;
112226
111739
  } else {
112227
- const v = this.#valList[index3];
112228
- if (this.#isBackgroundFetch(v)) {
112229
- const stale = allowStale && v.__staleWhileFetching !== undefined;
112230
- if (status) {
112231
- status.fetch = "inflight";
112232
- if (stale)
112233
- status.returnedStale = true;
112234
- }
112235
- return stale ? v.__staleWhileFetching : v.__returned = v;
112236
- }
112237
- const isStale = this.#isStale(index3);
112238
- if (!forceRefresh && !isStale) {
112239
- if (status)
112240
- status.fetch = "hit";
112241
- this.#moveToTail(index3);
112242
- if (updateAgeOnGet) {
112243
- this.#updateItemAge(index3);
112244
- }
112245
- if (status)
112246
- this.#statusTTL(status, index3);
112247
- return v;
112248
- }
112249
- const p = this.#backgroundFetch(k, index3, options, context);
112250
- const hasStale = p.__staleWhileFetching !== undefined;
112251
- const staleVal = hasStale && allowStale;
112252
- if (status) {
112253
- status.fetch = isStale ? "stale" : "refresh";
112254
- if (staleVal && isStale)
112255
- status.returnedStale = true;
112256
- }
112257
- return staleVal ? p.__staleWhileFetching : p.__returned = p;
112258
- }
112259
- }
112260
- async forceFetch(k, fetchOptions = {}) {
112261
- const v = await this.fetch(k, fetchOptions);
112262
- if (v === undefined)
111740
+ let u = this.#t[S];
111741
+ if (this.#e(u)) {
111742
+ let E2 = i2 && u.__staleWhileFetching !== undefined;
111743
+ return l && (l.fetch = "inflight", E2 && (l.returnedStale = true)), E2 ? u.__staleWhileFetching : u.__returned = u;
111744
+ }
111745
+ let T = this.#p(S);
111746
+ if (!_ && !T)
111747
+ return l && (l.fetch = "hit"), this.#D(S), s && this.#R(S), l && this.#z(l, S), u;
111748
+ let F = this.#G(t, S, b, p), O = F.__staleWhileFetching !== undefined && i2;
111749
+ return l && (l.fetch = T ? "stale" : "refresh", O && T && (l.returnedStale = true)), O ? F.__staleWhileFetching : F.__returned = F;
111750
+ }
111751
+ }
111752
+ async forceFetch(t, e = {}) {
111753
+ let i2 = await this.fetch(t, e);
111754
+ if (i2 === undefined)
112263
111755
  throw new Error("fetch() returned undefined");
112264
- return v;
111756
+ return i2;
112265
111757
  }
112266
- memo(k, memoOptions = {}) {
112267
- const memoMethod = this.#memoMethod;
112268
- if (!memoMethod) {
111758
+ memo(t, e = {}) {
111759
+ let i2 = this.#I;
111760
+ if (!i2)
112269
111761
  throw new Error("no memoMethod provided to constructor");
112270
- }
112271
- const { context, forceRefresh, ...options } = memoOptions;
112272
- const v = this.get(k, options);
112273
- if (!forceRefresh && v !== undefined)
112274
- return v;
112275
- const vv = memoMethod(k, v, {
112276
- options,
112277
- context
112278
- });
112279
- this.set(k, vv, options);
112280
- return vv;
112281
- }
112282
- get(k, getOptions = {}) {
112283
- const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
112284
- const index3 = this.#keyMap.get(k);
112285
- if (index3 !== undefined) {
112286
- const value = this.#valList[index3];
112287
- const fetching = this.#isBackgroundFetch(value);
112288
- if (status)
112289
- this.#statusTTL(status, index3);
112290
- if (this.#isStale(index3)) {
112291
- if (status)
112292
- status.get = "stale";
112293
- if (!fetching) {
112294
- if (!noDeleteOnStaleGet) {
112295
- this.#delete(k, "expire");
112296
- }
112297
- if (status && allowStale)
112298
- status.returnedStale = true;
112299
- return allowStale ? value : undefined;
112300
- } else {
112301
- if (status && allowStale && value.__staleWhileFetching !== undefined) {
112302
- status.returnedStale = true;
112303
- }
112304
- return allowStale ? value.__staleWhileFetching : undefined;
112305
- }
112306
- } else {
112307
- if (status)
112308
- status.get = "hit";
112309
- if (fetching) {
112310
- return value.__staleWhileFetching;
112311
- }
112312
- this.#moveToTail(index3);
112313
- if (updateAgeOnGet) {
112314
- this.#updateItemAge(index3);
112315
- }
112316
- return value;
112317
- }
112318
- } else if (status) {
112319
- status.get = "miss";
112320
- }
111762
+ let { context: s, forceRefresh: h, ...n } = e, o = this.get(t, n);
111763
+ if (!h && o !== undefined)
111764
+ return o;
111765
+ let r = i2(t, o, { options: n, context: s });
111766
+ return this.set(t, r, n), r;
111767
+ }
111768
+ get(t, e = {}) {
111769
+ let { allowStale: i2 = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, status: n } = e, o = this.#s.get(t);
111770
+ if (o !== undefined) {
111771
+ let r = this.#t[o], f = this.#e(r);
111772
+ return n && this.#z(n, o), this.#p(o) ? (n && (n.get = "stale"), f ? (n && i2 && r.__staleWhileFetching !== undefined && (n.returnedStale = true), i2 ? r.__staleWhileFetching : undefined) : (h || this.#E(t, "expire"), n && i2 && (n.returnedStale = true), i2 ? r : undefined)) : (n && (n.get = "hit"), f ? r.__staleWhileFetching : (this.#D(o), s && this.#R(o), r));
111773
+ } else
111774
+ n && (n.get = "miss");
112321
111775
  }
112322
- #connect(p, n) {
112323
- this.#prev[n] = p;
112324
- this.#next[p] = n;
111776
+ #k(t, e) {
111777
+ this.#u[e] = t, this.#a[t] = e;
112325
111778
  }
112326
- #moveToTail(index3) {
112327
- if (index3 !== this.#tail) {
112328
- if (index3 === this.#head) {
112329
- this.#head = this.#next[index3];
112330
- } else {
112331
- this.#connect(this.#prev[index3], this.#next[index3]);
112332
- }
112333
- this.#connect(this.#tail, index3);
112334
- this.#tail = index3;
112335
- }
111779
+ #D(t) {
111780
+ t !== this.#h && (t === this.#l ? this.#l = this.#a[t] : this.#k(this.#u[t], this.#a[t]), this.#k(this.#h, t), this.#h = t);
112336
111781
  }
112337
- delete(k) {
112338
- return this.#delete(k, "delete");
111782
+ delete(t) {
111783
+ return this.#E(t, "delete");
112339
111784
  }
112340
- #delete(k, reason) {
112341
- let deleted = false;
112342
- if (this.#size !== 0) {
112343
- const index3 = this.#keyMap.get(k);
112344
- if (index3 !== undefined) {
112345
- if (this.#autopurgeTimers?.[index3]) {
112346
- clearTimeout(this.#autopurgeTimers?.[index3]);
112347
- this.#autopurgeTimers[index3] = undefined;
112348
- }
112349
- deleted = true;
112350
- if (this.#size === 1) {
112351
- this.#clear(reason);
112352
- } else {
112353
- this.#removeItemSize(index3);
112354
- const v = this.#valList[index3];
112355
- if (this.#isBackgroundFetch(v)) {
112356
- v.__abortController.abort(new Error("deleted"));
112357
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
112358
- if (this.#hasDispose) {
112359
- this.#dispose?.(v, k, reason);
112360
- }
112361
- if (this.#hasDisposeAfter) {
112362
- this.#disposed?.push([v, k, reason]);
112363
- }
112364
- }
112365
- this.#keyMap.delete(k);
112366
- this.#keyList[index3] = undefined;
112367
- this.#valList[index3] = undefined;
112368
- if (index3 === this.#tail) {
112369
- this.#tail = this.#prev[index3];
112370
- } else if (index3 === this.#head) {
112371
- this.#head = this.#next[index3];
112372
- } else {
112373
- const pi = this.#prev[index3];
112374
- this.#next[pi] = this.#next[index3];
112375
- const ni = this.#next[index3];
112376
- this.#prev[ni] = this.#prev[index3];
111785
+ #E(t, e) {
111786
+ let i2 = false;
111787
+ if (this.#n !== 0) {
111788
+ let s = this.#s.get(t);
111789
+ if (s !== undefined)
111790
+ if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = undefined), i2 = true, this.#n === 1)
111791
+ this.#V(e);
111792
+ else {
111793
+ this.#W(s);
111794
+ let h = this.#t[s];
111795
+ if (this.#e(h) ? h.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(h, t, e), this.#f && this.#r?.push([h, t, e])), this.#s.delete(t), this.#i[s] = undefined, this.#t[s] = undefined, s === this.#h)
111796
+ this.#h = this.#u[s];
111797
+ else if (s === this.#l)
111798
+ this.#l = this.#a[s];
111799
+ else {
111800
+ let n = this.#u[s];
111801
+ this.#a[n] = this.#a[s];
111802
+ let o = this.#a[s];
111803
+ this.#u[o] = this.#u[s];
112377
111804
  }
112378
- this.#size--;
112379
- this.#free.push(index3);
111805
+ this.#n--, this.#b.push(s);
112380
111806
  }
112381
- }
112382
111807
  }
112383
- if (this.#hasDisposeAfter && this.#disposed?.length) {
112384
- const dt = this.#disposed;
112385
- let task;
112386
- while (task = dt?.shift()) {
112387
- this.#disposeAfter?.(...task);
112388
- }
111808
+ if (this.#f && this.#r?.length) {
111809
+ let s = this.#r, h;
111810
+ for (;h = s?.shift(); )
111811
+ this.#S?.(...h);
112389
111812
  }
112390
- return deleted;
111813
+ return i2;
112391
111814
  }
112392
111815
  clear() {
112393
- return this.#clear("delete");
111816
+ return this.#V("delete");
112394
111817
  }
112395
- #clear(reason) {
112396
- for (const index3 of this.#rindexes({ allowStale: true })) {
112397
- const v = this.#valList[index3];
112398
- if (this.#isBackgroundFetch(v)) {
112399
- v.__abortController.abort(new Error("deleted"));
112400
- } else {
112401
- const k = this.#keyList[index3];
112402
- if (this.#hasDispose) {
112403
- this.#dispose?.(v, k, reason);
112404
- }
112405
- if (this.#hasDisposeAfter) {
112406
- this.#disposed?.push([v, k, reason]);
112407
- }
112408
- }
112409
- }
112410
- this.#keyMap.clear();
112411
- this.#valList.fill(undefined);
112412
- this.#keyList.fill(undefined);
112413
- if (this.#ttls && this.#starts) {
112414
- this.#ttls.fill(0);
112415
- this.#starts.fill(0);
112416
- for (const t of this.#autopurgeTimers ?? []) {
112417
- if (t !== undefined)
112418
- clearTimeout(t);
111818
+ #V(t) {
111819
+ for (let e of this.#O({ allowStale: true })) {
111820
+ let i2 = this.#t[e];
111821
+ if (this.#e(i2))
111822
+ i2.__abortController.abort(new Error("deleted"));
111823
+ else {
111824
+ let s = this.#i[e];
111825
+ this.#T && this.#w?.(i2, s, t), this.#f && this.#r?.push([i2, s, t]);
112419
111826
  }
112420
- this.#autopurgeTimers?.fill(undefined);
112421
111827
  }
112422
- if (this.#sizes) {
112423
- this.#sizes.fill(0);
111828
+ if (this.#s.clear(), this.#t.fill(undefined), this.#i.fill(undefined), this.#d && this.#A) {
111829
+ this.#d.fill(0), this.#A.fill(0);
111830
+ for (let e of this.#g ?? [])
111831
+ e !== undefined && clearTimeout(e);
111832
+ this.#g?.fill(undefined);
112424
111833
  }
112425
- this.#head = 0;
112426
- this.#tail = 0;
112427
- this.#free.length = 0;
112428
- this.#calculatedSize = 0;
112429
- this.#size = 0;
112430
- if (this.#hasDisposeAfter && this.#disposed) {
112431
- const dt = this.#disposed;
112432
- let task;
112433
- while (task = dt?.shift()) {
112434
- this.#disposeAfter?.(...task);
112435
- }
111834
+ if (this.#y && this.#y.fill(0), this.#l = 0, this.#h = 0, this.#b.length = 0, this.#_ = 0, this.#n = 0, this.#f && this.#r) {
111835
+ let e = this.#r, i2;
111836
+ for (;i2 = e?.shift(); )
111837
+ this.#S?.(...i2);
112436
111838
  }
112437
111839
  }
112438
- }
111840
+ };
112439
111841
 
112440
111842
  // src/module/cache/auth.ts
112441
- var authCache = new LRUCache({
111843
+ var authCache = new L({
112442
111844
  max: 1e4,
112443
111845
  ttl: 1000 * 60 * 60 * 24 * 7
112444
111846
  });
@@ -112549,9 +111951,9 @@ import fs17 from "fs";
112549
111951
 
112550
111952
  // ../node_modules/.pnpm/@kevisual+router@0.0.70/node_modules/@kevisual/router/src/server/cookie.ts
112551
111953
  var NullObject2 = /* @__PURE__ */ (() => {
112552
- const C = function() {};
112553
- C.prototype = Object.create(null);
112554
- return C;
111954
+ const C2 = function() {};
111955
+ C2.prototype = Object.create(null);
111956
+ return C2;
112555
111957
  })();
112556
111958
  function parseCookie2(str, options) {
112557
111959
  const obj = new NullObject2;