mazey 5.10.0 → 5.10.2
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 +141 -21
- package/README.zh-CN.md +35 -7
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +187 -84
- 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
|
@@ -163,7 +163,7 @@ declare function calculateAspectRatio(width: number, height: number): string;
|
|
|
163
163
|
* ```typescript
|
|
164
164
|
* import {
|
|
165
165
|
* calculateCAGR,
|
|
166
|
-
*
|
|
166
|
+
* formatPercentage,
|
|
167
167
|
* } from "mazey";
|
|
168
168
|
*
|
|
169
169
|
* const cagr = calculateCAGR(
|
|
@@ -186,7 +186,7 @@ declare function calculateAspectRatio(width: number, height: number): string;
|
|
|
186
186
|
* cagr,
|
|
187
187
|
* equivalentCagr,
|
|
188
188
|
* negativeCagr,
|
|
189
|
-
* percentage:
|
|
189
|
+
* percentage: formatPercentage(cagr, 2),
|
|
190
190
|
* });
|
|
191
191
|
* ```
|
|
192
192
|
*
|
|
@@ -1056,15 +1056,19 @@ declare function convertKebabToCamel(kebabCase: string): string;
|
|
|
1056
1056
|
*/
|
|
1057
1057
|
declare function camelCaseToKebabCase(camelCase: string): string;
|
|
1058
1058
|
/**
|
|
1059
|
-
* Convert
|
|
1059
|
+
* Convert camel-case text to underscore-separated lowercase text.
|
|
1060
|
+
*
|
|
1061
|
+
* Insert an underscore before every uppercase ASCII letter, lowercase the
|
|
1062
|
+
* result, and remove one leading underscore. Acronyms are split per letter:
|
|
1063
|
+
* `XMLParser` becomes `x_m_l_parser`. Existing underscores are otherwise kept.
|
|
1060
1064
|
*
|
|
1061
1065
|
* Usage:
|
|
1062
1066
|
*
|
|
1063
1067
|
* ```javascript
|
|
1064
|
-
* import {
|
|
1068
|
+
* import { convertCamelToSnake } from "mazey";
|
|
1065
1069
|
*
|
|
1066
|
-
* const ret1 =
|
|
1067
|
-
* const ret2 =
|
|
1070
|
+
* const ret1 = convertCamelToSnake("ABC");
|
|
1071
|
+
* const ret2 = convertCamelToSnake("aBC");
|
|
1068
1072
|
* console.log(ret1);
|
|
1069
1073
|
* console.log(ret2);
|
|
1070
1074
|
* ```
|
|
@@ -1080,17 +1084,26 @@ declare function camelCaseToKebabCase(camelCase: string): string;
|
|
|
1080
1084
|
* @returns {string} "a_b_c"
|
|
1081
1085
|
* @category Util
|
|
1082
1086
|
*/
|
|
1083
|
-
declare function
|
|
1087
|
+
declare function convertCamelToSnake(camelCase: string): string;
|
|
1088
|
+
/**
|
|
1089
|
+
* Alias of `convertCamelToSnake`.
|
|
1090
|
+
* @deprecated Use `convertCamelToSnake` instead.
|
|
1091
|
+
* @category Util
|
|
1092
|
+
*/
|
|
1093
|
+
declare const convertCamelToUnder: typeof convertCamelToSnake;
|
|
1084
1094
|
/**
|
|
1085
|
-
* Convert
|
|
1095
|
+
* Convert underscore-separated text to camel case.
|
|
1096
|
+
*
|
|
1097
|
+
* Replace each underscore followed by a lowercase ASCII letter with that
|
|
1098
|
+
* uppercase letter. Preserve unmatched underscores and other characters.
|
|
1086
1099
|
*
|
|
1087
1100
|
* Usage:
|
|
1088
1101
|
*
|
|
1089
1102
|
* ```javascript
|
|
1090
|
-
* import {
|
|
1103
|
+
* import { convertSnakeToCamel } from "mazey";
|
|
1091
1104
|
*
|
|
1092
|
-
* const ret1 =
|
|
1093
|
-
* const ret2 =
|
|
1105
|
+
* const ret1 = convertSnakeToCamel("a_b_c");
|
|
1106
|
+
* const ret2 = convertSnakeToCamel("a_bb_cc");
|
|
1094
1107
|
* console.log(ret1, ret2);
|
|
1095
1108
|
* ```
|
|
1096
1109
|
*
|
|
@@ -1104,9 +1117,15 @@ declare function convertCamelToUnder(camelCase: string): string;
|
|
|
1104
1117
|
* @returns {string} "aBbCc"
|
|
1105
1118
|
* @category Util
|
|
1106
1119
|
*/
|
|
1107
|
-
declare function
|
|
1120
|
+
declare function convertSnakeToCamel(underCase: string): string;
|
|
1108
1121
|
/**
|
|
1109
|
-
* Alias of `
|
|
1122
|
+
* Alias of `convertSnakeToCamel`.
|
|
1123
|
+
* @deprecated Use `convertSnakeToCamel` instead.
|
|
1124
|
+
* @category Util
|
|
1125
|
+
*/
|
|
1126
|
+
declare const convertUnderToCamel: typeof convertSnakeToCamel;
|
|
1127
|
+
/**
|
|
1128
|
+
* Alias of `convertCamelToSnake`.
|
|
1110
1129
|
*
|
|
1111
1130
|
* @hidden
|
|
1112
1131
|
*/
|
|
@@ -1283,15 +1302,19 @@ declare function genUniqueNumString(n?: number): string;
|
|
|
1283
1302
|
*/
|
|
1284
1303
|
declare function generateUniqueNum(n?: number): string;
|
|
1285
1304
|
/**
|
|
1286
|
-
*
|
|
1305
|
+
* Format a numeric ratio as a percentage string.
|
|
1306
|
+
*
|
|
1307
|
+
* Multiply by 100. Falsy precision uses `Math.floor`, including for negative
|
|
1308
|
+
* ratios; truthy precision uses native `toFixed` and preserves trailing zeros.
|
|
1309
|
+
* Floating-point arithmetic and native precision conversion remain unchanged.
|
|
1287
1310
|
*
|
|
1288
1311
|
* Usage:
|
|
1289
1312
|
*
|
|
1290
1313
|
* ```javascript
|
|
1291
|
-
* import {
|
|
1314
|
+
* import { formatPercentage } from "mazey";
|
|
1292
1315
|
*
|
|
1293
|
-
* const ret1 =
|
|
1294
|
-
* const ret2 =
|
|
1316
|
+
* const ret1 = formatPercentage(0.2);
|
|
1317
|
+
* const ret2 = formatPercentage(0.2, 2);
|
|
1295
1318
|
* console.log(ret1);
|
|
1296
1319
|
* console.log(ret2);
|
|
1297
1320
|
* ```
|
|
@@ -1304,11 +1327,18 @@ declare function generateUniqueNum(n?: number): string;
|
|
|
1304
1327
|
* ```
|
|
1305
1328
|
*
|
|
1306
1329
|
* @param {number} num Floating-point ratio to convert.
|
|
1307
|
-
* @param {number} fixSize Number of decimal places
|
|
1330
|
+
* @param {number} fixSize Number of decimal places, defaulting to 0.
|
|
1308
1331
|
* @returns {string} The percentage string.
|
|
1332
|
+
* @throws {RangeError} If native `toFixed` rejects a truthy precision value.
|
|
1333
|
+
* @category Util
|
|
1334
|
+
*/
|
|
1335
|
+
declare function formatPercentage(num: number, fixSize?: number): string;
|
|
1336
|
+
/**
|
|
1337
|
+
* Alias of `formatPercentage`.
|
|
1338
|
+
* @deprecated Use `formatPercentage` instead.
|
|
1309
1339
|
* @category Util
|
|
1310
1340
|
*/
|
|
1311
|
-
declare
|
|
1341
|
+
declare const floatToPercent: typeof formatPercentage;
|
|
1312
1342
|
/**
|
|
1313
1343
|
* Format a number with a fixed number of decimal places.
|
|
1314
1344
|
*
|
|
@@ -1782,37 +1812,50 @@ declare function escapeHtmlAttribute(value: string, options?: {
|
|
|
1782
1812
|
preserveEntities?: boolean;
|
|
1783
1813
|
}): string;
|
|
1784
1814
|
/**
|
|
1785
|
-
*
|
|
1815
|
+
* Escape ampersands, angle brackets, quotes, and forward slashes as HTML entities.
|
|
1816
|
+
*
|
|
1817
|
+
* This performs character escaping only. It does not sanitize arbitrary HTML,
|
|
1818
|
+
* validate URLs, or make every HTML, JavaScript, or CSS context safe.
|
|
1786
1819
|
*
|
|
1787
1820
|
* Usage:
|
|
1788
1821
|
*
|
|
1789
1822
|
* ```javascript
|
|
1790
|
-
* import {
|
|
1823
|
+
* import { escapeHTML } from "mazey";
|
|
1791
1824
|
*
|
|
1792
|
-
* const ret =
|
|
1825
|
+
* const ret = escapeHTML("<div>hello world</div>");
|
|
1793
1826
|
* console.log(ret);
|
|
1794
1827
|
* ```
|
|
1795
1828
|
*
|
|
1796
1829
|
* Output:
|
|
1797
1830
|
*
|
|
1798
1831
|
* ```text
|
|
1799
|
-
* <div>hello world<
|
|
1832
|
+
* <div>hello world</div>
|
|
1800
1833
|
* ```
|
|
1801
1834
|
*
|
|
1802
|
-
* @param input
|
|
1803
|
-
* @returns The
|
|
1835
|
+
* @param input The string to escape.
|
|
1836
|
+
* @returns The escaped string.
|
|
1804
1837
|
* @category Util
|
|
1805
1838
|
*/
|
|
1806
|
-
declare function
|
|
1839
|
+
declare function escapeHTML(input: string): string;
|
|
1807
1840
|
/**
|
|
1808
|
-
*
|
|
1841
|
+
* Deprecated alias of {@link escapeHTML}.
|
|
1842
|
+
*
|
|
1843
|
+
* @deprecated Use `escapeHTML` instead.
|
|
1844
|
+
* @category Util
|
|
1845
|
+
*/
|
|
1846
|
+
declare const sanitizeInput: typeof escapeHTML;
|
|
1847
|
+
/**
|
|
1848
|
+
* Decode the fixed HTML entity set emitted by {@link escapeHTML}.
|
|
1849
|
+
*
|
|
1850
|
+
* Decoding uses one pass and preserves unrecognized entities. This is not a
|
|
1851
|
+
* general HTML entity decoder, and the result may contain active HTML markup.
|
|
1809
1852
|
*
|
|
1810
1853
|
* Usage:
|
|
1811
1854
|
*
|
|
1812
1855
|
* ```javascript
|
|
1813
|
-
* import {
|
|
1856
|
+
* import { unescapeHTML } from "mazey";
|
|
1814
1857
|
*
|
|
1815
|
-
* const ret =
|
|
1858
|
+
* const ret = unescapeHTML("<div>hello world</div>");
|
|
1816
1859
|
* console.log(ret);
|
|
1817
1860
|
* ```
|
|
1818
1861
|
*
|
|
@@ -1822,27 +1865,37 @@ declare function sanitizeInput(input: string): string;
|
|
|
1822
1865
|
* <div>hello world</div>
|
|
1823
1866
|
* ```
|
|
1824
1867
|
*
|
|
1825
|
-
* @param input
|
|
1826
|
-
* @returns The
|
|
1868
|
+
* @param input The string containing escaped characters.
|
|
1869
|
+
* @returns The decoded string.
|
|
1870
|
+
* @category Util
|
|
1871
|
+
*/
|
|
1872
|
+
declare function unescapeHTML(input: string): string;
|
|
1873
|
+
/**
|
|
1874
|
+
* Deprecated alias of {@link unescapeHTML}.
|
|
1875
|
+
*
|
|
1876
|
+
* @deprecated Use `unescapeHTML` instead.
|
|
1827
1877
|
* @category Util
|
|
1828
1878
|
*/
|
|
1829
|
-
declare
|
|
1879
|
+
declare const unsanitizeInput: typeof unescapeHTML;
|
|
1830
1880
|
/**
|
|
1831
|
-
* Alias of `
|
|
1881
|
+
* Alias of `unescapeHTML`.
|
|
1832
1882
|
*
|
|
1833
1883
|
* @hidden
|
|
1834
1884
|
*/
|
|
1835
1885
|
declare function unsanitize(str: string): string;
|
|
1836
1886
|
/**
|
|
1837
|
-
* Truncate a string by weighted
|
|
1838
|
-
*
|
|
1887
|
+
* Truncate a string by weighted UTF-16 length.
|
|
1888
|
+
*
|
|
1889
|
+
* Code units from U+0000 through U+00FF count as one; all other code units
|
|
1890
|
+
* count as two. Optional truncation text is appended after the length limit.
|
|
1891
|
+
* This does not measure bytes or rendered width and can split surrogate pairs.
|
|
1839
1892
|
*
|
|
1840
1893
|
* Usage:
|
|
1841
1894
|
*
|
|
1842
1895
|
* ```javascript
|
|
1843
|
-
* import {
|
|
1896
|
+
* import { truncateByWeightedLength } from "mazey";
|
|
1844
1897
|
*
|
|
1845
|
-
* const ret =
|
|
1898
|
+
* const ret = truncateByWeightedLength("hello world", 5);
|
|
1846
1899
|
* console.log(ret);
|
|
1847
1900
|
* ```
|
|
1848
1901
|
*
|
|
@@ -1859,12 +1912,19 @@ declare function unsanitize(str: string): string;
|
|
|
1859
1912
|
* @returns {string} The truncated string.
|
|
1860
1913
|
* @category Util
|
|
1861
1914
|
*/
|
|
1862
|
-
declare function
|
|
1915
|
+
declare function truncateByWeightedLength(str: string | null | undefined, len: number, options?: {
|
|
1863
1916
|
hasDot?: boolean;
|
|
1864
1917
|
dotText?: string;
|
|
1865
1918
|
}): string;
|
|
1866
1919
|
/**
|
|
1867
|
-
*
|
|
1920
|
+
* Deprecated alias of {@link truncateByWeightedLength}.
|
|
1921
|
+
*
|
|
1922
|
+
* @deprecated Use `truncateByWeightedLength` instead.
|
|
1923
|
+
* @category Util
|
|
1924
|
+
*/
|
|
1925
|
+
declare const cutZHString: typeof truncateByWeightedLength;
|
|
1926
|
+
/**
|
|
1927
|
+
* Alias of `truncateByWeightedLength`.
|
|
1868
1928
|
*
|
|
1869
1929
|
* Usage:
|
|
1870
1930
|
*
|
|
@@ -2037,17 +2097,20 @@ declare function genHashCode(str: string): number;
|
|
|
2037
2097
|
*/
|
|
2038
2098
|
declare function sha256Hex(input: string | BufferSource): Promise<string>;
|
|
2039
2099
|
/**
|
|
2040
|
-
* Check
|
|
2100
|
+
* Check whether a string has the 11-digit Chinese mobile-number format.
|
|
2101
|
+
*
|
|
2102
|
+
* The pattern requires a leading `1` followed by ten digits. It does not
|
|
2103
|
+
* verify assigned prefixes, ownership, reachability, or international formats.
|
|
2041
2104
|
*
|
|
2042
2105
|
* Usage:
|
|
2043
2106
|
*
|
|
2044
2107
|
* ```javascript
|
|
2045
|
-
* import {
|
|
2108
|
+
* import { isCNMobileNumber } from "mazey";
|
|
2046
2109
|
*
|
|
2047
|
-
* const ret1 =
|
|
2048
|
-
* const ret2 =
|
|
2049
|
-
* const ret3 =
|
|
2050
|
-
* const ret4 =
|
|
2110
|
+
* const ret1 = isCNMobileNumber("13800138000");
|
|
2111
|
+
* const ret2 = isCNMobileNumber("1380013800");
|
|
2112
|
+
* const ret3 = isCNMobileNumber("138001380000");
|
|
2113
|
+
* const ret4 = isCNMobileNumber("1380013800a");
|
|
2051
2114
|
* console.log(ret1, ret2, ret3, ret4);
|
|
2052
2115
|
* ```
|
|
2053
2116
|
*
|
|
@@ -2057,21 +2120,28 @@ declare function sha256Hex(input: string | BufferSource): Promise<string>;
|
|
|
2057
2120
|
* true false false false
|
|
2058
2121
|
* ```
|
|
2059
2122
|
*
|
|
2060
|
-
* @param mobile
|
|
2061
|
-
* @returns
|
|
2123
|
+
* @param mobile The string to check.
|
|
2124
|
+
* @returns Whether the string matches the Chinese mobile-number format.
|
|
2125
|
+
* @category Util
|
|
2126
|
+
*/
|
|
2127
|
+
declare function isCNMobileNumber(mobile: string): boolean;
|
|
2128
|
+
/**
|
|
2129
|
+
* Deprecated alias of {@link isCNMobileNumber}.
|
|
2130
|
+
*
|
|
2131
|
+
* @deprecated Use `isCNMobileNumber` instead.
|
|
2062
2132
|
* @category Util
|
|
2063
2133
|
*/
|
|
2064
|
-
declare
|
|
2134
|
+
declare const isValidPhoneNumber: typeof isCNMobileNumber;
|
|
2065
2135
|
/**
|
|
2066
|
-
* Deprecated alias of {@link
|
|
2136
|
+
* Deprecated alias of {@link isCNMobileNumber}.
|
|
2067
2137
|
*
|
|
2068
2138
|
* This helper validates an 11-digit Chinese mobile-shaped number. It does not
|
|
2069
2139
|
* detect a browser's device form factor; use `isPhone` for that purpose.
|
|
2070
2140
|
*
|
|
2071
|
-
* @deprecated Use `
|
|
2141
|
+
* @deprecated Use `isCNMobileNumber` instead.
|
|
2072
2142
|
* @category Util
|
|
2073
2143
|
*/
|
|
2074
|
-
declare const isMobile: typeof
|
|
2144
|
+
declare const isMobile: typeof isCNMobileNumber;
|
|
2075
2145
|
/**
|
|
2076
2146
|
* Check if the given string is a valid email.
|
|
2077
2147
|
*
|
|
@@ -2487,18 +2557,23 @@ declare function isValidHttpUrl(url: string, options?: {
|
|
|
2487
2557
|
strict: boolean;
|
|
2488
2558
|
}): boolean;
|
|
2489
2559
|
/**
|
|
2490
|
-
*
|
|
2560
|
+
* Extract the extension from a URL or path after removing query and fragment text.
|
|
2561
|
+
*
|
|
2562
|
+
* This string-based helper does not inspect file contents or detect MIME types.
|
|
2563
|
+
* It retains everything after the first dot in the final slash-delimited
|
|
2564
|
+
* segment, so `archive.tar.gz` returns `tar.gz`. It does not parse URL authority:
|
|
2565
|
+
* an origin-only input such as `https://example.com` returns `com`.
|
|
2491
2566
|
*
|
|
2492
2567
|
* Usage:
|
|
2493
2568
|
*
|
|
2494
2569
|
* ```javascript
|
|
2495
|
-
* import {
|
|
2570
|
+
* import { getURLPathExtension } from "mazey";
|
|
2496
2571
|
*
|
|
2497
|
-
* const ret1 =
|
|
2498
|
-
* const ret2 =
|
|
2499
|
-
* const ret3 =
|
|
2500
|
-
* const ret4 =
|
|
2501
|
-
* const ret5 =
|
|
2572
|
+
* const ret1 = getURLPathExtension("https://example.com/a/b/c.png");
|
|
2573
|
+
* const ret2 = getURLPathExtension("https://example.com/a/b/c.jpg");
|
|
2574
|
+
* const ret3 = getURLPathExtension("https://example.com/a/b/c.jpeg");
|
|
2575
|
+
* const ret4 = getURLPathExtension("/a/b/c.jpeg");
|
|
2576
|
+
* const ret5 = getURLPathExtension("https://example.com/a/b/c.v/a");
|
|
2502
2577
|
* console.log(ret1, ret2, ret3, ret4, ret5);
|
|
2503
2578
|
* ```
|
|
2504
2579
|
*
|
|
@@ -2508,11 +2583,18 @@ declare function isValidHttpUrl(url: string, options?: {
|
|
|
2508
2583
|
* png jpg jpeg jpeg ""
|
|
2509
2584
|
* ```
|
|
2510
2585
|
*
|
|
2511
|
-
* @param url
|
|
2512
|
-
* @returns
|
|
2586
|
+
* @param url The URL or path to inspect.
|
|
2587
|
+
* @returns The extension without the leading dot, or an empty string when absent.
|
|
2588
|
+
* @category URL
|
|
2589
|
+
*/
|
|
2590
|
+
declare function getURLPathExtension(url: string): boolean | string;
|
|
2591
|
+
/**
|
|
2592
|
+
* Deprecated alias of {@link getURLPathExtension}.
|
|
2593
|
+
*
|
|
2594
|
+
* @deprecated Use `getURLPathExtension` instead.
|
|
2513
2595
|
* @category URL
|
|
2514
2596
|
*/
|
|
2515
|
-
declare
|
|
2597
|
+
declare const getUrlFileType: typeof getURLPathExtension;
|
|
2516
2598
|
/**
|
|
2517
2599
|
* Retrieve a query parameter from a script URL in the browser.
|
|
2518
2600
|
*
|
|
@@ -2697,10 +2779,10 @@ declare function hasClass(obj: MazeyElement, cls: string): boolean;
|
|
|
2697
2779
|
* Advanced Usage:
|
|
2698
2780
|
*
|
|
2699
2781
|
* ```javascript
|
|
2700
|
-
* import { addClass,
|
|
2782
|
+
* import { addClass, getBrowserClassNames } from "mazey";
|
|
2701
2783
|
*
|
|
2702
2784
|
* const ele = document.querySelector("html");
|
|
2703
|
-
* addClass(ele,
|
|
2785
|
+
* addClass(ele, getBrowserClassNames());
|
|
2704
2786
|
* ```
|
|
2705
2787
|
*
|
|
2706
2788
|
* Output:
|
|
@@ -2774,18 +2856,18 @@ declare function removeClass(obj: MazeyElement, cls: string): void;
|
|
|
2774
2856
|
* <style>body { background-color: #444; }</style>
|
|
2775
2857
|
* ```
|
|
2776
2858
|
*
|
|
2777
|
-
* Example 3: Combine `
|
|
2859
|
+
* Example 3: Combine `createCSSRule` and `injectStyle` to add multiple styles at once.
|
|
2778
2860
|
*
|
|
2779
2861
|
* ```javascript
|
|
2780
|
-
* import {
|
|
2862
|
+
* import { createCSSRule, injectStyle } from "mazey";
|
|
2781
2863
|
*
|
|
2782
|
-
* const xStyle =
|
|
2864
|
+
* const xStyle = createCSSRule(
|
|
2783
2865
|
* ".footer>.x-wish>a:first-child" +
|
|
2784
2866
|
* ",div.wish-flex>a[href^='https://github.com/chengchuu']" +
|
|
2785
2867
|
* ",.m-hide",
|
|
2786
2868
|
* [ "display: none" ]
|
|
2787
2869
|
* );
|
|
2788
|
-
* const yStyle =
|
|
2870
|
+
* const yStyle = createCSSRule(
|
|
2789
2871
|
* ".footer>.y-wish:before",
|
|
2790
2872
|
* [
|
|
2791
2873
|
* `content: 'Copyright (c) chengchuu'`,
|
|
@@ -2855,13 +2937,16 @@ declare function setImgSizeBySrc(): boolean;
|
|
|
2855
2937
|
*/
|
|
2856
2938
|
declare function setImgWidHeiBySrc(): boolean;
|
|
2857
2939
|
/**
|
|
2858
|
-
*
|
|
2940
|
+
* Create CSS rule text from a selector and an array of declarations.
|
|
2941
|
+
*
|
|
2942
|
+
* Declarations are joined with semicolons. The selector and declarations are
|
|
2943
|
+
* used verbatim without validation or escaping; this function does not modify the DOM.
|
|
2859
2944
|
*
|
|
2860
2945
|
* Usage:
|
|
2861
2946
|
*
|
|
2862
2947
|
* ```javascript
|
|
2863
|
-
* const ret1 =
|
|
2864
|
-
* const ret2 =
|
|
2948
|
+
* const ret1 = createCSSRule(".a", [ "color:red" ]);
|
|
2949
|
+
* const ret2 = createCSSRule("#b", [ "color:red", "font-size:12px" ]);
|
|
2865
2950
|
* console.log(ret1);
|
|
2866
2951
|
* console.log(ret2);
|
|
2867
2952
|
* ```
|
|
@@ -2873,18 +2958,18 @@ declare function setImgWidHeiBySrc(): boolean;
|
|
|
2873
2958
|
* #b{color:red;font-size:12px;}
|
|
2874
2959
|
* ```
|
|
2875
2960
|
*
|
|
2876
|
-
* Example: Combine `
|
|
2961
|
+
* Example: Combine `createCSSRule` and `injectStyle` to add multiple styles at once.
|
|
2877
2962
|
*
|
|
2878
2963
|
* ```javascript
|
|
2879
|
-
* import {
|
|
2964
|
+
* import { createCSSRule, injectStyle } from "mazey";
|
|
2880
2965
|
*
|
|
2881
|
-
* const xStyle =
|
|
2966
|
+
* const xStyle = createCSSRule(
|
|
2882
2967
|
* ".footer>.x-wish>a:first-child" +
|
|
2883
2968
|
* ",div.wish-flex>a[href^='https://github.com/chengchuu']" +
|
|
2884
2969
|
* ",.m-hide",
|
|
2885
2970
|
* [ "display: none" ]
|
|
2886
2971
|
* );
|
|
2887
|
-
* const yStyle =
|
|
2972
|
+
* const yStyle = createCSSRule(
|
|
2888
2973
|
* ".footer>.y-wish:before",
|
|
2889
2974
|
* [
|
|
2890
2975
|
* `content: 'Copyright (c) chengchuu'`,
|
|
@@ -2906,10 +2991,17 @@ declare function setImgWidHeiBySrc(): boolean;
|
|
|
2906
2991
|
*
|
|
2907
2992
|
* @param {string} selector
|
|
2908
2993
|
* @param {array} styleArray
|
|
2909
|
-
* @returns {string} The
|
|
2994
|
+
* @returns {string} The CSS selector and declaration block.
|
|
2995
|
+
* @category DOM
|
|
2996
|
+
*/
|
|
2997
|
+
declare function createCSSRule(selector: string, styleArray: Array<string>): string;
|
|
2998
|
+
/**
|
|
2999
|
+
* Deprecated alias of {@link createCSSRule}.
|
|
3000
|
+
*
|
|
3001
|
+
* @deprecated Use `createCSSRule` instead.
|
|
2910
3002
|
* @category DOM
|
|
2911
3003
|
*/
|
|
2912
|
-
declare
|
|
3004
|
+
declare const genStyleString: typeof createCSSRule;
|
|
2913
3005
|
/**
|
|
2914
3006
|
* Get the value of the meta tag by the given name.
|
|
2915
3007
|
*
|
|
@@ -3848,7 +3940,7 @@ type VisitorType = "crawler" | "automation" | "unknown";
|
|
|
3848
3940
|
* @remarks Device classification is heuristic and spoofable. Do not use this
|
|
3849
3941
|
* helper as a security boundary or as a substitute for responsive CSS or
|
|
3850
3942
|
* feature detection. It does not inspect viewport dimensions. The separate
|
|
3851
|
-
* `isMobile` export is an alias of the `
|
|
3943
|
+
* `isMobile` export is an alias of the `isCNMobileNumber` string validator.
|
|
3852
3944
|
* @category Browser Information
|
|
3853
3945
|
*/
|
|
3854
3946
|
declare function isPhone(userAgent?: string): boolean;
|
|
@@ -4224,14 +4316,17 @@ declare function isStandalonePWA(options?: IsStandalonePWAOptions): boolean;
|
|
|
4224
4316
|
*/
|
|
4225
4317
|
declare function getBrowserInfo(): BrowserInfo;
|
|
4226
4318
|
/**
|
|
4227
|
-
*
|
|
4319
|
+
* Get CSS class-name tokens from the cached browser classification.
|
|
4320
|
+
*
|
|
4321
|
+
* Each available classification value receives the optional prefix and
|
|
4322
|
+
* separator. This function returns strings without modifying the DOM.
|
|
4228
4323
|
*
|
|
4229
4324
|
* Usage:
|
|
4230
4325
|
*
|
|
4231
4326
|
* ```javascript
|
|
4232
|
-
* import {
|
|
4327
|
+
* import { getBrowserClassNames } from "mazey";
|
|
4233
4328
|
*
|
|
4234
|
-
* const attrs =
|
|
4329
|
+
* const attrs = getBrowserClassNames();
|
|
4235
4330
|
* console.log(attrs);
|
|
4236
4331
|
* ```
|
|
4237
4332
|
*
|
|
@@ -4242,11 +4337,19 @@ declare function getBrowserInfo(): BrowserInfo;
|
|
|
4242
4337
|
* ```
|
|
4243
4338
|
*
|
|
4244
4339
|
* @remarks Browser only.
|
|
4245
|
-
* @param
|
|
4246
|
-
* @
|
|
4340
|
+
* @param prefix Optional prefix for every class name.
|
|
4341
|
+
* @param separator Separator between a non-empty prefix and each value. Defaults to `-`.
|
|
4342
|
+
* @returns Browser classification class names.
|
|
4343
|
+
* @category Browser Information
|
|
4344
|
+
*/
|
|
4345
|
+
declare function getBrowserClassNames(prefix?: string, separator?: string): string[];
|
|
4346
|
+
/**
|
|
4347
|
+
* Deprecated alias of {@link getBrowserClassNames}.
|
|
4348
|
+
*
|
|
4349
|
+
* @deprecated Use `getBrowserClassNames` instead.
|
|
4247
4350
|
* @category Browser Information
|
|
4248
4351
|
*/
|
|
4249
|
-
declare
|
|
4352
|
+
declare const genBrowserAttrs: typeof getBrowserClassNames;
|
|
4250
4353
|
/**
|
|
4251
4354
|
* Detect webp support.
|
|
4252
4355
|
*
|
|
@@ -4655,5 +4758,5 @@ declare const mazeyCon: Console;
|
|
|
4655
4758
|
*/
|
|
4656
4759
|
declare const timeCon: Console;
|
|
4657
4760
|
|
|
4658
|
-
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateAspectRatio, 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, hideElements, inRate, injectStyle, invokeEvent, invokeFn, isAndroid, isArray, isBool, isBoolean, isBrowser, isDesktop, isFunction, isHit, isIOS, isJSONString, isJsonString, isLinux, isMacOS, isMobile, isNonEmptyArray, isNonEmptyObject, isNullish, 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, onEvent, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, randomBoolean, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalJSON, setLocalStorage, setSessionJSON, setSessionStorage, setThemePreference, sha256Hex, show, showElements, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4761
|
+
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateAspectRatio, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToSnake, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertSnakeToCamel, convertToHtmlBreaks, convertUnderToCamel, createCSSRule, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, derivePackageMetadata, detectVisitorType, doFn, escapeHTML, escapeHtmlAttribute, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, formatLocalDateTime, formatPercentage, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserClassNames, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalJSON, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionJSON, getSessionStorage, getSystemTheme, getTTFB, getURLPathExtension, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, hide, hideElements, inRate, injectStyle, invokeEvent, invokeFn, isAndroid, isArray, isBool, isBoolean, isBrowser, isCNMobileNumber, isDesktop, isFunction, isHit, isIOS, isJSONString, isJsonString, isLinux, isMacOS, isMobile, isNonEmptyArray, isNonEmptyObject, isNullish, 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, onEvent, onURLChange, parseGitHubRepository, parseJsonSafe, parseLocalDateTime, randomBoolean, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveElementTarget, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalJSON, setLocalStorage, setSessionJSON, setSessionStorage, setThemePreference, sha256Hex, show, showElements, sleep, subYears, throttle, timeCon, toJavaScriptGlobalName, truncateByWeightedLength, truncateZHString, unescapeHTML, unsanitize, unsanitizeInput, updateQueryParam, waitTime, watchServiceWorkerUpdates, windowLoaded, zAxiosIsValidRes };
|
|
4659
4762
|
export type { DerivePackageMetadataOptions, DerivedPackageMetadata, DomVisibilityTarget, FormatByteSizeOptions, GitHubRepositoryDetails, InvestmentReturnRate, IsNumberOptions, IsSafePWAEnvOptions, IsStandalonePWAOptions, LocalDateTimePrecision, PWAEnvironment, PackageManager, PackageManifest, PackageManifestAuthor, PreferenceResult, ResolveElementTargetOptions, ResolvedTheme, ServiceWorkerUpdateCallbacks, ServiceWorkerUpdateWatcher, ThemePreference, VisitorType };
|