@unicom-cloud/utils 0.1.5 → 0.1.11

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 (135) hide show
  1. package/caseName.js +11 -0
  2. package/className.js +5 -0
  3. package/clipboardCopy.js +6 -0
  4. package/constant.js +4 -0
  5. package/content-disposition/index.js +56 -0
  6. package/contentDisposition.js +7 -0
  7. package/convert-time/index.js +61 -0
  8. package/convertTime.js +4 -0
  9. package/cookie.js +7 -0
  10. package/dayjs.js +5 -0
  11. package/decimal.js +5 -0
  12. package/eventEmitter.js +4 -0
  13. package/file.js +6 -0
  14. package/filesize.js +8 -0
  15. package/index.js +44 -31
  16. package/invariant.js +4 -0
  17. package/is.js +92 -0
  18. package/lunar-converter/index.js +641 -0
  19. package/lunarConverter.js +4 -0
  20. package/math.js +9 -0
  21. package/md5.js +4 -0
  22. package/mock.js +8 -0
  23. package/normalizeWheel.js +6 -0
  24. package/number-to-chinese/index.js +72 -0
  25. package/numberToChinese.js +4 -0
  26. package/nzh.js +4 -0
  27. package/object-keys-sort/index.js +7 -0
  28. package/objectKeysSort.js +2 -5
  29. package/package.json +1 -1
  30. package/random.js +15 -0
  31. package/screenfull.js +4 -0
  32. package/search-tree/index.js +54 -0
  33. package/searchTree.js +4 -0
  34. package/snapdom/src/api/preCache.js +31 -27
  35. package/snapdom/src/core/capture.js +55 -44
  36. package/snapdom/src/core/clone.js +11 -11
  37. package/snapdom/src/core/prepare.js +38 -31
  38. package/snapdom/src/modules/background.js +18 -43
  39. package/snapdom/src/modules/pseudo.js +66 -67
  40. package/snapdom/src/utils/helpers.js +105 -56
  41. package/snapdom.js +6 -0
  42. package/tree.js +11 -0
  43. package/turboStream.js +6 -0
  44. package/types/case-name/index.d.ts +11 -0
  45. package/types/class-name/index.d.ts +2 -0
  46. package/types/clipboard-copy/index.d.ts +2 -0
  47. package/types/constant/address.d.ts +14 -0
  48. package/types/constant/chineseCharacters.d.ts +2 -0
  49. package/types/constant/constellations.d.ts +2 -0
  50. package/types/constant/domain.d.ts +2 -0
  51. package/types/constant/identity.d.ts +2 -0
  52. package/types/constant/index.d.ts +1 -0
  53. package/types/constant/keyboardCode.d.ts +158 -0
  54. package/types/constant/licensePlate.d.ts +2 -0
  55. package/types/constant/name.d.ts +4 -0
  56. package/types/constant/platform.d.ts +11 -0
  57. package/types/constant/protocol.d.ts +2 -0
  58. package/types/constant/ui.d.ts +14 -0
  59. package/types/content-disposition/index.d.ts +10 -0
  60. package/types/convert-time/index.d.ts +32 -0
  61. package/types/cookie/index.d.ts +4 -0
  62. package/types/cookie/src/index.d.ts +114 -0
  63. package/types/dayjs/index.d.ts +1 -0
  64. package/types/decimal/decimal.d.ts +4 -0
  65. package/types/decimal/index.d.ts +1 -0
  66. package/types/event-emitter/index.d.ts +17 -0
  67. package/types/file/fileToURL.d.ts +2 -0
  68. package/types/file/index.d.ts +3 -0
  69. package/types/file/saveAs.d.ts +2 -0
  70. package/types/filesize/index.d.ts +2 -0
  71. package/types/filesize/src/constants.d.ts +42 -0
  72. package/types/filesize/src/filesize.d.ts +47 -0
  73. package/types/index.d.ts +24 -0
  74. package/types/invariant/index.d.ts +2 -0
  75. package/types/is/index.d.ts +53 -0
  76. package/types/lunar-converter/index.d.ts +113 -0
  77. package/types/math/index.d.ts +11 -0
  78. package/types/md5/index.d.ts +2 -0
  79. package/types/mock/MockWebSocket.d.ts +17 -0
  80. package/types/mock/MockXMLHttpRequest.d.ts +17 -0
  81. package/types/mock/index.d.ts +2 -0
  82. package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
  83. package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
  84. package/types/normalize-wheel/index.d.ts +115 -0
  85. package/types/normalize-wheel/isEventSupported.d.ts +16 -0
  86. package/types/number-to-chinese/index.d.ts +11 -0
  87. package/types/nzh/cn.d.ts +8 -0
  88. package/types/nzh/hk.d.ts +8 -0
  89. package/types/nzh/index.d.ts +1 -0
  90. package/types/nzh/nzh.d.ts +36 -0
  91. package/types/nzh/src/autoGet.d.ts +8 -0
  92. package/types/nzh/src/index.d.ts +34 -0
  93. package/types/nzh/src/langs/cn_b.d.ts +10 -0
  94. package/types/nzh/src/langs/cn_s.d.ts +7 -0
  95. package/types/nzh/src/langs/hk_b.d.ts +10 -0
  96. package/types/nzh/src/langs/hk_s.d.ts +7 -0
  97. package/types/nzh/src/utils.d.ts +65 -0
  98. package/types/object-keys-sort/index.d.ts +4 -0
  99. package/types/random/address.d.ts +8 -0
  100. package/types/random/constellation.d.ts +2 -0
  101. package/types/random/image.d.ts +5 -0
  102. package/types/random/index.d.ts +40 -0
  103. package/types/random/licensePlate.d.ts +2 -0
  104. package/types/random/name.d.ts +9 -0
  105. package/types/random/number.d.ts +6 -0
  106. package/types/random/text.d.ts +13 -0
  107. package/types/random/time.d.ts +2 -0
  108. package/types/random/web.d.ts +11 -0
  109. package/types/screenfull/index.d.ts +10 -0
  110. package/types/search-tree/index.d.ts +20 -0
  111. package/types/snapdom/index.d.ts +1 -0
  112. package/types/snapdom/src/api/preCache.d.ts +8 -0
  113. package/types/snapdom/src/api/snapdom.d.ts +26 -0
  114. package/types/snapdom/src/core/cache.d.ts +11 -0
  115. package/types/snapdom/src/core/capture.d.ts +17 -0
  116. package/types/snapdom/src/core/clone.d.ts +11 -0
  117. package/types/snapdom/src/core/prepare.d.ts +8 -0
  118. package/types/snapdom/src/index.browser.d.ts +1 -0
  119. package/types/snapdom/src/index.d.ts +2 -0
  120. package/types/snapdom/src/modules/background.d.ts +10 -0
  121. package/types/snapdom/src/modules/fonts.d.ts +25 -0
  122. package/types/snapdom/src/modules/images.d.ts +8 -0
  123. package/types/snapdom/src/modules/pseudo.d.ts +12 -0
  124. package/types/snapdom/src/modules/styles.d.ts +10 -0
  125. package/types/snapdom/src/utils/cssTools.d.ts +38 -0
  126. package/types/snapdom/src/utils/helpers.d.ts +71 -0
  127. package/types/tree/index.d.ts +8 -0
  128. package/types/turbo-stream/index.d.ts +1 -0
  129. package/types/turbo-stream/src/decode.d.ts +7 -0
  130. package/types/turbo-stream/src/encode.d.ts +27 -0
  131. package/types/turbo-stream/src/shared.d.ts +107 -0
  132. package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
  133. package/types/url-toolkit/index.d.ts +2 -0
  134. package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
  135. package/urlToolkit.js +8 -0
