@unicom-cloud/utils 0.1.4 → 0.1.10

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.
@@ -1,24 +1,24 @@
1
- const e = {
1
+ const o = {
2
2
  key: "Enter",
3
3
  code: "Enter",
4
4
  keyCode: 13
5
- }, o = {
5
+ }, e = {
6
6
  key: "Escape",
7
7
  code: "Escape",
8
8
  keyCode: 27
9
- }, t = {
9
+ }, t = e, c = {
10
10
  key: "Backspace",
11
11
  code: "Backspace",
12
12
  keyCode: 8
13
- }, c = {
13
+ }, k = {
14
14
  key: "Tab",
15
15
  code: "Tab",
16
16
  keyCode: 9
17
- }, k = {
17
+ }, y = {
18
18
  key: " ",
19
19
  code: "Space",
20
20
  keyCode: 32
21
- }, y = {
21
+ }, n = {
22
22
  key: "ArrowLeft",
23
23
  code: "ArrowLeft",
24
24
  keyCode: 37
@@ -26,80 +26,81 @@ const e = {
26
26
  key: "ArrowUp",
27
27
  code: "ArrowUp",
28
28
  keyCode: 38
29
- }, n = {
29
+ }, r = {
30
30
  key: "ArrowRight",
31
31
  code: "ArrowRight",
32
32
  keyCode: 39
33
- }, r = {
33
+ }, s = {
34
34
  key: "ArrowDown",
35
35
  code: "ArrowDown",
36
36
  keyCode: 40
37
- }, s = {
37
+ }, C = {
38
38
  key: "CapsLock",
39
39
  code: "CapsLock",
40
40
  keyCode: 20
41
- }, C = {
42
- key: "Meta"
43
41
  }, a = {
42
+ key: "Meta"
43
+ }, A = {
44
44
  key: "Meta",
45
45
  code: "MetaLeft",
46
46
  keyCode: 91
47
- }, A = {
47
+ }, f = {
48
48
  key: "Meta",
49
49
  code: "MetaRight",
50
50
  keyCode: 93
51
- }, f = {
52
- key: "Control"
53
51
  }, h = {
52
+ key: "Control"
53
+ }, i = {
54
54
  key: "Control",
55
55
  code: "ControlLeft",
56
56
  keyCode: 17
57
- }, i = {
57
+ }, l = {
58
58
  key: "Control",
59
59
  code: "ControlRight",
60
60
  keyCode: 17
61
- }, l = {
61
+ }, p = {
62
62
  key: "Alt"
63
63
  }, w = {
64
64
  key: "Alt",
65
65
  code: "AltLeft",
66
66
  keyCode: 18
67
- }, p = {
67
+ }, L = {
68
68
  key: "Alt",
69
69
  code: "AltRight",
70
70
  keyCode: 18
71
- }, L = {
72
- key: "Shift"
73
71
  }, g = {
72
+ key: "Shift"
73
+ }, R = {
74
74
  key: "Shift",
75
75
  code: "ShiftLeft",
76
76
  keyCode: 16
77
- }, R = {
77
+ }, S = {
78
78
  key: "Shift",
79
79
  code: "ShiftRight",
80
80
  keyCode: 16
81
81
  };
82
82
  export {
83
- l as Alt,
83
+ p as Alt,
84
84
  w as AltLeft,
85
- p as AltRight,
86
- r as ArrowDown,
87
- y as ArrowLeft,
88
- n as ArrowRight,
85
+ L as AltRight,
86
+ s as ArrowDown,
87
+ n as ArrowLeft,
88
+ r as ArrowRight,
89
89
  d as ArrowUp,
90
- t as Backspace,
91
- s as CapsLock,
92
- f as Control,
93
- h as ControlLeft,
94
- i as ControlRight,
95
- e as Enter,
96
- o as Esc,
97
- C as Meta,
98
- a as MetaLeft,
99
- A as MetaRight,
100
- L as Shift,
101
- g as ShiftLeft,
102
- R as ShiftRight,
103
- k as Space,
104
- c as Tab
90
+ c as Backspace,
91
+ C as CapsLock,
92
+ h as Control,
93
+ i as ControlLeft,
94
+ l as ControlRight,
95
+ o as Enter,
96
+ e as Esc,
97
+ t as Escape,
98
+ a as Meta,
99
+ A as MetaLeft,
100
+ f as MetaRight,
101
+ g as Shift,
102
+ R as ShiftLeft,
103
+ S as ShiftRight,
104
+ y as Space,
105
+ k as Tab
105
106
  };
@@ -1,20 +1,18 @@
1
- const i = navigator.userAgent.toLowerCase();
2
- var n;
3
- const e = window.__wxjs_environment === "miniprogram" || !!((n = window.wx) != null && n.getSystemInfoSync), a = /micromessenger/i.test(i), r = /dingtalk/i.test(i), w = /alipay|aliapp/i.test(i), s = /ipad|iphone|ipod/i.test(i), t = /android/i.test(i), c = /openharmony/i.test(i), d = /macintosh|mac os x/i.test(i), m = /windows|win32|win64|wow64/i.test(
1
+ const i = navigator.userAgent.toLowerCase(), t = window.__wxjs_environment === "miniprogram" || !!window.wx?.getSystemInfoSync, e = /micromessenger/i.test(i), a = /dingtalk/i.test(i), r = /alipay|aliapp/i.test(i), o = /ipad|iphone|ipod/i.test(i), s = /android/i.test(i), w = /openharmony/i.test(i), c = /macintosh|mac os x/i.test(i), d = /windows|win32|win64|wow64/i.test(
4
2
  i
5
- ), l = (s || t || /windows phone|blackberry|mobile|webos|iemobile|opera (mini|mobi)/i.test(
3
+ ), m = (o || s || /windows phone|blackberry|mobile|webos|iemobile|opera (mini|mobi)/i.test(
6
4
  i
7
- )) && ("ontouchend" in document || "ontouchend" in window), p = ["fullscreen", "standalone", "minimal-ui"].some((o) => window.matchMedia(`(display-mode: ${o})`).matches) || window.navigator.standalone === !0;
5
+ )) && ("ontouchend" in document || "ontouchend" in window), l = ["fullscreen", "standalone", "minimal-ui"].some((n) => window.matchMedia(`(display-mode: ${n})`).matches) || window.navigator.standalone === !0;
8
6
  export {
9
- w as isAlipayBrowser,
10
- t as isAndroidOS,
11
- r as isDingtalkBrowser,
12
- c as isHarmony,
13
- s as isIOS_OS,
14
- d as isMacOS,
15
- l as isMobileDevice,
16
- p as isPWA,
17
- a as isWeChatBrowser,
18
- e as isWeChatMiniProgram,
19
- m as isWindowsOS
7
+ r as isAlipayBrowser,
8
+ s as isAndroidOS,
9
+ a as isDingtalkBrowser,
10
+ w as isHarmony,
11
+ o as isIOS_OS,
12
+ c as isMacOS,
13
+ m as isMobileDevice,
14
+ l as isPWA,
15
+ e as isWeChatBrowser,
16
+ t as isWeChatMiniProgram,
17
+ d as isWindowsOS
20
18
  };
@@ -0,0 +1,56 @@
1
+ function m(t) {
2
+ if (!t) return null;
3
+ const e = {
4
+ type: "",
5
+ parameters: {}
6
+ }, o = t.match(/^([^;]+)/);
7
+ o && (e.type = o[1].trim());
8
+ const s = t.matchAll(
9
+ /;\s*([^=]+)=(?:"([^"]*)"|([^;]*))/g
10
+ );
11
+ for (const r of s) {
12
+ const n = r[1].trim().toLowerCase(), i = r[2] || r[3];
13
+ if (n.endsWith("*")) {
14
+ const a = p(i);
15
+ e.parameters[n] = a;
16
+ const c = n.slice(0, -1);
17
+ e.parameters[c] || (e.parameters[c] = a);
18
+ } else e.parameters[n] || (e.parameters[n] = i);
19
+ }
20
+ return e;
21
+ }
22
+ function p(t) {
23
+ const e = t.match(/^([^']*)'[^']*'(.*)$/);
24
+ if (!e) return t;
25
+ const [o, s, r] = e;
26
+ try {
27
+ const n = r.replace(
28
+ /%([0-9A-Fa-f]{2})/g,
29
+ (i, a) => String.fromCharCode(parseInt(a, 16))
30
+ );
31
+ return s && s.toLowerCase() !== "utf-8", n;
32
+ } catch (n) {
33
+ return console.warn("Failed to decode RFC 5987 value:", t, n), t;
34
+ }
35
+ }
36
+ function f(t) {
37
+ let e = t?.["content-disposition"];
38
+ if (e)
39
+ return m(e);
40
+ }
41
+ function d(t) {
42
+ const e = f(t);
43
+ if (e)
44
+ return e.parameters;
45
+ }
46
+ function l(t) {
47
+ const e = d(t);
48
+ if (e)
49
+ return e["filename*"] || e.filename;
50
+ }
51
+ export {
52
+ m as default,
53
+ f as getContentDispositionFromHeader,
54
+ l as getContentDispositionParametersFilenameFromHeader,
55
+ d as getContentDispositionParametersFromHeader
56
+ };
@@ -1,83 +1,83 @@
1
- const w = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, g = /^[\u0021-\u003A\u003C-\u007E]*$/, S = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, E = /^[\u0020-\u003A\u003D-\u007E]*$/, v = Object.prototype.toString, b = /* @__PURE__ */ (() => {
2
- const r = function() {
1
+ const w = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, g = /^[\u0021-\u003A\u003C-\u007E]*$/, p = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, S = /^[\u0020-\u003A\u003D-\u007E]*$/, E = Object.prototype.toString, v = /* @__PURE__ */ (() => {
2
+ const t = function() {
3
3
  };
4
- return r.prototype = /* @__PURE__ */ Object.create(null), r;
4
+ return t.prototype = /* @__PURE__ */ Object.create(null), t;
5
5
  })();
6
- function k(r, i) {
7
- const e = new b(), a = r.length;
6
+ function k(t, i) {
7
+ const e = new v(), a = t.length;
8
8
  if (a < 2) return e;
9
- const c = (i == null ? void 0 : i.decode) || p;
10
- let t = 0;
9
+ const c = i?.decode || b;
10
+ let r = 0;
11
11
  do {
12
- const n = r.indexOf("=", t);
12
+ const n = t.indexOf("=", r);
13
13
  if (n === -1) break;
14
- const d = r.indexOf(";", t), u = d === -1 ? a : d;
15
- if (n > u) {
16
- t = r.lastIndexOf(";", n - 1) + 1;
14
+ const u = t.indexOf(";", r), o = u === -1 ? a : u;
15
+ if (n > o) {
16
+ r = t.lastIndexOf(";", n - 1) + 1;
17
17
  continue;
18
18
  }
19
- const o = m(r, t, n), h = x(r, n, o), l = r.slice(o, h);
19
+ const d = s(t, r, n), x = m(t, n, d), l = t.slice(d, x);
20
20
  if (e[l] === void 0) {
21
- const f = m(r, n + 1, u), y = x(r, u, f), s = c(r.slice(f, y));
22
- e[l] = s;
21
+ const f = s(t, n + 1, o), h = m(t, o, f), y = c(t.slice(f, h));
22
+ e[l] = y;
23
23
  }
24
- t = u + 1;
25
- } while (t < a);
24
+ r = o + 1;
25
+ } while (r < a);
26
26
  return e;
27
27
  }
28
- function m(r, i, e) {
28
+ function s(t, i, e) {
29
29
  do {
30
- const a = r.charCodeAt(i);
30
+ const a = t.charCodeAt(i);
31
31
  if (a !== 32 && a !== 9) return i;
32
32
  } while (++i < e);
33
33
  return e;
34
34
  }
35
- function x(r, i, e) {
35
+ function m(t, i, e) {
36
36
  for (; i > e; ) {
37
- const a = r.charCodeAt(--i);
37
+ const a = t.charCodeAt(--i);
38
38
  if (a !== 32 && a !== 9) return i + 1;
39
39
  }
40
40
  return e;
41
41
  }
42
- function $(r, i, e) {
43
- const a = (e == null ? void 0 : e.encode) || encodeURIComponent;
44
- if (!w.test(r))
45
- throw new TypeError(`argument name is invalid: ${r}`);
42
+ function $(t, i, e) {
43
+ const a = e?.encode || encodeURIComponent;
44
+ if (!w.test(t))
45
+ throw new TypeError(`argument name is invalid: ${t}`);
46
46
  const c = a(i);
47
47
  if (!g.test(c))
48
48
  throw new TypeError(`argument val is invalid: ${i}`);
49
- let t = r + "=" + c;
50
- if (!e) return t;
49
+ let r = t + "=" + c;
50
+ if (!e) return r;
51
51
  if (e.maxAge !== void 0) {
52
52
  if (!Number.isInteger(e.maxAge))
53
53
  throw new TypeError(`option maxAge is invalid: ${e.maxAge}`);
54
- t += "; Max-Age=" + e.maxAge;
54
+ r += "; Max-Age=" + e.maxAge;
55
55
  }
56
56
  if (e.domain) {
57
- if (!S.test(e.domain))
57
+ if (!p.test(e.domain))
58
58
  throw new TypeError(`option domain is invalid: ${e.domain}`);
59
- t += "; Domain=" + e.domain;
59
+ r += "; Domain=" + e.domain;
60
60
  }
61
61
  if (e.path) {
62
- if (!E.test(e.path))
62
+ if (!S.test(e.path))
63
63
  throw new TypeError(`option path is invalid: ${e.path}`);
64
- t += "; Path=" + e.path;
64
+ r += "; Path=" + e.path;
65
65
  }
66
66
  if (e.expires) {
67
67
  if (!I(e.expires) || !Number.isFinite(e.expires.valueOf()))
68
68
  throw new TypeError(`option expires is invalid: ${e.expires}`);
69
- t += "; Expires=" + e.expires.toUTCString();
69
+ r += "; Expires=" + e.expires.toUTCString();
70
70
  }
71
- if (e.httpOnly && (t += "; HttpOnly"), e.secure && (t += "; Secure"), e.partitioned && (t += "; Partitioned"), e.priority)
71
+ if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.partitioned && (r += "; Partitioned"), e.priority)
72
72
  switch (typeof e.priority == "string" ? e.priority.toLowerCase() : void 0) {
73
73
  case "low":
74
- t += "; Priority=Low";
74
+ r += "; Priority=Low";
75
75
  break;
76
76
  case "medium":
77
- t += "; Priority=Medium";
77
+ r += "; Priority=Medium";
78
78
  break;
79
79
  case "high":
80
- t += "; Priority=High";
80
+ r += "; Priority=High";
81
81
  break;
82
82
  default:
83
83
  throw new TypeError(`option priority is invalid: ${e.priority}`);
@@ -86,29 +86,29 @@ function $(r, i, e) {
86
86
  switch (typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite) {
87
87
  case !0:
88
88
  case "strict":
89
- t += "; SameSite=Strict";
89
+ r += "; SameSite=Strict";
90
90
  break;
91
91
  case "lax":
92
- t += "; SameSite=Lax";
92
+ r += "; SameSite=Lax";
93
93
  break;
94
94
  case "none":
95
- t += "; SameSite=None";
95
+ r += "; SameSite=None";
96
96
  break;
97
97
  default:
98
98
  throw new TypeError(`option sameSite is invalid: ${e.sameSite}`);
99
99
  }
100
- return t;
100
+ return r;
101
101
  }
102
- function p(r) {
103
- if (r.indexOf("%") === -1) return r;
102
+ function b(t) {
103
+ if (t.indexOf("%") === -1) return t;
104
104
  try {
105
- return decodeURIComponent(r);
105
+ return decodeURIComponent(t);
106
106
  } catch {
107
- return r;
107
+ return t;
108
108
  }
109
109
  }
110
- function I(r) {
111
- return v.call(r) === "[object Date]";
110
+ function I(t) {
111
+ return E.call(t) === "[object Date]";
112
112
  }
113
113
  export {
114
114
  k as parse,
package/dayjs/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import a from "dayjs";
2
+ function s(e, n) {
3
+ let t = a.duration(e, n || "minutes");
4
+ return [
5
+ { value: t.years(), unit: "年" },
6
+ { value: t.months(), unit: "个月" },
7
+ { value: t.days(), unit: "天" },
8
+ { value: t.hours(), unit: "小时" },
9
+ { value: t.minutes(), unit: "分钟" },
10
+ { value: t.seconds(), unit: "秒" }
11
+ ].filter((u) => u.value > 0).map((u, o, r) => Math.floor(u.value) + u.unit).join("");
12
+ }
13
+ export {
14
+ s as convertToDurationBasedOnTimeUnits
15
+ };