sculp-js 1.10.3 → 1.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/array.js +7 -9
- package/lib/cjs/async.js +1 -1
- package/lib/cjs/base64.js +1 -1
- package/lib/cjs/clipboard.js +1 -1
- package/lib/cjs/cloneDeep.js +1 -1
- package/lib/cjs/cookie.js +1 -1
- package/lib/cjs/date.js +1 -1
- package/lib/cjs/dom.js +1 -1
- package/lib/cjs/download.js +1 -1
- package/lib/cjs/easing.js +1 -1
- package/lib/cjs/file.js +10 -9
- package/lib/cjs/func.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/isEqual.js +1 -1
- package/lib/cjs/math.js +1 -1
- package/lib/cjs/number.js +1 -1
- package/lib/cjs/object.js +10 -2
- package/lib/cjs/path.js +1 -1
- package/lib/cjs/qs.js +1 -1
- package/lib/cjs/random.js +1 -1
- package/lib/cjs/string.js +1 -1
- package/lib/cjs/tooltip.js +1 -1
- package/lib/cjs/tree.js +7 -1
- package/lib/cjs/type.js +4 -3
- package/lib/cjs/unique.js +1 -1
- package/lib/cjs/url.js +1 -1
- package/lib/cjs/validator.js +1 -1
- package/lib/cjs/variable.js +1 -1
- package/lib/cjs/watermark.js +1 -1
- package/lib/cjs/we-decode.js +1 -1
- package/lib/es/array.js +7 -9
- package/lib/es/async.js +1 -1
- package/lib/es/base64.js +1 -1
- package/lib/es/clipboard.js +1 -1
- package/lib/es/cloneDeep.js +1 -1
- package/lib/es/cookie.js +1 -1
- package/lib/es/date.js +1 -1
- package/lib/es/dom.js +1 -1
- package/lib/es/download.js +1 -1
- package/lib/es/easing.js +1 -1
- package/lib/es/file.js +10 -9
- package/lib/es/func.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/isEqual.js +1 -1
- package/lib/es/math.js +1 -1
- package/lib/es/number.js +1 -1
- package/lib/es/object.js +10 -2
- package/lib/es/path.js +1 -1
- package/lib/es/qs.js +1 -1
- package/lib/es/random.js +1 -1
- package/lib/es/string.js +1 -1
- package/lib/es/tooltip.js +1 -1
- package/lib/es/tree.js +7 -1
- package/lib/es/type.js +4 -3
- package/lib/es/unique.js +1 -1
- package/lib/es/url.js +1 -1
- package/lib/es/validator.js +1 -1
- package/lib/es/variable.js +1 -1
- package/lib/es/watermark.js +1 -1
- package/lib/es/we-decode.js +1 -1
- package/lib/index.d.ts +17 -7
- package/lib/umd/index.js +2 -3218
- package/package.json +2 -1
package/lib/es/math.js
CHANGED
package/lib/es/number.js
CHANGED
package/lib/es/object.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.10.
|
|
2
|
+
* sculp-js v1.10.5
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -33,6 +33,8 @@ function objectEach(obj, iterator) {
|
|
|
33
33
|
if (iterator(obj[key], key) === false)
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
obj = null;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* 异步遍历对象,返回 false 中断遍历
|
|
@@ -60,6 +62,8 @@ function objectMap(obj, iterator) {
|
|
|
60
62
|
continue;
|
|
61
63
|
obj2[key] = iterator(obj[key], key);
|
|
62
64
|
}
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
obj = null;
|
|
63
67
|
return obj2;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -76,6 +80,8 @@ function objectPick(obj, keys) {
|
|
|
76
80
|
obj2[k] = v;
|
|
77
81
|
}
|
|
78
82
|
});
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
obj = null;
|
|
79
85
|
return obj2;
|
|
80
86
|
}
|
|
81
87
|
/**
|
|
@@ -92,6 +98,8 @@ function objectOmit(obj, keys) {
|
|
|
92
98
|
obj2[k] = v;
|
|
93
99
|
}
|
|
94
100
|
});
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
obj = null;
|
|
95
103
|
return obj2;
|
|
96
104
|
}
|
|
97
105
|
const merge = (map, source, target) => {
|
|
@@ -163,7 +171,7 @@ function objectFill(source, target, fillable) {
|
|
|
163
171
|
return source;
|
|
164
172
|
}
|
|
165
173
|
/**
|
|
166
|
-
*
|
|
174
|
+
* 获取对象/数组指定层级下的属性值(现在可用ES6+的可选链?.来替代)
|
|
167
175
|
* @param {AnyObject} obj
|
|
168
176
|
* @param {string} path
|
|
169
177
|
* @param {boolean} strict
|
package/lib/es/path.js
CHANGED
package/lib/es/qs.js
CHANGED
package/lib/es/random.js
CHANGED
package/lib/es/string.js
CHANGED
package/lib/es/tooltip.js
CHANGED
package/lib/es/tree.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.10.
|
|
2
|
+
* sculp-js v1.10.5
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -68,6 +68,8 @@ function forEachDeep(tree, iterator, children = 'children', isReverse = false) {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
walk(tree, null);
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
tree = null;
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* 创建一个新数组, 深度优先遍历的Map函数(支持continue和break操作), 可用于insert tree item 和 remove tree item
|
|
@@ -137,6 +139,8 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
|
|
|
137
139
|
}
|
|
138
140
|
};
|
|
139
141
|
walk(tree, null, newTree);
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
tree = null;
|
|
140
144
|
return newTree;
|
|
141
145
|
}
|
|
142
146
|
/**
|
|
@@ -194,6 +198,8 @@ function formatTree(list, options = defaultFieldOptions) {
|
|
|
194
198
|
treeArr.push(item);
|
|
195
199
|
}
|
|
196
200
|
});
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
list = null;
|
|
197
203
|
return treeArr;
|
|
198
204
|
}
|
|
199
205
|
/**
|
package/lib/es/type.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.10.
|
|
2
|
+
* sculp-js v1.10.5
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
// 常用类型定义
|
|
8
|
+
const { toString, hasOwnProperty } = Object.prototype;
|
|
8
9
|
/**
|
|
9
10
|
* 判断对象内是否有该静态属性
|
|
10
11
|
* @param {object} obj
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
* @returns {boolean}
|
|
13
14
|
*/
|
|
14
15
|
function objectHas(obj, key) {
|
|
15
|
-
return
|
|
16
|
+
return hasOwnProperty.call(obj, key);
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* 判断一个对象是否为类数组
|
|
@@ -39,7 +40,7 @@ function arrayLike(any) {
|
|
|
39
40
|
* @returns
|
|
40
41
|
*/
|
|
41
42
|
function typeIs(any) {
|
|
42
|
-
return
|
|
43
|
+
return toString.call(any).slice(8, -1);
|
|
43
44
|
}
|
|
44
45
|
// 基本数据类型判断
|
|
45
46
|
const isString = (any) => typeof any === 'string';
|
package/lib/es/unique.js
CHANGED
package/lib/es/url.js
CHANGED
package/lib/es/validator.js
CHANGED
package/lib/es/variable.js
CHANGED
package/lib/es/watermark.js
CHANGED
package/lib/es/we-decode.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -432,13 +432,13 @@ declare function objectAssign<R = AnyObject | AnyArray>(source: ObjectAssignItem
|
|
|
432
432
|
*/
|
|
433
433
|
declare function objectFill<R extends AnyObject = AnyObject>(source: Partial<R>, target: Partial<R>, fillable?: (s: typeof source, t: typeof target, key: keyof R) => boolean): R;
|
|
434
434
|
/**
|
|
435
|
-
*
|
|
435
|
+
* 获取对象/数组指定层级下的属性值(现在可用ES6+的可选链?.来替代)
|
|
436
436
|
* @param {AnyObject} obj
|
|
437
437
|
* @param {string} path
|
|
438
438
|
* @param {boolean} strict
|
|
439
439
|
* @returns
|
|
440
440
|
*/
|
|
441
|
-
declare function objectGet(obj: AnyObject, path: string, strict?: boolean): {
|
|
441
|
+
declare function objectGet(obj: AnyObject | AnyArray | undefined, path: string, strict?: boolean): {
|
|
442
442
|
p: any | undefined;
|
|
443
443
|
k: string | undefined;
|
|
444
444
|
v: any | undefined;
|
|
@@ -604,19 +604,29 @@ interface ICompressOptions {
|
|
|
604
604
|
/** 图片类型 */
|
|
605
605
|
mime?: ImageType;
|
|
606
606
|
maxSize?: number;
|
|
607
|
+
minFileSizeKB?: number;
|
|
608
|
+
}
|
|
609
|
+
interface ICompressImgResult {
|
|
610
|
+
file: File;
|
|
611
|
+
bufferArray?: Uint8Array;
|
|
612
|
+
origin?: File;
|
|
613
|
+
beforeSrc?: string;
|
|
614
|
+
afterSrc?: string;
|
|
615
|
+
beforeKB?: number;
|
|
616
|
+
afterKB?: number;
|
|
607
617
|
}
|
|
608
618
|
/**
|
|
609
|
-
* Web端:等比例压缩图片批量处理 (
|
|
619
|
+
* Web端:等比例压缩图片批量处理 (小于minFileSizeKB:50,不压缩), 支持压缩全景图或长截图
|
|
610
620
|
*
|
|
611
621
|
* 1. 默认根据图片原始size及宽高适当地调整quality、width、height
|
|
612
622
|
* 2. 可指定压缩的图片质量 quality(若不指定则根据原始图片大小来计算), 来适当调整width、height
|
|
613
623
|
* 3. 可指定压缩的图片最大宽高 maxSize(若不指定则根据原始图片宽高来计算), 满足大屏幕图片展示的场景
|
|
614
624
|
*
|
|
615
625
|
* @param {File | FileList} file 图片或图片数组
|
|
616
|
-
* @param {ICompressOptions} options 压缩图片配置项,default: {mime:'image/jpeg'}
|
|
617
|
-
* @returns {Promise<
|
|
626
|
+
* @param {ICompressOptions} options 压缩图片配置项,default: {mime:'image/jpeg', minFileSizeKB: 50}
|
|
627
|
+
* @returns {Promise<ICompressImgResult | ICompressImgResult[] | null>}
|
|
618
628
|
*/
|
|
619
|
-
declare function compressImg(file: File | FileList, options?: ICompressOptions): Promise<
|
|
629
|
+
declare function compressImg(file: File | FileList, options?: ICompressOptions): Promise<ICompressImgResult | ICompressImgResult[] | null>;
|
|
620
630
|
|
|
621
631
|
interface ICanvasWM {
|
|
622
632
|
rootContainer?: HTMLElement | string;
|
|
@@ -1118,4 +1128,4 @@ type Comparable = null | undefined | boolean | number | string | Date | RegExp |
|
|
|
1118
1128
|
*/
|
|
1119
1129
|
declare function isEqual(a: Comparable, b: Comparable): boolean;
|
|
1120
1130
|
|
|
1121
|
-
export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type Comparable, type DateObj, type DateValue, type DebounceFunc, EMAIL_REGEX, type FileType, HEX_POOL, HTTP_URL_REGEX, type ICanvasWM, type ICompressOptions, type IFieldOptions, type IFilterCondition, 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 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, add, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, 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 as formatMoney, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, humanFileSize, isArray, isBigInt, isBoolean, isDate, isDigit, isEmail, isEmpty, isEqual, isError, isFloat, isFunction, isIdNo, isInteger, isIpV4, isIpV6, isJsonString, isNaN, isNull, isNullOrUnDef, isNullOrUnDef as isNullish, 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, 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 };
|
|
1131
|
+
export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type Comparable, type DateObj, type DateValue, type DebounceFunc, EMAIL_REGEX, type FileType, HEX_POOL, HTTP_URL_REGEX, type ICanvasWM, type ICompressImgResult, type ICompressOptions, type IFieldOptions, type IFilterCondition, 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 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, add, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, 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 as formatMoney, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, humanFileSize, isArray, isBigInt, isBoolean, isDate, isDigit, isEmail, isEmpty, isEqual, isError, isFloat, isFunction, isIdNo, isInteger, isIpV4, isIpV6, isJsonString, isNaN, isNull, isNullOrUnDef, isNullOrUnDef as isNullish, 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, 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 };
|