@apia/util 4.0.15 → 4.0.17

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.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { makeAutoObservable, makeObservable, observable } from 'mobx';
1
2
  import { jsx } from 'react/jsx-runtime';
2
3
  import * as React from 'react';
3
4
  import React__default, { useRef, useCallback, useState, useEffect, useMemo, createContext, useContext } from 'react';
4
5
  import uniqueId from 'lodash-es/uniqueId';
5
- import { makeAutoObservable } from 'mobx';
6
6
  import isFunction from 'lodash-es/isFunction';
7
7
  import dayjs from 'dayjs';
8
8
  import customParseFormat from 'dayjs/plugin/customParseFormat';
@@ -186,9 +186,21 @@ function dateToApiaFormat(date) {
186
186
  return dayjs(date).format(getDateFormat());
187
187
  }
188
188
 
189
- const isEnabled = window?.WP_DEVELOP_MODE;
189
+ const globals = {
190
+ getVersion() {
191
+ return {
192
+ version: VERSION,
193
+ commit: COMMITHASH,
194
+ branch: BRANCH,
195
+ env: ENVIRONMENT,
196
+ timestamp: TIMESTAMP,
197
+ package: PACKAGE_VERSION
198
+ };
199
+ }
200
+ };
201
+ window.Globals = globals;
190
202
  function isDebugDispatcherEnabled() {
191
- return isEnabled;
203
+ return globals.getVersion().env === "development";
192
204
  }
