mazey 5.6.9 → 5.7.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/README.md +105 -0
- package/README.zh-CN.md +67 -0
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +122 -7
- package/lib/index.esm.js +2 -2
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1969,12 +1969,12 @@ declare function sha256Hex(input: string | BufferSource): Promise<string>;
|
|
|
1969
1969
|
* Usage:
|
|
1970
1970
|
*
|
|
1971
1971
|
* ```javascript
|
|
1972
|
-
* import {
|
|
1972
|
+
* import { isValidPhoneNumber } from "mazey";
|
|
1973
1973
|
*
|
|
1974
|
-
* const ret1 =
|
|
1975
|
-
* const ret2 =
|
|
1976
|
-
* const ret3 =
|
|
1977
|
-
* const ret4 =
|
|
1974
|
+
* const ret1 = isValidPhoneNumber("13800138000");
|
|
1975
|
+
* const ret2 = isValidPhoneNumber("1380013800");
|
|
1976
|
+
* const ret3 = isValidPhoneNumber("138001380000");
|
|
1977
|
+
* const ret4 = isValidPhoneNumber("1380013800a");
|
|
1978
1978
|
* console.log(ret1, ret2, ret3, ret4);
|
|
1979
1979
|
* ```
|
|
1980
1980
|
*
|
|
@@ -1989,6 +1989,15 @@ declare function sha256Hex(input: string | BufferSource): Promise<string>;
|
|
|
1989
1989
|
* @category Util
|
|
1990
1990
|
*/
|
|
1991
1991
|
declare function isValidPhoneNumber(mobile: string): boolean;
|
|
1992
|
+
/**
|
|
1993
|
+
* Alias of {@link isValidPhoneNumber}.
|
|
1994
|
+
*
|
|
1995
|
+
* This helper validates an 11-digit Chinese mobile-shaped number. It does not
|
|
1996
|
+
* detect a browser's device form factor; use `isPhone` for that purpose.
|
|
1997
|
+
*
|
|
1998
|
+
* @category Util
|
|
1999
|
+
*/
|
|
2000
|
+
declare const isMobile: typeof isValidPhoneNumber;
|
|
1992
2001
|
/**
|
|
1993
2002
|
* Check if the given string is a valid email.
|
|
1994
2003
|
*
|
|
@@ -2885,6 +2894,50 @@ interface ResolveElementTargetOptions {
|
|
|
2885
2894
|
/** Optional adapter for ref-like or framework-specific target wrappers. */
|
|
2886
2895
|
unwrap?: (value: unknown) => unknown;
|
|
2887
2896
|
}
|
|
2897
|
+
/**
|
|
2898
|
+
* A target accepted by the DOM visibility helpers.
|
|
2899
|
+
*
|
|
2900
|
+
* @category DOM
|
|
2901
|
+
*/
|
|
2902
|
+
type DomVisibilityTarget = string | Element | Iterable<Element> | ArrayLike<Element> | null | undefined;
|
|
2903
|
+
/**
|
|
2904
|
+
* Hide every resolved element while preserving its visible inline `display`
|
|
2905
|
+
* value for a later call to {@link show}.
|
|
2906
|
+
*
|
|
2907
|
+
* ```javascript
|
|
2908
|
+
* import { hide } from "mazey";
|
|
2909
|
+
*
|
|
2910
|
+
* hide(".notice");
|
|
2911
|
+
* ```
|
|
2912
|
+
*
|
|
2913
|
+
* @remarks Selectors use the global document. Direct elements and collections
|
|
2914
|
+
* use their owning documents. Invalid selectors and unsupported values are
|
|
2915
|
+
* ignored. Duplicate elements are mutated once.
|
|
2916
|
+
* @param target Selector, element, iterable, array-like collection, or an empty target.
|
|
2917
|
+
* @returns The original target unchanged, to support chaining by the caller.
|
|
2918
|
+
* @category DOM
|
|
2919
|
+
*/
|
|
2920
|
+
declare function hide<T extends DomVisibilityTarget>(target: T): T;
|
|
2921
|
+
/**
|
|
2922
|
+
* Show every resolved element by restoring a display value preserved by
|
|
2923
|
+
* {@link hide}, or by applying the document-aware default for CSS-hidden
|
|
2924
|
+
* elements.
|
|
2925
|
+
*
|
|
2926
|
+
* ```javascript
|
|
2927
|
+
* import { show } from "mazey";
|
|
2928
|
+
*
|
|
2929
|
+
* const notices = document.querySelectorAll(".notice");
|
|
2930
|
+
* show(notices);
|
|
2931
|
+
* ```
|
|
2932
|
+
*
|
|
2933
|
+
* @remarks Selectors use the global document. Direct elements and collections
|
|
2934
|
+
* use their owning documents. Invalid selectors and unsupported values are
|
|
2935
|
+
* ignored. Duplicate elements are mutated once.
|
|
2936
|
+
* @param target Selector, element, iterable, array-like collection, or an empty target.
|
|
2937
|
+
* @returns The original target unchanged, to support chaining by the caller.
|
|
2938
|
+
* @category DOM
|
|
2939
|
+
*/
|
|
2940
|
+
declare function show<T extends DomVisibilityTarget>(target: T): T;
|
|
2888
2941
|
/**
|
|
2889
2942
|
* Resolve an element from a direct element, a selector, an optionally
|
|
2890
2943
|
* unwrapped value, or a component-like object containing an `$el` element.
|
|
@@ -3673,6 +3726,68 @@ declare function getPerformance(camelCase?: boolean): Promise<WebPerformance>;
|
|
|
3673
3726
|
* @category Browser Information
|
|
3674
3727
|
*/
|
|
3675
3728
|
type VisitorType = "crawler" | "automation" | "unknown";
|
|
3729
|
+
/**
|
|
3730
|
+
* Check whether a user agent represents a mobile phone or handset-class
|
|
3731
|
+
* device. Tablet devices are classified separately by {@link isTablet}.
|
|
3732
|
+
*
|
|
3733
|
+
* The classifier recognizes iPhone and iPod user agents, Android user agents
|
|
3734
|
+
* that contain the `Mobile` token, and a bounded `Mobile` token as a fallback
|
|
3735
|
+
* for otherwise unknown clients. Stronger tablet signals take priority.
|
|
3736
|
+
*
|
|
3737
|
+
* @param userAgent Optional user-agent string. Defaults to the current
|
|
3738
|
+
* browser's guarded navigator signals. An explicit string is classified by
|
|
3739
|
+
* itself without current platform or touch information.
|
|
3740
|
+
* @returns `true` for a recognized phone or handset-class device; otherwise
|
|
3741
|
+
* `false`. Returns `false` during SSR when no explicit user agent is available.
|
|
3742
|
+
* @throws {TypeError} If an explicitly supplied user agent is not a string.
|
|
3743
|
+
* @remarks Device classification is heuristic and spoofable. Do not use this
|
|
3744
|
+
* helper as a security boundary or as a substitute for responsive CSS or
|
|
3745
|
+
* feature detection. It does not inspect viewport dimensions. The separate
|
|
3746
|
+
* `isMobile` export is an alias of the `isValidPhoneNumber` string validator.
|
|
3747
|
+
* @category Browser Information
|
|
3748
|
+
*/
|
|
3749
|
+
declare function isPhone(userAgent?: string): boolean;
|
|
3750
|
+
/**
|
|
3751
|
+
* Check whether a user agent represents a desktop or laptop-class device.
|
|
3752
|
+
*
|
|
3753
|
+
* The classifier recognizes Windows, ordinary macOS, Linux, and ChromeOS.
|
|
3754
|
+
* Touch capability does not make a Windows device a tablet. A current browser
|
|
3755
|
+
* with the existing MacIntel multi-touch iPadOS compatibility signals is
|
|
3756
|
+
* excluded from desktop classification.
|
|
3757
|
+
*
|
|
3758
|
+
* @param userAgent Optional user-agent string. Defaults to the current
|
|
3759
|
+
* browser's guarded navigator signals. An explicit string is classified by
|
|
3760
|
+
* itself without current platform or touch information.
|
|
3761
|
+
* @returns `true` for a recognized desktop or laptop-class device; otherwise
|
|
3762
|
+
* `false`. Returns `false` during SSR when no explicit user agent is available.
|
|
3763
|
+
* @throws {TypeError} If an explicitly supplied user agent is not a string.
|
|
3764
|
+
* @remarks Device classification is heuristic and spoofable. Do not use this
|
|
3765
|
+
* helper as a security boundary or as a substitute for responsive CSS or
|
|
3766
|
+
* feature detection. It does not inspect viewport dimensions.
|
|
3767
|
+
* @category Browser Information
|
|
3768
|
+
*/
|
|
3769
|
+
declare function isDesktop(userAgent?: string): boolean;
|
|
3770
|
+
/**
|
|
3771
|
+
* Check whether a user agent represents a tablet device.
|
|
3772
|
+
*
|
|
3773
|
+
* The classifier recognizes conventional iPad user agents, bounded `Tablet`
|
|
3774
|
+
* tokens, and Android user agents without a `Mobile` token. When no explicit
|
|
3775
|
+
* user agent is supplied, it also recognizes modern iPadOS desktop mode from a
|
|
3776
|
+
* Macintosh user agent, `MacIntel` platform, and more than one touch point.
|
|
3777
|
+
* An explicit user agent never borrows current platform or touch signals.
|
|
3778
|
+
*
|
|
3779
|
+
* @param userAgent Optional user-agent string. Defaults to the current
|
|
3780
|
+
* browser's guarded navigator signals. An explicit string is classified by
|
|
3781
|
+
* itself without current platform or touch information.
|
|
3782
|
+
* @returns `true` for a recognized tablet device; otherwise `false`. Returns
|
|
3783
|
+
* `false` during SSR when no explicit user agent is available.
|
|
3784
|
+
* @throws {TypeError} If an explicitly supplied user agent is not a string.
|
|
3785
|
+
* @remarks Device classification is heuristic and spoofable. Do not use this
|
|
3786
|
+
* helper as a security boundary or as a substitute for responsive CSS or
|
|
3787
|
+
* feature detection. It does not inspect viewport dimensions.
|
|
3788
|
+
* @category Browser Information
|
|
3789
|
+
*/
|
|
3790
|
+
declare function isTablet(userAgent?: string): boolean;
|
|
3676
3791
|
/**
|
|
3677
3792
|
* Check whether a user agent represents iOS or iPadOS.
|
|
3678
3793
|
*
|
|
@@ -4382,5 +4497,5 @@ declare const mazeyCon: Console;
|
|
|
4382
4497
|
*/
|
|
4383
4498
|
declare const timeCon: Console;
|
|
4384
4499
|
|
|
4385
|
-
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, derivePackageMetadata, detectVisitorType, doFn, escapeHtmlAttribute, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, formatLocalDateTime, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalJSON, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionJSON, getSessionStorage, getSystemTheme, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, inRate, invokeEvent, invokeFn, isAndroid, isArray, isBool, isBoolean, isBrowser, isFunction, isHit, isIOS, isJSONString, isJsonString, isLinux, isMacOS, isNonEmptyArray, isNonEmptyObject, isNumber, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, isWindows, listenMediaQueryChanges, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalJSON, setLocalStorage, setSessionJSON, setSessionStorage, setThemePreference, sha256Hex, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4386
|
-
export type { DerivePackageMetadataOptions, DerivedPackageMetadata, FormatByteSizeOptions, GitHubRepositoryDetails, InvestmentReturnRate, IsSafePWAEnvOptions, LocalDateTimePrecision, PackageManager, PackageManifest, PackageManifestAuthor, PreferenceResult, ResolveElementTargetOptions, ResolvedTheme, ServiceWorkerUpdateCallbacks, ServiceWorkerUpdateWatcher, ThemePreference, VisitorType };
|
|
4500
|
+
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, derivePackageMetadata, detectVisitorType, doFn, escapeHtmlAttribute, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, formatLocalDateTime, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalJSON, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionJSON, getSessionStorage, getSystemTheme, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, hide, inRate, invokeEvent, invokeFn, isAndroid, isArray, isBool, isBoolean, isBrowser, isDesktop, isFunction, isHit, isIOS, isJSONString, isJsonString, isLinux, isMacOS, isMobile, isNonEmptyArray, isNonEmptyObject, isNumber, isPhone, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isTablet, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, isWindows, listenMediaQueryChanges, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalJSON, setLocalStorage, setSessionJSON, setSessionStorage, setThemePreference, sha256Hex, show, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4501
|
+
export type { DerivePackageMetadataOptions, DerivedPackageMetadata, DomVisibilityTarget, FormatByteSizeOptions, GitHubRepositoryDetails, InvestmentReturnRate, IsSafePWAEnvOptions, LocalDateTimePrecision, PackageManager, PackageManifest, PackageManifestAuthor, PreferenceResult, ResolveElementTargetOptions, ResolvedTheme, ServiceWorkerUpdateCallbacks, ServiceWorkerUpdateWatcher, ThemePreference, VisitorType };
|