native-fn 1.0.50 → 1.0.52
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 +31 -10
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +31 -10
- package/dist/native.umd.js +31 -10
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/app/index.cjs +90 -83
- package/dist/plugin/app/index.min.cjs +1 -1
- package/dist/plugin/app/index.min.mjs +1 -1
- package/dist/plugin/app/index.mjs +90 -83
- package/dist/plugin/app/index.umd.js +90 -83
- package/dist/plugin/app/index.umd.min.js +1 -1
- package/dist/plugin/app/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/dist/plugin/camera/index.cjs +30 -33
- package/dist/plugin/camera/index.min.cjs +1 -1
- package/dist/plugin/camera/index.min.mjs +1 -1
- package/dist/plugin/camera/index.mjs +30 -33
- package/dist/plugin/camera/index.umd.js +30 -33
- package/dist/plugin/camera/index.umd.min.js +1 -1
- package/dist/plugin/camera/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/dist/plugin/fullscreen/index.cjs +30 -9
- package/dist/plugin/fullscreen/index.min.cjs +1 -1
- package/dist/plugin/fullscreen/index.min.mjs +1 -1
- package/dist/plugin/fullscreen/index.mjs +30 -9
- package/dist/plugin/fullscreen/index.umd.js +30 -9
- package/dist/plugin/fullscreen/index.umd.min.js +1 -1
- package/dist/plugin/fullscreen/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/dist/plugin/theme/index.cjs +77 -35
- package/dist/plugin/theme/index.min.cjs +1 -1
- package/dist/plugin/theme/index.min.mjs +1 -1
- package/dist/plugin/theme/index.mjs +77 -35
- package/dist/plugin/theme/index.umd.js +77 -35
- package/dist/plugin/theme/index.umd.min.js +1 -1
- package/dist/plugin/theme/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/dist/src/plugin/app/utils/try-open-url.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,29 @@ var MessengerType;
|
|
|
13
13
|
MessengerType["Mail"] = "mail";
|
|
14
14
|
})(MessengerType || (MessengerType = {}));
|
|
15
15
|
|
|
16
|
+
function compareVersion(lhs, rhs) {
|
|
17
|
+
var pa = lhs.split('.');
|
|
18
|
+
var pb = rhs.split('.');
|
|
19
|
+
var length = Math.max(pa.length, pb.length);
|
|
20
|
+
for (var i = 0; i < length; i++) {
|
|
21
|
+
var a = void 0;
|
|
22
|
+
var b = void 0;
|
|
23
|
+
if (i < pa.length)
|
|
24
|
+
a = parseInt(pa[i], 10);
|
|
25
|
+
else
|
|
26
|
+
a = 0;
|
|
27
|
+
if (i < pb.length)
|
|
28
|
+
b = parseInt(pb[i], 10);
|
|
29
|
+
else
|
|
30
|
+
b = 0;
|
|
31
|
+
if (a > b)
|
|
32
|
+
return 1;
|
|
33
|
+
if (a < b)
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
16
39
|
var OS;
|
|
17
40
|
(function (OS) {
|
|
18
41
|
OS["Unknown"] = "Unknown";
|
|
@@ -68,7 +91,7 @@ var Platform = {
|
|
|
68
91
|
isStandalone: false,
|
|
69
92
|
isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(userAgent),
|
|
70
93
|
isNodeJS: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined,
|
|
71
|
-
isElectron: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined,
|
|
94
|
+
isElectron: (typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(userAgent)),
|
|
72
95
|
isReactNative: typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
73
96
|
};
|
|
74
97
|
var OS_RESOLVER_MAP = [
|
|
@@ -330,9 +353,6 @@ function getIsStandalone(os) {
|
|
|
330
353
|
return 'standalone' in navigator && !!navigator.standalone;
|
|
331
354
|
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
332
355
|
}
|
|
333
|
-
function getIsWebview() {
|
|
334
|
-
return /; ?wv|applewebkit(?!.*safari)/i.test(Platform.userAgent);
|
|
335
|
-
}
|
|
336
356
|
function getSemanticVersion(string) {
|
|
337
357
|
var parts = string.split('.');
|
|
338
358
|
return {
|
|
@@ -350,13 +370,14 @@ for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
|
350
370
|
if (matched !== null) {
|
|
351
371
|
Platform.os = os;
|
|
352
372
|
Platform.osVersion = resolveVersion(matched[1], resolver);
|
|
353
|
-
if (os === OS.iOS || os === OS.Android)
|
|
354
|
-
Platform.device = Devices.Mobile;
|
|
355
|
-
else if (os === OS.Windows || os === OS.MacOS)
|
|
356
|
-
Platform.device = Devices.Desktop;
|
|
357
373
|
break;
|
|
358
374
|
}
|
|
359
375
|
}
|
|
376
|
+
if (Platform.os === OS.iOS && compareVersion(Platform.osVersion, '18.6') === 0) {
|
|
377
|
+
var version = /\) Version\/([\d.]+)/.exec(Platform.userAgent);
|
|
378
|
+
if (version !== null && parseInt(version[1].substring(0, 2), 10) >= 26)
|
|
379
|
+
Platform.osVersion = version[1];
|
|
380
|
+
}
|
|
360
381
|
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
361
382
|
var map = ENGINE_RESOLVER_MAP[i];
|
|
362
383
|
var regexp = map[0];
|
|
@@ -464,9 +485,9 @@ if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntr
|
|
|
464
485
|
}
|
|
465
486
|
});
|
|
466
487
|
}
|
|
488
|
+
Platform.device = Platform.os === OS.iOS || Platform.os === OS.Android ? Devices.Mobile : Platform.os === OS.Windows || Platform.os === OS.MacOS ? Devices.Desktop : Devices.Unknown;
|
|
467
489
|
Platform.isMobile = Platform.device === Devices.Mobile;
|
|
468
490
|
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
469
|
-
Platform.isWebview = getIsWebview();
|
|
470
491
|
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
471
492
|
|
|
472
493
|
function capitalize(match) {
|
|
@@ -694,29 +715,6 @@ function createHiddenElement(tagName, focusable) {
|
|
|
694
715
|
return element;
|
|
695
716
|
}
|
|
696
717
|
|
|
697
|
-
function compareVersion(lhs, rhs) {
|
|
698
|
-
var pa = lhs.split('.');
|
|
699
|
-
var pb = rhs.split('.');
|
|
700
|
-
var length = Math.max(pa.length, pb.length);
|
|
701
|
-
for (var i = 0; i < length; i++) {
|
|
702
|
-
var a = void 0;
|
|
703
|
-
var b = void 0;
|
|
704
|
-
if (i < pa.length)
|
|
705
|
-
a = parseInt(pa[i], 10);
|
|
706
|
-
else
|
|
707
|
-
a = 0;
|
|
708
|
-
if (i < pb.length)
|
|
709
|
-
b = parseInt(pb[i], 10);
|
|
710
|
-
else
|
|
711
|
-
b = 0;
|
|
712
|
-
if (a > b)
|
|
713
|
-
return 1;
|
|
714
|
-
if (a < b)
|
|
715
|
-
return -1;
|
|
716
|
-
}
|
|
717
|
-
return 0;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
718
|
function openURLViaHref(url, index) {
|
|
721
719
|
var top = getTopmostWindow();
|
|
722
720
|
var document = top.document;
|
|
@@ -853,45 +851,47 @@ function restoreFocus() {
|
|
|
853
851
|
}
|
|
854
852
|
return hasFocus(document);
|
|
855
853
|
}
|
|
856
|
-
function
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
catch (_) {
|
|
879
|
-
}
|
|
854
|
+
function tryOpenURLReactNative(url) {
|
|
855
|
+
try {
|
|
856
|
+
var reactNative = require('react-native');
|
|
857
|
+
var linking_1 = reactNative.Linking;
|
|
858
|
+
return new Promise(function (resolve, reject) {
|
|
859
|
+
linking_1
|
|
860
|
+
.canOpenURL(url)
|
|
861
|
+
.then(function (canOpen) {
|
|
862
|
+
if (canOpen) {
|
|
863
|
+
linking_1
|
|
864
|
+
.openURL(url)
|
|
865
|
+
.then(resolve)
|
|
866
|
+
.catch(reject);
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
reject();
|
|
870
|
+
}
|
|
871
|
+
})
|
|
872
|
+
.catch(reject);
|
|
873
|
+
});
|
|
880
874
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
875
|
+
catch (_) {
|
|
876
|
+
return Promise.reject();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function tryOpenURLElectron(url) {
|
|
880
|
+
try {
|
|
881
|
+
var electron = require('electron');
|
|
882
|
+
var shell_1 = electron.shell;
|
|
883
|
+
return new Promise(function (resolve, reject) {
|
|
884
|
+
shell_1
|
|
885
|
+
.openExternal(url)
|
|
886
|
+
.then(resolve)
|
|
887
|
+
.catch(reject);
|
|
888
|
+
});
|
|
894
889
|
}
|
|
890
|
+
catch (_) {
|
|
891
|
+
return Promise.reject();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
function tryOpenURLBrowser(url, index, timeout) {
|
|
895
895
|
var top = getTopmostWindow();
|
|
896
896
|
var document = top.document;
|
|
897
897
|
var eventType = { focus: undefined, blur: undefined, visibilitychange: undefined };
|
|
@@ -978,6 +978,13 @@ function tryOpenUrl(url, index, timeout) {
|
|
|
978
978
|
}
|
|
979
979
|
});
|
|
980
980
|
}
|
|
981
|
+
function tryOpenURL(url, index, timeout) {
|
|
982
|
+
if (Platform.isReactNative)
|
|
983
|
+
return tryOpenURLReactNative(url);
|
|
984
|
+
if (Platform.isElectron)
|
|
985
|
+
return tryOpenURLElectron(url);
|
|
986
|
+
return tryOpenURLBrowser(url, index, timeout);
|
|
987
|
+
}
|
|
981
988
|
|
|
982
989
|
function createCustomError(name, Base) {
|
|
983
990
|
if (Base === void 0) { Base = Error; }
|
|
@@ -1202,12 +1209,12 @@ function canOpenUniversalURL() {
|
|
|
1202
1209
|
return Platform.os === OS.iOS && compareVersion(Platform.osVersion, '9.0') >= 0;
|
|
1203
1210
|
}
|
|
1204
1211
|
function getURLOpenError(tried) {
|
|
1205
|
-
var
|
|
1212
|
+
var triedURLString = '';
|
|
1206
1213
|
for (var i = 0; i < tried.length; i++)
|
|
1207
|
-
|
|
1208
|
-
if (
|
|
1209
|
-
|
|
1210
|
-
return new URLOpenError('Failed to open any of the provided URLs: ' +
|
|
1214
|
+
triedURLString += '\n' + (i + 1) + ': ' + tried[i];
|
|
1215
|
+
if (triedURLString.length > 0)
|
|
1216
|
+
triedURLString = '\n' + triedURLString + '\n';
|
|
1217
|
+
return new URLOpenError('Failed to open any of the provided URLs: ' + triedURLString);
|
|
1211
1218
|
}
|
|
1212
1219
|
function open(options) {
|
|
1213
1220
|
var os = Platform.os;
|
|
@@ -1282,12 +1289,12 @@ function open(options) {
|
|
|
1282
1289
|
if (infos.bundleId !== undefined && infos.trackId === undefined)
|
|
1283
1290
|
infos.trackId = getTrackId(infos.bundleId);
|
|
1284
1291
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1292
|
+
pushURL(urls, infos.intent, AppOpenState.Intent, canOpenIntentURL());
|
|
1293
|
+
pushURL(urls, infos.universal, AppOpenState.Universal, canOpenUniversalURL());
|
|
1294
|
+
pushURL(urls, infos.scheme, AppOpenState.Scheme);
|
|
1295
|
+
pushURL(urls, infos.fallback, AppOpenState.Fallback);
|
|
1296
|
+
pushURL(urls, infos.appStore, AppOpenState.Store);
|
|
1297
|
+
pushURL(urls, infos.webStore, AppOpenState.Store, infos.allowWebStore);
|
|
1291
1298
|
if (timeout === undefined)
|
|
1292
1299
|
timeout = getDefaultTimeoutByOS(os);
|
|
1293
1300
|
return new Promise(function (resolve, reject) {
|
|
@@ -1300,7 +1307,7 @@ function open(options) {
|
|
|
1300
1307
|
var url = entry[1];
|
|
1301
1308
|
if (typeof url === 'string') {
|
|
1302
1309
|
tried[index] = url;
|
|
1303
|
-
return
|
|
1310
|
+
return tryOpenURL(url, index, timeout)
|
|
1304
1311
|
.then(function () {
|
|
1305
1312
|
resolve(state);
|
|
1306
1313
|
})
|
|
@@ -1317,7 +1324,7 @@ function open(options) {
|
|
|
1317
1324
|
return openURLSequential();
|
|
1318
1325
|
});
|
|
1319
1326
|
}
|
|
1320
|
-
function
|
|
1327
|
+
function pushURL(urls, url, state, condition) {
|
|
1321
1328
|
if (condition === void 0) { condition = true; }
|
|
1322
1329
|
if ((typeof url === 'function' || typeof url === 'string') && condition)
|
|
1323
1330
|
urls.push([state, url]);
|
|
@@ -1443,7 +1450,7 @@ function normalize(value) {
|
|
|
1443
1450
|
}
|
|
1444
1451
|
function openMessenger(options, type) {
|
|
1445
1452
|
options = normalize(options);
|
|
1446
|
-
return
|
|
1453
|
+
return tryOpenURL(type + ':' + options.to
|
|
1447
1454
|
+ '?cc=' + options.cc
|
|
1448
1455
|
+ '&bcc=' + options.bcc
|
|
1449
1456
|
+ '&subject=' + options.subject
|
|
@@ -19,6 +19,29 @@
|
|
|
19
19
|
MessengerType["Mail"] = "mail";
|
|
20
20
|
})(MessengerType || (MessengerType = {}));
|
|
21
21
|
|
|
22
|
+
function compareVersion(lhs, rhs) {
|
|
23
|
+
var pa = lhs.split('.');
|
|
24
|
+
var pb = rhs.split('.');
|
|
25
|
+
var length = Math.max(pa.length, pb.length);
|
|
26
|
+
for (var i = 0; i < length; i++) {
|
|
27
|
+
var a = void 0;
|
|
28
|
+
var b = void 0;
|
|
29
|
+
if (i < pa.length)
|
|
30
|
+
a = parseInt(pa[i], 10);
|
|
31
|
+
else
|
|
32
|
+
a = 0;
|
|
33
|
+
if (i < pb.length)
|
|
34
|
+
b = parseInt(pb[i], 10);
|
|
35
|
+
else
|
|
36
|
+
b = 0;
|
|
37
|
+
if (a > b)
|
|
38
|
+
return 1;
|
|
39
|
+
if (a < b)
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
22
45
|
var OS;
|
|
23
46
|
(function (OS) {
|
|
24
47
|
OS["Unknown"] = "Unknown";
|
|
@@ -74,7 +97,7 @@
|
|
|
74
97
|
isStandalone: false,
|
|
75
98
|
isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(userAgent),
|
|
76
99
|
isNodeJS: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined,
|
|
77
|
-
isElectron: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined,
|
|
100
|
+
isElectron: (typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(userAgent)),
|
|
78
101
|
isReactNative: typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
79
102
|
};
|
|
80
103
|
var OS_RESOLVER_MAP = [
|
|
@@ -336,9 +359,6 @@
|
|
|
336
359
|
return 'standalone' in navigator && !!navigator.standalone;
|
|
337
360
|
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
338
361
|
}
|
|
339
|
-
function getIsWebview() {
|
|
340
|
-
return /; ?wv|applewebkit(?!.*safari)/i.test(Platform.userAgent);
|
|
341
|
-
}
|
|
342
362
|
function getSemanticVersion(string) {
|
|
343
363
|
var parts = string.split('.');
|
|
344
364
|
return {
|
|
@@ -356,13 +376,14 @@
|
|
|
356
376
|
if (matched !== null) {
|
|
357
377
|
Platform.os = os;
|
|
358
378
|
Platform.osVersion = resolveVersion(matched[1], resolver);
|
|
359
|
-
if (os === OS.iOS || os === OS.Android)
|
|
360
|
-
Platform.device = Devices.Mobile;
|
|
361
|
-
else if (os === OS.Windows || os === OS.MacOS)
|
|
362
|
-
Platform.device = Devices.Desktop;
|
|
363
379
|
break;
|
|
364
380
|
}
|
|
365
381
|
}
|
|
382
|
+
if (Platform.os === OS.iOS && compareVersion(Platform.osVersion, '18.6') === 0) {
|
|
383
|
+
var version = /\) Version\/([\d.]+)/.exec(Platform.userAgent);
|
|
384
|
+
if (version !== null && parseInt(version[1].substring(0, 2), 10) >= 26)
|
|
385
|
+
Platform.osVersion = version[1];
|
|
386
|
+
}
|
|
366
387
|
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
367
388
|
var map = ENGINE_RESOLVER_MAP[i];
|
|
368
389
|
var regexp = map[0];
|
|
@@ -470,9 +491,9 @@
|
|
|
470
491
|
}
|
|
471
492
|
});
|
|
472
493
|
}
|
|
494
|
+
Platform.device = Platform.os === OS.iOS || Platform.os === OS.Android ? Devices.Mobile : Platform.os === OS.Windows || Platform.os === OS.MacOS ? Devices.Desktop : Devices.Unknown;
|
|
473
495
|
Platform.isMobile = Platform.device === Devices.Mobile;
|
|
474
496
|
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
475
|
-
Platform.isWebview = getIsWebview();
|
|
476
497
|
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
477
498
|
|
|
478
499
|
function capitalize(match) {
|
|
@@ -700,29 +721,6 @@
|
|
|
700
721
|
return element;
|
|
701
722
|
}
|
|
702
723
|
|
|
703
|
-
function compareVersion(lhs, rhs) {
|
|
704
|
-
var pa = lhs.split('.');
|
|
705
|
-
var pb = rhs.split('.');
|
|
706
|
-
var length = Math.max(pa.length, pb.length);
|
|
707
|
-
for (var i = 0; i < length; i++) {
|
|
708
|
-
var a = void 0;
|
|
709
|
-
var b = void 0;
|
|
710
|
-
if (i < pa.length)
|
|
711
|
-
a = parseInt(pa[i], 10);
|
|
712
|
-
else
|
|
713
|
-
a = 0;
|
|
714
|
-
if (i < pb.length)
|
|
715
|
-
b = parseInt(pb[i], 10);
|
|
716
|
-
else
|
|
717
|
-
b = 0;
|
|
718
|
-
if (a > b)
|
|
719
|
-
return 1;
|
|
720
|
-
if (a < b)
|
|
721
|
-
return -1;
|
|
722
|
-
}
|
|
723
|
-
return 0;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
724
|
function openURLViaHref(url, index) {
|
|
727
725
|
var top = getTopmostWindow();
|
|
728
726
|
var document = top.document;
|
|
@@ -859,45 +857,47 @@
|
|
|
859
857
|
}
|
|
860
858
|
return hasFocus(document);
|
|
861
859
|
}
|
|
862
|
-
function
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
catch (_) {
|
|
885
|
-
}
|
|
860
|
+
function tryOpenURLReactNative(url) {
|
|
861
|
+
try {
|
|
862
|
+
var reactNative = require('react-native');
|
|
863
|
+
var linking_1 = reactNative.Linking;
|
|
864
|
+
return new Promise(function (resolve, reject) {
|
|
865
|
+
linking_1
|
|
866
|
+
.canOpenURL(url)
|
|
867
|
+
.then(function (canOpen) {
|
|
868
|
+
if (canOpen) {
|
|
869
|
+
linking_1
|
|
870
|
+
.openURL(url)
|
|
871
|
+
.then(resolve)
|
|
872
|
+
.catch(reject);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
reject();
|
|
876
|
+
}
|
|
877
|
+
})
|
|
878
|
+
.catch(reject);
|
|
879
|
+
});
|
|
886
880
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
881
|
+
catch (_) {
|
|
882
|
+
return Promise.reject();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function tryOpenURLElectron(url) {
|
|
886
|
+
try {
|
|
887
|
+
var electron = require('electron');
|
|
888
|
+
var shell_1 = electron.shell;
|
|
889
|
+
return new Promise(function (resolve, reject) {
|
|
890
|
+
shell_1
|
|
891
|
+
.openExternal(url)
|
|
892
|
+
.then(resolve)
|
|
893
|
+
.catch(reject);
|
|
894
|
+
});
|
|
900
895
|
}
|
|
896
|
+
catch (_) {
|
|
897
|
+
return Promise.reject();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function tryOpenURLBrowser(url, index, timeout) {
|
|
901
901
|
var top = getTopmostWindow();
|
|
902
902
|
var document = top.document;
|
|
903
903
|
var eventType = { focus: undefined, blur: undefined, visibilitychange: undefined };
|
|
@@ -984,6 +984,13 @@
|
|
|
984
984
|
}
|
|
985
985
|
});
|
|
986
986
|
}
|
|
987
|
+
function tryOpenURL(url, index, timeout) {
|
|
988
|
+
if (Platform.isReactNative)
|
|
989
|
+
return tryOpenURLReactNative(url);
|
|
990
|
+
if (Platform.isElectron)
|
|
991
|
+
return tryOpenURLElectron(url);
|
|
992
|
+
return tryOpenURLBrowser(url, index, timeout);
|
|
993
|
+
}
|
|
987
994
|
|
|
988
995
|
function createCustomError(name, Base) {
|
|
989
996
|
if (Base === void 0) { Base = Error; }
|
|
@@ -1208,12 +1215,12 @@
|
|
|
1208
1215
|
return Platform.os === OS.iOS && compareVersion(Platform.osVersion, '9.0') >= 0;
|
|
1209
1216
|
}
|
|
1210
1217
|
function getURLOpenError(tried) {
|
|
1211
|
-
var
|
|
1218
|
+
var triedURLString = '';
|
|
1212
1219
|
for (var i = 0; i < tried.length; i++)
|
|
1213
|
-
|
|
1214
|
-
if (
|
|
1215
|
-
|
|
1216
|
-
return new URLOpenError('Failed to open any of the provided URLs: ' +
|
|
1220
|
+
triedURLString += '\n' + (i + 1) + ': ' + tried[i];
|
|
1221
|
+
if (triedURLString.length > 0)
|
|
1222
|
+
triedURLString = '\n' + triedURLString + '\n';
|
|
1223
|
+
return new URLOpenError('Failed to open any of the provided URLs: ' + triedURLString);
|
|
1217
1224
|
}
|
|
1218
1225
|
function open(options) {
|
|
1219
1226
|
var os = Platform.os;
|
|
@@ -1288,12 +1295,12 @@
|
|
|
1288
1295
|
if (infos.bundleId !== undefined && infos.trackId === undefined)
|
|
1289
1296
|
infos.trackId = getTrackId(infos.bundleId);
|
|
1290
1297
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1298
|
+
pushURL(urls, infos.intent, AppOpenState.Intent, canOpenIntentURL());
|
|
1299
|
+
pushURL(urls, infos.universal, AppOpenState.Universal, canOpenUniversalURL());
|
|
1300
|
+
pushURL(urls, infos.scheme, AppOpenState.Scheme);
|
|
1301
|
+
pushURL(urls, infos.fallback, AppOpenState.Fallback);
|
|
1302
|
+
pushURL(urls, infos.appStore, AppOpenState.Store);
|
|
1303
|
+
pushURL(urls, infos.webStore, AppOpenState.Store, infos.allowWebStore);
|
|
1297
1304
|
if (timeout === undefined)
|
|
1298
1305
|
timeout = getDefaultTimeoutByOS(os);
|
|
1299
1306
|
return new Promise(function (resolve, reject) {
|
|
@@ -1306,7 +1313,7 @@
|
|
|
1306
1313
|
var url = entry[1];
|
|
1307
1314
|
if (typeof url === 'string') {
|
|
1308
1315
|
tried[index] = url;
|
|
1309
|
-
return
|
|
1316
|
+
return tryOpenURL(url, index, timeout)
|
|
1310
1317
|
.then(function () {
|
|
1311
1318
|
resolve(state);
|
|
1312
1319
|
})
|
|
@@ -1323,7 +1330,7 @@
|
|
|
1323
1330
|
return openURLSequential();
|
|
1324
1331
|
});
|
|
1325
1332
|
}
|
|
1326
|
-
function
|
|
1333
|
+
function pushURL(urls, url, state, condition) {
|
|
1327
1334
|
if (condition === void 0) { condition = true; }
|
|
1328
1335
|
if ((typeof url === 'function' || typeof url === 'string') && condition)
|
|
1329
1336
|
urls.push([state, url]);
|
|
@@ -1449,7 +1456,7 @@
|
|
|
1449
1456
|
}
|
|
1450
1457
|
function openMessenger(options, type) {
|
|
1451
1458
|
options = normalize(options);
|
|
1452
|
-
return
|
|
1459
|
+
return tryOpenURL(type + ':' + options.to
|
|
1453
1460
|
+ '?cc=' + options.cc
|
|
1454
1461
|
+ '&bcc=' + options.bcc
|
|
1455
1462
|
+ '&subject=' + options.subject
|