@livx.cc/appwrap 0.47.1 → 0.47.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/package.json
CHANGED
|
@@ -335,6 +335,30 @@ function createAssetServingClient(): android.webkit.WebViewClient {
|
|
|
335
335
|
);
|
|
336
336
|
},
|
|
337
337
|
|
|
338
|
+
// External URL schemes (mailto:/tel:/sms:/geo:/intent:/webcal:/market:/…) can't be rendered by the
|
|
339
|
+
// WebView — without this override it tries to LOAD them and dumps a full-page net::ERR_UNKNOWN_URL_SCHEME
|
|
340
|
+
// over the app. Hand every non-WebView scheme to the OS via ACTION_VIEW (intent: via parseUri) and
|
|
341
|
+
// return true so the WebView never navigates. http/https/file/about/blob/data/javascript stay in-WebView.
|
|
342
|
+
shouldOverrideUrlLoading(
|
|
343
|
+
view: android.webkit.WebView,
|
|
344
|
+
request: android.webkit.WebResourceRequest | string
|
|
345
|
+
): boolean {
|
|
346
|
+
const url: string = typeof request !== 'string' ? String(request.getUrl().toString()) : request;
|
|
347
|
+
const scheme = (url.split(':')[0] || '').toLowerCase();
|
|
348
|
+
if (['http', 'https', 'file', 'about', 'blob', 'data', 'javascript'].includes(scheme)) return false;
|
|
349
|
+
try {
|
|
350
|
+
const intent = scheme === 'intent'
|
|
351
|
+
? android.content.Intent.parseUri(url, android.content.Intent.URI_INTENT_SCHEME)
|
|
352
|
+
: new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url));
|
|
353
|
+
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
354
|
+
view.getContext().startActivity(intent);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
// No installed app handles the scheme — swallow (better a no-op than an error page over the app).
|
|
357
|
+
console.warn('[appwrap] no OS handler for external URL: ' + url + ' (' + e + ')');
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
},
|
|
361
|
+
|
|
338
362
|
onPageStarted(view: android.webkit.WebView, _url: string, _favicon: android.graphics.Bitmap): void {
|
|
339
363
|
// Fallback injection — no-op when the document-start scripts already ran
|
|
340
364
|
view.evaluateJavascript(buildBootstrapJs(), null as unknown as android.webkit.ValueCallback<string>);
|