@unicom-cloud/utils 0.1.5 → 0.1.11

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.
Files changed (135) hide show
  1. package/caseName.js +11 -0
  2. package/className.js +5 -0
  3. package/clipboardCopy.js +6 -0
  4. package/constant.js +4 -0
  5. package/content-disposition/index.js +56 -0
  6. package/contentDisposition.js +7 -0
  7. package/convert-time/index.js +61 -0
  8. package/convertTime.js +4 -0
  9. package/cookie.js +7 -0
  10. package/dayjs.js +5 -0
  11. package/decimal.js +5 -0
  12. package/eventEmitter.js +4 -0
  13. package/file.js +6 -0
  14. package/filesize.js +8 -0
  15. package/index.js +44 -31
  16. package/invariant.js +4 -0
  17. package/is.js +92 -0
  18. package/lunar-converter/index.js +641 -0
  19. package/lunarConverter.js +4 -0
  20. package/math.js +9 -0
  21. package/md5.js +4 -0
  22. package/mock.js +8 -0
  23. package/normalizeWheel.js +6 -0
  24. package/number-to-chinese/index.js +72 -0
  25. package/numberToChinese.js +4 -0
  26. package/nzh.js +4 -0
  27. package/object-keys-sort/index.js +7 -0
  28. package/objectKeysSort.js +2 -5
  29. package/package.json +1 -1
  30. package/random.js +15 -0
  31. package/screenfull.js +4 -0
  32. package/search-tree/index.js +54 -0
  33. package/searchTree.js +4 -0
  34. package/snapdom/src/api/preCache.js +31 -27
  35. package/snapdom/src/core/capture.js +55 -44
  36. package/snapdom/src/core/clone.js +11 -11
  37. package/snapdom/src/core/prepare.js +38 -31
  38. package/snapdom/src/modules/background.js +18 -43
  39. package/snapdom/src/modules/pseudo.js +66 -67
  40. package/snapdom/src/utils/helpers.js +105 -56
  41. package/snapdom.js +6 -0
  42. package/tree.js +11 -0
  43. package/turboStream.js +6 -0
  44. package/types/case-name/index.d.ts +11 -0
  45. package/types/class-name/index.d.ts +2 -0
  46. package/types/clipboard-copy/index.d.ts +2 -0
  47. package/types/constant/address.d.ts +14 -0
  48. package/types/constant/chineseCharacters.d.ts +2 -0
  49. package/types/constant/constellations.d.ts +2 -0
  50. package/types/constant/domain.d.ts +2 -0
  51. package/types/constant/identity.d.ts +2 -0
  52. package/types/constant/index.d.ts +1 -0
  53. package/types/constant/keyboardCode.d.ts +158 -0
  54. package/types/constant/licensePlate.d.ts +2 -0
  55. package/types/constant/name.d.ts +4 -0
  56. package/types/constant/platform.d.ts +11 -0
  57. package/types/constant/protocol.d.ts +2 -0
  58. package/types/constant/ui.d.ts +14 -0
  59. package/types/content-disposition/index.d.ts +10 -0
  60. package/types/convert-time/index.d.ts +32 -0
  61. package/types/cookie/index.d.ts +4 -0
  62. package/types/cookie/src/index.d.ts +114 -0
  63. package/types/dayjs/index.d.ts +1 -0
  64. package/types/decimal/decimal.d.ts +4 -0
  65. package/types/decimal/index.d.ts +1 -0
  66. package/types/event-emitter/index.d.ts +17 -0
  67. package/types/file/fileToURL.d.ts +2 -0
  68. package/types/file/index.d.ts +3 -0
  69. package/types/file/saveAs.d.ts +2 -0
  70. package/types/filesize/index.d.ts +2 -0
  71. package/types/filesize/src/constants.d.ts +42 -0
  72. package/types/filesize/src/filesize.d.ts +47 -0
  73. package/types/index.d.ts +24 -0
  74. package/types/invariant/index.d.ts +2 -0
  75. package/types/is/index.d.ts +53 -0
  76. package/types/lunar-converter/index.d.ts +113 -0
  77. package/types/math/index.d.ts +11 -0
  78. package/types/md5/index.d.ts +2 -0
  79. package/types/mock/MockWebSocket.d.ts +17 -0
  80. package/types/mock/MockXMLHttpRequest.d.ts +17 -0
  81. package/types/mock/index.d.ts +2 -0
  82. package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
  83. package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
  84. package/types/normalize-wheel/index.d.ts +115 -0
  85. package/types/normalize-wheel/isEventSupported.d.ts +16 -0
  86. package/types/number-to-chinese/index.d.ts +11 -0
  87. package/types/nzh/cn.d.ts +8 -0
  88. package/types/nzh/hk.d.ts +8 -0
  89. package/types/nzh/index.d.ts +1 -0
  90. package/types/nzh/nzh.d.ts +36 -0
  91. package/types/nzh/src/autoGet.d.ts +8 -0
  92. package/types/nzh/src/index.d.ts +34 -0
  93. package/types/nzh/src/langs/cn_b.d.ts +10 -0
  94. package/types/nzh/src/langs/cn_s.d.ts +7 -0
  95. package/types/nzh/src/langs/hk_b.d.ts +10 -0
  96. package/types/nzh/src/langs/hk_s.d.ts +7 -0
  97. package/types/nzh/src/utils.d.ts +65 -0
  98. package/types/object-keys-sort/index.d.ts +4 -0
  99. package/types/random/address.d.ts +8 -0
  100. package/types/random/constellation.d.ts +2 -0
  101. package/types/random/image.d.ts +5 -0
  102. package/types/random/index.d.ts +40 -0
  103. package/types/random/licensePlate.d.ts +2 -0
  104. package/types/random/name.d.ts +9 -0
  105. package/types/random/number.d.ts +6 -0
  106. package/types/random/text.d.ts +13 -0
  107. package/types/random/time.d.ts +2 -0
  108. package/types/random/web.d.ts +11 -0
  109. package/types/screenfull/index.d.ts +10 -0
  110. package/types/search-tree/index.d.ts +20 -0
  111. package/types/snapdom/index.d.ts +1 -0
  112. package/types/snapdom/src/api/preCache.d.ts +8 -0
  113. package/types/snapdom/src/api/snapdom.d.ts +26 -0
  114. package/types/snapdom/src/core/cache.d.ts +11 -0
  115. package/types/snapdom/src/core/capture.d.ts +17 -0
  116. package/types/snapdom/src/core/clone.d.ts +11 -0
  117. package/types/snapdom/src/core/prepare.d.ts +8 -0
  118. package/types/snapdom/src/index.browser.d.ts +1 -0
  119. package/types/snapdom/src/index.d.ts +2 -0
  120. package/types/snapdom/src/modules/background.d.ts +10 -0
  121. package/types/snapdom/src/modules/fonts.d.ts +25 -0
  122. package/types/snapdom/src/modules/images.d.ts +8 -0
  123. package/types/snapdom/src/modules/pseudo.d.ts +12 -0
  124. package/types/snapdom/src/modules/styles.d.ts +10 -0
  125. package/types/snapdom/src/utils/cssTools.d.ts +38 -0
  126. package/types/snapdom/src/utils/helpers.d.ts +71 -0
  127. package/types/tree/index.d.ts +8 -0
  128. package/types/turbo-stream/index.d.ts +1 -0
  129. package/types/turbo-stream/src/decode.d.ts +7 -0
  130. package/types/turbo-stream/src/encode.d.ts +27 -0
  131. package/types/turbo-stream/src/shared.d.ts +107 -0
  132. package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
  133. package/types/url-toolkit/index.d.ts +2 -0
  134. package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
  135. package/urlToolkit.js +8 -0
