@dxtmisha/functional 1.0.9 → 1.2.0

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.
@@ -394,7 +394,8 @@ function j(s) {
394
394
  function st(s, t) {
395
395
  return C(s) ? !1 : Array.isArray(t) ? t.includes(s) : P(s) && P(t) ? j(s) === j(t) : s === t;
396
396
  }
397
- let M = "ui-storage";
397
+ const R = {};
398
+ let k = "ui-storage";
398
399
  class it {
399
400
  /**
400
401
  * Constructor
@@ -406,8 +407,7 @@ class it {
406
407
  const i = `${e ? "session" : "storage"}#${t}`;
407
408
  if (i in R)
408
409
  return R[i];
409
- const n = this.getValue();
410
- n && (this.value = n.value, this.age = n.age), R[i] = this;
410
+ this.make(), R[i] = this;
411
411
  }
412
412
  /**
413
413
  * Changing the prefix in key names. Should be called at the beginning of the code.
@@ -416,7 +416,7 @@ class it {
416
416
  * @param newPrefix new prefix/ новый префикс
417
417
  */
418
418
  static setPrefix(t) {
419
- M = t;
419
+ k = t;
420
420
  }
421
421
  value;
422
422
  age;
@@ -453,6 +453,14 @@ class it {
453
453
  remove() {
454
454
  return this.getMethod()?.removeItem(this.getIndex()), this;
455
455
  }
456
+ /**
457
+ * Clearing all data from storage.
458
+ *
459
+ * Очистка всех данных из хранилища.
460
+ */
461
+ update() {
462
+ return this.make(), this;
463
+ }
456
464
  /**
457
465
  * Checks for storage time limit.
458
466
  *
@@ -477,7 +485,7 @@ class it {
477
485
  * Получение имени ключа в хранилище.
478
486
  */
479
487
  getIndex() {
480
- return `${M}${this.name}`;
488
+ return `${k}__${this.name}`;
481
489
  }
482
490
  /**
483
491
  * Getting data from storage.
@@ -493,8 +501,17 @@ class it {
493
501
  console.error("DataStorage", e);
494
502
  }
495
503
  }
504
+ /**
505
+ * Filling in the data from storage.
506
+ *
507
+ * Заполнение данными из хранилища.
508
+ */
509
+ make() {
510
+ const t = this.getValue();
511
+ return t ? (this.value = t.value, this.age = t.age) : (this.value = void 0, this.age = void 0), this;
512
+ }
496
513
  }
497
- const R = {}, nt = "geo-code", o = class o {
514
+ const nt = "geo-code", o = class o {
498
515
  /**
499
516
  * Information about the current country.
500
517
  *
@@ -714,7 +731,7 @@ const R = {}, nt = "geo-code", o = class o {
714
731
  l(o, "storage", new it(nt)), l(o, "location"), l(o, "item"), l(o, "language"), l(o, "timezone", (/* @__PURE__ */ new Date()).getTimezoneOffset()), o.location = o.findLocation(), o.language = o.findLanguage(o.location), o.item = o.getByCode(o.location);
715
732
  let w = o;
716
733
  var rt = /* @__PURE__ */ ((s) => (s.get = "GET", s.post = "POST", s.put = "PUT", s.delete = "DELETE", s))(rt || {});
717
- const x = "d-response-loading", k = [];
734
+ const M = "d-response-loading", x = [];
718
735
  class m {
719
736
  static url = "/api/";
720
737
  static response = [];
@@ -986,14 +1003,14 @@ class m {
986
1003
  */
987
1004
  static getResponse(t = "", e, i, n) {
988
1005
  return this.response.find((r) => {
989
- if (I(D(r?.disable)) !== !0 && (r.path instanceof RegExp && t.match(r.path) || t === r.path) && e === r.method && (k.indexOf(r) === -1 || n)) {
1006
+ if (I(D(r?.disable)) !== !0 && (r.path instanceof RegExp && t.match(r.path) || t === r.path) && e === r.method && (x.indexOf(r) === -1 || n)) {
990
1007
  const a = this.addRequestDefault(r?.request);
991
- let h = !1;
992
- if (i === a || a === "*any" ? h = !0 : E(i) && E(a) && p(i) && p(a) && !(i instanceof FormData) && !(a instanceof FormData) && Object.values(i).length === Object.values(a).length && (h = Object.entries(a).reduce(
993
- (u, [c, f]) => u && (f === i?.[c] || f === "*any"),
1008
+ let c = !1;
1009
+ if (i === a || a === "*any" ? c = !0 : E(i) && E(a) && p(i) && p(a) && !(i instanceof FormData) && !(a instanceof FormData) && Object.values(i).length === Object.values(a).length && (c = Object.entries(a).reduce(
1010
+ (u, [h, f]) => u && (f === i?.[h] || f === "*any"),
994
1011
  !0
995
- )), h)
996
- return n && console.warn(`Response type: ${r.path}`), k.push(r), !0;
1012
+ )), c)
1013
+ return n && console.warn(`Response type: ${r.path}`), x.push(r), !0;
997
1014
  }
998
1015
  return !1;
999
1016
  });
@@ -1011,19 +1028,19 @@ class m {
1011
1028
  queryReturn: n = void 0,
1012
1029
  globalPreparation: r = !0,
1013
1030
  globalEnd: a = !0
1014
- } = t, h = await this.makeEmulator(t);
1015
- if (h)
1016
- return h;
1031
+ } = t, c = await this.makeEmulator(t);
1032
+ if (c)
1033
+ return c;
1017
1034
  let u = {};
1018
1035
  d.show();
1019
1036
  try {
1020
1037
  this.preparationItem && r && await this.makePreparation();
1021
- const c = await this.makeQuery(t), f = a && this.preparationEndItem ? await this.makePreparationEnd(c) : {};
1022
- if (this.status = c.status, this.statusText = c.statusText, f?.reset)
1038
+ const h = await this.makeQuery(t), f = a && this.preparationEndItem ? await this.makePreparationEnd(h) : {};
1039
+ if (this.status = h.status, this.statusText = h.statusText, f?.reset)
1023
1040
  return d.hide(), await this.fetch(t);
1024
- n ? u = await n(c) : "data" in f ? u = f.data : (c.headers.get("Content-Type") ?? "").match("application/json") ? u = await c.json() : u = { data: await c.text() };
1025
- } catch (c) {
1026
- i && console.error("Api: ", c), this.error = c;
1041
+ n ? u = await n(h) : "data" in f ? u = f.data : (h.headers.get("Content-Type") ?? "").match("application/json") ? u = await h.json() : u = { data: await h.text() };
1042
+ } catch (h) {
1043
+ i && console.error("Api: ", h), this.error = h;
1027
1044
  }
1028
1045
  return d.hide(), this.makeData(u, e);
1029
1046
  }
@@ -1057,9 +1074,9 @@ class m {
1057
1074
  devMode: r = !1
1058
1075
  } = t;
1059
1076
  if (n || r) {
1060
- const a = this.addRequestDefault(t.request), h = this.getResponse(e, i, a, r);
1061
- if (h) {
1062
- const u = await this.fetchResponse(h, a);
1077
+ const a = this.addRequestDefault(t.request), c = this.getResponse(e, i, a, r);
1078
+ if (c) {
1079
+ const u = await this.fetchResponse(c, a);
1063
1080
  return r && console.warn("Response data:", e, a, u), u;
1064
1081
  }
1065
1082
  }
@@ -1076,11 +1093,11 @@ class m {
1076
1093
  path: n = "",
1077
1094
  pathFull: r = void 0,
1078
1095
  method: a = "GET",
1079
- headers: h = {},
1096
+ headers: c = {},
1080
1097
  type: u = "application/json;charset=UTF-8",
1081
- init: c = {}
1082
- } = t, f = r ?? this.getUrl(n, i), Z = `${f}${this.getBodyForGet(e, f, a)}`, N = this.getHeaders(h, u), A = {
1083
- ...c,
1098
+ init: h = {}
1099
+ } = t, f = r ?? this.getUrl(n, i), Z = `${f}${this.getBodyForGet(e, f, a)}`, N = this.getHeaders(c, u), A = {
1100
+ ...h,
1084
1101
  method: a,
1085
1102
  body: this.getBody(e, a)
1086
1103
  };
@@ -1131,7 +1148,7 @@ class m {
1131
1148
  * Включить загрузку для эмуляции запроса.
1132
1149
  */
1133
1150
  static startResponseLoading() {
1134
- this.responseLoading && clearTimeout(this.responseLoading), g() && document.body.classList.add(x);
1151
+ this.responseLoading && clearTimeout(this.responseLoading), g() && document.body.classList.add(M);
1135
1152
  }
1136
1153
  /**
1137
1154
  * Disable loading for request emulation.
@@ -1140,7 +1157,7 @@ class m {
1140
1157
  */
1141
1158
  static stopResponseLoading() {
1142
1159
  this.responseLoading = setTimeout(() => {
1143
- this.responseLoading = void 0, g() && document.body.classList.remove(x);
1160
+ this.responseLoading = void 0, g() && document.body.classList.remove(M);
1144
1161
  }, 1200);
1145
1162
  }
1146
1163
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * A class to handle BroadcastChannel messaging.
3
+ *
4
+ * Класс для работы с сообщениями BroadcastChannel.
5
+ */
6
+ export declare class BroadcastMessage<Message = any> {
7
+ protected callback?: ((event: MessageEvent<Message>) => void) | undefined;
8
+ protected channel?: BroadcastChannel;
9
+ /**
10
+ * Constructor
11
+ * @param name channel name/ название канала
12
+ * @param callback callback on message received/ колбэк на получение сообщения
13
+ */
14
+ constructor(name: string, callback?: ((event: MessageEvent<Message>) => void) | undefined);
15
+ /**
16
+ * Send a message to the channel.
17
+ *
18
+ * Отправить сообщение в канал.
19
+ * @param message message to send/ сообщение для отправки
20
+ */
21
+ post(message: Message): this;
22
+ /**
23
+ * Set the callback function to be called when a message is received.
24
+ *
25
+ * Установить функцию колбэка, которая будет вызвана при получении сообщения.
26
+ * @param callback callback function/ функция колбэка
27
+ */
28
+ setCallback(callback: (event: MessageEvent<Message>) => void): this;
29
+ /**
30
+ * Update state on message received.
31
+ *
32
+ * Обновление состояния при получении сообщения.
33
+ * @param event message event/ событие сообщения
34
+ */
35
+ protected readonly update: (event: MessageEvent<Message>) => this;
36
+ }
@@ -48,5 +48,11 @@ export declare class Cookie<T> {
48
48
  * Обновление данных cookie.
49
49
  */
50
50
  private update;
51
+ /**
52
+ * Update data from cookies.
53
+ *
54
+ * Обновляет данные из cookies.
55
+ */
56
+ static updateData(): void;
51
57
  }
52
58
  export {};
@@ -42,6 +42,12 @@ export declare class DataStorage<T> {
42
42
  * Удаление данных из хранилища.
43
43
  */
44
44
  remove(): this;
45
+ /**
46
+ * Clearing all data from storage.
47
+ *
48
+ * Очистка всех данных из хранилища.
49
+ */
50
+ update(): this;
45
51
  /**
46
52
  * Checks for storage time limit.
47
53
  *
@@ -67,4 +73,10 @@ export declare class DataStorage<T> {
67
73
  * Получение данных из хранилища.
68
74
  */
69
75
  private getValue;
76
+ /**
77
+ * Filling in the data from storage.
78
+ *
79
+ * Заполнение данными из хранилища.
80
+ */
81
+ private make;
70
82
  }
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ type BroadcastValueItem<T> = T | string | undefined;
3
+ /**
4
+ * Creates a reactive variable to manage data between browser tabs.
5
+ *
6
+ * Создает реактивную переменную для управления данными между вкладками браузера.
7
+ * @param name value name/ название значения
8
+ * @param defaultValue default value/ значение по умолчанию
9
+ */
10
+ export declare function useBroadcastValueRef<T>(name: string, defaultValue?: T | string | (() => (T | string))): Ref<BroadcastValueItem<T>>;
11
+ export {};
package/dist/flags.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import g from "@dxtmisha/media/flags";
2
- import { I as a } from "./Icons-C2lZhD4l.js";
2
+ import { I as a } from "./Icons-Bp74_rUm.js";
3
3
  const f = () => {
4
4
  a.add("flag-ad", g.AdSvg), a.add("flag-ae", g.AeSvg), a.add("flag-af", g.AfSvg), a.add("flag-ag", g.AgSvg), a.add("flag-ai", g.AiSvg), a.add("flag-al", g.AlSvg), a.add("flag-am", g.AmSvg), a.add("flag-an", g.AnSvg), a.add("flag-ao", g.AoSvg), a.add("flag-aq", g.AqSvg), a.add("flag-ar", g.ArSvg), a.add("flag-as", g.AsSvg), a.add("flag-at", g.AtSvg), a.add("flag-au", g.AuSvg), a.add("flag-aw", g.AwSvg), a.add("flag-ax", g.AxSvg), a.add("flag-az", g.AzSvg), a.add("flag-ba", g.BaSvg), a.add("flag-bb", g.BbSvg), a.add("flag-bd", g.BdSvg), a.add("flag-be", g.BeSvg), a.add("flag-bf", g.BfSvg), a.add("flag-bg", g.BgSvg), a.add("flag-bh", g.BhSvg), a.add("flag-bi", g.BiSvg), a.add("flag-bj", g.BjSvg), a.add("flag-bl", g.BlSvg), a.add("flag-bm", g.BmSvg), a.add("flag-bn", g.BnSvg), a.add("flag-bo", g.BoSvg), a.add("flag-bq", g.BqSvg), a.add("flag-br", g.BrSvg), a.add("flag-bs", g.BsSvg), a.add("flag-bt", g.BtSvg), a.add("flag-bv", g.BvSvg), a.add("flag-bw", g.BwSvg), a.add("flag-by", g.BySvg), a.add("flag-bz", g.BzSvg), a.add("flag-ca", g.CaSvg), a.add("flag-cc", g.CcSvg), a.add("flag-cd", g.CdSvg), a.add("flag-cf", g.CfSvg), a.add("flag-cg", g.CgSvg), a.add("flag-ch", g.ChSvg), a.add("flag-ci", g.CiSvg), a.add("flag-ck", g.CkSvg), a.add("flag-cl", g.ClSvg), a.add("flag-cm", g.CmSvg), a.add("flag-cn", g.CnSvg), a.add("flag-co", g.CoSvg), a.add("flag-cr", g.CrSvg), a.add("flag-cu", g.CuSvg), a.add("flag-cv", g.CvSvg), a.add("flag-cw", g.CwSvg), a.add("flag-cx", g.CxSvg), a.add("flag-cy", g.CySvg), a.add("flag-cz", g.CzSvg), a.add("flag-de", g.DeSvg), a.add("flag-dj", g.DjSvg), a.add("flag-dk", g.DkSvg), a.add("flag-dm", g.DmSvg), a.add("flag-do", g.DoSvg), a.add("flag-dz", g.DzSvg), a.add("flag-ec", g.EcSvg), a.add("flag-ee", g.EeSvg), a.add("flag-eg", g.EgSvg), a.add("flag-eh", g.EhSvg), a.add("flag-er", g.ErSvg), a.add("flag-es", g.EsSvg), a.add("flag-et", g.EtSvg), a.add("flag-fi", g.FiSvg), a.add("flag-fj", g.FjSvg), a.add("flag-fk", g.FkSvg), a.add("flag-fm", g.FmSvg), a.add("flag-fo", g.FoSvg), a.add("flag-fr", g.FrSvg), a.add("flag-ga", g.GaSvg), a.add("flag-gb", g.GbSvg), a.add("flag-gd", g.GdSvg), a.add("flag-ge", g.GeSvg), a.add("flag-gf", g.GfSvg), a.add("flag-gg", g.GgSvg), a.add("flag-gh", g.GhSvg), a.add("flag-gi", g.GiSvg), a.add("flag-gl", g.GlSvg), a.add("flag-gm", g.GmSvg), a.add("flag-gn", g.GnSvg), a.add("flag-gp", g.GpSvg), a.add("flag-gq", g.GqSvg), a.add("flag-gr", g.GrSvg), a.add("flag-gt", g.GtSvg), a.add("flag-gu", g.GuSvg), a.add("flag-gw", g.GwSvg), a.add("flag-gy", g.GySvg), a.add("flag-hk", g.HkSvg), a.add("flag-hm", g.HmSvg), a.add("flag-hn", g.HnSvg), a.add("flag-hr", g.HrSvg), a.add("flag-ht", g.HtSvg), a.add("flag-hu", g.HuSvg), a.add("flag-id", g.IdSvg), a.add("flag-ie", g.IeSvg), a.add("flag-il", g.IlSvg), a.add("flag-im", g.ImSvg), a.add("flag-in", g.InSvg), a.add("flag-io", g.IoSvg), a.add("flag-iq", g.IqSvg), a.add("flag-ir", g.IrSvg), a.add("flag-is", g.IsSvg), a.add("flag-it", g.ItSvg), a.add("flag-je", g.JeSvg), a.add("flag-jm", g.JmSvg), a.add("flag-jo", g.JoSvg), a.add("flag-jp", g.JpSvg), a.add("flag-ke", g.KeSvg), a.add("flag-kg", g.KgSvg), a.add("flag-kh", g.KhSvg), a.add("flag-ki", g.KiSvg), a.add("flag-km", g.KmSvg), a.add("flag-kn", g.KnSvg), a.add("flag-kp", g.KpSvg), a.add("flag-kr", g.KrSvg), a.add("flag-kw", g.KwSvg), a.add("flag-ky", g.KySvg), a.add("flag-kz", g.KzSvg), a.add("flag-la", g.LaSvg), a.add("flag-lb", g.LbSvg), a.add("flag-lc", g.LcSvg), a.add("flag-li", g.LiSvg), a.add("flag-lk", g.LkSvg), a.add("flag-lr", g.LrSvg), a.add("flag-ls", g.LsSvg), a.add("flag-lt", g.LtSvg), a.add("flag-lu", g.LuSvg), a.add("flag-lv", g.LvSvg), a.add("flag-ly", g.LySvg), a.add("flag-ma", g.MaSvg), a.add("flag-mc", g.McSvg), a.add("flag-md", g.MdSvg), a.add("flag-me", g.MeSvg), a.add("flag-mf", g.MfSvg), a.add("flag-mg", g.MgSvg), a.add("flag-mh", g.MhSvg), a.add("flag-mk", g.MkSvg), a.add("flag-ml", g.MlSvg), a.add("flag-mm", g.MmSvg), a.add("flag-mn", g.MnSvg), a.add("flag-mo", g.MoSvg), a.add("flag-mp", g.MpSvg), a.add("flag-mq", g.MqSvg), a.add("flag-mr", g.MrSvg), a.add("flag-ms", g.MsSvg), a.add("flag-mt", g.MtSvg), a.add("flag-mu", g.MuSvg), a.add("flag-mv", g.MvSvg), a.add("flag-mw", g.MwSvg), a.add("flag-mx", g.MxSvg), a.add("flag-my", g.MySvg), a.add("flag-mz", g.MzSvg), a.add("flag-na", g.NaSvg), a.add("flag-nc", g.NcSvg), a.add("flag-ne", g.NeSvg), a.add("flag-nf", g.NfSvg), a.add("flag-ng", g.NgSvg), a.add("flag-ni", g.NiSvg), a.add("flag-nl", g.NlSvg), a.add("flag-no", g.NoSvg), a.add("flag-np", g.NpSvg), a.add("flag-nr", g.NrSvg), a.add("flag-nu", g.NuSvg), a.add("flag-nz", g.NzSvg), a.add("flag-om", g.OmSvg), a.add("flag-pa", g.PaSvg), a.add("flag-pe", g.PeSvg), a.add("flag-pf", g.PfSvg), a.add("flag-pg", g.PgSvg), a.add("flag-ph", g.PhSvg), a.add("flag-pk", g.PkSvg), a.add("flag-pl", g.PlSvg), a.add("flag-pm", g.PmSvg), a.add("flag-pn", g.PnSvg), a.add("flag-pr", g.PrSvg), a.add("flag-ps", g.PsSvg), a.add("flag-pt", g.PtSvg), a.add("flag-pw", g.PwSvg), a.add("flag-py", g.PySvg), a.add("flag-qa", g.QaSvg), a.add("flag-re", g.ReSvg), a.add("flag-ro", g.RoSvg), a.add("flag-rs", g.RsSvg), a.add("flag-ru", g.RuSvg), a.add("flag-rw", g.RwSvg), a.add("flag-sa", g.SaSvg), a.add("flag-sb", g.SbSvg), a.add("flag-sc", g.ScSvg), a.add("flag-sd", g.SdSvg), a.add("flag-se", g.SeSvg), a.add("flag-sg", g.SgSvg), a.add("flag-sh", g.ShSvg), a.add("flag-si", g.SiSvg), a.add("flag-sj", g.SjSvg), a.add("flag-sk", g.SkSvg), a.add("flag-sl", g.SlSvg), a.add("flag-sm", g.SmSvg), a.add("flag-sn", g.SnSvg), a.add("flag-so", g.SoSvg), a.add("flag-sr", g.SrSvg), a.add("flag-ss", g.SsSvg), a.add("flag-st", g.StSvg), a.add("flag-sv", g.SvSvg), a.add("flag-sx", g.SxSvg), a.add("flag-sy", g.SySvg), a.add("flag-sz", g.SzSvg), a.add("flag-tc", g.TcSvg), a.add("flag-td", g.TdSvg), a.add("flag-tg", g.TgSvg), a.add("flag-th", g.ThSvg), a.add("flag-tj", g.TjSvg), a.add("flag-tk", g.TkSvg), a.add("flag-tl", g.TlSvg), a.add("flag-tm", g.TmSvg), a.add("flag-tn", g.TnSvg), a.add("flag-to", g.ToSvg), a.add("flag-tr", g.TrSvg), a.add("flag-tt", g.TtSvg), a.add("flag-tv", g.TvSvg), a.add("flag-tw", g.TwSvg), a.add("flag-tz", g.TzSvg), a.add("flag-ua", g.UaSvg), a.add("flag-ug", g.UgSvg), a.add("flag-us", g.UsSvg), a.add("flag-uy", g.UySvg), a.add("flag-uz", g.UzSvg), a.add("flag-va", g.VaSvg), a.add("flag-vc", g.VcSvg), a.add("flag-ve", g.VeSvg), a.add("flag-vg", g.VgSvg), a.add("flag-vi", g.ViSvg), a.add("flag-vn", g.VnSvg), a.add("flag-vu", g.VuSvg), a.add("flag-wf", g.WfSvg), a.add("flag-ws", g.WsSvg), a.add("flag-ye", g.YeSvg), a.add("flag-yt", g.YtSvg), a.add("flag-za", g.ZaSvg), a.add("flag-zm", g.ZmSvg), a.add("flag-zw", g.ZwSvg);
5
5
  };
package/dist/library.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './classes/Api';
2
+ export * from './classes/BroadcastMessage';
2
3
  export * from './classes/Cache';
3
4
  export * from './classes/CacheItem';
4
5
  export * from './classes/CacheStatic';
@@ -32,6 +33,7 @@ export * from './classes/ref/ListDataRef';
32
33
  export * from './classes/ref/RouterItemRef';
33
34
  export * from './classes/ref/ScrollbarWidthRef';
34
35
  export * from './composables/ref/useApiRef';
36
+ export * from './composables/ref/useBroadcastValueRef';
35
37
  export * from './composables/ref/useCookieRef';
36
38
  export * from './composables/ref/useGeoIntlRef';
37
39
  export * from './composables/ref/useHashRef';