sculp-js 1.6.1 → 1.7.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 (60) hide show
  1. package/README.md +12 -2
  2. package/lib/cjs/array.js +2 -2
  3. package/lib/cjs/async.js +2 -2
  4. package/lib/cjs/base64.js +2 -2
  5. package/lib/cjs/clipboard.js +2 -2
  6. package/lib/cjs/cookie.js +2 -2
  7. package/lib/cjs/date.js +2 -2
  8. package/lib/cjs/dom.js +2 -2
  9. package/lib/cjs/download.js +2 -2
  10. package/lib/cjs/easing.js +2 -2
  11. package/lib/cjs/file.js +2 -2
  12. package/lib/cjs/func.js +2 -2
  13. package/lib/cjs/index.js +26 -3
  14. package/lib/cjs/math.js +2 -2
  15. package/lib/cjs/number.js +2 -2
  16. package/lib/cjs/object.js +67 -20
  17. package/lib/cjs/path.js +2 -2
  18. package/lib/cjs/qs.js +2 -2
  19. package/lib/cjs/random.js +2 -2
  20. package/lib/cjs/string.js +3 -3
  21. package/lib/cjs/tooltip.js +2 -2
  22. package/lib/cjs/tree.js +10 -8
  23. package/lib/cjs/type.js +8 -8
  24. package/lib/cjs/unique.js +2 -2
  25. package/lib/cjs/url.js +2 -2
  26. package/lib/cjs/validator.js +147 -0
  27. package/lib/cjs/variable.js +118 -0
  28. package/lib/cjs/watermark.js +2 -2
  29. package/lib/cjs/we-decode.js +4 -4
  30. package/lib/es/array.js +2 -2
  31. package/lib/es/async.js +2 -2
  32. package/lib/es/base64.js +2 -2
  33. package/lib/es/clipboard.js +2 -2
  34. package/lib/es/cookie.js +2 -2
  35. package/lib/es/date.js +2 -2
  36. package/lib/es/dom.js +2 -2
  37. package/lib/es/download.js +2 -2
  38. package/lib/es/easing.js +2 -2
  39. package/lib/es/file.js +2 -2
  40. package/lib/es/func.js +2 -2
  41. package/lib/es/index.js +5 -3
  42. package/lib/es/math.js +2 -2
  43. package/lib/es/number.js +2 -2
  44. package/lib/es/object.js +67 -20
  45. package/lib/es/path.js +2 -2
  46. package/lib/es/qs.js +2 -2
  47. package/lib/es/random.js +2 -2
  48. package/lib/es/string.js +3 -3
  49. package/lib/es/tooltip.js +2 -2
  50. package/lib/es/tree.js +10 -8
  51. package/lib/es/type.js +8 -8
  52. package/lib/es/unique.js +2 -2
  53. package/lib/es/url.js +2 -2
  54. package/lib/es/validator.js +130 -0
  55. package/lib/es/variable.js +112 -0
  56. package/lib/es/watermark.js +2 -2
  57. package/lib/es/we-decode.js +4 -4
  58. package/lib/index.d.ts +154 -16
  59. package/lib/umd/index.js +327 -33
  60. package/package.json +1 -1