package/caseName.js ADDED
@@ -0,0 +1,11 @@
1
+ import "lodash/camelCase";
2
+ import "lodash/capitalize";
3
+ import "lodash/kebabCase";
4
+ import "lodash/lowerFirst";
5
+ import "lodash/snakeCase";
6
+ import "lodash/startCase";
7
+ import "lodash/upperFirst";
8
+ import { default as d } from "./case-name/index.js";
9
+ export {
10
+ d as default
11
+ };
package/className.js ADDED
@@ -0,0 +1,5 @@
1
+ import "lodash/isPlainObject";
2
+ import { default as e } from "./class-name/index.js";
3
+ export {
4
+ e as default
5
+ };
@@ -0,0 +1,6 @@
1
+ import "./is/index.js";
2
+ import "lodash/isString";
3
+ import { default as p } from "./clipboard-copy/index.js";
4
+ export {
5
+ p as default
6
+ };
package/constant.js ADDED
@@ -0,0 +1,4 @@
1
+ import { MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK as R } from "./constant/index.js";
2
+ export {
3
+ R as MATCH_MEDIA_PREFERS_COLOR_SCHEME_DARK
4
+ };
@@ -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
+ };
@@ -0,0 +1,7 @@
1
+ import { default as o, getContentDispositionFromHeader as r, getContentDispositionParametersFilenameFromHeader as i, getContentDispositionParametersFromHeader as n } from "./content-disposition/index.js";
2
+ export {
3
+ o as default,
4
+ r as getContentDispositionFromHeader,
5
+ i as getContentDispositionParametersFilenameFromHeader,
6
+ n as getContentDispositionParametersFromHeader
7
+ };
@@ -0,0 +1,61 @@
1
+ const f = {
2
+ millisecond: 1e-3,
3
+ // 1毫秒 = 0.001秒
4
+ second: 1,
5
+ // 1秒 = 1秒
6
+ minute: 60,
7
+ // 1分钟 = 60秒
8
+ hour: 3600,
9
+ // 1小时 = 3600秒
10
+ day: 86400,
11
+ // 1天 = 86400秒
12
+ week: 604800
13
+ // 1周 = 604800秒
14
+ }, r = [
15
+ { name: "年", seconds: 365 * 24 * 60 * 60, max: 1 / 0 },
16
+ // 年没有上限
17
+ { name: "个月", seconds: 30 * 24 * 60 * 60, max: 12 },
18
+ // 月份最大12
19
+ { name: "周", seconds: 7 * 24 * 60 * 60, max: 4 },
20
+ // 周最大4(约1个月)
21
+ { name: "天", seconds: 24 * 60 * 60, max: 7 },
22
+ // 日最大7(1周)
23
+ { name: "小时", seconds: 60 * 60, max: 24 },
24
+ // 小时最大24
25
+ { name: "分钟", seconds: 60, max: 60 },
26
+ // 分钟最大60
27
+ { name: "秒", seconds: 1, max: 60 }
28
+ // 秒最大60
29
+ ];
30
+ function h(a) {
31
+ return a.max !== void 0;
32
+ }
33
+ function x(a, i = {}) {
34
+ const {
35
+ inputUnit: m = "second",
36
+ units: o = r,
37
+ maxUnitCount: c = 1 / 0,
38
+ keepZero: d = !1
39
+ } = i, l = f[m] || 1;
40
+ let e = Math.abs(a) * l;
41
+ const s = [];
42
+ for (const n of o) {
43
+ if (e <= 0 || s.length >= c) break;
44
+ let t = 0;
45
+ if (!h(n))
46
+ t = Math.floor(e / n.seconds), e %= n.seconds;
47
+ else {
48
+ const u = Math.floor(e / n.seconds);
49
+ t = Math.min(u, n.max - 1), e -= t * n.seconds;
50
+ }
51
+ (t !== 0 || d) && s.push(`${t}${n.name}`);
52
+ }
53
+ if (e > 0 && s.length < c) {
54
+ const n = o[o.length - 1];
55
+ s.push(`0${n.name}`);
56
+ }
57
+ return s.length > 0 ? s.join(" ") : `0${o[o.length - 1].name}`;
58
+ }
59
+ export {
60
+ x as default
61
+ };
package/convertTime.js ADDED
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./convert-time/index.js";
2
+ export {
3
+ o as default
4
+ };
package/cookie.js ADDED
@@ -0,0 +1,7 @@
1
+ import * as o from "./cookie/src/index.js";
2
+ import { splitCookiesString as t } from "./cookie/index.js";
3
+ export {
4
+ o as cookie,
5
+ o as default,
6
+ t as splitCookiesString
7
+ };
package/dayjs.js ADDED
@@ -0,0 +1,5 @@
1
+ import "dayjs";
2
+ import { convertToDurationBasedOnTimeUnits as e } from "./dayjs/index.js";
3
+ export {
4
+ e as convertToDurationBasedOnTimeUnits
5
+ };
package/decimal.js ADDED
@@ -0,0 +1,5 @@
1
+ import { Decimal as f, default as l } from "./decimal/decimal.js";
2
+ export {
3
+ f as Decimal,
4
+ l as default
5
+ };
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./event-emitter/index.js";
2
+ export {
3
+ o as default
4
+ };
package/file.js ADDED
@@ -0,0 +1,6 @@
1
+ import { fileToURL as r } from "./file/fileToURL.js";
2
+ import { saveAs as m } from "./file/saveAs.js";
3
+ export {
4
+ r as fileToURL,
5
+ m as saveAs
6
+ };
package/filesize.js ADDED
@@ -0,0 +1,8 @@
1
+ import * as s from "./filesize/src/constants.js";
2
+ import { filesize as a, filesize as i, partial as o } from "./filesize/src/filesize.js";
3
+ export {
4
+ a as default,
5
+ i as filesize,
6
+ s as filesizeConstants,
7
+ o as partial
8
+ };
package/index.js CHANGED
@@ -1,46 +1,59 @@
1
- import * as o from "./is/index.js";
2
- import * as e from "./math/index.js";
1
+ import * as e from "./is/index.js";
2
+ import * as o from "./math/index.js";
3
3
  import * as r from "./tree/index.js";
