@kevisual/cli 0.0.99 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45775,7 +45775,7 @@ var require_path = __commonJS((exports) => {
45775
45775
  Object.defineProperty(exports, "__esModule", { value: true });
45776
45776
  exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = undefined;
45777
45777
  var os2 = __require("os");
45778
- var path9 = __require("path");
45778
+ var path10 = __require("path");
45779
45779
  var IS_WINDOWS_PLATFORM = os2.platform() === "win32";
45780
45780
  var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
45781
45781
  var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
@@ -45787,7 +45787,7 @@ var require_path = __commonJS((exports) => {
45787
45787
  }
45788
45788
  exports.unixify = unixify;
45789
45789
  function makeAbsolute(cwd, filepath) {
45790
- return path9.resolve(cwd, filepath);
45790
+ return path10.resolve(cwd, filepath);
45791
45791
  }
45792
45792
  exports.makeAbsolute = makeAbsolute;
45793
45793
  function removeLeadingDotSegment(entry2) {
@@ -47045,7 +47045,7 @@ var require_braces = __commonJS((exports, module) => {
47045
47045
 
47046
47046
  // ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
47047
47047
  var require_constants2 = __commonJS((exports, module) => {
47048
- var path9 = __require("path");
47048
+ var path10 = __require("path");
47049
47049
  var WIN_SLASH = "\\\\/";
47050
47050
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
47051
47051
  var DOT_LITERAL = "\\.";
@@ -47167,7 +47167,7 @@ var require_constants2 = __commonJS((exports, module) => {
47167
47167
  CHAR_UNDERSCORE: 95,
47168
47168
  CHAR_VERTICAL_LINE: 124,
47169
47169
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
47170
- SEP: path9.sep,
47170
+ SEP: path10.sep,
47171
47171
  extglobChars(chars) {
47172
47172
  return {
47173
47173
  "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
@@ -47185,7 +47185,7 @@ var require_constants2 = __commonJS((exports, module) => {
47185
47185
 
47186
47186
  // ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
47187
47187
  var require_utils2 = __commonJS((exports) => {
47188
- var path9 = __require("path");
47188
+ var path10 = __require("path");
47189
47189
  var win32 = process.platform === "win32";
47190
47190
  var {
47191
47191
  REGEX_BACKSLASH,
@@ -47214,7 +47214,7 @@ var require_utils2 = __commonJS((exports) => {
47214
47214
  if (options && typeof options.windows === "boolean") {
47215
47215
  return options.windows;
47216
47216
  }
47217
- return win32 === true || path9.sep === "\\";
47217
+ return win32 === true || path10.sep === "\\";
47218
47218
  };
47219
47219
  exports.escapeLast = (input, char, lastIdx) => {
47220
47220
  const idx = input.lastIndexOf(char, lastIdx);
@@ -48338,7 +48338,7 @@ var require_parse2 = __commonJS((exports, module) => {
48338
48338
 
48339
48339
  // ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
48340
48340
  var require_picomatch = __commonJS((exports, module) => {
48341
- var path9 = __require("path");
48341
+ var path10 = __require("path");
48342
48342
  var scan = require_scan();
48343
48343
  var parse2 = require_parse2();
48344
48344
  var utils2 = require_utils2();
@@ -48424,7 +48424,7 @@ var require_picomatch = __commonJS((exports, module) => {
48424
48424
  };
48425
48425
  picomatch2.matchBase = (input, glob2, options, posix = utils2.isWindows(options)) => {
48426
48426
  const regex = glob2 instanceof RegExp ? glob2 : picomatch2.makeRe(glob2, options);
48427
- return regex.test(path9.basename(input));
48427
+ return regex.test(path10.basename(input));
48428
48428
  };
48429
48429
  picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
48430
48430
  picomatch2.parse = (pattern2, options) => {
@@ -48645,7 +48645,7 @@ var require_micromatch = __commonJS((exports, module) => {
48645
48645
  var require_pattern = __commonJS((exports) => {
48646
48646
  Object.defineProperty(exports, "__esModule", { value: true });
48647
48647
  exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = undefined;
48648
- var path9 = __require("path");
48648
+ var path10 = __require("path");
48649
48649
  var globParent2 = require_glob_parent();
48650
48650
  var micromatch = require_micromatch();
48651
48651
  var GLOBSTAR = "**";
@@ -48740,7 +48740,7 @@ var require_pattern = __commonJS((exports) => {
48740
48740
  }
48741
48741
  exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
48742
48742
  function isAffectDepthOfReadingPattern(pattern2) {
48743
- const basename = path9.basename(pattern2);
48743
+ const basename = path10.basename(pattern2);
48744
48744
  return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename);
48745
48745
  }
48746
48746
  exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
@@ -48798,7 +48798,7 @@ var require_pattern = __commonJS((exports) => {
48798
48798
  }
48799
48799
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
48800
48800
  function isAbsolute(pattern2) {
48801
- return path9.isAbsolute(pattern2);
48801
+ return path10.isAbsolute(pattern2);
48802
48802
  }
48803
48803
  exports.isAbsolute = isAbsolute;
48804
48804
  });
@@ -48961,10 +48961,10 @@ var require_utils3 = __commonJS((exports) => {
48961
48961
  exports.array = array3;
48962
48962
  var errno2 = require_errno();
48963
48963
  exports.errno = errno2;
48964
- var fs8 = require_fs();
48965
- exports.fs = fs8;
48966
- var path9 = require_path();
48967
- exports.path = path9;
48964
+ var fs9 = require_fs();
48965
+ exports.fs = fs9;
48966
+ var path10 = require_path();
48967
+ exports.path = path10;
48968
48968
  var pattern2 = require_pattern();
48969
48969
  exports.pattern = pattern2;
48970
48970
  var stream3 = require_stream();
@@ -49060,8 +49060,8 @@ var require_tasks = __commonJS((exports) => {
49060
49060
  var require_async = __commonJS((exports) => {
49061
49061
  Object.defineProperty(exports, "__esModule", { value: true });
49062
49062
  exports.read = undefined;
49063
- function read(path9, settings2, callback) {
49064
- settings2.fs.lstat(path9, (lstatError, lstat) => {
49063
+ function read(path10, settings2, callback) {
49064
+ settings2.fs.lstat(path10, (lstatError, lstat) => {
49065
49065
  if (lstatError !== null) {
49066
49066
  callFailureCallback(callback, lstatError);
49067
49067
  return;
@@ -49070,7 +49070,7 @@ var require_async = __commonJS((exports) => {
49070
49070
  callSuccessCallback(callback, lstat);
49071
49071
  return;
49072
49072
  }
49073
- settings2.fs.stat(path9, (statError, stat) => {
49073
+ settings2.fs.stat(path10, (statError, stat) => {
49074
49074
  if (statError !== null) {
49075
49075
  if (settings2.throwErrorOnBrokenSymbolicLink) {
49076
49076
  callFailureCallback(callback, statError);
@@ -49099,13 +49099,13 @@ var require_async = __commonJS((exports) => {
49099
49099
  var require_sync = __commonJS((exports) => {
49100
49100
  Object.defineProperty(exports, "__esModule", { value: true });
49101
49101
  exports.read = undefined;
49102
- function read(path9, settings2) {
49103
- const lstat = settings2.fs.lstatSync(path9);
49102
+ function read(path10, settings2) {
49103
+ const lstat = settings2.fs.lstatSync(path10);
49104
49104
  if (!lstat.isSymbolicLink() || !settings2.followSymbolicLink) {
49105
49105
  return lstat;
49106
49106
  }
49107
49107
  try {
49108
- const stat = settings2.fs.statSync(path9);
49108
+ const stat = settings2.fs.statSync(path10);
49109
49109
  if (settings2.markSymbolicLink) {
49110
49110
  stat.isSymbolicLink = () => true;
49111
49111
  }
@@ -49124,12 +49124,12 @@ var require_sync = __commonJS((exports) => {
49124
49124
  var require_fs2 = __commonJS((exports) => {
49125
49125
  Object.defineProperty(exports, "__esModule", { value: true });
49126
49126
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
49127
- var fs8 = __require("fs");
49127
+ var fs9 = __require("fs");
49128
49128
  exports.FILE_SYSTEM_ADAPTER = {
49129
- lstat: fs8.lstat,
49130
- stat: fs8.stat,
49131
- lstatSync: fs8.lstatSync,
49132
- statSync: fs8.statSync
49129
+ lstat: fs9.lstat,
49130
+ stat: fs9.stat,
49131
+ lstatSync: fs9.lstatSync,
49132
+ statSync: fs9.statSync
49133
49133
  };
49134
49134
  function createFileSystemAdapter(fsMethods) {
49135
49135
  if (fsMethods === undefined) {
@@ -49143,13 +49143,13 @@ var require_fs2 = __commonJS((exports) => {
49143
49143
  // ../node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js
49144
49144
  var require_settings = __commonJS((exports) => {
49145
49145
  Object.defineProperty(exports, "__esModule", { value: true });
49146
- var fs8 = require_fs2();
49146
+ var fs9 = require_fs2();
49147
49147
 
49148
49148
  class Settings {
49149
49149
  constructor(_options = {}) {
49150
49150
  this._options = _options;
49151
49151
  this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
49152
- this.fs = fs8.createFileSystemAdapter(this._options.fs);
49152
+ this.fs = fs9.createFileSystemAdapter(this._options.fs);
49153
49153
  this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
49154
49154
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
49155
49155
  }
@@ -49168,17 +49168,17 @@ var require_out = __commonJS((exports) => {
49168
49168
  var sync2 = require_sync();
49169
49169
  var settings_1 = require_settings();
49170
49170
  exports.Settings = settings_1.default;
49171
- function stat(path9, optionsOrSettingsOrCallback, callback) {
49171
+ function stat(path10, optionsOrSettingsOrCallback, callback) {
49172
49172
  if (typeof optionsOrSettingsOrCallback === "function") {
49173
- async2.read(path9, getSettings(), optionsOrSettingsOrCallback);
49173
+ async2.read(path10, getSettings(), optionsOrSettingsOrCallback);
49174
49174
  return;
49175
49175
  }
49176
- async2.read(path9, getSettings(optionsOrSettingsOrCallback), callback);
49176
+ async2.read(path10, getSettings(optionsOrSettingsOrCallback), callback);
49177
49177
  }
49178
49178
  exports.stat = stat;
49179
- function statSync(path9, optionsOrSettings) {
49179
+ function statSync(path10, optionsOrSettings) {
49180
49180
  const settings2 = getSettings(optionsOrSettings);
49181
- return sync2.read(path9, settings2);
49181
+ return sync2.read(path10, settings2);
49182
49182
  }
49183
49183
  exports.statSync = statSync;
49184
49184
  function getSettings(settingsOrOptions = {}) {
@@ -49294,8 +49294,8 @@ var require_fs3 = __commonJS((exports) => {
49294
49294
  var require_utils4 = __commonJS((exports) => {
49295
49295
  Object.defineProperty(exports, "__esModule", { value: true });
49296
49296
  exports.fs = undefined;
49297
- var fs8 = require_fs3();
49298
- exports.fs = fs8;
49297
+ var fs9 = require_fs3();
49298
+ exports.fs = fs9;
49299
49299
  });
49300
49300
 
49301
49301
  // ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/common.js
@@ -49381,16 +49381,16 @@ var require_async2 = __commonJS((exports) => {
49381
49381
  return;
49382
49382
  }
49383
49383
  const tasks2 = names.map((name) => {
49384
- const path9 = common2.joinPathSegments(directory, name, settings2.pathSegmentSeparator);
49384
+ const path10 = common2.joinPathSegments(directory, name, settings2.pathSegmentSeparator);
49385
49385
  return (done) => {
49386
- fsStat.stat(path9, settings2.fsStatSettings, (error3, stats) => {
49386
+ fsStat.stat(path10, settings2.fsStatSettings, (error3, stats) => {
49387
49387
  if (error3 !== null) {
49388
49388
  done(error3);
49389
49389
  return;
49390
49390
  }
49391
49391
  const entry2 = {
49392
49392
  name,
49393
- path: path9,
49393
+ path: path10,
49394
49394
  dirent: utils2.fs.createDirentFromStats(name, stats)
49395
49395
  };
49396
49396
  if (settings2.stats) {
@@ -49478,14 +49478,14 @@ var require_sync2 = __commonJS((exports) => {
49478
49478
  var require_fs4 = __commonJS((exports) => {
49479
49479
  Object.defineProperty(exports, "__esModule", { value: true });
49480
49480
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
49481
- var fs8 = __require("fs");
49481
+ var fs9 = __require("fs");
49482
49482
  exports.FILE_SYSTEM_ADAPTER = {
49483
- lstat: fs8.lstat,
49484
- stat: fs8.stat,
49485
- lstatSync: fs8.lstatSync,
49486
- statSync: fs8.statSync,
49487
- readdir: fs8.readdir,
49488
- readdirSync: fs8.readdirSync
49483
+ lstat: fs9.lstat,
49484
+ stat: fs9.stat,
49485
+ lstatSync: fs9.lstatSync,
49486
+ statSync: fs9.statSync,
49487
+ readdir: fs9.readdir,
49488
+ readdirSync: fs9.readdirSync
49489
49489
  };
49490
49490
  function createFileSystemAdapter(fsMethods) {
49491
49491
  if (fsMethods === undefined) {
@@ -49499,16 +49499,16 @@ var require_fs4 = __commonJS((exports) => {
49499
49499
  // ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js
49500
49500
  var require_settings2 = __commonJS((exports) => {
49501
49501
  Object.defineProperty(exports, "__esModule", { value: true });
49502
- var path9 = __require("path");
49502
+ var path10 = __require("path");
49503
49503
  var fsStat = require_out();
49504
- var fs8 = require_fs4();
49504
+ var fs9 = require_fs4();
49505
49505
 
49506
49506
  class Settings {
49507
49507
  constructor(_options = {}) {
49508
49508
  this._options = _options;
49509
49509
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
49510
- this.fs = fs8.createFileSystemAdapter(this._options.fs);
49511
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path9.sep);
49510
+ this.fs = fs9.createFileSystemAdapter(this._options.fs);
49511
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path10.sep);
49512
49512
  this.stats = this._getValue(this._options.stats, false);
49513
49513
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
49514
49514
  this.fsStatSettings = new fsStat.Settings({
@@ -49532,17 +49532,17 @@ var require_out2 = __commonJS((exports) => {
49532
49532
  var sync2 = require_sync2();
49533
49533
  var settings_1 = require_settings2();
49534
49534
  exports.Settings = settings_1.default;
49535
- function scandir(path9, optionsOrSettingsOrCallback, callback) {
49535
+ function scandir(path10, optionsOrSettingsOrCallback, callback) {
49536
49536
  if (typeof optionsOrSettingsOrCallback === "function") {
49537
- async2.read(path9, getSettings(), optionsOrSettingsOrCallback);
49537
+ async2.read(path10, getSettings(), optionsOrSettingsOrCallback);
49538
49538
  return;
49539
49539
  }
49540
- async2.read(path9, getSettings(optionsOrSettingsOrCallback), callback);
49540
+ async2.read(path10, getSettings(optionsOrSettingsOrCallback), callback);
49541
49541
  }
49542
49542
  exports.scandir = scandir;
49543
- function scandirSync(path9, optionsOrSettings) {
49543
+ function scandirSync(path10, optionsOrSettings) {
49544
49544
  const settings2 = getSettings(optionsOrSettings);
49545
- return sync2.read(path9, settings2);
49545
+ return sync2.read(path10, settings2);
49546
49546
  }
49547
49547
  exports.scandirSync = scandirSync;
49548
49548
  function getSettings(settingsOrOptions = {}) {
@@ -50140,7 +50140,7 @@ var require_sync4 = __commonJS((exports) => {
50140
50140
  // ../node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js
50141
50141
  var require_settings3 = __commonJS((exports) => {
50142
50142
  Object.defineProperty(exports, "__esModule", { value: true });
50143
- var path9 = __require("path");
50143
+ var path10 = __require("path");
50144
50144
  var fsScandir = require_out2();
50145
50145
 
50146
50146
  class Settings {
@@ -50151,7 +50151,7 @@ var require_settings3 = __commonJS((exports) => {
50151
50151
  this.deepFilter = this._getValue(this._options.deepFilter, null);
50152
50152
  this.entryFilter = this._getValue(this._options.entryFilter, null);
50153
50153
  this.errorFilter = this._getValue(this._options.errorFilter, null);
50154
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path9.sep);
50154
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path10.sep);
50155
50155
  this.fsScandirSettings = new fsScandir.Settings({
50156
50156
  followSymbolicLinks: this._options.followSymbolicLinks,
50157
50157
  fs: this._options.fs,
@@ -50207,7 +50207,7 @@ var require_out3 = __commonJS((exports) => {
50207
50207
  // ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js
50208
50208
  var require_reader2 = __commonJS((exports) => {
50209
50209
  Object.defineProperty(exports, "__esModule", { value: true });
50210
- var path9 = __require("path");
50210
+ var path10 = __require("path");
50211
50211
  var fsStat = require_out();
50212
50212
  var utils2 = require_utils3();
50213
50213
 
@@ -50221,7 +50221,7 @@ var require_reader2 = __commonJS((exports) => {
50221
50221
  });
50222
50222
  }
50223
50223
  _getFullEntryPath(filepath) {
50224
- return path9.resolve(this._settings.cwd, filepath);
50224
+ return path10.resolve(this._settings.cwd, filepath);
50225
50225
  }
50226
50226
  _makeEntry(stats, pattern2) {
50227
50227
  const entry2 = {
@@ -50618,7 +50618,7 @@ var require_entry2 = __commonJS((exports) => {
50618
50618
  // ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js
50619
50619
  var require_provider = __commonJS((exports) => {
50620
50620
  Object.defineProperty(exports, "__esModule", { value: true });
50621
- var path9 = __require("path");
50621
+ var path10 = __require("path");
50622
50622
  var deep_1 = require_deep();
50623
50623
  var entry_1 = require_entry();
50624
50624
  var error_1 = require_error();
@@ -50633,7 +50633,7 @@ var require_provider = __commonJS((exports) => {
50633
50633
  this.entryTransformer = new entry_2.default(this._settings);
50634
50634
  }
50635
50635
  _getRootDirectory(task) {
50636
- return path9.resolve(this._settings.cwd, task.base);
50636
+ return path10.resolve(this._settings.cwd, task.base);
50637
50637
  }
50638
50638
  _getReaderOptions(task) {
50639
50639
  const basePath = task.base === "." ? "" : task.base;
@@ -50802,16 +50802,16 @@ var require_sync6 = __commonJS((exports) => {
50802
50802
  var require_settings4 = __commonJS((exports) => {
50803
50803
  Object.defineProperty(exports, "__esModule", { value: true });
50804
50804
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
50805
- var fs8 = __require("fs");
50805
+ var fs9 = __require("fs");
50806
50806
  var os2 = __require("os");
50807
50807
  var CPU_COUNT = Math.max(os2.cpus().length, 1);
50808
50808
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
50809
- lstat: fs8.lstat,
50810
- lstatSync: fs8.lstatSync,
50811
- stat: fs8.stat,
50812
- statSync: fs8.statSync,
50813
- readdir: fs8.readdir,
50814
- readdirSync: fs8.readdirSync
50809
+ lstat: fs9.lstat,
50810
+ lstatSync: fs9.lstatSync,
50811
+ stat: fs9.stat,
50812
+ statSync: fs9.statSync,
50813
+ readdir: fs9.readdir,
50814
+ readdirSync: fs9.readdirSync
50815
50815
  };
50816
50816
 
50817
50817
  class Settings {
@@ -50988,11 +50988,11 @@ var require_eventemitter3 = __commonJS((exports, module) => {
50988
50988
  else
50989
50989
  delete emitter._events[evt];
50990
50990
  }
50991
- function EventEmitter4() {
50991
+ function EventEmitter5() {
50992
50992
  this._events = new Events;
50993
50993
  this._eventsCount = 0;
50994
50994
  }
50995
- EventEmitter4.prototype.eventNames = function eventNames() {
50995
+ EventEmitter5.prototype.eventNames = function eventNames() {
50996
50996
  var names = [], events, name;
50997
50997
  if (this._eventsCount === 0)
50998
50998
  return names;
@@ -51005,7 +51005,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51005
51005
  }
51006
51006
  return names;
51007
51007
  };
51008
- EventEmitter4.prototype.listeners = function listeners(event) {
51008
+ EventEmitter5.prototype.listeners = function listeners(event) {
51009
51009
  var evt = prefix ? prefix + event : event, handlers = this._events[evt];
51010
51010
  if (!handlers)
51011
51011
  return [];
@@ -51016,7 +51016,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51016
51016
  }
51017
51017
  return ee;
51018
51018
  };
51019
- EventEmitter4.prototype.listenerCount = function listenerCount(event) {
51019
+ EventEmitter5.prototype.listenerCount = function listenerCount(event) {
51020
51020
  var evt = prefix ? prefix + event : event, listeners = this._events[evt];
51021
51021
  if (!listeners)
51022
51022
  return 0;
@@ -51024,7 +51024,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51024
51024
  return 1;
51025
51025
  return listeners.length;
51026
51026
  };
51027
- EventEmitter4.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
51027
+ EventEmitter5.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
51028
51028
  var evt = prefix ? prefix + event : event;
51029
51029
  if (!this._events[evt])
51030
51030
  return false;
@@ -51079,13 +51079,13 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51079
51079
  }
51080
51080
  return true;
51081
51081
  };
51082
- EventEmitter4.prototype.on = function on(event, fn, context) {
51082
+ EventEmitter5.prototype.on = function on(event, fn, context) {
51083
51083
  return addListener(this, event, fn, context, false);
51084
51084
  };
51085
- EventEmitter4.prototype.once = function once(event, fn, context) {
51085
+ EventEmitter5.prototype.once = function once(event, fn, context) {
51086
51086
  return addListener(this, event, fn, context, true);
51087
51087
  };
51088
- EventEmitter4.prototype.removeListener = function removeListener(event, fn, context, once) {
51088
+ EventEmitter5.prototype.removeListener = function removeListener(event, fn, context, once) {
51089
51089
  var evt = prefix ? prefix + event : event;
51090
51090
  if (!this._events[evt])
51091
51091
  return this;
@@ -51111,7 +51111,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51111
51111
  }
51112
51112
  return this;
51113
51113
  };
51114
- EventEmitter4.prototype.removeAllListeners = function removeAllListeners(event) {
51114
+ EventEmitter5.prototype.removeAllListeners = function removeAllListeners(event) {
51115
51115
  var evt;
51116
51116
  if (event) {
51117
51117
  evt = prefix ? prefix + event : event;
@@ -51123,12 +51123,12 @@ var require_eventemitter3 = __commonJS((exports, module) => {
51123
51123
  }
51124
51124
  return this;
51125
51125
  };
51126
- EventEmitter4.prototype.off = EventEmitter4.prototype.removeListener;
51127
- EventEmitter4.prototype.addListener = EventEmitter4.prototype.on;
51128
- EventEmitter4.prefixed = prefix;
51129
- EventEmitter4.EventEmitter = EventEmitter4;
51126
+ EventEmitter5.prototype.off = EventEmitter5.prototype.removeListener;
51127
+ EventEmitter5.prototype.addListener = EventEmitter5.prototype.on;
51128
+ EventEmitter5.prefixed = prefix;
51129
+ EventEmitter5.EventEmitter = EventEmitter5;
51130
51130
  if (typeof module !== "undefined") {
51131
- module.exports = EventEmitter4;
51131
+ module.exports = EventEmitter5;
51132
51132
  }
51133
51133
  });
51134
51134
 
@@ -52904,7 +52904,7 @@ var require_extension = __commonJS((exports, module) => {
52904
52904
 
52905
52905
  // ../node_modules/.pnpm/@kevisual+ws@8.0.0/node_modules/@kevisual/ws/lib/websocket.js
52906
52906
  var require_websocket = __commonJS((exports, module) => {
52907
- var EventEmitter6 = __require("events");
52907
+ var EventEmitter7 = __require("events");
52908
52908
  var https2 = __require("https");
52909
52909
  var http3 = __require("http");
52910
52910
  var net2 = __require("net");
@@ -52937,7 +52937,7 @@ var require_websocket = __commonJS((exports, module) => {
52937
52937
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
52938
52938
  var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
52939
52939
 
52940
- class WebSocket2 extends EventEmitter6 {
52940
+ class WebSocket2 extends EventEmitter7 {
52941
52941
  constructor(address, protocols, options) {
52942
52942
  super();
52943
52943
  this._binaryType = BINARY_TYPES[0];
@@ -53811,7 +53811,7 @@ var require_subprotocol = __commonJS((exports, module) => {
53811
53811
 
53812
53812
  // ../node_modules/.pnpm/@kevisual+ws@8.0.0/node_modules/@kevisual/ws/lib/websocket-server.js
53813
53813
  var require_websocket_server = __commonJS((exports, module) => {
53814
- var EventEmitter6 = __require("events");
53814
+ var EventEmitter7 = __require("events");
53815
53815
  var http3 = __require("http");
53816
53816
  var { Duplex } = __require("stream");
53817
53817
  var { createHash } = __require("crypto");
@@ -53825,7 +53825,7 @@ var require_websocket_server = __commonJS((exports, module) => {
53825
53825
  var CLOSING = 1;
53826
53826
  var CLOSED = 2;
53827
53827
 
53828
- class WebSocketServer2 extends EventEmitter6 {
53828
+ class WebSocketServer2 extends EventEmitter7 {
53829
53829
  constructor(options, callback) {
53830
53830
  super();
53831
53831
  options = {
@@ -54477,18 +54477,18 @@ var require_utils6 = __commonJS((exports, module) => {
54477
54477
  if (decode2)
54478
54478
  return decode2(data, hint);
54479
54479
  }
54480
- function basename(path16) {
54481
- if (typeof path16 !== "string")
54480
+ function basename(path17) {
54481
+ if (typeof path17 !== "string")
54482
54482
  return "";
54483
- for (let i2 = path16.length - 1;i2 >= 0; --i2) {
54484
- switch (path16.charCodeAt(i2)) {
54483
+ for (let i2 = path17.length - 1;i2 >= 0; --i2) {
54484
+ switch (path17.charCodeAt(i2)) {
54485
54485
  case 47:
54486
54486
  case 92:
54487
- path16 = path16.slice(i2 + 1);
54488
- return path16 === ".." || path16 === "." ? "" : path16;
54487
+ path17 = path17.slice(i2 + 1);
54488
+ return path17 === ".." || path17 === "." ? "" : path17;
54489
54489
  }
54490
54490
  }
54491
- return path16 === ".." || path16 === "." ? "" : path16;
54491
+ return path17 === ".." || path17 === "." ? "" : path17;
54492
54492
  }
54493
54493
  var TOKEN = [
54494
54494
  0,
@@ -58508,10 +58508,10 @@ var require_suggestSimilar = __commonJS((exports) => {
58508
58508
 
58509
58509
  // ../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js
58510
58510
  var require_command = __commonJS((exports) => {
58511
- var EventEmitter6 = __require("node:events").EventEmitter;
58511
+ var EventEmitter7 = __require("node:events").EventEmitter;
58512
58512
  var childProcess = __require("node:child_process");
58513
- var path19 = __require("node:path");
58514
- var fs21 = __require("node:fs");
58513
+ var path20 = __require("node:path");
58514
+ var fs22 = __require("node:fs");
58515
58515
  var process7 = __require("node:process");
58516
58516
  var { Argument, humanReadableArgName } = require_argument();
58517
58517
  var { CommanderError } = require_error2();
@@ -58519,7 +58519,7 @@ var require_command = __commonJS((exports) => {
58519
58519
  var { Option, DualOptions } = require_option();
58520
58520
  var { suggestSimilar } = require_suggestSimilar();
58521
58521
 
58522
- class Command2 extends EventEmitter6 {
58522
+ class Command2 extends EventEmitter7 {
58523
58523
  constructor(name) {
58524
58524
  super();
58525
58525
  this.commands = [];
@@ -59046,7 +59046,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
59046
59046
  this.processedArgs = [];
59047
59047
  }
59048
59048
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
59049
- if (fs21.existsSync(executableFile))
59049
+ if (fs22.existsSync(executableFile))
59050
59050
  return;
59051
59051
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
59052
59052
  const executableMissing = `'${executableFile}' does not exist
@@ -59060,12 +59060,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
59060
59060
  let launchWithNode = false;
59061
59061
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
59062
59062
  function findFile(baseDir, baseName) {
59063
- const localBin = path19.resolve(baseDir, baseName);
59064
- if (fs21.existsSync(localBin))
59063
+ const localBin = path20.resolve(baseDir, baseName);
59064
+ if (fs22.existsSync(localBin))
59065
59065
  return localBin;
59066
- if (sourceExt.includes(path19.extname(baseName)))
59066
+ if (sourceExt.includes(path20.extname(baseName)))
59067
59067
  return;
59068
- const foundExt = sourceExt.find((ext) => fs21.existsSync(`${localBin}${ext}`));
59068
+ const foundExt = sourceExt.find((ext) => fs22.existsSync(`${localBin}${ext}`));
59069
59069
  if (foundExt)
59070
59070
  return `${localBin}${foundExt}`;
59071
59071
  return;
@@ -59077,23 +59077,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
59077
59077
  if (this._scriptPath) {
59078
59078
  let resolvedScriptPath;
59079
59079
  try {
59080
- resolvedScriptPath = fs21.realpathSync(this._scriptPath);
59080
+ resolvedScriptPath = fs22.realpathSync(this._scriptPath);
59081
59081
  } catch {
59082
59082
  resolvedScriptPath = this._scriptPath;
59083
59083
  }
59084
- executableDir = path19.resolve(path19.dirname(resolvedScriptPath), executableDir);
59084
+ executableDir = path20.resolve(path20.dirname(resolvedScriptPath), executableDir);
59085
59085
  }
59086
59086
  if (executableDir) {
59087
59087
  let localFile = findFile(executableDir, executableFile);
59088
59088
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
59089
- const legacyName = path19.basename(this._scriptPath, path19.extname(this._scriptPath));
59089
+ const legacyName = path20.basename(this._scriptPath, path20.extname(this._scriptPath));
59090
59090
  if (legacyName !== this._name) {
59091
59091
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
59092
59092
  }
59093
59093
  }
59094
59094
  executableFile = localFile || executableFile;
59095
59095
  }
59096
- launchWithNode = sourceExt.includes(path19.extname(executableFile));
59096
+ launchWithNode = sourceExt.includes(path20.extname(executableFile));
59097
59097
  let proc;
59098
59098
  if (process7.platform !== "win32") {
59099
59099
  if (launchWithNode) {
@@ -59682,13 +59682,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
59682
59682
  cmd.helpGroup(this._defaultCommandGroup);
59683
59683
  }
59684
59684
  nameFromFilename(filename) {
59685
- this._name = path19.basename(filename, path19.extname(filename));
59685
+ this._name = path20.basename(filename, path20.extname(filename));
59686
59686
  return this;
59687
59687
  }
59688
- executableDir(path20) {
59689
- if (path20 === undefined)
59688
+ executableDir(path21) {
59689
+ if (path21 === undefined)
59690
59690
  return this._executableDir;
59691
- this._executableDir = path20;
59691
+ this._executableDir = path21;
59692
59692
  return this;
59693
59693
  }
59694
59694
  helpInformation(contextOptions) {
@@ -79145,8 +79145,8 @@ class HttpChain {
79145
79145
  }
79146
79146
 
79147
79147
  // src/services/init/index.ts
79148
- import fs14 from "node:fs";
79149
- import path13 from "node:path";
79148
+ import fs15 from "node:fs";
79149
+ import path14 from "node:path";
79150
79150
 
79151
79151
  // src/module/assistant/config/index.ts
79152
79152
  import path2 from "path";
@@ -80361,7 +80361,7 @@ __export(exports_manager, {
80361
80361
  AppType: () => AppType
80362
80362
  });
80363
80363
 
80364
- // ../node_modules/.pnpm/@kevisual+use-config@1.0.28_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
80364
+ // ../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
80365
80365
  import { createRequire as createRequire2 } from "node:module";
80366
80366
  import fs5 from "node:fs";
80367
80367
  import path6 from "node:path";
@@ -80809,71 +80809,6 @@ var getConfigFile = (opts) => {
80809
80809
  return lastLastPath;
80810
80810
  return "";
80811
80811
  };
80812
- var getConfig = (opts) => {
80813
- let quiet = opts?.quite ?? true;
80814
- const showError = opts?.showError ?? false;
80815
- if (opts?.dotenvOpts) {
80816
- const prased = import_dotenv2.default.config({ quiet, ...opts.dotenvOpts }).parsed;
80817
- if (prased) {
80818
- return prased;
80819
- } else {
80820
- if (showError) {
80821
- if (!quiet) {
80822
- console.warn("config 读取失败");
80823
- }
80824
- throw new Error("未找到配置文件");
80825
- }
80826
- return {};
80827
- }
80828
- }
80829
- const filePath = getConfigFile(opts);
80830
- if (!quiet && filePath) {
80831
- console.log("config pathname:", filePath);
80832
- }
80833
- if (!filePath) {
80834
- if (showError) {
80835
- if (!quiet) {
80836
- console.warn("config 路径未找到");
80837
- }
80838
- throw new Error("未找到配置文件");
80839
- }
80840
- return {};
80841
- }
80842
- const value = import_dotenv2.default.config({ quiet: true, path: filePath }).parsed;
80843
- return value;
80844
- };
80845
- var useConfig = (onlyInitConfig, force) => {
80846
- const config2 = global.config;
80847
- let _config = config2 || getConfig(onlyInitConfig);
80848
- !config2 && (global["config"] = _config);
80849
- if (force && onlyInitConfig) {
80850
- const _newConfig = getConfig(onlyInitConfig);
80851
- _config = mergeConfig(_newConfig);
80852
- }
80853
- return _config;
80854
- };
80855
- var mergeConfig = (config2) => {
80856
- const _config = global.config || {};
80857
- Object.assign(_config, config2);
80858
- global.config = _config;
80859
- return _config;
80860
- };
80861
- var useKey = (key, opts) => {
80862
- let v = useConfig()[key];
80863
- if (!v) {
80864
- v = process.env[key];
80865
- }
80866
- if (!v) {
80867
- return opts?.defaultValue || null;
80868
- }
80869
- if (opts?.isNumber && typeof v === "string") {
80870
- return Number(v);
80871
- }
80872
- if (opts?.isBoolean && typeof v === "string") {
80873
- return v === "true";
80874
- }
80875
- return v;
80876
- };
80877
80812
  var useFileStore = (str, opts) => {
80878
80813
  const publicPath = process.cwd();
80879
80814
  const filePath = path6.join(publicPath, str);
@@ -88413,276 +88348,1350 @@ var restart2 = promisify2(pm22.restart).bind(pm22);
88413
88348
  var reload = promisify2(pm22.reload).bind(pm22);
88414
88349
  var deleteProcess2 = promisify2(pm22.delete).bind(pm22);
88415
88350
  var list2 = promisify2(pm22.list).bind(pm22);
88416
- // src/module/local-apps/src/modules/app-file.ts
88417
- import path8 from "node:path";
88351
+ // ../node_modules/.pnpm/@kevisual+use-config@1.0.28_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
88352
+ import { createRequire as createRequire3 } from "node:module";
88418
88353
  import fs7 from "node:fs";
88419
- var getAppsPath2 = () => {
88420
- const appsPath = process.env.APPS_PATH;
88421
- if (appsPath) {
88422
- const resolvePath = path8.resolve(appsPath);
88423
- if (fileIsExist(resolvePath)) {
88424
- return resolvePath;
88425
- } else {
88426
- fs7.mkdirSync(resolvePath, { recursive: true });
88427
- return resolvePath;
88428
- }
88429
- }
88430
- return useFileStore("apps", { needExists: true });
88354
+ import path8 from "node:path";
88355
+ var __create3 = Object.create;
88356
+ var __getProtoOf3 = Object.getPrototypeOf;
88357
+ var __defProp3 = Object.defineProperty;
88358
+ var __getOwnPropNames3 = Object.getOwnPropertyNames;
88359
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
88360
+ var __toESM3 = (mod, isNodeMode, target) => {
88361
+ target = mod != null ? __create3(__getProtoOf3(mod)) : {};
88362
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target;
88363
+ for (let key of __getOwnPropNames3(mod))
88364
+ if (!__hasOwnProp3.call(to, key))
88365
+ __defProp3(to, key, {
88366
+ get: () => mod[key],
88367
+ enumerable: true
88368
+ });
88369
+ return to;
88431
88370
  };
88432
- var loadAppInfo2 = async (appsPath = "apps", filename = "apps.config.json") => {
88433
- let configFile = getConfigFile({
88434
- cwd: appsPath,
88435
- fileName: filename
88436
- });
88437
- if (!configFile) {
88438
- configFile = path8.join(appsPath, "..", filename);
88439
- fs7.writeFileSync(configFile, JSON.stringify({ list: [] }));
88440
- return { list: [] };
88441
- }
88442
- try {
88443
- const config2 = fs7.readFileSync(configFile, "utf-8");
88444
- const v = JSON.parse(config2);
88445
- if (!v.list) {
88446
- v.list = [];
88371
+ var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
88372
+ var __require3 = /* @__PURE__ */ createRequire3(import.meta.url);
88373
+ var require_package6 = __commonJS3((exports, module) => {
88374
+ module.exports = {
88375
+ name: "dotenv",
88376
+ version: "17.2.3",
88377
+ description: "Loads environment variables from .env file",
88378
+ main: "lib/main.js",
88379
+ types: "lib/main.d.ts",
88380
+ exports: {
88381
+ ".": {
88382
+ types: "./lib/main.d.ts",
88383
+ require: "./lib/main.js",
88384
+ default: "./lib/main.js"
88385
+ },
88386
+ "./config": "./config.js",
88387
+ "./config.js": "./config.js",
88388
+ "./lib/env-options": "./lib/env-options.js",
88389
+ "./lib/env-options.js": "./lib/env-options.js",
88390
+ "./lib/cli-options": "./lib/cli-options.js",
88391
+ "./lib/cli-options.js": "./lib/cli-options.js",
88392
+ "./package.json": "./package.json"
88393
+ },
88394
+ scripts: {
88395
+ "dts-check": "tsc --project tests/types/tsconfig.json",
88396
+ lint: "standard",
88397
+ pretest: "npm run lint && npm run dts-check",
88398
+ test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
88399
+ "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
88400
+ prerelease: "npm test",
88401
+ release: "standard-version"
88402
+ },
88403
+ repository: {
88404
+ type: "git",
88405
+ url: "git://github.com/motdotla/dotenv.git"
88406
+ },
88407
+ homepage: "https://github.com/motdotla/dotenv#readme",
88408
+ funding: "https://dotenvx.com",
88409
+ keywords: [
88410
+ "dotenv",
88411
+ "env",
88412
+ ".env",
88413
+ "environment",
88414
+ "variables",
88415
+ "config",
88416
+ "settings"
88417
+ ],
88418
+ readmeFilename: "README.md",
88419
+ license: "BSD-2-Clause",
88420
+ devDependencies: {
88421
+ "@types/node": "^18.11.3",
88422
+ decache: "^4.6.2",
88423
+ sinon: "^14.0.1",
88424
+ standard: "^17.0.0",
88425
+ "standard-version": "^9.5.0",
88426
+ tap: "^19.2.0",
88427
+ typescript: "^4.8.4"
88428
+ },
88429
+ engines: {
88430
+ node: ">=12"
88431
+ },
88432
+ browser: {
88433
+ fs: false
88447
88434
  }
88448
- return v;
88449
- } catch (e) {
88450
- console.error("读取配置文件失败", e.message);
88451
- return { list: [] };
88452
- }
88453
- };
88454
- var saveAppInfo2 = async (data, appsPath, filename = "apps.config.json") => {
88455
- const configFile = getConfigFile({
88456
- fileName: filename,
88457
- cwd: appsPath
88458
- });
88459
- if (!configFile) {
88460
- console.error("未找到配置文件");
88461
- return;
88462
- }
88463
- fs7.writeFileSync(configFile, JSON.stringify(data, null, 2));
88464
- };
88465
- var deleteFileAppInfo2 = async (key, appsPath) => {
88466
- const normalizedKey = key.replace(/\//g, path8.sep);
88467
- const directory = path8.join(appsPath, normalizedKey);
88468
- if (!fileIsExist(directory)) {
88469
- return;
88435
+ };
88436
+ });
88437
+ var require_main6 = __commonJS3((exports, module) => {
88438
+ var fs8 = __require3("fs");
88439
+ var path9 = __require3("path");
88440
+ var os2 = __require3("os");
88441
+ var crypto3 = __require3("crypto");
88442
+ var packageJson = require_package6();
88443
+ var version2 = packageJson.version;
88444
+ var TIPS = [
88445
+ "\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
88446
+ "\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
88447
+ "\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
88448
+ "\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
88449
+ "\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
88450
+ "\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
88451
+ "✅ audit secrets and track compliance: https://dotenvx.com/ops",
88452
+ "\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
88453
+ "\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
88454
+ "\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
88455
+ "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
88456
+ "⚙️ enable debug logging with { debug: true }",
88457
+ "⚙️ override existing env vars with { override: true }",
88458
+ "⚙️ suppress all logs with { quiet: true }",
88459
+ "⚙️ write to custom object with { processEnv: myObject }",
88460
+ "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
88461
+ ];
88462
+ function _getRandomTip() {
88463
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
88470
88464
  }
88471
- fs7.rmSync(directory, { recursive: true });
88472
- };
88473
-
88474
- // src/module/local-apps/src/modules/manager.ts
88475
- import { fork as fork2 } from "node:child_process";
88476
- import path9 from "node:path";
88477
- var import_fast_glob = __toESM(require_out4(), 1);
88478
- import fs8 from "node:fs";
88479
-
88480
- // src/module/local-apps/src/modules/pm2.ts
88481
- import { spawn } from "node:child_process";
88482
- import pm23 from "pm2";
88483
- import { promisify as promisify3 } from "node:util";
88484
- var normalizeScriptPath2 = (scriptPath) => {
88485
- if (process.platform === "win32") {
88486
- return scriptPath.replace(/\\/g, "/");
88465
+ function parseBoolean(value) {
88466
+ if (typeof value === "string") {
88467
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
88468
+ }
88469
+ return Boolean(value);
88487
88470
  }
88488
- return scriptPath;
88489
- };
88490
- var connect2 = async (noDaemonMode = false) => {
88491
- return new Promise((resolve, reject) => {
88492
- pm23.connect(noDaemonMode, (err) => {
88493
- if (err) {
88494
- console.error("pm2 connect error", err);
88495
- return reject(err);
88496
- }
88497
- resolve(true);
88498
- });
88499
- });
88500
- };
88501
- var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
88502
- var start3 = promisify3(pm23.start).bind(pm23);
88503
- var stop3 = promisify3(pm23.stop).bind(pm23);
88504
- var restart3 = promisify3(pm23.restart).bind(pm23);
88505
- var reload2 = promisify3(pm23.reload).bind(pm23);
88506
- var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
88507
- var list3 = promisify3(pm23.list).bind(pm23);
88508
- var checkInstall = async (app) => {
88509
- return new Promise((resolve, reject) => {
88510
- const install = spawn("pnpm", ["install"], {
88511
- cwd: app.path,
88512
- stdio: "inherit"
88513
- });
88514
- install.on("close", (code) => {
88515
- if (code !== 0) {
88516
- console.log("install failed");
88517
- return resolve(false);
88518
- }
88519
- console.log("install success");
88520
- resolve(true);
88521
- });
88522
- });
88523
- };
88524
-
88525
- class Pm2Connect2 {
88526
- needConnect = true;
88527
- isConnected = false;
88528
- constructor(needConnect = true) {
88529
- this.needConnect = needConnect;
88471
+ function supportsAnsi() {
88472
+ return process.stdout.isTTY;
88530
88473
  }
88531
- async sleep(ms2) {
88532
- return new Promise((resolve) => {
88533
- setTimeout(resolve, ms2);
88534
- });
88474
+ function dim(text) {
88475
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
88535
88476
  }
88536
- async checkConnect() {
88537
- const that = this;
88538
- try {
88539
- if (this.needConnect && !this.isConnected) {
88540
- const data = await connect2();
88541
- that.isConnected = !!data;
88477
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
88478
+ function parse2(src) {
88479
+ const obj = {};
88480
+ let lines = src.toString();
88481
+ lines = lines.replace(/\r\n?/mg, `
88482
+ `);
88483
+ let match;
88484
+ while ((match = LINE.exec(lines)) != null) {
88485
+ const key = match[1];
88486
+ let value = match[2] || "";
88487
+ value = value.trim();
88488
+ const maybeQuote = value[0];
88489
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
88490
+ if (maybeQuote === '"') {
88491
+ value = value.replace(/\\n/g, `
88492
+ `);
88493
+ value = value.replace(/\\r/g, "\r");
88542
88494
  }
88543
- } catch (e) {
88544
- console.log("pm2 check connect error", e);
88495
+ obj[key] = value;
88545
88496
  }
88497
+ return obj;
88546
88498
  }
88547
- async checkDisconnect(runOpts) {
88548
- const needExit = runOpts?.needExit ?? true;
88549
- if (this.needConnect && this.isConnected && needExit) {
88550
- this.disconnect();
88499
+ function _parseVault(options) {
88500
+ options = options || {};
88501
+ const vaultPath = _vaultPath(options);
88502
+ options.path = vaultPath;
88503
+ const result = DotenvModule.configDotenv(options);
88504
+ if (!result.parsed) {
88505
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
88506
+ err.code = "MISSING_DATA";
88507
+ throw err;
88551
88508
  }
88552
- }
88553
- async connect() {
88554
- try {
88555
- await connect2();
88556
- this.isConnected = true;
88557
- } catch (e) {
88558
- console.log("pm2 connect error", e);
88509
+ const keys = _dotenvKey(options).split(",");
88510
+ const length = keys.length;
88511
+ let decrypted;
88512
+ for (let i = 0;i < length; i++) {
88513
+ try {
88514
+ const key = keys[i].trim();
88515
+ const attrs = _instructions(result, key);
88516
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
88517
+ break;
88518
+ } catch (error3) {
88519
+ if (i + 1 >= length) {
88520
+ throw error3;
88521
+ }
88522
+ }
88559
88523
  }
88524
+ return DotenvModule.parse(decrypted);
88560
88525
  }
88561
- async disconnect() {
88562
- try {
88563
- pm23.disconnect();
88564
- await this.sleep(1000);
88565
- } catch (e) {
88566
- console.log("pm2 disconnect error", e);
88567
- }
88568
- this.isConnected = false;
88526
+ function _warn(message) {
88527
+ console.error(`[dotenv@${version2}][WARN] ${message}`);
88569
88528
  }
88570
- }
88571
-
88572
- class Pm2Manager2 {
88573
- pm2Connect;
88574
- appName;
88575
- script;
88576
- interpreter;
88577
- needConnect = true;
88578
- isConnect = false;
88579
- env;
88580
- constructor(opts) {
88581
- this.appName = opts.appName;
88582
- this.script = opts.script;
88583
- this.interpreter = opts.interpreter;
88584
- this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
88585
- this.env = opts.env || {};
88529
+ function _debug(message) {
88530
+ console.log(`[dotenv@${version2}][DEBUG] ${message}`);
88586
88531
  }
88587
- async list(runOpts) {
88588
- const _runOpts = { needExit: false, ...runOpts };
88589
- try {
88590
- await this.pm2Connect.checkConnect();
88591
- const apps = await list3();
88592
- return apps;
88593
- } catch (e) {
88594
- console.log("pm2 run error", e);
88595
- return [];
88596
- } finally {
88597
- this.pm2Connect.checkDisconnect(_runOpts);
88598
- }
88532
+ function _log(message) {
88533
+ console.log(`[dotenv@${version2}] ${message}`);
88599
88534
  }
88600
- async start(options, runOpts) {
88601
- const { appName, script, env: env2, interpreter } = this;
88602
- const needExit = runOpts?.needExit ?? true;
88603
- if (!script) {
88604
- console.error("script is required");
88605
- return;
88535
+ function _dotenvKey(options) {
88536
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
88537
+ return options.DOTENV_KEY;
88606
88538
  }
88607
- const normalizedScript = normalizeScriptPath2(script);
88608
- const starter = {
88609
- name: appName,
88610
- script: normalizedScript,
88611
- cwd: process.cwd(),
88612
- interpreter,
88613
- ...options,
88614
- env: {
88615
- NODE_ENV: "production",
88616
- ...env2,
88617
- ...options?.env
88618
- }
88619
- };
88620
- try {
88621
- await this.pm2Connect.checkConnect();
88622
- const apps = await this.list({ needExit: false });
88623
- const app = apps.find((app2) => app2.name === appName);
88624
- if (app && app.pid === 0) {
88625
- await start3(starter);
88626
- return;
88627
- } else if (!app) {
88628
- await start3(starter);
88629
- } else {
88630
- console.log(`pm2 app ${appName} is running`);
88631
- }
88632
- } catch (e) {
88633
- console.error("error", e);
88634
- } finally {
88635
- this.pm2Connect.checkDisconnect({ needExit });
88539
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
88540
+ return process.env.DOTENV_KEY;
88636
88541
  }
88542
+ return "";
88637
88543
  }
88638
- async stop(runOpts) {
88544
+ function _instructions(result, dotenvKey) {
88545
+ let uri;
88639
88546
  try {
88640
- await this.pm2Connect.checkConnect();
88641
- const apps = await this.list({ needExit: false });
88642
- const app = apps.find((app2) => app2.name === this.appName);
88643
- if (app && app.pid !== 0) {
88644
- await stop3(app.name);
88547
+ uri = new URL(dotenvKey);
88548
+ } catch (error3) {
88549
+ if (error3.code === "ERR_INVALID_URL") {
88550
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
88551
+ err.code = "INVALID_DOTENV_KEY";
88552
+ throw err;
88645
88553
  }
88646
- } catch (e) {
88647
- console.error("error", e);
88648
- } finally {
88649
- this.pm2Connect.checkDisconnect(runOpts);
88554
+ throw error3;
88555
+ }
88556
+ const key = uri.password;
88557
+ if (!key) {
88558
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
88559
+ err.code = "INVALID_DOTENV_KEY";
88560
+ throw err;
88561
+ }
88562
+ const environment = uri.searchParams.get("environment");
88563
+ if (!environment) {
88564
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
88565
+ err.code = "INVALID_DOTENV_KEY";
88566
+ throw err;
88567
+ }
88568
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
88569
+ const ciphertext = result.parsed[environmentKey];
88570
+ if (!ciphertext) {
88571
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
88572
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
88573
+ throw err;
88650
88574
  }
88575
+ return { ciphertext, key };
88651
88576
  }
88652
- async restart(runOpts) {
88653
- try {
88654
- await this.pm2Connect.checkConnect();
88655
- const apps = await this.list({ needExit: false });
88656
- const app = apps.find((app2) => app2.name === this.appName);
88657
- if (app) {
88658
- await restart3(app.name);
88577
+ function _vaultPath(options) {
88578
+ let possibleVaultPath = null;
88579
+ if (options && options.path && options.path.length > 0) {
88580
+ if (Array.isArray(options.path)) {
88581
+ for (const filepath of options.path) {
88582
+ if (fs8.existsSync(filepath)) {
88583
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
88584
+ }
88585
+ }
88586
+ } else {
88587
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
88659
88588
  }
88660
- } catch (e) {
88661
- console.error("error", e);
88662
- } finally {
88663
- this.pm2Connect.checkDisconnect(runOpts);
88589
+ } else {
88590
+ possibleVaultPath = path9.resolve(process.cwd(), ".env.vault");
88591
+ }
88592
+ if (fs8.existsSync(possibleVaultPath)) {
88593
+ return possibleVaultPath;
88664
88594
  }
88595
+ return null;
88665
88596
  }
88666
- async remove(runOpts) {
88667
- this.deleteProcess(runOpts);
88597
+ function _resolveHome(envPath) {
88598
+ return envPath[0] === "~" ? path9.join(os2.homedir(), envPath.slice(1)) : envPath;
88668
88599
  }
88669
- async deleteProcess(runOpts) {
88670
- try {
88671
- await this.pm2Connect.checkConnect();
88672
- const apps = await this.list({ needExit: false });
88673
- const app = apps.find((app2) => app2.name === this.appName);
88674
- if (app) {
88675
- await deleteProcess3(app.name);
88676
- }
88677
- } catch (e) {
88678
- console.error("error", e);
88679
- } finally {
88680
- this.pm2Connect.checkDisconnect(runOpts);
88600
+ function _configVault(options) {
88601
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
88602
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
88603
+ if (debug || !quiet) {
88604
+ _log("Loading env from encrypted .env.vault");
88681
88605
  }
88682
- }
88683
- }
88684
-
88685
- // src/module/local-apps/src/modules/manager.ts
88606
+ const parsed = DotenvModule._parseVault(options);
88607
+ let processEnv = process.env;
88608
+ if (options && options.processEnv != null) {
88609
+ processEnv = options.processEnv;
88610
+ }
88611
+ DotenvModule.populate(processEnv, parsed, options);
88612
+ return { parsed };
88613
+ }
88614
+ function configDotenv(options) {
88615
+ const dotenvPath = path9.resolve(process.cwd(), ".env");
88616
+ let encoding = "utf8";
88617
+ let processEnv = process.env;
88618
+ if (options && options.processEnv != null) {
88619
+ processEnv = options.processEnv;
88620
+ }
88621
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
88622
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
88623
+ if (options && options.encoding) {
88624
+ encoding = options.encoding;
88625
+ } else {
88626
+ if (debug) {
88627
+ _debug("No encoding is specified. UTF-8 is used by default");
88628
+ }
88629
+ }
88630
+ let optionPaths = [dotenvPath];
88631
+ if (options && options.path) {
88632
+ if (!Array.isArray(options.path)) {
88633
+ optionPaths = [_resolveHome(options.path)];
88634
+ } else {
88635
+ optionPaths = [];
88636
+ for (const filepath of options.path) {
88637
+ optionPaths.push(_resolveHome(filepath));
88638
+ }
88639
+ }
88640
+ }
88641
+ let lastError;
88642
+ const parsedAll = {};
88643
+ for (const path22 of optionPaths) {
88644
+ try {
88645
+ const parsed = DotenvModule.parse(fs8.readFileSync(path22, { encoding }));
88646
+ DotenvModule.populate(parsedAll, parsed, options);
88647
+ } catch (e) {
88648
+ if (debug) {
88649
+ _debug(`Failed to load ${path22} ${e.message}`);
88650
+ }
88651
+ lastError = e;
88652
+ }
88653
+ }
88654
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
88655
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
88656
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
88657
+ if (debug || !quiet) {
88658
+ const keysCount = Object.keys(populated).length;
88659
+ const shortPaths = [];
88660
+ for (const filePath of optionPaths) {
88661
+ try {
88662
+ const relative = path9.relative(process.cwd(), filePath);
88663
+ shortPaths.push(relative);
88664
+ } catch (e) {
88665
+ if (debug) {
88666
+ _debug(`Failed to load ${filePath} ${e.message}`);
88667
+ }
88668
+ lastError = e;
88669
+ }
88670
+ }
88671
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
88672
+ }
88673
+ if (lastError) {
88674
+ return { parsed: parsedAll, error: lastError };
88675
+ } else {
88676
+ return { parsed: parsedAll };
88677
+ }
88678
+ }
88679
+ function config2(options) {
88680
+ if (_dotenvKey(options).length === 0) {
88681
+ return DotenvModule.configDotenv(options);
88682
+ }
88683
+ const vaultPath = _vaultPath(options);
88684
+ if (!vaultPath) {
88685
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
88686
+ return DotenvModule.configDotenv(options);
88687
+ }
88688
+ return DotenvModule._configVault(options);
88689
+ }
88690
+ function decrypt(encrypted, keyStr) {
88691
+ const key = Buffer.from(keyStr.slice(-64), "hex");
88692
+ let ciphertext = Buffer.from(encrypted, "base64");
88693
+ const nonce = ciphertext.subarray(0, 12);
88694
+ const authTag = ciphertext.subarray(-16);
88695
+ ciphertext = ciphertext.subarray(12, -16);
88696
+ try {
88697
+ const aesgcm = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
88698
+ aesgcm.setAuthTag(authTag);
88699
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
88700
+ } catch (error3) {
88701
+ const isRange = error3 instanceof RangeError;
88702
+ const invalidKeyLength = error3.message === "Invalid key length";
88703
+ const decryptionFailed = error3.message === "Unsupported state or unable to authenticate data";
88704
+ if (isRange || invalidKeyLength) {
88705
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
88706
+ err.code = "INVALID_DOTENV_KEY";
88707
+ throw err;
88708
+ } else if (decryptionFailed) {
88709
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
88710
+ err.code = "DECRYPTION_FAILED";
88711
+ throw err;
88712
+ } else {
88713
+ throw error3;
88714
+ }
88715
+ }
88716
+ }
88717
+ function populate(processEnv, parsed, options = {}) {
88718
+ const debug = Boolean(options && options.debug);
88719
+ const override = Boolean(options && options.override);
88720
+ const populated = {};
88721
+ if (typeof parsed !== "object") {
88722
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
88723
+ err.code = "OBJECT_REQUIRED";
88724
+ throw err;
88725
+ }
88726
+ for (const key of Object.keys(parsed)) {
88727
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
88728
+ if (override === true) {
88729
+ processEnv[key] = parsed[key];
88730
+ populated[key] = parsed[key];
88731
+ }
88732
+ if (debug) {
88733
+ if (override === true) {
88734
+ _debug(`"${key}" is already defined and WAS overwritten`);
88735
+ } else {
88736
+ _debug(`"${key}" is already defined and was NOT overwritten`);
88737
+ }
88738
+ }
88739
+ } else {
88740
+ processEnv[key] = parsed[key];
88741
+ populated[key] = parsed[key];
88742
+ }
88743
+ }
88744
+ return populated;
88745
+ }
88746
+ var DotenvModule = {
88747
+ configDotenv,
88748
+ _configVault,
88749
+ _parseVault,
88750
+ config: config2,
88751
+ decrypt,
88752
+ parse: parse2,
88753
+ populate
88754
+ };
88755
+ exports.configDotenv = DotenvModule.configDotenv;
88756
+ exports._configVault = DotenvModule._configVault;
88757
+ exports._parseVault = DotenvModule._parseVault;
88758
+ exports.config = DotenvModule.config;
88759
+ exports.decrypt = DotenvModule.decrypt;
88760
+ exports.parse = DotenvModule.parse;
88761
+ exports.populate = DotenvModule.populate;
88762
+ module.exports = DotenvModule;
88763
+ });
88764
+ var import_dotenv3 = __toESM3(require_main6(), 1);
88765
+ var fileIsExist2 = (path22) => {
88766
+ try {
88767
+ fs7.accessSync(path22, fs7.constants.F_OK);
88768
+ return true;
88769
+ } catch (e) {
88770
+ return false;
88771
+ }
88772
+ };
88773
+ var getCwdDirname2 = () => {
88774
+ return process.cwd();
88775
+ };
88776
+ var getConfigFile2 = (opts) => {
88777
+ if (opts?.envConfigFile) {
88778
+ const filePath = path8.join(opts.cwd || getCwdDirname2(), opts.envConfigFile);
88779
+ if (fileIsExist2(filePath)) {
88780
+ return filePath;
88781
+ }
88782
+ }
88783
+ const fileName = opts?.fileName || ".env";
88784
+ const dirname = opts?.cwd || getCwdDirname2();
88785
+ const benPath = dirname + "/" + fileName;
88786
+ const ben = fileIsExist2(benPath);
88787
+ if (ben)
88788
+ return benPath;
88789
+ const lastPath = path8.join(dirname, "../" + fileName);
88790
+ const last = fileIsExist2(lastPath);
88791
+ if (last)
88792
+ return lastPath;
88793
+ const lastLastPath = path8.join(dirname, "../../" + fileName);
88794
+ const lastLast = fileIsExist2(lastLastPath);
88795
+ if (lastLast)
88796
+ return lastLastPath;
88797
+ return "";
88798
+ };
88799
+ var getConfig = (opts) => {
88800
+ let quiet = opts?.quite ?? true;
88801
+ const showError = opts?.showError ?? false;
88802
+ if (opts?.dotenvOpts) {
88803
+ const prased = import_dotenv3.default.config({ quiet, ...opts.dotenvOpts }).parsed;
88804
+ if (prased) {
88805
+ return prased;
88806
+ } else {
88807
+ if (showError) {
88808
+ if (!quiet) {
88809
+ console.warn("config 读取失败");
88810
+ }
88811
+ throw new Error("未找到配置文件");
88812
+ }
88813
+ return {};
88814
+ }
88815
+ }
88816
+ const filePath = getConfigFile2(opts);
88817
+ if (!quiet && filePath) {
88818
+ console.log("config pathname:", filePath);
88819
+ }
88820
+ if (!filePath) {
88821
+ if (showError) {
88822
+ if (!quiet) {
88823
+ console.warn("config 路径未找到");
88824
+ }
88825
+ throw new Error("未找到配置文件");
88826
+ }
88827
+ return {};
88828
+ }
88829
+ const value = import_dotenv3.default.config({ quiet: true, path: filePath }).parsed;
88830
+ return value;
88831
+ };
88832
+ var useConfig = (onlyInitConfig, force) => {
88833
+ const config2 = global.config;
88834
+ let _config = config2 || getConfig(onlyInitConfig);
88835
+ !config2 && (global["config"] = _config);
88836
+ if (force && onlyInitConfig) {
88837
+ const _newConfig = getConfig(onlyInitConfig);
88838
+ _config = mergeConfig(_newConfig);
88839
+ }
88840
+ return _config;
88841
+ };
88842
+ var mergeConfig = (config2) => {
88843
+ const _config = global.config || {};
88844
+ Object.assign(_config, config2);
88845
+ global.config = _config;
88846
+ return _config;
88847
+ };
88848
+ var useKey = (key, opts) => {
88849
+ let v = useConfig()[key];
88850
+ if (!v) {
88851
+ v = process.env[key];
88852
+ }
88853
+ if (!v) {
88854
+ return opts?.defaultValue || null;
88855
+ }
88856
+ if (opts?.isNumber && typeof v === "string") {
88857
+ return Number(v);
88858
+ }
88859
+ if (opts?.isBoolean && typeof v === "string") {
88860
+ return v === "true";
88861
+ }
88862
+ return v;
88863
+ };
88864
+ var useFileStore2 = (str, opts) => {
88865
+ const publicPath = process.cwd();
88866
+ const filePath = path8.join(publicPath, str);
88867
+ if (opts?.needExists) {
88868
+ if (!fileIsExist2(filePath)) {
88869
+ fs7.mkdirSync(filePath, { recursive: true });
88870
+ }
88871
+ }
88872
+ return filePath;
88873
+ };
88874
+ var isBrowser4 = typeof window !== "undefined" && typeof window.document !== "undefined";
88875
+ function getDefaultExportFromCjs5(x) {
88876
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
88877
+ }
88878
+ var eventemitter34 = { exports: {} };
88879
+ var hasRequiredEventemitter34;
88880
+ function requireEventemitter34() {
88881
+ if (hasRequiredEventemitter34)
88882
+ return eventemitter34.exports;
88883
+ hasRequiredEventemitter34 = 1;
88884
+ (function(module) {
88885
+ var has = Object.prototype.hasOwnProperty, prefix = "~";
88886
+ function Events() {}
88887
+ if (Object.create) {
88888
+ Events.prototype = Object.create(null);
88889
+ if (!new Events().__proto__)
88890
+ prefix = false;
88891
+ }
88892
+ function EE(fn, context, once) {
88893
+ this.fn = fn;
88894
+ this.context = context;
88895
+ this.once = once || false;
88896
+ }
88897
+ function addListener(emitter, event, fn, context, once) {
88898
+ if (typeof fn !== "function") {
88899
+ throw new TypeError("The listener must be a function");
88900
+ }
88901
+ var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
88902
+ if (!emitter._events[evt])
88903
+ emitter._events[evt] = listener, emitter._eventsCount++;
88904
+ else if (!emitter._events[evt].fn)
88905
+ emitter._events[evt].push(listener);
88906
+ else
88907
+ emitter._events[evt] = [emitter._events[evt], listener];
88908
+ return emitter;
88909
+ }
88910
+ function clearEvent(emitter, evt) {
88911
+ if (--emitter._eventsCount === 0)
88912
+ emitter._events = new Events;
88913
+ else
88914
+ delete emitter._events[evt];
88915
+ }
88916
+ function EventEmitter4() {
88917
+ this._events = new Events;
88918
+ this._eventsCount = 0;
88919
+ }
88920
+ EventEmitter4.prototype.eventNames = function eventNames() {
88921
+ var names = [], events, name;
88922
+ if (this._eventsCount === 0)
88923
+ return names;
88924
+ for (name in events = this._events) {
88925
+ if (has.call(events, name))
88926
+ names.push(prefix ? name.slice(1) : name);
88927
+ }
88928
+ if (Object.getOwnPropertySymbols) {
88929
+ return names.concat(Object.getOwnPropertySymbols(events));
88930
+ }
88931
+ return names;
88932
+ };
88933
+ EventEmitter4.prototype.listeners = function listeners(event) {
88934
+ var evt = prefix ? prefix + event : event, handlers = this._events[evt];
88935
+ if (!handlers)
88936
+ return [];
88937
+ if (handlers.fn)
88938
+ return [handlers.fn];
88939
+ for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
88940
+ ee[i] = handlers[i].fn;
88941
+ }
88942
+ return ee;
88943
+ };
88944
+ EventEmitter4.prototype.listenerCount = function listenerCount(event) {
88945
+ var evt = prefix ? prefix + event : event, listeners = this._events[evt];
88946
+ if (!listeners)
88947
+ return 0;
88948
+ if (listeners.fn)
88949
+ return 1;
88950
+ return listeners.length;
88951
+ };
88952
+ EventEmitter4.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
88953
+ var evt = prefix ? prefix + event : event;
88954
+ if (!this._events[evt])
88955
+ return false;
88956
+ var listeners = this._events[evt], len = arguments.length, args2, i;
88957
+ if (listeners.fn) {
88958
+ if (listeners.once)
88959
+ this.removeListener(event, listeners.fn, undefined, true);
88960
+ switch (len) {
88961
+ case 1:
88962
+ return listeners.fn.call(listeners.context), true;
88963
+ case 2:
88964
+ return listeners.fn.call(listeners.context, a1), true;
88965
+ case 3:
88966
+ return listeners.fn.call(listeners.context, a1, a2), true;
88967
+ case 4:
88968
+ return listeners.fn.call(listeners.context, a1, a2, a3), true;
88969
+ case 5:
88970
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
88971
+ case 6:
88972
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
88973
+ }
88974
+ for (i = 1, args2 = new Array(len - 1);i < len; i++) {
88975
+ args2[i - 1] = arguments[i];
88976
+ }
88977
+ listeners.fn.apply(listeners.context, args2);
88978
+ } else {
88979
+ var length = listeners.length, j;
88980
+ for (i = 0;i < length; i++) {
88981
+ if (listeners[i].once)
88982
+ this.removeListener(event, listeners[i].fn, undefined, true);
88983
+ switch (len) {
88984
+ case 1:
88985
+ listeners[i].fn.call(listeners[i].context);
88986
+ break;
88987
+ case 2:
88988
+ listeners[i].fn.call(listeners[i].context, a1);
88989
+ break;
88990
+ case 3:
88991
+ listeners[i].fn.call(listeners[i].context, a1, a2);
88992
+ break;
88993
+ case 4:
88994
+ listeners[i].fn.call(listeners[i].context, a1, a2, a3);
88995
+ break;
88996
+ default:
88997
+ if (!args2)
88998
+ for (j = 1, args2 = new Array(len - 1);j < len; j++) {
88999
+ args2[j - 1] = arguments[j];
89000
+ }
89001
+ listeners[i].fn.apply(listeners[i].context, args2);
89002
+ }
89003
+ }
89004
+ }
89005
+ return true;
89006
+ };
89007
+ EventEmitter4.prototype.on = function on(event, fn, context) {
89008
+ return addListener(this, event, fn, context, false);
89009
+ };
89010
+ EventEmitter4.prototype.once = function once(event, fn, context) {
89011
+ return addListener(this, event, fn, context, true);
89012
+ };
89013
+ EventEmitter4.prototype.removeListener = function removeListener(event, fn, context, once) {
89014
+ var evt = prefix ? prefix + event : event;
89015
+ if (!this._events[evt])
89016
+ return this;
89017
+ if (!fn) {
89018
+ clearEvent(this, evt);
89019
+ return this;
89020
+ }
89021
+ var listeners = this._events[evt];
89022
+ if (listeners.fn) {
89023
+ if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
89024
+ clearEvent(this, evt);
89025
+ }
89026
+ } else {
89027
+ for (var i = 0, events = [], length = listeners.length;i < length; i++) {
89028
+ if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
89029
+ events.push(listeners[i]);
89030
+ }
89031
+ }
89032
+ if (events.length)
89033
+ this._events[evt] = events.length === 1 ? events[0] : events;
89034
+ else
89035
+ clearEvent(this, evt);
89036
+ }
89037
+ return this;
89038
+ };
89039
+ EventEmitter4.prototype.removeAllListeners = function removeAllListeners(event) {
89040
+ var evt;
89041
+ if (event) {
89042
+ evt = prefix ? prefix + event : event;
89043
+ if (this._events[evt])
89044
+ clearEvent(this, evt);
89045
+ } else {
89046
+ this._events = new Events;
89047
+ this._eventsCount = 0;
89048
+ }
89049
+ return this;
89050
+ };
89051
+ EventEmitter4.prototype.off = EventEmitter4.prototype.removeListener;
89052
+ EventEmitter4.prototype.addListener = EventEmitter4.prototype.on;
89053
+ EventEmitter4.prefixed = prefix;
89054
+ EventEmitter4.EventEmitter = EventEmitter4;
89055
+ {
89056
+ module.exports = EventEmitter4;
89057
+ }
89058
+ })(eventemitter34);
89059
+ return eventemitter34.exports;
89060
+ }
89061
+ var eventemitter3Exports4 = requireEventemitter34();
89062
+ var EventEmitter4 = /* @__PURE__ */ getDefaultExportFromCjs5(eventemitter3Exports4);
89063
+ var reRunFn3 = (promiseOpts) => {
89064
+ const timeout = promiseOpts.timeout || 5 * 60 * 1000;
89065
+ const interval = promiseOpts.interval || 1000;
89066
+ const checkSuccess = promiseOpts?.checkSuccess || (() => true);
89067
+ const signal = promiseOpts.signal;
89068
+ return new Promise(async (resolve, reject) => {
89069
+ let intervalId;
89070
+ let timeoutId = setTimeout(() => {
89071
+ clearTimeout(intervalId);
89072
+ resolve({
89073
+ code: 500,
89074
+ message: "timeout"
89075
+ });
89076
+ }, timeout);
89077
+ const fn = promiseOpts.fn || (() => true);
89078
+ const runFn = async () => {
89079
+ if (signal?.aborted) {
89080
+ clearInterval(intervalId);
89081
+ clearTimeout(timeoutId);
89082
+ return resolve({
89083
+ code: 499,
89084
+ message: "operation cancelled"
89085
+ });
89086
+ }
89087
+ const res = await fn();
89088
+ if (!!checkSuccess(res)) {
89089
+ clearInterval(intervalId);
89090
+ clearTimeout(timeoutId);
89091
+ resolve({
89092
+ code: 200,
89093
+ data: res
89094
+ });
89095
+ } else {
89096
+ setTimeout(() => {
89097
+ runFn();
89098
+ }, interval);
89099
+ }
89100
+ };
89101
+ if (signal) {
89102
+ signal.addEventListener("abort", () => {
89103
+ clearInterval(intervalId);
89104
+ clearTimeout(timeoutId);
89105
+ resolve({
89106
+ code: 499,
89107
+ message: "operation cancelled"
89108
+ });
89109
+ });
89110
+ }
89111
+ runFn();
89112
+ });
89113
+ };
89114
+
89115
+ class BaseLoad3 {
89116
+ modules = new Map;
89117
+ event;
89118
+ loading;
89119
+ static reRunFn = reRunFn3;
89120
+ timeout = 5 * 60 * 1000;
89121
+ constructor() {
89122
+ this.event = new EventEmitter4;
89123
+ this.loading = false;
89124
+ }
89125
+ listenKey(key, listenOpts) {
89126
+ const timeout = listenOpts?.timeout ?? this.timeout;
89127
+ return new Promise((resolve) => {
89128
+ const timeoutId = setTimeout(() => {
89129
+ this.event.removeListener(key, onEvent);
89130
+ resolve({
89131
+ code: 500,
89132
+ message: "timeout"
89133
+ });
89134
+ }, timeout);
89135
+ const onEvent = (error3) => {
89136
+ clearTimeout(timeoutId);
89137
+ if (error3) {
89138
+ return resolve({
89139
+ code: 500,
89140
+ message: error3
89141
+ });
89142
+ }
89143
+ const data = this.modules.get(key);
89144
+ if (data?.loadSuccessClear) {
89145
+ this.remove(key);
89146
+ }
89147
+ resolve({
89148
+ code: 200,
89149
+ data: data?.modules
89150
+ });
89151
+ };
89152
+ this.event.once(key, onEvent);
89153
+ });
89154
+ }
89155
+ async hasLoaded(key, hasLoadOpts) {
89156
+ if (!key) {
89157
+ return {
89158
+ code: 404,
89159
+ message: "key is required"
89160
+ };
89161
+ }
89162
+ const has = this.modules.has(key);
89163
+ if (!has) {
89164
+ const isExist = hasLoadOpts?.isExist ?? true;
89165
+ const timeout = hasLoadOpts?.timeout ?? this.timeout;
89166
+ if (isExist) {
89167
+ return await this.listenKey(key, { timeout });
89168
+ }
89169
+ return {
89170
+ code: 404
89171
+ };
89172
+ }
89173
+ const data = this.modules.get(key);
89174
+ if (data?.status === "loaded") {
89175
+ return {
89176
+ code: 200,
89177
+ data: data.modules
89178
+ };
89179
+ }
89180
+ if (data?.status === "loading") {
89181
+ return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
89182
+ }
89183
+ if (data?.status === "error") {
89184
+ return {
89185
+ code: 500,
89186
+ message: "load error"
89187
+ };
89188
+ }
89189
+ if (data?.status === "cancel") {
89190
+ return {
89191
+ code: 499,
89192
+ message: "operation cancelled"
89193
+ };
89194
+ }
89195
+ return {
89196
+ code: 404
89197
+ };
89198
+ }
89199
+ async loadFn(loadContent, opts) {
89200
+ const key = opts.key;
89201
+ if (!key) {
89202
+ return {
89203
+ code: 404,
89204
+ message: "key is required"
89205
+ };
89206
+ }
89207
+ const newModule = {
89208
+ key: opts.key,
89209
+ status: "loading",
89210
+ loading: true,
89211
+ loadSuccessClear: opts.loadSuccessClear ?? true
89212
+ };
89213
+ let errorMessage = "";
89214
+ try {
89215
+ const isReRun = opts.isReRun ?? false;
89216
+ let res;
89217
+ if (!isReRun) {
89218
+ this.modules.set(key, newModule);
89219
+ res = await loadContent();
89220
+ } else {
89221
+ newModule.controller = new AbortController;
89222
+ const signal = newModule.controller.signal;
89223
+ this.modules.set(key, newModule);
89224
+ const data = await reRunFn3({
89225
+ timeout: opts.timeout,
89226
+ interval: opts.interval,
89227
+ checkSuccess: opts.checkSuccess,
89228
+ fn: loadContent,
89229
+ signal
89230
+ });
89231
+ newModule.controller = null;
89232
+ if (data.code === 499) {
89233
+ newModule.status = "cancel";
89234
+ return {
89235
+ code: 499,
89236
+ message: "operation cancelled"
89237
+ };
89238
+ }
89239
+ if (data.code !== 200) {
89240
+ throw new Error(data.message);
89241
+ }
89242
+ res = data.data;
89243
+ }
89244
+ newModule.modules = res;
89245
+ newModule.status = "loaded";
89246
+ return {
89247
+ code: 200,
89248
+ data: res
89249
+ };
89250
+ } catch (error3) {
89251
+ errorMessage = error3.message;
89252
+ newModule.status = "error";
89253
+ return {
89254
+ code: 500,
89255
+ message: error3
89256
+ };
89257
+ } finally {
89258
+ newModule.loading = false;
89259
+ this.modules.set(opts.key, newModule);
89260
+ if (!errorMessage) {
89261
+ this.event.emit(opts.key);
89262
+ } else {
89263
+ this.event.emit(opts.key, errorMessage);
89264
+ }
89265
+ }
89266
+ }
89267
+ async load(loadContent, opts) {
89268
+ this.loading = true;
89269
+ const key = opts.key;
89270
+ if (!key) {
89271
+ return {
89272
+ code: 404,
89273
+ message: "key is required"
89274
+ };
89275
+ }
89276
+ if (opts?.force) {
89277
+ this.remove(key);
89278
+ }
89279
+ const has = this.modules.has(key);
89280
+ if (has) {
89281
+ return await this.hasLoaded(key);
89282
+ }
89283
+ if (typeof loadContent === "function") {
89284
+ return this.loadFn(loadContent, opts);
89285
+ }
89286
+ console.error("loadContent is not a function and not has loaded");
89287
+ }
89288
+ remove(key) {
89289
+ const has = this.modules.has(key);
89290
+ if (has) {
89291
+ this.checkRemoveController(key);
89292
+ this.modules.delete(key);
89293
+ }
89294
+ }
89295
+ emitLoaded(key) {
89296
+ this.checkRemoveController(key);
89297
+ this.event.emit(key);
89298
+ }
89299
+ setModule(key, data, loadData) {
89300
+ const newModule = {
89301
+ key,
89302
+ status: "loaded",
89303
+ loading: false,
89304
+ modules: data || {},
89305
+ ...loadData
89306
+ };
89307
+ this.modules.set(key, newModule);
89308
+ this.emitLoaded(key);
89309
+ return newModule;
89310
+ }
89311
+ cancel(key) {
89312
+ this.checkRemoveController(key);
89313
+ }
89314
+ checkRemoveController(key) {
89315
+ const data = this.modules.get(key);
89316
+ if (data?.controller) {
89317
+ data.controller?.abort?.();
89318
+ delete data.controller;
89319
+ this.modules.set(key, data);
89320
+ }
89321
+ }
89322
+ }
89323
+ var gt3 = globalThis || window || self;
89324
+ var useEnv3 = (initEnv, initKey = "config", isOverwrite) => {
89325
+ const env2 = gt3[initKey];
89326
+ const _env = env2 || initEnv;
89327
+ if (!env2) {
89328
+ if (_env) {
89329
+ gt3[initKey] = _env;
89330
+ } else {
89331
+ gt3[initKey] = {};
89332
+ }
89333
+ } else if (isOverwrite) {
89334
+ gt3[initKey] = { ...env2, ...initEnv };
89335
+ }
89336
+ return gt3[initKey];
89337
+ };
89338
+ var useEnvKey3 = (key, init, initKey = "config") => {
89339
+ const _env = useEnv3({}, initKey);
89340
+ if (key && typeof _env[key] !== "undefined") {
89341
+ return _env[key];
89342
+ }
89343
+ if (key && init) {
89344
+ if (typeof init !== "function") {
89345
+ _env[key] = init;
89346
+ }
89347
+ if (typeof init === "function") {
89348
+ const result = init();
89349
+ if (result instanceof Promise) {
89350
+ return result.then((res) => {
89351
+ _env[key] = res;
89352
+ return res;
89353
+ });
89354
+ }
89355
+ _env[key] = result;
89356
+ }
89357
+ return _env[key];
89358
+ }
89359
+ if (key) {
89360
+ const baseLoad = new BaseLoad3;
89361
+ const voidFn = async () => {
89362
+ return _env[key];
89363
+ };
89364
+ const checkFn = async () => {
89365
+ const loadRes = await baseLoad.load(voidFn, {
89366
+ key,
89367
+ isReRun: true,
89368
+ checkSuccess: () => _env[key],
89369
+ timeout: 5 * 60 * 1000,
89370
+ interval: 1000
89371
+ });
89372
+ if (loadRes.code !== 200) {
89373
+ console.error("load key error");
89374
+ return null;
89375
+ }
89376
+ return _env[key];
89377
+ };
89378
+ return checkFn();
89379
+ }
89380
+ console.error("key is empty ");
89381
+ return null;
89382
+ };
89383
+ var useEnvKeyNew3 = (key, initKey = "config", opts) => {
89384
+ const _env = useEnv3({}, initKey);
89385
+ if (key) {
89386
+ delete _env[key];
89387
+ }
89388
+ if (opts?.getNew && opts.init) {
89389
+ return useEnvKey3(key, opts.init, initKey);
89390
+ } else if (opts?.getNew) {
89391
+ return useEnvKey3(key, null, initKey);
89392
+ }
89393
+ };
89394
+ var useContextKey3 = (key, init, isNew) => {
89395
+ if (isNew) {
89396
+ return useEnvKeyNew3(key, "context", { getNew: true, init });
89397
+ }
89398
+ return useEnvKey3(key, init, "context");
89399
+ };
89400
+ var use3 = useContextKey3;
89401
+ var useConfigKey3 = (key, init, isNew) => {
89402
+ if (isNew) {
89403
+ return useEnvKeyNew3(key, "config", { getNew: true, init });
89404
+ }
89405
+ return useEnvKey3(key, init, "config");
89406
+ };
89407
+
89408
+ class InitEnv3 {
89409
+ static isInit = false;
89410
+ static init(opts) {
89411
+ if (InitEnv3.isInit) {
89412
+ return;
89413
+ }
89414
+ const { load = true, page = false } = opts || {};
89415
+ InitEnv3.isInit = true;
89416
+ gt3.useConfigKey = useConfigKey3;
89417
+ gt3.useContextKey = useContextKey3;
89418
+ gt3.use = use3;
89419
+ gt3.webEnv = { useConfigKey: useConfigKey3, useContextKey: useContextKey3, use: use3 };
89420
+ load && (gt3.Load = BaseLoad3);
89421
+ }
89422
+ }
89423
+ InitEnv3.init();
89424
+
89425
+ // src/module/local-apps/src/modules/app-file.ts
89426
+ import path9 from "node:path";
89427
+ import fs8 from "node:fs";
89428
+ var getAppsPath2 = () => {
89429
+ const appsPath = process.env.APPS_PATH;
89430
+ if (appsPath) {
89431
+ const resolvePath = path9.resolve(appsPath);
89432
+ if (fileIsExist2(resolvePath)) {
89433
+ return resolvePath;
89434
+ } else {
89435
+ fs8.mkdirSync(resolvePath, { recursive: true });
89436
+ return resolvePath;
89437
+ }
89438
+ }
89439
+ return useFileStore2("apps", { needExists: true });
89440
+ };
89441
+ var loadAppInfo2 = async (appsPath = "apps", filename = "apps.config.json") => {
89442
+ let configFile = getConfigFile2({
89443
+ cwd: appsPath,
89444
+ fileName: filename
89445
+ });
89446
+ if (!configFile) {
89447
+ configFile = path9.join(appsPath, "..", filename);
89448
+ fs8.writeFileSync(configFile, JSON.stringify({ list: [] }));
89449
+ return { list: [] };
89450
+ }
89451
+ try {
89452
+ const config2 = fs8.readFileSync(configFile, "utf-8");
89453
+ const v = JSON.parse(config2);
89454
+ if (!v.list) {
89455
+ v.list = [];
89456
+ }
89457
+ return v;
89458
+ } catch (e) {
89459
+ console.error("读取配置文件失败", e.message);
89460
+ return { list: [] };
89461
+ }
89462
+ };
89463
+ var saveAppInfo2 = async (data, appsPath, filename = "apps.config.json") => {
89464
+ const configFile = getConfigFile2({
89465
+ fileName: filename,
89466
+ cwd: appsPath
89467
+ });
89468
+ if (!configFile) {
89469
+ console.error("未找到配置文件");
89470
+ return;
89471
+ }
89472
+ fs8.writeFileSync(configFile, JSON.stringify(data, null, 2));
89473
+ };
89474
+ var deleteFileAppInfo2 = async (key, appsPath) => {
89475
+ const normalizedKey = key.replace(/\//g, path9.sep);
89476
+ const directory = path9.join(appsPath, normalizedKey);
89477
+ if (!fileIsExist2(directory)) {
89478
+ return;
89479
+ }
89480
+ fs8.rmSync(directory, { recursive: true });
89481
+ };
89482
+
89483
+ // src/module/local-apps/src/modules/manager.ts
89484
+ import { fork as fork2 } from "node:child_process";
89485
+ import path10 from "node:path";
89486
+ var import_fast_glob = __toESM(require_out4(), 1);
89487
+ import fs9 from "node:fs";
89488
+
89489
+ // src/module/local-apps/src/modules/pm2.ts
89490
+ import { spawn } from "node:child_process";
89491
+ import pm23 from "pm2";
89492
+ import { promisify as promisify3 } from "node:util";
89493
+ var normalizeScriptPath2 = (scriptPath) => {
89494
+ if (process.platform === "win32") {
89495
+ return scriptPath.replace(/\\/g, "/");
89496
+ }
89497
+ return scriptPath;
89498
+ };
89499
+ var connect2 = async (noDaemonMode = false) => {
89500
+ return new Promise((resolve, reject) => {
89501
+ pm23.connect(noDaemonMode, (err) => {
89502
+ if (err) {
89503
+ console.error("pm2 connect error", err);
89504
+ return reject(err);
89505
+ }
89506
+ resolve(true);
89507
+ });
89508
+ });
89509
+ };
89510
+ var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
89511
+ var start3 = promisify3(pm23.start).bind(pm23);
89512
+ var stop3 = promisify3(pm23.stop).bind(pm23);
89513
+ var restart3 = promisify3(pm23.restart).bind(pm23);
89514
+ var reload2 = promisify3(pm23.reload).bind(pm23);
89515
+ var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
89516
+ var list3 = promisify3(pm23.list).bind(pm23);
89517
+ var checkInstall = async (app) => {
89518
+ return new Promise((resolve, reject) => {
89519
+ const install = spawn("pnpm", ["install"], {
89520
+ cwd: app.path,
89521
+ stdio: "inherit"
89522
+ });
89523
+ install.on("close", (code) => {
89524
+ if (code !== 0) {
89525
+ console.log("install failed");
89526
+ return resolve(false);
89527
+ }
89528
+ console.log("install success");
89529
+ resolve(true);
89530
+ });
89531
+ });
89532
+ };
89533
+
89534
+ class Pm2Connect2 {
89535
+ needConnect = true;
89536
+ isConnected = false;
89537
+ constructor(needConnect = true) {
89538
+ this.needConnect = needConnect;
89539
+ }
89540
+ async sleep(ms2) {
89541
+ return new Promise((resolve) => {
89542
+ setTimeout(resolve, ms2);
89543
+ });
89544
+ }
89545
+ async checkConnect() {
89546
+ const that = this;
89547
+ try {
89548
+ if (this.needConnect && !this.isConnected) {
89549
+ const data = await connect2();
89550
+ that.isConnected = !!data;
89551
+ }
89552
+ } catch (e) {
89553
+ console.log("pm2 check connect error", e);
89554
+ }
89555
+ }
89556
+ async checkDisconnect(runOpts) {
89557
+ const needExit = runOpts?.needExit ?? true;
89558
+ if (this.needConnect && this.isConnected && needExit) {
89559
+ this.disconnect();
89560
+ }
89561
+ }
89562
+ async connect() {
89563
+ try {
89564
+ await connect2();
89565
+ this.isConnected = true;
89566
+ } catch (e) {
89567
+ console.log("pm2 connect error", e);
89568
+ }
89569
+ }
89570
+ async disconnect() {
89571
+ try {
89572
+ pm23.disconnect();
89573
+ await this.sleep(1000);
89574
+ } catch (e) {
89575
+ console.log("pm2 disconnect error", e);
89576
+ }
89577
+ this.isConnected = false;
89578
+ }
89579
+ }
89580
+
89581
+ class Pm2Manager2 {
89582
+ pm2Connect;
89583
+ appName;
89584
+ script;
89585
+ interpreter;
89586
+ needConnect = true;
89587
+ isConnect = false;
89588
+ env;
89589
+ constructor(opts) {
89590
+ this.appName = opts.appName;
89591
+ this.script = opts.script;
89592
+ this.interpreter = opts.interpreter;
89593
+ this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
89594
+ this.env = opts.env || {};
89595
+ }
89596
+ async list(runOpts) {
89597
+ const _runOpts = { needExit: false, ...runOpts };
89598
+ try {
89599
+ await this.pm2Connect.checkConnect();
89600
+ const apps = await list3();
89601
+ return apps;
89602
+ } catch (e) {
89603
+ console.log("pm2 run error", e);
89604
+ return [];
89605
+ } finally {
89606
+ this.pm2Connect.checkDisconnect(_runOpts);
89607
+ }
89608
+ }
89609
+ async start(options, runOpts) {
89610
+ const { appName, script, env: env2, interpreter } = this;
89611
+ const needExit = runOpts?.needExit ?? true;
89612
+ if (!script) {
89613
+ console.error("script is required");
89614
+ return;
89615
+ }
89616
+ const normalizedScript = normalizeScriptPath2(script);
89617
+ const starter = {
89618
+ name: appName,
89619
+ script: normalizedScript,
89620
+ cwd: process.cwd(),
89621
+ interpreter,
89622
+ ...options,
89623
+ env: {
89624
+ NODE_ENV: "production",
89625
+ ...env2,
89626
+ ...options?.env
89627
+ }
89628
+ };
89629
+ try {
89630
+ await this.pm2Connect.checkConnect();
89631
+ const apps = await this.list({ needExit: false });
89632
+ const app = apps.find((app2) => app2.name === appName);
89633
+ if (app && app.pid === 0) {
89634
+ await start3(starter);
89635
+ return;
89636
+ } else if (!app) {
89637
+ await start3(starter);
89638
+ } else {
89639
+ console.log(`pm2 app ${appName} is running`);
89640
+ }
89641
+ } catch (e) {
89642
+ console.error("error", e);
89643
+ } finally {
89644
+ this.pm2Connect.checkDisconnect({ needExit });
89645
+ }
89646
+ }
89647
+ async stop(runOpts) {
89648
+ try {
89649
+ await this.pm2Connect.checkConnect();
89650
+ const apps = await this.list({ needExit: false });
89651
+ const app = apps.find((app2) => app2.name === this.appName);
89652
+ if (app && app.pid !== 0) {
89653
+ await stop3(app.name);
89654
+ }
89655
+ } catch (e) {
89656
+ console.error("error", e);
89657
+ } finally {
89658
+ this.pm2Connect.checkDisconnect(runOpts);
89659
+ }
89660
+ }
89661
+ async restart(runOpts) {
89662
+ try {
89663
+ await this.pm2Connect.checkConnect();
89664
+ const apps = await this.list({ needExit: false });
89665
+ const app = apps.find((app2) => app2.name === this.appName);
89666
+ if (app) {
89667
+ await restart3(app.name);
89668
+ }
89669
+ } catch (e) {
89670
+ console.error("error", e);
89671
+ } finally {
89672
+ this.pm2Connect.checkDisconnect(runOpts);
89673
+ }
89674
+ }
89675
+ async remove(runOpts) {
89676
+ this.deleteProcess(runOpts);
89677
+ }
89678
+ async deleteProcess(runOpts) {
89679
+ try {
89680
+ await this.pm2Connect.checkConnect();
89681
+ const apps = await this.list({ needExit: false });
89682
+ const app = apps.find((app2) => app2.name === this.appName);
89683
+ if (app) {
89684
+ await deleteProcess3(app.name);
89685
+ }
89686
+ } catch (e) {
89687
+ console.error("error", e);
89688
+ } finally {
89689
+ this.pm2Connect.checkDisconnect(runOpts);
89690
+ }
89691
+ }
89692
+ }
89693
+
89694
+ // src/module/local-apps/src/modules/manager.ts
88686
89695
  var onAppShowInfo2 = (app) => {
88687
89696
  return {
88688
89697
  key: app.key,
@@ -88957,12 +89966,12 @@ var LoadApp = async (app, opts) => {
88957
89966
  if (app.status !== "running") {
88958
89967
  return false;
88959
89968
  }
88960
- if (!fileIsExist(app.path)) {
89969
+ if (!fileIsExist2(app.path)) {
88961
89970
  console.error("app is not found");
88962
89971
  return false;
88963
89972
  }
88964
- const pathEntry = path9.join(app.path, app.entry);
88965
- if (!fileIsExist(pathEntry)) {
89973
+ const pathEntry = path10.join(app.path, app.entry);
89974
+ if (!fileIsExist2(pathEntry)) {
88966
89975
  console.error("file entry not found");
88967
89976
  return false;
88968
89977
  }
@@ -88981,7 +89990,7 @@ var LoadApp = async (app, opts) => {
88981
89990
  });
88982
89991
  app.process = childProcess;
88983
89992
  } else if (app.type === "system-app" /* SystemApp */) {
88984
- const pathEntryAndTimestamp = path9.join(app.path, entry2);
89993
+ const pathEntryAndTimestamp = path10.join(app.path, entry2);
88985
89994
  const importPath = process.platform === "win32" ? "file:///" + pathEntryAndTimestamp.replace(/\\/g, "/") : pathEntryAndTimestamp;
88986
89995
  const module = await import(importPath);
88987
89996
  if (module.loadApp && mainApp) {
@@ -88990,7 +89999,7 @@ var LoadApp = async (app, opts) => {
88990
89999
  } else if (app.type === "gateway-app" /* GatewayApp */) {
88991
90000
  console.log("gateway app not support");
88992
90001
  } else if (app.type === "pm2-system-app" /* Pm2SystemApp */) {
88993
- const pathEntry2 = path9.join(app.path, app.entry);
90002
+ const pathEntry2 = path10.join(app.path, app.entry);
88994
90003
  const pm2Manager = new Pm2Manager2({
88995
90004
  appName: app.key,
88996
90005
  script: pathEntry2,
@@ -89008,7 +90017,7 @@ var LoadApp = async (app, opts) => {
89008
90017
  pm2Options.interpreter = pm2Options.interpreter || app?.engine;
89009
90018
  }
89010
90019
  if (!pm2Options.cwd) {
89011
- pm2Options.cwd = path9.join(app.path, "../..");
90020
+ pm2Options.cwd = path10.join(app.path, "../..");
89012
90021
  }
89013
90022
  await pm2Manager.start(pm2Options);
89014
90023
  } else if (app.type === "script-app" /* ScriptApp */) {
@@ -89043,30 +90052,30 @@ var StopApp = async (app, opts) => {
89043
90052
  }
89044
90053
  };
89045
90054
  var installAppFromKey2 = async (key, _appPath) => {
89046
- const normalizedKey = key.replace(/\//g, path9.sep);
89047
- const directory = path9.join(_appPath, normalizedKey);
89048
- if (!fileIsExist(directory)) {
90055
+ const normalizedKey = key.replace(/\//g, path10.sep);
90056
+ const directory = path10.join(_appPath, normalizedKey);
90057
+ if (!fileIsExist2(directory)) {
89049
90058
  console.error("App not found", directory);
89050
90059
  throw new Error("App not found");
89051
90060
  }
89052
- const pkgs = path9.join(directory, "package.json");
89053
- if (!fileIsExist(pkgs)) {
90061
+ const pkgs = path10.join(directory, "package.json");
90062
+ if (!fileIsExist2(pkgs)) {
89054
90063
  throw new Error("Invalid package.json, need package.json in app directory");
89055
90064
  }
89056
- const json2 = fs8.readFileSync(pkgs, "utf-8");
90065
+ const json2 = fs9.readFileSync(pkgs, "utf-8");
89057
90066
  const pkg = JSON.parse(json2);
89058
90067
  const { name, version: version2, app } = pkg;
89059
90068
  if (!name || !version2 || !app) {
89060
90069
  console.error("need name, version and app in package.json");
89061
90070
  throw new Error("Invalid package.json format, need name, version and app");
89062
90071
  }
89063
- const readmeFile = path9.join(directory, "README.md");
89064
- const readmeFile2 = path9.join(directory, "readme.md");
90072
+ const readmeFile = path10.join(directory, "README.md");
90073
+ const readmeFile2 = path10.join(directory, "readme.md");
89065
90074
  let readmeDesc = "";
89066
- if (fileIsExist(readmeFile)) {
89067
- readmeDesc = fs8.readFileSync(readmeFile, "utf-8");
89068
- } else if (fileIsExist(readmeFile2)) {
89069
- readmeDesc = fs8.readFileSync(readmeFile2, "utf-8");
90075
+ if (fileIsExist2(readmeFile)) {
90076
+ readmeDesc = fs9.readFileSync(readmeFile, "utf-8");
90077
+ } else if (fileIsExist2(readmeFile2)) {
90078
+ readmeDesc = fs9.readFileSync(readmeFile2, "utf-8");
89070
90079
  }
89071
90080
  let showAppInfo = {
89072
90081
  key,
@@ -89081,13 +90090,13 @@ var installAppFromKey2 = async (key, _appPath) => {
89081
90090
  };
89082
90091
  app.key = key;
89083
90092
  if (app.type === "pm2-system-app") {
89084
- const pm2Cwd = path9.join(_appPath, "..");
90093
+ const pm2Cwd = path10.join(_appPath, "..");
89085
90094
  showAppInfo.pm2Options = { cwd: pm2Cwd, ...app.pm2Options };
89086
90095
  }
89087
90096
  return { pkg, showAppInfo };
89088
90097
  };
89089
90098
  var getAppPathKeys2 = async (_appPath) => {
89090
- const directory = path9.resolve(_appPath);
90099
+ const directory = path10.resolve(_appPath);
89091
90100
  const root2 = directory;
89092
90101
  const path1 = "*/package.json";
89093
90102
  const path22 = "*/*/package.json";
@@ -89098,7 +90107,7 @@ var getAppPathKeys2 = async (_appPath) => {
89098
90107
  ignore: ["**/node_modules/**"]
89099
90108
  });
89100
90109
  const appPathKeys = appsPackages.map((pkg) => {
89101
- const dir = path9.dirname(pkg);
90110
+ const dir = path10.dirname(pkg);
89102
90111
  return dir.replace(/\\/g, "/");
89103
90112
  });
89104
90113
  return appPathKeys;
@@ -89106,8 +90115,8 @@ var getAppPathKeys2 = async (_appPath) => {
89106
90115
 
89107
90116
  // src/module/assistant/local-app-manager/assistant-app.ts
89108
90117
  var import_fast_glob3 = __toESM(require_out4(), 1);
89109
- import path12 from "node:path";
89110
- import fs13 from "node:fs";
90118
+ import path13 from "node:path";
90119
+ import fs14 from "node:fs";
89111
90120
 
89112
90121
  // ../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
89113
90122
  var import__ = __toESM(require_eventemitter3(), 1);
@@ -89306,7 +90315,7 @@ var getEnvToken = () => {
89306
90315
  return envTokne;
89307
90316
  };
89308
90317
 
89309
- // ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query-browser.js
90318
+ // ../node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
89310
90319
  var isTextForContentType = (contentType) => {
89311
90320
  if (!contentType)
89312
90321
  return false;
@@ -89338,11 +90347,15 @@ var adapter = async (opts = {}, overloadOpts) => {
89338
90347
  url3 = new URL(opts.url, origin);
89339
90348
  }
89340
90349
  const isGet = method === "GET";
90350
+ const oldSearchParams = url3.searchParams;
89341
90351
  if (isGet) {
89342
- let searchParams = new URLSearchParams(opts.body);
90352
+ let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
89343
90353
  url3.search = searchParams.toString();
89344
90354
  } else {
89345
- const params = opts.params || {};
90355
+ const params = {
90356
+ ...Object.fromEntries(oldSearchParams),
90357
+ ...opts.params
90358
+ };
89346
90359
  const searchParams = new URLSearchParams(params);
89347
90360
  if (typeof opts.body === "object" && opts.body !== null) {
89348
90361
  let body2 = opts.body || {};
@@ -89802,8 +90815,8 @@ class Parser {
89802
90815
  }
89803
90816
 
89804
90817
  class Executor {
89805
- getValueByPath(obj, path10) {
89806
- return path10.split(".").reduce((acc, part) => acc?.[part], obj);
90818
+ getValueByPath(obj, path11) {
90819
+ return path11.split(".").reduce((acc, part) => acc?.[part], obj);
89807
90820
  }
89808
90821
  likeToRegex(pattern2) {
89809
90822
  let regex = "";
@@ -89951,17 +90964,270 @@ var initApi = async (opts) => {
89951
90964
  message: "初始化路由成功"
89952
90965
  };
89953
90966
  };
90967
+ // ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query-browser.js
90968
+ var isTextForContentType2 = (contentType) => {
90969
+ if (!contentType)
90970
+ return false;
90971
+ const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
90972
+ return textTypes.some((type) => contentType.includes(type));
90973
+ };
90974
+ var adapter2 = async (opts = {}, overloadOpts) => {
90975
+ const controller = new AbortController;
90976
+ const signal = controller.signal;
90977
+ const isPostFile = opts.isPostFile || false;
90978
+ let responseType = opts.responseType || "json";
90979
+ if (opts.isBlob) {
90980
+ responseType = "blob";
90981
+ } else if (opts.isText) {
90982
+ responseType = "text";
90983
+ }
90984
+ const timeout = opts.timeout || 60000 * 3;
90985
+ const timer = setTimeout(() => {
90986
+ controller.abort();
90987
+ }, timeout);
90988
+ let method = overloadOpts?.method || opts?.method || "POST";
90989
+ let headers = { ...opts?.headers, ...overloadOpts?.headers };
90990
+ let origin = "";
90991
+ let url3;
90992
+ if (opts?.url?.startsWith("http")) {
90993
+ url3 = new URL(opts.url);
90994
+ } else {
90995
+ origin = window?.location?.origin || "http://localhost:51515";
90996
+ url3 = new URL(opts.url, origin);
90997
+ }
90998
+ const isGet = method === "GET";
90999
+ if (isGet) {
91000
+ let searchParams = new URLSearchParams(opts.body);
91001
+ url3.search = searchParams.toString();
91002
+ } else {
91003
+ const params = opts.params || {};
91004
+ const searchParams = new URLSearchParams(params);
91005
+ if (typeof opts.body === "object" && opts.body !== null) {
91006
+ let body2 = opts.body || {};
91007
+ if (!params.path && body2?.path) {
91008
+ searchParams.set("path", body2.path);
91009
+ if (body2?.key) {
91010
+ searchParams.set("key", body2.key);
91011
+ }
91012
+ }
91013
+ }
91014
+ url3.search = searchParams.toString();
91015
+ }
91016
+ let body = undefined;
91017
+ if (isGet) {
91018
+ body = undefined;
91019
+ } else if (isPostFile) {
91020
+ body = opts.body;
91021
+ } else {
91022
+ headers = {
91023
+ "Content-Type": "application/json",
91024
+ ...headers
91025
+ };
91026
+ body = JSON.stringify(opts.body);
91027
+ }
91028
+ return fetch(url3, {
91029
+ method: method.toUpperCase(),
91030
+ signal,
91031
+ body,
91032
+ ...overloadOpts,
91033
+ headers
91034
+ }).then(async (response) => {
91035
+ const contentType = response.headers.get("Content-Type");
91036
+ if (responseType === "blob") {
91037
+ return await response.blob();
91038
+ }
91039
+ const isText = responseType === "text";
91040
+ const isJson = contentType && contentType.includes("application/json");
91041
+ if (isJson && !isText) {
91042
+ return await response.json();
91043
+ } else if (isTextForContentType2(contentType)) {
91044
+ return {
91045
+ code: response.status,
91046
+ status: response.status,
91047
+ data: await response.text()
91048
+ };
91049
+ } else {
91050
+ return response;
91051
+ }
91052
+ }).catch((err) => {
91053
+ if (err.name === "AbortError") {
91054
+ return {
91055
+ code: 408,
91056
+ message: "请求超时"
91057
+ };
91058
+ }
91059
+ return {
91060
+ code: 500,
91061
+ message: err.message || "网络错误"
91062
+ };
91063
+ }).finally(() => {
91064
+ clearTimeout(timer);
91065
+ });
91066
+ };
91067
+ var wrapperError2 = ({ code, message }) => {
91068
+ const result = {
91069
+ code: code || 500,
91070
+ success: false,
91071
+ message: message || "api request error",
91072
+ showError: (fn) => {},
91073
+ noMsg: true
91074
+ };
91075
+ return result;
91076
+ };
91077
+
91078
+ class Query2 {
91079
+ adapter;
91080
+ url;
91081
+ beforeRequest;
91082
+ afterResponse;
91083
+ headers;
91084
+ timeout;
91085
+ stop;
91086
+ qws;
91087
+ isClient = false;
91088
+ constructor(opts) {
91089
+ this.adapter = opts?.adapter || adapter2;
91090
+ const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
91091
+ this.url = opts?.url || defaultURL;
91092
+ this.headers = opts?.headers || {
91093
+ "Content-Type": "application/json"
91094
+ };
91095
+ this.timeout = opts?.timeout || 60000 * 3;
91096
+ if (opts.beforeRequest) {
91097
+ this.beforeRequest = opts.beforeRequest;
91098
+ } else {
91099
+ this.beforeRequest = async (opts2) => {
91100
+ const token = globalThis?.localStorage?.getItem("token");
91101
+ if (token) {
91102
+ opts2.headers = {
91103
+ ...opts2.headers,
91104
+ Authorization: `Bearer ${token}`
91105
+ };
91106
+ }
91107
+ return opts2;
91108
+ };
91109
+ }
91110
+ }
91111
+ setQueryWs(qws) {
91112
+ this.qws = qws;
91113
+ }
91114
+ setStop(stop4) {
91115
+ this.stop = stop4;
91116
+ }
91117
+ async get(params, options) {
91118
+ return this.post(params, options);
91119
+ }
91120
+ async post(body, options) {
91121
+ const url3 = options?.url || this.url;
91122
+ const { headers, adapter: adapter3, beforeRequest, afterResponse, timeout, ...rest } = options || {};
91123
+ const _headers = { ...this.headers, ...headers };
91124
+ const _adapter = adapter3 || this.adapter;
91125
+ const _beforeRequest = beforeRequest || this.beforeRequest;
91126
+ const _afterResponse = afterResponse || this.afterResponse;
91127
+ const _timeout = timeout || this.timeout;
91128
+ const req = {
91129
+ url: url3,
91130
+ headers: _headers,
91131
+ body,
91132
+ timeout: _timeout,
91133
+ ...rest
91134
+ };
91135
+ try {
91136
+ if (_beforeRequest) {
91137
+ const res = await _beforeRequest(req);
91138
+ if (res === false) {
91139
+ return wrapperError2({
91140
+ code: 500,
91141
+ message: "request is cancel",
91142
+ req
91143
+ });
91144
+ }
91145
+ }
91146
+ } catch (e) {
91147
+ console.error("request beforeFn error", e, req);
91148
+ return wrapperError2({
91149
+ code: 500,
91150
+ message: "api request beforeFn error"
91151
+ });
91152
+ }
91153
+ if (this.stop && !options?.noStop) {
91154
+ const that = this;
91155
+ await new Promise((resolve) => {
91156
+ let timer = 0;
91157
+ const detect = setInterval(() => {
91158
+ if (!that.stop) {
91159
+ clearInterval(detect);
91160
+ resolve(true);
91161
+ }
91162
+ timer++;
91163
+ if (timer > 30) {
91164
+ console.error("request stop: timeout", req.url, timer);
91165
+ }
91166
+ }, 1000);
91167
+ });
91168
+ }
91169
+ return _adapter(req).then(async (res) => {
91170
+ try {
91171
+ if (_afterResponse) {
91172
+ return await _afterResponse(res, {
91173
+ req,
91174
+ res,
91175
+ fetch: adapter3
91176
+ });
91177
+ }
91178
+ return res;
91179
+ } catch (e) {
91180
+ console.error("request afterFn error", e, req);
91181
+ return wrapperError2({
91182
+ code: 500,
91183
+ message: "api request afterFn error"
91184
+ });
91185
+ }
91186
+ });
91187
+ }
91188
+ before(fn) {
91189
+ this.beforeRequest = fn;
91190
+ }
91191
+ after(fn) {
91192
+ this.afterResponse = fn;
91193
+ }
91194
+ async fetchText(urlOrOptions, options) {
91195
+ let _options = { ...options };
91196
+ if (typeof urlOrOptions === "string" && !_options.url) {
91197
+ _options.url = urlOrOptions;
91198
+ }
91199
+ if (typeof urlOrOptions === "object") {
91200
+ _options = { ...urlOrOptions, ..._options };
91201
+ }
91202
+ const res = await adapter2({
91203
+ method: "GET",
91204
+ ..._options,
91205
+ headers: {
91206
+ ...this.headers,
91207
+ ..._options?.headers || {}
91208
+ }
91209
+ });
91210
+ if (res && !res.code) {
91211
+ return {
91212
+ code: 200,
91213
+ data: res
91214
+ };
91215
+ }
91216
+ return res;
91217
+ }
91218
+ }
91219
+
89954
91220
  // src/module/light-code/index.ts
89955
91221
  var import_fast_glob2 = __toESM(require_out4(), 1);
89956
- import path10 from "node:path";
89957
- import fs11 from "node:fs";
91222
+ import path11 from "node:path";
91223
+ import fs12 from "node:fs";
89958
91224
 
89959
91225
  // src/module/light-code/run.ts
89960
91226
  import { fork as fork3 } from "node:child_process";
89961
- import fs9 from "fs";
89962
- var fileExists = (path10) => {
91227
+ import fs10 from "fs";
91228
+ var fileExists = (path11) => {
89963
91229
  try {
89964
- fs9.accessSync(path10, fs9.constants.F_OK);
91230
+ fs10.accessSync(path11, fs10.constants.F_OK);
89965
91231
  return true;
89966
91232
  } catch (e) {
89967
91233
  return false;
@@ -90074,11 +91340,11 @@ var runCode = async (tsPath, params = {}, opts) => {
90074
91340
 
90075
91341
  // src/module/file-hash.ts
90076
91342
  import crypto3 from "node:crypto";
90077
- import fs10 from "node:fs";
91343
+ import fs11 from "node:fs";
90078
91344
  var getHash = (file2) => {
90079
- if (!fs10.existsSync(file2))
91345
+ if (!fs11.existsSync(file2))
90080
91346
  return "";
90081
- const buffer = fs10.readFileSync(file2);
91347
+ const buffer = fs11.readFileSync(file2);
90082
91348
  return crypto3.createHash("md5").update(buffer).digest("hex");
90083
91349
  };
90084
91350
  var getStringHash = (str) => {
@@ -90098,9 +91364,9 @@ var initLightCode = async (opts) => {
90098
91364
  return;
90099
91365
  }
90100
91366
  const appDir = config2.configPath.appsDir;
90101
- const lightcodeDir = path10.join(appDir, "light-code", "code");
90102
- if (!fs11.existsSync(lightcodeDir)) {
90103
- fs11.mkdirSync(lightcodeDir, { recursive: true });
91367
+ const lightcodeDir = path11.join(appDir, "light-code", "code");
91368
+ if (!fs12.existsSync(lightcodeDir)) {
91369
+ fs12.mkdirSync(lightcodeDir, { recursive: true });
90104
91370
  }
90105
91371
  let diffList = [];
90106
91372
  const codeFiles = import_fast_glob2.default.sync(["**/*.ts", "**/*.js"], {
@@ -90108,7 +91374,7 @@ var initLightCode = async (opts) => {
90108
91374
  onlyFiles: true
90109
91375
  }).map((file2) => {
90110
91376
  return {
90111
- filepath: path10.join(lightcodeDir, file2)
91377
+ filepath: path11.join(lightcodeDir, file2)
90112
91378
  };
90113
91379
  });
90114
91380
  if (sync2) {
@@ -90121,7 +91387,7 @@ var initLightCode = async (opts) => {
90121
91387
  const lightQueryList = queryRes.data?.list || [];
90122
91388
  for (const item of lightQueryList) {
90123
91389
  const codeHash = getStringHash(item.code || "");
90124
- diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath: path10.join(lightcodeDir, `${item.id}.ts`) });
91390
+ diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath: path11.join(lightcodeDir, `${item.id}.ts`) });
90125
91391
  }
90126
91392
  const codeFileSet = new Set(codeFiles.map((f) => f.filepath));
90127
91393
  const toAdd = diffList.filter((d) => !codeFileSet.has(d.filepath));
@@ -90129,13 +91395,13 @@ var initLightCode = async (opts) => {
90129
91395
  const toUpdate = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash !== getHash(d.filepath));
90130
91396
  const unchanged = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash === getHash(d.filepath));
90131
91397
  for (const item of toAdd) {
90132
- fs11.writeFileSync(item.filepath, item.code, "utf-8");
91398
+ fs12.writeFileSync(item.filepath, item.code, "utf-8");
90133
91399
  }
90134
91400
  for (const filepath of toDelete) {
90135
- fs11.unlinkSync(filepath.filepath);
91401
+ fs12.unlinkSync(filepath.filepath);
90136
91402
  }
90137
91403
  for (const item of toUpdate) {
90138
- fs11.writeFileSync(item.filepath, item.code, "utf-8");
91404
+ fs12.writeFileSync(item.filepath, item.code, "utf-8");
90139
91405
  }
90140
91406
  } else {
90141
91407
  console.error("light-code 同步失败", queryRes.message);
@@ -90193,8 +91459,8 @@ var initLightCode = async (opts) => {
90193
91459
  };
90194
91460
 
90195
91461
  // src/module/assistant/local-app-manager/assistant-app-resolve.ts
90196
- import path11 from "node:path";
90197
- import fs12 from "node:fs";
91462
+ import path12 from "node:path";
91463
+ import fs13 from "node:fs";
90198
91464
 
90199
91465
  class ModuleResolver {
90200
91466
  root;
@@ -90203,33 +91469,33 @@ class ModuleResolver {
90203
91469
  this.root = root2;
90204
91470
  }
90205
91471
  resolve(routePath) {
90206
- if (path11.isAbsolute(routePath)) {
91472
+ if (path12.isAbsolute(routePath)) {
90207
91473
  return routePath;
90208
91474
  }
90209
91475
  if (routePath.startsWith("@")) {
90210
91476
  return this.resolveScopedPackage(routePath);
90211
91477
  }
90212
91478
  if (!routePath.startsWith(".") && !routePath.startsWith("/")) {
90213
- const pkgPath = path11.join(this.root, "node_modules", routePath);
91479
+ const pkgPath = path12.join(this.root, "node_modules", routePath);
90214
91480
  if (this.fileIsExists(pkgPath)) {
90215
91481
  return pkgPath;
90216
91482
  }
90217
91483
  }
90218
- const localFullPath = path11.resolve(this.root, routePath);
91484
+ const localFullPath = path12.resolve(this.root, routePath);
90219
91485
  return this.fileIsExists(localFullPath) ? localFullPath : routePath;
90220
91486
  }
90221
91487
  resolveScopedPackage(routePath) {
90222
91488
  const parts = routePath.split("/");
90223
91489
  const pkgName = parts.slice(0, 2).join("/");
90224
91490
  const subPath = parts.slice(2).join("/");
90225
- const pkgPath = path11.join(this.root, "node_modules", pkgName);
90226
- const pkgJsonPath = path11.join(pkgPath, "package.json");
91491
+ const pkgPath = path12.join(this.root, "node_modules", pkgName);
91492
+ const pkgJsonPath = path12.join(pkgPath, "package.json");
90227
91493
  const pkg = this.readPackageJson(pkgJsonPath);
90228
91494
  if (!pkg) {
90229
91495
  return routePath;
90230
91496
  }
90231
91497
  const entryPath = this.resolvePackageExport(pkg, subPath);
90232
- return path11.join(pkgPath, entryPath);
91498
+ return path12.join(pkgPath, entryPath);
90233
91499
  }
90234
91500
  resolvePackageExport(pkg, subPath) {
90235
91501
  const exportsField = pkg.exports;
@@ -90248,11 +91514,11 @@ class ModuleResolver {
90248
91514
  readPackageJson(pkgJsonPath) {
90249
91515
  try {
90250
91516
  const cached2 = this.pkgCache.get(pkgJsonPath);
90251
- const stats = fs12.statSync(pkgJsonPath);
91517
+ const stats = fs13.statSync(pkgJsonPath);
90252
91518
  if (cached2 && cached2.mtime === stats.mtimeMs) {
90253
91519
  return cached2.pkg;
90254
91520
  }
90255
- const pkg = JSON.parse(fs12.readFileSync(pkgJsonPath, "utf-8"));
91521
+ const pkg = JSON.parse(fs13.readFileSync(pkgJsonPath, "utf-8"));
90256
91522
  this.pkgCache.set(pkgJsonPath, { pkg, mtime: stats.mtimeMs });
90257
91523
  return pkg;
90258
91524
  } catch {
@@ -90261,7 +91527,7 @@ class ModuleResolver {
90261
91527
  }
90262
91528
  fileIsExists(filepath) {
90263
91529
  try {
90264
- fs12.accessSync(filepath, fs12.constants.F_OK);
91530
+ fs13.accessSync(filepath, fs13.constants.F_OK);
90265
91531
  return true;
90266
91532
  } catch {
90267
91533
  return false;
@@ -90283,10 +91549,10 @@ class AssistantApp extends Manager2 {
90283
91549
  resolver;
90284
91550
  constructor(config2, mainApp) {
90285
91551
  config2.checkMounted();
90286
- const appsPath = config2?.configPath?.appsDir || path12.join(process.cwd(), "apps");
90287
- const pagesPath = config2?.configPath?.pagesDir || path12.join(process.cwd(), "pages");
91552
+ const appsPath = config2?.configPath?.appsDir || path13.join(process.cwd(), "apps");
91553
+ const pagesPath = config2?.configPath?.pagesDir || path13.join(process.cwd(), "pages");
90288
91554
  const appsConfigPath = config2.configPath?.appsConfigPath;
90289
- const configFimename = path12.basename(appsConfigPath || "");
91555
+ const configFimename = path13.basename(appsConfigPath || "");
90290
91556
  super({
90291
91557
  appsPath,
90292
91558
  configFilename: configFimename,
@@ -90303,7 +91569,7 @@ class AssistantApp extends Manager2 {
90303
91569
  });
90304
91570
  const pagesParse = pages.map((page) => {
90305
91571
  const [user, app] = page.split("/");
90306
- const contentStr = fs13.readFileSync(path12.join(this.pagesPath, page), "utf-8");
91572
+ const contentStr = fs14.readFileSync(path13.join(this.pagesPath, page), "utf-8");
90307
91573
  const content = parseIfJson2(contentStr);
90308
91574
  return {
90309
91575
  user,
@@ -90326,7 +91592,7 @@ class AssistantApp extends Manager2 {
90326
91592
  });
90327
91593
  const pagesParse = pages.map((page) => {
90328
91594
  const relativePath = page;
90329
- const contentStr = fs13.readFileSync(path12.join(root2, page), "utf-8");
91595
+ const contentStr = fs14.readFileSync(path13.join(root2, page), "utf-8");
90330
91596
  const content = parseIfJson2(contentStr);
90331
91597
  if (!content.appType) {
90332
91598
  const isWeb = relativePath.startsWith("pages/");
@@ -90431,7 +91697,7 @@ class AssistantApp extends Manager2 {
90431
91697
  console.warn("路由的api地址不能为空", proxyInfo.router);
90432
91698
  continue;
90433
91699
  }
90434
- const query = new Query({ url: url3 });
91700
+ const query = new Query2({ url: url3 });
90435
91701
  try {
90436
91702
  initApi({
90437
91703
  router: this.mainApp,
@@ -90487,13 +91753,13 @@ class AssistantApp extends Manager2 {
90487
91753
  }
90488
91754
  }
90489
91755
  // ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query.js
90490
- var isTextForContentType2 = (contentType) => {
91756
+ var isTextForContentType3 = (contentType) => {
90491
91757
  if (!contentType)
90492
91758
  return false;
90493
91759
  const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
90494
91760
  return textTypes.some((type) => contentType.includes(type));
90495
91761
  };
90496
- var adapter2 = async (opts = {}, overloadOpts) => {
91762
+ var adapter3 = async (opts = {}, overloadOpts) => {
90497
91763
  const controller = new AbortController;
90498
91764
  const signal = controller.signal;
90499
91765
  const isPostFile = opts.isPostFile || false;
@@ -90562,7 +91828,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
90562
91828
  const isJson = contentType && contentType.includes("application/json");
90563
91829
  if (isJson && !isText) {
90564
91830
  return await response.json();
90565
- } else if (isTextForContentType2(contentType)) {
91831
+ } else if (isTextForContentType3(contentType)) {
90566
91832
  return {
90567
91833
  code: response.status,
90568
91834
  status: response.status,
@@ -90586,7 +91852,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
90586
91852
  clearTimeout(timer);
90587
91853
  });
90588
91854
  };
90589
- var wrapperError2 = ({ code, message }) => {
91855
+ var wrapperError3 = ({ code, message }) => {
90590
91856
  const result = {
90591
91857
  code: code || 500,
90592
91858
  success: false,
@@ -90597,7 +91863,7 @@ var wrapperError2 = ({ code, message }) => {
90597
91863
  return result;
90598
91864
  };
90599
91865
 
90600
- class Query2 {
91866
+ class Query3 {
90601
91867
  adapter;
90602
91868
  url;
90603
91869
  beforeRequest;
@@ -90608,7 +91874,7 @@ class Query2 {
90608
91874
  qws;
90609
91875
  isClient = false;
90610
91876
  constructor(opts) {
90611
- this.adapter = opts?.adapter || adapter2;
91877
+ this.adapter = opts?.adapter || adapter3;
90612
91878
  const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
90613
91879
  this.url = opts?.url || defaultURL;
90614
91880
  this.headers = opts?.headers || {
@@ -90641,9 +91907,9 @@ class Query2 {
90641
91907
  }
90642
91908
  async post(body, options) {
90643
91909
  const url3 = options?.url || this.url;
90644
- const { headers, adapter: adapter3, beforeRequest, afterResponse, timeout, ...rest } = options || {};
91910
+ const { headers, adapter: adapter4, beforeRequest, afterResponse, timeout, ...rest } = options || {};
90645
91911
  const _headers = { ...this.headers, ...headers };
90646
- const _adapter = adapter3 || this.adapter;
91912
+ const _adapter = adapter4 || this.adapter;
90647
91913
  const _beforeRequest = beforeRequest || this.beforeRequest;
90648
91914
  const _afterResponse = afterResponse || this.afterResponse;
90649
91915
  const _timeout = timeout || this.timeout;
@@ -90658,7 +91924,7 @@ class Query2 {
90658
91924
  if (_beforeRequest) {
90659
91925
  const res = await _beforeRequest(req);
90660
91926
  if (res === false) {
90661
- return wrapperError2({
91927
+ return wrapperError3({
90662
91928
  code: 500,
90663
91929
  message: "request is cancel",
90664
91930
  req
@@ -90667,7 +91933,7 @@ class Query2 {
90667
91933
  }
90668
91934
  } catch (e) {
90669
91935
  console.error("request beforeFn error", e, req);
90670
- return wrapperError2({
91936
+ return wrapperError3({
90671
91937
  code: 500,
90672
91938
  message: "api request beforeFn error"
90673
91939
  });
@@ -90694,13 +91960,13 @@ class Query2 {
90694
91960
  return await _afterResponse(res, {
90695
91961
  req,
90696
91962
  res,
90697
- fetch: adapter3
91963
+ fetch: adapter4
90698
91964
  });
90699
91965
  }
90700
91966
  return res;
90701
91967
  } catch (e) {
90702
91968
  console.error("request afterFn error", e, req);
90703
- return wrapperError2({
91969
+ return wrapperError3({
90704
91970
  code: 500,
90705
91971
  message: "api request afterFn error"
90706
91972
  });
@@ -90721,7 +91987,7 @@ class Query2 {
90721
91987
  if (typeof urlOrOptions === "object") {
90722
91988
  _options = { ...urlOrOptions, ..._options };
90723
91989
  }
90724
- const res = await adapter2({
91990
+ const res = await adapter3({
90725
91991
  method: "GET",
90726
91992
  ..._options,
90727
91993
  headers: {
@@ -90746,7 +92012,7 @@ class AssistantQuery {
90746
92012
  constructor(config2) {
90747
92013
  config2.checkMounted();
90748
92014
  this.config = config2;
90749
- this.query = new Query2({ url: config2.getRegistry() + "/api/router" });
92015
+ this.query = new Query3({ url: config2.getRegistry() + "/api/router" });
90750
92016
  }
90751
92017
  post(body, options) {
90752
92018
  return this.query.post(body, options);
@@ -91333,18 +92599,18 @@ class AssistantInit extends AssistantConfig {
91333
92599
  return `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`;
91334
92600
  }
91335
92601
  setQuery(query2) {
91336
- this.#query = query2 || new Query2({
92602
+ this.#query = query2 || new Query3({
91337
92603
  url: `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`
91338
92604
  });
91339
92605
  }
91340
92606
  checkConfigPath() {
91341
- const assistantPath = path13.join(this.configDir, "assistant-app", "assistant-config.json");
92607
+ const assistantPath = path14.join(this.configDir, "assistant-app", "assistant-config.json");
91342
92608
  return checkFileExists(assistantPath);
91343
92609
  }
91344
92610
  createEnvConfig() {
91345
92611
  const env3 = this.configPath?.envConfigPath;
91346
92612
  if (!checkFileExists(env3, true)) {
91347
- fs14.writeFileSync(env3, `# 环境配置文件
92613
+ fs15.writeFileSync(env3, `# 环境配置文件
91348
92614
  `);
91349
92615
  console.log(chalk2.green("助手环境配置.env文件创建成功"));
91350
92616
  }
@@ -91352,7 +92618,7 @@ class AssistantInit extends AssistantConfig {
91352
92618
  createOtherConfig() {
91353
92619
  const appsConfig = this.configPath?.appsConfigPath;
91354
92620
  if (!checkFileExists(appsConfig, true)) {
91355
- fs14.writeFileSync(appsConfig, JSON.stringify({ description: "apps manager.", list: [] }));
92621
+ fs15.writeFileSync(appsConfig, JSON.stringify({ description: "apps manager.", list: [] }));
91356
92622
  console.log(chalk2.green("助手应用配置文件 apps.json 创建成功"));
91357
92623
  }
91358
92624
  }
@@ -91374,20 +92640,20 @@ class AssistantInit extends AssistantConfig {
91374
92640
  }
91375
92641
  }
91376
92642
  initPnpm() {
91377
- const pnpmPath = path13.join(this.configDir, "assistant-app", "pnpm-workspace.yaml");
92643
+ const pnpmPath = path14.join(this.configDir, "assistant-app", "pnpm-workspace.yaml");
91378
92644
  let create = false;
91379
92645
  if (!checkFileExists(pnpmPath, true)) {
91380
92646
  create = true;
91381
- fs14.writeFileSync(pnpmPath, `packages:
92647
+ fs15.writeFileSync(pnpmPath, `packages:
91382
92648
  - 'apps/**/*'
91383
92649
  - 'pages/**/*'
91384
92650
  `);
91385
92651
  console.log(chalk2.green("助手 pnpm-workspace.yaml 文件创建成功"));
91386
92652
  }
91387
- const packagePath = path13.join(this.configDir, "assistant-app", "package.json");
92653
+ const packagePath = path14.join(this.configDir, "assistant-app", "package.json");
91388
92654
  if (!checkFileExists(packagePath, true)) {
91389
92655
  create = true;
91390
- fs14.writeFileSync(packagePath, `{
92656
+ fs15.writeFileSync(packagePath, `{
91391
92657
  "name": "assistant-app",
91392
92658
  "version": "1.0.0",
91393
92659
  "description": "assistant-app package pnpm, node pkgs projects",
@@ -91429,7 +92695,7 @@ class AssistantInit extends AssistantConfig {
91429
92695
  }
91430
92696
  `);
91431
92697
  console.log(chalk2.green("助手 package.json 文件创建成功, 正在安装依赖..."));
91432
- installDeps({ appPath: path13.dirname(packagePath), isProduction: true }).then(() => {
92698
+ installDeps({ appPath: path14.dirname(packagePath), isProduction: true }).then(() => {
91433
92699
  console.log("------------------------------------------------");
91434
92700
  console.log(chalk2.green("助手依赖安装完成"));
91435
92701
  console.log("------------------------------------------------");
@@ -91440,10 +92706,10 @@ class AssistantInit extends AssistantConfig {
91440
92706
  };
91441
92707
  }
91442
92708
  initIgnore() {
91443
- const gitignorePath = path13.join(this.configDir, ".gitignore");
92709
+ const gitignorePath = path14.join(this.configDir, ".gitignore");
91444
92710
  let content = "";
91445
92711
  if (checkFileExists(gitignorePath, true)) {
91446
- content = fs14.readFileSync(gitignorePath, "utf-8");
92712
+ content = fs15.readFileSync(gitignorePath, "utf-8");
91447
92713
  }
91448
92714
  const ignoreLines = [
91449
92715
  "node_modules",
@@ -91469,7 +92735,7 @@ ${line}`;
91469
92735
  }
91470
92736
  });
91471
92737
  if (updated) {
91472
- fs14.writeFileSync(gitignorePath, content.trim() + `
92738
+ fs15.writeFileSync(gitignorePath, content.trim() + `
91473
92739
  `);
91474
92740
  console.log(chalk2.green(".gitignore 文件更新成功"));
91475
92741
  }
@@ -91498,24 +92764,24 @@ var manualParse = parseHomeArg(configDir);
91498
92764
  var _configDir = manualParse.configDir;
91499
92765
  var configDir2 = AssistantInit.detectConfigDir(_configDir);
91500
92766
  var isInit = manualParse?.options?.help ? false : true;
91501
- var assistantConfig2 = useContextKey2("assistantConfig", () => {
92767
+ var assistantConfig2 = useContextKey3("assistantConfig", () => {
91502
92768
  return new AssistantInit({
91503
92769
  path: configDir2,
91504
92770
  init: isInit,
91505
92771
  initWorkspace: manualParse.isOpencode ? false : true
91506
92772
  });
91507
92773
  });
91508
- var assistantQuery = useContextKey2("assistantQuery", () => {
92774
+ var assistantQuery = useContextKey3("assistantQuery", () => {
91509
92775
  return new AssistantQuery(assistantConfig2);
91510
92776
  });
91511
- var runtime = useContextKey2("runtime", () => {
92777
+ var runtime = useContextKey3("runtime", () => {
91512
92778
  console.log("Runtime detected:", manualParse);
91513
92779
  return {
91514
92780
  type: "client",
91515
92781
  isServer: manualParse.isServer
91516
92782
  };
91517
92783
  });
91518
- var app = useContextKey2("app", () => {
92784
+ var app = useContextKey3("app", () => {
91519
92785
  return new App({
91520
92786
  serverOptions: {
91521
92787
  path: "/client/router",
@@ -91527,7 +92793,7 @@ var app = useContextKey2("app", () => {
91527
92793
  }
91528
92794
  });
91529
92795
  });
91530
- var simpleRouter = useContextKey2("simpleRouter", () => {
92796
+ var simpleRouter = useContextKey3("simpleRouter", () => {
91531
92797
  return new SimpleRouter;
91532
92798
  });
91533
92799
  app.route({
@@ -91544,15 +92810,15 @@ app.route({
91544
92810
  }).addTo(app);
91545
92811
 
91546
92812
  // src/module/local-proxy/index.ts
91547
- import fs16 from "node:fs";
92813
+ import fs17 from "node:fs";
91548
92814
 
91549
92815
  // src/module/local-proxy/file.ts
91550
- import fs15 from "node:fs";
92816
+ import fs16 from "node:fs";
91551
92817
  var checkFileExists2 = (filePath, checkIsFile = false) => {
91552
92818
  try {
91553
- fs15.accessSync(filePath);
92819
+ fs16.accessSync(filePath);
91554
92820
  if (checkIsFile) {
91555
- return fs15.statSync(filePath).isFile();
92821
+ return fs16.statSync(filePath).isFile();
91556
92822
  }
91557
92823
  return true;
91558
92824
  } catch (error3) {
@@ -91561,7 +92827,7 @@ var checkFileExists2 = (filePath, checkIsFile = false) => {
91561
92827
  };
91562
92828
 
91563
92829
  // src/module/local-proxy/index.ts
91564
- import path14 from "node:path";
92830
+ import path15 from "node:path";
91565
92831
 
91566
92832
  class LocalProxy {
91567
92833
  localProxyProxyList = [];
@@ -91596,19 +92862,19 @@ class LocalProxy {
91596
92862
  return;
91597
92863
  }
91598
92864
  if (!checkFileExists2(frontAppDir)) {
91599
- fs16.mkdirSync(frontAppDir, { recursive: true });
92865
+ fs17.mkdirSync(frontAppDir, { recursive: true });
91600
92866
  }
91601
92867
  this.initing = true;
91602
- const userList = fs16.readdirSync(frontAppDir);
92868
+ const userList = fs17.readdirSync(frontAppDir);
91603
92869
  const localProxyProxyList = [];
91604
92870
  userList.forEach((user) => {
91605
- const userPath = path14.join(frontAppDir, user);
91606
- const stat = fs16.statSync(userPath);
92871
+ const userPath = path15.join(frontAppDir, user);
92872
+ const stat = fs17.statSync(userPath);
91607
92873
  if (stat.isDirectory()) {
91608
- const appList = fs16.readdirSync(userPath);
92874
+ const appList = fs17.readdirSync(userPath);
91609
92875
  appList.forEach((app2) => {
91610
- const appPath = path14.join(userPath, app2);
91611
- const indexPath = path14.join(appPath, "index.html");
92876
+ const appPath = path15.join(userPath, app2);
92877
+ const indexPath = path15.join(appPath, "index.html");
91612
92878
  if (!checkFileExists2(indexPath, true)) {
91613
92879
  return;
91614
92880
  }
@@ -91649,7 +92915,7 @@ class LocalProxy {
91649
92915
  fn();
91650
92916
  }, delay);
91651
92917
  };
91652
- fs16.watch(frontAppDir, { recursive: true }, (eventType, filename) => {
92918
+ fs17.watch(frontAppDir, { recursive: true }, (eventType, filename) => {
91653
92919
  if (eventType === "rename" || eventType === "change") {
91654
92920
  if (filename && filename.includes("node_modules")) {
91655
92921
  return;
@@ -91659,9 +92925,9 @@ class LocalProxy {
91659
92925
  if (!hasValidExtension) {
91660
92926
  return;
91661
92927
  }
91662
- const filePath = path14.join(frontAppDir, filename);
92928
+ const filePath = path15.join(frontAppDir, filename);
91663
92929
  try {
91664
- const stat = fs16.statSync(filePath);
92930
+ const stat = fs17.statSync(filePath);
91665
92931
  if (stat.isFile() || stat.isDirectory()) {
91666
92932
  debounce(that.init.bind(that), 5 * 1000);
91667
92933
  }
@@ -91729,8 +92995,8 @@ app.route({
91729
92995
  }).addTo(app);
91730
92996
 
91731
92997
  // src/services/app/index.ts
91732
- import path15 from "path";
91733
- import fs17 from "fs";
92998
+ import path16 from "path";
92999
+ import fs18 from "fs";
91734
93000
 
91735
93001
  // ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.1.0/node_modules/@inquirer/core/dist/lib/key.js
91736
93002
  var isTabKey = (key) => key.name === "tab";
@@ -93220,7 +94486,7 @@ class AppDownload {
93220
94486
  if (type === "web") {
93221
94487
  args2.push("-o", pagesDir);
93222
94488
  } else if (type === "app") {
93223
- args2.push("-o", path15.join(appsDir));
94489
+ args2.push("-o", path16.join(appsDir));
93224
94490
  } else {
93225
94491
  throw new Error("应用类型错误,只能是 web 或 app");
93226
94492
  }
@@ -93253,10 +94519,10 @@ class AppDownload {
93253
94519
  let deletePath = "";
93254
94520
  let isDelete = false;
93255
94521
  if (type === "web") {
93256
- const pagePath = path15.join(pagesDir, id2);
94522
+ const pagePath = path16.join(pagesDir, id2);
93257
94523
  deletePath = pagePath;
93258
94524
  } else if (type === "app") {
93259
- const appPath = path15.join(appsDir, id2);
94525
+ const appPath = path16.join(appsDir, id2);
93260
94526
  deletePath = appPath;
93261
94527
  }
93262
94528
  if (deletePath && checkFileExists(deletePath)) {
@@ -93267,7 +94533,7 @@ class AppDownload {
93267
94533
  return;
93268
94534
  }
93269
94535
  }
93270
- fs17.rmSync(deletePath, { recursive: true });
94536
+ fs18.rmSync(deletePath, { recursive: true });
93271
94537
  isDelete = true;
93272
94538
  console.log(`删除应用成功: ${deletePath}`);
93273
94539
  }
@@ -93344,18 +94610,18 @@ app.route({
93344
94610
  }).addTo(app);
93345
94611
 
93346
94612
  // ../node_modules/.pnpm/@kevisual+ai@0.0.24/node_modules/@kevisual/ai/dist/ai-provider-browser.js
93347
- var __create3 = Object.create;
93348
- var __getProtoOf3 = Object.getPrototypeOf;
93349
- var __defProp3 = Object.defineProperty;
93350
- var __getOwnPropNames3 = Object.getOwnPropertyNames;
94613
+ var __create4 = Object.create;
94614
+ var __getProtoOf4 = Object.getPrototypeOf;
94615
+ var __defProp4 = Object.defineProperty;
94616
+ var __getOwnPropNames4 = Object.getOwnPropertyNames;
93351
94617
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
93352
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
93353
- var __toESM3 = (mod, isNodeMode, target) => {
93354
- target = mod != null ? __create3(__getProtoOf3(mod)) : {};
93355
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target;
93356
- for (let key of __getOwnPropNames3(mod))
93357
- if (!__hasOwnProp3.call(to, key))
93358
- __defProp3(to, key, {
94618
+ var __hasOwnProp4 = Object.prototype.hasOwnProperty;
94619
+ var __toESM4 = (mod, isNodeMode, target) => {
94620
+ target = mod != null ? __create4(__getProtoOf4(mod)) : {};
94621
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp4(target, "default", { value: mod, enumerable: true }) : target;
94622
+ for (let key of __getOwnPropNames4(mod))
94623
+ if (!__hasOwnProp4.call(to, key))
94624
+ __defProp4(to, key, {
93359
94625
  get: () => mod[key],
93360
94626
  enumerable: true
93361
94627
  });
@@ -93366,19 +94632,19 @@ var __toCommonJS2 = (from) => {
93366
94632
  var entry2 = __moduleCache2.get(from), desc;
93367
94633
  if (entry2)
93368
94634
  return entry2;
93369
- entry2 = __defProp3({}, "__esModule", { value: true });
94635
+ entry2 = __defProp4({}, "__esModule", { value: true });
93370
94636
  if (from && typeof from === "object" || typeof from === "function")
93371
- __getOwnPropNames3(from).map((key) => !__hasOwnProp3.call(entry2, key) && __defProp3(entry2, key, {
94637
+ __getOwnPropNames4(from).map((key) => !__hasOwnProp4.call(entry2, key) && __defProp4(entry2, key, {
93372
94638
  get: () => from[key],
93373
94639
  enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
93374
94640
  }));
93375
94641
  __moduleCache2.set(from, entry2);
93376
94642
  return entry2;
93377
94643
  };
93378
- var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
94644
+ var __commonJS4 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
93379
94645
  var __export2 = (target, all) => {
93380
94646
  for (var name in all)
93381
- __defProp3(target, name, {
94647
+ __defProp4(target, name, {
93382
94648
  get: all[name],
93383
94649
  enumerable: true,
93384
94650
  configurable: true,
@@ -95165,13 +96431,13 @@ __export2(exports_events, {
95165
96431
  setMaxListeners: () => setMaxListeners2,
95166
96432
  once: () => once2,
95167
96433
  listenerCount: () => listenerCount2,
95168
- init: () => EventEmitter5,
96434
+ init: () => EventEmitter6,
95169
96435
  getMaxListeners: () => getMaxListeners2,
95170
96436
  getEventListeners: () => getEventListeners,
95171
96437
  default: () => events_default,
95172
96438
  captureRejectionSymbol: () => captureRejectionSymbol,
95173
96439
  addAbortListener: () => addAbortListener,
95174
- EventEmitter: () => EventEmitter5
96440
+ EventEmitter: () => EventEmitter6
95175
96441
  });
95176
96442
  function emitError(emitter, args2) {
95177
96443
  var { _events: events } = emitter;
@@ -95319,7 +96585,7 @@ var kRejection;
95319
96585
  var captureRejectionSymbol;
95320
96586
  var ArrayPrototypeSlice;
95321
96587
  var defaultMaxListeners = 10;
95322
- var EventEmitter5 = function(opts) {
96588
+ var EventEmitter6 = function(opts) {
95323
96589
  if (this._events === undefined || this._events === this.__proto__._events)
95324
96590
  this._events = { __proto__: null }, this._eventsCount = 0;
95325
96591
  if (this._maxListeners ??= undefined, this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture])
@@ -95403,14 +96669,14 @@ var init_events = __esm2(() => {
95403
96669
  kRejection = SymbolFor("nodejs.rejection");
95404
96670
  captureRejectionSymbol = SymbolFor("nodejs.rejection");
95405
96671
  ArrayPrototypeSlice = Array.prototype.slice;
95406
- EventEmitterPrototype = EventEmitter5.prototype = {};
96672
+ EventEmitterPrototype = EventEmitter6.prototype = {};
95407
96673
  EventEmitterPrototype._events = undefined;
95408
96674
  EventEmitterPrototype._eventsCount = 0;
95409
96675
  EventEmitterPrototype._maxListeners = undefined;
95410
96676
  EventEmitterPrototype.setMaxListeners = function(n) {
95411
96677
  return validateNumber2(n, "setMaxListeners", 0), this._maxListeners = n, this;
95412
96678
  };
95413
- EventEmitterPrototype.constructor = EventEmitter5;
96679
+ EventEmitterPrototype.constructor = EventEmitter6;
95414
96680
  EventEmitterPrototype.getMaxListeners = function() {
95415
96681
  return this?._maxListeners ?? defaultMaxListeners;
95416
96682
  };
@@ -95533,7 +96799,7 @@ var init_events = __esm2(() => {
95533
96799
  this.code = "ABORT_ERR", this.name = "AbortError";
95534
96800
  }
95535
96801
  };
95536
- Object.defineProperties(EventEmitter5, { captureRejections: { get() {
96802
+ Object.defineProperties(EventEmitter6, { captureRejections: { get() {
95537
96803
  return EventEmitterPrototype[kCapture];
95538
96804
  }, set(value) {
95539
96805
  validateBoolean(value, "EventEmitter.captureRejections"), EventEmitterPrototype[kCapture] = value;
@@ -95542,10 +96808,10 @@ var init_events = __esm2(() => {
95542
96808
  }, set: (arg) => {
95543
96809
  validateNumber2(arg, "defaultMaxListeners", 0), defaultMaxListeners = arg;
95544
96810
  } }, kMaxEventTargetListeners: { value: kMaxEventTargetListeners, enumerable: false, configurable: false, writable: false }, kMaxEventTargetListenersWarned: { value: kMaxEventTargetListenersWarned, enumerable: false, configurable: false, writable: false } });
95545
- Object.assign(EventEmitter5, { once: once2, getEventListeners, getMaxListeners: getMaxListeners2, setMaxListeners: setMaxListeners2, EventEmitter: EventEmitter5, usingDomains: false, captureRejectionSymbol, errorMonitor: kErrorMonitor, addAbortListener, init: EventEmitter5, listenerCount: listenerCount2 });
95546
- events_default = EventEmitter5;
96811
+ Object.assign(EventEmitter6, { once: once2, getEventListeners, getMaxListeners: getMaxListeners2, setMaxListeners: setMaxListeners2, EventEmitter: EventEmitter6, usingDomains: false, captureRejectionSymbol, errorMonitor: kErrorMonitor, addAbortListener, init: EventEmitter6, listenerCount: listenerCount2 });
96812
+ events_default = EventEmitter6;
95547
96813
  });
95548
- var require_stream5 = __commonJS3((exports, module) => {
96814
+ var require_stream5 = __commonJS4((exports, module) => {
95549
96815
  var __commonJS22 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
95550
96816
  var require_primordials = __commonJS22((exports2, module2) => {
95551
96817
 
@@ -99594,7 +100860,7 @@ var require_pbkdf2;
99594
100860
  var require_browserify_cipher;
99595
100861
  var require_diffie_hellman;
99596
100862
  var require_browserify_sign;
99597
- var require_package6;
100863
+ var require_package7;
99598
100864
  var require_bn;
99599
100865
  var require_minimalistic_assert;
99600
100866
  var require_utils5;
@@ -100628,7 +101894,7 @@ var init_crypto = __esm2(() => {
100628
101894
  exports.createVerify = crypto22.createVerify;
100629
101895
  exports.Verify = crypto22.Verify;
100630
101896
  });
100631
- require_package6 = __commonJS22((exports, module) => {
101897
+ require_package7 = __commonJS22((exports, module) => {
100632
101898
  module.exports = { name: "elliptic", version: "6.6.1", description: "EC cryptography", main: "lib/elliptic.js", files: ["lib"], scripts: { lint: "eslint lib test", "lint:fix": "npm run lint -- --fix", unit: "istanbul test _mocha --reporter=spec test/index.js", test: "npm run lint && npm run unit", version: "grunt dist && git add dist/" }, repository: { type: "git", url: "git@github.com:indutny/elliptic" }, keywords: ["EC", "Elliptic", "curve", "Cryptography"], author: "Fedor Indutny <fedor@indutny.com>", license: "MIT", bugs: { url: "https://github.com/indutny/elliptic/issues" }, homepage: "https://github.com/indutny/elliptic", devDependencies: { brfs: "^2.0.2", coveralls: "^3.1.0", eslint: "^7.6.0", grunt: "^1.2.1", "grunt-browserify": "^5.3.0", "grunt-cli": "^1.3.2", "grunt-contrib-connect": "^3.0.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-uglify": "^5.0.0", "grunt-mocha-istanbul": "^5.0.2", "grunt-saucelabs": "^9.0.1", istanbul: "^0.4.5", mocha: "^8.0.1" }, dependencies: { "bn.js": "^4.11.9", brorand: "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", inherits: "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } };
100633
101899
  });
100634
101900
  require_bn = __commonJS22((exports, module) => {
@@ -104298,7 +105564,7 @@ var init_crypto = __esm2(() => {
104298
105564
  });
104299
105565
  require_elliptic = __commonJS22((exports) => {
104300
105566
  var elliptic = exports;
104301
- elliptic.version = require_package6().version;
105567
+ elliptic.version = require_package7().version;
104302
105568
  elliptic.utils = require_utils22();
104303
105569
  elliptic.rand = require_brorand();
104304
105570
  elliptic.curve = require_curve();
@@ -107268,8 +108534,8 @@ var init_crypto = __esm2(() => {
107268
108534
  return result;
107269
108535
  return { result: this.isError(result) ? null : result, errors: state.errors };
107270
108536
  };
107271
- function ReporterError(path16, msg) {
107272
- this.path = path16, this.rethrow(msg);
108537
+ function ReporterError(path17, msg) {
108538
+ this.path = path17, this.rethrow(msg);
107273
108539
  }
107274
108540
  inherits2(ReporterError, Error);
107275
108541
  ReporterError.prototype.rethrow = function(msg) {
@@ -111700,7 +112966,7 @@ https://github.com/browserify/crypto-browserify`);
111700
112966
  webcrypto2 = crypto;
111701
112967
  crypto_default = crypto;
111702
112968
  });
111703
- var require_core = __commonJS3((exports, module) => {
112969
+ var require_core = __commonJS4((exports, module) => {
111704
112970
  (function(root2, factory) {
111705
112971
  if (typeof exports === "object") {
111706
112972
  module.exports = exports = factory();
@@ -111983,7 +113249,7 @@ var require_core = __commonJS3((exports, module) => {
111983
113249
  return CryptoJS;
111984
113250
  });
111985
113251
  });
111986
- var require_enc_base64 = __commonJS3((exports, module) => {
113252
+ var require_enc_base64 = __commonJS4((exports, module) => {
111987
113253
  (function(root2, factory) {
111988
113254
  if (typeof exports === "object") {
111989
113255
  module.exports = exports = factory(require_core());
@@ -112061,7 +113327,7 @@ var require_enc_base64 = __commonJS3((exports, module) => {
112061
113327
  return CryptoJS.enc.Base64;
112062
113328
  });
112063
113329
  });
112064
- var require_md52 = __commonJS3((exports, module) => {
113330
+ var require_md52 = __commonJS4((exports, module) => {
112065
113331
  (function(root2, factory) {
112066
113332
  if (typeof exports === "object") {
112067
113333
  module.exports = exports = factory(require_core());
@@ -112236,7 +113502,7 @@ var require_md52 = __commonJS3((exports, module) => {
112236
113502
  return CryptoJS.MD5;
112237
113503
  });
112238
113504
  });
112239
- var require_sha1 = __commonJS3((exports, module) => {
113505
+ var require_sha1 = __commonJS4((exports, module) => {
112240
113506
  (function(root2, factory) {
112241
113507
  if (typeof exports === "object") {
112242
113508
  module.exports = exports = factory(require_core());
@@ -112323,7 +113589,7 @@ var require_sha1 = __commonJS3((exports, module) => {
112323
113589
  return CryptoJS.SHA1;
112324
113590
  });
112325
113591
  });
112326
- var require_hmac2 = __commonJS3((exports, module) => {
113592
+ var require_hmac2 = __commonJS4((exports, module) => {
112327
113593
  (function(root2, factory) {
112328
113594
  if (typeof exports === "object") {
112329
113595
  module.exports = exports = factory(require_core());
@@ -112383,7 +113649,7 @@ var require_hmac2 = __commonJS3((exports, module) => {
112383
113649
  })();
112384
113650
  });
112385
113651
  });
112386
- var require_evpkdf = __commonJS3((exports, module) => {
113652
+ var require_evpkdf = __commonJS4((exports, module) => {
112387
113653
  (function(root2, factory, undef) {
112388
113654
  if (typeof exports === "object") {
112389
113655
  module.exports = exports = factory(require_core(), require_sha1(), require_hmac2());
@@ -112440,7 +113706,7 @@ var require_evpkdf = __commonJS3((exports, module) => {
112440
113706
  return CryptoJS.EvpKDF;
112441
113707
  });
112442
113708
  });
112443
- var require_cipher_core = __commonJS3((exports, module) => {
113709
+ var require_cipher_core = __commonJS4((exports, module) => {
112444
113710
  (function(root2, factory, undef) {
112445
113711
  if (typeof exports === "object") {
112446
113712
  module.exports = exports = factory(require_core(), require_evpkdf());
@@ -112736,7 +114002,7 @@ var require_cipher_core = __commonJS3((exports, module) => {
112736
114002
  }();
112737
114003
  });
112738
114004
  });
112739
- var require_aes = __commonJS3((exports, module) => {
114005
+ var require_aes = __commonJS4((exports, module) => {
112740
114006
  (function(root2, factory, undef) {
112741
114007
  if (typeof exports === "object") {
112742
114008
  module.exports = exports = factory(require_core(), require_enc_base64(), require_md52(), require_evpkdf(), require_cipher_core());
@@ -112886,7 +114152,7 @@ var require_aes = __commonJS3((exports, module) => {
112886
114152
  return CryptoJS.AES;
112887
114153
  });
112888
114154
  });
112889
- var require_enc_utf8 = __commonJS3((exports, module) => {
114155
+ var require_enc_utf8 = __commonJS4((exports, module) => {
112890
114156
  (function(root2, factory) {
112891
114157
  if (typeof exports === "object") {
112892
114158
  module.exports = exports = factory(require_core());
@@ -113318,13 +114584,13 @@ class ProviderManager {
113318
114584
  return this.provider.chat(messages);
113319
114585
  }
113320
114586
  }
113321
- var import_aes = __toESM3(require_aes(), 1);
113322
- var import_enc_utf8 = __toESM3(require_enc_utf8(), 1);
114587
+ var import_aes = __toESM4(require_aes(), 1);
114588
+ var import_enc_utf8 = __toESM4(require_enc_utf8(), 1);
113323
114589
  var CryptoJS = { AES: import_aes.default, enc: { Utf8: import_enc_utf8.default } };
113324
114590
 
113325
114591
  // src/routes/ai/index.ts
113326
- var app2 = useContextKey2("app");
113327
- var query2 = useContextKey2("assistantQuery");
114592
+ var app2 = useContextKey3("app");
114593
+ var query2 = useContextKey3("assistantQuery");
113328
114594
  app2.route({
113329
114595
  path: "ai",
113330
114596
  key: "chat",
@@ -113455,11 +114721,11 @@ app.route({
113455
114721
  })
113456
114722
  }
113457
114723
  }).define(async (ctx) => {
113458
- const { path: path16, key = "" } = ctx.query;
113459
- if (!path16) {
114724
+ const { path: path17, key = "" } = ctx.query;
114725
+ if (!path17) {
113460
114726
  ctx.throw("路径path不能为空");
113461
114727
  }
113462
- const res = await ctx.run({ path: path16, key, payload: ctx.query.payload || {} }, {
114728
+ const res = await ctx.run({ path: path17, key, payload: ctx.query.payload || {} }, {
113463
114729
  ...ctx
113464
114730
  });
113465
114731
  ctx.forward(res);
@@ -113698,7 +114964,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
113698
114964
 
113699
114965
  // ../node_modules/.pnpm/@opencode-ai+sdk@1.1.47/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
113700
114966
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
113701
- var defaultPathSerializer = ({ path: path16, url: _url2 }) => {
114967
+ var defaultPathSerializer = ({ path: path17, url: _url2 }) => {
113702
114968
  let url3 = _url2;
113703
114969
  const matches = _url2.match(PATH_PARAM_RE);
113704
114970
  if (matches) {
@@ -113717,7 +114983,7 @@ var defaultPathSerializer = ({ path: path16, url: _url2 }) => {
113717
114983
  name = name.substring(1);
113718
114984
  style = "matrix";
113719
114985
  }
113720
- const value = path16[name];
114986
+ const value = path17[name];
113721
114987
  if (value === undefined || value === null) {
113722
114988
  continue;
113723
114989
  }
@@ -113748,11 +115014,11 @@ var defaultPathSerializer = ({ path: path16, url: _url2 }) => {
113748
115014
  }
113749
115015
  return url3;
113750
115016
  };
113751
- var getUrl = ({ baseUrl, path: path16, query: query3, querySerializer, url: _url2 }) => {
115017
+ var getUrl = ({ baseUrl, path: path17, query: query3, querySerializer, url: _url2 }) => {
113752
115018
  const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
113753
115019
  let url3 = (baseUrl ?? "") + pathUrl;
113754
- if (path16) {
113755
- url3 = defaultPathSerializer({ path: path16, url: url3 });
115020
+ if (path17) {
115021
+ url3 = defaultPathSerializer({ path: path17, url: url3 });
113756
115022
  }
113757
115023
  let search = query3 ? querySerializer(query3) : "";
113758
115024
  if (search.startsWith("?")) {
@@ -117058,8 +118324,8 @@ var createProxyInfo = (proxyApiItem) => {
117058
118324
 
117059
118325
  // src/routes-simple/upload.ts
117060
118326
  var import_busboy = __toESM(require_lib2(), 1);
117061
- import path18 from "path";
117062
- import fs20 from "fs";
118327
+ import path19 from "path";
118328
+ import fs21 from "fs";
117063
118329
 
117064
118330
  // ../node_modules/.pnpm/@kevisual+router@0.0.64_typescript@5.8.2/node_modules/@kevisual/router/src/server/cookie.ts
117065
118331
  var NullObject2 = /* @__PURE__ */ (() => {
@@ -117144,11 +118410,11 @@ var getTokenFromRequest = (req) => {
117144
118410
 
117145
118411
  // src/routes-simple/router.ts
117146
118412
  import os5 from "node:os";
117147
- import path16 from "node:path";
117148
- import fs18 from "node:fs";
117149
- var defaultCachePath = path16.join(os5.homedir(), ".envision", "cache-file");
117150
- if (!fs18.existsSync(defaultCachePath)) {
117151
- fs18.mkdirSync(defaultCachePath, { recursive: true });
118413
+ import path17 from "node:path";
118414
+ import fs19 from "node:fs";
118415
+ var defaultCachePath = path17.join(os5.homedir(), ".envision", "cache-file");
118416
+ if (!fs19.existsSync(defaultCachePath)) {
118417
+ fs19.mkdirSync(defaultCachePath, { recursive: true });
117152
118418
  }
117153
118419
  var cacheFilePath = defaultCachePath;
117154
118420
  var eventClientsInit = () => {
@@ -117215,8 +118481,8 @@ var validateDirectory = (directory) => {
117215
118481
  };
117216
118482
 
117217
118483
  // src/module/upload/mv.ts
117218
- import fs19 from "node:fs";
117219
- import path17 from "node:path";
118484
+ import fs20 from "node:fs";
118485
+ import path18 from "node:path";
117220
118486
 
117221
118487
  class UploadManager {
117222
118488
  config;
@@ -117229,12 +118495,12 @@ class UploadManager {
117229
118495
  const appsDir = this.config.configPath?.appsDir;
117230
118496
  let dir = type === "app-file" ? appsDir : pageDir;
117231
118497
  if (type === "file" || type === "app-file") {
117232
- const fullTargetPath = targetPath.startsWith("/") ? targetPath : path17.join(dir, targetPath);
118498
+ const fullTargetPath = targetPath.startsWith("/") ? targetPath : path18.join(dir, targetPath);
117233
118499
  const targetDir = fullTargetPath.substring(0, fullTargetPath.lastIndexOf("/"));
117234
- if (!fs19.existsSync(targetDir)) {
117235
- fs19.mkdirSync(targetDir, { recursive: true });
118500
+ if (!fs20.existsSync(targetDir)) {
118501
+ fs20.mkdirSync(targetDir, { recursive: true });
117236
118502
  }
117237
- fs19.renameSync(temppath, fullTargetPath);
118503
+ fs20.renameSync(temppath, fullTargetPath);
117238
118504
  return fullTargetPath;
117239
118505
  }
117240
118506
  }
@@ -117289,8 +118555,8 @@ var uploadResources = async (req, res) => {
117289
118555
  });
117290
118556
  busboy.on("file", (fieldname, fileStream, info) => {
117291
118557
  const { filename, encoding, mimeType } = info;
117292
- const tempPath = path18.join(cacheFilePath, `${Date.now()}-${Math.random().toString(36).substring(7)}`);
117293
- const writeStream = fs20.createWriteStream(tempPath);
118558
+ const tempPath = path19.join(cacheFilePath, `${Date.now()}-${Math.random().toString(36).substring(7)}`);
118559
+ const writeStream = fs21.createWriteStream(tempPath);
117294
118560
  const filePromise = new Promise((resolve, reject) => {
117295
118561
  fileStream.on("data", (chunk) => {
117296
118562
  bytesReceived += chunk.length;
@@ -117329,8 +118595,8 @@ var uploadResources = async (req, res) => {
117329
118595
  }
117330
118596
  const clearFiles = () => {
117331
118597
  files.forEach((file3) => {
117332
- if (file3?.filepath && fs20.existsSync(file3.filepath)) {
117333
- fs20.unlinkSync(file3.filepath);
118598
+ if (file3?.filepath && fs21.existsSync(file3.filepath)) {
118599
+ fs21.unlinkSync(file3.filepath);
117334
118600
  }
117335
118601
  });
117336
118602
  };
@@ -117372,7 +118638,7 @@ var uploadResources = async (req, res) => {
117372
118638
  targetPath: minioPath
117373
118639
  });
117374
118640
  if (type !== "file") {
117375
- fs20.unlinkSync(tempPath);
118641
+ fs21.unlinkSync(tempPath);
117376
118642
  }
117377
118643
  }
117378
118644
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -117405,10 +118671,10 @@ var {
117405
118671
 
117406
118672
  // src/server.ts
117407
118673
  import { spawnSync as spawnSync3 } from "node:child_process";
117408
- import path20 from "node:path";
118674
+ import path21 from "node:path";
117409
118675
  // src/module/get-bun-path.ts
117410
- import fs21 from "node:fs";
117411
- import path19 from "node:path";
118676
+ import fs22 from "node:fs";
118677
+ import path20 from "node:path";
117412
118678
  import { execSync as execSync2 } from "node:child_process";
117413
118679
  var getBunPath = () => {
117414
118680
  const isWindows = process.platform === "win32";
@@ -117419,8 +118685,8 @@ var getBunPath = () => {
117419
118685
  if (isWindows) {
117420
118686
  try {
117421
118687
  const globalNodeModules = execSync2("npm root -g", { encoding: "utf-8" }).trim();
117422
- const bunExePath = path19.join(globalNodeModules, "bun", "bin", "bun.exe");
117423
- if (fs21.existsSync(bunExePath)) {
118688
+ const bunExePath = path20.join(globalNodeModules, "bun", "bin", "bun.exe");
118689
+ if (fs22.existsSync(bunExePath)) {
117424
118690
  return bunExePath;
117425
118691
  }
117426
118692
  } catch (error4) {}
@@ -117431,9 +118697,9 @@ var getBunPath = () => {
117431
118697
  return bunPath;
117432
118698
  }
117433
118699
  if (bunPath) {
117434
- const bunDir = path19.dirname(bunPath);
117435
- const bunExePath = path19.join(bunDir, "node_modules", "bun", "bin", "bun.exe");
117436
- if (fs21.existsSync(bunExePath)) {
118700
+ const bunDir = path20.dirname(bunPath);
118701
+ const bunExePath = path20.join(bunDir, "node_modules", "bun", "bin", "bun.exe");
118702
+ if (fs22.existsSync(bunExePath)) {
117437
118703
  return bunExePath;
117438
118704
  }
117439
118705
  }
@@ -117441,7 +118707,7 @@ var getBunPath = () => {
117441
118707
  } else {
117442
118708
  try {
117443
118709
  const bunPath = execSync2("which bun", { encoding: "utf-8" }).trim();
117444
- if (bunPath && fs21.existsSync(bunPath)) {
118710
+ if (bunPath && fs22.existsSync(bunPath)) {
117445
118711
  return bunPath;
117446
118712
  }
117447
118713
  } catch (error4) {}
@@ -117453,7 +118719,7 @@ var getBunPath = () => {
117453
118719
  "C:\\Bun\\bun.exe"
117454
118720
  ];
117455
118721
  for (const p of commonPaths) {
117456
- if (fs21.existsSync(p)) {
118722
+ if (fs22.existsSync(p)) {
117457
118723
  return p;
117458
118724
  }
117459
118725
  }
@@ -117461,7 +118727,7 @@ var getBunPath = () => {
117461
118727
  };
117462
118728
 
117463
118729
  // ../node_modules/.pnpm/@kevisual+video-tools@0.0.13_dotenv@17.2.3_supports-color@10.2.2/node_modules/@kevisual/video-tools/src/ws/index.ts
117464
- var isBrowser4 = typeof process === "undefined" || typeof window !== "undefined" && typeof window.document !== "undefined" || typeof process !== "undefined" && process?.env?.BROWSER === "true";
118730
+ var isBrowser5 = typeof process === "undefined" || typeof window !== "undefined" && typeof window.document !== "undefined" || typeof process !== "undefined" && process?.env?.BROWSER === "true";
117465
118731
  var chantHttpToWs = (url3) => {
117466
118732
  if (url3.startsWith("http://")) {
117467
118733
  return url3.replace("http://", "ws://");
@@ -117474,7 +118740,7 @@ var chantHttpToWs = (url3) => {
117474
118740
  var initWs = async (url3, options) => {
117475
118741
  let ws;
117476
118742
  url3 = chantHttpToWs(url3);
117477
- if (isBrowser4) {
118743
+ if (isBrowser5) {
117478
118744
  ws = new WebSocket(url3);
117479
118745
  } else {
117480
118746
  const wsPakcages = "ws";
@@ -117958,7 +119224,7 @@ program.description("启动服务").option("-d, --daemon", "是否以守护进
117958
119224
  const [_interpreter, execPath] = process.argv;
117959
119225
  const name = options.name;
117960
119226
  const port = options.port;
117961
- const runPath = path20.resolve(execPath);
119227
+ const runPath = path21.resolve(execPath);
117962
119228
  const escapePath = (p) => {
117963
119229
  let normalized = p.replace(/\\/g, "/");
117964
119230
  return normalized.includes(" ") ? `"${normalized}"` : normalized;
@@ -118021,7 +119287,7 @@ program.description("启动服务").option("-d, --daemon", "是否以守护进
118021
119287
  const listenPath = config3?.server?.path || "::";
118022
119288
  const server2 = await runServer(listenPort, listenPath);
118023
119289
  if (options.input) {
118024
- const _input = path20.resolve(options.input);
119290
+ const _input = path21.resolve(options.input);
118025
119291
  if (checkFileExists(_input)) {
118026
119292
  await import(_input);
118027
119293
  }