@kevisual/cli 0.1.38 → 0.1.40
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 +2033 -1011
- package/dist/assistant-server.js +1959 -937
- package/dist/assistant.js +1767 -756
- package/dist/cli.js +254 -149
- package/package.json +9 -9
package/dist/cli.js
CHANGED
|
@@ -44434,7 +44434,7 @@ class App extends QueryRouterServer {
|
|
|
44434
44434
|
}
|
|
44435
44435
|
}
|
|
44436
44436
|
|
|
44437
|
-
// node_modules/.pnpm/@kevisual+context@0.0.
|
|
44437
|
+
// node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
|
|
44438
44438
|
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
44439
44439
|
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
44440
44440
|
function getDefaultExportFromCjs(x) {
|
|
@@ -59973,7 +59973,7 @@ import os3 from "os";
|
|
|
59973
59973
|
import path2 from "path";
|
|
59974
59974
|
import fs2 from "fs";
|
|
59975
59975
|
|
|
59976
|
-
// node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.
|
|
59976
|
+
// node_modules/.pnpm/@kevisual+use-config@1.0.30_dotenv@17.4.1/node_modules/@kevisual/use-config/dist/app.js
|
|
59977
59977
|
import { createRequire as createRequire3 } from "node:module";
|
|
59978
59978
|
import fs from "node:fs";
|
|
59979
59979
|
import path from "node:path";
|
|
@@ -61387,7 +61387,7 @@ class BaseQuery {
|
|
|
61387
61387
|
}
|
|
61388
61388
|
}
|
|
61389
61389
|
|
|
61390
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
61390
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-cache.ts
|
|
61391
61391
|
var defaultCacheData = {
|
|
61392
61392
|
loginUsers: [],
|
|
61393
61393
|
user: undefined,
|
|
@@ -61958,7 +61958,7 @@ class BaseLoad3 {
|
|
|
61958
61958
|
// node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
|
|
61959
61959
|
var import__2 = __toESM(require_eventemitter32(), 1);
|
|
61960
61960
|
|
|
61961
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
61961
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login.ts
|
|
61962
61962
|
class QueryLogin extends BaseQuery {
|
|
61963
61963
|
cacheStore;
|
|
61964
61964
|
isBrowser;
|
|
@@ -62370,7 +62370,7 @@ class QueryLogin extends BaseQuery {
|
|
|
62370
62370
|
}
|
|
62371
62371
|
}
|
|
62372
62372
|
|
|
62373
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
62373
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-node-cache.ts
|
|
62374
62374
|
import { homedir } from "node:os";
|
|
62375
62375
|
import { join, dirname } from "node:path";
|
|
62376
62376
|
import fs3 from "node:fs";
|
|
@@ -62514,7 +62514,7 @@ class LoginNodeCache {
|
|
|
62514
62514
|
}
|
|
62515
62515
|
}
|
|
62516
62516
|
|
|
62517
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
62517
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login-node.ts
|
|
62518
62518
|
var cache = new LoginNodeCache;
|
|
62519
62519
|
|
|
62520
62520
|
class QueryLoginNode extends QueryLogin {
|
|
@@ -62623,14 +62623,14 @@ var normalizeScriptPath = (scriptPath) => {
|
|
|
62623
62623
|
// src/module/download/install.ts
|
|
62624
62624
|
var import_fast_glob = __toESM(require_out4(), 1);
|
|
62625
62625
|
|
|
62626
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62626
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
62627
62627
|
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
62628
62628
|
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
62629
62629
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
62630
62630
|
var isTabKey = (key) => key.name === "tab";
|
|
62631
62631
|
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
62632
62632
|
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
62633
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62633
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
62634
62634
|
class AbortPromptError extends Error {
|
|
62635
62635
|
name = "AbortPromptError";
|
|
62636
62636
|
message = "Prompt was aborted";
|
|
@@ -62656,10 +62656,10 @@ class HookError extends Error {
|
|
|
62656
62656
|
class ValidationError extends Error {
|
|
62657
62657
|
name = "ValidationError";
|
|
62658
62658
|
}
|
|
62659
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62659
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
62660
62660
|
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
62661
62661
|
|
|
62662
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62662
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
62663
62663
|
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
62664
62664
|
var hookStorage = new AsyncLocalStorage;
|
|
62665
62665
|
function createStore(rl) {
|
|
@@ -62764,7 +62764,7 @@ var effectScheduler = {
|
|
|
62764
62764
|
}
|
|
62765
62765
|
};
|
|
62766
62766
|
|
|
62767
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62767
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
62768
62768
|
function isFactory(value) {
|
|
62769
62769
|
return typeof value === "function";
|
|
62770
62770
|
}
|
|
@@ -62785,7 +62785,7 @@ function useState(defaultValue) {
|
|
|
62785
62785
|
});
|
|
62786
62786
|
}
|
|
62787
62787
|
|
|
62788
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62788
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
62789
62789
|
function useEffect(cb, depArray) {
|
|
62790
62790
|
withPointer((pointer) => {
|
|
62791
62791
|
const oldDeps = pointer.get();
|
|
@@ -62797,7 +62797,7 @@ function useEffect(cb, depArray) {
|
|
|
62797
62797
|
});
|
|
62798
62798
|
}
|
|
62799
62799
|
|
|
62800
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
62800
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
62801
62801
|
import { styleText } from "node:util";
|
|
62802
62802
|
|
|
62803
62803
|
// node_modules/.pnpm/@inquirer+figures@2.0.5/node_modules/@inquirer/figures/dist/index.js
|
|
@@ -63089,7 +63089,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
|
63089
63089
|
var dist_default = figures;
|
|
63090
63090
|
var replacements = Object.entries(specialMainSymbols);
|
|
63091
63091
|
|
|
63092
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63092
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
63093
63093
|
var defaultTheme = {
|
|
63094
63094
|
prefix: {
|
|
63095
63095
|
idle: styleText("blue", "?"),
|
|
@@ -63110,7 +63110,7 @@ var defaultTheme = {
|
|
|
63110
63110
|
}
|
|
63111
63111
|
};
|
|
63112
63112
|
|
|
63113
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63113
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
63114
63114
|
function isPlainObject4(value) {
|
|
63115
63115
|
if (typeof value !== "object" || value === null)
|
|
63116
63116
|
return false;
|
|
@@ -63138,7 +63138,7 @@ function makeTheme(...themes) {
|
|
|
63138
63138
|
return deepMerge(...themesToMerge);
|
|
63139
63139
|
}
|
|
63140
63140
|
|
|
63141
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63141
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
63142
63142
|
function usePrefix({ status = "idle", theme }) {
|
|
63143
63143
|
const [showLoader, setShowLoader] = useState(false);
|
|
63144
63144
|
const [tick, setTick] = useState(0);
|
|
@@ -63168,7 +63168,7 @@ function usePrefix({ status = "idle", theme }) {
|
|
|
63168
63168
|
const iconName = status === "loading" ? "idle" : status;
|
|
63169
63169
|
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
63170
63170
|
}
|
|
63171
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63171
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
63172
63172
|
function useMemo(fn, dependencies) {
|
|
63173
63173
|
return withPointer((pointer) => {
|
|
63174
63174
|
const prev = pointer.get();
|
|
@@ -63180,11 +63180,11 @@ function useMemo(fn, dependencies) {
|
|
|
63180
63180
|
return prev.value;
|
|
63181
63181
|
});
|
|
63182
63182
|
}
|
|
63183
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63183
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
63184
63184
|
function useRef(val) {
|
|
63185
63185
|
return useState({ current: val })[0];
|
|
63186
63186
|
}
|
|
63187
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63187
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
63188
63188
|
function useKeypress(userHandler) {
|
|
63189
63189
|
const signal = useRef(userHandler);
|
|
63190
63190
|
signal.current = userHandler;
|
|
@@ -63202,7 +63202,7 @@ function useKeypress(userHandler) {
|
|
|
63202
63202
|
};
|
|
63203
63203
|
}, []);
|
|
63204
63204
|
}
|
|
63205
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63205
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
63206
63206
|
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
63207
63207
|
|
|
63208
63208
|
// node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
@@ -63546,7 +63546,7 @@ function wrapAnsi(string5, columns, options2) {
|
|
|
63546
63546
|
`);
|
|
63547
63547
|
}
|
|
63548
63548
|
|
|
63549
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63549
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
63550
63550
|
function breakLines(content, width) {
|
|
63551
63551
|
return content.split(`
|
|
63552
63552
|
`).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
|
|
@@ -63557,7 +63557,7 @@ function readlineWidth() {
|
|
|
63557
63557
|
return import_cli_width.default({ defaultWidth: 80, output: readline().output });
|
|
63558
63558
|
}
|
|
63559
63559
|
|
|
63560
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63560
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
63561
63561
|
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
63562
63562
|
const state = useRef({
|
|
63563
63563
|
lastPointer: active,
|
|
@@ -63623,7 +63623,7 @@ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
|
63623
63623
|
return pageBuffer.filter((line) => typeof line === "string").join(`
|
|
63624
63624
|
`);
|
|
63625
63625
|
}
|
|
63626
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63626
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
63627
63627
|
var import_mute_stream = __toESM(require_lib(), 1);
|
|
63628
63628
|
import * as readline2 from "node:readline";
|
|
63629
63629
|
import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
@@ -63836,7 +63836,7 @@ var {
|
|
|
63836
63836
|
unload
|
|
63837
63837
|
} = signalExitWrap(processOk(process8) ? new SignalExit(process8) : new SignalExitFallback);
|
|
63838
63838
|
|
|
63839
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63839
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
63840
63840
|
import { stripVTControlCharacters } from "node:util";
|
|
63841
63841
|
|
|
63842
63842
|
// node_modules/.pnpm/@inquirer+ansi@2.0.5/node_modules/@inquirer/ansi/dist/index.js
|
|
@@ -63855,7 +63855,7 @@ var cursorTo = (x, y) => {
|
|
|
63855
63855
|
var eraseLine = ESC2 + "2K";
|
|
63856
63856
|
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
63857
63857
|
|
|
63858
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63858
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
63859
63859
|
var height = (content) => content.split(`
|
|
63860
63860
|
`).length;
|
|
63861
63861
|
var lastLine = (content) => content.split(`
|
|
@@ -63920,7 +63920,7 @@ class ScreenManager {
|
|
|
63920
63920
|
}
|
|
63921
63921
|
}
|
|
63922
63922
|
|
|
63923
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63923
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
63924
63924
|
class PromisePolyfill extends Promise {
|
|
63925
63925
|
static withResolver() {
|
|
63926
63926
|
let resolve;
|
|
@@ -63933,7 +63933,7 @@ class PromisePolyfill extends Promise {
|
|
|
63933
63933
|
}
|
|
63934
63934
|
}
|
|
63935
63935
|
|
|
63936
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
63936
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
63937
63937
|
import path3 from "node:path";
|
|
63938
63938
|
var nativeSetImmediate = globalThis.setImmediate;
|
|
63939
63939
|
function getCallSites() {
|
|
@@ -64044,7 +64044,7 @@ function createPrompt(view) {
|
|
|
64044
64044
|
};
|
|
64045
64045
|
return prompt;
|
|
64046
64046
|
}
|
|
64047
|
-
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.
|
|
64047
|
+
// node_modules/.pnpm/@inquirer+core@11.1.8_@types+node@25.6.0/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
64048
64048
|
import { styleText as styleText2 } from "node:util";
|
|
64049
64049
|
class Separator {
|
|
64050
64050
|
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
@@ -64058,7 +64058,7 @@ class Separator {
|
|
|
64058
64058
|
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
64059
64059
|
}
|
|
64060
64060
|
}
|
|
64061
|
-
// node_modules/.pnpm/@inquirer+confirm@6.0.11_@types+node@25.
|
|
64061
|
+
// node_modules/.pnpm/@inquirer+confirm@6.0.11_@types+node@25.6.0/node_modules/@inquirer/confirm/dist/index.js
|
|
64062
64062
|
function getBooleanValue(value, defaultValue) {
|
|
64063
64063
|
let answer = defaultValue !== false;
|
|
64064
64064
|
if (/^(y|yes)/i.test(value))
|
|
@@ -64103,7 +64103,7 @@ var dist_default4 = createPrompt((config4, done) => {
|
|
|
64103
64103
|
const message = theme.style.message(config4.message, status);
|
|
64104
64104
|
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
|
|
64105
64105
|
});
|
|
64106
|
-
// node_modules/.pnpm/@inquirer+input@5.0.11_@types+node@25.
|
|
64106
|
+
// node_modules/.pnpm/@inquirer+input@5.0.11_@types+node@25.6.0/node_modules/@inquirer/input/dist/index.js
|
|
64107
64107
|
var inputTheme = {
|
|
64108
64108
|
validationFailureMode: "keep"
|
|
64109
64109
|
};
|
|
@@ -64187,7 +64187,7 @@ var dist_default5 = createPrompt((config4, done) => {
|
|
|
64187
64187
|
error49
|
|
64188
64188
|
];
|
|
64189
64189
|
});
|
|
64190
|
-
// node_modules/.pnpm/@inquirer+password@5.0.11_@types+node@25.
|
|
64190
|
+
// node_modules/.pnpm/@inquirer+password@5.0.11_@types+node@25.6.0/node_modules/@inquirer/password/dist/index.js
|
|
64191
64191
|
var passwordTheme = {
|
|
64192
64192
|
style: {
|
|
64193
64193
|
maskedText: "[input is masked]"
|
|
@@ -64240,7 +64240,7 @@ var dist_default6 = createPrompt((config4, done) => {
|
|
|
64240
64240
|
}
|
|
64241
64241
|
return [[prefix, message, config4.mask ? formattedValue : helpTip].join(" "), error49];
|
|
64242
64242
|
});
|
|
64243
|
-
// node_modules/.pnpm/@inquirer+select@5.1.3_@types+node@25.
|
|
64243
|
+
// node_modules/.pnpm/@inquirer+select@5.1.3_@types+node@25.6.0/node_modules/@inquirer/select/dist/index.js
|
|
64244
64244
|
import { styleText as styleText3 } from "node:util";
|
|
64245
64245
|
var selectTheme = {
|
|
64246
64246
|
icon: { cursor: dist_default.pointer },
|
|
@@ -68377,23 +68377,17 @@ app.route({
|
|
|
68377
68377
|
}
|
|
68378
68378
|
}).addTo(app);
|
|
68379
68379
|
|
|
68380
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
68380
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/dist/query-config.js
|
|
68381
68381
|
var isTextForContentType3 = (contentType) => {
|
|
68382
68382
|
if (!contentType)
|
|
68383
68383
|
return false;
|
|
68384
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
68384
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
68385
68385
|
return textTypes.some((type) => contentType.includes(type));
|
|
68386
68386
|
};
|
|
68387
68387
|
var adapter3 = async (opts = {}, overloadOpts) => {
|
|
68388
68388
|
const controller = new AbortController;
|
|
68389
68389
|
const signal = controller.signal;
|
|
68390
68390
|
const isPostFile = opts.isPostFile || false;
|
|
68391
|
-
let responseType = opts.responseType || "json";
|
|
68392
|
-
if (opts.isBlob) {
|
|
68393
|
-
responseType = "blob";
|
|
68394
|
-
} else if (opts.isText) {
|
|
68395
|
-
responseType = "text";
|
|
68396
|
-
}
|
|
68397
68391
|
const timeout = opts.timeout || 60000 * 3;
|
|
68398
68392
|
const timer = setTimeout(() => {
|
|
68399
68393
|
controller.abort();
|
|
@@ -68405,13 +68399,13 @@ var adapter3 = async (opts = {}, overloadOpts) => {
|
|
|
68405
68399
|
if (opts?.url?.startsWith("http")) {
|
|
68406
68400
|
url4 = new URL(opts.url);
|
|
68407
68401
|
} else {
|
|
68408
|
-
origin =
|
|
68409
|
-
url4 = new URL(opts
|
|
68402
|
+
origin = globalThis?.location?.origin || "http://localhost:51515";
|
|
68403
|
+
url4 = new URL(opts?.url || "", origin);
|
|
68410
68404
|
}
|
|
68411
68405
|
const isGet = method === "GET";
|
|
68412
68406
|
const oldSearchParams = url4.searchParams;
|
|
68413
68407
|
if (isGet) {
|
|
68414
|
-
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts
|
|
68408
|
+
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
|
|
68415
68409
|
url4.search = searchParams.toString();
|
|
68416
68410
|
} else {
|
|
68417
68411
|
const params = {
|
|
@@ -68436,11 +68430,13 @@ var adapter3 = async (opts = {}, overloadOpts) => {
|
|
|
68436
68430
|
} else if (isPostFile) {
|
|
68437
68431
|
body = opts.body;
|
|
68438
68432
|
} else {
|
|
68439
|
-
|
|
68440
|
-
|
|
68441
|
-
|
|
68442
|
-
|
|
68443
|
-
|
|
68433
|
+
if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
|
|
68434
|
+
headers = {
|
|
68435
|
+
"Content-Type": "application/json",
|
|
68436
|
+
...headers
|
|
68437
|
+
};
|
|
68438
|
+
body = JSON.stringify(opts.body);
|
|
68439
|
+
}
|
|
68444
68440
|
}
|
|
68445
68441
|
return fetch(url4, {
|
|
68446
68442
|
method: method.toUpperCase(),
|
|
@@ -68450,21 +68446,31 @@ var adapter3 = async (opts = {}, overloadOpts) => {
|
|
|
68450
68446
|
headers
|
|
68451
68447
|
}).then(async (response) => {
|
|
68452
68448
|
const contentType = response.headers.get("Content-Type");
|
|
68453
|
-
if (responseType === "blob") {
|
|
68454
|
-
return await response.blob();
|
|
68455
|
-
}
|
|
68456
|
-
const isText = responseType === "text";
|
|
68457
68449
|
const isJson = contentType && contentType.includes("application/json");
|
|
68458
|
-
|
|
68459
|
-
|
|
68450
|
+
const isSuccess = response.ok;
|
|
68451
|
+
if (isJson) {
|
|
68452
|
+
const json3 = await response.json();
|
|
68453
|
+
if (json3?.code) {
|
|
68454
|
+
return json3;
|
|
68455
|
+
}
|
|
68456
|
+
return {
|
|
68457
|
+
code: isSuccess ? 200 : response.status,
|
|
68458
|
+
status: response.status,
|
|
68459
|
+
data: json3
|
|
68460
|
+
};
|
|
68460
68461
|
} else if (isTextForContentType3(contentType)) {
|
|
68461
68462
|
return {
|
|
68462
|
-
code: response.status,
|
|
68463
|
+
code: isSuccess ? 200 : response.status,
|
|
68463
68464
|
status: response.status,
|
|
68464
68465
|
data: await response.text()
|
|
68465
68466
|
};
|
|
68466
68467
|
} else {
|
|
68467
|
-
return
|
|
68468
|
+
return {
|
|
68469
|
+
code: isSuccess ? 200 : response.status,
|
|
68470
|
+
status: response.status,
|
|
68471
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
68472
|
+
response
|
|
68473
|
+
};
|
|
68468
68474
|
}
|
|
68469
68475
|
}).catch((err) => {
|
|
68470
68476
|
if (err.name === "AbortError") {
|
|
@@ -68484,16 +68490,14 @@ var adapter3 = async (opts = {}, overloadOpts) => {
|
|
|
68484
68490
|
var wrapperError3 = ({ code, message: message2 }) => {
|
|
68485
68491
|
const result = {
|
|
68486
68492
|
code: code || 500,
|
|
68487
|
-
|
|
68488
|
-
message: message2 || "api request error",
|
|
68489
|
-
showError: (fn) => {},
|
|
68490
|
-
noMsg: true
|
|
68493
|
+
message: message2 || "请求错误"
|
|
68491
68494
|
};
|
|
68492
68495
|
return result;
|
|
68493
68496
|
};
|
|
68494
68497
|
|
|
68495
68498
|
class Query3 {
|
|
68496
68499
|
adapter;
|
|
68500
|
+
baseURL;
|
|
68497
68501
|
url;
|
|
68498
68502
|
beforeRequest;
|
|
68499
68503
|
afterResponse;
|
|
@@ -68501,20 +68505,29 @@ class Query3 {
|
|
|
68501
68505
|
timeout;
|
|
68502
68506
|
stop;
|
|
68503
68507
|
qws;
|
|
68504
|
-
|
|
68508
|
+
tokenName;
|
|
68509
|
+
storage;
|
|
68510
|
+
token;
|
|
68505
68511
|
constructor(opts) {
|
|
68506
68512
|
this.adapter = opts?.adapter || adapter3;
|
|
68513
|
+
this.tokenName = opts?.tokenName || "token";
|
|
68514
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
68507
68515
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
68508
68516
|
this.url = opts?.url || defaultURL;
|
|
68517
|
+
if (this.url.startsWith("http")) {
|
|
68518
|
+
const urlObj = new URL(this.url);
|
|
68519
|
+
this.baseURL = urlObj.origin;
|
|
68520
|
+
}
|
|
68521
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
68509
68522
|
this.headers = opts?.headers || {
|
|
68510
68523
|
"Content-Type": "application/json"
|
|
68511
68524
|
};
|
|
68512
68525
|
this.timeout = opts?.timeout || 60000 * 3;
|
|
68513
|
-
if (opts
|
|
68526
|
+
if (opts?.beforeRequest) {
|
|
68514
68527
|
this.beforeRequest = opts.beforeRequest;
|
|
68515
68528
|
} else {
|
|
68516
68529
|
this.beforeRequest = async (opts2) => {
|
|
68517
|
-
const token =
|
|
68530
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
68518
68531
|
if (token) {
|
|
68519
68532
|
opts2.headers = {
|
|
68520
68533
|
...opts2.headers,
|
|
@@ -68549,13 +68562,20 @@ class Query3 {
|
|
|
68549
68562
|
timeout: _timeout,
|
|
68550
68563
|
...rest
|
|
68551
68564
|
};
|
|
68565
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
68566
|
+
if (!isStartsWithHttp) {
|
|
68567
|
+
if (this.baseURL) {
|
|
68568
|
+
const baseURL2 = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
68569
|
+
req.url = baseURL2 + req.url;
|
|
68570
|
+
}
|
|
68571
|
+
}
|
|
68552
68572
|
try {
|
|
68553
68573
|
if (_beforeRequest) {
|
|
68554
68574
|
const res = await _beforeRequest(req);
|
|
68555
68575
|
if (res === false) {
|
|
68556
68576
|
return wrapperError3({
|
|
68557
68577
|
code: 500,
|
|
68558
|
-
message: "
|
|
68578
|
+
message: "请求取消",
|
|
68559
68579
|
req
|
|
68560
68580
|
});
|
|
68561
68581
|
}
|
|
@@ -68564,12 +68584,13 @@ class Query3 {
|
|
|
68564
68584
|
console.error("request beforeFn error", e, req);
|
|
68565
68585
|
return wrapperError3({
|
|
68566
68586
|
code: 500,
|
|
68567
|
-
message: "
|
|
68587
|
+
message: "请求在请求前处理时发生错误",
|
|
68588
|
+
req
|
|
68568
68589
|
});
|
|
68569
68590
|
}
|
|
68570
68591
|
if (this.stop && !options2?.noStop) {
|
|
68571
68592
|
const that = this;
|
|
68572
|
-
await new Promise((resolve) => {
|
|
68593
|
+
const res = await new Promise((resolve) => {
|
|
68573
68594
|
let timer = 0;
|
|
68574
68595
|
const detect = setInterval(() => {
|
|
68575
68596
|
if (!that.stop) {
|
|
@@ -68577,11 +68598,20 @@ class Query3 {
|
|
|
68577
68598
|
resolve(true);
|
|
68578
68599
|
}
|
|
68579
68600
|
timer++;
|
|
68580
|
-
if (timer >
|
|
68581
|
-
console.error("
|
|
68601
|
+
if (timer > 5) {
|
|
68602
|
+
console.error("等待请求失败:", req.url, timer);
|
|
68603
|
+
clearInterval(detect);
|
|
68604
|
+
resolve(false);
|
|
68582
68605
|
}
|
|
68583
68606
|
}, 1000);
|
|
68584
68607
|
});
|
|
68608
|
+
if (!res) {
|
|
68609
|
+
return wrapperError3({
|
|
68610
|
+
code: 500,
|
|
68611
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
68612
|
+
req
|
|
68613
|
+
});
|
|
68614
|
+
}
|
|
68585
68615
|
}
|
|
68586
68616
|
return _adapter(req).then(async (res) => {
|
|
68587
68617
|
try {
|
|
@@ -68594,10 +68624,11 @@ class Query3 {
|
|
|
68594
68624
|
}
|
|
68595
68625
|
return res;
|
|
68596
68626
|
} catch (e) {
|
|
68597
|
-
console.error("
|
|
68627
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
68598
68628
|
return wrapperError3({
|
|
68599
68629
|
code: 500,
|
|
68600
|
-
message: "
|
|
68630
|
+
message: "请求在响应后处理时发生错误",
|
|
68631
|
+
req
|
|
68601
68632
|
});
|
|
68602
68633
|
}
|
|
68603
68634
|
});
|
|
@@ -68817,23 +68848,17 @@ app.route({
|
|
|
68817
68848
|
console.log("Delete Config Result:", showMore(res));
|
|
68818
68849
|
}).addTo(app);
|
|
68819
68850
|
|
|
68820
|
-
// node_modules/.pnpm/@kevisual+api@0.0.
|
|
68851
|
+
// node_modules/.pnpm/@kevisual+api@0.0.67_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/dist/query-secret.js
|
|
68821
68852
|
var isTextForContentType4 = (contentType) => {
|
|
68822
68853
|
if (!contentType)
|
|
68823
68854
|
return false;
|
|
68824
|
-
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
|
|
68855
|
+
const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
|
|
68825
68856
|
return textTypes.some((type) => contentType.includes(type));
|
|
68826
68857
|
};
|
|
68827
68858
|
var adapter4 = async (opts = {}, overloadOpts) => {
|
|
68828
68859
|
const controller = new AbortController;
|
|
68829
68860
|
const signal = controller.signal;
|
|
68830
68861
|
const isPostFile = opts.isPostFile || false;
|
|
68831
|
-
let responseType = opts.responseType || "json";
|
|
68832
|
-
if (opts.isBlob) {
|
|
68833
|
-
responseType = "blob";
|
|
68834
|
-
} else if (opts.isText) {
|
|
68835
|
-
responseType = "text";
|
|
68836
|
-
}
|
|
68837
68862
|
const timeout = opts.timeout || 60000 * 3;
|
|
68838
68863
|
const timer = setTimeout(() => {
|
|
68839
68864
|
controller.abort();
|
|
@@ -68845,13 +68870,13 @@ var adapter4 = async (opts = {}, overloadOpts) => {
|
|
|
68845
68870
|
if (opts?.url?.startsWith("http")) {
|
|
68846
68871
|
url4 = new URL(opts.url);
|
|
68847
68872
|
} else {
|
|
68848
|
-
origin =
|
|
68849
|
-
url4 = new URL(opts
|
|
68873
|
+
origin = globalThis?.location?.origin || "http://localhost:51515";
|
|
68874
|
+
url4 = new URL(opts?.url || "", origin);
|
|
68850
68875
|
}
|
|
68851
68876
|
const isGet = method === "GET";
|
|
68852
68877
|
const oldSearchParams = url4.searchParams;
|
|
68853
68878
|
if (isGet) {
|
|
68854
|
-
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts
|
|
68879
|
+
let searchParams = new URLSearchParams({ ...Object.fromEntries(oldSearchParams), ...opts?.params, ...opts?.body });
|
|
68855
68880
|
url4.search = searchParams.toString();
|
|
68856
68881
|
} else {
|
|
68857
68882
|
const params = {
|
|
@@ -68876,11 +68901,13 @@ var adapter4 = async (opts = {}, overloadOpts) => {
|
|
|
68876
68901
|
} else if (isPostFile) {
|
|
68877
68902
|
body = opts.body;
|
|
68878
68903
|
} else {
|
|
68879
|
-
|
|
68880
|
-
|
|
68881
|
-
|
|
68882
|
-
|
|
68883
|
-
|
|
68904
|
+
if (opts.body && typeof opts.body === "object" && !(opts.body instanceof FormData)) {
|
|
68905
|
+
headers = {
|
|
68906
|
+
"Content-Type": "application/json",
|
|
68907
|
+
...headers
|
|
68908
|
+
};
|
|
68909
|
+
body = JSON.stringify(opts.body);
|
|
68910
|
+
}
|
|
68884
68911
|
}
|
|
68885
68912
|
return fetch(url4, {
|
|
68886
68913
|
method: method.toUpperCase(),
|
|
@@ -68890,21 +68917,31 @@ var adapter4 = async (opts = {}, overloadOpts) => {
|
|
|
68890
68917
|
headers
|
|
68891
68918
|
}).then(async (response) => {
|
|
68892
68919
|
const contentType = response.headers.get("Content-Type");
|
|
68893
|
-
if (responseType === "blob") {
|
|
68894
|
-
return await response.blob();
|
|
68895
|
-
}
|
|
68896
|
-
const isText = responseType === "text";
|
|
68897
68920
|
const isJson = contentType && contentType.includes("application/json");
|
|
68898
|
-
|
|
68899
|
-
|
|
68921
|
+
const isSuccess = response.ok;
|
|
68922
|
+
if (isJson) {
|
|
68923
|
+
const json3 = await response.json();
|
|
68924
|
+
if (json3?.code) {
|
|
68925
|
+
return json3;
|
|
68926
|
+
}
|
|
68927
|
+
return {
|
|
68928
|
+
code: isSuccess ? 200 : response.status,
|
|
68929
|
+
status: response.status,
|
|
68930
|
+
data: json3
|
|
68931
|
+
};
|
|
68900
68932
|
} else if (isTextForContentType4(contentType)) {
|
|
68901
68933
|
return {
|
|
68902
|
-
code: response.status,
|
|
68934
|
+
code: isSuccess ? 200 : response.status,
|
|
68903
68935
|
status: response.status,
|
|
68904
68936
|
data: await response.text()
|
|
68905
68937
|
};
|
|
68906
68938
|
} else {
|
|
68907
|
-
return
|
|
68939
|
+
return {
|
|
68940
|
+
code: isSuccess ? 200 : response.status,
|
|
68941
|
+
status: response.status,
|
|
68942
|
+
data: "非文本非JSON响应, 请手动处理response。",
|
|
68943
|
+
response
|
|
68944
|
+
};
|
|
68908
68945
|
}
|
|
68909
68946
|
}).catch((err) => {
|
|
68910
68947
|
if (err.name === "AbortError") {
|
|
@@ -68924,16 +68961,14 @@ var adapter4 = async (opts = {}, overloadOpts) => {
|
|
|
68924
68961
|
var wrapperError4 = ({ code, message: message2 }) => {
|
|
68925
68962
|
const result = {
|
|
68926
68963
|
code: code || 500,
|
|
68927
|
-
|
|
68928
|
-
message: message2 || "api request error",
|
|
68929
|
-
showError: (fn) => {},
|
|
68930
|
-
noMsg: true
|
|
68964
|
+
message: message2 || "请求错误"
|
|
68931
68965
|
};
|
|
68932
68966
|
return result;
|
|
68933
68967
|
};
|
|
68934
68968
|
|
|
68935
68969
|
class Query4 {
|
|
68936
68970
|
adapter;
|
|
68971
|
+
baseURL;
|
|
68937
68972
|
url;
|
|
68938
68973
|
beforeRequest;
|
|
68939
68974
|
afterResponse;
|
|
@@ -68941,20 +68976,29 @@ class Query4 {
|
|
|
68941
68976
|
timeout;
|
|
68942
68977
|
stop;
|
|
68943
68978
|
qws;
|
|
68944
|
-
|
|
68979
|
+
tokenName;
|
|
68980
|
+
storage;
|
|
68981
|
+
token;
|
|
68945
68982
|
constructor(opts) {
|
|
68946
68983
|
this.adapter = opts?.adapter || adapter4;
|
|
68984
|
+
this.tokenName = opts?.tokenName || "token";
|
|
68985
|
+
this.storage = opts?.storage || globalThis?.localStorage;
|
|
68947
68986
|
const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
|
|
68948
68987
|
this.url = opts?.url || defaultURL;
|
|
68988
|
+
if (this.url.startsWith("http")) {
|
|
68989
|
+
const urlObj = new URL(this.url);
|
|
68990
|
+
this.baseURL = urlObj.origin;
|
|
68991
|
+
}
|
|
68992
|
+
this.baseURL = opts?.baseURL || this.baseURL;
|
|
68949
68993
|
this.headers = opts?.headers || {
|
|
68950
68994
|
"Content-Type": "application/json"
|
|
68951
68995
|
};
|
|
68952
68996
|
this.timeout = opts?.timeout || 60000 * 3;
|
|
68953
|
-
if (opts
|
|
68997
|
+
if (opts?.beforeRequest) {
|
|
68954
68998
|
this.beforeRequest = opts.beforeRequest;
|
|
68955
68999
|
} else {
|
|
68956
69000
|
this.beforeRequest = async (opts2) => {
|
|
68957
|
-
const token =
|
|
69001
|
+
const token = this.token || this.storage?.getItem?.(this.tokenName);
|
|
68958
69002
|
if (token) {
|
|
68959
69003
|
opts2.headers = {
|
|
68960
69004
|
...opts2.headers,
|
|
@@ -68989,13 +69033,20 @@ class Query4 {
|
|
|
68989
69033
|
timeout: _timeout,
|
|
68990
69034
|
...rest
|
|
68991
69035
|
};
|
|
69036
|
+
const isStartsWithHttp = req.url.startsWith("http");
|
|
69037
|
+
if (!isStartsWithHttp) {
|
|
69038
|
+
if (this.baseURL) {
|
|
69039
|
+
const baseURL2 = new URL(this.baseURL || globalThis?.location?.origin).origin;
|
|
69040
|
+
req.url = baseURL2 + req.url;
|
|
69041
|
+
}
|
|
69042
|
+
}
|
|
68992
69043
|
try {
|
|
68993
69044
|
if (_beforeRequest) {
|
|
68994
69045
|
const res = await _beforeRequest(req);
|
|
68995
69046
|
if (res === false) {
|
|
68996
69047
|
return wrapperError4({
|
|
68997
69048
|
code: 500,
|
|
68998
|
-
message: "
|
|
69049
|
+
message: "请求取消",
|
|
68999
69050
|
req
|
|
69000
69051
|
});
|
|
69001
69052
|
}
|
|
@@ -69004,12 +69055,13 @@ class Query4 {
|
|
|
69004
69055
|
console.error("request beforeFn error", e, req);
|
|
69005
69056
|
return wrapperError4({
|
|
69006
69057
|
code: 500,
|
|
69007
|
-
message: "
|
|
69058
|
+
message: "请求在请求前处理时发生错误",
|
|
69059
|
+
req
|
|
69008
69060
|
});
|
|
69009
69061
|
}
|
|
69010
69062
|
if (this.stop && !options2?.noStop) {
|
|
69011
69063
|
const that = this;
|
|
69012
|
-
await new Promise((resolve) => {
|
|
69064
|
+
const res = await new Promise((resolve) => {
|
|
69013
69065
|
let timer = 0;
|
|
69014
69066
|
const detect = setInterval(() => {
|
|
69015
69067
|
if (!that.stop) {
|
|
@@ -69017,11 +69069,20 @@ class Query4 {
|
|
|
69017
69069
|
resolve(true);
|
|
69018
69070
|
}
|
|
69019
69071
|
timer++;
|
|
69020
|
-
if (timer >
|
|
69021
|
-
console.error("
|
|
69072
|
+
if (timer > 5) {
|
|
69073
|
+
console.error("等待请求失败:", req.url, timer);
|
|
69074
|
+
clearInterval(detect);
|
|
69075
|
+
resolve(false);
|
|
69022
69076
|
}
|
|
69023
69077
|
}, 1000);
|
|
69024
69078
|
});
|
|
69079
|
+
if (!res) {
|
|
69080
|
+
return wrapperError4({
|
|
69081
|
+
code: 500,
|
|
69082
|
+
message: "请求取消,可能是因为用户未登录或者token过期",
|
|
69083
|
+
req
|
|
69084
|
+
});
|
|
69085
|
+
}
|
|
69025
69086
|
}
|
|
69026
69087
|
return _adapter(req).then(async (res) => {
|
|
69027
69088
|
try {
|
|
@@ -69034,10 +69095,11 @@ class Query4 {
|
|
|
69034
69095
|
}
|
|
69035
69096
|
return res;
|
|
69036
69097
|
} catch (e) {
|
|
69037
|
-
console.error("
|
|
69098
|
+
console.error("请求在响应后处理时发生错误", e, req);
|
|
69038
69099
|
return wrapperError4({
|
|
69039
69100
|
code: 500,
|
|
69040
|
-
message: "
|
|
69101
|
+
message: "请求在响应后处理时发生错误",
|
|
69102
|
+
req
|
|
69041
69103
|
});
|
|
69042
69104
|
}
|
|
69043
69105
|
});
|
|
@@ -69670,6 +69732,63 @@ var import_fast_glob2 = __toESM(require_out4(), 1);
|
|
|
69670
69732
|
import path12 from "node:path";
|
|
69671
69733
|
import fs14 from "node:fs";
|
|
69672
69734
|
import crypto5 from "node:crypto";
|
|
69735
|
+
|
|
69736
|
+
// node_modules/.pnpm/@kevisual+cnb@0.0.75_dotenv@17.4.1_idb-keyval@6.2.2/node_modules/@kevisual/cnb/src/repo/download.ts
|
|
69737
|
+
var downloadByCNBApi = async (url4, opts) => {
|
|
69738
|
+
const hash3 = opts?.hash;
|
|
69739
|
+
const headers = {
|
|
69740
|
+
Accept: "application/vnd.cnb.api+json",
|
|
69741
|
+
...opts?.token ? { Authorization: `${opts.token}` } : {},
|
|
69742
|
+
...opts?.headers
|
|
69743
|
+
};
|
|
69744
|
+
const res = await fetch(url4, {
|
|
69745
|
+
headers
|
|
69746
|
+
});
|
|
69747
|
+
let resJson;
|
|
69748
|
+
try {
|
|
69749
|
+
resJson = await res.json();
|
|
69750
|
+
} catch (e) {
|
|
69751
|
+
console.error(`下载失败 ${url4}: ${res.statusText}`, e);
|
|
69752
|
+
return { code: res.status, buffer: null };
|
|
69753
|
+
}
|
|
69754
|
+
if (res.ok) {
|
|
69755
|
+
if (resJson.size === 0) {
|
|
69756
|
+
return { code: 200, buffer: Buffer.from("") };
|
|
69757
|
+
}
|
|
69758
|
+
if (resJson.type === "blob" && resJson.encoding === "base64") {
|
|
69759
|
+
if (resJson.content) {
|
|
69760
|
+
if (hash3 && resJson.sha === hash3) {
|
|
69761
|
+
return { code: 304, buffer: null };
|
|
69762
|
+
}
|
|
69763
|
+
const buffer = Buffer.from(resJson.content, "base64");
|
|
69764
|
+
return { code: 200, buffer };
|
|
69765
|
+
}
|
|
69766
|
+
}
|
|
69767
|
+
if (resJson.type === "lfs") {
|
|
69768
|
+
const lfs_download_url = resJson.lfs_download_url;
|
|
69769
|
+
if (lfs_download_url) {
|
|
69770
|
+
const lfsRes = await fetch(lfs_download_url, {
|
|
69771
|
+
headers
|
|
69772
|
+
});
|
|
69773
|
+
if (lfsRes.ok) {
|
|
69774
|
+
const etag = lfsRes.headers.get("ETag");
|
|
69775
|
+
if (hash3 && etag === hash3) {
|
|
69776
|
+
return { code: 304, buffer: null };
|
|
69777
|
+
}
|
|
69778
|
+
const arrayBuffer = await lfsRes.arrayBuffer();
|
|
69779
|
+
return { code: 200, buffer: Buffer.from(arrayBuffer) };
|
|
69780
|
+
}
|
|
69781
|
+
}
|
|
69782
|
+
}
|
|
69783
|
+
console.error(`下载失败 ${url4}: 内容为空`, resJson);
|
|
69784
|
+
return { code: 200, buffer: null };
|
|
69785
|
+
} else {
|
|
69786
|
+
console.error(`下载失败 ${url4}: ${res.statusText}`, resJson);
|
|
69787
|
+
return { code: res.status, buffer: null };
|
|
69788
|
+
}
|
|
69789
|
+
};
|
|
69790
|
+
|
|
69791
|
+
// src/routes/pod/modules/pod.ts
|
|
69673
69792
|
var gitBlobHashContent = (content) => {
|
|
69674
69793
|
const bytes = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
|
69675
69794
|
const header = "blob " + bytes.length + "\x00";
|
|
@@ -69972,32 +70091,6 @@ var downloadResource = async (url4, opts) => {
|
|
|
69972
70091
|
return { code: res.status, buffer: null };
|
|
69973
70092
|
}
|
|
69974
70093
|
};
|
|
69975
|
-
var downloadByCNBApi = async (url4, opts) => {
|
|
69976
|
-
const hash3 = opts?.hash;
|
|
69977
|
-
const res = await fetch(url4, {
|
|
69978
|
-
headers: {
|
|
69979
|
-
Accept: "application/vnd.cnb.api+json",
|
|
69980
|
-
...opts?.headers
|
|
69981
|
-
}
|
|
69982
|
-
});
|
|
69983
|
-
let resJson;
|
|
69984
|
-
try {
|
|
69985
|
-
resJson = await res.json();
|
|
69986
|
-
} catch (e) {
|
|
69987
|
-
console.error(`下载失败 ${url4}: ${res.statusText}`, e);
|
|
69988
|
-
return { code: res.status, buffer: null };
|
|
69989
|
-
}
|
|
69990
|
-
if (res.ok && resJson.type === "blob" && resJson.encoding === "base64" && resJson.content) {
|
|
69991
|
-
if (hash3 && resJson.sha === hash3) {
|
|
69992
|
-
return { code: 304, buffer: null };
|
|
69993
|
-
}
|
|
69994
|
-
const buffer = Buffer.from(resJson.content, "base64");
|
|
69995
|
-
return { code: 200, buffer };
|
|
69996
|
-
} else {
|
|
69997
|
-
console.error(`下载失败 ${url4}: ${res.statusText}`, resJson);
|
|
69998
|
-
return { code: res.status, buffer: null };
|
|
69999
|
-
}
|
|
70000
|
-
};
|
|
70001
70094
|
var getRootIgnore = async (dir) => {
|
|
70002
70095
|
const cnbIgnorePath = path12.join(dir, ".cnbignore");
|
|
70003
70096
|
const gitIgnorePath = path12.join(dir, ".gitignore");
|
|
@@ -70102,7 +70195,8 @@ app.route({
|
|
|
70102
70195
|
key: "fetch",
|
|
70103
70196
|
middleware: ["auth-admin"]
|
|
70104
70197
|
}).define(async (ctx) => {
|
|
70105
|
-
const url4 = "https://api.cnb.cool/
|
|
70198
|
+
const url4 = "https://api.cnb.cool/zxj.im/beads-base/-/git/contents/docs/main-gen.png";
|
|
70199
|
+
const filename = new URL(url4).pathname.split("/").pop() || "downloaded_file";
|
|
70106
70200
|
const CNB_API_KEY = useKey("CNB_API_KEY");
|
|
70107
70201
|
console.log("CNB_API_KEY", CNB_API_KEY);
|
|
70108
70202
|
const res = await downloadByCNBApi(url4, {
|
|
@@ -70111,7 +70205,7 @@ app.route({
|
|
|
70111
70205
|
}
|
|
70112
70206
|
});
|
|
70113
70207
|
if (res.code === 200 && res.buffer) {
|
|
70114
|
-
fs15.writeFileSync(
|
|
70208
|
+
fs15.writeFileSync(`./${filename}`, res.buffer);
|
|
70115
70209
|
} else {
|
|
70116
70210
|
console.error(`下载失败 ${url4}: ${res.code}`);
|
|
70117
70211
|
}
|
|
@@ -71929,9 +72023,14 @@ import crypto6 from "node:crypto";
|
|
|
71929
72023
|
var hashFile = (content) => {
|
|
71930
72024
|
return crypto6.createHash("sha1").update(content).digest("hex");
|
|
71931
72025
|
};
|
|
72026
|
+
var statSync = (filepath) => {
|
|
72027
|
+
const stat = fs24.statSync(filepath);
|
|
72028
|
+
stat.mtimeMs = floorMs(stat.mtimeMs);
|
|
72029
|
+
return stat;
|
|
72030
|
+
};
|
|
71932
72031
|
|
|
71933
72032
|
class MarkLocalManager {
|
|
71934
|
-
filename = "
|
|
72033
|
+
filename = "index";
|
|
71935
72034
|
constructor(options2) {
|
|
71936
72035
|
this.setRoot(options2?.root);
|
|
71937
72036
|
}
|
|
@@ -71951,11 +72050,11 @@ class MarkLocalManager {
|
|
|
71951
72050
|
if (!fileIsExist3(fullPath)) {
|
|
71952
72051
|
return null;
|
|
71953
72052
|
}
|
|
71954
|
-
const stat =
|
|
72053
|
+
const stat = statSync(fullPath);
|
|
71955
72054
|
if (!stat.isDirectory()) {
|
|
71956
72055
|
return null;
|
|
71957
72056
|
}
|
|
71958
|
-
const files = import_fast_glob6.default.sync(`*/${this.filename}`, {
|
|
72057
|
+
const files = import_fast_glob6.default.sync(`*/${this.filename}.{md,mdx}`, {
|
|
71959
72058
|
cwd: fullPath,
|
|
71960
72059
|
ignore: ["node_modules", "**/node_modules/**", ".git", "**/.git/**"],
|
|
71961
72060
|
onlyFiles: true
|
|
@@ -72034,18 +72133,18 @@ class MarkLocalManager {
|
|
|
72034
72133
|
const newFiles = [];
|
|
72035
72134
|
for (const file3 of fileList) {
|
|
72036
72135
|
try {
|
|
72037
|
-
const
|
|
72136
|
+
const statInfo = statSync(path20.resolve(config4.root, file3));
|
|
72038
72137
|
const existFile = hasFiles.find((f) => f.name === file3);
|
|
72039
72138
|
if (!existFile) {
|
|
72040
72139
|
newFiles.push({
|
|
72041
72140
|
name: file3,
|
|
72042
|
-
updatedAt:
|
|
72141
|
+
updatedAt: statInfo.mtimeMs
|
|
72043
72142
|
});
|
|
72044
72143
|
continue;
|
|
72045
72144
|
}
|
|
72046
|
-
let needUpdate = !existFile.updatedAt ||
|
|
72145
|
+
let needUpdate = !existFile.updatedAt || statInfo.mtimeMs > existFile.updatedAt;
|
|
72047
72146
|
if (needUpdate) {
|
|
72048
|
-
existFile.updatedAt =
|
|
72147
|
+
existFile.updatedAt = statInfo.mtimeMs;
|
|
72049
72148
|
const content = fs24.readFileSync(path20.resolve(config4.root, file3), "utf-8");
|
|
72050
72149
|
const matterContent = import_gray_matter.default(content);
|
|
72051
72150
|
existFile.title = matterContent.data?.title || "";
|
|
@@ -72101,7 +72200,7 @@ class MarkLocalManager {
|
|
|
72101
72200
|
}
|
|
72102
72201
|
fs24.writeFileSync(path20.join(markDir, "data.json"), JSON.stringify(mark, null, 2), "utf-8");
|
|
72103
72202
|
if (opts?.stat) {
|
|
72104
|
-
const statInfo =
|
|
72203
|
+
const statInfo = statSync(markPath);
|
|
72105
72204
|
const resources = mark.data?.resources || [];
|
|
72106
72205
|
let resourceSize = 0;
|
|
72107
72206
|
for (let resource of resources) {
|
|
@@ -72109,7 +72208,7 @@ class MarkLocalManager {
|
|
|
72109
72208
|
const filePath = path20.resolve(markDir, resource.name);
|
|
72110
72209
|
console.log(`Calculating size for resource: ${filePath}`);
|
|
72111
72210
|
try {
|
|
72112
|
-
const resStat =
|
|
72211
|
+
const resStat = statSync(filePath);
|
|
72113
72212
|
resourceSize += resStat.size;
|
|
72114
72213
|
} catch (error49) {
|
|
72115
72214
|
console.error(`Failed to get stat for resource: ${resource.name}`, error49);
|
|
@@ -72163,6 +72262,9 @@ var fileIsExist3 = (filepath) => {
|
|
|
72163
72262
|
return false;
|
|
72164
72263
|
}
|
|
72165
72264
|
};
|
|
72265
|
+
var floorMs = (ms) => {
|
|
72266
|
+
return Math.floor(ms / 1000) * 1000;
|
|
72267
|
+
};
|
|
72166
72268
|
|
|
72167
72269
|
// src/command/mark.ts
|
|
72168
72270
|
var markCmd = new Command("mark").alias("m").description("mark相关命令");
|
|
@@ -89083,20 +89185,23 @@ app.route({
|
|
|
89083
89185
|
args: {
|
|
89084
89186
|
dir: exports_external2.string().optional().describe("目录"),
|
|
89085
89187
|
title: exports_external2.string().optional().describe("标题"),
|
|
89086
|
-
id: exports_external2.string().optional().describe("id")
|
|
89188
|
+
id: exports_external2.string().optional().describe("id"),
|
|
89189
|
+
ext: exports_external2.string().optional().describe("mdx或者md,默认为md")
|
|
89087
89190
|
}
|
|
89088
89191
|
}
|
|
89089
89192
|
}).define(async (ctx) => {
|
|
89090
|
-
let { dir, title, id } = ctx.args;
|
|
89193
|
+
let { dir, title, id, ext } = ctx.args;
|
|
89091
89194
|
const markLocalManager2 = new MarkLocalManager({ root: dir });
|
|
89092
89195
|
await markLocalManager2.mount();
|
|
89093
89196
|
const config5 = markLocalManager2.getConfig();
|
|
89094
|
-
const
|
|
89197
|
+
const dayId = "x" + import_dayjs2.default().format("YYYYMMDDHHmm");
|
|
89198
|
+
const dirname2 = `${id || dayId}`;
|
|
89095
89199
|
const dirpath = path25.resolve(config5.root, dirname2);
|
|
89096
89200
|
if (!fileIsExist3(dirpath)) {
|
|
89097
89201
|
fs27.mkdirSync(dirpath, { recursive: true });
|
|
89098
89202
|
}
|
|
89099
|
-
const
|
|
89203
|
+
const filename = markLocalManager2.filename;
|
|
89204
|
+
const filepath = path25.resolve(config5.root, dirname2, `${filename}.${ext || "md"}`);
|
|
89100
89205
|
const data = {
|
|
89101
89206
|
title: title || dirname2,
|
|
89102
89207
|
updateAt: Date.now()
|