@startlibs/utils 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/lib/index.js +65 -33
  2. package/package.json +1 -1
  3. package/yarn-error.log +3643 -0
package/lib/index.js CHANGED
@@ -574,7 +574,11 @@ function () {
574
574
  case 0:
575
575
  return _context4.abrupt("return", innerFetcher(addQueryString(url, jsonParams), _objectSpread({
576
576
  method: 'GET'
577
- }, fetchOptions)));
577
+ }, fetchOptions, {
578
+ headers: _objectSpread({
579
+ 'X-Requested-With': 'XMLHttpRequest'
580
+ }, fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.headers)
581
+ })));
578
582
 
579
583
  case 1:
580
584
  case "end":
@@ -881,7 +885,7 @@ var getFrameOffset = function getFrameOffset(i, total) {
881
885
  };
882
886
 
883
887
  var emotion = createEmotion({
884
- nonce: 'animation_nonce'
888
+ nonce: typeof document !== 'undefined' && (document.querySelector('meta[property="csp-nonce"]') || {}).content || 'animation_nonce'
885
889
  });
886
890
  var oneWayAnimation = function oneWayAnimation() {
887
891
  for (var _len5 = arguments.length, frames = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
@@ -1435,6 +1439,16 @@ var useEventListener = function useEventListener(eventName, callback) {
1435
1439
  };
1436
1440
  }, deps);
1437
1441
  };
