web-launch-kit 0.0.1 → 0.0.2
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/README.md +55 -43
- package/dist/index.d.ts +15 -1
- package/dist/launch-kit.cjs +169 -14
- package/dist/launch-kit.cjs.map +1 -1
- package/dist/launch-kit.min.cjs +1 -1
- package/dist/launch-kit.min.cjs.map +1 -1
- package/dist/launch-kit.min.mjs +1 -1
- package/dist/launch-kit.min.mjs.map +1 -1
- package/dist/launch-kit.mjs +169 -14
- package/dist/launch-kit.mjs.map +1 -1
- package/dist/launch-kit.umd.js +169 -14
- package/dist/launch-kit.umd.js.map +1 -1
- package/dist/launch-kit.umd.min.js +1 -1
- package/dist/launch-kit.umd.min.js.map +1 -1
- package/package.json +7 -2
package/dist/launch-kit.umd.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LaunchKit = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var version$1 = "0.0.
|
|
7
|
+
var version$1 = "0.0.2";
|
|
8
8
|
var packageJSON$1 = {
|
|
9
9
|
version: version$1};
|
|
10
10
|
|
|
@@ -942,7 +942,7 @@
|
|
|
942
942
|
var IOS_DEFAULT_TIMEOUT = 2000;
|
|
943
943
|
var WINDOWS_DEFAULT_TIMEOUT = 750;
|
|
944
944
|
var MACOS_DEFAULT_TIMEOUT = 750;
|
|
945
|
-
var
|
|
945
|
+
var DEFAULT_TIMEOUT = 750;
|
|
946
946
|
var NAVIGATOR = globalThis.navigator;
|
|
947
947
|
var CLEANUP_INPUT_ELEMENT = null;
|
|
948
948
|
function createTypeGuard(tag) {
|
|
@@ -976,7 +976,7 @@
|
|
|
976
976
|
case 'macos':
|
|
977
977
|
return MACOS_DEFAULT_TIMEOUT;
|
|
978
978
|
default:
|
|
979
|
-
return
|
|
979
|
+
return DEFAULT_TIMEOUT;
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
982
|
function isDocumentHidden() {
|
|
@@ -1082,7 +1082,7 @@
|
|
|
1082
1082
|
return hasFocus(topDocument);
|
|
1083
1083
|
}
|
|
1084
1084
|
function stripURL(value) {
|
|
1085
|
-
return
|
|
1085
|
+
return isURL(value) ? value.toString() : value;
|
|
1086
1086
|
}
|
|
1087
1087
|
function resolveFocusEventConfig() {
|
|
1088
1088
|
var top = getTopmostWindow();
|
|
@@ -1296,6 +1296,8 @@
|
|
|
1296
1296
|
var fallback;
|
|
1297
1297
|
var allowAppStore;
|
|
1298
1298
|
var allowWebStore;
|
|
1299
|
+
var allowScheme;
|
|
1300
|
+
var assumeAllowedInApp;
|
|
1299
1301
|
var timeout;
|
|
1300
1302
|
var intent;
|
|
1301
1303
|
var packageName;
|
|
@@ -1312,8 +1314,10 @@
|
|
|
1312
1314
|
scheme = stripURL(option.android.scheme);
|
|
1313
1315
|
fallback = stripURL(option.android.fallback);
|
|
1314
1316
|
packageName = option.android.packageName;
|
|
1317
|
+
assumeAllowedInApp = option.android.assumeAllowedInApp === true;
|
|
1315
1318
|
allowAppStore = option.android.allowAppStore;
|
|
1316
1319
|
allowWebStore = option.android.allowWebStore;
|
|
1320
|
+
allowScheme = canOpenScheme(assumeAllowedInApp);
|
|
1317
1321
|
timeout = option.android.timeout;
|
|
1318
1322
|
if (typeof intent !== 'undefined' && (typeof scheme === 'undefined' || typeof packageName === 'undefined' || typeof fallback === 'undefined')) {
|
|
1319
1323
|
var parsed = parseIntentURL(intent);
|
|
@@ -1330,12 +1334,12 @@
|
|
|
1330
1334
|
timeout = ANDROID_DEFAULT_TIMEOUT;
|
|
1331
1335
|
if (typeof intent !== 'undefined' && canOpenIntent())
|
|
1332
1336
|
resolved.push(['intent', intent]);
|
|
1333
|
-
if (typeof scheme !== 'undefined')
|
|
1337
|
+
if (typeof scheme !== 'undefined' && allowScheme)
|
|
1334
1338
|
resolved.push(['scheme', scheme]);
|
|
1335
1339
|
if (typeof fallback !== 'undefined')
|
|
1336
1340
|
resolved.push(['fallback', fallback]);
|
|
1337
1341
|
if (typeof packageName !== 'undefined') {
|
|
1338
|
-
if (allowAppStore)
|
|
1342
|
+
if (allowAppStore && allowScheme)
|
|
1339
1343
|
resolved.push(['store', createAppStoreURL(packageName, os)]);
|
|
1340
1344
|
if (allowWebStore)
|
|
1341
1345
|
resolved.push(['store', createWebStoreURL(packageName, os)]);
|
|
@@ -1349,21 +1353,23 @@
|
|
|
1349
1353
|
fallback = stripURL(option.ios.fallback);
|
|
1350
1354
|
bundleId = option.ios.bundleId;
|
|
1351
1355
|
trackId = option.ios.trackId;
|
|
1356
|
+
assumeAllowedInApp = option.ios.assumeAllowedInApp === true;
|
|
1352
1357
|
allowAppStore = option.ios.allowAppStore;
|
|
1353
1358
|
allowWebStore = option.ios.allowWebStore;
|
|
1359
|
+
allowScheme = canOpenScheme(assumeAllowedInApp);
|
|
1354
1360
|
timeout = option.ios.timeout;
|
|
1355
1361
|
if (typeof bundleId !== 'undefined' && typeof trackId === 'undefined')
|
|
1356
1362
|
trackId = getTrackId(bundleId);
|
|
1357
1363
|
if (typeof timeout === 'undefined')
|
|
1358
1364
|
timeout = IOS_DEFAULT_TIMEOUT;
|
|
1359
|
-
if (typeof universal !== 'undefined' && canOpenUniversal())
|
|
1365
|
+
if (typeof universal !== 'undefined' && canOpenUniversal(assumeAllowedInApp))
|
|
1360
1366
|
resolved.push(['universal', universal]);
|
|
1361
|
-
if (typeof scheme !== 'undefined')
|
|
1367
|
+
if (typeof scheme !== 'undefined' && allowScheme)
|
|
1362
1368
|
resolved.push(['scheme', scheme]);
|
|
1363
1369
|
if (typeof fallback !== 'undefined')
|
|
1364
1370
|
resolved.push(['fallback', fallback]);
|
|
1365
1371
|
if (typeof trackId !== 'undefined') {
|
|
1366
|
-
if (allowAppStore)
|
|
1372
|
+
if (allowAppStore && allowScheme)
|
|
1367
1373
|
resolved.push(['store', createAppStoreURL(trackId, os)]);
|
|
1368
1374
|
if (allowWebStore)
|
|
1369
1375
|
resolved.push(['store', createWebStoreURL(trackId, os)]);
|
|
@@ -1436,10 +1442,41 @@
|
|
|
1436
1442
|
return false;
|
|
1437
1443
|
if (browser === 'opera' && PlatformKit.compareVersion(version, '14.0') < 0)
|
|
1438
1444
|
return false;
|
|
1439
|
-
|
|
1445
|
+
if (isFullyBlockedInAppBrowser() || isPartnerAppOnly())
|
|
1446
|
+
return false;
|
|
1447
|
+
return !(/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(PlatformKit.userAgent) || /instagram[\/ ][-\w.]+/i.test(PlatformKit.userAgent) || /musical_ly(?:.+app_?version\/|_)[\w.]+/i.test(PlatformKit.userAgent) || /ultralite app_version\/[\w.]+/i.test(PlatformKit.userAgent));
|
|
1448
|
+
}
|
|
1449
|
+
function canOpenUniversal(assumeAllowedInApp) {
|
|
1450
|
+
if (assumeAllowedInApp === void 0) { assumeAllowedInApp = false; }
|
|
1451
|
+
if (PlatformKit.os.name !== 'ios' || PlatformKit.compareVersion(PlatformKit.os.version, '9.0') < 0)
|
|
1452
|
+
return false;
|
|
1453
|
+
if (isPartnerAppOnly() && !assumeAllowedInApp)
|
|
1454
|
+
return false;
|
|
1455
|
+
var userAgent = PlatformKit.userAgent;
|
|
1456
|
+
var wechat = userAgent.match(/micromessenger\/(\d+(?:\.\d+)*)/i);
|
|
1457
|
+
if (wechat !== null && PlatformKit.compareVersion(wechat[1], '7.0.5') < 0)
|
|
1458
|
+
return false;
|
|
1459
|
+
if (/ qq\/[\d.]+/i.test(userAgent) || /m?qqbrowser\/[\d.]+/i.test(userAgent) || /ucbrowser\/[\d.]+/i.test(userAgent))
|
|
1460
|
+
return false;
|
|
1461
|
+
return !/qzone\/.*_qz_[\d.]+/i.test(userAgent);
|
|
1462
|
+
}
|
|
1463
|
+
function canOpenScheme(assumeAllowedInApp) {
|
|
1464
|
+
if (assumeAllowedInApp === void 0) { assumeAllowedInApp = false; }
|
|
1465
|
+
var os = PlatformKit.os.name;
|
|
1466
|
+
if (os === 'android')
|
|
1467
|
+
return !isFullyBlockedInAppBrowser() && (!isPartnerAppOnly() || assumeAllowedInApp);
|
|
1468
|
+
if (os === 'ios')
|
|
1469
|
+
return !/micromessenger\/[\w.]+/i.test(PlatformKit.userAgent) && (!isPartnerAppOnly() || assumeAllowedInApp);
|
|
1470
|
+
return true;
|
|
1471
|
+
}
|
|
1472
|
+
function isFullyBlockedInAppBrowser() {
|
|
1473
|
+
if (PlatformKit.os.name !== 'android')
|
|
1474
|
+
return false;
|
|
1475
|
+
var userAgent = PlatformKit.userAgent;
|
|
1476
|
+
return /micromessenger\/[\w.]+/i.test(userAgent) || / qq\/[\d.]+/i.test(userAgent) || /qzone\/.*_qz_[\d.]+/i.test(userAgent) || /baiduboxapp\/[\d.]+/i.test(userAgent);
|
|
1440
1477
|
}
|
|
1441
|
-
function
|
|
1442
|
-
return
|
|
1478
|
+
function isPartnerAppOnly() {
|
|
1479
|
+
return /weibo.*weibo__[\d.]+/i.test(PlatformKit.userAgent);
|
|
1443
1480
|
}
|
|
1444
1481
|
function canOpenSetting() {
|
|
1445
1482
|
var os = PlatformKit.os.name;
|
|
@@ -1546,6 +1583,18 @@
|
|
|
1546
1583
|
function encodeMailBody(value) {
|
|
1547
1584
|
return escapeURIComponentString(value.replace(/\r\n|\n|\r/g, '\r\n'));
|
|
1548
1585
|
}
|
|
1586
|
+
function encodeMapValue(value) {
|
|
1587
|
+
if (isArray(value))
|
|
1588
|
+
return value[0] + ',' + value[1];
|
|
1589
|
+
return escapeURIComponentString(value);
|
|
1590
|
+
}
|
|
1591
|
+
function encodeBingRoutePoint(value) {
|
|
1592
|
+
if (typeof value === 'undefined')
|
|
1593
|
+
return '';
|
|
1594
|
+
if (isArray(value))
|
|
1595
|
+
return 'pos.' + value[0] + '_' + value[1];
|
|
1596
|
+
return escapeURIComponentString(value);
|
|
1597
|
+
}
|
|
1549
1598
|
function toArray(value) {
|
|
1550
1599
|
return typeof value === 'undefined' ? [] : typeof value === 'string' ? [value] : value;
|
|
1551
1600
|
}
|
|
@@ -1792,12 +1841,12 @@
|
|
|
1792
1841
|
catch (error) {
|
|
1793
1842
|
return Promise.reject(error);
|
|
1794
1843
|
}
|
|
1795
|
-
var tried = [];
|
|
1796
1844
|
var urls = resolved[0];
|
|
1797
1845
|
var timeout = resolved[1];
|
|
1798
1846
|
if (urls.length === 0)
|
|
1799
1847
|
return Promise.reject(new Error('No openable URL candidates were resolved for the current OS ("' + PlatformKit.os.name + '"). Provide at least one of: scheme, intent, universal, fallback, or store id for this platform.'));
|
|
1800
1848
|
return new Promise(function (resolve, reject) {
|
|
1849
|
+
var tried = [];
|
|
1801
1850
|
function openURLSequential(index) {
|
|
1802
1851
|
if (index === void 0) { index = 0; }
|
|
1803
1852
|
if (index >= urls.length)
|
|
@@ -1869,6 +1918,112 @@
|
|
|
1869
1918
|
url += '?' + joining(params, undefined, '&');
|
|
1870
1919
|
return openURL(0, url, getDefaultTimeout());
|
|
1871
1920
|
},
|
|
1921
|
+
map: function (options) {
|
|
1922
|
+
if (options === void 0) { options = {}; }
|
|
1923
|
+
var params = [];
|
|
1924
|
+
var urls = [];
|
|
1925
|
+
var url = '';
|
|
1926
|
+
switch (PlatformKit.os.name) {
|
|
1927
|
+
case 'android':
|
|
1928
|
+
if (typeof options.coordinate !== 'undefined') {
|
|
1929
|
+
url = 'geo:' + options.coordinate[0] + ',' + options.coordinate[1];
|
|
1930
|
+
}
|
|
1931
|
+
else if (typeof options.query !== 'undefined') {
|
|
1932
|
+
url = 'geo:0,0';
|
|
1933
|
+
params.push('q=' + escapeURIComponentString(options.query));
|
|
1934
|
+
}
|
|
1935
|
+
else {
|
|
1936
|
+
url = 'geo:0,0';
|
|
1937
|
+
}
|
|
1938
|
+
if (typeof options.zoom !== 'undefined')
|
|
1939
|
+
params.push('z=' + options.zoom);
|
|
1940
|
+
if (params.length > 0)
|
|
1941
|
+
url = url + '?' + joining(params, undefined, '&');
|
|
1942
|
+
urls.push(url);
|
|
1943
|
+
break;
|
|
1944
|
+
case 'ios':
|
|
1945
|
+
case 'macos':
|
|
1946
|
+
if (typeof options.directions !== 'undefined') {
|
|
1947
|
+
if (typeof options.directions.destination !== 'undefined')
|
|
1948
|
+
params.push('daddr=' + encodeMapValue(options.directions.destination));
|
|
1949
|
+
if (typeof options.directions.origin !== 'undefined')
|
|
1950
|
+
params.push('saddr=' + encodeMapValue(options.directions.origin));
|
|
1951
|
+
}
|
|
1952
|
+
else if (typeof options.coordinate !== 'undefined') {
|
|
1953
|
+
params.push('ll=' + options.coordinate[0] + ',' + options.coordinate[1]);
|
|
1954
|
+
if (typeof options.label !== 'undefined')
|
|
1955
|
+
params.push('q=' + escapeURIComponentString(options.label));
|
|
1956
|
+
}
|
|
1957
|
+
else if (typeof options.query !== 'undefined') {
|
|
1958
|
+
params.push('q=' + escapeURIComponentString(options.query));
|
|
1959
|
+
}
|
|
1960
|
+
if (typeof options.zoom !== 'undefined')
|
|
1961
|
+
params.push('z=' + options.zoom);
|
|
1962
|
+
urls.push('maps://?' + joining(params, undefined, '&'));
|
|
1963
|
+
break;
|
|
1964
|
+
case 'windows':
|
|
1965
|
+
if (typeof options.directions !== 'undefined') {
|
|
1966
|
+
params.push('rtp=' + encodeBingRoutePoint(options.directions.origin) + '~' + encodeBingRoutePoint(options.directions.destination));
|
|
1967
|
+
}
|
|
1968
|
+
else if (typeof options.coordinate !== 'undefined') {
|
|
1969
|
+
params.push('cp=' + options.coordinate[0] + '~' + options.coordinate[1]);
|
|
1970
|
+
if (typeof options.label !== 'undefined')
|
|
1971
|
+
params.push('q=' + escapeURIComponentString(options.label));
|
|
1972
|
+
}
|
|
1973
|
+
else if (typeof options.query !== 'undefined') {
|
|
1974
|
+
params.push('where=' + escapeURIComponentString(options.query));
|
|
1975
|
+
}
|
|
1976
|
+
if (typeof options.zoom !== 'undefined')
|
|
1977
|
+
params.push('lvl=' + options.zoom);
|
|
1978
|
+
urls.push('bingmaps:?' + joining(params, undefined, '&'));
|
|
1979
|
+
}
|
|
1980
|
+
if (typeof options.fallback !== 'undefined') {
|
|
1981
|
+
urls.push(stripURL(options.fallback));
|
|
1982
|
+
}
|
|
1983
|
+
else {
|
|
1984
|
+
var params_1 = ['api=1'];
|
|
1985
|
+
if (typeof options.directions !== 'undefined') {
|
|
1986
|
+
params_1.push('destination=' + encodeMapValue(options.directions.destination));
|
|
1987
|
+
if (typeof options.directions.origin !== 'undefined')
|
|
1988
|
+
params_1.push('origin=' + encodeMapValue(options.directions.origin));
|
|
1989
|
+
urls.push('https://www.google.com/maps/dir/?' + joining(params_1, undefined, '&'));
|
|
1990
|
+
}
|
|
1991
|
+
else {
|
|
1992
|
+
if (typeof options.coordinate !== 'undefined')
|
|
1993
|
+
params_1.push('query=' + options.coordinate[0] + ',' + options.coordinate[1]);
|
|
1994
|
+
else if (typeof options.query !== 'undefined')
|
|
1995
|
+
params_1.push('query=' + escapeURIComponentString(options.query));
|
|
1996
|
+
if (typeof options.zoom !== 'undefined')
|
|
1997
|
+
params_1.push('zoom=' + options.zoom);
|
|
1998
|
+
urls.push('https://www.google.com/maps/search/?' + joining(params_1, undefined, '&'));
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
return new Promise(function (resolve, reject) {
|
|
2002
|
+
var tried = [];
|
|
2003
|
+
function openURLSequential(index) {
|
|
2004
|
+
if (index === void 0) { index = 0; }
|
|
2005
|
+
if (index >= urls.length)
|
|
2006
|
+
return reject(new Error('Failed to open a map using all available URLs.\n\nAttempted URLs:\n' + joining(tried, undefined, '\n↓\n')));
|
|
2007
|
+
var url = urls[index];
|
|
2008
|
+
if (typeof url === 'string') {
|
|
2009
|
+
tried[index] = url;
|
|
2010
|
+
return openURL(index, url, getDefaultTimeout())
|
|
2011
|
+
.then(function () {
|
|
2012
|
+
resolve();
|
|
2013
|
+
})
|
|
2014
|
+
.catch(function () {
|
|
2015
|
+
openURLSequential(index + 1);
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
else {
|
|
2019
|
+
tried[index] = '[function fallback]';
|
|
2020
|
+
url();
|
|
2021
|
+
resolve();
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
return openURLSequential();
|
|
2025
|
+
});
|
|
2026
|
+
},
|
|
1872
2027
|
filepicker: function (options) {
|
|
1873
2028
|
if (options === void 0) { options = {}; }
|
|
1874
2029
|
var module;
|
|
@@ -1971,7 +2126,7 @@
|
|
|
1971
2126
|
if (index === void 0) { index = 0; }
|
|
1972
2127
|
if (index >= urls.length)
|
|
1973
2128
|
return reject(new Error('Failed to open the "' + type + '" settings pane using all available URLs.\n\nAttempted URLs:\n' + joining(urls, undefined, '\n↓\n')));
|
|
1974
|
-
return openURL(index, urls[index],
|
|
2129
|
+
return openURL(index, urls[index], DEFAULT_TIMEOUT)
|
|
1975
2130
|
.then(function () {
|
|
1976
2131
|
resolve();
|
|
1977
2132
|
})
|