@unicom-cloud/utils 0.1.16 → 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 (63) 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/HolidayUtil.js +48 -49
  18. package/nzh/nzh.d.ts +74 -0
  19. package/package.json +1 -1
  20. package/query-string/base.d.ts +717 -0
  21. package/query-string/base.js +268 -0
  22. package/query-string/index.d.ts +16 -0
  23. package/query-string/index.js +4 -0
  24. package/query-string/splitOnFirst.js +14 -0
  25. package/queryString.js +4 -0
  26. package/random/index.js +56 -35
  27. package/snapdom/src/api/preCache.js +51 -28
  28. package/snapdom/src/core/cache.js +1 -4
  29. package/snapdom/src/core/capture.js +45 -44
  30. package/snapdom/src/core/clone.js +82 -66
  31. package/snapdom/src/core/prepare.js +167 -45
  32. package/snapdom/src/modules/background.js +29 -19
  33. package/snapdom/src/modules/fonts.js +158 -111
  34. package/snapdom/src/modules/images.js +14 -9
  35. package/snapdom/src/modules/pseudo.js +52 -47
  36. package/snapdom/src/modules/styles.js +22 -22
  37. package/snapdom/src/modules/svgDefs.js +39 -20
  38. package/snapdom/src/utils/cssTools.js +58 -51
  39. package/snapdom/src/utils/helpers.js +197 -140
  40. package/snapdom/types/snapdom.d.ts +101 -0
  41. package/types/constant/index.d.ts +11 -0
  42. package/types/constant/platform.d.ts +1 -0
  43. package/types/index.d.ts +3 -0
  44. package/types/js-cookie/index.d.ts +1 -0
  45. package/types/js-cookie/src/api.d.mts +2 -0
  46. package/types/js-cookie/src/assign.d.mts +1 -0
  47. package/types/js-cookie/src/converter.d.mts +5 -0
  48. package/types/query-string/base.d.ts +11 -0
  49. package/types/query-string/index.d.ts +2 -0
  50. package/types/query-string/splitOnFirst.d.ts +1 -0
  51. package/types/random/index.d.ts +14 -23
  52. package/types/snapdom/src/api/preCache.d.ts +2 -5
  53. package/types/snapdom/src/core/cache.d.ts +0 -3
  54. package/types/snapdom/src/core/clone.d.ts +1 -1
  55. package/types/snapdom/src/modules/background.d.ts +16 -6
  56. package/types/snapdom/src/modules/fonts.d.ts +5 -1
  57. package/types/snapdom/src/modules/pseudo.d.ts +1 -1
  58. package/types/snapdom/src/modules/styles.d.ts +1 -1
  59. package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
  60. package/types/snapdom/src/utils/cssTools.d.ts +2 -10
  61. package/types/snapdom/src/utils/helpers.d.ts +13 -7
  62. package/types/turbo-stream/src/shared.d.ts +3 -3
  63. package/url-toolkit/src/url-toolkit.d.ts +22 -0
@@ -0,0 +1,14 @@
1
+ const n = {
2
+ read: function(e) {
3
+ return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
4
+ },
5
+ write: function(e) {
6
+ return encodeURIComponent(e).replace(
7
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
8
+ decodeURIComponent
9
+ );
10
+ }
11
+ };
12
+ export {
13
+ n as default
14
+ };
package/jsCookie.js ADDED
@@ -0,0 +1,4 @@
1
+ import { default as o } from "./js-cookie/src/api.js";
2
+ export {
3
+ o as default
4
+ };
@@ -35,85 +35,84 @@ class s {
35
35
  return (n < 10 ? "0" : "") + n;
36
36
  }
37
37
  static _findForward(n) {
38
- const t = s._DATA_IN_USE.indexOf(n);
39
- if (t < 0)
38
+ const e = s._DATA_IN_USE.indexOf(n);
39
+ if (e < 0)
40
40
  return null;
41
- let e = s._DATA_IN_USE.substring(t);
42
- const r = e.length % s._SIZE;
43
- for (r > 0 && (e = e.substring(r)); e.indexOf(n) !== 0 && e.length >= s._SIZE; )
44
- e = e.substring(s._SIZE);
45
- return e;
41
+ let t = s._DATA_IN_USE.substring(e);
42
+ const r = t.length % s._SIZE;
43
+ for (r > 0 && (t = t.substring(r)); t.indexOf(n) !== 0 && t.length >= s._SIZE; )
44
+ t = t.substring(s._SIZE);
45
+ return t;
46
46
  }
