nhanh-pure-function 4.5.0 → 4.6.0
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/Browser/index.d.ts +1 -1
- package/dist/Element/index.d.ts +1 -1
- package/dist/Math/index.d.ts +87 -0
- package/dist/Types/index.d.ts +9 -0
- package/dist/Utility/index.d.ts +3 -85
- package/dist/Utility/modules/colorConverter.d.ts +137 -0
- package/dist/Utility/{Runtime → modules}/index.d.ts +1 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +723 -594
- package/package.json +1 -1
- /package/dist/Browser/{Runtime → modules}/index.d.ts +0 -0
- /package/dist/Browser/{Runtime → modules}/soundEffects.d.ts +0 -0
- /package/dist/Browser/{Runtime → modules}/webSocketClient.d.ts +0 -0
- /package/dist/Element/{Runtime → modules}/drop.d.ts +0 -0
- /package/dist/Element/{Runtime → modules}/fullscreen.d.ts +0 -0
- /package/dist/Element/{Runtime → modules}/index.d.ts +0 -0
- /package/dist/Utility/{Runtime → modules}/shortcutKey.d.ts +0 -0
- /package/dist/Utility/{Runtime → modules}/undoRedoHistory.d.ts +0 -0
package/dist/Browser/index.d.ts
CHANGED
package/dist/Element/index.d.ts
CHANGED
package/dist/Math/index.d.ts
CHANGED
|
@@ -32,6 +32,19 @@ export declare function _Math_PointToLineDistance(point: [number, number], lineS
|
|
|
32
32
|
* @returns [起点坐标[x,y], 终点坐标[x,y]]
|
|
33
33
|
*/
|
|
34
34
|
export declare function _Math_GetArcPoints(x: number, y: number, radius: number, startAngle: number, endAngle: number, axisX?: number, axisY?: number): [[number, number], [number, number]];
|
|
35
|
+
/**
|
|
36
|
+
* 计算两个经纬度坐标之间的直线距离(单位:米)。
|
|
37
|
+
*
|
|
38
|
+
* 先将经纬度通过 Mercator 投影转换为平面坐标(米),
|
|
39
|
+
* 再计算二维平面欧几里得距离,适用于短距离近似计算。
|
|
40
|
+
*
|
|
41
|
+
* @param lng1 第一个点的经度(度),范围 [-180, 180]
|
|
42
|
+
* @param lat1 第一个点的纬度(度),范围 [-85.05, 85.05]
|
|
43
|
+
* @param lng2 第二个点的经度(度),范围 [-180, 180]
|
|
44
|
+
* @param lat2 第二个点的纬度(度),范围 [-85.05, 85.05]
|
|
45
|
+
* @returns 两点间的距离(米)
|
|
46
|
+
*/
|
|
47
|
+
export declare function _Math_CalculateDistanceLngLat(lng1: number, lat1: number, lng2: number, lat2: number): number;
|
|
35
48
|
/** 计算平面直角坐标系中两点的距离 */
|
|
36
49
|
export declare function _Math_CalculateDistance2D(x1: number, y1: number, x2: number, y2: number): number;
|
|
37
50
|
/** 获取两点的中点 */
|
|
@@ -75,3 +88,77 @@ export declare function _Math_GetBezierCurveNodes(nodes: [number, number][], pro
|
|
|
75
88
|
* @returns 椭圆上的点 [x, y]
|
|
76
89
|
*/
|
|
77
90
|
export declare function _Math_GetEllipsePoints(aspectRatio: number, progress: number, normalizeToUnitSquare?: boolean): [number, number];
|
|
91
|
+
/**
|
|
92
|
+
* 将数值钳制在指定区间内。
|
|
93
|
+
* @param value 输入值
|
|
94
|
+
* @param min 下限
|
|
95
|
+
* @param max 上限
|
|
96
|
+
* @returns 钳制后的值
|
|
97
|
+
*/
|
|
98
|
+
export declare function _Math_Clamp(value: number, min: number, max: number): number;
|
|
99
|
+
/**
|
|
100
|
+
* 线性插值。
|
|
101
|
+
* @param a 起始值
|
|
102
|
+
* @param b 结束值
|
|
103
|
+
* @param t 插值参数,[0, 1]
|
|
104
|
+
* @returns 插值结果
|
|
105
|
+
*/
|
|
106
|
+
export declare function _Math_Lerp(a: number, b: number, t: number): number;
|
|
107
|
+
/**
|
|
108
|
+
* 逆线性插值:计算 value 在 [a, b] 区间的位置比例。
|
|
109
|
+
* @param a 区间下限
|
|
110
|
+
* @param b 区间上限
|
|
111
|
+
* @param value 当前值
|
|
112
|
+
* @returns 比例 t,0 表示在 a,1 表示在 b
|
|
113
|
+
*/
|
|
114
|
+
export declare function _Math_InverseLerp(a: number, b: number, value: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* 将 value 从 [fromMin, fromMax] 区间映射到 [toMin, toMax] 区间。
|
|
117
|
+
* @param value 输入值
|
|
118
|
+
* @param fromMin 源区间下限
|
|
119
|
+
* @param fromMax 源区间上限
|
|
120
|
+
* @param toMin 目标区间下限
|
|
121
|
+
* @param toMax 目标区间上限
|
|
122
|
+
* @returns 映射后的值
|
|
123
|
+
*/
|
|
124
|
+
export declare function _Math_Remap(value: number, fromMin: number, fromMax: number, toMin: number, toMax: number): number;
|
|
125
|
+
/**
|
|
126
|
+
* 角度转弧度。
|
|
127
|
+
* @param deg 角度(度)
|
|
128
|
+
* @returns 弧度
|
|
129
|
+
*/
|
|
130
|
+
export declare function _Math_DegToRad(deg: number): number;
|
|
131
|
+
/**
|
|
132
|
+
* 弧度转角度。
|
|
133
|
+
* @param rad 弧度
|
|
134
|
+
* @returns 角度(度)
|
|
135
|
+
*/
|
|
136
|
+
export declare function _Math_RadToDeg(rad: number): number;
|
|
137
|
+
/**
|
|
138
|
+
* 将角度归一化到指定范围。
|
|
139
|
+
* @param angle 输入角度(度)
|
|
140
|
+
* @param signed 为 true 时归一化到 [-180, 180),默认 false 归一化到 [0, 360)
|
|
141
|
+
* @returns 归一化后的角度
|
|
142
|
+
*/
|
|
143
|
+
export declare function _Math_NormalizeAngle(angle: number, signed?: boolean): number;
|
|
144
|
+
/**
|
|
145
|
+
* 判断点是否在矩形内(含边界)。
|
|
146
|
+
* @param px 点 X 坐标
|
|
147
|
+
* @param py 点 Y 坐标
|
|
148
|
+
* @param rx 矩形左上角 X
|
|
149
|
+
* @param ry 矩形左上角 Y
|
|
150
|
+
* @param rw 矩形宽度
|
|
151
|
+
* @param rh 矩形高度
|
|
152
|
+
* @returns true 表示点在矩形内
|
|
153
|
+
*/
|
|
154
|
+
export declare function _Math_IsPointInRect(px: number, py: number, rx: number, ry: number, rw: number, rh: number): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* 判断点是否在圆形内(含边界)。
|
|
157
|
+
* @param px 点 X 坐标
|
|
158
|
+
* @param py 点 Y 坐标
|
|
159
|
+
* @param cx 圆心 X
|
|
160
|
+
* @param cy 圆心 Y
|
|
161
|
+
* @param radius 圆半径
|
|
162
|
+
* @returns true 表示点在圆内
|
|
163
|
+
*/
|
|
164
|
+
export declare function _Math_IsPointInCircle(px: number, py: number, cx: number, cy: number, radius: number): boolean;
|
package/dist/Types/index.d.ts
CHANGED
|
@@ -37,3 +37,12 @@ export type _Type_DeepPartial<T> = {
|
|
|
37
37
|
export type _Type_Mutable<T> = {
|
|
38
38
|
-readonly [P in keyof T]: T[P];
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* 递归地将类型中的所有只读(readonly)属性转换为可写(writable)属性
|
|
42
|
+
* @template T - 要处理的基础类型
|
|
43
|
+
* @description 与TypeScript内置的Writable不同,DeepWritable会对嵌套对象进行递归处理,
|
|
44
|
+
* 使所有层级的属性都变为可写。适用于需要修改对象属性的场景,但需要确保对象不会被其他地方引用。
|
|
45
|
+
*/
|
|
46
|
+
export type _Type_DeepWritable<T> = {
|
|
47
|
+
-readonly [P in keyof T]: _Type_DeepWritable<T[P]>;
|
|
48
|
+
};
|
package/dist/Utility/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { _Type_DeepWritable } from '../Types';
|
|
2
|
+
export * from './modules';
|
|
2
3
|
/**
|
|
3
4
|
* 寻找空闲时机执行传入方法
|
|
4
5
|
* @param callback 需执行的方法
|
|
@@ -73,7 +74,7 @@ export declare function _Utility_RotateList<T>(list: T[]): T[][];
|
|
|
73
74
|
* @param {any} val - 需要克隆的值
|
|
74
75
|
* @returns {any} - 克隆后的值
|
|
75
76
|
*/
|
|
76
|
-
export declare function _Utility_Clone<T>(val: T): T
|
|
77
|
+
export declare function _Utility_Clone<T>(val: T): _Type_DeepWritable<T>;
|
|
77
78
|
/**
|
|
78
79
|
* 函数装饰器:精准测量并记录目标函数的执行耗时(单位:毫秒)
|
|
79
80
|
*
|
|
@@ -100,86 +101,3 @@ export declare function _Utility_TimeConsumption<T extends Function>(func: T, co
|
|
|
100
101
|
* @returns 实际暂停的毫秒数
|
|
101
102
|
*/
|
|
102
103
|
export declare function _Utility_Sleep(ms: number): number;
|
|
103
|
-
/**
|
|
104
|
-
* 颜色转换工具。
|
|
105
|
-
* 支持输入:hex/rgb/hsl/hsv,统一解析后输出指定格式。
|
|
106
|
-
*/
|
|
107
|
-
export declare class _Utility_ColorConverter {
|
|
108
|
-
private constructor();
|
|
109
|
-
private static readonly DEFAULT_ALPHA;
|
|
110
|
-
/**
|
|
111
|
-
* 数值钳制,确保在合法区间内。
|
|
112
|
-
*/
|
|
113
|
-
private static clamp;
|
|
114
|
-
private static normalizeHue;
|
|
115
|
-
/**
|
|
116
|
-
* 根据色相分段与色度参数生成 RGB(0-255)。
|
|
117
|
-
*/
|
|
118
|
-
private static chromaToRgb;
|
|
119
|
-
private static resolveAlpha;
|
|
120
|
-
private static toRoundedRgbString;
|
|
121
|
-
/**
|
|
122
|
-
* HSL 转 RGB。
|
|
123
|
-
* h: 0-360, s/l: 0-100
|
|
124
|
-
*/
|
|
125
|
-
private static hslToRgb;
|
|
126
|
-
/**
|
|
127
|
-
* HSV 转 RGB。
|
|
128
|
-
* h: 0-360, s/v: 0-100
|
|
129
|
-
*/
|
|
130
|
-
private static hsvToRgb;
|
|
131
|
-
/**
|
|
132
|
-
* 解析任意受支持的颜色格式并标准化为 RGBA。
|
|
133
|
-
*/
|
|
134
|
-
private static parseColor;
|
|
135
|
-
/**
|
|
136
|
-
* 十进制颜色分量转两位十六进制字符串。
|
|
137
|
-
*/
|
|
138
|
-
private static toHexPart;
|
|
139
|
-
/**
|
|
140
|
-
* RGB 转 HSL。
|
|
141
|
-
* 返回 h:0-360, s/l:0-100
|
|
142
|
-
*/
|
|
143
|
-
private static rgbToHsl;
|
|
144
|
-
/**
|
|
145
|
-
* RGB 转 HSV。
|
|
146
|
-
* 返回 h:0-360, s/v:0-100
|
|
147
|
-
*/
|
|
148
|
-
private static rgbToHsv;
|
|
149
|
-
/**
|
|
150
|
-
* 转换为 HEX(#RRGGBB)。
|
|
151
|
-
*/
|
|
152
|
-
static toHex(color: string): string;
|
|
153
|
-
/**
|
|
154
|
-
* 转换为 HEXA(#RRGGBBAA)。
|
|
155
|
-
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
156
|
-
*/
|
|
157
|
-
static toHexa(color: string, alpha?: number): string;
|
|
158
|
-
/**
|
|
159
|
-
* 转换为 RGB(rgb(r, g, b))。
|
|
160
|
-
*/
|
|
161
|
-
static toRgb(color: string): string;
|
|
162
|
-
/**
|
|
163
|
-
* 转换为 RGBA(rgba(r, g, b, a))。
|
|
164
|
-
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
165
|
-
*/
|
|
166
|
-
static toRgba(color: string, alpha?: number): string;
|
|
167
|
-
/**
|
|
168
|
-
* 转换为 HSL(hsl(h, s%, l%))。
|
|
169
|
-
*/
|
|
170
|
-
static toHsl(color: string): string;
|
|
171
|
-
/**
|
|
172
|
-
* 转换为 HSLA(hsla(h, s%, l%, a))。
|
|
173
|
-
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
174
|
-
*/
|
|
175
|
-
static toHsla(color: string, alpha?: number): string;
|
|
176
|
-
/**
|
|
177
|
-
* 转换为 HSV(hsv(h, s%, v%))。
|
|
178
|
-
*/
|
|
179
|
-
static toHsv(color: string): string;
|
|
180
|
-
/**
|
|
181
|
-
* 转换为 HSVA(hsva(h, s%, v%, a))。
|
|
182
|
-
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
183
|
-
*/
|
|
184
|
-
static toHsva(color: string, alpha?: number): string;
|
|
185
|
-
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 颜色转换工具。
|
|
3
|
+
* 支持输入:hex/rgb/hsl/hsv,统一解析后输出指定格式。
|
|
4
|
+
*/
|
|
5
|
+
export declare class _Utility_ColorConverter {
|
|
6
|
+
private constructor();
|
|
7
|
+
private static readonly DEFAULT_ALPHA;
|
|
8
|
+
/**
|
|
9
|
+
* 数值钳制,确保在合法区间内。
|
|
10
|
+
*/
|
|
11
|
+
private static clamp;
|
|
12
|
+
private static normalizeHue;
|
|
13
|
+
/**
|
|
14
|
+
* 根据色相分段与色度参数生成 RGB(0-255)。
|
|
15
|
+
*/
|
|
16
|
+
private static chromaToRgb;
|
|
17
|
+
private static resolveAlpha;
|
|
18
|
+
private static toRoundedRgbString;
|
|
19
|
+
/**
|
|
20
|
+
* HSL 转 RGB。
|
|
21
|
+
* h: 0-360, s/l: 0-100
|
|
22
|
+
*/
|
|
23
|
+
private static hslToRgb;
|
|
24
|
+
/**
|
|
25
|
+
* HSV 转 RGB。
|
|
26
|
+
* h: 0-360, s/v: 0-100
|
|
27
|
+
*/
|
|
28
|
+
private static hsvToRgb;
|
|
29
|
+
/**
|
|
30
|
+
* 解析任意受支持的颜色格式并标准化为 RGBA。
|
|
31
|
+
*/
|
|
32
|
+
private static parseColor;
|
|
33
|
+
/**
|
|
34
|
+
* 十进制颜色分量转两位十六进制字符串。
|
|
35
|
+
*/
|
|
36
|
+
private static toHexPart;
|
|
37
|
+
/**
|
|
38
|
+
* RGB 转 HSL。
|
|
39
|
+
* 返回 h:0-360, s/l:0-100
|
|
40
|
+
*/
|
|
41
|
+
private static rgbToHsl;
|
|
42
|
+
/**
|
|
43
|
+
* RGB 转 HSV。
|
|
44
|
+
* 返回 h:0-360, s/v:0-100
|
|
45
|
+
*/
|
|
46
|
+
private static rgbToHsv;
|
|
47
|
+
/**
|
|
48
|
+
* 转换为 HEX(#RRGGBB)。
|
|
49
|
+
*/
|
|
50
|
+
static toHex(color: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* 转换为 HEXA(#RRGGBBAA)。
|
|
53
|
+
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
54
|
+
*/
|
|
55
|
+
static toHexa(color: string, alpha?: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* 转换为 RGB(rgb(r, g, b))。
|
|
58
|
+
*/
|
|
59
|
+
static toRgb(color: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* 转换为 RGBA(rgba(r, g, b, a))。
|
|
62
|
+
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
63
|
+
*/
|
|
64
|
+
static toRgba(color: string, alpha?: number): string;
|
|
65
|
+
/**
|
|
66
|
+
* 转换为 HSL(hsl(h, s%, l%))。
|
|
67
|
+
*/
|
|
68
|
+
static toHsl(color: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* 转换为 HSLA(hsla(h, s%, l%, a))。
|
|
71
|
+
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
72
|
+
*/
|
|
73
|
+
static toHsla(color: string, alpha?: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* 转换为 HSV(hsv(h, s%, v%))。
|
|
76
|
+
*/
|
|
77
|
+
static toHsv(color: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* 转换为 HSVA(hsva(h, s%, v%, a))。
|
|
80
|
+
* alpha 不传时保留输入颜色中的透明度(默认 1)。
|
|
81
|
+
*/
|
|
82
|
+
static toHsva(color: string, alpha?: number): string;
|
|
83
|
+
/**
|
|
84
|
+
* 返回解析后的 RGBA 对象。
|
|
85
|
+
* @param color 任意受支持的颜色字符串(hex/rgb/hsl/hsv)
|
|
86
|
+
* @returns {{ r: number; g: number; b: number; a: number }} RGBA 分量,r/g/b 范围 0-255,a 范围 0-1
|
|
87
|
+
*/
|
|
88
|
+
static toRgbaObject(color: string): {
|
|
89
|
+
r: number;
|
|
90
|
+
g: number;
|
|
91
|
+
b: number;
|
|
92
|
+
a: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 判断两个颜色是否在允许的色差范围内(基于 RGB 欧几里得距离)。
|
|
96
|
+
* @param colorA 第一个颜色字符串
|
|
97
|
+
* @param colorB 第二个颜色字符串
|
|
98
|
+
* @param threshold 允许的最大色差值,范围约 0(完全相同)到 442(黑白最大距离),含 alpha 时上限约 510
|
|
99
|
+
* @param includeAlpha 是否将 alpha 差值纳入计算,默认 true;启用时 alpha 差值会缩放到 0-255 参与距离
|
|
100
|
+
* @returns true 表示在允许色差内
|
|
101
|
+
*/
|
|
102
|
+
static isWithinColorDifference(colorA: string, colorB: string, threshold: number, includeAlpha?: boolean): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 混合两个颜色(在 RGBA 空间线性插值)。
|
|
105
|
+
* @param colorA 起始颜色
|
|
106
|
+
* @param colorB 终点颜色
|
|
107
|
+
* @param ratio 混合比例,0 = 完全 A,1 = 完全 B
|
|
108
|
+
* @returns 混合后的 rgba 字符串
|
|
109
|
+
*/
|
|
110
|
+
static mix(colorA: string, colorB: string, ratio: number): string;
|
|
111
|
+
/**
|
|
112
|
+
* 转换为灰度(基于 ITU-R BT.709 权重)。
|
|
113
|
+
* @param color 任意受支持的颜色字符串
|
|
114
|
+
* @returns 灰度 rgb 字符串
|
|
115
|
+
*/
|
|
116
|
+
static toGrayscale(color: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* 计算 WCAG 2.0 相对亮度。
|
|
119
|
+
* @param color 任意受支持的颜色字符串
|
|
120
|
+
* @returns 相对亮度值,范围 [0, 1]
|
|
121
|
+
*/
|
|
122
|
+
static luminance(color: string): number;
|
|
123
|
+
/**
|
|
124
|
+
* 计算 WCAG 2.0 对比度。
|
|
125
|
+
* @param colorA 第一个颜色
|
|
126
|
+
* @param colorB 第二个颜色
|
|
127
|
+
* @returns 对比度值,范围 [1, 21]
|
|
128
|
+
*/
|
|
129
|
+
static contrastRatio(colorA: string, colorB: string): number;
|
|
130
|
+
/**
|
|
131
|
+
* 设置透明度并返回 rgba 字符串。
|
|
132
|
+
* @param color 任意受支持的颜色字符串
|
|
133
|
+
* @param alpha 目标透明度,范围 [0, 1]
|
|
134
|
+
* @returns rgba 字符串
|
|
135
|
+
*/
|
|
136
|
+
static withAlpha(color: string, alpha: number): string;
|
|
137
|
+
}
|