ranuts 0.1.0-alpha → 0.1.0-alpha-22
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 -0
- package/dist/build/build.es.d.ts +2 -0
- package/dist/build/build.umd.d.ts +2 -0
- package/dist/build/build.umd.ml.d.ts +2 -0
- package/dist/build/build.umd.node.d.ts +2 -0
- package/dist/build/build.umd.react.d.ts +2 -0
- package/dist/build/build.umd.utils.d.ts +2 -0
- package/dist/build/build.umd.wasm.d.ts +2 -0
- package/dist/color-48RIDBG4.js +82262 -0
- package/dist/examples/clone-deep-example.d.ts +1 -0
- package/dist/examples/is-equal-example.d.ts +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +151 -84
- package/dist/plugins/vite-plugins-banner.d.ts +2 -0
- package/dist/reactify-Z-V9Vblb.js +83 -0
- package/dist/src/arithmetic/index.d.ts +186 -0
- package/dist/src/cache/expires.d.ts +1 -0
- package/dist/src/ml/index.d.ts +2 -0
- package/dist/src/ml/index.js +1243 -0
- package/dist/src/ml/ocr.d.ts +11 -0
- package/dist/src/node/appendFile.d.ts +7 -0
- package/dist/src/node/body.d.ts +9 -0
- package/dist/src/node/color.d.ts +7 -0
- package/dist/src/node/command.d.ts +8 -0
- package/dist/src/node/ctx2req.d.ts +5 -0
- package/dist/src/node/fileInfo.d.ts +7 -0
- package/dist/src/node/fs.d.ts +7 -0
- package/dist/src/node/get.d.ts +10 -0
- package/dist/src/node/getIPAdress.d.ts +1 -0
- package/dist/src/node/index.d.ts +25 -0
- package/dist/src/node/index.js +54 -0
- package/dist/src/node/isColorSupported.d.ts +2 -0
- package/dist/src/node/paresUrl.d.ts +19 -0
- package/dist/src/node/readDir.d.ts +6 -0
- package/dist/src/node/readFile.d.ts +9 -0
- package/dist/src/node/router.d.ts +42 -0
- package/dist/src/node/send.d.ts +7 -0
- package/dist/src/node/server.d.ts +18 -0
- package/dist/src/node/startTask.d.ts +2 -0
- package/dist/src/node/stream.d.ts +15 -0
- package/dist/src/node/taskEnd.d.ts +2 -0
- package/dist/src/node/traverse.d.ts +17 -0
- package/dist/src/node/watchFile.d.ts +8 -0
- package/dist/src/node/websocket.d.ts +57 -0
- package/dist/src/node/writeFile.d.ts +8 -0
- package/dist/src/node/ws.d.ts +8 -0
- package/dist/src/optimize/index.d.ts +36 -0
- package/dist/src/optimize/promise.d.ts +0 -0
- package/dist/src/ran/commit.d.ts +0 -0
- package/dist/src/ran/dom.d.ts +0 -0
- package/dist/src/ran/hooks.d.ts +0 -0
- package/dist/src/ran/index.d.ts +20 -0
- package/dist/src/ran/min.d.ts +32 -0
- package/dist/src/ran/reconcile.d.ts +0 -0
- package/dist/src/ran/schedule.d.ts +0 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/index.js +4 -0
- package/dist/src/react/reactify.d.ts +2 -0
- package/dist/src/sort/bubble.d.ts +7 -0
- package/dist/src/sort/bucket.d.ts +7 -0
- package/dist/src/sort/count.d.ts +7 -0
- package/dist/src/sort/heap.d.ts +7 -0
- package/dist/src/sort/index.d.ts +0 -0
- package/dist/src/sort/insert.d.ts +7 -0
- package/dist/src/sort/merge.d.ts +7 -0
- package/dist/src/sort/quick.d.ts +7 -0
- package/dist/src/sort/radix.d.ts +7 -0
- package/dist/src/sort/randomArray.d.ts +9 -0
- package/dist/src/sort/select.d.ts +7 -0
- package/dist/src/sort/shell.d.ts +7 -0
- package/dist/src/utils/audioRecorder.d.ts +16 -0
- package/dist/src/utils/behavior.d.ts +15 -0
- package/dist/src/utils/bom.d.ts +230 -0
- package/dist/src/utils/color.d.ts +71 -0
- package/dist/src/utils/compose.d.ts +10 -0
- package/dist/src/utils/console.d.ts +1 -0
- package/dist/src/utils/debounce.d.ts +7 -0
- package/dist/src/utils/device.d.ts +25 -0
- package/dist/src/utils/dom.d.ts +105 -0
- package/dist/src/utils/error.d.ts +1 -0
- package/dist/src/utils/func.d.ts +1 -0
- package/dist/src/utils/img.d.ts +16 -0
- package/dist/src/utils/index.d.ts +35 -0
- package/dist/src/utils/index.js +4551 -0
- package/dist/src/utils/memoize.d.ts +7 -0
- package/dist/src/utils/mimeType.d.ts +9 -0
- package/dist/src/utils/monitor.d.ts +38 -0
- package/dist/src/utils/network.d.ts +39 -0
- package/dist/src/utils/noop.d.ts +2 -0
- package/dist/src/utils/number.d.ts +45 -0
- package/dist/src/utils/obj.d.ts +83 -0
- package/dist/src/utils/performance.d.ts +21 -0
- package/dist/src/utils/queue.d.ts +33 -0
- package/dist/src/utils/report.d.ts +8 -0
- package/dist/src/utils/request.d.ts +17 -0
- package/dist/src/utils/script.d.ts +7 -0
- package/dist/src/utils/signal.d.ts +6 -0
- package/dist/src/utils/storage.d.ts +2 -0
- package/dist/src/utils/str.d.ts +212 -0
- package/dist/src/utils/subscribe.d.ts +46 -0
- package/dist/src/utils/throttle.d.ts +15 -0
- package/dist/src/utils/time.d.ts +20 -0
- package/dist/src/utils/totp/sha/common.d.ts +151 -0
- package/dist/src/utils/totp/sha/converters.d.ts +88 -0
- package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
- package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
- package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
- package/dist/src/utils/totp/sha/sha.d.ts +103 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
- package/dist/src/utils/totp/totp.d.ts +23 -0
- package/dist/src/utils/visual/application.d.ts +14 -0
- package/dist/src/utils/visual/demo/index.d.ts +1 -0
- package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
- package/dist/src/utils/visual/enums.d.ts +27 -0
- package/dist/src/utils/visual/event/boundary.d.ts +22 -0
- package/dist/src/utils/visual/event/event.d.ts +14 -0
- package/dist/src/utils/visual/event/index.d.ts +6 -0
- package/dist/src/utils/visual/event/types.d.ts +32 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
- package/dist/src/utils/visual/graphics/index.d.ts +4 -0
- package/dist/src/utils/visual/index.d.ts +7 -0
- package/dist/src/utils/visual/math/bezier.d.ts +2 -0
- package/dist/src/utils/visual/math/enums.d.ts +3 -0
- package/dist/src/utils/visual/math/index.d.ts +5 -0
- package/dist/src/utils/visual/math/matrix.d.ts +113 -0
- package/dist/src/utils/visual/math/transform.d.ts +29 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
- package/dist/src/utils/visual/render/index.d.ts +3 -0
- package/dist/src/utils/visual/render/render.d.ts +15 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
- package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
- package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
- package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +17 -0
- package/dist/src/utils/visual/shape/circle.d.ts +11 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
- package/dist/src/utils/visual/shape/index.d.ts +7 -0
- package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
- package/dist/src/utils/visual/shape/shape.d.ts +6 -0
- package/dist/src/utils/visual/style/fill.d.ts +8 -0
- package/dist/src/utils/visual/style/index.d.ts +3 -0
- package/dist/src/utils/visual/style/line.d.ts +10 -0
- package/dist/src/utils/visual/types.d.ts +17 -0
- package/dist/src/utils/visual/vertex/container.d.ts +73 -0
- package/dist/src/utils/visual/vertex/index.d.ts +5 -0
- package/dist/src/utils/visual/vertex/point.d.ts +18 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
- package/dist/src/vnode/chainDom.d.ts +47 -0
- package/dist/src/vnode/h.d.ts +6 -0
- package/dist/src/vnode/hooks.d.ts +23 -0
- package/dist/src/vnode/htmlDomApi.d.ts +33 -0
- package/dist/src/vnode/init.d.ts +2 -0
- package/dist/src/vnode/is.d.ts +5 -0
- package/dist/src/vnode/modules/attributes.d.ts +8 -0
- package/dist/src/vnode/modules/class.d.ts +8 -0
- package/dist/src/vnode/modules/index.d.ts +3 -0
- package/dist/src/vnode/modules/listeners.d.ts +12 -0
- package/dist/src/vnode/modules/props.d.ts +8 -0
- package/dist/src/vnode/modules/style.d.ts +14 -0
- package/dist/src/vnode/vnode.d.ts +31 -0
- package/dist/src/wasm/index.d.ts +2 -0
- package/dist/src/wasm/index.js +346 -0
- package/dist/src/wasm/word.d.ts +17 -0
- package/dist/src/wicket/bridge.d.ts +4 -0
- package/dist/src/wicket/index.d.ts +29 -0
- package/dist/test/arithmetic.test.d.ts +1 -0
- package/dist/test/cloneDeep.test.d.ts +1 -0
- package/dist/test/encodeUrl.test.d.ts +1 -0
- package/dist/test/escapeHtml.test.d.ts +1 -0
- package/dist/test/is-equal.test.d.ts +1 -0
- package/dist/test/mimeType.test.d.ts +1 -0
- package/dist/test/server.test.d.ts +1 -0
- package/dist/test/sort.test.d.ts +1 -0
- package/dist/test/status.test.d.ts +1 -0
- package/dist/test/totp.test.d.ts +1 -0
- package/dist/test/utils/compose.test.d.ts +1 -0
- package/dist/test/utils/mergeObj.test.d.ts +1 -0
- package/dist/test/utils/ocr.test.d.ts +1 -0
- package/dist/test/visual/math.test.d.ts +1 -0
- package/dist/test/vnode/index.d.ts +1 -0
- package/dist/test/vnode/server.d.ts +2 -0
- package/dist/test/vnode/vnode.d.ts +1 -0
- package/dist/test/websocket.test.d.ts +1 -0
- package/dist/test/writeFile.test.d.ts +1 -0
- package/dist/umd/index.umd.cjs +1 -0
- package/dist/umd/ml/ml.umd.cjs +1 -0
- package/dist/umd/node/node.umd.cjs +1 -0
- package/dist/umd/react/react.umd.cjs +1 -0
- package/dist/umd/utils/utils.umd.cjs +1 -0
- package/dist/umd/wasm/wasm.umd.cjs +1 -0
- package/dist/vite.config.d.ts +11 -0
- package/dist/ws-CUTzWNwq.js +703 -0
- package/package.json +70 -13
- package/readme.md +91 -0
- package/typings.d.ts +28 -0
- package/dist/index.js.map +0 -1
- package/dist/index.umd.cjs +0 -2
- package/dist/index.umd.cjs.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const MimeType: Map<string, string>;
|
|
2
|
+
export declare const setMime: (ext: string, mimeType: string) => Map<string, string>;
|
|
3
|
+
export declare function getMime(ext: string): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Get file extensions from MIME type
|
|
6
|
+
* @param mimeType The MIME type to get extensions for
|
|
7
|
+
* @returns Array of file extensions (without dot)
|
|
8
|
+
*/
|
|
9
|
+
export declare const getExtensions: (mimeType: string) => string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
payload: Record<string, unknown>;
|
|
3
|
+
type?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class Monitor {
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* @description: 页面加载性能上报
|
|
9
|
+
* @param {Payload} param1
|
|
10
|
+
*/
|
|
11
|
+
reportPerformance(): void;
|
|
12
|
+
/**
|
|
13
|
+
* @description: 手动触发的上报
|
|
14
|
+
* @param {Record} payload
|
|
15
|
+
* @param {*} unknown
|
|
16
|
+
*/
|
|
17
|
+
log(payload: Record<string, unknown>): void;
|
|
18
|
+
/**
|
|
19
|
+
* @description: 点击上报
|
|
20
|
+
* @return {*}
|
|
21
|
+
*/
|
|
22
|
+
reportClick(): void;
|
|
23
|
+
reportXhr(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @description: fetch上报
|
|
26
|
+
*/
|
|
27
|
+
reportFetch(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @description: 错误上报
|
|
30
|
+
*/
|
|
31
|
+
reportError(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @description: 上报console
|
|
34
|
+
*/
|
|
35
|
+
reportConsole(): void;
|
|
36
|
+
init: () => void;
|
|
37
|
+
initialize(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const status: {
|
|
2
|
+
message: Map<number, string>;
|
|
3
|
+
code: Map<string, number>;
|
|
4
|
+
codes: number[];
|
|
5
|
+
redirect: {
|
|
6
|
+
300: boolean;
|
|
7
|
+
301: boolean;
|
|
8
|
+
302: boolean;
|
|
9
|
+
303: boolean;
|
|
10
|
+
305: boolean;
|
|
11
|
+
307: boolean;
|
|
12
|
+
308: boolean;
|
|
13
|
+
};
|
|
14
|
+
empty: {
|
|
15
|
+
204: boolean;
|
|
16
|
+
205: boolean;
|
|
17
|
+
304: boolean;
|
|
18
|
+
};
|
|
19
|
+
retry: {
|
|
20
|
+
502: boolean;
|
|
21
|
+
503: boolean;
|
|
22
|
+
504: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Get the status code.
|
|
27
|
+
*
|
|
28
|
+
* Given a number, this will throw if it is not a known status
|
|
29
|
+
* code, otherwise the code will be returned. Given a string,
|
|
30
|
+
* the string will be parsed for a number and return the code
|
|
31
|
+
* if valid, otherwise will lookup the code assuming this is
|
|
32
|
+
* the status message.
|
|
33
|
+
*
|
|
34
|
+
* @param {string|number} code
|
|
35
|
+
* @returns {number}
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
declare function getStatus(code?: number | string): number | string | undefined;
|
|
39
|
+
export { getStatus, status };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
interface ComputeNumberResult {
|
|
2
|
+
result: number;
|
|
3
|
+
next: (a: string, b: number) => ComputeNumberResult;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @description: 百分比转换成数字
|
|
7
|
+
* @param {string} str
|
|
8
|
+
* @return {*}
|
|
9
|
+
*/
|
|
10
|
+
export declare const perToNum: (str?: string) => number;
|
|
11
|
+
/**
|
|
12
|
+
* @description: 限制最大和最小值
|
|
13
|
+
* @return {*}
|
|
14
|
+
*/
|
|
15
|
+
export declare const range: (num: number, min?: number, max?: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* 数字运算(主要用于小数点精度问题)
|
|
18
|
+
* @param {number} a 前面的值
|
|
19
|
+
* @param {"+"|"-"|"*"|"/"} type 计算方式
|
|
20
|
+
* @param {number} b 后面的值
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* // 可链式调用
|
|
24
|
+
* const res = computeNumber(1.3, "-", 1.2).next("+", 1.5).next("*", 2.3).next("/", 0.2).result;
|
|
25
|
+
* console.log(res);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class Mathjs {
|
|
29
|
+
/**
|
|
30
|
+
* 获取数字小数点的长度
|
|
31
|
+
* @param {number} n 数字
|
|
32
|
+
*/
|
|
33
|
+
getDecimalLength: (n: number) => number;
|
|
34
|
+
amend: (n: number, precision?: number) => number;
|
|
35
|
+
power: (a: number, b: number) => number;
|
|
36
|
+
static handleMethod: (l: number, r: number) => ((type: string) => number | undefined);
|
|
37
|
+
static add: (a: number, b: number) => number | undefined;
|
|
38
|
+
static divide: (a: number, b: number) => number | undefined;
|
|
39
|
+
static multiply: (a: number, b: number) => number | undefined;
|
|
40
|
+
static subtract: (a: number, b: number) => number | undefined;
|
|
41
|
+
}
|
|
42
|
+
export declare function mathjs(a: number, type: string, b: number): ComputeNumberResult;
|
|
43
|
+
export declare const transformNumber: (value: string, locale?: string, precision?: number, fixed?: number) => string;
|
|
44
|
+
export declare const addNumSym: (value: string | number, flag?: string | number) => string;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description: 对象转 url 字符串
|
|
3
|
+
* @param {*} data
|
|
4
|
+
* @return {*}
|
|
5
|
+
*/
|
|
6
|
+
export declare function querystring(data?: {}): string;
|
|
7
|
+
export declare const formatJson: (jsonObj: string, callback?: () => void) => string;
|
|
8
|
+
/**
|
|
9
|
+
* @description: 过滤对象的属性,去除对象中在list数组里面有的属性,返回一个新对象,一般是用于去除空字符和null
|
|
10
|
+
* @param {Object} obj 传入对象
|
|
11
|
+
* @param {Array} list 传入数组
|
|
12
|
+
* @return {Object}
|
|
13
|
+
*/
|
|
14
|
+
export declare const filterObj: (obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>;
|
|
15
|
+
type Obj = Record<string, any>;
|
|
16
|
+
/**
|
|
17
|
+
* @description: 合并对象
|
|
18
|
+
* @param {Obj} a
|
|
19
|
+
* @param {Obj} b
|
|
20
|
+
* @return {*}
|
|
21
|
+
*/
|
|
22
|
+
export declare const merge: (a: Obj, b?: Obj) => Obj;
|
|
23
|
+
/**
|
|
24
|
+
* 重写对象上面的某个属性
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
* @param {IAnyObject} source 需要被重写的对象
|
|
28
|
+
* @param {string} name 需要被重写对象的 key
|
|
29
|
+
* @param {(...args: any[]) => any} replacement 以原有的函数作为参数,执行并重写原有函数
|
|
30
|
+
* @param {boolean} isForced 是否强制重写(可能原先没有该属性)
|
|
31
|
+
*/
|
|
32
|
+
export declare function replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* @description: 将 exports 对象拼接到 obj 上,并冻结 obj
|
|
35
|
+
* @param {Object} obj
|
|
36
|
+
* @param {Object} exports
|
|
37
|
+
* @return {Object}
|
|
38
|
+
*/
|
|
39
|
+
export declare const mergeExports: (obj: Record<string, string>, exports: Record<string, string>) => Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* @description: 给全局对象上增加属性
|
|
42
|
+
* @param {string} name
|
|
43
|
+
* @param {string} value
|
|
44
|
+
* @return {*}
|
|
45
|
+
*/
|
|
46
|
+
export declare const setAttributeByGlobal: (name: string, value: unknown) => void;
|
|
47
|
+
/**
|
|
48
|
+
* 深度比较两个值是否相等
|
|
49
|
+
* 实现类似 Lodash 的 isEqual 函数
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* 检查两个值是否为基本相同的值
|
|
53
|
+
* 处理特殊情况如 NaN, -0/+0
|
|
54
|
+
*/
|
|
55
|
+
export declare function sameValueZero(x: any, y: any): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 判断是否为类对象
|
|
58
|
+
*/
|
|
59
|
+
export declare function isObjectLike(value: any): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* 获取对象的标签
|
|
62
|
+
*/
|
|
63
|
+
export declare function getTag(value: any): string;
|
|
64
|
+
/**
|
|
65
|
+
* 检查是否是类数组对象
|
|
66
|
+
*/
|
|
67
|
+
export declare function isArrayLike(value: any): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* 深度比较两个值是否相等
|
|
70
|
+
* @param value 第一个值
|
|
71
|
+
* @param other 第二个值
|
|
72
|
+
* @param seen 已经比较过的对象(用于处理循环引用)
|
|
73
|
+
* @returns 两个值是否相等
|
|
74
|
+
*/
|
|
75
|
+
export declare function isEqual(value: any, other: any, seen?: Map<any, any>): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* 深克隆函数,支持各种复杂数据类型和循环引用
|
|
78
|
+
* @param value 需要深度克隆的值
|
|
79
|
+
* @param cloneMap 用于跟踪已克隆的对象,避免循环引用问题
|
|
80
|
+
* @returns 克隆后的值
|
|
81
|
+
*/
|
|
82
|
+
export declare const cloneDeep: <T>(value: T, cloneMap?: WeakMap<object, any>) => T;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BasicType {
|
|
2
|
+
[x: string]: number | undefined;
|
|
3
|
+
dnsSearch: number;
|
|
4
|
+
tcpConnect: number;
|
|
5
|
+
sslConnect: number;
|
|
6
|
+
request: number;
|
|
7
|
+
response: number;
|
|
8
|
+
parseDomTree: number;
|
|
9
|
+
resource: number;
|
|
10
|
+
domReady: number;
|
|
11
|
+
httpHead: number;
|
|
12
|
+
interactive: number;
|
|
13
|
+
complete: number;
|
|
14
|
+
redirect: number;
|
|
15
|
+
redirectTime: number;
|
|
16
|
+
duration: number;
|
|
17
|
+
fp: number | undefined;
|
|
18
|
+
fcp: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function getPerformance(): BasicType | undefined;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Func } from '@/utils/memoize';
|
|
2
|
+
interface QuestQueueOptions {
|
|
3
|
+
simultaneous: number;
|
|
4
|
+
total: number;
|
|
5
|
+
}
|
|
6
|
+
type Fun = Function | Func;
|
|
7
|
+
export declare class QuestQueue {
|
|
8
|
+
current: number;
|
|
9
|
+
queue: Fun[];
|
|
10
|
+
simultaneous: number;
|
|
11
|
+
executed: number;
|
|
12
|
+
total: number;
|
|
13
|
+
constructor({ simultaneous, total }: QuestQueueOptions);
|
|
14
|
+
/**
|
|
15
|
+
* @description: 传入异步函数,添加到队列并执行
|
|
16
|
+
* @param {Fun} asynchronous
|
|
17
|
+
* @return {*}
|
|
18
|
+
*/
|
|
19
|
+
add: (asynchronous: Fun) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @description: 执行异步函数
|
|
22
|
+
* @param {*} Promise
|
|
23
|
+
* @return {*}
|
|
24
|
+
*/
|
|
25
|
+
running: () => Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* @description: 并发执行所有的异步函数,并返回所有的结果
|
|
28
|
+
* @param {*} Promise
|
|
29
|
+
* @return {*}
|
|
30
|
+
*/
|
|
31
|
+
allSettled: () => Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface BeaconPayload {
|
|
2
|
+
url?: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
payload: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare const report: ({ url, type, payload, }: BeaconPayload) => boolean | undefined | void;
|
|
7
|
+
export declare function createData(params?: Record<string, unknown>): Record<string, unknown>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Hooks = (...args: unknown[]) => void;
|
|
2
|
+
export interface Options {
|
|
3
|
+
requestHook: Hooks;
|
|
4
|
+
responseHook: Hooks;
|
|
5
|
+
errorHook: Hooks;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @description: fetch
|
|
9
|
+
* @param {Partial} options
|
|
10
|
+
*/
|
|
11
|
+
export declare const handleFetchHook: (options?: Partial<Options>) => void;
|
|
12
|
+
/**
|
|
13
|
+
* @description: xhr
|
|
14
|
+
* @param {Partial} options
|
|
15
|
+
* @return {*}
|
|
16
|
+
*/
|
|
17
|
+
export declare const handleXhrHook: (options?: Partial<Options>) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 动态插入 script/link 标签
|
|
3
|
+
* @param {Array | String} url script/link的url队列
|
|
4
|
+
* @param {Element} append 插入的父元素 默认 body
|
|
5
|
+
* @param {Function} callback 所有 script onload 回调 也可通过返回的 promise 执行回调
|
|
6
|
+
*/
|
|
7
|
+
export declare const scriptOnLoad: (urls: string[], append?: HTMLElement, callback?: Function) => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SyncHook } from './subscribe';
|
|
2
|
+
export declare const subscribers: SyncHook;
|
|
3
|
+
export declare const createSignal: <T = unknown>(value: T, options?: {
|
|
4
|
+
subscriber?: string;
|
|
5
|
+
equals?: boolean | ((prev: T | undefined, next: T) => boolean);
|
|
6
|
+
}) => [() => T, (newValue: T) => void];
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description: 将字符串转对象,比如
|
|
3
|
+
* @param {string} url 'a=1&b=2&c=3'
|
|
4
|
+
* @param {string} sep &
|
|
5
|
+
* @param {string} eq =
|
|
6
|
+
* @return {object} {a:1,b:2,c:3}
|
|
7
|
+
*/
|
|
8
|
+
export declare const strParse: (str?: string, sep?: string | RegExp, eq?: string | RegExp) => Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* @description: 清除空格和换行
|
|
11
|
+
* @param {*} str
|
|
12
|
+
* @return {*}
|
|
13
|
+
*/
|
|
14
|
+
export declare const clearBr: (str?: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* @description: 传入字符串和指定的格式,将字符串转成 xml
|
|
17
|
+
* @param {string} xmlStr
|
|
18
|
+
* @param {DOMParserSupportedType} format
|
|
19
|
+
* @return {Document}
|
|
20
|
+
*/
|
|
21
|
+
export declare const str2Xml: (xmlStr: string, format?: DOMParserSupportedType) => HTMLElement | undefined;
|
|
22
|
+
export declare const isString: (obj: unknown) => boolean;
|
|
23
|
+
export declare function randomString(len?: number): string;
|
|
24
|
+
export declare function changeHumpToLowerCase(str: string): string;
|
|
25
|
+
interface ClearStrOption {
|
|
26
|
+
urlencoded?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @description: 去除字符串首尾的空格,encode 编码,首尾的引号
|
|
30
|
+
* @param {string} str
|
|
31
|
+
* @return {string}
|
|
32
|
+
*/
|
|
33
|
+
export declare const clearStr: (str: string, options?: ClearStrOption) => string;
|
|
34
|
+
/**
|
|
35
|
+
* 获取文本中包含搜索关键词的完整句子,对于重复的句子只保留最长的一个
|
|
36
|
+
* @param text 原文本
|
|
37
|
+
* @param searchValue 搜索关键词
|
|
38
|
+
* @returns 包含关键词的完整句子数组(已去重)
|
|
39
|
+
*/
|
|
40
|
+
export declare function getMatchingSentences(text: string, searchValue: string): string[];
|
|
41
|
+
export declare const toString: (value: string | number) => string;
|
|
42
|
+
export declare const checkEncoding: (uint8Array: Uint8Array) => string;
|
|
43
|
+
export interface TransformText {
|
|
44
|
+
encoding: string;
|
|
45
|
+
content: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const transformText: (content: string | ArrayBuffer) => TransformText | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* MD5 hash function implementation
|
|
50
|
+
* @param str The string to hash
|
|
51
|
+
* @returns The MD5 hash as a hexadecimal string
|
|
52
|
+
*/
|
|
53
|
+
export declare const md5: (str: string) => string;
|
|
54
|
+
export declare const getRandomString: (len?: number) => string;
|
|
55
|
+
type FileChunk = {
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
size: number;
|
|
59
|
+
lastModified: number;
|
|
60
|
+
totalChunks: number;
|
|
61
|
+
chunkIndex: number;
|
|
62
|
+
data: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 消息编解码工具
|
|
66
|
+
* 正确处理所有 Unicode 字符,包括中文、emoji 等
|
|
67
|
+
* 编码后的字符串只包含 A-Z, a-z, 0-9, +, /, = 这些安全字符
|
|
68
|
+
* 适合在 URL、Cookie 等场景使用
|
|
69
|
+
* 编码解码过程是双向的,不会丢失数据,不会出现编码解码不一致的问题
|
|
70
|
+
*/
|
|
71
|
+
export declare const MessageCodec: {
|
|
72
|
+
/**
|
|
73
|
+
* 编码消息
|
|
74
|
+
* @param data 要编码的数据
|
|
75
|
+
* @returns 编码后的字符串
|
|
76
|
+
*/
|
|
77
|
+
encode(data: any): string;
|
|
78
|
+
/**
|
|
79
|
+
* 解码消息
|
|
80
|
+
* @param encodedStr 编码后的字符串
|
|
81
|
+
* @returns 解码后的数据
|
|
82
|
+
*/
|
|
83
|
+
decode<T = any>(encodedStr: string): T | null;
|
|
84
|
+
/**
|
|
85
|
+
* 编码文件对象
|
|
86
|
+
* @param file File对象
|
|
87
|
+
* @returns 编码后的字符串
|
|
88
|
+
* @throws {MessageCodecError} 当文件编码失败时抛出
|
|
89
|
+
*/
|
|
90
|
+
encodeFile(file: File): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* 解码文件对象
|
|
93
|
+
* @param encoded 编码后的字符串
|
|
94
|
+
* @returns 解码后的 File 对象
|
|
95
|
+
* @throws {MessageCodecError} 当解码失败或类型不匹配时抛出
|
|
96
|
+
*/
|
|
97
|
+
decodeFile(encoded: string): File;
|
|
98
|
+
/**
|
|
99
|
+
* 编码 Blob 对象
|
|
100
|
+
* @param blob Blob 对象
|
|
101
|
+
* @returns 编码后的字符串
|
|
102
|
+
* @throws {MessageCodecError} 当编码失败时抛出
|
|
103
|
+
*/
|
|
104
|
+
encodeBlob(blob: Blob): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* 解码 Blob 对象
|
|
107
|
+
* @param encoded 编码后的字符串
|
|
108
|
+
* @returns 解码后的 Blob 对象
|
|
109
|
+
* @throws {MessageCodecError} 当解码失败或类型不匹配时抛出
|
|
110
|
+
*/
|
|
111
|
+
decodeBlob(encoded: string): Blob;
|
|
112
|
+
/**
|
|
113
|
+
* 编码 Date 对象
|
|
114
|
+
* @param date Date 对象
|
|
115
|
+
* @returns 编码后的字符串
|
|
116
|
+
*/
|
|
117
|
+
encodeDate(date: Date): string;
|
|
118
|
+
/**
|
|
119
|
+
* 解码 Date 对象
|
|
120
|
+
* @param encodedStr 编码后的字符串
|
|
121
|
+
* @returns 解码后的 Date 对象
|
|
122
|
+
*/
|
|
123
|
+
decodeDate(encodedStr: string): Date;
|
|
124
|
+
/**
|
|
125
|
+
* 编码 RegExp 对象
|
|
126
|
+
* @param regexp RegExp 对象
|
|
127
|
+
* @returns 编码后的字符串
|
|
128
|
+
*/
|
|
129
|
+
encodeRegExp(regexp: RegExp): string;
|
|
130
|
+
/**
|
|
131
|
+
* 解码 RegExp 对象
|
|
132
|
+
* @param encodedStr 编码后的字符串
|
|
133
|
+
* @returns 解码后的 RegExp 对象
|
|
134
|
+
*/
|
|
135
|
+
decodeRegExp(encodedStr: string): RegExp;
|
|
136
|
+
/**
|
|
137
|
+
* 编码 Map 对象
|
|
138
|
+
* @param map Map 对象
|
|
139
|
+
* @returns 编码后的字符串
|
|
140
|
+
*/
|
|
141
|
+
encodeMap<K, V>(map: Map<K, V>): string;
|
|
142
|
+
/**
|
|
143
|
+
* 解码 Map 对象
|
|
144
|
+
* @param encodedStr 编码后的字符串
|
|
145
|
+
* @returns 解码后的 Map 对象
|
|
146
|
+
*/
|
|
147
|
+
decodeMap<K, V>(encodedStr: string): Map<K, V>;
|
|
148
|
+
/**
|
|
149
|
+
* 编码 Set 对象
|
|
150
|
+
* @param set Set 对象
|
|
151
|
+
* @returns 编码后的字符串
|
|
152
|
+
*/
|
|
153
|
+
encodeSet<T>(set: Set<T>): string;
|
|
154
|
+
/**
|
|
155
|
+
* 解码 Set 对象
|
|
156
|
+
* @param encodedStr 编码后的字符串
|
|
157
|
+
* @returns 解码后的 Set 对象
|
|
158
|
+
*/
|
|
159
|
+
decodeSet<T>(encodedStr: string): Set<T>;
|
|
160
|
+
/**
|
|
161
|
+
* 编码 Error 对象
|
|
162
|
+
* @param error Error 对象
|
|
163
|
+
* @returns 编码后的字符串
|
|
164
|
+
*/
|
|
165
|
+
encodeError(error: Error): string;
|
|
166
|
+
/**
|
|
167
|
+
* 解码 Error 对象
|
|
168
|
+
* @param encodedStr 编码后的字符串
|
|
169
|
+
* @returns 解码后的 Error 对象
|
|
170
|
+
*/
|
|
171
|
+
decodeError(encodedStr: string): Error;
|
|
172
|
+
/**
|
|
173
|
+
* 编码 ArrayBuffer 对象
|
|
174
|
+
* @param buffer ArrayBuffer 对象
|
|
175
|
+
* @returns 编码后的字符串
|
|
176
|
+
*/
|
|
177
|
+
encodeArrayBuffer(buffer: ArrayBuffer): string;
|
|
178
|
+
/**
|
|
179
|
+
* 解码 ArrayBuffer 对象
|
|
180
|
+
* @param encodedStr 编码后的字符串
|
|
181
|
+
* @returns 解码后的 ArrayBuffer 对象
|
|
182
|
+
*/
|
|
183
|
+
decodeArrayBuffer(encodedStr: string): ArrayBuffer;
|
|
184
|
+
/**
|
|
185
|
+
* 编码 TypedArray 对象
|
|
186
|
+
* @param typedArray TypedArray 对象
|
|
187
|
+
* @returns 编码后的字符串
|
|
188
|
+
*/
|
|
189
|
+
encodeTypedArray(typedArray: ArrayBufferView): string;
|
|
190
|
+
/**
|
|
191
|
+
* 解码 TypedArray 对象
|
|
192
|
+
* @param encodedStr 编码后的字符串
|
|
193
|
+
* @returns 解码后的 TypedArray 对象
|
|
194
|
+
*/
|
|
195
|
+
decodeTypedArray(encodedStr: string): ArrayBufferView;
|
|
196
|
+
/**
|
|
197
|
+
* 分片编码文件对象
|
|
198
|
+
* @param file File 对象
|
|
199
|
+
* @param chunkSize 分片大小,默认 1MB
|
|
200
|
+
* @returns 包含文件信息和分片数据的可传输对象数组
|
|
201
|
+
* @throws {MessageCodecError} 当分片编码失败时抛出
|
|
202
|
+
*/
|
|
203
|
+
encodeFileChunked(file: File, chunkSize?: number): Promise<FileChunk[]>;
|
|
204
|
+
/**
|
|
205
|
+
* 解码分片文件对象
|
|
206
|
+
* @param chunks 编码后的文件分片数组
|
|
207
|
+
* @returns 重建的File对象
|
|
208
|
+
* @throws {MessageCodecError} 当分片解码失败或分片不完整时抛出
|
|
209
|
+
*/
|
|
210
|
+
decodeFileChunked(chunks: FileChunk[]): Promise<File>;
|
|
211
|
+
};
|
|
212
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type Callback = Function;
|
|
2
|
+
export type EventName = string | symbol;
|
|
3
|
+
export type EventItem = {
|
|
4
|
+
name?: string | symbol;
|
|
5
|
+
callback: Callback;
|
|
6
|
+
initialCallback?: Callback;
|
|
7
|
+
};
|
|
8
|
+
export declare const NEW_LISTENER = "NEW_LISTENER";
|
|
9
|
+
export declare class SyncHook {
|
|
10
|
+
readonly _events: Map<EventName, Set<EventItem>>;
|
|
11
|
+
/**
|
|
12
|
+
* @description: 订阅事件
|
|
13
|
+
* @param {EventName} eventName
|
|
14
|
+
* @param {EventItem} eventItem
|
|
15
|
+
* @return {void}
|
|
16
|
+
*/
|
|
17
|
+
tap: (eventName: EventName, eventItem: EventItem | Callback) => this;
|
|
18
|
+
/**
|
|
19
|
+
* @description: 触发事件
|
|
20
|
+
* @param {EventName} eventName
|
|
21
|
+
* @param {array} args
|
|
22
|
+
* @return {void}
|
|
23
|
+
*/
|
|
24
|
+
call: (eventName: EventName, ...args: Array<unknown>) => this;
|
|
25
|
+
/**
|
|
26
|
+
* @description: 同步触发事件
|
|
27
|
+
* @param {EventName} eventName
|
|
28
|
+
* @param {array} args
|
|
29
|
+
* @return {Promise<void>}
|
|
30
|
+
*/
|
|
31
|
+
callSync: (eventName: EventName, ...args: Array<unknown>) => Promise<this>;
|
|
32
|
+
/**
|
|
33
|
+
* @description: 只订阅一次事件,触发后就移除事件
|
|
34
|
+
* @param {EventName} eventName
|
|
35
|
+
* @param {EventItem} eventItem
|
|
36
|
+
* @return {void}
|
|
37
|
+
*/
|
|
38
|
+
once: (eventName: EventName, eventItem: EventItem | Callback) => this;
|
|
39
|
+
/**
|
|
40
|
+
* @description: 移除订阅的事件
|
|
41
|
+
* @param {EventName} eventName
|
|
42
|
+
* @param {EventItem} eventItem
|
|
43
|
+
* @return {void}
|
|
44
|
+
*/
|
|
45
|
+
off: (eventName: EventName, eventItem: EventItem | Callback) => this;
|
|
46
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type ThrottleFunc<T extends (...args: any[]) => void> = (...args: Parameters<T>) => any;
|
|
2
|
+
/**
|
|
3
|
+
* @description: 节流
|
|
4
|
+
* @param {any} fn
|
|
5
|
+
* @param {*} wait
|
|
6
|
+
* @return {*}
|
|
7
|
+
*/
|
|
8
|
+
export declare function throttle<T extends (...args: any[]) => any>(func: T, delay?: number): ThrottleFunc<T>;
|
|
9
|
+
/**
|
|
10
|
+
* @description: 生成节流函数
|
|
11
|
+
* @param {*} Function
|
|
12
|
+
* @return {*}
|
|
13
|
+
*/
|
|
14
|
+
export declare const generateThrottle: () => Function;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description: 时间戳转日期
|
|
3
|
+
* @param {*} timestamp
|
|
4
|
+
* @param {*} returnType
|
|
5
|
+
* @return {*}
|
|
6
|
+
*/
|
|
7
|
+
export declare function timestampToTime(timestamp?: number | string): Date & {
|
|
8
|
+
format?: Function;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @description: 时间秒,转化成:分割的时间
|
|
12
|
+
* @param {number} time
|
|
13
|
+
* @return {*}
|
|
14
|
+
*/
|
|
15
|
+
export declare const timeFormat: (time: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* @description: 获取当前时间戳
|
|
18
|
+
* @return {*}
|
|
19
|
+
*/
|
|
20
|
+
export declare const performanceTime: () => number;
|