@unicom-cloud/utils 0.1.14 → 0.1.16

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 (40) hide show
  1. package/content-disposition/index.js +34 -31
  2. package/contentDisposition.js +7 -5
  3. package/file/saveAs.js +13 -14
  4. package/lunar/lib/Holiday.js +2 -6
  5. package/lunar/lib/HolidayUtil.js +113 -99
  6. package/lunar/lib/I18n.js +395 -975
  7. package/lunar/lib/JieQi.js +12 -16
  8. package/lunar/lib/Lunar.js +224 -672
  9. package/lunar/lib/LunarMonth.js +35 -98
  10. package/lunar/lib/LunarTime.js +24 -103
  11. package/lunar/lib/LunarUtil.js +426 -1728
  12. package/lunar/lib/LunarYear.js +473 -566
  13. package/lunar/lib/ShouXingUtil.js +6714 -6690
  14. package/lunar/lib/Solar.js +24 -49
  15. package/lunar/lib/SolarHalfYear.js +0 -2
  16. package/lunar/lib/SolarMonth.js +4 -6
  17. package/lunar/lib/SolarSeason.js +0 -2
  18. package/lunar/lib/SolarUtil.js +238 -226
  19. package/lunar/lib/SolarWeek.js +7 -11
  20. package/lunar/lib/SolarYear.js +0 -1
  21. package/mock/MockWebSocket.js +2 -2
  22. package/package.json +1 -1
  23. package/snapdom/src/api/snapdom.js +72 -71
  24. package/snapdom/src/core/prepare.js +21 -21
  25. package/snapdom/src/modules/background.js +23 -17
  26. package/snapdom/src/modules/fonts.js +99 -91
  27. package/snapdom/src/modules/pseudo.js +59 -70
  28. package/tinycolor/src/conversion.js +1 -1
  29. package/tinycolor/src/index.js +2 -19
  30. package/turbo-stream/src/encode.js +5 -8
  31. package/turbo-stream/src/shared.js +117 -119
  32. package/types/file/saveAs.d.ts +1 -1
  33. package/types/lunar/lib/Lunar.d.ts +0 -98
  34. package/types/lunar/lib/LunarMonth.d.ts +0 -12
  35. package/types/lunar/lib/LunarTime.d.ts +0 -22
  36. package/types/lunar/lib/LunarUtil.d.ts +0 -90
  37. package/types/lunar/lib/LunarYear.d.ts +0 -30
  38. package/types/lunar/lib/Solar.d.ts +0 -5
  39. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  40. package/types/tinycolor/src/conversion.d.ts +1 -1
@@ -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
  }