@unicom-cloud/utils 0.1.15 → 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.
Files changed (90) hide show
  1. package/class-name/index.js +5 -5
  2. package/constant/index.js +24 -2
  3. package/constant/platform.js +13 -12
  4. package/constant.js +24 -2
  5. package/content-disposition/index.js +3 -3
  6. package/date/convertTime.js +4 -4
  7. package/event-emitter/index.js +2 -4
  8. package/filesize/types/constants.d.ts +81 -0
  9. package/filesize/types/filesize.d.ts +97 -0
  10. package/index.js +66 -60
  11. package/js-cookie/index.d.ts +116 -0
  12. package/js-cookie/index.js +4 -0
  13. package/js-cookie/src/api.js +56 -0
  14. package/js-cookie/src/assign.js +11 -0
  15. package/js-cookie/src/converter.js +14 -0
  16. package/jsCookie.js +4 -0
  17. package/lunar/lib/Holiday.js +2 -6
  18. package/lunar/lib/HolidayUtil.js +113 -100
  19. package/lunar/lib/I18n.js +395 -975
  20. package/lunar/lib/JieQi.js +12 -16
  21. package/lunar/lib/Lunar.js +224 -672
  22. package/lunar/lib/LunarMonth.js +35 -98
  23. package/lunar/lib/LunarTime.js +24 -103
  24. package/lunar/lib/LunarUtil.js +426 -1728
  25. package/lunar/lib/LunarYear.js +473 -566
  26. package/lunar/lib/ShouXingUtil.js +6714 -6690
  27. package/lunar/lib/Solar.js +24 -49
  28. package/lunar/lib/SolarHalfYear.js +0 -2
  29. package/lunar/lib/SolarMonth.js +4 -6
  30. package/lunar/lib/SolarSeason.js +0 -2
  31. package/lunar/lib/SolarUtil.js +238 -226
  32. package/lunar/lib/SolarWeek.js +7 -11
  33. package/lunar/lib/SolarYear.js +0 -1
  34. package/nzh/nzh.d.ts +74 -0
  35. package/package.json +1 -1
  36. package/query-string/base.d.ts +717 -0
  37. package/query-string/base.js +268 -0
  38. package/query-string/index.d.ts +16 -0
  39. package/query-string/index.js +4 -0
  40. package/query-string/splitOnFirst.js +14 -0
  41. package/queryString.js +4 -0
  42. package/random/index.js +56 -35
  43. package/snapdom/src/api/preCache.js +51 -28
  44. package/snapdom/src/core/cache.js +1 -4
  45. package/snapdom/src/core/capture.js +45 -44
  46. package/snapdom/src/core/clone.js +82 -66
  47. package/snapdom/src/core/prepare.js +168 -46
  48. package/snapdom/src/modules/background.js +29 -19
  49. package/snapdom/src/modules/fonts.js +146 -91
  50. package/snapdom/src/modules/images.js +14 -9
  51. package/snapdom/src/modules/pseudo.js +55 -58
  52. package/snapdom/src/modules/styles.js +22 -22
  53. package/snapdom/src/modules/svgDefs.js +39 -20
  54. package/snapdom/src/utils/cssTools.js +58 -51
  55. package/snapdom/src/utils/helpers.js +197 -140
  56. package/snapdom/types/snapdom.d.ts +101 -0
  57. package/tinycolor/src/conversion.js +1 -1
  58. package/tinycolor/src/index.js +2 -19
  59. package/turbo-stream/src/encode.js +5 -8
  60. package/turbo-stream/src/shared.js +117 -119
  61. package/types/constant/index.d.ts +11 -0
  62. package/types/constant/platform.d.ts +1 -0
  63. package/types/index.d.ts +3 -0
  64. package/types/js-cookie/index.d.ts +1 -0
  65. package/types/js-cookie/src/api.d.mts +2 -0
  66. package/types/js-cookie/src/assign.d.mts +1 -0
  67. package/types/js-cookie/src/converter.d.mts +5 -0
  68. package/types/lunar/lib/Lunar.d.ts +0 -98
  69. package/types/lunar/lib/LunarMonth.d.ts +0 -12
  70. package/types/lunar/lib/LunarTime.d.ts +0 -22
  71. package/types/lunar/lib/LunarUtil.d.ts +0 -90
  72. package/types/lunar/lib/LunarYear.d.ts +0 -30
  73. package/types/lunar/lib/Solar.d.ts +0 -5
  74. package/types/query-string/base.d.ts +11 -0
  75. package/types/query-string/index.d.ts +2 -0
  76. package/types/query-string/splitOnFirst.d.ts +1 -0
  77. package/types/random/index.d.ts +14 -23
  78. package/types/snapdom/src/api/preCache.d.ts +2 -5
  79. package/types/snapdom/src/core/cache.d.ts +0 -3
  80. package/types/snapdom/src/core/clone.d.ts +1 -1
  81. package/types/snapdom/src/modules/background.d.ts +16 -6
  82. package/types/snapdom/src/modules/fonts.d.ts +5 -1
  83. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  84. package/types/snapdom/src/modules/styles.d.ts +1 -1
  85. package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
  86. package/types/snapdom/src/utils/cssTools.d.ts +2 -10
  87. package/types/snapdom/src/utils/helpers.d.ts +13 -7
  88. package/types/tinycolor/src/conversion.d.ts +1 -1
  89. package/types/turbo-stream/src/shared.d.ts +3 -3
  90. package/url-toolkit/src/url-toolkit.d.ts +22 -0
