sculp-js 1.8.4 → 1.10.0
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 +1 -1
- package/lib/cjs/async.js +1 -1
- package/lib/cjs/base64.js +1 -1
- package/lib/cjs/clipboard.js +7 -11
- 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 +11 -7
- package/lib/cjs/download.js +1 -1
- package/lib/cjs/easing.js +1 -1
- package/lib/cjs/file.js +1 -1
- package/lib/cjs/func.js +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/isEqual.js +1 -1
- package/lib/cjs/math.js +1 -1
- package/lib/cjs/number.js +55 -12
- package/lib/cjs/object.js +1 -1
- 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 +20 -16
- package/lib/cjs/tree.js +2 -2
- package/lib/cjs/type.js +1 -1
- package/lib/cjs/unique.js +1 -1
- package/lib/cjs/url.js +15 -5
- package/lib/cjs/validator.js +1 -1
- package/lib/cjs/variable.js +1 -1
- package/lib/cjs/watermark.js +20 -19
- package/lib/cjs/we-decode.js +1 -1
- package/lib/es/array.js +1 -1
- package/lib/es/async.js +1 -1
- package/lib/es/base64.js +1 -1
- package/lib/es/clipboard.js +7 -11
- 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 +11 -7
- package/lib/es/download.js +1 -1
- package/lib/es/easing.js +1 -1
- package/lib/es/file.js +1 -1
- package/lib/es/func.js +1 -1
- package/lib/es/index.js +2 -2
- package/lib/es/isEqual.js +1 -1
- package/lib/es/math.js +1 -1
- package/lib/es/number.js +54 -13
- package/lib/es/object.js +1 -1
- 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 +20 -16
- package/lib/es/tree.js +2 -2
- package/lib/es/type.js +1 -1
- package/lib/es/unique.js +1 -1
- package/lib/es/url.js +15 -5
- package/lib/es/validator.js +1 -1
- package/lib/es/variable.js +1 -1
- package/lib/es/watermark.js +20 -19
- package/lib/es/we-decode.js +1 -1
- package/lib/index.d.ts +55 -29
- package/lib/umd/index.js +607 -552
- package/package.json +2 -1
package/lib/index.d.ts
CHANGED
|
@@ -285,10 +285,10 @@ declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?:
|
|
|
285
285
|
* 字符串的像素宽度
|
|
286
286
|
* @param {string} str 目标字符串
|
|
287
287
|
* @param {number} fontSize 字符串字体大小
|
|
288
|
-
* @param {boolean}
|
|
288
|
+
* @param {boolean} isRemove 计算后是否移除创建的dom元素
|
|
289
289
|
* @returns {*}
|
|
290
290
|
*/
|
|
291
|
-
declare function getStrWidthPx(str: string, fontSize?: number,
|
|
291
|
+
declare function getStrWidthPx(str: string, fontSize?: number, isRemove?: boolean): number;
|
|
292
292
|
|
|
293
293
|
interface Params<T = string | number> {
|
|
294
294
|
[key: string]: T | Array<T>;
|
|
@@ -526,9 +526,10 @@ interface Url {
|
|
|
526
526
|
/**
|
|
527
527
|
* url 解析
|
|
528
528
|
* @param {string} url
|
|
529
|
+
* @param {boolean} isModernApi 使用现代API:URL, 默认true (对无效url解析会抛错), 否则使用a标签来解析(兼容性更强)
|
|
529
530
|
* @returns {Url}
|
|
530
531
|
*/
|
|
531
|
-
declare const urlParse: (url: string) => Url;
|
|
532
|
+
declare const urlParse: (url: string, isModernApi?: boolean) => Url;
|
|
532
533
|
/**
|
|
533
534
|
* url 字符化,url 对象里的 searchParams 会覆盖 url 原有的查询参数
|
|
534
535
|
* @param {Url} url
|
|
@@ -595,23 +596,23 @@ interface ICompressOptions {
|
|
|
595
596
|
declare function compressImg(file: File | FileList, options: ICompressOptions): Promise<object> | undefined;
|
|
596
597
|
|
|
597
598
|
interface ICanvasWM {
|
|
598
|
-
|
|
599
|
-
width
|
|
600
|
-
height
|
|
601
|
-
textAlign
|
|
602
|
-
textBaseline
|
|
603
|
-
font
|
|
604
|
-
fillStyle
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
599
|
+
rootContainer?: HTMLElement | string;
|
|
600
|
+
width?: string;
|
|
601
|
+
height?: string;
|
|
602
|
+
textAlign?: CanvasTextAlign;
|
|
603
|
+
textBaseline?: CanvasTextBaseline;
|
|
604
|
+
font?: string;
|
|
605
|
+
fillStyle?: string;
|
|
606
|
+
rotate?: number;
|
|
607
|
+
zIndex?: number;
|
|
608
|
+
watermarkId?: string;
|
|
608
609
|
}
|
|
609
610
|
/**
|
|
610
611
|
* canvas 实现 水印, 具备防删除功能
|
|
611
612
|
* @param {ICanvasWM} canvasWM
|
|
612
613
|
* @example genCanvasWM({ content: 'QQMusicFE' })
|
|
613
614
|
*/
|
|
614
|
-
declare function genCanvasWM(canvasWM
|
|
615
|
+
declare function genCanvasWM(content?: string, canvasWM?: ICanvasWM): void;
|
|
615
616
|
|
|
616
617
|
interface DebounceFunc<F extends AnyFunc> {
|
|
617
618
|
(...args: Parameters<F>): void;
|
|
@@ -697,22 +698,45 @@ declare const HEX_POOL: string;
|
|
|
697
698
|
* @returns {string}
|
|
698
699
|
*/
|
|
699
700
|
declare function numberToHex(decimal: number | string, hexPool?: string): string;
|
|
701
|
+
interface INumberAbbr {
|
|
702
|
+
ratio?: number;
|
|
703
|
+
decimals?: number;
|
|
704
|
+
separator?: string;
|
|
705
|
+
}
|
|
700
706
|
/**
|
|
701
|
-
*
|
|
707
|
+
* 将数字转换为携带单位的字符串
|
|
702
708
|
* @param {number | string} num
|
|
703
709
|
* @param {Array<string>} units
|
|
704
|
-
* @param {
|
|
705
|
-
* @param {number} exponent
|
|
710
|
+
* @param {INumberAbbr} options default: { ratio: 1000, decimals: 0, separator: ' ' }
|
|
706
711
|
* @returns {string}
|
|
707
712
|
*/
|
|
708
|
-
declare const numberAbbr: (num: number | string, units: Array<string>,
|
|
713
|
+
declare const numberAbbr: (num: number | string, units: Array<string>, options?: INumberAbbr) => string;
|
|
714
|
+
interface IHumanFileSizeOptions {
|
|
715
|
+
decimals?: number;
|
|
716
|
+
si?: boolean;
|
|
717
|
+
separator?: string;
|
|
718
|
+
baseUnit?: string;
|
|
719
|
+
maxUnit?: string;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Converting file size in bytes to human-readable string
|
|
723
|
+
* reference: https://zh.wikipedia.org/wiki/%E5%8D%83%E5%AD%97%E8%8A%82
|
|
724
|
+
* @param {number | string} num bytes Number in Bytes
|
|
725
|
+
* @param {IHumanFileSizeOptions} options default: { decimals = 0, si = false, separator = ' ' }
|
|
726
|
+
* si: True to use metric (SI) units, aka powers of 1000, the units is
|
|
727
|
+
* ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'].
|
|
728
|
+
* False to use binary (IEC), aka powers of 1024, the units is
|
|
729
|
+
* ['Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
|
730
|
+
* @returns
|
|
731
|
+
*/
|
|
732
|
+
declare function humanFileSize(num: number | string, options?: IHumanFileSizeOptions): string;
|
|
709
733
|
/**
|
|
710
734
|
* 将数字格式化成千位分隔符显示的字符串
|
|
711
|
-
* @param {number}
|
|
712
|
-
* @param {
|
|
735
|
+
* @param {number|string} num 数字
|
|
736
|
+
* @param {number} decimals 格式化成指定小数位精度的参数
|
|
713
737
|
* @returns {string}
|
|
714
738
|
*/
|
|
715
|
-
declare function formatNumber(
|
|
739
|
+
declare function formatNumber(num: number | string, decimals?: number): string;
|
|
716
740
|
|
|
717
741
|
declare const UNIQUE_NUMBER_SAFE_LENGTH = 18;
|
|
718
742
|
/**
|
|
@@ -740,26 +764,28 @@ declare const uniqueString: UniqueString;
|
|
|
740
764
|
* @Desc 自定义的tooltip方法, 支持拖动悬浮提示
|
|
741
765
|
* Created by chendeqiao on 2017/5/8.
|
|
742
766
|
* @example
|
|
743
|
-
* <span onmouseleave="handleMouseLeave('#root')" onmousemove="handleMouseEnter({
|
|
744
|
-
* onmouseenter="handleMouseEnter({'#root', title: 'title content', event: event})">title content </span>
|
|
767
|
+
* <span onmouseleave="handleMouseLeave('#root')" onmousemove="handleMouseEnter({rootContainer: '#root', title: 'title content', event: event})"
|
|
768
|
+
* onmouseenter="handleMouseEnter({rootContainer:'#root', title: 'title content', event: event})">title content </span>
|
|
745
769
|
*/
|
|
746
770
|
interface ITooltipParams {
|
|
747
|
-
|
|
771
|
+
rootContainer: HTMLElement | string;
|
|
748
772
|
title: string;
|
|
749
|
-
event: PointerEvent;
|
|
773
|
+
event: PointerEvent | MouseEvent;
|
|
774
|
+
bgColor?: string;
|
|
775
|
+
color?: string;
|
|
750
776
|
}
|
|
751
777
|
/**
|
|
752
778
|
* 自定义title提示功能的mouseenter事件句柄
|
|
753
779
|
* @param {ITooltipParams} param1
|
|
754
780
|
* @returns {*}
|
|
755
781
|
*/
|
|
756
|
-
declare function handleMouseEnter({
|
|
782
|
+
declare function handleMouseEnter({ rootContainer, title, event, bgColor, color }: ITooltipParams): void;
|
|
757
783
|
/**
|
|
758
784
|
* 移除提示文案dom的事件句柄
|
|
759
|
-
* @param {string}
|
|
785
|
+
* @param {string} rootContainer
|
|
760
786
|
* @returns {*}
|
|
761
787
|
*/
|
|
762
|
-
declare function handleMouseLeave(
|
|
788
|
+
declare function handleMouseLeave(rootContainer?: HTMLElement | string): void;
|
|
763
789
|
declare const tooltipEvent: {
|
|
764
790
|
handleMouseEnter: typeof handleMouseEnter;
|
|
765
791
|
handleMouseLeave: typeof handleMouseLeave;
|
|
@@ -1066,4 +1092,4 @@ type Comparable = null | undefined | boolean | number | string | Date | RegExp |
|
|
|
1066
1092
|
*/
|
|
1067
1093
|
declare function isEqual(a: Comparable, b: Comparable): boolean;
|
|
1068
1094
|
|
|
1069
|
-
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, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, 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 };
|
|
1095
|
+
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 };
|