@@ -0,0 +1,130 @@
1
+ /*!
2
+ * sculp-js v1.7.0
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ // 邮箱
8
+ const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
9
+ /**
10
+ * 判断字符串是否为邮箱格式,不对邮箱真实性做验证,如域名是否正确等
11
+ * @param {string} value
12
+ * @returns {boolean}
13
+ */
14
+ const isEmail = (value) => EMAIL_REGEX.test(value);
15
+ // 手机号码 (中国大陆)
16
+ // reference: https://www.runoob.com/regexp/regexp-syntax.html (?: 是非捕获元之一)
17
+ const PHONE_REGEX = /^(?:(?:\+|00)86)?1\d{10}$/;
18
+ /**
19
+ * 判断字符串是否为宽松手机格式,即首位为 1 的 11 位数字都属于手机号
20
+ * @param {string} value
21
+ * @returns {boolean}
22
+ */
23
+ const isPhone = (value) => PHONE_REGEX.test(value);
24
+ // 身份证号码
25
+ // http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/
26
+ // ["北京市", "天津市", "河北省", "山西省", "内蒙古自治区",
27
+ // "辽宁省", "吉林省", "黑龙江省",
28
+ // "上海市", "江苏省", "浙江省", "安徽省", "福建省", "江西省", "山东省",
29
+ // "河南省", "湖北省", "湖南省", "广东省", "广西壮族自治区", "海南省",
30
+ // "重庆市", "四川省", "贵州省", "云南省", "西藏自治区",
31
+ // "陕西省", "甘肃省", "青海省","宁夏回族自治区", "新疆维吾尔自治区",
32
+ // "台湾省",
33
+ // "香港特别行政区", "澳门特别行政区"]
34
+ // ["11", "12", "13", "14", "15",
35
+ // "21", "22", "23",
36
+ // "31", "32", "33", "34", "35", "36", "37",
37
+ // "41", "42", "43", "44", "45", "46",
38
+ // "50", "51", "52", "53", "54",
39
+ // "61", "62", "63", "64", "65",
40
+ // "71",
41
+ // "81", "82"]
42
+ // 91 国外
43
+ const IDNO_RE = /^(1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|7[1]|8[1-2]|9[1])\d{4}(18|19|20)\d{2}[01]\d[0123]\d{4}[\dxX]$/;
44
+ /**
45
+ * 判断字符串是否为身份证号码格式
46
+ * @param {string} value
47
+ * @returns {boolean}
48
+ */
49
+ const isIdNo = (value) => {
50
+ const isSameFormat = IDNO_RE.test(value);
51
+ if (!isSameFormat)
52
+ return false;
53
+ const year = Number(value.slice(6, 10));
54
+ const month = Number(value.slice(10, 12));
55
+ const date = Number(value.slice(12, 14));
56
+ const d = new Date(year, month - 1, date);
57
+ const isSameDate = d.getFullYear() === year && d.getMonth() + 1 === month && d.getDate() === date;
58
+ if (!isSameDate)
59
+ return false;
60
+ // 将身份证号码前面的17位数分别乘以不同的系数;
61
+ // 从第一位到第十七位的系数分别为:7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2
62
+ // 将这17位数字和系数相乘的结果相加;
63
+ // 用加出来和除以11,看余数是多少;
64
+ // 余数只可能有0-1-2-3-4-5-6-7-8-9-10这11个数字;
65
+ // 其分别对应的最后一位身份证的号码为1-0-X-9-8-7-6-5-4-3-2
66
+ // 通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2。
67
+ const coefficientList = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
68
+ const residueList = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
69
+ let sum = 0;
70
+ for (let start = 0; start < 17; start++) {
71
+ sum += Number(value.slice(start, start + 1)) * coefficientList[start];
72
+ }
73
+ return residueList[sum % 11] === value.slice(-1);
74
+ };
75
+ const URL_REGEX = /^(https?|ftp):\/\/([^\s/$.?#].[^\s]*)$/i;
76
+ const HTTP_URL_REGEX = /^https?:\/\/([^\s/$.?#].[^\s]*)$/i;
77
+ /**
78
+ * 判断字符串是否为 url 格式,支持 http、https、ftp 协议,支持域名或者 ipV4
79
+ * @param {string} value
80
+ * @returns {boolean}
81
+ */
82
+ const isUrl = (url, includeFtp = false) => {
83
+ const regex = includeFtp ? URL_REGEX : HTTP_URL_REGEX;
84
+ return regex.test(url);
85
+ };
86
+ // ipv4
87
+ const IPV4_REGEX = /^(?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/;
88
+ // ipv6
89
+ const IPV6_REGEX = /^(([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}|([\da-fA-F]{1,4}:){1,7}:|([\da-fA-F]{1,4}:){1,6}:[\da-fA-F]{1,4}|([\da-fA-F]{1,4}:){1,5}(:[\da-fA-F]{1,4}){1,2}|([\da-fA-F]{1,4}:){1,4}(:[\da-fA-F]{1,4}){1,3}|([\da-fA-F]{1,4}:){1,3}(:[\da-fA-F]{1,4}){1,4}|([\da-fA-F]{1,4}:){1,2}(:[\da-fA-F]{1,4}){1,5}|[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,6})|:((:[\da-fA-F]{1,4}){1,7}|:)|fe80:(:[\da-fA-F]{0,4}){0,4}%[\da-zA-Z]+|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|1?\d)?\d)\.){3}(25[0-5]|(2[0-4]|1?\d)?\d)|([\da-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1?\d)?\d)\.){3}(25[0-5]|(2[0-4]|1?\d)?\d))$/i;
90
+ /**
91
+ * 判断字符串是否为 IPV4 格式,不对 ip 真实性做验证
92
+ * @param {string} value
93
+ * @returns {boolean}
94
+ */
95
+ const isIpV4 = (value) => IPV4_REGEX.test(value);
96
+ /**
97
+ * 判断字符串是否为 IPV6 格式,不对 ip 真实性做验证
98
+ * @param {string} value
99
+ * @returns {boolean}
100
+ */
101
+ const isIpV6 = (value) => IPV6_REGEX.test(value);
102
+ const INTEGER_RE = /^(-?[1-9]\d*|0)$/;
103
+ /**
104
+ * 判断字符串是否为整数(自然数),即 ...,-3,-2,-1,0,1,2,3,...
105
+ * @param {string} value
106
+ * @returns {boolean}
107
+ */
108
+ const isInteger = (value) => INTEGER_RE.test(value);
109
+ const FLOAT_RE = /^-?([1-9]\d*|0)\.\d*[1-9]$/;
110
+ /**
111
+ * 判断字符串是否为浮点数,即必须有小数点的有理数
112
+ * @param {string} value
113
+ * @returns {boolean}
114
+ */
115
+ const isFloat = (value) => FLOAT_RE.test(value);
116
+ /**
117
+ * 判断字符串是否为正确数值,包括整数和浮点数
118
+ * @param {string} value
119
+ * @returns {boolean}
120
+ */
121
+ const isNumerical = (value) => isInteger(value) || isFloat(value);
122
+ const DIGIT_RE = /^\d+$/;
123
+ /**
124
+ * 判断字符串是否为数字,例如六位数字短信验证码(093031)
125
+ * @param {string} value
126
+ * @returns {boolean}
127
+ */
128
+ const isDigit = (value) => DIGIT_RE.test(value);
129
+
130
+ export { EMAIL_REGEX, HTTP_URL_REGEX, IPV4_REGEX, IPV6_REGEX, PHONE_REGEX, URL_REGEX, isDigit, isEmail, isFloat, isIdNo, isInteger, isIpV4, isIpV6, isNumerical, isPhone, isUrl };
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * sculp-js v1.7.0
3
+ * (c) 2023-present chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ import { objectHas } from './type.js';
8
+
9
+ /**
10
+ * 去除字符串中重复字符
11
+ * @param {string} str
12
+ * @returns string
13
+ * @example
14
+ *
15
+ * uniqueSymbol('1a1bac');
16
+ * // => '1abc'
17
+ */
18
+ function uniqueSymbol(str) {
19
+ return [...new Set(str.trim().split(''))].join('');
20
+ }
21
+ /**
22
+ * 转义所有特殊字符
23
+ * @param {string} str 原字符串
24
+ * reference: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_expressions
25
+ * @returns string
26
+ */
27
+ function escapeRegExp(str) {
28
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); //$&表示整个被匹配的字符串
29
+ }
30
+ /**
31
+ * 根据左右匹配符号生产解析变量(自动删除变量内的空白)
32
+ * @param {string} leftMatchSymbol
33
+ * @param {string} rightMatchSymbol
34
+ * @returns RegExp
35
+ */
36
+ function parseVariableRegExp(leftMatchSymbol, rightMatchSymbol) {
37
+ return new RegExp(`${escapeRegExp(leftMatchSymbol.trim())}\\s*([^${escapeRegExp(uniqueSymbol(leftMatchSymbol))}${escapeRegExp(uniqueSymbol(rightMatchSymbol))}\\s]*)\\s*${rightMatchSymbol.trim()}`, 'g');
38
+ }
39
+ /**
40
+ * 解析字符串的插值变量
41
+ * @param {string} str 字符串
42
+ * @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
43
+ * @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
44
+ * @returns string[]
45
+ * @example
46
+ *
47
+ * default match symbol {} same as /{\s*([^{}\s]*)\s*}/g
48
+ */
49
+ function parseVarFromString(str, leftMatchSymbol = '{', rightMatchSymbol = '}') {
50
+ return Array.from(str.matchAll(parseVariableRegExp(leftMatchSymbol, rightMatchSymbol))).map(el => el?.[1]);
51
+ }
52
+ /**
53
+ * 替换字符串中的插值变量
54
+ * @param {string} sourceStr
55
+ * @param {Record<string, any>} targetObj
56
+ * @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
57
+ * @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
58
+ * @returns string
59
+ */
60
+ function replaceVarFromString(sourceStr, targetObj, leftMatchSymbol = '{', rightMatchSymbol = '}') {
61
+ return sourceStr.replace(new RegExp(parseVariableRegExp(leftMatchSymbol, rightMatchSymbol)), function (m, p1) {
62
+ return objectHas(targetObj, p1) ? targetObj[p1] : m;
63
+ });
64
+ }
65
+ /**
66
+ * 在指定作用域中执行代码
67
+ * @param {string} code 要执行的代码(需包含 return 语句或表达式)
68
+ * @param {Object} scope 作用域对象(键值对形式的变量环境)
69
+ * @returns 代码执行结果
70
+ *
71
+ * @example
72
+ * // 测试用例 1: 基本变量访问
73
+ * executeInScope("return a + b;", { a: 1, b: 2 });
74
+ * // 3
75
+ *
76
+ * // 测试用例 2: 支持复杂表达式和运算
77
+ * executeInScope(
78
+ * "return Array.from({ length: 3 }, (_, i) => base + i);",
79
+ * { base: 100 }
80
+ * );
81
+ * // [100, 101, 102]
82
+ *
83
+ * // 支持外传函数作用域执行
84
+ * const scope = {
85
+ * $: {
86
+ * fun: {
87
+ * time: {
88
+ * now: function () {
89
+ * return new Date();
90
+ * },
91
+ * },
92
+ * },
93
+ * },
94
+ * };
95
+ * executeInScope("return $.fun.time.now()", scope)
96
+ */
97
+ function executeInScope(code, scope = {}) {
98
+ // 提取作用域对象的键和值
99
+ const keys = Object.keys(scope);
100
+ const values = keys.map(key => scope[key]);
101
+ try {
102
+ // 动态创建函数,将作用域的键作为参数,代码作为函数体
103
+ const func = new Function(...keys, `return (() => { ${code} })()`);
104
+ // 调用函数并传入作用域的值
105
+ return func(...values);
106
+ }
107
+ catch (error) {
108
+ throw new Error(`代码执行失败: ${error.message}`);
109
+ }
110
+ }
111
+
112
+ export { escapeRegExp, executeInScope, parseVarFromString, replaceVarFromString, uniqueSymbol };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.6.1
3
- * (c) 2023-2025 chandq
2
+ * sculp-js v1.7.0
3
+ * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.6.1
3
- * (c) 2023-2025 chandq
2
+ * sculp-js v1.7.0
3
+ * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -10,7 +10,7 @@ const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3
10
10
  /**
11
11
  * 字符串编码成Base64 (适用于任何环境,包括小程序)
12
12
  * @param {string} string
13
- * @return {string}
13
+ * @returns {string}
14
14
  */