47
47
  static _findBackward(n) {
48
- const t = s._DATA_IN_USE.lastIndexOf(n);
49
- if (t < 0)
48
+ const e = s._DATA_IN_USE.lastIndexOf(n);
49
+ if (e < 0)
50
50
  return null;
51
- const e = n.length;
52
- let r = s._DATA_IN_USE.substring(0, t + e), c = r.length;
51
+ const t = n.length;
52
+ let r = s._DATA_IN_USE.substring(0, e + t), c = r.length;
53
53
  const g = c % s._SIZE;
54
- for (g > 0 && (r = r.substring(0, c - g)), c = r.length; c - e !== r.lastIndexOf(n) && c >= s._SIZE; )
54
+ for (g > 0 && (r = r.substring(0, c - g)), c = r.length; c - t !== r.lastIndexOf(n) && c >= s._SIZE; )
55
55
  r = r.substring(0, c - s._SIZE), c = r.length;
56
56
  return r;
57
57
  }
58
58
  static _buildHolidayForward(n) {
59
- const t = n.substring(0, 8), e = s._NAMES_IN_USE[n.charCodeAt(8) - s._ZERO], r = n.charCodeAt(9) === s._ZERO, c = n.substring(10, 18);
60
- return new E(t, e, r, c);
59
+ const e = n.substring(0, 8), t = s._NAMES_IN_USE[n.charCodeAt(8) - s._ZERO], r = n.charCodeAt(9) === s._ZERO, c = n.substring(10, 18);
60
+ return new E(e, t, r, c);
61
61
  }
62
62
  static _buildHolidayBackward(n) {
63
- const t = n.length, e = n.substring(t - 18, t - 10), r = s._NAMES_IN_USE[n.charCodeAt(t - 10) - s._ZERO], c = n.charCodeAt(t - 9) === s._ZERO, g = n.substring(t - 8);
64
- return new E(e, r, c, g);
63
+ const e = n.length, t = n.substring(e - 18, e - 10), r = s._NAMES_IN_USE[n.charCodeAt(e - 10) - s._ZERO], c = n.charCodeAt(e - 9) === s._ZERO, g = n.substring(e - 8);
64
+ return new E(t, r, c, g);
65
65
  }
66
66
  static _findHolidaysForward(n) {
67
- const t = [];
68
- let e = s._findForward(n);
69
- if (e == null)
70
- return t;
71
- for (; e.indexOf(n) === 0; )
72
- t.push(s._buildHolidayForward(e)), e = e.substring(s._SIZE);
73
- return t;
67
+ const e = [];
68
+ let t = s._findForward(n);
69
+ if (t == null)
70
+ return e;
71
+ for (; t.indexOf(n) === 0; )
72
+ e.push(s._buildHolidayForward(t)), t = t.substring(s._SIZE);
73
+ return e;
74
74
  }
75
75
  static _findHolidaysBackward(n) {
76
- const t = [];
77
- let e = s._findBackward(n);
78
- if (e == null)
79
- return t;
80
- let r = e.length;
76
+ const e = [];
77
+ let t = s._findBackward(n);
78
+ if (t == null)
79
+ return e;
80
+ let r = t.length;
81
81
  const c = n.length;
82
- for (; r - c === e.lastIndexOf(n); )
83
- t.push(s._buildHolidayBackward(e)), e = e.substring(0, r - s._SIZE), r = e.length;
84
- return t.reverse(), t;
82
+ for (; r - c === t.lastIndexOf(n); )
83
+ e.push(s._buildHolidayBackward(t)), t = t.substring(0, r - s._SIZE), r = t.length;
84
+ return e.reverse(), e;
85
85
  }
