web-launch-kit 0.0.6 → 0.0.8
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 +41 -7
- package/README.md +45 -7
- package/dist/index.d.ts +7 -1
- package/dist/launch-kit.cjs +66 -3
- 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 +66 -3
- package/dist/launch-kit.mjs.map +1 -1
- package/dist/launch-kit.umd.js +66 -3
- 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 +1 -1
package/dist/launch-kit.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version$3 = "0.0.
|
|
1
|
+
var version$3 = "0.0.8";
|
|
2
2
|
var packageJSON$3 = {
|
|
3
3
|
version: version$3};
|
|
4
4
|
|
|
@@ -2343,6 +2343,7 @@ function resolveOptions(option) {
|
|
|
2343
2343
|
var timeout;
|
|
2344
2344
|
var intent;
|
|
2345
2345
|
var packageName;
|
|
2346
|
+
var allowIntent = true;
|
|
2346
2347
|
var bundleId;
|
|
2347
2348
|
var trackId;
|
|
2348
2349
|
var universal;
|
|
@@ -2352,6 +2353,7 @@ function resolveOptions(option) {
|
|
|
2352
2353
|
case 'android':
|
|
2353
2354
|
if (typeof option.android === 'undefined')
|
|
2354
2355
|
return [[], 0];
|
|
2356
|
+
allowIntent = option.android.allowIntent !== false;
|
|
2355
2357
|
intent = stripURL(option.android.intent);
|
|
2356
2358
|
scheme = stripURL(option.android.scheme);
|
|
2357
2359
|
fallback = stripURL(option.android.fallback);
|
|
@@ -2370,11 +2372,11 @@ function resolveOptions(option) {
|
|
|
2370
2372
|
if (typeof parsed.fallback !== 'undefined' && typeof fallback === 'undefined')
|
|
2371
2373
|
fallback = parsed.fallback;
|
|
2372
2374
|
}
|
|
2373
|
-
if (typeof scheme !== 'undefined' && typeof intent === 'undefined')
|
|
2375
|
+
if (allowIntent && typeof scheme !== 'undefined' && typeof intent === 'undefined')
|
|
2374
2376
|
intent = createIntentURL(scheme, packageName, fallback);
|
|
2375
2377
|
if (typeof timeout === 'undefined')
|
|
2376
2378
|
timeout = ANDROID_DEFAULT_TIMEOUT;
|
|
2377
|
-
if (typeof intent !== 'undefined' && canOpenIntent())
|
|
2379
|
+
if (allowIntent && typeof intent !== 'undefined' && canOpenIntent())
|
|
2378
2380
|
resolved.push(['intent', intent]);
|
|
2379
2381
|
if (typeof scheme !== 'undefined' && allowScheme)
|
|
2380
2382
|
resolved.push(['scheme', scheme]);
|
|
@@ -2520,6 +2522,34 @@ function isFullyBlockedInAppBrowser() {
|
|
|
2520
2522
|
function isPartnerAppOnly() {
|
|
2521
2523
|
return /weibo.*weibo__[\d.]+/i.test(PlatformKit.userAgent);
|
|
2522
2524
|
}
|
|
2525
|
+
function canOpenXSafari() {
|
|
2526
|
+
if (PlatformKit.os.name !== 'ios')
|
|
2527
|
+
return false;
|
|
2528
|
+
var version = PlatformKit.os.version;
|
|
2529
|
+
if (PlatformKit.compareVersion(version, '15.0') < 0)
|
|
2530
|
+
return false;
|
|
2531
|
+
if (PlatformKit.compareVersion(version, '16.0') >= 0 && PlatformKit.compareVersion(version, '17.0') < 0)
|
|
2532
|
+
return false;
|
|
2533
|
+
var inAppBrowser = PlatformKit.inAppBrowser;
|
|
2534
|
+
if (inAppBrowser === 'facebook' || inAppBrowser === 'instagram')
|
|
2535
|
+
return false;
|
|
2536
|
+
return canOpenScheme();
|
|
2537
|
+
}
|
|
2538
|
+
function isInWebview() {
|
|
2539
|
+
return PlatformKit.inAppBrowser !== null || PlatformKit.webview;
|
|
2540
|
+
}
|
|
2541
|
+
function canEscapeWebview() {
|
|
2542
|
+
if (!isInWebview())
|
|
2543
|
+
return false;
|
|
2544
|
+
var inAppBrowser = PlatformKit.inAppBrowser;
|
|
2545
|
+
if (inAppBrowser === 'kakaotalk' || inAppBrowser === 'line')
|
|
2546
|
+
return true;
|
|
2547
|
+
if (PlatformKit.os.name === 'android')
|
|
2548
|
+
return canOpenIntent();
|
|
2549
|
+
if (PlatformKit.os.name === 'ios')
|
|
2550
|
+
return canOpenXSafari();
|
|
2551
|
+
return false;
|
|
2552
|
+
}
|
|
2523
2553
|
function canOpenWindowsSetting(version) {
|
|
2524
2554
|
if (version.length === 0)
|
|
2525
2555
|
return false;
|
|
@@ -2617,6 +2647,24 @@ function createWebStoreURL(id, os) {
|
|
|
2617
2647
|
return os;
|
|
2618
2648
|
}
|
|
2619
2649
|
}
|
|
2650
|
+
function appendURLParameter(url, parameter) {
|
|
2651
|
+
var index = url.indexOf('#');
|
|
2652
|
+
var base = index === -1 ? url : url.substring(0, index);
|
|
2653
|
+
var hash = index === -1 ? '' : url.substring(index);
|
|
2654
|
+
return base + (base.indexOf('?') === -1 ? '?' : '&') + parameter + hash;
|
|
2655
|
+
}
|
|
2656
|
+
function createEscapeWebviewURL(url) {
|
|
2657
|
+
var inAppBrowser = PlatformKit.inAppBrowser;
|
|
2658
|
+
if (inAppBrowser === 'kakaotalk')
|
|
2659
|
+
return 'kakaotalk://web/openExternal?url=' + escapeURIComponentString(url);
|
|
2660
|
+
if (inAppBrowser === 'line')
|
|
2661
|
+
return appendURLParameter(url, 'openExternalBrowser=1');
|
|
2662
|
+
if (PlatformKit.os.name === 'android' && canOpenIntent())
|
|
2663
|
+
return createIntentURL(url, 'com.android.chrome', url);
|
|
2664
|
+
if (PlatformKit.os.name === 'ios' && canOpenXSafari())
|
|
2665
|
+
return 'x-safari-' + url;
|
|
2666
|
+
return undefined;
|
|
2667
|
+
}
|
|
2620
2668
|
function escapeURIComponentString(value) {
|
|
2621
2669
|
return encodeURIComponent(value)
|
|
2622
2670
|
.replace(/[!'()*]/g, function (char) {
|
|
@@ -2890,6 +2938,9 @@ var LaunchKit = {
|
|
|
2890
2938
|
get canOpenSetting() {
|
|
2891
2939
|
return canOpenSetting();
|
|
2892
2940
|
},
|
|
2941
|
+
get canEscapeWebview() {
|
|
2942
|
+
return canEscapeWebview();
|
|
2943
|
+
},
|
|
2893
2944
|
getTrackId: getTrackIdAsync,
|
|
2894
2945
|
getProductId: getProductIdAsync,
|
|
2895
2946
|
},
|
|
@@ -3157,6 +3208,18 @@ var LaunchKit = {
|
|
|
3157
3208
|
return openURLSequential();
|
|
3158
3209
|
});
|
|
3159
3210
|
},
|
|
3211
|
+
escapeWebview: function (options) {
|
|
3212
|
+
if (options === void 0) { options = {}; }
|
|
3213
|
+
if (!isInWebview())
|
|
3214
|
+
return Promise.reject(new Error('Escaping the webview is not needed: the current environment is not an in-app browser or webview. (userAgent: "' + PlatformKit.userAgent + '")'));
|
|
3215
|
+
var url = typeof options.url !== 'undefined' ? stripURL(options.url) : getTopmostWindow().location.href;
|
|
3216
|
+
if (!isWebURL(url))
|
|
3217
|
+
return Promise.reject(new Error('Cannot escape the webview: only http(s) URLs can be reopened in an external browser. (url: "' + url + '")'));
|
|
3218
|
+
var escape = createEscapeWebviewURL(url);
|
|
3219
|
+
if (typeof escape === 'undefined')
|
|
3220
|
+
return Promise.reject(new Error('Failed to escape the webview: no escape route is available in the current environment. (userAgent: "' + PlatformKit.userAgent + '")'));
|
|
3221
|
+
return openURL(0, escape, getDefaultTimeout(), isWebURL(escape));
|
|
3222
|
+
},
|
|
3160
3223
|
};
|
|
3161
3224
|
|
|
3162
3225
|
export { SettingType, LaunchKit as default };
|