@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.
- package/dist/assistant-opencode.js +1990 -724
- package/dist/assistant-server.js +1880 -614
- package/dist/assistant.js +1844 -578
- package/dist/envision.js +127 -120
- package/package.json +8 -7
|
@@ -12399,7 +12399,7 @@ var require_path = __commonJS((exports) => {
|
|
|
12399
12399
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12400
12400
|
exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = undefined;
|
|
12401
12401
|
var os2 = __require("os");
|
|
12402
|
-
var
|
|
12402
|
+
var path7 = __require("path");
|
|
12403
12403
|
var IS_WINDOWS_PLATFORM = os2.platform() === "win32";
|
|
12404
12404
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
12405
12405
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -12411,7 +12411,7 @@ var require_path = __commonJS((exports) => {
|
|
|
12411
12411
|
}
|
|
12412
12412
|
exports.unixify = unixify;
|
|
12413
12413
|
function makeAbsolute(cwd, filepath) {
|
|
12414
|
-
return
|
|
12414
|
+
return path7.resolve(cwd, filepath);
|
|
12415
12415
|
}
|
|
12416
12416
|
exports.makeAbsolute = makeAbsolute;
|
|
12417
12417
|
function removeLeadingDotSegment(entry2) {
|
|
@@ -13669,7 +13669,7 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
13669
13669
|
|
|
13670
13670
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
|
|
13671
13671
|
var require_constants2 = __commonJS((exports, module) => {
|
|
13672
|
-
var
|
|
13672
|
+
var path7 = __require("path");
|
|
13673
13673
|
var WIN_SLASH = "\\\\/";
|
|
13674
13674
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
13675
13675
|
var DOT_LITERAL = "\\.";
|
|
@@ -13791,7 +13791,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
13791
13791
|
CHAR_UNDERSCORE: 95,
|
|
13792
13792
|
CHAR_VERTICAL_LINE: 124,
|
|
13793
13793
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
13794
|
-
SEP:
|
|
13794
|
+
SEP: path7.sep,
|
|
13795
13795
|
extglobChars(chars) {
|
|
13796
13796
|
return {
|
|
13797
13797
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -13809,7 +13809,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
13809
13809
|
|
|
13810
13810
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
|
|
13811
13811
|
var require_utils2 = __commonJS((exports) => {
|
|
13812
|
-
var
|
|
13812
|
+
var path7 = __require("path");
|
|
13813
13813
|
var win32 = process.platform === "win32";
|
|
13814
13814
|
var {
|
|
13815
13815
|
REGEX_BACKSLASH,
|
|
@@ -13838,7 +13838,7 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
13838
13838
|
if (options && typeof options.windows === "boolean") {
|
|
13839
13839
|
return options.windows;
|
|
13840
13840
|
}
|
|
13841
|
-
return win32 === true ||
|
|
13841
|
+
return win32 === true || path7.sep === "\\";
|
|
13842
13842
|
};
|
|
13843
13843
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
13844
13844
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -14962,7 +14962,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
14962
14962
|
|
|
14963
14963
|
// ../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
|
|
14964
14964
|
var require_picomatch = __commonJS((exports, module) => {
|
|
14965
|
-
var
|
|
14965
|
+
var path7 = __require("path");
|
|
14966
14966
|
var scan = require_scan();
|
|
14967
14967
|
var parse2 = require_parse2();
|
|
14968
14968
|
var utils2 = require_utils2();
|
|
@@ -15048,7 +15048,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
15048
15048
|
};
|
|
15049
15049
|
picomatch2.matchBase = (input, glob2, options, posix = utils2.isWindows(options)) => {
|
|
15050
15050
|
const regex = glob2 instanceof RegExp ? glob2 : picomatch2.makeRe(glob2, options);
|
|
15051
|
-
return regex.test(
|
|
15051
|
+
return regex.test(path7.basename(input));
|
|
15052
15052
|
};
|
|
15053
15053
|
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
15054
15054
|
picomatch2.parse = (pattern2, options) => {
|
|
@@ -15269,7 +15269,7 @@ var require_micromatch = __commonJS((exports, module) => {
|
|
|
15269
15269
|
var require_pattern = __commonJS((exports) => {
|
|
15270
15270
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15271
15271
|
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;
|
|
15272
|
-
var
|
|
15272
|
+
var path7 = __require("path");
|
|
15273
15273
|
var globParent2 = require_glob_parent();
|
|
15274
15274
|
var micromatch = require_micromatch();
|
|
15275
15275
|
var GLOBSTAR = "**";
|
|
@@ -15364,7 +15364,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
15364
15364
|
}
|
|
15365
15365
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
15366
15366
|
function isAffectDepthOfReadingPattern(pattern2) {
|
|
15367
|
-
const basename =
|
|
15367
|
+
const basename = path7.basename(pattern2);
|
|
15368
15368
|
return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename);
|
|
15369
15369
|
}
|
|
15370
15370
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -15422,7 +15422,7 @@ var require_pattern = __commonJS((exports) => {
|
|
|
15422
15422
|
}
|
|
15423
15423
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
15424
15424
|
function isAbsolute(pattern2) {
|
|
15425
|
-
return
|
|
15425
|
+
return path7.isAbsolute(pattern2);
|
|
15426
15426
|
}
|
|
15427
15427
|
exports.isAbsolute = isAbsolute;
|
|
15428
15428
|
});
|
|
@@ -15585,10 +15585,10 @@ var require_utils3 = __commonJS((exports) => {
|
|
|
15585
15585
|
exports.array = array3;
|
|
15586
15586
|
var errno2 = require_errno();
|
|
15587
15587
|
exports.errno = errno2;
|
|
15588
|
-
var
|
|
15589
|
-
exports.fs =
|
|
15590
|
-
var
|
|
15591
|
-
exports.path =
|
|
15588
|
+
var fs7 = require_fs();
|
|
15589
|
+
exports.fs = fs7;
|
|
15590
|
+
var path7 = require_path();
|
|
15591
|
+
exports.path = path7;
|
|
15592
15592
|
var pattern2 = require_pattern();
|
|
15593
15593
|
exports.pattern = pattern2;
|
|
15594
15594
|
var stream3 = require_stream();
|
|
@@ -15684,8 +15684,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
15684
15684
|
var require_async = __commonJS((exports) => {
|
|
15685
15685
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15686
15686
|
exports.read = undefined;
|
|
15687
|
-
function read(
|
|
15688
|
-
settings2.fs.lstat(
|
|
15687
|
+
function read(path7, settings2, callback) {
|
|
15688
|
+
settings2.fs.lstat(path7, (lstatError, lstat) => {
|
|
15689
15689
|
if (lstatError !== null) {
|
|
15690
15690
|
callFailureCallback(callback, lstatError);
|
|
15691
15691
|
return;
|
|
@@ -15694,7 +15694,7 @@ var require_async = __commonJS((exports) => {
|
|
|
15694
15694
|
callSuccessCallback(callback, lstat);
|
|
15695
15695
|
return;
|
|
15696
15696
|
}
|
|
15697
|
-
settings2.fs.stat(
|
|
15697
|
+
settings2.fs.stat(path7, (statError, stat) => {
|
|
15698
15698
|
if (statError !== null) {
|
|
15699
15699
|
if (settings2.throwErrorOnBrokenSymbolicLink) {
|
|
15700
15700
|
callFailureCallback(callback, statError);
|
|
@@ -15723,13 +15723,13 @@ var require_async = __commonJS((exports) => {
|
|
|
15723
15723
|
var require_sync = __commonJS((exports) => {
|
|
15724
15724
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15725
15725
|
exports.read = undefined;
|
|
15726
|
-
function read(
|
|
15727
|
-
const lstat = settings2.fs.lstatSync(
|
|
15726
|
+
function read(path7, settings2) {
|
|
15727
|
+
const lstat = settings2.fs.lstatSync(path7);
|
|
15728
15728
|
if (!lstat.isSymbolicLink() || !settings2.followSymbolicLink) {
|
|
15729
15729
|
return lstat;
|
|
15730
15730
|
}
|
|
15731
15731
|
try {
|
|
15732
|
-
const stat = settings2.fs.statSync(
|
|
15732
|
+
const stat = settings2.fs.statSync(path7);
|
|
15733
15733
|
if (settings2.markSymbolicLink) {
|
|
15734
15734
|
stat.isSymbolicLink = () => true;
|
|
15735
15735
|
}
|
|
@@ -15748,12 +15748,12 @@ var require_sync = __commonJS((exports) => {
|
|
|
15748
15748
|
var require_fs2 = __commonJS((exports) => {
|
|
15749
15749
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15750
15750
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
15751
|
-
var
|
|
15751
|
+
var fs7 = __require("fs");
|
|
15752
15752
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
15753
|
-
lstat:
|
|
15754
|
-
stat:
|
|
15755
|
-
lstatSync:
|
|
15756
|
-
statSync:
|
|
15753
|
+
lstat: fs7.lstat,
|
|
15754
|
+
stat: fs7.stat,
|
|
15755
|
+
lstatSync: fs7.lstatSync,
|
|
15756
|
+
statSync: fs7.statSync
|
|
15757
15757
|
};
|
|
15758
15758
|
function createFileSystemAdapter(fsMethods) {
|
|
15759
15759
|
if (fsMethods === undefined) {
|
|
@@ -15767,13 +15767,13 @@ var require_fs2 = __commonJS((exports) => {
|
|
|
15767
15767
|
// ../node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js
|
|
15768
15768
|
var require_settings = __commonJS((exports) => {
|
|
15769
15769
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15770
|
-
var
|
|
15770
|
+
var fs7 = require_fs2();
|
|
15771
15771
|
|
|
15772
15772
|
class Settings {
|
|
15773
15773
|
constructor(_options = {}) {
|
|
15774
15774
|
this._options = _options;
|
|
15775
15775
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
15776
|
-
this.fs =
|
|
15776
|
+
this.fs = fs7.createFileSystemAdapter(this._options.fs);
|
|
15777
15777
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
15778
15778
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
15779
15779
|
}
|
|
@@ -15792,17 +15792,17 @@ var require_out = __commonJS((exports) => {
|
|
|
15792
15792
|
var sync2 = require_sync();
|
|
15793
15793
|
var settings_1 = require_settings();
|
|
15794
15794
|
exports.Settings = settings_1.default;
|
|
15795
|
-
function stat(
|
|
15795
|
+
function stat(path7, optionsOrSettingsOrCallback, callback) {
|
|
15796
15796
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
15797
|
-
async2.read(
|
|
15797
|
+
async2.read(path7, getSettings(), optionsOrSettingsOrCallback);
|
|
15798
15798
|
return;
|
|
15799
15799
|
}
|
|
15800
|
-
async2.read(
|
|
15800
|
+
async2.read(path7, getSettings(optionsOrSettingsOrCallback), callback);
|
|
15801
15801
|
}
|
|
15802
15802
|
exports.stat = stat;
|
|
15803
|
-
function statSync(
|
|
15803
|
+
function statSync(path7, optionsOrSettings) {
|
|
15804
15804
|
const settings2 = getSettings(optionsOrSettings);
|
|
15805
|
-
return sync2.read(
|
|
15805
|
+
return sync2.read(path7, settings2);
|
|
15806
15806
|
}
|
|
15807
15807
|
exports.statSync = statSync;
|
|
15808
15808
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -15918,8 +15918,8 @@ var require_fs3 = __commonJS((exports) => {
|
|
|
15918
15918
|
var require_utils4 = __commonJS((exports) => {
|
|
15919
15919
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15920
15920
|
exports.fs = undefined;
|
|
15921
|
-
var
|
|
15922
|
-
exports.fs =
|
|
15921
|
+
var fs7 = require_fs3();
|
|
15922
|
+
exports.fs = fs7;
|
|
15923
15923
|
});
|
|
15924
15924
|
|
|
15925
15925
|
// ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/common.js
|
|
@@ -16005,16 +16005,16 @@ var require_async2 = __commonJS((exports) => {
|
|
|
16005
16005
|
return;
|
|
16006
16006
|
}
|
|
16007
16007
|
const tasks2 = names.map((name) => {
|
|
16008
|
-
const
|
|
16008
|
+
const path7 = common2.joinPathSegments(directory, name, settings2.pathSegmentSeparator);
|
|
16009
16009
|
return (done) => {
|
|
16010
|
-
fsStat.stat(
|
|
16010
|
+
fsStat.stat(path7, settings2.fsStatSettings, (error3, stats) => {
|
|
16011
16011
|
if (error3 !== null) {
|
|
16012
16012
|
done(error3);
|
|
16013
16013
|
return;
|
|
16014
16014
|
}
|
|
16015
16015
|
const entry2 = {
|
|
16016
16016
|
name,
|
|
16017
|
-
path:
|
|
16017
|
+
path: path7,
|
|
16018
16018
|
dirent: utils2.fs.createDirentFromStats(name, stats)
|
|
16019
16019
|
};
|
|
16020
16020
|
if (settings2.stats) {
|
|
@@ -16102,14 +16102,14 @@ var require_sync2 = __commonJS((exports) => {
|
|
|
16102
16102
|
var require_fs4 = __commonJS((exports) => {
|
|
16103
16103
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16104
16104
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = undefined;
|
|
16105
|
-
var
|
|
16105
|
+
var fs7 = __require("fs");
|
|
16106
16106
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
16107
|
-
lstat:
|
|
16108
|
-
stat:
|
|
16109
|
-
lstatSync:
|
|
16110
|
-
statSync:
|
|
16111
|
-
readdir:
|
|
16112
|
-
readdirSync:
|
|
16107
|
+
lstat: fs7.lstat,
|
|
16108
|
+
stat: fs7.stat,
|
|
16109
|
+
lstatSync: fs7.lstatSync,
|
|
16110
|
+
statSync: fs7.statSync,
|
|
16111
|
+
readdir: fs7.readdir,
|
|
16112
|
+
readdirSync: fs7.readdirSync
|
|
16113
16113
|
};
|
|
16114
16114
|
function createFileSystemAdapter(fsMethods) {
|
|
16115
16115
|
if (fsMethods === undefined) {
|
|
@@ -16123,16 +16123,16 @@ var require_fs4 = __commonJS((exports) => {
|
|
|
16123
16123
|
// ../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js
|
|
16124
16124
|
var require_settings2 = __commonJS((exports) => {
|
|
16125
16125
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16126
|
-
var
|
|
16126
|
+
var path7 = __require("path");
|
|
16127
16127
|
var fsStat = require_out();
|
|
16128
|
-
var
|
|
16128
|
+
var fs7 = require_fs4();
|
|
16129
16129
|
|
|
16130
16130
|
class Settings {
|
|
16131
16131
|
constructor(_options = {}) {
|
|
16132
16132
|
this._options = _options;
|
|
16133
16133
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
16134
|
-
this.fs =
|
|
16135
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
16134
|
+
this.fs = fs7.createFileSystemAdapter(this._options.fs);
|
|
16135
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path7.sep);
|
|
16136
16136
|
this.stats = this._getValue(this._options.stats, false);
|
|
16137
16137
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
16138
16138
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -16156,17 +16156,17 @@ var require_out2 = __commonJS((exports) => {
|
|
|
16156
16156
|
var sync2 = require_sync2();
|
|
16157
16157
|
var settings_1 = require_settings2();
|
|
16158
16158
|
exports.Settings = settings_1.default;
|
|
16159
|
-
function scandir(
|
|
16159
|
+
function scandir(path7, optionsOrSettingsOrCallback, callback) {
|
|
16160
16160
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
16161
|
-
async2.read(
|
|
16161
|
+
async2.read(path7, getSettings(), optionsOrSettingsOrCallback);
|
|
16162
16162
|
return;
|
|
16163
16163
|
}
|
|
16164
|
-
async2.read(
|
|
16164
|
+
async2.read(path7, getSettings(optionsOrSettingsOrCallback), callback);
|
|
16165
16165
|
}
|
|
16166
16166
|
exports.scandir = scandir;
|
|
16167
|
-
function scandirSync(
|
|
16167
|
+
function scandirSync(path7, optionsOrSettings) {
|
|
16168
16168
|
const settings2 = getSettings(optionsOrSettings);
|
|
16169
|
-
return sync2.read(
|
|
16169
|
+
return sync2.read(path7, settings2);
|
|
16170
16170
|
}
|
|
16171
16171
|
exports.scandirSync = scandirSync;
|
|
16172
16172
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -16764,7 +16764,7 @@ var require_sync4 = __commonJS((exports) => {
|
|
|
16764
16764
|
// ../node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js
|
|
16765
16765
|
var require_settings3 = __commonJS((exports) => {
|
|
16766
16766
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16767
|
-
var
|
|
16767
|
+
var path7 = __require("path");
|
|
16768
16768
|
var fsScandir = require_out2();
|
|
16769
16769
|
|
|
16770
16770
|
class Settings {
|
|
@@ -16775,7 +16775,7 @@ var require_settings3 = __commonJS((exports) => {
|
|
|
16775
16775
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
16776
16776
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
16777
16777
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
16778
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
16778
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path7.sep);
|
|
16779
16779
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
16780
16780
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
16781
16781
|
fs: this._options.fs,
|
|
@@ -16831,7 +16831,7 @@ var require_out3 = __commonJS((exports) => {
|
|
|
16831
16831
|
// ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js
|
|
16832
16832
|
var require_reader2 = __commonJS((exports) => {
|
|
16833
16833
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16834
|
-
var
|
|
16834
|
+
var path7 = __require("path");
|
|
16835
16835
|
var fsStat = require_out();
|
|
16836
16836
|
var utils2 = require_utils3();
|
|
16837
16837
|
|
|
@@ -16845,7 +16845,7 @@ var require_reader2 = __commonJS((exports) => {
|
|
|
16845
16845
|
});
|
|
16846
16846
|
}
|
|
16847
16847
|
_getFullEntryPath(filepath) {
|
|
16848
|
-
return
|
|
16848
|
+
return path7.resolve(this._settings.cwd, filepath);
|
|
16849
16849
|
}
|
|
16850
16850
|
_makeEntry(stats, pattern2) {
|
|
16851
16851
|
const entry2 = {
|
|
@@ -17242,7 +17242,7 @@ var require_entry2 = __commonJS((exports) => {
|
|
|
17242
17242
|
// ../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js
|
|
17243
17243
|
var require_provider = __commonJS((exports) => {
|
|
17244
17244
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17245
|
-
var
|
|
17245
|
+
var path7 = __require("path");
|
|
17246
17246
|
var deep_1 = require_deep();
|
|
17247
17247
|
var entry_1 = require_entry();
|
|
17248
17248
|
var error_1 = require_error();
|
|
@@ -17257,7 +17257,7 @@ var require_provider = __commonJS((exports) => {
|
|
|
17257
17257
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
17258
17258
|
}
|
|
17259
17259
|
_getRootDirectory(task) {
|
|
17260
|
-
return
|
|
17260
|
+
return path7.resolve(this._settings.cwd, task.base);
|
|
17261
17261
|
}
|
|
17262
17262
|
_getReaderOptions(task) {
|
|
17263
17263
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -17426,16 +17426,16 @@ var require_sync6 = __commonJS((exports) => {
|
|
|
17426
17426
|
var require_settings4 = __commonJS((exports) => {
|
|
17427
17427
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17428
17428
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
|
|
17429
|
-
var
|
|
17429
|
+
var fs7 = __require("fs");
|
|
17430
17430
|
var os2 = __require("os");
|
|
17431
17431
|
var CPU_COUNT = Math.max(os2.cpus().length, 1);
|
|
17432
17432
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
17433
|
-
lstat:
|
|
17434
|
-
lstatSync:
|
|
17435
|
-
stat:
|
|
17436
|
-
statSync:
|
|
17437
|
-
readdir:
|
|
17438
|
-
readdirSync:
|
|
17433
|
+
lstat: fs7.lstat,
|
|
17434
|
+
lstatSync: fs7.lstatSync,
|
|
17435
|
+
stat: fs7.stat,
|
|
17436
|
+
statSync: fs7.statSync,
|
|
17437
|
+
readdir: fs7.readdir,
|
|
17438
|
+
readdirSync: fs7.readdirSync
|
|
17439
17439
|
};
|
|
17440
17440
|
|
|
17441
17441
|
class Settings {
|
|
@@ -17612,11 +17612,11 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17612
17612
|
else
|
|
17613
17613
|
delete emitter._events[evt];
|
|
17614
17614
|
}
|
|
17615
|
-
function
|
|
17615
|
+
function EventEmitter4() {
|
|
17616
17616
|
this._events = new Events;
|
|
17617
17617
|
this._eventsCount = 0;
|
|
17618
17618
|
}
|
|
17619
|
-
|
|
17619
|
+
EventEmitter4.prototype.eventNames = function eventNames() {
|
|
17620
17620
|
var names = [], events, name;
|
|
17621
17621
|
if (this._eventsCount === 0)
|
|
17622
17622
|
return names;
|
|
@@ -17629,7 +17629,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17629
17629
|
}
|
|
17630
17630
|
return names;
|
|
17631
17631
|
};
|
|
17632
|
-
|
|
17632
|
+
EventEmitter4.prototype.listeners = function listeners(event) {
|
|
17633
17633
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
17634
17634
|
if (!handlers)
|
|
17635
17635
|
return [];
|
|
@@ -17640,7 +17640,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17640
17640
|
}
|
|
17641
17641
|
return ee;
|
|
17642
17642
|
};
|
|
17643
|
-
|
|
17643
|
+
EventEmitter4.prototype.listenerCount = function listenerCount(event) {
|
|
17644
17644
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
17645
17645
|
if (!listeners)
|
|
17646
17646
|
return 0;
|
|
@@ -17648,7 +17648,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17648
17648
|
return 1;
|
|
17649
17649
|
return listeners.length;
|
|
17650
17650
|
};
|
|
17651
|
-
|
|
17651
|
+
EventEmitter4.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
17652
17652
|
var evt = prefix ? prefix + event : event;
|
|
17653
17653
|
if (!this._events[evt])
|
|
17654
17654
|
return false;
|
|
@@ -17703,13 +17703,13 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17703
17703
|
}
|
|
17704
17704
|
return true;
|
|
17705
17705
|
};
|
|
17706
|
-
|
|
17706
|
+
EventEmitter4.prototype.on = function on(event, fn, context) {
|
|
17707
17707
|
return addListener(this, event, fn, context, false);
|
|
17708
17708
|
};
|
|
17709
|
-
|
|
17709
|
+
EventEmitter4.prototype.once = function once(event, fn, context) {
|
|
17710
17710
|
return addListener(this, event, fn, context, true);
|
|
17711
17711
|
};
|
|
17712
|
-
|
|
17712
|
+
EventEmitter4.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
17713
17713
|
var evt = prefix ? prefix + event : event;
|
|
17714
17714
|
if (!this._events[evt])
|
|
17715
17715
|
return this;
|
|
@@ -17735,7 +17735,7 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17735
17735
|
}
|
|
17736
17736
|
return this;
|
|
17737
17737
|
};
|
|
17738
|
-
|
|
17738
|
+
EventEmitter4.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
17739
17739
|
var evt;
|
|
17740
17740
|
if (event) {
|
|
17741
17741
|
evt = prefix ? prefix + event : event;
|
|
@@ -17747,12 +17747,12 @@ var require_eventemitter3 = __commonJS((exports, module) => {
|
|
|
17747
17747
|
}
|
|
17748
17748
|
return this;
|
|
17749
17749
|
};
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17750
|
+
EventEmitter4.prototype.off = EventEmitter4.prototype.removeListener;
|
|
17751
|
+
EventEmitter4.prototype.addListener = EventEmitter4.prototype.on;
|
|
17752
|
+
EventEmitter4.prefixed = prefix;
|
|
17753
|
+
EventEmitter4.EventEmitter = EventEmitter4;
|
|
17754
17754
|
if (typeof module !== "undefined") {
|
|
17755
|
-
module.exports =
|
|
17755
|
+
module.exports = EventEmitter4;
|
|
17756
17756
|
}
|
|
17757
17757
|
});
|
|
17758
17758
|
|
|
@@ -18292,18 +18292,18 @@ var require_utils6 = __commonJS((exports, module) => {
|
|
|
18292
18292
|
if (decode3)
|
|
18293
18293
|
return decode3(data, hint);
|
|
18294
18294
|
}
|
|
18295
|
-
function basename(
|
|
18296
|
-
if (typeof
|
|
18295
|
+
function basename(path13) {
|
|
18296
|
+
if (typeof path13 !== "string")
|
|
18297
18297
|
return "";
|
|
18298
|
-
for (let i2 =
|
|
18299
|
-
switch (
|
|
18298
|
+
for (let i2 = path13.length - 1;i2 >= 0; --i2) {
|
|
18299
|
+
switch (path13.charCodeAt(i2)) {
|
|
18300
18300
|
case 47:
|
|
18301
18301
|
case 92:
|
|
18302
|
-
|
|
18303
|
-
return
|
|
18302
|
+
path13 = path13.slice(i2 + 1);
|
|
18303
|
+
return path13 === ".." || path13 === "." ? "" : path13;
|
|
18304
18304
|
}
|
|
18305
18305
|
}
|
|
18306
|
-
return
|
|
18306
|
+
return path13 === ".." || path13 === "." ? "" : path13;
|
|
18307
18307
|
}
|
|
18308
18308
|
var TOKEN = [
|
|
18309
18309
|
0,
|
|
@@ -40316,8 +40316,8 @@ class HttpChain {
|
|
|
40316
40316
|
}
|
|
40317
40317
|
|
|
40318
40318
|
// src/services/init/index.ts
|
|
40319
|
-
import
|
|
40320
|
-
import
|
|
40319
|
+
import fs13 from "node:fs";
|
|
40320
|
+
import path11 from "node:path";
|
|
40321
40321
|
|
|
40322
40322
|
// src/module/assistant/config/index.ts
|
|
40323
40323
|
import path2 from "path";
|
|
@@ -40784,7 +40784,7 @@ __export(exports_manager, {
|
|
|
40784
40784
|
AppType: () => AppType
|
|
40785
40785
|
});
|
|
40786
40786
|
|
|
40787
|
-
// ../node_modules/.pnpm/@kevisual+use-config@1.0.
|
|
40787
|
+
// ../node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
|
|
40788
40788
|
import { createRequire as createRequire2 } from "node:module";
|
|
40789
40789
|
import fs3 from "node:fs";
|
|
40790
40790
|
import path3 from "node:path";
|
|
@@ -41232,71 +41232,6 @@ var getConfigFile = (opts) => {
|
|
|
41232
41232
|
return lastLastPath;
|
|
41233
41233
|
return "";
|
|
41234
41234
|
};
|
|
41235
|
-
var getConfig = (opts) => {
|
|
41236
|
-
let quiet = opts?.quite ?? true;
|
|
41237
|
-
const showError = opts?.showError ?? false;
|
|
41238
|
-
if (opts?.dotenvOpts) {
|
|
41239
|
-
const prased = import_dotenv2.default.config({ quiet, ...opts.dotenvOpts }).parsed;
|
|
41240
|
-
if (prased) {
|
|
41241
|
-
return prased;
|
|
41242
|
-
} else {
|
|
41243
|
-
if (showError) {
|
|
41244
|
-
if (!quiet) {
|
|
41245
|
-
console.warn("config 读取失败");
|
|
41246
|
-
}
|
|
41247
|
-
throw new Error("未找到配置文件");
|
|
41248
|
-
}
|
|
41249
|
-
return {};
|
|
41250
|
-
}
|
|
41251
|
-
}
|
|
41252
|
-
const filePath = getConfigFile(opts);
|
|
41253
|
-
if (!quiet && filePath) {
|
|
41254
|
-
console.log("config pathname:", filePath);
|
|
41255
|
-
}
|
|
41256
|
-
if (!filePath) {
|
|
41257
|
-
if (showError) {
|
|
41258
|
-
if (!quiet) {
|
|
41259
|
-
console.warn("config 路径未找到");
|
|
41260
|
-
}
|
|
41261
|
-
throw new Error("未找到配置文件");
|
|
41262
|
-
}
|
|
41263
|
-
return {};
|
|
41264
|
-
}
|
|
41265
|
-
const value = import_dotenv2.default.config({ quiet: true, path: filePath }).parsed;
|
|
41266
|
-
return value;
|
|
41267
|
-
};
|
|
41268
|
-
var useConfig = (onlyInitConfig, force) => {
|
|
41269
|
-
const config2 = global.config;
|
|
41270
|
-
let _config = config2 || getConfig(onlyInitConfig);
|
|
41271
|
-
!config2 && (global["config"] = _config);
|
|
41272
|
-
if (force && onlyInitConfig) {
|
|
41273
|
-
const _newConfig = getConfig(onlyInitConfig);
|
|
41274
|
-
_config = mergeConfig(_newConfig);
|
|
41275
|
-
}
|
|
41276
|
-
return _config;
|
|
41277
|
-
};
|
|
41278
|
-
var mergeConfig = (config2) => {
|
|
41279
|
-
const _config = global.config || {};
|
|
41280
|
-
Object.assign(_config, config2);
|
|
41281
|
-
global.config = _config;
|
|
41282
|
-
return _config;
|
|
41283
|
-
};
|
|
41284
|
-
var useKey = (key, opts) => {
|
|
41285
|
-
let v = useConfig()[key];
|
|
41286
|
-
if (!v) {
|
|
41287
|
-
v = process.env[key];
|
|
41288
|
-
}
|
|
41289
|
-
if (!v) {
|
|
41290
|
-
return opts?.defaultValue || null;
|
|
41291
|
-
}
|
|
41292
|
-
if (opts?.isNumber && typeof v === "string") {
|
|
41293
|
-
return Number(v);
|
|
41294
|
-
}
|
|
41295
|
-
if (opts?.isBoolean && typeof v === "string") {
|
|
41296
|
-
return v === "true";
|
|
41297
|
-
}
|
|
41298
|
-
return v;
|
|
41299
|
-
};
|
|
41300
41235
|
var useFileStore = (str, opts) => {
|
|
41301
41236
|
const publicPath = process.cwd();
|
|
41302
41237
|
const filePath = path3.join(publicPath, str);
|
|
@@ -48836,278 +48771,1352 @@ var restart2 = promisify2(pm22.restart).bind(pm22);
|
|
|
48836
48771
|
var reload = promisify2(pm22.reload).bind(pm22);
|
|
48837
48772
|
var deleteProcess2 = promisify2(pm22.delete).bind(pm22);
|
|
48838
48773
|
var list2 = promisify2(pm22.list).bind(pm22);
|
|
48839
|
-
//
|
|
48840
|
-
import
|
|
48774
|
+
// ../node_modules/.pnpm/@kevisual+use-config@1.0.28_dotenv@17.2.3/node_modules/@kevisual/use-config/dist/app.js
|
|
48775
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
48841
48776
|
import fs5 from "node:fs";
|
|
48842
|
-
|
|
48843
|
-
|
|
48844
|
-
|
|
48845
|
-
|
|
48846
|
-
|
|
48847
|
-
|
|
48848
|
-
|
|
48849
|
-
|
|
48850
|
-
|
|
48851
|
-
|
|
48852
|
-
|
|
48853
|
-
|
|
48777
|
+
import path5 from "node:path";
|
|
48778
|
+
var __create3 = Object.create;
|
|
48779
|
+
var __getProtoOf3 = Object.getPrototypeOf;
|
|
48780
|
+
var __defProp3 = Object.defineProperty;
|
|
48781
|
+
var __getOwnPropNames3 = Object.getOwnPropertyNames;
|
|
48782
|
+
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
48783
|
+
var __toESM3 = (mod, isNodeMode, target) => {
|
|
48784
|
+
target = mod != null ? __create3(__getProtoOf3(mod)) : {};
|
|
48785
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target;
|
|
48786
|
+
for (let key of __getOwnPropNames3(mod))
|
|
48787
|
+
if (!__hasOwnProp3.call(to, key))
|
|
48788
|
+
__defProp3(to, key, {
|
|
48789
|
+
get: () => mod[key],
|
|
48790
|
+
enumerable: true
|
|
48791
|
+
});
|
|
48792
|
+
return to;
|
|
48854
48793
|
};
|
|
48855
|
-
var
|
|
48856
|
-
|
|
48857
|
-
|
|
48858
|
-
|
|
48859
|
-
|
|
48860
|
-
|
|
48861
|
-
|
|
48862
|
-
|
|
48863
|
-
|
|
48864
|
-
|
|
48865
|
-
|
|
48866
|
-
|
|
48867
|
-
|
|
48868
|
-
|
|
48869
|
-
|
|
48794
|
+
var __commonJS3 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
48795
|
+
var __require3 = /* @__PURE__ */ createRequire3(import.meta.url);
|
|
48796
|
+
var require_package3 = __commonJS3((exports, module) => {
|
|
48797
|
+
module.exports = {
|
|
48798
|
+
name: "dotenv",
|
|
48799
|
+
version: "17.2.3",
|
|
48800
|
+
description: "Loads environment variables from .env file",
|
|
48801
|
+
main: "lib/main.js",
|
|
48802
|
+
types: "lib/main.d.ts",
|
|
48803
|
+
exports: {
|
|
48804
|
+
".": {
|
|
48805
|
+
types: "./lib/main.d.ts",
|
|
48806
|
+
require: "./lib/main.js",
|
|
48807
|
+
default: "./lib/main.js"
|
|
48808
|
+
},
|
|
48809
|
+
"./config": "./config.js",
|
|
48810
|
+
"./config.js": "./config.js",
|
|
48811
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
48812
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
48813
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
48814
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
48815
|
+
"./package.json": "./package.json"
|
|
48816
|
+
},
|
|
48817
|
+
scripts: {
|
|
48818
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
48819
|
+
lint: "standard",
|
|
48820
|
+
pretest: "npm run lint && npm run dts-check",
|
|
48821
|
+
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
48822
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
48823
|
+
prerelease: "npm test",
|
|
48824
|
+
release: "standard-version"
|
|
48825
|
+
},
|
|
48826
|
+
repository: {
|
|
48827
|
+
type: "git",
|
|
48828
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
48829
|
+
},
|
|
48830
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
48831
|
+
funding: "https://dotenvx.com",
|
|
48832
|
+
keywords: [
|
|
48833
|
+
"dotenv",
|
|
48834
|
+
"env",
|
|
48835
|
+
".env",
|
|
48836
|
+
"environment",
|
|
48837
|
+
"variables",
|
|
48838
|
+
"config",
|
|
48839
|
+
"settings"
|
|
48840
|
+
],
|
|
48841
|
+
readmeFilename: "README.md",
|
|
48842
|
+
license: "BSD-2-Clause",
|
|
48843
|
+
devDependencies: {
|
|
48844
|
+
"@types/node": "^18.11.3",
|
|
48845
|
+
decache: "^4.6.2",
|
|
48846
|
+
sinon: "^14.0.1",
|
|
48847
|
+
standard: "^17.0.0",
|
|
48848
|
+
"standard-version": "^9.5.0",
|
|
48849
|
+
tap: "^19.2.0",
|
|
48850
|
+
typescript: "^4.8.4"
|
|
48851
|
+
},
|
|
48852
|
+
engines: {
|
|
48853
|
+
node: ">=12"
|
|
48854
|
+
},
|
|
48855
|
+
browser: {
|
|
48856
|
+
fs: false
|
|
48870
48857
|
}
|
|
48871
|
-
|
|
48872
|
-
|
|
48873
|
-
|
|
48874
|
-
|
|
48875
|
-
|
|
48876
|
-
|
|
48877
|
-
var
|
|
48878
|
-
|
|
48879
|
-
|
|
48880
|
-
|
|
48881
|
-
|
|
48882
|
-
|
|
48883
|
-
|
|
48884
|
-
|
|
48885
|
-
|
|
48886
|
-
|
|
48887
|
-
|
|
48888
|
-
|
|
48889
|
-
|
|
48890
|
-
|
|
48891
|
-
|
|
48892
|
-
|
|
48858
|
+
};
|
|
48859
|
+
});
|
|
48860
|
+
var require_main3 = __commonJS3((exports, module) => {
|
|
48861
|
+
var fs6 = __require3("fs");
|
|
48862
|
+
var path6 = __require3("path");
|
|
48863
|
+
var os2 = __require3("os");
|
|
48864
|
+
var crypto2 = __require3("crypto");
|
|
48865
|
+
var packageJson = require_package3();
|
|
48866
|
+
var version2 = packageJson.version;
|
|
48867
|
+
var TIPS = [
|
|
48868
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
48869
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
48870
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
48871
|
+
"\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
|
|
48872
|
+
"\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
48873
|
+
"\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
|
|
48874
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
48875
|
+
"\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
48876
|
+
"\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
|
|
48877
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
48878
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
48879
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
48880
|
+
"⚙️ override existing env vars with { override: true }",
|
|
48881
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
48882
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
48883
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
48884
|
+
];
|
|
48885
|
+
function _getRandomTip() {
|
|
48886
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
48893
48887
|
}
|
|
48894
|
-
|
|
48895
|
-
|
|
48896
|
-
|
|
48897
|
-
|
|
48898
|
-
|
|
48899
|
-
import path6 from "node:path";
|
|
48900
|
-
var import_fast_glob = __toESM(require_out4(), 1);
|
|
48901
|
-
import fs6 from "node:fs";
|
|
48902
|
-
|
|
48903
|
-
// src/module/local-apps/src/modules/pm2.ts
|
|
48904
|
-
import { spawn } from "node:child_process";
|
|
48905
|
-
import pm23 from "pm2";
|
|
48906
|
-
import { promisify as promisify3 } from "node:util";
|
|
48907
|
-
var normalizeScriptPath2 = (scriptPath) => {
|
|
48908
|
-
if (process.platform === "win32") {
|
|
48909
|
-
return scriptPath.replace(/\\/g, "/");
|
|
48888
|
+
function parseBoolean(value) {
|
|
48889
|
+
if (typeof value === "string") {
|
|
48890
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
48891
|
+
}
|
|
48892
|
+
return Boolean(value);
|
|
48910
48893
|
}
|
|
48911
|
-
|
|
48912
|
-
|
|
48913
|
-
var connect2 = async (noDaemonMode = false) => {
|
|
48914
|
-
return new Promise((resolve, reject) => {
|
|
48915
|
-
pm23.connect(noDaemonMode, (err) => {
|
|
48916
|
-
if (err) {
|
|
48917
|
-
console.error("pm2 connect error", err);
|
|
48918
|
-
return reject(err);
|
|
48919
|
-
}
|
|
48920
|
-
resolve(true);
|
|
48921
|
-
});
|
|
48922
|
-
});
|
|
48923
|
-
};
|
|
48924
|
-
var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
|
|
48925
|
-
var start3 = promisify3(pm23.start).bind(pm23);
|
|
48926
|
-
var stop3 = promisify3(pm23.stop).bind(pm23);
|
|
48927
|
-
var restart3 = promisify3(pm23.restart).bind(pm23);
|
|
48928
|
-
var reload2 = promisify3(pm23.reload).bind(pm23);
|
|
48929
|
-
var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
|
|
48930
|
-
var list3 = promisify3(pm23.list).bind(pm23);
|
|
48931
|
-
var checkInstall = async (app) => {
|
|
48932
|
-
return new Promise((resolve, reject) => {
|
|
48933
|
-
const install = spawn("pnpm", ["install"], {
|
|
48934
|
-
cwd: app.path,
|
|
48935
|
-
stdio: "inherit"
|
|
48936
|
-
});
|
|
48937
|
-
install.on("close", (code) => {
|
|
48938
|
-
if (code !== 0) {
|
|
48939
|
-
console.log("install failed");
|
|
48940
|
-
return resolve(false);
|
|
48941
|
-
}
|
|
48942
|
-
console.log("install success");
|
|
48943
|
-
resolve(true);
|
|
48944
|
-
});
|
|
48945
|
-
});
|
|
48946
|
-
};
|
|
48947
|
-
|
|
48948
|
-
class Pm2Connect2 {
|
|
48949
|
-
needConnect = true;
|
|
48950
|
-
isConnected = false;
|
|
48951
|
-
constructor(needConnect = true) {
|
|
48952
|
-
this.needConnect = needConnect;
|
|
48894
|
+
function supportsAnsi() {
|
|
48895
|
+
return process.stdout.isTTY;
|
|
48953
48896
|
}
|
|
48954
|
-
|
|
48955
|
-
return
|
|
48956
|
-
setTimeout(resolve, ms2);
|
|
48957
|
-
});
|
|
48897
|
+
function dim(text) {
|
|
48898
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
48958
48899
|
}
|
|
48959
|
-
|
|
48960
|
-
|
|
48961
|
-
|
|
48962
|
-
|
|
48963
|
-
|
|
48964
|
-
|
|
48900
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
48901
|
+
function parse2(src) {
|
|
48902
|
+
const obj = {};
|
|
48903
|
+
let lines = src.toString();
|
|
48904
|
+
lines = lines.replace(/\r\n?/mg, `
|
|
48905
|
+
`);
|
|
48906
|
+
let match;
|
|
48907
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
48908
|
+
const key = match[1];
|
|
48909
|
+
let value = match[2] || "";
|
|
48910
|
+
value = value.trim();
|
|
48911
|
+
const maybeQuote = value[0];
|
|
48912
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
48913
|
+
if (maybeQuote === '"') {
|
|
48914
|
+
value = value.replace(/\\n/g, `
|
|
48915
|
+
`);
|
|
48916
|
+
value = value.replace(/\\r/g, "\r");
|
|
48965
48917
|
}
|
|
48966
|
-
|
|
48967
|
-
console.log("pm2 check connect error", e);
|
|
48918
|
+
obj[key] = value;
|
|
48968
48919
|
}
|
|
48920
|
+
return obj;
|
|
48969
48921
|
}
|
|
48970
|
-
|
|
48971
|
-
|
|
48972
|
-
|
|
48973
|
-
|
|
48922
|
+
function _parseVault(options) {
|
|
48923
|
+
options = options || {};
|
|
48924
|
+
const vaultPath = _vaultPath(options);
|
|
48925
|
+
options.path = vaultPath;
|
|
48926
|
+
const result = DotenvModule.configDotenv(options);
|
|
48927
|
+
if (!result.parsed) {
|
|
48928
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
48929
|
+
err.code = "MISSING_DATA";
|
|
48930
|
+
throw err;
|
|
48974
48931
|
}
|
|
48975
|
-
|
|
48976
|
-
|
|
48977
|
-
|
|
48978
|
-
|
|
48979
|
-
|
|
48980
|
-
|
|
48981
|
-
|
|
48932
|
+
const keys = _dotenvKey(options).split(",");
|
|
48933
|
+
const length = keys.length;
|
|
48934
|
+
let decrypted;
|
|
48935
|
+
for (let i = 0;i < length; i++) {
|
|
48936
|
+
try {
|
|
48937
|
+
const key = keys[i].trim();
|
|
48938
|
+
const attrs = _instructions(result, key);
|
|
48939
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
48940
|
+
break;
|
|
48941
|
+
} catch (error3) {
|
|
48942
|
+
if (i + 1 >= length) {
|
|
48943
|
+
throw error3;
|
|
48944
|
+
}
|
|
48945
|
+
}
|
|
48982
48946
|
}
|
|
48947
|
+
return DotenvModule.parse(decrypted);
|
|
48983
48948
|
}
|
|
48984
|
-
|
|
48985
|
-
|
|
48986
|
-
pm23.disconnect();
|
|
48987
|
-
await this.sleep(1000);
|
|
48988
|
-
} catch (e) {
|
|
48989
|
-
console.log("pm2 disconnect error", e);
|
|
48990
|
-
}
|
|
48991
|
-
this.isConnected = false;
|
|
48949
|
+
function _warn(message) {
|
|
48950
|
+
console.error(`[dotenv@${version2}][WARN] ${message}`);
|
|
48992
48951
|
}
|
|
48993
|
-
|
|
48994
|
-
|
|
48995
|
-
class Pm2Manager2 {
|
|
48996
|
-
pm2Connect;
|
|
48997
|
-
appName;
|
|
48998
|
-
script;
|
|
48999
|
-
interpreter;
|
|
49000
|
-
needConnect = true;
|
|
49001
|
-
isConnect = false;
|
|
49002
|
-
env;
|
|
49003
|
-
constructor(opts) {
|
|
49004
|
-
this.appName = opts.appName;
|
|
49005
|
-
this.script = opts.script;
|
|
49006
|
-
this.interpreter = opts.interpreter;
|
|
49007
|
-
this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
|
|
49008
|
-
this.env = opts.env || {};
|
|
48952
|
+
function _debug(message) {
|
|
48953
|
+
console.log(`[dotenv@${version2}][DEBUG] ${message}`);
|
|
49009
48954
|
}
|
|
49010
|
-
|
|
49011
|
-
|
|
49012
|
-
try {
|
|
49013
|
-
await this.pm2Connect.checkConnect();
|
|
49014
|
-
const apps = await list3();
|
|
49015
|
-
return apps;
|
|
49016
|
-
} catch (e) {
|
|
49017
|
-
console.log("pm2 run error", e);
|
|
49018
|
-
return [];
|
|
49019
|
-
} finally {
|
|
49020
|
-
this.pm2Connect.checkDisconnect(_runOpts);
|
|
49021
|
-
}
|
|
48955
|
+
function _log(message) {
|
|
48956
|
+
console.log(`[dotenv@${version2}] ${message}`);
|
|
49022
48957
|
}
|
|
49023
|
-
|
|
49024
|
-
|
|
49025
|
-
|
|
49026
|
-
if (!script) {
|
|
49027
|
-
console.error("script is required");
|
|
49028
|
-
return;
|
|
48958
|
+
function _dotenvKey(options) {
|
|
48959
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
48960
|
+
return options.DOTENV_KEY;
|
|
49029
48961
|
}
|
|
49030
|
-
|
|
49031
|
-
|
|
49032
|
-
name: appName,
|
|
49033
|
-
script: normalizedScript,
|
|
49034
|
-
cwd: process.cwd(),
|
|
49035
|
-
interpreter,
|
|
49036
|
-
...options,
|
|
49037
|
-
env: {
|
|
49038
|
-
NODE_ENV: "production",
|
|
49039
|
-
...env2,
|
|
49040
|
-
...options?.env
|
|
49041
|
-
}
|
|
49042
|
-
};
|
|
49043
|
-
try {
|
|
49044
|
-
await this.pm2Connect.checkConnect();
|
|
49045
|
-
const apps = await this.list({ needExit: false });
|
|
49046
|
-
const app = apps.find((app2) => app2.name === appName);
|
|
49047
|
-
if (app && app.pid === 0) {
|
|
49048
|
-
await start3(starter);
|
|
49049
|
-
return;
|
|
49050
|
-
} else if (!app) {
|
|
49051
|
-
await start3(starter);
|
|
49052
|
-
} else {
|
|
49053
|
-
console.log(`pm2 app ${appName} is running`);
|
|
49054
|
-
}
|
|
49055
|
-
} catch (e) {
|
|
49056
|
-
console.error("error", e);
|
|
49057
|
-
} finally {
|
|
49058
|
-
this.pm2Connect.checkDisconnect({ needExit });
|
|
48962
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
48963
|
+
return process.env.DOTENV_KEY;
|
|
49059
48964
|
}
|
|
48965
|
+
return "";
|
|
49060
48966
|
}
|
|
49061
|
-
|
|
48967
|
+
function _instructions(result, dotenvKey) {
|
|
48968
|
+
let uri;
|
|
49062
48969
|
try {
|
|
49063
|
-
|
|
49064
|
-
|
|
49065
|
-
|
|
49066
|
-
|
|
49067
|
-
|
|
48970
|
+
uri = new URL(dotenvKey);
|
|
48971
|
+
} catch (error3) {
|
|
48972
|
+
if (error3.code === "ERR_INVALID_URL") {
|
|
48973
|
+
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");
|
|
48974
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
48975
|
+
throw err;
|
|
49068
48976
|
}
|
|
49069
|
-
|
|
49070
|
-
|
|
49071
|
-
|
|
49072
|
-
|
|
48977
|
+
throw error3;
|
|
48978
|
+
}
|
|
48979
|
+
const key = uri.password;
|
|
48980
|
+
if (!key) {
|
|
48981
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
48982
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
48983
|
+
throw err;
|
|
48984
|
+
}
|
|
48985
|
+
const environment = uri.searchParams.get("environment");
|
|
48986
|
+
if (!environment) {
|
|
48987
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
48988
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
48989
|
+
throw err;
|
|
48990
|
+
}
|
|
48991
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
48992
|
+
const ciphertext = result.parsed[environmentKey];
|
|
48993
|
+
if (!ciphertext) {
|
|
48994
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
48995
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
48996
|
+
throw err;
|
|
49073
48997
|
}
|
|
48998
|
+
return { ciphertext, key };
|
|
49074
48999
|
}
|
|
49075
|
-
|
|
49076
|
-
|
|
49077
|
-
|
|
49078
|
-
|
|
49079
|
-
|
|
49080
|
-
|
|
49081
|
-
|
|
49000
|
+
function _vaultPath(options) {
|
|
49001
|
+
let possibleVaultPath = null;
|
|
49002
|
+
if (options && options.path && options.path.length > 0) {
|
|
49003
|
+
if (Array.isArray(options.path)) {
|
|
49004
|
+
for (const filepath of options.path) {
|
|
49005
|
+
if (fs6.existsSync(filepath)) {
|
|
49006
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
49007
|
+
}
|
|
49008
|
+
}
|
|
49009
|
+
} else {
|
|
49010
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
49082
49011
|
}
|
|
49083
|
-
}
|
|
49084
|
-
|
|
49085
|
-
}
|
|
49086
|
-
|
|
49012
|
+
} else {
|
|
49013
|
+
possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
|
|
49014
|
+
}
|
|
49015
|
+
if (fs6.existsSync(possibleVaultPath)) {
|
|
49016
|
+
return possibleVaultPath;
|
|
49087
49017
|
}
|
|
49018
|
+
return null;
|
|
49088
49019
|
}
|
|
49089
|
-
|
|
49090
|
-
|
|
49020
|
+
function _resolveHome(envPath) {
|
|
49021
|
+
return envPath[0] === "~" ? path6.join(os2.homedir(), envPath.slice(1)) : envPath;
|
|
49091
49022
|
}
|
|
49092
|
-
|
|
49093
|
-
|
|
49094
|
-
|
|
49095
|
-
|
|
49096
|
-
|
|
49097
|
-
if (app) {
|
|
49098
|
-
await deleteProcess3(app.name);
|
|
49099
|
-
}
|
|
49100
|
-
} catch (e) {
|
|
49101
|
-
console.error("error", e);
|
|
49102
|
-
} finally {
|
|
49103
|
-
this.pm2Connect.checkDisconnect(runOpts);
|
|
49023
|
+
function _configVault(options) {
|
|
49024
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
49025
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
49026
|
+
if (debug || !quiet) {
|
|
49027
|
+
_log("Loading env from encrypted .env.vault");
|
|
49104
49028
|
}
|
|
49105
|
-
|
|
49106
|
-
|
|
49107
|
-
|
|
49108
|
-
|
|
49109
|
-
|
|
49110
|
-
|
|
49029
|
+
const parsed = DotenvModule._parseVault(options);
|
|
49030
|
+
let processEnv = process.env;
|
|
49031
|
+
if (options && options.processEnv != null) {
|
|
49032
|
+
processEnv = options.processEnv;
|
|
49033
|
+
}
|
|
49034
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
49035
|
+
return { parsed };
|
|
49036
|
+
}
|
|
49037
|
+
function configDotenv(options) {
|
|
49038
|
+
const dotenvPath = path6.resolve(process.cwd(), ".env");
|
|
49039
|
+
let encoding = "utf8";
|
|
49040
|
+
let processEnv = process.env;
|
|
49041
|
+
if (options && options.processEnv != null) {
|
|
49042
|
+
processEnv = options.processEnv;
|
|
49043
|
+
}
|
|
49044
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
49045
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
49046
|
+
if (options && options.encoding) {
|
|
49047
|
+
encoding = options.encoding;
|
|
49048
|
+
} else {
|
|
49049
|
+
if (debug) {
|
|
49050
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
49051
|
+
}
|
|
49052
|
+
}
|
|
49053
|
+
let optionPaths = [dotenvPath];
|
|
49054
|
+
if (options && options.path) {
|
|
49055
|
+
if (!Array.isArray(options.path)) {
|
|
49056
|
+
optionPaths = [_resolveHome(options.path)];
|
|
49057
|
+
} else {
|
|
49058
|
+
optionPaths = [];
|
|
49059
|
+
for (const filepath of options.path) {
|
|
49060
|
+
optionPaths.push(_resolveHome(filepath));
|
|
49061
|
+
}
|
|
49062
|
+
}
|
|
49063
|
+
}
|
|
49064
|
+
let lastError;
|
|
49065
|
+
const parsedAll = {};
|
|
49066
|
+
for (const path22 of optionPaths) {
|
|
49067
|
+
try {
|
|
49068
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(path22, { encoding }));
|
|
49069
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
49070
|
+
} catch (e) {
|
|
49071
|
+
if (debug) {
|
|
49072
|
+
_debug(`Failed to load ${path22} ${e.message}`);
|
|
49073
|
+
}
|
|
49074
|
+
lastError = e;
|
|
49075
|
+
}
|
|
49076
|
+
}
|
|
49077
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
49078
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
49079
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
49080
|
+
if (debug || !quiet) {
|
|
49081
|
+
const keysCount = Object.keys(populated).length;
|
|
49082
|
+
const shortPaths = [];
|
|
49083
|
+
for (const filePath of optionPaths) {
|
|
49084
|
+
try {
|
|
49085
|
+
const relative = path6.relative(process.cwd(), filePath);
|
|
49086
|
+
shortPaths.push(relative);
|
|
49087
|
+
} catch (e) {
|
|
49088
|
+
if (debug) {
|
|
49089
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
49090
|
+
}
|
|
49091
|
+
lastError = e;
|
|
49092
|
+
}
|
|
49093
|
+
}
|
|
49094
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
49095
|
+
}
|
|
49096
|
+
if (lastError) {
|
|
49097
|
+
return { parsed: parsedAll, error: lastError };
|
|
49098
|
+
} else {
|
|
49099
|
+
return { parsed: parsedAll };
|
|
49100
|
+
}
|
|
49101
|
+
}
|
|
49102
|
+
function config2(options) {
|
|
49103
|
+
if (_dotenvKey(options).length === 0) {
|
|
49104
|
+
return DotenvModule.configDotenv(options);
|
|
49105
|
+
}
|
|
49106
|
+
const vaultPath = _vaultPath(options);
|
|
49107
|
+
if (!vaultPath) {
|
|
49108
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
49109
|
+
return DotenvModule.configDotenv(options);
|
|
49110
|
+
}
|
|
49111
|
+
return DotenvModule._configVault(options);
|
|
49112
|
+
}
|
|
49113
|
+
function decrypt(encrypted, keyStr) {
|
|
49114
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
49115
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
49116
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
49117
|
+
const authTag = ciphertext.subarray(-16);
|
|
49118
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
49119
|
+
try {
|
|
49120
|
+
const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
|
|
49121
|
+
aesgcm.setAuthTag(authTag);
|
|
49122
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
49123
|
+
} catch (error3) {
|
|
49124
|
+
const isRange = error3 instanceof RangeError;
|
|
49125
|
+
const invalidKeyLength = error3.message === "Invalid key length";
|
|
49126
|
+
const decryptionFailed = error3.message === "Unsupported state or unable to authenticate data";
|
|
49127
|
+
if (isRange || invalidKeyLength) {
|
|
49128
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
49129
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
49130
|
+
throw err;
|
|
49131
|
+
} else if (decryptionFailed) {
|
|
49132
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
49133
|
+
err.code = "DECRYPTION_FAILED";
|
|
49134
|
+
throw err;
|
|
49135
|
+
} else {
|
|
49136
|
+
throw error3;
|
|
49137
|
+
}
|
|
49138
|
+
}
|
|
49139
|
+
}
|
|
49140
|
+
function populate(processEnv, parsed, options = {}) {
|
|
49141
|
+
const debug = Boolean(options && options.debug);
|
|
49142
|
+
const override = Boolean(options && options.override);
|
|
49143
|
+
const populated = {};
|
|
49144
|
+
if (typeof parsed !== "object") {
|
|
49145
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
49146
|
+
err.code = "OBJECT_REQUIRED";
|
|
49147
|
+
throw err;
|
|
49148
|
+
}
|
|
49149
|
+
for (const key of Object.keys(parsed)) {
|
|
49150
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
49151
|
+
if (override === true) {
|
|
49152
|
+
processEnv[key] = parsed[key];
|
|
49153
|
+
populated[key] = parsed[key];
|
|
49154
|
+
}
|
|
49155
|
+
if (debug) {
|
|
49156
|
+
if (override === true) {
|
|
49157
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
49158
|
+
} else {
|
|
49159
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
49160
|
+
}
|
|
49161
|
+
}
|
|
49162
|
+
} else {
|
|
49163
|
+
processEnv[key] = parsed[key];
|
|
49164
|
+
populated[key] = parsed[key];
|
|
49165
|
+
}
|
|
49166
|
+
}
|
|
49167
|
+
return populated;
|
|
49168
|
+
}
|
|
49169
|
+
var DotenvModule = {
|
|
49170
|
+
configDotenv,
|
|
49171
|
+
_configVault,
|
|
49172
|
+
_parseVault,
|
|
49173
|
+
config: config2,
|
|
49174
|
+
decrypt,
|
|
49175
|
+
parse: parse2,
|
|
49176
|
+
populate
|
|
49177
|
+
};
|
|
49178
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
|
49179
|
+
exports._configVault = DotenvModule._configVault;
|
|
49180
|
+
exports._parseVault = DotenvModule._parseVault;
|
|
49181
|
+
exports.config = DotenvModule.config;
|
|
49182
|
+
exports.decrypt = DotenvModule.decrypt;
|
|
49183
|
+
exports.parse = DotenvModule.parse;
|
|
49184
|
+
exports.populate = DotenvModule.populate;
|
|
49185
|
+
module.exports = DotenvModule;
|
|
49186
|
+
});
|
|
49187
|
+
var import_dotenv3 = __toESM3(require_main3(), 1);
|
|
49188
|
+
var fileIsExist2 = (path22) => {
|
|
49189
|
+
try {
|
|
49190
|
+
fs5.accessSync(path22, fs5.constants.F_OK);
|
|
49191
|
+
return true;
|
|
49192
|
+
} catch (e) {
|
|
49193
|
+
return false;
|
|
49194
|
+
}
|
|
49195
|
+
};
|
|
49196
|
+
var getCwdDirname2 = () => {
|
|
49197
|
+
return process.cwd();
|
|
49198
|
+
};
|
|
49199
|
+
var getConfigFile2 = (opts) => {
|
|
49200
|
+
if (opts?.envConfigFile) {
|
|
49201
|
+
const filePath = path5.join(opts.cwd || getCwdDirname2(), opts.envConfigFile);
|
|
49202
|
+
if (fileIsExist2(filePath)) {
|
|
49203
|
+
return filePath;
|
|
49204
|
+
}
|
|
49205
|
+
}
|
|
49206
|
+
const fileName = opts?.fileName || ".env";
|
|
49207
|
+
const dirname = opts?.cwd || getCwdDirname2();
|
|
49208
|
+
const benPath = dirname + "/" + fileName;
|
|
49209
|
+
const ben = fileIsExist2(benPath);
|
|
49210
|
+
if (ben)
|
|
49211
|
+
return benPath;
|
|
49212
|
+
const lastPath = path5.join(dirname, "../" + fileName);
|
|
49213
|
+
const last = fileIsExist2(lastPath);
|
|
49214
|
+
if (last)
|
|
49215
|
+
return lastPath;
|
|
49216
|
+
const lastLastPath = path5.join(dirname, "../../" + fileName);
|
|
49217
|
+
const lastLast = fileIsExist2(lastLastPath);
|
|
49218
|
+
if (lastLast)
|
|
49219
|
+
return lastLastPath;
|
|
49220
|
+
return "";
|
|
49221
|
+
};
|
|
49222
|
+
var getConfig = (opts) => {
|
|
49223
|
+
let quiet = opts?.quite ?? true;
|
|
49224
|
+
const showError = opts?.showError ?? false;
|
|
49225
|
+
if (opts?.dotenvOpts) {
|
|
49226
|
+
const prased = import_dotenv3.default.config({ quiet, ...opts.dotenvOpts }).parsed;
|
|
49227
|
+
if (prased) {
|
|
49228
|
+
return prased;
|
|
49229
|
+
} else {
|
|
49230
|
+
if (showError) {
|
|
49231
|
+
if (!quiet) {
|
|
49232
|
+
console.warn("config 读取失败");
|
|
49233
|
+
}
|
|
49234
|
+
throw new Error("未找到配置文件");
|
|
49235
|
+
}
|
|
49236
|
+
return {};
|
|
49237
|
+
}
|
|
49238
|
+
}
|
|
49239
|
+
const filePath = getConfigFile2(opts);
|
|
49240
|
+
if (!quiet && filePath) {
|
|
49241
|
+
console.log("config pathname:", filePath);
|
|
49242
|
+
}
|
|
49243
|
+
if (!filePath) {
|
|
49244
|
+
if (showError) {
|
|
49245
|
+
if (!quiet) {
|
|
49246
|
+
console.warn("config 路径未找到");
|
|
49247
|
+
}
|
|
49248
|
+
throw new Error("未找到配置文件");
|
|
49249
|
+
}
|
|
49250
|
+
return {};
|
|
49251
|
+
}
|
|
49252
|
+
const value = import_dotenv3.default.config({ quiet: true, path: filePath }).parsed;
|
|
49253
|
+
return value;
|
|
49254
|
+
};
|
|
49255
|
+
var useConfig = (onlyInitConfig, force) => {
|
|
49256
|
+
const config2 = global.config;
|
|
49257
|
+
let _config = config2 || getConfig(onlyInitConfig);
|
|
49258
|
+
!config2 && (global["config"] = _config);
|
|
49259
|
+
if (force && onlyInitConfig) {
|
|
49260
|
+
const _newConfig = getConfig(onlyInitConfig);
|
|
49261
|
+
_config = mergeConfig(_newConfig);
|
|
49262
|
+
}
|
|
49263
|
+
return _config;
|
|
49264
|
+
};
|
|
49265
|
+
var mergeConfig = (config2) => {
|
|
49266
|
+
const _config = global.config || {};
|
|
49267
|
+
Object.assign(_config, config2);
|
|
49268
|
+
global.config = _config;
|
|
49269
|
+
return _config;
|
|
49270
|
+
};
|
|
49271
|
+
var useKey = (key, opts) => {
|
|
49272
|
+
let v = useConfig()[key];
|
|
49273
|
+
if (!v) {
|
|
49274
|
+
v = process.env[key];
|
|
49275
|
+
}
|
|
49276
|
+
if (!v) {
|
|
49277
|
+
return opts?.defaultValue || null;
|
|
49278
|
+
}
|
|
49279
|
+
if (opts?.isNumber && typeof v === "string") {
|
|
49280
|
+
return Number(v);
|
|
49281
|
+
}
|
|
49282
|
+
if (opts?.isBoolean && typeof v === "string") {
|
|
49283
|
+
return v === "true";
|
|
49284
|
+
}
|
|
49285
|
+
return v;
|
|
49286
|
+
};
|
|
49287
|
+
var useFileStore2 = (str, opts) => {
|
|
49288
|
+
const publicPath = process.cwd();
|
|
49289
|
+
const filePath = path5.join(publicPath, str);
|
|
49290
|
+
if (opts?.needExists) {
|
|
49291
|
+
if (!fileIsExist2(filePath)) {
|
|
49292
|
+
fs5.mkdirSync(filePath, { recursive: true });
|
|
49293
|
+
}
|
|
49294
|
+
}
|
|
49295
|
+
return filePath;
|
|
49296
|
+
};
|
|
49297
|
+
var isBrowser3 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
49298
|
+
function getDefaultExportFromCjs4(x) {
|
|
49299
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
49300
|
+
}
|
|
49301
|
+
var eventemitter33 = { exports: {} };
|
|
49302
|
+
var hasRequiredEventemitter33;
|
|
49303
|
+
function requireEventemitter33() {
|
|
49304
|
+
if (hasRequiredEventemitter33)
|
|
49305
|
+
return eventemitter33.exports;
|
|
49306
|
+
hasRequiredEventemitter33 = 1;
|
|
49307
|
+
(function(module) {
|
|
49308
|
+
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
49309
|
+
function Events() {}
|
|
49310
|
+
if (Object.create) {
|
|
49311
|
+
Events.prototype = Object.create(null);
|
|
49312
|
+
if (!new Events().__proto__)
|
|
49313
|
+
prefix = false;
|
|
49314
|
+
}
|
|
49315
|
+
function EE(fn, context, once) {
|
|
49316
|
+
this.fn = fn;
|
|
49317
|
+
this.context = context;
|
|
49318
|
+
this.once = once || false;
|
|
49319
|
+
}
|
|
49320
|
+
function addListener(emitter, event, fn, context, once) {
|
|
49321
|
+
if (typeof fn !== "function") {
|
|
49322
|
+
throw new TypeError("The listener must be a function");
|
|
49323
|
+
}
|
|
49324
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
49325
|
+
if (!emitter._events[evt])
|
|
49326
|
+
emitter._events[evt] = listener, emitter._eventsCount++;
|
|
49327
|
+
else if (!emitter._events[evt].fn)
|
|
49328
|
+
emitter._events[evt].push(listener);
|
|
49329
|
+
else
|
|
49330
|
+
emitter._events[evt] = [emitter._events[evt], listener];
|
|
49331
|
+
return emitter;
|
|
49332
|
+
}
|
|
49333
|
+
function clearEvent(emitter, evt) {
|
|
49334
|
+
if (--emitter._eventsCount === 0)
|
|
49335
|
+
emitter._events = new Events;
|
|
49336
|
+
else
|
|
49337
|
+
delete emitter._events[evt];
|
|
49338
|
+
}
|
|
49339
|
+
function EventEmitter3() {
|
|
49340
|
+
this._events = new Events;
|
|
49341
|
+
this._eventsCount = 0;
|
|
49342
|
+
}
|
|
49343
|
+
EventEmitter3.prototype.eventNames = function eventNames() {
|
|
49344
|
+
var names = [], events, name;
|
|
49345
|
+
if (this._eventsCount === 0)
|
|
49346
|
+
return names;
|
|
49347
|
+
for (name in events = this._events) {
|
|
49348
|
+
if (has.call(events, name))
|
|
49349
|
+
names.push(prefix ? name.slice(1) : name);
|
|
49350
|
+
}
|
|
49351
|
+
if (Object.getOwnPropertySymbols) {
|
|
49352
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
49353
|
+
}
|
|
49354
|
+
return names;
|
|
49355
|
+
};
|
|
49356
|
+
EventEmitter3.prototype.listeners = function listeners(event) {
|
|
49357
|
+
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
49358
|
+
if (!handlers)
|
|
49359
|
+
return [];
|
|
49360
|
+
if (handlers.fn)
|
|
49361
|
+
return [handlers.fn];
|
|
49362
|
+
for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
|
|
49363
|
+
ee[i] = handlers[i].fn;
|
|
49364
|
+
}
|
|
49365
|
+
return ee;
|
|
49366
|
+
};
|
|
49367
|
+
EventEmitter3.prototype.listenerCount = function listenerCount(event) {
|
|
49368
|
+
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
49369
|
+
if (!listeners)
|
|
49370
|
+
return 0;
|
|
49371
|
+
if (listeners.fn)
|
|
49372
|
+
return 1;
|
|
49373
|
+
return listeners.length;
|
|
49374
|
+
};
|
|
49375
|
+
EventEmitter3.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
49376
|
+
var evt = prefix ? prefix + event : event;
|
|
49377
|
+
if (!this._events[evt])
|
|
49378
|
+
return false;
|
|
49379
|
+
var listeners = this._events[evt], len = arguments.length, args2, i;
|
|
49380
|
+
if (listeners.fn) {
|
|
49381
|
+
if (listeners.once)
|
|
49382
|
+
this.removeListener(event, listeners.fn, undefined, true);
|
|
49383
|
+
switch (len) {
|
|
49384
|
+
case 1:
|
|
49385
|
+
return listeners.fn.call(listeners.context), true;
|
|
49386
|
+
case 2:
|
|
49387
|
+
return listeners.fn.call(listeners.context, a1), true;
|
|
49388
|
+
case 3:
|
|
49389
|
+
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
49390
|
+
case 4:
|
|
49391
|
+
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
49392
|
+
case 5:
|
|
49393
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
49394
|
+
case 6:
|
|
49395
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
49396
|
+
}
|
|
49397
|
+
for (i = 1, args2 = new Array(len - 1);i < len; i++) {
|
|
49398
|
+
args2[i - 1] = arguments[i];
|
|
49399
|
+
}
|
|
49400
|
+
listeners.fn.apply(listeners.context, args2);
|
|
49401
|
+
} else {
|
|
49402
|
+
var length = listeners.length, j;
|
|
49403
|
+
for (i = 0;i < length; i++) {
|
|
49404
|
+
if (listeners[i].once)
|
|
49405
|
+
this.removeListener(event, listeners[i].fn, undefined, true);
|
|
49406
|
+
switch (len) {
|
|
49407
|
+
case 1:
|
|
49408
|
+
listeners[i].fn.call(listeners[i].context);
|
|
49409
|
+
break;
|
|
49410
|
+
case 2:
|
|
49411
|
+
listeners[i].fn.call(listeners[i].context, a1);
|
|
49412
|
+
break;
|
|
49413
|
+
case 3:
|
|
49414
|
+
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
49415
|
+
break;
|
|
49416
|
+
case 4:
|
|
49417
|
+
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
49418
|
+
break;
|
|
49419
|
+
default:
|
|
49420
|
+
if (!args2)
|
|
49421
|
+
for (j = 1, args2 = new Array(len - 1);j < len; j++) {
|
|
49422
|
+
args2[j - 1] = arguments[j];
|
|
49423
|
+
}
|
|
49424
|
+
listeners[i].fn.apply(listeners[i].context, args2);
|
|
49425
|
+
}
|
|
49426
|
+
}
|
|
49427
|
+
}
|
|
49428
|
+
return true;
|
|
49429
|
+
};
|
|
49430
|
+
EventEmitter3.prototype.on = function on(event, fn, context) {
|
|
49431
|
+
return addListener(this, event, fn, context, false);
|
|
49432
|
+
};
|
|
49433
|
+
EventEmitter3.prototype.once = function once(event, fn, context) {
|
|
49434
|
+
return addListener(this, event, fn, context, true);
|
|
49435
|
+
};
|
|
49436
|
+
EventEmitter3.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
49437
|
+
var evt = prefix ? prefix + event : event;
|
|
49438
|
+
if (!this._events[evt])
|
|
49439
|
+
return this;
|
|
49440
|
+
if (!fn) {
|
|
49441
|
+
clearEvent(this, evt);
|
|
49442
|
+
return this;
|
|
49443
|
+
}
|
|
49444
|
+
var listeners = this._events[evt];
|
|
49445
|
+
if (listeners.fn) {
|
|
49446
|
+
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
49447
|
+
clearEvent(this, evt);
|
|
49448
|
+
}
|
|
49449
|
+
} else {
|
|
49450
|
+
for (var i = 0, events = [], length = listeners.length;i < length; i++) {
|
|
49451
|
+
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
49452
|
+
events.push(listeners[i]);
|
|
49453
|
+
}
|
|
49454
|
+
}
|
|
49455
|
+
if (events.length)
|
|
49456
|
+
this._events[evt] = events.length === 1 ? events[0] : events;
|
|
49457
|
+
else
|
|
49458
|
+
clearEvent(this, evt);
|
|
49459
|
+
}
|
|
49460
|
+
return this;
|
|
49461
|
+
};
|
|
49462
|
+
EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
49463
|
+
var evt;
|
|
49464
|
+
if (event) {
|
|
49465
|
+
evt = prefix ? prefix + event : event;
|
|
49466
|
+
if (this._events[evt])
|
|
49467
|
+
clearEvent(this, evt);
|
|
49468
|
+
} else {
|
|
49469
|
+
this._events = new Events;
|
|
49470
|
+
this._eventsCount = 0;
|
|
49471
|
+
}
|
|
49472
|
+
return this;
|
|
49473
|
+
};
|
|
49474
|
+
EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
|
|
49475
|
+
EventEmitter3.prototype.addListener = EventEmitter3.prototype.on;
|
|
49476
|
+
EventEmitter3.prefixed = prefix;
|
|
49477
|
+
EventEmitter3.EventEmitter = EventEmitter3;
|
|
49478
|
+
{
|
|
49479
|
+
module.exports = EventEmitter3;
|
|
49480
|
+
}
|
|
49481
|
+
})(eventemitter33);
|
|
49482
|
+
return eventemitter33.exports;
|
|
49483
|
+
}
|
|
49484
|
+
var eventemitter3Exports3 = requireEventemitter33();
|
|
49485
|
+
var EventEmitter3 = /* @__PURE__ */ getDefaultExportFromCjs4(eventemitter3Exports3);
|
|
49486
|
+
var reRunFn2 = (promiseOpts) => {
|
|
49487
|
+
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
49488
|
+
const interval = promiseOpts.interval || 1000;
|
|
49489
|
+
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
49490
|
+
const signal = promiseOpts.signal;
|
|
49491
|
+
return new Promise(async (resolve, reject) => {
|
|
49492
|
+
let intervalId;
|
|
49493
|
+
let timeoutId = setTimeout(() => {
|
|
49494
|
+
clearTimeout(intervalId);
|
|
49495
|
+
resolve({
|
|
49496
|
+
code: 500,
|
|
49497
|
+
message: "timeout"
|
|
49498
|
+
});
|
|
49499
|
+
}, timeout);
|
|
49500
|
+
const fn = promiseOpts.fn || (() => true);
|
|
49501
|
+
const runFn = async () => {
|
|
49502
|
+
if (signal?.aborted) {
|
|
49503
|
+
clearInterval(intervalId);
|
|
49504
|
+
clearTimeout(timeoutId);
|
|
49505
|
+
return resolve({
|
|
49506
|
+
code: 499,
|
|
49507
|
+
message: "operation cancelled"
|
|
49508
|
+
});
|
|
49509
|
+
}
|
|
49510
|
+
const res = await fn();
|
|
49511
|
+
if (!!checkSuccess(res)) {
|
|
49512
|
+
clearInterval(intervalId);
|
|
49513
|
+
clearTimeout(timeoutId);
|
|
49514
|
+
resolve({
|
|
49515
|
+
code: 200,
|
|
49516
|
+
data: res
|
|
49517
|
+
});
|
|
49518
|
+
} else {
|
|
49519
|
+
setTimeout(() => {
|
|
49520
|
+
runFn();
|
|
49521
|
+
}, interval);
|
|
49522
|
+
}
|
|
49523
|
+
};
|
|
49524
|
+
if (signal) {
|
|
49525
|
+
signal.addEventListener("abort", () => {
|
|
49526
|
+
clearInterval(intervalId);
|
|
49527
|
+
clearTimeout(timeoutId);
|
|
49528
|
+
resolve({
|
|
49529
|
+
code: 499,
|
|
49530
|
+
message: "operation cancelled"
|
|
49531
|
+
});
|
|
49532
|
+
});
|
|
49533
|
+
}
|
|
49534
|
+
runFn();
|
|
49535
|
+
});
|
|
49536
|
+
};
|
|
49537
|
+
|
|
49538
|
+
class BaseLoad2 {
|
|
49539
|
+
modules = new Map;
|
|
49540
|
+
event;
|
|
49541
|
+
loading;
|
|
49542
|
+
static reRunFn = reRunFn2;
|
|
49543
|
+
timeout = 5 * 60 * 1000;
|
|
49544
|
+
constructor() {
|
|
49545
|
+
this.event = new EventEmitter3;
|
|
49546
|
+
this.loading = false;
|
|
49547
|
+
}
|
|
49548
|
+
listenKey(key, listenOpts) {
|
|
49549
|
+
const timeout = listenOpts?.timeout ?? this.timeout;
|
|
49550
|
+
return new Promise((resolve) => {
|
|
49551
|
+
const timeoutId = setTimeout(() => {
|
|
49552
|
+
this.event.removeListener(key, onEvent);
|
|
49553
|
+
resolve({
|
|
49554
|
+
code: 500,
|
|
49555
|
+
message: "timeout"
|
|
49556
|
+
});
|
|
49557
|
+
}, timeout);
|
|
49558
|
+
const onEvent = (error3) => {
|
|
49559
|
+
clearTimeout(timeoutId);
|
|
49560
|
+
if (error3) {
|
|
49561
|
+
return resolve({
|
|
49562
|
+
code: 500,
|
|
49563
|
+
message: error3
|
|
49564
|
+
});
|
|
49565
|
+
}
|
|
49566
|
+
const data = this.modules.get(key);
|
|
49567
|
+
if (data?.loadSuccessClear) {
|
|
49568
|
+
this.remove(key);
|
|
49569
|
+
}
|
|
49570
|
+
resolve({
|
|
49571
|
+
code: 200,
|
|
49572
|
+
data: data?.modules
|
|
49573
|
+
});
|
|
49574
|
+
};
|
|
49575
|
+
this.event.once(key, onEvent);
|
|
49576
|
+
});
|
|
49577
|
+
}
|
|
49578
|
+
async hasLoaded(key, hasLoadOpts) {
|
|
49579
|
+
if (!key) {
|
|
49580
|
+
return {
|
|
49581
|
+
code: 404,
|
|
49582
|
+
message: "key is required"
|
|
49583
|
+
};
|
|
49584
|
+
}
|
|
49585
|
+
const has = this.modules.has(key);
|
|
49586
|
+
if (!has) {
|
|
49587
|
+
const isExist = hasLoadOpts?.isExist ?? true;
|
|
49588
|
+
const timeout = hasLoadOpts?.timeout ?? this.timeout;
|
|
49589
|
+
if (isExist) {
|
|
49590
|
+
return await this.listenKey(key, { timeout });
|
|
49591
|
+
}
|
|
49592
|
+
return {
|
|
49593
|
+
code: 404
|
|
49594
|
+
};
|
|
49595
|
+
}
|
|
49596
|
+
const data = this.modules.get(key);
|
|
49597
|
+
if (data?.status === "loaded") {
|
|
49598
|
+
return {
|
|
49599
|
+
code: 200,
|
|
49600
|
+
data: data.modules
|
|
49601
|
+
};
|
|
49602
|
+
}
|
|
49603
|
+
if (data?.status === "loading") {
|
|
49604
|
+
return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
|
|
49605
|
+
}
|
|
49606
|
+
if (data?.status === "error") {
|
|
49607
|
+
return {
|
|
49608
|
+
code: 500,
|
|
49609
|
+
message: "load error"
|
|
49610
|
+
};
|
|
49611
|
+
}
|
|
49612
|
+
if (data?.status === "cancel") {
|
|
49613
|
+
return {
|
|
49614
|
+
code: 499,
|
|
49615
|
+
message: "operation cancelled"
|
|
49616
|
+
};
|
|
49617
|
+
}
|
|
49618
|
+
return {
|
|
49619
|
+
code: 404
|
|
49620
|
+
};
|
|
49621
|
+
}
|
|
49622
|
+
async loadFn(loadContent, opts) {
|
|
49623
|
+
const key = opts.key;
|
|
49624
|
+
if (!key) {
|
|
49625
|
+
return {
|
|
49626
|
+
code: 404,
|
|
49627
|
+
message: "key is required"
|
|
49628
|
+
};
|
|
49629
|
+
}
|
|
49630
|
+
const newModule = {
|
|
49631
|
+
key: opts.key,
|
|
49632
|
+
status: "loading",
|
|
49633
|
+
loading: true,
|
|
49634
|
+
loadSuccessClear: opts.loadSuccessClear ?? true
|
|
49635
|
+
};
|
|
49636
|
+
let errorMessage = "";
|
|
49637
|
+
try {
|
|
49638
|
+
const isReRun = opts.isReRun ?? false;
|
|
49639
|
+
let res;
|
|
49640
|
+
if (!isReRun) {
|
|
49641
|
+
this.modules.set(key, newModule);
|
|
49642
|
+
res = await loadContent();
|
|
49643
|
+
} else {
|
|
49644
|
+
newModule.controller = new AbortController;
|
|
49645
|
+
const signal = newModule.controller.signal;
|
|
49646
|
+
this.modules.set(key, newModule);
|
|
49647
|
+
const data = await reRunFn2({
|
|
49648
|
+
timeout: opts.timeout,
|
|
49649
|
+
interval: opts.interval,
|
|
49650
|
+
checkSuccess: opts.checkSuccess,
|
|
49651
|
+
fn: loadContent,
|
|
49652
|
+
signal
|
|
49653
|
+
});
|
|
49654
|
+
newModule.controller = null;
|
|
49655
|
+
if (data.code === 499) {
|
|
49656
|
+
newModule.status = "cancel";
|
|
49657
|
+
return {
|
|
49658
|
+
code: 499,
|
|
49659
|
+
message: "operation cancelled"
|
|
49660
|
+
};
|
|
49661
|
+
}
|
|
49662
|
+
if (data.code !== 200) {
|
|
49663
|
+
throw new Error(data.message);
|
|
49664
|
+
}
|
|
49665
|
+
res = data.data;
|
|
49666
|
+
}
|
|
49667
|
+
newModule.modules = res;
|
|
49668
|
+
newModule.status = "loaded";
|
|
49669
|
+
return {
|
|
49670
|
+
code: 200,
|
|
49671
|
+
data: res
|
|
49672
|
+
};
|
|
49673
|
+
} catch (error3) {
|
|
49674
|
+
errorMessage = error3.message;
|
|
49675
|
+
newModule.status = "error";
|
|
49676
|
+
return {
|
|
49677
|
+
code: 500,
|
|
49678
|
+
message: error3
|
|
49679
|
+
};
|
|
49680
|
+
} finally {
|
|
49681
|
+
newModule.loading = false;
|
|
49682
|
+
this.modules.set(opts.key, newModule);
|
|
49683
|
+
if (!errorMessage) {
|
|
49684
|
+
this.event.emit(opts.key);
|
|
49685
|
+
} else {
|
|
49686
|
+
this.event.emit(opts.key, errorMessage);
|
|
49687
|
+
}
|
|
49688
|
+
}
|
|
49689
|
+
}
|
|
49690
|
+
async load(loadContent, opts) {
|
|
49691
|
+
this.loading = true;
|
|
49692
|
+
const key = opts.key;
|
|
49693
|
+
if (!key) {
|
|
49694
|
+
return {
|
|
49695
|
+
code: 404,
|
|
49696
|
+
message: "key is required"
|
|
49697
|
+
};
|
|
49698
|
+
}
|
|
49699
|
+
if (opts?.force) {
|
|
49700
|
+
this.remove(key);
|
|
49701
|
+
}
|
|
49702
|
+
const has = this.modules.has(key);
|
|
49703
|
+
if (has) {
|
|
49704
|
+
return await this.hasLoaded(key);
|
|
49705
|
+
}
|
|
49706
|
+
if (typeof loadContent === "function") {
|
|
49707
|
+
return this.loadFn(loadContent, opts);
|
|
49708
|
+
}
|
|
49709
|
+
console.error("loadContent is not a function and not has loaded");
|
|
49710
|
+
}
|
|
49711
|
+
remove(key) {
|
|
49712
|
+
const has = this.modules.has(key);
|
|
49713
|
+
if (has) {
|
|
49714
|
+
this.checkRemoveController(key);
|
|
49715
|
+
this.modules.delete(key);
|
|
49716
|
+
}
|
|
49717
|
+
}
|
|
49718
|
+
emitLoaded(key) {
|
|
49719
|
+
this.checkRemoveController(key);
|
|
49720
|
+
this.event.emit(key);
|
|
49721
|
+
}
|
|
49722
|
+
setModule(key, data, loadData) {
|
|
49723
|
+
const newModule = {
|
|
49724
|
+
key,
|
|
49725
|
+
status: "loaded",
|
|
49726
|
+
loading: false,
|
|
49727
|
+
modules: data || {},
|
|
49728
|
+
...loadData
|
|
49729
|
+
};
|
|
49730
|
+
this.modules.set(key, newModule);
|
|
49731
|
+
this.emitLoaded(key);
|
|
49732
|
+
return newModule;
|
|
49733
|
+
}
|
|
49734
|
+
cancel(key) {
|
|
49735
|
+
this.checkRemoveController(key);
|
|
49736
|
+
}
|
|
49737
|
+
checkRemoveController(key) {
|
|
49738
|
+
const data = this.modules.get(key);
|
|
49739
|
+
if (data?.controller) {
|
|
49740
|
+
data.controller?.abort?.();
|
|
49741
|
+
delete data.controller;
|
|
49742
|
+
this.modules.set(key, data);
|
|
49743
|
+
}
|
|
49744
|
+
}
|
|
49745
|
+
}
|
|
49746
|
+
var gt2 = globalThis || window || self;
|
|
49747
|
+
var useEnv2 = (initEnv, initKey = "config", isOverwrite) => {
|
|
49748
|
+
const env2 = gt2[initKey];
|
|
49749
|
+
const _env = env2 || initEnv;
|
|
49750
|
+
if (!env2) {
|
|
49751
|
+
if (_env) {
|
|
49752
|
+
gt2[initKey] = _env;
|
|
49753
|
+
} else {
|
|
49754
|
+
gt2[initKey] = {};
|
|
49755
|
+
}
|
|
49756
|
+
} else if (isOverwrite) {
|
|
49757
|
+
gt2[initKey] = { ...env2, ...initEnv };
|
|
49758
|
+
}
|
|
49759
|
+
return gt2[initKey];
|
|
49760
|
+
};
|
|
49761
|
+
var useEnvKey2 = (key, init, initKey = "config") => {
|
|
49762
|
+
const _env = useEnv2({}, initKey);
|
|
49763
|
+
if (key && typeof _env[key] !== "undefined") {
|
|
49764
|
+
return _env[key];
|
|
49765
|
+
}
|
|
49766
|
+
if (key && init) {
|
|
49767
|
+
if (typeof init !== "function") {
|
|
49768
|
+
_env[key] = init;
|
|
49769
|
+
}
|
|
49770
|
+
if (typeof init === "function") {
|
|
49771
|
+
const result = init();
|
|
49772
|
+
if (result instanceof Promise) {
|
|
49773
|
+
return result.then((res) => {
|
|
49774
|
+
_env[key] = res;
|
|
49775
|
+
return res;
|
|
49776
|
+
});
|
|
49777
|
+
}
|
|
49778
|
+
_env[key] = result;
|
|
49779
|
+
}
|
|
49780
|
+
return _env[key];
|
|
49781
|
+
}
|
|
49782
|
+
if (key) {
|
|
49783
|
+
const baseLoad = new BaseLoad2;
|
|
49784
|
+
const voidFn = async () => {
|
|
49785
|
+
return _env[key];
|
|
49786
|
+
};
|
|
49787
|
+
const checkFn = async () => {
|
|
49788
|
+
const loadRes = await baseLoad.load(voidFn, {
|
|
49789
|
+
key,
|
|
49790
|
+
isReRun: true,
|
|
49791
|
+
checkSuccess: () => _env[key],
|
|
49792
|
+
timeout: 5 * 60 * 1000,
|
|
49793
|
+
interval: 1000
|
|
49794
|
+
});
|
|
49795
|
+
if (loadRes.code !== 200) {
|
|
49796
|
+
console.error("load key error");
|
|
49797
|
+
return null;
|
|
49798
|
+
}
|
|
49799
|
+
return _env[key];
|
|
49800
|
+
};
|
|
49801
|
+
return checkFn();
|
|
49802
|
+
}
|
|
49803
|
+
console.error("key is empty ");
|
|
49804
|
+
return null;
|
|
49805
|
+
};
|
|
49806
|
+
var useEnvKeyNew2 = (key, initKey = "config", opts) => {
|
|
49807
|
+
const _env = useEnv2({}, initKey);
|
|
49808
|
+
if (key) {
|
|
49809
|
+
delete _env[key];
|
|
49810
|
+
}
|
|
49811
|
+
if (opts?.getNew && opts.init) {
|
|
49812
|
+
return useEnvKey2(key, opts.init, initKey);
|
|
49813
|
+
} else if (opts?.getNew) {
|
|
49814
|
+
return useEnvKey2(key, null, initKey);
|
|
49815
|
+
}
|
|
49816
|
+
};
|
|
49817
|
+
var useContextKey2 = (key, init, isNew) => {
|
|
49818
|
+
if (isNew) {
|
|
49819
|
+
return useEnvKeyNew2(key, "context", { getNew: true, init });
|
|
49820
|
+
}
|
|
49821
|
+
return useEnvKey2(key, init, "context");
|
|
49822
|
+
};
|
|
49823
|
+
var use2 = useContextKey2;
|
|
49824
|
+
var useConfigKey2 = (key, init, isNew) => {
|
|
49825
|
+
if (isNew) {
|
|
49826
|
+
return useEnvKeyNew2(key, "config", { getNew: true, init });
|
|
49827
|
+
}
|
|
49828
|
+
return useEnvKey2(key, init, "config");
|
|
49829
|
+
};
|
|
49830
|
+
|
|
49831
|
+
class InitEnv2 {
|
|
49832
|
+
static isInit = false;
|
|
49833
|
+
static init(opts) {
|
|
49834
|
+
if (InitEnv2.isInit) {
|
|
49835
|
+
return;
|
|
49836
|
+
}
|
|
49837
|
+
const { load = true, page = false } = opts || {};
|
|
49838
|
+
InitEnv2.isInit = true;
|
|
49839
|
+
gt2.useConfigKey = useConfigKey2;
|
|
49840
|
+
gt2.useContextKey = useContextKey2;
|
|
49841
|
+
gt2.use = use2;
|
|
49842
|
+
gt2.webEnv = { useConfigKey: useConfigKey2, useContextKey: useContextKey2, use: use2 };
|
|
49843
|
+
load && (gt2.Load = BaseLoad2);
|
|
49844
|
+
}
|
|
49845
|
+
}
|
|
49846
|
+
InitEnv2.init();
|
|
49847
|
+
|
|
49848
|
+
// src/module/local-apps/src/modules/app-file.ts
|
|
49849
|
+
import path6 from "node:path";
|
|
49850
|
+
import fs6 from "node:fs";
|
|
49851
|
+
var getAppsPath2 = () => {
|
|
49852
|
+
const appsPath = process.env.APPS_PATH;
|
|
49853
|
+
if (appsPath) {
|
|
49854
|
+
const resolvePath = path6.resolve(appsPath);
|
|
49855
|
+
if (fileIsExist2(resolvePath)) {
|
|
49856
|
+
return resolvePath;
|
|
49857
|
+
} else {
|
|
49858
|
+
fs6.mkdirSync(resolvePath, { recursive: true });
|
|
49859
|
+
return resolvePath;
|
|
49860
|
+
}
|
|
49861
|
+
}
|
|
49862
|
+
return useFileStore2("apps", { needExists: true });
|
|
49863
|
+
};
|
|
49864
|
+
var loadAppInfo2 = async (appsPath = "apps", filename = "apps.config.json") => {
|
|
49865
|
+
let configFile = getConfigFile2({
|
|
49866
|
+
cwd: appsPath,
|
|
49867
|
+
fileName: filename
|
|
49868
|
+
});
|
|
49869
|
+
if (!configFile) {
|
|
49870
|
+
configFile = path6.join(appsPath, "..", filename);
|
|
49871
|
+
fs6.writeFileSync(configFile, JSON.stringify({ list: [] }));
|
|
49872
|
+
return { list: [] };
|
|
49873
|
+
}
|
|
49874
|
+
try {
|
|
49875
|
+
const config2 = fs6.readFileSync(configFile, "utf-8");
|
|
49876
|
+
const v = JSON.parse(config2);
|
|
49877
|
+
if (!v.list) {
|
|
49878
|
+
v.list = [];
|
|
49879
|
+
}
|
|
49880
|
+
return v;
|
|
49881
|
+
} catch (e) {
|
|
49882
|
+
console.error("读取配置文件失败", e.message);
|
|
49883
|
+
return { list: [] };
|
|
49884
|
+
}
|
|
49885
|
+
};
|
|
49886
|
+
var saveAppInfo2 = async (data, appsPath, filename = "apps.config.json") => {
|
|
49887
|
+
const configFile = getConfigFile2({
|
|
49888
|
+
fileName: filename,
|
|
49889
|
+
cwd: appsPath
|
|
49890
|
+
});
|
|
49891
|
+
if (!configFile) {
|
|
49892
|
+
console.error("未找到配置文件");
|
|
49893
|
+
return;
|
|
49894
|
+
}
|
|
49895
|
+
fs6.writeFileSync(configFile, JSON.stringify(data, null, 2));
|
|
49896
|
+
};
|
|
49897
|
+
var deleteFileAppInfo2 = async (key, appsPath) => {
|
|
49898
|
+
const normalizedKey = key.replace(/\//g, path6.sep);
|
|
49899
|
+
const directory = path6.join(appsPath, normalizedKey);
|
|
49900
|
+
if (!fileIsExist2(directory)) {
|
|
49901
|
+
return;
|
|
49902
|
+
}
|
|
49903
|
+
fs6.rmSync(directory, { recursive: true });
|
|
49904
|
+
};
|
|
49905
|
+
|
|
49906
|
+
// src/module/local-apps/src/modules/manager.ts
|
|
49907
|
+
import { fork as fork2 } from "node:child_process";
|
|
49908
|
+
import path7 from "node:path";
|
|
49909
|
+
var import_fast_glob = __toESM(require_out4(), 1);
|
|
49910
|
+
import fs7 from "node:fs";
|
|
49911
|
+
|
|
49912
|
+
// src/module/local-apps/src/modules/pm2.ts
|
|
49913
|
+
import { spawn } from "node:child_process";
|
|
49914
|
+
import pm23 from "pm2";
|
|
49915
|
+
import { promisify as promisify3 } from "node:util";
|
|
49916
|
+
var normalizeScriptPath2 = (scriptPath) => {
|
|
49917
|
+
if (process.platform === "win32") {
|
|
49918
|
+
return scriptPath.replace(/\\/g, "/");
|
|
49919
|
+
}
|
|
49920
|
+
return scriptPath;
|
|
49921
|
+
};
|
|
49922
|
+
var connect2 = async (noDaemonMode = false) => {
|
|
49923
|
+
return new Promise((resolve, reject) => {
|
|
49924
|
+
pm23.connect(noDaemonMode, (err) => {
|
|
49925
|
+
if (err) {
|
|
49926
|
+
console.error("pm2 connect error", err);
|
|
49927
|
+
return reject(err);
|
|
49928
|
+
}
|
|
49929
|
+
resolve(true);
|
|
49930
|
+
});
|
|
49931
|
+
});
|
|
49932
|
+
};
|
|
49933
|
+
var disconnect2 = promisify3(pm23.disconnect).bind(pm23);
|
|
49934
|
+
var start3 = promisify3(pm23.start).bind(pm23);
|
|
49935
|
+
var stop3 = promisify3(pm23.stop).bind(pm23);
|
|
49936
|
+
var restart3 = promisify3(pm23.restart).bind(pm23);
|
|
49937
|
+
var reload2 = promisify3(pm23.reload).bind(pm23);
|
|
49938
|
+
var deleteProcess3 = promisify3(pm23.delete).bind(pm23);
|
|
49939
|
+
var list3 = promisify3(pm23.list).bind(pm23);
|
|
49940
|
+
var checkInstall = async (app) => {
|
|
49941
|
+
return new Promise((resolve, reject) => {
|
|
49942
|
+
const install = spawn("pnpm", ["install"], {
|
|
49943
|
+
cwd: app.path,
|
|
49944
|
+
stdio: "inherit"
|
|
49945
|
+
});
|
|
49946
|
+
install.on("close", (code) => {
|
|
49947
|
+
if (code !== 0) {
|
|
49948
|
+
console.log("install failed");
|
|
49949
|
+
return resolve(false);
|
|
49950
|
+
}
|
|
49951
|
+
console.log("install success");
|
|
49952
|
+
resolve(true);
|
|
49953
|
+
});
|
|
49954
|
+
});
|
|
49955
|
+
};
|
|
49956
|
+
|
|
49957
|
+
class Pm2Connect2 {
|
|
49958
|
+
needConnect = true;
|
|
49959
|
+
isConnected = false;
|
|
49960
|
+
constructor(needConnect = true) {
|
|
49961
|
+
this.needConnect = needConnect;
|
|
49962
|
+
}
|
|
49963
|
+
async sleep(ms2) {
|
|
49964
|
+
return new Promise((resolve) => {
|
|
49965
|
+
setTimeout(resolve, ms2);
|
|
49966
|
+
});
|
|
49967
|
+
}
|
|
49968
|
+
async checkConnect() {
|
|
49969
|
+
const that = this;
|
|
49970
|
+
try {
|
|
49971
|
+
if (this.needConnect && !this.isConnected) {
|
|
49972
|
+
const data = await connect2();
|
|
49973
|
+
that.isConnected = !!data;
|
|
49974
|
+
}
|
|
49975
|
+
} catch (e) {
|
|
49976
|
+
console.log("pm2 check connect error", e);
|
|
49977
|
+
}
|
|
49978
|
+
}
|
|
49979
|
+
async checkDisconnect(runOpts) {
|
|
49980
|
+
const needExit = runOpts?.needExit ?? true;
|
|
49981
|
+
if (this.needConnect && this.isConnected && needExit) {
|
|
49982
|
+
this.disconnect();
|
|
49983
|
+
}
|
|
49984
|
+
}
|
|
49985
|
+
async connect() {
|
|
49986
|
+
try {
|
|
49987
|
+
await connect2();
|
|
49988
|
+
this.isConnected = true;
|
|
49989
|
+
} catch (e) {
|
|
49990
|
+
console.log("pm2 connect error", e);
|
|
49991
|
+
}
|
|
49992
|
+
}
|
|
49993
|
+
async disconnect() {
|
|
49994
|
+
try {
|
|
49995
|
+
pm23.disconnect();
|
|
49996
|
+
await this.sleep(1000);
|
|
49997
|
+
} catch (e) {
|
|
49998
|
+
console.log("pm2 disconnect error", e);
|
|
49999
|
+
}
|
|
50000
|
+
this.isConnected = false;
|
|
50001
|
+
}
|
|
50002
|
+
}
|
|
50003
|
+
|
|
50004
|
+
class Pm2Manager2 {
|
|
50005
|
+
pm2Connect;
|
|
50006
|
+
appName;
|
|
50007
|
+
script;
|
|
50008
|
+
interpreter;
|
|
50009
|
+
needConnect = true;
|
|
50010
|
+
isConnect = false;
|
|
50011
|
+
env;
|
|
50012
|
+
constructor(opts) {
|
|
50013
|
+
this.appName = opts.appName;
|
|
50014
|
+
this.script = opts.script;
|
|
50015
|
+
this.interpreter = opts.interpreter;
|
|
50016
|
+
this.pm2Connect = opts.pm2Connect || new Pm2Connect2;
|
|
50017
|
+
this.env = opts.env || {};
|
|
50018
|
+
}
|
|
50019
|
+
async list(runOpts) {
|
|
50020
|
+
const _runOpts = { needExit: false, ...runOpts };
|
|
50021
|
+
try {
|
|
50022
|
+
await this.pm2Connect.checkConnect();
|
|
50023
|
+
const apps = await list3();
|
|
50024
|
+
return apps;
|
|
50025
|
+
} catch (e) {
|
|
50026
|
+
console.log("pm2 run error", e);
|
|
50027
|
+
return [];
|
|
50028
|
+
} finally {
|
|
50029
|
+
this.pm2Connect.checkDisconnect(_runOpts);
|
|
50030
|
+
}
|
|
50031
|
+
}
|
|
50032
|
+
async start(options, runOpts) {
|
|
50033
|
+
const { appName, script, env: env2, interpreter } = this;
|
|
50034
|
+
const needExit = runOpts?.needExit ?? true;
|
|
50035
|
+
if (!script) {
|
|
50036
|
+
console.error("script is required");
|
|
50037
|
+
return;
|
|
50038
|
+
}
|
|
50039
|
+
const normalizedScript = normalizeScriptPath2(script);
|
|
50040
|
+
const starter = {
|
|
50041
|
+
name: appName,
|
|
50042
|
+
script: normalizedScript,
|
|
50043
|
+
cwd: process.cwd(),
|
|
50044
|
+
interpreter,
|
|
50045
|
+
...options,
|
|
50046
|
+
env: {
|
|
50047
|
+
NODE_ENV: "production",
|
|
50048
|
+
...env2,
|
|
50049
|
+
...options?.env
|
|
50050
|
+
}
|
|
50051
|
+
};
|
|
50052
|
+
try {
|
|
50053
|
+
await this.pm2Connect.checkConnect();
|
|
50054
|
+
const apps = await this.list({ needExit: false });
|
|
50055
|
+
const app = apps.find((app2) => app2.name === appName);
|
|
50056
|
+
if (app && app.pid === 0) {
|
|
50057
|
+
await start3(starter);
|
|
50058
|
+
return;
|
|
50059
|
+
} else if (!app) {
|
|
50060
|
+
await start3(starter);
|
|
50061
|
+
} else {
|
|
50062
|
+
console.log(`pm2 app ${appName} is running`);
|
|
50063
|
+
}
|
|
50064
|
+
} catch (e) {
|
|
50065
|
+
console.error("error", e);
|
|
50066
|
+
} finally {
|
|
50067
|
+
this.pm2Connect.checkDisconnect({ needExit });
|
|
50068
|
+
}
|
|
50069
|
+
}
|
|
50070
|
+
async stop(runOpts) {
|
|
50071
|
+
try {
|
|
50072
|
+
await this.pm2Connect.checkConnect();
|
|
50073
|
+
const apps = await this.list({ needExit: false });
|
|
50074
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
50075
|
+
if (app && app.pid !== 0) {
|
|
50076
|
+
await stop3(app.name);
|
|
50077
|
+
}
|
|
50078
|
+
} catch (e) {
|
|
50079
|
+
console.error("error", e);
|
|
50080
|
+
} finally {
|
|
50081
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
50082
|
+
}
|
|
50083
|
+
}
|
|
50084
|
+
async restart(runOpts) {
|
|
50085
|
+
try {
|
|
50086
|
+
await this.pm2Connect.checkConnect();
|
|
50087
|
+
const apps = await this.list({ needExit: false });
|
|
50088
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
50089
|
+
if (app) {
|
|
50090
|
+
await restart3(app.name);
|
|
50091
|
+
}
|
|
50092
|
+
} catch (e) {
|
|
50093
|
+
console.error("error", e);
|
|
50094
|
+
} finally {
|
|
50095
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
50096
|
+
}
|
|
50097
|
+
}
|
|
50098
|
+
async remove(runOpts) {
|
|
50099
|
+
this.deleteProcess(runOpts);
|
|
50100
|
+
}
|
|
50101
|
+
async deleteProcess(runOpts) {
|
|
50102
|
+
try {
|
|
50103
|
+
await this.pm2Connect.checkConnect();
|
|
50104
|
+
const apps = await this.list({ needExit: false });
|
|
50105
|
+
const app = apps.find((app2) => app2.name === this.appName);
|
|
50106
|
+
if (app) {
|
|
50107
|
+
await deleteProcess3(app.name);
|
|
50108
|
+
}
|
|
50109
|
+
} catch (e) {
|
|
50110
|
+
console.error("error", e);
|
|
50111
|
+
} finally {
|
|
50112
|
+
this.pm2Connect.checkDisconnect(runOpts);
|
|
50113
|
+
}
|
|
50114
|
+
}
|
|
50115
|
+
}
|
|
50116
|
+
|
|
50117
|
+
// src/module/local-apps/src/modules/manager.ts
|
|
50118
|
+
var onAppShowInfo2 = (app) => {
|
|
50119
|
+
return {
|
|
49111
50120
|
key: app.key,
|
|
49112
50121
|
status: app.status,
|
|
49113
50122
|
engine: app.engine,
|
|
@@ -49380,12 +50389,12 @@ var LoadApp = async (app, opts) => {
|
|
|
49380
50389
|
if (app.status !== "running") {
|
|
49381
50390
|
return false;
|
|
49382
50391
|
}
|
|
49383
|
-
if (!
|
|
50392
|
+
if (!fileIsExist2(app.path)) {
|
|
49384
50393
|
console.error("app is not found");
|
|
49385
50394
|
return false;
|
|
49386
50395
|
}
|
|
49387
|
-
const pathEntry =
|
|
49388
|
-
if (!
|
|
50396
|
+
const pathEntry = path7.join(app.path, app.entry);
|
|
50397
|
+
if (!fileIsExist2(pathEntry)) {
|
|
49389
50398
|
console.error("file entry not found");
|
|
49390
50399
|
return false;
|
|
49391
50400
|
}
|
|
@@ -49404,7 +50413,7 @@ var LoadApp = async (app, opts) => {
|
|
|
49404
50413
|
});
|
|
49405
50414
|
app.process = childProcess;
|
|
49406
50415
|
} else if (app.type === "system-app" /* SystemApp */) {
|
|
49407
|
-
const pathEntryAndTimestamp =
|
|
50416
|
+
const pathEntryAndTimestamp = path7.join(app.path, entry2);
|
|
49408
50417
|
const importPath = process.platform === "win32" ? "file:///" + pathEntryAndTimestamp.replace(/\\/g, "/") : pathEntryAndTimestamp;
|
|
49409
50418
|
const module = await import(importPath);
|
|
49410
50419
|
if (module.loadApp && mainApp) {
|
|
@@ -49413,7 +50422,7 @@ var LoadApp = async (app, opts) => {
|
|
|
49413
50422
|
} else if (app.type === "gateway-app" /* GatewayApp */) {
|
|
49414
50423
|
console.log("gateway app not support");
|
|
49415
50424
|
} else if (app.type === "pm2-system-app" /* Pm2SystemApp */) {
|
|
49416
|
-
const pathEntry2 =
|
|
50425
|
+
const pathEntry2 = path7.join(app.path, app.entry);
|
|
49417
50426
|
const pm2Manager = new Pm2Manager2({
|
|
49418
50427
|
appName: app.key,
|
|
49419
50428
|
script: pathEntry2,
|
|
@@ -49431,7 +50440,7 @@ var LoadApp = async (app, opts) => {
|
|
|
49431
50440
|
pm2Options.interpreter = pm2Options.interpreter || app?.engine;
|
|
49432
50441
|
}
|
|
49433
50442
|
if (!pm2Options.cwd) {
|
|
49434
|
-
pm2Options.cwd =
|
|
50443
|
+
pm2Options.cwd = path7.join(app.path, "../..");
|
|
49435
50444
|
}
|
|
49436
50445
|
await pm2Manager.start(pm2Options);
|
|
49437
50446
|
} else if (app.type === "script-app" /* ScriptApp */) {
|
|
@@ -49466,30 +50475,30 @@ var StopApp = async (app, opts) => {
|
|
|
49466
50475
|
}
|
|
49467
50476
|
};
|
|
49468
50477
|
var installAppFromKey2 = async (key, _appPath) => {
|
|
49469
|
-
const normalizedKey = key.replace(/\//g,
|
|
49470
|
-
const directory =
|
|
49471
|
-
if (!
|
|
50478
|
+
const normalizedKey = key.replace(/\//g, path7.sep);
|
|
50479
|
+
const directory = path7.join(_appPath, normalizedKey);
|
|
50480
|
+
if (!fileIsExist2(directory)) {
|
|
49472
50481
|
console.error("App not found", directory);
|
|
49473
50482
|
throw new Error("App not found");
|
|
49474
50483
|
}
|
|
49475
|
-
const pkgs =
|
|
49476
|
-
if (!
|
|
50484
|
+
const pkgs = path7.join(directory, "package.json");
|
|
50485
|
+
if (!fileIsExist2(pkgs)) {
|
|
49477
50486
|
throw new Error("Invalid package.json, need package.json in app directory");
|
|
49478
50487
|
}
|
|
49479
|
-
const json2 =
|
|
50488
|
+
const json2 = fs7.readFileSync(pkgs, "utf-8");
|
|
49480
50489
|
const pkg = JSON.parse(json2);
|
|
49481
50490
|
const { name, version: version2, app } = pkg;
|
|
49482
50491
|
if (!name || !version2 || !app) {
|
|
49483
50492
|
console.error("need name, version and app in package.json");
|
|
49484
50493
|
throw new Error("Invalid package.json format, need name, version and app");
|
|
49485
50494
|
}
|
|
49486
|
-
const readmeFile =
|
|
49487
|
-
const readmeFile2 =
|
|
50495
|
+
const readmeFile = path7.join(directory, "README.md");
|
|
50496
|
+
const readmeFile2 = path7.join(directory, "readme.md");
|
|
49488
50497
|
let readmeDesc = "";
|
|
49489
|
-
if (
|
|
49490
|
-
readmeDesc =
|
|
49491
|
-
} else if (
|
|
49492
|
-
readmeDesc =
|
|
50498
|
+
if (fileIsExist2(readmeFile)) {
|
|
50499
|
+
readmeDesc = fs7.readFileSync(readmeFile, "utf-8");
|
|
50500
|
+
} else if (fileIsExist2(readmeFile2)) {
|
|
50501
|
+
readmeDesc = fs7.readFileSync(readmeFile2, "utf-8");
|
|
49493
50502
|
}
|
|
49494
50503
|
let showAppInfo = {
|
|
49495
50504
|
key,
|
|
@@ -49504,13 +50513,13 @@ var installAppFromKey2 = async (key, _appPath) => {
|
|
|
49504
50513
|
};
|
|
49505
50514
|
app.key = key;
|
|
49506
50515
|
if (app.type === "pm2-system-app") {
|
|
49507
|
-
const pm2Cwd =
|
|
50516
|
+
const pm2Cwd = path7.join(_appPath, "..");
|
|
49508
50517
|
showAppInfo.pm2Options = { cwd: pm2Cwd, ...app.pm2Options };
|
|
49509
50518
|
}
|
|
49510
50519
|
return { pkg, showAppInfo };
|
|
49511
50520
|
};
|
|
49512
50521
|
var getAppPathKeys2 = async (_appPath) => {
|
|
49513
|
-
const directory =
|
|
50522
|
+
const directory = path7.resolve(_appPath);
|
|
49514
50523
|
const root2 = directory;
|
|
49515
50524
|
const path1 = "*/package.json";
|
|
49516
50525
|
const path22 = "*/*/package.json";
|
|
@@ -49521,7 +50530,7 @@ var getAppPathKeys2 = async (_appPath) => {
|
|
|
49521
50530
|
ignore: ["**/node_modules/**"]
|
|
49522
50531
|
});
|
|
49523
50532
|
const appPathKeys = appsPackages.map((pkg) => {
|
|
49524
|
-
const dir =
|
|
50533
|
+
const dir = path7.dirname(pkg);
|
|
49525
50534
|
return dir.replace(/\\/g, "/");
|
|
49526
50535
|
});
|
|
49527
50536
|
return appPathKeys;
|
|
@@ -49529,8 +50538,8 @@ var getAppPathKeys2 = async (_appPath) => {
|
|
|
49529
50538
|
|
|
49530
50539
|
// src/module/assistant/local-app-manager/assistant-app.ts
|
|
49531
50540
|
var import_fast_glob3 = __toESM(require_out4(), 1);
|
|
49532
|
-
import
|
|
49533
|
-
import
|
|
50541
|
+
import path10 from "node:path";
|
|
50542
|
+
import fs12 from "node:fs";
|
|
49534
50543
|
|
|
49535
50544
|
// ../node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
|
|
49536
50545
|
var import__ = __toESM(require_eventemitter3(), 1);
|
|
@@ -49701,7 +50710,7 @@ var getEnvToken = () => {
|
|
|
49701
50710
|
return envTokne;
|
|
49702
50711
|
};
|
|
49703
50712
|
|
|
49704
|
-
// ../node_modules/.pnpm/@kevisual+query@0.0.
|
|
50713
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.39/node_modules/@kevisual/query/dist/query-browser.js
|
|
49705
50714
|
var isTextForContentType = (contentType) => {
|
|
49706
50715
|
if (!contentType)
|
|
49707
50716
|
return false;
|
|
@@ -49733,11 +50742,15 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
49733
50742
|
url3 = new URL(opts.url, origin);
|
|
49734
50743
|
}
|
|
49735
50744
|
const isGet = method === "GET";
|
|
50745
|
+
const oldSearchParams = url3.searchParams;
|
|
49736
50746
|
if (isGet) {
|
|
49737
|
-
let searchParams = new URLSearchParams(opts.body);
|
|
50747
|
+
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts.body });
|
|
49738
50748
|
url3.search = searchParams.toString();
|
|
49739
50749
|
} else {
|
|
49740
|
-
const params =
|
|
50750
|
+
const params = {
|
|
50751
|
+
...Object.fromEntries(oldSearchParams),
|
|
50752
|
+
...opts.params
|
|
50753
|
+
};
|
|
49741
50754
|
const searchParams = new URLSearchParams(params);
|
|
49742
50755
|
if (typeof opts.body === "object" && opts.body !== null) {
|
|
49743
50756
|
let body2 = opts.body || {};
|
|
@@ -50197,8 +51210,8 @@ class Parser {
|
|
|
50197
51210
|
}
|
|
50198
51211
|
|
|
50199
51212
|
class Executor {
|
|
50200
|
-
getValueByPath(obj,
|
|
50201
|
-
return
|
|
51213
|
+
getValueByPath(obj, path8) {
|
|
51214
|
+
return path8.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
50202
51215
|
}
|
|
50203
51216
|
likeToRegex(pattern2) {
|
|
50204
51217
|
let regex = "";
|
|
@@ -50346,17 +51359,270 @@ var initApi = async (opts) => {
|
|
|
50346
51359
|
message: "初始化路由成功"
|
|
50347
51360
|
};
|
|
50348
51361
|
};
|
|
51362
|
+
// ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query-browser.js
|
|
51363
|
+
var isTextForContentType2 = (contentType) => {
|
|
51364
|
+
if (!contentType)
|
|
51365
|
+
return false;
|
|
51366
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
51367
|
+
return textTypes.some((type) => contentType.includes(type));
|
|
51368
|
+
};
|
|
51369
|
+
var adapter2 = async (opts = {}, overloadOpts) => {
|
|
51370
|
+
const controller = new AbortController;
|
|
51371
|
+
const signal = controller.signal;
|
|
51372
|
+
const isPostFile = opts.isPostFile || false;
|
|
51373
|
+
let responseType = opts.responseType || "json";
|
|
51374
|
+
if (opts.isBlob) {
|
|
51375
|
+
responseType = "blob";
|
|
51376
|
+
} else if (opts.isText) {
|
|
51377
|
+
responseType = "text";
|
|
51378
|
+
}
|
|
51379
|
+
const timeout = opts.timeout || 60000 * 3;
|
|
51380
|
+
const timer = setTimeout(() => {
|
|
51381
|
+
controller.abort();
|
|
51382
|
+
}, timeout);
|
|
51383
|
+
let method = overloadOpts?.method || opts?.method || "POST";
|
|
51384
|
+
let headers = { ...opts?.headers, ...overloadOpts?.headers };
|
|
51385
|
+
let origin = "";
|
|
51386
|
+
let url3;
|
|
51387
|
+
if (opts?.url?.startsWith("http")) {
|
|
51388
|
+
url3 = new URL(opts.url);
|
|
51389
|
+
} else {
|
|
51390
|
+
origin = window?.location?.origin || "http://localhost:51515";
|
|
51391
|
+
url3 = new URL(opts.url, origin);
|
|
51392
|
+
}
|
|
51393
|
+
const isGet = method === "GET";
|
|
51394
|
+
if (isGet) {
|
|
51395
|
+
let searchParams = new URLSearchParams(opts.body);
|
|
51396
|
+
url3.search = searchParams.toString();
|
|
51397
|
+
} else {
|
|
51398
|
+
const params = opts.params || {};
|
|
51399
|
+
const searchParams = new URLSearchParams(params);
|
|
51400
|
+
if (typeof opts.body === "object" && opts.body !== null) {
|
|
51401
|
+
let body2 = opts.body || {};
|
|
51402
|
+
if (!params.path && body2?.path) {
|
|
51403
|
+
searchParams.set("path", body2.path);
|
|
51404
|
+
if (body2?.key) {
|
|
51405
|
+
searchParams.set("key", body2.key);
|
|
51406
|
+
}
|
|
51407
|
+
}
|
|
51408
|
+
}
|
|
51409
|
+
url3.search = searchParams.toString();
|
|
51410
|
+
}
|
|
51411
|
+
let body = undefined;
|
|
51412
|
+
if (isGet) {
|
|
51413
|
+
body = undefined;
|
|
51414
|
+
} else if (isPostFile) {
|
|
51415
|
+
body = opts.body;
|
|
51416
|
+
} else {
|
|
51417
|
+
headers = {
|
|
51418
|
+
"Content-Type": "application/json",
|
|
51419
|
+
...headers
|
|
51420
|
+
};
|
|
51421
|
+
body = JSON.stringify(opts.body);
|
|
51422
|
+
}
|
|
51423
|
+
return fetch(url3, {
|
|
51424
|
+
method: method.toUpperCase(),
|
|
51425
|
+
signal,
|
|
51426
|
+
body,
|
|
51427
|
+
...overloadOpts,
|
|
51428
|
+
headers
|
|
51429
|
+
}).then(async (response) => {
|
|
51430
|
+
const contentType = response.headers.get("Content-Type");
|
|
51431
|
+
if (responseType === "blob") {
|
|
51432
|
+
return await response.blob();
|
|
51433
|
+
}
|
|
51434
|
+
const isText = responseType === "text";
|
|
51435
|
+
const isJson = contentType && contentType.includes("application/json");
|
|
51436
|
+
if (isJson && !isText) {
|
|
51437
|
+
return await response.json();
|
|
51438
|
+
} else if (isTextForContentType2(contentType)) {
|
|
51439
|
+
return {
|
|
51440
|
+
code: response.status,
|
|
51441
|
+
status: response.status,
|
|
51442
|
+
data: await response.text()
|
|
51443
|
+
};
|
|
51444
|
+
} else {
|
|
51445
|
+
return response;
|
|
51446
|
+
}
|
|
51447
|
+
}).catch((err) => {
|
|
51448
|
+
if (err.name === "AbortError") {
|
|
51449
|
+
return {
|
|
51450
|
+
code: 408,
|
|
51451
|
+
message: "请求超时"
|
|
51452
|
+
};
|
|
51453
|
+
}
|
|
51454
|
+
return {
|
|
51455
|
+
code: 500,
|
|
51456
|
+
message: err.message || "网络错误"
|
|
51457
|
+
};
|
|
51458
|
+
}).finally(() => {
|
|
51459
|
+
clearTimeout(timer);
|
|
51460
|
+
});
|
|
51461
|
+
};
|
|
51462
|
+
var wrapperError2 = ({ code, message }) => {
|
|
51463
|
+
const result = {
|
|
51464
|
+
code: code || 500,
|
|
51465
|
+
success: false,
|
|
51466
|
+
message: message || "api request error",
|
|
51467
|
+
showError: (fn) => {},
|
|
51468
|
+
noMsg: true
|
|
51469
|
+
};
|
|
51470
|
+
return result;
|
|
51471
|
+
};
|
|
51472
|
+
|
|
51473
|
+
class Query2 {
|
|
51474
|
+
adapter;
|
|
51475
|
+
url;
|
|
51476
|
+
beforeRequest;
|
|
51477
|
+
afterResponse;
|
|
51478
|
+
headers;
|
|
51479
|
+
timeout;
|
|
51480
|
+
stop;
|
|
51481
|
+
qws;
|
|
51482
|
+
isClient = false;
|
|
51483
|
+
constructor(opts) {
|
|
51484
|
+
this.adapter = opts?.adapter || adapter2;
|
|
51485
|
+
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
51486
|
+
this.url = opts?.url || defaultURL;
|
|
51487
|
+
this.headers = opts?.headers || {
|
|
51488
|
+
"Content-Type": "application/json"
|
|
51489
|
+
};
|
|
51490
|
+
this.timeout = opts?.timeout || 60000 * 3;
|
|
51491
|
+
if (opts.beforeRequest) {
|
|
51492
|
+
this.beforeRequest = opts.beforeRequest;
|
|
51493
|
+
} else {
|
|
51494
|
+
this.beforeRequest = async (opts2) => {
|
|
51495
|
+
const token = globalThis?.localStorage?.getItem("token");
|
|
51496
|
+
if (token) {
|
|
51497
|
+
opts2.headers = {
|
|
51498
|
+
...opts2.headers,
|
|
51499
|
+
Authorization: `Bearer ${token}`
|
|
51500
|
+
};
|
|
51501
|
+
}
|
|
51502
|
+
return opts2;
|
|
51503
|
+
};
|
|
51504
|
+
}
|
|
51505
|
+
}
|
|
51506
|
+
setQueryWs(qws) {
|
|
51507
|
+
this.qws = qws;
|
|
51508
|
+
}
|
|
51509
|
+
setStop(stop4) {
|
|
51510
|
+
this.stop = stop4;
|
|
51511
|
+
}
|
|
51512
|
+
async get(params, options) {
|
|
51513
|
+
return this.post(params, options);
|
|
51514
|
+
}
|
|
51515
|
+
async post(body, options) {
|
|
51516
|
+
const url3 = options?.url || this.url;
|
|
51517
|
+
const { headers, adapter: adapter3, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
51518
|
+
const _headers = { ...this.headers, ...headers };
|
|
51519
|
+
const _adapter = adapter3 || this.adapter;
|
|
51520
|
+
const _beforeRequest = beforeRequest || this.beforeRequest;
|
|
51521
|
+
const _afterResponse = afterResponse || this.afterResponse;
|
|
51522
|
+
const _timeout = timeout || this.timeout;
|
|
51523
|
+
const req = {
|
|
51524
|
+
url: url3,
|
|
51525
|
+
headers: _headers,
|
|
51526
|
+
body,
|
|
51527
|
+
timeout: _timeout,
|
|
51528
|
+
...rest
|
|
51529
|
+
};
|
|
51530
|
+
try {
|
|
51531
|
+
if (_beforeRequest) {
|
|
51532
|
+
const res = await _beforeRequest(req);
|
|
51533
|
+
if (res === false) {
|
|
51534
|
+
return wrapperError2({
|
|
51535
|
+
code: 500,
|
|
51536
|
+
message: "request is cancel",
|
|
51537
|
+
req
|
|
51538
|
+
});
|
|
51539
|
+
}
|
|
51540
|
+
}
|
|
51541
|
+
} catch (e) {
|
|
51542
|
+
console.error("request beforeFn error", e, req);
|
|
51543
|
+
return wrapperError2({
|
|
51544
|
+
code: 500,
|
|
51545
|
+
message: "api request beforeFn error"
|
|
51546
|
+
});
|
|
51547
|
+
}
|
|
51548
|
+
if (this.stop && !options?.noStop) {
|
|
51549
|
+
const that = this;
|
|
51550
|
+
await new Promise((resolve) => {
|
|
51551
|
+
let timer = 0;
|
|
51552
|
+
const detect = setInterval(() => {
|
|
51553
|
+
if (!that.stop) {
|
|
51554
|
+
clearInterval(detect);
|
|
51555
|
+
resolve(true);
|
|
51556
|
+
}
|
|
51557
|
+
timer++;
|
|
51558
|
+
if (timer > 30) {
|
|
51559
|
+
console.error("request stop: timeout", req.url, timer);
|
|
51560
|
+
}
|
|
51561
|
+
}, 1000);
|
|
51562
|
+
});
|
|
51563
|
+
}
|
|
51564
|
+
return _adapter(req).then(async (res) => {
|
|
51565
|
+
try {
|
|
51566
|
+
if (_afterResponse) {
|
|
51567
|
+
return await _afterResponse(res, {
|
|
51568
|
+
req,
|
|
51569
|
+
res,
|
|
51570
|
+
fetch: adapter3
|
|
51571
|
+
});
|
|
51572
|
+
}
|
|
51573
|
+
return res;
|
|
51574
|
+
} catch (e) {
|
|
51575
|
+
console.error("request afterFn error", e, req);
|
|
51576
|
+
return wrapperError2({
|
|
51577
|
+
code: 500,
|
|
51578
|
+
message: "api request afterFn error"
|
|
51579
|
+
});
|
|
51580
|
+
}
|
|
51581
|
+
});
|
|
51582
|
+
}
|
|
51583
|
+
before(fn) {
|
|
51584
|
+
this.beforeRequest = fn;
|
|
51585
|
+
}
|
|
51586
|
+
after(fn) {
|
|
51587
|
+
this.afterResponse = fn;
|
|
51588
|
+
}
|
|
51589
|
+
async fetchText(urlOrOptions, options) {
|
|
51590
|
+
let _options = { ...options };
|
|
51591
|
+
if (typeof urlOrOptions === "string" && !_options.url) {
|
|
51592
|
+
_options.url = urlOrOptions;
|
|
51593
|
+
}
|
|
51594
|
+
if (typeof urlOrOptions === "object") {
|
|
51595
|
+
_options = { ...urlOrOptions, ..._options };
|
|
51596
|
+
}
|
|
51597
|
+
const res = await adapter2({
|
|
51598
|
+
method: "GET",
|
|
51599
|
+
..._options,
|
|
51600
|
+
headers: {
|
|
51601
|
+
...this.headers,
|
|
51602
|
+
..._options?.headers || {}
|
|
51603
|
+
}
|
|
51604
|
+
});
|
|
51605
|
+
if (res && !res.code) {
|
|
51606
|
+
return {
|
|
51607
|
+
code: 200,
|
|
51608
|
+
data: res
|
|
51609
|
+
};
|
|
51610
|
+
}
|
|
51611
|
+
return res;
|
|
51612
|
+
}
|
|
51613
|
+
}
|
|
51614
|
+
|
|
50349
51615
|
// src/module/light-code/index.ts
|
|
50350
51616
|
var import_fast_glob2 = __toESM(require_out4(), 1);
|
|
50351
|
-
import
|
|
50352
|
-
import
|
|
51617
|
+
import path8 from "node:path";
|
|
51618
|
+
import fs10 from "node:fs";
|
|
50353
51619
|
|
|
50354
51620
|
// src/module/light-code/run.ts
|
|
50355
51621
|
import { fork as fork3 } from "node:child_process";
|
|
50356
|
-
import
|
|
50357
|
-
var fileExists = (
|
|
51622
|
+
import fs8 from "fs";
|
|
51623
|
+
var fileExists = (path8) => {
|
|
50358
51624
|
try {
|
|
50359
|
-
|
|
51625
|
+
fs8.accessSync(path8, fs8.constants.F_OK);
|
|
50360
51626
|
return true;
|
|
50361
51627
|
} catch (e) {
|
|
50362
51628
|
return false;
|
|
@@ -50469,11 +51735,11 @@ var runCode = async (tsPath, params = {}, opts) => {
|
|
|
50469
51735
|
|
|
50470
51736
|
// src/module/file-hash.ts
|
|
50471
51737
|
import crypto2 from "node:crypto";
|
|
50472
|
-
import
|
|
51738
|
+
import fs9 from "node:fs";
|
|
50473
51739
|
var getHash = (file2) => {
|
|
50474
|
-
if (!
|
|
51740
|
+
if (!fs9.existsSync(file2))
|
|
50475
51741
|
return "";
|
|
50476
|
-
const buffer =
|
|
51742
|
+
const buffer = fs9.readFileSync(file2);
|
|
50477
51743
|
return crypto2.createHash("md5").update(buffer).digest("hex");
|
|
50478
51744
|
};
|
|
50479
51745
|
var getStringHash = (str) => {
|
|
@@ -50493,9 +51759,9 @@ var initLightCode = async (opts) => {
|
|
|
50493
51759
|
return;
|
|
50494
51760
|
}
|
|
50495
51761
|
const appDir = config2.configPath.appsDir;
|
|
50496
|
-
const lightcodeDir =
|
|
50497
|
-
if (!
|
|
50498
|
-
|
|
51762
|
+
const lightcodeDir = path8.join(appDir, "light-code", "code");
|
|
51763
|
+
if (!fs10.existsSync(lightcodeDir)) {
|
|
51764
|
+
fs10.mkdirSync(lightcodeDir, { recursive: true });
|
|
50499
51765
|
}
|
|
50500
51766
|
let diffList = [];
|
|
50501
51767
|
const codeFiles = import_fast_glob2.default.sync(["**/*.ts", "**/*.js"], {
|
|
@@ -50503,7 +51769,7 @@ var initLightCode = async (opts) => {
|
|
|
50503
51769
|
onlyFiles: true
|
|
50504
51770
|
}).map((file2) => {
|
|
50505
51771
|
return {
|
|
50506
|
-
filepath:
|
|
51772
|
+
filepath: path8.join(lightcodeDir, file2)
|
|
50507
51773
|
};
|
|
50508
51774
|
});
|
|
50509
51775
|
if (sync2) {
|
|
@@ -50516,7 +51782,7 @@ var initLightCode = async (opts) => {
|
|
|
50516
51782
|
const lightQueryList = queryRes.data?.list || [];
|
|
50517
51783
|
for (const item of lightQueryList) {
|
|
50518
51784
|
const codeHash = getStringHash(item.code || "");
|
|
50519
|
-
diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath:
|
|
51785
|
+
diffList.push({ id: item.id, code: item.code || "", hash: codeHash, filepath: path8.join(lightcodeDir, `${item.id}.ts`) });
|
|
50520
51786
|
}
|
|
50521
51787
|
const codeFileSet = new Set(codeFiles.map((f) => f.filepath));
|
|
50522
51788
|
const toAdd = diffList.filter((d) => !codeFileSet.has(d.filepath));
|
|
@@ -50524,13 +51790,13 @@ var initLightCode = async (opts) => {
|
|
|
50524
51790
|
const toUpdate = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash !== getHash(d.filepath));
|
|
50525
51791
|
const unchanged = diffList.filter((d) => codeFileSet.has(d.filepath) && d.hash === getHash(d.filepath));
|
|
50526
51792
|
for (const item of toAdd) {
|
|
50527
|
-
|
|
51793
|
+
fs10.writeFileSync(item.filepath, item.code, "utf-8");
|
|
50528
51794
|
}
|
|
50529
51795
|
for (const filepath of toDelete) {
|
|
50530
|
-
|
|
51796
|
+
fs10.unlinkSync(filepath.filepath);
|
|
50531
51797
|
}
|
|
50532
51798
|
for (const item of toUpdate) {
|
|
50533
|
-
|
|
51799
|
+
fs10.writeFileSync(item.filepath, item.code, "utf-8");
|
|
50534
51800
|
}
|
|
50535
51801
|
} else {
|
|
50536
51802
|
console.error("light-code 同步失败", queryRes.message);
|
|
@@ -50588,8 +51854,8 @@ var initLightCode = async (opts) => {
|
|
|
50588
51854
|
};
|
|
50589
51855
|
|
|
50590
51856
|
// src/module/assistant/local-app-manager/assistant-app-resolve.ts
|
|
50591
|
-
import
|
|
50592
|
-
import
|
|
51857
|
+
import path9 from "node:path";
|
|
51858
|
+
import fs11 from "node:fs";
|
|
50593
51859
|
|
|
50594
51860
|
class ModuleResolver {
|
|
50595
51861
|
root;
|
|
@@ -50598,33 +51864,33 @@ class ModuleResolver {
|
|
|
50598
51864
|
this.root = root2;
|
|
50599
51865
|
}
|
|
50600
51866
|
resolve(routePath) {
|
|
50601
|
-
if (
|
|
51867
|
+
if (path9.isAbsolute(routePath)) {
|
|
50602
51868
|
return routePath;
|
|
50603
51869
|
}
|
|
50604
51870
|
if (routePath.startsWith("@")) {
|
|
50605
51871
|
return this.resolveScopedPackage(routePath);
|
|
50606
51872
|
}
|
|
50607
51873
|
if (!routePath.startsWith(".") && !routePath.startsWith("/")) {
|
|
50608
|
-
const pkgPath =
|
|
51874
|
+
const pkgPath = path9.join(this.root, "node_modules", routePath);
|
|
50609
51875
|
if (this.fileIsExists(pkgPath)) {
|
|
50610
51876
|
return pkgPath;
|
|
50611
51877
|
}
|
|
50612
51878
|
}
|
|
50613
|
-
const localFullPath =
|
|
51879
|
+
const localFullPath = path9.resolve(this.root, routePath);
|
|
50614
51880
|
return this.fileIsExists(localFullPath) ? localFullPath : routePath;
|
|
50615
51881
|
}
|
|
50616
51882
|
resolveScopedPackage(routePath) {
|
|
50617
51883
|
const parts = routePath.split("/");
|
|
50618
51884
|
const pkgName = parts.slice(0, 2).join("/");
|
|
50619
51885
|
const subPath = parts.slice(2).join("/");
|
|
50620
|
-
const pkgPath =
|
|
50621
|
-
const pkgJsonPath =
|
|
51886
|
+
const pkgPath = path9.join(this.root, "node_modules", pkgName);
|
|
51887
|
+
const pkgJsonPath = path9.join(pkgPath, "package.json");
|
|
50622
51888
|
const pkg = this.readPackageJson(pkgJsonPath);
|
|
50623
51889
|
if (!pkg) {
|
|
50624
51890
|
return routePath;
|
|
50625
51891
|
}
|
|
50626
51892
|
const entryPath = this.resolvePackageExport(pkg, subPath);
|
|
50627
|
-
return
|
|
51893
|
+
return path9.join(pkgPath, entryPath);
|
|
50628
51894
|
}
|
|
50629
51895
|
resolvePackageExport(pkg, subPath) {
|
|
50630
51896
|
const exportsField = pkg.exports;
|
|
@@ -50643,11 +51909,11 @@ class ModuleResolver {
|
|
|
50643
51909
|
readPackageJson(pkgJsonPath) {
|
|
50644
51910
|
try {
|
|
50645
51911
|
const cached2 = this.pkgCache.get(pkgJsonPath);
|
|
50646
|
-
const stats =
|
|
51912
|
+
const stats = fs11.statSync(pkgJsonPath);
|
|
50647
51913
|
if (cached2 && cached2.mtime === stats.mtimeMs) {
|
|
50648
51914
|
return cached2.pkg;
|
|
50649
51915
|
}
|
|
50650
|
-
const pkg = JSON.parse(
|
|
51916
|
+
const pkg = JSON.parse(fs11.readFileSync(pkgJsonPath, "utf-8"));
|
|
50651
51917
|
this.pkgCache.set(pkgJsonPath, { pkg, mtime: stats.mtimeMs });
|
|
50652
51918
|
return pkg;
|
|
50653
51919
|
} catch {
|
|
@@ -50656,7 +51922,7 @@ class ModuleResolver {
|
|
|
50656
51922
|
}
|
|
50657
51923
|
fileIsExists(filepath) {
|
|
50658
51924
|
try {
|
|
50659
|
-
|
|
51925
|
+
fs11.accessSync(filepath, fs11.constants.F_OK);
|
|
50660
51926
|
return true;
|
|
50661
51927
|
} catch {
|
|
50662
51928
|
return false;
|
|
@@ -50678,10 +51944,10 @@ class AssistantApp extends Manager2 {
|
|
|
50678
51944
|
resolver;
|
|
50679
51945
|
constructor(config2, mainApp) {
|
|
50680
51946
|
config2.checkMounted();
|
|
50681
|
-
const appsPath = config2?.configPath?.appsDir ||
|
|
50682
|
-
const pagesPath = config2?.configPath?.pagesDir ||
|
|
51947
|
+
const appsPath = config2?.configPath?.appsDir || path10.join(process.cwd(), "apps");
|
|
51948
|
+
const pagesPath = config2?.configPath?.pagesDir || path10.join(process.cwd(), "pages");
|
|
50683
51949
|
const appsConfigPath = config2.configPath?.appsConfigPath;
|
|
50684
|
-
const configFimename =
|
|
51950
|
+
const configFimename = path10.basename(appsConfigPath || "");
|
|
50685
51951
|
super({
|
|
50686
51952
|
appsPath,
|
|
50687
51953
|
configFilename: configFimename,
|
|
@@ -50698,7 +51964,7 @@ class AssistantApp extends Manager2 {
|
|
|
50698
51964
|
});
|
|
50699
51965
|
const pagesParse = pages.map((page) => {
|
|
50700
51966
|
const [user, app] = page.split("/");
|
|
50701
|
-
const contentStr =
|
|
51967
|
+
const contentStr = fs12.readFileSync(path10.join(this.pagesPath, page), "utf-8");
|
|
50702
51968
|
const content = parseIfJson2(contentStr);
|
|
50703
51969
|
return {
|
|
50704
51970
|
user,
|
|
@@ -50721,7 +51987,7 @@ class AssistantApp extends Manager2 {
|
|
|
50721
51987
|
});
|
|
50722
51988
|
const pagesParse = pages.map((page) => {
|
|
50723
51989
|
const relativePath = page;
|
|
50724
|
-
const contentStr =
|
|
51990
|
+
const contentStr = fs12.readFileSync(path10.join(root2, page), "utf-8");
|
|
50725
51991
|
const content = parseIfJson2(contentStr);
|
|
50726
51992
|
if (!content.appType) {
|
|
50727
51993
|
const isWeb = relativePath.startsWith("pages/");
|
|
@@ -50826,7 +52092,7 @@ class AssistantApp extends Manager2 {
|
|
|
50826
52092
|
console.warn("路由的api地址不能为空", proxyInfo.router);
|
|
50827
52093
|
continue;
|
|
50828
52094
|
}
|
|
50829
|
-
const query = new
|
|
52095
|
+
const query = new Query2({ url: url3 });
|
|
50830
52096
|
try {
|
|
50831
52097
|
initApi({
|
|
50832
52098
|
router: this.mainApp,
|
|
@@ -50882,13 +52148,13 @@ class AssistantApp extends Manager2 {
|
|
|
50882
52148
|
}
|
|
50883
52149
|
}
|
|
50884
52150
|
// ../node_modules/.pnpm/@kevisual+query@0.0.38/node_modules/@kevisual/query/dist/query.js
|
|
50885
|
-
var
|
|
52151
|
+
var isTextForContentType3 = (contentType) => {
|
|
50886
52152
|
if (!contentType)
|
|
50887
52153
|
return false;
|
|
50888
52154
|
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
50889
52155
|
return textTypes.some((type) => contentType.includes(type));
|
|
50890
52156
|
};
|
|
50891
|
-
var
|
|
52157
|
+
var adapter3 = async (opts = {}, overloadOpts) => {
|
|
50892
52158
|
const controller = new AbortController;
|
|
50893
52159
|
const signal = controller.signal;
|
|
50894
52160
|
const isPostFile = opts.isPostFile || false;
|
|
@@ -50957,7 +52223,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
50957
52223
|
const isJson = contentType && contentType.includes("application/json");
|
|
50958
52224
|
if (isJson && !isText) {
|
|
50959
52225
|
return await response.json();
|
|
50960
|
-
} else if (
|
|
52226
|
+
} else if (isTextForContentType3(contentType)) {
|
|
50961
52227
|
return {
|
|
50962
52228
|
code: response.status,
|
|
50963
52229
|
status: response.status,
|
|
@@ -50981,7 +52247,7 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
50981
52247
|
clearTimeout(timer);
|
|
50982
52248
|
});
|
|
50983
52249
|
};
|
|
50984
|
-
var
|
|
52250
|
+
var wrapperError3 = ({ code, message }) => {
|
|
50985
52251
|
const result = {
|
|
50986
52252
|
code: code || 500,
|
|
50987
52253
|
success: false,
|
|
@@ -50992,7 +52258,7 @@ var wrapperError2 = ({ code, message }) => {
|
|
|
50992
52258
|
return result;
|
|
50993
52259
|
};
|
|
50994
52260
|
|
|
50995
|
-
class
|
|
52261
|
+
class Query3 {
|
|
50996
52262
|
adapter;
|
|
50997
52263
|
url;
|
|
50998
52264
|
beforeRequest;
|
|
@@ -51003,7 +52269,7 @@ class Query2 {
|
|
|
51003
52269
|
qws;
|
|
51004
52270
|
isClient = false;
|
|
51005
52271
|
constructor(opts) {
|
|
51006
|
-
this.adapter = opts?.adapter ||
|
|
52272
|
+
this.adapter = opts?.adapter || adapter3;
|
|
51007
52273
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
51008
52274
|
this.url = opts?.url || defaultURL;
|
|
51009
52275
|
this.headers = opts?.headers || {
|
|
@@ -51036,9 +52302,9 @@ class Query2 {
|
|
|
51036
52302
|
}
|
|
51037
52303
|
async post(body, options) {
|
|
51038
52304
|
const url3 = options?.url || this.url;
|
|
51039
|
-
const { headers, adapter:
|
|
52305
|
+
const { headers, adapter: adapter4, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
51040
52306
|
const _headers = { ...this.headers, ...headers };
|
|
51041
|
-
const _adapter =
|
|
52307
|
+
const _adapter = adapter4 || this.adapter;
|
|
51042
52308
|
const _beforeRequest = beforeRequest || this.beforeRequest;
|
|
51043
52309
|
const _afterResponse = afterResponse || this.afterResponse;
|
|
51044
52310
|
const _timeout = timeout || this.timeout;
|
|
@@ -51053,7 +52319,7 @@ class Query2 {
|
|
|
51053
52319
|
if (_beforeRequest) {
|
|
51054
52320
|
const res = await _beforeRequest(req);
|
|
51055
52321
|
if (res === false) {
|
|
51056
|
-
return
|
|
52322
|
+
return wrapperError3({
|
|
51057
52323
|
code: 500,
|
|
51058
52324
|
message: "request is cancel",
|
|
51059
52325
|
req
|
|
@@ -51062,7 +52328,7 @@ class Query2 {
|
|
|
51062
52328
|
}
|
|
51063
52329
|
} catch (e) {
|
|
51064
52330
|
console.error("request beforeFn error", e, req);
|
|
51065
|
-
return
|
|
52331
|
+
return wrapperError3({
|
|
51066
52332
|
code: 500,
|
|
51067
52333
|
message: "api request beforeFn error"
|
|
51068
52334
|
});
|
|
@@ -51089,13 +52355,13 @@ class Query2 {
|
|
|
51089
52355
|
return await _afterResponse(res, {
|
|
51090
52356
|
req,
|
|
51091
52357
|
res,
|
|
51092
|
-
fetch:
|
|
52358
|
+
fetch: adapter4
|
|
51093
52359
|
});
|
|
51094
52360
|
}
|
|
51095
52361
|
return res;
|
|
51096
52362
|
} catch (e) {
|
|
51097
52363
|
console.error("request afterFn error", e, req);
|
|
51098
|
-
return
|
|
52364
|
+
return wrapperError3({
|
|
51099
52365
|
code: 500,
|
|
51100
52366
|
message: "api request afterFn error"
|
|
51101
52367
|
});
|
|
@@ -51116,7 +52382,7 @@ class Query2 {
|
|
|
51116
52382
|
if (typeof urlOrOptions === "object") {
|
|
51117
52383
|
_options = { ...urlOrOptions, ..._options };
|
|
51118
52384
|
}
|
|
51119
|
-
const res = await
|
|
52385
|
+
const res = await adapter3({
|
|
51120
52386
|
method: "GET",
|
|
51121
52387
|
..._options,
|
|
51122
52388
|
headers: {
|
|
@@ -51141,7 +52407,7 @@ class AssistantQuery {
|
|
|
51141
52407
|
constructor(config2) {
|
|
51142
52408
|
config2.checkMounted();
|
|
51143
52409
|
this.config = config2;
|
|
51144
|
-
this.query = new
|
|
52410
|
+
this.query = new Query3({ url: config2.getRegistry() + "/api/router" });
|
|
51145
52411
|
}
|
|
51146
52412
|
post(body, options) {
|
|
51147
52413
|
return this.query.post(body, options);
|
|
@@ -51727,18 +52993,18 @@ class AssistantInit extends AssistantConfig {
|
|
|
51727
52993
|
return `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`;
|
|
51728
52994
|
}
|
|
51729
52995
|
setQuery(query2) {
|
|
51730
|
-
this.#query = query2 || new
|
|
52996
|
+
this.#query = query2 || new Query3({
|
|
51731
52997
|
url: `${this.getConfig()?.app?.url || "https://kevisual.cn"}/api/router`
|
|
51732
52998
|
});
|
|
51733
52999
|
}
|
|
51734
53000
|
checkConfigPath() {
|
|
51735
|
-
const assistantPath =
|
|
53001
|
+
const assistantPath = path11.join(this.configDir, "assistant-app", "assistant-config.json");
|
|
51736
53002
|
return checkFileExists(assistantPath);
|
|
51737
53003
|
}
|
|
51738
53004
|
createEnvConfig() {
|
|
51739
53005
|
const env3 = this.configPath?.envConfigPath;
|
|
51740
53006
|
if (!checkFileExists(env3, true)) {
|
|
51741
|
-
|
|
53007
|
+
fs13.writeFileSync(env3, `# 环境配置文件
|
|
51742
53008
|
`);
|
|
51743
53009
|
console.log(chalk2.green("助手环境配置.env文件创建成功"));
|
|
51744
53010
|
}
|
|
@@ -51746,7 +53012,7 @@ class AssistantInit extends AssistantConfig {
|
|
|
51746
53012
|
createOtherConfig() {
|
|
51747
53013
|
const appsConfig = this.configPath?.appsConfigPath;
|
|
51748
53014
|
if (!checkFileExists(appsConfig, true)) {
|
|
51749
|
-
|
|
53015
|
+
fs13.writeFileSync(appsConfig, JSON.stringify({ description: "apps manager.", list: [] }));
|
|
51750
53016
|
console.log(chalk2.green("助手应用配置文件 apps.json 创建成功"));
|
|
51751
53017
|
}
|
|
51752
53018
|
}
|
|
@@ -51768,20 +53034,20 @@ class AssistantInit extends AssistantConfig {
|
|
|
51768
53034
|
}
|
|
51769
53035
|
}
|
|
51770
53036
|
initPnpm() {
|
|
51771
|
-
const pnpmPath =
|
|
53037
|
+
const pnpmPath = path11.join(this.configDir, "assistant-app", "pnpm-workspace.yaml");
|
|
51772
53038
|
let create = false;
|
|
51773
53039
|
if (!checkFileExists(pnpmPath, true)) {
|
|
51774
53040
|
create = true;
|
|
51775
|
-
|
|
53041
|
+
fs13.writeFileSync(pnpmPath, `packages:
|
|
51776
53042
|
- 'apps/**/*'
|
|
51777
53043
|
- 'pages/**/*'
|
|
51778
53044
|
`);
|
|
51779
53045
|
console.log(chalk2.green("助手 pnpm-workspace.yaml 文件创建成功"));
|
|
51780
53046
|
}
|
|
51781
|
-
const packagePath =
|
|
53047
|
+
const packagePath = path11.join(this.configDir, "assistant-app", "package.json");
|
|
51782
53048
|
if (!checkFileExists(packagePath, true)) {
|
|
51783
53049
|
create = true;
|
|
51784
|
-
|
|
53050
|
+
fs13.writeFileSync(packagePath, `{
|
|
51785
53051
|
"name": "assistant-app",
|
|
51786
53052
|
"version": "1.0.0",
|
|
51787
53053
|
"description": "assistant-app package pnpm, node pkgs projects",
|
|
@@ -51823,7 +53089,7 @@ class AssistantInit extends AssistantConfig {
|
|
|
51823
53089
|
}
|
|
51824
53090
|
`);
|
|
51825
53091
|
console.log(chalk2.green("助手 package.json 文件创建成功, 正在安装依赖..."));
|
|
51826
|
-
installDeps({ appPath:
|
|
53092
|
+
installDeps({ appPath: path11.dirname(packagePath), isProduction: true }).then(() => {
|
|
51827
53093
|
console.log("------------------------------------------------");
|
|
51828
53094
|
console.log(chalk2.green("助手依赖安装完成"));
|
|
51829
53095
|
console.log("------------------------------------------------");
|
|
@@ -51834,10 +53100,10 @@ class AssistantInit extends AssistantConfig {
|
|
|
51834
53100
|
};
|
|
51835
53101
|
}
|
|
51836
53102
|
initIgnore() {
|
|
51837
|
-
const gitignorePath =
|
|
53103
|
+
const gitignorePath = path11.join(this.configDir, ".gitignore");
|
|
51838
53104
|
let content = "";
|
|
51839
53105
|
if (checkFileExists(gitignorePath, true)) {
|
|
51840
|
-
content =
|
|
53106
|
+
content = fs13.readFileSync(gitignorePath, "utf-8");
|
|
51841
53107
|
}
|
|
51842
53108
|
const ignoreLines = [
|
|
51843
53109
|
"node_modules",
|
|
@@ -51863,7 +53129,7 @@ ${line}`;
|
|
|
51863
53129
|
}
|
|
51864
53130
|
});
|
|
51865
53131
|
if (updated) {
|
|
51866
|
-
|
|
53132
|
+
fs13.writeFileSync(gitignorePath, content.trim() + `
|
|
51867
53133
|
`);
|
|
51868
53134
|
console.log(chalk2.green(".gitignore 文件更新成功"));
|
|
51869
53135
|
}
|
|
@@ -51892,24 +53158,24 @@ var manualParse = parseHomeArg(configDir);
|
|
|
51892
53158
|
var _configDir = manualParse.configDir;
|
|
51893
53159
|
var configDir2 = AssistantInit.detectConfigDir(_configDir);
|
|
51894
53160
|
var isInit = manualParse?.options?.help ? false : true;
|
|
51895
|
-
var assistantConfig2 =
|
|
53161
|
+
var assistantConfig2 = useContextKey2("assistantConfig", () => {
|
|
51896
53162
|
return new AssistantInit({
|
|
51897
53163
|
path: configDir2,
|
|
51898
53164
|
init: isInit,
|
|
51899
53165
|
initWorkspace: manualParse.isOpencode ? false : true
|
|
51900
53166
|
});
|
|
51901
53167
|
});
|
|
51902
|
-
var assistantQuery =
|
|
53168
|
+
var assistantQuery = useContextKey2("assistantQuery", () => {
|
|
51903
53169
|
return new AssistantQuery(assistantConfig2);
|
|
51904
53170
|
});
|
|
51905
|
-
var runtime =
|
|
53171
|
+
var runtime = useContextKey2("runtime", () => {
|
|
51906
53172
|
console.log("Runtime detected:", manualParse);
|
|
51907
53173
|
return {
|
|
51908
53174
|
type: "client",
|
|
51909
53175
|
isServer: manualParse.isServer
|
|
51910
53176
|
};
|
|
51911
53177
|
});
|
|
51912
|
-
var app =
|
|
53178
|
+
var app = useContextKey2("app", () => {
|
|
51913
53179
|
return new App({
|
|
51914
53180
|
serverOptions: {
|
|
51915
53181
|
path: "/client/router",
|
|
@@ -51921,7 +53187,7 @@ var app = useContextKey("app", () => {
|
|
|
51921
53187
|
}
|
|
51922
53188
|
});
|
|
51923
53189
|
});
|
|
51924
|
-
var simpleRouter =
|
|
53190
|
+
var simpleRouter = useContextKey2("simpleRouter", () => {
|
|
51925
53191
|
return new SimpleRouter;
|
|
51926
53192
|
});
|
|
51927
53193
|
app.route({
|
|
@@ -51938,7 +53204,7 @@ app.route({
|
|
|
51938
53204
|
}).addTo(app);
|
|
51939
53205
|
|
|
51940
53206
|
// ../node_modules/.pnpm/@kevisual+router@0.0.64_typescript@5.8.2/node_modules/@kevisual/router/dist/opencode.js
|
|
51941
|
-
function
|
|
53207
|
+
function getDefaultExportFromCjs5(x) {
|
|
51942
53208
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
51943
53209
|
}
|
|
51944
53210
|
var eventemitter3$1 = { exports: {} };
|
|
@@ -51979,11 +53245,11 @@ function requireEventemitter3$1() {
|
|
|
51979
53245
|
else
|
|
51980
53246
|
delete emitter._events[evt];
|
|
51981
53247
|
}
|
|
51982
|
-
function
|
|
53248
|
+
function EventEmitter5() {
|
|
51983
53249
|
this._events = new Events;
|
|
51984
53250
|
this._eventsCount = 0;
|
|
51985
53251
|
}
|
|
51986
|
-
|
|
53252
|
+
EventEmitter5.prototype.eventNames = function eventNames() {
|
|
51987
53253
|
var names = [], events, name;
|
|
51988
53254
|
if (this._eventsCount === 0)
|
|
51989
53255
|
return names;
|
|
@@ -51996,7 +53262,7 @@ function requireEventemitter3$1() {
|
|
|
51996
53262
|
}
|
|
51997
53263
|
return names;
|
|
51998
53264
|
};
|
|
51999
|
-
|
|
53265
|
+
EventEmitter5.prototype.listeners = function listeners(event) {
|
|
52000
53266
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
52001
53267
|
if (!handlers)
|
|
52002
53268
|
return [];
|
|
@@ -52007,7 +53273,7 @@ function requireEventemitter3$1() {
|
|
|
52007
53273
|
}
|
|
52008
53274
|
return ee;
|
|
52009
53275
|
};
|
|
52010
|
-
|
|
53276
|
+
EventEmitter5.prototype.listenerCount = function listenerCount(event) {
|
|
52011
53277
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
52012
53278
|
if (!listeners)
|
|
52013
53279
|
return 0;
|
|
@@ -52015,7 +53281,7 @@ function requireEventemitter3$1() {
|
|
|
52015
53281
|
return 1;
|
|
52016
53282
|
return listeners.length;
|
|
52017
53283
|
};
|
|
52018
|
-
|
|
53284
|
+
EventEmitter5.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
52019
53285
|
var evt = prefix ? prefix + event : event;
|
|
52020
53286
|
if (!this._events[evt])
|
|
52021
53287
|
return false;
|
|
@@ -52070,13 +53336,13 @@ function requireEventemitter3$1() {
|
|
|
52070
53336
|
}
|
|
52071
53337
|
return true;
|
|
52072
53338
|
};
|
|
52073
|
-
|
|
53339
|
+
EventEmitter5.prototype.on = function on(event, fn, context) {
|
|
52074
53340
|
return addListener(this, event, fn, context, false);
|
|
52075
53341
|
};
|
|
52076
|
-
|
|
53342
|
+
EventEmitter5.prototype.once = function once(event, fn, context) {
|
|
52077
53343
|
return addListener(this, event, fn, context, true);
|
|
52078
53344
|
};
|
|
52079
|
-
|
|
53345
|
+
EventEmitter5.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
52080
53346
|
var evt = prefix ? prefix + event : event;
|
|
52081
53347
|
if (!this._events[evt])
|
|
52082
53348
|
return this;
|
|
@@ -52102,7 +53368,7 @@ function requireEventemitter3$1() {
|
|
|
52102
53368
|
}
|
|
52103
53369
|
return this;
|
|
52104
53370
|
};
|
|
52105
|
-
|
|
53371
|
+
EventEmitter5.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
52106
53372
|
var evt;
|
|
52107
53373
|
if (event) {
|
|
52108
53374
|
evt = prefix ? prefix + event : event;
|
|
@@ -52114,19 +53380,19 @@ function requireEventemitter3$1() {
|
|
|
52114
53380
|
}
|
|
52115
53381
|
return this;
|
|
52116
53382
|
};
|
|
52117
|
-
|
|
52118
|
-
|
|
52119
|
-
|
|
52120
|
-
|
|
53383
|
+
EventEmitter5.prototype.off = EventEmitter5.prototype.removeListener;
|
|
53384
|
+
EventEmitter5.prototype.addListener = EventEmitter5.prototype.on;
|
|
53385
|
+
EventEmitter5.prefixed = prefix;
|
|
53386
|
+
EventEmitter5.EventEmitter = EventEmitter5;
|
|
52121
53387
|
{
|
|
52122
|
-
module.exports =
|
|
53388
|
+
module.exports = EventEmitter5;
|
|
52123
53389
|
}
|
|
52124
53390
|
})(eventemitter3$1);
|
|
52125
53391
|
return eventemitter3$1.exports;
|
|
52126
53392
|
}
|
|
52127
|
-
var
|
|
52128
|
-
var
|
|
52129
|
-
var
|
|
53393
|
+
var eventemitter3Exports4 = requireEventemitter3$1();
|
|
53394
|
+
var EventEmitter5 = /* @__PURE__ */ getDefaultExportFromCjs5(eventemitter3Exports4);
|
|
53395
|
+
var reRunFn3 = (promiseOpts) => {
|
|
52130
53396
|
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
52131
53397
|
const interval = promiseOpts.interval || 1000;
|
|
52132
53398
|
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
@@ -52178,14 +53444,14 @@ var reRunFn2 = (promiseOpts) => {
|
|
|
52178
53444
|
});
|
|
52179
53445
|
};
|
|
52180
53446
|
|
|
52181
|
-
class
|
|
53447
|
+
class BaseLoad3 {
|
|
52182
53448
|
modules = new Map;
|
|
52183
53449
|
event;
|
|
52184
53450
|
loading;
|
|
52185
|
-
static reRunFn =
|
|
53451
|
+
static reRunFn = reRunFn3;
|
|
52186
53452
|
timeout = 5 * 60 * 1000;
|
|
52187
53453
|
constructor() {
|
|
52188
|
-
this.event = new
|
|
53454
|
+
this.event = new EventEmitter5;
|
|
52189
53455
|
this.loading = false;
|
|
52190
53456
|
}
|
|
52191
53457
|
listenKey(key, listenOpts) {
|
|
@@ -52287,7 +53553,7 @@ class BaseLoad2 {
|
|
|
52287
53553
|
newModule.controller = new AbortController;
|
|
52288
53554
|
const signal = newModule.controller.signal;
|
|
52289
53555
|
this.modules.set(key, newModule);
|
|
52290
|
-
const data = await
|
|
53556
|
+
const data = await reRunFn3({
|
|
52291
53557
|
timeout: opts.timeout,
|
|
52292
53558
|
interval: opts.interval,
|
|
52293
53559
|
checkSuccess: opts.checkSuccess,
|
|
@@ -52386,21 +53652,21 @@ class BaseLoad2 {
|
|
|
52386
53652
|
}
|
|
52387
53653
|
}
|
|
52388
53654
|
}
|
|
52389
|
-
var
|
|
52390
|
-
var
|
|
52391
|
-
const env3 =
|
|
53655
|
+
var gt3 = globalThis || window || self;
|
|
53656
|
+
var useEnv3 = (initEnv, initKey = "config", isOverwrite) => {
|
|
53657
|
+
const env3 = gt3[initKey];
|
|
52392
53658
|
const _env = env3 || initEnv;
|
|
52393
53659
|
if (!env3) {
|
|
52394
53660
|
if (_env) {
|
|
52395
|
-
|
|
53661
|
+
gt3[initKey] = _env;
|
|
52396
53662
|
} else {
|
|
52397
|
-
|
|
53663
|
+
gt3[initKey] = {};
|
|
52398
53664
|
}
|
|
52399
53665
|
}
|
|
52400
|
-
return
|
|
53666
|
+
return gt3[initKey];
|
|
52401
53667
|
};
|
|
52402
|
-
var
|
|
52403
|
-
const _env =
|
|
53668
|
+
var useEnvKey3 = (key, init, initKey = "config") => {
|
|
53669
|
+
const _env = useEnv3({}, initKey);
|
|
52404
53670
|
if (key && typeof _env[key] !== "undefined") {
|
|
52405
53671
|
return _env[key];
|
|
52406
53672
|
}
|
|
@@ -52421,7 +53687,7 @@ var useEnvKey2 = (key, init, initKey = "config") => {
|
|
|
52421
53687
|
return _env[key];
|
|
52422
53688
|
}
|
|
52423
53689
|
if (key) {
|
|
52424
|
-
const baseLoad = new
|
|
53690
|
+
const baseLoad = new BaseLoad3;
|
|
52425
53691
|
const voidFn = async () => {
|
|
52426
53692
|
return _env[key];
|
|
52427
53693
|
};
|
|
@@ -52444,53 +53710,53 @@ var useEnvKey2 = (key, init, initKey = "config") => {
|
|
|
52444
53710
|
console.error("key is empty ");
|
|
52445
53711
|
return null;
|
|
52446
53712
|
};
|
|
52447
|
-
var
|
|
52448
|
-
const _env =
|
|
53713
|
+
var useEnvKeyNew3 = (key, initKey = "config", opts) => {
|
|
53714
|
+
const _env = useEnv3({}, initKey);
|
|
52449
53715
|
if (key) {
|
|
52450
53716
|
delete _env[key];
|
|
52451
53717
|
}
|
|
52452
53718
|
if (opts?.getNew && opts.init) {
|
|
52453
|
-
return
|
|
53719
|
+
return useEnvKey3(key, opts.init, initKey);
|
|
52454
53720
|
} else if (opts?.getNew) {
|
|
52455
|
-
return
|
|
53721
|
+
return useEnvKey3(key, null, initKey);
|
|
52456
53722
|
}
|
|
52457
53723
|
};
|
|
52458
|
-
var
|
|
53724
|
+
var useContextKey3 = (key, init, isNew) => {
|
|
52459
53725
|
if (isNew) {
|
|
52460
|
-
return
|
|
53726
|
+
return useEnvKeyNew3(key, "context", { getNew: true, init });
|
|
52461
53727
|
}
|
|
52462
|
-
return
|
|
53728
|
+
return useEnvKey3(key, init, "context");
|
|
52463
53729
|
};
|
|
52464
|
-
var
|
|
52465
|
-
var
|
|
53730
|
+
var use3 = useContextKey3;
|
|
53731
|
+
var useConfigKey3 = (key, init, isNew) => {
|
|
52466
53732
|
if (isNew) {
|
|
52467
|
-
return
|
|
53733
|
+
return useEnvKeyNew3(key, "config", { getNew: true, init });
|
|
52468
53734
|
}
|
|
52469
|
-
return
|
|
53735
|
+
return useEnvKey3(key, init, "config");
|
|
52470
53736
|
};
|
|
52471
53737
|
|
|
52472
|
-
class
|
|
53738
|
+
class InitEnv3 {
|
|
52473
53739
|
static isInit = false;
|
|
52474
53740
|
static init(opts) {
|
|
52475
|
-
if (
|
|
53741
|
+
if (InitEnv3.isInit) {
|
|
52476
53742
|
return;
|
|
52477
53743
|
}
|
|
52478
53744
|
const { load = true, page = false } = opts || {};
|
|
52479
|
-
|
|
52480
|
-
|
|
52481
|
-
|
|
52482
|
-
|
|
52483
|
-
|
|
52484
|
-
load && (
|
|
53745
|
+
InitEnv3.isInit = true;
|
|
53746
|
+
gt3.useConfigKey = useConfigKey3;
|
|
53747
|
+
gt3.useContextKey = useContextKey3;
|
|
53748
|
+
gt3.use = use3;
|
|
53749
|
+
gt3.webEnv = { useConfigKey: useConfigKey3, useContextKey: useContextKey3, use: use3 };
|
|
53750
|
+
load && (gt3.Load = BaseLoad3);
|
|
52485
53751
|
}
|
|
52486
53752
|
}
|
|
52487
|
-
|
|
52488
|
-
var
|
|
52489
|
-
var
|
|
52490
|
-
function
|
|
52491
|
-
if (
|
|
52492
|
-
return
|
|
52493
|
-
|
|
53753
|
+
InitEnv3.init();
|
|
53754
|
+
var eventemitter34 = { exports: {} };
|
|
53755
|
+
var hasRequiredEventemitter34;
|
|
53756
|
+
function requireEventemitter34() {
|
|
53757
|
+
if (hasRequiredEventemitter34)
|
|
53758
|
+
return eventemitter34.exports;
|
|
53759
|
+
hasRequiredEventemitter34 = 1;
|
|
52494
53760
|
(function(module) {
|
|
52495
53761
|
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
52496
53762
|
function Events() {}
|
|
@@ -52523,11 +53789,11 @@ function requireEventemitter33() {
|
|
|
52523
53789
|
else
|
|
52524
53790
|
delete emitter._events[evt];
|
|
52525
53791
|
}
|
|
52526
|
-
function
|
|
53792
|
+
function EventEmitter6() {
|
|
52527
53793
|
this._events = new Events;
|
|
52528
53794
|
this._eventsCount = 0;
|
|
52529
53795
|
}
|
|
52530
|
-
|
|
53796
|
+
EventEmitter6.prototype.eventNames = function eventNames() {
|
|
52531
53797
|
var names = [], events, name;
|
|
52532
53798
|
if (this._eventsCount === 0)
|
|
52533
53799
|
return names;
|
|
@@ -52540,7 +53806,7 @@ function requireEventemitter33() {
|
|
|
52540
53806
|
}
|
|
52541
53807
|
return names;
|
|
52542
53808
|
};
|
|
52543
|
-
|
|
53809
|
+
EventEmitter6.prototype.listeners = function listeners(event) {
|
|
52544
53810
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
52545
53811
|
if (!handlers)
|
|
52546
53812
|
return [];
|
|
@@ -52551,7 +53817,7 @@ function requireEventemitter33() {
|
|
|
52551
53817
|
}
|
|
52552
53818
|
return ee;
|
|
52553
53819
|
};
|
|
52554
|
-
|
|
53820
|
+
EventEmitter6.prototype.listenerCount = function listenerCount(event) {
|
|
52555
53821
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
52556
53822
|
if (!listeners)
|
|
52557
53823
|
return 0;
|
|
@@ -52559,7 +53825,7 @@ function requireEventemitter33() {
|
|
|
52559
53825
|
return 1;
|
|
52560
53826
|
return listeners.length;
|
|
52561
53827
|
};
|
|
52562
|
-
|
|
53828
|
+
EventEmitter6.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
52563
53829
|
var evt = prefix ? prefix + event : event;
|
|
52564
53830
|
if (!this._events[evt])
|
|
52565
53831
|
return false;
|
|
@@ -52614,13 +53880,13 @@ function requireEventemitter33() {
|
|
|
52614
53880
|
}
|
|
52615
53881
|
return true;
|
|
52616
53882
|
};
|
|
52617
|
-
|
|
53883
|
+
EventEmitter6.prototype.on = function on(event, fn, context) {
|
|
52618
53884
|
return addListener(this, event, fn, context, false);
|
|
52619
53885
|
};
|
|
52620
|
-
|
|
53886
|
+
EventEmitter6.prototype.once = function once(event, fn, context) {
|
|
52621
53887
|
return addListener(this, event, fn, context, true);
|
|
52622
53888
|
};
|
|
52623
|
-
|
|
53889
|
+
EventEmitter6.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
52624
53890
|
var evt = prefix ? prefix + event : event;
|
|
52625
53891
|
if (!this._events[evt])
|
|
52626
53892
|
return this;
|
|
@@ -52646,7 +53912,7 @@ function requireEventemitter33() {
|
|
|
52646
53912
|
}
|
|
52647
53913
|
return this;
|
|
52648
53914
|
};
|
|
52649
|
-
|
|
53915
|
+
EventEmitter6.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
52650
53916
|
var evt;
|
|
52651
53917
|
if (event) {
|
|
52652
53918
|
evt = prefix ? prefix + event : event;
|
|
@@ -52658,17 +53924,17 @@ function requireEventemitter33() {
|
|
|
52658
53924
|
}
|
|
52659
53925
|
return this;
|
|
52660
53926
|
};
|
|
52661
|
-
|
|
52662
|
-
|
|
52663
|
-
|
|
52664
|
-
|
|
53927
|
+
EventEmitter6.prototype.off = EventEmitter6.prototype.removeListener;
|
|
53928
|
+
EventEmitter6.prototype.addListener = EventEmitter6.prototype.on;
|
|
53929
|
+
EventEmitter6.prefixed = prefix;
|
|
53930
|
+
EventEmitter6.EventEmitter = EventEmitter6;
|
|
52665
53931
|
{
|
|
52666
|
-
module.exports =
|
|
53932
|
+
module.exports = EventEmitter6;
|
|
52667
53933
|
}
|
|
52668
|
-
})(
|
|
52669
|
-
return
|
|
53934
|
+
})(eventemitter34);
|
|
53935
|
+
return eventemitter34.exports;
|
|
52670
53936
|
}
|
|
52671
|
-
|
|
53937
|
+
requireEventemitter34();
|
|
52672
53938
|
var NEVER2 = Object.freeze({
|
|
52673
53939
|
status: "aborted"
|
|
52674
53940
|
});
|
|
@@ -52846,10 +54112,10 @@ function mergeDefs2(...defs) {
|
|
|
52846
54112
|
function cloneDef2(schema) {
|
|
52847
54113
|
return mergeDefs2(schema._zod.def);
|
|
52848
54114
|
}
|
|
52849
|
-
function getElementAtPath2(obj,
|
|
52850
|
-
if (!
|
|
54115
|
+
function getElementAtPath2(obj, path12) {
|
|
54116
|
+
if (!path12)
|
|
52851
54117
|
return obj;
|
|
52852
|
-
return
|
|
54118
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
52853
54119
|
}
|
|
52854
54120
|
function promiseAllObject2(promisesObj) {
|
|
52855
54121
|
const keys = Object.keys(promisesObj);
|
|
@@ -53230,11 +54496,11 @@ function aborted2(x, startIndex = 0) {
|
|
|
53230
54496
|
}
|
|
53231
54497
|
return false;
|
|
53232
54498
|
}
|
|
53233
|
-
function prefixIssues2(
|
|
54499
|
+
function prefixIssues2(path12, issues) {
|
|
53234
54500
|
return issues.map((iss) => {
|
|
53235
54501
|
var _a2;
|
|
53236
54502
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
53237
|
-
iss.path.unshift(
|
|
54503
|
+
iss.path.unshift(path12);
|
|
53238
54504
|
return iss;
|
|
53239
54505
|
});
|
|
53240
54506
|
}
|
|
@@ -53480,7 +54746,7 @@ function formatError2(error3, mapper = (issue3) => issue3.message) {
|
|
|
53480
54746
|
}
|
|
53481
54747
|
function treeifyError2(error3, mapper = (issue3) => issue3.message) {
|
|
53482
54748
|
const result = { errors: [] };
|
|
53483
|
-
const processError = (error4,
|
|
54749
|
+
const processError = (error4, path12 = []) => {
|
|
53484
54750
|
var _a2, _b;
|
|
53485
54751
|
for (const issue3 of error4.issues) {
|
|
53486
54752
|
if (issue3.code === "invalid_union" && issue3.errors.length) {
|
|
@@ -53490,7 +54756,7 @@ function treeifyError2(error3, mapper = (issue3) => issue3.message) {
|
|
|
53490
54756
|
} else if (issue3.code === "invalid_element") {
|
|
53491
54757
|
processError({ issues: issue3.issues }, issue3.path);
|
|
53492
54758
|
} else {
|
|
53493
|
-
const fullpath = [...
|
|
54759
|
+
const fullpath = [...path12, ...issue3.path];
|
|
53494
54760
|
if (fullpath.length === 0) {
|
|
53495
54761
|
result.errors.push(mapper(issue3));
|
|
53496
54762
|
continue;
|
|
@@ -53522,8 +54788,8 @@ function treeifyError2(error3, mapper = (issue3) => issue3.message) {
|
|
|
53522
54788
|
}
|
|
53523
54789
|
function toDotPath2(_path) {
|
|
53524
54790
|
const segs = [];
|
|
53525
|
-
const
|
|
53526
|
-
for (const seg of
|
|
54791
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
54792
|
+
for (const seg of path12) {
|
|
53527
54793
|
if (typeof seg === "number")
|
|
53528
54794
|
segs.push(`[${seg}]`);
|
|
53529
54795
|
else if (typeof seg === "symbol")
|
|
@@ -65474,13 +66740,13 @@ function resolveRef2(ref, ctx) {
|
|
|
65474
66740
|
if (!ref.startsWith("#")) {
|
|
65475
66741
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
65476
66742
|
}
|
|
65477
|
-
const
|
|
65478
|
-
if (
|
|
66743
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
66744
|
+
if (path12.length === 0) {
|
|
65479
66745
|
return ctx.rootSchema;
|
|
65480
66746
|
}
|
|
65481
66747
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
65482
|
-
if (
|
|
65483
|
-
const key =
|
|
66748
|
+
if (path12[0] === defsKey) {
|
|
66749
|
+
const key = path12[1];
|
|
65484
66750
|
if (!key || !ctx.defs[key]) {
|
|
65485
66751
|
throw new Error(`Reference not found: ${ref}`);
|
|
65486
66752
|
}
|
|
@@ -66370,8 +67636,8 @@ class Parser2 {
|
|
|
66370
67636
|
}
|
|
66371
67637
|
|
|
66372
67638
|
class Executor2 {
|
|
66373
|
-
getValueByPath(obj,
|
|
66374
|
-
return
|
|
67639
|
+
getValueByPath(obj, path12) {
|
|
67640
|
+
return path12.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
66375
67641
|
}
|
|
66376
67642
|
likeToRegex(pattern2) {
|
|
66377
67643
|
let regex = "";
|
|
@@ -66489,11 +67755,11 @@ var addCallFn = (app2) => {
|
|
|
66489
67755
|
})
|
|
66490
67756
|
}
|
|
66491
67757
|
}).define(async (ctx) => {
|
|
66492
|
-
const { path:
|
|
66493
|
-
if (!
|
|
67758
|
+
const { path: path12, key = "" } = ctx.query;
|
|
67759
|
+
if (!path12) {
|
|
66494
67760
|
ctx.throw("路径path不能为空");
|
|
66495
67761
|
}
|
|
66496
|
-
const res = await ctx.run({ path:
|
|
67762
|
+
const res = await ctx.run({ path: path12, key, payload: ctx.query.payload || {} }, {
|
|
66497
67763
|
...ctx
|
|
66498
67764
|
});
|
|
66499
67765
|
ctx.forward(res);
|
|
@@ -66502,7 +67768,7 @@ var addCallFn = (app2) => {
|
|
|
66502
67768
|
var createRouterAgentPluginFn = (opts) => {
|
|
66503
67769
|
let router = opts?.router;
|
|
66504
67770
|
if (!router) {
|
|
66505
|
-
const app2 =
|
|
67771
|
+
const app2 = useContextKey3("app");
|
|
66506
67772
|
router = app2;
|
|
66507
67773
|
}
|
|
66508
67774
|
if (!router) {
|
|
@@ -66523,7 +67789,7 @@ var createRouterAgentPluginFn = (opts) => {
|
|
|
66523
67789
|
return false;
|
|
66524
67790
|
});
|
|
66525
67791
|
const AgentPlugin = async (pluginInput) => {
|
|
66526
|
-
|
|
67792
|
+
useContextKey3("plugin-input", () => pluginInput, true);
|
|
66527
67793
|
const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {};
|
|
66528
67794
|
return {
|
|
66529
67795
|
...hooks,
|
|
@@ -66619,8 +67885,8 @@ app.route({
|
|
|
66619
67885
|
}).addTo(app);
|
|
66620
67886
|
|
|
66621
67887
|
// src/services/app/index.ts
|
|
66622
|
-
import
|
|
66623
|
-
import
|
|
67888
|
+
import path12 from "path";
|
|
67889
|
+
import fs14 from "fs";
|
|
66624
67890
|
|
|
66625
67891
|
// ../node_modules/.pnpm/@inquirer+core@11.1.1_@types+node@25.1.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
66626
67892
|
var isTabKey = (key) => key.name === "tab";
|
|
@@ -68110,7 +69376,7 @@ class AppDownload {
|
|
|
68110
69376
|
if (type === "web") {
|
|
68111
69377
|
args2.push("-o", pagesDir);
|
|
68112
69378
|
} else if (type === "app") {
|
|
68113
|
-
args2.push("-o",
|
|
69379
|
+
args2.push("-o", path12.join(appsDir));
|
|
68114
69380
|
} else {
|
|
68115
69381
|
throw new Error("应用类型错误,只能是 web 或 app");
|
|
68116
69382
|
}
|
|
@@ -68143,10 +69409,10 @@ class AppDownload {
|
|
|
68143
69409
|
let deletePath = "";
|
|
68144
69410
|
let isDelete = false;
|
|
68145
69411
|
if (type === "web") {
|
|
68146
|
-
const pagePath =
|
|
69412
|
+
const pagePath = path12.join(pagesDir, id3);
|
|
68147
69413
|
deletePath = pagePath;
|
|
68148
69414
|
} else if (type === "app") {
|
|
68149
|
-
const appPath =
|
|
69415
|
+
const appPath = path12.join(appsDir, id3);
|
|
68150
69416
|
deletePath = appPath;
|
|
68151
69417
|
}
|
|
68152
69418
|
if (deletePath && checkFileExists(deletePath)) {
|
|
@@ -68157,7 +69423,7 @@ class AppDownload {
|
|
|
68157
69423
|
return;
|
|
68158
69424
|
}
|
|
68159
69425
|
}
|
|
68160
|
-
|
|
69426
|
+
fs14.rmSync(deletePath, { recursive: true });
|
|
68161
69427
|
isDelete = true;
|
|
68162
69428
|
console.log(`删除应用成功: ${deletePath}`);
|
|
68163
69429
|
}
|
|
@@ -68234,18 +69500,18 @@ app.route({
|
|
|
68234
69500
|
}).addTo(app);
|
|
68235
69501
|
|
|
68236
69502
|
// ../node_modules/.pnpm/@kevisual+ai@0.0.24/node_modules/@kevisual/ai/dist/ai-provider-browser.js
|
|
68237
|
-
var
|
|
68238
|
-
var
|
|
68239
|
-
var
|
|
68240
|
-
var
|
|
69503
|
+
var __create4 = Object.create;
|
|
69504
|
+
var __getProtoOf4 = Object.getPrototypeOf;
|
|
69505
|
+
var __defProp4 = Object.defineProperty;
|
|
69506
|
+
var __getOwnPropNames4 = Object.getOwnPropertyNames;
|
|
68241
69507
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
68242
|
-
var
|
|
68243
|
-
var
|
|
68244
|
-
target = mod != null ?
|
|
68245
|
-
const to = isNodeMode || !mod || !mod.__esModule ?
|
|
68246
|
-
for (let key of
|
|
68247
|
-
if (!
|
|
68248
|
-
|
|
69508
|
+
var __hasOwnProp4 = Object.prototype.hasOwnProperty;
|
|
69509
|
+
var __toESM4 = (mod, isNodeMode, target) => {
|
|
69510
|
+
target = mod != null ? __create4(__getProtoOf4(mod)) : {};
|
|
69511
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp4(target, "default", { value: mod, enumerable: true }) : target;
|
|
69512
|
+
for (let key of __getOwnPropNames4(mod))
|
|
69513
|
+
if (!__hasOwnProp4.call(to, key))
|
|
69514
|
+
__defProp4(to, key, {
|
|
68249
69515
|
get: () => mod[key],
|
|
68250
69516
|
enumerable: true
|
|
68251
69517
|
});
|
|
@@ -68256,19 +69522,19 @@ var __toCommonJS2 = (from) => {
|
|
|
68256
69522
|
var entry2 = __moduleCache2.get(from), desc;
|
|
68257
69523
|
if (entry2)
|
|
68258
69524
|
return entry2;
|
|
68259
|
-
entry2 =
|
|
69525
|
+
entry2 = __defProp4({}, "__esModule", { value: true });
|
|
68260
69526
|
if (from && typeof from === "object" || typeof from === "function")
|
|
68261
|
-
|
|
69527
|
+
__getOwnPropNames4(from).map((key) => !__hasOwnProp4.call(entry2, key) && __defProp4(entry2, key, {
|
|
68262
69528
|
get: () => from[key],
|
|
68263
69529
|
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
68264
69530
|
}));
|
|
68265
69531
|
__moduleCache2.set(from, entry2);
|
|
68266
69532
|
return entry2;
|
|
68267
69533
|
};
|
|
68268
|
-
var
|
|
69534
|
+
var __commonJS4 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
68269
69535
|
var __export2 = (target, all) => {
|
|
68270
69536
|
for (var name in all)
|
|
68271
|
-
|
|
69537
|
+
__defProp4(target, name, {
|
|
68272
69538
|
get: all[name],
|
|
68273
69539
|
enumerable: true,
|
|
68274
69540
|
configurable: true,
|
|
@@ -70055,13 +71321,13 @@ __export2(exports_events, {
|
|
|
70055
71321
|
setMaxListeners: () => setMaxListeners2,
|
|
70056
71322
|
once: () => once2,
|
|
70057
71323
|
listenerCount: () => listenerCount2,
|
|
70058
|
-
init: () =>
|
|
71324
|
+
init: () => EventEmitter6,
|
|
70059
71325
|
getMaxListeners: () => getMaxListeners2,
|
|
70060
71326
|
getEventListeners: () => getEventListeners,
|
|
70061
71327
|
default: () => events_default,
|
|
70062
71328
|
captureRejectionSymbol: () => captureRejectionSymbol,
|
|
70063
71329
|
addAbortListener: () => addAbortListener,
|
|
70064
|
-
EventEmitter: () =>
|
|
71330
|
+
EventEmitter: () => EventEmitter6
|
|
70065
71331
|
});
|
|
70066
71332
|
function emitError(emitter, args2) {
|
|
70067
71333
|
var { _events: events } = emitter;
|
|
@@ -70209,7 +71475,7 @@ var kRejection;
|
|
|
70209
71475
|
var captureRejectionSymbol;
|
|
70210
71476
|
var ArrayPrototypeSlice;
|
|
70211
71477
|
var defaultMaxListeners = 10;
|
|
70212
|
-
var
|
|
71478
|
+
var EventEmitter6 = function(opts) {
|
|
70213
71479
|
if (this._events === undefined || this._events === this.__proto__._events)
|
|
70214
71480
|
this._events = { __proto__: null }, this._eventsCount = 0;
|
|
70215
71481
|
if (this._maxListeners ??= undefined, this[kCapture] = opts?.captureRejections ? Boolean(opts?.captureRejections) : EventEmitterPrototype[kCapture])
|
|
@@ -70293,14 +71559,14 @@ var init_events = __esm2(() => {
|
|
|
70293
71559
|
kRejection = SymbolFor("nodejs.rejection");
|
|
70294
71560
|
captureRejectionSymbol = SymbolFor("nodejs.rejection");
|
|
70295
71561
|
ArrayPrototypeSlice = Array.prototype.slice;
|
|
70296
|
-
EventEmitterPrototype =
|
|
71562
|
+
EventEmitterPrototype = EventEmitter6.prototype = {};
|
|
70297
71563
|
EventEmitterPrototype._events = undefined;
|
|
70298
71564
|
EventEmitterPrototype._eventsCount = 0;
|
|
70299
71565
|
EventEmitterPrototype._maxListeners = undefined;
|
|
70300
71566
|
EventEmitterPrototype.setMaxListeners = function(n) {
|
|
70301
71567
|
return validateNumber2(n, "setMaxListeners", 0), this._maxListeners = n, this;
|
|
70302
71568
|
};
|
|
70303
|
-
EventEmitterPrototype.constructor =
|
|
71569
|
+
EventEmitterPrototype.constructor = EventEmitter6;
|
|
70304
71570
|
EventEmitterPrototype.getMaxListeners = function() {
|
|
70305
71571
|
return this?._maxListeners ?? defaultMaxListeners;
|
|
70306
71572
|
};
|
|
@@ -70423,7 +71689,7 @@ var init_events = __esm2(() => {
|
|
|
70423
71689
|
this.code = "ABORT_ERR", this.name = "AbortError";
|
|
70424
71690
|
}
|
|
70425
71691
|
};
|
|
70426
|
-
Object.defineProperties(
|
|
71692
|
+
Object.defineProperties(EventEmitter6, { captureRejections: { get() {
|
|
70427
71693
|
return EventEmitterPrototype[kCapture];
|
|
70428
71694
|
}, set(value) {
|
|
70429
71695
|
validateBoolean(value, "EventEmitter.captureRejections"), EventEmitterPrototype[kCapture] = value;
|
|
@@ -70432,10 +71698,10 @@ var init_events = __esm2(() => {
|
|
|
70432
71698
|
}, set: (arg) => {
|
|
70433
71699
|
validateNumber2(arg, "defaultMaxListeners", 0), defaultMaxListeners = arg;
|
|
70434
71700
|
} }, kMaxEventTargetListeners: { value: kMaxEventTargetListeners, enumerable: false, configurable: false, writable: false }, kMaxEventTargetListenersWarned: { value: kMaxEventTargetListenersWarned, enumerable: false, configurable: false, writable: false } });
|
|
70435
|
-
Object.assign(
|
|
70436
|
-
events_default =
|
|
71701
|
+
Object.assign(EventEmitter6, { once: once2, getEventListeners, getMaxListeners: getMaxListeners2, setMaxListeners: setMaxListeners2, EventEmitter: EventEmitter6, usingDomains: false, captureRejectionSymbol, errorMonitor: kErrorMonitor, addAbortListener, init: EventEmitter6, listenerCount: listenerCount2 });
|
|
71702
|
+
events_default = EventEmitter6;
|
|
70437
71703
|
});
|
|
70438
|
-
var require_stream5 =
|
|
71704
|
+
var require_stream5 = __commonJS4((exports, module) => {
|
|
70439
71705
|
var __commonJS22 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
70440
71706
|
var require_primordials = __commonJS22((exports2, module2) => {
|
|
70441
71707
|
|
|
@@ -74484,7 +75750,7 @@ var require_pbkdf2;
|
|
|
74484
75750
|
var require_browserify_cipher;
|
|
74485
75751
|
var require_diffie_hellman;
|
|
74486
75752
|
var require_browserify_sign;
|
|
74487
|
-
var
|
|
75753
|
+
var require_package4;
|
|
74488
75754
|
var require_bn;
|
|
74489
75755
|
var require_minimalistic_assert;
|
|
74490
75756
|
var require_utils5;
|
|
@@ -75518,7 +76784,7 @@ var init_crypto = __esm2(() => {
|
|
|
75518
76784
|
exports.createVerify = crypto22.createVerify;
|
|
75519
76785
|
exports.Verify = crypto22.Verify;
|
|
75520
76786
|
});
|
|
75521
|
-
|
|
76787
|
+
require_package4 = __commonJS22((exports, module) => {
|
|
75522
76788
|
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" } };
|
|
75523
76789
|
});
|
|
75524
76790
|
require_bn = __commonJS22((exports, module) => {
|
|
@@ -79188,7 +80454,7 @@ var init_crypto = __esm2(() => {
|
|
|
79188
80454
|
});
|
|
79189
80455
|
require_elliptic = __commonJS22((exports) => {
|
|
79190
80456
|
var elliptic = exports;
|
|
79191
|
-
elliptic.version =
|
|
80457
|
+
elliptic.version = require_package4().version;
|
|
79192
80458
|
elliptic.utils = require_utils22();
|
|
79193
80459
|
elliptic.rand = require_brorand();
|
|
79194
80460
|
elliptic.curve = require_curve();
|
|
@@ -82158,8 +83424,8 @@ var init_crypto = __esm2(() => {
|
|
|
82158
83424
|
return result;
|
|
82159
83425
|
return { result: this.isError(result) ? null : result, errors: state.errors };
|
|
82160
83426
|
};
|
|
82161
|
-
function ReporterError(
|
|
82162
|
-
this.path =
|
|
83427
|
+
function ReporterError(path13, msg) {
|
|
83428
|
+
this.path = path13, this.rethrow(msg);
|
|
82163
83429
|
}
|
|
82164
83430
|
inherits2(ReporterError, Error);
|
|
82165
83431
|
ReporterError.prototype.rethrow = function(msg) {
|
|
@@ -86590,7 +87856,7 @@ https://github.com/browserify/crypto-browserify`);
|
|
|
86590
87856
|
webcrypto2 = crypto;
|
|
86591
87857
|
crypto_default = crypto;
|
|
86592
87858
|
});
|
|
86593
|
-
var require_core =
|
|
87859
|
+
var require_core = __commonJS4((exports, module) => {
|
|
86594
87860
|
(function(root2, factory) {
|
|
86595
87861
|
if (typeof exports === "object") {
|
|
86596
87862
|
module.exports = exports = factory();
|
|
@@ -86873,7 +88139,7 @@ var require_core = __commonJS3((exports, module) => {
|
|
|
86873
88139
|
return CryptoJS;
|
|
86874
88140
|
});
|
|
86875
88141
|
});
|
|
86876
|
-
var require_enc_base64 =
|
|
88142
|
+
var require_enc_base64 = __commonJS4((exports, module) => {
|
|
86877
88143
|
(function(root2, factory) {
|
|
86878
88144
|
if (typeof exports === "object") {
|
|
86879
88145
|
module.exports = exports = factory(require_core());
|
|
@@ -86951,7 +88217,7 @@ var require_enc_base64 = __commonJS3((exports, module) => {
|
|
|
86951
88217
|
return CryptoJS.enc.Base64;
|
|
86952
88218
|
});
|
|
86953
88219
|
});
|
|
86954
|
-
var require_md52 =
|
|
88220
|
+
var require_md52 = __commonJS4((exports, module) => {
|
|
86955
88221
|
(function(root2, factory) {
|
|
86956
88222
|
if (typeof exports === "object") {
|
|
86957
88223
|
module.exports = exports = factory(require_core());
|
|
@@ -87126,7 +88392,7 @@ var require_md52 = __commonJS3((exports, module) => {
|
|
|
87126
88392
|
return CryptoJS.MD5;
|
|
87127
88393
|
});
|
|
87128
88394
|
});
|
|
87129
|
-
var require_sha1 =
|
|
88395
|
+
var require_sha1 = __commonJS4((exports, module) => {
|
|
87130
88396
|
(function(root2, factory) {
|
|
87131
88397
|
if (typeof exports === "object") {
|
|
87132
88398
|
module.exports = exports = factory(require_core());
|
|
@@ -87213,7 +88479,7 @@ var require_sha1 = __commonJS3((exports, module) => {
|
|
|
87213
88479
|
return CryptoJS.SHA1;
|
|
87214
88480
|
});
|
|
87215
88481
|
});
|
|
87216
|
-
var require_hmac2 =
|
|
88482
|
+
var require_hmac2 = __commonJS4((exports, module) => {
|
|
87217
88483
|
(function(root2, factory) {
|
|
87218
88484
|
if (typeof exports === "object") {
|
|
87219
88485
|
module.exports = exports = factory(require_core());
|
|
@@ -87273,7 +88539,7 @@ var require_hmac2 = __commonJS3((exports, module) => {
|
|
|
87273
88539
|
})();
|
|
87274
88540
|
});
|
|
87275
88541
|
});
|
|
87276
|
-
var require_evpkdf =
|
|
88542
|
+
var require_evpkdf = __commonJS4((exports, module) => {
|
|
87277
88543
|
(function(root2, factory, undef) {
|
|
87278
88544
|
if (typeof exports === "object") {
|
|
87279
88545
|
module.exports = exports = factory(require_core(), require_sha1(), require_hmac2());
|
|
@@ -87330,7 +88596,7 @@ var require_evpkdf = __commonJS3((exports, module) => {
|
|
|
87330
88596
|
return CryptoJS.EvpKDF;
|
|
87331
88597
|
});
|
|
87332
88598
|
});
|
|
87333
|
-
var require_cipher_core =
|
|
88599
|
+
var require_cipher_core = __commonJS4((exports, module) => {
|
|
87334
88600
|
(function(root2, factory, undef) {
|
|
87335
88601
|
if (typeof exports === "object") {
|
|
87336
88602
|
module.exports = exports = factory(require_core(), require_evpkdf());
|
|
@@ -87626,7 +88892,7 @@ var require_cipher_core = __commonJS3((exports, module) => {
|
|
|
87626
88892
|
}();
|
|
87627
88893
|
});
|
|
87628
88894
|
});
|
|
87629
|
-
var require_aes =
|
|
88895
|
+
var require_aes = __commonJS4((exports, module) => {
|
|
87630
88896
|
(function(root2, factory, undef) {
|
|
87631
88897
|
if (typeof exports === "object") {
|
|
87632
88898
|
module.exports = exports = factory(require_core(), require_enc_base64(), require_md52(), require_evpkdf(), require_cipher_core());
|
|
@@ -87776,7 +89042,7 @@ var require_aes = __commonJS3((exports, module) => {
|
|
|
87776
89042
|
return CryptoJS.AES;
|
|
87777
89043
|
});
|
|
87778
89044
|
});
|
|
87779
|
-
var require_enc_utf8 =
|
|
89045
|
+
var require_enc_utf8 = __commonJS4((exports, module) => {
|
|
87780
89046
|
(function(root2, factory) {
|
|
87781
89047
|
if (typeof exports === "object") {
|
|
87782
89048
|
module.exports = exports = factory(require_core());
|
|
@@ -88208,13 +89474,13 @@ class ProviderManager {
|
|
|
88208
89474
|
return this.provider.chat(messages);
|
|
88209
89475
|
}
|
|
88210
89476
|
}
|
|
88211
|
-
var import_aes =
|
|
88212
|
-
var import_enc_utf8 =
|
|
89477
|
+
var import_aes = __toESM4(require_aes(), 1);
|
|
89478
|
+
var import_enc_utf8 = __toESM4(require_enc_utf8(), 1);
|
|
88213
89479
|
var CryptoJS = { AES: import_aes.default, enc: { Utf8: import_enc_utf8.default } };
|
|
88214
89480
|
|
|
88215
89481
|
// src/routes/ai/index.ts
|
|
88216
|
-
var app2 =
|
|
88217
|
-
var query2 =
|
|
89482
|
+
var app2 = useContextKey2("app");
|
|
89483
|
+
var query2 = useContextKey2("assistantQuery");
|
|
88218
89484
|
app2.route({
|
|
88219
89485
|
path: "ai",
|
|
88220
89486
|
key: "chat",
|
|
@@ -88345,11 +89611,11 @@ app.route({
|
|
|
88345
89611
|
})
|
|
88346
89612
|
}
|
|
88347
89613
|
}).define(async (ctx) => {
|
|
88348
|
-
const { path:
|
|
88349
|
-
if (!
|
|
89614
|
+
const { path: path13, key = "" } = ctx.query;
|
|
89615
|
+
if (!path13) {
|
|
88350
89616
|
ctx.throw("路径path不能为空");
|
|
88351
89617
|
}
|
|
88352
|
-
const res = await ctx.run({ path:
|
|
89618
|
+
const res = await ctx.run({ path: path13, key, payload: ctx.query.payload || {} }, {
|
|
88353
89619
|
...ctx
|
|
88354
89620
|
});
|
|
88355
89621
|
ctx.forward(res);
|
|
@@ -88588,7 +89854,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
88588
89854
|
|
|
88589
89855
|
// ../node_modules/.pnpm/@opencode-ai+sdk@1.1.47/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
|
|
88590
89856
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
88591
|
-
var defaultPathSerializer = ({ path:
|
|
89857
|
+
var defaultPathSerializer = ({ path: path13, url: _url3 }) => {
|
|
88592
89858
|
let url4 = _url3;
|
|
88593
89859
|
const matches = _url3.match(PATH_PARAM_RE);
|
|
88594
89860
|
if (matches) {
|
|
@@ -88607,7 +89873,7 @@ var defaultPathSerializer = ({ path: path12, url: _url3 }) => {
|
|
|
88607
89873
|
name = name.substring(1);
|
|
88608
89874
|
style = "matrix";
|
|
88609
89875
|
}
|
|
88610
|
-
const value =
|
|
89876
|
+
const value = path13[name];
|
|
88611
89877
|
if (value === undefined || value === null) {
|
|
88612
89878
|
continue;
|
|
88613
89879
|
}
|
|
@@ -88638,11 +89904,11 @@ var defaultPathSerializer = ({ path: path12, url: _url3 }) => {
|
|
|
88638
89904
|
}
|
|
88639
89905
|
return url4;
|
|
88640
89906
|
};
|
|
88641
|
-
var getUrl = ({ baseUrl, path:
|
|
89907
|
+
var getUrl = ({ baseUrl, path: path13, query: query3, querySerializer, url: _url3 }) => {
|
|
88642
89908
|
const pathUrl = _url3.startsWith("/") ? _url3 : `/${_url3}`;
|
|
88643
89909
|
let url4 = (baseUrl ?? "") + pathUrl;
|
|
88644
|
-
if (
|
|
88645
|
-
url4 = defaultPathSerializer({ path:
|
|
89910
|
+
if (path13) {
|
|
89911
|
+
url4 = defaultPathSerializer({ path: path13, url: url4 });
|
|
88646
89912
|
}
|
|
88647
89913
|
let search = query3 ? querySerializer(query3) : "";
|
|
88648
89914
|
if (search.startsWith("?")) {
|
|
@@ -90161,16 +91427,16 @@ app.route({
|
|
|
90161
91427
|
}).addTo(app);
|
|
90162
91428
|
|
|
90163
91429
|
// ../node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
|
|
90164
|
-
var
|
|
90165
|
-
function
|
|
91430
|
+
var isBrowser4 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
91431
|
+
function getDefaultExportFromCjs6(x) {
|
|
90166
91432
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
90167
91433
|
}
|
|
90168
|
-
var
|
|
90169
|
-
var
|
|
90170
|
-
function
|
|
90171
|
-
if (
|
|
90172
|
-
return
|
|
90173
|
-
|
|
91434
|
+
var eventemitter35 = { exports: {} };
|
|
91435
|
+
var hasRequiredEventemitter35;
|
|
91436
|
+
function requireEventemitter35() {
|
|
91437
|
+
if (hasRequiredEventemitter35)
|
|
91438
|
+
return eventemitter35.exports;
|
|
91439
|
+
hasRequiredEventemitter35 = 1;
|
|
90174
91440
|
(function(module) {
|
|
90175
91441
|
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
90176
91442
|
function Events() {}
|
|
@@ -90203,11 +91469,11 @@ function requireEventemitter34() {
|
|
|
90203
91469
|
else
|
|
90204
91470
|
delete emitter._events[evt];
|
|
90205
91471
|
}
|
|
90206
|
-
function
|
|
91472
|
+
function EventEmitter7() {
|
|
90207
91473
|
this._events = new Events;
|
|
90208
91474
|
this._eventsCount = 0;
|
|
90209
91475
|
}
|
|
90210
|
-
|
|
91476
|
+
EventEmitter7.prototype.eventNames = function eventNames() {
|
|
90211
91477
|
var names = [], events, name;
|
|
90212
91478
|
if (this._eventsCount === 0)
|
|
90213
91479
|
return names;
|
|
@@ -90220,7 +91486,7 @@ function requireEventemitter34() {
|
|
|
90220
91486
|
}
|
|
90221
91487
|
return names;
|
|
90222
91488
|
};
|
|
90223
|
-
|
|
91489
|
+
EventEmitter7.prototype.listeners = function listeners(event) {
|
|
90224
91490
|
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
90225
91491
|
if (!handlers)
|
|
90226
91492
|
return [];
|
|
@@ -90231,7 +91497,7 @@ function requireEventemitter34() {
|
|
|
90231
91497
|
}
|
|
90232
91498
|
return ee;
|
|
90233
91499
|
};
|
|
90234
|
-
|
|
91500
|
+
EventEmitter7.prototype.listenerCount = function listenerCount(event) {
|
|
90235
91501
|
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
90236
91502
|
if (!listeners)
|
|
90237
91503
|
return 0;
|
|
@@ -90239,7 +91505,7 @@ function requireEventemitter34() {
|
|
|
90239
91505
|
return 1;
|
|
90240
91506
|
return listeners.length;
|
|
90241
91507
|
};
|
|
90242
|
-
|
|
91508
|
+
EventEmitter7.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
90243
91509
|
var evt = prefix ? prefix + event : event;
|
|
90244
91510
|
if (!this._events[evt])
|
|
90245
91511
|
return false;
|
|
@@ -90294,13 +91560,13 @@ function requireEventemitter34() {
|
|
|
90294
91560
|
}
|
|
90295
91561
|
return true;
|
|
90296
91562
|
};
|
|
90297
|
-
|
|
91563
|
+
EventEmitter7.prototype.on = function on(event, fn, context) {
|
|
90298
91564
|
return addListener(this, event, fn, context, false);
|
|
90299
91565
|
};
|
|
90300
|
-
|
|
91566
|
+
EventEmitter7.prototype.once = function once(event, fn, context) {
|
|
90301
91567
|
return addListener(this, event, fn, context, true);
|
|
90302
91568
|
};
|
|
90303
|
-
|
|
91569
|
+
EventEmitter7.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
90304
91570
|
var evt = prefix ? prefix + event : event;
|
|
90305
91571
|
if (!this._events[evt])
|
|
90306
91572
|
return this;
|
|
@@ -90326,7 +91592,7 @@ function requireEventemitter34() {
|
|
|
90326
91592
|
}
|
|
90327
91593
|
return this;
|
|
90328
91594
|
};
|
|
90329
|
-
|
|
91595
|
+
EventEmitter7.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
90330
91596
|
var evt;
|
|
90331
91597
|
if (event) {
|
|
90332
91598
|
evt = prefix ? prefix + event : event;
|
|
@@ -90338,19 +91604,19 @@ function requireEventemitter34() {
|
|
|
90338
91604
|
}
|
|
90339
91605
|
return this;
|
|
90340
91606
|
};
|
|
90341
|
-
|
|
90342
|
-
|
|
90343
|
-
|
|
90344
|
-
|
|
91607
|
+
EventEmitter7.prototype.off = EventEmitter7.prototype.removeListener;
|
|
91608
|
+
EventEmitter7.prototype.addListener = EventEmitter7.prototype.on;
|
|
91609
|
+
EventEmitter7.prefixed = prefix;
|
|
91610
|
+
EventEmitter7.EventEmitter = EventEmitter7;
|
|
90345
91611
|
{
|
|
90346
|
-
module.exports =
|
|
91612
|
+
module.exports = EventEmitter7;
|
|
90347
91613
|
}
|
|
90348
|
-
})(
|
|
90349
|
-
return
|
|
91614
|
+
})(eventemitter35);
|
|
91615
|
+
return eventemitter35.exports;
|
|
90350
91616
|
}
|
|
90351
|
-
var
|
|
90352
|
-
var
|
|
90353
|
-
var
|
|
91617
|
+
var eventemitter3Exports5 = requireEventemitter35();
|
|
91618
|
+
var EventEmitter7 = /* @__PURE__ */ getDefaultExportFromCjs6(eventemitter3Exports5);
|
|
91619
|
+
var reRunFn4 = (promiseOpts) => {
|
|
90354
91620
|
const timeout2 = promiseOpts.timeout || 5 * 60 * 1000;
|
|
90355
91621
|
const interval = promiseOpts.interval || 1000;
|
|
90356
91622
|
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
@@ -90402,14 +91668,14 @@ var reRunFn3 = (promiseOpts) => {
|
|
|
90402
91668
|
});
|
|
90403
91669
|
};
|
|
90404
91670
|
|
|
90405
|
-
class
|
|
91671
|
+
class BaseLoad4 {
|
|
90406
91672
|
modules = new Map;
|
|
90407
91673
|
event;
|
|
90408
91674
|
loading;
|
|
90409
|
-
static reRunFn =
|
|
91675
|
+
static reRunFn = reRunFn4;
|
|
90410
91676
|
timeout = 5 * 60 * 1000;
|
|
90411
91677
|
constructor() {
|
|
90412
|
-
this.event = new
|
|
91678
|
+
this.event = new EventEmitter7;
|
|
90413
91679
|
this.loading = false;
|
|
90414
91680
|
}
|
|
90415
91681
|
listenKey(key, listenOpts) {
|
|
@@ -90511,7 +91777,7 @@ class BaseLoad3 {
|
|
|
90511
91777
|
newModule.controller = new AbortController;
|
|
90512
91778
|
const signal = newModule.controller.signal;
|
|
90513
91779
|
this.modules.set(key, newModule);
|
|
90514
|
-
const data = await
|
|
91780
|
+
const data = await reRunFn4({
|
|
90515
91781
|
timeout: opts.timeout,
|
|
90516
91782
|
interval: opts.interval,
|
|
90517
91783
|
checkSuccess: opts.checkSuccess,
|
|
@@ -90610,23 +91876,23 @@ class BaseLoad3 {
|
|
|
90610
91876
|
}
|
|
90611
91877
|
}
|
|
90612
91878
|
}
|
|
90613
|
-
var
|
|
90614
|
-
var
|
|
90615
|
-
const env3 =
|
|
91879
|
+
var gt4 = globalThis || window || self;
|
|
91880
|
+
var useEnv4 = (initEnv, initKey = "config", isOverwrite) => {
|
|
91881
|
+
const env3 = gt4[initKey];
|
|
90616
91882
|
const _env = env3 || initEnv;
|
|
90617
91883
|
if (!env3) {
|
|
90618
91884
|
if (_env) {
|
|
90619
|
-
|
|
91885
|
+
gt4[initKey] = _env;
|
|
90620
91886
|
} else {
|
|
90621
|
-
|
|
91887
|
+
gt4[initKey] = {};
|
|
90622
91888
|
}
|
|
90623
91889
|
} else if (isOverwrite) {
|
|
90624
|
-
|
|
91890
|
+
gt4[initKey] = { ...env3, ...initEnv };
|
|
90625
91891
|
}
|
|
90626
|
-
return
|
|
91892
|
+
return gt4[initKey];
|
|
90627
91893
|
};
|
|
90628
|
-
var
|
|
90629
|
-
const _env =
|
|
91894
|
+
var useEnvKey4 = (key, init, initKey = "config") => {
|
|
91895
|
+
const _env = useEnv4({}, initKey);
|
|
90630
91896
|
if (key && typeof _env[key] !== "undefined") {
|
|
90631
91897
|
return _env[key];
|
|
90632
91898
|
}
|
|
@@ -90647,7 +91913,7 @@ var useEnvKey3 = (key, init, initKey = "config") => {
|
|
|
90647
91913
|
return _env[key];
|
|
90648
91914
|
}
|
|
90649
91915
|
if (key) {
|
|
90650
|
-
const baseLoad = new
|
|
91916
|
+
const baseLoad = new BaseLoad4;
|
|
90651
91917
|
const voidFn = async () => {
|
|
90652
91918
|
return _env[key];
|
|
90653
91919
|
};
|
|
@@ -90670,46 +91936,46 @@ var useEnvKey3 = (key, init, initKey = "config") => {
|
|
|
90670
91936
|
console.error("key is empty ");
|
|
90671
91937
|
return null;
|
|
90672
91938
|
};
|
|
90673
|
-
var
|
|
90674
|
-
const _env =
|
|
91939
|
+
var useEnvKeyNew4 = (key, initKey = "config", opts) => {
|
|
91940
|
+
const _env = useEnv4({}, initKey);
|
|
90675
91941
|
if (key) {
|
|
90676
91942
|
delete _env[key];
|
|
90677
91943
|
}
|
|
90678
91944
|
if (opts?.getNew && opts.init) {
|
|
90679
|
-
return
|
|
91945
|
+
return useEnvKey4(key, opts.init, initKey);
|
|
90680
91946
|
} else if (opts?.getNew) {
|
|
90681
|
-
return
|
|
91947
|
+
return useEnvKey4(key, null, initKey);
|
|
90682
91948
|
}
|
|
90683
91949
|
};
|
|
90684
|
-
var
|
|
91950
|
+
var useContextKey4 = (key, init, isNew) => {
|
|
90685
91951
|
if (isNew) {
|
|
90686
|
-
return
|
|
91952
|
+
return useEnvKeyNew4(key, "context", { getNew: true, init });
|
|
90687
91953
|
}
|
|
90688
|
-
return
|
|
91954
|
+
return useEnvKey4(key, init, "context");
|
|
90689
91955
|
};
|
|
90690
|
-
var
|
|
90691
|
-
var
|
|
91956
|
+
var use4 = useContextKey4;
|
|
91957
|
+
var useConfigKey4 = (key, init, isNew) => {
|
|
90692
91958
|
if (isNew) {
|
|
90693
|
-
return
|
|
91959
|
+
return useEnvKeyNew4(key, "config", { getNew: true, init });
|
|
90694
91960
|
}
|
|
90695
|
-
return
|
|
91961
|
+
return useEnvKey4(key, init, "config");
|
|
90696
91962
|
};
|
|
90697
|
-
class
|
|
91963
|
+
class InitEnv4 {
|
|
90698
91964
|
static isInit = false;
|
|
90699
91965
|
static init(opts) {
|
|
90700
|
-
if (
|
|
91966
|
+
if (InitEnv4.isInit) {
|
|
90701
91967
|
return;
|
|
90702
91968
|
}
|
|
90703
91969
|
const { load: load2 = true, page = false } = opts || {};
|
|
90704
|
-
|
|
90705
|
-
|
|
90706
|
-
|
|
90707
|
-
|
|
90708
|
-
|
|
90709
|
-
load2 && (
|
|
91970
|
+
InitEnv4.isInit = true;
|
|
91971
|
+
gt4.useConfigKey = useConfigKey4;
|
|
91972
|
+
gt4.useContextKey = useContextKey4;
|
|
91973
|
+
gt4.use = use4;
|
|
91974
|
+
gt4.webEnv = { useConfigKey: useConfigKey4, useContextKey: useContextKey4, use: use4 };
|
|
91975
|
+
load2 && (gt4.Load = BaseLoad4);
|
|
90710
91976
|
}
|
|
90711
91977
|
}
|
|
90712
|
-
|
|
91978
|
+
InitEnv4.init();
|
|
90713
91979
|
|
|
90714
91980
|
// src/routes/remote/index.ts
|
|
90715
91981
|
app.route({
|
|
@@ -90718,7 +91984,7 @@ app.route({
|
|
|
90718
91984
|
middleware: ["admin-auth"],
|
|
90719
91985
|
description: "获取远程app连接状态"
|
|
90720
91986
|
}).define(async (ctx) => {
|
|
90721
|
-
const manager =
|
|
91987
|
+
const manager = useContextKey4("manager");
|
|
90722
91988
|
if (manager?.remoteApp?.isConnect()) {
|
|
90723
91989
|
const url4 = manager.remoteUrl || "";
|
|
90724
91990
|
ctx.body = {
|
|
@@ -90736,7 +92002,7 @@ app.route({
|
|
|
90736
92002
|
middleware: ["admin-auth"],
|
|
90737
92003
|
description: "连接远程app"
|
|
90738
92004
|
}).define(async (ctx) => {
|
|
90739
|
-
const manager =
|
|
92005
|
+
const manager = useContextKey4("manager");
|
|
90740
92006
|
if (!manager) {
|
|
90741
92007
|
ctx.body = {
|
|
90742
92008
|
content: "远程app管理器未初始化"
|
|
@@ -92147,8 +93413,8 @@ app.route({
|
|
|
92147
93413
|
|
|
92148
93414
|
// src/routes-simple/upload.ts
|
|
92149
93415
|
var import_busboy = __toESM(require_lib2(), 1);
|
|
92150
|
-
import
|
|
92151
|
-
import
|
|
93416
|
+
import path15 from "path";
|
|
93417
|
+
import fs17 from "fs";
|
|
92152
93418
|
|
|
92153
93419
|
// ../node_modules/.pnpm/@kevisual+router@0.0.64_typescript@5.8.2/node_modules/@kevisual/router/src/server/cookie.ts
|
|
92154
93420
|
var NullObject2 = /* @__PURE__ */ (() => {
|
|
@@ -92233,18 +93499,18 @@ var getTokenFromRequest = (req) => {
|
|
|
92233
93499
|
|
|
92234
93500
|
// src/routes-simple/router.ts
|
|
92235
93501
|
import os5 from "node:os";
|
|
92236
|
-
import
|
|
92237
|
-
import
|
|
92238
|
-
var defaultCachePath =
|
|
92239
|
-
if (!
|
|
92240
|
-
|
|
93502
|
+
import path13 from "node:path";
|
|
93503
|
+
import fs15 from "node:fs";
|
|
93504
|
+
var defaultCachePath = path13.join(os5.homedir(), ".envision", "cache-file");
|
|
93505
|
+
if (!fs15.existsSync(defaultCachePath)) {
|
|
93506
|
+
fs15.mkdirSync(defaultCachePath, { recursive: true });
|
|
92241
93507
|
}
|
|
92242
93508
|
var cacheFilePath = defaultCachePath;
|
|
92243
93509
|
var eventClientsInit = () => {
|
|
92244
93510
|
const clients = new Map;
|
|
92245
93511
|
return clients;
|
|
92246
93512
|
};
|
|
92247
|
-
var clients =
|
|
93513
|
+
var clients = useContextKey4("event-clients", () => eventClientsInit());
|
|
92248
93514
|
var getTaskId = (req) => {
|
|
92249
93515
|
const url4 = new URL(req.url || "", "http://localhost");
|
|
92250
93516
|
const taskId = url4.searchParams.get("taskId");
|
|
@@ -92304,8 +93570,8 @@ var validateDirectory = (directory) => {
|
|
|
92304
93570
|
};
|
|
92305
93571
|
|
|
92306
93572
|
// src/module/upload/mv.ts
|
|
92307
|
-
import
|
|
92308
|
-
import
|
|
93573
|
+
import fs16 from "node:fs";
|
|
93574
|
+
import path14 from "node:path";
|
|
92309
93575
|
|
|
92310
93576
|
class UploadManager {
|
|
92311
93577
|
config;
|
|
@@ -92318,12 +93584,12 @@ class UploadManager {
|
|
|
92318
93584
|
const appsDir = this.config.configPath?.appsDir;
|
|
92319
93585
|
let dir = type === "app-file" ? appsDir : pageDir;
|
|
92320
93586
|
if (type === "file" || type === "app-file") {
|
|
92321
|
-
const fullTargetPath = targetPath.startsWith("/") ? targetPath :
|
|
93587
|
+
const fullTargetPath = targetPath.startsWith("/") ? targetPath : path14.join(dir, targetPath);
|
|
92322
93588
|
const targetDir = fullTargetPath.substring(0, fullTargetPath.lastIndexOf("/"));
|
|
92323
|
-
if (!
|
|
92324
|
-
|
|
93589
|
+
if (!fs16.existsSync(targetDir)) {
|
|
93590
|
+
fs16.mkdirSync(targetDir, { recursive: true });
|
|
92325
93591
|
}
|
|
92326
|
-
|
|
93592
|
+
fs16.renameSync(temppath, fullTargetPath);
|
|
92327
93593
|
return fullTargetPath;
|
|
92328
93594
|
}
|
|
92329
93595
|
}
|
|
@@ -92378,8 +93644,8 @@ var uploadResources = async (req, res) => {
|
|
|
92378
93644
|
});
|
|
92379
93645
|
busboy.on("file", (fieldname, fileStream, info) => {
|
|
92380
93646
|
const { filename, encoding, mimeType } = info;
|
|
92381
|
-
const tempPath =
|
|
92382
|
-
const writeStream =
|
|
93647
|
+
const tempPath = path15.join(cacheFilePath, `${Date.now()}-${Math.random().toString(36).substring(7)}`);
|
|
93648
|
+
const writeStream = fs17.createWriteStream(tempPath);
|
|
92383
93649
|
const filePromise = new Promise((resolve, reject) => {
|
|
92384
93650
|
fileStream.on("data", (chunk) => {
|
|
92385
93651
|
bytesReceived += chunk.length;
|
|
@@ -92418,8 +93684,8 @@ var uploadResources = async (req, res) => {
|
|
|
92418
93684
|
}
|
|
92419
93685
|
const clearFiles = () => {
|
|
92420
93686
|
files.forEach((file4) => {
|
|
92421
|
-
if (file4?.filepath &&
|
|
92422
|
-
|
|
93687
|
+
if (file4?.filepath && fs17.existsSync(file4.filepath)) {
|
|
93688
|
+
fs17.unlinkSync(file4.filepath);
|
|
92423
93689
|
}
|
|
92424
93690
|
});
|
|
92425
93691
|
};
|
|
@@ -92461,7 +93727,7 @@ var uploadResources = async (req, res) => {
|
|
|
92461
93727
|
targetPath: minioPath
|
|
92462
93728
|
});
|
|
92463
93729
|
if (type !== "file") {
|
|
92464
|
-
|
|
93730
|
+
fs17.unlinkSync(tempPath);
|
|
92465
93731
|
}
|
|
92466
93732
|
}
|
|
92467
93733
|
res.writeHead(200, { "Content-Type": "application/json" });
|