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