@kevisual/cli 0.1.5 → 0.1.7
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 +7107 -3606
- package/dist/assistant-server.js +4597 -1084
- package/dist/assistant.js +29826 -6954
- package/dist/envision.js +1268 -1133
- package/package.json +7 -8
package/dist/envision.js
CHANGED
|
@@ -10268,7 +10268,7 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
10268
10268
|
if (!(_concurrency >= 1)) {
|
|
10269
10269
|
throw new Error("fastqueue concurrency must be equal to or greater than 1");
|
|
10270
10270
|
}
|
|
10271
|
-
var
|
|
10271
|
+
var cache2 = reusify(Task);
|
|
10272
10272
|
var queueHead = null;
|
|
10273
10273
|
var queueTail = null;
|
|
10274
10274
|
var _running = 0;
|
|
@@ -10348,7 +10348,7 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
10348
10348
|
return _running === 0 && self2.length() === 0;
|
|
10349
10349
|
}
|
|
10350
10350
|
function push(value, done) {
|
|
10351
|
-
var current =
|
|
10351
|
+
var current = cache2.get();
|
|
10352
10352
|
current.context = context;
|
|
10353
10353
|
current.release = release;
|
|
10354
10354
|
current.value = value;
|
|
@@ -10369,7 +10369,7 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
10369
10369
|
}
|
|
10370
10370
|
}
|
|
10371
10371
|
function unshift(value, done) {
|
|
10372
|
-
var current =
|
|
10372
|
+
var current = cache2.get();
|
|
10373
10373
|
current.context = context;
|
|
10374
10374
|
current.release = release;
|
|
10375
10375
|
current.value = value;
|
|
@@ -10391,7 +10391,7 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
10391
10391
|
}
|
|
10392
10392
|
function release(holder) {
|
|
10393
10393
|
if (holder) {
|
|
10394
|
-
|
|
10394
|
+
cache2.release(holder);
|
|
10395
10395
|
}
|
|
10396
10396
|
var next = queueHead;
|
|
10397
10397
|
if (next && _running <= _concurrency) {
|
|
@@ -21754,7 +21754,8 @@ var {
|
|
|
21754
21754
|
// src/program.ts
|
|
21755
21755
|
import fs from "fs";
|
|
21756
21756
|
|
|
21757
|
-
// node_modules/.pnpm/@kevisual+context@0.0.
|
|
21757
|
+
// node_modules/.pnpm/@kevisual+context@0.0.8/node_modules/@kevisual/context/dist/app.js
|
|
21758
|
+
var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
21758
21759
|
function getDefaultExportFromCjs(x) {
|
|
21759
21760
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
21760
21761
|
}
|
|
@@ -22218,7 +22219,7 @@ var useEnv = (initEnv, initKey = "config", isOverwrite) => {
|
|
|
22218
22219
|
}
|
|
22219
22220
|
return gt[initKey];
|
|
22220
22221
|
};
|
|
22221
|
-
var useEnvKey = (key, init, initKey = "config") => {
|
|
22222
|
+
var useEnvKey = (key, init, initKey = "config", opts = {}) => {
|
|
22222
22223
|
const _env = useEnv({}, initKey);
|
|
22223
22224
|
if (key && typeof _env[key] !== "undefined") {
|
|
22224
22225
|
return _env[key];
|
|
@@ -22244,12 +22245,13 @@ var useEnvKey = (key, init, initKey = "config") => {
|
|
|
22244
22245
|
const voidFn = async () => {
|
|
22245
22246
|
return _env[key];
|
|
22246
22247
|
};
|
|
22248
|
+
const timeout = opts.timeout || 5 * 60 * 1000;
|
|
22247
22249
|
const checkFn = async () => {
|
|
22248
22250
|
const loadRes = await baseLoad.load(voidFn, {
|
|
22249
22251
|
key,
|
|
22250
22252
|
isReRun: true,
|
|
22251
22253
|
checkSuccess: () => _env[key],
|
|
22252
|
-
timeout
|
|
22254
|
+
timeout,
|
|
22253
22255
|
interval: 1000
|
|
22254
22256
|
});
|
|
22255
22257
|
if (loadRes.code !== 200) {
|
|
@@ -22265,27 +22267,28 @@ var useEnvKey = (key, init, initKey = "config") => {
|
|
|
22265
22267
|
};
|
|
22266
22268
|
var useEnvKeyNew = (key, initKey = "config", opts) => {
|
|
22267
22269
|
const _env = useEnv({}, initKey);
|
|
22270
|
+
const timeout = opts?.timeout;
|
|
22268
22271
|
if (key) {
|
|
22269
22272
|
delete _env[key];
|
|
22270
22273
|
}
|
|
22271
22274
|
if (opts?.getNew && opts.init) {
|
|
22272
|
-
return useEnvKey(key, opts.init, initKey);
|
|
22275
|
+
return useEnvKey(key, opts.init, initKey, { timeout });
|
|
22273
22276
|
} else if (opts?.getNew) {
|
|
22274
|
-
return useEnvKey(key, null, initKey);
|
|
22277
|
+
return useEnvKey(key, null, initKey, { timeout });
|
|
22275
22278
|
}
|
|
22276
22279
|
};
|
|
22277
|
-
var useContextKey = (key, init,
|
|
22278
|
-
if (isNew) {
|
|
22279
|
-
return useEnvKeyNew(key, "context", { getNew: true, init });
|
|
22280
|
+
var useContextKey = (key, init, opts) => {
|
|
22281
|
+
if (opts?.isNew) {
|
|
22282
|
+
return useEnvKeyNew(key, "context", { getNew: true, init, ...opts });
|
|
22280
22283
|
}
|
|
22281
|
-
return useEnvKey(key, init, "context");
|
|
22284
|
+
return useEnvKey(key, init, "context", opts);
|
|
22282
22285
|
};
|
|
22283
22286
|
var use = useContextKey;
|
|
22284
|
-
var useConfigKey = (key, init,
|
|
22285
|
-
if (isNew) {
|
|
22286
|
-
return useEnvKeyNew(key, "config", { getNew: true, init });
|
|
22287
|
+
var useConfigKey = (key, init, opts) => {
|
|
22288
|
+
if (opts?.isNew) {
|
|
22289
|
+
return useEnvKeyNew(key, "config", { getNew: true, init, ...opts });
|
|
22287
22290
|
}
|
|
22288
|
-
return useEnvKey(key, init, "config");
|
|
22291
|
+
return useEnvKey(key, init, "config", opts);
|
|
22289
22292
|
};
|
|
22290
22293
|
|
|
22291
22294
|
class InitEnv {
|
|
@@ -22309,8 +22312,8 @@ InitEnv.init();
|
|
|
22309
22312
|
var version = useContextKey("version", () => {
|
|
22310
22313
|
let version2 = "0.0.64";
|
|
22311
22314
|
try {
|
|
22312
|
-
if ("0.1.
|
|
22313
|
-
version2 = "0.1.
|
|
22315
|
+
if ("0.1.7")
|
|
22316
|
+
version2 = "0.1.7";
|
|
22314
22317
|
} catch (e) {}
|
|
22315
22318
|
return version2;
|
|
22316
22319
|
});
|
|
@@ -23427,14 +23430,14 @@ var getEnvToken = () => {
|
|
|
23427
23430
|
return envTokne;
|
|
23428
23431
|
};
|
|
23429
23432
|
|
|
23430
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23433
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
23431
23434
|
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
23432
23435
|
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
23433
23436
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
23434
23437
|
var isTabKey = (key) => key.name === "tab";
|
|
23435
23438
|
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
23436
23439
|
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
23437
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23440
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
23438
23441
|
class AbortPromptError extends Error {
|
|
23439
23442
|
name = "AbortPromptError";
|
|
23440
23443
|
message = "Prompt was aborted";
|
|
@@ -23460,10 +23463,10 @@ class HookError extends Error {
|
|
|
23460
23463
|
class ValidationError extends Error {
|
|
23461
23464
|
name = "ValidationError";
|
|
23462
23465
|
}
|
|
23463
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23466
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
23464
23467
|
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
23465
23468
|
|
|
23466
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23469
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
23467
23470
|
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
23468
23471
|
var hookStorage = new AsyncLocalStorage;
|
|
23469
23472
|
function createStore(rl) {
|
|
@@ -23568,7 +23571,7 @@ var effectScheduler = {
|
|
|
23568
23571
|
}
|
|
23569
23572
|
};
|
|
23570
23573
|
|
|
23571
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23574
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
23572
23575
|
function useState(defaultValue) {
|
|
23573
23576
|
return withPointer((pointer) => {
|
|
23574
23577
|
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
@@ -23586,7 +23589,7 @@ function useState(defaultValue) {
|
|
|
23586
23589
|
});
|
|
23587
23590
|
}
|
|
23588
23591
|
|
|
23589
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23592
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
23590
23593
|
function useEffect(cb, depArray) {
|
|
23591
23594
|
withPointer((pointer) => {
|
|
23592
23595
|
const oldDeps = pointer.get();
|
|
@@ -23598,7 +23601,7 @@ function useEffect(cb, depArray) {
|
|
|
23598
23601
|
});
|
|
23599
23602
|
}
|
|
23600
23603
|
|
|
23601
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23604
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
23602
23605
|
import { styleText } from "node:util";
|
|
23603
23606
|
|
|
23604
23607
|
// node_modules/.pnpm/@inquirer+figures@2.0.3/node_modules/@inquirer/figures/dist/index.js
|
|
@@ -23890,7 +23893,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
|
23890
23893
|
var dist_default = figures;
|
|
23891
23894
|
var replacements = Object.entries(specialMainSymbols);
|
|
23892
23895
|
|
|
23893
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23896
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
23894
23897
|
var defaultTheme = {
|
|
23895
23898
|
prefix: {
|
|
23896
23899
|
idle: styleText("blue", "?"),
|
|
@@ -23911,7 +23914,7 @@ var defaultTheme = {
|
|
|
23911
23914
|
}
|
|
23912
23915
|
};
|
|
23913
23916
|
|
|
23914
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23917
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
23915
23918
|
function isPlainObject(value) {
|
|
23916
23919
|
if (typeof value !== "object" || value === null)
|
|
23917
23920
|
return false;
|
|
@@ -23939,7 +23942,7 @@ function makeTheme(...themes) {
|
|
|
23939
23942
|
return deepMerge(...themesToMerge);
|
|
23940
23943
|
}
|
|
23941
23944
|
|
|
23942
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23945
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
23943
23946
|
function usePrefix({ status = "idle", theme }) {
|
|
23944
23947
|
const [showLoader, setShowLoader] = useState(false);
|
|
23945
23948
|
const [tick, setTick] = useState(0);
|
|
@@ -23969,7 +23972,7 @@ function usePrefix({ status = "idle", theme }) {
|
|
|
23969
23972
|
const iconName = status === "loading" ? "idle" : status;
|
|
23970
23973
|
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
23971
23974
|
}
|
|
23972
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23975
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
23973
23976
|
function useMemo(fn, dependencies) {
|
|
23974
23977
|
return withPointer((pointer) => {
|
|
23975
23978
|
const prev = pointer.get();
|
|
@@ -23981,11 +23984,11 @@ function useMemo(fn, dependencies) {
|
|
|
23981
23984
|
return prev.value;
|
|
23982
23985
|
});
|
|
23983
23986
|
}
|
|
23984
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23987
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
23985
23988
|
function useRef(val) {
|
|
23986
23989
|
return useState({ current: val })[0];
|
|
23987
23990
|
}
|
|
23988
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
23991
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
23989
23992
|
function useKeypress(userHandler) {
|
|
23990
23993
|
const signal = useRef(userHandler);
|
|
23991
23994
|
signal.current = userHandler;
|
|
@@ -24003,7 +24006,7 @@ function useKeypress(userHandler) {
|
|
|
24003
24006
|
};
|
|
24004
24007
|
}, []);
|
|
24005
24008
|
}
|
|
24006
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24009
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
24007
24010
|
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
24008
24011
|
|
|
24009
24012
|
// node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
@@ -24347,7 +24350,7 @@ function wrapAnsi(string, columns, options) {
|
|
|
24347
24350
|
`);
|
|
24348
24351
|
}
|
|
24349
24352
|
|
|
24350
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24353
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
24351
24354
|
function breakLines(content, width) {
|
|
24352
24355
|
return content.split(`
|
|
24353
24356
|
`).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
|
|
@@ -24358,7 +24361,7 @@ function readlineWidth() {
|
|
|
24358
24361
|
return import_cli_width.default({ defaultWidth: 80, output: readline().output });
|
|
24359
24362
|
}
|
|
24360
24363
|
|
|
24361
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24364
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
24362
24365
|
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
24363
24366
|
const state = useRef({
|
|
24364
24367
|
lastPointer: active,
|
|
@@ -24424,7 +24427,7 @@ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
|
24424
24427
|
return pageBuffer.filter((line) => typeof line === "string").join(`
|
|
24425
24428
|
`);
|
|
24426
24429
|
}
|
|
24427
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24430
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
24428
24431
|
var import_mute_stream = __toESM(require_lib(), 1);
|
|
24429
24432
|
import * as readline2 from "node:readline";
|
|
24430
24433
|
import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
@@ -24637,7 +24640,7 @@ var {
|
|
|
24637
24640
|
unload
|
|
24638
24641
|
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
24639
24642
|
|
|
24640
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24643
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
24641
24644
|
import { stripVTControlCharacters } from "node:util";
|
|
24642
24645
|
|
|
24643
24646
|
// node_modules/.pnpm/@inquirer+ansi@2.0.3/node_modules/@inquirer/ansi/dist/index.js
|
|
@@ -24656,7 +24659,7 @@ var cursorTo = (x, y) => {
|
|
|
24656
24659
|
var eraseLine = ESC2 + "2K";
|
|
24657
24660
|
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
24658
24661
|
|
|
24659
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24662
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
24660
24663
|
var height = (content) => content.split(`
|
|
24661
24664
|
`).length;
|
|
24662
24665
|
var lastLine = (content) => content.split(`
|
|
@@ -24721,7 +24724,7 @@ class ScreenManager {
|
|
|
24721
24724
|
}
|
|
24722
24725
|
}
|
|
24723
24726
|
|
|
24724
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24727
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
24725
24728
|
class PromisePolyfill extends Promise {
|
|
24726
24729
|
static withResolver() {
|
|
24727
24730
|
let resolve;
|
|
@@ -24734,7 +24737,7 @@ class PromisePolyfill extends Promise {
|
|
|
24734
24737
|
}
|
|
24735
24738
|
}
|
|
24736
24739
|
|
|
24737
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24740
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
24738
24741
|
function getCallSites() {
|
|
24739
24742
|
const _prepareStackTrace = Error.prepareStackTrace;
|
|
24740
24743
|
let result = [];
|
|
@@ -24820,7 +24823,7 @@ function createPrompt(view) {
|
|
|
24820
24823
|
};
|
|
24821
24824
|
return prompt;
|
|
24822
24825
|
}
|
|
24823
|
-
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.
|
|
24826
|
+
// node_modules/.pnpm/@inquirer+core@11.1.3_@types+node@25.3.0/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
24824
24827
|
import { styleText as styleText2 } from "node:util";
|
|
24825
24828
|
class Separator {
|
|
24826
24829
|
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
@@ -24834,7 +24837,7 @@ class Separator {
|
|
|
24834
24837
|
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
24835
24838
|
}
|
|
24836
24839
|
}
|
|
24837
|
-
// node_modules/.pnpm/@inquirer+confirm@6.0.6_@types+node@25.
|
|
24840
|
+
// node_modules/.pnpm/@inquirer+confirm@6.0.6_@types+node@25.3.0/node_modules/@inquirer/confirm/dist/index.js
|
|
24838
24841
|
function getBooleanValue(value, defaultValue) {
|
|
24839
24842
|
let answer = defaultValue !== false;
|
|
24840
24843
|
if (/^(y|yes)/i.test(value))
|
|
@@ -24879,7 +24882,7 @@ var dist_default4 = createPrompt((config, done) => {
|
|
|
24879
24882
|
const message = theme.style.message(config.message, status);
|
|
24880
24883
|
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
|
|
24881
24884
|
});
|
|
24882
|
-
// node_modules/.pnpm/@inquirer+input@5.0.6_@types+node@25.
|
|
24885
|
+
// node_modules/.pnpm/@inquirer+input@5.0.6_@types+node@25.3.0/node_modules/@inquirer/input/dist/index.js
|
|
24883
24886
|
var inputTheme = {
|
|
24884
24887
|
validationFailureMode: "keep"
|
|
24885
24888
|
};
|
|
@@ -24963,7 +24966,7 @@ var dist_default5 = createPrompt((config, done) => {
|
|
|
24963
24966
|
error
|
|
24964
24967
|
];
|
|
24965
24968
|
});
|
|
24966
|
-
// node_modules/.pnpm/@inquirer+select@5.0.6_@types+node@25.
|
|
24969
|
+
// node_modules/.pnpm/@inquirer+select@5.0.6_@types+node@25.3.0/node_modules/@inquirer/select/dist/index.js
|
|
24967
24970
|
import { styleText as styleText3 } from "node:util";
|
|
24968
24971
|
var selectTheme = {
|
|
24969
24972
|
icon: { cursor: dist_default.pointer },
|
|
@@ -25123,23 +25126,17 @@ var dist_default6 = createPrompt((config, done) => {
|
|
|
25123
25126
|
var import_md5 = __toESM(require_md5(), 1);
|
|
25124
25127
|
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
25125
25128
|
|
|
25126
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
25129
|
+
// node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query.js
|
|
25127
25130
|
var isTextForContentType = (contentType) => {
|
|
25128
25131
|
if (!contentType)
|
|
25129
25132
|
return false;
|
|
25130
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
25133
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
25131
25134
|
return textTypes.some((type) => contentType.includes(type));
|
|
25132
25135
|
};
|
|
25133
25136
|
var adapter = async (opts = {}, overloadOpts) => {
|
|
25134
25137
|
const controller = new AbortController;
|
|
25135
25138
|
const signal = controller.signal;
|
|
25136
25139
|
const isPostFile = opts.isPostFile || false;
|
|
25137
|
-
let responseType = opts.responseType || "json";
|
|
25138
|
-
if (opts.isBlob) {
|
|
25139
|
-
responseType = "blob";
|
|
25140
|
-
} else if (opts.isText) {
|
|
25141
|
-
responseType = "text";
|
|
25142
|
-
}
|
|
25143
25140
|
const timeout = opts.timeout || 60000 * 3;
|
|
25144
25141
|
const timer = setTimeout(() => {
|
|
25145
25142
|
controller.abort();
|
|
@@ -25198,21 +25195,31 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
25198
25195
|
headers
|
|
25199
25196
|
}).then(async (response) => {
|
|
25200
25197
|
const contentType = response.headers.get("Content-Type");
|
|
25201
|
-
if (responseType === "blob") {
|
|
25202
|
-
return await response.blob();
|
|
25203
|
-
}
|
|
25204
|
-
const isText = responseType === "text";
|
|
25205
25198
|
const isJson = contentType && contentType.includes("application/json");
|
|
25206
|
-
|
|
25207
|
-
|
|
25199
|
+
const isSuccess = response.ok;
|
|
25200
|
+
if (isJson) {
|
|
25201
|
+
const json = await response.json();
|
|
25202
|
+
if (json?.code) {
|
|
25203
|
+
return json;
|
|
25204
|
+
}
|
|
25205
|
+
return {
|
|
25206
|
+
code: isSuccess ? 200 : response.status,
|
|
25207
|
+
status: response.status,
|
|
25208
|
+
data: json
|
|
25209
|
+
};
|
|
25208
25210
|
} else if (isTextForContentType(contentType)) {
|
|
25209
25211
|
return {
|
|
25210
|
-
code: response.status,
|
|
25212
|
+
code: isSuccess ? 200 : response.status,
|
|
25211
25213
|
status: response.status,
|
|
25212
25214
|
data: await response.text()
|
|
25213
25215
|
};
|
|
25214
25216
|
} else {
|
|
25215
|
-
return
|
|
25217
|
+
return {
|
|
25218
|
+
code: isSuccess ? 200 : response.status,
|
|
25219
|
+
status: response.status,
|
|
25220
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
25221
|
+
response
|
|
25222
|
+
};
|
|
25216
25223
|
}
|
|
25217
25224
|
}).catch((err) => {
|
|
25218
25225
|
if (err.name === "AbortError") {
|
|
@@ -25229,28 +25236,17 @@ var adapter = async (opts = {}, overloadOpts) => {
|
|
|
25229
25236
|
clearTimeout(timer);
|
|
25230
25237
|
});
|
|
25231
25238
|
};
|
|
25232
|
-
var setBaseResponse = (res) => {
|
|
25233
|
-
res.success = res.code === 200;
|
|
25234
|
-
res.showError = (fn) => {
|
|
25235
|
-
if (!res.success && !res.noMsg) {
|
|
25236
|
-
fn?.();
|
|
25237
|
-
}
|
|
25238
|
-
};
|
|
25239
|
-
return res;
|
|
25240
|
-
};
|
|
25241
25239
|
var wrapperError = ({ code, message }) => {
|
|
25242
25240
|
const result = {
|
|
25243
25241
|
code: code || 500,
|
|
25244
|
-
|
|
25245
|
-
message: message || "api request error",
|
|
25246
|
-
showError: (fn) => {},
|
|
25247
|
-
noMsg: true
|
|
25242
|
+
message: message || "请求错误"
|
|
25248
25243
|
};
|
|
25249
25244
|
return result;
|
|
25250
25245
|
};
|
|
25251
25246
|
|
|
25252
25247
|
class Query {
|
|
25253
25248
|
adapter;
|
|
25249
|
+
baseURL;
|
|
25254
25250
|
url;
|
|
25255
25251
|
beforeRequest;
|
|
25256
25252
|
afterResponse;
|
|
@@ -25258,11 +25254,20 @@ class Query {
|
|
|
25258
25254
|
timeout;
|
|
25259
25255
|
stop;
|
|
25260
25256
|
qws;
|
|
25261
|
-
|
|
25257
|
+
tokenName;
|
|
25258
|
+
storage;
|
|
25259
|
+
token;
|
|
25262
25260
|
constructor(opts) {
|
|
25263
25261
|
this.adapter = opts?.adapter || adapter;
|
|
25262
|
+
this.tokenName = opts?.tokenName || "token";
|
|
25263
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
25264
25264
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
25265
25265
|
this.url = opts?.url || defaultURL;
|
|
25266
|
+
if (this.url.startsWith("http")) {
|
|
25267
|
+
const urlObj = new URL(this.url);
|
|
25268
|
+
this.baseURL = urlObj.origin;
|
|
25269
|
+
}
|
|
25270
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
25266
25271
|
this.headers = opts?.headers || {
|
|
25267
25272
|
"Content-Type": "application/json"
|
|
25268
25273
|
};
|
|
@@ -25271,7 +25276,7 @@ class Query {
|
|
|
25271
25276
|
this.beforeRequest = opts.beforeRequest;
|
|
25272
25277
|
} else {
|
|
25273
25278
|
this.beforeRequest = async (opts2) => {
|
|
25274
|
-
const token =
|
|
25279
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
25275
25280
|
if (token) {
|
|
25276
25281
|
opts2.headers = {
|
|
25277
25282
|
...opts2.headers,
|
|
@@ -25293,7 +25298,6 @@ class Query {
|
|
|
25293
25298
|
}
|
|
25294
25299
|
async post(body, options) {
|
|
25295
25300
|
const url = options?.url || this.url;
|
|
25296
|
-
console.log("query post", url, body, options);
|
|
25297
25301
|
const { headers, adapter: adapter2, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
25298
25302
|
const _headers = { ...this.headers, ...headers };
|
|
25299
25303
|
const _adapter = adapter2 || this.adapter;
|
|
@@ -25307,13 +25311,20 @@ class Query {
|
|
|
25307
25311
|
timeout: _timeout,
|
|
25308
25312
|
...rest
|
|
25309
25313
|
};
|
|
25314
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
25315
|
+
if (!isStartsWithHttp) {
|
|
25316
|
+
if (this.baseURL) {
|
|
25317
|
+
const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
25318
|
+
req.url = baseURL + req.url;
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25310
25321
|
try {
|
|
25311
25322
|
if (_beforeRequest) {
|
|
25312
25323
|
const res = await _beforeRequest(req);
|
|
25313
25324
|
if (res === false) {
|
|
25314
25325
|
return wrapperError({
|
|
25315
25326
|
code: 500,
|
|
25316
|
-
message: "
|
|
25327
|
+
message: "请求取消",
|
|
25317
25328
|
req
|
|
25318
25329
|
});
|
|
25319
25330
|
}
|
|
@@ -25322,13 +25333,13 @@ class Query {
|
|
|
25322
25333
|
console.error("request beforeFn error", e, req);
|
|
25323
25334
|
return wrapperError({
|
|
25324
25335
|
code: 500,
|
|
25325
|
-
message: "
|
|
25336
|
+
message: "请求在请求前处理时发生错误",
|
|
25326
25337
|
req
|
|
25327
25338
|
});
|
|
25328
25339
|
}
|
|
25329
25340
|
if (this.stop && !options?.noStop) {
|
|
25330
25341
|
const that = this;
|
|
25331
|
-
await new Promise((resolve) => {
|
|
25342
|
+
const res = await new Promise((resolve) => {
|
|
25332
25343
|
let timer = 0;
|
|
25333
25344
|
const detect = setInterval(() => {
|
|
25334
25345
|
if (!that.stop) {
|
|
@@ -25336,11 +25347,20 @@ class Query {
|
|
|
25336
25347
|
resolve(true);
|
|
25337
25348
|
}
|
|
25338
25349
|
timer++;
|
|
25339
|
-
if (timer >
|
|
25340
|
-
console.error("
|
|
25350
|
+
if (timer > 5) {
|
|
25351
|
+
console.error("等待请求失败:", req.url, timer);
|
|
25352
|
+
clearInterval(detect);
|
|
25353
|
+
resolve(false);
|
|
25341
25354
|
}
|
|
25342
25355
|
}, 1000);
|
|
25343
25356
|
});
|
|
25357
|
+
if (!res) {
|
|
25358
|
+
return wrapperError({
|
|
25359
|
+
code: 500,
|
|
25360
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
25361
|
+
req
|
|
25362
|
+
});
|
|
25363
|
+
}
|
|
25344
25364
|
}
|
|
25345
25365
|
return _adapter(req).then(async (res) => {
|
|
25346
25366
|
try {
|
|
@@ -25353,10 +25373,10 @@ class Query {
|
|
|
25353
25373
|
}
|
|
25354
25374
|
return res;
|
|
25355
25375
|
} catch (e) {
|
|
25356
|
-
console.error("
|
|
25376
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
25357
25377
|
return wrapperError({
|
|
25358
25378
|
code: 500,
|
|
25359
|
-
message: "
|
|
25379
|
+
message: "请求在响应后处理时发生错误",
|
|
25360
25380
|
req
|
|
25361
25381
|
});
|
|
25362
25382
|
}
|
|
@@ -25394,23 +25414,17 @@ class Query {
|
|
|
25394
25414
|
}
|
|
25395
25415
|
}
|
|
25396
25416
|
|
|
25397
|
-
// node_modules/.pnpm/@kevisual+query@0.0.
|
|
25417
|
+
// node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query-browser.js
|
|
25398
25418
|
var isTextForContentType2 = (contentType) => {
|
|
25399
25419
|
if (!contentType)
|
|
25400
25420
|
return false;
|
|
25401
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
25421
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
25402
25422
|
return textTypes.some((type) => contentType.includes(type));
|
|
25403
25423
|
};
|
|
25404
25424
|
var adapter2 = async (opts = {}, overloadOpts) => {
|
|
25405
25425
|
const controller = new AbortController;
|
|
25406
25426
|
const signal = controller.signal;
|
|
25407
25427
|
const isPostFile = opts.isPostFile || false;
|
|
25408
|
-
let responseType = opts.responseType || "json";
|
|
25409
|
-
if (opts.isBlob) {
|
|
25410
|
-
responseType = "blob";
|
|
25411
|
-
} else if (opts.isText) {
|
|
25412
|
-
responseType = "text";
|
|
25413
|
-
}
|
|
25414
25428
|
const timeout = opts.timeout || 60000 * 3;
|
|
25415
25429
|
const timer = setTimeout(() => {
|
|
25416
25430
|
controller.abort();
|
|
@@ -25469,21 +25483,31 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
25469
25483
|
headers
|
|
25470
25484
|
}).then(async (response) => {
|
|
25471
25485
|
const contentType = response.headers.get("Content-Type");
|
|
25472
|
-
if (responseType === "blob") {
|
|
25473
|
-
return await response.blob();
|
|
25474
|
-
}
|
|
25475
|
-
const isText = responseType === "text";
|
|
25476
25486
|
const isJson = contentType && contentType.includes("application/json");
|
|
25477
|
-
|
|
25478
|
-
|
|
25487
|
+
const isSuccess = response.ok;
|
|
25488
|
+
if (isJson) {
|
|
25489
|
+
const json = await response.json();
|
|
25490
|
+
if (json?.code) {
|
|
25491
|
+
return json;
|
|
25492
|
+
}
|
|
25493
|
+
return {
|
|
25494
|
+
code: isSuccess ? 200 : response.status,
|
|
25495
|
+
status: response.status,
|
|
25496
|
+
data: json
|
|
25497
|
+
};
|
|
25479
25498
|
} else if (isTextForContentType2(contentType)) {
|
|
25480
25499
|
return {
|
|
25481
|
-
code: response.status,
|
|
25500
|
+
code: isSuccess ? 200 : response.status,
|
|
25482
25501
|
status: response.status,
|
|
25483
25502
|
data: await response.text()
|
|
25484
25503
|
};
|
|
25485
25504
|
} else {
|
|
25486
|
-
return
|
|
25505
|
+
return {
|
|
25506
|
+
code: isSuccess ? 200 : response.status,
|
|
25507
|
+
status: response.status,
|
|
25508
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
25509
|
+
response
|
|
25510
|
+
};
|
|
25487
25511
|
}
|
|
25488
25512
|
}).catch((err) => {
|
|
25489
25513
|
if (err.name === "AbortError") {
|
|
@@ -25503,16 +25527,14 @@ var adapter2 = async (opts = {}, overloadOpts) => {
|
|
|
25503
25527
|
var wrapperError2 = ({ code, message }) => {
|
|
25504
25528
|
const result = {
|
|
25505
25529
|
code: code || 500,
|
|
25506
|
-
|
|
25507
|
-
message: message || "api request error",
|
|
25508
|
-
showError: (fn) => {},
|
|
25509
|
-
noMsg: true
|
|
25530
|
+
message: message || "请求错误"
|
|
25510
25531
|
};
|
|
25511
25532
|
return result;
|
|
25512
25533
|
};
|
|
25513
25534
|
|
|
25514
25535
|
class Query2 {
|
|
25515
25536
|
adapter;
|
|
25537
|
+
baseURL;
|
|
25516
25538
|
url;
|
|
25517
25539
|
beforeRequest;
|
|
25518
25540
|
afterResponse;
|
|
@@ -25520,11 +25542,20 @@ class Query2 {
|
|
|
25520
25542
|
timeout;
|
|
25521
25543
|
stop;
|
|
25522
25544
|
qws;
|
|
25523
|
-
|
|
25545
|
+
tokenName;
|
|
25546
|
+
storage;
|
|
25547
|
+
token;
|
|
25524
25548
|
constructor(opts) {
|
|
25525
25549
|
this.adapter = opts?.adapter || adapter2;
|
|
25550
|
+
this.tokenName = opts?.tokenName || "token";
|
|
25551
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
25526
25552
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
25527
25553
|
this.url = opts?.url || defaultURL;
|
|
25554
|
+
if (this.url.startsWith("http")) {
|
|
25555
|
+
const urlObj = new URL(this.url);
|
|
25556
|
+
this.baseURL = urlObj.origin;
|
|
25557
|
+
}
|
|
25558
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
25528
25559
|
this.headers = opts?.headers || {
|
|
25529
25560
|
"Content-Type": "application/json"
|
|
25530
25561
|
};
|
|
@@ -25533,7 +25564,7 @@ class Query2 {
|
|
|
25533
25564
|
this.beforeRequest = opts.beforeRequest;
|
|
25534
25565
|
} else {
|
|
25535
25566
|
this.beforeRequest = async (opts2) => {
|
|
25536
|
-
const token =
|
|
25567
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
25537
25568
|
if (token) {
|
|
25538
25569
|
opts2.headers = {
|
|
25539
25570
|
...opts2.headers,
|
|
@@ -25555,7 +25586,6 @@ class Query2 {
|
|
|
25555
25586
|
}
|
|
25556
25587
|
async post(body, options) {
|
|
25557
25588
|
const url = options?.url || this.url;
|
|
25558
|
-
console.log("query post", url, body, options);
|
|
25559
25589
|
const { headers, adapter: adapter22, beforeRequest, afterResponse, timeout, ...rest } = options || {};
|
|
25560
25590
|
const _headers = { ...this.headers, ...headers };
|
|
25561
25591
|
const _adapter = adapter22 || this.adapter;
|
|
@@ -25569,13 +25599,20 @@ class Query2 {
|
|
|
25569
25599
|
timeout: _timeout,
|
|
25570
25600
|
...rest
|
|
25571
25601
|
};
|
|
25602
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
25603
|
+
if (!isStartsWithHttp) {
|
|
25604
|
+
if (this.baseURL) {
|
|
25605
|
+
const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
25606
|
+
req.url = baseURL + req.url;
|
|
25607
|
+
}
|
|
25608
|
+
}
|
|
25572
25609
|
try {
|
|
25573
25610
|
if (_beforeRequest) {
|
|
25574
25611
|
const res = await _beforeRequest(req);
|
|
25575
25612
|
if (res === false) {
|
|
25576
25613
|
return wrapperError2({
|
|
25577
25614
|
code: 500,
|
|
25578
|
-
message: "
|
|
25615
|
+
message: "请求取消",
|
|
25579
25616
|
req
|
|
25580
25617
|
});
|
|
25581
25618
|
}
|
|
@@ -25584,13 +25621,13 @@ class Query2 {
|
|
|
25584
25621
|
console.error("request beforeFn error", e, req);
|
|
25585
25622
|
return wrapperError2({
|
|
25586
25623
|
code: 500,
|
|
25587
|
-
message: "
|
|
25624
|
+
message: "请求在请求前处理时发生错误",
|
|
25588
25625
|
req
|
|
25589
25626
|
});
|
|
25590
25627
|
}
|
|
25591
25628
|
if (this.stop && !options?.noStop) {
|
|
25592
25629
|
const that = this;
|
|
25593
|
-
await new Promise((resolve) => {
|
|
25630
|
+
const res = await new Promise((resolve) => {
|
|
25594
25631
|
let timer = 0;
|
|
25595
25632
|
const detect = setInterval(() => {
|
|
25596
25633
|
if (!that.stop) {
|
|
@@ -25598,11 +25635,20 @@ class Query2 {
|
|
|
25598
25635
|
resolve(true);
|
|
25599
25636
|
}
|
|
25600
25637
|
timer++;
|
|
25601
|
-
if (timer >
|
|
25602
|
-
console.error("
|
|
25638
|
+
if (timer > 5) {
|
|
25639
|
+
console.error("等待请求失败:", req.url, timer);
|
|
25640
|
+
clearInterval(detect);
|
|
25641
|
+
resolve(false);
|
|
25603
25642
|
}
|
|
25604
25643
|
}, 1000);
|
|
25605
25644
|
});
|
|
25645
|
+
if (!res) {
|
|
25646
|
+
return wrapperError2({
|
|
25647
|
+
code: 500,
|
|
25648
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
25649
|
+
req
|
|
25650
|
+
});
|
|
25651
|
+
}
|
|
25606
25652
|
}
|
|
25607
25653
|
return _adapter(req).then(async (res) => {
|
|
25608
25654
|
try {
|
|
@@ -25615,10 +25661,10 @@ class Query2 {
|
|
|
25615
25661
|
}
|
|
25616
25662
|
return res;
|
|
25617
25663
|
} catch (e) {
|
|
25618
|
-
console.error("
|
|
25664
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
25619
25665
|
return wrapperError2({
|
|
25620
25666
|
code: 500,
|
|
25621
|
-
message: "
|
|
25667
|
+
message: "请求在响应后处理时发生错误",
|
|
25622
25668
|
req
|
|
25623
25669
|
});
|
|
25624
25670
|
}
|
|
@@ -25681,13 +25727,8 @@ class BaseQuery {
|
|
|
25681
25727
|
}
|
|
25682
25728
|
}
|
|
25683
25729
|
|
|
25684
|
-
// node_modules/.pnpm/@kevisual+
|
|
25685
|
-
|
|
25686
|
-
import { join, dirname } from "path";
|
|
25687
|
-
import fs4 from "fs";
|
|
25688
|
-
import { readFileSync, writeFileSync, accessSync } from "fs";
|
|
25689
|
-
import { readFile, writeFile, unlink, mkdir } from "fs/promises";
|
|
25690
|
-
var LoginCacheStore = class {
|
|
25730
|
+
// node_modules/.pnpm/@kevisual+api@0.0.55_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-cache.ts
|
|
25731
|
+
class LoginCacheStore {
|
|
25691
25732
|
cache;
|
|
25692
25733
|
name;
|
|
25693
25734
|
cacheData;
|
|
@@ -25745,6 +25786,8 @@ var LoginCacheStore = class {
|
|
|
25745
25786
|
this.cacheData.id = user.id;
|
|
25746
25787
|
this.cacheData.accessToken = user.accessToken;
|
|
25747
25788
|
this.cacheData.refreshToken = user.refreshToken;
|
|
25789
|
+
this.cacheData.accessTokenExpiresIn = user.accessTokenExpiresIn;
|
|
25790
|
+
this.cacheData.createdAt = user.createdAt;
|
|
25748
25791
|
await this.setValue(this.cacheData);
|
|
25749
25792
|
}
|
|
25750
25793
|
getCurrentUser() {
|
|
@@ -25782,466 +25825,1008 @@ var LoginCacheStore = class {
|
|
|
25782
25825
|
this.cacheData.refreshToken = undefined;
|
|
25783
25826
|
await this.setValue(this.cacheData);
|
|
25784
25827
|
}
|
|
25785
|
-
}
|
|
25786
|
-
|
|
25787
|
-
|
|
25788
|
-
|
|
25789
|
-
|
|
25790
|
-
|
|
25791
|
-
|
|
25792
|
-
|
|
25793
|
-
|
|
25794
|
-
|
|
25795
|
-
|
|
25796
|
-
|
|
25797
|
-
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
|
|
25801
|
-
|
|
25802
|
-
|
|
25803
|
-
|
|
25804
|
-
}
|
|
25805
|
-
async init() {
|
|
25806
|
-
await this.cacheStore.init();
|
|
25807
|
-
this.load = true;
|
|
25808
|
-
this.onLoad?.();
|
|
25809
|
-
}
|
|
25810
|
-
async post(data, opts) {
|
|
25811
|
-
try {
|
|
25812
|
-
return this.query.post({ path: "user", ...data }, opts);
|
|
25813
|
-
} catch (error) {
|
|
25814
|
-
console.log("error", error);
|
|
25815
|
-
return {
|
|
25816
|
-
code: 400
|
|
25817
|
-
};
|
|
25818
|
-
}
|
|
25819
|
-
}
|
|
25820
|
-
async login(data) {
|
|
25821
|
-
const res = await this.post({ key: "login", ...data });
|
|
25822
|
-
if (res.code === 200) {
|
|
25823
|
-
const { accessToken, refreshToken } = res?.data || {};
|
|
25824
|
-
this.storage.setItem("token", accessToken || "");
|
|
25825
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken });
|
|
25826
|
-
}
|
|
25827
|
-
return res;
|
|
25828
|
-
}
|
|
25829
|
-
async loginByCode(data) {
|
|
25830
|
-
const res = await this.post({ path: "sms", key: "login", data });
|
|
25831
|
-
if (res.code === 200) {
|
|
25832
|
-
const { accessToken, refreshToken } = res?.data || {};
|
|
25833
|
-
this.storage.setItem("token", accessToken || "");
|
|
25834
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken });
|
|
25828
|
+
}
|
|
25829
|
+
|
|
25830
|
+
// node_modules/.pnpm/@kevisual+load@0.0.6/node_modules/@kevisual/load/dist/load.js
|
|
25831
|
+
function getDefaultExportFromCjs3(x) {
|
|
25832
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
25833
|
+
}
|
|
25834
|
+
var eventemitter33 = { exports: {} };
|
|
25835
|
+
var hasRequiredEventemitter33;
|
|
25836
|
+
function requireEventemitter33() {
|
|
25837
|
+
if (hasRequiredEventemitter33)
|
|
25838
|
+
return eventemitter33.exports;
|
|
25839
|
+
hasRequiredEventemitter33 = 1;
|
|
25840
|
+
(function(module) {
|
|
25841
|
+
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
25842
|
+
function Events() {}
|
|
25843
|
+
if (Object.create) {
|
|
25844
|
+
Events.prototype = Object.create(null);
|
|
25845
|
+
if (!new Events().__proto__)
|
|
25846
|
+
prefix = false;
|
|
25835
25847
|
}
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
this.storage.setItem("token", accessToken || "");
|
|
25841
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken });
|
|
25842
|
-
}
|
|
25843
|
-
async loginByWechat(data) {
|
|
25844
|
-
const res = await this.post({ path: "wx", key: "open-login", code: data.code });
|
|
25845
|
-
if (res.code === 200) {
|
|
25846
|
-
const { accessToken, refreshToken } = res?.data || {};
|
|
25847
|
-
this.storage.setItem("token", accessToken || "");
|
|
25848
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken });
|
|
25848
|
+
function EE(fn, context, once) {
|
|
25849
|
+
this.fn = fn;
|
|
25850
|
+
this.context = context;
|
|
25851
|
+
this.once = once || false;
|
|
25849
25852
|
}
|
|
25850
|
-
|
|
25851
|
-
|
|
25852
|
-
|
|
25853
|
-
const url = new URL(window.location.href);
|
|
25854
|
-
const code = url.searchParams.get("code");
|
|
25855
|
-
const state = url.searchParams.get("state");
|
|
25856
|
-
if (code && state) {
|
|
25857
|
-
const res = await this.loginByWechat({ code });
|
|
25858
|
-
if (res.code === 200) {
|
|
25859
|
-
onSuccess?.(res.data);
|
|
25860
|
-
} else {
|
|
25861
|
-
onError?.(res);
|
|
25853
|
+
function addListener(emitter, event, fn, context, once) {
|
|
25854
|
+
if (typeof fn !== "function") {
|
|
25855
|
+
throw new TypeError("The listener must be a function");
|
|
25862
25856
|
}
|
|
25857
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
25858
|
+
if (!emitter._events[evt])
|
|
25859
|
+
emitter._events[evt] = listener, emitter._eventsCount++;
|
|
25860
|
+
else if (!emitter._events[evt].fn)
|
|
25861
|
+
emitter._events[evt].push(listener);
|
|
25862
|
+
else
|
|
25863
|
+
emitter._events[evt] = [emitter._events[evt], listener];
|
|
25864
|
+
return emitter;
|
|
25863
25865
|
}
|
|
25864
|
-
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
|
|
25868
|
-
|
|
25869
|
-
const user = resUser.data;
|
|
25870
|
-
if (user) {
|
|
25871
|
-
this.cacheStore.setLoginUser({
|
|
25872
|
-
user,
|
|
25873
|
-
id: user.id,
|
|
25874
|
-
accessToken,
|
|
25875
|
-
refreshToken
|
|
25876
|
-
});
|
|
25877
|
-
} else {
|
|
25878
|
-
console.error("登录失败");
|
|
25879
|
-
}
|
|
25880
|
-
}
|
|
25866
|
+
function clearEvent(emitter, evt) {
|
|
25867
|
+
if (--emitter._eventsCount === 0)
|
|
25868
|
+
emitter._events = new Events;
|
|
25869
|
+
else
|
|
25870
|
+
delete emitter._events[evt];
|
|
25881
25871
|
}
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
let data = { refreshToken: _refreshToken };
|
|
25886
|
-
if (!_refreshToken) {
|
|
25887
|
-
await this.cacheStore.clearCurrentUser();
|
|
25888
|
-
return {
|
|
25889
|
-
code: 401,
|
|
25890
|
-
message: "请先登录",
|
|
25891
|
-
data: {}
|
|
25892
|
-
};
|
|
25872
|
+
function EventEmitter3() {
|
|
25873
|
+
this._events = new Events;
|
|
25874
|
+
this._eventsCount = 0;
|
|
25893
25875
|
}
|
|
25894
|
-
|
|
25895
|
-
|
|
25896
|
-
|
|
25897
|
-
return
|
|
25876
|
+
EventEmitter3.prototype.eventNames = function eventNames() {
|
|
25877
|
+
var names = [], events, name;
|
|
25878
|
+
if (this._eventsCount === 0)
|
|
25879
|
+
return names;
|
|
25880
|
+
for (name in events = this._events) {
|
|
25881
|
+
if (has.call(events, name))
|
|
25882
|
+
names.push(prefix ? name.slice(1) : name);
|
|
25898
25883
|
}
|
|
25899
|
-
|
|
25900
|
-
|
|
25901
|
-
|
|
25902
|
-
|
|
25903
|
-
|
|
25904
|
-
|
|
25905
|
-
|
|
25906
|
-
|
|
25907
|
-
|
|
25908
|
-
|
|
25909
|
-
|
|
25910
|
-
|
|
25911
|
-
|
|
25912
|
-
|
|
25913
|
-
|
|
25914
|
-
|
|
25915
|
-
|
|
25916
|
-
|
|
25917
|
-
|
|
25918
|
-
|
|
25919
|
-
|
|
25920
|
-
|
|
25921
|
-
|
|
25922
|
-
|
|
25923
|
-
|
|
25924
|
-
|
|
25925
|
-
|
|
25926
|
-
|
|
25884
|
+
if (Object.getOwnPropertySymbols) {
|
|
25885
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
25886
|
+
}
|
|
25887
|
+
return names;
|
|
25888
|
+
};
|
|
25889
|
+
EventEmitter3.prototype.listeners = function listeners(event) {
|
|
25890
|
+
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
25891
|
+
if (!handlers)
|
|
25892
|
+
return [];
|
|
25893
|
+
if (handlers.fn)
|
|
25894
|
+
return [handlers.fn];
|
|
25895
|
+
for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
|
|
25896
|
+
ee[i] = handlers[i].fn;
|
|
25897
|
+
}
|
|
25898
|
+
return ee;
|
|
25899
|
+
};
|
|
25900
|
+
EventEmitter3.prototype.listenerCount = function listenerCount(event) {
|
|
25901
|
+
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
25902
|
+
if (!listeners)
|
|
25903
|
+
return 0;
|
|
25904
|
+
if (listeners.fn)
|
|
25905
|
+
return 1;
|
|
25906
|
+
return listeners.length;
|
|
25907
|
+
};
|
|
25908
|
+
EventEmitter3.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
25909
|
+
var evt = prefix ? prefix + event : event;
|
|
25910
|
+
if (!this._events[evt])
|
|
25911
|
+
return false;
|
|
25912
|
+
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
25913
|
+
if (listeners.fn) {
|
|
25914
|
+
if (listeners.once)
|
|
25915
|
+
this.removeListener(event, listeners.fn, undefined, true);
|
|
25916
|
+
switch (len) {
|
|
25917
|
+
case 1:
|
|
25918
|
+
return listeners.fn.call(listeners.context), true;
|
|
25919
|
+
case 2:
|
|
25920
|
+
return listeners.fn.call(listeners.context, a1), true;
|
|
25921
|
+
case 3:
|
|
25922
|
+
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
25923
|
+
case 4:
|
|
25924
|
+
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
25925
|
+
case 5:
|
|
25926
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
25927
|
+
case 6:
|
|
25928
|
+
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
25927
25929
|
}
|
|
25928
|
-
|
|
25930
|
+
for (i = 1, args = new Array(len - 1);i < len; i++) {
|
|
25931
|
+
args[i - 1] = arguments[i];
|
|
25932
|
+
}
|
|
25933
|
+
listeners.fn.apply(listeners.context, args);
|
|
25934
|
+
} else {
|
|
25935
|
+
var length = listeners.length, j;
|
|
25936
|
+
for (i = 0;i < length; i++) {
|
|
25937
|
+
if (listeners[i].once)
|
|
25938
|
+
this.removeListener(event, listeners[i].fn, undefined, true);
|
|
25939
|
+
switch (len) {
|
|
25940
|
+
case 1:
|
|
25941
|
+
listeners[i].fn.call(listeners[i].context);
|
|
25942
|
+
break;
|
|
25943
|
+
case 2:
|
|
25944
|
+
listeners[i].fn.call(listeners[i].context, a1);
|
|
25945
|
+
break;
|
|
25946
|
+
case 3:
|
|
25947
|
+
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
25948
|
+
break;
|
|
25949
|
+
case 4:
|
|
25950
|
+
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
25951
|
+
break;
|
|
25952
|
+
default:
|
|
25953
|
+
if (!args)
|
|
25954
|
+
for (j = 1, args = new Array(len - 1);j < len; j++) {
|
|
25955
|
+
args[j - 1] = arguments[j];
|
|
25956
|
+
}
|
|
25957
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
25958
|
+
}
|
|
25959
|
+
}
|
|
25960
|
+
}
|
|
25961
|
+
return true;
|
|
25962
|
+
};
|
|
25963
|
+
EventEmitter3.prototype.on = function on(event, fn, context) {
|
|
25964
|
+
return addListener(this, event, fn, context, false);
|
|
25965
|
+
};
|
|
25966
|
+
EventEmitter3.prototype.once = function once(event, fn, context) {
|
|
25967
|
+
return addListener(this, event, fn, context, true);
|
|
25968
|
+
};
|
|
25969
|
+
EventEmitter3.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
25970
|
+
var evt = prefix ? prefix + event : event;
|
|
25971
|
+
if (!this._events[evt])
|
|
25972
|
+
return this;
|
|
25973
|
+
if (!fn) {
|
|
25974
|
+
clearEvent(this, evt);
|
|
25975
|
+
return this;
|
|
25976
|
+
}
|
|
25977
|
+
var listeners = this._events[evt];
|
|
25978
|
+
if (listeners.fn) {
|
|
25979
|
+
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
25980
|
+
clearEvent(this, evt);
|
|
25981
|
+
}
|
|
25982
|
+
} else {
|
|
25983
|
+
for (var i = 0, events = [], length = listeners.length;i < length; i++) {
|
|
25984
|
+
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
25985
|
+
events.push(listeners[i]);
|
|
25986
|
+
}
|
|
25987
|
+
}
|
|
25988
|
+
if (events.length)
|
|
25989
|
+
this._events[evt] = events.length === 1 ? events[0] : events;
|
|
25990
|
+
else
|
|
25991
|
+
clearEvent(this, evt);
|
|
25992
|
+
}
|
|
25993
|
+
return this;
|
|
25994
|
+
};
|
|
25995
|
+
EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
25996
|
+
var evt;
|
|
25997
|
+
if (event) {
|
|
25998
|
+
evt = prefix ? prefix + event : event;
|
|
25999
|
+
if (this._events[evt])
|
|
26000
|
+
clearEvent(this, evt);
|
|
26001
|
+
} else {
|
|
26002
|
+
this._events = new Events;
|
|
26003
|
+
this._eventsCount = 0;
|
|
25929
26004
|
}
|
|
26005
|
+
return this;
|
|
26006
|
+
};
|
|
26007
|
+
EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
|
|
26008
|
+
EventEmitter3.prototype.addListener = EventEmitter3.prototype.on;
|
|
26009
|
+
EventEmitter3.prefixed = prefix;
|
|
26010
|
+
EventEmitter3.EventEmitter = EventEmitter3;
|
|
26011
|
+
{
|
|
26012
|
+
module.exports = EventEmitter3;
|
|
25930
26013
|
}
|
|
25931
|
-
|
|
25932
|
-
|
|
25933
|
-
|
|
25934
|
-
|
|
25935
|
-
|
|
25936
|
-
|
|
25937
|
-
|
|
25938
|
-
|
|
26014
|
+
})(eventemitter33);
|
|
26015
|
+
return eventemitter33.exports;
|
|
26016
|
+
}
|
|
26017
|
+
var eventemitter3Exports3 = requireEventemitter33();
|
|
26018
|
+
var EventEmitter3 = /* @__PURE__ */ getDefaultExportFromCjs3(eventemitter3Exports3);
|
|
26019
|
+
var reRunFn3 = (promiseOpts) => {
|
|
26020
|
+
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
26021
|
+
const interval = promiseOpts.interval || 1000;
|
|
26022
|
+
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
26023
|
+
const signal = promiseOpts.signal;
|
|
26024
|
+
return new Promise(async (resolve, reject) => {
|
|
26025
|
+
let intervalId;
|
|
26026
|
+
let timeoutId = setTimeout(() => {
|
|
26027
|
+
clearTimeout(intervalId);
|
|
26028
|
+
resolve({
|
|
26029
|
+
code: 500,
|
|
26030
|
+
message: "timeout"
|
|
26031
|
+
});
|
|
26032
|
+
}, timeout);
|
|
26033
|
+
const fn = promiseOpts.fn || (() => true);
|
|
26034
|
+
const runFn = async () => {
|
|
26035
|
+
if (signal?.aborted) {
|
|
26036
|
+
clearInterval(intervalId);
|
|
26037
|
+
clearTimeout(timeoutId);
|
|
26038
|
+
return resolve({
|
|
26039
|
+
code: 499,
|
|
26040
|
+
message: "operation cancelled"
|
|
26041
|
+
});
|
|
25939
26042
|
}
|
|
25940
|
-
|
|
25941
|
-
|
|
25942
|
-
|
|
25943
|
-
|
|
25944
|
-
|
|
25945
|
-
|
|
26043
|
+
const res = await fn();
|
|
26044
|
+
if (!!checkSuccess(res)) {
|
|
26045
|
+
clearInterval(intervalId);
|
|
26046
|
+
clearTimeout(timeoutId);
|
|
26047
|
+
resolve({
|
|
26048
|
+
code: 200,
|
|
26049
|
+
data: res
|
|
26050
|
+
});
|
|
26051
|
+
} else {
|
|
26052
|
+
setTimeout(() => {
|
|
26053
|
+
runFn();
|
|
26054
|
+
}, interval);
|
|
25946
26055
|
}
|
|
25947
|
-
|
|
25948
|
-
|
|
25949
|
-
|
|
26056
|
+
};
|
|
26057
|
+
if (signal) {
|
|
26058
|
+
signal.addEventListener("abort", () => {
|
|
26059
|
+
clearInterval(intervalId);
|
|
26060
|
+
clearTimeout(timeoutId);
|
|
26061
|
+
resolve({
|
|
26062
|
+
code: 499,
|
|
26063
|
+
message: "operation cancelled"
|
|
26064
|
+
});
|
|
26065
|
+
});
|
|
25950
26066
|
}
|
|
26067
|
+
runFn();
|
|
26068
|
+
});
|
|
26069
|
+
};
|
|
26070
|
+
|
|
26071
|
+
class BaseLoad3 {
|
|
26072
|
+
modules = new Map;
|
|
26073
|
+
event;
|
|
26074
|
+
loading;
|
|
26075
|
+
static reRunFn = reRunFn3;
|
|
26076
|
+
timeout = 5 * 60 * 1000;
|
|
26077
|
+
constructor() {
|
|
26078
|
+
this.event = new EventEmitter3;
|
|
26079
|
+
this.loading = false;
|
|
25951
26080
|
}
|
|
25952
|
-
|
|
25953
|
-
const
|
|
25954
|
-
|
|
25955
|
-
|
|
25956
|
-
|
|
25957
|
-
|
|
25958
|
-
|
|
26081
|
+
listenKey(key, listenOpts) {
|
|
26082
|
+
const timeout = listenOpts?.timeout ?? this.timeout;
|
|
26083
|
+
return new Promise((resolve) => {
|
|
26084
|
+
const timeoutId = setTimeout(() => {
|
|
26085
|
+
this.event.removeListener(key, onEvent);
|
|
26086
|
+
resolve({
|
|
26087
|
+
code: 500,
|
|
26088
|
+
message: "timeout"
|
|
26089
|
+
});
|
|
26090
|
+
}, timeout);
|
|
26091
|
+
const onEvent = (error) => {
|
|
26092
|
+
clearTimeout(timeoutId);
|
|
26093
|
+
if (error) {
|
|
26094
|
+
return resolve({
|
|
26095
|
+
code: 500,
|
|
26096
|
+
message: error
|
|
26097
|
+
});
|
|
25959
26098
|
}
|
|
25960
|
-
|
|
25961
|
-
|
|
25962
|
-
|
|
25963
|
-
afterResponse: async (response, ctx) => {
|
|
25964
|
-
if (response?.code === 401 && check401 && !token) {
|
|
25965
|
-
return await that.afterCheck401ToRefreshToken(response, ctx);
|
|
26099
|
+
const data = this.modules.get(key);
|
|
26100
|
+
if (data?.loadSuccessClear) {
|
|
26101
|
+
this.remove(key);
|
|
25966
26102
|
}
|
|
25967
|
-
|
|
25968
|
-
|
|
26103
|
+
resolve({
|
|
26104
|
+
code: 200,
|
|
26105
|
+
data: data?.modules
|
|
26106
|
+
});
|
|
26107
|
+
};
|
|
26108
|
+
this.event.once(key, onEvent);
|
|
25969
26109
|
});
|
|
25970
26110
|
}
|
|
25971
|
-
async
|
|
25972
|
-
|
|
25973
|
-
|
|
25974
|
-
|
|
25975
|
-
|
|
25976
|
-
|
|
25977
|
-
|
|
25978
|
-
|
|
25979
|
-
|
|
25980
|
-
|
|
25981
|
-
|
|
25982
|
-
|
|
25983
|
-
|
|
25984
|
-
|
|
25985
|
-
|
|
25986
|
-
|
|
25987
|
-
|
|
25988
|
-
|
|
25989
|
-
|
|
25990
|
-
|
|
26111
|
+
async hasLoaded(key, hasLoadOpts) {
|
|
26112
|
+
if (!key) {
|
|
26113
|
+
return {
|
|
26114
|
+
code: 404,
|
|
26115
|
+
message: "key is required"
|
|
26116
|
+
};
|
|
26117
|
+
}
|
|
26118
|
+
const has = this.modules.has(key);
|
|
26119
|
+
if (!has) {
|
|
26120
|
+
const isExist = hasLoadOpts?.isExist ?? true;
|
|
26121
|
+
const timeout = hasLoadOpts?.timeout ?? this.timeout;
|
|
26122
|
+
if (isExist) {
|
|
26123
|
+
return await this.listenKey(key, { timeout });
|
|
26124
|
+
}
|
|
26125
|
+
return {
|
|
26126
|
+
code: 404
|
|
26127
|
+
};
|
|
26128
|
+
}
|
|
26129
|
+
const data = this.modules.get(key);
|
|
26130
|
+
if (data?.status === "loaded") {
|
|
25991
26131
|
return {
|
|
25992
26132
|
code: 200,
|
|
25993
|
-
data:
|
|
25994
|
-
accessToken: user.accessToken,
|
|
25995
|
-
refreshToken: user.refreshToken
|
|
25996
|
-
},
|
|
25997
|
-
success: true,
|
|
25998
|
-
message: "切换用户成功"
|
|
26133
|
+
data: data.modules
|
|
25999
26134
|
};
|
|
26000
26135
|
}
|
|
26001
|
-
|
|
26002
|
-
|
|
26003
|
-
const { accessToken, refreshToken } = res?.data || {};
|
|
26004
|
-
this.storage.setItem("token", accessToken || "");
|
|
26005
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken });
|
|
26136
|
+
if (data?.status === "loading") {
|
|
26137
|
+
return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
|
|
26006
26138
|
}
|
|
26007
|
-
|
|
26008
|
-
|
|
26009
|
-
|
|
26010
|
-
|
|
26011
|
-
|
|
26012
|
-
|
|
26013
|
-
|
|
26014
|
-
|
|
26015
|
-
|
|
26016
|
-
|
|
26139
|
+
if (data?.status === "error") {
|
|
26140
|
+
return {
|
|
26141
|
+
code: 500,
|
|
26142
|
+
message: "load error"
|
|
26143
|
+
};
|
|
26144
|
+
}
|
|
26145
|
+
if (data?.status === "cancel") {
|
|
26146
|
+
return {
|
|
26147
|
+
code: 499,
|
|
26148
|
+
message: "operation cancelled"
|
|
26149
|
+
};
|
|
26150
|
+
}
|
|
26151
|
+
return {
|
|
26152
|
+
code: 404
|
|
26153
|
+
};
|
|
26017
26154
|
}
|
|
26018
|
-
async
|
|
26019
|
-
const
|
|
26020
|
-
|
|
26021
|
-
|
|
26022
|
-
|
|
26023
|
-
|
|
26024
|
-
|
|
26025
|
-
|
|
26026
|
-
|
|
26027
|
-
|
|
26028
|
-
|
|
26029
|
-
|
|
26030
|
-
|
|
26155
|
+
async loadFn(loadContent, opts) {
|
|
26156
|
+
const key = opts.key;
|
|
26157
|
+
if (!key) {
|
|
26158
|
+
return {
|
|
26159
|
+
code: 404,
|
|
26160
|
+
message: "key is required"
|
|
26161
|
+
};
|
|
26162
|
+
}
|
|
26163
|
+
const newModule = {
|
|
26164
|
+
key: opts.key,
|
|
26165
|
+
status: "loading",
|
|
26166
|
+
loading: true,
|
|
26167
|
+
loadSuccessClear: opts.loadSuccessClear ?? true
|
|
26168
|
+
};
|
|
26169
|
+
let errorMessage = "";
|
|
26170
|
+
try {
|
|
26171
|
+
const isReRun = opts.isReRun ?? false;
|
|
26172
|
+
let res;
|
|
26173
|
+
if (!isReRun) {
|
|
26174
|
+
this.modules.set(key, newModule);
|
|
26175
|
+
res = await loadContent();
|
|
26176
|
+
} else {
|
|
26177
|
+
newModule.controller = new AbortController;
|
|
26178
|
+
const signal = newModule.controller.signal;
|
|
26179
|
+
this.modules.set(key, newModule);
|
|
26180
|
+
const data = await reRunFn3({
|
|
26181
|
+
timeout: opts.timeout,
|
|
26182
|
+
interval: opts.interval,
|
|
26183
|
+
checkSuccess: opts.checkSuccess,
|
|
26184
|
+
fn: loadContent,
|
|
26185
|
+
signal
|
|
26186
|
+
});
|
|
26187
|
+
newModule.controller = null;
|
|
26188
|
+
if (data.code === 499) {
|
|
26189
|
+
newModule.status = "cancel";
|
|
26190
|
+
return {
|
|
26191
|
+
code: 499,
|
|
26192
|
+
message: "operation cancelled"
|
|
26193
|
+
};
|
|
26031
26194
|
}
|
|
26032
|
-
|
|
26195
|
+
if (data.code !== 200) {
|
|
26196
|
+
throw new Error(data.message);
|
|
26197
|
+
}
|
|
26198
|
+
res = data.data;
|
|
26199
|
+
}
|
|
26200
|
+
newModule.modules = res;
|
|
26201
|
+
newModule.status = "loaded";
|
|
26202
|
+
return {
|
|
26203
|
+
code: 200,
|
|
26204
|
+
data: res
|
|
26205
|
+
};
|
|
26206
|
+
} catch (error) {
|
|
26207
|
+
errorMessage = error.message;
|
|
26208
|
+
newModule.status = "error";
|
|
26209
|
+
return {
|
|
26210
|
+
code: 500,
|
|
26211
|
+
message: error
|
|
26212
|
+
};
|
|
26213
|
+
} finally {
|
|
26214
|
+
newModule.loading = false;
|
|
26215
|
+
this.modules.set(opts.key, newModule);
|
|
26216
|
+
if (!errorMessage) {
|
|
26217
|
+
this.event.emit(opts.key);
|
|
26218
|
+
} else {
|
|
26219
|
+
this.event.emit(opts.key, errorMessage);
|
|
26033
26220
|
}
|
|
26034
|
-
});
|
|
26035
|
-
}
|
|
26036
|
-
async checkLoginStatus(token) {
|
|
26037
|
-
const res = await this.post({
|
|
26038
|
-
path: "user",
|
|
26039
|
-
key: "checkLoginStatus",
|
|
26040
|
-
loginToken: token
|
|
26041
|
-
});
|
|
26042
|
-
if (res.code === 200) {
|
|
26043
|
-
const accessToken = res.data?.accessToken;
|
|
26044
|
-
this.storage.setItem("token", accessToken || "");
|
|
26045
|
-
await this.beforeSetLoginUser({ accessToken, refreshToken: res.data?.refreshToken });
|
|
26046
|
-
return res;
|
|
26047
26221
|
}
|
|
26048
|
-
return false;
|
|
26049
|
-
}
|
|
26050
|
-
loginWithWeb(baseURL, { MD5, jsonwebtoken }) {
|
|
26051
|
-
const randomId = Math.random().toString(36).substring(2, 15);
|
|
26052
|
-
const timestamp = Date.now();
|
|
26053
|
-
const tokenSecret = "xiao" + randomId;
|
|
26054
|
-
const sign = MD5(`${tokenSecret}${timestamp}`).toString();
|
|
26055
|
-
const token = jsonwebtoken.sign({ randomId, timestamp, sign }, tokenSecret, {
|
|
26056
|
-
expiresIn: 60 * 10
|
|
26057
|
-
});
|
|
26058
|
-
const url = `${baseURL}/api/router?path=user&key=webLogin&p&loginToken=${token}&sign=${sign}&randomId=${randomId}`;
|
|
26059
|
-
return { url, token, tokenSecret };
|
|
26060
26222
|
}
|
|
26061
|
-
|
|
26062
|
-
|
|
26063
|
-
|
|
26064
|
-
|
|
26065
|
-
|
|
26066
|
-
|
|
26067
|
-
|
|
26068
|
-
|
|
26069
|
-
return true;
|
|
26070
|
-
} else if (createIfNotExists && isFile) {
|
|
26071
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
26072
|
-
return false;
|
|
26223
|
+
async load(loadContent, opts) {
|
|
26224
|
+
this.loading = true;
|
|
26225
|
+
const key = opts.key;
|
|
26226
|
+
if (!key) {
|
|
26227
|
+
return {
|
|
26228
|
+
code: 404,
|
|
26229
|
+
message: "key is required"
|
|
26230
|
+
};
|
|
26073
26231
|
}
|
|
26074
|
-
|
|
26075
|
-
|
|
26076
|
-
}
|
|
26077
|
-
|
|
26078
|
-
|
|
26079
|
-
|
|
26080
|
-
|
|
26081
|
-
|
|
26082
|
-
|
|
26083
|
-
return {};
|
|
26084
|
-
}
|
|
26085
|
-
};
|
|
26086
|
-
var writeConfigFile = (filePath, data) => {
|
|
26087
|
-
writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
26088
|
-
};
|
|
26089
|
-
var getHostName = () => {
|
|
26090
|
-
const configDir = join(homedir(), ".config", "envision");
|
|
26091
|
-
const configFile = join(configDir, "config.json");
|
|
26092
|
-
const config = readConfigFile(configFile);
|
|
26093
|
-
const baseURL = config.baseURL || "https://kevisual.cn";
|
|
26094
|
-
const hostname = new URL(baseURL).hostname;
|
|
26095
|
-
return hostname;
|
|
26096
|
-
};
|
|
26097
|
-
var StorageNode = class {
|
|
26098
|
-
cacheData;
|
|
26099
|
-
filePath;
|
|
26100
|
-
constructor() {
|
|
26101
|
-
this.cacheData = {};
|
|
26102
|
-
const configDir = join(homedir(), ".config", "envision");
|
|
26103
|
-
const hostname = getHostName();
|
|
26104
|
-
this.filePath = join(configDir, "config", `${hostname}-storage.json`);
|
|
26105
|
-
fileExists(this.filePath, { isFile: true });
|
|
26106
|
-
}
|
|
26107
|
-
async loadCache() {
|
|
26108
|
-
const filePath = this.filePath;
|
|
26109
|
-
try {
|
|
26110
|
-
const data = await readConfigFile(filePath);
|
|
26111
|
-
this.cacheData = data;
|
|
26112
|
-
} catch (error) {
|
|
26113
|
-
this.cacheData = {};
|
|
26114
|
-
await writeFile(filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26232
|
+
if (opts?.force) {
|
|
26233
|
+
this.remove(key);
|
|
26234
|
+
}
|
|
26235
|
+
const has = this.modules.has(key);
|
|
26236
|
+
if (has) {
|
|
26237
|
+
return await this.hasLoaded(key);
|
|
26238
|
+
}
|
|
26239
|
+
if (typeof loadContent === "function") {
|
|
26240
|
+
return this.loadFn(loadContent, opts);
|
|
26115
26241
|
}
|
|
26242
|
+
console.error("loadContent is not a function and not has loaded");
|
|
26116
26243
|
}
|
|
26117
|
-
|
|
26118
|
-
|
|
26244
|
+
remove(key) {
|
|
26245
|
+
const has = this.modules.has(key);
|
|
26246
|
+
if (has) {
|
|
26247
|
+
this.checkRemoveController(key);
|
|
26248
|
+
this.modules.delete(key);
|
|
26249
|
+
}
|
|
26119
26250
|
}
|
|
26120
|
-
|
|
26121
|
-
|
|
26251
|
+
emitLoaded(key) {
|
|
26252
|
+
this.checkRemoveController(key);
|
|
26253
|
+
this.event.emit(key);
|
|
26122
26254
|
}
|
|
26123
|
-
|
|
26124
|
-
|
|
26125
|
-
|
|
26255
|
+
setModule(key, data, loadData) {
|
|
26256
|
+
const newModule = {
|
|
26257
|
+
key,
|
|
26258
|
+
status: "loaded",
|
|
26259
|
+
loading: false,
|
|
26260
|
+
modules: data || {},
|
|
26261
|
+
...loadData
|
|
26262
|
+
};
|
|
26263
|
+
this.modules.set(key, newModule);
|
|
26264
|
+
this.emitLoaded(key);
|
|
26265
|
+
return newModule;
|
|
26126
26266
|
}
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
writeFile(this.filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26267
|
+
cancel(key) {
|
|
26268
|
+
this.checkRemoveController(key);
|
|
26130
26269
|
}
|
|
26131
|
-
|
|
26132
|
-
|
|
26133
|
-
|
|
26270
|
+
checkRemoveController(key) {
|
|
26271
|
+
const data = this.modules.get(key);
|
|
26272
|
+
if (data?.controller) {
|
|
26273
|
+
data.controller?.abort?.();
|
|
26274
|
+
delete data.controller;
|
|
26275
|
+
this.modules.set(key, data);
|
|
26276
|
+
}
|
|
26134
26277
|
}
|
|
26135
|
-
|
|
26136
|
-
|
|
26278
|
+
}
|
|
26279
|
+
|
|
26280
|
+
// node_modules/.pnpm/@kevisual+api@0.0.55_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login.ts
|
|
26281
|
+
class QueryLogin extends BaseQuery {
|
|
26282
|
+
cacheStore;
|
|
26283
|
+
isBrowser;
|
|
26284
|
+
load;
|
|
26285
|
+
storage;
|
|
26286
|
+
onLoad;
|
|
26287
|
+
constructor(opts) {
|
|
26288
|
+
super({
|
|
26289
|
+
query: opts?.query || new Query2
|
|
26290
|
+
});
|
|
26291
|
+
this.cacheStore = new LoginCacheStore({ name: "login", cache: opts?.cache });
|
|
26292
|
+
this.isBrowser = opts?.isBrowser ?? true;
|
|
26293
|
+
this.init();
|
|
26294
|
+
this.onLoad = opts?.onLoad;
|
|
26295
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
26296
|
+
if (!this.storage) {
|
|
26297
|
+
throw new Error("storage is required");
|
|
26298
|
+
}
|
|
26137
26299
|
}
|
|
26138
|
-
|
|
26139
|
-
|
|
26140
|
-
filepath;
|
|
26141
|
-
constructor(filepath) {
|
|
26142
|
-
this.filepath = filepath || join(homedir(), ".config", "envision", "config", `${getHostName()}-login.json`);
|
|
26143
|
-
fileExists(this.filepath, { isFile: true });
|
|
26300
|
+
setQuery(query) {
|
|
26301
|
+
this.query = query;
|
|
26144
26302
|
}
|
|
26145
|
-
async
|
|
26303
|
+
async init() {
|
|
26304
|
+
await this.cacheStore.init();
|
|
26305
|
+
this.load = true;
|
|
26306
|
+
this.onLoad?.();
|
|
26307
|
+
}
|
|
26308
|
+
async post(data, opts) {
|
|
26146
26309
|
try {
|
|
26147
|
-
|
|
26148
|
-
const data = readConfigFile(filePath);
|
|
26149
|
-
return data;
|
|
26310
|
+
return this.query.post({ path: "user", ...data }, opts);
|
|
26150
26311
|
} catch (error) {
|
|
26151
|
-
console.log("
|
|
26152
|
-
return {
|
|
26312
|
+
console.log("error", error);
|
|
26313
|
+
return {
|
|
26314
|
+
code: 400
|
|
26315
|
+
};
|
|
26153
26316
|
}
|
|
26154
26317
|
}
|
|
26155
|
-
async
|
|
26156
|
-
|
|
26157
|
-
|
|
26158
|
-
const
|
|
26159
|
-
|
|
26160
|
-
|
|
26161
|
-
console.log("set error", error);
|
|
26318
|
+
async login(data) {
|
|
26319
|
+
const res = await this.post({ key: "login", ...data });
|
|
26320
|
+
if (res.code === 200) {
|
|
26321
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
|
|
26322
|
+
this.storage.setItem("token", accessToken || "");
|
|
26323
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26162
26324
|
}
|
|
26325
|
+
return res;
|
|
26163
26326
|
}
|
|
26164
|
-
async
|
|
26165
|
-
await
|
|
26327
|
+
async loginByCode(data) {
|
|
26328
|
+
const res = await this.post({ path: "sms", key: "login", data });
|
|
26329
|
+
if (res.code === 200) {
|
|
26330
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
|
|
26331
|
+
this.storage.setItem("token", accessToken || "");
|
|
26332
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26333
|
+
}
|
|
26334
|
+
return res;
|
|
26166
26335
|
}
|
|
26167
|
-
async
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26171
|
-
|
|
26172
|
-
|
|
26173
|
-
|
|
26174
|
-
|
|
26175
|
-
|
|
26176
|
-
|
|
26336
|
+
async setLoginToken(token) {
|
|
26337
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = token;
|
|
26338
|
+
this.storage.setItem("token", accessToken || "");
|
|
26339
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26340
|
+
}
|
|
26341
|
+
async loginByWechat(data) {
|
|
26342
|
+
const res = await this.post({ path: "wx", key: "open-login", code: data.code });
|
|
26343
|
+
if (res.code === 200) {
|
|
26344
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
|
|
26345
|
+
this.storage.setItem("token", accessToken || "");
|
|
26346
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26177
26347
|
}
|
|
26348
|
+
return res;
|
|
26178
26349
|
}
|
|
26179
|
-
async
|
|
26180
|
-
|
|
26350
|
+
async checkWechat({ onSuccess, onError }) {
|
|
26351
|
+
const url = new URL(window.location.href);
|
|
26352
|
+
const code = url.searchParams.get("code");
|
|
26353
|
+
const state = url.searchParams.get("state");
|
|
26354
|
+
if (code && state) {
|
|
26355
|
+
const res = await this.loginByWechat({ code });
|
|
26356
|
+
if (res.code === 200) {
|
|
26357
|
+
onSuccess?.(res.data);
|
|
26358
|
+
} else {
|
|
26359
|
+
onError?.(res);
|
|
26360
|
+
}
|
|
26361
|
+
}
|
|
26181
26362
|
}
|
|
26182
|
-
}
|
|
26183
|
-
|
|
26184
|
-
await
|
|
26185
|
-
|
|
26186
|
-
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26363
|
+
async beforeSetLoginUser({ accessToken, refreshToken, check401, accessTokenExpiresIn }) {
|
|
26364
|
+
if (accessToken && refreshToken) {
|
|
26365
|
+
const resUser = await this.getMe(accessToken, check401);
|
|
26366
|
+
if (resUser.code === 200) {
|
|
26367
|
+
const user = resUser.data;
|
|
26368
|
+
if (user) {
|
|
26369
|
+
this.cacheStore.setLoginUser({
|
|
26370
|
+
user,
|
|
26371
|
+
id: user.id,
|
|
26372
|
+
accessToken,
|
|
26373
|
+
refreshToken,
|
|
26374
|
+
accessTokenExpiresIn,
|
|
26375
|
+
createdAt: Date.now()
|
|
26376
|
+
});
|
|
26377
|
+
} else {
|
|
26378
|
+
console.error("登录失败");
|
|
26379
|
+
}
|
|
26380
|
+
}
|
|
26381
|
+
}
|
|
26382
|
+
}
|
|
26383
|
+
async queryRefreshToken(refreshToken) {
|
|
26384
|
+
const _refreshToken = refreshToken || this.cacheStore.getRefreshToken();
|
|
26385
|
+
let data = { refreshToken: _refreshToken };
|
|
26386
|
+
if (!_refreshToken) {
|
|
26387
|
+
await this.cacheStore.clearCurrentUser();
|
|
26388
|
+
return {
|
|
26389
|
+
code: 401,
|
|
26390
|
+
message: "请先登录",
|
|
26391
|
+
data: {}
|
|
26392
|
+
};
|
|
26393
|
+
}
|
|
26394
|
+
return this.post({ key: "refreshToken", data }, {
|
|
26395
|
+
afterResponse: async (response, ctx) => {
|
|
26396
|
+
return response;
|
|
26397
|
+
}
|
|
26191
26398
|
});
|
|
26192
26399
|
}
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
};
|
|
26201
|
-
|
|
26202
|
-
|
|
26203
|
-
|
|
26204
|
-
|
|
26205
|
-
|
|
26206
|
-
|
|
26207
|
-
|
|
26208
|
-
|
|
26209
|
-
|
|
26210
|
-
|
|
26400
|
+
async afterCheck401ToRefreshToken(response, ctx, refetch) {
|
|
26401
|
+
const that = this;
|
|
26402
|
+
if (response?.code === 401) {
|
|
26403
|
+
const hasRefreshToken = await that.cacheStore.getRefreshToken();
|
|
26404
|
+
if (hasRefreshToken) {
|
|
26405
|
+
const res = await that.queryRefreshToken(hasRefreshToken);
|
|
26406
|
+
if (res.code === 200) {
|
|
26407
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
|
|
26408
|
+
that.storage.setItem("token", accessToken || "");
|
|
26409
|
+
await that.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn, check401: false });
|
|
26410
|
+
if (refetch && ctx && ctx.req && ctx.req.url && ctx.fetch) {
|
|
26411
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
26412
|
+
const url = ctx.req?.url;
|
|
26413
|
+
const body = ctx.req?.body;
|
|
26414
|
+
const headers = ctx.req?.headers;
|
|
26415
|
+
const res2 = await ctx.fetch(url, {
|
|
26416
|
+
method: "POST",
|
|
26417
|
+
body,
|
|
26418
|
+
headers: { ...headers, Authorization: `Bearer ${accessToken}` }
|
|
26419
|
+
});
|
|
26420
|
+
return res2;
|
|
26421
|
+
}
|
|
26422
|
+
} else {
|
|
26423
|
+
that.storage.removeItem("token");
|
|
26424
|
+
await that.cacheStore.clearCurrentUser();
|
|
26425
|
+
}
|
|
26426
|
+
return res;
|
|
26427
|
+
}
|
|
26428
|
+
}
|
|
26429
|
+
return response;
|
|
26211
26430
|
}
|
|
26212
|
-
|
|
26213
|
-
|
|
26431
|
+
async run401Action(response, ctx, opts) {
|
|
26432
|
+
const that = this;
|
|
26433
|
+
const refetch = opts?.refetch ?? false;
|
|
26434
|
+
if (response?.code === 401) {
|
|
26435
|
+
if (that.query.stop === true) {
|
|
26436
|
+
return { code: 500, success: false, message: "refresh token loading..." };
|
|
26437
|
+
}
|
|
26438
|
+
that.query.stop = true;
|
|
26439
|
+
const res = await that.afterCheck401ToRefreshToken(response, ctx, refetch);
|
|
26440
|
+
that.query.stop = false;
|
|
26441
|
+
opts?.afterCheck?.(res);
|
|
26442
|
+
if (res.code === 401) {
|
|
26443
|
+
opts?.afterAlso401?.(res);
|
|
26444
|
+
}
|
|
26445
|
+
return res;
|
|
26446
|
+
} else {
|
|
26447
|
+
return response;
|
|
26448
|
+
}
|
|
26214
26449
|
}
|
|
26215
|
-
|
|
26216
|
-
|
|
26217
|
-
|
|
26218
|
-
|
|
26219
|
-
|
|
26220
|
-
|
|
26221
|
-
|
|
26450
|
+
async getMe(token, check401 = true) {
|
|
26451
|
+
const _token = token || this.storage.getItem("token");
|
|
26452
|
+
const that = this;
|
|
26453
|
+
return that.post({ key: "me" }, {
|
|
26454
|
+
beforeRequest: async (config) => {
|
|
26455
|
+
if (config.headers) {
|
|
26456
|
+
config.headers["Authorization"] = `Bearer ${_token}`;
|
|
26457
|
+
}
|
|
26458
|
+
if (!_token) {
|
|
26459
|
+
return false;
|
|
26460
|
+
}
|
|
26461
|
+
return config;
|
|
26462
|
+
},
|
|
26463
|
+
afterResponse: async (response, ctx) => {
|
|
26464
|
+
if (response?.code === 401 && check401 && !token) {
|
|
26465
|
+
return await that.afterCheck401ToRefreshToken(response, ctx);
|
|
26466
|
+
}
|
|
26467
|
+
return response;
|
|
26468
|
+
}
|
|
26469
|
+
});
|
|
26470
|
+
}
|
|
26471
|
+
async checkLocalUser() {
|
|
26472
|
+
const user = await this.cacheStore.getCurrentUser();
|
|
26473
|
+
if (user) {
|
|
26474
|
+
return user;
|
|
26222
26475
|
}
|
|
26476
|
+
return null;
|
|
26477
|
+
}
|
|
26478
|
+
async checkLocalToken() {
|
|
26479
|
+
const token = this.storage.getItem("token");
|
|
26480
|
+
return !!token;
|
|
26481
|
+
}
|
|
26482
|
+
async getToken() {
|
|
26483
|
+
const token = this.storage.getItem("token");
|
|
26484
|
+
return token || "";
|
|
26485
|
+
}
|
|
26486
|
+
async beforeRequest(opts = {}) {
|
|
26487
|
+
const token = this.storage.getItem("token");
|
|
26223
26488
|
if (token) {
|
|
26224
|
-
|
|
26489
|
+
opts.headers = { ...opts.headers, Authorization: `Bearer ${token}` };
|
|
26225
26490
|
}
|
|
26491
|
+
return opts;
|
|
26226
26492
|
}
|
|
26227
|
-
|
|
26228
|
-
};
|
|
26229
|
-
|
|
26230
|
-
|
|
26231
|
-
|
|
26232
|
-
|
|
26233
|
-
|
|
26234
|
-
|
|
26235
|
-
|
|
26236
|
-
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
-
|
|
26240
|
-
|
|
26241
|
-
|
|
26242
|
-
|
|
26243
|
-
|
|
26244
|
-
|
|
26493
|
+
async postSwitchUser(username) {
|
|
26494
|
+
return this.post({ key: "switchCheck", data: { username } });
|
|
26495
|
+
}
|
|
26496
|
+
async switchUser(username) {
|
|
26497
|
+
const localUserList = await this.cacheStore.getCurrentUserList();
|
|
26498
|
+
const user = localUserList.find((userItem) => userItem.user.username === username);
|
|
26499
|
+
if (user) {
|
|
26500
|
+
this.storage.setItem("token", user.accessToken || "");
|
|
26501
|
+
await this.beforeSetLoginUser({
|
|
26502
|
+
accessToken: user.accessToken,
|
|
26503
|
+
refreshToken: user.refreshToken,
|
|
26504
|
+
accessTokenExpiresIn: user.accessTokenExpiresIn
|
|
26505
|
+
});
|
|
26506
|
+
return {
|
|
26507
|
+
code: 200,
|
|
26508
|
+
data: {
|
|
26509
|
+
accessToken: user.accessToken,
|
|
26510
|
+
refreshToken: user.refreshToken,
|
|
26511
|
+
accessTokenExpiresIn: user.accessTokenExpiresIn
|
|
26512
|
+
},
|
|
26513
|
+
success: true,
|
|
26514
|
+
message: "切换用户成功"
|
|
26515
|
+
};
|
|
26516
|
+
}
|
|
26517
|
+
const res = await this.postSwitchUser(username);
|
|
26518
|
+
if (res.code === 200) {
|
|
26519
|
+
const { accessToken, refreshToken, accessTokenExpiresIn } = res?.data || {};
|
|
26520
|
+
this.storage.setItem("token", accessToken || "");
|
|
26521
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26522
|
+
}
|
|
26523
|
+
return res;
|
|
26524
|
+
}
|
|
26525
|
+
async logout() {
|
|
26526
|
+
this.storage.removeItem("token");
|
|
26527
|
+
const users = await this.cacheStore.getCurrentUserList();
|
|
26528
|
+
const tokens = users.map((user) => {
|
|
26529
|
+
return user?.accessToken;
|
|
26530
|
+
}).filter(Boolean);
|
|
26531
|
+
this.cacheStore.delValue();
|
|
26532
|
+
return this.post({ key: "logout", data: { tokens } });
|
|
26533
|
+
}
|
|
26534
|
+
async hasUser(username) {
|
|
26535
|
+
const that = this;
|
|
26536
|
+
return this.post({
|
|
26537
|
+
path: "org",
|
|
26538
|
+
key: "hasUser",
|
|
26539
|
+
data: {
|
|
26540
|
+
username
|
|
26541
|
+
}
|
|
26542
|
+
}, {
|
|
26543
|
+
afterResponse: async (response, ctx) => {
|
|
26544
|
+
if (response?.code === 401) {
|
|
26545
|
+
const res = await that.afterCheck401ToRefreshToken(response, ctx, true);
|
|
26546
|
+
return res;
|
|
26547
|
+
}
|
|
26548
|
+
return response;
|
|
26549
|
+
}
|
|
26550
|
+
});
|
|
26551
|
+
}
|
|
26552
|
+
async checkLoginStatus(token) {
|
|
26553
|
+
const res = await this.post({
|
|
26554
|
+
path: "user",
|
|
26555
|
+
key: "checkLoginStatus",
|
|
26556
|
+
loginToken: token
|
|
26557
|
+
});
|
|
26558
|
+
if (res.code === 200) {
|
|
26559
|
+
const { accessTokenExpiresIn, accessToken, refreshToken } = res.data;
|
|
26560
|
+
this.storage.setItem("token", accessToken || "");
|
|
26561
|
+
await this.beforeSetLoginUser({ accessToken, refreshToken, accessTokenExpiresIn });
|
|
26562
|
+
return res;
|
|
26563
|
+
}
|
|
26564
|
+
return false;
|
|
26565
|
+
}
|
|
26566
|
+
loginWithWeb(baseURL, { MD5, jsonwebtoken }) {
|
|
26567
|
+
const randomId = Math.random().toString(36).substring(2, 15);
|
|
26568
|
+
const timestamp = Date.now();
|
|
26569
|
+
const tokenSecret = "xiao" + randomId;
|
|
26570
|
+
let sign = "";
|
|
26571
|
+
if (MD5) {
|
|
26572
|
+
sign = MD5(`${tokenSecret}${timestamp}`).toString();
|
|
26573
|
+
}
|
|
26574
|
+
let token = "";
|
|
26575
|
+
if (jsonwebtoken) {
|
|
26576
|
+
token = jsonwebtoken.sign({ randomId, timestamp, sign }, tokenSecret, {
|
|
26577
|
+
expiresIn: 60 * 10
|
|
26578
|
+
});
|
|
26579
|
+
} else {
|
|
26580
|
+
token = tokenSecret;
|
|
26581
|
+
}
|
|
26582
|
+
const url = `${baseURL}/api/router?path=user&key=webLogin&p&loginToken=${token}&sign=${sign}&randomId=${randomId}`;
|
|
26583
|
+
return { url, token, tokenSecret };
|
|
26584
|
+
}
|
|
26585
|
+
async pollLoginStatus(data) {
|
|
26586
|
+
const token = data.token;
|
|
26587
|
+
const load2 = new BaseLoad3;
|
|
26588
|
+
load2.load(async () => {
|
|
26589
|
+
const res2 = await this.checkLoginStatus(token);
|
|
26590
|
+
if (res2.code === 500) {
|
|
26591
|
+
load2.cancel("check-login-status");
|
|
26592
|
+
}
|
|
26593
|
+
return res2;
|
|
26594
|
+
}, {
|
|
26595
|
+
key: "check-login-status",
|
|
26596
|
+
isReRun: true,
|
|
26597
|
+
checkSuccess: (data2) => {
|
|
26598
|
+
return data2?.code === 200;
|
|
26599
|
+
}
|
|
26600
|
+
});
|
|
26601
|
+
const res = await load2.hasLoaded("check-login-status", {
|
|
26602
|
+
timeout: 60 * 3 * 1000
|
|
26603
|
+
});
|
|
26604
|
+
if (res.code === 200 && res.data?.code === 200) {
|
|
26605
|
+
try {
|
|
26606
|
+
console.log("网页登录成功");
|
|
26607
|
+
return true;
|
|
26608
|
+
} catch (error) {
|
|
26609
|
+
console.log("登录失败", error);
|
|
26610
|
+
return false;
|
|
26611
|
+
}
|
|
26612
|
+
}
|
|
26613
|
+
console.log("登录失败", res);
|
|
26614
|
+
return false;
|
|
26615
|
+
}
|
|
26616
|
+
}
|
|
26617
|
+
|
|
26618
|
+
// node_modules/.pnpm/@kevisual+api@0.0.55_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-node-cache.ts
|
|
26619
|
+
import { homedir } from "node:os";
|
|
26620
|
+
import { join, dirname } from "node:path";
|
|
26621
|
+
import fs4 from "node:fs";
|
|
26622
|
+
import { readFileSync, writeFileSync, accessSync, unlinkSync, mkdirSync } from "node:fs";
|
|
26623
|
+
var fileExists = (filePath, { createIfNotExists = true, isFile = true, isDir = false } = {}) => {
|
|
26624
|
+
try {
|
|
26625
|
+
accessSync(filePath, fs4.constants.F_OK);
|
|
26626
|
+
return true;
|
|
26627
|
+
} catch (error) {
|
|
26628
|
+
if (createIfNotExists && isDir) {
|
|
26629
|
+
mkdirSync(filePath, { recursive: true });
|
|
26630
|
+
return true;
|
|
26631
|
+
} else if (createIfNotExists && isFile) {
|
|
26632
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
26633
|
+
return false;
|
|
26634
|
+
}
|
|
26635
|
+
return false;
|
|
26636
|
+
}
|
|
26637
|
+
};
|
|
26638
|
+
var readConfigFile = (filePath) => {
|
|
26639
|
+
try {
|
|
26640
|
+
const data = readFileSync(filePath, "utf-8");
|
|
26641
|
+
const jsonData = JSON.parse(data);
|
|
26642
|
+
return jsonData;
|
|
26643
|
+
} catch (error) {
|
|
26644
|
+
return {};
|
|
26645
|
+
}
|
|
26646
|
+
};
|
|
26647
|
+
var writeConfigFile = (filePath, data) => {
|
|
26648
|
+
writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
26649
|
+
};
|
|
26650
|
+
var getHostName = (baseURL) => {
|
|
26651
|
+
const configDir = join(homedir(), ".config", "envision");
|
|
26652
|
+
const configFile = join(configDir, "config.json");
|
|
26653
|
+
const config = readConfigFile(configFile);
|
|
26654
|
+
const _baseURL = baseURL || config.baseURL || "https://kevisual.cn";
|
|
26655
|
+
const hostname = new URL(_baseURL).hostname;
|
|
26656
|
+
return hostname;
|
|
26657
|
+
};
|
|
26658
|
+
|
|
26659
|
+
class StorageNode {
|
|
26660
|
+
cacheData;
|
|
26661
|
+
filePath = "";
|
|
26662
|
+
hostname = "";
|
|
26663
|
+
constructor(opts) {
|
|
26664
|
+
this.cacheData = {};
|
|
26665
|
+
const hostname = getHostName(opts?.baseURL);
|
|
26666
|
+
this.setHostName(hostname, { load: opts?.load });
|
|
26667
|
+
}
|
|
26668
|
+
setHostName(hostname, opts) {
|
|
26669
|
+
const load2 = opts?.load ?? false;
|
|
26670
|
+
if (hostname.startsWith("http")) {
|
|
26671
|
+
hostname = new URL(hostname).hostname;
|
|
26672
|
+
}
|
|
26673
|
+
const configDir = join(homedir(), ".config", "envision");
|
|
26674
|
+
this.filePath = join(configDir, "config", `${hostname}-storage.json`);
|
|
26675
|
+
this.hostname = hostname;
|
|
26676
|
+
fileExists(this.filePath, { isFile: true });
|
|
26677
|
+
if (load2) {
|
|
26678
|
+
this.loadCache();
|
|
26679
|
+
}
|
|
26680
|
+
}
|
|
26681
|
+
loadCache() {
|
|
26682
|
+
const filePath = this.filePath;
|
|
26683
|
+
try {
|
|
26684
|
+
const data = readConfigFile(filePath);
|
|
26685
|
+
this.cacheData = data;
|
|
26686
|
+
} catch (error) {
|
|
26687
|
+
this.cacheData = {};
|
|
26688
|
+
writeFileSync(filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26689
|
+
}
|
|
26690
|
+
}
|
|
26691
|
+
get length() {
|
|
26692
|
+
return Object.keys(this.cacheData).length;
|
|
26693
|
+
}
|
|
26694
|
+
getItem(key) {
|
|
26695
|
+
return this.cacheData[key];
|
|
26696
|
+
}
|
|
26697
|
+
setItem(key, value) {
|
|
26698
|
+
this.cacheData[key] = value;
|
|
26699
|
+
writeFileSync(this.filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26700
|
+
}
|
|
26701
|
+
removeItem(key) {
|
|
26702
|
+
delete this.cacheData[key];
|
|
26703
|
+
writeFileSync(this.filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26704
|
+
}
|
|
26705
|
+
clear() {
|
|
26706
|
+
this.cacheData = {};
|
|
26707
|
+
writeFileSync(this.filePath, JSON.stringify(this.cacheData, null, 2));
|
|
26708
|
+
}
|
|
26709
|
+
key(index) {
|
|
26710
|
+
return Object.keys(this.cacheData)[index];
|
|
26711
|
+
}
|
|
26712
|
+
}
|
|
26713
|
+
|
|
26714
|
+
class LoginNodeCache {
|
|
26715
|
+
filepath;
|
|
26716
|
+
constructor(opts) {
|
|
26717
|
+
this.filepath = join(homedir(), ".config", "envision", "config", `${getHostName(opts?.baseURL)}-login.json`);
|
|
26718
|
+
fileExists(this.filepath, { isFile: true });
|
|
26719
|
+
if (opts?.load) {
|
|
26720
|
+
this.loadCache(this.filepath);
|
|
26721
|
+
}
|
|
26722
|
+
}
|
|
26723
|
+
async get(_key) {
|
|
26724
|
+
try {
|
|
26725
|
+
const filePath = this.filepath;
|
|
26726
|
+
const data = readConfigFile(filePath);
|
|
26727
|
+
return data;
|
|
26728
|
+
} catch (error) {
|
|
26729
|
+
console.log("get error", error);
|
|
26730
|
+
return {};
|
|
26731
|
+
}
|
|
26732
|
+
}
|
|
26733
|
+
async set(_key, value) {
|
|
26734
|
+
try {
|
|
26735
|
+
const data = readConfigFile(this.filepath);
|
|
26736
|
+
const newData = { ...data, ...value };
|
|
26737
|
+
writeConfigFile(this.filepath, newData);
|
|
26738
|
+
} catch (error) {
|
|
26739
|
+
console.log("set error", error);
|
|
26740
|
+
}
|
|
26741
|
+
}
|
|
26742
|
+
async del() {
|
|
26743
|
+
unlinkSync(this.filepath);
|
|
26744
|
+
}
|
|
26745
|
+
loadCache(filePath) {
|
|
26746
|
+
try {
|
|
26747
|
+
const data = readFileSync(filePath, "utf-8");
|
|
26748
|
+
const jsonData = JSON.parse(data);
|
|
26749
|
+
return jsonData;
|
|
26750
|
+
} catch (error) {
|
|
26751
|
+
console.log("create new cache file:", filePath);
|
|
26752
|
+
const defaultData = { loginUsers: [] };
|
|
26753
|
+
writeConfigFile(filePath, defaultData);
|
|
26754
|
+
return defaultData;
|
|
26755
|
+
}
|
|
26756
|
+
}
|
|
26757
|
+
init() {
|
|
26758
|
+
return this.loadCache(this.filepath);
|
|
26759
|
+
}
|
|
26760
|
+
}
|
|
26761
|
+
|
|
26762
|
+
// node_modules/.pnpm/@kevisual+api@0.0.55_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login-node.ts
|
|
26763
|
+
var cache = new LoginNodeCache;
|
|
26764
|
+
|
|
26765
|
+
class QueryLoginNode extends QueryLogin {
|
|
26766
|
+
constructor(opts) {
|
|
26767
|
+
const baseURL = opts?.query?.baseURL;
|
|
26768
|
+
const storage = new StorageNode({ baseURL, load: true });
|
|
26769
|
+
const cache2 = new LoginNodeCache({ baseURL, load: true });
|
|
26770
|
+
super({
|
|
26771
|
+
...opts,
|
|
26772
|
+
isBrowser: false,
|
|
26773
|
+
storage,
|
|
26774
|
+
cache: cache2
|
|
26775
|
+
});
|
|
26776
|
+
}
|
|
26777
|
+
}
|
|
26778
|
+
|
|
26779
|
+
// src/module/query.ts
|
|
26780
|
+
var config = getConfig2();
|
|
26781
|
+
var baseURL = config?.baseURL || "https://kevisual.cn";
|
|
26782
|
+
var storage = new StorageNode({ load: true });
|
|
26783
|
+
var getBaseURL = () => {
|
|
26784
|
+
return baseURL;
|
|
26785
|
+
};
|
|
26786
|
+
var query = new Query({
|
|
26787
|
+
url: `${getBaseURL()}/api/router`
|
|
26788
|
+
});
|
|
26789
|
+
var getHeader = async () => {
|
|
26790
|
+
const headers = {
|
|
26791
|
+
"Content-Type": "application/json"
|
|
26792
|
+
};
|
|
26793
|
+
let token = getEnvToken();
|
|
26794
|
+
if (!token) {
|
|
26795
|
+
token = await storage.getItem("token");
|
|
26796
|
+
}
|
|
26797
|
+
if (token) {
|
|
26798
|
+
headers["Authorization"] = "Bearer " + token;
|
|
26799
|
+
}
|
|
26800
|
+
return headers;
|
|
26801
|
+
};
|
|
26802
|
+
query.beforeRequest = async (config2) => {
|
|
26803
|
+
if (config2.headers) {
|
|
26804
|
+
let token = getEnvToken();
|
|
26805
|
+
if (!token) {
|
|
26806
|
+
token = await storage.getItem("token");
|
|
26807
|
+
}
|
|
26808
|
+
if (token) {
|
|
26809
|
+
config2.headers["Authorization"] = "Bearer " + token;
|
|
26810
|
+
}
|
|
26811
|
+
}
|
|
26812
|
+
return config2;
|
|
26813
|
+
};
|
|
26814
|
+
query.afterResponse = async (response, ctx) => {
|
|
26815
|
+
return await queryLogin.run401Action(response, ctx);
|
|
26816
|
+
};
|
|
26817
|
+
var queryLogin = new QueryLoginNode({
|
|
26818
|
+
query,
|
|
26819
|
+
onLoad: async () => {}
|
|
26820
|
+
});
|
|
26821
|
+
var getUrl = (url) => {
|
|
26822
|
+
return new URL("/api/router", url).href;
|
|
26823
|
+
};
|
|
26824
|
+
|
|
26825
|
+
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
26826
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
26827
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
26828
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
26829
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
26245
26830
|
var styles = {
|
|
26246
26831
|
modifier: {
|
|
26247
26832
|
reset: [0, 0],
|
|
@@ -26578,612 +27163,162 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
|
26578
27163
|
returnValue += string.slice(endIndex);
|
|
26579
27164
|
return returnValue;
|
|
26580
27165
|
}
|
|
26581
|
-
|
|
26582
|
-
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
26583
|
-
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
26584
|
-
var GENERATOR = Symbol("GENERATOR");
|
|
26585
|
-
var STYLER = Symbol("STYLER");
|
|
26586
|
-
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
26587
|
-
var levelMapping = [
|
|
26588
|
-
"ansi",
|
|
26589
|
-
"ansi",
|
|
26590
|
-
"ansi256",
|
|
26591
|
-
"ansi16m"
|
|
26592
|
-
];
|
|
26593
|
-
var styles2 = Object.create(null);
|
|
26594
|
-
var applyOptions = (object, options = {}) => {
|
|
26595
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
26596
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
26597
|
-
}
|
|
26598
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
26599
|
-
object.level = options.level === undefined ? colorLevel : options.level;
|
|
26600
|
-
};
|
|
26601
|
-
|
|
26602
|
-
class Chalk {
|
|
26603
|
-
constructor(options) {
|
|
26604
|
-
return chalkFactory(options);
|
|
26605
|
-
}
|
|
26606
|
-
}
|
|
26607
|
-
var chalkFactory = (options) => {
|
|
26608
|
-
const chalk = (...strings) => strings.join(" ");
|
|
26609
|
-
applyOptions(chalk, options);
|
|
26610
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
26611
|
-
return chalk;
|
|
26612
|
-
};
|
|
26613
|
-
function createChalk(options) {
|
|
26614
|
-
return chalkFactory(options);
|
|
26615
|
-
}
|
|
26616
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
26617
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
26618
|
-
styles2[styleName] = {
|
|
26619
|
-
get() {
|
|
26620
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
26621
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
26622
|
-
return builder;
|
|
26623
|
-
}
|
|
26624
|
-
};
|
|
26625
|
-
}
|
|
26626
|
-
styles2.visible = {
|
|
26627
|
-
get() {
|
|
26628
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
26629
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
26630
|
-
return builder;
|
|
26631
|
-
}
|
|
26632
|
-
};
|
|
26633
|
-
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
26634
|
-
if (model === "rgb") {
|
|
26635
|
-
if (level === "ansi16m") {
|
|
26636
|
-
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
26637
|
-
}
|
|
26638
|
-
if (level === "ansi256") {
|
|
26639
|
-
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
26640
|
-
}
|
|
26641
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
26642
|
-
}
|
|
26643
|
-
if (model === "hex") {
|
|
26644
|
-
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
26645
|
-
}
|
|
26646
|
-
return ansi_styles_default[type][model](...arguments_);
|
|
26647
|
-
};
|
|
26648
|
-
var usedModels = ["rgb", "hex", "ansi256"];
|
|
26649
|
-
for (const model of usedModels) {
|
|
26650
|
-
styles2[model] = {
|
|
26651
|
-
get() {
|
|
26652
|
-
const { level } = this;
|
|
26653
|
-
return function(...arguments_) {
|
|
26654
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
26655
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
26656
|
-
};
|
|
26657
|
-
}
|
|
26658
|
-
};
|
|
26659
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
26660
|
-
styles2[bgModel] = {
|
|
26661
|
-
get() {
|
|
26662
|
-
const { level } = this;
|
|
26663
|
-
return function(...arguments_) {
|
|
26664
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
26665
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
26666
|
-
};
|
|
26667
|
-
}
|
|
26668
|
-
};
|
|
26669
|
-
}
|
|
26670
|
-
var proto = Object.defineProperties(() => {}, {
|
|
26671
|
-
...styles2,
|
|
26672
|
-
level: {
|
|
26673
|
-
enumerable: true,
|
|
26674
|
-
get() {
|
|
26675
|
-
return this[GENERATOR].level;
|
|
26676
|
-
},
|
|
26677
|
-
set(level) {
|
|
26678
|
-
this[GENERATOR].level = level;
|
|
26679
|
-
}
|
|
26680
|
-
}
|
|
26681
|
-
});
|
|
26682
|
-
var createStyler = (open, close, parent) => {
|
|
26683
|
-
let openAll;
|
|
26684
|
-
let closeAll;
|
|
26685
|
-
if (parent === undefined) {
|
|
26686
|
-
openAll = open;
|
|
26687
|
-
closeAll = close;
|
|
26688
|
-
} else {
|
|
26689
|
-
openAll = parent.openAll + open;
|
|
26690
|
-
closeAll = close + parent.closeAll;
|
|
26691
|
-
}
|
|
26692
|
-
return {
|
|
26693
|
-
open,
|
|
26694
|
-
close,
|
|
26695
|
-
openAll,
|
|
26696
|
-
closeAll,
|
|
26697
|
-
parent
|
|
26698
|
-
};
|
|
26699
|
-
};
|
|
26700
|
-
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
26701
|
-
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
26702
|
-
Object.setPrototypeOf(builder, proto);
|
|
26703
|
-
builder[GENERATOR] = self2;
|
|
26704
|
-
builder[STYLER] = _styler;
|
|
26705
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
26706
|
-
return builder;
|
|
26707
|
-
};
|
|
26708
|
-
var applyStyle = (self2, string) => {
|
|
26709
|
-
if (self2.level <= 0 || !string) {
|
|
26710
|
-
return self2[IS_EMPTY] ? "" : string;
|
|
26711
|
-
}
|
|
26712
|
-
let styler = self2[STYLER];
|
|
26713
|
-
if (styler === undefined) {
|
|
26714
|
-
return string;
|
|
26715
|
-
}
|
|
26716
|
-
const { openAll, closeAll } = styler;
|
|
26717
|
-
if (string.includes("\x1B")) {
|
|
26718
|
-
while (styler !== undefined) {
|
|
26719
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
26720
|
-
styler = styler.parent;
|
|
26721
|
-
}
|
|
26722
|
-
}
|
|
26723
|
-
const lfIndex = string.indexOf(`
|
|
26724
|
-
`);
|
|
26725
|
-
if (lfIndex !== -1) {
|
|
26726
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
26727
|
-
}
|
|
26728
|
-
return openAll + string + closeAll;
|
|
26729
|
-
};
|
|
26730
|
-
Object.defineProperties(createChalk.prototype, styles2);
|
|
26731
|
-
var chalk = createChalk();
|
|
26732
|
-
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
26733
|
-
var source_default = chalk;
|
|
26734
|
-
|
|
26735
|
-
// src/module/chalk.ts
|
|
26736
|
-
var chalk2 = new Chalk({ level: 3 });
|
|
26737
|
-
|
|
26738
|
-
// node_modules/.pnpm/@kevisual+load@0.0.6/node_modules/@kevisual/load/dist/load.js
|
|
26739
|
-
function getDefaultExportFromCjs3(x) {
|
|
26740
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
26741
|
-
}
|
|
26742
|
-
var eventemitter33 = { exports: {} };
|
|
26743
|
-
var hasRequiredEventemitter33;
|
|
26744
|
-
function requireEventemitter33() {
|
|
26745
|
-
if (hasRequiredEventemitter33)
|
|
26746
|
-
return eventemitter33.exports;
|
|
26747
|
-
hasRequiredEventemitter33 = 1;
|
|
26748
|
-
(function(module) {
|
|
26749
|
-
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
26750
|
-
function Events() {}
|
|
26751
|
-
if (Object.create) {
|
|
26752
|
-
Events.prototype = Object.create(null);
|
|
26753
|
-
if (!new Events().__proto__)
|
|
26754
|
-
prefix = false;
|
|
26755
|
-
}
|
|
26756
|
-
function EE(fn, context, once) {
|
|
26757
|
-
this.fn = fn;
|
|
26758
|
-
this.context = context;
|
|
26759
|
-
this.once = once || false;
|
|
26760
|
-
}
|
|
26761
|
-
function addListener(emitter, event, fn, context, once) {
|
|
26762
|
-
if (typeof fn !== "function") {
|
|
26763
|
-
throw new TypeError("The listener must be a function");
|
|
26764
|
-
}
|
|
26765
|
-
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
26766
|
-
if (!emitter._events[evt])
|
|
26767
|
-
emitter._events[evt] = listener, emitter._eventsCount++;
|
|
26768
|
-
else if (!emitter._events[evt].fn)
|
|
26769
|
-
emitter._events[evt].push(listener);
|
|
26770
|
-
else
|
|
26771
|
-
emitter._events[evt] = [emitter._events[evt], listener];
|
|
26772
|
-
return emitter;
|
|
26773
|
-
}
|
|
26774
|
-
function clearEvent(emitter, evt) {
|
|
26775
|
-
if (--emitter._eventsCount === 0)
|
|
26776
|
-
emitter._events = new Events;
|
|
26777
|
-
else
|
|
26778
|
-
delete emitter._events[evt];
|
|
26779
|
-
}
|
|
26780
|
-
function EventEmitter3() {
|
|
26781
|
-
this._events = new Events;
|
|
26782
|
-
this._eventsCount = 0;
|
|
26783
|
-
}
|
|
26784
|
-
EventEmitter3.prototype.eventNames = function eventNames() {
|
|
26785
|
-
var names = [], events, name;
|
|
26786
|
-
if (this._eventsCount === 0)
|
|
26787
|
-
return names;
|
|
26788
|
-
for (name in events = this._events) {
|
|
26789
|
-
if (has.call(events, name))
|
|
26790
|
-
names.push(prefix ? name.slice(1) : name);
|
|
26791
|
-
}
|
|
26792
|
-
if (Object.getOwnPropertySymbols) {
|
|
26793
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
26794
|
-
}
|
|
26795
|
-
return names;
|
|
26796
|
-
};
|
|
26797
|
-
EventEmitter3.prototype.listeners = function listeners(event) {
|
|
26798
|
-
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
26799
|
-
if (!handlers)
|
|
26800
|
-
return [];
|
|
26801
|
-
if (handlers.fn)
|
|
26802
|
-
return [handlers.fn];
|
|
26803
|
-
for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
|
|
26804
|
-
ee[i] = handlers[i].fn;
|
|
26805
|
-
}
|
|
26806
|
-
return ee;
|
|
26807
|
-
};
|
|
26808
|
-
EventEmitter3.prototype.listenerCount = function listenerCount(event) {
|
|
26809
|
-
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
26810
|
-
if (!listeners)
|
|
26811
|
-
return 0;
|
|
26812
|
-
if (listeners.fn)
|
|
26813
|
-
return 1;
|
|
26814
|
-
return listeners.length;
|
|
26815
|
-
};
|
|
26816
|
-
EventEmitter3.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
26817
|
-
var evt = prefix ? prefix + event : event;
|
|
26818
|
-
if (!this._events[evt])
|
|
26819
|
-
return false;
|
|
26820
|
-
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
26821
|
-
if (listeners.fn) {
|
|
26822
|
-
if (listeners.once)
|
|
26823
|
-
this.removeListener(event, listeners.fn, undefined, true);
|
|
26824
|
-
switch (len) {
|
|
26825
|
-
case 1:
|
|
26826
|
-
return listeners.fn.call(listeners.context), true;
|
|
26827
|
-
case 2:
|
|
26828
|
-
return listeners.fn.call(listeners.context, a1), true;
|
|
26829
|
-
case 3:
|
|
26830
|
-
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
26831
|
-
case 4:
|
|
26832
|
-
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
26833
|
-
case 5:
|
|
26834
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
26835
|
-
case 6:
|
|
26836
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
26837
|
-
}
|
|
26838
|
-
for (i = 1, args = new Array(len - 1);i < len; i++) {
|
|
26839
|
-
args[i - 1] = arguments[i];
|
|
26840
|
-
}
|
|
26841
|
-
listeners.fn.apply(listeners.context, args);
|
|
26842
|
-
} else {
|
|
26843
|
-
var length = listeners.length, j;
|
|
26844
|
-
for (i = 0;i < length; i++) {
|
|
26845
|
-
if (listeners[i].once)
|
|
26846
|
-
this.removeListener(event, listeners[i].fn, undefined, true);
|
|
26847
|
-
switch (len) {
|
|
26848
|
-
case 1:
|
|
26849
|
-
listeners[i].fn.call(listeners[i].context);
|
|
26850
|
-
break;
|
|
26851
|
-
case 2:
|
|
26852
|
-
listeners[i].fn.call(listeners[i].context, a1);
|
|
26853
|
-
break;
|
|
26854
|
-
case 3:
|
|
26855
|
-
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
26856
|
-
break;
|
|
26857
|
-
case 4:
|
|
26858
|
-
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
26859
|
-
break;
|
|
26860
|
-
default:
|
|
26861
|
-
if (!args)
|
|
26862
|
-
for (j = 1, args = new Array(len - 1);j < len; j++) {
|
|
26863
|
-
args[j - 1] = arguments[j];
|
|
26864
|
-
}
|
|
26865
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
26866
|
-
}
|
|
26867
|
-
}
|
|
26868
|
-
}
|
|
26869
|
-
return true;
|
|
26870
|
-
};
|
|
26871
|
-
EventEmitter3.prototype.on = function on(event, fn, context) {
|
|
26872
|
-
return addListener(this, event, fn, context, false);
|
|
26873
|
-
};
|
|
26874
|
-
EventEmitter3.prototype.once = function once(event, fn, context) {
|
|
26875
|
-
return addListener(this, event, fn, context, true);
|
|
26876
|
-
};
|
|
26877
|
-
EventEmitter3.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
26878
|
-
var evt = prefix ? prefix + event : event;
|
|
26879
|
-
if (!this._events[evt])
|
|
26880
|
-
return this;
|
|
26881
|
-
if (!fn) {
|
|
26882
|
-
clearEvent(this, evt);
|
|
26883
|
-
return this;
|
|
26884
|
-
}
|
|
26885
|
-
var listeners = this._events[evt];
|
|
26886
|
-
if (listeners.fn) {
|
|
26887
|
-
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
26888
|
-
clearEvent(this, evt);
|
|
26889
|
-
}
|
|
26890
|
-
} else {
|
|
26891
|
-
for (var i = 0, events = [], length = listeners.length;i < length; i++) {
|
|
26892
|
-
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
26893
|
-
events.push(listeners[i]);
|
|
26894
|
-
}
|
|
26895
|
-
}
|
|
26896
|
-
if (events.length)
|
|
26897
|
-
this._events[evt] = events.length === 1 ? events[0] : events;
|
|
26898
|
-
else
|
|
26899
|
-
clearEvent(this, evt);
|
|
26900
|
-
}
|
|
26901
|
-
return this;
|
|
26902
|
-
};
|
|
26903
|
-
EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
26904
|
-
var evt;
|
|
26905
|
-
if (event) {
|
|
26906
|
-
evt = prefix ? prefix + event : event;
|
|
26907
|
-
if (this._events[evt])
|
|
26908
|
-
clearEvent(this, evt);
|
|
26909
|
-
} else {
|
|
26910
|
-
this._events = new Events;
|
|
26911
|
-
this._eventsCount = 0;
|
|
26912
|
-
}
|
|
26913
|
-
return this;
|
|
26914
|
-
};
|
|
26915
|
-
EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
|
|
26916
|
-
EventEmitter3.prototype.addListener = EventEmitter3.prototype.on;
|
|
26917
|
-
EventEmitter3.prefixed = prefix;
|
|
26918
|
-
EventEmitter3.EventEmitter = EventEmitter3;
|
|
26919
|
-
{
|
|
26920
|
-
module.exports = EventEmitter3;
|
|
26921
|
-
}
|
|
26922
|
-
})(eventemitter33);
|
|
26923
|
-
return eventemitter33.exports;
|
|
26924
|
-
}
|
|
26925
|
-
var eventemitter3Exports3 = requireEventemitter33();
|
|
26926
|
-
var EventEmitter3 = /* @__PURE__ */ getDefaultExportFromCjs3(eventemitter3Exports3);
|
|
26927
|
-
var reRunFn3 = (promiseOpts) => {
|
|
26928
|
-
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
26929
|
-
const interval = promiseOpts.interval || 1000;
|
|
26930
|
-
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
26931
|
-
const signal = promiseOpts.signal;
|
|
26932
|
-
return new Promise(async (resolve, reject) => {
|
|
26933
|
-
let intervalId;
|
|
26934
|
-
let timeoutId = setTimeout(() => {
|
|
26935
|
-
clearTimeout(intervalId);
|
|
26936
|
-
resolve({
|
|
26937
|
-
code: 500,
|
|
26938
|
-
message: "timeout"
|
|
26939
|
-
});
|
|
26940
|
-
}, timeout);
|
|
26941
|
-
const fn = promiseOpts.fn || (() => true);
|
|
26942
|
-
const runFn = async () => {
|
|
26943
|
-
if (signal?.aborted) {
|
|
26944
|
-
clearInterval(intervalId);
|
|
26945
|
-
clearTimeout(timeoutId);
|
|
26946
|
-
return resolve({
|
|
26947
|
-
code: 499,
|
|
26948
|
-
message: "operation cancelled"
|
|
26949
|
-
});
|
|
26950
|
-
}
|
|
26951
|
-
const res = await fn();
|
|
26952
|
-
if (!!checkSuccess(res)) {
|
|
26953
|
-
clearInterval(intervalId);
|
|
26954
|
-
clearTimeout(timeoutId);
|
|
26955
|
-
resolve({
|
|
26956
|
-
code: 200,
|
|
26957
|
-
data: res
|
|
26958
|
-
});
|
|
26959
|
-
} else {
|
|
26960
|
-
setTimeout(() => {
|
|
26961
|
-
runFn();
|
|
26962
|
-
}, interval);
|
|
26963
|
-
}
|
|
26964
|
-
};
|
|
26965
|
-
if (signal) {
|
|
26966
|
-
signal.addEventListener("abort", () => {
|
|
26967
|
-
clearInterval(intervalId);
|
|
26968
|
-
clearTimeout(timeoutId);
|
|
26969
|
-
resolve({
|
|
26970
|
-
code: 499,
|
|
26971
|
-
message: "operation cancelled"
|
|
26972
|
-
});
|
|
26973
|
-
});
|
|
26974
|
-
}
|
|
26975
|
-
runFn();
|
|
26976
|
-
});
|
|
26977
|
-
};
|
|
26978
|
-
|
|
26979
|
-
class BaseLoad3 {
|
|
26980
|
-
modules = new Map;
|
|
26981
|
-
event;
|
|
26982
|
-
loading;
|
|
26983
|
-
static reRunFn = reRunFn3;
|
|
26984
|
-
timeout = 5 * 60 * 1000;
|
|
26985
|
-
constructor() {
|
|
26986
|
-
this.event = new EventEmitter3;
|
|
26987
|
-
this.loading = false;
|
|
26988
|
-
}
|
|
26989
|
-
listenKey(key, listenOpts) {
|
|
26990
|
-
const timeout = listenOpts?.timeout ?? this.timeout;
|
|
26991
|
-
return new Promise((resolve) => {
|
|
26992
|
-
const timeoutId = setTimeout(() => {
|
|
26993
|
-
this.event.removeListener(key, onEvent);
|
|
26994
|
-
resolve({
|
|
26995
|
-
code: 500,
|
|
26996
|
-
message: "timeout"
|
|
26997
|
-
});
|
|
26998
|
-
}, timeout);
|
|
26999
|
-
const onEvent = (error) => {
|
|
27000
|
-
clearTimeout(timeoutId);
|
|
27001
|
-
if (error) {
|
|
27002
|
-
return resolve({
|
|
27003
|
-
code: 500,
|
|
27004
|
-
message: error
|
|
27005
|
-
});
|
|
27006
|
-
}
|
|
27007
|
-
const data = this.modules.get(key);
|
|
27008
|
-
if (data?.loadSuccessClear) {
|
|
27009
|
-
this.remove(key);
|
|
27010
|
-
}
|
|
27011
|
-
resolve({
|
|
27012
|
-
code: 200,
|
|
27013
|
-
data: data?.modules
|
|
27014
|
-
});
|
|
27015
|
-
};
|
|
27016
|
-
this.event.once(key, onEvent);
|
|
27017
|
-
});
|
|
27018
|
-
}
|
|
27019
|
-
async hasLoaded(key, hasLoadOpts) {
|
|
27020
|
-
if (!key) {
|
|
27021
|
-
return {
|
|
27022
|
-
code: 404,
|
|
27023
|
-
message: "key is required"
|
|
27024
|
-
};
|
|
27025
|
-
}
|
|
27026
|
-
const has = this.modules.has(key);
|
|
27027
|
-
if (!has) {
|
|
27028
|
-
const isExist = hasLoadOpts?.isExist ?? true;
|
|
27029
|
-
const timeout = hasLoadOpts?.timeout ?? this.timeout;
|
|
27030
|
-
if (isExist) {
|
|
27031
|
-
return await this.listenKey(key, { timeout });
|
|
27032
|
-
}
|
|
27033
|
-
return {
|
|
27034
|
-
code: 404
|
|
27035
|
-
};
|
|
27036
|
-
}
|
|
27037
|
-
const data = this.modules.get(key);
|
|
27038
|
-
if (data?.status === "loaded") {
|
|
27039
|
-
return {
|
|
27040
|
-
code: 200,
|
|
27041
|
-
data: data.modules
|
|
27042
|
-
};
|
|
27043
|
-
}
|
|
27044
|
-
if (data?.status === "loading") {
|
|
27045
|
-
return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
|
|
27046
|
-
}
|
|
27047
|
-
if (data?.status === "error") {
|
|
27048
|
-
return {
|
|
27049
|
-
code: 500,
|
|
27050
|
-
message: "load error"
|
|
27051
|
-
};
|
|
27052
|
-
}
|
|
27053
|
-
if (data?.status === "cancel") {
|
|
27054
|
-
return {
|
|
27055
|
-
code: 499,
|
|
27056
|
-
message: "operation cancelled"
|
|
27057
|
-
};
|
|
27166
|
+
|
|
27167
|
+
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
27168
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
27169
|
+
var GENERATOR = Symbol("GENERATOR");
|
|
27170
|
+
var STYLER = Symbol("STYLER");
|
|
27171
|
+
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
27172
|
+
var levelMapping = [
|
|
27173
|
+
"ansi",
|
|
27174
|
+
"ansi",
|
|
27175
|
+
"ansi256",
|
|
27176
|
+
"ansi16m"
|
|
27177
|
+
];
|
|
27178
|
+
var styles2 = Object.create(null);
|
|
27179
|
+
var applyOptions = (object, options = {}) => {
|
|
27180
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
27181
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
27182
|
+
}
|
|
27183
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
27184
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
27185
|
+
};
|
|
27186
|
+
|
|
27187
|
+
class Chalk {
|
|
27188
|
+
constructor(options) {
|
|
27189
|
+
return chalkFactory(options);
|
|
27190
|
+
}
|
|
27191
|
+
}
|
|
27192
|
+
var chalkFactory = (options) => {
|
|
27193
|
+
const chalk = (...strings) => strings.join(" ");
|
|
27194
|
+
applyOptions(chalk, options);
|
|
27195
|
+
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
27196
|
+
return chalk;
|
|
27197
|
+
};
|
|
27198
|
+
function createChalk(options) {
|
|
27199
|
+
return chalkFactory(options);
|
|
27200
|
+
}
|
|
27201
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
27202
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
27203
|
+
styles2[styleName] = {
|
|
27204
|
+
get() {
|
|
27205
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
27206
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
27207
|
+
return builder;
|
|
27058
27208
|
}
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27209
|
+
};
|
|
27210
|
+
}
|
|
27211
|
+
styles2.visible = {
|
|
27212
|
+
get() {
|
|
27213
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
27214
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
27215
|
+
return builder;
|
|
27062
27216
|
}
|
|
27063
|
-
|
|
27064
|
-
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
|
|
27068
|
-
message: "key is required"
|
|
27069
|
-
};
|
|
27217
|
+
};
|
|
27218
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
27219
|
+
if (model === "rgb") {
|
|
27220
|
+
if (level === "ansi16m") {
|
|
27221
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
27070
27222
|
}
|
|
27071
|
-
|
|
27072
|
-
|
|
27073
|
-
status: "loading",
|
|
27074
|
-
loading: true,
|
|
27075
|
-
loadSuccessClear: opts.loadSuccessClear ?? true
|
|
27076
|
-
};
|
|
27077
|
-
let errorMessage = "";
|
|
27078
|
-
try {
|
|
27079
|
-
const isReRun = opts.isReRun ?? false;
|
|
27080
|
-
let res;
|
|
27081
|
-
if (!isReRun) {
|
|
27082
|
-
this.modules.set(key, newModule);
|
|
27083
|
-
res = await loadContent();
|
|
27084
|
-
} else {
|
|
27085
|
-
newModule.controller = new AbortController;
|
|
27086
|
-
const signal = newModule.controller.signal;
|
|
27087
|
-
this.modules.set(key, newModule);
|
|
27088
|
-
const data = await reRunFn3({
|
|
27089
|
-
timeout: opts.timeout,
|
|
27090
|
-
interval: opts.interval,
|
|
27091
|
-
checkSuccess: opts.checkSuccess,
|
|
27092
|
-
fn: loadContent,
|
|
27093
|
-
signal
|
|
27094
|
-
});
|
|
27095
|
-
newModule.controller = null;
|
|
27096
|
-
if (data.code === 499) {
|
|
27097
|
-
newModule.status = "cancel";
|
|
27098
|
-
return {
|
|
27099
|
-
code: 499,
|
|
27100
|
-
message: "operation cancelled"
|
|
27101
|
-
};
|
|
27102
|
-
}
|
|
27103
|
-
if (data.code !== 200) {
|
|
27104
|
-
throw new Error(data.message);
|
|
27105
|
-
}
|
|
27106
|
-
res = data.data;
|
|
27107
|
-
}
|
|
27108
|
-
newModule.modules = res;
|
|
27109
|
-
newModule.status = "loaded";
|
|
27110
|
-
return {
|
|
27111
|
-
code: 200,
|
|
27112
|
-
data: res
|
|
27113
|
-
};
|
|
27114
|
-
} catch (error) {
|
|
27115
|
-
errorMessage = error.message;
|
|
27116
|
-
newModule.status = "error";
|
|
27117
|
-
return {
|
|
27118
|
-
code: 500,
|
|
27119
|
-
message: error
|
|
27120
|
-
};
|
|
27121
|
-
} finally {
|
|
27122
|
-
newModule.loading = false;
|
|
27123
|
-
this.modules.set(opts.key, newModule);
|
|
27124
|
-
if (!errorMessage) {
|
|
27125
|
-
this.event.emit(opts.key);
|
|
27126
|
-
} else {
|
|
27127
|
-
this.event.emit(opts.key, errorMessage);
|
|
27128
|
-
}
|
|
27223
|
+
if (level === "ansi256") {
|
|
27224
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
27129
27225
|
}
|
|
27226
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
27130
27227
|
}
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27228
|
+
if (model === "hex") {
|
|
27229
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
27230
|
+
}
|
|
27231
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
27232
|
+
};
|
|
27233
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
27234
|
+
for (const model of usedModels) {
|
|
27235
|
+
styles2[model] = {
|
|
27236
|
+
get() {
|
|
27237
|
+
const { level } = this;
|
|
27238
|
+
return function(...arguments_) {
|
|
27239
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
27240
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
27138
27241
|
};
|
|
27139
27242
|
}
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
return
|
|
27146
|
-
|
|
27147
|
-
|
|
27148
|
-
|
|
27243
|
+
};
|
|
27244
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
27245
|
+
styles2[bgModel] = {
|
|
27246
|
+
get() {
|
|
27247
|
+
const { level } = this;
|
|
27248
|
+
return function(...arguments_) {
|
|
27249
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
27250
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
27251
|
+
};
|
|
27149
27252
|
}
|
|
27150
|
-
|
|
27151
|
-
|
|
27152
|
-
|
|
27153
|
-
|
|
27154
|
-
|
|
27155
|
-
|
|
27156
|
-
|
|
27253
|
+
};
|
|
27254
|
+
}
|
|
27255
|
+
var proto = Object.defineProperties(() => {}, {
|
|
27256
|
+
...styles2,
|
|
27257
|
+
level: {
|
|
27258
|
+
enumerable: true,
|
|
27259
|
+
get() {
|
|
27260
|
+
return this[GENERATOR].level;
|
|
27261
|
+
},
|
|
27262
|
+
set(level) {
|
|
27263
|
+
this[GENERATOR].level = level;
|
|
27157
27264
|
}
|
|
27158
27265
|
}
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27266
|
+
});
|
|
27267
|
+
var createStyler = (open, close, parent) => {
|
|
27268
|
+
let openAll;
|
|
27269
|
+
let closeAll;
|
|
27270
|
+
if (parent === undefined) {
|
|
27271
|
+
openAll = open;
|
|
27272
|
+
closeAll = close;
|
|
27273
|
+
} else {
|
|
27274
|
+
openAll = parent.openAll + open;
|
|
27275
|
+
closeAll = close + parent.closeAll;
|
|
27162
27276
|
}
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
27172
|
-
|
|
27173
|
-
|
|
27277
|
+
return {
|
|
27278
|
+
open,
|
|
27279
|
+
close,
|
|
27280
|
+
openAll,
|
|
27281
|
+
closeAll,
|
|
27282
|
+
parent
|
|
27283
|
+
};
|
|
27284
|
+
};
|
|
27285
|
+
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
27286
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
27287
|
+
Object.setPrototypeOf(builder, proto);
|
|
27288
|
+
builder[GENERATOR] = self2;
|
|
27289
|
+
builder[STYLER] = _styler;
|
|
27290
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
27291
|
+
return builder;
|
|
27292
|
+
};
|
|
27293
|
+
var applyStyle = (self2, string) => {
|
|
27294
|
+
if (self2.level <= 0 || !string) {
|
|
27295
|
+
return self2[IS_EMPTY] ? "" : string;
|
|
27174
27296
|
}
|
|
27175
|
-
|
|
27176
|
-
|
|
27297
|
+
let styler = self2[STYLER];
|
|
27298
|
+
if (styler === undefined) {
|
|
27299
|
+
return string;
|
|
27177
27300
|
}
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
this.modules.set(key, data);
|
|
27301
|
+
const { openAll, closeAll } = styler;
|
|
27302
|
+
if (string.includes("\x1B")) {
|
|
27303
|
+
while (styler !== undefined) {
|
|
27304
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
27305
|
+
styler = styler.parent;
|
|
27184
27306
|
}
|
|
27185
27307
|
}
|
|
27186
|
-
|
|
27308
|
+
const lfIndex = string.indexOf(`
|
|
27309
|
+
`);
|
|
27310
|
+
if (lfIndex !== -1) {
|
|
27311
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
27312
|
+
}
|
|
27313
|
+
return openAll + string + closeAll;
|
|
27314
|
+
};
|
|
27315
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
27316
|
+
var chalk = createChalk();
|
|
27317
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
27318
|
+
var source_default = chalk;
|
|
27319
|
+
|
|
27320
|
+
// src/module/chalk.ts
|
|
27321
|
+
var chalk2 = new Chalk({ level: 3 });
|
|
27187
27322
|
|
|
27188
27323
|
// src/module/login/login-by-web.ts
|
|
27189
27324
|
var pollLoginStatus = async (token, opts) => {
|
|
@@ -31185,7 +31320,7 @@ class QueryRouterServer extends QueryRouter {
|
|
|
31185
31320
|
}
|
|
31186
31321
|
|
|
31187
31322
|
// node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
|
|
31188
|
-
var
|
|
31323
|
+
var isBrowser3 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
31189
31324
|
function getDefaultExportFromCjs4(x) {
|
|
31190
31325
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
31191
31326
|
}
|
|
@@ -33601,7 +33736,7 @@ function mitt_default(n) {
|
|
|
33601
33736
|
}
|
|
33602
33737
|
|
|
33603
33738
|
// node_modules/.pnpm/@kevisual+app@0.0.2_dotenv@17.3.1/node_modules/@kevisual/app/src/app.ts
|
|
33604
|
-
var
|
|
33739
|
+
var isBrowser5 = typeof window !== "undefined";
|
|
33605
33740
|
|
|
33606
33741
|
class App {
|
|
33607
33742
|
#router;
|
|
@@ -33620,7 +33755,7 @@ class App {
|
|
|
33620
33755
|
if (opts?.storage) {
|
|
33621
33756
|
this.storage = opts.storage;
|
|
33622
33757
|
} else {
|
|
33623
|
-
if (
|
|
33758
|
+
if (isBrowser5) {
|
|
33624
33759
|
this.storage = sessionStorage;
|
|
33625
33760
|
} else {
|
|
33626
33761
|
console.warn("没有提供 storage,某些功能可能无法使用");
|
|
@@ -33664,7 +33799,7 @@ class App {
|
|
|
33664
33799
|
return this.ai;
|
|
33665
33800
|
}
|
|
33666
33801
|
get token() {
|
|
33667
|
-
if (
|
|
33802
|
+
if (isBrowser5 && !this.#token) {
|
|
33668
33803
|
this.#token = localStorage?.getItem("token") || "";
|
|
33669
33804
|
return this.#token;
|
|
33670
33805
|
}
|
|
@@ -33695,7 +33830,7 @@ class App {
|
|
|
33695
33830
|
}
|
|
33696
33831
|
const data = res.data || {};
|
|
33697
33832
|
const config2 = data.data || {};
|
|
33698
|
-
if (
|
|
33833
|
+
if (isBrowser5) {
|
|
33699
33834
|
this.storage?.setItem?.(`config_${key}`, JSON.stringify(config2));
|
|
33700
33835
|
}
|
|
33701
33836
|
return config2;
|
|
@@ -34372,22 +34507,22 @@ var L = class a2 {
|
|
|
34372
34507
|
};
|
|
34373
34508
|
|
|
34374
34509
|
// src/module/cache.ts
|
|
34375
|
-
var
|
|
34510
|
+
var cache2 = new L({
|
|
34376
34511
|
max: 1e4,
|
|
34377
34512
|
ttl: 1000 * 60 * 60 * 24 * 7
|
|
34378
34513
|
});
|
|
34379
34514
|
var sessionStorage2 = {
|
|
34380
34515
|
setItem: (key, value) => {
|
|
34381
|
-
|
|
34516
|
+
cache2.set(key, value);
|
|
34382
34517
|
},
|
|
34383
34518
|
getItem: (key) => {
|
|
34384
|
-
return
|
|
34519
|
+
return cache2.get(key);
|
|
34385
34520
|
},
|
|
34386
34521
|
removeItem: (key) => {
|
|
34387
|
-
|
|
34522
|
+
cache2.delete(key);
|
|
34388
34523
|
},
|
|
34389
34524
|
clear: () => {
|
|
34390
|
-
|
|
34525
|
+
cache2.clear();
|
|
34391
34526
|
}
|
|
34392
34527
|
};
|
|
34393
34528
|
|
|
@@ -35343,10 +35478,10 @@ var isJWK = (key) => isObject(key) && typeof key.kty === "string";
|
|
|
35343
35478
|
var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
35344
35479
|
var isPublicJWK = (key) => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
35345
35480
|
var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
35346
|
-
var
|
|
35481
|
+
var cache3;
|
|
35347
35482
|
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
35348
|
-
|
|
35349
|
-
let cached =
|
|
35483
|
+
cache3 ||= new WeakMap;
|
|
35484
|
+
let cached = cache3.get(key);
|
|
35350
35485
|
if (cached?.[alg]) {
|
|
35351
35486
|
return cached[alg];
|
|
35352
35487
|
}
|
|
@@ -35354,15 +35489,15 @@ var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
35354
35489
|
if (freeze)
|
|
35355
35490
|
Object.freeze(key);
|
|
35356
35491
|
if (!cached) {
|
|
35357
|
-
|
|
35492
|
+
cache3.set(key, { [alg]: cryptoKey });
|
|
35358
35493
|
} else {
|
|
35359
35494
|
cached[alg] = cryptoKey;
|
|
35360
35495
|
}
|
|
35361
35496
|
return cryptoKey;
|
|
35362
35497
|
};
|
|
35363
35498
|
var handleKeyObject = (keyObject, alg) => {
|
|
35364
|
-
|
|
35365
|
-
let cached =
|
|
35499
|
+
cache3 ||= new WeakMap;
|
|
35500
|
+
let cached = cache3.get(keyObject);
|
|
35366
35501
|
if (cached?.[alg]) {
|
|
35367
35502
|
return cached[alg];
|
|
35368
35503
|
}
|
|
@@ -35475,7 +35610,7 @@ var handleKeyObject = (keyObject, alg) => {
|
|
|
35475
35610
|
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
35476
35611
|
}
|
|
35477
35612
|
if (!cached) {
|
|
35478
|
-
|
|
35613
|
+
cache3.set(keyObject, { [alg]: cryptoKey });
|
|
35479
35614
|
} else {
|
|
35480
35615
|
cached[alg] = cryptoKey;
|
|
35481
35616
|
}
|
|
@@ -37422,7 +37557,7 @@ var getJWKS = new Command("get").description("获取 JWKS 内容").option("-d ,
|
|
|
37422
37557
|
jwksCmd.addCommand(getJWKS);
|
|
37423
37558
|
program.addCommand(jwksCmd);
|
|
37424
37559
|
|
|
37425
|
-
// node_modules/.pnpm/@kevisual+cnb@0.0.
|
|
37560
|
+
// node_modules/.pnpm/@kevisual+cnb@0.0.28_dotenv@17.3.1_idb-keyval@6.2.2_ioredis@5.9.3/node_modules/@kevisual/cnb/dist/keep.js
|
|
37426
37561
|
import { createRequire as createRequire4 } from "node:module";
|
|
37427
37562
|
var __create4 = Object.create;
|
|
37428
37563
|
var __getProtoOf4 = Object.getPrototypeOf;
|