magtool 1.0.3 → 1.0.5

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 (2) hide show
  1. package/dist/util.js +120 -77
  2. package/package.json +14 -14
package/dist/util.js CHANGED
@@ -1,134 +1,177 @@
1
- const E = (i) => {
2
- const u = (e) => new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
3
- i.config.globalProperties.$getImg = u, window.$getImg = u;
4
- const $ = (e, n = 0) => {
5
- let t = parseInt(Math.random() * e);
6
- return t += n, t;
1
+ const M = (i) => {
2
+ const b = (e, t = 0) => {
3
+ let o = parseInt(Math.random() * e);
4
+ return o += t, o;
7
5
  };
8
- window.$rn = $;
9
- const g = (e, n) => {
10
- let t = [];
11
- for (let o = 0; o < e; o++)
12
- t.push(n(o));
13
- return t;
6
+ window.$rn = b;
7
+ const $ = (e, t) => {
8
+ let o = [];
9
+ for (let r = 0; r < e; r++)
10
+ o.push(t(r));
11
+ return o;
14
12
  };
15
- window.$fd = g, i.config.globalProperties.$setTimeout = function(e = () => {
16
- }, n) {
13
+ window.$fd = $, i.config.globalProperties.$setTimeout = function(e = () => {
14
+ }, t) {
17
15
  this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
18
16
  e(), clearTimeout(this.timer);
19
- }, n);
17
+ }, t);
20
18
  };
21
- const b = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
22
- window.$toUpperCamel = b;
23
- const c = (e, n = 2) => {
24
- const t = window.$getType(e);
25
- let o;
26
- t === "Number" ? (e = e.toFixed(n), o = String(e), e = String(Math.abs(e))) : t === "String" && (o = e, e = String(Math.abs(Number(e))));
27
- const r = e.split(".");
28
- let a = r[0].split("");
19
+ const y = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
20
+ window.$toUpperCamel = y;
21
+ const f = (e, t = 2) => {
22
+ const o = window.$getType(e);
23
+ let r;
24
+ o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
25
+ const n = e.split(".");
26
+ let a = n[0].split("");
29
27
  a = a.reverse();
30
28
  let l = [];
31
29
  a.forEach((N, m) => {
32
30
  m !== 0 && m % 3 === 0 && l.push(","), l.push(N);
33
31
  });
34
- let s = l.reverse().join("");
35
- return window.$getType(n) === "Number" && n > 0 && (s += ".", r[1] ? s += r[1].padEnd(n, 0).substr(0, n) : s += "0".padEnd(n, "0")), Number(o) !== Number(e) ? `-${s}` : s;
32
+ let c = l.reverse().join("");
33
+ return window.$getType(t) === "Number" && t > 0 && (c += ".", n[1] ? c += n[1].padEnd(t, 0).substr(0, t) : c += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${c}` : c;
36
34
  };
37
- window.$fa = c, i.config.globalProperties.$fa = c;
38
- const p = ({
35
+ window.$fa = f, i.config.globalProperties.$fa = f;
36
+ const u = ({
39
37
  prop: e,
40
- currency: n,
41
- value: t,
42
- obj: o = window.$map.asa.asaMetric.allObj
38
+ currency: t,
39
+ value: o,
40
+ obj: r = window.$map.asa.asaMetric.allObj
43
41
  }) => {
44
- const r = o[e];
45
- return r.unit === "currency" ? n ? `${n} ${window.$fa(t, r == null ? void 0 : r.precision)}` : window.$fa(t, r == null ? void 0 : r.precision) : r.unit === "%" ? `${window.$fa(t, r == null ? void 0 : r.precision)}%` : window.$fa(t, r == null ? void 0 : r.precision);
42
+ const n = r[e];
43
+ return n.unit === "currency" ? t ? `${t} ${window.$fa(o, n == null ? void 0 : n.precision)}` : window.$fa(o, n == null ? void 0 : n.precision) : n.unit === "%" ? `${window.$fa(o, n == null ? void 0 : n.precision)}%` : window.$fa(o, n == null ? void 0 : n.precision);
46
44
  };
47
- window.$fu = p, i.config.globalProperties.$fu = p;
45
+ window.$fu = u, i.config.globalProperties.$fu = u;
48
46
  const d = (e = () => {
49
- }, n = 2) => {
50
- let t = null;
51
- return new Promise((o, r) => {
52
- t = setTimeout(() => {
53
- e(o, r), clearTimeout(t), o(!0);
54
- }, n * 100);
47
+ }, t = 2) => {
48
+ let o = null;
49
+ return new Promise((r, n) => {
50
+ o = setTimeout(() => {
51
+ e(r, n), clearTimeout(o), r(!0);
52
+ }, t * 100);
55
53
  });
56
54
  };
57
55
  window.$pm = d, window.$promise = d;
58
- const w = (e = () => {
59
- }, n = 500) => {
60
- let t;
61
- return function(...o) {
62
- t && clearTimeout(t), t = setTimeout(() => {
63
- e.apply(this, o);
64
- }, n);
56
+ const p = (e = () => {
57
+ }, t = 500) => {
58
+ let o;
59
+ return function(...r) {
60
+ o && clearTimeout(o), o = setTimeout(() => {
61
+ e.apply(this, r);
62
+ }, t);
65
63
  };
66
64
  };
67
- window.$db = w, window.$debounce = w, Number.prototype.toFixedNumber = function(e) {
65
+ window.$db = p, window.$debounce = p, Number.prototype.toFixedNumber = function(e) {
68
66
  return Number(this.toFixed(e));
69
67
  }, Array.prototype.filter1 = function(e) {
70
68
  if (!e || typeof e != "function")
71
69
  throw new Error(e + " is not a function");
72
- let n, t;
73
- for (let o = 0; o < this.length; o++)
74
- if (e(this[o], o, this)) {
75
- t = o, n = this[o];
70
+ let t, o;
71
+ for (let r = 0; r < this.length; r++)
72
+ if (e(this[r], r, this)) {
73
+ o = r, t = this[r];
76
74
  break;
77
75
  }
78
76
  return {
79
- index: t,
80
- data: n
77
+ index: o,
78
+ data: t
81
79
  };
82
80
  }, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
83
- const f = (e, n) => {
81
+ const w = (e, t) => {
84
82
  if (!e) {
85
83
  console.info("No Value");
86
84
  return;
87
85
  }
88
- const t = window.$l("Copied");
89
- let o;
90
- if (n ? window.$getType(n) !== "Boolean" ? o = `${t} ${n}: ${e}` : o = `${t}: ${e}` : o = t, navigator.clipboard && window.isSecureContext)
86
+ const o = window.$l("Copied");
87
+ let r;
88
+ if (t ? window.$getType(t) !== "Boolean" ? r = `${o} ${t}: ${e}` : r = `${o}: ${e}` : r = o, navigator.clipboard && window.isSecureContext)
91
89
  navigator.clipboard.writeText(e).then(() => {
92
90
  i.config.globalProperties.$message.success({
93
- message: o,
91
+ message: r,
94
92
  // grouping: true,
95
93
  center: !0,
96
94
  duration: 0
97
95
  });
98
96
  });
99
97
  else {
100
- let r = document.createElement("textarea");
101
- r.value = e, r.style.position = "fixed", r.style.opacity = 0, document.body.appendChild(r), r.select(), document.execCommand("Copy"), r.remove(), i.config.globalProperties.$message.success({
102
- message: o,
98
+ let n = document.createElement("textarea");
99
+ n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), i.config.globalProperties.$message.success({
100
+ message: r,
103
101
  // grouping: true,
104
102
  center: !0,
105
103
  duration: 0
106
104
  });
107
105
  }
108
106
  };
109
- window.$copy = f, i.config.globalProperties.$copy = f;
107
+ window.$copy = w, i.config.globalProperties.$copy = w;
110
108
  const h = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
111
109
  window.$sc = h;
112
- const y = {
110
+ const F = {
113
111
  cpa: "avgCPA",
114
112
  cpt: "avgCPT"
115
- }, T = (e, n = y) => {
116
- const t = n[e.name];
117
- t && (e.name = t);
113
+ }, C = (e, t = F) => {
114
+ const o = t[e.name];
115
+ o && (e.name = o);
118
116
  };
119
- window.$nr = T;
120
- const C = (e, n) => (Object.keys(e).forEach((t) => {
121
- objMap[t] && (e[objMap[t]] = e[t], delete e[t]);
117
+ window.$nr = C;
118
+ const T = (e, t) => (Object.keys(e).forEach((o) => {
119
+ objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
122
120
  }), e);
123
- window.$nro = C;
124
- const P = (e) => {
125
- let n = 0;
126
- return Object.keys(e).forEach((t) => {
127
- (window.$getType(e[t]) === "Array" && e[t].length !== 0 || e[t]) && n++;
128
- }), n;
121
+ window.$nro = T;
122
+ const k = (e) => {
123
+ let t = 0;
124
+ return Object.keys(e).forEach((o) => {
125
+ (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
126
+ }), t;
127
+ };
128
+ window.$pc = k;
129
+ const g = {
130
+ info: {
131
+ tag: "background-color:#0085FF; color:#f1f7ff;",
132
+ style: "background-color:#f1f7ff; color:#0085FF;"
133
+ },
134
+ log: {
135
+ tag: "background-color:#FFFFFF; color:#272b41;",
136
+ style: "background-color:#272b41; color:#FFFFFF;"
137
+ },
138
+ error: {
139
+ tag: "background-color:#ff4d4f; color:#fff3f3;",
140
+ style: "background-color:#fff3f3; color:#ff4d4f;"
141
+ },
142
+ warn: {
143
+ tag: "background-color:#fa8b0c; color:#fffbf6;",
144
+ style: "background-color:#fffbf6; color:#fa8b0c;"
145
+ },
146
+ success: {
147
+ tag: "background-color:#20c997; color:#f6fffc;",
148
+ style: "background-color:#f6fffc; color:#20c997;"
149
+ }
150
+ }, s = (e = "info", t) => {
151
+ e === "success" && (e = "info"), console[e](
152
+ `%c ${e.toUpperCase()} %c┆${t}┆`,
153
+ `${g[e].tag}`,
154
+ `${g[e].style}`
155
+ );
156
+ };
157
+ window.$console = {
158
+ info: (...e) => {
159
+ s("info", e);
160
+ },
161
+ log: (...e) => {
162
+ s("log", e);
163
+ },
164
+ error: (...e) => {
165
+ s("error", e);
166
+ },
167
+ warn: (...e) => {
168
+ s("warn", e);
169
+ },
170
+ success: (...e) => {
171
+ s("success", e);
172
+ }
129
173
  };
130
- window.$pc = P;
131
174
  };
132
175
  export {
133
- E as d
176
+ M as d
134
177
  };
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "magtool",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "author": "magxl",
6
- "main": "./dist/index.mjs",
7
- "module": "./dist/index.mjs",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.mjs"
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
12
  },
13
13
  "./cps": {
14
- "import": "./dist/cps.mjs",
15
- "require": "./dist/cps.mjs"
14
+ "import": "./dist/cps.js",
15
+ "require": "./dist/cps.js"
16
16
  },
17
17
  "./directive": {
18
- "import": "./dist/directive.mjs",
19
- "require": "./dist/directive.mjs"
18
+ "import": "./dist/directive.js",
19
+ "require": "./dist/directive.js"
20
20
  },
21
21
  "./util": {
22
- "import": "./dist/util.mjs",
23
- "require": "./dist/util.mjs"
22
+ "import": "./dist/util.js",
23
+ "require": "./dist/util.js"
24
24
  },
25
25
  "./store": {
26
- "import": "./dist/store.mjs",
27
- "require": "./dist/store.mjs"
26
+ "import": "./dist/store.js",
27
+ "require": "./dist/store.js"
28
28
  }
29
29
  },
30
30
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "dist/*"
36
36
  ],
37
37
  "dependencies": {
38
- "magtool": "^1.0.2",
38
+ "magtool": "^1.0.3",
39
39
  "moment": "^2.30.1",
40
40
  "pinia": "^3.0.0",
41
41
  "vue": "^3.3.4"