@javascriptcommon/react-native-webview 13.12.16
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 +82 -0
- package/android/build.gradle +110 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/AndroidManifestNew.xml +13 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCBasicAuthCredential.java +11 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +372 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +450 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +328 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewConfig.java +11 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java +14 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +720 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewMessagingModule.kt +19 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java +554 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +56 -0
- package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewWrapper.kt +39 -0
- package/android/src/main/java/com/reactnativecommunity/webview/URLUtil.java +179 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopCustomMenuSelectionEvent.kt +24 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +25 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt +25 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt +24 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt +24 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt +25 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt +24 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopNewWindowEvent.kt +25 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopRenderProcessGoneEvent.kt +26 -0
- package/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt +29 -0
- package/android/src/main/res/xml/file_provider_paths.xml +6 -0
- package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +553 -0
- package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java +63 -0
- package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +328 -0
- package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java +59 -0
- package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
- package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
- package/apple/RNCWKProcessPoolManager.h +15 -0
- package/apple/RNCWKProcessPoolManager.m +36 -0
- package/apple/RNCWebView.h +35 -0
- package/apple/RNCWebView.mm +546 -0
- package/apple/RNCWebViewDecisionManager.h +20 -0
- package/apple/RNCWebViewDecisionManager.m +47 -0
- package/apple/RNCWebViewImpl.h +161 -0
- package/apple/RNCWebViewImpl.m +1979 -0
- package/apple/RNCWebViewManager.h +9 -0
- package/apple/RNCWebViewManager.mm +215 -0
- package/apple/RNCWebViewModule.h +23 -0
- package/apple/RNCWebViewModule.mm +34 -0
- package/index.d.ts +65 -0
- package/index.js +4 -0
- package/ios/RNCWebView.xcodeproj/project.pbxproj +273 -0
- package/lib/NativeRNCWebViewModule.d.ts +10 -0
- package/lib/NativeRNCWebViewModule.js +1 -0
- package/lib/RNCWebViewNativeComponent.d.ts +242 -0
- package/lib/RNCWebViewNativeComponent.js +1 -0
- package/lib/WebView.android.d.ts +6 -0
- package/lib/WebView.android.js +1 -0
- package/lib/WebView.d.ts +6 -0
- package/lib/WebView.ios.d.ts +6 -0
- package/lib/WebView.ios.js +1 -0
- package/lib/WebView.js +1 -0
- package/lib/WebView.macos.d.ts +6 -0
- package/lib/WebView.macos.js +1 -0
- package/lib/WebView.styles.d.ts +38 -0
- package/lib/WebView.styles.js +1 -0
- package/lib/WebView.windows.d.ts +17 -0
- package/lib/WebView.windows.js +1 -0
- package/lib/WebViewNativeComponent.macos.d.ts +3 -0
- package/lib/WebViewNativeComponent.macos.js +1 -0
- package/lib/WebViewNativeComponent.windows.d.ts +3 -0
- package/lib/WebViewNativeComponent.windows.js +1 -0
- package/lib/WebViewShared.d.ts +38 -0
- package/lib/WebViewShared.js +1 -0
- package/lib/WebViewTypes.d.ts +1093 -0
- package/lib/WebViewTypes.js +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +1 -0
- package/macos/RNCWebView.xcodeproj/project.pbxproj +363 -0
- package/package.json +101 -0
- package/react-native-webview.podspec +46 -0
- package/react-native.config.js +44 -0
- package/src/NativeRNCWebViewModule.ts +15 -0
- package/src/RNCWebViewNativeComponent.ts +342 -0
- package/src/WebView.android.tsx +317 -0
- package/src/WebView.ios.tsx +299 -0
- package/src/WebView.macos.tsx +245 -0
- package/src/WebView.styles.ts +41 -0
- package/src/WebView.tsx +25 -0
- package/src/WebView.windows.tsx +210 -0
- package/src/WebViewNativeComponent.macos.ts +7 -0
- package/src/WebViewNativeComponent.windows.ts +8 -0
- package/src/WebViewShared.tsx +283 -0
- package/src/WebViewTypes.ts +1332 -0
- package/src/__tests__/WebViewShared-test.js +323 -0
- package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
- package/src/index.ts +4 -0
- package/windows/ExperimentalFeatures.props +11 -0
- package/windows/ReactNativeWebView/PropertySheet.props +16 -0
- package/windows/ReactNativeWebView/ReactNativeWebView.def +3 -0
- package/windows/ReactNativeWebView/ReactNativeWebView.filters +33 -0
- package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +189 -0
- package/windows/ReactNativeWebView/ReactPackageProvider.cpp +26 -0
- package/windows/ReactNativeWebView/ReactPackageProvider.h +20 -0
- package/windows/ReactNativeWebView/ReactPackageProvider.idl +7 -0
- package/windows/ReactNativeWebView/ReactWebView.cpp +242 -0
- package/windows/ReactNativeWebView/ReactWebView.h +56 -0
- package/windows/ReactNativeWebView/ReactWebView.idl +31 -0
- package/windows/ReactNativeWebView/ReactWebView2.cpp +473 -0
- package/windows/ReactNativeWebView/ReactWebView2.h +91 -0
- package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +205 -0
- package/windows/ReactNativeWebView/ReactWebView2Manager.h +57 -0
- package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
- package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
- package/windows/ReactNativeWebView/ReactWebViewManager.cpp +224 -0
- package/windows/ReactNativeWebView/ReactWebViewManager.h +58 -0
- package/windows/ReactNativeWebView/WebBridge.cpp +19 -0
- package/windows/ReactNativeWebView/WebBridge.h +24 -0
- package/windows/ReactNativeWebView/WebBridge.idl +11 -0
- package/windows/ReactNativeWebView/pch.cpp +1 -0
- package/windows/ReactNativeWebView/pch.h +37 -0
- package/windows/ReactNativeWebView.sln +185 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2006 The Android Open Source Project
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* The source code is obtained from the Android SDK Sources (API level 31),
|
|
19
|
+
* and modified by UNIDY2002 <UNIDY2002@outlook.com>.
|
|
20
|
+
*
|
|
21
|
+
* Change list:
|
|
22
|
+
* - Remove all unused class members except guessFileName,
|
|
23
|
+
* CONTENT_DISPOSITION_PATTERN and parseContentDisposition
|
|
24
|
+
* - Improve CONTENT_DISPOSITION_PATTERN and parseContentDisposition to add
|
|
25
|
+
* support for the "filename*" parameter in content disposition
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
package com.reactnativecommunity.webview;
|
|
29
|
+
|
|
30
|
+
import android.net.Uri;
|
|
31
|
+
import android.webkit.MimeTypeMap;
|
|
32
|
+
import androidx.annotation.Nullable;
|
|
33
|
+
|
|
34
|
+
import java.io.UnsupportedEncodingException;
|
|
35
|
+
import java.net.URLDecoder;
|
|
36
|
+
import java.util.Locale;
|
|
37
|
+
import java.util.regex.Matcher;
|
|
38
|
+
import java.util.regex.Pattern;
|
|
39
|
+
|
|
40
|
+
public final class URLUtil {
|
|
41
|
+
/**
|
|
42
|
+
* Guesses canonical filename that a download would have, using
|
|
43
|
+
* the URL and contentDisposition. File extension, if not defined,
|
|
44
|
+
* is added based on the mimetype
|
|
45
|
+
* @param url Url to the content
|
|
46
|
+
* @param contentDisposition Content-Disposition HTTP header or {@code null}
|
|
47
|
+
* @param mimeType Mime-type of the content or {@code null}
|
|
48
|
+
*
|
|
49
|
+
* @return suggested filename
|
|
50
|
+
*/
|
|
51
|
+
public static final String guessFileName(
|
|
52
|
+
String url,
|
|
53
|
+
@Nullable String contentDisposition,
|
|
54
|
+
@Nullable String mimeType) {
|
|
55
|
+
String filename = null;
|
|
56
|
+
String extension = null;
|
|
57
|
+
|
|
58
|
+
// If we couldn't do anything with the hint, move toward the content disposition
|
|
59
|
+
if (filename == null && contentDisposition != null) {
|
|
60
|
+
filename = parseContentDisposition(contentDisposition);
|
|
61
|
+
if (filename != null) {
|
|
62
|
+
int index = filename.lastIndexOf('/') + 1;
|
|
63
|
+
if (index > 0) {
|
|
64
|
+
filename = filename.substring(index);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// If all the other http-related approaches failed, use the plain uri
|
|
70
|
+
if (filename == null) {
|
|
71
|
+
String decodedUrl = Uri.decode(url);
|
|
72
|
+
if (decodedUrl != null) {
|
|
73
|
+
int queryIndex = decodedUrl.indexOf('?');
|
|
74
|
+
// If there is a query string strip it, same as desktop browsers
|
|
75
|
+
if (queryIndex > 0) {
|
|
76
|
+
decodedUrl = decodedUrl.substring(0, queryIndex);
|
|
77
|
+
}
|
|
78
|
+
if (!decodedUrl.endsWith("/")) {
|
|
79
|
+
int index = decodedUrl.lastIndexOf('/') + 1;
|
|
80
|
+
if (index > 0) {
|
|
81
|
+
filename = decodedUrl.substring(index);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Finally, if couldn't get filename from URI, get a generic filename
|
|
88
|
+
if (filename == null) {
|
|
89
|
+
filename = "downloadfile";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Split filename between base and extension
|
|
93
|
+
// Add an extension if filename does not have one
|
|
94
|
+
int dotIndex = filename.indexOf('.');
|
|
95
|
+
if (dotIndex < 0) {
|
|
96
|
+
if (mimeType != null) {
|
|
97
|
+
extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
|
98
|
+
if (extension != null) {
|
|
99
|
+
extension = "." + extension;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (extension == null) {
|
|
103
|
+
if (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("text/")) {
|
|
104
|
+
if (mimeType.equalsIgnoreCase("text/html")) {
|
|
105
|
+
extension = ".html";
|
|
106
|
+
} else {
|
|
107
|
+
extension = ".txt";
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
extension = ".bin";
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
if (mimeType != null) {
|
|
115
|
+
// Compare the last segment of the extension against the mime type.
|
|
116
|
+
// If there's a mismatch, discard the entire extension.
|
|
117
|
+
int lastDotIndex = filename.lastIndexOf('.');
|
|
118
|
+
String typeFromExt = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
|
119
|
+
filename.substring(lastDotIndex + 1));
|
|
120
|
+
if (typeFromExt != null && !typeFromExt.equalsIgnoreCase(mimeType)) {
|
|
121
|
+
extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
|
122
|
+
if (extension != null) {
|
|
123
|
+
extension = "." + extension;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (extension == null) {
|
|
128
|
+
extension = filename.substring(dotIndex);
|
|
129
|
+
}
|
|
130
|
+
filename = filename.substring(0, dotIndex);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return filename + extension;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Regex used to parse content-disposition headers */
|
|
137
|
+
private static final Pattern CONTENT_DISPOSITION_PATTERN =
|
|
138
|
+
Pattern.compile("attachment(?:;\\s*filename\\s*=\\s*(\"?)([^\"]*)\\1)?(?:;\\s*filename\\s*\\*\\s*=\\s*([^']*)'[^']*'([^']*))?\\s*$",
|
|
139
|
+
Pattern.CASE_INSENSITIVE);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Parse the Content-Disposition HTTP Header. The format of the header
|
|
143
|
+
* is defined here: <a href="https://www.rfc-editor.org/rfc/rfc6266">RFC 6266</a>
|
|
144
|
+
* This header provides a filename for content that is going to be
|
|
145
|
+
* downloaded to the file system. We only support the attachment type.
|
|
146
|
+
*/
|
|
147
|
+
static String parseContentDisposition(String contentDisposition) {
|
|
148
|
+
try {
|
|
149
|
+
// The regex attempts to match the following pattern:
|
|
150
|
+
// attachment; filename="(Group 2)"; filename*=(Group 3)'(lang)'(Group 4)
|
|
151
|
+
// Group 4 refers to the percent-encoded filename, and the charset
|
|
152
|
+
// is specified in Group 3.
|
|
153
|
+
// Group 2 is the fallback filename.
|
|
154
|
+
// Group 1 refers to the quotation marks around Group 2.
|
|
155
|
+
//
|
|
156
|
+
// Test cases can be found at http://test.greenbytes.de/tech/tc2231/
|
|
157
|
+
// Examples can be found at https://www.rfc-editor.org/rfc/rfc6266#section-5
|
|
158
|
+
// There are a few known limitations:
|
|
159
|
+
// - any Content Disposition value that does not have parameters
|
|
160
|
+
// arranged in the order of "attachment...filename...filename*"
|
|
161
|
+
// or contains extra parameters shall fail to be parsed
|
|
162
|
+
// - any filename that contains " shall fail to be parsed
|
|
163
|
+
Matcher m = CONTENT_DISPOSITION_PATTERN.matcher(contentDisposition);
|
|
164
|
+
if (m.find()) {
|
|
165
|
+
if (m.group(3) != null && m.group(4) != null) {
|
|
166
|
+
try {
|
|
167
|
+
return URLDecoder.decode(m.group(4), m.group(3).isEmpty() ? "UTF-8" : m.group(3));
|
|
168
|
+
} catch (UnsupportedEncodingException e) {
|
|
169
|
+
// Skip the ext-parameter as the encoding is unsupported
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return m.group(2);
|
|
173
|
+
}
|
|
174
|
+
} catch (IllegalStateException ex) {
|
|
175
|
+
// This function is defined as returning null when it can't parse the header
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
package/android/src/main/java/com/reactnativecommunity/webview/events/TopCustomMenuSelectionEvent.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when there is a loading progress event.
|
|
9
|
+
*/
|
|
10
|
+
class TopCustomMenuSelectionEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopCustomMenuSelectionEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topCustomMenuSelection"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when a http error is received from the server.
|
|
9
|
+
*/
|
|
10
|
+
class TopHttpErrorEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopHttpErrorEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topHttpError"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when there is an error in loading.
|
|
9
|
+
*/
|
|
10
|
+
class TopLoadingErrorEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopLoadingErrorEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topLoadingError"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
|
|
25
|
+
}
|
package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when loading is completed.
|
|
9
|
+
*/
|
|
10
|
+
class TopLoadingFinishEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopLoadingFinishEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topLoadingFinish"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
}
|
package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when there is a loading progress event.
|
|
9
|
+
*/
|
|
10
|
+
class TopLoadingProgressEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopLoadingProgressEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topLoadingProgress"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when loading has started
|
|
9
|
+
*/
|
|
10
|
+
class TopLoadingStartEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopLoadingStartEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topLoadingStart"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when there is an error in loading.
|
|
9
|
+
*/
|
|
10
|
+
class TopMessageEvent(viewId: Int, private val mEventData: WritableMap) : Event<TopMessageEvent>(viewId) {
|
|
11
|
+
companion object {
|
|
12
|
+
const val EVENT_NAME = "topMessage"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun getEventName(): String = EVENT_NAME
|
|
16
|
+
|
|
17
|
+
override fun canCoalesce(): Boolean = false
|
|
18
|
+
|
|
19
|
+
override fun getCoalescingKey(): Short = 0
|
|
20
|
+
|
|
21
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) {
|
|
22
|
+
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, mEventData)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when the WebView opens a new Window (i.e: target=_blank)
|
|
9
|
+
*/
|
|
10
|
+
class TopOpenWindowEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
11
|
+
Event<TopOpenWindowEvent>(viewId) {
|
|
12
|
+
companion object {
|
|
13
|
+
const val EVENT_NAME = "topOpenWindow"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getEventName(): String = EVENT_NAME
|
|
17
|
+
|
|
18
|
+
override fun canCoalesce(): Boolean = false
|
|
19
|
+
|
|
20
|
+
override fun getCoalescingKey(): Short = 0
|
|
21
|
+
|
|
22
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
23
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
24
|
+
|
|
25
|
+
}
|
package/android/src/main/java/com/reactnativecommunity/webview/events/TopRenderProcessGoneEvent.kt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when the WebView's process has crashed or
|
|
9
|
+
was killed by the OS.
|
|
10
|
+
*/
|
|
11
|
+
class TopRenderProcessGoneEvent(viewId: Int, private val mEventData: WritableMap) :
|
|
12
|
+
Event<TopRenderProcessGoneEvent>(viewId) {
|
|
13
|
+
companion object {
|
|
14
|
+
const val EVENT_NAME = "topRenderProcessGone"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun getEventName(): String = EVENT_NAME
|
|
18
|
+
|
|
19
|
+
override fun canCoalesce(): Boolean = false
|
|
20
|
+
|
|
21
|
+
override fun getCoalescingKey(): Short = 0
|
|
22
|
+
|
|
23
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
24
|
+
rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.reactnativecommunity.webview.events
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.uimanager.events.Event
|
|
5
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emitted when shouldOverrideUrlLoading is called
|
|
9
|
+
*/
|
|
10
|
+
class TopShouldStartLoadWithRequestEvent(viewId: Int, private val mData: WritableMap) : Event<TopShouldStartLoadWithRequestEvent>(viewId) {
|
|
11
|
+
companion object {
|
|
12
|
+
const val EVENT_NAME = "topShouldStartLoadWithRequest"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
init {
|
|
16
|
+
mData.putString("navigationType", "other")
|
|
17
|
+
// Android does not raise shouldOverrideUrlLoading for inner frames
|
|
18
|
+
mData.putBoolean("isTopFrame", true)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun getEventName(): String = EVENT_NAME
|
|
22
|
+
|
|
23
|
+
override fun canCoalesce(): Boolean = false
|
|
24
|
+
|
|
25
|
+
override fun getCoalescingKey(): Short = 0
|
|
26
|
+
|
|
27
|
+
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
28
|
+
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, mData)
|
|
29
|
+
}
|