ranuts 0.1.0-alpha.9 → 0.2.0-alpha.1

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 (179) hide show
  1. package/CLAUDE.md +164 -0
  2. package/README.md +116 -0
  3. package/{readme.md → README.zh-CN.md} +43 -12
  4. package/dist/bin/generate-api-docs.d.ts +1 -0
  5. package/dist/build/build.es.d.ts +2 -0
  6. package/dist/build/build.umd.d.ts +2 -0
  7. package/dist/build/build.umd.node.d.ts +2 -0
  8. package/dist/build/build.umd.utils.d.ts +2 -0
  9. package/dist/color-CRdlaDqQ.js +1 -0
  10. package/dist/examples/clone-deep-example.d.ts +1 -0
  11. package/dist/examples/is-equal-example.d.ts +1 -0
  12. package/dist/index.d.ts +5 -21
  13. package/dist/index.js +1 -2484
  14. package/dist/plugins/vite-plugins-banner.d.ts +2 -0
  15. package/dist/rolldown-runtime-I3TIJKkN.js +1 -0
  16. package/dist/src/node/appendFile.d.ts +7 -0
  17. package/dist/src/node/body.d.ts +9 -0
  18. package/dist/src/node/color.d.ts +7 -0
  19. package/dist/src/node/command.d.ts +8 -0
  20. package/dist/src/node/ctx2req.d.ts +5 -0
  21. package/dist/src/node/fileInfo.d.ts +7 -0
  22. package/dist/src/node/fs.d.ts +7 -0
  23. package/dist/src/node/get.d.ts +10 -0
  24. package/dist/src/node/getIPAdress.d.ts +1 -0
  25. package/dist/src/node/index.d.ts +25 -0
  26. package/dist/src/node/index.js +1 -0
  27. package/dist/src/node/isColorSupported.d.ts +2 -0
  28. package/dist/src/node/paresUrl.d.ts +19 -0
  29. package/dist/src/node/readDir.d.ts +6 -0
  30. package/dist/src/node/readFile.d.ts +9 -0
  31. package/dist/src/node/router.d.ts +42 -0
  32. package/dist/src/node/send.d.ts +7 -0
  33. package/dist/src/node/server.d.ts +18 -0
  34. package/dist/src/node/startTask.d.ts +2 -0
  35. package/dist/src/node/stream.d.ts +15 -0
  36. package/dist/src/node/taskEnd.d.ts +2 -0
  37. package/dist/src/node/traverse.d.ts +17 -0
  38. package/dist/src/node/watchFile.d.ts +8 -0
  39. package/dist/src/node/writeFile.d.ts +8 -0
  40. package/dist/src/node/ws.d.ts +8 -0
  41. package/dist/src/utils/audioRecorder.d.ts +16 -0
  42. package/dist/src/utils/behavior.d.ts +15 -0
  43. package/dist/src/utils/bom.d.ts +294 -0
  44. package/dist/src/utils/color.d.ts +71 -0
  45. package/dist/src/utils/compose.d.ts +10 -0
  46. package/dist/src/utils/console.d.ts +1 -0
  47. package/dist/src/utils/debounce.d.ts +7 -0
  48. package/dist/src/utils/device.d.ts +25 -0
  49. package/dist/src/utils/dom.d.ts +105 -0
  50. package/dist/src/utils/error.d.ts +1 -0
  51. package/dist/src/utils/func.d.ts +1 -0
  52. package/dist/src/utils/img.d.ts +16 -0
  53. package/dist/src/utils/index.d.ts +35 -0
  54. package/dist/src/utils/index.js +1 -0
  55. package/dist/src/utils/memoize.d.ts +7 -0
  56. package/dist/src/utils/mimeType.d.ts +9 -0
  57. package/dist/src/utils/monitor.d.ts +38 -0
  58. package/dist/src/utils/network.d.ts +39 -0
  59. package/dist/src/utils/noop.d.ts +2 -0
  60. package/dist/src/utils/number.d.ts +45 -0
  61. package/dist/src/utils/obj.d.ts +83 -0
  62. package/dist/src/utils/performance.d.ts +21 -0
  63. package/dist/src/utils/queue.d.ts +33 -0
  64. package/dist/src/utils/report.d.ts +8 -0
  65. package/dist/src/utils/request.d.ts +17 -0
  66. package/dist/src/utils/script.d.ts +7 -0
  67. package/dist/src/utils/signal.d.ts +6 -0
  68. package/dist/src/utils/storage.d.ts +2 -0
  69. package/dist/src/utils/str.d.ts +212 -0
  70. package/dist/src/utils/subscribe.d.ts +46 -0
  71. package/dist/src/utils/throttle.d.ts +15 -0
  72. package/dist/src/utils/time.d.ts +20 -0
  73. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  74. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  75. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  76. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  77. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  78. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  79. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  80. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  81. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  82. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  83. package/dist/src/utils/totp/totp.d.ts +23 -0
  84. package/dist/src/utils/visual/application.d.ts +27 -0
  85. package/dist/src/utils/visual/enums.d.ts +27 -0
  86. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  87. package/dist/src/utils/visual/event/event.d.ts +14 -0
  88. package/dist/src/utils/visual/event/index.d.ts +6 -0
  89. package/dist/src/utils/visual/event/types.d.ts +32 -0
  90. package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
  91. package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
  92. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
  93. package/dist/src/utils/visual/graphics/index.d.ts +4 -0
  94. package/dist/src/utils/visual/index.d.ts +7 -0
  95. package/dist/src/utils/visual/index.js +1 -0
  96. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  97. package/dist/src/utils/visual/math/enums.d.ts +3 -0
  98. package/dist/src/utils/visual/math/index.d.ts +5 -0
  99. package/dist/src/utils/visual/math/matrix.d.ts +113 -0
  100. package/dist/src/utils/visual/math/transform.d.ts +29 -0
  101. package/dist/src/utils/visual/render/batchRenderer.d.ts +78 -0
  102. package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
  103. package/dist/src/utils/visual/render/index.d.ts +3 -0
  104. package/dist/src/utils/visual/render/render.d.ts +11 -0
  105. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  106. package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +1 -0
  107. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  108. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  109. package/dist/src/utils/visual/render/utils/index.test.d.ts +1 -0
  110. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  111. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +7 -0
  112. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  113. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  114. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  115. package/dist/src/utils/visual/render/webGlRenderer.d.ts +14 -0
  116. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  117. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  118. package/dist/src/utils/visual/shape/index.d.ts +7 -0
  119. package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
  120. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  121. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  122. package/dist/src/utils/visual/shape/shape.d.ts +6 -0
  123. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  124. package/dist/src/utils/visual/style/index.d.ts +3 -0
  125. package/dist/src/utils/visual/style/line.d.ts +10 -0
  126. package/dist/src/utils/visual/types.d.ts +18 -0
  127. package/dist/src/utils/visual/vertex/container.d.ts +74 -0
  128. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  129. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  130. package/dist/src/vnode/chainDom.d.ts +47 -0
  131. package/dist/src/vnode/h.d.ts +6 -0
  132. package/dist/src/vnode/hooks.d.ts +23 -0
  133. package/dist/src/vnode/htmlDomApi.d.ts +33 -0
  134. package/dist/src/vnode/index.d.ts +18 -0
  135. package/dist/src/vnode/index.js +1 -0
  136. package/dist/src/vnode/init.d.ts +2 -0
  137. package/dist/src/vnode/is.d.ts +5 -0
  138. package/dist/src/vnode/modules/attributes.d.ts +8 -0
  139. package/dist/src/vnode/modules/class.d.ts +8 -0
  140. package/dist/src/vnode/modules/index.d.ts +3 -0
  141. package/dist/src/vnode/modules/listeners.d.ts +12 -0
  142. package/dist/src/vnode/modules/props.d.ts +8 -0
  143. package/dist/src/vnode/modules/style.d.ts +14 -0
  144. package/dist/src/vnode/vnode.d.ts +31 -0
  145. package/dist/subscribe-CINWsor3.js +1 -0
  146. package/dist/test/bridge.test.d.ts +1 -0
  147. package/dist/test/clearBr.test.d.ts +1 -0
  148. package/dist/test/cloneDeep.test.d.ts +1 -0
  149. package/dist/test/command.test.d.ts +1 -0
  150. package/dist/test/encodeUrl.test.d.ts +1 -0
  151. package/dist/test/escapeHtml.test.d.ts +1 -0
  152. package/dist/test/is-equal.test.d.ts +1 -0
  153. package/dist/test/mimeType.test.d.ts +1 -0
  154. package/dist/test/package-exports.test.d.ts +1 -0
  155. package/dist/test/server.test.d.ts +1 -0
  156. package/dist/test/status.test.d.ts +1 -0
  157. package/dist/test/totp.test.d.ts +1 -0
  158. package/dist/test/utils/compose.test.d.ts +1 -0
  159. package/dist/test/utils/mergeObj.test.d.ts +1 -0
  160. package/dist/test/visual/math.test.d.ts +1 -0
  161. package/dist/test/visual-application.test.d.ts +1 -0
  162. package/dist/test/visual-batch.test.d.ts +1 -0
  163. package/dist/test/visual-math.test.d.ts +1 -0
  164. package/dist/test/vnode/index.d.ts +1 -0
  165. package/dist/test/vnode/server.d.ts +2 -0
  166. package/dist/test/vnode/vnode.d.ts +1 -0
  167. package/dist/test/vnode.test.d.ts +1 -0
  168. package/dist/test/websocket.test.d.ts +1 -0
  169. package/dist/test/writeFile.test.d.ts +1 -0
  170. package/dist/umd/index.umd.cjs +1 -0
  171. package/dist/umd/node/node.umd.cjs +1 -0
  172. package/dist/umd/utils/utils.umd.cjs +1 -0
  173. package/dist/utils-_OxsVZmz.js +1 -0
  174. package/dist/vite.config.d.ts +8 -0
  175. package/dist/vitest.config.d.ts +2 -0
  176. package/docs/API.md +305 -0
  177. package/package.json +67 -15
  178. package/typings.d.ts +28 -0
  179. package/dist/index.umd.cjs +0 -1