193
205
  const debugDispatcher = new class DDispatcher {
194
206
  constructor() {
@@ -216,7 +228,7 @@ const debugDispatcher = new class DDispatcher {
216
228
  };
217
229
  }
218
230
  on(action, cb, help, onlyDevelop = false) {
219
- if (!isEnabled && onlyDevelop)
231
+ if (!isDebugDispatcherEnabled() && onlyDevelop)
220
232
  return () => {
221
233
  };
222
234
  if (Object.keys(this.actions).includes(action))
@@ -533,43 +545,88 @@ function autoDisconnectMutationObserver(element, callback, conf) {
533
545
 
534
546
  const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;
535
547
  function findScrollContainer(el) {
536
- return !(el instanceof HTMLElement) || typeof window.getComputedStyle !== "function" ? null : el.scrollHeight >= el.clientHeight && !REGEXP_SCROLL_PARENT.test(
548
+ const found = !(el instanceof HTMLElement) || typeof window.getComputedStyle !== "function" ? null : el.scrollHeight >= el.clientHeight && !REGEXP_SCROLL_PARENT.test(
537
549
  window.getComputedStyle(el).overflowY || "visible"
538
- ) ? el : findScrollContainer(el.parentElement) || document.body;
550
+ ) ? el : findScrollContainer(el.parentElement) || document;
551
+ if (found === document.body) {
552
+ return document.body.parentElement;
553
+ }
554
+ return found;
539
555
  }
540
556
 
541
557
  function findOffsetRelativeToScrollParent(element, which = "Top") {
542
558
  const scrollParent = findScrollContainer(element);
543
- let currentElement = element;
544
559
  let offset = 0;
545
- let offsetParent = currentElement;
546
- while (currentElement && currentElement !== scrollParent && currentElement !== document.body && offsetParent !== scrollParent) {
547
- if (offsetParent !== currentElement.offsetParent) {
548
- offset += currentElement[`offset${which}`];
549
- offsetParent = currentElement.offsetParent;
550
- }
551
- currentElement = currentElement.parentElement;
560
+ let current = element;
561
+ while (current && current !== document.body && current !== scrollParent) {
562
+ offset += current[`offset${which}`];
563
+ current = current.offsetParent;
552
564
  }
553
- return offset;
565
+ const scrollAmount = scrollParent[`scroll${which}`] || 0;
566
+ return offset - scrollAmount;
554
567
  }
555
568
 
556
569
  const scrollIntervals = {};
557
- function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId = void 0) {
558
- if (scrollId) {
559
- clearTimeout(scrollIntervals[scrollId]);
570
+ function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId) {
571
+ const id = scrollId ?? `${Date.now()}_${Math.random()}`;
572
+ if (scrollIntervals[id]) {
573
+ clearTimeout(scrollIntervals[id]);
560
574
  }
561
575
  const scrollParent = findScrollContainer(element);
562
- const offsetTop = findOffsetRelativeToScrollParent(element);
563
- if (scrollParent && (scrollParent.scrollTop + fixedOffsetTop > offsetTop || (scrollParent?.clientHeight ?? Infinity) - fixedOffsetTop < element.getBoundingClientRect().height)) {
564
- scrollParent.scrollTop = offsetTop - fixedOffsetTop;
565
- } else if (scrollParent && scrollParent.scrollTop + scrollParent.clientHeight < offsetTop + element.getBoundingClientRect().height) {
566
- scrollParent.scrollTop = offsetTop;
567
- }
568
- if (tries > 0)
569
- scrollIntervals[scrollId ?? "noId"] = setTimeout(
570
- () => scrollParentIntoElement(element, fixedOffsetTop, tries - 1, timeout),
571
- timeout
572
- );
576
+ if (!scrollParent) {
577
+ return;
578
+ }
579
+ const parentRect = scrollParent.getBoundingClientRect();
580
+ const elemRect = element.getBoundingClientRect();
581
+ const topOverflow = elemRect.top - (parentRect.top + fixedOffsetTop);
582
+ const bottomOverflow = elemRect.bottom - parentRect.bottom + fixedOffsetTop;
583
+ if (topOverflow < 0) {
584
+ scrollParent.scrollTop += topOverflow;
585
+ } else if (bottomOverflow > 0) {
586
+ scrollParent.scrollTop += bottomOverflow;
587
+ }
588
+ if (tries > 0) {
589
+ scrollIntervals[id] = window.setTimeout(() => {
590
+ scrollParentIntoElement(element, fixedOffsetTop, tries - 1, timeout, id);
591
+ }, timeout);
592
+ }
593
+ }
594
+
595
+ const controller = {
596
+ direction: ""
597
+ };
598
+ makeObservable(controller, { direction: observable });
599
+ function initScrollController() {
600
+ if (controller.direction !== "")
601
+ return;
602
+ controller.direction = "both";
603
+ function setShouldShow(direction) {
604
+ controller.direction = direction;
605
+ }
606
+ const resizeObserver = new ResizeObserver(() => {
607
+ if (document.documentElement.scrollHeight === window.innerHeight)
608
+ controller.direction = "both";
609
+ });
610
+ resizeObserver.observe(document.documentElement);
611
+ let currentScroll = document.documentElement.scrollTop;
612
+ function handleScroll() {
613
+ const direction = controller.direction;
614
+ if (document.documentElement.scrollTop > currentScroll && direction !== "down") {
615
+ setShouldShow("down");
616
+ } else if (document.documentElement.scrollTop < currentScroll && direction !== "up") {
617
+ setShouldShow("up");
618
+ }
619
+ currentScroll = document.documentElement.scrollTop;
620
+ }
621
+ document.addEventListener("scroll", handleScroll);
622
+ return () => {
623
+ resizeObserver.disconnect();
624
+ document.removeEventListener("scroll", handleScroll);
625
+ };
626
+ }
627
+ initScrollController();
628
+ function useMatchScrollDirection(direction) {
629
+ return controller.direction === "both" || controller.direction === direction;
573
630
  }
574
631
 
575
632
  function usePanAndZoom(effectiveMargin = { left: 0, bottom: 0, right: 0, top: 0 }, blockZoom = true) {
@@ -708,7 +765,12 @@ const customEvents = {
708
765
  * está vacío
709
766
  */
710
767
  hidePanel: "hidePanel",
711
- showPanel: "showPanel"
768
+ showPanel: "showPanel",
769
+ /**
770
+ * Evento lanzado por formsEventsController sobre window
771
+ * cuando se termina de procesar los formularios de la tarea
772
+ */
773
+ formsReady: "formsReady"
712
774
  };
713
775
 
714
776
  const cantFocusSelector = [
@@ -760,15 +822,15 @@ function isChild(element, checkParent) {
760
822
  return !!getSpecificParent(element, checkParent);
761
823
  }
762
824
 
763
- var __accessCheck$4 = (obj, member, msg) => {
825
+ var __accessCheck$3 = (obj, member, msg) => {
764
826
  if (!member.has(obj))
765
827
  throw TypeError("Cannot " + msg);
766
828
  };
767
- var __privateGet$4 = (obj, member, getter) => {
768
- __accessCheck$4(obj, member, "read from private field");
829
+ var __privateGet$3 = (obj, member, getter) => {
830
+ __accessCheck$3(obj, member, "read from private field");
769
831
  return getter ? getter.call(obj) : member.get(obj);
770
832
  };
771
- var __privateAdd$4 = (obj, member, value) => {
833
+ var __privateAdd$3 = (obj, member, value) => {
772
834
  if (member.has(obj))
773
835
  throw TypeError("Cannot add the same private member more than once");
774
836
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
@@ -777,7 +839,7 @@ var _parameters;
777
839
  class Url {
778
840
  constructor(baseUrl, defaultAllowMultiple = true) {
779
841
  this.defaultAllowMultiple = defaultAllowMultiple;
780
- __privateAdd$4(this, _parameters, {});
842
+ __privateAdd$3(this, _parameters, {});
781
843
  const [base, query] = baseUrl.split("?");
782
844
  this.base = base;
783
845
  query?.split("&").forEach((current) => {
@@ -787,9 +849,9 @@ class Url {
787
849
  }
788
850
  addParameter(name, value, allowMultiple) {
789
851
  if (allowMultiple === void 0 && !this.defaultAllowMultiple || allowMultiple === false)
790
- __privateGet$4(this, _parameters)[name] = String(value);
852
+ __privateGet$3(this, _parameters)[name] = String(value);
791
853
  else
792
- __privateGet$4(this, _parameters)[name] = __privateGet$4(this, _parameters)[name] ? [...arrayOrArray(__privateGet$4(this, _parameters)[name]), String(value)] : [String(value)];
854
+ __privateGet$3(this, _parameters)[name] = __privateGet$3(this, _parameters)[name] ? [...arrayOrArray(__privateGet$3(this, _parameters)[name]), String(value)] : [String(value)];
793
855
  }
794
856
  addParameters(parameters) {
795
857
  parameters.forEach(
@@ -797,10 +859,10 @@ class Url {
797
859
  );
798
860
  }
799
861
  getParameter(name) {
800
- return __privateGet$4(this, _parameters)[name];
862
+ return __privateGet$3(this, _parameters)[name];
801
863
  }
802
864
  toString() {
803
- const parametersArray = Object.entries(__privateGet$4(this, _parameters));
865
+ const parametersArray = Object.entries(__privateGet$3(this, _parameters));
804
866
  return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
805
867
  ([name, value]) => Array.isArray(value) ? value.map((current) => `${name}=${current}`).join("&") : `${name}=${String(value)}`
806
868
  ).join("&")}` : ""}`;
@@ -887,7 +949,9 @@ class EventEmitter {
887
949
  on(event, cb) {
888
950
  if (!this.callbacks.on[event])
889
951
  this.callbacks.on[event] = [];
890
- this.callbacks.on[event].push(cb);
952
+ if (!this.callbacks.on[event].find((c) => c === cb)) {
953
+ this.callbacks.on[event].push(cb);
954
+ }
891
955
  return () => {
892
956
  this.callbacks.on[event] = this.callbacks.on[event].filter(
893
957
  (c) => c !== cb
@@ -1212,21 +1276,21 @@ class BouncingEmitter extends StatefulEmitter {
1212
1276
  }
1213
1277
  }
1214
1278
 
1215
- var __accessCheck$3 = (obj, member, msg) => {
1279
+ var __accessCheck$2 = (obj, member, msg) => {
1216
1280
  if (!member.has(obj))
1217
1281
  throw TypeError("Cannot " + msg);
1218
1282
  };
1219
- var __privateGet$3 = (obj, member, getter) => {
1220
- __accessCheck$3(obj, member, "read from private field");
1283
+ var __privateGet$2 = (obj, member, getter) => {
1284
+ __accessCheck$2(obj, member, "read from private field");
1221
1285
  return getter ? getter.call(obj) : member.get(obj);
1222
1286
  };
1223
- var __privateAdd$3 = (obj, member, value) => {
1287
+ var __privateAdd$2 = (obj, member, value) => {
1224
1288
  if (member.has(obj))
1225
1289
  throw TypeError("Cannot add the same private member more than once");
1226
1290
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1227
1291
  };
1228
- var __privateSet$3 = (obj, member, value, setter) => {
1229
- __accessCheck$3(obj, member, "write to private field");
1292
+ var __privateSet$2 = (obj, member, value, setter) => {
1293
+ __accessCheck$2(obj, member, "write to private field");
1230
1294
  member.set(obj, value);
1231
1295
  return value;
1232
1296
  };
@@ -1235,7 +1299,7 @@ const historySize = 50;
1235
1299
  const globalFocus = new (_a$1 = class {
1236
1300
  constructor() {
1237
1301
  this.focused = [];
1238
- __privateAdd$3(this, _onFocusCallbacks, []);
1302
+ __privateAdd$2(this, _onFocusCallbacks, []);
1239
1303
  debugDispatcher.on(
1240
1304
  "focusHistory",
1241
1305
  () => {
@@ -1245,12 +1309,12 @@ const globalFocus = new (_a$1 = class {
1245
1309
  );
1246
1310
  }
1247
1311
  offFocus(cb) {
1248
- __privateSet$3(this, _onFocusCallbacks, __privateGet$3(this, _onFocusCallbacks).filter(
1312
+ __privateSet$2(this, _onFocusCallbacks, __privateGet$2(this, _onFocusCallbacks).filter(
1249
1313
  (current) => current !== cb
1250
1314
  ));
1251
1315
  }
1252
1316
  onFocus(cb) {
1253
- __privateGet$3(this, _onFocusCallbacks).push(cb);
1317
+ __privateGet$2(this, _onFocusCallbacks).push(cb);
1254
1318
  return () => {
1255
1319
  this.offFocus(cb);
1256
1320
  };
@@ -1267,7 +1331,7 @@ const globalFocus = new (_a$1 = class {
1267
1331
  if (this.focused.length > historySize) {
1268
1332
  this.focused = this.focused.splice(0, historySize);
1269
1333
  }
1270
- __privateGet$3(this, _onFocusCallbacks).forEach((cb) => cb());
1334
+ __privateGet$2(this, _onFocusCallbacks).forEach((cb) => cb());
1271
1335
  }
1272
1336
  get list() {
1273
1337
  return [...this.focused];
@@ -1294,97 +1358,6 @@ const globalFocus = new (_a$1 = class {
1294
1358
  }
1295
1359
  }, _onFocusCallbacks = new WeakMap(), _a$1)();
1296
1360
 
1297
- var __accessCheck$2 = (obj, member, msg) => {
1298
- if (!member.has(obj))
1299
- throw TypeError("Cannot " + msg);
1300
- };
1301
- var __privateGet$2 = (obj, member, getter) => {
1302
- __accessCheck$2(obj, member, "read from private field");
1303
- return getter ? getter.call(obj) : member.get(obj);
1304
- };
1305
- var __privateAdd$2 = (obj, member, value) => {
1306
- if (member.has(obj))
1307
- throw TypeError("Cannot add the same private member more than once");
1308
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1309
- };
1310
- var __privateSet$2 = (obj, member, value, setter) => {
1311
- __accessCheck$2(obj, member, "write to private field");
1312
- member.set(obj, value);
1313
- return value;
1314
- };
1315
- var __privateMethod$1 = (obj, member, method) => {
1316
- __accessCheck$2(obj, member, "access private method");
1317
- return method;
1318
- };
1319
- var _hasReleasedFirstTime, _wasReleasedFirstTime, _isForced, _locks, _shoutLockState, shoutLockState_fn;
1320
- class ScreenLocker extends EventEmitter {
1321
- constructor() {
1322
- super();
1323
- __privateAdd$2(this, _shoutLockState);
1324
- __privateAdd$2(this, _hasReleasedFirstTime, false);
1325
- __privateAdd$2(this, _wasReleasedFirstTime, false);
1326
- __privateAdd$2(this, _isForced, false);
1327
- __privateAdd$2(this, _locks, {
1328
- common: false
1329
- });
1330
- this.emit("ready", null);
1331
- }
1332
- get hasReleasedFirstTime() {
1333
- return __privateGet$2(this, _hasReleasedFirstTime);
1334
- }
1335
- get isForced() {
1336
- return __privateGet$2(this, _isForced);
1337
- }
1338
- /**
1339
- * Permite saber si un bloqueo determinado está activo o si la clase tiene
1340
- * forceLock activo.
1341
- */
1342
- isLocked(lockName = "common") {
1343
- return __privateGet$2(this, _locks)[lockName] || __privateGet$2(this, _isForced);
1344
- }
1345
- lock(lockName = "common") {
1346
- __privateGet$2(this, _locks)[lockName] = true;
1347
- __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
1348
- }
1349
- unlock(lockName = "common") {
1350
- if (lockName === "common")
1351
- __privateSet$2(this, _hasReleasedFirstTime, true);
1352
- __privateGet$2(this, _locks)[lockName] = false;
1353
- __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
1354
- }
1355
- force() {
1356
- __privateSet$2(this, _isForced, true);
1357
- __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
1358
- }
1359
- releaseForced() {
1360
- __privateSet$2(this, _isForced, false);
1361
- __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
1362
- }
1363
- }
1364
- _hasReleasedFirstTime = new WeakMap();
1365
- _wasReleasedFirstTime = new WeakMap();
1366
- _isForced = new WeakMap();
1367
- _locks = new WeakMap();
1368
- _shoutLockState = new WeakSet();
1369
- shoutLockState_fn = function(lockName) {
1370
- if (__privateGet$2(this, _isForced) || lockName === void 0) {
1371
- this.emit("forcedStateChange", {
1372
- isForced: __privateGet$2(this, _isForced),
1373
- hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime)
1374
- });
1375
- } else {
1376
- if (lockName === "common" && !__privateGet$2(this, _wasReleasedFirstTime) && __privateGet$2(this, _hasReleasedFirstTime)) {
1377
- this.emit("releaseForFirstTime", null);
1378
- }
1379
- this.emit("lockStateChange", {
1380
- lockName,
1381
- hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime),
1382
- isLocked: __privateGet$2(this, _locks)[lockName]
1383
- });
1384
- }
1385
- };
1386
- const screenLocker = new ScreenLocker();
1387
-
1388
1361
  var __accessCheck$1 = (obj, member, msg) => {
1389
1362
  if (!member.has(obj))
1390
1363
  throw TypeError("Cannot " + msg);
@@ -1741,6 +1714,105 @@ function useLocalStorage(prop, defaultValue) {
1741
1714
  ];
1742
1715
  }
1743
1716
 
1717
+ class Semaphore {
1718
+ /**
1719
+ * Creates a new instance of the Semaphore.
1720
+ *
1721
+ * @param concurrency - The maximum number of concurrent tasks allowed.
1722
+ */
1723
+ constructor(concurrency) {
1724
+ this.concurrency = concurrency;
1725
+ this.current = 0;
1726
+ this.queue = [];
1727
+ }
1728
+ /**
1729
+ * Acquires a permit to run a task.
1730
+ *
1731
+ * If the number of currently acquired permits is less than the concurrency limit,
1732
+ * the promise resolves immediately. Otherwise, it is queued until a permit is released.
1733
+ *
1734
+ * @returns A promise that resolves when the permit has been acquired.
1735
+ */
1736
+ async acquire() {
1737
+ if (this.current < this.concurrency) {
1738
+ this.current++;
1739
+ return Promise.resolve();
1740
+ }
1741
+ return new Promise((resolve) => {
1742
+ this.queue.push(resolve);
1743
+ });
1744
+ }
1745
+ /**
1746
+ * Releases a previously acquired permit.
1747
+ *
1748
+ * If there are queued tasks waiting for a permit, the next one is dequeued and allowed to proceed.
1749
+ */
1750
+ release() {
1751
+ this.current--;
1752
+ this.queue.shift()?.();
1753
+ }
1754
+ }
1755
+
1756
+ class Mutex extends Semaphore {
1757
+ constructor() {
1758
+ super(1);
1759
+ }
1760
+ async runExclusive(cb) {
1761
+ await this.acquire();
1762
+ await cb();
1763
+ this.release();
1764
+ }
1765
+ }
1766
+
1767
+ class Locker extends EventEmitter {
1768
+ constructor() {
1769
+ super();
1770
+ this.locks = 0;
1771
+ this.hasReleased = false;
1772
+ this.mutex = new Mutex();
1773
+ makeObservable(this, {
1774
+ locks: observable
1775
+ });
1776
+ }
1777
+ get isLocked() {
1778
+ return this.locks > 0;
1779
+ }
1780
+ lock() {
1781
+ this.mutex.acquire().then(() => {
1782
+ this.locks++;
1783
+ });
1784
+ }
1785
+ unlock() {
1786
+ this.mutex.acquire().then(() => {
1787
+ this.locks--;
1788
+ if (!this.hasReleased && this.locks === 0) {
1789
+ this.emit("releaseForFirstTime", null);
1790
+ this.hasReleased = true;
1791
+ }
1792
+ });
1793
+ }
1794
+ }
1795
+ const screenLocker = new Locker();
1796
+
1797
+ class ScrollLocker {
1798
+ static evaluate() {
1799
+ Object.assign(document.body.style, {
1800
+ maxHeight: this.locks > 0 ? "100vh" : "unset",
1801
+ overflow: this.locks > 0 ? "hidden" : "auto",
1802
+ paddingRight: this.locks > 0 && document.body.scrollHeight > document.body.clientHeight ? "10px" : "0px"
1803
+ });
1804
+ }
1805
+ static lock() {
1806
+ this.locks++;
1807
+ this.evaluate();
1808
+ }
1809
+ static unlock() {
1810
+ this.locks--;
1811
+ this.evaluate();
1812
+ }
1813
+ }
1814
+ ScrollLocker.locks = 0;
1815
+
1744
1816
  var __accessCheck = (obj, member, msg) => {
1745
1817
  if (!member.has(obj))
1746
1818
  throw TypeError("Cannot " + msg);
@@ -1914,7 +1986,7 @@ const focus = new (_a = class {
1914
1986
  }, _checkInstruction = new WeakSet(), checkInstruction_fn = function(focusCheck) {
1915
1987
  return focusCheck.currentInstruction === __privateGet(this, _currentInstruction);
1916
1988
  }, _doFocus = new WeakSet(), doFocus_fn = async function(HTMLElement, focusCheck, isLastTry, configuration) {
1917
- if (screenLocker.isLocked("common") && !configuration?.focusEvenWhenScreenLocked) {
1989
+ if (screenLocker.isLocked && !configuration?.focusEvenWhenScreenLocked) {
1918
1990
  return null;
1919
1991
  }
1920
1992
  const actualHTMLElement = isFunction(HTMLElement) ? HTMLElement(isLastTry) : HTMLElement;
@@ -2708,6 +2780,12 @@ class ClassNameBuilder {
2708
2780
  }
2709
2781
  }
2710
2782
 
2783
+ function decodeBase64ToUtf8(base64String) {
2784
+ const binaryString = atob(base64String);
2785
+ const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
2786
+ return new TextDecoder("utf-8").decode(bytes);
2787
+ }
2788
+
2711
2789
  function toBoolean(value) {
2712
2790
  if (typeof value === "string") {
2713
2791
  return !["false", ""].includes(value.toLowerCase());
@@ -2828,37 +2906,5 @@ const postNavigation = (url, data) => {
2828
2906
  form.submit();
2829
2907
  };
2830
2908
 
2831
- class Mutex {
2832
- constructor() {
2833
- this.locked = false;
2834
- this.queue = [];
2835
- }
2836
- async lock() {
2837
- const ticket = new Promise((resolve) => this.queue.push(resolve));
2838
- if (!this.locked) {
2839
- this.locked = true;
2840
- const next = this.queue.shift();
2841
- next();
2842
- }
2843
- await ticket;
2844
- }
2845
- unlock() {
2846
- if (this.queue.length > 0) {
2847
- const next = this.queue.shift();
2848
- next();
2849
- } else {
2850
- this.locked = false;
2851
- }
2852
- }
2853
- async runExclusive(fn) {
2854
- await this.lock();
2855
- try {
2856
- return await fn();
2857
- } finally {
2858
- this.unlock();
2859
- }
2860
- }
2861
- }
2862
-
2863
- export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Mutex, PropsSelectorUndefinedObject, PropsStore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
2909
+ export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Locker, Mutex, PropsSelectorUndefinedObject, PropsStore, ScrollLocker, Semaphore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeBase64ToUtf8, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, globals, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
2864
2910
  //# sourceMappingURL=index.js.map