4
4
  import * as t from "./turbo-stream/index.js";
5
5
  import * as a from "./url-toolkit/index.js";
6
6
  import { default as p } from "./case-name/index.js";
7
7
  import { default as l } from "./class-name/index.js";
8
- import { default as n } from "./clipboard-copy/index.js";
9
- import { splitCookiesString as c } from "./cookie/index.js";
10
- import { default as b } from "./decimal/decimal.js";
11
- import { default as k } from "./event-emitter/index.js";
12
- import { fileToURL as S } from "./file/fileToURL.js";
13
- import { saveAs as C } from "./file/saveAs.js";
8
+ import { default as d } from "./clipboard-copy/index.js";
9
+ import { default as c, getContentDispositionFromHeader as C, getContentDispositionParametersFilenameFromHeader as h, getContentDispositionParametersFromHeader as T } from "./content-disposition/index.js";
10
+ import { default as v } from "./convert-time/index.js";
11
+ import { splitCookiesString as g } from "./cookie/index.js";
12
+ import { default as z } from "./decimal/decimal.js";
13
+ import { default as F } from "./event-emitter/index.js";
14
+ import { fileToURL as H } from "./file/fileToURL.js";
15
+ import { saveAs as L } from "./file/saveAs.js";
14
16
  import * as s from "./filesize/src/constants.js";