86
- static getHoliday(n, t = 0, e = 0) {
86
+ static getHoliday(n, e = 0, t = 0) {
87
87
  let r;
88
- return t == 0 || e == 0 ? r = s._findHolidaysForward((n + "").replace(/-/g, "")) : r = s._findHolidaysForward(
89
- n + s._padding(t) + s._padding(e)
88
+ return e == 0 || t == 0 ? r = s._findHolidaysForward((n + "").replace(/-/g, "")) : r = s._findHolidaysForward(
89
+ n + s._padding(e) + s._padding(t)
90
90
  ), r.length < 1 ? null : r[0];
91
91
  }
92
- static getHolidays(n, t = 0) {
93
- return t == 0 ? s._findHolidaysForward(
92
+ static getHolidays(n, e = 0) {
93
+ return e == 0 ? s._findHolidaysForward(
94
94
  (n + "").replace(/-/g, "")
95
95
  ) : s._findHolidaysForward(
96
- n + s._padding(t)
96
+ n + s._padding(e)
97
97
  );
98
98
  }
99
- static getHolidaysByTarget(n, t = 0) {
100
- return t == 0 ? s._findHolidaysBackward(
99
+ static getHolidaysByTarget(n, e = 0) {
100
+ return e == 0 ? s._findHolidaysBackward(
101
101
  (n + "").replace(/-/g, "")
102
102
  ) : s._findHolidaysBackward(
103
- n + s._padding(t)
103
+ n + s._padding(e)
104
104
  );
105
105
  }
106
106
  static _fixNames(n) {
107
107
  n && (s._NAMES_IN_USE = n);
108
108
  }
109
109
  static _fixData(n) {
110
- if (!n)
111
- return;
112
- const t = [];
110
+ if (!n) return;
111
+ const e = [];
113
112
  for (; n.length >= s._SIZE; ) {
114
- const e = n.substring(0, s._SIZE), r = e.substring(0, 8), c = s._TAG_REMOVE == e.substring(8, 9), g = s.getHoliday(r);
113
+ const t = n.substring(0, s._SIZE), r = t.substring(0, 8), c = s._TAG_REMOVE == t.substring(8, 9), g = s.getHoliday(r);
115
114
  if (!g)
116
- c || t.push(e);
115
+ c || e.push(t);
117
116
  else {
118
117
  let u = -1;
119
118
  for (let f = 0, a = s._NAMES_IN_USE.length; f < a; f++)
@@ -125,16 +124,16 @@ class s {
125
124
  const f = r + String.fromCharCode(u + s._ZERO) + (g.isWork() ? "0" : "1") + g.getTarget().replace(/-/g, "");
126
125
  s._DATA_IN_USE = s._DATA_IN_USE.replace(
127
126
  new RegExp(f, "g"),
128
- c ? "" : e
127
+ c ? "" : t
129
128
  );
130
129
  }
131
130
  }
132
131
  n = n.substring(s._SIZE);
133
132
  }
134
- t.length > 0 && (s._DATA_IN_USE += t.join(""));
133
+ e.length > 0 && (s._DATA_IN_USE += e.join(""));
135
134
  }
136
- static fix(n, t) {
137
- t ? (s._fixNames(n), s._fixData(t)) : s._fixData(n);
135
+ static fix(n, e) {
136
+ e ? (s._fixNames(n), s._fixData(e)) : s._fixData(n);
138
137
  }
139
138
  }
140
139
  export {
package/nzh/nzh.d.ts ADDED
@@ -0,0 +1,74 @@
1
+ interface Options {
2
+ /*
3
+ * 十的口语化开关, 默认值为 false
4
+ * 注:Nzh.cn和Nzh.hk中的encodeS方法默认 true
5
+ * */
6
+ tenMin?: boolean;
7
+ /**
8
+ * "万万"化开关, 默认值为 true
9
+ * */
10
+ ww?: boolean;
11
+ }
12
+ interface ToMoneyOptions extends Options {
13
+ /**
14
+ * 输出完整金额开关, toMoney 函数专用配置, 默认 false
15
+ * */
16
+ complete?: boolean;
17
+ /*
18
+ * 输出金额前缀字符, toMoney 函数专用配置, 默认 true
19
+ * */
20
+ outSymbol?: boolean;
21
+ /*
22
+ * 个位为0时不省略元,toMoney 函数专用配置, 默认 false
23
+ * */
24
+ unOmitYuan?: boolean;
25
+ /**
26
+ * 不以源数据加整,以输出结果加“整”(只要输出的结果没有到分位就加“整”)
27
+ */
28
+ forceZheng?: boolean;
29
+ }
30
+ interface Lang {
31
+ ch: string;
32
+ ch_u: string;
33
+ ch_f: string;
34
+ ch_d: string;
35
+ m_t: string;
36
+ m_z: string;
37
+ m_u: string;
38
+ }
39
+ interface Langs {
40
+ s: Lang;
41
+ b: Lang;
42
+ hk_s: Lang;
43
+ hk_b: Lang;
44
+ }
45
+ interface BuiltIn {
46
+ encodeS(num: number | string, options?: Options): string;
47
+ encodeB(num: number | string, options?: Options): string;
48
+ decodeS(zhnum: string, options?: Options): string;
49
+ decodeB(zhnum: string, options?: Options): string;
50
+ toMoney(num: number | string, options?: ToMoneyOptions): string;
51
+ }
52
+
53
+ declare module 'nzh' {
54
+ export default class Nzh {
55
+ constructor(lang: Lang);
56
+ public encode(num: number | string, options?: Options): string;
57
+ public decode(zhnum: string, options?: Options): string;
58
+ public toMoney(num: number | string, options?: ToMoneyOptions): string;
59
+
60
+ static cn: BuiltIn;
61
+ static hk: BuiltIn;
62
+ static langs: Langs;
63
+ }
64
+ }
65
+
66
+ declare module 'nzh/cn' {
67
+ const nzhcn: BuiltIn;
68
+ export default nzhcn;
69
+ }
70
+
71
+ declare module 'nzh/hk' {
72
+ const nzhhk: BuiltIn;
73
+ export default nzhhk;
74
+ }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@unicom-cloud/utils","version":"0.1.16","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
1
+ {"name":"@unicom-cloud/utils","version":"0.1.17","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}