native-fn 1.0.68 → 1.0.70

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 (58) hide show
  1. package/dist/native.cjs +3 -3
  2. package/dist/native.min.cjs +1 -1
  3. package/dist/native.min.mjs +1 -1
  4. package/dist/native.mjs +3 -3
  5. package/dist/native.umd.js +3 -3
  6. package/dist/native.umd.min.js +1 -1
  7. package/dist/plugin/app/index.cjs +347 -344
  8. package/dist/plugin/app/index.min.cjs +1 -1
  9. package/dist/plugin/app/index.min.mjs +1 -1
  10. package/dist/plugin/app/index.mjs +347 -344
  11. package/dist/plugin/app/index.umd.js +347 -344
  12. package/dist/plugin/app/index.umd.min.js +1 -1
  13. package/dist/plugin/app/src/plugin/app/cores/index.d.ts +14 -0
  14. package/dist/plugin/app/src/plugin/appearance/constants/index.d.ts +1 -1
  15. package/dist/plugin/appearance/index.cjs +43 -35
  16. package/dist/plugin/appearance/index.d.ts +0 -63
  17. package/dist/plugin/appearance/index.min.cjs +1 -1
  18. package/dist/plugin/appearance/index.min.mjs +1 -1
  19. package/dist/plugin/appearance/index.mjs +43 -35
  20. package/dist/plugin/appearance/index.umd.js +43 -35
  21. package/dist/plugin/appearance/index.umd.min.js +1 -1
  22. package/dist/plugin/appearance/src/plugin/app/cores/index.d.ts +14 -0
  23. package/dist/plugin/appearance/src/plugin/appearance/constants/index.d.ts +1 -1
  24. package/dist/plugin/camera/index.cjs +2 -2
  25. package/dist/plugin/camera/index.min.cjs +1 -1
  26. package/dist/plugin/camera/index.min.mjs +1 -1
  27. package/dist/plugin/camera/index.mjs +2 -2
  28. package/dist/plugin/camera/index.umd.js +2 -2
  29. package/dist/plugin/camera/index.umd.min.js +1 -1
  30. package/dist/plugin/camera/src/plugin/app/cores/index.d.ts +14 -0
  31. package/dist/plugin/camera/src/plugin/appearance/constants/index.d.ts +1 -1
  32. package/dist/plugin/clipboard/index.cjs +4 -4
  33. package/dist/plugin/clipboard/index.min.cjs +1 -1
  34. package/dist/plugin/clipboard/index.min.mjs +1 -1
  35. package/dist/plugin/clipboard/index.mjs +4 -4
  36. package/dist/plugin/clipboard/index.umd.js +4 -4
  37. package/dist/plugin/clipboard/index.umd.min.js +1 -1
  38. package/dist/plugin/clipboard/src/plugin/app/cores/index.d.ts +14 -0
  39. package/dist/plugin/clipboard/src/plugin/appearance/constants/index.d.ts +1 -1
  40. package/dist/plugin/fullscreen/index.cjs +6 -6
  41. package/dist/plugin/fullscreen/index.min.cjs +1 -1
  42. package/dist/plugin/fullscreen/index.min.mjs +1 -1
  43. package/dist/plugin/fullscreen/index.mjs +6 -6
  44. package/dist/plugin/fullscreen/index.umd.js +6 -6
  45. package/dist/plugin/fullscreen/index.umd.min.js +1 -1
  46. package/dist/plugin/fullscreen/src/plugin/app/cores/index.d.ts +14 -0
  47. package/dist/plugin/fullscreen/src/plugin/appearance/constants/index.d.ts +1 -1
  48. package/dist/plugin/theme/index.cjs +6 -6
  49. package/dist/plugin/theme/index.min.cjs +1 -1
  50. package/dist/plugin/theme/index.min.mjs +1 -1
  51. package/dist/plugin/theme/index.mjs +6 -6
  52. package/dist/plugin/theme/index.umd.js +6 -6
  53. package/dist/plugin/theme/index.umd.min.js +1 -1
  54. package/dist/plugin/theme/src/plugin/app/cores/index.d.ts +14 -0
  55. package/dist/plugin/theme/src/plugin/appearance/constants/index.d.ts +1 -1
  56. package/dist/src/plugin/app/cores/index.d.ts +14 -0
  57. package/dist/src/plugin/appearance/constants/index.d.ts +1 -1
  58. package/package.json +1 -1
