@unicom-cloud/utils 0.1.16 → 0.1.17
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/class-name/index.js +5 -5
- package/constant/index.js +24 -2
- package/constant/platform.js +13 -12
- package/constant.js +24 -2
- package/content-disposition/index.js +3 -3
- package/date/convertTime.js +4 -4
- package/event-emitter/index.js +2 -4
- package/filesize/types/constants.d.ts +81 -0
- package/filesize/types/filesize.d.ts +97 -0
- package/index.js +66 -60
- package/js-cookie/index.d.ts +116 -0
- package/js-cookie/index.js +4 -0
- package/js-cookie/src/api.js +56 -0
- package/js-cookie/src/assign.js +11 -0
- package/js-cookie/src/converter.js +14 -0
- package/jsCookie.js +4 -0
- package/lunar/lib/HolidayUtil.js +48 -49
- package/nzh/nzh.d.ts +74 -0
- package/package.json +1 -1
- package/query-string/base.d.ts +717 -0
- package/query-string/base.js +268 -0
- package/query-string/index.d.ts +16 -0
- package/query-string/index.js +4 -0
- package/query-string/splitOnFirst.js +14 -0
- package/queryString.js +4 -0
- package/random/index.js +56 -35
- package/snapdom/src/api/preCache.js +51 -28
- package/snapdom/src/core/cache.js +1 -4
- package/snapdom/src/core/capture.js +45 -44
- package/snapdom/src/core/clone.js +82 -66
- package/snapdom/src/core/prepare.js +167 -45
- package/snapdom/src/modules/background.js +29 -19
- package/snapdom/src/modules/fonts.js +158 -111
- package/snapdom/src/modules/images.js +14 -9
- package/snapdom/src/modules/pseudo.js +52 -47
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/modules/svgDefs.js +39 -20
- package/snapdom/src/utils/cssTools.js +58 -51
- package/snapdom/src/utils/helpers.js +197 -140
- package/snapdom/types/snapdom.d.ts +101 -0
- package/types/constant/index.d.ts +11 -0
- package/types/constant/platform.d.ts +1 -0
- package/types/index.d.ts +3 -0
- package/types/js-cookie/index.d.ts +1 -0
- package/types/js-cookie/src/api.d.mts +2 -0
- package/types/js-cookie/src/assign.d.mts +1 -0
- package/types/js-cookie/src/converter.d.mts +5 -0
- package/types/query-string/base.d.ts +11 -0
- package/types/query-string/index.d.ts +2 -0
- package/types/query-string/splitOnFirst.d.ts +1 -0
- package/types/random/index.d.ts +14 -23
- package/types/snapdom/src/api/preCache.d.ts +2 -5
- package/types/snapdom/src/core/cache.d.ts +0 -3
- package/types/snapdom/src/core/clone.d.ts +1 -1
- package/types/snapdom/src/modules/background.d.ts +16 -6
- package/types/snapdom/src/modules/fonts.d.ts +5 -1
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
- package/types/snapdom/src/utils/cssTools.d.ts +2 -10
- package/types/snapdom/src/utils/helpers.d.ts +13 -7
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/url-toolkit/src/url-toolkit.d.ts +22 -0
package/class-name/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return [...new Set(
|
|
1
|
+
import a from "lodash/isPlainObject";
|
|
2
|
+
function l(...n) {
|
|
3
|
+
const e = n.flat(1 / 0).map((t, r, s) => a(t) ? Object.keys(t).filter((i) => t[i]) : t).flat(1 / 0).filter(Boolean).join(" ").split(" ").filter(Boolean);
|
|
4
|
+
return [...new Set(e)].join(" ");
|
|
5
5
|
}
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
l as default
|
|
8
8
|
};
|
package/constant/index.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import * as o from "./address.js";
|
|
2
|
+
import * as t from "./chineseCharacters.js";
|
|
3
|
+
import * as a from "./constellations.js";
|
|
4
|
+
import * as r from "./domain.js";
|
|
5
|
+
import * as s from "./identity.js";
|
|
6
|
+
import * as e from "./keyboardCode.js";
|
|
7
|
+
import * as n from "./licensePlate.js";
|
|
8
|
+
import * as m from "./name.js";
|
|
9
|
+
import * as p from "./platform.js";
|
|
10
|
+
import * as i from "./protocol.js";
|
|
11
|
+
import * as c from "./ui.js";
|
|
12
|
+
const _ = window.matchMedia(
|
|
2
13
|
"(prefers-color-scheme: dark)"
|
|
3
14
|
);
|
|
4
15
|
export {
|
|
5
|
-
|
|
16
|
+
_ as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK,
|
|
17
|
+
t as chineseCharacters,
|
|
18
|
+
a as constellations,
|
|
19
|
+
o as date,
|
|
20
|
+
r as domain,
|
|
21
|
+
s as identity,
|
|
22
|
+
e as keyboardCode,
|
|
23
|
+
n as licensePlate,
|
|
24
|
+
m as name,
|
|
25
|
+
p as platform,
|
|
26
|
+
i as protocol,
|
|
27
|
+
c as ui
|
|
6
28
|
};
|
package/constant/platform.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
const i = navigator.userAgent.toLowerCase(), t = window.__wxjs_environment === "miniprogram" || !!window.wx?.getSystemInfoSync,
|
|
1
|
+
const i = navigator.userAgent.toLowerCase(), t = window.__wxjs_environment === "miniprogram" || !!window.wx?.getSystemInfoSync, a = /micromessenger/i.test(i), r = /dingtalk/i.test(i), c = /alipay|aliapp/i.test(i), n = /ipad|iphone|ipod/i.test(i), e = /android/i.test(i), w = /openharmony/i.test(i), s = /macintosh|mac os x/i.test(i), d = n || s, m = /windows|win32|win64|wow64/i.test(
|
|
2
2
|
i
|
|
3
|
-
),
|
|
3
|
+
), l = (n || e || /windows phone|blackberry|mobile|webos|iemobile|opera (mini|mobi)/i.test(
|
|
4
4
|
i
|
|
5
|
-
)) && ("ontouchend" in document || "ontouchend" in window),
|
|
5
|
+
)) && ("ontouchend" in document || "ontouchend" in window), p = ["fullscreen", "standalone", "minimal-ui"].some((o) => window.matchMedia(`(display-mode: ${o})`).matches) || window.navigator.standalone === !0;
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
c as isAlipayBrowser,
|
|
8
|
+
e as isAndroidOS,
|
|
9
|
+
d as isAppleDevice,
|
|
10
|
+
r as isDingtalkBrowser,
|
|
10
11
|
w as isHarmony,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
n as isIOS_OS,
|
|
13
|
+
s as isMacOS,
|
|
14
|
+
l as isMobileDevice,
|
|
15
|
+
p as isPWA,
|
|
16
|
+
a as isWeChatBrowser,
|
|
16
17
|
t as isWeChatMiniProgram,
|
|
17
|
-
|
|
18
|
+
m as isWindowsOS
|
|
18
19
|
};
|
package/constant.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as o from "./constant/address.js";
|
|
2
|
+
import * as t from "./constant/chineseCharacters.js";
|
|
3
|
+
import * as a from "./constant/constellations.js";
|
|
4
|
+
import * as r from "./constant/domain.js";
|
|
5
|
+
import * as s from "./constant/identity.js";
|
|
6
|
+
import * as e from "./constant/keyboardCode.js";
|
|
7
|
+
import * as n from "./constant/licensePlate.js";
|
|
8
|
+
import * as m from "./constant/name.js";
|
|
9
|
+
import * as p from "./constant/platform.js";
|
|
10
|
+
import * as i from "./constant/protocol.js";
|
|
11
|
+
import * as c from "./constant/ui.js";
|
|
12
|
+
import { MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK as l } from "./constant/index.js";
|
|
2
13
|
export {
|
|
3
|
-
|
|
14
|
+
l as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK,
|
|
15
|
+
t as chineseCharacters,
|
|
16
|
+
a as constellations,
|
|
17
|
+
o as date,
|
|
18
|
+
r as domain,
|
|
19
|
+
s as identity,
|
|
20
|
+
e as keyboardCode,
|
|
21
|
+
n as licensePlate,
|
|
22
|
+
m as name,
|
|
23
|
+
p as platform,
|
|
24
|
+
i as protocol,
|
|
25
|
+
c as ui
|
|
4
26
|
};
|
|
@@ -17,7 +17,7 @@ function p(t) {
|
|
|
17
17
|
const c = f(n), i = r.slice(0, -1);
|
|
18
18
|
e.parameters[i] || (e.parameters[i] = c), e.parameters[r] = c;
|
|
19
19
|
} catch (c) {
|
|
20
|
-
console.debug(`RFC5987
|
|
20
|
+
console.debug(`RFC5987解码失败:${n}`, c), e.parameters[r] = n;
|
|
21
21
|
}
|
|
22
22
|
else !e.parameters[r] && !e.parameters[`${r}*`] && (e.parameters[r] = n);
|
|
23
23
|
}
|
|
@@ -31,9 +31,9 @@ function f(t) {
|
|
|
31
31
|
const n = decodeURIComponent(
|
|
32
32
|
r.replace(/%(?![0-9A-Fa-f]{2})/g, "%25")
|
|
33
33
|
);
|
|
34
|
-
return s && !/^utf-?8$/i.test(s) && console.warn(`非UTF-8
|
|
34
|
+
return s && !/^utf-?8$/i.test(s) && console.warn(`非UTF-8编码暂未转换:${s}`), n;
|
|
35
35
|
} catch (n) {
|
|
36
|
-
return console.warn(`RFC5987
|
|
36
|
+
return console.warn(`RFC5987解码失败:${t}`, n), t;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function l(t) {
|
package/date/convertTime.js
CHANGED
|
@@ -14,13 +14,13 @@ const f = {
|
|
|
14
14
|
}, r = [
|
|
15
15
|
{ name: "年", seconds: 365 * 24 * 60 * 60, max: 1 / 0 },
|
|
16
16
|
// 年没有上限
|
|
17
|
-
{ name: "个月", seconds:
|
|
17
|
+
{ name: "个月", seconds: 720 * 60 * 60, max: 12 },
|
|
18
18
|
// 月份最大12
|
|
19
|
-
{ name: "周", seconds:
|
|
19
|
+
{ name: "周", seconds: 10080 * 60, max: 4 },
|
|
20
20
|
// 周最大4(约1个月)
|
|
21
|
-
{ name: "天", seconds:
|
|
21
|
+
{ name: "天", seconds: 1440 * 60, max: 7 },
|
|
22
22
|
// 日最大7(1周)
|
|
23
|
-
{ name: "小时", seconds:
|
|
23
|
+
{ name: "小时", seconds: 3600, max: 24 },
|
|
24
24
|
// 小时最大24
|
|
25
25
|
{ name: "分钟", seconds: 60, max: 60 },
|
|
26
26
|
// 分钟最大60
|
package/event-emitter/index.js
CHANGED
|
@@ -20,15 +20,13 @@ class h {
|
|
|
20
20
|
s.push(e), this.#t.set(t, s);
|
|
21
21
|
}
|
|
22
22
|
off(t, e) {
|
|
23
|
-
if (!t)
|
|
24
|
-
return;
|
|
23
|
+
if (!t) return;
|
|
25
24
|
if (!e) {
|
|
26
25
|
this.#t.delete(t);
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
const s = this.#t.get(t);
|
|
30
|
-
if (!s)
|
|
31
|
-
return;
|
|
29
|
+
if (!s) return;
|
|
32
30
|
if (s.length === 0) {
|
|
33
31
|
this.#t.delete(t);
|
|
34
32
|
return;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Error Messages
|
|
2
|
+
export const INVALID_NUMBER: 'Invalid number';
|
|
3
|
+
export const INVALID_ROUND: 'Invalid rounding method';
|
|
4
|
+
|
|
5
|
+
// Standard Types
|
|
6
|
+
export const IEC: 'iec';
|
|
7
|
+
export const JEDEC: 'jedec';
|
|
8
|
+
export const SI: 'si';
|
|
9
|
+
|
|
10
|
+
// Unit Types
|
|
11
|
+
export const BIT: 'bit';
|
|
12
|
+
export const BITS: 'bits';
|
|
13
|
+
export const BYTE: 'byte';
|
|
14
|
+
export const BYTES: 'bytes';
|
|
15
|
+
export const SI_KBIT: 'kbit';
|
|
16
|
+
export const SI_KBYTE: 'kB';
|
|
17
|
+
|
|
18
|
+
// Output Format Types
|
|
19
|
+
export const ARRAY: 'array';
|
|
20
|
+
export const FUNCTION: 'function';
|
|
21
|
+
export const OBJECT: 'object';
|
|
22
|
+
export const STRING: 'string';
|
|
23
|
+
|
|
24
|
+
// Processing Constants
|
|
25
|
+
export const EXPONENT: 'exponent';
|
|
26
|
+
export const ROUND: 'round';
|
|
27
|
+
|
|
28
|
+
// Special Characters and Values
|
|
29
|
+
export const EMPTY: '';
|
|
30
|
+
export const PERIOD: '.';
|
|
31
|
+
export const S: 's';
|
|
32
|
+
export const SPACE: ' ';
|
|
33
|
+
export const ZERO: '0';
|
|
34
|
+
|
|
35
|
+
// Data Structures
|
|
36
|
+
export const STRINGS: {
|
|
37
|
+
symbol: {
|
|
38
|
+
iec: {
|
|
39
|
+
bits: [
|
|
40
|
+
'bit',
|
|
41
|
+
'Kibit',
|
|
42
|
+
'Mibit',
|
|
43
|
+
'Gibit',
|
|
44
|
+
'Tibit',
|
|
45
|
+
'Pibit',
|
|
46
|
+
'Eibit',
|
|
47
|
+
'Zibit',
|
|
48
|
+
'Yibit',
|
|
49
|
+
];
|
|
50
|
+
bytes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
51
|
+
};
|
|
52
|
+
jedec: {
|
|
53
|
+
bits: [
|
|
54
|
+
'bit',
|
|
55
|
+
'Kbit',
|
|
56
|
+
'Mbit',
|
|
57
|
+
'Gbit',
|
|
58
|
+
'Tbit',
|
|
59
|
+
'Pbit',
|
|
60
|
+
'Ebit',
|
|
61
|
+
'Zbit',
|
|
62
|
+
'Ybit',
|
|
63
|
+
];
|
|
64
|
+
bytes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
fullform: {
|
|
68
|
+
iec: ['', 'kibi', 'mebi', 'gibi', 'tebi', 'pebi', 'exbi', 'zebi', 'yobi'];
|
|
69
|
+
jedec: [
|
|
70
|
+
'',
|
|
71
|
+
'kilo',
|
|
72
|
+
'mega',
|
|
73
|
+
'giga',
|
|
74
|
+
'tera',
|
|
75
|
+
'peta',
|
|
76
|
+
'exa',
|
|
77
|
+
'zetta',
|
|
78
|
+
'yotta',
|
|
79
|
+
];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options interface for configuring filesize behavior
|
|
3
|
+
*/
|
|
4
|
+
export interface FilesizeOptions {
|
|
5
|
+
/** If true, calculates bits instead of bytes */
|
|
6
|
+
bits?: boolean;
|
|
7
|
+
/** If true, pads decimal places to match round parameter */
|
|
8
|
+
pad?: boolean;
|
|
9
|
+
/** Number base (2 for binary, 10 for decimal, -1 for auto) */
|
|
10
|
+
base?: number;
|
|
11
|
+
/** Number of decimal places to round to */
|
|
12
|
+
round?: number;
|
|
13
|
+
/** Locale for number formatting, true for system locale */
|
|
14
|
+
locale?: string | boolean;
|
|
15
|
+
/** Additional options for locale formatting */
|
|
16
|
+
localeOptions?: Intl.NumberFormatOptions;
|
|
17
|
+
/** Custom decimal separator */
|
|
18
|
+
separator?: string;
|
|
19
|
+
/** String to separate value and unit */
|
|
20
|
+
spacer?: string;
|
|
21
|
+
/** Custom unit symbols */
|
|
22
|
+
symbols?: Record<string, string>;
|
|
23
|
+
/** Unit standard to use (SI, IEC, JEDEC) */
|
|
24
|
+
standard?: 'si' | 'iec' | 'jedec' | '';
|
|
25
|
+
/** Output format: "string", "array", "object", or "exponent" */
|
|
26
|
+
output?: 'string' | 'array' | 'object' | 'exponent';
|
|
27
|
+
/** If true, uses full unit names instead of abbreviations */
|
|
28
|
+
fullform?: boolean;
|
|
29
|
+
/** Custom full unit names */
|
|
30
|
+
fullforms?: string[];
|
|
31
|
+
/** Force specific exponent (-1 for auto) */
|
|
32
|
+
exponent?: number;
|
|
33
|
+
/** Math rounding method to use */
|
|
34
|
+
roundingMethod?: 'round' | 'floor' | 'ceil';
|
|
35
|
+
/** Number of significant digits (0 for auto) */
|
|
36
|
+
precision?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Object format return type when output is "object"
|
|
41
|
+
*/
|
|
42
|
+
export interface FilesizeObject {
|
|
43
|
+
/** The numeric value */
|
|
44
|
+
value: number | string;
|
|
45
|
+
/** The unit symbol */
|
|
46
|
+
symbol: string;
|
|
47
|
+
/** The exponent used in calculation */
|
|
48
|
+
exponent: number;
|
|
49
|
+
/** The original unit before symbol customization */
|
|
50
|
+
unit: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Array format return type when output is "array"
|
|
55
|
+
*/
|
|
56
|
+
export type FilesizeArray = [number | string, string];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Return type based on output option
|
|
60
|
+
*/
|
|
61
|
+
export type FilesizeReturn<T extends FilesizeOptions = {}> =
|
|
62
|
+
T['output'] extends 'object'
|
|
63
|
+
? FilesizeObject
|
|
64
|
+
: T['output'] extends 'array'
|
|
65
|
+
? FilesizeArray
|
|
66
|
+
: T['output'] extends 'exponent'
|
|
67
|
+
? number
|
|
68
|
+
: string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Converts a file size in bytes to a human-readable string with appropriate units
|
|
72
|
+
* @param arg - The file size in bytes to convert
|
|
73
|
+
* @param options - Configuration options for formatting
|
|
74
|
+
* @returns Formatted file size based on output option
|
|
75
|
+
* @throws {TypeError} When arg is not a valid number or roundingMethod is invalid
|
|
76
|
+
* @example
|
|
77
|
+
* filesize(1024) // "1 KB"
|
|
78
|
+
* filesize(1024, {bits: true}) // "8 Kb"
|
|
79
|
+
* filesize(1024, {output: "object"}) // {value: 1, symbol: "KB", exponent: 1, unit: "KB"}
|
|
80
|
+
*/
|
|
81
|
+
export function filesize<T extends FilesizeOptions = {}>(
|
|
82
|
+
arg: number | string | bigint,
|
|
83
|
+
options?: T,
|
|
84
|
+
): FilesizeReturn<T>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Creates a partially applied version of filesize with preset options
|
|
88
|
+
* @param options - Default options to apply to the returned function
|
|
89
|
+
* @returns A function that takes a file size and returns formatted output
|
|
90
|
+
* @example
|
|
91
|
+
* const formatBytes = partial({round: 1, standard: "iec"});
|
|
92
|
+
* formatBytes(1024) // "1.0 KiB"
|
|
93
|
+
* formatBytes(2048) // "2.0 KiB"
|
|
94
|
+
*/
|
|
95
|
+
export function partial<T extends FilesizeOptions = {}>(
|
|
96
|
+
options?: T,
|
|
97
|
+
): (arg: number | string | bigint) => FilesizeReturn<T>;
|
package/index.js
CHANGED
|
@@ -1,62 +1,68 @@
|
|
|
1
|
-
import * as o from "./
|
|
2
|
-
import * as e from "./
|
|
3
|
-
import * as r from "./
|
|
4
|
-
import * as t from "./
|
|
5
|
-
import * as a from "./
|
|
6
|
-
import * as s from "./
|
|
7
|
-
import * as i from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import {
|
|
13
|
-
import { default as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { default as U } from "./
|
|
22
|
-
import { default as $ } from "./
|
|
23
|
-
import
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
26
|
-
import { default as
|
|
27
|
-
import {
|
|
28
|
-
import
|
|
1
|
+
import * as o from "./constant/index.js";
|
|
2
|
+
import * as e from "./date/index.js";
|
|
3
|
+
import * as r from "./is/index.js";
|
|
4
|
+
import * as t from "./math/index.js";
|
|
5
|
+
import * as a from "./snapdom/index.js";
|
|
6
|
+
import * as s from "./tree/index.js";
|
|
7
|
+
import * as i from "./turbo-stream/index.js";
|
|
8
|
+
import * as m from "./ui-color/index.js";
|
|
9
|
+
import * as p from "./url-toolkit/index.js";
|
|
10
|
+
import { default as u } from "./case-name/index.js";
|
|
11
|
+
import { default as C } from "./class-name/index.js";
|
|
12
|
+
import { default as b } from "./clipboard-copy/index.js";
|
|
13
|
+
import { default as k, getContentDispositionFromHeader as T, getContentDispositionParametersFilenameFromHeader as g, getContentDispositionParametersFromHeader as y } from "./content-disposition/index.js";
|
|
14
|
+
import { splitCookiesString as D } from "./cookie/index.js";
|
|
15
|
+
import { default as S } from "./decimal/decimal.js";
|
|
16
|
+
import { default as H } from "./event-emitter/index.js";
|
|
17
|
+
import { fileToURL as L } from "./file/fileToURL.js";
|
|
18
|
+
import { saveAs as P } from "./file/saveAs.js";
|
|
19
|
+
import * as f from "./filesize/src/constants.js";
|
|
20
|
+
import { filesize as E, partial as K } from "./filesize/src/filesize.js";
|
|
21
|
+
import { default as U } from "./invariant/index.js";
|
|
22
|
+
import { default as $ } from "./js-cookie/src/api.js";
|
|
23
|
+
import * as n from "./lunar/lib/index.js";
|
|
24
|
+
import { default as w } from "./md5/index.js";
|
|
25
|
+
import { default as G } from "./normalize-wheel/index.js";
|
|
26
|
+
import { default as J } from "./number-to-chinese/index.js";
|
|
27
|
+
import { default as O } from "./nzh/nzh.js";
|
|
28
|
+
import { default as V } from "./object-keys-sort/index.js";
|
|
29
|
+
import { default as Y } from "./screenfull/index.js";
|
|
30
|
+
import { TinyColor as oo } from "./tinycolor/src/index.js";
|
|
31
|
+
import * as x from "./cookie/src/index.js";
|
|
29
32
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
S as
|
|
39
|
-
H as
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
T as
|
|
44
|
-
g as
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
r as
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
w as
|
|
51
|
-
G as
|
|
52
|
-
J as
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
n as Lunar,
|
|
34
|
+
u as caseName,
|
|
35
|
+
C as className,
|
|
36
|
+
b as clipboardCopy,
|
|
37
|
+
o as constant,
|
|
38
|
+
k as contentDisposition,
|
|
39
|
+
x as cookie,
|
|
40
|
+
e as date,
|
|
41
|
+
S as decimal,
|
|
42
|
+
H as eventEmitter,
|
|
43
|
+
L as fileToURL,
|
|
44
|
+
E as filesize,
|
|
45
|
+
f as filesizeConstants,
|
|
46
|
+
T as getContentDispositionFromHeader,
|
|
47
|
+
g as getContentDispositionParametersFilenameFromHeader,
|
|
48
|
+
y as getContentDispositionParametersFromHeader,
|
|
49
|
+
U as invariant,
|
|
50
|
+
r as is,
|
|
51
|
+
$ as jsCookie,
|
|
52
|
+
t as math,
|
|
53
|
+
w as md5,
|
|
54
|
+
G as normalizeWheel,
|
|
55
|
+
J as numberToChinese,
|
|
56
|
+
O as nzh,
|
|
57
|
+
V as objectKeysSort,
|
|
58
|
+
K as partial,
|
|
59
|
+
P as saveAs,
|
|
60
|
+
Y as screenfull,
|
|
61
|
+
a as snapdom,
|
|
62
|
+
D as splitCookiesString,
|
|
63
|
+
oo as tinycolor,
|
|
64
|
+
s as tree,
|
|
65
|
+
i as turboStream,
|
|
66
|
+
m as uiColor,
|
|
67
|
+
p as urlToolkit
|
|
62
68
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
declare namespace Cookies {
|
|
2
|
+
interface CookieAttributes {
|
|
3
|
+
/**
|
|
4
|
+
* Define when the cookie will be removed. Value can be a Number
|
|
5
|
+
* which will be interpreted as days from time of creation or a
|
|
6
|
+
* Date instance. If omitted, the cookie becomes a session cookie.
|
|
7
|
+
*/
|
|
8
|
+
expires?: number | Date | undefined;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Define the path where the cookie is available. Defaults to '/'
|
|
12
|
+
*/
|
|
13
|
+
path?: string | undefined;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Define the domain where the cookie is available. Defaults to
|
|
17
|
+
* the domain of the page where the cookie was created.
|
|
18
|
+
*/
|
|
19
|
+
domain?: string | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A Boolean indicating if the cookie transmission requires a
|
|
23
|
+
* secure protocol (https). Defaults to false.
|
|
24
|
+
*/
|
|
25
|
+
secure?: boolean | undefined;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Asserts that a cookie must not be sent with cross-origin requests,
|
|
29
|
+
* providing some protection against cross-site request forgery
|
|
30
|
+
* attacks (CSRF)
|
|
31
|
+
*/
|
|
32
|
+
sameSite?:
|
|
33
|
+
| 'strict'
|
|
34
|
+
| 'Strict'
|
|
35
|
+
| 'lax'
|
|
36
|
+
| 'Lax'
|
|
37
|
+
| 'none'
|
|
38
|
+
| 'None'
|
|
39
|
+
| undefined;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An attribute which will be serialized, conformably to RFC 6265
|
|
43
|
+
* section 5.2.
|
|
44
|
+
*/
|
|
45
|
+
[property: string]: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface CookiesStatic<T = string> {
|
|
49
|
+
readonly attributes: CookieAttributes;
|
|
50
|
+
readonly converter: Required<Converter<string>>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a cookie
|
|
53
|
+
*/
|
|
54
|
+
set(
|
|
55
|
+
name: string,
|
|
56
|
+
value: string | T,
|
|
57
|
+
options?: CookieAttributes,
|
|
58
|
+
): string | undefined;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Read cookie
|
|
62
|
+
*/
|
|
63
|
+
get(name: string): string | T | undefined;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Read all available cookies
|
|
67
|
+
*/
|
|
68
|
+
get(): { [key: string]: string };
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Delete cookie
|
|
72
|
+
*/
|
|
73
|
+
remove(name: string, options?: CookieAttributes): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Cookie attribute defaults can be set globally by creating an
|
|
77
|
+
* instance of the api via withAttributes(), or individually for
|
|
78
|
+
* each call to Cookies.set(...) by passing a plain object as the
|
|
79
|
+
* last argument. Per-call attributes override the default attributes.
|
|
80
|
+
*/
|
|
81
|
+
withAttributes(attributes: CookieAttributes): CookiesStatic<T>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create a new instance of the api that overrides the default
|
|
85
|
+
* decoding implementation. All methods that rely in a proper
|
|
86
|
+
* decoding to work, such as Cookies.remove() and Cookies.get(),
|
|
87
|
+
* will run the converter first for each cookie. The returned
|
|
88
|
+
* string will be used as the cookie value.
|
|
89
|
+
*/
|
|
90
|
+
withConverter<TConv = string>(
|
|
91
|
+
converter: Converter<TConv>,
|
|
92
|
+
): CookiesStatic<TConv>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface Converter<TConv> {
|
|
96
|
+
write?: CookieWriteConverter<TConv> | undefined;
|
|
97
|
+
read?: CookieReadConverter<TConv> | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type CookieWriteConverter<T> = (value: string | T, name: string) => string;
|
|
101
|
+
type CookieReadConverter<T> = (value: string, name: string) => string | T;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare const Cookies: Cookies.CookiesStatic & {
|
|
105
|
+
/**
|
|
106
|
+
* If there is any danger of a conflict with the namespace Cookies,
|
|
107
|
+
* the noConflict method will allow you to define a new namespace
|
|
108
|
+
* and preserve the original one. This is especially useful when
|
|
109
|
+
* running the script on third party sites e.g. as part of a widget
|
|
110
|
+
* or SDK. Note: The noConflict method is not necessary when using
|
|
111
|
+
* AMD or CommonJS, thus it is not exposed in those environments.
|
|
112
|
+
*/
|
|
113
|
+
noConflict?(): Cookies.CookiesStatic;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default Cookies;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import t from "./assign.js";
|
|
2
|
+
import l from "./converter.js";
|
|
3
|
+
function p(f, s) {
|
|
4
|
+
function u(n, i, e) {
|
|
5
|
+
if (!(typeof document > "u")) {
|
|
6
|
+
e = t({}, s, e), typeof e.expires == "number" && (e.expires = new Date(Date.now() + e.expires * 864e5)), e.expires && (e.expires = e.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
7
|
+
var r = "";
|
|
8
|
+
for (var o in e)
|
|
9
|
+
e[o] && (r += "; " + o, e[o] !== !0 && (r += "=" + e[o].split(";")[0]));
|
|
10
|
+
return document.cookie = n + "=" + f.write(i, n) + r;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function d(n) {
|
|
14
|
+
if (!(typeof document > "u" || arguments.length && !n)) {
|
|
15
|
+
for (var i = document.cookie ? document.cookie.split("; ") : [], e = {}, r = 0; r < i.length; r++) {
|
|
16
|
+
var o = i[r].split("="), v = o.slice(1).join("=");
|
|
17
|
+
try {
|
|
18
|
+
var c = decodeURIComponent(o[0]);
|
|
19
|
+
if (c in e || (e[c] = f.read(v, c)), n === c)
|
|
20
|
+
break;
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return n ? e[n] : e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return Object.create(
|
|
28
|
+
{
|
|
29
|
+
set: u,
|
|
30
|
+
get: d,
|
|
31
|
+
remove: function(n, i) {
|
|
32
|
+
u(
|
|
33
|
+
n,
|
|
34
|
+
"",
|
|
35
|
+
t({}, i, {
|
|
36
|
+
expires: -1
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
withAttributes: function(n) {
|
|
41
|
+
return p(this.converter, t({}, this.attributes, n));
|
|
42
|
+
},
|
|
43
|
+
withConverter: function(n) {
|
|
44
|
+
return p(t({}, this.converter, n), this.attributes);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
attributes: { value: Object.freeze(s) },
|
|
49
|
+
converter: { value: Object.freeze(f) }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const x = p(l, { path: "/" });
|
|
54
|
+
export {
|
|
55
|
+
x as default
|
|
56
|
+
};
|