ranuts 0.1.0-alpha.2 → 0.1.0-alpha.20

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.
Files changed (216) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build/build.es.d.ts +2 -0
  3. package/dist/build/build.umd.d.ts +2 -0
  4. package/dist/build/build.umd.ml.d.ts +2 -0
  5. package/dist/build/build.umd.node.d.ts +2 -0
  6. package/dist/build/build.umd.react.d.ts +2 -0
  7. package/dist/build/build.umd.utils.d.ts +2 -0
  8. package/dist/build/build.umd.wasm.d.ts +2 -0
  9. package/dist/examples/clone-deep-example.d.ts +1 -0
  10. package/dist/examples/is-equal-example.d.ts +1 -0
  11. package/dist/index.d.ts +9 -16
  12. package/dist/index.js +147 -1116
  13. package/dist/mimeType-CrLryRe7.js +81821 -0
  14. package/dist/plugins/vite-plugins-banner.d.ts +2 -0
  15. package/dist/reactify-Z-V9Vblb.js +83 -0
  16. package/dist/src/arithmetic/index.d.ts +186 -0
  17. package/dist/src/cache/expires.d.ts +1 -0
  18. package/dist/src/ml/index.d.ts +2 -0
  19. package/dist/src/ml/index.js +1243 -0
  20. package/dist/src/ml/ocr.d.ts +11 -0
  21. package/dist/src/node/appendFile.d.ts +7 -0
  22. package/dist/src/node/body.d.ts +9 -0
  23. package/dist/src/node/color.d.ts +7 -0
  24. package/dist/src/node/command.d.ts +8 -0
  25. package/dist/src/node/ctx2req.d.ts +5 -0
  26. package/dist/src/node/fileInfo.d.ts +7 -0
  27. package/dist/src/node/fs.d.ts +7 -0
  28. package/dist/src/node/get.d.ts +10 -0
  29. package/dist/src/node/getIPAdress.d.ts +1 -0
  30. package/dist/src/node/index.d.ts +25 -0
  31. package/dist/src/node/index.js +54 -0
  32. package/dist/src/node/isColorSupported.d.ts +2 -0
  33. package/dist/src/node/paresUrl.d.ts +19 -0
  34. package/dist/src/node/readDir.d.ts +6 -0
  35. package/dist/src/node/readFile.d.ts +9 -0
  36. package/dist/src/node/router.d.ts +42 -0
  37. package/dist/src/node/send.d.ts +7 -0
  38. package/dist/src/node/server.d.ts +18 -0
  39. package/dist/src/node/startTask.d.ts +2 -0
  40. package/dist/src/node/stream.d.ts +15 -0
  41. package/dist/src/node/taskEnd.d.ts +2 -0
  42. package/dist/src/node/traverse.d.ts +17 -0
  43. package/dist/src/node/watchFile.d.ts +8 -0
  44. package/dist/src/node/websocket.d.ts +57 -0
  45. package/dist/src/node/writeFile.d.ts +8 -0
  46. package/dist/src/node/ws.d.ts +8 -0
  47. package/dist/src/optimize/index.d.ts +36 -0
  48. package/dist/src/optimize/promise.d.ts +0 -0
  49. package/dist/src/ran/commit.d.ts +0 -0
  50. package/dist/src/ran/dom.d.ts +0 -0
  51. package/dist/src/ran/hooks.d.ts +0 -0
  52. package/dist/src/ran/index.d.ts +20 -0
  53. package/dist/src/ran/min.d.ts +32 -0
  54. package/dist/src/ran/reconcile.d.ts +0 -0
  55. package/dist/src/ran/schedule.d.ts +0 -0
  56. package/dist/src/react/index.d.ts +2 -0
  57. package/dist/src/react/index.js +4 -0
  58. package/dist/src/react/reactify.d.ts +2 -0
  59. package/dist/src/sort/bubble.d.ts +7 -0
  60. package/dist/src/sort/bucket.d.ts +7 -0
  61. package/dist/src/sort/count.d.ts +7 -0
  62. package/dist/src/sort/heap.d.ts +7 -0
  63. package/dist/src/sort/index.d.ts +0 -0
  64. package/dist/src/sort/insert.d.ts +7 -0
  65. package/dist/src/sort/merge.d.ts +7 -0
  66. package/dist/src/sort/quick.d.ts +7 -0
  67. package/dist/src/sort/radix.d.ts +7 -0
  68. package/dist/src/sort/randomArray.d.ts +9 -0
  69. package/dist/src/sort/select.d.ts +7 -0
  70. package/dist/src/sort/shell.d.ts +7 -0
  71. package/dist/src/utils/audioRecorder.d.ts +16 -0
  72. package/dist/src/utils/behavior.d.ts +15 -0
  73. package/dist/src/utils/bom.d.ts +220 -0
  74. package/dist/src/utils/color.d.ts +71 -0
  75. package/dist/src/utils/compose.d.ts +10 -0
  76. package/dist/src/utils/console.d.ts +1 -0
  77. package/dist/src/utils/debounce.d.ts +7 -0
  78. package/dist/src/utils/device.d.ts +25 -0
  79. package/dist/src/utils/dom.d.ts +105 -0
  80. package/dist/src/utils/error.d.ts +1 -0
  81. package/dist/src/utils/img.d.ts +16 -0
  82. package/dist/src/utils/index.d.ts +35 -0
  83. package/dist/src/utils/index.js +4504 -0
  84. package/dist/src/utils/memoize.d.ts +7 -0
  85. package/dist/src/utils/mimeType.d.ts +3 -0
  86. package/dist/src/utils/monitor.d.ts +38 -0
  87. package/dist/src/utils/network.d.ts +39 -0
  88. package/dist/src/utils/noop.d.ts +2 -0
  89. package/dist/src/utils/number.d.ts +45 -0
  90. package/dist/src/utils/obj.d.ts +83 -0
  91. package/dist/src/utils/performance.d.ts +21 -0
  92. package/dist/src/utils/queue.d.ts +33 -0
  93. package/dist/src/utils/report.d.ts +8 -0
  94. package/dist/src/utils/request.d.ts +17 -0
  95. package/dist/src/utils/script.d.ts +7 -0
  96. package/dist/src/utils/signal.d.ts +6 -0
  97. package/dist/src/utils/storage.d.ts +2 -0
  98. package/dist/src/utils/str.d.ts +72 -0
  99. package/dist/src/utils/subscribe.d.ts +46 -0
  100. package/dist/src/utils/throttle.d.ts +15 -0
  101. package/dist/src/utils/time.d.ts +20 -0
  102. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  103. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  104. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  105. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  106. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  107. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  108. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  109. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  110. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  111. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  112. package/dist/src/utils/totp/totp.d.ts +23 -0
  113. package/dist/src/utils/visual/application.d.ts +14 -0
  114. package/dist/src/utils/visual/demo/index.d.ts +1 -0
  115. package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
  116. package/dist/src/utils/visual/enums.d.ts +27 -0
  117. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  118. package/dist/src/utils/visual/event/event.d.ts +14 -0
  119. package/dist/src/utils/visual/event/index.d.ts +6 -0
  120. package/dist/src/utils/visual/event/types.d.ts +32 -0
  121. package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
  122. package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
  123. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
  124. package/dist/src/utils/visual/graphics/index.d.ts +4 -0
  125. package/dist/src/utils/visual/index.d.ts +7 -0
  126. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  127. package/dist/src/utils/visual/math/enums.d.ts +3 -0
  128. package/dist/src/utils/visual/math/index.d.ts +5 -0
  129. package/dist/src/utils/visual/math/matrix.d.ts +113 -0
  130. package/dist/src/utils/visual/math/transform.d.ts +29 -0
  131. package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
  132. package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
  133. package/dist/src/utils/visual/render/index.d.ts +3 -0
  134. package/dist/src/utils/visual/render/render.d.ts +15 -0
  135. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  136. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  137. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  138. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  139. package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
  140. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
  141. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  142. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  143. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  144. package/dist/src/utils/visual/render/webGlRenderer.d.ts +17 -0
  145. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  146. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  147. package/dist/src/utils/visual/shape/index.d.ts +7 -0
  148. package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
  149. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  150. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  151. package/dist/src/utils/visual/shape/shape.d.ts +6 -0
  152. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  153. package/dist/src/utils/visual/style/index.d.ts +3 -0
  154. package/dist/src/utils/visual/style/line.d.ts +10 -0
  155. package/dist/src/utils/visual/types.d.ts +17 -0
  156. package/dist/src/utils/visual/vertex/container.d.ts +73 -0
  157. package/dist/src/utils/visual/vertex/index.d.ts +5 -0
  158. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  159. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  160. package/dist/src/vnode/chainDom.d.ts +47 -0
  161. package/dist/src/vnode/h.d.ts +6 -0
  162. package/dist/src/vnode/hooks.d.ts +23 -0
  163. package/dist/src/vnode/htmlDomApi.d.ts +33 -0
  164. package/dist/src/vnode/init.d.ts +2 -0
  165. package/dist/src/vnode/is.d.ts +5 -0
  166. package/dist/src/vnode/modules/attributes.d.ts +8 -0
  167. package/dist/src/vnode/modules/class.d.ts +8 -0
  168. package/dist/src/vnode/modules/index.d.ts +3 -0
  169. package/dist/src/vnode/modules/listeners.d.ts +12 -0
  170. package/dist/src/vnode/modules/props.d.ts +8 -0
  171. package/dist/src/vnode/modules/style.d.ts +14 -0
  172. package/dist/src/vnode/vnode.d.ts +31 -0
  173. package/dist/src/wasm/index.d.ts +2 -0
  174. package/dist/src/wasm/index.js +346 -0
  175. package/dist/src/wasm/word.d.ts +17 -0
  176. package/dist/src/wicket/bridge.d.ts +4 -0
  177. package/dist/src/wicket/index.d.ts +29 -0
  178. package/dist/test/arithmetic.test.d.ts +1 -0
  179. package/dist/test/cloneDeep.test.d.ts +1 -0
  180. package/dist/test/encodeUrl.test.d.ts +1 -0
  181. package/dist/test/escapeHtml.test.d.ts +1 -0
  182. package/dist/test/is-equal.test.d.ts +1 -0
  183. package/dist/test/mimeType.test.d.ts +1 -0
  184. package/dist/test/server.test.d.ts +1 -0
  185. package/dist/test/sort.test.d.ts +1 -0
  186. package/dist/test/status.test.d.ts +1 -0
  187. package/dist/test/totp.test.d.ts +1 -0
  188. package/dist/test/utils/compose.test.d.ts +1 -0
  189. package/dist/test/utils/mergeObj.test.d.ts +1 -0
  190. package/dist/test/utils/ocr.test.d.ts +1 -0
  191. package/dist/test/visual/math.test.d.ts +1 -0
  192. package/dist/test/vnode/index.d.ts +1 -0
  193. package/dist/test/vnode/server.d.ts +2 -0
  194. package/dist/test/vnode/vnode.d.ts +1 -0
  195. package/dist/test/websocket.test.d.ts +1 -0
  196. package/dist/test/writeFile.test.d.ts +1 -0
  197. package/dist/tsconfig.json +25 -0
  198. package/dist/umd/index.umd.cjs +1 -0
  199. package/dist/umd/ml/ml.umd.cjs +1 -0
  200. package/dist/umd/node/node.umd.cjs +1 -0
  201. package/dist/umd/react/react.umd.cjs +1 -0
  202. package/dist/umd/utils/utils.umd.cjs +1 -0
  203. package/dist/umd/wasm/wasm.umd.cjs +1 -0
  204. package/dist/vite.config.d.ts +11 -0
  205. package/dist/ws-ioQsn2UB.js +703 -0
  206. package/package.json +55 -21
  207. package/readme.md +90 -0
  208. package/typings.d.ts +28 -0
  209. package/assets/img/sort/bubble.gif +0 -0
  210. package/assets/img/sort/complexity.png +0 -0
  211. package/assets/img/sort/select.gif +0 -0
  212. package/assets/img/sort/sort.png +0 -0
  213. package/assets/img/tree/balanceTree.png +0 -0
  214. package/dist/index.js.map +0 -1
  215. package/dist/index.umd.cjs +0 -2
  216. package/dist/index.umd.cjs.map +0 -1
