@react-native-ohos/react-native-webview 13.10.5-rc.4 → 13.10.5-rc.6
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 +2 -0
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +133 -129
- 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 +47 -4
- package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +6 -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 -1
- package/src/RNCWebViewNativeComponent.ts +2 -0
- package/src/WebView.harmony.tsx +2 -0
package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h
CHANGED
|
@@ -31,6 +31,8 @@ namespace rnoh {
|
|
|
31
31
|
object.setProperty(rt, "injectedJavaScriptBeforeContentLoadedForMainFrameOnly", true);
|
|
32
32
|
object.setProperty(rt, "javaScriptCanOpenWindowsAutomatically", true);
|
|
33
33
|
object.setProperty(rt, "javaScriptEnabled", true);
|
|
34
|
+
object.setProperty(rt, "hasOnShouldStartLoadWithRequestEvent", true);
|
|
35
|
+
object.setProperty(rt, "originWhitelist", true);
|
|
34
36
|
object.setProperty(rt, "webviewDebuggingEnabled", true);
|
|
35
37
|
object.setProperty(rt, "mediaPlaybackRequiresUserAction", true);
|
|
36
38
|
object.setProperty(rt, "messagingEnabled", true);
|
|
@@ -16,136 +16,140 @@
|
|
|
16
16
|
namespace facebook {
|
|
17
17
|
namespace react {
|
|
18
18
|
|
|
19
|
-
RNCWebViewProps::RNCWebViewProps(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
19
|
+
RNCWebViewProps::RNCWebViewProps(const PropsParserContext &context, const RNCWebViewProps &sourceProps,
|
|
20
|
+
const RawProps &rawProps)
|
|
21
|
+
: ViewProps(context, sourceProps, rawProps),
|
|
23
22
|
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
23
|
+
allowFileAccess(convertRawProp(context, rawProps, "allowFileAccess", sourceProps.allowFileAccess, {false})),
|
|
24
|
+
allowsProtectedMedia(
|
|
25
|
+
convertRawProp(context, rawProps, "allowsProtectedMedia", sourceProps.allowsProtectedMedia, {false})),
|
|
26
|
+
allowsFullscreenVideo(
|
|
27
|
+
convertRawProp(context, rawProps, "allowsFullscreenVideo", sourceProps.allowsFullscreenVideo, {false})),
|
|
28
|
+
androidLayerType(convertRawProp(context, rawProps, "androidLayerType", sourceProps.androidLayerType,
|
|
29
|
+
{RNCWebViewAndroidLayerType::None})),
|
|
30
|
+
cacheMode(
|
|
31
|
+
convertRawProp(context, rawProps, "cacheMode", sourceProps.cacheMode, {RNCWebViewCacheMode::LOAD_DEFAULT})),
|
|
32
|
+
domStorageEnabled(convertRawProp(context, rawProps, "domStorageEnabled", sourceProps.domStorageEnabled, {false})),
|
|
33
|
+
downloadingMessage(convertRawProp(context, rawProps, "downloadingMessage", sourceProps.downloadingMessage, {})),
|
|
34
|
+
forceDarkOn(convertRawProp(context, rawProps, "forceDarkOn", sourceProps.forceDarkOn, {false})),
|
|
35
|
+
geolocationEnabled(
|
|
36
|
+
convertRawProp(context, rawProps, "geolocationEnabled", sourceProps.geolocationEnabled, {false})),
|
|
37
|
+
lackPermissionToDownloadMessage(convertRawProp(context, rawProps, "lackPermissionToDownloadMessage",
|
|
38
|
+
sourceProps.lackPermissionToDownloadMessage, {})),
|
|
39
|
+
messagingModuleName(
|
|
40
|
+
convertRawProp(context, rawProps, "messagingModuleName", sourceProps.messagingModuleName, {})),
|
|
41
|
+
minimumFontSize(convertRawProp(context, rawProps, "minimumFontSize", sourceProps.minimumFontSize, {0})),
|
|
42
|
+
mixedContentMode(convertRawProp(context, rawProps, "mixedContentMode", sourceProps.mixedContentMode,
|
|
43
|
+
{RNCWebViewMixedContentMode::Never})),
|
|
44
|
+
nestedScrollEnabled(
|
|
45
|
+
convertRawProp(context, rawProps, "nestedScrollEnabled", sourceProps.nestedScrollEnabled, {false})),
|
|
46
|
+
overScrollMode(convertRawProp(context, rawProps, "overScrollMode", sourceProps.overScrollMode, {})),
|
|
47
|
+
saveFormDataDisabled(
|
|
48
|
+
convertRawProp(context, rawProps, "saveFormDataDisabled", sourceProps.saveFormDataDisabled, {false})),
|
|
49
|
+
scalesPageToFit(convertRawProp(context, rawProps, "scalesPageToFit", sourceProps.scalesPageToFit, {false})),
|
|
50
|
+
setBuiltInZoomControls(
|
|
51
|
+
convertRawProp(context, rawProps, "setBuiltInZoomControls", sourceProps.setBuiltInZoomControls, {false})),
|
|
52
|
+
setDisplayZoomControls(
|
|
53
|
+
convertRawProp(context, rawProps, "setDisplayZoomControls", sourceProps.setDisplayZoomControls, {false})),
|
|
54
|
+
setSupportMultipleWindows(convertRawProp(context, rawProps, "setSupportMultipleWindows",
|
|
55
|
+
sourceProps.setSupportMultipleWindows, {false})),
|
|
56
|
+
textZoom(convertRawProp(context, rawProps, "textZoom", sourceProps.textZoom, {0})),
|
|
57
|
+
thirdPartyCookiesEnabled(
|
|
58
|
+
convertRawProp(context, rawProps, "thirdPartyCookiesEnabled", sourceProps.thirdPartyCookiesEnabled, {false})),
|
|
59
|
+
hasOnScroll(convertRawProp(context, rawProps, "hasOnScroll", sourceProps.hasOnScroll, {false})),
|
|
60
|
+
injectedJavaScriptObject(
|
|
61
|
+
convertRawProp(context, rawProps, "injectedJavaScriptObject", sourceProps.injectedJavaScriptObject, {})),
|
|
62
|
+
allowingReadAccessToURL(
|
|
63
|
+
convertRawProp(context, rawProps, "allowingReadAccessToURL", sourceProps.allowingReadAccessToURL, {})),
|
|
64
|
+
allowsBackForwardNavigationGestures(convertRawProp(context, rawProps, "allowsBackForwardNavigationGestures",
|
|
65
|
+
sourceProps.allowsBackForwardNavigationGestures, {false})),
|
|
66
|
+
allowsInlineMediaPlayback(convertRawProp(context, rawProps, "allowsInlineMediaPlayback",
|
|
67
|
+
sourceProps.allowsInlineMediaPlayback, {false})),
|
|
68
|
+
allowsAirPlayForMediaPlayback(convertRawProp(context, rawProps, "allowsAirPlayForMediaPlayback",
|
|
69
|
+
sourceProps.allowsAirPlayForMediaPlayback, {false})),
|
|
70
|
+
allowsLinkPreview(convertRawProp(context, rawProps, "allowsLinkPreview", sourceProps.allowsLinkPreview, {false})),
|
|
71
|
+
automaticallyAdjustContentInsets(convertRawProp(context, rawProps, "automaticallyAdjustContentInsets",
|
|
72
|
+
sourceProps.automaticallyAdjustContentInsets, {false})),
|
|
73
|
+
ignoreSilentHardwareSwitch(convertRawProp(context, rawProps, "ignoreSilentHardwareSwitch",
|
|
74
|
+
sourceProps.ignoreSilentHardwareSwitch, {false})),
|
|
75
|
+
autoManageStatusBarEnabled(convertRawProp(context, rawProps, "autoManageStatusBarEnabled",
|
|
76
|
+
sourceProps.autoManageStatusBarEnabled, {false})),
|
|
77
|
+
bounces(convertRawProp(context, rawProps, "bounces", sourceProps.bounces, {false})),
|
|
78
|
+
contentInset(convertRawProp(context, rawProps, "contentInset", sourceProps.contentInset, {})),
|
|
79
|
+
contentInsetAdjustmentBehavior(convertRawProp(context, rawProps, "contentInsetAdjustmentBehavior",
|
|
80
|
+
sourceProps.contentInsetAdjustmentBehavior,
|
|
81
|
+
{RNCWebViewContentInsetAdjustmentBehavior::Never})),
|
|
82
|
+
contentMode(convertRawProp(context, rawProps, "contentMode", sourceProps.contentMode,
|
|
83
|
+
{RNCWebViewContentMode::Recommended})),
|
|
84
|
+
dataDetectorTypes(convertRawProp(context, rawProps, "dataDetectorTypes", sourceProps.dataDetectorTypes, {})),
|
|
85
|
+
decelerationRate(convertRawProp(context, rawProps, "decelerationRate", sourceProps.decelerationRate, {0.0})),
|
|
86
|
+
directionalLockEnabled(
|
|
87
|
+
convertRawProp(context, rawProps, "directionalLockEnabled", sourceProps.directionalLockEnabled, {false})),
|
|
88
|
+
enableApplePay(convertRawProp(context, rawProps, "enableApplePay", sourceProps.enableApplePay, {false})),
|
|
89
|
+
hideKeyboardAccessoryView(convertRawProp(context, rawProps, "hideKeyboardAccessoryView",
|
|
90
|
+
sourceProps.hideKeyboardAccessoryView, {false})),
|
|
91
|
+
keyboardDisplayRequiresUserAction(convertRawProp(context, rawProps, "keyboardDisplayRequiresUserAction",
|
|
92
|
+
sourceProps.keyboardDisplayRequiresUserAction, {false})),
|
|
93
|
+
limitsNavigationsToAppBoundDomains(convertRawProp(context, rawProps, "limitsNavigationsToAppBoundDomains",
|
|
94
|
+
sourceProps.limitsNavigationsToAppBoundDomains, {false})),
|
|
95
|
+
mediaCapturePermissionGrantType(convertRawProp(context, rawProps, "mediaCapturePermissionGrantType",
|
|
96
|
+
sourceProps.mediaCapturePermissionGrantType,
|
|
97
|
+
{RNCWebViewMediaCapturePermissionGrantType::Prompt})),
|
|
98
|
+
pagingEnabled(convertRawProp(context, rawProps, "pagingEnabled", sourceProps.pagingEnabled, {false})),
|
|
99
|
+
pullToRefreshEnabled(
|
|
100
|
+
convertRawProp(context, rawProps, "pullToRefreshEnabled", sourceProps.pullToRefreshEnabled, {false})),
|
|
101
|
+
scrollEnabled(convertRawProp(context, rawProps, "scrollEnabled", sourceProps.scrollEnabled, {false})),
|
|
102
|
+
hasOnShouldStartLoadWithRequestEvent(convertRawProp(context, rawProps, "hasOnShouldStartLoadWithRequestEvent",
|
|
103
|
+
sourceProps.hasOnShouldStartLoadWithRequestEvent, {false})),
|
|
104
|
+
originWhitelist(convertRawProp(context, rawProps, "originWhitelist", sourceProps.originWhitelist, {})),
|
|
105
|
+
sharedCookiesEnabled(
|
|
106
|
+
convertRawProp(context, rawProps, "sharedCookiesEnabled", sourceProps.sharedCookiesEnabled, {false})),
|
|
107
|
+
textInteractionEnabled(
|
|
108
|
+
convertRawProp(context, rawProps, "textInteractionEnabled", sourceProps.textInteractionEnabled, {false})),
|
|
109
|
+
useSharedProcessPool(
|
|
110
|
+
convertRawProp(context, rawProps, "useSharedProcessPool", sourceProps.useSharedProcessPool, {false})),
|
|
111
|
+
menuItems(convertRawProp(context, rawProps, "menuItems", sourceProps.menuItems, {})),
|
|
112
|
+
suppressMenuItems(convertRawProp(context, rawProps, "suppressMenuItems", sourceProps.suppressMenuItems, {})),
|
|
113
|
+
hasOnFileDownload(convertRawProp(context, rawProps, "hasOnFileDownload", sourceProps.hasOnFileDownload, {false})),
|
|
114
|
+
fraudulentWebsiteWarningEnabled(convertRawProp(context, rawProps, "fraudulentWebsiteWarningEnabled",
|
|
115
|
+
sourceProps.fraudulentWebsiteWarningEnabled, {false})),
|
|
116
|
+
allowFileAccessFromFileURLs(convertRawProp(context, rawProps, "allowFileAccessFromFileURLs",
|
|
117
|
+
sourceProps.allowFileAccessFromFileURLs, {false})),
|
|
118
|
+
allowUniversalAccessFromFileURLs(convertRawProp(context, rawProps, "allowUniversalAccessFromFileURLs",
|
|
119
|
+
sourceProps.allowUniversalAccessFromFileURLs, {false})),
|
|
120
|
+
applicationNameForUserAgent(convertRawProp(context, rawProps, "applicationNameForUserAgent",
|
|
121
|
+
sourceProps.applicationNameForUserAgent, {})),
|
|
122
|
+
basicAuthCredential(
|
|
123
|
+
convertRawProp(context, rawProps, "basicAuthCredential", sourceProps.basicAuthCredential, {})),
|
|
124
|
+
cacheEnabled(convertRawProp(context, rawProps, "cacheEnabled", sourceProps.cacheEnabled, {false})),
|
|
125
|
+
incognito(convertRawProp(context, rawProps, "incognito", sourceProps.incognito, {false})),
|
|
126
|
+
injectedJavaScript(convertRawProp(context, rawProps, "injectedJavaScript", sourceProps.injectedJavaScript, {})),
|
|
127
|
+
injectedJavaScriptBeforeContentLoaded(convertRawProp(context, rawProps, "injectedJavaScriptBeforeContentLoaded",
|
|
128
|
+
sourceProps.injectedJavaScriptBeforeContentLoaded, {})),
|
|
129
|
+
injectedJavaScriptForMainFrameOnly(convertRawProp(context, rawProps, "injectedJavaScriptForMainFrameOnly",
|
|
130
|
+
sourceProps.injectedJavaScriptForMainFrameOnly, {false})),
|
|
131
|
+
injectedJavaScriptBeforeContentLoadedForMainFrameOnly(
|
|
132
|
+
convertRawProp(context, rawProps, "injectedJavaScriptBeforeContentLoadedForMainFrameOnly",
|
|
133
|
+
sourceProps.injectedJavaScriptBeforeContentLoadedForMainFrameOnly, {false})),
|
|
134
|
+
javaScriptCanOpenWindowsAutomatically(convertRawProp(context, rawProps, "javaScriptCanOpenWindowsAutomatically",
|
|
135
|
+
sourceProps.javaScriptCanOpenWindowsAutomatically, {false})),
|
|
136
|
+
javaScriptEnabled(convertRawProp(context, rawProps, "javaScriptEnabled", sourceProps.javaScriptEnabled, {false})),
|
|
137
|
+
webviewDebuggingEnabled(
|
|
138
|
+
convertRawProp(context, rawProps, "webviewDebuggingEnabled", sourceProps.webviewDebuggingEnabled, {false})),
|
|
139
|
+
mediaPlaybackRequiresUserAction(convertRawProp(context, rawProps, "mediaPlaybackRequiresUserAction",
|
|
140
|
+
sourceProps.mediaPlaybackRequiresUserAction, {false})),
|
|
141
|
+
messagingEnabled(convertRawProp(context, rawProps, "messagingEnabled", sourceProps.messagingEnabled, {false})),
|
|
142
|
+
shouldStartLoadWithRequestEnabled(convertRawProp(context, rawProps, "shouldStartLoadWithRequestEnabled",
|
|
143
|
+
sourceProps.shouldStartLoadWithRequestEnabled, {false})),
|
|
144
|
+
hasOnOpenWindowEvent(
|
|
145
|
+
convertRawProp(context, rawProps, "hasOnOpenWindowEvent", sourceProps.hasOnOpenWindowEvent, {false})),
|
|
146
|
+
showsHorizontalScrollIndicator(convertRawProp(context, rawProps, "showsHorizontalScrollIndicator",
|
|
147
|
+
sourceProps.showsHorizontalScrollIndicator, {false})),
|
|
148
|
+
showsVerticalScrollIndicator(convertRawProp(context, rawProps, "showsVerticalScrollIndicator",
|
|
149
|
+
sourceProps.showsVerticalScrollIndicator, {false})),
|
|
150
|
+
newSource(convertRawProp(context, rawProps, "newSource", sourceProps.newSource, {})),
|
|
151
|
+
userAgent(convertRawProp(context, rawProps, "userAgent", sourceProps.userAgent, {})),
|
|
152
|
+
schemeList(convertRawProp(context, rawProps, "schemeList", sourceProps.schemeList, {})) {}
|
|
149
153
|
|
|
150
154
|
} // namespace react
|
|
151
155
|
} // namespace facebook
|
|
@@ -321,6 +321,8 @@ namespace facebook {
|
|
|
321
321
|
bool injectedJavaScriptBeforeContentLoadedForMainFrameOnly{false};
|
|
322
322
|
bool javaScriptCanOpenWindowsAutomatically{false};
|
|
323
323
|
bool javaScriptEnabled{false};
|
|
324
|
+
bool hasOnShouldStartLoadWithRequestEvent{false};
|
|
325
|
+
folly::dynamic originWhitelist{};
|
|
324
326
|
bool webviewDebuggingEnabled{false};
|
|
325
327
|
bool mediaPlaybackRequiresUserAction{false};
|
|
326
328
|
bool messagingEnabled{false};
|
|
@@ -71,6 +71,7 @@ export interface WebViewProps extends ViewRawProps {
|
|
|
71
71
|
incognito: boolean
|
|
72
72
|
userAgent: string
|
|
73
73
|
shouldStartLoadWithRequestEnabled: boolean
|
|
74
|
+
hasOnShouldStartLoadWithRequestEvent?: boolean
|
|
74
75
|
originWhitelist: Array<string>
|
|
75
76
|
thirdPartyCookiesEnabled: boolean
|
|
76
77
|
fraudulentWebsiteWarningEnabled: boolean
|
|
@@ -59,6 +59,7 @@ export const WEB_VIEW = "RNCWebView"
|
|
|
59
59
|
@Sendable
|
|
60
60
|
class WorkerRunnable implements WorkerTaskRunnable<ShouldStartParams> {
|
|
61
61
|
run(rnInstance: AnyThreadRNInstance, params: ShouldStartParams): void {
|
|
62
|
+
params.lockState = ShouldOverrideCallbackState.UNDECIDED
|
|
62
63
|
rnInstance.getTurboModule<WebViewTurboModule>(TM.RNCWebViewModule.NAME).setShouldStartParams(params)
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -113,6 +114,9 @@ export struct RNCWebView {
|
|
|
113
114
|
private shouldInterceptLoad: boolean = true
|
|
114
115
|
private callLoadTimer: number = -1
|
|
115
116
|
static readonly SHOULD_OVERRIDE_URL_LOADING_TIMEOUT: number = 250
|
|
117
|
+
private debounceTimer: number = -1
|
|
118
|
+
static readonly DEBOUNCE_TIME: number = 100
|
|
119
|
+
private isFirstDebounce: boolean = true
|
|
116
120
|
|
|
117
121
|
aboutToAppear() {
|
|
118
122
|
try {
|
|
@@ -403,9 +407,32 @@ export struct RNCWebView {
|
|
|
403
407
|
}
|
|
404
408
|
return permissionDialogMessage;
|
|
405
409
|
}
|
|
406
|
-
|
|
410
|
+
originWhitelistToRegex(originWhitelist: string): string {
|
|
411
|
+
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
|
|
412
|
+
return `^${originWhitelist.replace(matchOperatorsRegex, '\\$&').replace(/\\\*/g, '.*')}`;
|
|
413
|
+
}
|
|
414
|
+
extractOrigin(url: string): string {
|
|
415
|
+
const result = /^[A-Za-z][A-Za-z0-9+\-.]+:(\/\/)?[^/]*/.exec(url);
|
|
416
|
+
return result === null ? '' : result[0];
|
|
417
|
+
};
|
|
418
|
+
passesWhitelist(compiledWhitelist: string[], url: string) {
|
|
419
|
+
const origin = this.extractOrigin(url);
|
|
420
|
+
return compiledWhitelist.some((x) => new RegExp(x).test(origin));
|
|
421
|
+
};
|
|
422
|
+
compileWhitelist(originWhitelist: string[]): string[] {
|
|
423
|
+
return ['about:blank', ...(originWhitelist || [])].map(this.originWhitelistToRegex);
|
|
424
|
+
}
|
|
407
425
|
onLoadIntercept(event: OnLoadInterceptEvent): boolean {
|
|
408
426
|
Logger.debug(TAG, `onLoadIntercept start`)
|
|
427
|
+
let originWhitelistArr = this.descriptorWrapper.rawProps.originWhitelist;
|
|
428
|
+
let hasOnShouldStartLoadWithRequestEventBool = this.descriptorWrapper.rawProps.hasOnShouldStartLoadWithRequestEvent
|
|
429
|
+
let urlString =
|
|
430
|
+
this.webViewBaseOperate?.verifyURLFormat(event.data.getRequestUrl(), this.source.html, this.source.baseUrl) || "";
|
|
431
|
+
|
|
432
|
+
if (this.passesWhitelist(this.compileWhitelist(originWhitelistArr), urlString) &&
|
|
433
|
+
!hasOnShouldStartLoadWithRequestEventBool) {
|
|
434
|
+
return false
|
|
435
|
+
}
|
|
409
436
|
this.webViewBaseOperate?.setLockIdentifier(BaseOperate.generateLockIdentifier())
|
|
410
437
|
|
|
411
438
|
const params = new ShouldStartParams();
|
|
@@ -642,9 +669,25 @@ export struct RNCWebView {
|
|
|
642
669
|
}
|
|
643
670
|
})
|
|
644
671
|
}
|
|
645
|
-
//
|
|
646
|
-
|
|
647
|
-
|
|
672
|
+
// 防抖处理webview尺寸设置
|
|
673
|
+
const newWidth = this.descriptorWrapper.layoutMetrics.frame.size.width
|
|
674
|
+
const newHeight = this.descriptorWrapper.layoutMetrics.frame.size.height
|
|
675
|
+
|
|
676
|
+
if (this.debounceTimer !== -1) {
|
|
677
|
+
clearTimeout(this.debounceTimer)
|
|
678
|
+
this.debounceTimer = -1
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (this.isFirstDebounce) {
|
|
682
|
+
this.webviewWidth = newWidth
|
|
683
|
+
this.webviewHeight = newHeight
|
|
684
|
+
this.isFirstDebounce = false // 标记为非首次
|
|
685
|
+
} else {
|
|
686
|
+
this.debounceTimer = setTimeout(() => {
|
|
687
|
+
this.webviewWidth = newWidth
|
|
688
|
+
this.webviewHeight = newHeight
|
|
689
|
+
}, RNCWebView.DEBOUNCE_TIME)
|
|
690
|
+
}
|
|
648
691
|
this.scrollEnabled = this.descriptorWrapper.rawProps.scrollEnabled;
|
|
649
692
|
// 当禁止滚动时,使用父组件滚动
|
|
650
693
|
this.nestedScroll = this.scrollEnabled ? NestedScrollMode.SELF_FIRST : NestedScrollMode.PARENT_FIRST;
|
|
@@ -56,7 +56,7 @@ export class WebViewTurboModule extends AnyThreadTurboModule implements TM.RNCWe
|
|
|
56
56
|
// 锁状态
|
|
57
57
|
export enum ShouldOverrideCallbackState {
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* 等待返回状态
|
|
60
60
|
*/
|
|
61
61
|
UNDECIDED,
|
|
62
62
|
/**
|
|
@@ -67,6 +67,10 @@ export enum ShouldOverrideCallbackState {
|
|
|
67
67
|
* 允许加载
|
|
68
68
|
*/
|
|
69
69
|
ALLOW_LOADING,
|
|
70
|
+
/**
|
|
71
|
+
* 允许加载
|
|
72
|
+
*/
|
|
73
|
+
DEFAULT,
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
@Sendable
|
|
@@ -74,5 +78,5 @@ export class ShouldStartParams {
|
|
|
74
78
|
shouldStart: boolean = true
|
|
75
79
|
lockIdentifier: number = -1
|
|
76
80
|
// 对应ShouldOverrideCallbackState
|
|
77
|
-
lockState: number =
|
|
81
|
+
lockState: number = ShouldOverrideCallbackState.DEFAULT
|
|
78
82
|
}
|
|
@@ -86,6 +86,8 @@ export namespace RNCWebView {
|
|
|
86
86
|
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
|
|
87
87
|
javaScriptCanOpenWindowsAutomatically?: boolean;
|
|
88
88
|
javaScriptEnabled?: boolean;
|
|
89
|
+
hasOnShouldStartLoadWithRequestEvent?:boolean,
|
|
90
|
+
originWhitelist?:readonly string[];
|
|
89
91
|
webviewDebuggingEnabled?: boolean;
|
|
90
92
|
mediaPlaybackRequiresUserAction?: boolean;
|
|
91
93
|
messagingEnabled: 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.10.5-rc.
|
|
12
|
+
"version": "13.10.5-rc.6",
|
|
13
13
|
"homepage": "https://github.com/react-native-oh-library/react-native-webview#readme",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"macos": "react-native run-macos --scheme WebviewExample --project-path example/macos",
|
|
@@ -246,6 +246,8 @@ export interface NativeProps extends ViewProps {
|
|
|
246
246
|
hasOnOpenWindowEvent?: boolean;
|
|
247
247
|
onScroll?: DirectEventHandler<ScrollEvent>;
|
|
248
248
|
onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
|
|
249
|
+
hasOnShouldStartLoadWithRequestEvent?: boolean;
|
|
250
|
+
originWhitelist?:readonly string[];
|
|
249
251
|
showsHorizontalScrollIndicator?: boolean;
|
|
250
252
|
showsVerticalScrollIndicator?: boolean;
|
|
251
253
|
newSource: UnsafeMixed<Readonly<{
|
package/src/WebView.harmony.tsx
CHANGED
|
@@ -275,6 +275,8 @@ const WebViewComponent = forwardRef<{}, IOSWebViewProps & { scalesPageToFit: boo
|
|
|
275
275
|
onOpenWindow={onOpenWindowProp && onOpenWindow}
|
|
276
276
|
hasOnOpenWindowEvent={onOpenWindowProp !== undefined}
|
|
277
277
|
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
278
|
+
originWhitelist={originWhitelist}
|
|
279
|
+
hasOnShouldStartLoadWithRequestEvent={onShouldStartLoadWithRequestProp !== undefined}
|
|
278
280
|
onContentProcessDidTerminate={onContentProcessDidTerminate}
|
|
279
281
|
thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
|
|
280
282
|
pullToRefreshEnabled={pullToRefreshEnabled}
|