@kevisual/router 0.2.6 → 0.2.8

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/app.js CHANGED
@@ -17248,7 +17248,7 @@ config(en_default());
17248
17248
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
17249
17249
  var zod_default = exports_external;
17250
17250
 
17251
- // ../../node_modules/.pnpm/nanoid@5.1.7/node_modules/nanoid/index.js
17251
+ // ../../node_modules/.pnpm/nanoid@5.1.9/node_modules/nanoid/index.js
17252
17252
  import { webcrypto as crypto } from "node:crypto";
17253
17253
  var POOL_SIZE_MULTIPLIER = 128;
17254
17254
  var pool;
@@ -17269,8 +17269,25 @@ function random2(bytes) {
17269
17269
  return pool.subarray(poolOffset - bytes, poolOffset);
17270
17270
  }
17271
17271
  function customRandom(alphabet, defaultSize, getRandom) {
17272
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
17273
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
17272
+ let safeByteCutoff = 256 - 256 % alphabet.length;
17273
+ if (safeByteCutoff === 256) {
17274
+ let mask = alphabet.length - 1;
17275
+ return (size = defaultSize) => {
17276
+ if (!size)
17277
+ return "";
17278
+ let id = "";
17279
+ while (true) {
17280
+ let bytes = getRandom(size);
17281
+ let i = size;
17282
+ while (i--) {
17283
+ id += alphabet[bytes[i] & mask];
17284
+ if (id.length >= size)
17285
+ return id;
17286
+ }
17287
+ }
17288
+ };
17289
+ }
17290
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
17274
17291
  return (size = defaultSize) => {
17275
17292
  if (!size)
17276
17293
  return "";
@@ -17279,9 +17296,11 @@ function customRandom(alphabet, defaultSize, getRandom) {
17279
17296
  let bytes = getRandom(step);
17280
17297
  let i = step;
17281
17298
  while (i--) {
17282
- id += alphabet[bytes[i] & mask] || "";
17283
- if (id.length >= size)
17284
- return id;
17299
+ if (bytes[i] < safeByteCutoff) {
17300
+ id += alphabet[bytes[i] % alphabet.length];
17301
+ if (id.length >= size)
17302
+ return id;
17303
+ }
17285
17304
  }
17286
17305
  }
17287
17306
  };
@@ -17915,6 +17934,9 @@ class QueryRouterServer extends QueryRouter {
17915
17934
  }
17916
17935
  return super.run(msg, ctx);
17917
17936
  }
17937
+ async runLocal(msg, ctx) {
17938
+ return this.run(msg, { ...ctx, appId: this.appId });
17939
+ }
17918
17940
  async runAction(api2, payload, ctx) {
17919
17941
  const { path, key, rid } = api2;
17920
17942
  return this.run({ path, key, rid, payload }, ctx);
@@ -18900,7 +18922,7 @@ class App extends QueryRouterServer {
18900
18922
  }
18901
18923
  }
18902
18924
 
18903
- // ../../node_modules/.pnpm/@kevisual+context@0.0.8/node_modules/@kevisual/context/dist/app.js
18925
+ // ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
18904
18926
  var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined";