15
15
  function weBtoa(string) {
16
16
  // 同window.btoa: 字符串编码成Base64
@@ -32,7 +32,7 @@ function weBtoa(string) {
32
32
  /**
33
33
  * Base64解码为原始字符串(适用于任何环境,包括小程序)
34
34
  * @param {string} string
35
- * @return {string}
35
+ * @returns {string}
36
36
  */
37
37
  function weAtob(string) {
38
38
  // 同window.atob: Base64解码为原始字符串
package/lib/index.d.ts CHANGED
@@ -53,7 +53,7 @@ declare const isRegExp: (any: unknown) => any is RegExp;
53
53
  /**
54
54
  * 判断一个字符串是否为有效的 JSON, 若有效则返回有效的JSON对象,否则false
55
55
  * @param {string} str
56
- * @return {Object | boolean}
56
+ * @returns {Object | boolean}
57
57
  */
58
58
  declare function isJsonString(str: string): Object | boolean;
59
59
  /**
@@ -70,19 +70,19 @@ declare function isJsonString(str: string): Object | boolean;
70
70
  * @returns {boolean} Returns `true` if `value` is empty, else `false`.
71
71
  * @example
72
72
  *
73
- * _.isEmpty(null);
73
+ * isEmpty(null);
74
74
  * // => true
75
75
  *
76
- * _.isEmpty(true);
76
+ * isEmpty(true);
77
77
  * // => true
78
78
  *
79
- * _.isEmpty(1);
79
+ * isEmpty(1);
80
80
  * // => true
81
81
  *
82
- * _.isEmpty([1, 2, 3]);
82
+ * isEmpty([1, 2, 3]);
83
83
  * // => false
84
84
  *
85
- * _.isEmpty({ 'a': 1 });
85
+ * isEmpty({ 'a': 1 });
86
86
  * // => false
87
87
  */
88
88
  declare function isEmpty(value: any): boolean;
@@ -410,11 +410,11 @@ declare function objectGet(obj: AnyObject, path: string, strict?: boolean): {
410
410
  };
411
411
  /**
412
412
  * 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
413
- * @param {AnyObject | AnyArray} obj
413
+ * @param {T} source
414
414
  * @param {WeakMap} map
415
- * @returns {AnyObject | AnyArray}
415
+ * @returns {T}
416
416
  */
417
- declare function cloneDeep(obj: Object, map?: WeakMap<object, any>): AnyObject | AnyArray;
417
+ declare function cloneDeep<T>(source: T, map?: WeakMap<any, any>): T;
418
418
 
419
419
  /**
420
420
  * 标准化路径
@@ -492,7 +492,7 @@ declare const stringFill: (length: number, value?: string) => string;
492
492
  /**
493
493
  * 解析URL查询参数
494
494
  * @param {string} searchStr
495
- * @return {Record<string, string | string[]>}
495
+ * @returns {Record<string, string | string[]>}
496
496
  */
497
497
  declare function parseQueryParams(searchStr?: string): Record<string, string | string[]>;
498
498
 
@@ -781,7 +781,7 @@ declare function forEachDeep<V>(tree: ArrayLike<V>, iterator: (val: V, i: number
781
781
  * @param {boolean} isReverse 是否反向遍历
782
782
  * @returns {any[]} 新的一棵树
783
783
  */
784
- declare function forEachMap<V>(tree: ArrayLike<V>, iterator: (val: V, i: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => boolean | any, children?: string, isReverse?: boolean): any[];
784
+ declare function mapDeep<V>(tree: ArrayLike<V>, iterator: (val: V, i: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => boolean | any, children?: string, isReverse?: boolean): any[];
785
785
  type IdLike = number | string;
786
786
  interface ITreeConf {
787
787
  id: string | number;
@@ -846,7 +846,7 @@ declare function formatTree(list: any[], options?: IFieldOptions): any[];
846
846
  * 树形结构转扁平化
847
847
  * @param {any} treeList
848
848
  * @param {IFieldOptions} options
849
- * @return {*}
849
+ * @returns {*}
850
850
  */
851
851
  declare function flatTree(treeList: any[], options?: IFieldOptions): any[];
852
852
  /**
@@ -854,7 +854,7 @@ declare function flatTree(treeList: any[], options?: IFieldOptions): any[];
854
854
  * @param {any[]} nodes
855
855
  * @param {string} query
856
856
  * @param {ISearchTreeOpts} options
857
- * @return {any[]}
857
+ * @returns {any[]}
858
858
  */
859
859
  declare function fuzzySearchTree(nodes: any[], query: string, options?: ISearchTreeOpts): any[];
860
860
 
@@ -896,13 +896,13 @@ declare function strip(num: NumberType, precision?: number): number;
896
896
  /**
897
897
  * 字符串编码成Base64 (适用于任何环境,包括小程序)
898
898
  * @param {string} string
899
- * @return {string}
899
+ * @returns {string}
900
900
  */
901
901
  declare function weBtoa(string: string): string;
902
902
  /**
903
903
  * Base64解码为原始字符串(适用于任何环境,包括小程序)
904
904
  * @param {string} string
905
- * @return {string}
905
+ * @returns {string}
906
906
  */
907
907
  declare function weAtob(string: string): string;
908
908
 
@@ -919,4 +919,142 @@ declare function decodeFromBase64(base64: string): string;
919
919
  */
920
920
  declare function encodeToBase64(rawStr: string): string;
921
921
 
922
- export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ICompressOptions, type IFieldOptions, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, type WithChildren, add, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, crossOriginDownload, dateParse, dateToEnd, dateToStart, debounce, decodeFromBase64, divide, downloadBlob, downloadData, downloadHref, downloadURL, encodeToBase64, flatTree, forEachDeep, forEachMap, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isEmpty, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, multiply, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, parseQueryParams, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, strip, subtract, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAtob, weBtoa };
922
+ declare const EMAIL_REGEX: RegExp;
923
+ /**
924
+ * 判断字符串是否为邮箱格式,不对邮箱真实性做验证,如域名是否正确等
925
+ * @param {string} value
926
+ * @returns {boolean}
927
+ */
928
+ declare const isEmail: (value: string) => boolean;
929
+ declare const PHONE_REGEX: RegExp;
930
+ /**
931
+ * 判断字符串是否为宽松手机格式,即首位为 1 的 11 位数字都属于手机号
932
+ * @param {string} value
933
+ * @returns {boolean}
934
+ */
935
+ declare const isPhone: (value: string) => boolean;
936
+ /**
937
+ * 判断字符串是否为身份证号码格式
938
+ * @param {string} value
939
+ * @returns {boolean}
940
+ */
941
+ declare const isIdNo: (value: string) => boolean;
942
+ declare const URL_REGEX: RegExp;
943
+ declare const HTTP_URL_REGEX: RegExp;
944
+ /**
945
+ * 判断字符串是否为 url 格式,支持 http、https、ftp 协议,支持域名或者 ipV4
946
+ * @param {string} value
947
+ * @returns {boolean}
948
+ */
949
+ declare const isUrl: (url: string, includeFtp?: boolean) => boolean;
950
+ declare const IPV4_REGEX: RegExp;
951
+ declare const IPV6_REGEX: RegExp;
952
+ /**
953
+ * 判断字符串是否为 IPV4 格式,不对 ip 真实性做验证
954
+ * @param {string} value
955
+ * @returns {boolean}
956
+ */
957
+ declare const isIpV4: (value: string) => boolean;
958
+ /**
959
+ * 判断字符串是否为 IPV6 格式,不对 ip 真实性做验证
960
+ * @param {string} value
961
+ * @returns {boolean}
962
+ */
963
+ declare const isIpV6: (value: string) => boolean;
964
+ /**
965
+ * 判断字符串是否为整数(自然数),即 ...,-3,-2,-1,0,1,2,3,...
966
+ * @param {string} value
967
+ * @returns {boolean}
968
+ */
969
+ declare const isInteger: (value: string) => boolean;
970
+ /**
971
+ * 判断字符串是否为浮点数,即必须有小数点的有理数
972
+ * @param {string} value
973
+ * @returns {boolean}
974
+ */
975
+ declare const isFloat: (value: string) => boolean;
976
+ /**
977
+ * 判断字符串是否为正确数值,包括整数和浮点数
978
+ * @param {string} value
979
+ * @returns {boolean}
980
+ */
981
+ declare const isNumerical: (value: string) => boolean;
982
+ /**
983
+ * 判断字符串是否为数字,例如六位数字短信验证码(093031)
984
+ * @param {string} value
985
+ * @returns {boolean}
986
+ */
987
+ declare const isDigit: (value: string) => boolean;
988
+
989
+ /**
990
+ * 去除字符串中重复字符
991
+ * @param {string} str
992
+ * @returns string
993
+ * @example
994
+ *
995
+ * uniqueSymbol('1a1bac');
996
+ * // => '1abc'
997
+ */
998
+ declare function uniqueSymbol(str: string): string;
999
+ /**
1000
+ * 转义所有特殊字符
1001
+ * @param {string} str 原字符串
1002
+ * reference: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_expressions
1003
+ * @returns string
1004
+ */
1005
+ declare function escapeRegExp(str: string): string;
1006
+ /**
1007
+ * 解析字符串的插值变量
1008
+ * @param {string} str 字符串
1009
+ * @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
1010
+ * @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
1011
+ * @returns string[]
1012
+ * @example
1013
+ *
1014
+ * default match symbol {} same as /{\s*([^{}\s]*)\s*}/g
1015
+ */
1016
+ declare function parseVarFromString(str: string, leftMatchSymbol?: string, rightMatchSymbol?: string): string[];
1017
+ /**
1018
+ * 替换字符串中的插值变量
1019
+ * @param {string} sourceStr
1020
+ * @param {Record<string, any>} targetObj
1021
+ * @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
1022
+ * @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
1023
+ * @returns string
1024
+ */
1025
+ declare function replaceVarFromString(sourceStr: string, targetObj: Record<string, any>, leftMatchSymbol?: string, rightMatchSymbol?: string): string;
1026
+ /**
1027
+ * 在指定作用域中执行代码
1028
+ * @param {string} code 要执行的代码(需包含 return 语句或表达式)
1029
+ * @param {Object} scope 作用域对象(键值对形式的变量环境)
1030
+ * @returns 代码执行结果
1031
+ *
1032
+ * @example
1033
+ * // 测试用例 1: 基本变量访问
1034
+ * executeInScope("return a + b;", { a: 1, b: 2 });
1035
+ * // 3
1036
+ *
1037
+ * // 测试用例 2: 支持复杂表达式和运算
1038
+ * executeInScope(
1039
+ * "return Array.from({ length: 3 }, (_, i) => base + i);",
1040
+ * { base: 100 }
1041
+ * );
1042
+ * // [100, 101, 102]
1043
+ *
1044
+ * // 支持外传函数作用域执行
1045
+ * const scope = {
1046
+ * $: {
1047
+ * fun: {
1048
+ * time: {
1049
+ * now: function () {
1050
+ * return new Date();
1051
+ * },
1052
+ * },
1053
+ * },
1054
+ * },
1055
+ * };
1056
+ * executeInScope("return $.fun.time.now()", scope)
1057
+ */
1058
+ declare function executeInScope(code: string, scope?: Record<string, any>): any;
1059
+
1060
+ export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, EMAIL_REGEX, type FileType, HEX_POOL, HTTP_URL_REGEX, type ICanvasWM, type ICompressOptions, type IFieldOptions, IPV4_REGEX, IPV6_REGEX, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, PHONE_REGEX, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, URL_REGEX, type UniqueString, type Url, type WithChildren, add, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, crossOriginDownload, dateParse, dateToEnd, dateToStart, debounce, decodeFromBase64, divide, downloadBlob, downloadData, downloadHref, downloadURL, encodeToBase64, escapeRegExp, executeInScope, flatTree, forEachDeep, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDigit, isDomReady, isEmail, isEmpty, isError, isFloat, isFunction, isIdNo, isInteger, isIpV4, isIpV6, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isNumerical, isObject, isPhone, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isUrl, isValidDate, mapDeep, multiply, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, parseQueryParams, parseVarFromString, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, replaceVarFromString, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, strip, subtract, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, uniqueSymbol, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAtob, weBtoa };