1442
+ var useEventListenerIf = function useEventListenerIf(check, eventName, callback) {
1443
+ var deps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1444
+ useEffect(function () {
1445
+ if (!check()) return;
1446
+ window.addEventListener(eventName, callback);
1447
+ return function () {
1448
+ return window.removeEventListener(eventName, callback);
1449
+ };
1450
+ }, deps);
1451
+ };
1438
1452
  var useEventListenerFor = function useEventListenerFor(element, eventName, callback) {
1439
1453
  var deps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1440
1454
  useEffect(function () {
@@ -1479,30 +1493,21 @@ var will = function will(fn) {
1479
1493
  return fn.apply(void 0, props.concat(more));
1480
1494
  };
1481
1495
  };
1482
- var unWill = function unWill(fn) {
1483
- for (var _len5 = arguments.length, props = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
1484
- props[_key5 - 1] = arguments[_key5];
1485
- }
1486
-
1487
- return function () {
1488
- return fn.apply(void 0, props);
1489
- };
1490
- };
1491
1496
  var lazyValue = function lazyValue(v) {
1492
1497
  return function () {
1493
1498
  return v;
1494
1499
  };
1495
1500
  };
1496
1501
  var callIfFunction = function callIfFunction(prop) {
1497
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
1498
- args[_key6 - 1] = arguments[_key6];
1502
+ for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
1503
+ args[_key5 - 1] = arguments[_key5];
1499
1504
  }
1500
1505
 
1501
1506
  return typeof prop === "function" ? prop.apply(void 0, args) : prop;
1502
1507
  };
1503
1508
  var callIfFunctions = function callIfFunctions(prop) {
1504
- for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
1505
- args[_key7 - 1] = arguments[_key7];
1509
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
1510
+ args[_key6 - 1] = arguments[_key6];
1506
1511
  }
1507
1512
 
1508
1513
  return typeof prop === "function" ? prop.apply(void 0, _toConsumableArray(args.map(function (e) {
@@ -1510,13 +1515,13 @@ var callIfFunctions = function callIfFunctions(prop) {
1510
1515
  }))) : prop;
1511
1516
  };
1512
1517
  var callMany = function callMany() {
1513
- for (var _len8 = arguments.length, many = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
1514
- many[_key8] = arguments[_key8];
1518
+ for (var _len7 = arguments.length, many = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1519
+ many[_key7] = arguments[_key7];
1515
1520
  }
1516
1521
 
1517
1522
  return function () {
1518
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
1519
- args[_key9] = arguments[_key9];
1523
+ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
1524
+ args[_key8] = arguments[_key8];
1520
1525
  }
1521
1526
 
1522
1527
  return many.map(function (_) {
@@ -1525,15 +1530,15 @@ var callMany = function callMany() {
1525
1530
  };
1526
1531
  };
1527
1532
  var ifUndefined = function ifUndefined(v) {
1528
- for (var _len10 = arguments.length, or = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
1529
- or[_key10 - 1] = arguments[_key10];
1533
+ for (var _len9 = arguments.length, or = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
1534
+ or[_key9 - 1] = arguments[_key9];
1530
1535
  }
1531
1536
 
1532
1537
  return v !== undefined ? v : or.length === 1 ? or[0] : ifUndefined.apply(void 0, [or[0]].concat(_toConsumableArray(or.slice(1))));
1533
1538
  };
1534
1539
  var using = function using() {
1535
- for (var _len11 = arguments.length, v = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
1536
- v[_key11] = arguments[_key11];
1540
+ for (var _len10 = arguments.length, v = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
1541
+ v[_key10] = arguments[_key10];
1537
1542
  }
1538
1543
 
1539
1544
  return function (fn) {
@@ -1638,20 +1643,23 @@ function isRetina() {
1638
1643
  return (window.matchMedia && (window.matchMedia('only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx), only screen and (min-resolution: 75.6dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)').matches) || window.devicePixelRatio && window.devicePixelRatio >= 2) && /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
1639
1644
  }
1640
1645
  function isMobile() {
1641
- var check = false;
1646
+ if (typeof navigator === 'undefined') return false;
1647
+ var ua = navigator.userAgent;
1648
+ var isAndroid = /android/i.test(ua);
1649
+ var isiOS = /iphone|ipod|ipad/i.test(ua); // iPadOS 13+ reports "Macintosh" but has touch
1642
1650
 
1643
- if (typeof navigator === 'undefined') {
1644
- return false;
1651
+ var isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1652
+ return isAndroid || isiOS || isIPadOS;
1653
+ }
1654
+ function isAndroid() {
1655
+ if (navigator.userAgentData) {
1656
+ return navigator.userAgentData.platform === "Android";
1645
1657
  }
1646
1658
 
1647
- (function (a) {
1648
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series([46])0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br([ev])w|bumb|bw-([nu])|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do([cp])o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly([-_])|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-([mpt])|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c([- _agpst])|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac([ -/])|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja([tv])a|jbro|jemu|jigs|kddi|keji|kgt([ /])|klon|kpt |kwc-|kyo([ck])|le(no|xi)|lg( g|\/([klu])|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t([- ov])|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30([02])|n50([025])|n7(0([01])|10)|ne(([cm])-|on|tf|wf|wg|wt)|nok([6i])|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan([adt])|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c([-01])|47|mc|nd|ri)|sgh-|shar|sie([-m])|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c([- ])|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4))) check = true;
1649
- })(navigator.userAgent || navigator.vendor || window['opera']);
1650
-
1651
- return check;
1659
+ return /Android/i.test(navigator.userAgent);
1652
1660
  }
1653
1661
  var isPWA = function isPWA() {
1654
- return window.matchMedia && window.matchMedia("(display-mode: standalone)").matches;
1662
+ return window.matchMedia && window.matchMedia("(display-mode: standalone)").matches || !!window.hasWebviewBridge;
1655
1663
  };
1656
1664
  function isTouchDevice() {
1657
1665
  return window.document && 'ontouchstart' in window.document.documentElement;
@@ -1930,6 +1938,30 @@ var getUID = function getUID() {
1930
1938
  var getUrlParams = function getUrlParams() {
1931
1939
  return _fromPairs(Array.from(new URLSearchParams(location.search).entries()));
1932
1940
  };
1941
+ var isShallowEqualSameKeys = function isShallowEqualSameKeys(a, b) {
1942
+ for (var key in a) {
1943
+ if (a[key] !== b[key]) {
1944
+ return false;
1945
+ }
1946
+ }
1947
+
1948
+ return true;
1949
+ };
1950
+ var isShallowEqual = function isShallowEqual(a, b) {
1951
+ for (var key in a) {
1952
+ if (!(key in b) || a[key] !== b[key]) {
1953
+ return false;
1954
+ }
1955
+ }
1956
+
1957
+ for (var key in b) {
1958
+ if (!(key in a) || a[key] !== b[key]) {
1959
+ return false;
1960
+ }
1961
+ }
1962
+
1963
+ return true;
1964
+ };
1933
1965
 
1934
1966
  var disableSelect = function disableSelect(e) {
1935
1967
  e.preventDefault();
@@ -2364,4 +2396,4 @@ var parseDecimalToNumber = function parseDecimalToNumber(v) {
2364
2396
  return _isString(v) ? Number(v.replace(/\./g, '').replace(',', ".")) : v || 0;
2365
2397
  };
2366
2398
 
2367
- export { Action, COMPLETE_ACTION, DAY, FETCH, HOUR, MINUTE, MONTH, REDUCE, SECOND, SKIPPED_ACTION, SKIP_DISPATCH, SKIP_FETCH, SkipAction, WEEK, YEAR, _s, activateActions, addExtraProp, addHttp, addQueryString, addZero, animationTiming, asciify, asyncDebounce, blockDiffIntervals, callIfFunction, callIfFunctions, callMany, cancelableTimer, compareBest, concatSelectors, constrainEvent, createPressAndHoldEvent, createPressAndMoveEvent, createPressEvent, createPromiseQueue, createPromiseResolverPair, createSimplePromiseLock, customTheme, diffIntervals, digitsToPattern, ellipsis, fixMediaQuery, formFetch, formFetchWithResponse, formatDate, formatDateToPattern, formatHour, formatJoin, formatJoinArr, formatPath, getClosestOffsetScroll, getColor, getFetcher, getFetcherWithResponse, getMargin, getNumberInputType, getNumberInputType2, getScrollParent, getStartOfDay, getUID, getUrlParams, identityFn, identityOpacityFrames, identityTranslateFrames, ifNotProp, ifProp, ifPropEquals, ifUndefined, intToHour, intervalsIntersect, intervalsIntersectExclusive, intervalsIntersection, intsToHour, isElementInView, isEmptyHtml, isHighDensity, isIOS, isIPad, isMobile, isPWA, isRetina, isSameDay, isSmallDevice, isTouchDevice, isUrl, lazyValue, linkRegex, mapGetOrSet, media, normalizeMouse, normalizePress, normalizeText, normalizeTextUrl, normalizeTouch, notPrinterMedia, oneWayAnimation, parseDate, parseDecimalToNumber, postFetcher, postFetcherWithResponse, preventDefault, printerMedia, promiseMapReduce, prop, queryStringToObj, rafThrottle, removeAccents, safeNewLineToBr, scrollIntoViewWithOffset, scrollWidth, selectPath, smoothScroll, startBlockDiffIntervals, stopPropagation, styledExtend, timerPromise, toHighest, toLowest, touchClick, twoWayAnimation, unWill, useEventListener, useEventListenerFor, using, vheight, will, willFormatDecimal, willRafThrottle, wrapLazy };
2399
+ export { Action, COMPLETE_ACTION, DAY, FETCH, HOUR, MINUTE, MONTH, REDUCE, SECOND, SKIPPED_ACTION, SKIP_DISPATCH, SKIP_FETCH, SkipAction, WEEK, YEAR, _s, activateActions, addExtraProp, addHttp, addQueryString, addZero, animationTiming, asciify, asyncDebounce, blockDiffIntervals, callIfFunction, callIfFunctions, callMany, cancelableTimer, compareBest, concatSelectors, constrainEvent, createPressAndHoldEvent, createPressAndMoveEvent, createPressEvent, createPromiseQueue, createPromiseResolverPair, createSimplePromiseLock, customTheme, diffIntervals, digitsToPattern, ellipsis, fixMediaQuery, formFetch, formFetchWithResponse, formatDate, formatDateToPattern, formatHour, formatJoin, formatJoinArr, formatPath, getClosestOffsetScroll, getColor, getFetcher, getFetcherWithResponse, getMargin, getNumberInputType, getNumberInputType2, getScrollParent, getStartOfDay, getUID, getUrlParams, identityFn, identityOpacityFrames, identityTranslateFrames, ifNotProp, ifProp, ifPropEquals, ifUndefined, intToHour, intervalsIntersect, intervalsIntersectExclusive, intervalsIntersection, intsToHour, isAndroid, isElementInView, isEmptyHtml, isHighDensity, isIOS, isIPad, isMobile, isPWA, isRetina, isSameDay, isShallowEqual, isShallowEqualSameKeys, isSmallDevice, isTouchDevice, isUrl, lazyValue, linkRegex, mapGetOrSet, media, normalizeMouse, normalizePress, normalizeText, normalizeTextUrl, normalizeTouch, notPrinterMedia, oneWayAnimation, parseDate, parseDecimalToNumber, postFetcher, postFetcherWithResponse, preventDefault, printerMedia, promiseMapReduce, prop, queryStringToObj, rafThrottle, removeAccents, safeNewLineToBr, scrollIntoViewWithOffset, scrollWidth, selectPath, smoothScroll, startBlockDiffIntervals, stopPropagation, styledExtend, timerPromise, toHighest, toLowest, touchClick, twoWayAnimation, useEventListener, useEventListenerFor, useEventListenerIf, using, vheight, will, willFormatDecimal, willRafThrottle, wrapLazy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startlibs/utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Startlibs Utils",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,