@@ -0,0 +1,115 @@
1
+ export default normalizeWheel;
2
+ /**
3
+ * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
4
+ * complicated, thus this doc is long and (hopefully) detailed enough to answer
5
+ * your questions.
6
+ *
7
+ * If you need to react to the mouse wheel in a predictable way, this code is
8
+ * like your bestest friend. * hugs *
9
+ *
10
+ * As of today, there are 4 DOM event types you can listen to:
11
+ *
12
+ * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
13
+ * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
14
+ * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
15
+ * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
16
+ *
17
+ * So what to do? The is the best:
18
+ *
19
+ * normalizeWheel.getEventType();
20
+ *
21
+ * In your event callback, use this code to get sane interpretation of the
22
+ * deltas. This code will return an object with properties:
23
+ *
24
+ * spinX -- normalized spin speed (use for zoom) - x plane
25
+ * spinY -- " - y plane
26
+ * pixelX -- normalized distance (to pixels) - x plane
27
+ * pixelY -- " - y plane
28
+ *
29
+ * Wheel values are provided by the browser assuming you are using the wheel to
30
+ * scroll a web page by a number of lines or pixels (or pages). Values can vary
31
+ * significantly on different platforms and browsers, forgetting that you can
32
+ * scroll at different speeds. Some devices (like trackpads) emit more events
33
+ * at smaller increments with fine granularity, and some emit massive jumps with
34
+ * linear speed or acceleration.
35
+ *
36
+ * This code does its best to normalize the deltas for you:
37
+ *
38
+ * - spin is trying to normalize how far the wheel was spun (or trackpad
39
+ * dragged). This is super useful for zoom support where you want to
40
+ * throw away the chunky scroll steps on the PC and make those equal to
41
+ * the slow and smooth tiny steps on the Mac. Key data: This code tries to
42
+ * resolve a single slow step on a wheel to 1.
43
+ *
44
+ * - pixel is normalizing the desired scroll delta in pixel units. You'll
45
+ * get the crazy differences between browsers, but at least it'll be in
46
+ * pixels!
47
+ *
48
+ * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
49
+ * should translate to positive value zooming IN, negative zooming OUT.
50
+ * This matches the newer 'wheel' event.
51
+ *
52
+ * Why are there spinX, spinY (or pixels)?
53
+ *
54
+ * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
55
+ * with a mouse. It results in side-scrolling in the browser by default.
56
+ *
57
+ * - spinY is what you expect -- it's the classic axis of a mouse wheel.
58
+ *
59
+ * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
60
+ * probably is by browsers in conjunction with fancy 3D controllers .. but
61
+ * you know.
62
+ *
63
+ * Implementation info:
64
+ *
65
+ * Examples of 'wheel' event if you scroll slowly (down) by one step with an
66
+ * average mouse:
67
+ *
68
+ * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
69
+ * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
70
+ * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
71
+ * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
72
+ * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
73
+ *
74
+ * On the trackpad:
75
+ *
76
+ * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
77
+ * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
78
+ *
79
+ * On other/older browsers.. it's more complicated as there can be multiple and
80
+ * also missing delta values.
81
+ *
82
+ * The 'wheel' event is more standard:
83
+ *
84
+ * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
85
+ *
86
+ * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
87
+ * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
88
+ * backward compatibility with older events. Those other values help us
89
+ * better normalize spin speed. Example of what the browsers provide:
90
+ *
91
+ * | event.wheelDelta | event.detail
92
+ * ------------------+------------------+--------------
93
+ * Safari v5/OS X | -120 | 0
94
+ * Safari v5/Win7 | -120 | 0
95
+ * Chrome v17/OS X | -120 | 0
96
+ * Chrome v17/Win7 | -120 | 0
97
+ * IE9/Win7 | -120 | undefined
98
+ * Firefox v4/OS X | undefined | 1
99
+ * Firefox v4/Win7 | undefined | 3
100
+ *
101
+ */
102
+ declare function normalizeWheel(event: any): {
103
+ spinX: number;
104
+ spinY: number;
105
+ pixelX: number;
106
+ pixelY: number;
107
+ };
108
+ declare namespace normalizeWheel {
109
+ /**
110
+ * The best combination if you prefer spinX + spinY normalization. It favors
111
+ * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
112
+ * 'wheel' event, making spin speed determination impossible.
113
+ */
114
+ function getEventType(): "wheel" | "DOMMouseScroll" | "mousewheel";
115
+ }
@@ -0,0 +1,16 @@
1
+ export default isEventSupported;
2
+ /**
3
+ * Checks if an event is supported in the current execution environment.
4
+ *
5
+ * NOTE: This will not work correctly for non-generic events such as `change`,
6
+ * `reset`, `load`, `error`, and `select`.
7
+ *
8
+ * Borrows from Modernizr.
9
+ *
10
+ * @param {string} eventNameSuffix Event name, e.g. "click".
11
+ * @param {?boolean} capture Check if the capture phase is supported.
12
+ * @return {boolean} True if the event is supported.
13
+ * @internal
14
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
15
+ */
16
+ declare function isEventSupported(eventNameSuffix: string, capture: boolean | null): boolean;
@@ -0,0 +1,11 @@
1
+ interface NumberToChineseOptions {
2
+ mode?: 'normal' | 'money';
3
+ negativeSymbol?: string;
4
+ decimalDigits?: number;
5
+ trailingZeros?: boolean;
6
+ }
7
+ /**
8
+ * 数字转中文主函数
9
+ */
10
+ declare function numberToChinese(num: number, options?: NumberToChineseOptions): string;
11
+ export default numberToChinese;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ encodeS: (num: any, options: any) => string;
3
+ encodeB: (num: any, options: any) => string;
4
+ decodeS: (...args: any[]) => string | number;
5
+ decodeB: (...args: any[]) => string | number;
6
+ toMoney: (num: any, options: any) => string;
7
+ };
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ encodeS: (num: any, options: any) => string;
3
+ encodeB: (num: any, options: any) => string;
4
+ decodeS: (...args: any[]) => string | number;
5
+ decodeB: (...args: any[]) => string | number;
6
+ toMoney: (num: any, options: any) => string;
7
+ };
8
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ export default Nzh;
2
+ declare function Nzh(lang: any): void;
3
+ declare class Nzh {
4
+ constructor(lang: any);
5
+ lang: any;
6
+ encode: (...args: any[]) => string;
7
+ decode: (...args: any[]) => string | number;
8
+ toMoney: (...args: any[]) => string;
9
+ }
10
+ declare namespace Nzh {
11
+ export { langs };
12
+ export let cn: {
13
+ encodeS: (num: any, options: any) => string;
14
+ encodeB: (num: any, options: any) => string;
15
+ decodeS: (...args: any[]) => string | number;
16
+ decodeB: (...args: any[]) => string | number;
17
+ toMoney: (num: any, options: any) => string;
18
+ };
19
+ export let hk: {
20
+ encodeS: (num: any, options: any) => string;
21
+ encodeB: (num: any, options: any) => string;
22
+ decodeS: (...args: any[]) => string | number;
23
+ decodeB: (...args: any[]) => string | number;
24
+ toMoney: (num: any, options: any) => string;
25
+ };
26
+ }
27
+ declare namespace langs {
28
+ export { cn_s as s };
29
+ export { cn_b as b };
30
+ export { hk_s };
31
+ export { hk_b };
32
+ }
33
+ import cn_s from './src/langs/cn_s';
34
+ import cn_b from './src/langs/cn_b';
35
+ import hk_s from './src/langs/hk_s';
36
+ import hk_b from './src/langs/hk_b';
@@ -0,0 +1,8 @@
1
+ export function getNzhObjByLang(lang_s: any, lang_b: any): {
2
+ encodeS: (num: any, options: any) => string;
3
+ encodeB: (num: any, options: any) => string;
4
+ decodeS: (...args: any[]) => string | number;
5
+ decodeB: (...args: any[]) => string | number;
6
+ toMoney: (num: any, options: any) => string;
7
+ };
8
+ export default getNzhObjByLang;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 阿拉伯数字转中文数字
3
+ *
4
+ * @param {String} num 阿拉伯数字/字符串 , 科学记数法字符串
5
+ * @param {Object} opration 转换配置
6
+ * {
7
+ * ww: {万万化单位 | false}
8
+ * tenMin: {十的口语化 | false}
9
+ * }
10
+ * @returns String
11
+ */
12
+ export function CL(num: string, options: any): string;
13
+ /**
14
+ * 中文数字转阿拉伯数字
15
+ *
16
+ * @param {string} cnnumb 中文数字字符串
17
+ * @returns Number
18
+ */
19
+ export function unCL(cnnumb: string, options: any): string | number;
20
+ /**
21
+ * 阿拉伯数字转金额
22
+ *
23
+ * @param {String} num 阿拉伯数字/字符串 , 科学记数法字符串
24
+ * @param {Object} options 转换配置
25
+ * {
26
+ * ww:{万万化开关 | true},
27
+ * unOmitYuan: {整数为0时不省略元| false},
28
+ * complete:{完整金额格式 | false},
29
+ * outSymbol:{是否输出金额符号 | true}
30
+ * forceZheng:{以转换结果加“整” | false}
31
+ * }
32
+ * @returns String
33
+ */
34
+ export function toMoney(num: string, options: Object): string;
@@ -0,0 +1,10 @@
1
+ export default cn_b;
2
+ declare namespace cn_b {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ let m_t: string;
8
+ let m_z: string;
9
+ let m_u: string;
10
+ }
@@ -0,0 +1,7 @@
1
+ export default cn_s;
2
+ declare namespace cn_s {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ }
@@ -0,0 +1,10 @@
1
+ export default hk_b;
2
+ declare namespace hk_b {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ let m_t: string;
8
+ let m_z: string;
9
+ let m_u: string;
10
+ }
@@ -0,0 +1,7 @@
1
+ export default hk_s;
2
+ declare namespace hk_s {
3
+ let ch: string;
4
+ let ch_u: string;
5
+ let ch_f: string;
6
+ let ch_d: string;
7
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 科学计数法转十进制
3
+ *
4
+ * @param {string} num 科学记数法字符串
5
+ * @returns string
6
+ */
7
+ export function e2ten(num: string): string;
8
+ /**
9
+ * 分析数字字符串
10
+ *
11
+ * @param {string} num NumberString
12
+ * @returns object
13
+ */
14
+ export function getNumbResult(num: string): {
15
+ int: string;
16
+ decimal: string;
17
+ minus: boolean;
18
+ num: string;
19
+ } | undefined;
20
+ /**
21
+ * 数组归一 (按索引覆盖合并数组,并清空被合并的数组)
22
+ *
23
+ * @param {array} baseArray 基础数组
24
+ * @param {...array} array1
25
+ * @returns array
26
+ */
27
+ export function centerArray(baseArray: array, ...args: array[]): array;
28
+ /**
29
+ * 检查对像属性 (非原型链)
30
+ *
31
+ * @param {object} obj
32
+ * @param {string} key
33
+ * @returns
34
+ */
35
+ export function hasAttr(obj: object, key: string): boolean;
36
+ /**
37
+ * 扩展对像(浅复制)
38
+ *
39
+ * @param {object} obj
40
+ * @param {object} obj1
41
+ * @returns
42
+ */
43
+ export function extend(obj: object, ...args: any[]): any;
44
+ /**
45
+ * 获取真实数位
46
+ *
47
+ * @param {number} index 中文单位的索引
48
+ */
49
+ export function getDigit(index: number): number;
50
+ /**
51
+ * 往数组头部插入0
52
+ *
53
+ * @param {array} arr
54
+ * @param {number} n
55
+ */
56
+ export function unshiftZero(arr: array, n: number): void;
57
+ /**
58
+ * 清理多余"零"
59
+ *
60
+ * @param {any} str
61
+ * @param {any} zero "零"字符
62
+ * @param {any} type 清理模式 ^ - 开头, $ - 结尾, nto1 - 多个连续变一个
63
+ * @returns
64
+ */
65
+ export function clearZero(str: any, zero: any, type: any): any;
@@ -0,0 +1,4 @@
1
+ export default objectKeysSort;
2
+ declare function objectKeysSort(params: any): {
3
+ [k: string]: any;
4
+ };
@@ -0,0 +1,8 @@
1
+ export default address;
2
+ declare namespace address {
3
+ function region(): string | undefined;
4
+ function province(): string;
5
+ function city(prefix: any): string;
6
+ function county(prefix: any): string;
7
+ function zip(len: any): string;
8
+ }
@@ -0,0 +1,2 @@
1
+ export default constellation;
2
+ declare function constellation(): string | undefined;
@@ -0,0 +1,5 @@
1
+ export function generateImageDataURL(params?: {}): string;
2
+ export default image;
3
+ declare namespace image {
4
+ export { generateImageDataURL };
5
+ }
@@ -0,0 +1,40 @@
1
+ declare namespace _default {
2
+ export { number };
3
+ export let natural: (min?: number, max?: number) => number;
4
+ export let integer: (min?: number, max?: number) => number;
5
+ export let float: (min: any, max: any) => number;
6
+ export function boolean(): boolean;
7
+ export function sex(): string;
8
+ export { sample as pick };
9
+ export { text };
10
+ export let ctitle: (min: any, max: any) => string;
11
+ export let cparagraph: (min: any, max: any) => string;
12
+ export let csentence: (min: any, max: any) => string;
13
+ export let cword: (pool: any, min: any, max: any, ...args: any[]) => string;
14
+ export { name };
15
+ export let cname: () => string;
16
+ export { web };
17
+ export let phone: () => string;
18
+ export { address };
19
+ export function county(p: any): string;
20
+ export function company(): string;
21
+ export function project(): string;
22
+ export { time };
23
+ export { constellation };
24
+ export { licensePlate };
25
+ export function uuid(): string;
26
+ export function id(): number;
27
+ export function increment(step: any): number;
28
+ export { image };
29
+ }
30
+ export default _default;
31
+ import number from './number';
32
+ import sample from 'lodash/sample';
33
+ import text from './text';
34
+ import name from './name';
35
+ import web from './web';
36
+ import address from './address';
37
+ import time from './time';
38
+ import constellation from './constellation';
39
+ import licensePlate from './licensePlate';
40
+ import image from './image';
@@ -0,0 +1,2 @@
1
+ export default licensePlate;
2
+ declare function licensePlate(): string;
@@ -0,0 +1,9 @@
1
+ export default name;
2
+ declare namespace name {
3
+ function first(): string | undefined;
4
+ function last(): string | undefined;
5
+ function name(middle: any): string;
6
+ function cfirst(): string | undefined;
7
+ function clast(): string | undefined;
8
+ function cname(): string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export default number;
2
+ declare namespace number {
3
+ function natural(min?: number, max?: number): number;
4
+ function integer(min?: number, max?: number): number;
5
+ function float(min: any, max: any): number;
6
+ }
@@ -0,0 +1,13 @@
1
+ export default text;
2
+ declare namespace text {
3
+ function paragraph(min: any, max: any): string;
4
+ function cparagraph(min: any, max: any): string;
5
+ function sentence(min: any, max: any): string;
6
+ function csentence(min: any, max: any): string;
7
+ function word(min: any, max: any): string;
8
+ function cword(pool: any, min: any, max: any, ...args: any[]): string;
9
+ function title(min: any, max: any): string;
10
+ function ctitle(min: any, max: any): string;
11
+ function character(pool: any): any;
12
+ function string(pool: any, min: any, max: any, ...args: any[]): string;
13
+ }
@@ -0,0 +1,2 @@
1
+ export default time;
2
+ declare function time(a: any, b: any): string;
@@ -0,0 +1,11 @@
1
+ export default web;
2
+ declare namespace web {
3
+ function url(v: any, host: any): string;
4
+ function protocol(): string | undefined;
5
+ function domain(v: any): string;
6
+ function tld(): string | undefined;
7
+ function email(domain: any): string;
8
+ function phone(): string;
9
+ function ip(): string;
10
+ function port(): number;
11
+ }
@@ -0,0 +1,10 @@
1
+ export default screenfull;
2
+ declare namespace screenfull {
3
+ export function request(element: HTMLElement | undefined, options: any): Promise<any>;
4
+ export function exit(): Promise<any>;
5
+ export function toggle(element: any, options: any): any;
6
+ export function on(event: any, callback: any): void;
7
+ export function off(event: any, callback: any): void;
8
+ export { nativeAPI as raw };
9
+ }
10
+ declare const nativeAPI: {};
@@ -0,0 +1,20 @@
1
+ type Primitive = string | number | boolean | symbol | null | undefined;
2
+ type ConditionValue<T = unknown> = Primitive | ((value: T) => boolean) | RegExp;
3
+ interface SearchOptions {
4
+ strategy?: 'BFS' | 'DFS';
5
+ childrenKey?: string;
6
+ strict?: boolean;
7
+ }
8
+ interface TreeNode {
9
+ [key: string]: unknown;
10
+ children?: TreeNode[];
11
+ }
12
+ /**
13
+ * 非递归树搜索算法
14
+ * @param {TreeNode[]} treeData - 树数据
15
+ * @param {Record<string, ConditionValue>} searchCondition - 搜索条件对象
16
+ * @param {SearchOptions} [options={}] - 配置选项
17
+ * @returns {TreeNode | null} 找到的节点或null
18
+ */
19
+ declare function searchTree(treeData: TreeNode[], searchCondition: Record<string, ConditionValue>, options?: SearchOptions): TreeNode | null;
20
+ export default searchTree;
@@ -0,0 +1 @@
1
+ export * from "./src";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Preloads images, background images, and optionally fonts into cache before DOM capture.
3
+ *
4
+ * @param {Document|Element} [root=document] - The root node to search for resources
5
+ * @param {Object} [options={}] - Pre-caching options
6
+ * @returns {Promise<void>} Resolves when all resources are pre-cached
7
+ */
8
+ export function preCache(root?: Document | Element, options?: Object): Promise<void>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Main entry point: captures a DOM element and returns an object with export methods.
3
+ *
4
+ * @param {Element} element - DOM element to capture
5
+ * @param {Object} [options={}] - Capture options
6
+ * @returns {Promise<Object>} Object with export methods (toRaw, toImg, toCanvas, etc.)
7
+ */
8
+ export function snapdom(element: Element, options?: Object): Promise<Object>;
9
+ export namespace snapdom {
10
+ /**
11
+ * Captures a DOM element and returns an object with export methods (internal use).
12
+ *
13
+ * @param {Element} el - DOM element to capture
14
+ * @param {Object} [options={}] - Capture options
15
+ * @returns {Promise<Object>} Object with export methods
16
+ */
17
+ function capture(el: Element, options?: Object): Promise<Object>;
18
+ function toRaw(el: any, options: any): Promise<any>;
19
+ function toImg(el: any, options: any): Promise<any>;
20
+ function toCanvas(el: any, options: any): Promise<any>;
21
+ function toBlob(el: any, options: any): Promise<any>;
22
+ function toPng(el: any, options: any): Promise<any>;
23
+ function toJpg(el: any, options: any): Promise<any>;
24
+ function toWebp(el: any, options: any): Promise<any>;
25
+ function download(el: any, options?: {}): Promise<any>;
26
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Caches for images, backgrounds, resources, and computed styles used during DOM capture.
3
+ * @module cache
4
+ */
5
+ export const imageCache: Map<any, any>;
6
+ export const bgCache: Map<any, any>;
7
+ export const resourceCache: Map<any, any>;
8
+ export const defaultStylesCache: Map<any, any>;
9
+ export const baseCSSCache: Map<any, any>;
10
+ export const computedStyleCache: WeakMap<WeakKey, any>;
11
+ export const processedFontURLs: Set<any>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Captures an HTML element as an SVG data URL, inlining styles, images, backgrounds, and optionally fonts.
3
+ *
4
+ * @param {Element} element - DOM element to capture
5
+ * @param {Object} [options={}] - Capture options
6
+ * @param {boolean} [options.compress=true] - Whether to compress style keys
7
+ * @param {boolean} [options.embedFonts=false] - Whether to embed custom fonts
8
+ * @param {boolean} [options.fast=true] - Whether to skip idle delay for faster results
9
+ * @param {number} [options.scale=1] - Output scale multiplier
10
+ * @returns {Promise<string>} Promise that resolves to an SVG data URL
11
+ */
12
+ export function captureDOM(element: Element, options?: {
13
+ compress?: boolean | undefined;
14
+ embedFonts?: boolean | undefined;
15
+ fast?: boolean | undefined;
16
+ scale?: number | undefined;
17
+ }): Promise<string>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a deep clone of a DOM node, including styles, shadow DOM, and special handling for excluded/placeholder/canvas nodes.
3
+ *
4
+ * @param {Node} node - Node to clone
5
+ * @param {Map} styleMap - Map to store element-to-style-key mappings
6
+ * @param {WeakMap} styleCache - Cache of computed styles
7
+ * @param {WeakMap} nodeMap - Map to track original-to-clone node relationships
8
+ * @param {boolean} compress - Whether to compress style keys
9
+ * @returns {Node|null} Cloned node with styles and shadow DOM content, or null for empty text nodes
10
+ */
11
+ export function deepClone(node: Node, styleMap: Map<any, any>, styleCache: WeakMap<any, any>, nodeMap: WeakMap<any, any>, compress: boolean): Node | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Prepares a clone of an element for capture, inlining pseudo-elements and generating CSS classes.
3
+ *
4
+ * @param {Element} element - Element to clone
5
+ * @param {boolean} [compress=false] - Whether to compress style keys
6
+ * @returns {Promise<Object>} Object containing the clone, generated CSS, and style cache
7
+ */
8
+ export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean): Promise<Object>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { preCache } from "./api/preCache.js";
2
+ export { snapdom } from "./api/snapdom.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Converts all background images in the cloned element tree to data URLs.
3
+ *
4
+ * @param {Element} source - Original element
5
+ * @param {Element} clone - Cloned element
6
+ * @param {WeakMap} styleCache - Cache of computed styles
7
+ * @param {Object} [options={}] - Options for image processing
8
+ * @returns {Promise<void>} Promise that resolves when all background images are processed
9
+ */
10
+ export function inlineBackgroundImages(source: Element, clone: Element, styleCache: WeakMap<any, any>, options?: Object): Promise<void>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Converts a unicode character from an icon font into a data URL image.
3
+ *
4
+ * @export
5
+ * @param {string} unicodeChar - The unicode character to render
6
+ * @param {string} fontFamily - The font family name
7
+ * @param {string|number} fontWeight - The font weight
8
+ * @param {number} [fontSize=32] - The font size in pixels
9
+ * @param {string} [color="#000"] - The color to use
10
+ * @returns {Promise<string>} Data URL of the rendered icon
11
+ */
12
+ export function iconToImage(unicodeChar: string, fontFamily: string, fontWeight: string | number, fontSize?: number, color?: string): Promise<string>;
13
+ /**
14
+ * Embeds custom fonts found in the document as data URLs in CSS.
15
+ *
16
+ * @export
17
+ * @param {Object} options
18
+ * @param {boolean} [options.ignoreIconFonts=true] - Whether to skip icon fonts
19
+ * @param {boolean} [options.preCached=false] - Whether to use pre-cached resources
20
+ * @returns {Promise<string>} The inlined CSS for custom fonts
21
+ */
22
+ export function embedCustomFonts({ ignoreIconFonts, preCached, }?: {
23
+ ignoreIconFonts?: boolean | undefined;
24
+ preCached?: boolean | undefined;
25
+ }): Promise<string>;