@@ -405,7 +405,7 @@ for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
405
405
  }
406
406
  if (IS_REACT_NATIVE) {
407
407
  try {
408
- var reactNative = (0, eval)('require')('react-native');
408
+ var reactNative = require('react-native');
409
409
  var platform = reactNative.Platform;
410
410
  var os = platform.OS;
411
411
  var release = '' + platform.Version;
@@ -434,7 +434,7 @@ if (IS_REACT_NATIVE) {
434
434
  }
435
435
  if (IS_NODE_JS) {
436
436
  try {
437
- var os = (0, eval)('require')('os');
437
+ var os = require('os');
438
438
  var platform = os.platform();
439
439
  var release = os.release();
440
440
  var version = getSemanticVersion(release);
@@ -507,6 +507,169 @@ Platform.isMobile = Platform.device === Devices.Mobile;
507
507
  Platform.isDesktop = Platform.device === Devices.Desktop;
508
508
  Platform.isStandalone = getIsStandalone(Platform.os);
509
509
 
510
+ function createCustomError(name, Base) {
511
+ if (Base === void 0) { Base = Error; }
512
+ function CustomError(message) {
513
+ if (!(this instanceof CustomError))
514
+ return new CustomError(message);
515
+ var error = new Base(message || '');
516
+ if (typeof Object.setPrototypeOf === 'function')
517
+ Object.setPrototypeOf(error, CustomError.prototype);
518
+ else
519
+ error.__proto__ = CustomError.prototype;
520
+ error.name = name;
521
+ if (message !== undefined)
522
+ error.message = message;
523
+ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
524
+ try {
525
+ Object.defineProperty(error, Symbol.toStringTag, {
526
+ value: name,
527
+ writable: false,
528
+ enumerable: false,
529
+ configurable: true
530
+ });
531
+ }
532
+ catch (_) {
533
+ }
534
+ }
535
+ if (typeof Error.captureStackTrace === 'function') {
536
+ Error.captureStackTrace(error, CustomError);
537
+ }
538
+ else if (Base.captureStackTrace && typeof Base.captureStackTrace === 'function') {
539
+ Base.captureStackTrace(error, CustomError);
540
+ }
541
+ else {
542
+ try {
543
+ var tempError = new Base();
544
+ if (tempError.stack)
545
+ error.stack = tempError.stack;
546
+ }
547
+ catch (_) {
548
+ }
549
+ }
550
+ return error;
551
+ }
552
+ CustomError.prototype = Object.create(Base.prototype, {
553
+ constructor: {
554
+ value: CustomError,
555
+ writable: true,
556
+ enumerable: false,
557
+ configurable: true
558
+ }
559
+ });
560
+ try {
561
+ Object.defineProperty(CustomError.prototype, 'name', {
562
+ value: name,
563
+ writable: true,
564
+ enumerable: false,
565
+ configurable: true
566
+ });
567
+ }
568
+ catch (_) {
569
+ try {
570
+ CustomError.prototype.name = name;
571
+ }
572
+ catch (_) {
573
+ }
574
+ }
575
+ try {
576
+ Object.defineProperty(CustomError, 'name', {
577
+ value: name,
578
+ writable: false,
579
+ enumerable: false,
580
+ configurable: true
581
+ });
582
+ }
583
+ catch (_) {
584
+ }
585
+ return CustomError;
586
+ }
587
+
588
+ var URLOpenError = createCustomError('URLOpenError');
589
+
590
+ function getTopmostWindow() {
591
+ try {
592
+ if (globalThis.top && globalThis.top !== window) {
593
+ void globalThis.top.location.href;
594
+ return globalThis.top;
595
+ }
596
+ }
597
+ catch (_) {
598
+ }
599
+ return window;
600
+ }
601
+
602
+ function createHiddenElement(tagName, focusable) {
603
+ if (focusable === void 0) { focusable = true; }
604
+ if (typeof globalThis.document === 'undefined')
605
+ return undefined;
606
+ var element = globalThis.document.createElement(tagName);
607
+ if ('width' in element)
608
+ element.width = '0';
609
+ if ('height' in element)
610
+ element.height = '0';
611
+ if ('border' in element)
612
+ element.border = '0';
613
+ if ('frameBorder' in element)
614
+ element.frameBorder = '0';
615
+ if ('scrolling' in element)
616
+ element.scrolling = 'no';
617
+ if ('cellPadding' in element)
618
+ element.cellPadding = '0';
619
+ if ('cellSpacing' in element)
620
+ element.cellSpacing = '0';
621
+ if ('frame' in element)
622
+ element.frame = 'void';
623
+ if ('rules' in element)
624
+ element.rules = 'none';
625
+ if ('noWrap' in element)
626
+ element.noWrap = true;
627
+ element.tabIndex = -1;
628
+ element.setAttribute('role', 'presentation');
629
+ if (focusable) {
630
+ element.style.width = '1px';
631
+ element.style.height = '1px';
632
+ }
633
+ else {
634
+ element.setAttribute('aria-hidden', 'true');
635
+ element.style.width = '0';
636
+ element.style.height = '0';
637
+ element.style.zIndex = '-9999';
638
+ element.style.display = 'none';
639
+ element.style.visibility = 'hidden';
640
+ element.style.pointerEvents = 'none';
641
+ }
642
+ element.style.position = 'absolute';
643
+ element.style.top = '0';
644
+ element.style.left = '0';
645
+ element.style.padding = '0';
646
+ element.style.margin = '0';
647
+ element.style.border = 'none';
648
+ element.style.outline = 'none';
649
+ element.style.clip = 'rect(1px, 1px, 1px, 1px)';
650
+ element.style.clipPath = 'inset(50%)';
651
+ element.style.overflow = 'hidden';
652
+ element.style.whiteSpace = 'nowrap';
653
+ return element;
654
+ }
655
+
656
+ function dispatchClickEvent(element, view) {
657
+ if (view === void 0) { view = window; }
658
+ var fake;
659
+ try {
660
+ fake = new MouseEvent('click', {
661
+ bubbles: true,
662
+ cancelable: true,
663
+ view: view
664
+ });
665
+ }
666
+ catch (_) {
667
+ fake = globalThis.document.createEvent('MouseEvents');
668
+ fake.initMouseEvent('click', true, true, view, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
669
+ }
670
+ element.dispatchEvent(fake);
671
+ }
672
+
510
673
  function capitalize(_) {
511
674
  var groups = [];
512
675
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -651,89 +814,156 @@ var EventListenerUtils = {
651
814
  }
652
815
  };
653
816
 
654
- function getTopmostWindow() {
817
+ var _a;
818
+ var App = {
819
+ open: open,
820
+ messenger: (_a = {},
821
+ _a[MessengerType.Telephone] = openMessengerTelephone,
822
+ _a[MessengerType.Message] = openMessengerMessage,
823
+ _a[MessengerType.Mail] = openMessengerMail,
824
+ _a),
825
+ };
826
+ function getTrackId(bundle) {
655
827
  try {
656
- if (globalThis.top && globalThis.top !== window) {
657
- void globalThis.top.location.href;
658
- return globalThis.top;
828
+ var xhr = new XMLHttpRequest();
829
+ xhr.open('GET', 'https://itunes.apple.com/lookup?bundleId=' + bundle, false);
830
+ xhr.send();
831
+ if (xhr.status === 200) {
832
+ try {
833
+ var response = JSON.parse(xhr.response);
834
+ if (response.results === undefined)
835
+ return undefined;
836
+ var results = response.results;
837
+ if (!Array.isArray(results) || results.length === 0)
838
+ return undefined;
839
+ var result = results[0];
840
+ if (result === undefined)
841
+ return undefined;
842
+ return result.trackId;
843
+ }
844
+ catch (_) {
845
+ return undefined;
846
+ }
659
847
  }
848
+ return undefined;
660
849
  }
661
850
  catch (_) {
851
+ return undefined;
662
852
  }
663
- return window;
664
853
  }
665
-
666
- function dispatchClickEvent(element, view) {
667
- if (view === void 0) { view = window; }
668
- var fake;
669
- try {
670
- fake = new MouseEvent('click', {
671
- bubbles: true,
672
- cancelable: true,
673
- view: view
674
- });
675
- }
676
- catch (_) {
677
- fake = globalThis.document.createEvent('MouseEvents');
678
- fake.initMouseEvent('click', true, true, view, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
854
+ function createIntentURL(scheme, packageName, fallback) {
855
+ var split = scheme.split('://');
856
+ var prefix = split[0];
857
+ var suffix = split[1];
858
+ var intent = 'intent://';
859
+ if (suffix !== undefined)
860
+ intent = intent + suffix;
861
+ intent = intent + '#Intent;'
862
+ + 'scheme=' + prefix + ';'
863
+ + 'action=android.intent.action.VIEW;'
864
+ + 'category=android.intent.category.BROWSABLE;';
865
+ if (packageName !== undefined)
866
+ intent = intent + 'package=' + packageName + ';';
867
+ if (fallback !== undefined && typeof fallback === 'string')
868
+ intent = intent + 'S.browser_fallback_url=' + fallback + ';';
869
+ else if (packageName !== undefined)
870
+ intent = intent + 'S.browser_fallback_url=' + createAppStoreURL(packageName, OS.Android) + ';';
871
+ return intent + 'end';
872
+ }
873
+ function parseIntentURL(intent) {
874
+ var parsed = {};
875
+ var split = intent.split('#Intent;');
876
+ var host = split[0].substring(9);
877
+ var suffix = split[1];
878
+ var parameterString = suffix.substring(0, suffix.length - 4);
879
+ var parameters = parameterString.split(';');
880
+ var extras = {};
881
+ for (var i = 0; i < parameters.length; i++) {
882
+ var part = parameters[i];
883
+ var index = part.indexOf('=');
884
+ if (index !== -1)
885
+ extras[part.substring(0, index)] = part.substring(index + 1);
679
886
  }
680
- element.dispatchEvent(fake);
887
+ if (extras['scheme'] !== undefined)
888
+ parsed.scheme = (extras['scheme'] + '://' + host);
889
+ if (extras['package'] !== undefined)
890
+ parsed.packageName = extras['package'];
891
+ if (extras['S.browser_fallback_url'] !== undefined)
892
+ parsed.fallback = extras['S.browser_fallback_url'];
893
+ return parsed;
681
894
  }
682
-
683
- function createHiddenElement(tagName, focusable) {
684
- if (focusable === void 0) { focusable = true; }
685
- if (typeof globalThis.document === 'undefined')
895
+ function createAppStoreURL(packageName, os) {
896
+ if (packageName === undefined)
686
897
  return undefined;
687
- var element = globalThis.document.createElement(tagName);
688
- if ('width' in element)
689
- element.width = '0';
690
- if ('height' in element)
691
- element.height = '0';
692
- if ('border' in element)
693
- element.border = '0';
694
- if ('frameBorder' in element)
695
- element.frameBorder = '0';
696
- if ('scrolling' in element)
697
- element.scrolling = 'no';
698
- if ('cellPadding' in element)
699
- element.cellPadding = '0';
700
- if ('cellSpacing' in element)
701
- element.cellSpacing = '0';
702
- if ('frame' in element)
703
- element.frame = 'void';
704
- if ('rules' in element)
705
- element.rules = 'none';
706
- if ('noWrap' in element)
707
- element.noWrap = true;
708
- element.tabIndex = -1;
709
- element.setAttribute('role', 'presentation');
710
- if (focusable) {
711
- element.style.width = '1px';
712
- element.style.height = '1px';
898
+ switch (os) {
899
+ case OS.Android:
900
+ return 'market://details?id=' + packageName;
901
+ case OS.iOS:
902
+ return 'itms-apps://itunes.apple.com/app/id' + packageName + '?mt=8';
903
+ case OS.Windows:
904
+ return 'ms-windows-store://pdp/?ProductId=' + packageName;
905
+ case OS.MacOS:
906
+ return 'macappstore://itunes.apple.com/app/id' + packageName + '?mt=12';
907
+ default:
908
+ throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
713
909
  }
714
- else {
715
- element.setAttribute('aria-hidden', 'true');
716
- element.style.width = '0';
717
- element.style.height = '0';
718
- element.style.zIndex = '-9999';
719
- element.style.display = 'none';
720
- element.style.visibility = 'hidden';
721
- element.style.pointerEvents = 'none';
910
+ }
911
+ function createWebStoreURL(packageName, os) {
912
+ if (packageName === undefined)
913
+ return undefined;
914
+ switch (os) {
915
+ case OS.Android:
916
+ return 'https://play.google.com/store/apps/details?id=' + packageName;
917
+ case OS.iOS:
918
+ return 'https://itunes.apple.com/app/id' + packageName + '?mt=8';
919
+ case OS.Windows:
920
+ return 'https://apps.microsoft.com/detail/' + packageName;
921
+ case OS.MacOS:
922
+ return 'https://apps.apple.com/app/id' + packageName + '?mt=12';
923
+ default:
924
+ throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
722
925
  }
723
- element.style.position = 'absolute';
724
- element.style.top = '0';
725
- element.style.left = '0';
726
- element.style.padding = '0';
727
- element.style.margin = '0';
728
- element.style.border = 'none';
729
- element.style.outline = 'none';
730
- element.style.clip = 'rect(1px, 1px, 1px, 1px)';
731
- element.style.clipPath = 'inset(50%)';
732
- element.style.overflow = 'hidden';
733
- element.style.whiteSpace = 'nowrap';
734
- return element;
735
926
  }
736
-
927
+ function getDefaultTimeoutByOS(os) {
928
+ switch (os) {
929
+ case OS.iOS:
930
+ return 2000;
931
+ case OS.Android:
932
+ return 1000;
933
+ default:
934
+ return 750;
935
+ }
936
+ }
937
+ function canOpenIntentURL() {
938
+ if (Platform.os !== OS.Android)
939
+ return false;
940
+ if (Platform.browser === Browsers.SamsungInternet && compareVersion(Platform.browserVersion, '17.0.1.69') >= 0 && compareVersion(Platform.browserVersion, '17.0.7.34') < 0)
941
+ return false;
942
+ if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '41.0') < 0)
943
+ return false;
944
+ if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '58.0') >= 0 && compareVersion(Platform.browserVersion, '68.11.0') < 0)
945
+ return false;
946
+ if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '79.0') >= 0 && compareVersion(Platform.browserVersion, '81.2.0') < 0)
947
+ return false;
948
+ if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '96.0') >= 0 && compareVersion(Platform.browserVersion, '107.0') < 0)
949
+ return false;
950
+ if (Platform.browser === Browsers.Opera && compareVersion(Platform.browserVersion, '14.0') < 0)
951
+ return false;
952
+ if (/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(Platform.userAgent) || /instagram[\/ ][-\w.]+/i.test(Platform.userAgent) || /micromessenger\/([\w.]+)/i.test(Platform.userAgent) || /musical_ly(?:.+app_?version\/|_)[\w.]+/i.test(Platform.userAgent) || /ultralite app_version\/[\w.]+/i.test(Platform.userAgent))
953
+ return false;
954
+ return true;
955
+ }
956
+ function canOpenUniversalURL() {
957
+ return Platform.os === OS.iOS && compareVersion(Platform.osVersion, '9.0') >= 0;
958
+ }
959
+ function getURLOpenError(tried) {
960
+ var triedURLString = '';
961
+ for (var i = 0; i < tried.length; i++)
962
+ triedURLString += '\n' + (i + 1) + ': ' + tried[i];
963
+ if (triedURLString.length > 0)
964
+ triedURLString = '\n' + triedURLString + '\n';
965
+ return new URLOpenError('Failed to open any of the provided URLs: ' + triedURLString);
966
+ }
737
967
  function openURLViaHref(url, index) {
738
968
  var top = getTopmostWindow();
739
969
  var topDocument = top.document;
@@ -873,50 +1103,54 @@ function restoreFocus() {
873
1103
  }
874
1104
  return hasFocus(topDocument);
875
1105
  }
876
- function tryOpenURL(url, index, timeout) {
877
- if (IS_REACT_NATIVE) {
878
- try {
879
- var reactNative_1 = (0, eval)('require')('react-native');
880
- return new Promise(function (resolve, reject) {
881
- reactNative_1.Linking.canOpenURL(url)
882
- .then(function (canOpen) {
883
- if (canOpen) {
884
- reactNative_1.Linking.openURL(url)
885
- .then(resolve)
886
- .catch(reject);
887
- }
888
- else {
889
- reject();
890
- }
891
- })
892
- .catch(reject);
893
- });
894
- }
895
- catch (_) {
896
- return Promise.reject();
897
- }
1106
+ function tryOpenURLViaReactNative(url) {
1107
+ try {
1108
+ var reactNative_1 = require('react-native');
1109
+ return new Promise(function (resolve, reject) {
1110
+ reactNative_1.Linking.canOpenURL(url)
1111
+ .then(function (canOpen) {
1112
+ if (canOpen) {
1113
+ reactNative_1.Linking.openURL(url)
1114
+ .then(resolve)
1115
+ .catch(reject);
1116
+ }
1117
+ else {
1118
+ reject();
1119
+ }
1120
+ })
1121
+ .catch(reject);
1122
+ });
898
1123
  }
899
- if (IS_ELECTRON) {
900
- try {
901
- var shell_1;
902
- if (typeof globalThis.electronBridge !== 'undefined') {
903
- shell_1 = globalThis.electronBridge;
904
- }
905
- else {
906
- var electron = (0, eval)('require')('electron');
907
- shell_1 = electron.shell;
908
- }
909
- return new Promise(function (resolve, reject) {
910
- shell_1
911
- .openExternal(url)
912
- .then(resolve)
913
- .catch(reject);
914
- });
1124
+ catch (_) {
1125
+ return Promise.reject();
1126
+ }
1127
+ }
1128
+ function tryOpenURLViaElectron(url) {
1129
+ try {
1130
+ var shell_1;
1131
+ if (typeof globalThis.electronBridge !== 'undefined') {
1132
+ shell_1 = globalThis.electronBridge;
915
1133
  }
916
- catch (_) {
917
- return Promise.reject();
1134
+ else {
1135
+ var electron = require('electron');
1136
+ shell_1 = electron.shell;
918
1137
  }
1138
+ return new Promise(function (resolve, reject) {
1139
+ shell_1
1140
+ .openExternal(url)
1141
+ .then(resolve)
1142
+ .catch(reject);
1143
+ });
1144
+ }
1145
+ catch (_) {
1146
+ return Promise.reject();
919
1147
  }
1148
+ }
1149
+ function tryOpenURL(url, index, timeout) {
1150
+ if (IS_REACT_NATIVE)
1151
+ return tryOpenURLViaReactNative(url);
1152
+ if (IS_ELECTRON)
1153
+ return tryOpenURLViaElectron(url);
920
1154
  var top = getTopmostWindow();
921
1155
  var topDocument = top.document;
922
1156
  var eventType = { focus: undefined, blur: undefined, visibilitychange: undefined };
@@ -1028,237 +1262,6 @@ function tryOpenURL(url, index, timeout) {
1028
1262
  }
1029
1263
  });
1030
1264
  }
1031
-
1032
- function createCustomError(name, Base) {
1033
- if (Base === void 0) { Base = Error; }
1034
- function CustomError(message) {
1035
- if (!(this instanceof CustomError))
1036
- return new CustomError(message);
1037
- var error = new Base(message || '');
1038
- if (typeof Object.setPrototypeOf === 'function')
1039
- Object.setPrototypeOf(error, CustomError.prototype);
1040
- else
1041
- error.__proto__ = CustomError.prototype;
1042
- error.name = name;
1043
- if (message !== undefined)
1044
- error.message = message;
1045
- if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1046
- try {
1047
- Object.defineProperty(error, Symbol.toStringTag, {
1048
- value: name,
1049
- writable: false,
1050
- enumerable: false,
1051
- configurable: true
1052
- });
1053
- }
1054
- catch (_) {
1055
- }
1056
- }
1057
- if (typeof Error.captureStackTrace === 'function') {
1058
- Error.captureStackTrace(error, CustomError);
1059
- }
1060
- else if (Base.captureStackTrace && typeof Base.captureStackTrace === 'function') {
1061
- Base.captureStackTrace(error, CustomError);
1062
- }
1063
- else {
1064
- try {
1065
- var tempError = new Base();
1066
- if (tempError.stack)
1067
- error.stack = tempError.stack;
1068
- }
1069
- catch (_) {
1070
- }
1071
- }
1072
- return error;
1073
- }
1074
- CustomError.prototype = Object.create(Base.prototype, {
1075
- constructor: {
1076
- value: CustomError,
1077
- writable: true,
1078
- enumerable: false,
1079
- configurable: true
1080
- }
1081
- });
1082
- try {
1083
- Object.defineProperty(CustomError.prototype, 'name', {
1084
- value: name,
1085
- writable: true,
1086
- enumerable: false,
1087
- configurable: true
1088
- });
1089
- }
1090
- catch (_) {
1091
- try {
1092
- CustomError.prototype.name = name;
1093
- }
1094
- catch (_) {
1095
- }
1096
- }
1097
- try {
1098
- Object.defineProperty(CustomError, 'name', {
1099
- value: name,
1100
- writable: false,
1101
- enumerable: false,
1102
- configurable: true
1103
- });
1104
- }
1105
- catch (_) {
1106
- }
1107
- return CustomError;
1108
- }
1109
-
1110
- var URLOpenError = createCustomError('URLOpenError');
1111
-
1112
- var _a;
1113
- var App = {
1114
- open: open,
1115
- messenger: (_a = {},
1116
- _a[MessengerType.Telephone] = openMessengerTelephone,
1117
- _a[MessengerType.Message] = openMessengerMessage,
1118
- _a[MessengerType.Mail] = openMessengerMail,
1119
- _a),
1120
- };
1121
- function getTrackId(bundle) {
1122
- try {
1123
- var xhr = new XMLHttpRequest();
1124
- xhr.open('GET', 'https://itunes.apple.com/lookup?bundleId=' + bundle, false);
1125
- xhr.send();
1126
- if (xhr.status === 200) {
1127
- try {
1128
- var response = JSON.parse(xhr.response);
1129
- if (response.results === undefined)
1130
- return undefined;
1131
- var results = response.results;
1132
- if (!Array.isArray(results) || results.length === 0)
1133
- return undefined;
1134
- var result = results[0];
1135
- if (result === undefined)
1136
- return undefined;
1137
- return result.trackId;
1138
- }
1139
- catch (_) {
1140
- return undefined;
1141
- }
1142
- }
1143
- return undefined;
1144
- }
1145
- catch (_) {
1146
- return undefined;
1147
- }
1148
- }
1149
- function createIntentURL(scheme, packageName, fallback) {
1150
- var split = scheme.split('://');
1151
- var prefix = split[0];
1152
- var suffix = split[1];
1153
- var intent = 'intent://';
1154
- if (suffix !== undefined)
1155
- intent = intent + suffix;
1156
- intent = intent + '#Intent;'
1157
- + 'scheme=' + prefix + ';'
1158
- + 'action=android.intent.action.VIEW;'
1159
- + 'category=android.intent.category.BROWSABLE;';
1160
- if (packageName !== undefined)
1161
- intent = intent + 'package=' + packageName + ';';
1162
- if (fallback !== undefined && typeof fallback === 'string')
1163
- intent = intent + 'S.browser_fallback_url=' + fallback + ';';
1164
- else if (packageName !== undefined)
1165
- intent = intent + 'S.browser_fallback_url=' + createAppStoreURL(packageName, OS.Android) + ';';
1166
- return intent + 'end';
1167
- }
1168
- function parseIntentURL(intent) {
1169
- var parsed = {};
1170
- var split = intent.split('#Intent;');
1171
- var host = split[0].substring(9);
1172
- var suffix = split[1];
1173
- var parameterString = suffix.substring(0, suffix.length - 4);
1174
- var parameters = parameterString.split(';');
1175
- var extras = {};
1176
- for (var i = 0; i < parameters.length; i++) {
1177
- var part = parameters[i];
1178
- var index = part.indexOf('=');
1179
- if (index !== -1)
1180
- extras[part.substring(0, index)] = part.substring(index + 1);
1181
- }
1182
- if (extras['scheme'] !== undefined)
1183
- parsed.scheme = (extras['scheme'] + '://' + host);
1184
- if (extras['package'] !== undefined)
1185
- parsed.packageName = extras['package'];
1186
- if (extras['S.browser_fallback_url'] !== undefined)
1187
- parsed.fallback = extras['S.browser_fallback_url'];
1188
- return parsed;
1189
- }
1190
- function createAppStoreURL(packageName, os) {
1191
- if (packageName === undefined)
1192
- return undefined;
1193
- switch (os) {
1194
- case OS.Android:
1195
- return 'market://details?id=' + packageName;
1196
- case OS.iOS:
1197
- return 'itms-apps://itunes.apple.com/app/id' + packageName + '?mt=8';
1198
- case OS.Windows:
1199
- return 'ms-windows-store://pdp/?ProductId=' + packageName;
1200
- case OS.MacOS:
1201
- return 'macappstore://itunes.apple.com/app/id' + packageName + '?mt=12';
1202
- default:
1203
- throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
1204
- }
1205
- }
1206
- function createWebStoreURL(packageName, os) {
1207
- if (packageName === undefined)
1208
- return undefined;
1209
- switch (os) {
1210
- case OS.Android:
1211
- return 'https://play.google.com/store/apps/details?id=' + packageName;
1212
- case OS.iOS:
1213
- return 'https://itunes.apple.com/app/id' + packageName + '?mt=8';
1214
- case OS.Windows:
1215
- return 'https://apps.microsoft.com/detail/' + packageName;
1216
- case OS.MacOS:
1217
- return 'https://apps.apple.com/app/id' + packageName + '?mt=12';
1218
- default:
1219
- throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
1220
- }
1221
- }
1222
- function getDefaultTimeoutByOS(os) {
1223
- switch (os) {
1224
- case OS.iOS:
1225
- return 2000;
1226
- case OS.Android:
1227
- return 1000;
1228
- default:
1229
- return 750;
1230
- }
1231
- }
1232
- function canOpenIntentURL() {
1233
- if (Platform.os !== OS.Android)
1234
- return false;
1235
- if (Platform.browser === Browsers.SamsungInternet && compareVersion(Platform.browserVersion, '17.0.1.69') >= 0 && compareVersion(Platform.browserVersion, '17.0.7.34') < 0)
1236
- return false;
1237
- if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '41.0') < 0)
1238
- return false;
1239
- if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '58.0') >= 0 && compareVersion(Platform.browserVersion, '68.11.0') < 0)
1240
- return false;
1241
- if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '79.0') >= 0 && compareVersion(Platform.browserVersion, '81.2.0') < 0)
1242
- return false;
1243
- if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '96.0') >= 0 && compareVersion(Platform.browserVersion, '107.0') < 0)
1244
- return false;
1245
- if (Platform.browser === Browsers.Opera && compareVersion(Platform.browserVersion, '14.0') < 0)
1246
- return false;
1247
- if (/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(Platform.userAgent) || /instagram[\/ ][-\w.]+/i.test(Platform.userAgent) || /micromessenger\/([\w.]+)/i.test(Platform.userAgent) || /musical_ly(?:.+app_?version\/|_)[\w.]+/i.test(Platform.userAgent) || /ultralite app_version\/[\w.]+/i.test(Platform.userAgent))
1248
- return false;
1249
- return true;
1250
- }
1251
- function canOpenUniversalURL() {
1252
- return Platform.os === OS.iOS && compareVersion(Platform.osVersion, '9.0') >= 0;
1253
- }
1254
- function getURLOpenError(tried) {
1255
- var triedURLString = '';
1256
- for (var i = 0; i < tried.length; i++)
1257
- triedURLString += '\n' + (i + 1) + ': ' + tried[i];
1258
- if (triedURLString.length > 0)
1259
- triedURLString = '\n' + triedURLString + '\n';
1260
- return new URLOpenError('Failed to open any of the provided URLs: ' + triedURLString);
1261
- }
1262
1265
  function open(options) {
1263
1266
  var os = Platform.os;
1264
1267
  var urls = [];