@@ -0,0 +1,7 @@
1
+ export type Func = () => unknown;
2
+ /**
3
+ * @description: 返回缓存的函数,执行一次后,无须执行直接返回结果
4
+ * @param {Func} fn
5
+ * @return {Func}
6
+ */
7
+ export declare const memoize: (fn: unknown) => Func;
@@ -0,0 +1,3 @@
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;
@@ -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,2 @@
1
+ export declare const noop: () => void;
2
+ export type Noop = () => void;
@@ -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,2 @@
1
+ export declare const localStorageSetItem: (name: string, value: string) => void;
2
+ export declare const localStorageGetItem: (name: string) => string;
@@ -0,0 +1,72 @@
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
+ /**
56
+ * 消息编解码工具
57
+ */
58
+ export declare const MessageCodec: {
59
+ /**
60
+ * 编码消息
61
+ * @param data 要编码的数据
62
+ * @returns 编码后的字符串
63
+ */
64
+ encode(data: any): string;
65
+ /**
66
+ * 解码消息
67
+ * @param encodedStr 编码后的字符串
68
+ * @returns 解码后的数据
69
+ */
70
+ decode<T = any>(encodedStr: string): T | null;
71
+ };
72
+ 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;
@@ -0,0 +1,151 @@
1
+ import type { EncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, FormatType, GenericInputType, packedValue } from './custom_types';
2
+ export declare const TWO_PWR_32 = 4294967296;
3
+ export declare const K_sha2: number[];
4
+ export declare const H_trunc: number[];
5
+ export declare const H_full: number[];
6
+ export declare const sha_variant_error = "Chosen SHA variant is not supported";
7
+ export declare const mac_rounds_error = "Cannot set numRounds with MAC";
8
+ /**
9
+ * Concatenates 2 packed arrays. Clobbers array `a`.
10
+ *
11
+ * @param a First array to concatenate.
12
+ * @param b Second array to concatenate.
13
+ * @returns The concatentation of `a` + `b`.
14
+ */
15
+ export declare function packedLEConcat(a: packedValue, b: packedValue): packedValue;
16
+ /**
17
+ * Validate hash list containing output formatting options, ensuring presence of every option or adding the default
18
+ * value.
19
+ *
20
+ * @param options Hashmap of output formatting options from user.
21
+ * @returns Validated hashmap containing output formatting options.
22
+ */
23
+ export declare function getOutputOpts(options?: {
24
+ outputUpper?: boolean;
25
+ b64Pad?: string;
26
+ shakeLen?: number;
27
+ outputLen?: number;
28
+ }): {
29
+ outputUpper: boolean;
30
+ b64Pad: string;
31
+ outputLen: number;
32
+ };
33
+ /**
34
+ * Parses an external constructor object and returns a packed number, if possible.
35
+ *
36
+ * @param key The human-friendly key name to prefix any errors with
37
+ * @param value The input value object to parse
38
+ * @param bigEndianMod Modifier for whether hash function is big or small endian.
39
+ * @param fallback Fallback value if `value` is undefined. If not present and `value` is undefined, an Error is thrown
40
+ */
41
+ export declare function parseInputOption(key: string, value: GenericInputType | undefined, bigEndianMod: -1 | 1, fallback?: packedValue): packedValue;
42
+ export declare abstract class jsSHABase<StateT, VariantT> {
43
+ /**
44
+ * @param variant The desired SHA variant.
45
+ * @param inputFormat The input format to be used in future `update` calls.
46
+ * @param options Hashmap of extra input options.
47
+ */
48
+ protected readonly shaVariant: VariantT;
49
+ protected readonly inputFormat: FormatType;
50
+ protected readonly utfType: EncodingType;
51
+ protected readonly numRounds: number;
52
+ protected abstract intermediateState: StateT;
53
+ protected keyWithIPad: number[];
54
+ protected keyWithOPad: number[];
55
+ protected remainder: number[];
56
+ protected remainderLen: number;
57
+ protected updateCalled: boolean;
58
+ protected processedLen: number;
59
+ protected macKeySet: boolean;
60
+ protected abstract readonly variantBlockSize: number;
61
+ protected abstract readonly bigEndianMod: -1 | 1;
62
+ protected abstract readonly outputBinLen: number;
63
+ protected abstract readonly isVariableLen: boolean;
64
+ protected abstract readonly HMACSupported: boolean;
65
+ protected abstract readonly converterFunc: (input: any, existingBin: number[], existingBinLen: number) => packedValue;
66
+ protected abstract readonly roundFunc: (block: number[], H: StateT) => StateT;
67
+ protected abstract readonly finalizeFunc: (remainder: number[], remainderBinLen: number, processedBinLen: number, H: StateT, outputLen: number) => number[];
68
+ protected abstract readonly stateCloneFunc: (state: StateT) => StateT;
69
+ protected abstract readonly newStateFunc: (variant: VariantT) => StateT;
70
+ protected abstract readonly getMAC: ((options: {
71
+ outputLen: number;
72
+ }) => number[]) | null;
73
+ protected constructor(variant: VariantT, inputFormat: 'TEXT', options?: FixedLengthOptionsEncodingType);
74
+ protected constructor(variant: VariantT, inputFormat: FormatNoTextType, options?: FixedLengthOptionsNoEncodingType);
75
+ /**
76
+ * Hashes as many blocks as possible. Stores the rest for either a future update or getHash call.
77
+ *
78
+ * @param srcString The input to be hashed.
79
+ * @returns A reference to the object.
80
+ */
81
+ update(srcString: string | ArrayBuffer | Uint8Array): this;
82
+ /**
83
+ * Returns the desired SHA hash of the input fed in via `update` calls.
84
+ *
85
+ * @param format The desired output formatting
86
+ * @param options Hashmap of output formatting options. `outputLen` must be specified for variable length hashes.
87
+ * `outputLen` replaces the now deprecated `shakeLen` key.
88
+ * @returns The hash in the format specified.
89
+ */
90
+ getHash(format: 'HEX', options?: {
91
+ outputUpper?: boolean;
92
+ outputLen?: number;
93
+ shakeLen?: number;
94
+ }): string;
95
+ getHash(format: 'B64', options?: {
96
+ b64Pad?: string;
97
+ outputLen?: number;
98
+ shakeLen?: number;
99
+ }): string;
100
+ getHash(format: 'BYTES', options?: {
101
+ outputLen?: number;
102
+ shakeLen?: number;
103
+ }): string;
104
+ getHash(format: 'UINT8ARRAY', options?: {
105
+ outputLen?: number;
106
+ shakeLen?: number;
107
+ }): Uint8Array;
108
+ getHash(format: 'ARRAYBUFFER', options?: {
109
+ outputLen?: number;
110
+ shakeLen?: number;
111
+ }): ArrayBuffer;
112
+ /**
113
+ * Sets the HMAC key for an eventual `getHMAC` call. Must be called immediately after jsSHA object instantiation.
114
+ *
115
+ * @param key The key used to calculate the HMAC
116
+ * @param inputFormat The format of key.
117
+ * @param options Hashmap of extra input options.
118
+ */
119
+ setHMACKey(key: string, inputFormat: 'TEXT', options?: {
120
+ encoding?: EncodingType;
121
+ }): void;
122
+ setHMACKey(key: string, inputFormat: 'B64' | 'HEX' | 'BYTES'): void;
123
+ setHMACKey(key: ArrayBuffer, inputFormat: 'ARRAYBUFFER'): void;
124
+ setHMACKey(key: Uint8Array, inputFormat: 'UINT8ARRAY'): void;
125
+ /**
126
+ * Internal function that sets the MAC key.
127
+ *
128
+ * @param key The packed MAC key to use
129
+ */
130
+ protected _setHMACKey(key: packedValue): void;
131
+ /**
132
+ * Returns the the HMAC in the specified format using the key given by a previous `setHMACKey` call.
133
+ *
134
+ * @param format The desired output formatting.
135
+ * @param options Hashmap of extra outputs options.
136
+ * @returns The HMAC in the format specified.
137
+ */
138
+ getHMAC(format: 'HEX', options?: {
139
+ outputUpper?: boolean;
140
+ }): string;
141
+ getHMAC(format: 'B64', options?: {
142
+ b64Pad?: string;
143
+ }): string;
144
+ getHMAC(format: 'BYTES'): string;
145
+ getHMAC(format: 'UINT8ARRAY'): Uint8Array;
146
+ getHMAC(format: 'ARRAYBUFFER'): ArrayBuffer;
147
+ /**
148
+ * Internal function that returns the "raw" HMAC
149
+ */
150
+ protected _getHMAC(): number[];
151
+ }