@@ -0,0 +1,71 @@
1
+ export declare const FMT: Record<string, Array<string>>;
2
+ type ColorVal = (string | number)[];
3
+ export declare class Rgb {
4
+ r: string | number;
5
+ g: string | number;
6
+ b: string | number;
7
+ constructor(col: Array<string | number>);
8
+ toString(): string;
9
+ }
10
+ export declare class Rgba extends Rgb {
11
+ a: string | number;
12
+ constructor(col: Array<string | number>);
13
+ toString(): string;
14
+ }
15
+ export declare class Hsl {
16
+ h: string | number;
17
+ s: string | number;
18
+ l: string | number;
19
+ constructor(col: Array<string | number>);
20
+ toString(): string;
21
+ }
22
+ export declare class Hsla extends Hsl {
23
+ a: string | number;
24
+ constructor(col: Array<string | number>);
25
+ toString(): string;
26
+ }
27
+ export declare class Color {
28
+ r: string | number;
29
+ g: string | number;
30
+ b: string | number;
31
+ a: string | number;
32
+ rgb: Rgb;
33
+ rgba: Rgba;
34
+ hex: string;
35
+ hsl: Hsl;
36
+ hsla: Hsla;
37
+ h: string | number;
38
+ s: string | number;
39
+ l: string | number;
40
+ constructor(r: string | number | Array<string | number>, g?: string | number, b?: string | number, a?: string | number);
41
+ setHue(newHue: string | number): void;
42
+ setSat(newSat: string | number): void;
43
+ setLum(newLum: number): void;
44
+ setAlpha(newAlpha: string | number): void;
45
+ updateFromHsl(): void;
46
+ }
47
+ export declare const randomColor: () => Color;
48
+ export declare const hexToRgb: (hex: string) => RegExpExecArray | null | Array<number>;
49
+ export declare const componentToHex: (c: string | number) => string;
50
+ export declare const rgbToHex: (r: string | number | Array<string | number>, g?: string | number, b?: string | number) => string;
51
+ export declare const rgbToHsl: (r: number | number[], g?: number, b?: number) => Array<number>;
52
+ export declare const hue2rgb: (p: number, q: number, t: number) => number;
53
+ export declare const hslToRgb: (h: number | string | number[], s: number | string, l: number | string) => Array<number>;
54
+ export declare const rgbToHsb: (r: number, g: number, b: number) => number[];
55
+ export declare const hsbToRgb: (h: number, s: number, v: number) => number[];
56
+ export declare const hsvToRgb: (h: number, s: number, v: number) => number[];
57
+ export declare const hsbToHsl: (h: any, s: any, b: any) => number[];
58
+ export declare const hsvToHsl: (h: any, s: any, b: any) => number[];
59
+ export declare class ColorScheme {
60
+ palette: Color[];
61
+ constructor(colorVal: (string | number)[], angleArray: number[]);
62
+ createFromColors(colorVal: (string | number)[]): Color[];
63
+ createFromAngles(colorVal: string | number | (string | number)[], angleArray: number[]): Color[];
64
+ static Compl(colorVal: ColorVal): ColorScheme;
65
+ static Triad(colorVal: ColorVal): ColorScheme;
66
+ static Tetrad(colorVal: ColorVal): ColorScheme;
67
+ static Analog(colorVal: ColorVal): ColorScheme;
68
+ static Split(colorVal: ColorVal): ColorScheme;
69
+ static Accent(colorVal: ColorVal): ColorScheme;
70
+ }
71
+ export {};
@@ -0,0 +1,10 @@
1
+ export type Next = () => Promise<never> | Promise<void>;
2
+ type Middleware<T> = (context: T, next: Next) => any;
3
+ type ComposedMiddleware<T> = (context: T, next?: Next) => Promise<void>;
4
+ /**
5
+ * @description: 将异步函数转化为同步的方式进行执行
6
+ * @param {Array} middleware
7
+ * @return {*}
8
+ */
9
+ export declare function compose<T>(middleware: Array<Middleware<T>>): ComposedMiddleware<T>;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare const handleConsole: (hooks?: (...args: unknown[]) => void) => void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 防抖
3
+ * @param {any} fn
4
+ * @param {*} ms
5
+ * @return {*}
6
+ */
7
+ export declare const debounce: (fn: any, ms?: number) => any;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @description: 判断当前设备
3
+ * @param {*} function
4
+ * @return {*}
5
+ */
6
+ export declare enum DEVICE {
7
+ IPAD = "ipad",
8
+ ANDROID = "android",
9
+ IPhONE = "iphone",
10
+ PC = "pc"
11
+ }
12
+ export type CurrentDevice = 'ipad' | 'android' | 'iphone' | 'pc';
13
+ export declare const currentDevice: () => CurrentDevice;
14
+ export declare const isClient: boolean;
15
+ /**
16
+ * @description: 判断是否是微信浏览器的函数
17
+ * @param {*} boolean
18
+ * @return {*}
19
+ */
20
+ export declare const isWeiXin: () => boolean;
21
+ /**
22
+ * 是否是移动端
23
+ */
24
+ export declare const isMobile: () => boolean;
25
+ export declare const isBangDevice: () => boolean;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @description: 给指定的元素添加指定的 class
3
+ * @param {Element} element
4
+ * @param {string} addClass
5
+ */
6
+ export declare const addClassToElement: (element: Element, addClass: string) => void;
7
+ /**
8
+ * @description: 给指定的元素移除指定的 class
9
+ * @param {Element} element
10
+ * @param {string} removeClass
11
+ */
12
+ export declare const removeClassToElement: (element: Element, removeClass: string) => void;
13
+ /**
14
+ * @description: 创建一个 Fragment
15
+ * @param {Element} list
16
+ * @return {*}
17
+ */
18
+ export declare const createDocumentFragment: (list: Element[]) => DocumentFragment | undefined;
19
+ export declare function escapeHtml(string?: string | number | null): string;
20
+ /**
21
+ * @description: 根据 UI 稿宽度设置 rem
22
+ * @param {*} void
23
+ * @return {*}
24
+ */
25
+ export declare const setFontSize2html: (designWidth?: number) => void;
26
+ /**
27
+ * @description: 链式调用的 dom 操作
28
+ * (tag) (key value) (children)
29
+ * @return {HTMLElement}
30
+ */
31
+ export declare class Chain {
32
+ listener: Map<string, Map<string, EventListener>>;
33
+ element: HTMLElement;
34
+ constructor(tagName: string, options?: ElementCreationOptions);
35
+ /**
36
+ * @description: 创建元素
37
+ * @param {string} tagName
38
+ * @param {ElementCreationOptions} options
39
+ * @return {Chain}
40
+ */
41
+ create: (tagName: string, options?: ElementCreationOptions) => HTMLElement;
42
+ /**
43
+ * @description: 设置当前元素的属性
44
+ * @param {string} name
45
+ * @param {string} value
46
+ * @return {Chain}
47
+ */
48
+ setAttribute: (name: string, value: string) => Chain;
49
+ /**
50
+ * @description: 移除当前元素的属性
51
+ * @param {string} name
52
+ * @return {Chain}
53
+ */
54
+ removeAttribute: (name: string) => Chain;
55
+ /**
56
+ * @description: 当前元素添加子元素
57
+ * @param {HTMLElement} child
58
+ * @return {ChainElement}
59
+ */
60
+ append: (child: HTMLElement) => Chain;
61
+ /**
62
+ * @description: 当前元素移除子元素
63
+ * @param {HTMLElement} child
64
+ * @return {Chain}
65
+ */
66
+ remove: (child: HTMLElement) => Chain;
67
+ /**
68
+ * @description: 给当前元素设置文本内容
69
+ * @param {string} text
70
+ * @return {Chain}
71
+ */
72
+ setTextContent: (text: string) => Chain;
73
+ /**
74
+ * @description: 给当前元素设置样式
75
+ * @param {string} name
76
+ * @param {string} value
77
+ * @return {Chain}
78
+ */
79
+ setStyle: (name: string, value: string) => Chain;
80
+ private addElementByType;
81
+ /**
82
+ * @description: 给当前元素添加子元素
83
+ * @return {Chain}
84
+ */
85
+ addChild: (child: Chain | Chain[] | HTMLElement | HTMLElement[]) => Chain;
86
+ /**
87
+ * @description: 给当前元素添加事件监听
88
+ * @param {string} type
89
+ * @param {EventListener} listener
90
+ * @return {Chain}
91
+ */
92
+ listen: <K extends keyof HTMLElementEventMap>(type: K, listener: EventListener, options?: boolean | AddEventListenerOptions) => Chain;
93
+ /**
94
+ * @description: 移除当前元素的事件监听
95
+ * @param {string} type
96
+ * @return {Chain}
97
+ */
98
+ clearListener: <K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions) => Chain;
99
+ /**
100
+ * @description: 移除当前元素的所有事件监听
101
+ * @return {Chain}
102
+ */
103
+ clearAllListener: () => Chain;
104
+ }
105
+ export declare const create: (tagName: string, options?: ElementCreationOptions) => Chain;
@@ -0,0 +1 @@
1
+ export declare const handleError: (hooks?: (error: Error | PromiseRejectionEvent | ErrorEvent) => void) => void;
@@ -0,0 +1 @@
1
+ export declare const isFunction: (handler: unknown) => handler is Function;
@@ -0,0 +1,16 @@
1
+ import type { BaseReturn } from '@/utils/bom';
2
+ /**
3
+ * @description: 校验图片尺寸
4
+ * @param {File} file
5
+ * @return {*}
6
+ */
7
+ export declare const isImageSize: (file: File, width?: number, height?: number) => Promise<boolean>;
8
+ export interface convertImageToBase64Return extends BaseReturn {
9
+ data: string | ArrayBuffer | null;
10
+ }
11
+ /**
12
+ * @description: 图片转 base64
13
+ * @param {File} file
14
+ * @return {*}
15
+ */
16
+ export declare const convertImageToBase64: (file: File) => Promise<convertImageToBase64Return>;
@@ -0,0 +1,35 @@
1
+ import { SyncHook } from './subscribe';
2
+ import { Mathjs, addNumSym, mathjs, perToNum, range, transformNumber } from './number';
3
+ import { MessageCodec, changeHumpToLowerCase, checkEncoding, clearBr, clearStr, getMatchingSentences, getRandomString, isString, md5, randomString, str2Xml, strParse, toString, transformText } from './str';
4
+ import type { TransformText } from './str';
5
+ import { BridgeManager, Client, Platform, PostMessageBridge, acceptPortBridge, createPortBridge, openPortBridge, BRIDGE_MARKER, DEFAULT_CHANNEL, appendUrl, bridgeManager, connection, createObjectURL, durationHandler, encodeUrl, getAllQueryString, getCookie, getCookieByName, getFrame, getHost, getPixelRatio, getQuery, getWindow, imageRequest, isSafari, networkSpeed, removeGhosting, requestUrlToBuffer, retain } from './bom';
6
+ import type { BridgeManagerOptions, BroadcastPayload, CallToPayload, MessageData, MessageHandler, PendingRequest, PortBridge, OpenPortBridgeOptions, AcceptPortBridgeOptions } from './bom';
7
+ import { cloneDeep, filterObj, formatJson, isEqual, merge, mergeExports, querystring, replaceOld, setAttributeByGlobal } from './obj';
8
+ import { MimeType, getExtensions, getMime, setMime } from './mimeType';
9
+ import { AudioRecorder } from './audioRecorder';
10
+ import { createSignal, subscribers } from './signal';
11
+ import { audioVendor, canvasVendor, webglVendor } from './behavior';
12
+ import { TOTP } from './totp/totp';
13
+ import { localStorageGetItem, localStorageSetItem } from './storage';
14
+ import { compose } from './compose';
15
+ import { handleConsole } from './console';
16
+ import { debounce } from './debounce';
17
+ import { Chain, addClassToElement, create, createDocumentFragment, escapeHtml, removeClassToElement, setFontSize2html } from './dom';
18
+ import { handleError } from './error';
19
+ import { convertImageToBase64, isImageSize } from './img';
20
+ import { memoize } from './memoize';
21
+ import { Monitor } from './monitor';
22
+ import { getStatus, status } from './network';
23
+ import { noop } from './noop';
24
+ import { getPerformance } from './performance';
25
+ import { QuestQueue } from './queue';
26
+ import { createData, report } from './report';
27
+ import { handleFetchHook } from './request';
28
+ import { scriptOnLoad } from './script';
29
+ import { generateThrottle, throttle } from './throttle';
30
+ import { performanceTime, timeFormat, timestampToTime } from './time';
31
+ import type { CurrentDevice } from './device';
32
+ import { currentDevice, isBangDevice, isClient, isMobile, isWeiXin } from './device';
33
+ import { Color, ColorScheme, FMT, Hsl, Hsla, Rgb, Rgba, componentToHex, hexToRgb, hsbToRgb, hslToRgb, hsvToHsl, hsvToRgb, hue2rgb, randomColor, rgbToHex, rgbToHsb, rgbToHsl } from '@/utils/color';
34
+ export { performanceTime, timeFormat, timestampToTime, generateThrottle, throttle, SyncHook, changeHumpToLowerCase, clearBr, clearStr, isString, randomString, str2Xml, strParse, scriptOnLoad, handleFetchHook, createData, report, QuestQueue, noop, getPerformance, querystring, formatJson, filterObj, merge, replaceOld, mergeExports, perToNum, range, Mathjs, mathjs, getStatus, status, Monitor, MimeType, getExtensions, setMime, getMime, memoize, isImageSize, convertImageToBase64, handleError, addClassToElement, removeClassToElement, createDocumentFragment, escapeHtml, isClient, isWeiXin, isMobile, debounce, currentDevice, handleConsole, compose, Color, FMT, Hsl, Hsla, Rgb, Rgba, randomColor, hexToRgb, componentToHex, rgbToHex, rgbToHsl, hue2rgb, hslToRgb, rgbToHsb, hsbToRgb, hsvToRgb, hsvToHsl, ColorScheme, AudioRecorder, webglVendor, canvasVendor, audioVendor, retain, getCookie, requestUrlToBuffer, getPixelRatio, createObjectURL, getFrame, getHost, getAllQueryString, appendUrl, removeGhosting, getCookieByName, getWindow, connection, encodeUrl, imageRequest, durationHandler, networkSpeed, TOTP, isBangDevice, localStorageGetItem, localStorageSetItem, setAttributeByGlobal, setFontSize2html, Chain, create, isEqual, cloneDeep, createSignal, subscribers, getMatchingSentences, transformNumber, toString, addNumSym, getQuery, checkEncoding, transformText, isSafari, md5, getRandomString, bridgeManager, Client, BridgeManager, PostMessageBridge, MessageCodec, Platform, openPortBridge, acceptPortBridge, createPortBridge, BRIDGE_MARKER, DEFAULT_CHANNEL, };
35
+ export type { CurrentDevice, TransformText, MessageHandler, MessageData, PendingRequest, BridgeManagerOptions, BroadcastPayload, CallToPayload, PortBridge, OpenPortBridgeOptions, AcceptPortBridgeOptions, };
@@ -0,0 +1 @@
1
+ import{t as s}from"../../subscribe-CINWsor3.js";import{A as a,C as t,D as o,E as r,F as m,I as i,M as p,N as f,O as j,P as b,S as c,T as l,_ as u,a as x,b as d,c as e,d as g,f as h,g as k,h as n,i as v,j as w,k as y,l as A,m as C,n as D,o as E,p as M,r as N,s as O,t as S,u as T,v as _,w as F,x as I,y as P}from"../../color-CRdlaDqQ.js";import{$ as q,A as z,At as B,B as G,C as H,Ct as J,D as K,Dt as L,E as Q,Et as R,F as U,G as V,H as W,I as X,J as Y,K as Z,L as $,M as ss,Mt as as,N as ts,Nt as os,O as rs,Ot as ms,P as is,Q as ps,R as fs,S as js,St as bs,T as cs,Tt as ls,U as us,V as xs,W as ds,X as es,Y as gs,Z as hs,_ as ks,_t as ns,a as vs,at as ws,b as ys,bt as As,c as Cs,ct as Ds,d as Es,dt as Ms,et as Ns,f as Os,ft as Ss,g as Ts,gt as _s,h as Fs,ht as Is,i as Ps,it as qs,j as zs,jt as Bs,k as Gs,kt as Hs,l as Js,lt as Ks,m as Ls,mt as Qs,n as Rs,nt as Us,o as Vs,ot as Ws,p as Xs,pt as Ys,q as Zs,r as $s,rt as sa,s as aa,st as ta,t as oa,tt as ra,u as ma,ut as ia,v as pa,vt as fa,w as ja,wt as ba,x as ca,xt as la,y as ua,yt as xa,z as da}from"../../utils-_OxsVZmz.js";export{ts as AudioRecorder,ds as BRIDGE_MARKER,V as BridgeManager,Fs as Chain,Z as Client,S as Color,D as ColorScheme,Zs as DEFAULT_CHANNEL,N as FMT,v as Hsl,x as Hsla,ms as Mathjs,t as MessageCodec,P as MimeType,vs as Monitor,Y as Platform,gs as PostMessageBridge,Rs as QuestQueue,E as Rgb,O as Rgba,s as SyncHook,K as TOTP,es as acceptPortBridge,Ts as addClassToElement,Hs as addNumSym,hs as appendUrl,rs as audioVendor,ps as bridgeManager,Gs as canvasVendor,F as changeHumpToLowerCase,l as checkEncoding,r as clearBr,o as clearStr,is as cloneDeep,e as componentToHex,ja as compose,q as connection,Os as convertImageToBase64,ks as create,Js as createData,pa as createDocumentFragment,Ns as createObjectURL,ra as createPortBridge,zs as createSignal,xa as currentDevice,js as debounce,Us as durationHandler,sa as encodeUrl,ua as escapeHtml,U as filterObj,X as formatJson,Vs as generateThrottle,qs as getAllQueryString,ws as getCookie,Ws as getCookieByName,d as getExtensions,ta as getFrame,Ds as getHost,j as getMatchingSentences,I as getMime,Es as getPerformance,Ks as getPixelRatio,ia as getQuery,y as getRandomString,$s as getStatus,Ms as getWindow,H as handleConsole,Ls as handleError,Cs as handleFetchHook,A as hexToRgb,T as hsbToRgb,g as hslToRgb,h as hsvToHsl,M as hsvToRgb,C as hue2rgb,Ss as imageRequest,As as isBangDevice,la as isClient,$ as isEqual,Xs as isImageSize,bs as isMobile,Ys as isSafari,a as isString,J as isWeiXin,cs as localStorageGetItem,Q as localStorageSetItem,B as mathjs,w as md5,us as memoize,fs as merge,da as mergeExports,Qs as networkSpeed,L as noop,Is as openPortBridge,Bs as perToNum,ba as performanceTime,G as querystring,n as randomColor,p as randomString,as as range,ys as removeClassToElement,_s as removeGhosting,xs as replaceOld,ma as report,ns as requestUrlToBuffer,fa as retain,k as rgbToHex,u as rgbToHsb,_ as rgbToHsl,oa as scriptOnLoad,W as setAttributeByGlobal,ca as setFontSize2html,c as setMime,Ps as status,f as str2Xml,b as strParse,ss as subscribers,aa as throttle,ls as timeFormat,R as timestampToTime,m as toString,os as transformNumber,i as transformText,z as webglVendor};
@@ -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,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,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?: () => void) => 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;