@@ -1,17 +1,13 @@
1
- import { HolidayUtil as H } from "./HolidayUtil.js";
2
- import { Lunar as x } from "./Lunar.js";
1
+ import { HolidayUtil as L } from "./HolidayUtil.js";
2
+ import { Lunar as H } from "./Lunar.js";
3
3
  import { LunarUtil as u } from "./LunarUtil.js";
4
- import { SolarMonth as p } from "./SolarMonth.js";
4
+ import { SolarMonth as k } from "./SolarMonth.js";
5
5
  import { SolarUtil as o } from "./SolarUtil.js";
6
6
  import { SolarWeek as W } from "./SolarWeek.js";
7
7
  class a {
8
- static J2000 = 2451545;
9
- _year;
10
- _month;
11
- _day;
12
- _hour;
13
- _minute;
14
- _second;
8
+ static {
9
+ this.J2000 = 2451545;
10
+ }
15
11
  static fromYmd(t, e, i) {
16
12
  return a.fromYmdHms(t, e, i, 0, 0, 0);
17
13
  }
@@ -41,8 +37,8 @@ class a {
41
37
  i -= h, i *= 60;
42
38
  let f = Math.floor(i);
43
39
  i -= f, i *= 60;
44
- let _ = Math.round(i);
45
- return _ > 59 && (_ -= 60, f++), f > 59 && (f -= 60, h++), h > 23 && (h -= 24, m += 1), a.fromYmdHms(n, s, m, h, f, _);
40
+ let l = Math.round(i);
41
+ return l > 59 && (l -= 60, f++), f > 59 && (f -= 60, h++), h > 23 && (h -= 24, m += 1), a.fromYmdHms(n, s, m, h, f, l);
46
42
  }
47
43
  static fromBaZi(t, e, i, r, n = 2, s = 1900) {
48
44
  n = n == 1 ? 1 : 2;
@@ -52,21 +48,21 @@ class a {
52
48
  return m;
53
49
  let f = u.getJiaZiIndex(t) - 57;
54
50
  f < 0 && (f += 60), f++, h *= 2;
55
- const _ = u.index(r.substring(1), u.ZHI, -1) * 2;
56
- let c = [_];
57
- _ == 0 && n == 2 && (c = [0, 23]);
58
- const E = s - 1, I = (/* @__PURE__ */ new Date()).getFullYear();
59
- for (; f <= I; ) {
60
- if (f >= E) {
61
- const d = x.fromYmd(f, 1, 1), L = d.getJieQiList();
62
- let g = d.getJieQiTable()[L[4 + h]];
51
+ const l = u.index(r.substring(1), u.ZHI, -1) * 2;
52
+ let d = [l];
53
+ l == 0 && n == 2 && (d = [0, 23]);
54
+ const x = s - 1, E = (/* @__PURE__ */ new Date()).getFullYear();
55
+ for (; f <= E; ) {
56
+ if (f >= x) {
57
+ const y = H.fromYmd(f, 1, 1), I = y.getJieQiList();
58
+ let g = y.getJieQiTable()[I[4 + h]];
63
59
  if (g.getYear() >= s) {
64
- let l = u.getJiaZiIndex(i) - u.getJiaZiIndex(
60
+ let _ = u.getJiaZiIndex(i) - u.getJiaZiIndex(
65
61
  g.getLunar().getDayInGanZhiExact2()
66
62
  );
67
- l < 0 && (l += 60), l > 0 && (g = g.next(l)), c.forEach((M) => {
63
+ _ < 0 && (_ += 60), _ > 0 && (g = g.next(_)), d.forEach((M) => {
68
64
  let Y = 0, w = 0;
69
- l == 0 && M === g.getHour() && (Y = g.getMinute(), w = g.getSecond());
65
+ _ == 0 && M === g.getHour() && (Y = g.getMinute(), w = g.getSecond());
70
66
  const D = a.fromYmdHms(
71
67
  g.getYear(),
72
68
  g.getMonth(),
@@ -74,8 +70,8 @@ class a {
74
70
  M,
75
71
  Y,
76
72
  w
77
- ), y = D.getLunar(), k = n === 2 ? y.getDayInGanZhiExact2() : y.getDayInGanZhiExact();
78
- y.getYearInGanZhiExact() === t && y.getMonthInGanZhiExact() === e && k === i && y.getTimeInGanZhi() === r && m.push(D);
73
+ ), c = D.getLunar(), p = n === 2 ? c.getDayInGanZhiExact2() : c.getDayInGanZhiExact();
74
+ c.getYearInGanZhiExact() === t && c.getMonthInGanZhiExact() === e && p === i && c.getTimeInGanZhi() === r && m.push(D);
79
75
  });
80
76
  }
81
77
  }
@@ -149,27 +145,6 @@ class a {
149
145
  const e = this._month * 100 + this._day;
150
146
  return e >= 321 && e <= 419 ? t = 0 : e >= 420 && e <= 520 ? t = 1 : e >= 521 && e <= 621 ? t = 2 : e >= 622 && e <= 722 ? t = 3 : e >= 723 && e <= 822 ? t = 4 : e >= 823 && e <= 922 ? t = 5 : e >= 923 && e <= 1023 ? t = 6 : e >= 1024 && e <= 1122 ? t = 7 : e >= 1123 && e <= 1221 ? t = 8 : e >= 1222 || e <= 119 ? t = 9 : e <= 218 && (t = 10), o.XINGZUO[t];
151
147
  }
152
- /**
153
- * 获取薪资比例(感谢 https://gitee.com/smr1987)
154
- * @returns 1 | 2 | 3 薪资比例
155
- */
156
- getSalaryRate() {
157
- if (this._month === 1 && this._day === 1 || this._month === 5 && this._day === 1 || this._month === 10 && this._day >= 1 && this._day <= 3)
158
- return 3;
159
- const t = this.getLunar();
160
- if (t.getMonth() === 1 && t.getDay() >= 1 && t.getDay() <= 3 || t.getMonth() === 5 && t.getDay() === 5 || t.getMonth() === 8 && t.getDay() === 15 || t.getJieQi() === "清明")
161
- return 3;
162
- const e = H.getHoliday(this._year, this._month, this._day);
163
- if (e) {
164
- if (!e.isWork())
165
- return 2;
166
- } else {
167
- const i = this.getWeek();
168
- if (i === 6 || i === 0)
169
- return 2;
170
- }
171
- return 1;
172
- }
173
148
  toYmd() {
174
149
  let t = this._year + "";
175
150
  for (; t.length < 4; )
@@ -202,7 +177,7 @@ class a {
202
177
  return e === 1582 && i === 10 ? r > 4 && r < 15 && (r += 10) : i === 2 && r > 28 && (o.isLeapYear(e) || (r = 28)), a.fromYmdHms(e, i, r, this._hour, this._minute, this._second);
203
178
  }
204
179
  nextMonth(t) {
205
- const e = p.fromYm(this._year, this._month).next(t), i = e.getYear(), r = e.getMonth();
180
+ const e = k.fromYm(this._year, this._month).next(t), i = e.getYear(), r = e.getMonth();
206
181
  let n = this._day;
207
182
  if (i === 1582 && r === 10)
208
183
  n > 4 && n < 15 && (n += 10);
@@ -242,7 +217,7 @@ class a {
242
217
  for (; r > 0; ) {
243
218
  i = i.next(n);
244
219
  let s = !0;
245
- const m = H.getHoliday(
220
+ const m = L.getHoliday(
246
221
  i.getYear(),
247
222
  i.getMonth(),
248
223
  i.getDay()
@@ -275,7 +250,7 @@ class a {
275
250
  );
276
251
  }
277
252
  getLunar() {
278
- return x.fromSolar(this);
253
+ return H.fromSolar(this);
279
254
  }
280
255
  getJulianDay() {
281
256
  let t = this._year, e = this._month;
@@ -1,7 +1,5 @@
1
1
  import { SolarMonth as o } from "./SolarMonth.js";
2
2
  class r {
3
- _year;
4
- _month;
5
3
  static fromYm(t, e) {
6
4
  return new r(t, e);
7
5
  }
@@ -1,9 +1,7 @@
1
1
  import { Solar as h } from "./Solar.js";
2
- import { SolarUtil as n } from "./SolarUtil.js";
3
- import { SolarWeek as i } from "./SolarWeek.js";
2
+ import { SolarUtil as i } from "./SolarUtil.js";
3
+ import { SolarWeek as n } from "./SolarWeek.js";
4
4
  class o {
5
- _year;
6
- _month;
7
5
  static fromYm(t, r) {
8
6
  return new o(t, r);
9
7
  }
@@ -27,14 +25,14 @@ class o {
27
25
  getDays() {
28
26
  const t = [], r = h.fromYmd(this._year, this._month, 1);
29
27
  t.push(r);
30
- const e = n.getDaysOfMonth(this._year, this._month);
28
+ const e = i.getDaysOfMonth(this._year, this._month);
31
29
  for (let s = 1; s < e; s++)
32
30
  t.push(r.next(s));
33
31
  return t;
34
32
  }
35
33
  getWeeks(t) {
36
34
  const r = [];
37
- let e = i.fromYmd(this._year, this._month, 1, t);
35
+ let e = n.fromYmd(this._year, this._month, 1, t);
38
36
  for (; ; ) {
39
37
  r.push(e), e = e.next(1, !1);
40
38
  const s = e.getFirstDay();
@@ -1,7 +1,5 @@
1
1
  import { SolarMonth as h } from "./SolarMonth.js";
2
2
  class r {
3
- _year;
4
- _month;
5
3
  static fromYm(t, e) {
6
4
  return new r(t, e);
7
5
  }