ddan-js 2.8.10 → 2.8.11

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.
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bezier1 = (p0, p1, t) => {
4
+ return {
5
+ x: (1 - t) * p0.x + t * p1.x,
6
+ y: (1 - t) * p0.y + t * p1.y,
7
+ };
8
+ };
9
+ const bezier2 = (p0, p1, p2, t) => {
10
+ const q0 = bezier1(p0, p1, t);
11
+ const q1 = bezier1(p1, p2, t);
12
+ return bezier1(q0, q1, t);
13
+ };
14
+ const bezier3 = (p0, p1, p2, p3, t) => {
15
+ const q0 = bezier2(p0, p1, p2, t);
16
+ const q1 = bezier2(p1, p2, p3, t);
17
+ return bezier1(q0, q1, t);
18
+ };
19
+ /**
20
+ * 贝塞尔曲线
21
+ * @param points
22
+ * @param t [0, 1]
23
+ * @returns
24
+ */
25
+ const bezier = (points, t) => {
26
+ if (points.length === 1) {
27
+ return points[0]; // 递归终点
28
+ }
29
+ const nextPoints = [];
30
+ for (let i = 0; i < points.length - 1; i++) {
31
+ nextPoints.push({
32
+ x: (1 - t) * points[i].x + t * points[i + 1].x,
33
+ y: (1 - t) * points[i].y + t * points[i + 1].y,
34
+ });
35
+ }
36
+ return bezier(nextPoints, t);
37
+ };
38
+ /**
39
+ * 计算二项式系数 C(n, k)
40
+ * @param n 阶数
41
+ * @param k 选择的点数
42
+ * @returns 二项式系数
43
+ */
44
+ const binomialCoefficient = (n, k) => {
45
+ if (k === 0 || k === n)
46
+ return 1;
47
+ let res = 1;
48
+ for (let i = 1; i <= k; i++) {
49
+ res = (res * (n - i + 1)) / i;
50
+ }
51
+ return res;
52
+ };
53
+ /**
54
+ * 贝塞尔曲线
55
+ * @param points
56
+ * @param t [0, 1]
57
+ * @returns
58
+ */
59
+ const bezierCurve = (points, t) => {
60
+ const n = points.length - 1;
61
+ let x = 0;
62
+ let y = 0;
63
+ for (let i = 0; i <= n; i++) {
64
+ const coefficient = binomialCoefficient(n, i) * Math.pow(1 - t, n - i) * Math.pow(t, i);
65
+ x += coefficient * points[i].x;
66
+ y += coefficient * points[i].y;
67
+ }
68
+ return { x, y };
69
+ };
70
+ exports.default = { bezier1, bezier2, bezier3, bezier, bezierCurve };
@@ -168,7 +168,7 @@ class Socks5 {
168
168
  const destination = await this.parseClientRequest(clientSocket);
169
169
  const addr = destination.addr;
170
170
  addrport = `${addr}:${destination.port}`;
171
- this.__debug && this.__logger?.info(`[socks5] handle connection`, addrport);
171
+ this.__debug && this.__logger?.info(`[socks5] connection`, addrport);
172
172
  const proxyConfig = this.findProxyConfig(addr);
173
173
  if (proxyConfig) {
174
174
  // 走上游代理
@@ -334,6 +334,11 @@ declare const dHook: {
334
334
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
335
335
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
336
336
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
337
+ bezier1: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
338
+ bezier2: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
339
+ bezier3: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, p3: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
340
+ bezier: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
341
+ bezierCurve: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
337
342
  logString: (data: any) => string;
338
343
  logParse: (logStr: string) => string;
339
344
  logRString: (data: any) => Promise<string>;
@@ -685,6 +690,11 @@ declare const _default: {
685
690
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
686
691
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
687
692
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
693
+ bezier1: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
694
+ bezier2: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
695
+ bezier3: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, p3: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
696
+ bezier: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
697
+ bezierCurve: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
688
698
  logString: (data: any) => string;
689
699
  logParse: (logStr: string) => string;
690
700
  logRString: (data: any) => Promise<string>;
@@ -334,6 +334,11 @@ declare const dHook: {
334
334
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
335
335
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
336
336
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
337
+ bezier1: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
338
+ bezier2: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
339
+ bezier3: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, p3: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
340
+ bezier: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
341
+ bezierCurve: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
337
342
  logString: (data: any) => string;
338
343
  logParse: (logStr: string) => string;
339
344
  logRString: (data: any) => Promise<string>;
@@ -721,6 +726,11 @@ declare const _default: {
721
726
  pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
722
727
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
723
728
  safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
729
+ bezier1: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
730
+ bezier2: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
731
+ bezier3: (p0: import("./typings").Ddan.IPoint, p1: import("./typings").Ddan.IPoint, p2: import("./typings").Ddan.IPoint, p3: import("./typings").Ddan.IPoint, t: number) => import("./typings").Ddan.IPoint;
732
+ bezier: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
733
+ bezierCurve: (points: import("./typings").Ddan.IPoint[], t: number) => import("./typings").Ddan.IPoint;
724
734
  logString: (data: any) => string;
725
735
  logParse: (logStr: string) => string;
726
736
  logRString: (data: any) => Promise<string>;
@@ -25,6 +25,11 @@ declare const _default: {
25
25
  pipe: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DPipeline;
26
26
  pipeline: (max?: number) => DPipeline;
27
27
  safeTask: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DSafeTask;
28
+ bezier1: (p0: Ddan.IPoint, p1: Ddan.IPoint, t: number) => Ddan.IPoint;
29
+ bezier2: (p0: Ddan.IPoint, p1: Ddan.IPoint, p2: Ddan.IPoint, t: number) => Ddan.IPoint;
30
+ bezier3: (p0: Ddan.IPoint, p1: Ddan.IPoint, p2: Ddan.IPoint, p3: Ddan.IPoint, t: number) => Ddan.IPoint;
31
+ bezier: (points: Ddan.IPoint[], t: number) => Ddan.IPoint;
32
+ bezierCurve: (points: Ddan.IPoint[], t: number) => Ddan.IPoint;
28
33
  logString: (data: any) => string;
29
34
  logParse: (logStr: string) => string;
30
35
  logRString: (data: any) => Promise<string>;
@@ -0,0 +1,9 @@
1
+ import { Ddan } from '../../../typings';
2
+ declare const _default: {
3
+ bezier1: (p0: Ddan.IPoint, p1: Ddan.IPoint, t: number) => Ddan.IPoint;
4
+ bezier2: (p0: Ddan.IPoint, p1: Ddan.IPoint, p2: Ddan.IPoint, t: number) => Ddan.IPoint;
5
+ bezier3: (p0: Ddan.IPoint, p1: Ddan.IPoint, p2: Ddan.IPoint, p3: Ddan.IPoint, t: number) => Ddan.IPoint;
6
+ bezier: (points: Ddan.IPoint[], t: number) => Ddan.IPoint;
7
+ bezierCurve: (points: Ddan.IPoint[], t: number) => Ddan.IPoint;
8
+ };
9
+ export default _default;
@@ -4,6 +4,10 @@ export declare namespace Ddan {
4
4
  key: string;
5
5
  value: T;
6
6
  }
7
+ interface IPoint {
8
+ x: number;
9
+ y: number;
10
+ }
7
11
  type KeyValue<T = any> = Required<IKeyValuePart<T>>;
8
12
  type Function = (...args: any[]) => void;
9
13
  type PFunction<T = any> = Promise<T> | Function;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.8.10",
3
+ "version": "2.8.11",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",