x-essential-lib 0.9.7 → 0.9.9

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.
@@ -0,0 +1,231 @@
1
+ import { getCurrentInstance as x, getCurrentScope as W, hasInjectionContext as k, inject as E, watch as R, onScopeDispose as L, shallowRef as b, watchEffect as U, toValue as p, computed as w, onMounted as D, unref as B } from "vue";
2
+ function F(e, t) {
3
+ return W() ? (L(e, t), !0) : !1;
4
+ }
5
+ const y = /* @__PURE__ */ new WeakMap(), z = /* @__NO_SIDE_EFFECTS__ */ (...e) => {
6
+ var t;
7
+ const n = e[0], r = (t = x()) === null || t === void 0 ? void 0 : t.proxy, o = r ?? W();
8
+ if (o == null && !k()) throw new Error("injectLocal must be called in setup");
9
+ return o && y.has(o) && n in y.get(o) ? y.get(o)[n] : E(...e);
10
+ }, G = typeof window < "u" && typeof document < "u";
11
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
12
+ const Q = Object.prototype.toString, V = (e) => Q.call(e) === "[object Object]";
13
+ function O(e) {
14
+ return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
15
+ }
16
+ function j(e) {
17
+ return Array.isArray(e) ? e : [e];
18
+ }
19
+ function H(e, t, n) {
20
+ return R(e, t, {
21
+ ...n,
22
+ immediate: !0
23
+ });
24
+ }
25
+ const I = G ? window : void 0;
26
+ function J(e) {
27
+ var t;
28
+ const n = p(e);
29
+ return (t = n?.$el) !== null && t !== void 0 ? t : n;
30
+ }
31
+ function K(...e) {
32
+ const t = [], n = () => {
33
+ t.forEach((i) => i()), t.length = 0;
34
+ }, r = (i, c, s, a) => (i.addEventListener(c, s, a), () => i.removeEventListener(c, s, a)), o = w(() => {
35
+ const i = j(p(e[0])).filter((c) => c != null);
36
+ return i.every((c) => typeof c != "string") ? i : void 0;
37
+ }), l = H(() => {
38
+ var i, c;
39
+ return [
40
+ (i = (c = o.value) === null || c === void 0 ? void 0 : c.map((s) => J(s))) !== null && i !== void 0 ? i : [I].filter((s) => s != null),
41
+ j(p(o.value ? e[1] : e[0])),
42
+ j(B(o.value ? e[2] : e[1])),
43
+ p(o.value ? e[3] : e[2])
44
+ ];
45
+ }, ([i, c, s, a]) => {
46
+ if (n(), !i?.length || !c?.length || !s?.length) return;
47
+ const d = V(a) ? { ...a } : a;
48
+ t.push(...i.flatMap((m) => c.flatMap((f) => s.map(($) => r(m, f, $, d)))));
49
+ }, { flush: "post" }), u = () => {
50
+ l(), n();
51
+ };
52
+ return F(n), u;
53
+ }
54
+ // @__NO_SIDE_EFFECTS__
55
+ function N() {
56
+ const e = b(!1), t = x();
57
+ return t && D(() => {
58
+ e.value = !0;
59
+ }, t), e;
60
+ }
61
+ // @__NO_SIDE_EFFECTS__
62
+ function X(e) {
63
+ const t = /* @__PURE__ */ N();
64
+ return w(() => (t.value, !!e()));
65
+ }
66
+ const Y = Symbol("vueuse-ssr-width");
67
+ // @__NO_SIDE_EFFECTS__
68
+ function Z() {
69
+ const e = k() ? /* @__PURE__ */ z(Y, null) : null;
70
+ return typeof e == "number" ? e : void 0;
71
+ }
72
+ function q(e, t = {}) {
73
+ const { window: n = I, ssrWidth: r = /* @__PURE__ */ Z() } = t, o = /* @__PURE__ */ X(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), l = b(typeof r == "number"), u = b(), i = b(!1), c = (s) => {
74
+ i.value = s.matches;
75
+ };
76
+ return U(() => {
77
+ if (l.value) {
78
+ l.value = !o.value, i.value = p(e).split(",").some((s) => {
79
+ const a = s.includes("not all"), d = s.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), m = s.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
80
+ let f = !!(d || m);
81
+ return d && f && (f = r >= O(d[1])), m && f && (f = r <= O(m[1])), a ? !f : f;
82
+ });
83
+ return;
84
+ }
85
+ o.value && (u.value = n.matchMedia(p(e)), i.value = u.value.matches);
86
+ }), K(u, "change", c, { passive: !0 }), w(() => i.value);
87
+ }
88
+ // @__NO_SIDE_EFFECTS__
89
+ function ye(e) {
90
+ return q("(prefers-color-scheme: dark)", e);
91
+ }
92
+ function g(e) {
93
+ for (var t = 1; t < arguments.length; t++) {
94
+ var n = arguments[t];
95
+ for (var r in n)
96
+ e[r] = n[r];
97
+ }
98
+ return e;
99
+ }
100
+ var _ = {
101
+ read: function(e) {
102
+ return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
103
+ },
104
+ write: function(e) {
105
+ return encodeURIComponent(e).replace(
106
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
107
+ decodeURIComponent
108
+ );
109
+ }
110
+ };
111
+ function S(e, t) {
112
+ function n(o, l, u) {
113
+ if (!(typeof document > "u")) {
114
+ u = g({}, t, u), typeof u.expires == "number" && (u.expires = new Date(Date.now() + u.expires * 864e5)), u.expires && (u.expires = u.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
115
+ var i = "";
116
+ for (var c in u)
117
+ u[c] && (i += "; " + c, u[c] !== !0 && (i += "=" + u[c].split(";")[0]));
118
+ return document.cookie = o + "=" + e.write(l, o) + i;
119
+ }
120
+ }
121
+ function r(o) {
122
+ if (!(typeof document > "u" || arguments.length && !o)) {
123
+ for (var l = document.cookie ? document.cookie.split("; ") : [], u = {}, i = 0; i < l.length; i++) {
124
+ var c = l[i].split("="), s = c.slice(1).join("=");
125
+ try {
126
+ var a = decodeURIComponent(c[0]);
127
+ if (u[a] = e.read(s, a), o === a)
128
+ break;
129
+ } catch {
130
+ }
131
+ }
132
+ return o ? u[o] : u;
133
+ }
134
+ }
135
+ return Object.create(
136
+ {
137
+ set: n,
138
+ get: r,
139
+ remove: function(o, l) {
140
+ n(
141
+ o,
142
+ "",
143
+ g({}, l, {
144
+ expires: -1
145
+ })
146
+ );
147
+ },
148
+ withAttributes: function(o) {
149
+ return S(this.converter, g({}, this.attributes, o));
150
+ },
151
+ withConverter: function(o) {
152
+ return S(g({}, this.converter, o), this.attributes);
153
+ }
154
+ },
155
+ {
156
+ attributes: { value: Object.freeze(t) },
157
+ converter: { value: Object.freeze(e) }
158
+ }
159
+ );
160
+ }
161
+ var je = S(_, { path: "/" });
162
+ function Se(e) {
163
+ return { all: e = e || /* @__PURE__ */ new Map(), on: function(t, n) {
164
+ var r = e.get(t);
165
+ r ? r.push(n) : e.set(t, [n]);
166
+ }, off: function(t, n) {
167
+ var r = e.get(t);
168
+ r && (n ? r.splice(r.indexOf(n) >>> 0, 1) : e.set(t, []));
169
+ }, emit: function(t, n) {
170
+ var r = e.get(t);
171
+ r && r.slice().map(function(o) {
172
+ o(n);
173
+ }), (r = e.get("*")) && r.slice().map(function(o) {
174
+ o(t, n);
175
+ });
176
+ } };
177
+ }
178
+ var ee = typeof global == "object" && global && global.Object === Object && global, te = typeof self == "object" && self && self.Object === Object && self, ne = ee || te || Function("return this")(), v = ne.Symbol, A = Object.prototype, oe = A.hasOwnProperty, re = A.toString, h = v ? v.toStringTag : void 0;
179
+ function ie(e) {
180
+ var t = oe.call(e, h), n = e[h];
181
+ try {
182
+ e[h] = void 0;
183
+ var r = !0;
184
+ } catch {
185
+ }
186
+ var o = re.call(e);
187
+ return r && (t ? e[h] = n : delete e[h]), o;
188
+ }
189
+ var ce = Object.prototype, ue = ce.toString;
190
+ function se(e) {
191
+ return ue.call(e);
192
+ }
193
+ var le = "[object Null]", ae = "[object Undefined]", T = v ? v.toStringTag : void 0;
194
+ function fe(e) {
195
+ return e == null ? e === void 0 ? ae : le : T && T in Object(e) ? ie(e) : se(e);
196
+ }
197
+ function de(e) {
198
+ return e != null && typeof e == "object";
199
+ }
200
+ var pe = "[object Symbol]";
201
+ function ve(e) {
202
+ return typeof e == "symbol" || de(e) && fe(e) == pe;
203
+ }
204
+ function me(e, t) {
205
+ for (var n = -1, r = e == null ? 0 : e.length, o = Array(r); ++n < r; )
206
+ o[n] = t(e[n], n, e);
207
+ return o;
208
+ }
209
+ var he = Array.isArray, C = v ? v.prototype : void 0, M = C ? C.toString : void 0;
210
+ function P(e) {
211
+ if (typeof e == "string")
212
+ return e;
213
+ if (he(e))
214
+ return me(e, P) + "";
215
+ if (ve(e))
216
+ return M ? M.call(e) : "";
217
+ var t = e + "";
218
+ return t == "0" && 1 / e == -1 / 0 ? "-0" : t;
219
+ }
220
+ function ge(e) {
221
+ return e == null ? "" : P(e);
222
+ }
223
+ function we(e) {
224
+ return ge(e).toLowerCase();
225
+ }
226
+ export {
227
+ je as a,
228
+ Se as m,
229
+ we as t,
230
+ ye as u
231
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
3
  "private": false,
4
- "version": "0.9.7",
4
+ "version": "0.9.9",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -25,6 +25,7 @@
25
25
  "@vueuse/core": "^14.0.0",
26
26
  "axios": "^1.13.2",
27
27
  "js-cookie": "^3.0.5",
28
+ "lodash-es": "^4.17.21",
28
29
  "mitt": "^3.0.1",
29
30
  "vue": "^3.5.23",
30
31
  "vue-i18n": "^11.1.12",
@@ -34,6 +35,7 @@
34
35
  "devDependencies": {
35
36
  "@eslint/js": "^9.39.1",
36
37
  "@types/js-cookie": "^3.0.6",
38
+ "@types/lodash-es": "^4.17.12",
37
39
  "@types/node": "^24.10.0",
38
40
  "@vitejs/plugin-vue": "^6.0.1",
39
41
  "eslint": "^9.39.1",
@@ -1,182 +0,0 @@
1
- import { getCurrentInstance as j, getCurrentScope as M, hasInjectionContext as x, inject as I, watch as b, onScopeDispose as E, shallowRef as h, watchEffect as O, toValue as p, computed as w, onMounted as R, unref as D } from "vue";
2
- function U(e, n) {
3
- return M() ? (E(e, n), !0) : !1;
4
- }
5
- const g = /* @__PURE__ */ new WeakMap(), A = /* @__NO_SIDE_EFFECTS__ */ (...e) => {
6
- var n;
7
- const t = e[0], i = (n = j()) === null || n === void 0 ? void 0 : n.proxy, o = i ?? M();
8
- if (o == null && !x()) throw new Error("injectLocal must be called in setup");
9
- return o && g.has(o) && t in g.get(o) ? g.get(o)[t] : I(...e);
10
- }, B = typeof window < "u" && typeof document < "u";
11
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
12
- const F = Object.prototype.toString, L = (e) => F.call(e) === "[object Object]";
13
- function S(e) {
14
- return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
15
- }
16
- function y(e) {
17
- return Array.isArray(e) ? e : [e];
18
- }
19
- function P(e, n, t) {
20
- return b(e, n, {
21
- ...t,
22
- immediate: !0
23
- });
24
- }
25
- const W = B ? window : void 0;
26
- function T(e) {
27
- var n;
28
- const t = p(e);
29
- return (n = t?.$el) !== null && n !== void 0 ? n : t;
30
- }
31
- function $(...e) {
32
- const n = [], t = () => {
33
- n.forEach((r) => r()), n.length = 0;
34
- }, i = (r, c, s, l) => (r.addEventListener(c, s, l), () => r.removeEventListener(c, s, l)), o = w(() => {
35
- const r = y(p(e[0])).filter((c) => c != null);
36
- return r.every((c) => typeof c != "string") ? r : void 0;
37
- }), a = P(() => {
38
- var r, c;
39
- return [
40
- (r = (c = o.value) === null || c === void 0 ? void 0 : c.map((s) => T(s))) !== null && r !== void 0 ? r : [W].filter((s) => s != null),
41
- y(p(o.value ? e[1] : e[0])),
42
- y(D(o.value ? e[2] : e[1])),
43
- p(o.value ? e[3] : e[2])
44
- ];
45
- }, ([r, c, s, l]) => {
46
- if (t(), !r?.length || !c?.length || !s?.length) return;
47
- const f = L(l) ? { ...l } : l;
48
- n.push(...r.flatMap((v) => c.flatMap((d) => s.map((k) => i(v, d, k, f)))));
49
- }, { flush: "post" }), u = () => {
50
- a(), t();
51
- };
52
- return U(t), u;
53
- }
54
- // @__NO_SIDE_EFFECTS__
55
- function z() {
56
- const e = h(!1), n = j();
57
- return n && R(() => {
58
- e.value = !0;
59
- }, n), e;
60
- }
61
- // @__NO_SIDE_EFFECTS__
62
- function G(e) {
63
- const n = /* @__PURE__ */ z();
64
- return w(() => (n.value, !!e()));
65
- }
66
- const Q = Symbol("vueuse-ssr-width");
67
- // @__NO_SIDE_EFFECTS__
68
- function V() {
69
- const e = x() ? /* @__PURE__ */ A(Q, null) : null;
70
- return typeof e == "number" ? e : void 0;
71
- }
72
- function H(e, n = {}) {
73
- const { window: t = W, ssrWidth: i = /* @__PURE__ */ V() } = n, o = /* @__PURE__ */ G(() => t && "matchMedia" in t && typeof t.matchMedia == "function"), a = h(typeof i == "number"), u = h(), r = h(!1), c = (s) => {
74
- r.value = s.matches;
75
- };
76
- return O(() => {
77
- if (a.value) {
78
- a.value = !o.value, r.value = p(e).split(",").some((s) => {
79
- const l = s.includes("not all"), f = s.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), v = s.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
80
- let d = !!(f || v);
81
- return f && d && (d = i >= S(f[1])), v && d && (d = i <= S(v[1])), l ? !d : d;
82
- });
83
- return;
84
- }
85
- o.value && (u.value = t.matchMedia(p(e)), r.value = u.value.matches);
86
- }), $(u, "change", c, { passive: !0 }), w(() => r.value);
87
- }
88
- // @__NO_SIDE_EFFECTS__
89
- function X(e) {
90
- return H("(prefers-color-scheme: dark)", e);
91
- }
92
- function m(e) {
93
- for (var n = 1; n < arguments.length; n++) {
94
- var t = arguments[n];
95
- for (var i in t)
96
- e[i] = t[i];
97
- }
98
- return e;
99
- }
100
- var J = {
101
- read: function(e) {
102
- return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
103
- },
104
- write: function(e) {
105
- return encodeURIComponent(e).replace(
106
- /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
107
- decodeURIComponent
108
- );
109
- }
110
- };
111
- function C(e, n) {
112
- function t(o, a, u) {
113
- if (!(typeof document > "u")) {
114
- u = m({}, n, u), typeof u.expires == "number" && (u.expires = new Date(Date.now() + u.expires * 864e5)), u.expires && (u.expires = u.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
115
- var r = "";
116
- for (var c in u)
117
- u[c] && (r += "; " + c, u[c] !== !0 && (r += "=" + u[c].split(";")[0]));
118
- return document.cookie = o + "=" + e.write(a, o) + r;
119
- }
120
- }
121
- function i(o) {
122
- if (!(typeof document > "u" || arguments.length && !o)) {
123
- for (var a = document.cookie ? document.cookie.split("; ") : [], u = {}, r = 0; r < a.length; r++) {
124
- var c = a[r].split("="), s = c.slice(1).join("=");
125
- try {
126
- var l = decodeURIComponent(c[0]);
127
- if (u[l] = e.read(s, l), o === l)
128
- break;
129
- } catch {
130
- }
131
- }
132
- return o ? u[o] : u;
133
- }
134
- }
135
- return Object.create(
136
- {
137
- set: t,
138
- get: i,
139
- remove: function(o, a) {
140
- t(
141
- o,
142
- "",
143
- m({}, a, {
144
- expires: -1
145
- })
146
- );
147
- },
148
- withAttributes: function(o) {
149
- return C(this.converter, m({}, this.attributes, o));
150
- },
151
- withConverter: function(o) {
152
- return C(m({}, this.converter, o), this.attributes);
153
- }
154
- },
155
- {
156
- attributes: { value: Object.freeze(n) },
157
- converter: { value: Object.freeze(e) }
158
- }
159
- );
160
- }
161
- var Y = C(J, { path: "/" });
162
- function Z(e) {
163
- return { all: e = e || /* @__PURE__ */ new Map(), on: function(n, t) {
164
- var i = e.get(n);
165
- i ? i.push(t) : e.set(n, [t]);
166
- }, off: function(n, t) {
167
- var i = e.get(n);
168
- i && (t ? i.splice(i.indexOf(t) >>> 0, 1) : e.set(n, []));
169
- }, emit: function(n, t) {
170
- var i = e.get(n);
171
- i && i.slice().map(function(o) {
172
- o(t);
173
- }), (i = e.get("*")) && i.slice().map(function(o) {
174
- o(n, t);
175
- });
176
- } };
177
- }
178
- export {
179
- Y as a,
180
- Z as m,
181
- X as u
182
- };