nhanh-pure-function 3.0.5 → 3.0.6-beta.2
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/LICENSE +21 -21
- package/README.md +18 -18
- package/package.json +46 -45
- package/dist/Animate/index.d.ts +0 -45
- package/dist/Animate/type.d.ts +0 -0
- package/dist/Blob/index.d.ts +0 -10
- package/dist/Blob/type.d.ts +0 -0
- package/dist/Browser/index.d.ts +0 -77
- package/dist/Browser/type.d.ts +0 -0
- package/dist/Constant.d.ts +0 -256
- package/dist/Element/index.d.ts +0 -91
- package/dist/Element/type.d.ts +0 -33
- package/dist/File/index.d.ts +0 -19
- package/dist/File/type.d.ts +0 -0
- package/dist/Format/index.d.ts +0 -75
- package/dist/Format/type.d.ts +0 -0
- package/dist/Math/index.d.ts +0 -50
- package/dist/Math/type.d.ts +0 -0
- package/dist/Utility/index.d.ts +0 -106
- package/dist/Utility/type.d.ts +0 -0
- package/dist/Valid/index.d.ts +0 -131
- package/dist/Valid/type.d.ts +0 -6
- package/dist/index.cjs.js +0 -3
- package/dist/index.d.ts +0 -43
- package/dist/index.es.js +0 -1501
package/dist/Element/type.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type UiLibrary = "naiveUI" | "ElementPlus" | "Element";
|
|
2
|
-
export type EventFunctionMap = Partial<Record<"mousedown" | "mousemove" | "mouseup" | "click" | "touchstart" | "touchmove" | "touchend" | "touchcancel", (event: Event) => void>>;
|
|
3
|
-
/** 拖拽配置 */
|
|
4
|
-
export type DragOption = {
|
|
5
|
-
/** 拖拽范围限制 */
|
|
6
|
-
limit?: {
|
|
7
|
-
max: {
|
|
8
|
-
top: number;
|
|
9
|
-
left: number;
|
|
10
|
-
};
|
|
11
|
-
min: {
|
|
12
|
-
top: number;
|
|
13
|
-
left: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
/** 指定的拖拽元素 */
|
|
17
|
-
dragDom?: HTMLElement;
|
|
18
|
-
};
|
|
19
|
-
/** 更新后的位置信息 */
|
|
20
|
-
export type UpdateValue = {
|
|
21
|
-
top: number;
|
|
22
|
-
left: number;
|
|
23
|
-
percentage?: {
|
|
24
|
-
top: number;
|
|
25
|
-
left: number;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
/** 局部拖拽配置 */
|
|
29
|
-
export type LocalDragOptions = {
|
|
30
|
-
limit?: DragOption["limit"];
|
|
31
|
-
update_move?: (value: UpdateValue) => void | undefined;
|
|
32
|
-
update_up?: (value: UpdateValue) => void | undefined;
|
|
33
|
-
};
|
package/dist/File/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 读取文件
|
|
3
|
-
* @param src 文件地址
|
|
4
|
-
* @returns 文件的字符串内容
|
|
5
|
-
*/
|
|
6
|
-
export declare function _File_Read(src: string): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* 下载文件
|
|
9
|
-
* @param {string} href - 文件路径
|
|
10
|
-
* @param {string} [fileName] - 导出文件名
|
|
11
|
-
*/
|
|
12
|
-
export declare function _File_Download(href: string, fileName?: string): Promise<unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* 创建文件并下载
|
|
15
|
-
* @param {BlobPart[]} content 文件内容
|
|
16
|
-
* @param {string} fileName 文件名称
|
|
17
|
-
* @param {BlobPropertyBag} options Blob 配置
|
|
18
|
-
*/
|
|
19
|
-
export declare function _File_CreateAndDownload(content: BlobPart[], fileName: string, options?: BlobPropertyBag): void;
|
package/dist/File/type.d.ts
DELETED
|
File without changes
|
package/dist/Format/index.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 首字母大写
|
|
3
|
-
* @param str
|
|
4
|
-
* @returns string
|
|
5
|
-
*/
|
|
6
|
-
export declare function _Format_CapitalizeFirstLetter(string: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* 转为百分比字符串
|
|
9
|
-
* @param value 分子
|
|
10
|
-
* @param totalValue 分母
|
|
11
|
-
* @param decimalPlaces 保留小数位
|
|
12
|
-
* @returns 10.00%
|
|
13
|
-
*/
|
|
14
|
-
export declare function _Format_Percentage(value: number, totalValue: number, decimalPlaces?: number): string;
|
|
15
|
-
/**
|
|
16
|
-
* 格式化数字,给数字加上千位分隔符。
|
|
17
|
-
* @param {number} number - 要格式化的数字。
|
|
18
|
-
* @returns {string} - 格式化后的字符串。
|
|
19
|
-
*/
|
|
20
|
-
export declare function _Format_NumberWithCommas(number: number): string;
|
|
21
|
-
/**
|
|
22
|
-
* 将纯数字转换为带单位的数字格式
|
|
23
|
-
*
|
|
24
|
-
* @param value - 要转换的数字或字符串形式的数字
|
|
25
|
-
* @param config - 配置对象
|
|
26
|
-
* @param config.join - 是否将数字和单位拼接成一个字符串,默认为 `false`
|
|
27
|
-
* @param config.suffix - 单位后缀,默认为 `万`
|
|
28
|
-
* @param config.decimalPlaces - 保留的小数位数,默认为 `2`
|
|
29
|
-
*
|
|
30
|
-
* @returns 返回转换后的结果:
|
|
31
|
-
* - 如果 `config.join` 为 `true`,返回拼接后的字符串,如 "12.34万"
|
|
32
|
-
* - 如果 `config.join` 为 `false`,返回一个数组,如 [ 12.34, '万' ]
|
|
33
|
-
*/
|
|
34
|
-
export declare function _Format_NumberWithUnit(value: string | number, config?: {
|
|
35
|
-
join?: boolean;
|
|
36
|
-
suffix?: string;
|
|
37
|
-
decimalPlaces?: number;
|
|
38
|
-
}): string | (string | number)[];
|
|
39
|
-
/**
|
|
40
|
-
* 格式化文件大小
|
|
41
|
-
* @param {number} size
|
|
42
|
-
* @returns string
|
|
43
|
-
*/
|
|
44
|
-
export declare function _Format_FileSize(size: number): string;
|
|
45
|
-
/**
|
|
46
|
-
* 时间戳转换字符串
|
|
47
|
-
* @param {Number | Date} time 时间戳或Date对象
|
|
48
|
-
* @param {String} template 完整模板 --> YYYY MM DD hh mm ss ms
|
|
49
|
-
* @param {Boolean} pad 补0
|
|
50
|
-
*/
|
|
51
|
-
export declare function _Format_Timestamp(time: number | Date, template?: string, pad?: boolean): string;
|
|
52
|
-
/**
|
|
53
|
-
* 从给定的href中提取名称部分
|
|
54
|
-
* 该函数旨在处理URL字符串,并返回URL路径的最后一部分,去除查询参数
|
|
55
|
-
*
|
|
56
|
-
* @param {string} href - 待处理的URL字符串
|
|
57
|
-
* @param {string} [defaultName="file"] - 默认的文件名,当无法提取时使用
|
|
58
|
-
* @returns {string} URL路径的最后一部分,不包括查询参数
|
|
59
|
-
*/
|
|
60
|
-
export declare function _Format_HrefName(href: string, defaultName?: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* 驼峰命名
|
|
63
|
-
* @param {字符串} str
|
|
64
|
-
* @param {是否删除分割字符} isRemoveDelimiter
|
|
65
|
-
* @returns 'wq1wqw-qw2qw' -> 'wq1Wqw-Qw2Qw' / 'wqWqwQwQw'
|
|
66
|
-
*/
|
|
67
|
-
export declare function _Format_CamelCase(str: string, isRemoveDelimiter?: boolean): string;
|
|
68
|
-
/**
|
|
69
|
-
* 排除子串
|
|
70
|
-
* @param inputString 需裁剪字符串
|
|
71
|
-
* @param substringToDelete 被裁减字符串
|
|
72
|
-
* @param delimiter 分隔符
|
|
73
|
-
* @returns 裁减后的字符串
|
|
74
|
-
*/
|
|
75
|
-
export declare function _Format_ExcludeSubstring(inputString: string, substringToDelete: string, delimiter?: string): string;
|
package/dist/Format/type.d.ts
DELETED
|
File without changes
|
package/dist/Math/index.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将经纬度转换为平面坐标
|
|
3
|
-
* @param lng 经度
|
|
4
|
-
* @param lat 纬度
|
|
5
|
-
* @returns 平面坐标 [x, y](米)
|
|
6
|
-
*/
|
|
7
|
-
export declare function _Math_LngLatToPlane(lng: number, lat: number): [number, number];
|
|
8
|
-
/**
|
|
9
|
-
* 将平面坐标转换为经纬度
|
|
10
|
-
* @param x 平面坐标 X 值(米)
|
|
11
|
-
* @param y 平面坐标 Y 值(米)
|
|
12
|
-
* @returns 经纬度 [lng, lat](度)
|
|
13
|
-
*/
|
|
14
|
-
export declare function _Math_PlaneToLngLat(x: number, y: number): [number, number];
|
|
15
|
-
/**
|
|
16
|
-
* 计算点到线段的距离
|
|
17
|
-
* @param point 点击位置
|
|
18
|
-
* @param lineStart 线段起点
|
|
19
|
-
* @param lineEnd 线段终点
|
|
20
|
-
* @returns 点到线段的距离
|
|
21
|
-
*/
|
|
22
|
-
export declare function _Math_PointToLineDistance(point: [number, number], lineStart: [number, number], lineEnd: [number, number]): number;
|
|
23
|
-
/**
|
|
24
|
-
* 计算圆弧的起点和终点坐标
|
|
25
|
-
* @param x 圆心X坐标
|
|
26
|
-
* @param y 圆心Y坐标
|
|
27
|
-
* @param radius 圆弧半径
|
|
28
|
-
* @param startAngle 起始角度(弧度制,0表示X轴正方向)
|
|
29
|
-
* @param endAngle 结束角度(弧度制)
|
|
30
|
-
* @param axisX X轴方向(1=正方向向右,-1=正方向向左)
|
|
31
|
-
* @param axisY Y轴方向(1=正方向向上,-1=正方向向下)
|
|
32
|
-
* @returns [起点坐标[x,y], 终点坐标[x,y]]
|
|
33
|
-
*/
|
|
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
|
-
export declare function _Math_CalculateDistance2D(x1: number, y1: number, x2: number, y2: number): number;
|
|
37
|
-
/** 获取两点的中点 */
|
|
38
|
-
export declare function _Math_GetMidpoint(x1: number, y1: number, x2: number, y2: number): {
|
|
39
|
-
x: number;
|
|
40
|
-
y: number;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* 计算从起点沿方向向量延伸后与画布边界的交点
|
|
44
|
-
* @param startPoint 线段起点坐标 [x, y]
|
|
45
|
-
* @param direction 方向向量 [dx, dy]
|
|
46
|
-
* @param canvasWidth 画布宽度
|
|
47
|
-
* @param canvasHeight 画布高度
|
|
48
|
-
* @returns 与边界的交点坐标
|
|
49
|
-
*/
|
|
50
|
-
export declare function _Math_GetBoundaryIntersection(startPoint: [number, number], direction: [number, number], canvasWidth: number, canvasHeight: number): [number, number];
|
package/dist/Math/type.d.ts
DELETED
|
File without changes
|
package/dist/Utility/index.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 寻找空闲时机执行传入方法
|
|
3
|
-
* @param callback 需执行的方法
|
|
4
|
-
*/
|
|
5
|
-
export declare function _Utility_ExecuteWhenIdle(callback: Function): void;
|
|
6
|
-
/**
|
|
7
|
-
* 等待条件满足
|
|
8
|
-
* @param conditionChecker 条件检查器
|
|
9
|
-
* @param timeoutMillis 超时毫秒数
|
|
10
|
-
* @returns Promise<unknown>
|
|
11
|
-
*/
|
|
12
|
-
export declare function _Utility_WaitForCondition(conditionChecker: () => boolean, timeoutMillis: number): Promise<"完成" | "超时">;
|
|
13
|
-
/**
|
|
14
|
-
* 合并对象 注意: 本函数会直接操作 A
|
|
15
|
-
* @param {Object | Array} A
|
|
16
|
-
* @param {Object | Array} B
|
|
17
|
-
* @returns (A & B) | A | B | undefined
|
|
18
|
-
*/
|
|
19
|
-
export declare function _Utility_MergeObjects<T, T1>(A: T, B: T1, visitedObjects?: [any, any][], outTime?: number): (T & T1) | T | T1 | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* 生成一个UUID(通用唯一标识符)字符串
|
|
22
|
-
* 可以选择性地在UUID前面添加前缀
|
|
23
|
-
*
|
|
24
|
-
* @param {string} prefix - 可选参数,要添加到UUID前面的前缀
|
|
25
|
-
* @returns {string} 一个带有可选前缀的UUID字符串
|
|
26
|
-
*/
|
|
27
|
-
export declare function _Utility_GenerateUUID(prefix?: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* 防抖
|
|
30
|
-
* @param {Function} fn
|
|
31
|
-
* @param {number} delay
|
|
32
|
-
* @returns {Function}
|
|
33
|
-
*/
|
|
34
|
-
export declare function _Utility_Debounce<T extends (...args: any[]) => void>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
35
|
-
/**
|
|
36
|
-
* 节流
|
|
37
|
-
* @param {Function} fn
|
|
38
|
-
* @param {number} delay
|
|
39
|
-
* @returns {Function}
|
|
40
|
-
*/
|
|
41
|
-
export declare function _Utility_Throttle<T extends (...args: any[]) => void>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
42
|
-
/**
|
|
43
|
-
* 根据路径初始化目标对象
|
|
44
|
-
* 如果路径中某个属性不存在,则会创建该属性及其所有父属性
|
|
45
|
-
* 最终返回路径的最后一个属性对应的值或undefined(如果路径不存在)
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} model - 要初始化的模型对象
|
|
48
|
-
* @param {string} path - 属性路径,使用英文句点分隔
|
|
49
|
-
* @param {any} initValue - 初始值
|
|
50
|
-
* @returns {any} 路径的最后一个属性对应的值或 initValue
|
|
51
|
-
*/
|
|
52
|
-
export declare function _Utility_InitTargetByPath(model: any, path: string, initValue?: any): any;
|
|
53
|
-
/**
|
|
54
|
-
* 根据路径获取目标对象
|
|
55
|
-
* 该函数用于在给定的模型中,通过路径字符串来获取深层嵌套的目标对象如果路径中的某一部分不存在,则会创建一个新的对象(除非已经是路径的最后一部分)
|
|
56
|
-
*
|
|
57
|
-
* @param {Object} model - 包含要查询的数据的模型对象
|
|
58
|
-
* @param {string} path - 用点分隔的路径字符串,表示要访问的对象属性路径
|
|
59
|
-
* @returns {Object|undefined} - 返回目标对象,如果路径不存在则返回undefined
|
|
60
|
-
*/
|
|
61
|
-
export declare function _Utility_GetTargetByPath(model: any, path: string): any;
|
|
62
|
-
/**
|
|
63
|
-
* 根据路径更新目标值
|
|
64
|
-
*
|
|
65
|
-
* 该函数通过一个点分隔的路径来更新一个对象中的嵌套属性值
|
|
66
|
-
* 它使用了reduce方法来遍历路径数组,并在路径的终点设置新的值
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} model - 包含要更新数据的模型对象
|
|
69
|
-
* @param {string} path - 点分隔的字符串路径,指示如何到达目标属性
|
|
70
|
-
* @param {*} value - 要设置的新值
|
|
71
|
-
* @returns {*} - 返回更新后的模型对象中的值
|
|
72
|
-
*/
|
|
73
|
-
export declare function _Utility_SetTargetByPath(model: any, path: string, value: any): any;
|
|
74
|
-
/**
|
|
75
|
-
* 旋转列表函数
|
|
76
|
-
*
|
|
77
|
-
* 该函数接受一个列表作为参数,并返回一个二维数组,其中每个内部数组都是原列表的一种旋转形式
|
|
78
|
-
* 旋转列表的原理是将原列表分割成两部分,并将这两部分重新组合,形成一个新的列表
|
|
79
|
-
*
|
|
80
|
-
* @param list T[] - 需要旋转的列表,列表元素类型为泛型T
|
|
81
|
-
* @returns T[][] - 返回一个二维数组,每个内部数组代表原列表的一种旋转形式
|
|
82
|
-
*/
|
|
83
|
-
export declare function _Utility_RotateList<T>(list: T[]): T[][];
|
|
84
|
-
/**
|
|
85
|
-
* 克隆给定值的函数
|
|
86
|
-
* 该函数尝试使用window.structuredClone方法进行深克隆,如果失败则使用自定义方法
|
|
87
|
-
* @param {any} val - 需要克隆的值
|
|
88
|
-
* @returns {any} - 克隆后的值
|
|
89
|
-
*/
|
|
90
|
-
export declare function _Utility_Clone<T>(val: T): T;
|
|
91
|
-
/**
|
|
92
|
-
* 函数装饰器,用于测量并记录另一个函数的执行时间
|
|
93
|
-
* @param func 要测量执行时间的函数
|
|
94
|
-
* @param level 耗时与颜色对应的数组,用于在控制台中着色显示
|
|
95
|
-
* @param maxHistory 保留的最大历史记录数,默认为30
|
|
96
|
-
*/
|
|
97
|
-
export declare function _Utility_TimeConsumption(func: Function, level: [number, string][], maxHistory?: number): void | ((...args: any[]) => any);
|
|
98
|
-
/**
|
|
99
|
-
* 暂停执行指定毫秒数的操作
|
|
100
|
-
* 此函数通过 busy-wait(忙等待)的方式实现,它会持续执行一些无用的操作以消耗时间
|
|
101
|
-
* 这种方法虽然简单,但会占用CPU资源,因此不推荐在实际应用中使用
|
|
102
|
-
*
|
|
103
|
-
* @param ms 暂停的毫秒数
|
|
104
|
-
* @returns 实际暂停的毫秒数
|
|
105
|
-
*/
|
|
106
|
-
export declare function _Utility_Sleep(ms: number): number;
|
package/dist/Utility/type.d.ts
DELETED
|
File without changes
|
package/dist/Valid/index.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { FileType } from '../Constant';
|
|
2
|
-
import { DataType, Point } from './type';
|
|
3
|
-
/**
|
|
4
|
-
* 是正常对象吗
|
|
5
|
-
* @param {} value
|
|
6
|
-
* @returns boolean
|
|
7
|
-
*/
|
|
8
|
-
export declare function _Valid_IsObject(value: any): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* 检查单个一维数组参数是否合法(元素为有限数字)
|
|
11
|
-
* @param arr - 待检查的数组
|
|
12
|
-
* @param minLength - 数组最小长度 (默认2)
|
|
13
|
-
* @returns 参数合法返回 true,否则返回 false
|
|
14
|
-
*/
|
|
15
|
-
export declare function _Valid_IsNumberArray(arr: unknown, minLength?: number): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* 检查二维数组结构是否合法(每个元素都是有效的一维数组)
|
|
18
|
-
* @param arr - 待检查的二维数组
|
|
19
|
-
* @param minLength - 外层数组最小长度 (默认1)
|
|
20
|
-
* @param innerMinLength - 内层数组最小长度 (默认2)
|
|
21
|
-
* @returns 所有元素都合法返回 true,否则返回 false
|
|
22
|
-
*/
|
|
23
|
-
export declare function _Valid_Is2DNumberArray(arr: unknown, minLength?: number, innerMinLength?: number): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 误差范围
|
|
26
|
-
* @param value 需要判断的数字
|
|
27
|
-
* @param target 目标数字
|
|
28
|
-
* @param errorMargin 正负误差范围
|
|
29
|
-
* @returns 是否在误差内
|
|
30
|
-
*/
|
|
31
|
-
export declare function _Valid_IsInMargin(value: number, target: number, errorMargin: number): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* 判断点是否在多边形内
|
|
34
|
-
* @param point - 待检测的点,包含 x 和 y 坐标
|
|
35
|
-
* @param polygon - 多边形的点集,数组形式,每个点包含 x 和 y 坐标
|
|
36
|
-
* @returns boolean - 点是否在多边形内
|
|
37
|
-
*/
|
|
38
|
-
export declare function _Valid_IsPointInPolygon(point: Point, polygon: Point[]): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* 判断无限延伸的直线是否与矩形区域相交
|
|
41
|
-
* @param rectCorner1 矩形对角顶点1 [x, y]
|
|
42
|
-
* @param rectCorner2 矩形对角顶点2 [x, y]
|
|
43
|
-
* @param linePointA 直线上一点A [x, y]
|
|
44
|
-
* @param linePointB 直线上一点B [x, y]
|
|
45
|
-
* @returns 直线是否与矩形相交
|
|
46
|
-
*/
|
|
47
|
-
export declare function _Valid_DoesInfiniteLineIntersectRectangle(rectCorner1: [number, number], rectCorner2: [number, number], linePointA: [number, number], linePointB: [number, number]): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* 数据类型
|
|
50
|
-
* @param {any} value
|
|
51
|
-
* @returns string
|
|
52
|
-
*/
|
|
53
|
-
export declare function _Valid_DataType(value: any): DataType;
|
|
54
|
-
/**
|
|
55
|
-
* 判断给定URL是否指向一个安全上下文
|
|
56
|
-
*
|
|
57
|
-
* 安全上下文是指通过一系列安全协议访问的资源,这些协议提供了数据的加密传输和身份验证
|
|
58
|
-
* 本函数通过检查URL的协议前缀来判断是否属于安全上下文
|
|
59
|
-
*
|
|
60
|
-
* @param {string} url - 待检查的URL字符串
|
|
61
|
-
* @returns {boolean} - 如果URL指向安全上下文,则返回true;否则返回false
|
|
62
|
-
*/
|
|
63
|
-
export declare function _Valid_IsSecureContext(url: string): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* 使用 XMLHttpRequest 检查指定 URL 的连接状态
|
|
66
|
-
*
|
|
67
|
-
* 此函数通过发送一个 HEAD 请求来检查给定 URL 是否可访问 HEAD 请求仅请求文档头部信息,
|
|
68
|
-
* 而不是整个页面,因此比 GET 或 POST 请求更快此方法常用于检查 URL 是否有效,以及服务器的响应时间等
|
|
69
|
-
*
|
|
70
|
-
* @param {string} url - 需要检查连接的 URL 地址
|
|
71
|
-
* @returns {Promise} - 返回一个 Promise 对象,该对象在连接成功时解析,在连接失败时拒绝
|
|
72
|
-
*/
|
|
73
|
-
export declare function _Valid_CheckConnectionWithXHR(url: string): Promise<unknown>;
|
|
74
|
-
/**
|
|
75
|
-
* 文件类型检查器类
|
|
76
|
-
* 用于检查文件URL的类型
|
|
77
|
-
*/
|
|
78
|
-
export declare class _Valid_FileTypeChecker {
|
|
79
|
-
private static cachedEntries;
|
|
80
|
-
constructor();
|
|
81
|
-
/**
|
|
82
|
-
* 检查给定URL的文件类型
|
|
83
|
-
* @param {string} url - 文件的URL
|
|
84
|
-
* @param {string} [type] - 可选参数,指定要检查的文件类型
|
|
85
|
-
* @returns {string} - 如果URL与指定类型或任何已知类型匹配,则返回文件类型,否则返回"unknown"
|
|
86
|
-
*/
|
|
87
|
-
static check(url: string): FileType | "unknown";
|
|
88
|
-
static check(url: string, type: FileType): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* 静态方法,用于解析地址信息
|
|
91
|
-
* 该方法接受一个URL字符串,将其解析为一个包含地址详情的对象数组
|
|
92
|
-
* 主要用于批量处理以逗号分隔的URL列表,为每个URL生成相应的名称和类型
|
|
93
|
-
*
|
|
94
|
-
* @param {string} url - 以逗号分隔的URL字符串,每个URL代表一个资源的位置
|
|
95
|
-
* @returns {Array} - 包含每个URL及其相关信息(名称和类型)的对象数组
|
|
96
|
-
*/
|
|
97
|
-
static parseAddresses(url: string): {
|
|
98
|
-
url: string;
|
|
99
|
-
name: string;
|
|
100
|
-
type: "audio" | "code" | "script" | "video" | "image" | "ppt" | "word" | "excel" | "pdf" | "text" | "archive" | "font" | "database" | "markup" | "configuration" | "logs" | "unknown";
|
|
101
|
-
}[];
|
|
102
|
-
/**
|
|
103
|
-
* 检查 MIME 类型是否与指定的模式匹配
|
|
104
|
-
* @param {string} type - 要检查的 MIME 类型(如 "image/png")
|
|
105
|
-
* @param {string} [accept] - 可接受的 MIME 类型模式(如 "image/*, text/plain")
|
|
106
|
-
* @returns {boolean} - 如果类型匹配,则返回 true,否则返回 false
|
|
107
|
-
*/
|
|
108
|
-
static matchesMimeType(type: string, accept?: string): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* 类型标准化函数
|
|
111
|
-
* 该函数旨在将文件类型或MIME类型字符串转换为标准格式
|
|
112
|
-
* 主要处理三种情况:带扩展名的字符串、简写格式的类型以及已标准格式的类型
|
|
113
|
-
*
|
|
114
|
-
* @param {string} type - 文件类型或MIME类型字符串
|
|
115
|
-
* @returns {string} 标准化的MIME类型字符串,如果无法识别则返回原始输入
|
|
116
|
-
*/
|
|
117
|
-
static _normalizeType(type: string): string;
|
|
118
|
-
/**
|
|
119
|
-
* 检查URL是否具有任何指定的文件扩展名
|
|
120
|
-
* @param {string} url - 文件的URL
|
|
121
|
-
* @param {string[]} validExtensions - 有效文件扩展名的数组
|
|
122
|
-
* @returns {boolean} - 如果URL具有任何指定的文件扩展名,则返回true,否则返回false
|
|
123
|
-
*/
|
|
124
|
-
static _checkExtension(url: string, validExtensions: string[]): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* 检测文件URL的类型
|
|
127
|
-
* @param {string} url - 文件的URL
|
|
128
|
-
* @returns {string} - 如果URL与任何已知类型匹配,则返回文件类型,否则返回"unknown"
|
|
129
|
-
*/
|
|
130
|
-
static _detectFileType(url: string): "audio" | "code" | "script" | "video" | "image" | "ppt" | "word" | "excel" | "pdf" | "text" | "archive" | "font" | "database" | "markup" | "configuration" | "logs" | "unknown";
|
|
131
|
-
}
|
package/dist/Valid/type.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export interface Point {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
}
|
|
5
|
-
/** 定义所有可能的数据类型字符串 */
|
|
6
|
-
export type DataType = "null" | "undefined" | "boolean" | "number" | "string" | "symbol" | "bigint" | "function" | "array" | "object" | "date" | "regexp" | "map" | "set" | "error" | "promise" | "weakmap" | "weakset" | "arraybuffer" | "dataview" | "int8array" | "uint8array" | "uint8clampedarray" | "int16array" | "uint16array" | "int32array" | "uint32array" | "float32array" | "float64array" | "bigint64array" | "biguint64array";
|
package/dist/index.cjs.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".no-select{-webkit-user-select:none;-ms-user-select:none;user-select:none}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
"use strict";var pt=Object.defineProperty;var st=n=>{throw TypeError(n)};var gt=(n,e,t)=>e in n?pt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>gt(n,typeof e!="symbol"?e+"":e,t),at=(n,e,t)=>e.has(n)||st("Cannot "+t);var u=(n,e,t)=>(at(n,e,"read from private field"),t?t.call(n):e.get(n)),f=(n,e,t)=>e.has(n)?st("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),m=(n,e,t,i)=>(at(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ct={".mp3":"audio/mpeg",".mp4":"video/mp4",".m4a":"audio/mp4",".aac":"audio/aac",".ogg":"audio/ogg",".wav":"audio/wav",".flac":"audio/flac",".opus":"audio/opus",".webm":"video/webm",".avi":"video/x-msvideo",".mov":"video/quicktime",".wmv":"video/x-ms-wmv",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".bmp":"image/bmp",".tiff":"image/tiff",".ico":"image/vnd.microsoft.icon",".svg":"image/svg+xml",".webp":"image/webp",".heif":"image/heif",".heic":"image/heic",".json":"application/json",".xml":"application/xml",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".ts":"application/typescript",".csv":"text/csv",".tsv":"text/tab-separated-values",".txt":"text/plain",".md":"text/markdown",".rtf":"application/rtf",".pdf":"application/pdf",".zip":"application/zip",".rar":"application/x-rar-compressed",".tar":"application/x-tar",".gz":"application/gzip",".7z":"application/x-7z-compressed",".exe":"application/x-msdownload",".apk":"application/vnd.android.package-archive",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".odt":"application/vnd.oasis.opendocument.text",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odp":"application/vnd.oasis.opendocument.presentation",".jsonld":"application/ld+json",".yaml":"application/x-yaml",".yml":"application/x-yaml",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".map":"application/json"},G={image:[".jpg",".jpeg",".png",".gif",".bmp",".webp",".tiff",".svg",".heif",".heic",".ico",".raw",".jfif",".avif",".png8",".indd",".eps",".ai"],ppt:[".ppt",".pptx",".odp"],word:[".doc",".docx",".odt",".rtf"],excel:[".xls",".xlsx",".ods",".csv",".tsv"],pdf:[".pdf"],text:[".txt",".csv",".md",".json",".yaml",".yml",".log",".ini",".rtf"],audio:[".mp3",".wav",".ogg",".flac",".aac",".wma",".m4a",".alac",".ape",".opus",".amr",".ra",".mid",".midi",".aiff",".pcm",".au",".wavpack",".spx"],video:[".mp4",".avi",".mkv",".mov",".wmv",".flv",".webm",".mpg",".mpeg",".3gp",".vob",".ogv",".m4v",".ts",".rm",".rmvb",".m2ts",".divx",".xvid",".swf",".f4v"],archive:[".zip",".rar",".tar",".gz",".bz2",".xz",".7z",".tar.gz",".tar.bz2",".tar.xz",".tar.lz",".tar.lzma",".cab",".iso",".dmg",".tgz",".apk",".gz2",".tar.zst"],code:[".js",".ts",".py",".java",".cpp",".c",".html",".css",".scss",".less",".sass",".php",".rb",".go",".swift",".rs",".kt",".scala",".lua",".pl",".m",".h",".xml",".json",".yaml",".yml",".toml",".vue",".ejs",".handlebars",".jinja",".dart"],font:[".woff",".woff2",".ttf",".otf",".eot",".svg",".ttc",".fnt",".fon",".otc"],database:[".sql",".sqlite",".db",".mdb",".accdb",".jsonld",".xml",".csv"],markup:[".html",".htm",".xhtml",".xml",".json",".yaml",".yml"],configuration:[".ini",".conf",".cfg",".env",".properties",".json",".toml"],logs:[".log",".err",".trace",".out"],script:[".bash",".sh",".zsh",".bat",".ps1",".vbs",".cmd",".sed",".awk",".php"]},et=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],_t=["_self","_blank","_parent","_top"],rt={Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6},Tabloid:{width:279.4,height:431.8},Ledger:{width:431.8,height:279.4},Executive:{width:184.2,height:266.7},Folio:{width:215.9,height:330.2},Quarto:{width:215,height:275},"Government-Letter":{width:203.2,height:266.7},A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},A10:{width:26,height:37},B0:{width:1e3,height:1414},B1:{width:707,height:1e3},B2:{width:500,height:707},B3:{width:353,height:500},B4:{width:250,height:353},B5:{width:176,height:250},B6:{width:125,height:176},B7:{width:88,height:125},B8:{width:62,height:88},B9:{width:44,height:62},B10:{width:31,height:44},C0:{width:917,height:1297},C1:{width:648,height:917},C2:{width:458,height:648},C3:{width:324,height:458},C4:{width:229,height:324},C5:{width:162,height:229},C6:{width:114,height:162},C7:{width:81,height:114},C8:{width:57,height:81}},wt=Object.keys(rt).map(n=>({value:n,label:n}));function yt(n,e=500){let t,i=!0;function o(r){if(!i)return;t||(t=r);let a=Math.min((r-t)/e,1);n(a),r-t<e&&requestAnimationFrame(o)}return requestAnimationFrame(o),()=>i=!1}function xt(n,e,t,i,o=2){let r=n,a=!1,s=1,c=n,l=e,h=t;const d=()=>{const x=(l-c)/h;return Number(x.toFixed(o))};let p=d();const y=x=>Math.min(Math.max(x,c),l),_=x=>Number(x.toFixed(o)),I=(x,H,V)=>{const S=[];return x>=H&&S.push("最小值必须小于最大值"),V<=0?S.push("分段数必须为正数"):d()==0&&S.push("数值精度过低,致使动画步长为 0"),S},j=(x,H,V)=>{const S=I(x,H,V);return S.length>0?(console.error(`参数更新失败: ${S.join("; ")}`),!1):(c=x,l=H,h=V,p=d(),r=y(r),!0)},X=()=>{a&&(s=r>=l?-1:r<=c?1:s,r=y(r+p*s),i(_(r)),requestAnimationFrame(X))};return{play(x=r){if(r=y(x),I(c,l,h).length)return console.error("配置参数错误",this.getParams());a||(a=!0,X())},pause(){a=!1},getCurrent:()=>_(r),isPlaying:()=>a,updateParams:j,getParams:()=>({min:c,max:l,steps:h,precision:o,stepSize:p})}}function bt(n,e,t,i,o=2){if(t<=0)return console.error("动画步数 必须为正数");const r=d=>Number(d.toFixed(o)),a=e-n,s=r(Math.abs(a)/t);if(s===0)return console.error("数值精度过低,致使动画步长为 0");const c=Math.sign(a);let l=n;const h=()=>{l=r(l+s*c),(c>0?l<e:l>e)?(i(l),requestAnimationFrame(h)):i(e)};h()}function vt(n,e="image/png"){try{let t,i=e;if(n instanceof File)return URL.createObjectURL(n);if(typeof n=="string"){let r=n;const a=r.match(/^data:([^;]*)(;base64)?,(.*)$/i);if(a){if(!a[2])return console.error("无效的数据 URL:缺少 base64 编码声明");if(i=a[1]||i,r=a[3],!r)return console.error("数据 URL 包含空有效负载")}r=r.replace(/[^A-Za-z0-9+/=]/g,"");const s=atob(r);t=new Uint8Array(s.length);for(let c=0;c<s.length;c++)t[c]=s.charCodeAt(c)}else if(n instanceof ArrayBuffer)t=new Uint8Array(n);else if(n instanceof Uint8Array)t=n;else return console.error("不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array");const o=new Blob([t],{type:i});return URL.createObjectURL(o)}catch(t){return console.error("数据到 ImageURL 的转换失败:",t.message,t.stack||"没有可用的堆栈跟踪"),null}}function Et(n,e=10){let t=0,i=e;function o(){if(i>0)i--,requestAnimationFrame(o);else{const a=(+new Date-t)/e,s=1e3/a;n(Number(s.toFixed(2)),Number(a.toFixed(2)))}}requestAnimationFrame(()=>{t=+new Date,o()})}function Mt(n){const e=()=>Promise.resolve(),t=s=>(console.error(s),Promise.reject(s));function i(){return navigator.clipboard.writeText(n).then(e).catch(t)}function o(){const s=document.createElement("div");s.innerText=n,document.body.appendChild(s);const c=document.createRange();c.selectNodeContents(s);const l=window.getSelection();let h=!1;return l&&(l.removeAllRanges(),l.addRange(c),h=document.execCommand("copy")),document.body.removeChild(s),h?Promise.resolve():Promise.reject()}function r(){const s=document.createElement("textarea");s.value=n,document.body.appendChild(s),s.select(),s.setSelectionRange(0,n.length);let c=!1;return document.activeElement===s&&(c=document.execCommand("Copy",!0)),document.body.removeChild(s),c?Promise.resolve():Promise.reject()}function a(){return o().then(e).catch(()=>{r().then(e).catch(()=>t("复制方式尽皆失效"))})}return navigator.clipboard?i().catch(a):a()}class lt{constructor(){}static add(e,t){this.keys.set(e,t)}static open(e,t,i,o){const r=this.keys.get(e);if(r&&!r.closed)return r.focus(),r;{const a=window.open(t,i,o);if(a)return this.keys.set(e,a),a;console.error("window.open failed: 可能是浏览器阻止了弹出窗口"),this.keys.delete(e)}}static isOpen(e){const t=this.keys.get(e);return t!=null&&t.closed&&this.keys.delete(e),this.keys.has(e)}static getWindow(e){if(this.isOpen(e))return this.keys.get(e)}static close(e){const t=this.keys.get(e);t&&(t.close(),this.keys.delete(e))}static closeAll(){this.keys.forEach((e,t)=>e.close()),this.keys.clear()}}F(lt,"keys",new Map);function Ft(n,e){const t=rt[n];if(!t)throw new Error(`未知纸张类型: ${n}`);const{width:i,height:o}=t,r=_=>_/25.4,s=typeof window<"u"?window.devicePixelRatio*96:300,c=_=>Math.round(r(_)*s),l=c(i),h=c(o),d=c(e),p=Math.max(0,l-2*d),y=Math.max(0,h-2*d);return{contentWidth:p,contentHeight:y,paddingPx:d,paperWidthPx:l,paperHeightPx:h}}function Ct(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Tt(n,e,t=2){return!Number.isFinite(n)||!Number.isFinite(e)||!Number.isFinite(t)?(console.error("所有参数必须是有限的数字"),""):e===0?(console.error("分母不能为零"),""):t<0?(console.error("小数位数不能为负数"),""):(n/e*100).toFixed(t)+"%"}function It(n){const t=n.toString().split("."),i=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?i+"."+t[1]:i}function Pt(n,e){const t={join:!0,suffix:"",decimalPlaces:2},{join:i,suffix:o,decimalPlaces:r}={...t,...e||{}},a=Number(n);if(isNaN(a))return i?`0${o}`:[0,o];const s=Math.abs(a),c=a>=0,l=Math.max(0,Math.floor(Math.log10(s)/4)),h=Math.pow(1e4,l),d=s/h,p=(c?1:-1)*parseFloat(d.toFixed(Math.max(0,r)));return i?`${p}${et[l]}${o}`:[p,et[l]+o]}function Lt(n){const e=["B","KB","MB","GB","TB","PB"];let t=0;for(;n>1024;)n/=1024,t++;return`${Math.round(n*100)/100} ${e[t]}`}function St(n,e="YYYY-MM-DD hh:mm:ss",t=!0){const i=new Date(n);if(isNaN(i.getTime()))return console.error("Invalid date"),"";const o={YYYY:r=>r.getFullYear(),MM:r=>r.getMonth()+1,DD:r=>r.getDate(),hh:r=>r.getHours(),mm:r=>r.getMinutes(),ss:r=>r.getSeconds(),ms:r=>r.getMilliseconds()};return e.replace(/YYYY|MM|DD|hh|mm|ss|ms/g,r=>{const a=o[r](i);return t?String(a).padStart(2,"0"):String(a)})}function Z(n,e="file"){if(!n||(n=String(n).trim(),n===""))return e;const t=n.split("/");return t[t.length-1].split("?")[0]}function At(n,e){return n=n.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),e?n.replace(/[^a-zA-Z]+/g,""):n}function Ut(n,e,t=","){const i=new RegExp(`(^|${t})${e}(${t}|$)`,"g");return n.replace(i,function(o,r,a){return r===a?t:""})}function Ot(n){return!(n===null||typeof n!="object"||Array.isArray(n))}function ut(n,e=2){if(Array.isArray(n)&&n.length>=e){for(let i=0;i<n.length;i++)if(typeof n[i]!="number"||!Number.isFinite(n[i]))return!1}else return!1;return!0}function Rt(n,e=1,t=2){if(Array.isArray(n)&&n.length>=e){for(let o=0;o<n.length;o++)if(!ut(n[o],t))return!1}else return!1;return!0}function Dt(n,e,t){return Math.abs(n-e)<=t}function jt(n,e){let t=!1;const{x:i,y:o}=n,r=e.length;for(let a=0,s=r-1;a<r;s=a++){const c=e[a].x,l=e[a].y,h=e[s].x,d=e[s].y;l>o!=d>o&&i<(h-c)*(o-l)/(d-l)+c&&(t=!t)}return t}function kt(n,e,t,i){const o=Math.min(n[0],e[0]),r=Math.max(n[0],e[0]),a=Math.min(n[1],e[1]),s=Math.max(n[1],e[1]),c=[[o,a],[r,a],[r,s],[o,s]],l=i[1]-t[1],h=t[0]-i[0],d=i[0]*t[1]-t[0]*i[1];if(l===0&&h===0){const[I,j]=t;return I>=o&&I<=r&&j>=a&&j<=s}const p=1e-10;let y=!1,_=!1;for(const[I,j]of c){const X=l*I+h*j+d;if(Math.abs(X)<p||(X>p?y=!0:_=!0,y&&_))return!0}return y&&_}function K(n){return Object.prototype.toString.call(n).slice(8,-1).toLowerCase()}function Nt(n){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>n.startsWith(t))}function zt(n){return new Promise((e,t)=>{if(typeof n!="string"||n.trim()===""||!n.includes("://")){t(new Error("Invalid URL: Must be a non-empty string"));return}try{new XMLHttpRequest().open("HEAD",n,!0)}catch(r){t(new Error(`Invalid URL format: ${r.message}`));return}const i=new XMLHttpRequest;i.open("HEAD",n,!0);const o=r=>{t(new Error(`Request failed: ${r.type}`))};i.onreadystatechange=function(){i.readyState===XMLHttpRequest.DONE&&(i.status===0?t(new Error("Network error or CORS blocked")):i.status>=200&&i.status<300?e(!0):t(new Error(`HTTP Error: ${i.status}`)))},i.onerror=o,i.onabort=o,i.ontimeout=o;try{i.send()}catch(r){t(new Error(`Request send failed: ${r.message}`))}})}const P=class P{constructor(){if(new.target===P)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(e,t){if(!e||typeof e!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const i=Z(e).toLowerCase();if(t){if(!G.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const o=G[t];return P._checkExtension(i,o)}return P._detectFileType(i)}static parseAddresses(e){return!e||typeof e!="string"?(console.error("Invalid URL provided"),[]):e.split(",").map(t=>{const i=Z(t),o=this.check(t);return{url:t,name:i,type:o}})}static matchesMimeType(e,t){if(!t)return!0;if(typeof e!="string"||typeof t!="string")return!1;const i=P._normalizeType(e),o=t.split(",").map(s=>P._normalizeType(s.trim())),[r,a="*"]=i.split("/");return o.some(s=>{const[c,l="*"]=s.split("/");return(c==="*"||r==="*"||c===r)&&(l==="*"||a==="*"||l===a)})}static _normalizeType(e){return e.startsWith(".")&&!e.includes("/")?ct[e.toLowerCase()]||e:e.includes("/")?e:`${e}/*`}static _checkExtension(e,t){return t.some(i=>e.endsWith(i))}static _detectFileType(e){for(const[t,i]of P.cachedEntries)if(i.some(o=>e.endsWith(o)))return t;return"unknown"}};F(P,"cachedEntries",Object.entries(G));let nt=P;function Bt(n){if(typeof n!="function")return console.error("非函数:",n);const e=function(t){t.didTimeout||t.timeRemaining()<=0?requestIdleCallback(e):n()};requestIdleCallback(e)}function qt(n,e){const t=+new Date;return new Promise((i,o)=>{const r=()=>{if(+new Date-t>=e)return o("超时");if(n())return i("完成");requestIdleCallback(r)};r()})}function it(n,e,t=[],i=+new Date){if(i<+new Date-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const o=K(n),r=K(e);if(o!=r)return e;if(o=="object"||o=="array"){if(t.some(([a,s])=>a==n&&s==e))return n;if(t.push([n,e]),o=="object"){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)){const s=e[a],c=n[a],l=it(c,s,t,i);n[a]=l}return n}else if(o=="array")return e.forEach((a,s)=>{const c=a,l=n[s],h=it(l,c,t,i);n[s]=h}),n}else return e}function Wt(n=""){return n+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function ht(n,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>{n(...i),t=void 0},e)}}function $t(n,e){let t=-1/0;return function(...i){const o=performance.now();if(o-t>e){t=o;try{n(...i)}catch(r){console.error("Throttled function execution failed:",r)}}}}function Yt(n,e,t){if(!n||!e)return n;const i=e.split(".");return i.reduce((o,r,a)=>o.hasOwnProperty(r)?o[r]:a===i.length-1?o[r]=t:o[r]={},n)}function Xt(n,e){if(!n||!e)return n;const t=e.split(".");return t.reduce((i,o,r)=>i.hasOwnProperty(o)?i[o]:r==t.length-1?void 0:{},n)}function Ht(n,e,t){if(!n||!e)return n;const i=e.split(".");return i.reduce((o,r,a)=>(a===i.length-1&&(o[r]=t),o.hasOwnProperty(r)?o[r]:o[r]={}),n)}function Vt(n){return n.map((e,t)=>n.slice(t).concat(n.slice(0,t)))}function Gt(n){const e=window.structuredClone,t=(i,o=new WeakMap)=>{const r=i;if(r===null||typeof r!="object")return r;if(o.has(r))return o.get(r);switch(K(r)){case"array":{const s=[];o.set(r,s);for(const c of r)s.push(t(c,o));return s}case"object":{if(r===null)return r;const s={};o.set(r,s);for(const c in r)Object.prototype.hasOwnProperty.call(r,c)&&(s[c]=t(r[c],o));return s}case"date":{const s=new Date(r.getTime());return o.set(r,s),s}case"regexp":{const s=r,c=new RegExp(s.source,s.flags);return c.lastIndex=s.lastIndex,o.set(r,c),c}case"map":{const s=new Map;return o.set(r,s),r.forEach((c,l)=>{s.set(t(l,o),t(c,o))}),s}case"set":{const s=new Set;return o.set(r,s),r.forEach(c=>{s.add(t(c,o))}),s}case"arraybuffer":case"dataview":case"int8array":case"uint8array":case"uint8clampedarray":case"int16array":case"uint16array":case"int32array":case"uint32array":case"float32array":case"float64array":case"bigint64array":case"biguint64array":{const s=r,c=s.constructor,l=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),h=new c(l,s.byteOffset,s.byteLength/s.BYTES_PER_ELEMENT);return o.set(r,h),h}case"error":{const s=r,c=new s.constructor(s.message);return c.stack=s.stack,c.name=s.name,o.set(r,c),c}case"function":case"promise":case"weakmap":case"weakset":default:return r}};try{return e?e(n):t(n)}catch(i){return console.error("structuredClone error:",i),e&&t(n)}}function Zt(n,e,t=30){if(typeof n!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(e))return console.error("第二个参数必须是一个数组。");let i=[],o=0;const r=(a,s)=>{for(const[c,l]of s)if(a>=c)return l;return"black"};return function(...a){const s=performance.now(),c=n(...a),l=performance.now()-s;i.push(l),i.length>t&&i.shift(),o=i.reduce((p,y)=>p+y,0)/i.length||0;const h=r(l,e),d=r(o,e);return console.log(`%c单次耗时:${l.toFixed(2)}ms
|
|
3
|
-
%c平均耗时(${i.length}次):${o.toFixed(2)}ms`,`color: ${h}; padding: 2px 0;`,`color: ${d}; padding: 2px 0;`),c}}function Kt(n){const e=Date.now();let t=performance.now();for(;Date.now()-e<n;){t=Math.sin(t)*1e6,(t>1e6||t<-1e6)&&(t=0);try{const i=t.toString().substring(0,8);history.replaceState(null,"",`#${i}`)}catch{}}return Date.now()-e}function Qt(n){const e=ht(n,100);let t=0,i=0;return function(o){const r=o.target;if(!r||!(r instanceof Element))return;const{scrollTop:a,scrollHeight:s,clientHeight:c,scrollLeft:l,scrollWidth:h,clientWidth:d}=r;function p(){if(t==a)return;const _=t>a;if(t=a,_)return;s-a-c<=1&&e("vertical")}function y(){if(i==l)return;const _=i>l;if(i=l,_)return;h-l-d<=1&&e("horizontal")}p(),y()}}function Jt(n,e,t){const{isClickAllowed:i,uiLibrary:o=["naiveUI","ElementPlus","Element"]}=t||{},r=function(c){const l=[];for(const h in c)Object.hasOwnProperty.call(c,h)&&o.includes(h)&&l.push(...c[h]);return l}({naiveUI:[".v-binder-follower-container",".n-image-preview-container",".n-modal-container"],ElementPlus:[".el-popper"],Element:[".el-popper"]});function a(){e(),document.removeEventListener("mousedown",s)}function s(c){if(i){const d=i(c);if(d)return;if(d===!1)return a()}const l=c.target;if(!(l instanceof Element)||!l.isConnected)return;n.concat(r).some(d=>!!(l!=null&&l.closest(d)))||a()}requestAnimationFrame(()=>document.addEventListener("mousedown",s))}var b,A,U,N,z,C,T,L,B;class te{constructor(){f(this,b);f(this,A,!1);f(this,U,{});f(this,N,0);f(this,z,0);f(this,C,0);f(this,T,0);f(this,L);f(this,B)}init(e,t){m(this,b,e),m(this,L,t==null?void 0:t.limit),m(this,B,t==null?void 0:t.dragDom),m(this,U,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(e){const t=e==="bind"?"addEventListener":"removeEventListener";if(!u(this,b))return console.error("No DOM");u(this,b)[t]("mousedown",u(this,U).mousedown),document[t]("mousemove",u(this,U).mousemove),document[t]("mouseup",u(this,U).mouseup)}alterLocation(){if(!u(this,b))return console.error("No DOM");u(this,L)&&(m(this,C,Math.min(u(this,C),u(this,L).max.top)),m(this,C,Math.max(u(this,C),u(this,L).min.top)),m(this,T,Math.min(u(this,T),u(this,L).max.left)),m(this,T,Math.max(u(this,T),u(this,L).min.left))),u(this,b).style.setProperty("--top",u(this,C)+"px"),u(this,b).style.setProperty("--left",u(this,T)+"px")}mousedown(e){if(!u(this,b))return console.error("No DOM");if(u(this,B)&&e.target!=u(this,B))return;document.body.classList.add("no-select"),m(this,A,!0);const t=u(this,b).getBoundingClientRect(),{pageX:i,pageY:o}=e;m(this,N,i),m(this,z,o),m(this,C,t.y),m(this,T,t.x)}mousemove(e){const{pageX:t,pageY:i}=e;u(this,A)&&(m(this,C,u(this,C)+(i-u(this,z))),m(this,T,u(this,T)+(t-u(this,N))),m(this,N,t),m(this,z,i),this.alterLocation())}mouseup(){u(this,A)&&(m(this,A,!1),document.body.classList.remove("no-select"))}}b=new WeakMap,A=new WeakMap,U=new WeakMap,N=new WeakMap,z=new WeakMap,C=new WeakMap,T=new WeakMap,L=new WeakMap,B=new WeakMap;var v,O,R,q,W,E,M,w,$,Y;class ee{constructor(){f(this,v);f(this,O,!1);f(this,R,{});f(this,q,0);f(this,W,0);f(this,E,0);f(this,M,0);f(this,w);f(this,$);f(this,Y)}init(e,t={}){m(this,v,e),m(this,w,t.limit),m(this,$,t.update_move),m(this,Y,t.update_up),m(this,R,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(e){const t=e==="bind"?"addEventListener":"removeEventListener";if(!u(this,v))return console.error("No DOM");u(this,v)[t]("mousedown",u(this,R).mousedown),document[t]("mousemove",u(this,R).mousemove),document[t]("mouseup",u(this,R).mouseup)}updateValue(){const e={top:u(this,E),left:u(this,M),percentage:{top:0,left:0}};if(u(this,w)){const t=i=>u(this,w)?(e[i]-u(this,w).min[i])/(u(this,w).max[i]-u(this,w).min[i]):0;e.percentage={top:t("top")||0,left:t("left")||0}}return e}alterLocation(){if(!u(this,v))return console.error("No DOM");u(this,w)&&(m(this,E,Math.min(u(this,E),u(this,w).max.top)),m(this,E,Math.max(u(this,E),u(this,w).min.top)),m(this,M,Math.min(u(this,M),u(this,w).max.left)),m(this,M,Math.max(u(this,M),u(this,w).min.left))),u(this,$)&&u(this,$).call(this,this.updateValue()),u(this,v).style.setProperty("--top",u(this,E)+"px"),u(this,v).style.setProperty("--left",u(this,M)+"px")}mousedown(e){if(!u(this,v))return console.error("No DOM");document.body.classList.add("no-select"),m(this,O,!0);const t=u(this,v).getBoundingClientRect();m(this,W,t.y),m(this,q,t.x);const{pageX:i,pageY:o}=e;m(this,E,o-u(this,W)),m(this,M,i-u(this,q)),this.alterLocation()}mousemove(e){const{pageX:t,pageY:i}=e;u(this,O)&&(m(this,E,i-u(this,W)),m(this,M,t-u(this,q)),this.alterLocation())}mouseup(){u(this,O)&&(m(this,O,!1),document.body.classList.remove("no-select"),u(this,Y)&&u(this,Y).call(this,this.updateValue()))}}v=new WeakMap,O=new WeakMap,R=new WeakMap,q=new WeakMap,W=new WeakMap,E=new WeakMap,M=new WeakMap,w=new WeakMap,$=new WeakMap,Y=new WeakMap;function tt(n){if(typeof n=="string"){const e=document.querySelector(n);if(!e)throw new Error(`Element "${n}" not found`);return e}else return n||document.documentElement}function mt(n){const e=tt(n);return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.reject("No Fullscreen API")}function dt(){const n=document;return document.exitFullscreen?document.exitFullscreen():n.mozCancelFullScreen?n.mozCancelFullScreen():n.webkitExitFullscreen?n.webkitExitFullscreen():n.msExitFullscreen?n.msExitFullscreen():Promise.reject("No ExitFullscreen API")}function ot(n){const e=tt(n),t=document,i=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return e==i||!n&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function ne(n){return n=tt(n),function(){ot(n)?dt():mt(n)}}function ie(n,e){const t=tt(e),i=()=>{n(ot(t))};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),i(),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i)}}function re(n,e){if(typeof n=="number")return n;if(/px/.test(n))return Number(n.replace(/px/,""))||0;const t=document.createElement("div");t.style.width=n,e=e||document.body,e.appendChild(t);const i=t.getBoundingClientRect().width;return e.removeChild(t),i}function oe(n,e){if(!n)return;let t,i;if(typeof e=="string"){const r=document.querySelector(e);if(!r)return;const a=r.getBoundingClientRect();t=a.width,i=a.height}else if(Array.isArray(e))t=e[0],i=e[1];else{const r=e.getBoundingClientRect();t=r.width,i=r.height}const o=t/i;return o>n?[n*i,i]:o<n?[t,t/n]:[t,i]}function se(n,e=5e3){return new Promise((t,i)=>{const o=new Image;o.src=n;const r=setTimeout(()=>{i(new Error("图片加载超时")),o.onload=null,o.onerror=null},e);o.onload=()=>{clearTimeout(r);const a=o.naturalWidth,s=o.naturalHeight,c=a/s;t([o,c])},o.onerror=()=>{clearTimeout(r),i(new Error("图片加载失败"))},o.crossOrigin="Anonymous"})}function ae(n){return new Promise((e,t)=>{fetch(n).then(i=>e(i.text())).catch(i=>{console.error("Error fetching :",i),t(i)})})}function ft(n,e){return new Promise((t,i)=>{try{e=e||Z(n,"downloaded_file"),fetch(n).then(o=>(o.ok||i(`文件下载失败,状态码: ${o.status}`),o.blob())).then(o=>{const r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download=decodeURIComponent(e),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),t(o)}).catch(i)}catch(o){i(o)}})}function ce(n,e,t){if(!t){let r=e.replace(/^[^.]+./,"");r=r==e?"text/plain":"application/"+r,t={type:r}}const i=new Blob(n,t),o=URL.createObjectURL(i);ft(o,e)}const le=Math.PI/2,Q=Math.PI/180,J=6378137,ue=85.05112878;function he(n,e){const t=Math.max(Math.min(n,180),-180),i=Math.max(Math.min(e,ue),-85.05112878),o=t*Q*J,r=i*Q,a=Math.log(Math.tan(Math.PI/4+r/2))*J;return[o,a]}function me(n,e){const t=n/J/Q,i=(2*Math.atan(Math.exp(e/J))-le)/Q;return[t,i]}function de(n,e,t){const[i,o]=n,[r,a]=e,[s,c]=t,l=(s-r)**2+(c-a)**2;if(l===0)return Math.sqrt((i-r)**2+(o-a)**2);let h=((i-r)*(s-r)+(o-a)*(c-a))/l;return h=Math.max(0,Math.min(1,h)),Math.sqrt((i-(r+h*(s-r)))**2+(o-(a+h*(c-a)))**2)}function fe(n,e,t,i,o,r=1,a=1){const s=n+t*Math.cos(i)*r,c=e+t*Math.sin(i)*a,l=n+t*Math.cos(o)*r,h=e+t*Math.sin(o)*a;return[[s,c],[l,h]]}function pe(n,e,t,i){return Math.hypot(Math.abs(t-n),Math.abs(i-e))}function ge(n,e,t,i){const o=(n+t)/2,r=(e+i)/2;return{x:o,y:r}}function _e(n,e,t,i){const[o,r]=n,[a,s]=e;let c=1/0;if(a!==0){const l=a>0?(t-o)/a:-o/a;l>0&&(c=Math.min(c,l))}if(s!==0){const l=s>0?(i-r)/s:-r/s;l>0&&(c=Math.min(c,l))}return c===1/0?n:[o+a*c,r+s*c]}class k{constructor(e,t){F(this,"resolve");F(this,"reject");this.resolve=e,this.reject=t}run(e){var t,i;return e instanceof Promise?e.then(o=>{var r;return(r=this.resolve)==null||r.call(this),o}).catch(o=>{var r;return(r=this.reject)==null||r.call(this),Promise.reject(o)}):e?(t=this.resolve)==null||t.call(this):(i=this.reject)==null||i.call(this),e}}class we extends k{constructor(e){super(),this.resolve=e}warning(...e){const t=()=>{var i,o;return(o=(i=D.tips).warning)==null?void 0:o.call(i,...e)};return new k(this.resolve,t)}error(...e){const t=()=>{var i,o;return(o=(i=D.tips).error)==null?void 0:o.call(i,...e)};return new k(this.resolve,t)}}class ye extends k{constructor(e){super(),this.reject=e}info(...e){const t=()=>{var i,o;return(o=(i=D.tips).info)==null?void 0:o.call(i,...e)};return new k(t,this.reject)}success(...e){const t=()=>{var i,o;return(o=(i=D.tips).success)==null?void 0:o.call(i,...e)};return new k(t,this.reject)}}const g=class g{constructor(){if(new.target===g)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(e,t){if(typeof t!="function")return console.error("TipHandler must be a function");g.tips[e]=t}static resolveTip(e){return function(...t){const i=()=>{var o,r;return(r=(o=g.tips)[e])==null?void 0:r.call(o,...t)};return new we(i)}}static rejectTip(e){return function(...t){const i=()=>{var o,r;return(r=(o=g.tips)[e])==null?void 0:r.call(o,...t)};return new ye(i)}}};F(g,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),F(g,"info",g.resolveTip("info")),F(g,"success",g.resolveTip("success")),F(g,"warning",g.rejectTip("warning")),F(g,"error",g.rejectTip("error"));let D=g;exports.EXTENSION_TO_MIME=ct;exports.FILE_EXTENSIONS=G;exports.PAPER_SIZE_DEFINITIONS=rt;exports.PAPER_SIZE_OPTIONS=wt;exports.UNIT_LABELS=et;exports.WINDOW_TARGET=_t;exports._Animate_CreateOscillator=xt;exports._Animate_NumericTransition=bt;exports._Animate_Schedule=yt;exports._Blob_ConvertDataToImageUrl=vt;exports._Browser_CalculatePrintableArea=Ft;exports._Browser_CopyToClipboard=Mt;exports._Browser_GetFrameRate=Et;exports._Browser_KeyedWindowManager=lt;exports._Element_CalculateCanvasSize=oe;exports._Element_CloseOnOutsideClick=Jt;exports._Element_Drag=te;exports._Element_EnterFullscreen=mt;exports._Element_ExitFullscreen=dt;exports._Element_Fullscreen=ne;exports._Element_FullscreenObserver=ie;exports._Element_GetOtherSizeInPixels=re;exports._Element_IsFullscreen=ot;exports._Element_LoadImage=se;exports._Element_LocalDrag=ee;exports._Element_ScrollEndListener=Qt;exports._File_CreateAndDownload=ce;exports._File_Download=ft;exports._File_Read=ae;exports._Format_CamelCase=At;exports._Format_CapitalizeFirstLetter=Ct;exports._Format_ExcludeSubstring=Ut;exports._Format_FileSize=Lt;exports._Format_HrefName=Z;exports._Format_NumberWithCommas=It;exports._Format_NumberWithUnit=Pt;exports._Format_Percentage=Tt;exports._Format_Timestamp=St;exports._Math_CalculateDistance2D=pe;exports._Math_GetArcPoints=fe;exports._Math_GetBoundaryIntersection=_e;exports._Math_GetMidpoint=ge;exports._Math_LngLatToPlane=he;exports._Math_PlaneToLngLat=me;exports._Math_PointToLineDistance=de;exports._Tip=D;exports._Utility_Clone=Gt;exports._Utility_Debounce=ht;exports._Utility_ExecuteWhenIdle=Bt;exports._Utility_GenerateUUID=Wt;exports._Utility_GetTargetByPath=Xt;exports._Utility_InitTargetByPath=Yt;exports._Utility_MergeObjects=it;exports._Utility_RotateList=Vt;exports._Utility_SetTargetByPath=Ht;exports._Utility_Sleep=Kt;exports._Utility_Throttle=$t;exports._Utility_TimeConsumption=Zt;exports._Utility_WaitForCondition=qt;exports._Valid_CheckConnectionWithXHR=zt;exports._Valid_DataType=K;exports._Valid_DoesInfiniteLineIntersectRectangle=kt;exports._Valid_FileTypeChecker=nt;exports._Valid_Is2DNumberArray=Rt;exports._Valid_IsInMargin=Dt;exports._Valid_IsNumberArray=ut;exports._Valid_IsObject=Ot;exports._Valid_IsPointInPolygon=jt;exports._Valid_IsSecureContext=Nt;
|
package/dist/index.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export * from './Constant';
|
|
2
|
-
export * from './Animate';
|
|
3
|
-
export * from './Blob';
|
|
4
|
-
export * from './Browser';
|
|
5
|
-
export * from './Element';
|
|
6
|
-
export * from './File';
|
|
7
|
-
export * from './Format';
|
|
8
|
-
export * from './Math';
|
|
9
|
-
export * from './Utility';
|
|
10
|
-
export * from './Valid';
|
|
11
|
-
type TipHandler = ((...args: any[]) => void) | undefined;
|
|
12
|
-
type TipType = "info" | "success" | "warning" | "error";
|
|
13
|
-
declare class TipFlow {
|
|
14
|
-
protected resolve: TipHandler;
|
|
15
|
-
protected reject: TipHandler;
|
|
16
|
-
constructor(resolve?: TipHandler, reject?: TipHandler);
|
|
17
|
-
run<T>(value: T): T;
|
|
18
|
-
}
|
|
19
|
-
declare class ResolveTip extends TipFlow {
|
|
20
|
-
constructor(resolve: TipHandler);
|
|
21
|
-
warning(...args: any[]): TipFlow;
|
|
22
|
-
error(...args: any[]): TipFlow;
|
|
23
|
-
}
|
|
24
|
-
declare class RejectTip extends TipFlow {
|
|
25
|
-
constructor(reject: TipHandler);
|
|
26
|
-
info(...args: any[]): TipFlow;
|
|
27
|
-
success(...args: any[]): TipFlow;
|
|
28
|
-
}
|
|
29
|
-
export declare class _Tip {
|
|
30
|
-
static tips: Record<TipType, TipHandler>;
|
|
31
|
-
/**
|
|
32
|
-
* 构造函数
|
|
33
|
-
* @throws 如果尝试实例化该类,则抛出错误,因为应该使用静态方法
|
|
34
|
-
*/
|
|
35
|
-
constructor();
|
|
36
|
-
static register(type: TipType, handler: TipHandler): void;
|
|
37
|
-
private static resolveTip;
|
|
38
|
-
static info: (...args: any[]) => ResolveTip;
|
|
39
|
-
static success: (...args: any[]) => ResolveTip;
|
|
40
|
-
private static rejectTip;
|
|
41
|
-
static warning: (...args: any[]) => RejectTip;
|
|
42
|
-
static error: (...args: any[]) => RejectTip;
|
|
43
|
-
}
|