@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,18 +1,11 @@
1
- import { LunarUtil as e } from "./LunarUtil.js";
2
- import { LunarYear as _ } from "./LunarYear.js";
3
- import { Solar as O } from "./Solar.js";
4
- class m {
5
- _year;
6
- _month;
7
- _dayCount;
8
- _firstJulianDay;
9
- _index;
10
- _zhiIndex;
11
- static fromYm(t, i) {
12
- return _.fromYear(t).getMonth(i);
1
+ import { LunarUtil as m } from "./LunarUtil.js";
2
+ import { LunarYear as f } from "./LunarYear.js";
3
+ class l {
4
+ static fromYm(n, t) {
5
+ return f.fromYear(n).getMonth(t);
13
6
  }
14
- constructor(t, i, s, h, o) {
15
- this._year = t, this._month = i, this._dayCount = s, this._firstJulianDay = h, this._index = o, this._zhiIndex = (o - 1 + e.BASE_MONTH_ZHI_INDEX) % 12;
7
+ constructor(n, t, i, a, h) {
8
+ this._year = n, this._month = t, this._dayCount = i, this._firstJulianDay = a, this._index = h, this._zhiIndex = (h - 1 + m.BASE_MONTH_ZHI_INDEX) % 12;
16
9
  }
17
10
  getYear() {
18
11
  return this._year;
@@ -24,17 +17,17 @@ class m {
24
17
  return this._index;
25
18
  }
26
19
  getGanIndex() {
27
- const t = (_.fromYear(this._year).getGanIndex() + 1) % 5 * 2;
28
- return (this._index - 1 + t) % 10;
20
+ const n = (f.fromYear(this._year).getGanIndex() + 1) % 5 * 2;
21
+ return (this._index - 1 + n) % 10;
29
22
  }
30
23
  getZhiIndex() {
31
24
  return this._zhiIndex;
32
25
  }
33
26
  getGan() {
34
- return e.GAN[this.getGanIndex() + 1];
27
+ return m.GAN[this.getGanIndex() + 1];
35
28
  }
36
29
  getZhi() {
37
- return e.ZHI[this._zhiIndex + 1];
30
+ return m.ZHI[this._zhiIndex + 1];
38
31
  }
39
32
  getGanZhi() {
40
33
  return this.getGan() + this.getZhi();
@@ -48,103 +41,47 @@ class m {
48
41
  getFirstJulianDay() {
49
42
  return this._firstJulianDay;
50
43
  }
51
- getPositionXi() {
52
- return e.POSITION_XI[this.getGanIndex() + 1];
53
- }
54
- getPositionXiDesc() {
55
- return e.POSITION_DESC[this.getPositionXi()];
56
- }
57
- getPositionYangGui() {
58
- return e.POSITION_YANG_GUI[this.getGanIndex() + 1];
59
- }
60
- getPositionYangGuiDesc() {
61
- return e.POSITION_DESC[this.getPositionYangGui()];
62
- }
63
- getPositionYinGui() {
64
- return e.POSITION_YIN_GUI[this.getGanIndex() + 1];
65
- }
66
- getPositionYinGuiDesc() {
67
- return e.POSITION_DESC[this.getPositionYinGui()];
68
- }
69
- getPositionFu(t = 2) {
70
- return (t == 1 ? e.POSITION_FU : e.POSITION_FU_2)[this.getGanIndex() + 1];
71
- }
72
- getPositionFuDesc(t = 2) {
73
- return e.POSITION_DESC[this.getPositionFu(t)];
74
- }
75
- getPositionCai() {
76
- return e.POSITION_CAI[this.getGanIndex() + 1];
77
- }
78
- getPositionCaiDesc() {
79
- return e.POSITION_DESC[this.getPositionCai()];
80
- }
81
- getPositionTaiSui() {
82
- let t;
83
- switch (Math.abs(this._month)) {
84
- case 1:
85
- case 5:
86
- case 9:
87
- t = "艮";
88
- break;
89
- case 3:
90
- case 7:
91
- case 11:
92
- t = "坤";
93
- break;
94
- case 4:
95
- case 8:
96
- case 12:
97
- t = "巽";
98
- break;
99
- default:
100
- t = e.POSITION_GAN[O.fromJulianDay(this.getFirstJulianDay()).getLunar().getMonthGanIndex()];
101
- }
102
- return t;
103
- }
104
- getPositionTaiSuiDesc() {
105
- return e.POSITION_DESC[this.getPositionTaiSui()];
106
- }
107
44
  toString() {
108
- return `${this.getYear()}年${this.isLeap() ? "闰" : ""}${e.MONTH[Math.abs(this.getMonth())]}月(${this.getDayCount()})天`;
45
+ return `${this.getYear()}年${this.isLeap() ? "闰" : ""}${m.MONTH[Math.abs(this.getMonth())]}月(${this.getDayCount()})天`;
109
46
  }
110
- next(t) {
111
- if (t == 0)
112
- return m.fromYm(this._year, this._month);
47
+ next(n) {
48
+ if (n == 0)
49
+ return l.fromYm(this._year, this._month);
113
50
  {
114
- let i = Math.abs(t), s = this._year, h = s, o = this._month, a = 0, n = _.fromYear(s).getMonths(), r, g, u;
115
- if (t > 0) {
51
+ let t = Math.abs(n), i = this._year, a = i, h = this._month, s = 0, e = f.fromYear(i).getMonths(), r, o, g;
52
+ if (n > 0) {
116
53
  for (; ; ) {
117
- for (u = n.length, r = 0; r < u; r++)
118
- if (g = n[r], g.getYear() === h && g.getMonth() === o) {
119
- a = r;
54
+ for (g = e.length, r = 0; r < g; r++)
55
+ if (o = e[r], o.getYear() === a && o.getMonth() === h) {
56
+ s = r;
120
57
  break;
121
58
  }
122
- const I = u - a - 1;
123
- if (i < I)
59
+ const u = g - s - 1;
60
+ if (t < u)
124
61
  break;
125
- i -= I;
126
- const P = n[u - 1];
127
- h = P.getYear(), o = P.getMonth(), s++, n = _.fromYear(s).getMonths();
62
+ t -= u;
63
+ const _ = e[g - 1];
64
+ a = _.getYear(), h = _.getMonth(), i++, e = f.fromYear(i).getMonths();
128
65
  }
129
- return n[a + i];
66
+ return e[s + t];
130
67
  } else {
131
68
  for (; ; ) {
132
- for (u = n.length, r = 0; r < u; r++)
133
- if (g = n[r], g.getYear() === h && g.getMonth() === o) {
134
- a = r;
69
+ for (g = e.length, r = 0; r < g; r++)
70
+ if (o = e[r], o.getYear() === a && o.getMonth() === h) {
71
+ s = r;
135
72
  break;
136
73
  }
137
- if (i <= a)
74
+ if (t <= s)
138
75
  break;
139
- i -= a;
140
- const I = n[0];
141
- h = I.getYear(), o = I.getMonth(), s--, n = _.fromYear(s).getMonths();
76
+ t -= s;
77
+ const u = e[0];
78
+ a = u.getYear(), h = u.getMonth(), i--, e = f.fromYear(i).getMonths();
142
79
  }
143
- return n[a - i];
80
+ return e[s - t];
144
81
  }
145
82
  }
146
83
  }
147
84
  }
148
85
  export {
149
- m as LunarMonth
86
+ l as LunarMonth
150
87
  };
@@ -1,22 +1,19 @@
1
- import { Lunar as a } from "./Lunar.js";
2
- import { LunarUtil as t } from "./LunarUtil.js";
3
- class s {
4
- _ganIndex;
5
- _zhiIndex;
6
- _lunar;
7
- static fromYmdHms(n, e, i, r, g, h) {
8
- return new s(n, e, i, r, g, h);
9
- }
10
- constructor(n, e, i, r, g, h) {
11
- this._lunar = a.fromYmdHms(
12
- n,
13
- e,
1
+ import { Lunar as s } from "./Lunar.js";
2
+ import { LunarUtil as e } from "./LunarUtil.js";
3
+ class a {
4
+ static fromYmdHms(t, i, h, n, r, g) {
5
+ return new a(t, i, h, n, r, g);
6
+ }
7
+ constructor(t, i, h, n, r, g) {
8
+ this._lunar = s.fromYmdHms(
9
+ t,
14
10
  i,
11
+ h,
12
+ n,
15
13
  r,
16
- g,
17
- h
18
- ), this._zhiIndex = t.getTimeZhiIndex(
19
- [(r < 10 ? "0" : "") + r, (g < 10 ? "0" : "") + g].join(
14
+ g
15
+ ), this._zhiIndex = e.getTimeZhiIndex(
16
+ [(n < 10 ? "0" : "") + n, (r < 10 ? "0" : "") + r].join(
20
17
  ":"
21
18
  )
22
19
  ), this._ganIndex = (this._lunar.getDayGanIndexExact() % 5 * 2 + this._zhiIndex) % 10;
@@ -28,111 +25,35 @@ class s {
28
25
  return this._zhiIndex;
29
26
  }
30
27
  getGan() {
31
- return t.GAN[this._ganIndex + 1];
28
+ return e.GAN[this._ganIndex + 1];
32
29
  }
33
30
  getZhi() {
34
- return t.ZHI[this._zhiIndex + 1];
31
+ return e.ZHI[this._zhiIndex + 1];
35
32
  }
36
33
  getGanZhi() {
37
34
  return this.getGan() + this.getZhi();
38
35
  }
39
36
  getShengXiao() {
40
- return t.SHENGXIAO[this._zhiIndex + 1];
41
- }
42
- getPositionXi() {
43
- return t.POSITION_XI[this._ganIndex + 1];
44
- }
45
- getPositionXiDesc() {
46
- return t.POSITION_DESC[this.getPositionXi()];
47
- }
48
- getPositionYangGui() {
49
- return t.POSITION_YANG_GUI[this._ganIndex + 1];
50
- }
51
- getPositionYangGuiDesc() {
52
- return t.POSITION_DESC[this.getPositionYangGui()];
53
- }
54
- getPositionYinGui() {
55
- return t.POSITION_YIN_GUI[this._ganIndex + 1];
56
- }
57
- getPositionYinGuiDesc() {
58
- return t.POSITION_DESC[this.getPositionYinGui()];
59
- }
60
- getPositionFu(n = 2) {
61
- return (n === 1 ? t.POSITION_FU : t.POSITION_FU_2)[this._ganIndex + 1];
62
- }
63
- getPositionFuDesc(n = 2) {
64
- return t.POSITION_DESC[this.getPositionFu(n)];
65
- }
66
- getPositionCai() {
67
- return t.POSITION_CAI[this._ganIndex + 1];
68
- }
69
- getPositionCaiDesc() {
70
- return t.POSITION_DESC[this.getPositionCai()];
71
- }
72
- getNaYin() {
73
- return t.NAYIN[this.getGanZhi()];
74
- }
75
- getTianShen() {
76
- return t.TIAN_SHEN[(this._zhiIndex + t.ZHI_TIAN_SHEN_OFFSET[this._lunar.getDayZhiExact()]) % 12 + 1];
77
- }
78
- getTianShenType() {
79
- return t.TIAN_SHEN_TYPE[this.getTianShen()];
80
- }
81
- getTianShenLuck() {
82
- return t.TIAN_SHEN_TYPE_LUCK[this.getTianShenType()];
83
- }
84
- getChong() {
85
- return t.CHONG[this._zhiIndex];
86
- }
87
- getSha() {
88
- return t.SHA[this.getZhi()];
89
- }
90
- getChongShengXiao() {
91
- const n = this.getChong();
92
- for (let e = 0, i = t.ZHI.length; e < i; e++)
93
- if (t.ZHI[e] === n)
94
- return t.SHENGXIAO[e];
95
- return "";
96
- }
97
- getChongDesc() {
98
- return "(" + this.getChongGan() + this.getChong() + ")" + this.getChongShengXiao();
37
+ return e.SHENGXIAO[this._zhiIndex + 1];
99
38
  }
100
39
  getChongGan() {
101
- return t.CHONG_GAN[this._ganIndex];
40
+ return e.CHONG_GAN[this._ganIndex];
102
41
  }
103
42
  getChongGanTie() {
104
- return t.CHONG_GAN_TIE[this._ganIndex];
105
- }
106
- getYi() {
107
- return t.getTimeYi(
108
- this._lunar.getDayInGanZhiExact(),
109
- this.getGanZhi()
110
- );
111
- }
112
- getJi() {
113
- return t.getTimeJi(
114
- this._lunar.getDayInGanZhiExact(),
115
- this.getGanZhi()
116
- );
117
- }
118
- getXun() {
119
- return t.getXun(this.getGanZhi());
120
- }
121
- getXunKong() {
122
- return t.getXunKong(this.getGanZhi());
43
+ return e.CHONG_GAN_TIE[this._ganIndex];
123
44
  }
124
45
  getMinHm() {
125
- let n = this._lunar.getHour();
126
- return n < 1 ? "00:00" : n > 22 ? "23:00" : (n % 2 === 0 && (n -= 1), (n < 10 ? "0" : "") + n + ":00");
46
+ let t = this._lunar.getHour();
47
+ return t < 1 ? "00:00" : t > 22 ? "23:00" : (t % 2 === 0 && (t -= 1), (t < 10 ? "0" : "") + t + ":00");
127
48
  }
128
49
  getMaxHm() {
129
- let n = this._lunar.getHour();
130
- return n < 1 ? "00:59" : n > 22 ? "23:59" : (n % 2 !== 0 && (n += 1), (n < 10 ? "0" : "") + n + ":59");
50
+ let t = this._lunar.getHour();
51
+ return t < 1 ? "00:59" : t > 22 ? "23:59" : (t % 2 !== 0 && (t += 1), (t < 10 ? "0" : "") + t + ":59");
131
52
  }
132
53
  toString() {
133
54
  return this.getGanZhi();
134
55
  }
135
56
  }
136
57
  export {
137
- s as LunarTime
58
+ a as LunarTime
138
59
  };