web-launch-kit 0.0.8 → 0.0.10
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.ko.md +37 -3
- package/README.md +37 -2
- package/dist/index.d.ts +3 -1
- package/dist/launch-kit.cjs +177 -59
- 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 +177 -59
- package/dist/launch-kit.mjs.map +1 -1
- package/dist/launch-kit.umd.js +177 -59
- 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/dist/utils/get-id.d.ts +2 -2
- package/package.json +2 -2
package/dist/launch-kit.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version$3 = "0.0.
|
|
1
|
+
var version$3 = "0.0.10";
|
|
2
2
|
var packageJSON$3 = {
|
|
3
3
|
version: version$3};
|
|
4
4
|
|
|
@@ -1280,7 +1280,7 @@ function createHiddenElement(tagName, focusable) {
|
|
|
1280
1280
|
return element;
|
|
1281
1281
|
}
|
|
1282
1282
|
|
|
1283
|
-
var version = "0.0.
|
|
1283
|
+
var version = "0.0.6";
|
|
1284
1284
|
var packageJSON = {
|
|
1285
1285
|
version: version};
|
|
1286
1286
|
|
|
@@ -1409,6 +1409,27 @@ function expandTag(tag) {
|
|
|
1409
1409
|
chain.push(segments.slice(0, i).join('-'));
|
|
1410
1410
|
return freeze(chain);
|
|
1411
1411
|
}
|
|
1412
|
+
function maximizeTag(tag) {
|
|
1413
|
+
var parsed = parseTag(tag);
|
|
1414
|
+
if (parsed === null)
|
|
1415
|
+
return null;
|
|
1416
|
+
if (parsed.script !== null && parsed.region !== null)
|
|
1417
|
+
return parsed;
|
|
1418
|
+
var IntlLocale = getIntlLocaleConstructor();
|
|
1419
|
+
if (typeof IntlLocale === 'undefined')
|
|
1420
|
+
return parsed;
|
|
1421
|
+
try {
|
|
1422
|
+
var intlLocale = new IntlLocale(parsed.baseName);
|
|
1423
|
+
if (typeof intlLocale.maximize === 'function') {
|
|
1424
|
+
var reparsed = parseTag(intlLocale.maximize().toString());
|
|
1425
|
+
if (reparsed !== null)
|
|
1426
|
+
return reparsed;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
catch (_) {
|
|
1430
|
+
}
|
|
1431
|
+
return parsed;
|
|
1432
|
+
}
|
|
1412
1433
|
function toLookupKey(tag) {
|
|
1413
1434
|
var parsed = parseTag(tag);
|
|
1414
1435
|
return (parsed === null ? tag : parsed.baseName).toLowerCase();
|
|
@@ -1451,6 +1472,11 @@ function resolveDirection(primary) {
|
|
|
1451
1472
|
catch (_) {
|
|
1452
1473
|
}
|
|
1453
1474
|
}
|
|
1475
|
+
if (primary.script === null) {
|
|
1476
|
+
var maximized = maximizeTag(primary.baseName);
|
|
1477
|
+
if (maximized !== null && maximized.script !== null)
|
|
1478
|
+
return contains(RTL_SCRIPTS, maximized.script);
|
|
1479
|
+
}
|
|
1454
1480
|
return isRTL(primary);
|
|
1455
1481
|
}
|
|
1456
1482
|
var subtags = null;
|
|
@@ -1550,6 +1576,9 @@ var LocaleKit = {
|
|
|
1550
1576
|
expand: function (tag) {
|
|
1551
1577
|
return expandTag(tag);
|
|
1552
1578
|
},
|
|
1579
|
+
maximize: function (tag) {
|
|
1580
|
+
return maximizeTag(tag);
|
|
1581
|
+
},
|
|
1553
1582
|
lookup: function (supported, fallback) {
|
|
1554
1583
|
return lookupTag(supported, languages, typeof fallback === 'undefined' ? null : fallback);
|
|
1555
1584
|
},
|
|
@@ -1562,6 +1591,7 @@ var CACHE_PREFIX = 'web-launch-kit:';
|
|
|
1562
1591
|
var TRACK_ID = 'track-id';
|
|
1563
1592
|
var PRODUCT_ID = 'product-id';
|
|
1564
1593
|
var TRACK_ID_CACHE_TTL = 1000 * 60 * 60;
|
|
1594
|
+
var ALPHA2_REGION_PATTERN$1 = /^[A-Z]{2}$/;
|
|
1565
1595
|
function toCacheKey(mode, query) {
|
|
1566
1596
|
return CACHE_PREFIX + mode + ':' + query;
|
|
1567
1597
|
}
|
|
@@ -1694,27 +1724,34 @@ function requestGet(url, async) {
|
|
|
1694
1724
|
}
|
|
1695
1725
|
}
|
|
1696
1726
|
}
|
|
1697
|
-
function
|
|
1698
|
-
var
|
|
1699
|
-
var
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
var
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1727
|
+
function resolveMarket(language, country) {
|
|
1728
|
+
var locale = language;
|
|
1729
|
+
var market;
|
|
1730
|
+
if (typeof country !== 'undefined' && ALPHA2_REGION_PATTERN$1.test(country.toUpperCase()))
|
|
1731
|
+
market = country.toUpperCase();
|
|
1732
|
+
if (typeof market === 'undefined') {
|
|
1733
|
+
var source = typeof locale !== 'undefined'
|
|
1734
|
+
? locale
|
|
1735
|
+
: (LocaleKit.language === null ? undefined : LocaleKit.language);
|
|
1736
|
+
if (typeof source !== 'undefined') {
|
|
1737
|
+
var maximized = LocaleKit.maximize(source);
|
|
1738
|
+
if (maximized !== null && maximized.region !== null && ALPHA2_REGION_PATTERN$1.test(maximized.region))
|
|
1739
|
+
market = maximized.region;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
if (typeof locale === 'undefined' && LocaleKit.language !== null)
|
|
1743
|
+
locale = LocaleKit.language;
|
|
1744
|
+
if (typeof locale === 'undefined')
|
|
1745
|
+
locale = 'en-US';
|
|
1746
|
+
if (typeof market === 'undefined')
|
|
1747
|
+
market = 'US';
|
|
1748
|
+
return [locale, market];
|
|
1749
|
+
}
|
|
1750
|
+
function resolveGetProductIdURL(packageFamilyName, language, country) {
|
|
1751
|
+
var resolved = resolveMarket(language, country);
|
|
1752
|
+
var locale = resolved[0];
|
|
1753
|
+
var market = resolved[1];
|
|
1754
|
+
return 'https://displaycatalog.md.mp.microsoft.com/v7.0/products/lookup?value=' + encodeURIComponent(packageFamilyName) + '&market=' + encodeURIComponent(market) + '&languages=' + encodeURIComponent(locale) + '&alternateId=PackageFamilyName';
|
|
1718
1755
|
}
|
|
1719
1756
|
function resolveGetTrackIdURL(bundleId) {
|
|
1720
1757
|
return 'https://itunes.apple.com/lookup?bundleId=' + encodeURIComponent(bundleId);
|
|
@@ -1742,12 +1779,12 @@ function parseGetTrackIdResponse(response) {
|
|
|
1742
1779
|
return undefined;
|
|
1743
1780
|
return '' + result.trackId;
|
|
1744
1781
|
}
|
|
1745
|
-
function getProductId(packageFamilyName) {
|
|
1782
|
+
function getProductId(packageFamilyName, language, country) {
|
|
1746
1783
|
var cache = idCache.get(PRODUCT_ID, packageFamilyName);
|
|
1747
1784
|
if (typeof cache !== 'undefined')
|
|
1748
1785
|
return cache;
|
|
1749
1786
|
try {
|
|
1750
|
-
var productId = parseGetProductIdResponse(requestGet(resolveGetProductIdURL(packageFamilyName)));
|
|
1787
|
+
var productId = parseGetProductIdResponse(requestGet(resolveGetProductIdURL(packageFamilyName, language, country)));
|
|
1751
1788
|
if (typeof productId === 'undefined')
|
|
1752
1789
|
return undefined;
|
|
1753
1790
|
idCache.set(PRODUCT_ID, packageFamilyName, productId);
|
|
@@ -1772,12 +1809,12 @@ function getTrackId(bundleId) {
|
|
|
1772
1809
|
return undefined;
|
|
1773
1810
|
}
|
|
1774
1811
|
}
|
|
1775
|
-
function getProductIdAsync(packageFamilyName) {
|
|
1812
|
+
function getProductIdAsync(packageFamilyName, language, country) {
|
|
1776
1813
|
var cache = idCache.get(PRODUCT_ID, packageFamilyName);
|
|
1777
1814
|
if (typeof cache !== 'undefined')
|
|
1778
1815
|
return Promise.resolve(cache);
|
|
1779
1816
|
try {
|
|
1780
|
-
return requestGet(resolveGetProductIdURL(packageFamilyName), true)
|
|
1817
|
+
return requestGet(resolveGetProductIdURL(packageFamilyName, language, country), true)
|
|
1781
1818
|
.then(parseGetProductIdResponse)
|
|
1782
1819
|
.then(function (productId) {
|
|
1783
1820
|
if (typeof productId === 'undefined')
|
|
@@ -1892,6 +1929,7 @@ var MACOS_DEFAULT_TIMEOUT = 750;
|
|
|
1892
1929
|
var DEFAULT_TIMEOUT = 750;
|
|
1893
1930
|
var GLOBAL = getGlobal$1();
|
|
1894
1931
|
var NAVIGATOR = GLOBAL.navigator;
|
|
1932
|
+
var ALPHA2_REGION_PATTERN = /^[A-Z]{2}$/;
|
|
1895
1933
|
var CLEANUP_INPUT_ELEMENT = null;
|
|
1896
1934
|
var DEBUG = false;
|
|
1897
1935
|
var APP_IN_FLIGHT = null;
|
|
@@ -2111,6 +2149,13 @@ function resolveFocusEventConfig() {
|
|
|
2111
2149
|
};
|
|
2112
2150
|
}
|
|
2113
2151
|
}
|
|
2152
|
+
function resolveEventBinding(config) {
|
|
2153
|
+
return {
|
|
2154
|
+
configured: typeof config.target !== 'undefined' && typeof config.type !== 'undefined',
|
|
2155
|
+
target: config.target,
|
|
2156
|
+
type: config.type,
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2114
2159
|
function openURL(tried, url, timeout, terminal) {
|
|
2115
2160
|
if (terminal === void 0) { terminal = false; }
|
|
2116
2161
|
var config = resolveFocusEventConfig();
|
|
@@ -2184,6 +2229,9 @@ function openURL(tried, url, timeout, terminal) {
|
|
|
2184
2229
|
return new Promise(function (resolve, reject) {
|
|
2185
2230
|
if (DEBUG)
|
|
2186
2231
|
debugger;
|
|
2232
|
+
var blurBinding = resolveEventBinding(config.blur);
|
|
2233
|
+
var focusBinding = resolveEventBinding(config.focus);
|
|
2234
|
+
var visibilityBinding = resolveEventBinding(config.visibilitychange);
|
|
2187
2235
|
var timeoutId;
|
|
2188
2236
|
var resolved = false;
|
|
2189
2237
|
function cleanup() {
|
|
@@ -2192,12 +2240,14 @@ function openURL(tried, url, timeout, terminal) {
|
|
|
2192
2240
|
timeoutId = undefined;
|
|
2193
2241
|
}
|
|
2194
2242
|
try {
|
|
2195
|
-
if (
|
|
2196
|
-
EventKit.remove(
|
|
2197
|
-
if (
|
|
2198
|
-
EventKit.remove(
|
|
2199
|
-
if (
|
|
2200
|
-
EventKit.remove(
|
|
2243
|
+
if (blurBinding.configured)
|
|
2244
|
+
EventKit.remove(blurBinding.target, blurBinding.type, onblur);
|
|
2245
|
+
if (focusBinding.configured)
|
|
2246
|
+
EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
|
|
2247
|
+
if (visibilityBinding.configured)
|
|
2248
|
+
EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
|
|
2249
|
+
if (navigationPagehide)
|
|
2250
|
+
EventKit.remove(top, 'pagehide', onpagehide);
|
|
2201
2251
|
}
|
|
2202
2252
|
catch (_) {
|
|
2203
2253
|
}
|
|
@@ -2231,10 +2281,10 @@ function openURL(tried, url, timeout, terminal) {
|
|
|
2231
2281
|
clearTimeout(timeoutId);
|
|
2232
2282
|
timeoutId = undefined;
|
|
2233
2283
|
}
|
|
2234
|
-
if (
|
|
2235
|
-
EventKit.remove(
|
|
2236
|
-
if (
|
|
2237
|
-
EventKit.add(
|
|
2284
|
+
if (blurBinding.configured)
|
|
2285
|
+
EventKit.remove(blurBinding.target, blurBinding.type, onblur);
|
|
2286
|
+
if (focusBinding.configured)
|
|
2287
|
+
EventKit.add(focusBinding.target, focusBinding.type, onfocus);
|
|
2238
2288
|
}
|
|
2239
2289
|
function onfocus() {
|
|
2240
2290
|
done(true);
|
|
@@ -2245,13 +2295,19 @@ function openURL(tried, url, timeout, terminal) {
|
|
|
2245
2295
|
else
|
|
2246
2296
|
onfocus();
|
|
2247
2297
|
}
|
|
2298
|
+
function onpagehide() {
|
|
2299
|
+
done(true);
|
|
2300
|
+
}
|
|
2301
|
+
var navigationPagehide = config.blur.type !== 'pagehide';
|
|
2248
2302
|
timeoutId = setTimeout(function () {
|
|
2249
2303
|
done(false);
|
|
2250
2304
|
}, timeout);
|
|
2251
|
-
if (
|
|
2252
|
-
EventKit.add(
|
|
2253
|
-
if (
|
|
2254
|
-
EventKit.add(
|
|
2305
|
+
if (blurBinding.configured)
|
|
2306
|
+
EventKit.add(blurBinding.target, blurBinding.type, onblur);
|
|
2307
|
+
if (visibilityBinding.configured)
|
|
2308
|
+
EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
|
|
2309
|
+
if (navigationPagehide)
|
|
2310
|
+
EventKit.add(top, 'pagehide', onpagehide);
|
|
2255
2311
|
if (!hasFocus(topDocument))
|
|
2256
2312
|
restoreFocus();
|
|
2257
2313
|
try {
|
|
@@ -2341,6 +2397,8 @@ function resolveOptions(option) {
|
|
|
2341
2397
|
var allowScheme;
|
|
2342
2398
|
var assumeAllowedInApp;
|
|
2343
2399
|
var timeout;
|
|
2400
|
+
var language;
|
|
2401
|
+
var country;
|
|
2344
2402
|
var intent;
|
|
2345
2403
|
var packageName;
|
|
2346
2404
|
var allowIntent = true;
|
|
@@ -2363,6 +2421,8 @@ function resolveOptions(option) {
|
|
|
2363
2421
|
allowWebStore = option.android.allowWebStore;
|
|
2364
2422
|
allowScheme = canOpenScheme(assumeAllowedInApp);
|
|
2365
2423
|
timeout = option.android.timeout;
|
|
2424
|
+
language = option.android.language;
|
|
2425
|
+
country = option.android.country;
|
|
2366
2426
|
if (typeof intent !== 'undefined' && (typeof scheme === 'undefined' || typeof packageName === 'undefined' || typeof fallback === 'undefined')) {
|
|
2367
2427
|
var parsed = parseIntentURL(intent);
|
|
2368
2428
|
if (typeof parsed.scheme !== 'undefined' && typeof scheme === 'undefined')
|
|
@@ -2386,7 +2446,7 @@ function resolveOptions(option) {
|
|
|
2386
2446
|
if (allowAppStore && allowScheme)
|
|
2387
2447
|
resolved.push(['store', createAppStoreURL(packageName, os)]);
|
|
2388
2448
|
if (allowWebStore)
|
|
2389
|
-
resolved.push(['store', createWebStoreURL(packageName, os)]);
|
|
2449
|
+
resolved.push(['store', createWebStoreURL(packageName, os, language, country)]);
|
|
2390
2450
|
}
|
|
2391
2451
|
return [resolved, timeout];
|
|
2392
2452
|
case 'ios':
|
|
@@ -2402,6 +2462,8 @@ function resolveOptions(option) {
|
|
|
2402
2462
|
allowWebStore = option.ios.allowWebStore;
|
|
2403
2463
|
allowScheme = canOpenScheme(assumeAllowedInApp);
|
|
2404
2464
|
timeout = option.ios.timeout;
|
|
2465
|
+
language = option.ios.language;
|
|
2466
|
+
country = option.ios.country;
|
|
2405
2467
|
if (typeof bundleId !== 'undefined' && typeof trackId === 'undefined')
|
|
2406
2468
|
trackId = getTrackId(bundleId);
|
|
2407
2469
|
if (typeof timeout === 'undefined')
|
|
@@ -2416,7 +2478,7 @@ function resolveOptions(option) {
|
|
|
2416
2478
|
if (allowAppStore && allowScheme)
|
|
2417
2479
|
resolved.push(['store', createAppStoreURL(trackId, os)]);
|
|
2418
2480
|
if (allowWebStore)
|
|
2419
|
-
resolved.push(['store', createWebStoreURL(trackId, os)]);
|
|
2481
|
+
resolved.push(['store', createWebStoreURL(trackId, os, language, country)]);
|
|
2420
2482
|
}
|
|
2421
2483
|
return [resolved, timeout];
|
|
2422
2484
|
case 'windows':
|
|
@@ -2429,8 +2491,10 @@ function resolveOptions(option) {
|
|
|
2429
2491
|
allowAppStore = option.windows.allowAppStore;
|
|
2430
2492
|
allowWebStore = option.windows.allowWebStore;
|
|
2431
2493
|
timeout = option.windows.timeout;
|
|
2494
|
+
language = option.windows.language;
|
|
2495
|
+
country = option.windows.country;
|
|
2432
2496
|
if (typeof packageFamilyName !== 'undefined' && typeof productId === 'undefined')
|
|
2433
|
-
productId = getProductId(packageFamilyName);
|
|
2497
|
+
productId = getProductId(packageFamilyName, language, country);
|
|
2434
2498
|
if (typeof timeout === 'undefined')
|
|
2435
2499
|
timeout = WINDOWS_DEFAULT_TIMEOUT;
|
|
2436
2500
|
if (typeof scheme !== 'undefined')
|
|
@@ -2441,7 +2505,7 @@ function resolveOptions(option) {
|
|
|
2441
2505
|
if (allowAppStore)
|
|
2442
2506
|
resolved.push(['store', createAppStoreURL(productId, os)]);
|
|
2443
2507
|
if (allowWebStore)
|
|
2444
|
-
resolved.push(['store', createWebStoreURL(productId, os)]);
|
|
2508
|
+
resolved.push(['store', createWebStoreURL(productId, os, language, country)]);
|
|
2445
2509
|
}
|
|
2446
2510
|
return [resolved, timeout];
|
|
2447
2511
|
case 'macos':
|
|
@@ -2454,6 +2518,8 @@ function resolveOptions(option) {
|
|
|
2454
2518
|
allowAppStore = option.macos.allowAppStore;
|
|
2455
2519
|
allowWebStore = option.macos.allowWebStore;
|
|
2456
2520
|
timeout = option.macos.timeout;
|
|
2521
|
+
language = option.macos.language;
|
|
2522
|
+
country = option.macos.country;
|
|
2457
2523
|
if (typeof bundleId !== 'undefined' && typeof trackId === 'undefined')
|
|
2458
2524
|
trackId = getTrackId(bundleId);
|
|
2459
2525
|
if (typeof timeout === 'undefined')
|
|
@@ -2466,7 +2532,7 @@ function resolveOptions(option) {
|
|
|
2466
2532
|
if (allowAppStore)
|
|
2467
2533
|
resolved.push(['store', createAppStoreURL(trackId, os)]);
|
|
2468
2534
|
if (allowWebStore)
|
|
2469
|
-
resolved.push(['store', createWebStoreURL(trackId, os)]);
|
|
2535
|
+
resolved.push(['store', createWebStoreURL(trackId, os, language, country)]);
|
|
2470
2536
|
}
|
|
2471
2537
|
return [resolved, timeout];
|
|
2472
2538
|
}
|
|
@@ -2633,19 +2699,69 @@ function createAppStoreURL(id, os) {
|
|
|
2633
2699
|
return os;
|
|
2634
2700
|
}
|
|
2635
2701
|
}
|
|
2636
|
-
function createWebStoreURL(id, os) {
|
|
2702
|
+
function createWebStoreURL(id, os, language, country) {
|
|
2703
|
+
var resolved = resolveCountry(language, country);
|
|
2704
|
+
var countryPath = typeof resolved !== 'undefined' ? resolved.toLowerCase() + '/' : '';
|
|
2705
|
+
var url;
|
|
2637
2706
|
switch (os) {
|
|
2638
2707
|
case 'android':
|
|
2639
|
-
|
|
2708
|
+
url = 'https://play.google.com/store/apps/details?id=' + id;
|
|
2709
|
+
if (typeof language !== 'undefined')
|
|
2710
|
+
url = appendURLParameter(url, 'hl=' + escapeURIComponentString(language));
|
|
2711
|
+
if (typeof resolved !== 'undefined')
|
|
2712
|
+
url = appendURLParameter(url, 'gl=' + resolved);
|
|
2713
|
+
break;
|
|
2640
2714
|
case 'ios':
|
|
2641
|
-
|
|
2715
|
+
url = 'https://itunes.apple.com/' + countryPath + 'app/id' + id + '?mt=8';
|
|
2716
|
+
if (typeof language !== 'undefined')
|
|
2717
|
+
url = appendURLParameter(url, 'l=' + escapeURIComponentString(language));
|
|
2718
|
+
break;
|
|
2642
2719
|
case 'windows':
|
|
2643
|
-
|
|
2720
|
+
url = 'https://apps.microsoft.com/detail/' + id;
|
|
2721
|
+
if (typeof language !== 'undefined')
|
|
2722
|
+
url = appendURLParameter(url, 'hl=' + escapeURIComponentString(language));
|
|
2723
|
+
if (typeof resolved !== 'undefined')
|
|
2724
|
+
url = appendURLParameter(url, 'gl=' + resolved);
|
|
2725
|
+
break;
|
|
2644
2726
|
case 'macos':
|
|
2645
|
-
|
|
2727
|
+
url = 'https://apps.apple.com/' + countryPath + 'app/id' + id + '?mt=12';
|
|
2728
|
+
if (typeof language !== 'undefined')
|
|
2729
|
+
url = appendURLParameter(url, 'l=' + escapeURIComponentString(language));
|
|
2730
|
+
break;
|
|
2646
2731
|
default:
|
|
2647
2732
|
return os;
|
|
2648
2733
|
}
|
|
2734
|
+
return url;
|
|
2735
|
+
}
|
|
2736
|
+
function extractRegion(tag) {
|
|
2737
|
+
var parts = tag.replace(/_/g, '-').split('-');
|
|
2738
|
+
for (var i = 1; i < parts.length; i++) {
|
|
2739
|
+
if (/^[A-Za-z]{2}$/.test(parts[i]))
|
|
2740
|
+
return parts[i].toUpperCase();
|
|
2741
|
+
}
|
|
2742
|
+
return undefined;
|
|
2743
|
+
}
|
|
2744
|
+
function resolveCountry(language, country) {
|
|
2745
|
+
if (typeof country !== 'undefined' && ALPHA2_REGION_PATTERN.test(country.toUpperCase()))
|
|
2746
|
+
return country.toUpperCase();
|
|
2747
|
+
if (typeof language === 'undefined')
|
|
2748
|
+
return undefined;
|
|
2749
|
+
var region = extractRegion(language);
|
|
2750
|
+
if (typeof region !== 'undefined')
|
|
2751
|
+
return region;
|
|
2752
|
+
if (typeof Intl !== 'undefined' && typeof Intl.Locale === 'function') {
|
|
2753
|
+
try {
|
|
2754
|
+
var locale = new Intl.Locale(language);
|
|
2755
|
+
if (typeof locale.maximize === 'function') {
|
|
2756
|
+
var maximized = locale.maximize();
|
|
2757
|
+
if (typeof maximized !== 'undefined' && maximized !== null && typeof maximized.region === 'string' && ALPHA2_REGION_PATTERN.test(maximized.region.toUpperCase()))
|
|
2758
|
+
return maximized.region.toUpperCase();
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
catch (_) {
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
return undefined;
|
|
2649
2765
|
}
|
|
2650
2766
|
function appendURLParameter(url, parameter) {
|
|
2651
2767
|
var index = url.indexOf('#');
|
|
@@ -2795,6 +2911,8 @@ function resolveFile(module) {
|
|
|
2795
2911
|
});
|
|
2796
2912
|
}
|
|
2797
2913
|
function resolveInput(module, resolve) {
|
|
2914
|
+
var focusBinding = resolveEventBinding(config.focus);
|
|
2915
|
+
var visibilityBinding = resolveEventBinding(config.visibilitychange);
|
|
2798
2916
|
var resolved = false;
|
|
2799
2917
|
function done(success) {
|
|
2800
2918
|
if (resolved)
|
|
@@ -2832,10 +2950,10 @@ function resolveFile(module) {
|
|
|
2832
2950
|
}
|
|
2833
2951
|
else {
|
|
2834
2952
|
module.onclick = function () {
|
|
2835
|
-
if (
|
|
2836
|
-
EventKit.add(
|
|
2837
|
-
if (
|
|
2838
|
-
EventKit.add(
|
|
2953
|
+
if (focusBinding.configured)
|
|
2954
|
+
EventKit.add(focusBinding.target, focusBinding.type, onfocus);
|
|
2955
|
+
if (visibilityBinding.configured)
|
|
2956
|
+
EventKit.add(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
|
|
2839
2957
|
setTimeout(function () {
|
|
2840
2958
|
EventKit.add(topDocument, 'click', onclick);
|
|
2841
2959
|
}, 100);
|
|
@@ -2847,10 +2965,10 @@ function resolveFile(module) {
|
|
|
2847
2965
|
function cleanup() {
|
|
2848
2966
|
CLEANUP_INPUT_ELEMENT = null;
|
|
2849
2967
|
try {
|
|
2850
|
-
if (
|
|
2851
|
-
EventKit.remove(
|
|
2852
|
-
if (
|
|
2853
|
-
EventKit.remove(
|
|
2968
|
+
if (focusBinding.configured)
|
|
2969
|
+
EventKit.remove(focusBinding.target, focusBinding.type, onfocus);
|
|
2970
|
+
if (visibilityBinding.configured)
|
|
2971
|
+
EventKit.remove(visibilityBinding.target, visibilityBinding.type, onvisibilitychange);
|
|
2854
2972
|
EventKit.remove(topDocument, 'click', onclick);
|
|
2855
2973
|
}
|
|
2856
2974
|
catch (_) {
|