react-native-minimal-webview 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +130 -2
- package/android/build.gradle +26 -0
- package/android/consumer-rules.pro +4 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/minimalwebview/Asks.kt +44 -0
- package/android/src/main/java/expo/modules/minimalwebview/DocumentEnd.kt +31 -0
- package/android/src/main/java/expo/modules/minimalwebview/Hooks.kt +496 -0
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebView.kt +510 -0
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewClients.kt +359 -0
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewModule.kt +245 -0
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewNavigation.kt +199 -0
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewScripts.kt +191 -0
- package/android/src/main/java/expo/modules/minimalwebview/NavigationRules.kt +113 -0
- package/android/src/main/java/expo/modules/minimalwebview/PlatformSettings.kt +306 -0
- package/android/src/main/java/expo/modules/minimalwebview/PullToRefresh.kt +76 -0
- package/android/src/main/java/expo/modules/minimalwebview/requests/Downloads.kt +258 -0
- package/android/src/main/java/expo/modules/minimalwebview/requests/FileUpload.kt +44 -0
- package/android/src/main/java/expo/modules/minimalwebview/requests/FullscreenVideo.kt +87 -0
- package/android/src/main/java/expo/modules/minimalwebview/requests/Permissions.kt +77 -0
- package/build/WebView.d.ts +99 -0
- package/build/WebView.d.ts.map +1 -0
- package/build/WebView.js +448 -0
- package/build/WebView.js.map +1 -0
- package/build/bridge/createBridge.d.ts +32 -0
- package/build/bridge/createBridge.d.ts.map +1 -0
- package/build/bridge/createBridge.js +135 -0
- package/build/bridge/createBridge.js.map +1 -0
- package/build/bridge/endpoint.d.ts +35 -0
- package/build/bridge/endpoint.d.ts.map +1 -0
- package/build/bridge/endpoint.js +100 -0
- package/build/bridge/endpoint.js.map +1 -0
- package/build/bridge/origins.d.ts +25 -0
- package/build/bridge/origins.d.ts.map +1 -0
- package/build/bridge/origins.js +60 -0
- package/build/bridge/origins.js.map +1 -0
- package/build/bridge/pageClient.generated.d.ts +3 -0
- package/build/bridge/pageClient.generated.d.ts.map +1 -0
- package/build/bridge/pageClient.generated.js +4 -0
- package/build/bridge/pageClient.generated.js.map +1 -0
- package/build/bridge/protocol.d.ts +50 -0
- package/build/bridge/protocol.d.ts.map +1 -0
- package/build/bridge/protocol.js +52 -0
- package/build/bridge/protocol.js.map +1 -0
- package/build/defaultNavigationRules.d.ts +16 -0
- package/build/defaultNavigationRules.d.ts.map +1 -0
- package/build/defaultNavigationRules.js +23 -0
- package/build/defaultNavigationRules.js.map +1 -0
- package/build/index.d.ts +31 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +30 -0
- package/build/index.js.map +1 -0
- package/build/platform.generated.d.ts +702 -0
- package/build/platform.generated.d.ts.map +1 -0
- package/build/platform.generated.js +199 -0
- package/build/platform.generated.js.map +1 -0
- package/build/reactNativeWebViewDefaults.d.ts +21 -0
- package/build/reactNativeWebViewDefaults.d.ts.map +1 -0
- package/build/reactNativeWebViewDefaults.js +12 -0
- package/build/reactNativeWebViewDefaults.js.map +1 -0
- package/build/reactNativeWebViewMessages.d.ts +22 -0
- package/build/reactNativeWebViewMessages.d.ts.map +1 -0
- package/build/reactNativeWebViewMessages.js +30 -0
- package/build/reactNativeWebViewMessages.js.map +1 -0
- package/build/refStore.d.ts +31 -0
- package/build/refStore.d.ts.map +1 -0
- package/build/refStore.js +113 -0
- package/build/refStore.js.map +1 -0
- package/build/types.d.ts +1127 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.defaults.d.ts +8 -0
- package/build/types.defaults.d.ts.map +1 -0
- package/build/types.defaults.js +17 -0
- package/build/types.defaults.js.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/Asks.swift +45 -0
- package/ios/DelegateProxy.swift +162 -0
- package/ios/DocumentEnd.swift +23 -0
- package/ios/DownloadName.swift +12 -0
- package/ios/Downloads.swift +51 -0
- package/ios/Hooks.swift +308 -0
- package/ios/Loads.swift +44 -0
- package/ios/MRWExceptions.h +9 -0
- package/ios/MRWExceptions.m +10 -0
- package/ios/MRWInvoke.h +23 -0
- package/ios/MRWInvoke.m +187 -0
- package/ios/MinimalWebView+Dialogs.swift +99 -0
- package/ios/MinimalWebView+Navigation.swift +244 -0
- package/ios/MinimalWebView+Scripts.swift +92 -0
- package/ios/MinimalWebView.docc/MinimalWebView.md +13 -0
- package/ios/MinimalWebView.podspec +32 -0
- package/ios/MinimalWebView.swift +512 -0
- package/ios/MinimalWebViewModule.swift +110 -0
- package/ios/NavigationRules.swift +123 -0
- package/ios/OriginRules.swift +35 -0
- package/ios/PlatformCompletions.generated.swift +39 -0
- package/ios/PlatformSettings.swift +247 -0
- package/ios/ReadAccess.swift +19 -0
- package/ios/Recovery.swift +25 -0
- package/ios/SharedCookies.swift +59 -0
- package/package.json +94 -4
- package/src/WebView.tsx +623 -0
- package/src/bridge/createBridge.ts +176 -0
- package/src/bridge/endpoint.ts +119 -0
- package/src/bridge/origins.ts +62 -0
- package/src/bridge/pageClient.generated.ts +5 -0
- package/src/bridge/pageClient.ts +68 -0
- package/src/bridge/protocol.ts +78 -0
- package/src/defaultNavigationRules.ts +25 -0
- package/src/index.ts +37 -0
- package/src/platform.generated.ts +694 -0
- package/src/reactNativeWebViewDefaults.ts +13 -0
- package/src/reactNativeWebViewMessages.ts +32 -0
- package/src/refStore.ts +164 -0
- package/src/types.defaults.ts +24 -0
- package/src/types.ts +1194 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package expo.modules.minimalwebview.requests
|
|
2
|
+
|
|
3
|
+
import android.net.Uri
|
|
4
|
+
import android.webkit.ValueCallback
|
|
5
|
+
import android.webkit.WebChromeClient.FileChooserParams
|
|
6
|
+
import expo.modules.minimalwebview.MinimalWebView
|
|
7
|
+
import expo.modules.minimalwebview.MinimalWebViewModule
|
|
8
|
+
|
|
9
|
+
/** `<input type="file">`, and the `onFileRequest` prop. */
|
|
10
|
+
internal class FileUpload(private val owner: MinimalWebView) {
|
|
11
|
+
// The page's open file chooser (WebView allows one at a time). Chromium releases it only while its document is alive,
|
|
12
|
+
// so a navigation away cancels it when it starts, not at commit; a later answer is dropped.
|
|
13
|
+
private var held: ValueCallback<Array<Uri>>? = null
|
|
14
|
+
|
|
15
|
+
/** Wraps the file chooser's [callback] so it is answered once: by whoever takes the request, or by [cancel]. */
|
|
16
|
+
fun hold(callback: ValueCallback<Array<Uri>>): ValueCallback<Array<Uri>> =
|
|
17
|
+
object : ValueCallback<Array<Uri>> {
|
|
18
|
+
override fun onReceiveValue(value: Array<Uri>?) {
|
|
19
|
+
if (held !== this) return
|
|
20
|
+
held = null
|
|
21
|
+
callback.onReceiveValue(value)
|
|
22
|
+
}
|
|
23
|
+
}.also { held = it }
|
|
24
|
+
|
|
25
|
+
fun cancel() = held?.onReceiveValue(null)
|
|
26
|
+
|
|
27
|
+
/** The app's prop, else the system chooser (its intent ignores `capture`). [callback] is answered once. */
|
|
28
|
+
fun onShowFileChooser(callback: ValueCallback<Array<Uri>>, params: FileChooserParams) {
|
|
29
|
+
if ("onFileRequest" !in owner.requestHandlers) {
|
|
30
|
+
val module = owner.appContext.registry.getModule<MinimalWebViewModule>()
|
|
31
|
+
if (module == null) callback.onReceiveValue(null) else module.openFileChooser(params.createIntent(), callback::onReceiveValue)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
val request = mapOf(
|
|
35
|
+
"accept" to params.acceptTypes.filter { it.isNotEmpty() },
|
|
36
|
+
"multiple" to (params.mode == FileChooserParams.MODE_OPEN_MULTIPLE),
|
|
37
|
+
"capture" to params.isCaptureEnabled
|
|
38
|
+
)
|
|
39
|
+
owner.asks.ask("core", "onFileRequest", request) { answer ->
|
|
40
|
+
val uris = (answer as? List<*>)?.mapNotNull { (it as? String)?.let(Uri::parse) }
|
|
41
|
+
callback.onReceiveValue(uris?.toTypedArray())
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package expo.modules.minimalwebview.requests
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.view.View
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import android.webkit.WebChromeClient.CustomViewCallback
|
|
7
|
+
import android.widget.FrameLayout
|
|
8
|
+
import androidx.activity.ComponentActivity
|
|
9
|
+
import androidx.activity.OnBackPressedCallback
|
|
10
|
+
import androidx.core.view.ViewCompat
|
|
11
|
+
import androidx.core.view.WindowCompat
|
|
12
|
+
import androidx.core.view.WindowInsetsCompat
|
|
13
|
+
import androidx.core.view.WindowInsetsControllerCompat
|
|
14
|
+
import expo.modules.minimalwebview.DocumentEnd
|
|
15
|
+
import expo.modules.minimalwebview.MinimalWebView
|
|
16
|
+
|
|
17
|
+
/** HTML5 fullscreen video, and the `onFullscreenChange` prop. */
|
|
18
|
+
internal class FullscreenVideo(private val owner: MinimalWebView) {
|
|
19
|
+
private var shownCallback: CustomViewCallback? = null
|
|
20
|
+
private var backdrop: FrameLayout? = null
|
|
21
|
+
private var backCallback: OnBackPressedCallback? = null
|
|
22
|
+
// The app's bars before fullscreen, restored on exit: an immersive app keeps its bars hidden.
|
|
23
|
+
private var barsShownBefore = 0
|
|
24
|
+
private var barsBehaviorBefore: Int? = null
|
|
25
|
+
|
|
26
|
+
/** Returns false when there is no window to cover; the caller then tells WebView the view is hidden. */
|
|
27
|
+
fun onShowCustomView(view: View, callback: CustomViewCallback): Boolean {
|
|
28
|
+
if (shownCallback != null) exit()
|
|
29
|
+
val window = owner.webView.rootView as? ViewGroup ?: return false
|
|
30
|
+
backdrop = FrameLayout(view.context).apply {
|
|
31
|
+
setBackgroundColor(Color.BLACK)
|
|
32
|
+
addView(view, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
|
33
|
+
window.addView(this, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
|
34
|
+
}
|
|
35
|
+
shownCallback = callback
|
|
36
|
+
backCallback = (owner.activity as? ComponentActivity)?.let { component ->
|
|
37
|
+
object : OnBackPressedCallback(true) {
|
|
38
|
+
override fun handleOnBackPressed() = exit()
|
|
39
|
+
}.also { component.onBackPressedDispatcher.addCallback(it) }
|
|
40
|
+
}
|
|
41
|
+
controller()?.apply {
|
|
42
|
+
val insets = ViewCompat.getRootWindowInsets(owner.webView)
|
|
43
|
+
barsShownBefore = listOf(WindowInsetsCompat.Type.statusBars(), WindowInsetsCompat.Type.navigationBars())
|
|
44
|
+
.filter { insets?.isVisible(it) ?: true }
|
|
45
|
+
.fold(0) { mask, type -> mask or type }
|
|
46
|
+
barsBehaviorBefore = systemBarsBehavior
|
|
47
|
+
hide(WindowInsetsCompat.Type.systemBars())
|
|
48
|
+
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
|
49
|
+
}
|
|
50
|
+
report(true)
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Leaves fullscreen from our side: WebView then calls onHideCustomView. */
|
|
55
|
+
private fun exit() {
|
|
56
|
+
val callback = shownCallback ?: return
|
|
57
|
+
onHideCustomView()
|
|
58
|
+
callback.onCustomViewHidden()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Removes the fullscreen view, which WebView hid or we are leaving. */
|
|
62
|
+
fun onHideCustomView() {
|
|
63
|
+
if (shownCallback == null) return
|
|
64
|
+
shownCallback = null
|
|
65
|
+
backdrop?.let { (it.parent as? ViewGroup)?.removeView(it) }
|
|
66
|
+
backdrop?.removeAllViews()
|
|
67
|
+
backdrop = null
|
|
68
|
+
controller()?.apply {
|
|
69
|
+
show(barsShownBefore)
|
|
70
|
+
barsBehaviorBefore?.let { systemBarsBehavior = it }
|
|
71
|
+
}
|
|
72
|
+
backCallback?.remove()
|
|
73
|
+
backCallback = null
|
|
74
|
+
report(false)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private fun report(active: Boolean) {
|
|
78
|
+
if ("onFullscreenChange" in owner.requestHandlers) owner.emit("core", "onFullscreenChange", mapOf("active" to active))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private fun controller() = owner.activity?.window?.let { WindowCompat.getInsetsController(it, it.decorView) }
|
|
82
|
+
|
|
83
|
+
/** The Document ended: its fullscreen view goes. A crash leaves no renderer to tell; at unmount WebView is told. */
|
|
84
|
+
fun documentEnded(reason: DocumentEnd) {
|
|
85
|
+
if (reason == DocumentEnd.CLOSING) exit() else onHideCustomView()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
package expo.modules.minimalwebview.requests
|
|
2
|
+
|
|
3
|
+
import android.net.Uri
|
|
4
|
+
import android.webkit.GeolocationPermissions
|
|
5
|
+
import android.webkit.PermissionRequest
|
|
6
|
+
import expo.modules.minimalwebview.MinimalWebView
|
|
7
|
+
|
|
8
|
+
/** The `onPermissionRequest` prop. */
|
|
9
|
+
internal class Permissions(private val owner: MinimalWebView) {
|
|
10
|
+
// Asks waiting for JS, by their PermissionRequest or GeolocationPermissions.Callback, for the platform cancels.
|
|
11
|
+
private val waiting = mutableMapOf<Any, Int>()
|
|
12
|
+
|
|
13
|
+
/** Returns true when the app's prop takes the request; it is then granted or denied once. */
|
|
14
|
+
fun onPermissionRequest(request: PermissionRequest): Boolean {
|
|
15
|
+
val known = request.resources.filter { it in RESOURCES }
|
|
16
|
+
return decide(request, request.origin.toString(), known.map { RESOURCES.getValue(it) }, deny = request::deny) {
|
|
17
|
+
request.grant(known.toTypedArray())
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun onGeolocationPrompt(origin: String, callback: GeolocationPermissions.Callback) =
|
|
22
|
+
decide(callback, origin, listOf("geolocation"), deny = { callback.invoke(origin, false, false) }) {
|
|
23
|
+
callback.invoke(origin, true, false)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Chromium gave up on the request: cancel its ask, removed first so that nothing answers the request. Answering one
|
|
27
|
+
// Chromium already destroyed aborts the app on WebView 133 (an invalid JNI weak reference).
|
|
28
|
+
fun onPermissionRequestCanceled(request: PermissionRequest) {
|
|
29
|
+
waiting.remove(request)?.let { owner.asks.cancel(it) }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Not told which prompt: every geolocation ask goes, unanswered like a cancelled request.
|
|
33
|
+
fun onGeolocationPromptHidden() =
|
|
34
|
+
waiting.keys.filterIsInstance<GeolocationPermissions.Callback>().forEach { key -> waiting.remove(key)?.let { owner.asks.cancel(it) } }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Asks the app, then runs [grant] or [deny]. False (the core denies) without the prop. Android reports the requesting
|
|
38
|
+
* frame's origin but not the frame: one that isn't the top-level page's is denied (main frame only).
|
|
39
|
+
*/
|
|
40
|
+
private fun decide(key: Any, origin: String, resources: List<String>, deny: () -> Unit, grant: () -> Unit): Boolean {
|
|
41
|
+
if ("onPermissionRequest" !in owner.requestHandlers) return false
|
|
42
|
+
val value = originOf(origin)
|
|
43
|
+
if (resources.isEmpty() || value != originOf(owner.webView.url)) {
|
|
44
|
+
deny()
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
waiting[key] = owner.asks.ask("core", "onPermissionRequest", mapOf("origin" to value, "resources" to resources)) { answer ->
|
|
48
|
+
// Not there: Chromium cancelled the request, and it takes no answer.
|
|
49
|
+
if (waiting.remove(key) == null) return@ask
|
|
50
|
+
if (answer == true) grant() else deny()
|
|
51
|
+
}
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
internal companion object {
|
|
56
|
+
private val RESOURCES = mapOf(
|
|
57
|
+
PermissionRequest.RESOURCE_VIDEO_CAPTURE to "camera",
|
|
58
|
+
PermissionRequest.RESOURCE_AUDIO_CAPTURE to "microphone",
|
|
59
|
+
PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID to "protectedMedia"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `location.origin` form: the scheme's default port left out. A missing scheme or host prints as `null` (`data:…`
|
|
64
|
+
* gives `data://null`, `""` gives `null://null`), and `file:///x` gives `file://`.
|
|
65
|
+
*/
|
|
66
|
+
fun originOf(url: String?): String? {
|
|
67
|
+
val uri = Uri.parse(url ?: return null)
|
|
68
|
+
return origin(uri.scheme, uri.host, uri.port)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** [originOf] from the scheme, host and port (-1 for none) that `Uri` parses. */
|
|
72
|
+
fun origin(scheme: String?, host: String?, port: Int): String {
|
|
73
|
+
val defaultPort = if (scheme == "https") 443 else 80
|
|
74
|
+
return "$scheme://$host" + if (port == -1 || port == defaultPort) "" else ":$port"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { WebViewProps } from './types';
|
|
2
|
+
/** A page's message comes with its origin, as native verified it (`location.origin` form). */
|
|
3
|
+
export type BridgeEvent = {
|
|
4
|
+
message: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
} | {
|
|
7
|
+
navigated: true;
|
|
8
|
+
} | {
|
|
9
|
+
unavailable: true;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An event as native sends it: `key` is the hook's key, `core` for the core's own. `askId` is set when native waits for
|
|
13
|
+
* the answer.
|
|
14
|
+
*/
|
|
15
|
+
export type AskableEvent = {
|
|
16
|
+
key: string;
|
|
17
|
+
name: string;
|
|
18
|
+
payload: Record<string, unknown>;
|
|
19
|
+
askId?: number;
|
|
20
|
+
};
|
|
21
|
+
/** The native view's methods, on its ref. */
|
|
22
|
+
export type NativeMethods = {
|
|
23
|
+
goBack(): Promise<void>;
|
|
24
|
+
goForward(): Promise<void>;
|
|
25
|
+
reload(): Promise<void>;
|
|
26
|
+
stopLoading(): Promise<void>;
|
|
27
|
+
bridgePost(message: string): Promise<void>;
|
|
28
|
+
/** Answers a native `ask`. `json` is JSON, as for `call`. */
|
|
29
|
+
answer(askId: number, json: string): Promise<void>;
|
|
30
|
+
/** The JSON-encoded result. */
|
|
31
|
+
evaluate(script: string): Promise<string>;
|
|
32
|
+
/** Reads a platform setting: the JSON of its value. */
|
|
33
|
+
get(path: string): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Calls a platform method: the JSON of its result. `argsJson` is JSON, so that a `null` argument survives the native
|
|
36
|
+
* conversion.
|
|
37
|
+
*/
|
|
38
|
+
call(path: string, argsJson: string): Promise<string>;
|
|
39
|
+
/** A hook's `context.handle` handler: the JSON of its reply. `args` is JSON, as for `call`. */
|
|
40
|
+
hook(name: string, method: string, args: string): Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A WebView whose native side decides navigations and owns the navigation state: see {@link WebViewProps} and
|
|
44
|
+
* {@link WebViewRef}.
|
|
45
|
+
* @group WebView
|
|
46
|
+
*/
|
|
47
|
+
export declare function WebView(props: WebViewProps): import("react").JSX.Element;
|
|
48
|
+
/**
|
|
49
|
+
* Android's process-wide WebView functions, like the static methods of Android's `WebView`. On iOS they do nothing,
|
|
50
|
+
* and `defaultUserAgent` is null.
|
|
51
|
+
* @group WebView
|
|
52
|
+
* @android
|
|
53
|
+
* @namespace
|
|
54
|
+
*/
|
|
55
|
+
export declare const AndroidWebView: {
|
|
56
|
+
/**
|
|
57
|
+
* Android's default user agent, for `android.settings.userAgentString` with a suffix.
|
|
58
|
+
*
|
|
59
|
+
* The first read loads WebView's code, on the JS thread: read it once `warmUp()` has had time or a WebView is
|
|
60
|
+
* mounted.
|
|
61
|
+
* @android
|
|
62
|
+
*/
|
|
63
|
+
readonly defaultUserAgent: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Starts WebView before any WebView mounts, so the first WebView mounts sooner.
|
|
66
|
+
*
|
|
67
|
+
* It helps only if it runs well before the first WebView mounts: at app start, or as the screen with the WebView is
|
|
68
|
+
* pushed. Calling it at mount gains nothing. WebView starts once per app, and React Native's first `fetch` starts
|
|
69
|
+
* it too.
|
|
70
|
+
* @android
|
|
71
|
+
*/
|
|
72
|
+
warmUp(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Opens a connection to `url`'s origin (DNS, TCP, TLS) in WebView's default profile, ahead of a load that comes
|
|
75
|
+
* later.
|
|
76
|
+
*
|
|
77
|
+
* Use it for a load that hasn't started yet: as the screen with the WebView is pushed, or for the next page a
|
|
78
|
+
* mounted WebView will go to. A WebView connects to its `source` itself as it mounts, so preconnecting `source` at
|
|
79
|
+
* mount gains nothing.
|
|
80
|
+
*
|
|
81
|
+
* It starts WebView on the UI thread if nothing has yet, so call it once `warmUp()` has had time or a WebView is
|
|
82
|
+
* mounted.
|
|
83
|
+
*
|
|
84
|
+
* Needs the androidx.webkit features `MULTI_PROFILE` and `ENQUEUE_PRECONNECT` or `PRECONNECT`; without them it does
|
|
85
|
+
* nothing. For prefetch and prerender, a native hook uses `ProfileStore`.
|
|
86
|
+
* @android
|
|
87
|
+
*/
|
|
88
|
+
preconnect(url: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Turns remote debugging (`chrome://inspect`) of every WebView in the app on or off.
|
|
91
|
+
*
|
|
92
|
+
* Until it is called, it is on when the app is debuggable (a debug build) and off otherwise. Called before any
|
|
93
|
+
* WebView exists, it applies when the first one is made, so it doesn't start WebView. On iOS,
|
|
94
|
+
* `ios.webView.inspectable` sets it per WebView.
|
|
95
|
+
* @android
|
|
96
|
+
*/
|
|
97
|
+
setWebContentsDebuggingEnabled(enabled: boolean): void;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=WebView.d.ts.map
|
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