18905
18927
  function getDefaultExportFromCjs(x) {
18906
18928
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -20109,7 +20131,7 @@ app
20109
20131
  10. **中间件找不到会返回 404**,错误信息中会包含找不到的中间件列表。
20110
20132
  `;
20111
20133
  // package.json
20112
- var version2 = "0.2.5";
20134
+ var version2 = "0.2.7";
20113
20135
 
20114
20136
  // agent/routes/route-create.ts
20115
20137
  app.route({
@@ -449,6 +449,20 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
449
449
  token?: string;
450
450
  data?: any;
451
451
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
452
+ /**
453
+ * 调用了handle
454
+ * @param param0
455
+ * @returns
456
+ */
457
+ runLocal(msg: {
458
+ rid?: string;
459
+ path?: string;
460
+ key?: string;
461
+ payload?: any;
462
+ args?: any;
463
+ token?: string;
464
+ data?: any;
465
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
452
466
  runAction<T extends {
453
467
  rid?: string;
454
468
  path?: string;
@@ -449,6 +449,20 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
449
449
  token?: string;
450
450
  data?: any;
451
451
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
452
+ /**
453
+ * 调用了handle
454
+ * @param param0
455
+ * @returns
456
+ */
457
+ runLocal(msg: {
458
+ rid?: string;
459
+ path?: string;
460
+ key?: string;
461
+ payload?: any;
462
+ args?: any;
463
+ token?: string;
464
+ data?: any;
465
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
452
466
  runAction<T extends {
453
467
  rid?: string;
454
468
  path?: string;
package/dist/opencode.js CHANGED
@@ -685,7 +685,7 @@ var require_md5 = __commonJS((exports, module) => {
685
685
  });
686
686
  });
687
687
 
688
- // ../../node_modules/.pnpm/@kevisual+context@0.0.8/node_modules/@kevisual/context/dist/app.js
688
+ // ../../node_modules/.pnpm/@kevisual+context@0.0.10/node_modules/@kevisual/context/dist/app.js
689
689
  var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
690
690
  function getDefaultExportFromCjs(x) {
691
691
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -14774,7 +14774,7 @@ function date4(params) {
14774
14774
 
14775
14775
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
14776
14776
  config(en_default());
14777
- // ../../node_modules/.pnpm/nanoid@5.1.7/node_modules/nanoid/index.js
14777
+ // ../../node_modules/.pnpm/nanoid@5.1.9/node_modules/nanoid/index.js
14778
14778
  import { webcrypto as crypto } from "node:crypto";
14779
14779
  var POOL_SIZE_MULTIPLIER = 128;
14780
14780
  var pool;
@@ -14795,8 +14795,25 @@ function random(bytes) {
14795
14795
  return pool.subarray(poolOffset - bytes, poolOffset);
14796
14796
  }
14797
14797
  function customRandom(alphabet, defaultSize, getRandom) {
14798
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
14799
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
14798
+ let safeByteCutoff = 256 - 256 % alphabet.length;
14799
+ if (safeByteCutoff === 256) {
14800
+ let mask = alphabet.length - 1;
14801
+ return (size = defaultSize) => {
14802
+ if (!size)
14803
+ return "";
14804
+ let id = "";
14805
+ while (true) {
14806
+ let bytes = getRandom(size);
14807
+ let i = size;
14808
+ while (i--) {
14809
+ id += alphabet[bytes[i] & mask];
14810
+ if (id.length >= size)
14811
+ return id;
14812
+ }
14813
+ }
14814
+ };
14815
+ }
14816
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
14800
14817
  return (size = defaultSize) => {
14801
14818
  if (!size)
14802
14819
  return "";
@@ -14805,9 +14822,11 @@ function customRandom(alphabet, defaultSize, getRandom) {
14805
14822
  let bytes = getRandom(step);
14806
14823
  let i = step;
14807
14824
  while (i--) {
14808
- id += alphabet[bytes[i] & mask] || "";
14809
- if (id.length >= size)
14810
- return id;
14825
+ if (bytes[i] < safeByteCutoff) {
14826
+ id += alphabet[bytes[i] % alphabet.length];
14827
+ if (id.length >= size)
14828
+ return id;
14829
+ }
14811
14830
  }
14812
14831
  }
14813
14832
  };
@@ -505,6 +505,20 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
505
505
  token?: string;
506
506
  data?: any;
507
507
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
508
+ /**
509
+ * 调用了handle
510
+ * @param param0
511
+ * @returns
512
+ */
513
+ runLocal(msg: {
514
+ rid?: string;
515
+ path?: string;
516
+ key?: string;
517
+ payload?: any;
518
+ args?: any;
519
+ token?: string;
520
+ data?: any;
521
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
508
522
  runAction<T extends {
509
523
  rid?: string;
510
524
  path?: string;
@@ -32534,20 +32534,41 @@ function date4(params) {
32534
32534
 
32535
32535
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
32536
32536
  config(en_default());
32537
- // ../../node_modules/.pnpm/nanoid@5.1.7/node_modules/nanoid/index.browser.js
32537
+ // ../../node_modules/.pnpm/nanoid@5.1.9/node_modules/nanoid/index.browser.js
32538
32538
  var random2 = (bytes) => crypto.getRandomValues(new Uint8Array(bytes));
32539
32539
  var customRandom = (alphabet, defaultSize, getRandom) => {
32540
- let mask = (2 << Math.log2(alphabet.length - 1)) - 1;
32541
- let step = -~(1.6 * mask * defaultSize / alphabet.length);
32540
+ let safeByteCutoff = 256 - 256 % alphabet.length;
32541
+ if (safeByteCutoff === 256) {
32542
+ let mask = alphabet.length - 1;
32543
+ return (size = defaultSize) => {
32544
+ if (!size)
32545
+ return "";
32546
+ let id = "";
32547
+ while (true) {
32548
+ let bytes = getRandom(size);
32549
+ let j = size;
32550
+ while (j--) {
32551
+ id += alphabet[bytes[j] & mask];
32552
+ if (id.length >= size)
32553
+ return id;
32554
+ }
32555
+ }
32556
+ };
32557
+ }
32558
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
32542
32559
  return (size = defaultSize) => {
32560
+ if (!size)
32561
+ return "";
32543
32562
  let id = "";
32544
32563
  while (true) {
32545
32564
  let bytes = getRandom(step);
32546
- let j = step | 0;
32565
+ let j = step;
32547
32566
  while (j--) {
32548
- id += alphabet[bytes[j] & mask] || "";
32549
- if (id.length >= size)
32550
- return id;
32567
+ if (bytes[j] < safeByteCutoff) {
32568
+ id += alphabet[bytes[j] % alphabet.length];
32569
+ if (id.length >= size)
32570
+ return id;
32571
+ }
32551
32572
  }
32552
32573
  }
32553
32574
  };
@@ -33179,6 +33200,9 @@ class QueryRouterServer extends QueryRouter {
33179
33200
  }
33180
33201
  return super.run(msg, ctx);
33181
33202
  }
33203
+ async runLocal(msg, ctx) {
33204
+ return this.run(msg, { ...ctx, appId: this.appId });
33205
+ }
33182
33206
  async runAction(api2, payload, ctx) {
33183
33207
  const { path, key, rid } = api2;
33184
33208
  return this.run({ path, key, rid, payload }, ctx);
@@ -446,6 +446,20 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
446
446
  token?: string;
447
447
  data?: any;
448
448
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
449
+ /**
450
+ * 调用了handle
451
+ * @param param0
452
+ * @returns
453
+ */
454
+ runLocal(msg: {
455
+ rid?: string;
456
+ path?: string;
457
+ key?: string;
458
+ payload?: any;
459
+ args?: any;
460
+ token?: string;
461
+ data?: any;
462
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
449
463
  runAction<T extends {
450
464
  rid?: string;
451
465
  path?: string;
package/dist/router.d.ts CHANGED
@@ -511,6 +511,20 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
511
511
  token?: string;
512
512
  data?: any;
513
513
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
514
+ /**
515
+ * 调用了handle
516
+ * @param param0
517
+ * @returns
518
+ */
519
+ runLocal(msg: {
520
+ rid?: string;
521
+ path?: string;
522
+ key?: string;
523
+ payload?: any;
524
+ args?: any;
525
+ token?: string;
526
+ data?: any;
527
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
514
528
  runAction<T extends {
515
529
  rid?: string;
516
530
  path?: string;
package/dist/router.js CHANGED
@@ -17245,7 +17245,7 @@ function date4(params) {
17245
17245
 
17246
17246
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
17247
17247
  config(en_default());
17248
- // ../../node_modules/.pnpm/nanoid@5.1.7/node_modules/nanoid/index.js
17248
+ // ../../node_modules/.pnpm/nanoid@5.1.9/node_modules/nanoid/index.js
17249
17249
  import { webcrypto as crypto } from "node:crypto";
17250
17250
  var POOL_SIZE_MULTIPLIER = 128;
17251
17251
  var pool;
@@ -17266,8 +17266,25 @@ function random2(bytes) {
17266
17266
  return pool.subarray(poolOffset - bytes, poolOffset);
17267
17267
  }
17268
17268
  function customRandom(alphabet, defaultSize, getRandom) {
17269
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
17270
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
17269
+ let safeByteCutoff = 256 - 256 % alphabet.length;
17270
+ if (safeByteCutoff === 256) {
17271
+ let mask = alphabet.length - 1;
17272
+ return (size = defaultSize) => {
17273
+ if (!size)
17274
+ return "";
17275
+ let id = "";
17276
+ while (true) {
17277
+ let bytes = getRandom(size);
17278
+ let i = size;
17279
+ while (i--) {
17280
+ id += alphabet[bytes[i] & mask];
17281
+ if (id.length >= size)
17282
+ return id;
17283
+ }
17284
+ }
17285
+ };
17286
+ }
17287
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
17271
17288
  return (size = defaultSize) => {
17272
17289
  if (!size)
17273
17290
  return "";
@@ -17276,9 +17293,11 @@ function customRandom(alphabet, defaultSize, getRandom) {
17276
17293
  let bytes = getRandom(step);
17277
17294
  let i = step;
17278
17295
  while (i--) {
17279
- id += alphabet[bytes[i] & mask] || "";
17280
- if (id.length >= size)
17281
- return id;
17296
+ if (bytes[i] < safeByteCutoff) {
17297
+ id += alphabet[bytes[i] % alphabet.length];
17298
+ if (id.length >= size)
17299
+ return id;
17300
+ }
17282
17301
  }
17283
17302
  }
17284
17303
  };
@@ -17912,6 +17931,9 @@ class QueryRouterServer extends QueryRouter {
17912
17931
  }
17913
17932
  return super.run(msg, ctx);
17914
17933
  }
17934
+ async runLocal(msg, ctx) {
17935
+ return this.run(msg, { ...ctx, appId: this.appId });
17936
+ }
17915
17937
  async runAction(api2, payload, ctx) {
17916
17938
  const { path, key, rid } = api2;
17917
17939
  return this.run({ path, key, rid, payload }, ctx);
package/dist/ws.d.ts CHANGED
@@ -496,6 +496,20 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
496
496
  token?: string;
497
497
  data?: any;
498
498
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
499
+ /**
500
+ * 调用了handle
501
+ * @param param0
502
+ * @returns
503
+ */
504
+ runLocal(msg: {
505
+ rid?: string;
506
+ path?: string;
507
+ key?: string;
508
+ payload?: any;
509
+ args?: any;
510
+ token?: string;
511
+ data?: any;
512
+ }, ctx?: Partial<RouteContext<C>>): Promise<any>;
499
513
  runAction<T extends {
500
514
  rid?: string;
501
515
  path?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@kevisual/router",
4
- "version": "0.2.6",
4
+ "version": "0.2.8",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",
@@ -27,7 +27,7 @@
27
27
  "@kevisual/dts": "^0.0.4",
28
28
  "@kevisual/js-filter": "^0.0.6",
29
29
  "@kevisual/local-proxy": "^0.0.8",
30
- "@kevisual/query": "^0.0.55",
30
+ "@kevisual/query": "^0.0.56",
31
31
  "@kevisual/remote-app": "^0.0.7",
32
32
  "@kevisual/use-config": "^1.0.30",
33
33
  "@opencode-ai/plugin": "^1.4.6",
@@ -42,7 +42,7 @@
42
42
  "es-toolkit": "^1.45.1",
43
43
  "eventemitter3": "^5.0.4",
44
44
  "fast-glob": "^3.3.3",
45
- "nanoid": "^5.1.7",
45
+ "nanoid": "^5.1.9",
46
46
  "path-to-regexp": "^8.4.2",
47
47
  "send": "^1.2.1",
48
48
  "typescript": "^6.0.2",
package/src/commander.ts CHANGED
@@ -2,7 +2,6 @@ import { Command, program } from 'commander';
2
2
  import { App } from './app.ts';
3
3
  import { RemoteApp } from '@kevisual/remote-app'
4
4
  import z from 'zod';
5
- import { create } from 'node:domain';
6
5
  export const groupByPath = (routes: App['routes']) => {
7
6
  return routes.reduce((acc, route) => {
8
7
  const path = route.path || 'default';
package/src/route.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CustomError, throwError, CustomErrorOptions } from './result/error.ts';
1
+ import { CustomError, throwError } from './result/error.ts';
2
2
  import { pick } from './utils/pick.ts';
3
3
  import { listenProcess, MockProcess } from './utils/listen-process.ts';
4
4
  import { z } from 'zod';
@@ -773,7 +773,14 @@ export class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Qu
773
773
  }
774
774
  return super.run(msg, ctx as RouteContext<C>);
775
775
  }
776
-
776
+ /**
777
+ * 调用了handle
778
+ * @param param0
779
+ * @returns
780
+ */
781
+ async runLocal(msg: { rid?: string; path?: string; key?: string; payload?: any, args?: any, token?: string, data?: any }, ctx?: Partial<RouteContext<C>>) {
782
+ return this.run(msg, { ...ctx, appId: this.appId } as RouteContext<C>);
783
+ }
777
784
  async runAction<T extends { rid?: string; path?: string; key?: string; metadata?: { args?: any } } = {}>(
778
785
  api: T,
779
786
  payload: RunActionPayload<T>,