15
- import { filesize as y, partial as N } from "./filesize/src/filesize.js";
16
- import { default as j } from "./invariant/index.js";
17
- import { default as E } from "./md5/index.js";
18
- import { default as L } from "./normalize-wheel/index.js";
19
- import { default as U } from "./nzh/nzh.js";
20
- import { default as q } from "./objectKeysSort.js";
21
- import { default as B } from "./screenfull/index.js";
17
+ import { filesize as P, partial as j } from "./filesize/src/filesize.js";
18
+ import { default as E } from "./invariant/index.js";
19
+ import { default as R } from "./lunar-converter/index.js";
20
+ import { default as W } from "./md5/index.js";
21
+ import { default as w } from "./normalize-wheel/index.js";
22
+ import { default as G } from "./number-to-chinese/index.js";
23
+ import { default as J } from "./nzh/nzh.js";
24
+ import { default as O } from "./object-keys-sort/index.js";
25
+ import { default as V } from "./screenfull/index.js";
26
+ import { default as Y } from "./search-tree/index.js";
22
27
  import * as m from "./cookie/src/index.js";
23
28
  export {
29
+ R as LunarConverter,
24
30
  p as caseName,
25
31
  l as className,
26
- n as clipboardCopy,
32
+ d as clipboardCopy,
33
+ c as contentDisposition,
34
+ v as convertTime,
27
35
  m as cookie,
28
- b as decimal,
29
- k as eventEmitter,
30
- S as fileToURL,
31
- y as filesize,
36
+ z as decimal,
37
+ F as eventEmitter,
38
+ H as fileToURL,
39
+ P as filesize,
32
40
  s as filesizeConstants,
33
- j as invariant,
34
- o as is,
35
- e as math,
36
- E as md5,
37
- L as normalizeWheel,
38
- U as nzh,
39
- q as objectKeysSort,
40
- N as partial,
41
- C as saveAs,
42
- B as screenfull,
43
- c as splitCookiesString,
41
+ C as getContentDispositionFromHeader,
42
+ h as getContentDispositionParametersFilenameFromHeader,
43
+ T as getContentDispositionParametersFromHeader,
44
+ E as invariant,
45
+ e as is,
46
+ o as math,
47
+ W as md5,
48
+ w as normalizeWheel,
49
+ G as numberToChinese,
50
+ J as nzh,
51
+ O as objectKeysSort,
52
+ j as partial,
53
+ L as saveAs,
54
+ V as screenfull,
55
+ Y as searchTree,
56
+ g as splitCookiesString,
44
57
  r as tree,
45
58
  t as turboStream,
46
59
  a as urlToolkit
package/invariant.js ADDED
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./invariant/index.js";
2
+ export {
3
+ o as default
4
+ };
package/is.js ADDED
@@ -0,0 +1,92 @@
1
+ import { default as t } from "lodash/isArguments";
2
+ import { default as o } from "lodash/isArray";
3
+ import { default as f } from "lodash/isArrayBuffer";
4
+ import { default as l } from "lodash/isArrayLike";
5
+ import { default as m } from "lodash/isArrayLikeObject";
6
+ import { default as d } from "lodash/isBoolean";
7
+ import { default as n } from "lodash/isBuffer";
8
+ import { default as y } from "lodash/isDate";
9
+ import { default as c } from "lodash/isElement";
10
+ import { default as A } from "lodash/isEmpty";
11
+ import { default as g } from "lodash/isEqual";
12
+ import { default as R } from "lodash/isEqualWith";
13
+ import { default as j } from "lodash/isError";
14
+ import { default as B } from "lodash/isFinite";
15
+ import { default as L } from "lodash/isFunction";
16
+ import { default as W } from "lodash/isInteger";
17
+ import { default as I } from "lodash/isLength";
18
+ import { default as D } from "lodash/isMap";
19
+ import { default as V } from "lodash/isMatch";
20
+ import { default as J } from "lodash/isMatchWith";
21
+ import { default as U } from "lodash/isNaN";
22
+ import { default as z } from "lodash/isNative";
23
+ import { default as H } from "lodash/isNil";
24
+ import { default as Q } from "lodash/isNull";
25
+ import { default as Y } from "lodash/isNumber";
26
+ import { default as _ } from "lodash/isObject";
27
+ import { default as ee } from "lodash/isObjectLike";
28
+ import { default as te } from "lodash/isPlainObject";
29
+ import { default as oe } from "lodash/isRegExp";
30
+ import { default as fe } from "lodash/isSafeInteger";
31
+ import { default as le } from "lodash/isSet";
32
+ import { default as me } from "lodash/isString";
33
+ import { default as de } from "lodash/isSymbol";
34
+ import { default as ne } from "lodash/isTypedArray";
35
+ import { default as ye } from "lodash/isUndefined";
36
+ import { default as ce } from "lodash/isWeakMap";
37
+ import { default as Ae } from "lodash/isWeakSet";
38
+ import { isBlob as ge, isColor as Oe, isColor2 as Re, isEmptyArray as he, isEmptyObject as je, isEmptyValue as ke, isFile as Be, isJSON as Ce, isPromise as Le, isReadableByteStreamControllerSupported as Me, isReadableStream as We, isReadableStreamDefaultControllerSupported as Fe, isReadableStreamSupported as Ie, isReadableStreamSymbolAsyncIteratorSupported as qe, isValidColor as De } from "./is/index.js";
39
+ export {
40
+ t as isArguments,
41
+ o as isArray,
42
+ f as isArrayBuffer,
43
+ l as isArrayLike,
44
+ m as isArrayLikeObject,
45
+ ge as isBlob,
46
+ d as isBoolean,
47
+ n as isBuffer,
48
+ Oe as isColor,
49
+ Re as isColor2,
50
+ y as isDate,
51
+ c as isElement,
52
+ A as isEmpty,
53
+ he as isEmptyArray,
54
+ je as isEmptyObject,
55
+ ke as isEmptyValue,
56
+ g as isEqual,
57
+ R as isEqualWith,
58
+ j as isError,
59
+ Be as isFile,
60
+ B as isFinite,
61
+ L as isFunction,
62
+ W as isInteger,
63
+ Ce as isJSON,
64
+ I as isLength,
65
+ D as isMap,
66
+ V as isMatch,
67
+ J as isMatchWith,
68
+ U as isNaN,
69
+ z as isNative,
70
+ H as isNil,
71
+ Q as isNull,
72
+ Y as isNumber,
73
+ _ as isObject,
74
+ ee as isObjectLike,
75
+ te as isPlainObject,
76
+ Le as isPromise,
77
+ Me as isReadableByteStreamControllerSupported,
78
+ We as isReadableStream,
79
+ Fe as isReadableStreamDefaultControllerSupported,
80
+ Ie as isReadableStreamSupported,
81
+ qe as isReadableStreamSymbolAsyncIteratorSupported,
82
+ oe as isRegExp,
83
+ fe as isSafeInteger,
84
+ le as isSet,
85
+ me as isString,
86
+ de as isSymbol,
87
+ ne as isTypedArray,
88
+ ye as isUndefined,
89
+ De as isValidColor,
90
+ ce as isWeakMap,
91
+ Ae as isWeakSet
92
+ };