@kevisual/cli 0.1.5 → 0.1.6

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.
@@ -16727,7 +16727,7 @@ var require_dist_cjs49 = __commonJS((exports) => {
16727
16727
  exports.retryMiddlewareOptions = retryMiddlewareOptions;
16728
16728
  });
16729
16729
 
16730
- // ../node_modules/.pnpm/@aws-sdk+signature-v4-multi-region@3.991.0/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
16730
+ // ../node_modules/.pnpm/@aws-sdk+signature-v4-multi-region@3.992.0/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
16731
16731
  var require_dist_cjs50 = __commonJS((exports) => {
16732
16732
  var middlewareSdkS3 = require_dist_cjs35();
16733
16733
  var signatureV4 = require_dist_cjs19();
@@ -16823,7 +16823,7 @@ var require_dist_cjs50 = __commonJS((exports) => {
16823
16823
  exports.signatureV4CrtContainer = signatureV4CrtContainer;
16824
16824
  });
16825
16825
 
16826
- // ../node_modules/.pnpm/@aws-sdk+util-endpoints@3.991.0/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js
16826
+ // ../node_modules/.pnpm/@aws-sdk+util-endpoints@3.992.0/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js
16827
16827
  var require_dist_cjs51 = __commonJS((exports) => {
16828
16828
  var utilEndpoints = require_dist_cjs36();
16829
16829
  var urlParser = require_dist_cjs38();
@@ -17236,7 +17236,7 @@ var require_dist_cjs51 = __commonJS((exports) => {
17236
17236
  exports.useDefaultPartitionInfo = useDefaultPartitionInfo;
17237
17237
  });
17238
17238
 
17239
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/ruleset.js
17239
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/ruleset.js
17240
17240
  var require_ruleset = __commonJS((exports) => {
17241
17241
  Object.defineProperty(exports, "__esModule", { value: true });
17242
17242
  exports.ruleSet = undefined;
@@ -17435,7 +17435,7 @@ var require_ruleset = __commonJS((exports) => {
17435
17435
  exports.ruleSet = _data;
17436
17436
  });
17437
17437
 
17438
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/endpointResolver.js
17438
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/endpointResolver.js
17439
17439
  var require_endpointResolver = __commonJS((exports) => {
17440
17440
  Object.defineProperty(exports, "__esModule", { value: true });
17441
17441
  exports.defaultEndpointResolver = undefined;
@@ -17471,7 +17471,7 @@ var require_endpointResolver = __commonJS((exports) => {
17471
17471
  util_endpoints_2.customEndpointFunctions.aws = util_endpoints_1.awsEndpointFunctions;
17472
17472
  });
17473
17473
 
17474
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/auth/httpAuthSchemeProvider.js
17474
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/auth/httpAuthSchemeProvider.js
17475
17475
  var require_httpAuthSchemeProvider = __commonJS((exports) => {
17476
17476
  Object.defineProperty(exports, "__esModule", { value: true });
17477
17477
  exports.resolveHttpAuthSchemeConfig = exports.defaultS3HttpAuthSchemeProvider = exports.defaultS3HttpAuthSchemeParametersProvider = undefined;
@@ -17597,7 +17597,7 @@ var require_httpAuthSchemeProvider = __commonJS((exports) => {
17597
17597
  exports.resolveHttpAuthSchemeConfig = resolveHttpAuthSchemeConfig;
17598
17598
  });
17599
17599
 
17600
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/models/S3ServiceException.js
17600
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/models/S3ServiceException.js
17601
17601
  var require_S3ServiceException = __commonJS((exports) => {
17602
17602
  Object.defineProperty(exports, "__esModule", { value: true });
17603
17603
  exports.S3ServiceException = exports.__ServiceException = undefined;
@@ -17615,7 +17615,7 @@ var require_S3ServiceException = __commonJS((exports) => {
17615
17615
  exports.S3ServiceException = S3ServiceException;
17616
17616
  });
17617
17617
 
17618
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/models/errors.js
17618
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/models/errors.js
17619
17619
  var require_errors = __commonJS((exports) => {
17620
17620
  Object.defineProperty(exports, "__esModule", { value: true });
17621
17621
  exports.ObjectAlreadyInActiveTierError = exports.IdempotencyParameterMismatch = exports.TooManyParts = exports.InvalidWriteOffset = exports.InvalidRequest = exports.EncryptionTypeMismatch = exports.NotFound = exports.NoSuchKey = exports.InvalidObjectState = exports.NoSuchBucket = exports.BucketAlreadyOwnedByYou = exports.BucketAlreadyExists = exports.ObjectNotInActiveTierError = exports.AccessDenied = exports.NoSuchUpload = undefined;
@@ -17836,7 +17836,7 @@ var require_errors = __commonJS((exports) => {
17836
17836
  exports.ObjectAlreadyInActiveTierError = ObjectAlreadyInActiveTierError;
17837
17837
  });
17838
17838
 
17839
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/schemas/schemas_0.js
17839
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/schemas/schemas_0.js
17840
17840
  var require_schemas_0 = __commonJS((exports) => {
17841
17841
  Object.defineProperty(exports, "__esModule", { value: true });
17842
17842
  exports.CreateBucketMetadataTableConfigurationRequest$ = exports.CreateBucketMetadataConfigurationRequest$ = exports.CreateBucketConfiguration$ = exports.CORSRule$ = exports.CORSConfiguration$ = exports.CopyPartResult$ = exports.CopyObjectResult$ = exports.CopyObjectRequest$ = exports.CopyObjectOutput$ = exports.ContinuationEvent$ = exports.Condition$ = exports.CompleteMultipartUploadRequest$ = exports.CompleteMultipartUploadOutput$ = exports.CompletedPart$ = exports.CompletedMultipartUpload$ = exports.CommonPrefix$ = exports.Checksum$ = exports.BucketLoggingStatus$ = exports.BucketLifecycleConfiguration$ = exports.BucketInfo$ = exports.Bucket$ = exports.BlockedEncryptionTypes$ = exports.AnalyticsS3BucketDestination$ = exports.AnalyticsExportDestination$ = exports.AnalyticsConfiguration$ = exports.AnalyticsAndOperator$ = exports.AccessControlTranslation$ = exports.AccessControlPolicy$ = exports.AccelerateConfiguration$ = exports.AbortMultipartUploadRequest$ = exports.AbortMultipartUploadOutput$ = exports.AbortIncompleteMultipartUpload$ = exports.AbacStatus$ = exports.errorTypeRegistries = exports.TooManyParts$ = exports.ObjectNotInActiveTierError$ = exports.ObjectAlreadyInActiveTierError$ = exports.NotFound$ = exports.NoSuchUpload$ = exports.NoSuchKey$ = exports.NoSuchBucket$ = exports.InvalidWriteOffset$ = exports.InvalidRequest$ = exports.InvalidObjectState$ = exports.IdempotencyParameterMismatch$ = exports.EncryptionTypeMismatch$ = exports.BucketAlreadyOwnedByYou$ = exports.BucketAlreadyExists$ = exports.AccessDenied$ = exports.S3ServiceException$ = undefined;
@@ -23030,12 +23030,12 @@ var require_schemas_0 = __commonJS((exports) => {
23030
23030
  ];
23031
23031
  });
23032
23032
 
23033
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/package.json
23033
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/package.json
23034
23034
  var require_package3 = __commonJS((exports, module) => {
23035
23035
  module.exports = {
23036
23036
  name: "@aws-sdk/client-s3",
23037
23037
  description: "AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native",
23038
- version: "3.991.0",
23038
+ version: "3.992.0",
23039
23039
  scripts: {
23040
23040
  build: "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
23041
23041
  "build:cjs": "node ../../scripts/compilation/inline client-s3",
@@ -23077,9 +23077,9 @@ var require_package3 = __commonJS((exports, module) => {
23077
23077
  "@aws-sdk/middleware-ssec": "^3.972.3",
23078
23078
  "@aws-sdk/middleware-user-agent": "^3.972.10",
23079
23079
  "@aws-sdk/region-config-resolver": "^3.972.3",
23080
- "@aws-sdk/signature-v4-multi-region": "3.991.0",
23080
+ "@aws-sdk/signature-v4-multi-region": "3.992.0",
23081
23081
  "@aws-sdk/types": "^3.973.1",
23082
- "@aws-sdk/util-endpoints": "3.991.0",
23082
+ "@aws-sdk/util-endpoints": "3.992.0",
23083
23083
  "@aws-sdk/util-user-agent-browser": "^3.972.3",
23084
23084
  "@aws-sdk/util-user-agent-node": "^3.972.8",
23085
23085
  "@smithy/config-resolver": "^4.4.6",
@@ -23118,7 +23118,7 @@ var require_package3 = __commonJS((exports, module) => {
23118
23118
  tslib: "^2.6.2"
23119
23119
  },
23120
23120
  devDependencies: {
23121
- "@aws-sdk/signature-v4-crt": "3.991.0",
23121
+ "@aws-sdk/signature-v4-crt": "3.992.0",
23122
23122
  "@tsconfig/node20": "20.1.8",
23123
23123
  "@types/node": "^20.14.8",
23124
23124
  concurrently: "7.0.0",
@@ -31452,7 +31452,7 @@ var require_dist_cjs72 = __commonJS((exports) => {
31452
31452
  exports.readableStreamHasher = readableStreamHasher;
31453
31453
  });
31454
31454
 
31455
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
31455
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
31456
31456
  var require_runtimeConfig_shared5 = __commonJS((exports) => {
31457
31457
  Object.defineProperty(exports, "__esModule", { value: true });
31458
31458
  exports.getRuntimeConfig = undefined;
@@ -31511,7 +31511,7 @@ var require_runtimeConfig_shared5 = __commonJS((exports) => {
31511
31511
  exports.getRuntimeConfig = getRuntimeConfig;
31512
31512
  });
31513
31513
 
31514
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
31514
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
31515
31515
  var require_runtimeConfig5 = __commonJS((exports) => {
31516
31516
  Object.defineProperty(exports, "__esModule", { value: true });
31517
31517
  exports.getRuntimeConfig = undefined;
@@ -31848,7 +31848,7 @@ var require_dist_cjs75 = __commonJS((exports) => {
31848
31848
  exports.waiterServiceDefaults = waiterServiceDefaults;
31849
31849
  });
31850
31850
 
31851
- // ../node_modules/.pnpm/@aws-sdk+client-s3@3.991.0/node_modules/@aws-sdk/client-s3/dist-cjs/index.js
31851
+ // ../node_modules/.pnpm/@aws-sdk+client-s3@3.992.0/node_modules/@aws-sdk/client-s3/dist-cjs/index.js
31852
31852
  var require_dist_cjs76 = __commonJS((exports) => {
31853
31853
  var middlewareExpectContinue = require_dist_cjs3();
31854
31854
  var middlewareFlexibleChecksums = require_dist_cjs29();
@@ -60208,7 +60208,8 @@ var require_commander = __commonJS((exports) => {
60208
60208
  exports.InvalidOptionArgumentError = InvalidArgumentError;
60209
60209
  });
60210
60210
 
60211
- // ../node_modules/.pnpm/@kevisual+context@0.0.6/node_modules/@kevisual/context/dist/app.js
60211
+ // ../node_modules/.pnpm/@kevisual+context@0.0.8/node_modules/@kevisual/context/dist/app.js
60212
+ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
60212
60213
  function getDefaultExportFromCjs(x) {
60213
60214
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
60214
60215
  }
@@ -60672,7 +60673,7 @@ var useEnv = (initEnv, initKey = "config", isOverwrite) => {
60672
60673
  }
60673
60674
  return gt[initKey];
60674
60675
  };
60675
- var useEnvKey = (key, init, initKey = "config") => {
60676
+ var useEnvKey = (key, init, initKey = "config", opts = {}) => {
60676
60677
  const _env = useEnv({}, initKey);
60677
60678
  if (key && typeof _env[key] !== "undefined") {
60678
60679
  return _env[key];
@@ -60698,12 +60699,13 @@ var useEnvKey = (key, init, initKey = "config") => {
60698
60699
  const voidFn = async () => {
60699
60700
  return _env[key];
60700
60701
  };
60702
+ const timeout = opts.timeout || 5 * 60 * 1000;
60701
60703
  const checkFn = async () => {
60702
60704
  const loadRes = await baseLoad.load(voidFn, {
60703
60705
  key,
60704
60706
  isReRun: true,
60705
60707
  checkSuccess: () => _env[key],
60706
- timeout: 5 * 60 * 1000,
60708
+ timeout,
60707
60709
  interval: 1000
60708
60710
  });
60709
60711
  if (loadRes.code !== 200) {
@@ -60719,27 +60721,28 @@ var useEnvKey = (key, init, initKey = "config") => {
60719
60721
  };
60720
60722
  var useEnvKeyNew = (key, initKey = "config", opts) => {
60721
60723
  const _env = useEnv({}, initKey);
60724
+ const timeout = opts?.timeout;
60722
60725
  if (key) {
60723
60726
  delete _env[key];
60724
60727
  }
60725
60728
  if (opts?.getNew && opts.init) {
60726
- return useEnvKey(key, opts.init, initKey);
60729
+ return useEnvKey(key, opts.init, initKey, { timeout });
60727
60730
  } else if (opts?.getNew) {
60728
- return useEnvKey(key, null, initKey);
60731
+ return useEnvKey(key, null, initKey, { timeout });
60729
60732
  }
60730
60733
  };
60731
- var useContextKey = (key, init, isNew) => {
60732
- if (isNew) {
60733
- return useEnvKeyNew(key, "context", { getNew: true, init });
60734
+ var useContextKey = (key, init, opts) => {
60735
+ if (opts?.isNew) {
60736
+ return useEnvKeyNew(key, "context", { getNew: true, init, ...opts });
60734
60737
  }
60735
- return useEnvKey(key, init, "context");
60738
+ return useEnvKey(key, init, "context", opts);
60736
60739
  };
60737
60740
  var use = useContextKey;
60738
- var useConfigKey = (key, init, isNew) => {
60739
- if (isNew) {
60740
- return useEnvKeyNew(key, "config", { getNew: true, init });
60741
+ var useConfigKey = (key, init, opts) => {
60742
+ if (opts?.isNew) {
60743
+ return useEnvKeyNew(key, "config", { getNew: true, init, ...opts });
60741
60744
  }
60742
- return useEnvKey(key, init, "config");
60745
+ return useEnvKey(key, init, "config", opts);
60743
60746
  };
60744
60747
 
60745
60748
  class InitEnv {
@@ -60759,7 +60762,7 @@ class InitEnv {
60759
60762
  }
60760
60763
  InitEnv.init();
60761
60764
 
60762
- // ../node_modules/.pnpm/@kevisual+router@0.0.74/node_modules/@kevisual/router/dist/router.js
60765
+ // ../node_modules/.pnpm/@kevisual+router@0.0.80/node_modules/@kevisual/router/dist/router.js
60763
60766
  import { createRequire as createRequire2 } from "node:module";
60764
60767
  import { webcrypto as crypto2 } from "node:crypto";
60765
60768
  import http from "node:http";
@@ -77423,11 +77426,101 @@ var nanoid3 = customAlphabet("abcdefghijklmnopqrstuvwxyz", 16);
77423
77426
  var randomId = (length = 8, affix = "") => {
77424
77427
  return affix + nanoid3(length);
77425
77428
  };
77429
+ var extractArgs = (args) => {
77430
+ if (args && typeof args === "object" && typeof args.shape === "object") {
77431
+ return args.shape;
77432
+ }
77433
+ return args || {};
77434
+ };
77435
+ var toJSONSchema2 = (args, opts) => {
77436
+ const mergeObject = opts?.mergeObject ?? false;
77437
+ if (!args)
77438
+ return {};
77439
+ const _override = ({ jsonSchema, path, zodSchema }) => {
77440
+ if (Array.isArray(path) && path.length > 0) {
77441
+ return;
77442
+ }
77443
+ const isOptional = zodSchema.isOptional?.();
77444
+ if (isOptional) {
77445
+ jsonSchema.optional = true;
77446
+ }
77447
+ };
77448
+ const isError = (keys2) => {
77449
+ const errorKeys = ["toJSONSchema", "def", "type", "parse"];
77450
+ const hasErrorKeys = errorKeys.every((key) => keys2.includes(key));
77451
+ return hasErrorKeys;
77452
+ };
77453
+ const override = opts?.override || _override;
77454
+ if (mergeObject) {
77455
+ if (typeof args === "object" && typeof args.toJSONSchema === "function") {
77456
+ return args.toJSONSchema();
77457
+ }
77458
+ if (isError(Object.keys(args))) {
77459
+ return {};
77460
+ }
77461
+ const schema = exports_external.object(args);
77462
+ return schema.toJSONSchema();
77463
+ }
77464
+ args = extractArgs(args);
77465
+ let keys = Object.keys(args);
77466
+ if (isError(keys)) {
77467
+ console.error(`[toJSONSchema error]: 解析到的 schema 可能不正确,包含了zod默认的value的schema. 请检查输入的 schema 是否正确。`);
77468
+ args = {};
77469
+ keys = [];
77470
+ }
77471
+ if (mergeObject) {}
77472
+ let newArgs = {};
77473
+ for (let key of keys) {
77474
+ const item = args[key];
77475
+ if (item && typeof item === "object" && typeof item.toJSONSchema === "function") {
77476
+ newArgs[key] = item.toJSONSchema({ override });
77477
+ } else {
77478
+ newArgs[key] = args[key];
77479
+ }
77480
+ }
77481
+ return newArgs;
77482
+ };
77483
+ var fromJSONSchema2 = (args = {}, opts) => {
77484
+ let resultArgs = null;
77485
+ const mergeObject = opts?.mergeObject ?? false;
77486
+ if (args["$schema"] || args.type === "object" && args.properties && typeof args.properties === "object") {
77487
+ const objectSchema = exports_external.fromJSONSchema(args);
77488
+ const extract = extractArgs(objectSchema);
77489
+ const keys = Object.keys(extract);
77490
+ const newArgs = {};
77491
+ for (let key of keys) {
77492
+ newArgs[key] = extract[key];
77493
+ }
77494
+ resultArgs = newArgs;
77495
+ }
77496
+ if (!resultArgs) {
77497
+ const keys = Object.keys(args);
77498
+ const newArgs = {};
77499
+ for (let key of keys) {
77500
+ const item = args[key];
77501
+ newArgs[key] = exports_external.fromJSONSchema(item);
77502
+ if (item.optional) {
77503
+ newArgs[key] = newArgs[key].optional();
77504
+ }
77505
+ }
77506
+ resultArgs = newArgs;
77507
+ }
77508
+ if (mergeObject) {
77509
+ resultArgs = exports_external.object(resultArgs);
77510
+ }
77511
+ return resultArgs;
77512
+ };
77426
77513
  var pickValue = ["path", "key", "id", "description", "type", "middleware", "metadata"];
77427
77514
  var tool = {
77428
77515
  schema: exports_external
77429
77516
  };
77430
77517
  var createSkill = (skill) => {
77518
+ if (skill.tags) {
77519
+ const hasOpencode = skill.tags.includes("opencode");
77520
+ if (!hasOpencode) {
77521
+ skill.tags.push("opencode");
77522
+ }
77523
+ }
77431
77524
  return {
77432
77525
  args: {},
77433
77526
  ...skill
@@ -77444,7 +77537,6 @@ class Route {
77444
77537
  metadata;
77445
77538
  middleware;
77446
77539
  type = "route";
77447
- data;
77448
77540
  isDebug;
77449
77541
  constructor(path = "", key = "", opts) {
77450
77542
  if (!path) {
@@ -77536,45 +77628,19 @@ class Route {
77536
77628
  addTo(router, opts) {
77537
77629
  router.add(this, opts);
77538
77630
  }
77539
- setData(data) {
77540
- this.data = data;
77541
- return this;
77542
- }
77543
77631
  throw(...args) {
77544
77632
  throw new CustomError(...args);
77545
77633
  }
77546
77634
  }
77547
- var toJSONSchema2 = (route) => {
77635
+ var toJSONSchemaRoute = (route) => {
77548
77636
  const pickValues = pick(route, pickValue);
77549
77637
  if (pickValues?.metadata?.args) {
77550
- const args = pickValues.metadata.args;
77551
- const keys = Object.keys(args);
77552
- const newArgs = {};
77553
- for (let key of keys) {
77554
- const item = args[key];
77555
- if (item && typeof item === "object" && typeof item.toJSONSchema === "function") {
77556
- newArgs[key] = item.toJSONSchema();
77557
- } else {
77558
- newArgs[key] = args[key];
77559
- }
77560
- }
77561
- pickValues.metadata.args = newArgs;
77638
+ pickValues.metadata.args = toJSONSchema3(pickValues?.metadata?.args, { mergeObject: false });
77562
77639
  }
77563
77640
  return pickValues;
77564
77641
  };
77565
- var fromJSONSchema2 = (route) => {
77566
- const args = route?.metadata?.args;
77567
- if (!args)
77568
- return route;
77569
- const keys = Object.keys(args);
77570
- const newArgs = {};
77571
- for (let key of keys) {
77572
- const item = args[key];
77573
- newArgs[key] = exports_external.fromJSONSchema(item);
77574
- }
77575
- route.metadata.args = newArgs;
77576
- return route;
77577
- };
77642
+ var toJSONSchema3 = toJSONSchema2;
77643
+ var fromJSONSchema3 = fromJSONSchema2;
77578
77644
 
77579
77645
  class QueryRouter {
77580
77646
  appId = "";
@@ -77828,20 +77894,6 @@ class QueryRouter {
77828
77894
  getList(filter) {
77829
77895
  return this.routes.filter(filter || (() => true)).map((r) => {
77830
77896
  const pickValues = pick(r, pickValue);
77831
- if (pickValues?.metadata?.args) {
77832
- const args = pickValues.metadata.args;
77833
- const keys = Object.keys(args);
77834
- const newArgs = {};
77835
- for (let key of keys) {
77836
- const item = args[key];
77837
- if (item && typeof item === "object" && typeof item.toJSONSchema === "function") {
77838
- newArgs[key] = item.toJSONSchema();
77839
- } else {
77840
- newArgs[key] = args[key];
77841
- }
77842
- }
77843
- pickValues.metadata.args = newArgs;
77844
- }
77845
77897
  return pickValues;
77846
77898
  });
77847
77899
  }
@@ -77913,7 +77965,7 @@ class QueryRouter {
77913
77965
  ctx.body = {
77914
77966
  list: list.map((item) => {
77915
77967
  const route = pick(item, ["id", "path", "key", "description", "middleware", "metadata"]);
77916
- return toJSONSchema2(route);
77968
+ return toJSONSchemaRoute(route);
77917
77969
  }),
77918
77970
  isUser
77919
77971
  };
@@ -77929,8 +77981,8 @@ class QueryRouter {
77929
77981
  }
77930
77982
  return listenProcess({ app: this, params, ...opts });
77931
77983
  }
77932
- toJSONSchema = toJSONSchema2;
77933
- fromJSONSchema = fromJSONSchema2;
77984
+ toJSONSchema = toJSONSchema3;
77985
+ fromJSONSchema = fromJSONSchema3;
77934
77986
  }
77935
77987
  var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
77936
77988
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
@@ -78873,7 +78925,7 @@ class App extends QueryRouter {
78873
78925
  }
78874
78926
  }
78875
78927
 
78876
- // ../node_modules/.pnpm/@kevisual+router@0.0.74/node_modules/@kevisual/router/dist/router-simple.js
78928
+ // ../node_modules/.pnpm/@kevisual+router@0.0.80/node_modules/@kevisual/router/dist/router-simple.js
78877
78929
  import url3 from "node:url";
78878
78930
  var __create3 = Object.create;
78879
78931
  var __getProtoOf3 = Object.getPrototypeOf;
@@ -79244,7 +79296,7 @@ var require_dist = __commonJS3((exports) => {
79244
79296
  });
79245
79297
  var import_path_to_regexp = __toESM3(require_dist(), 1);
79246
79298
  var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
79247
- var isBrowser2 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
79299
+ var isBrowser3 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
79248
79300
  var isDeno2 = typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string";
79249
79301
  var isBun2 = typeof Bun !== "undefined" && typeof Bun.version === "string";
79250
79302
  var parseBody2 = async (req) => {
@@ -80287,7 +80339,7 @@ var useFileStore = (str, opts) => {
80287
80339
  }
80288
80340
  return filePath;
80289
80341
  };
80290
- var isBrowser3 = typeof window !== "undefined" && typeof window.document !== "undefined";
80342
+ var isBrowser5 = typeof window !== "undefined" && typeof window.document !== "undefined";
80291
80343
  function getDefaultExportFromCjs2(x) {
80292
80344
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
80293
80345
  }
@@ -81287,7 +81339,7 @@ function omit2(obj, keys) {
81287
81339
  return result;
81288
81340
  }
81289
81341
  // ../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/predicate/isBrowser.mjs
81290
- function isBrowser4() {
81342
+ function isBrowser6() {
81291
81343
  return typeof window !== "undefined" && window?.document != null;
81292
81344
  }
81293
81345
  // ../node_modules/.pnpm/@kevisual+oss@0.0.19/node_modules/@kevisual/oss/src/util/hash.ts
@@ -89819,23 +89871,17 @@ var getEnvToken = () => {
89819
89871
  return envTokne;
89820
89872
  };
89821
89873
 
89822
- // ../node_modules/.pnpm/@kevisual+query@0.0.44/node_modules/@kevisual/query/dist/query-browser.js
89874
+ // ../node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query-browser.js
89823
89875
  var isTextForContentType = (contentType) => {
89824
89876
  if (!contentType)
89825
89877
  return false;
89826
- const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
89878
+ const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
89827
89879
  return textTypes.some((type) => contentType.includes(type));
89828
89880
  };
89829
89881
  var adapter = async (opts = {}, overloadOpts) => {
89830
89882
  const controller = new AbortController;
89831
89883
  const signal = controller.signal;
89832
89884
  const isPostFile = opts.isPostFile || false;
89833
- let responseType = opts.responseType || "json";
89834
- if (opts.isBlob) {
89835
- responseType = "blob";
89836
- } else if (opts.isText) {
89837
- responseType = "text";
89838
- }
89839
89885
  const timeout = opts.timeout || 60000 * 3;
89840
89886
  const timer = setTimeout(() => {
89841
89887
  controller.abort();
@@ -89894,21 +89940,31 @@ var adapter = async (opts = {}, overloadOpts) => {
89894
89940
  headers
89895
89941
  }).then(async (response) => {
89896
89942
  const contentType = response.headers.get("Content-Type");
89897
- if (responseType === "blob") {
89898
- return await response.blob();
89899
- }
89900
- const isText = responseType === "text";
89901
89943
  const isJson = contentType && contentType.includes("application/json");
89902
- if (isJson && !isText) {
89903
- return await response.json();
89944
+ const isSuccess = response.ok;
89945
+ if (isJson) {
89946
+ const json2 = await response.json();
89947
+ if (json2?.code) {
89948
+ return json2;
89949
+ }
89950
+ return {
89951
+ code: isSuccess ? 200 : response.status,
89952
+ status: response.status,
89953
+ data: json2
89954
+ };
89904
89955
  } else if (isTextForContentType(contentType)) {
89905
89956
  return {
89906
- code: response.status,
89957
+ code: isSuccess ? 200 : response.status,
89907
89958
  status: response.status,
89908
89959
  data: await response.text()
89909
89960
  };
89910
89961
  } else {
89911
- return response;
89962
+ return {
89963
+ code: isSuccess ? 200 : response.status,
89964
+ status: response.status,
89965
+ data: "非文本非JSON响应, 请手动处理response。",
89966
+ response
89967
+ };
89912
89968
  }
89913
89969
  }).catch((err) => {
89914
89970
  if (err.name === "AbortError") {
@@ -89928,16 +89984,14 @@ var adapter = async (opts = {}, overloadOpts) => {
89928
89984
  var wrapperError = ({ code, message }) => {
89929
89985
  const result = {
89930
89986
  code: code || 500,
89931
- success: false,
89932
- message: message || "api request error",
89933
- showError: (fn) => {},
89934
- noMsg: true
89987
+ message: message || "请求错误"
89935
89988
  };
89936
89989
  return result;
89937
89990
  };
89938
89991
 
89939
89992
  class Query {
89940
89993
  adapter;
89994
+ baseURL;
89941
89995
  url;
89942
89996
  beforeRequest;
89943
89997
  afterResponse;
@@ -89945,11 +89999,20 @@ class Query {
89945
89999
  timeout;
89946
90000
  stop;
89947
90001
  qws;
89948
- isClient = false;
90002
+ tokenName;
90003
+ storage;
90004
+ token;
89949
90005
  constructor(opts) {
89950
90006
  this.adapter = opts?.adapter || adapter;
90007
+ this.tokenName = opts?.tokenName || "token";
90008
+ this.storage = opts?.storage || globalThis?.localStorage;
89951
90009
  const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
89952
90010
  this.url = opts?.url || defaultURL;
90011
+ if (this.url.startsWith("http")) {
90012
+ const urlObj = new URL(this.url);
90013
+ this.baseURL = urlObj.origin;
90014
+ }
90015
+ this.baseURL = opts?.baseURL || this.baseURL;
89953
90016
  this.headers = opts?.headers || {
89954
90017
  "Content-Type": "application/json"
89955
90018
  };
@@ -89958,7 +90021,7 @@ class Query {
89958
90021
  this.beforeRequest = opts.beforeRequest;
89959
90022
  } else {
89960
90023
  this.beforeRequest = async (opts2) => {
89961
- const token = globalThis?.localStorage?.getItem("token");
90024
+ const token = this.token || this.storage?.getItem?.(this.tokenName);
89962
90025
  if (token) {
89963
90026
  opts2.headers = {
89964
90027
  ...opts2.headers,
@@ -89980,7 +90043,6 @@ class Query {
89980
90043
  }
89981
90044
  async post(body, options) {
89982
90045
  const url4 = options?.url || this.url;
89983
- console.log("query post", url4, body, options);
89984
90046
  const { headers, adapter: adapter2, beforeRequest, afterResponse, timeout, ...rest } = options || {};
89985
90047
  const _headers = { ...this.headers, ...headers };
89986
90048
  const _adapter = adapter2 || this.adapter;
@@ -89994,13 +90056,20 @@ class Query {
89994
90056
  timeout: _timeout,
89995
90057
  ...rest
89996
90058
  };
90059
+ const isStartsWithHttp = req.url.startsWith("http");
90060
+ if (!isStartsWithHttp) {
90061
+ if (this.baseURL) {
90062
+ const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
90063
+ req.url = baseURL + req.url;
90064
+ }
90065
+ }
89997
90066
  try {
89998
90067
  if (_beforeRequest) {
89999
90068
  const res = await _beforeRequest(req);
90000
90069
  if (res === false) {
90001
90070
  return wrapperError({
90002
90071
  code: 500,
90003
- message: "request is cancel",
90072
+ message: "请求取消",
90004
90073
  req
90005
90074
  });
90006
90075
  }
@@ -90009,13 +90078,13 @@ class Query {
90009
90078
  console.error("request beforeFn error", e, req);
90010
90079
  return wrapperError({
90011
90080
  code: 500,
90012
- message: "api request beforeFn error",
90081
+ message: "请求在请求前处理时发生错误",
90013
90082
  req
90014
90083
  });
90015
90084
  }
90016
90085
  if (this.stop && !options?.noStop) {
90017
90086
  const that = this;
90018
- await new Promise((resolve) => {
90087
+ const res = await new Promise((resolve) => {
90019
90088
  let timer = 0;
90020
90089
  const detect = setInterval(() => {
90021
90090
  if (!that.stop) {
@@ -90023,11 +90092,20 @@ class Query {
90023
90092
  resolve(true);
90024
90093
  }
90025
90094
  timer++;
90026
- if (timer > 30) {
90027
- console.error("request stop: timeout", req.url, timer);
90095
+ if (timer > 5) {
90096
+ console.error("等待请求失败:", req.url, timer);
90097
+ clearInterval(detect);
90098
+ resolve(false);
90028
90099
  }
90029
90100
  }, 1000);
90030
90101
  });
90102
+ if (!res) {
90103
+ return wrapperError({
90104
+ code: 500,
90105
+ message: "请求取消,可能是因为用户未登录或者token过期",
90106
+ req
90107
+ });
90108
+ }
90031
90109
  }
90032
90110
  return _adapter(req).then(async (res) => {
90033
90111
  try {
@@ -90040,10 +90118,10 @@ class Query {
90040
90118
  }
90041
90119
  return res;
90042
90120
  } catch (e) {
90043
- console.error("request afterFn error", e, req);
90121
+ console.error("请求在响应后处理时发生错误", e, req);
90044
90122
  return wrapperError({
90045
90123
  code: 500,
90046
- message: "api request afterFn error",
90124
+ message: "请求在响应后处理时发生错误",
90047
90125
  req
90048
90126
  });
90049
90127
  }
@@ -90081,7 +90159,7 @@ class Query {
90081
90159
  }
90082
90160
  }
90083
90161
 
90084
- // ../node_modules/.pnpm/@kevisual+router@0.0.74/node_modules/@kevisual/router/dist/router-browser.js
90162
+ // ../node_modules/.pnpm/@kevisual+router@0.0.80/node_modules/@kevisual/router/dist/router-browser.js
90085
90163
  var __create5 = Object.create;
90086
90164
  var __getProtoOf5 = Object.getPrototypeOf;
90087
90165
  var __defProp5 = Object.defineProperty;
@@ -90309,7 +90387,7 @@ __export3(exports_external2, {
90309
90387
  transform: () => transform2,
90310
90388
  toUpperCase: () => _toUpperCase2,
90311
90389
  toLowerCase: () => _toLowerCase2,
90312
- toJSONSchema: () => toJSONSchema3,
90390
+ toJSONSchema: () => toJSONSchema4,
90313
90391
  templateLiteral: () => templateLiteral2,
90314
90392
  symbol: () => symbol2,
90315
90393
  superRefine: () => superRefine2,
@@ -90402,7 +90480,7 @@ __export3(exports_external2, {
90402
90480
  globalRegistry: () => globalRegistry2,
90403
90481
  getErrorMap: () => getErrorMap2,
90404
90482
  function: () => _function2,
90405
- fromJSONSchema: () => fromJSONSchema3,
90483
+ fromJSONSchema: () => fromJSONSchema4,
90406
90484
  formatError: () => formatError2,
90407
90485
  float64: () => float642,
90408
90486
  float32: () => float322,
@@ -90529,7 +90607,7 @@ __export3(exports_core22, {
90529
90607
  version: () => version2,
90530
90608
  util: () => exports_util2,
90531
90609
  treeifyError: () => treeifyError2,
90532
- toJSONSchema: () => toJSONSchema3,
90610
+ toJSONSchema: () => toJSONSchema4,
90533
90611
  toDotPath: () => toDotPath2,
90534
90612
  safeParseAsync: () => safeParseAsync3,
90535
90613
  safeParse: () => safeParse3,
@@ -101766,7 +101844,7 @@ var allProcessors2 = {
101766
101844
  optional: optionalProcessor2,
101767
101845
  lazy: lazyProcessor2
101768
101846
  };
101769
- function toJSONSchema3(input, params) {
101847
+ function toJSONSchema4(input, params) {
101770
101848
  if ("_idmap" in input) {
101771
101849
  const registry22 = input;
101772
101850
  const ctx2 = initializeContext2({ ...params, processors: allProcessors2 });
@@ -103685,7 +103763,7 @@ function convertSchema2(schema, ctx) {
103685
103763
  }
103686
103764
  return baseSchema;
103687
103765
  }
103688
- function fromJSONSchema3(schema, params) {
103766
+ function fromJSONSchema4(schema, params) {
103689
103767
  if (typeof schema === "boolean") {
103690
103768
  return schema ? z2.any() : z2.never();
103691
103769
  }
@@ -104088,7 +104166,7 @@ function filter(data, query) {
104088
104166
  return executor.execute(ast, data);
104089
104167
  }
104090
104168
 
104091
- // ../node_modules/.pnpm/@kevisual+api@0.0.51_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
104169
+ // ../node_modules/.pnpm/@kevisual+api@0.0.52_@types+react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-proxy/router-api-proxy.ts
104092
104170
  var initApi = async (opts) => {
104093
104171
  const router = opts?.router;
104094
104172
  const item = opts?.item;
@@ -104109,7 +104187,7 @@ var initApi = async (opts) => {
104109
104187
  _list = _list.filter((i) => !excludeIds.includes(i.id));
104110
104188
  }
104111
104189
  }
104112
- const _isBrowser = isBrowser4();
104190
+ const _isBrowser = isBrowser6();
104113
104191
  for (const r of _list) {
104114
104192
  if (r.path || r.id) {
104115
104193
  _isBrowser && console.debug(`注册路由: [${r.path}] ${r?.key}`, "API");
@@ -104125,7 +104203,7 @@ var initApi = async (opts) => {
104125
104203
  metadata
104126
104204
  }).define(async (ctx) => {
104127
104205
  const msg = { ...ctx.query };
104128
- if (msg.token === undefined && token !== undefined) {
104206
+ if (msg.token === undefined && token !== undefined && !_isBrowser) {
104129
104207
  msg.token = token;
104130
104208
  }
104131
104209
  const res2 = await query.post({ path: r.path, key: r.key, ...msg });
@@ -104516,7 +104594,7 @@ __export(exports_external3, {
104516
104594
  transform: () => transform3,
104517
104595
  toUpperCase: () => _toUpperCase3,
104518
104596
  toLowerCase: () => _toLowerCase3,
104519
- toJSONSchema: () => toJSONSchema6,
104597
+ toJSONSchema: () => toJSONSchema7,
104520
104598
  templateLiteral: () => templateLiteral3,
104521
104599
  symbol: () => symbol3,
104522
104600
  superRefine: () => superRefine3,
@@ -104609,7 +104687,7 @@ __export(exports_external3, {
104609
104687
  globalRegistry: () => globalRegistry3,
104610
104688
  getErrorMap: () => getErrorMap3,
104611
104689
  function: () => _function3,
104612
- fromJSONSchema: () => fromJSONSchema6,
104690
+ fromJSONSchema: () => fromJSONSchema7,
104613
104691
  formatError: () => formatError3,
104614
104692
  float64: () => float643,
104615
104693
  float32: () => float323,
@@ -104738,7 +104816,7 @@ __export(exports_core3, {
104738
104816
  version: () => version3,
104739
104817
  util: () => exports_util3,
104740
104818
  treeifyError: () => treeifyError3,
104741
- toJSONSchema: () => toJSONSchema6,
104819
+ toJSONSchema: () => toJSONSchema7,
104742
104820
  toDotPath: () => toDotPath3,
104743
104821
  safeParseAsync: () => safeParseAsync5,
104744
104822
  safeParse: () => safeParse5,
@@ -116047,7 +116125,7 @@ var allProcessors3 = {
116047
116125
  optional: optionalProcessor3,
116048
116126
  lazy: lazyProcessor3
116049
116127
  };
116050
- function toJSONSchema6(input, params) {
116128
+ function toJSONSchema7(input, params) {
116051
116129
  if ("_idmap" in input) {
116052
116130
  const registry4 = input;
116053
116131
  const ctx2 = initializeContext3({ ...params, processors: allProcessors3 });
@@ -117980,7 +118058,7 @@ function convertSchema3(schema, ctx) {
117980
118058
  }
117981
118059
  return baseSchema;
117982
118060
  }
117983
- function fromJSONSchema6(schema, params) {
118061
+ function fromJSONSchema7(schema, params) {
117984
118062
  if (typeof schema === "boolean") {
117985
118063
  return schema ? z3.any() : z3.never();
117986
118064
  }
@@ -118231,23 +118309,17 @@ class AssistantApp extends Manager2 {
118231
118309
  }
118232
118310
  }
118233
118311
  }
118234
- // ../node_modules/.pnpm/@kevisual+query@0.0.44/node_modules/@kevisual/query/dist/query.js
118312
+ // ../node_modules/.pnpm/@kevisual+query@0.0.49/node_modules/@kevisual/query/dist/query.js
118235
118313
  var isTextForContentType2 = (contentType) => {
118236
118314
  if (!contentType)
118237
118315
  return false;
118238
- const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md"];
118316
+ const textTypes = ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded", "md", "json"];
118239
118317
  return textTypes.some((type) => contentType.includes(type));
118240
118318
  };
118241
118319
  var adapter2 = async (opts = {}, overloadOpts) => {
118242
118320
  const controller = new AbortController;
118243
118321
  const signal = controller.signal;
118244
118322
  const isPostFile = opts.isPostFile || false;
118245
- let responseType = opts.responseType || "json";
118246
- if (opts.isBlob) {
118247
- responseType = "blob";
118248
- } else if (opts.isText) {
118249
- responseType = "text";
118250
- }
118251
118323
  const timeout = opts.timeout || 60000 * 3;
118252
118324
  const timer = setTimeout(() => {
118253
118325
  controller.abort();
@@ -118306,21 +118378,31 @@ var adapter2 = async (opts = {}, overloadOpts) => {
118306
118378
  headers
118307
118379
  }).then(async (response) => {
118308
118380
  const contentType = response.headers.get("Content-Type");
118309
- if (responseType === "blob") {
118310
- return await response.blob();
118311
- }
118312
- const isText = responseType === "text";
118313
118381
  const isJson = contentType && contentType.includes("application/json");
118314
- if (isJson && !isText) {
118315
- return await response.json();
118382
+ const isSuccess = response.ok;
118383
+ if (isJson) {
118384
+ const json4 = await response.json();
118385
+ if (json4?.code) {
118386
+ return json4;
118387
+ }
118388
+ return {
118389
+ code: isSuccess ? 200 : response.status,
118390
+ status: response.status,
118391
+ data: json4
118392
+ };
118316
118393
  } else if (isTextForContentType2(contentType)) {
118317
118394
  return {
118318
- code: response.status,
118395
+ code: isSuccess ? 200 : response.status,
118319
118396
  status: response.status,
118320
118397
  data: await response.text()
118321
118398
  };
118322
118399
  } else {
118323
- return response;
118400
+ return {
118401
+ code: isSuccess ? 200 : response.status,
118402
+ status: response.status,
118403
+ data: "非文本非JSON响应, 请手动处理response。",
118404
+ response
118405
+ };
118324
118406
  }
118325
118407
  }).catch((err) => {
118326
118408
  if (err.name === "AbortError") {
@@ -118340,16 +118422,14 @@ var adapter2 = async (opts = {}, overloadOpts) => {
118340
118422
  var wrapperError2 = ({ code, message }) => {
118341
118423
  const result = {
118342
118424
  code: code || 500,
118343
- success: false,
118344
- message: message || "api request error",
118345
- showError: (fn) => {},
118346
- noMsg: true
118425
+ message: message || "请求错误"
118347
118426
  };
118348
118427
  return result;
118349
118428
  };
118350
118429
 
118351
118430
  class Query2 {
118352
118431
  adapter;
118432
+ baseURL;
118353
118433
  url;
118354
118434
  beforeRequest;
118355
118435
  afterResponse;
@@ -118357,11 +118437,20 @@ class Query2 {
118357
118437
  timeout;
118358
118438
  stop;
118359
118439
  qws;
118360
- isClient = false;
118440
+ tokenName;
118441
+ storage;
118442
+ token;
118361
118443
  constructor(opts) {
118362
118444
  this.adapter = opts?.adapter || adapter2;
118445
+ this.tokenName = opts?.tokenName || "token";
118446
+ this.storage = opts?.storage || globalThis?.localStorage;
118363
118447
  const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
118364
118448
  this.url = opts?.url || defaultURL;
118449
+ if (this.url.startsWith("http")) {
118450
+ const urlObj = new URL(this.url);
118451
+ this.baseURL = urlObj.origin;
118452
+ }
118453
+ this.baseURL = opts?.baseURL || this.baseURL;
118365
118454
  this.headers = opts?.headers || {
118366
118455
  "Content-Type": "application/json"
118367
118456
  };
@@ -118370,7 +118459,7 @@ class Query2 {
118370
118459
  this.beforeRequest = opts.beforeRequest;
118371
118460
  } else {
118372
118461
  this.beforeRequest = async (opts2) => {
118373
- const token = globalThis?.localStorage?.getItem("token");
118462
+ const token = this.token || this.storage?.getItem?.(this.tokenName);
118374
118463
  if (token) {
118375
118464
  opts2.headers = {
118376
118465
  ...opts2.headers,
@@ -118392,7 +118481,6 @@ class Query2 {
118392
118481
  }
118393
118482
  async post(body, options) {
118394
118483
  const url4 = options?.url || this.url;
118395
- console.log("query post", url4, body, options);
118396
118484
  const { headers, adapter: adapter22, beforeRequest, afterResponse, timeout, ...rest } = options || {};
118397
118485
  const _headers = { ...this.headers, ...headers };
118398
118486
  const _adapter = adapter22 || this.adapter;
@@ -118406,13 +118494,20 @@ class Query2 {
118406
118494
  timeout: _timeout,
118407
118495
  ...rest
118408
118496
  };
118497
+ const isStartsWithHttp = req.url.startsWith("http");
118498
+ if (!isStartsWithHttp) {
118499
+ if (this.baseURL) {
118500
+ const baseURL = new URL(this.baseURL || globalThis?.location?.origin).origin;
118501
+ req.url = baseURL + req.url;
118502
+ }
118503
+ }
118409
118504
  try {
118410
118505
  if (_beforeRequest) {
118411
118506
  const res = await _beforeRequest(req);
118412
118507
  if (res === false) {
118413
118508
  return wrapperError2({
118414
118509
  code: 500,
118415
- message: "request is cancel",
118510
+ message: "请求取消",
118416
118511
  req
118417
118512
  });
118418
118513
  }
@@ -118421,13 +118516,13 @@ class Query2 {
118421
118516
  console.error("request beforeFn error", e, req);
118422
118517
  return wrapperError2({
118423
118518
  code: 500,
118424
- message: "api request beforeFn error",
118519
+ message: "请求在请求前处理时发生错误",
118425
118520
  req
118426
118521
  });
118427
118522
  }
118428
118523
  if (this.stop && !options?.noStop) {
118429
118524
  const that = this;
118430
- await new Promise((resolve) => {
118525
+ const res = await new Promise((resolve) => {
118431
118526
  let timer = 0;
118432
118527
  const detect = setInterval(() => {
118433
118528
  if (!that.stop) {
@@ -118435,11 +118530,20 @@ class Query2 {
118435
118530
  resolve(true);
118436
118531
  }
118437
118532
  timer++;
118438
- if (timer > 30) {
118439
- console.error("request stop: timeout", req.url, timer);
118533
+ if (timer > 5) {
118534
+ console.error("等待请求失败:", req.url, timer);
118535
+ clearInterval(detect);
118536
+ resolve(false);
118440
118537
  }
118441
118538
  }, 1000);
118442
118539
  });
118540
+ if (!res) {
118541
+ return wrapperError2({
118542
+ code: 500,
118543
+ message: "请求取消,可能是因为用户未登录或者token过期",
118544
+ req
118545
+ });
118546
+ }
118443
118547
  }
118444
118548
  return _adapter(req).then(async (res) => {
118445
118549
  try {
@@ -118452,10 +118556,10 @@ class Query2 {
118452
118556
  }
118453
118557
  return res;
118454
118558
  } catch (e) {
118455
- console.error("request afterFn error", e, req);
118559
+ console.error("请求在响应后处理时发生错误", e, req);
118456
118560
  return wrapperError2({
118457
118561
  code: 500,
118458
- message: "api request afterFn error",
118562
+ message: "请求在响应后处理时发生错误",
118459
118563
  req
118460
118564
  });
118461
118565
  }
@@ -144514,7 +144618,7 @@ var import_busboy = __toESM(require_lib2(), 1);
144514
144618
  import path19 from "path";
144515
144619
  import fs21 from "fs";
144516
144620
 
144517
- // ../node_modules/.pnpm/@kevisual+router@0.0.74/node_modules/@kevisual/router/src/server/cookie.ts
144621
+ // ../node_modules/.pnpm/@kevisual+router@0.0.80/node_modules/@kevisual/router/src/server/cookie.ts
144518
144622
  var NullObject2 = /* @__PURE__ */ (() => {
144519
144623
  const C2 = function() {};
144520
144624
  C2.prototype = Object.create(null);
@@ -144914,7 +145018,7 @@ var getBunPath = () => {
144914
145018
  };
144915
145019
 
144916
145020
  // ../node_modules/.pnpm/@kevisual+video-tools@0.0.13_dotenv@17.3.1_supports-color@10.2.2/node_modules/@kevisual/video-tools/src/ws/index.ts
144917
- var isBrowser5 = typeof process === "undefined" || typeof window !== "undefined" && typeof window.document !== "undefined" || typeof process !== "undefined" && process?.env?.BROWSER === "true";
145021
+ var isBrowser7 = typeof process === "undefined" || typeof window !== "undefined" && typeof window.document !== "undefined" || typeof process !== "undefined" && process?.env?.BROWSER === "true";
144918
145022
  var chantHttpToWs = (url4) => {
144919
145023
  if (url4.startsWith("http://")) {
144920
145024
  return url4.replace("http://", "ws://");
@@ -144927,7 +145031,7 @@ var chantHttpToWs = (url4) => {
144927
145031
  var initWs = async (url4, options) => {
144928
145032
  let ws;
144929
145033
  url4 = chantHttpToWs(url4);
144930
- if (isBrowser5) {
145034
+ if (isBrowser7) {
144931
145035
  ws = new WebSocket(url4);
144932
145036
  } else {
144933
145037
  const wsPakcages = "ws";