@vtj/utils 0.16.36 → 0.17.1

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.
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  var Dt = Object.defineProperty;
2
2
  var Bt = (t, e, n) => e in t ? Dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var _ = (t, e, n) => Bt(t, typeof e != "symbol" ? e + "" : e, n);
3
+ var C = (t, e, n) => Bt(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  import { omit as me, merge as W, debounce as vt, throttle as It, isUrl as qe, pathToRegexpCompile as qt, uuid as Mt, rURL as Ht, template as $t } from "@vtj/base";
5
5
  export * from "@vtj/base";
6
6
  import { ref as ge } from "vue";
@@ -16,16 +16,16 @@ import { ref as ge } from "vue";
16
16
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
17
17
  * @name @vtj/utils
18
18
  * @author CHC chenhuachun1549@dingtalk.com
19
- * @version 0.16.36
19
+ * @version 0.17.1
20
20
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
21
21
  */
22
- const es = "0.16.36";
22
+ const es = "0.17.1";
23
23
  function ct(t, e) {
24
24
  return function() {
25
25
  return t.apply(e, arguments);
26
26
  };
27
27
  }
28
- const { toString: Jt } = Object.prototype, { getPrototypeOf: _e } = Object, { iterator: ce, toStringTag: lt } = Symbol, le = /* @__PURE__ */ ((t) => (e) => {
28
+ const { toString: Jt } = Object.prototype, { getPrototypeOf: Ce } = Object, { iterator: ce, toStringTag: lt } = Symbol, le = /* @__PURE__ */ ((t) => (e) => {
29
29
  const n = Jt.call(e);
30
30
  return t[n] || (t[n] = n.slice(8, -1).toLowerCase());
31
31
  })(/* @__PURE__ */ Object.create(null)), U = (t) => (t = t.toLowerCase(), (e) => le(e) === t), ue = (t) => (e) => typeof e === t, { isArray: H } = Array, M = ue("undefined");
@@ -40,7 +40,7 @@ function Wt(t) {
40
40
  const zt = ue("string"), x = ue("function"), ft = ue("number"), X = (t) => t !== null && typeof t == "object", Vt = (t) => t === !0 || t === !1, se = (t) => {
41
41
  if (le(t) !== "object")
42
42
  return !1;
43
- const e = _e(t);
43
+ const e = Ce(t);
44
44
  return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(lt in t) && !(ce in t);
45
45
  }, Kt = (t) => {
46
46
  if (!X(t) || K(t))
@@ -135,7 +135,7 @@ const fn = (t, e, n, { allOwnKeys: r } = {}) => (G(
135
135
  do {
136
136
  for (s = Object.getOwnPropertyNames(t), o = s.length; o-- > 0; )
137
137
  i = s[o], (!r || r(i, t, e)) && !a[i] && (e[i] = t[i], a[i] = !0);
138
- t = n !== !1 && _e(t);
138
+ t = n !== !1 && Ce(t);
139
139
  } while (t && (!n || n(t, e)) && t !== Object.prototype);
140
140
  return e;
141
141
  }, mn = (t, e, n) => {
@@ -151,7 +151,7 @@ const fn = (t, e, n, { allOwnKeys: r } = {}) => (G(
151
151
  for (; e-- > 0; )
152
152
  n[e] = t[e];
153
153
  return n;
154
- }, yn = /* @__PURE__ */ ((t) => (e) => t && e instanceof t)(typeof Uint8Array < "u" && _e(Uint8Array)), wn = (t, e) => {
154
+ }, yn = /* @__PURE__ */ ((t) => (e) => t && e instanceof t)(typeof Uint8Array < "u" && Ce(Uint8Array)), wn = (t, e) => {
155
155
  const r = (t && t[ce]).call(t);
156
156
  let s;
157
157
  for (; (s = r.next()) && !s.done; ) {
@@ -196,10 +196,10 @@ const fn = (t, e, n, { allOwnKeys: r } = {}) => (G(
196
196
  return H(t) ? r(t) : r(String(t).split(e)), n;
197
197
  }, An = () => {
198
198
  }, xn = (t, e) => t != null && Number.isFinite(t = +t) ? t : e;
199
- function Cn(t) {
199
+ function _n(t) {
200
200
  return !!(t && x(t.append) && t[lt] === "FormData" && t[ce]);
201
201
  }
202
- const _n = (t) => {
202
+ const Cn = (t) => {
203
203
  const e = new Array(10), n = (r, s) => {
204
204
  if (X(r)) {
205
205
  if (e.indexOf(r) >= 0)
@@ -280,8 +280,8 @@ const _n = (t) => {
280
280
  findKey: dt,
281
281
  global: B,
282
282
  isContextDefined: pt,
283
- isSpecCompliantForm: Cn,
284
- toJSONObject: _n,
283
+ isSpecCompliantForm: _n,
284
+ toJSONObject: Cn,
285
285
  isAsyncFn: Pn,
286
286
  isThenable: Ln,
287
287
  setImmediate: mt,
@@ -733,7 +733,7 @@ function er(t, e) {
733
733
  });
734
734
  });
735
735
  }
736
- let C = class {
736
+ let _ = class {
737
737
  constructor(e) {
738
738
  e && this.set(e);
739
739
  }
@@ -859,7 +859,7 @@ let C = class {
859
859
  return c.isArray(e) ? e.forEach(o) : o(e), this;
860
860
  }
861
861
  };
862
- C.accessor([
862
+ _.accessor([
863
863
  "Content-Type",
864
864
  "Content-Length",
865
865
  "Accept",
@@ -867,7 +867,7 @@ C.accessor([
867
867
  "User-Agent",
868
868
  "Authorization"
869
869
  ]);
870
- c.reduceDescriptors(C.prototype, ({ value: t }, e) => {
870
+ c.reduceDescriptors(_.prototype, ({ value: t }, e) => {
871
871
  let n = e[0].toUpperCase() + e.slice(1);
872
872
  return {
873
873
  get: () => t,
@@ -876,9 +876,9 @@ c.reduceDescriptors(C.prototype, ({ value: t }, e) => {
876
876
  }
877
877
  };
878
878
  });
879
- c.freezeMethods(C);
879
+ c.freezeMethods(_);
880
880
  function be(t, e) {
881
- const n = this || Q, r = e || n, s = C.from(r.headers);
881
+ const n = this || Q, r = e || n, s = _.from(r.headers);
882
882
  let o = r.data;
883
883
  return c.forEach(t, function(a) {
884
884
  o = a.call(n, o, s.normalize(), e ? e.status : void 0);
@@ -1016,7 +1016,7 @@ function Ot(t, e, n) {
1016
1016
  let r = !ir(e);
1017
1017
  return t && (r || n == !1) ? ar(t, e) : e;
1018
1018
  }
1019
- const Xe = (t) => t instanceof C ? { ...t } : t;
1019
+ const Xe = (t) => t instanceof _ ? { ...t } : t;
1020
1020
  function I(t, e) {
1021
1021
  e = e || {};
1022
1022
  const n = {};
@@ -1085,7 +1085,7 @@ function I(t, e) {
1085
1085
  const Tt = (t) => {
1086
1086
  const e = I({}, t);
1087
1087
  let { data: n, withXSRFToken: r, xsrfHeaderName: s, xsrfCookieName: o, headers: i, auth: a } = e;
1088
- if (e.headers = i = C.from(i), e.url = bt(
1088
+ if (e.headers = i = _.from(i), e.url = bt(
1089
1089
  Ot(e.baseURL, e.url, e.allowAbsoluteUrls),
1090
1090
  t.params,
1091
1091
  t.paramsSerializer
@@ -1113,7 +1113,7 @@ const Tt = (t) => {
1113
1113
  return new Promise(function(n, r) {
1114
1114
  const s = Tt(t);
1115
1115
  let o = s.data;
1116
- const i = C.from(s.headers).normalize();
1116
+ const i = _.from(s.headers).normalize();
1117
1117
  let { responseType: a, onUploadProgress: f, onDownloadProgress: u } = s, l, h, y, R, d;
1118
1118
  function m() {
1119
1119
  R && R(), d && d(), s.cancelToken && s.cancelToken.unsubscribe(l), s.signal && s.signal.removeEventListener("abort", l);
@@ -1123,7 +1123,7 @@ const Tt = (t) => {
1123
1123
  function w() {
1124
1124
  if (!p)
1125
1125
  return;
1126
- const b = C.from(
1126
+ const b = _.from(
1127
1127
  "getAllResponseHeaders" in p && p.getAllResponseHeaders()
1128
1128
  ), P = {
1129
1129
  data: !a || a === "text" || a === "json" ? p.responseText : p.response,
@@ -1403,7 +1403,7 @@ const Tt = (t) => {
1403
1403
  return !ve && D && D(), await new Promise((j, q) => {
1404
1404
  St(j, q, {
1405
1405
  data: kt,
1406
- headers: C.from(F.headers),
1406
+ headers: _.from(F.headers),
1407
1407
  status: F.status,
1408
1408
  statusText: F.statusText,
1409
1409
  config: d,
@@ -1496,20 +1496,20 @@ function Re(t) {
1496
1496
  throw new Y(null, t);
1497
1497
  }
1498
1498
  function nt(t) {
1499
- return Re(t), t.headers = C.from(t.headers), t.data = be.call(t, t.transformRequest), ["post", "put", "patch"].indexOf(t.method) !== -1 && t.headers.setContentType("application/x-www-form-urlencoded", !1), xt.getAdapter(t.adapter || Q.adapter, t)(t).then(
1499
+ return Re(t), t.headers = _.from(t.headers), t.data = be.call(t, t.transformRequest), ["post", "put", "patch"].indexOf(t.method) !== -1 && t.headers.setContentType("application/x-www-form-urlencoded", !1), xt.getAdapter(t.adapter || Q.adapter, t)(t).then(
1500
1500
  function(r) {
1501
- return Re(t), r.data = be.call(t, t.transformResponse, r), r.headers = C.from(r.headers), r;
1501
+ return Re(t), r.data = be.call(t, t.transformResponse, r), r.headers = _.from(r.headers), r;
1502
1502
  },
1503
1503
  function(r) {
1504
1504
  return Et(r) || (Re(t), r && r.response && (r.response.data = be.call(
1505
1505
  t,
1506
1506
  t.transformResponse,
1507
1507
  r.response
1508
- ), r.response.headers = C.from(r.response.headers))), Promise.reject(r);
1508
+ ), r.response.headers = _.from(r.response.headers))), Promise.reject(r);
1509
1509
  }
1510
1510
  );
1511
1511
  }
1512
- const Ct = "1.13.6", de = {};
1512
+ const _t = "1.13.6", de = {};
1513
1513
  ["object", "boolean", "number", "function", "string", "symbol"].forEach((t, e) => {
1514
1514
  de[t] = function(r) {
1515
1515
  return typeof r === t || "a" + (e < 1 ? "n " : " ") + t;
@@ -1518,7 +1518,7 @@ const Ct = "1.13.6", de = {};
1518
1518
  const rt = {};
1519
1519
  de.transitional = function(e, n, r) {
1520
1520
  function s(o, i) {
1521
- return "[Axios v" + Ct + "] Transitional option '" + o + "'" + i + (r ? ". " + r : "");
1521
+ return "[Axios v" + _t + "] Transitional option '" + o + "'" + i + (r ? ". " + r : "");
1522
1522
  }
1523
1523
  return (o, i, a) => {
1524
1524
  if (e === !1)
@@ -1625,7 +1625,7 @@ let v = class {
1625
1625
  let i = o && c.merge(o.common, o[n.method]);
1626
1626
  o && c.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (d) => {
1627
1627
  delete o[d];
1628
- }), n.headers = C.concat(i, o);
1628
+ }), n.headers = _.concat(i, o);
1629
1629
  const a = [];
1630
1630
  let f = !0;
1631
1631
  this.interceptors.request.forEach(function(m) {
@@ -1700,7 +1700,7 @@ c.forEach(["post", "put", "patch"], function(e) {
1700
1700
  }
1701
1701
  v.prototype[e] = n(), v.prototype[e + "Form"] = n(!0);
1702
1702
  });
1703
- let Rr = class _t {
1703
+ let Rr = class Ct {
1704
1704
  constructor(e) {
1705
1705
  if (typeof e != "function")
1706
1706
  throw new TypeError("executor must be a function.");
@@ -1766,7 +1766,7 @@ let Rr = class _t {
1766
1766
  static source() {
1767
1767
  let e;
1768
1768
  return {
1769
- token: new _t(function(s) {
1769
+ token: new Ct(function(s) {
1770
1770
  e = s;
1771
1771
  }),
1772
1772
  cancel: e
@@ -1866,7 +1866,7 @@ E.Axios = v;
1866
1866
  E.CanceledError = Y;
1867
1867
  E.CancelToken = Rr;
1868
1868
  E.isCancel = Et;
1869
- E.VERSION = Ct;
1869
+ E.VERSION = _t;
1870
1870
  E.toFormData = fe;
1871
1871
  E.AxiosError = g;
1872
1872
  E.Cancel = E.CanceledError;
@@ -1876,7 +1876,7 @@ E.all = function(e) {
1876
1876
  E.spread = Er;
1877
1877
  E.isAxiosError = Sr;
1878
1878
  E.mergeConfig = I;
1879
- E.AxiosHeaders = C;
1879
+ E.AxiosHeaders = _;
1880
1880
  E.formToJSON = (t) => Rt(c.isHTMLForm(t) ? new FormData(t) : t);
1881
1881
  E.getAdapter = xt.getAdapter;
1882
1882
  E.HttpStatusCode = Ae;
@@ -1902,16 +1902,16 @@ const {
1902
1902
  form: "application/x-www-form-urlencoded",
1903
1903
  json: "application/json",
1904
1904
  data: "multipart/form-data"
1905
- }, Tr = ["put", "post", "patch"], st = "Local-Request-Id", Ar = 100, xr = 300, Cr = "/api/proxy";
1906
- class _r {
1905
+ }, Tr = ["put", "post", "patch"], st = "Local-Request-Id", Ar = 100, xr = 300, _r = "/api/proxy";
1906
+ class Cr {
1907
1907
  constructor(e = {}) {
1908
- _(this, "axios");
1909
- _(this, "settings");
1910
- _(this, "records", {});
1911
- _(this, "isLoading", !1);
1912
- _(this, "stopSkipWarn");
1913
- _(this, "showLoading");
1914
- _(this, "showError");
1908
+ C(this, "axios");
1909
+ C(this, "settings");
1910
+ C(this, "records", {});
1911
+ C(this, "isLoading", !1);
1912
+ C(this, "stopSkipWarn");
1913
+ C(this, "showLoading");
1914
+ C(this, "showError");
1915
1915
  this.settings = Object.assign({ type: "form" }, e.settings || {});
1916
1916
  const n = me(e, [
1917
1917
  "settings",
@@ -2008,7 +2008,7 @@ class _r {
2008
2008
  url: n,
2009
2009
  headers: r
2010
2010
  };
2011
- const s = e.proxyPath || Cr, { protocol: o, host: i } = location || {}, a = qe(n) ? n : `${o}//${i}${n}`;
2011
+ const s = e.proxyPath || _r, { protocol: o, host: i } = location || {}, a = qe(n) ? n : `${o}//${i}${n}`;
2012
2012
  return r.Target = a, {
2013
2013
  url: s,
2014
2014
  headers: r
@@ -2019,11 +2019,10 @@ class _r {
2019
2019
  n && r && Object.keys(this.records).length > 0 && (this.isLoading = !0, r());
2020
2020
  }
2021
2021
  closeLoading(e) {
2022
- const { loading: n, hideLoading: r } = e;
2023
- if (!n) return;
2022
+ const { hideLoading: n } = e;
2024
2023
  this.isLoading = !1;
2025
- const s = Object.keys(this.records);
2026
- r && s.length === 0 && (this.isLoading = !1, r());
2024
+ const r = Object.keys(this.records);
2025
+ n && r.length === 0 && (this.isLoading = !1, n());
2027
2026
  }
2028
2027
  _showError(e, n) {
2029
2028
  const { failMessage: r, showError: s } = e;
@@ -2099,7 +2098,7 @@ class _r {
2099
2098
  }
2100
2099
  }
2101
2100
  function Pr(t = {}) {
2102
- const e = new _r(t), n = e.send.bind(e), r = e.cancel.bind(e), s = e.setConfig.bind(e), o = e.useRequest.bind(e), i = e.useResponse.bind(e);
2101
+ const e = new Cr(t), n = e.send.bind(e), r = e.cancel.bind(e), s = e.setConfig.bind(e), o = e.useRequest.bind(e), i = e.useResponse.bind(e);
2103
2102
  return Object.assign(n, {
2104
2103
  ...e,
2105
2104
  instance: e,
@@ -2170,16 +2169,16 @@ function As(t, e) {
2170
2169
  const n = t;
2171
2170
  return n.lastModified = Date.now(), n.lastModifiedDate = /* @__PURE__ */ new Date(), n.name = e, n;
2172
2171
  }
2173
- const xs = (t) => V ? window.requestAnimationFrame(t) : setTimeout(t, 16), Cs = (t) => V ? window.cancelAnimationFrame(t) : clearTimeout(t);
2172
+ const xs = (t) => V ? window.requestAnimationFrame(t) : setTimeout(t, 16), _s = (t) => V ? window.cancelAnimationFrame(t) : clearTimeout(t);
2174
2173
  class Nr {
2175
2174
  constructor(e = {}) {
2176
- _(this, "options", {
2175
+ C(this, "options", {
2177
2176
  type: "cache",
2178
2177
  expired: 0,
2179
2178
  prefix: "__VTJ_"
2180
2179
  });
2181
- _(this, "caches", {});
2182
- _(this, "types");
2180
+ C(this, "caches", {});
2181
+ C(this, "types");
2183
2182
  this.types = {
2184
2183
  local: V ? window.localStorage : this.caches,
2185
2184
  session: V ? window.sessionStorage : this.caches,
@@ -2224,7 +2223,7 @@ class Nr {
2224
2223
  r === this.caches ? this.caches = {} : r.clear();
2225
2224
  }
2226
2225
  }
2227
- const _s = new Nr();
2226
+ const Cs = new Nr();
2228
2227
  function Nt(t) {
2229
2228
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
2230
2229
  }
@@ -2401,8 +2400,8 @@ const Jr = {
2401
2400
  };
2402
2401
  class Wr {
2403
2402
  constructor(e) {
2404
- _(this, "config");
2405
- _(this, "options");
2403
+ C(this, "config");
2404
+ C(this, "options");
2406
2405
  this.options = { ...Jr, ...e };
2407
2406
  const n = typeof location < "u" ? location : {}, r = (/__(?:logConf|logLevel)__=([^#/&]*)/.exec(
2408
2407
  n.href
@@ -2433,12 +2432,12 @@ function zr(t) {
2433
2432
  return new Wr(t);
2434
2433
  }
2435
2434
  const Us = zr({ level: "log", bizName: "VTJ" });
2436
- /*! js-cookie v3.0.5 | MIT */
2435
+ /*! js-cookie v3.0.8 | MIT */
2437
2436
  function re(t) {
2438
2437
  for (var e = 1; e < arguments.length; e++) {
2439
2438
  var n = arguments[e];
2440
2439
  for (var r in n)
2441
- t[r] = n[r];
2440
+ r !== "__proto__" && (t[r] = n[r]);
2442
2441
  }
2443
2442
  return t;
2444
2443
  }
@@ -2453,7 +2452,7 @@ var Vr = {
2453
2452
  );
2454
2453
  }
2455
2454
  };
2456
- function Ce(t, e) {
2455
+ function _e(t, e) {
2457
2456
  function n(s, o, i) {
2458
2457
  if (!(typeof document > "u")) {
2459
2458
  i = re({}, e, i), typeof i.expires == "number" && (i.expires = new Date(Date.now() + i.expires * 864e5)), i.expires && (i.expires = i.expires.toUTCString()), s = encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
@@ -2469,7 +2468,7 @@ function Ce(t, e) {
2469
2468
  var f = o[a].split("="), u = f.slice(1).join("=");
2470
2469
  try {
2471
2470
  var l = decodeURIComponent(f[0]);
2472
- if (i[l] = t.read(u, l), s === l)
2471
+ if (l in i || (i[l] = t.read(u, l)), s === l)
2473
2472
  break;
2474
2473
  } catch {
2475
2474
  }
@@ -2491,10 +2490,10 @@ function Ce(t, e) {
2491
2490
  );
2492
2491
  },
2493
2492
  withAttributes: function(s) {
2494
- return Ce(this.converter, re({}, this.attributes, s));
2493
+ return _e(this.converter, re({}, this.attributes, s));
2495
2494
  },
2496
2495
  withConverter: function(s) {
2497
- return Ce(re({}, this.converter, s), this.attributes);
2496
+ return _e(re({}, this.converter, s), this.attributes);
2498
2497
  }
2499
2498
  },
2500
2499
  {
@@ -2503,7 +2502,7 @@ function Ce(t, e) {
2503
2502
  }
2504
2503
  );
2505
2504
  }
2506
- var Fe = Ce(Vr, { path: "/" });
2505
+ var Fe = _e(Vr, { path: "/" });
2507
2506
  function Kr(t, e, n) {
2508
2507
  Fe.set(t, e, n);
2509
2508
  }
@@ -2607,12 +2606,12 @@ function Bs() {
2607
2606
  export {
2608
2607
  st as LOCAL_REQUEST_ID,
2609
2608
  Wr as Logger,
2610
- _r as Request,
2609
+ Cr as Request,
2611
2610
  Nr as Storage,
2612
2611
  es as VTJ_UTILS_VERSION,
2613
2612
  E as axios,
2614
2613
  As as blobToFile,
2615
- Cs as cAF,
2614
+ _s as cAF,
2616
2615
  Fs as cookie,
2617
2616
  Lr as createApi,
2618
2617
  Rs as createApis,
@@ -2632,7 +2631,7 @@ export {
2632
2631
  Us as logger,
2633
2632
  xs as rAF,
2634
2633
  Lt as request,
2635
- _s as storage,
2634
+ Cs as storage,
2636
2635
  Ps as url,
2637
2636
  Es as useApi
2638
2637
  };