@react-native-ohos/react-native-webview 13.15.1-rc.8 → 13.15.2-rc.1
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/harmony/rn_webview/oh-package.json5 +1 -1
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +116 -109
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +90 -85
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +2 -0
- package/harmony/rn_webview/src/main/ets/Magic.ets +1 -0
- package/harmony/rn_webview/src/main/ets/RNCWebView.ets +45 -2
- package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +2 -0
- package/harmony/rn_webview.har +0 -0
- package/package.json +1 -2
- package/src/RNCWebViewNativeComponent.ts +2 -0
- package/src/WebView.harmony.tsx +6 -4
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"name": "@react-native-ohos/react-native-webview",
|
|
7
7
|
"description": "main cpai architecture",
|
|
8
8
|
"main": "index.ets",
|
|
9
|
-
"version": "13.15.
|
|
9
|
+
"version": "13.15.2-rc.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@rnoh/react-native-openharmony": "../react_native_openharmony.har"
|
|
12
12
|
}
|
package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h
CHANGED
|
@@ -5,115 +5,122 @@
|
|
|
5
5
|
#pragma once
|
|
6
6
|
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
7
7
|
|
|
8
|
-
namespace rnoh
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
8
|
+
namespace rnoh
|
|
9
|
+
{
|
|
10
|
+
class RNCWebViewJSIBinder : public ViewComponentJSIBinder
|
|
11
|
+
{
|
|
12
|
+
protected:
|
|
13
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
|
|
14
|
+
{
|
|
15
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
16
|
+
object.setProperty(rt, "allowFileAccess", true);
|
|
17
|
+
object.setProperty(rt, "allowsProtectedMedia", true);
|
|
18
|
+
object.setProperty(rt, "allowsFullscreenVideo", true);
|
|
19
|
+
object.setProperty(rt, "androidLayerType", true);
|
|
20
|
+
object.setProperty(rt, "cacheMode", true);
|
|
21
|
+
object.setProperty(rt, "domStorageEnabled", true);
|
|
22
|
+
object.setProperty(rt, "downloadingMessage", true);
|
|
23
|
+
object.setProperty(rt, "forceDarkOn", true);
|
|
24
|
+
object.setProperty(rt, "geolocationEnabled", true);
|
|
25
|
+
object.setProperty(rt, "lackPermissionToDownloadMessage", true);
|
|
26
|
+
object.setProperty(rt, "messagingModuleName", true);
|
|
27
|
+
object.setProperty(rt, "minimumFontSize", true);
|
|
28
|
+
object.setProperty(rt, "mixedContentMode", true);
|
|
29
|
+
object.setProperty(rt, "nestedScrollEnabled", true);
|
|
30
|
+
object.setProperty(rt, "overScrollMode", true);
|
|
31
|
+
object.setProperty(rt, "saveFormDataDisabled", true);
|
|
32
|
+
object.setProperty(rt, "scalesPageToFit", true);
|
|
33
|
+
object.setProperty(rt, "setBuiltInZoomControls", true);
|
|
34
|
+
object.setProperty(rt, "setDisplayZoomControls", true);
|
|
35
|
+
object.setProperty(rt, "setSupportMultipleWindows", true);
|
|
36
|
+
object.setProperty(rt, "textZoom", true);
|
|
37
|
+
object.setProperty(rt, "thirdPartyCookiesEnabled", true);
|
|
38
|
+
object.setProperty(rt, "hasOnShouldStartLoadWithRequestEvent", true);
|
|
39
|
+
object.setProperty(rt, "originWhitelist", true);
|
|
40
|
+
object.setProperty(rt, "hasOnScroll", true);
|
|
41
|
+
object.setProperty(rt, "injectedJavaScriptObject", true);
|
|
42
|
+
object.setProperty(rt, "paymentRequestEnabled", true);
|
|
43
|
+
object.setProperty(rt, "allowingReadAccessToURL", true);
|
|
44
|
+
object.setProperty(rt, "allowsBackForwardNavigationGestures", true);
|
|
45
|
+
object.setProperty(rt, "allowsInlineMediaPlayback", true);
|
|
46
|
+
object.setProperty(rt, "allowsPictureInPictureMediaPlayback", true);
|
|
47
|
+
object.setProperty(rt, "allowsAirPlayForMediaPlayback", true);
|
|
48
|
+
object.setProperty(rt, "allowsLinkPreview", true);
|
|
49
|
+
object.setProperty(rt, "automaticallyAdjustContentInsets", true);
|
|
50
|
+
object.setProperty(rt, "ignoreSilentHardwareSwitch", true);
|
|
51
|
+
object.setProperty(rt, "autoManageStatusBarEnabled", true);
|
|
52
|
+
object.setProperty(rt, "bounces", true);
|
|
53
|
+
object.setProperty(rt, "contentInset", "Object");
|
|
54
|
+
object.setProperty(rt, "contentInsetAdjustmentBehavior", true);
|
|
55
|
+
object.setProperty(rt, "contentMode", true);
|
|
56
|
+
object.setProperty(rt, "dataDetectorTypes", true);
|
|
57
|
+
object.setProperty(rt, "decelerationRate", true);
|
|
58
|
+
object.setProperty(rt, "directionalLockEnabled", true);
|
|
59
|
+
object.setProperty(rt, "enableApplePay", true);
|
|
60
|
+
object.setProperty(rt, "hideKeyboardAccessoryView", true);
|
|
61
|
+
object.setProperty(rt, "keyboardDisplayRequiresUserAction", true);
|
|
62
|
+
object.setProperty(rt, "limitsNavigationsToAppBoundDomains", true);
|
|
63
|
+
object.setProperty(rt, "mediaCapturePermissionGrantType", true);
|
|
64
|
+
object.setProperty(rt, "pagingEnabled", true);
|
|
65
|
+
object.setProperty(rt, "pullToRefreshEnabled", true);
|
|
66
|
+
object.setProperty(rt, "refreshControlLightMode", true);
|
|
67
|
+
object.setProperty(rt, "scrollEnabled", true);
|
|
68
|
+
object.setProperty(rt, "sharedCookiesEnabled", true);
|
|
69
|
+
object.setProperty(rt, "textInteractionEnabled", true);
|
|
70
|
+
object.setProperty(rt, "useSharedProcessPool", true);
|
|
71
|
+
object.setProperty(rt, "menuItems", true);
|
|
72
|
+
object.setProperty(rt, "suppressMenuItems", true);
|
|
73
|
+
object.setProperty(rt, "hasOnFileDownload", true);
|
|
74
|
+
object.setProperty(rt, "fraudulentWebsiteWarningEnabled", true);
|
|
75
|
+
object.setProperty(rt, "allowFileAccessFromFileURLs", true);
|
|
76
|
+
object.setProperty(rt, "allowUniversalAccessFromFileURLs", true);
|
|
77
|
+
object.setProperty(rt, "applicationNameForUserAgent", true);
|
|
78
|
+
object.setProperty(rt, "basicAuthCredential", "Object");
|
|
79
|
+
object.setProperty(rt, "cacheEnabled", true);
|
|
80
|
+
object.setProperty(rt, "incognito", true);
|
|
81
|
+
object.setProperty(rt, "injectedJavaScript", true);
|
|
82
|
+
object.setProperty(rt, "injectedJavaScriptBeforeContentLoaded", true);
|
|
83
|
+
object.setProperty(rt, "injectedJavaScriptForMainFrameOnly", true);
|
|
84
|
+
object.setProperty(rt, "injectedJavaScriptBeforeContentLoadedForMainFrameOnly", true);
|
|
85
|
+
object.setProperty(rt, "javaScriptCanOpenWindowsAutomatically", true);
|
|
86
|
+
object.setProperty(rt, "javaScriptEnabled", true);
|
|
87
|
+
object.setProperty(rt, "webviewDebuggingEnabled", true);
|
|
88
|
+
object.setProperty(rt, "mediaPlaybackRequiresUserAction", true);
|
|
89
|
+
object.setProperty(rt, "messagingEnabled", true);
|
|
90
|
+
object.setProperty(rt, "shouldStartLoadWithRequestEnabled", true);
|
|
91
|
+
object.setProperty(rt, "hasOnOpenWindowEvent", true);
|
|
92
|
+
object.setProperty(rt, "showsHorizontalScrollIndicator", true);
|
|
93
|
+
object.setProperty(rt, "showsVerticalScrollIndicator", true);
|
|
94
|
+
object.setProperty(rt, "indicatorStyle", true);
|
|
95
|
+
object.setProperty(rt, "newSource", "Object");
|
|
96
|
+
object.setProperty(rt, "userAgent", true);
|
|
97
|
+
return object;
|
|
98
|
+
}
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
|
|
101
|
+
{
|
|
102
|
+
facebook::jsi::Object events(rt);
|
|
103
|
+
return events;
|
|
104
|
+
}
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
106
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
|
|
107
|
+
{
|
|
108
|
+
facebook::jsi::Object events(rt);
|
|
109
|
+
events.setProperty(rt, "topContentSizeChange", createDirectEvent(rt, "onContentSizeChange"));
|
|
110
|
+
events.setProperty(rt, "topRenderProcessGone", createDirectEvent(rt, "onRenderProcessGone"));
|
|
111
|
+
events.setProperty(rt, "topContentProcessDidTerminate", createDirectEvent(rt, "onContentProcessDidTerminate"));
|
|
112
|
+
events.setProperty(rt, "topCustomMenuSelection", createDirectEvent(rt, "onCustomMenuSelection"));
|
|
113
|
+
events.setProperty(rt, "topFileDownload", createDirectEvent(rt, "onFileDownload"));
|
|
114
|
+
events.setProperty(rt, "topLoadingError", createDirectEvent(rt, "onLoadingError"));
|
|
115
|
+
events.setProperty(rt, "topLoadingFinish", createDirectEvent(rt, "onLoadingFinish"));
|
|
116
|
+
events.setProperty(rt, "topLoadingProgress", createDirectEvent(rt, "onLoadingProgress"));
|
|
117
|
+
events.setProperty(rt, "topLoadingStart", createDirectEvent(rt, "onLoadingStart"));
|
|
118
|
+
events.setProperty(rt, "topHttpError", createDirectEvent(rt, "onHttpError"));
|
|
119
|
+
events.setProperty(rt, "topMessage", createDirectEvent(rt, "onMessage"));
|
|
120
|
+
events.setProperty(rt, "topOpenWindow", createDirectEvent(rt, "onOpenWindow"));
|
|
121
|
+
events.setProperty(rt, "topScroll", createDirectEvent(rt, "onScroll"));
|
|
122
|
+
events.setProperty(rt, "topShouldStartLoadWithRequest", createDirectEvent(rt, "onShouldStartLoadWithRequest"));
|
|
123
|
+
return events;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
119
126
|
} // namespace rnoh
|
|
@@ -12,92 +12,97 @@
|
|
|
12
12
|
#include <react/renderer/core/PropsParserContext.h>
|
|
13
13
|
#include <react/renderer/core/propsConversions.h>
|
|
14
14
|
|
|
15
|
-
namespace facebook::react
|
|
15
|
+
namespace facebook::react
|
|
16
|
+
{
|
|
16
17
|
|
|
17
|
-
RNCWebViewProps::RNCWebViewProps(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
RNCWebViewProps::RNCWebViewProps(
|
|
19
|
+
const PropsParserContext &context,
|
|
20
|
+
const RNCWebViewProps &sourceProps,
|
|
21
|
+
const RawProps &rawProps) : ViewProps(context, sourceProps, rawProps),
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
23
|
+
allowFileAccess(convertRawProp(context, rawProps, "allowFileAccess", sourceProps.allowFileAccess, {false})),
|
|
24
|
+
allowsProtectedMedia(convertRawProp(context, rawProps, "allowsProtectedMedia", sourceProps.allowsProtectedMedia, {false})),
|
|
25
|
+
allowsFullscreenVideo(convertRawProp(context, rawProps, "allowsFullscreenVideo", sourceProps.allowsFullscreenVideo, {false})),
|
|
26
|
+
androidLayerType(convertRawProp(context, rawProps, "androidLayerType", sourceProps.androidLayerType, {RNCWebViewAndroidLayerType::None})),
|
|
27
|
+
cacheMode(convertRawProp(context, rawProps, "cacheMode", sourceProps.cacheMode, {RNCWebViewCacheMode::LOAD_DEFAULT})),
|
|
28
|
+
domStorageEnabled(convertRawProp(context, rawProps, "domStorageEnabled", sourceProps.domStorageEnabled, {false})),
|
|
29
|
+
downloadingMessage(convertRawProp(context, rawProps, "downloadingMessage", sourceProps.downloadingMessage, {})),
|
|
30
|
+
forceDarkOn(convertRawProp(context, rawProps, "forceDarkOn", sourceProps.forceDarkOn, {false})),
|
|
31
|
+
geolocationEnabled(convertRawProp(context, rawProps, "geolocationEnabled", sourceProps.geolocationEnabled, {false})),
|
|
32
|
+
lackPermissionToDownloadMessage(convertRawProp(context, rawProps, "lackPermissionToDownloadMessage", sourceProps.lackPermissionToDownloadMessage, {})),
|
|
33
|
+
messagingModuleName(convertRawProp(context, rawProps, "messagingModuleName", sourceProps.messagingModuleName, {})),
|
|
34
|
+
minimumFontSize(convertRawProp(context, rawProps, "minimumFontSize", sourceProps.minimumFontSize, {0})),
|
|
35
|
+
mixedContentMode(convertRawProp(context, rawProps, "mixedContentMode", sourceProps.mixedContentMode, {RNCWebViewMixedContentMode::Never})),
|
|
36
|
+
nestedScrollEnabled(convertRawProp(context, rawProps, "nestedScrollEnabled", sourceProps.nestedScrollEnabled, {false})),
|
|
37
|
+
overScrollMode(convertRawProp(context, rawProps, "overScrollMode", sourceProps.overScrollMode, {})),
|
|
38
|
+
saveFormDataDisabled(convertRawProp(context, rawProps, "saveFormDataDisabled", sourceProps.saveFormDataDisabled, {false})),
|
|
39
|
+
scalesPageToFit(convertRawProp(context, rawProps, "scalesPageToFit", sourceProps.scalesPageToFit, {true})),
|
|
40
|
+
setBuiltInZoomControls(convertRawProp(context, rawProps, "setBuiltInZoomControls", sourceProps.setBuiltInZoomControls, {true})),
|
|
41
|
+
setDisplayZoomControls(convertRawProp(context, rawProps, "setDisplayZoomControls", sourceProps.setDisplayZoomControls, {false})),
|
|
42
|
+
setSupportMultipleWindows(convertRawProp(context, rawProps, "setSupportMultipleWindows", sourceProps.setSupportMultipleWindows, {true})),
|
|
43
|
+
textZoom(convertRawProp(context, rawProps, "textZoom", sourceProps.textZoom, {0})),
|
|
44
|
+
thirdPartyCookiesEnabled(convertRawProp(context, rawProps, "thirdPartyCookiesEnabled", sourceProps.thirdPartyCookiesEnabled, {true})),
|
|
45
|
+
hasOnScroll(convertRawProp(context, rawProps, "hasOnScroll", sourceProps.hasOnScroll, {false})),
|
|
46
|
+
injectedJavaScriptObject(convertRawProp(context, rawProps, "injectedJavaScriptObject", sourceProps.injectedJavaScriptObject, {})),
|
|
47
|
+
paymentRequestEnabled(convertRawProp(context, rawProps, "paymentRequestEnabled", sourceProps.paymentRequestEnabled, {false})),
|
|
48
|
+
allowingReadAccessToURL(convertRawProp(context, rawProps, "allowingReadAccessToURL", sourceProps.allowingReadAccessToURL, {})),
|
|
49
|
+
allowsBackForwardNavigationGestures(convertRawProp(context, rawProps, "allowsBackForwardNavigationGestures", sourceProps.allowsBackForwardNavigationGestures, {false})),
|
|
50
|
+
allowsInlineMediaPlayback(convertRawProp(context, rawProps, "allowsInlineMediaPlayback", sourceProps.allowsInlineMediaPlayback, {false})),
|
|
51
|
+
allowsPictureInPictureMediaPlayback(convertRawProp(context, rawProps, "allowsPictureInPictureMediaPlayback", sourceProps.allowsPictureInPictureMediaPlayback, {false})),
|
|
52
|
+
allowsAirPlayForMediaPlayback(convertRawProp(context, rawProps, "allowsAirPlayForMediaPlayback", sourceProps.allowsAirPlayForMediaPlayback, {false})),
|
|
53
|
+
allowsLinkPreview(convertRawProp(context, rawProps, "allowsLinkPreview", sourceProps.allowsLinkPreview, {true})),
|
|
54
|
+
automaticallyAdjustContentInsets(convertRawProp(context, rawProps, "automaticallyAdjustContentInsets", sourceProps.automaticallyAdjustContentInsets, {true})),
|
|
55
|
+
ignoreSilentHardwareSwitch(convertRawProp(context, rawProps, "ignoreSilentHardwareSwitch", sourceProps.ignoreSilentHardwareSwitch, {false})),
|
|
56
|
+
autoManageStatusBarEnabled(convertRawProp(context, rawProps, "autoManageStatusBarEnabled", sourceProps.autoManageStatusBarEnabled, {true})),
|
|
57
|
+
bounces(convertRawProp(context, rawProps, "bounces", sourceProps.bounces, {true})),
|
|
58
|
+
contentInset(convertRawProp(context, rawProps, "contentInset", sourceProps.contentInset, {})),
|
|
59
|
+
contentInsetAdjustmentBehavior(convertRawProp(context, rawProps, "contentInsetAdjustmentBehavior", sourceProps.contentInsetAdjustmentBehavior, {RNCWebViewContentInsetAdjustmentBehavior::Never})),
|
|
60
|
+
contentMode(convertRawProp(context, rawProps, "contentMode", sourceProps.contentMode, {RNCWebViewContentMode::Recommended})),
|
|
61
|
+
dataDetectorTypes(convertRawProp(context, rawProps, "dataDetectorTypes", RNCWebViewDataDetectorTypesMaskWrapped{.value = sourceProps.dataDetectorTypes}, {static_cast<RNCWebViewDataDetectorTypesMask>(RNCWebViewDataDetectorTypes::PhoneNumber)}).value),
|
|
62
|
+
decelerationRate(convertRawProp(context, rawProps, "decelerationRate", sourceProps.decelerationRate, {0.0})),
|
|
63
|
+
directionalLockEnabled(convertRawProp(context, rawProps, "directionalLockEnabled", sourceProps.directionalLockEnabled, {true})),
|
|
64
|
+
enableApplePay(convertRawProp(context, rawProps, "enableApplePay", sourceProps.enableApplePay, {false})),
|
|
65
|
+
hideKeyboardAccessoryView(convertRawProp(context, rawProps, "hideKeyboardAccessoryView", sourceProps.hideKeyboardAccessoryView, {false})),
|
|
66
|
+
keyboardDisplayRequiresUserAction(convertRawProp(context, rawProps, "keyboardDisplayRequiresUserAction", sourceProps.keyboardDisplayRequiresUserAction, {true})),
|
|
67
|
+
limitsNavigationsToAppBoundDomains(convertRawProp(context, rawProps, "limitsNavigationsToAppBoundDomains", sourceProps.limitsNavigationsToAppBoundDomains, {false})),
|
|
68
|
+
mediaCapturePermissionGrantType(convertRawProp(context, rawProps, "mediaCapturePermissionGrantType", sourceProps.mediaCapturePermissionGrantType, {RNCWebViewMediaCapturePermissionGrantType::Prompt})),
|
|
69
|
+
pagingEnabled(convertRawProp(context, rawProps, "pagingEnabled", sourceProps.pagingEnabled, {false})),
|
|
70
|
+
pullToRefreshEnabled(convertRawProp(context, rawProps, "pullToRefreshEnabled", sourceProps.pullToRefreshEnabled, {false})),
|
|
71
|
+
refreshControlLightMode(convertRawProp(context, rawProps, "refreshControlLightMode", sourceProps.refreshControlLightMode, {false})),
|
|
72
|
+
scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {true})),
|
|
73
|
+
sharedCookiesEnabled(convertRawProp(context, rawProps, "sharedCookiesEnabled", sourceProps.sharedCookiesEnabled, {false})),
|
|
74
|
+
textInteractionEnabled(convertRawProp(context, rawProps, "textInteractionEnabled", sourceProps.textInteractionEnabled, {true})),
|
|
75
|
+
useSharedProcessPool(convertRawProp(context, rawProps, "useSharedProcessPool", sourceProps.useSharedProcessPool, {true})),
|
|
76
|
+
menuItems(convertRawProp(context, rawProps, "menuItems", sourceProps.menuItems, {})),
|
|
77
|
+
suppressMenuItems(convertRawProp(context, rawProps, "suppressMenuItems", sourceProps.suppressMenuItems, {})),
|
|
78
|
+
hasOnFileDownload(convertRawProp(context, rawProps, "hasOnFileDownload", sourceProps.hasOnFileDownload, {false})),
|
|
79
|
+
fraudulentWebsiteWarningEnabled(convertRawProp(context, rawProps, "fraudulentWebsiteWarningEnabled", sourceProps.fraudulentWebsiteWarningEnabled, {true})),
|
|
80
|
+
allowFileAccessFromFileURLs(convertRawProp(context, rawProps, "allowFileAccessFromFileURLs", sourceProps.allowFileAccessFromFileURLs, {false})),
|
|
81
|
+
allowUniversalAccessFromFileURLs(convertRawProp(context, rawProps, "allowUniversalAccessFromFileURLs", sourceProps.allowUniversalAccessFromFileURLs, {false})),
|
|
82
|
+
applicationNameForUserAgent(convertRawProp(context, rawProps, "applicationNameForUserAgent", sourceProps.applicationNameForUserAgent, {})),
|
|
83
|
+
basicAuthCredential(convertRawProp(context, rawProps, "basicAuthCredential", sourceProps.basicAuthCredential, {})),
|
|
84
|
+
cacheEnabled(convertRawProp(context, rawProps, "cacheEnabled", sourceProps.cacheEnabled, {true})),
|
|
85
|
+
incognito(convertRawProp(context, rawProps, "incognito", sourceProps.incognito, {false})),
|
|
86
|
+
hasOnShouldStartLoadWithRequestEvent(convertRawProp(context, rawProps, "hasOnShouldStartLoadWithRequestEvent",
|
|
87
|
+
sourceProps.hasOnShouldStartLoadWithRequestEvent, {false})),
|
|
88
|
+
originWhitelist(convertRawProp(context, rawProps, "originWhitelist", sourceProps.originWhitelist, {})),
|
|
89
|
+
injectedJavaScript(convertRawProp(context, rawProps, "injectedJavaScript", sourceProps.injectedJavaScript, {})),
|
|
90
|
+
injectedJavaScriptBeforeContentLoaded(convertRawProp(context, rawProps, "injectedJavaScriptBeforeContentLoaded", sourceProps.injectedJavaScriptBeforeContentLoaded, {})),
|
|
91
|
+
injectedJavaScriptForMainFrameOnly(convertRawProp(context, rawProps, "injectedJavaScriptForMainFrameOnly", sourceProps.injectedJavaScriptForMainFrameOnly, {true})),
|
|
92
|
+
injectedJavaScriptBeforeContentLoadedForMainFrameOnly(convertRawProp(context, rawProps, "injectedJavaScriptBeforeContentLoadedForMainFrameOnly", sourceProps.injectedJavaScriptBeforeContentLoadedForMainFrameOnly, {true})),
|
|
93
|
+
javaScriptCanOpenWindowsAutomatically(convertRawProp(context, rawProps, "javaScriptCanOpenWindowsAutomatically", sourceProps.javaScriptCanOpenWindowsAutomatically, {false})),
|
|
94
|
+
javaScriptEnabled(convertRawProp(context, rawProps, "javaScriptEnabled", sourceProps.javaScriptEnabled, {true})),
|
|
95
|
+
webviewDebuggingEnabled(convertRawProp(context, rawProps, "webviewDebuggingEnabled", sourceProps.webviewDebuggingEnabled, {false})),
|
|
96
|
+
mediaPlaybackRequiresUserAction(convertRawProp(context, rawProps, "mediaPlaybackRequiresUserAction", sourceProps.mediaPlaybackRequiresUserAction, {true})),
|
|
97
|
+
messagingEnabled(convertRawProp(context, rawProps, "messagingEnabled", sourceProps.messagingEnabled, {false})),
|
|
98
|
+
shouldStartLoadWithRequestEnabled(convertRawProp(context, rawProps, "shouldStartLoadWithRequestEnabled", sourceProps.shouldStartLoadWithRequestEnabled, {false})),
|
|
99
|
+
hasOnOpenWindowEvent(convertRawProp(context, rawProps, "hasOnOpenWindowEvent", sourceProps.hasOnOpenWindowEvent, {false})),
|
|
100
|
+
showsHorizontalScrollIndicator(convertRawProp(context, rawProps, "showsHorizontalScrollIndicator", sourceProps.showsHorizontalScrollIndicator, {true})),
|
|
101
|
+
showsVerticalScrollIndicator(convertRawProp(context, rawProps, "showsVerticalScrollIndicator", sourceProps.showsVerticalScrollIndicator, {true})),
|
|
102
|
+
indicatorStyle(convertRawProp(context, rawProps, "indicatorStyle", sourceProps.indicatorStyle, {RNCWebViewIndicatorStyle::Default})),
|
|
103
|
+
newSource(convertRawProp(context, rawProps, "newSource", sourceProps.newSource, {})),
|
|
104
|
+
userAgent(convertRawProp(context, rawProps, "userAgent", sourceProps.userAgent, {}))
|
|
105
|
+
{
|
|
106
|
+
}
|
|
102
107
|
|
|
103
108
|
} // namespace facebook::react
|
|
@@ -448,6 +448,8 @@ class RNCWebViewProps final : public ViewProps {
|
|
|
448
448
|
int textZoom{0};
|
|
449
449
|
bool thirdPartyCookiesEnabled{true};
|
|
450
450
|
bool hasOnScroll{false};
|
|
451
|
+
bool hasOnShouldStartLoadWithRequestEvent{false};
|
|
452
|
+
folly::dynamic originWhitelist{};
|
|
451
453
|
std::string injectedJavaScriptObject{};
|
|
452
454
|
bool paymentRequestEnabled{false};
|
|
453
455
|
std::string allowingReadAccessToURL{};
|
|
@@ -45,6 +45,7 @@ export interface WebViewProps extends ViewRawProps {
|
|
|
45
45
|
cacheMode: CACHE_MODE
|
|
46
46
|
domStorageEnabled: boolean
|
|
47
47
|
scalesPageToFit: boolean
|
|
48
|
+
hasOnShouldStartLoadWithRequestEvent?: boolean
|
|
48
49
|
messagingModuleName: string
|
|
49
50
|
webviewDebuggingEnabled: boolean
|
|
50
51
|
scrollEnabled: boolean
|
|
@@ -95,6 +95,9 @@ export struct RNCWebView {
|
|
|
95
95
|
private shouldInterceptLoad: boolean = true
|
|
96
96
|
private callLoadTimer: number = -1
|
|
97
97
|
static readonly SHOULD_OVERRIDE_URL_LOADING_TIMEOUT: number = 250
|
|
98
|
+
private debounceTimer: number = -1
|
|
99
|
+
static readonly DEBOUNCE_TIME: number = 100
|
|
100
|
+
private isFirstDebounce: boolean = true
|
|
98
101
|
|
|
99
102
|
aboutToAppear() {
|
|
100
103
|
try {
|
|
@@ -373,9 +376,33 @@ export struct RNCWebView {
|
|
|
373
376
|
}
|
|
374
377
|
return permissionDialogMessage;
|
|
375
378
|
}
|
|
379
|
+
originWhitelistToRegex(originWhitelist: string): string {
|
|
380
|
+
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
|
|
381
|
+
return `^${originWhitelist.replace(matchOperatorsRegex, '\\$&').replace(/\\\*/g, '.*')}`;
|
|
382
|
+
}
|
|
383
|
+
extractOrigin(url: string): string {
|
|
384
|
+
const result = /^[A-Za-z][A-Za-z0-9+\-.]+:(\/\/)?[^/]*/.exec(url);
|
|
385
|
+
return result === null ? '' : result[0];
|
|
386
|
+
};
|
|
387
|
+
passesWhitelist(compiledWhitelist: string[], url: string) {
|
|
388
|
+
const origin = this.extractOrigin(url);
|
|
389
|
+
return compiledWhitelist.some((x) => new RegExp(x).test(origin));
|
|
390
|
+
};
|
|
391
|
+
compileWhitelist(originWhitelist: string[]): string[] {
|
|
392
|
+
return ['about:blank', ...(originWhitelist || [])].map(this.originWhitelistToRegex);
|
|
393
|
+
}
|
|
376
394
|
|
|
377
395
|
onLoadIntercept(event: OnLoadInterceptEvent): boolean {
|
|
378
396
|
Logger.debug(TAG, `onLoadIntercept start`)
|
|
397
|
+
let originWhitelistArr = this.descriptorWrapper.rawProps.originWhitelist;
|
|
398
|
+
let hasOnShouldStartLoadWithRequestEventBool = this.descriptorWrapper.rawProps.hasOnShouldStartLoadWithRequestEvent
|
|
399
|
+
let urlString =
|
|
400
|
+
this.webViewBaseOperate?.verifyURLFormat(event.data.getRequestUrl(), this.source.html, this.source.baseUrl) || "";
|
|
401
|
+
|
|
402
|
+
if (this.passesWhitelist(this.compileWhitelist(originWhitelistArr), urlString) &&
|
|
403
|
+
!hasOnShouldStartLoadWithRequestEventBool) {
|
|
404
|
+
return false
|
|
405
|
+
}
|
|
379
406
|
this.webViewBaseOperate?.setLockIdentifier(BaseOperate.generateLockIdentifier())
|
|
380
407
|
|
|
381
408
|
const params = new ShouldStartParams();
|
|
@@ -613,8 +640,24 @@ export struct RNCWebView {
|
|
|
613
640
|
})
|
|
614
641
|
}
|
|
615
642
|
// this.html = this.source.html
|
|
616
|
-
|
|
617
|
-
|
|
643
|
+
const newWidth = this.descriptorWrapper.layoutMetrics.frame.size.width
|
|
644
|
+
const newHeight = this.descriptorWrapper.layoutMetrics.frame.size.height
|
|
645
|
+
|
|
646
|
+
if (this.debounceTimer !== -1) {
|
|
647
|
+
clearTimeout(this.debounceTimer)
|
|
648
|
+
this.debounceTimer = -1
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if (this.isFirstDebounce) {
|
|
652
|
+
this.webviewWidth = newWidth
|
|
653
|
+
this.webviewHeight = newHeight
|
|
654
|
+
this.isFirstDebounce = false
|
|
655
|
+
} else {
|
|
656
|
+
this.debounceTimer = setTimeout(() => {
|
|
657
|
+
this.webviewWidth = newWidth
|
|
658
|
+
this.webviewHeight = newHeight
|
|
659
|
+
}, RNCWebView.DEBOUNCE_TIME)
|
|
660
|
+
}
|
|
618
661
|
this.scrollEnabled = this.descriptorWrapper.rawProps.scrollEnabled;
|
|
619
662
|
// 当禁止滚动时,使用父组件滚动
|
|
620
663
|
this.nestedScroll = this.scrollEnabled ? NestedScrollMode.SELF_FIRST : NestedScrollMode.PARENT_FIRST;
|
|
@@ -45,6 +45,8 @@ export namespace RNCWebView {
|
|
|
45
45
|
hasOnScroll?: boolean;
|
|
46
46
|
injectedJavaScriptObject?: string;
|
|
47
47
|
paymentRequestEnabled?: boolean;
|
|
48
|
+
hasOnShouldStartLoadWithRequestEvent?:boolean,
|
|
49
|
+
originWhitelist?:readonly string[];
|
|
48
50
|
allowingReadAccessToURL?: string;
|
|
49
51
|
allowsBackForwardNavigationGestures?: boolean;
|
|
50
52
|
allowsInlineMediaPlayback?: boolean;
|
package/harmony/rn_webview.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"Thibault Malbranche <malbranche.thibault@gmail.com>"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "13.15.
|
|
12
|
+
"version": "13.15.2-rc.1",
|
|
13
13
|
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-webview/tree/br_rnoh0.77#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"macos": "react-native run-macos --scheme WebviewExample --project-path example/macos",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@react-native/eslint-config": "0.73.2",
|
|
49
49
|
"@react-native/metro-config": "0.73.5",
|
|
50
50
|
"@react-native/typescript-config": "0.73.1",
|
|
51
|
-
"@react-native-oh/react-native-harmony-cli": "file:./packages/rnoh-react-native-harmony-cli-0.77.18.tgz",
|
|
52
51
|
"@rnx-kit/metro-config": "1.3.15",
|
|
53
52
|
"@semantic-release/git": "7.0.16",
|
|
54
53
|
"@types/invariant": "^2.2.30",
|
|
@@ -246,6 +246,8 @@ export interface NativeProps extends ViewProps {
|
|
|
246
246
|
textInteractionEnabled?: WithDefault<boolean, true>;
|
|
247
247
|
useSharedProcessPool?: WithDefault<boolean, true>;
|
|
248
248
|
onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
|
|
249
|
+
hasOnShouldStartLoadWithRequestEvent?: boolean;
|
|
250
|
+
originWhitelist?:readonly string[];
|
|
249
251
|
onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
|
|
250
252
|
onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
|
|
251
253
|
|
package/src/WebView.harmony.tsx
CHANGED
|
@@ -67,7 +67,7 @@ const WebViewComponent = forwardRef<{}, IOSWebViewProps & { scalesPageToFit: boo
|
|
|
67
67
|
injectedJavaScript,
|
|
68
68
|
injectedJavaScriptBeforeContentLoaded,
|
|
69
69
|
injectedJavaScriptObject,
|
|
70
|
-
menuItems=[],
|
|
70
|
+
menuItems = [],
|
|
71
71
|
injectedJavaScriptForMainFrameOnly = true,
|
|
72
72
|
injectedJavaScriptBeforeContentLoadedForMainFrameOnly = true,
|
|
73
73
|
thirdPartyCookiesEnabled = false,
|
|
@@ -97,15 +97,15 @@ const WebViewComponent = forwardRef<{}, IOSWebViewProps & { scalesPageToFit: boo
|
|
|
97
97
|
allowsInlineMediaPlayback,
|
|
98
98
|
allowsPictureInPictureMediaPlayback,
|
|
99
99
|
allowsAirPlayForMediaPlayback,
|
|
100
|
-
mediaPlaybackRequiresUserAction=true,
|
|
100
|
+
mediaPlaybackRequiresUserAction = true,
|
|
101
101
|
dataDetectorTypes,
|
|
102
102
|
incognito,
|
|
103
103
|
decelerationRate: decelerationRateProp,
|
|
104
104
|
onShouldStartLoadWithRequest: onShouldStartLoadWithRequestProp,
|
|
105
105
|
onStartShouldSetResponder,
|
|
106
106
|
onMoveShouldSetResponderCapture,
|
|
107
|
-
pullToRefreshEnabled=false,
|
|
108
|
-
refreshControlLightMode=false,
|
|
107
|
+
pullToRefreshEnabled = false,
|
|
108
|
+
refreshControlLightMode = false,
|
|
109
109
|
onResponderMove,
|
|
110
110
|
...otherProps
|
|
111
111
|
},
|
|
@@ -310,6 +310,8 @@ const WebViewComponent = forwardRef<{}, IOSWebViewProps & { scalesPageToFit: boo
|
|
|
310
310
|
mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
|
|
311
311
|
menuItems={menuItems}
|
|
312
312
|
newSource={newSource}
|
|
313
|
+
originWhitelist={originWhitelist}
|
|
314
|
+
hasOnShouldStartLoadWithRequestEvent={onShouldStartLoadWithRequestProp !== undefined}
|
|
313
315
|
style={webViewStyles}
|
|
314
316
|
webviewDebuggingEnabled={webviewDebuggingEnabled}
|
|
315
317
|
paymentRequestEnabled={paymentRequestEnabled}
|