@endge/utils 0.24.0 → 0.24.2
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.d.ts +1 -1
- package/dist/utils.js +38 -31
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -241,7 +241,7 @@ export declare class EventBus<StaticEvents extends Record<string, any>, CustomEv
|
|
|
241
241
|
/**
|
|
242
242
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
243
243
|
*/
|
|
244
|
-
constructor(predefinedEvents
|
|
244
|
+
constructor(predefinedEvents?: Array<keyof StaticEvents>);
|
|
245
245
|
/**
|
|
246
246
|
* Обрабатывает входящее событие EventBus.
|
|
247
247
|
*/
|
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var L = Object.defineProperty;
|
|
2
2
|
var k = (r, t, e) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var a = (r, t, e) => k(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { ref as y, watch as O, triggerRef as A, onScopeDispose as P, reactive as
|
|
5
|
-
import { parse as
|
|
4
|
+
import { ref as y, watch as O, triggerRef as A, onScopeDispose as P, reactive as R } from "vue";
|
|
5
|
+
import { parse as z, serialize as I } from "cookie-es";
|
|
6
6
|
import { destr as H } from "destr";
|
|
7
7
|
import { plainToInstance as b, instanceToPlain as S, Transform as u, TransformationType as d, Expose as U } from "class-transformer";
|
|
8
8
|
import { IsOptional as j } from "class-validator";
|
|
@@ -10,8 +10,8 @@ import "reflect-metadata";
|
|
|
10
10
|
import v from "lodash/debounce.js";
|
|
11
11
|
import { v4 as B } from "uuid";
|
|
12
12
|
import { DateTime as J } from "ts-luxon";
|
|
13
|
-
import { differenceInSeconds as C, format as T, differenceInCalendarDays as K, isAfter as
|
|
14
|
-
import { utcToZonedTime as G, getTimezoneOffset as
|
|
13
|
+
import { differenceInSeconds as C, format as T, differenceInCalendarDays as K, isAfter as _, isEqual as V, isBefore as F, startOfDay as p, endOfDay as Z } from "date-fns";
|
|
14
|
+
import { utcToZonedTime as G, getTimezoneOffset as w } from "date-fns-tz";
|
|
15
15
|
import { fetchEventSource as W, EventStreamContentType as Y } from "@microsoft/fetch-event-source";
|
|
16
16
|
import { defineStore as q } from "pinia";
|
|
17
17
|
const Q = {
|
|
@@ -21,7 +21,7 @@ const Q = {
|
|
|
21
21
|
encode: (r) => encodeURIComponent(typeof r == "string" ? r : JSON.stringify(r))
|
|
22
22
|
}, xt = (r, t) => {
|
|
23
23
|
var s;
|
|
24
|
-
const e = { ...Q, ...t || {} }, n =
|
|
24
|
+
const e = { ...Q, ...t || {} }, n = z(document.cookie, e), i = y(n[r] ?? ((s = e.default) == null ? void 0 : s.call(e)));
|
|
25
25
|
return O(i, () => {
|
|
26
26
|
document.cookie = X(r, i.value, e);
|
|
27
27
|
}), i;
|
|
@@ -34,7 +34,7 @@ class M {
|
|
|
34
34
|
/**
|
|
35
35
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
36
36
|
*/
|
|
37
|
-
constructor(t) {
|
|
37
|
+
constructor(t = []) {
|
|
38
38
|
a(this, "listeners", /* @__PURE__ */ new Map());
|
|
39
39
|
t.forEach((e) => {
|
|
40
40
|
this.listeners.set(e, /* @__PURE__ */ new Set());
|
|
@@ -742,10 +742,10 @@ function Pt() {
|
|
|
742
742
|
Reflect.defineMetadata(tt, t, r);
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
|
-
function
|
|
745
|
+
function Rt(r, t, e) {
|
|
746
746
|
r.__afterDeserializeMethods__ || (r.__afterDeserializeMethods__ = []), r.__afterDeserializeMethods__.push(t);
|
|
747
747
|
}
|
|
748
|
-
function
|
|
748
|
+
function zt(r) {
|
|
749
749
|
return function(t, e) {
|
|
750
750
|
u(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), j(r)(t, e);
|
|
751
751
|
};
|
|
@@ -1211,15 +1211,23 @@ class ae {
|
|
|
1211
1211
|
*/
|
|
1212
1212
|
async runAsync(t, e = /* @__PURE__ */ new Set()) {
|
|
1213
1213
|
const n = Object.keys(t), i = Object.fromEntries(
|
|
1214
|
-
n.map((
|
|
1214
|
+
n.map((c) => [c, this.wrapIfAsync(t[c])])
|
|
1215
1215
|
), s = Array.from(e), o = s.length > 0 ? `
|
|
1216
1216
|
|
|
1217
1217
|
expose({ ${s.join(", ")} });
|
|
1218
1218
|
` : "", l = `${this.script}${o}`;
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1219
|
+
try {
|
|
1220
|
+
return await new Function(
|
|
1221
|
+
...n,
|
|
1222
|
+
`"use strict"; return (async () => { ${l} })();`
|
|
1223
|
+
)(...Object.values(i));
|
|
1224
|
+
} catch (c) {
|
|
1225
|
+
console.warn(
|
|
1226
|
+
"(ScriptRunner.runAsync): Ошибка в скрипте:",
|
|
1227
|
+
l,
|
|
1228
|
+
c
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1223
1231
|
}
|
|
1224
1232
|
/**
|
|
1225
1233
|
* Синхронно вычисляет выражение в контексте.
|
|
@@ -1237,7 +1245,7 @@ expose({ ${s.join(", ")} });
|
|
|
1237
1245
|
)(...i);
|
|
1238
1246
|
} catch (l) {
|
|
1239
1247
|
console.warn(
|
|
1240
|
-
"(ScriptRunner.runSync): Ошибка в
|
|
1248
|
+
"(ScriptRunner.runSync): Ошибка в скрипте:",
|
|
1241
1249
|
this.script,
|
|
1242
1250
|
l
|
|
1243
1251
|
);
|
|
@@ -1249,7 +1257,6 @@ expose({ ${s.join(", ")} });
|
|
|
1249
1257
|
*/
|
|
1250
1258
|
evaluate(t) {
|
|
1251
1259
|
const e = Object.keys(t), n = Object.values(t);
|
|
1252
|
-
console.log(t);
|
|
1253
1260
|
try {
|
|
1254
1261
|
return new Function(
|
|
1255
1262
|
...e,
|
|
@@ -1257,7 +1264,7 @@ expose({ ${s.join(", ")} });
|
|
|
1257
1264
|
)(...n);
|
|
1258
1265
|
} catch (i) {
|
|
1259
1266
|
console.warn(
|
|
1260
|
-
"(ScriptRunner.
|
|
1267
|
+
"(ScriptRunner.evaluate): Ошибка в выражении:",
|
|
1261
1268
|
this.script,
|
|
1262
1269
|
i
|
|
1263
1270
|
);
|
|
@@ -1317,14 +1324,14 @@ function ue(r) {
|
|
|
1317
1324
|
return String(r).charAt(0).toUpperCase() + String(r).slice(1);
|
|
1318
1325
|
}
|
|
1319
1326
|
function fe(r, t) {
|
|
1320
|
-
return
|
|
1327
|
+
return _(r, t) || V(r, t);
|
|
1321
1328
|
}
|
|
1322
1329
|
function he(r, t, e, n) {
|
|
1323
1330
|
const i = p(r), s = p(t), o = p(e), l = p(n);
|
|
1324
|
-
return !F(s, o) && !
|
|
1331
|
+
return !F(s, o) && !_(i, l);
|
|
1325
1332
|
}
|
|
1326
1333
|
function de(r, t, e) {
|
|
1327
|
-
return !F(r, p(t)) && !
|
|
1334
|
+
return !F(r, p(t)) && !_(r, Z(e));
|
|
1328
1335
|
}
|
|
1329
1336
|
const me = (r) => r && new Date(r);
|
|
1330
1337
|
function pe(r, t = "HH:mm dd.MM.yyyy", e = {}) {
|
|
@@ -1364,14 +1371,14 @@ function Se(r, t) {
|
|
|
1364
1371
|
const e = C(r, t), { hours: n, minutes: i } = x(e);
|
|
1365
1372
|
return n || i ? `${e > 0 ? "-" : "+"}${h(n)}:${h(i)}` : "";
|
|
1366
1373
|
}
|
|
1367
|
-
function
|
|
1374
|
+
function we(r, t) {
|
|
1368
1375
|
const e = C(r, t), { hours: n, minutes: i } = x(e);
|
|
1369
1376
|
return n || i ? `${e > 0 ? "-" : ""}${h(n)}:${h(i)}` : "";
|
|
1370
1377
|
}
|
|
1371
1378
|
function E(r = /* @__PURE__ */ new Date()) {
|
|
1372
1379
|
return new Date(r.getFullYear(), r.getMonth(), r.getDate());
|
|
1373
1380
|
}
|
|
1374
|
-
function
|
|
1381
|
+
function _e(r, t) {
|
|
1375
1382
|
const e = K(E(r), E(t));
|
|
1376
1383
|
return e ? e > 7 ? {
|
|
1377
1384
|
variant: "red",
|
|
@@ -1488,9 +1495,9 @@ function h(r) {
|
|
|
1488
1495
|
function Me(r) {
|
|
1489
1496
|
const t = /* @__PURE__ */ new Date();
|
|
1490
1497
|
try {
|
|
1491
|
-
const e =
|
|
1498
|
+
const e = w(r, t), n = Intl.supportedValuesOf("timeZone");
|
|
1492
1499
|
for (const i of n)
|
|
1493
|
-
if (
|
|
1500
|
+
if (w(i, t) === e)
|
|
1494
1501
|
return i;
|
|
1495
1502
|
} catch {
|
|
1496
1503
|
return null;
|
|
@@ -1498,7 +1505,7 @@ function Me(r) {
|
|
|
1498
1505
|
return null;
|
|
1499
1506
|
}
|
|
1500
1507
|
function $e(r) {
|
|
1501
|
-
return
|
|
1508
|
+
return w(r, /* @__PURE__ */ new Date());
|
|
1502
1509
|
}
|
|
1503
1510
|
class Ne {
|
|
1504
1511
|
constructor(t) {
|
|
@@ -1586,7 +1593,7 @@ class Le {
|
|
|
1586
1593
|
}
|
|
1587
1594
|
}
|
|
1588
1595
|
const ke = q("tooltip", () => {
|
|
1589
|
-
const r =
|
|
1596
|
+
const r = R({}), t = y(null);
|
|
1590
1597
|
function e(c) {
|
|
1591
1598
|
r[c.id] = {
|
|
1592
1599
|
...c,
|
|
@@ -1623,9 +1630,9 @@ function Pe(r, t) {
|
|
|
1623
1630
|
var e;
|
|
1624
1631
|
return r("div", {}, (e = t.slots) != null && e.default ? t.slots.default() : []);
|
|
1625
1632
|
}
|
|
1626
|
-
const
|
|
1633
|
+
const Re = "x-collection-tooltip-id";
|
|
1627
1634
|
export {
|
|
1628
|
-
|
|
1635
|
+
Rt as AfterDeserialize,
|
|
1629
1636
|
It as AppBus,
|
|
1630
1637
|
Pt as BeforeSerialize,
|
|
1631
1638
|
Ot as Collection,
|
|
@@ -1639,7 +1646,7 @@ export {
|
|
|
1639
1646
|
rt as IS_DEBUG,
|
|
1640
1647
|
Bt as IgnoreToPlain,
|
|
1641
1648
|
At as IndexedCollection,
|
|
1642
|
-
|
|
1649
|
+
zt as IsOptionalTransformed,
|
|
1643
1650
|
Zt as Json,
|
|
1644
1651
|
Gt as JsonString,
|
|
1645
1652
|
$t as NamedExecutor,
|
|
@@ -1654,7 +1661,7 @@ export {
|
|
|
1654
1661
|
se as StructuredLogger,
|
|
1655
1662
|
$ as Subscribable,
|
|
1656
1663
|
st as SystemClock,
|
|
1657
|
-
|
|
1664
|
+
Re as TooltipAttribute,
|
|
1658
1665
|
Pe as TooltipRegistrator,
|
|
1659
1666
|
Yt as TypeMap,
|
|
1660
1667
|
qt as TypeRecord,
|
|
@@ -1663,7 +1670,7 @@ export {
|
|
|
1663
1670
|
Xt as compareNumber,
|
|
1664
1671
|
oe as createInstance,
|
|
1665
1672
|
Se as diffDuration,
|
|
1666
|
-
|
|
1673
|
+
we as diffDurationTable,
|
|
1667
1674
|
le as dt,
|
|
1668
1675
|
Te as extractTime,
|
|
1669
1676
|
be as findMinMaxDates,
|
|
@@ -1672,7 +1679,7 @@ export {
|
|
|
1672
1679
|
ot as formatDatetimeTZ,
|
|
1673
1680
|
Fe as formatDatetimeTZSpecial,
|
|
1674
1681
|
ee as generateUUID,
|
|
1675
|
-
|
|
1682
|
+
_e as getDateOnlyDiffFactor,
|
|
1676
1683
|
ye as getDayOfWeek,
|
|
1677
1684
|
et as getOnDeserializedMethod,
|
|
1678
1685
|
$e as getTimezoneOffsetMs,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endge/utils",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.24.
|
|
4
|
+
"version": "0.24.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/utils.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"uuid": "^11.0.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"pinia": "^3.0.0",
|
|
39
|
+
"pinia": "^2.1.7 || ^3.0.0",
|
|
40
40
|
"vue": "^3.5.13"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|