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