@react-native-ohos/react-native-webview 13.15.1-rc.1 → 13.15.1-rc.3
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 +20 -20
- package/README.OpenSource +10 -10
- package/README.md +12 -12
- package/harmony/rn_webview/OAT.xml +44 -44
- package/harmony/rn_webview/build-profile.json5 +28 -28
- package/harmony/rn_webview/index.ets +12 -12
- package/harmony/rn_webview/oh-package.json5 +13 -13
- package/harmony/rn_webview/src/main/cpp/CMakeLists.txt +9 -9
- package/harmony/rn_webview/src/main/cpp/WebViewPackage.h +16 -16
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/BaseReactNativeWebviewPackage.h +95 -95
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +119 -119
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.cpp +18 -18
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.h +16 -16
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.cpp +17 -17
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.h +16 -16
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ComponentDescriptors.h +24 -24
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.cpp +241 -241
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.h +263 -263
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +103 -103
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +509 -509
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.cpp +17 -17
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.h +32 -32
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.cpp +16 -16
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.h +28 -28
- package/harmony/rn_webview/src/main/ets/CutomReference.ts +29 -29
- package/harmony/rn_webview/src/main/ets/Logger.ts +43 -43
- package/harmony/rn_webview/src/main/ets/Magic.ets +184 -184
- package/harmony/rn_webview/src/main/ets/RNCWebView.ets +570 -570
- package/harmony/rn_webview/src/main/ets/RNCWebViewPackage.ets +37 -37
- package/harmony/rn_webview/src/main/ets/ShouldRequestUrl.ts +47 -47
- package/harmony/rn_webview/src/main/ets/WebViewBaseOperate.ets +457 -443
- package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +57 -57
- package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +524 -524
- package/harmony/rn_webview/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/rn_webview/src/main/ets/generated/index.ets +5 -5
- package/harmony/rn_webview/src/main/ets/generated/ts.ts +6 -6
- package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebView.ts +18 -18
- package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebViewModule.ts +16 -16
- package/harmony/rn_webview/src/main/ets/generated/turboModules/ts.ts +6 -6
- package/harmony/rn_webview/src/main/module.json5 +10 -10
- package/harmony/rn_webview/src/main/resources/base/element/string.json +39 -39
- package/harmony/rn_webview/src/main/resources/en_US/element/string.json +39 -39
- package/harmony/rn_webview/src/main/resources/zh_CN/element/string.json +39 -39
- package/harmony/rn_webview/src/test/List.test.ets +4 -4
- package/harmony/rn_webview/src/test/LocalUnit.test.ets +32 -32
- package/harmony/rn_webview/ts.ets +8 -8
- package/harmony/rn_webview.har +0 -0
- package/package.json +99 -99
- package/src/NativeRNCWebView.ts +21 -21
- package/src/NativeRNCWebViewModule.ts +19 -19
- package/src/RNCWebViewNativeComponent.ts +354 -354
- package/src/WebView.harmony.tsx +342 -342
- package/src/WebView.tsx +10 -10
- package/src/codegenUtils.ts +10 -10
- package/src/index.ts +10 -10
- package/harmony/rn_webview/BuildProfile.ets +0 -17
|
@@ -1,354 +1,354 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
-
* Use of this source code is governed by a MIT license that can be
|
|
4
|
-
* found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { HostComponent, ViewProps } from 'react-native';
|
|
8
|
-
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
9
|
-
import {
|
|
10
|
-
DirectEventHandler,
|
|
11
|
-
Double,
|
|
12
|
-
Int32,
|
|
13
|
-
WithDefault,
|
|
14
|
-
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
15
|
-
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
16
|
-
|
|
17
|
-
export type WebViewNativeEvent = Readonly<{
|
|
18
|
-
url: string;
|
|
19
|
-
loading: boolean;
|
|
20
|
-
title: string;
|
|
21
|
-
canGoBack: boolean;
|
|
22
|
-
canGoForward: boolean;
|
|
23
|
-
lockIdentifier: Double;
|
|
24
|
-
}>;
|
|
25
|
-
export type WebViewCustomMenuSelectionEvent = Readonly<{
|
|
26
|
-
label: string;
|
|
27
|
-
key: string;
|
|
28
|
-
selectedText: string;
|
|
29
|
-
}>;
|
|
30
|
-
export type WebViewMessageEvent = Readonly<{
|
|
31
|
-
url: string;
|
|
32
|
-
loading: boolean;
|
|
33
|
-
title: string;
|
|
34
|
-
canGoBack: boolean;
|
|
35
|
-
canGoForward: boolean;
|
|
36
|
-
lockIdentifier: Double;
|
|
37
|
-
data: string;
|
|
38
|
-
}>;
|
|
39
|
-
export type WebViewOpenWindowEvent = Readonly<{
|
|
40
|
-
targetUrl: string;
|
|
41
|
-
}>;
|
|
42
|
-
export type WebViewHttpErrorEvent = Readonly<{
|
|
43
|
-
url: string;
|
|
44
|
-
loading: boolean;
|
|
45
|
-
title: string;
|
|
46
|
-
canGoBack: boolean;
|
|
47
|
-
canGoForward: boolean;
|
|
48
|
-
lockIdentifier: Double;
|
|
49
|
-
description: string;
|
|
50
|
-
statusCode: Int32;
|
|
51
|
-
}>;
|
|
52
|
-
|
|
53
|
-
export type WebViewErrorEvent = Readonly<{
|
|
54
|
-
url: string;
|
|
55
|
-
loading: boolean;
|
|
56
|
-
title: string;
|
|
57
|
-
canGoBack: boolean;
|
|
58
|
-
canGoForward: boolean;
|
|
59
|
-
lockIdentifier: Double;
|
|
60
|
-
domain?: string;
|
|
61
|
-
code: Int32;
|
|
62
|
-
description: string;
|
|
63
|
-
}>;
|
|
64
|
-
|
|
65
|
-
export type WebViewNativeProgressEvent = Readonly<{
|
|
66
|
-
url: string;
|
|
67
|
-
loading: boolean;
|
|
68
|
-
title: string;
|
|
69
|
-
canGoBack: boolean;
|
|
70
|
-
canGoForward: boolean;
|
|
71
|
-
lockIdentifier: Double;
|
|
72
|
-
progress: Double;
|
|
73
|
-
}>;
|
|
74
|
-
|
|
75
|
-
export type WebViewNavigationEvent = Readonly<{
|
|
76
|
-
url: string;
|
|
77
|
-
loading: boolean;
|
|
78
|
-
title: string;
|
|
79
|
-
canGoBack: boolean;
|
|
80
|
-
canGoForward: boolean;
|
|
81
|
-
lockIdentifier: Double;
|
|
82
|
-
navigationType:
|
|
83
|
-
| 'click'
|
|
84
|
-
| 'formsubmit'
|
|
85
|
-
| 'backforward'
|
|
86
|
-
| 'reload'
|
|
87
|
-
| 'formresubmit'
|
|
88
|
-
| 'other';
|
|
89
|
-
mainDocumentURL?: string;
|
|
90
|
-
}>;
|
|
91
|
-
|
|
92
|
-
export type ShouldStartLoadRequestEvent = Readonly<{
|
|
93
|
-
url: string;
|
|
94
|
-
loading: boolean;
|
|
95
|
-
title: string;
|
|
96
|
-
canGoBack: boolean;
|
|
97
|
-
canGoForward: boolean;
|
|
98
|
-
lockIdentifier: Double;
|
|
99
|
-
navigationType:
|
|
100
|
-
| 'click'
|
|
101
|
-
| 'formsubmit'
|
|
102
|
-
| 'backforward'
|
|
103
|
-
| 'reload'
|
|
104
|
-
| 'formresubmit'
|
|
105
|
-
| 'other';
|
|
106
|
-
mainDocumentURL?: string;
|
|
107
|
-
isTopFrame: boolean;
|
|
108
|
-
}>;
|
|
109
|
-
|
|
110
|
-
type ScrollEvent = Readonly<{
|
|
111
|
-
contentInset: {
|
|
112
|
-
bottom: Double;
|
|
113
|
-
left: Double;
|
|
114
|
-
right: Double;
|
|
115
|
-
top: Double;
|
|
116
|
-
};
|
|
117
|
-
contentOffset: {
|
|
118
|
-
y: Double;
|
|
119
|
-
x: Double;
|
|
120
|
-
};
|
|
121
|
-
contentSize: {
|
|
122
|
-
height: Double;
|
|
123
|
-
width: Double;
|
|
124
|
-
};
|
|
125
|
-
layoutMeasurement: {
|
|
126
|
-
height: Double;
|
|
127
|
-
width: Double;
|
|
128
|
-
};
|
|
129
|
-
targetContentOffset?: {
|
|
130
|
-
y: Double;
|
|
131
|
-
x: Double;
|
|
132
|
-
};
|
|
133
|
-
velocity?: {
|
|
134
|
-
y: Double;
|
|
135
|
-
x: Double;
|
|
136
|
-
};
|
|
137
|
-
zoomScale?: Double;
|
|
138
|
-
responderIgnoreScroll?: boolean;
|
|
139
|
-
}>;
|
|
140
|
-
|
|
141
|
-
type WebViewRenderProcessGoneEvent = Readonly<{
|
|
142
|
-
didCrash: boolean;
|
|
143
|
-
}>;
|
|
144
|
-
|
|
145
|
-
type WebViewDownloadEvent = Readonly<{
|
|
146
|
-
downloadUrl: string;
|
|
147
|
-
}>;
|
|
148
|
-
|
|
149
|
-
// type MenuItem = Readonly<{label: string, key: string}>;
|
|
150
|
-
|
|
151
|
-
export interface NativeProps extends ViewProps {
|
|
152
|
-
// Android only
|
|
153
|
-
allowFileAccess?: boolean;
|
|
154
|
-
allowsProtectedMedia?: boolean;
|
|
155
|
-
allowsFullscreenVideo?: boolean;
|
|
156
|
-
androidLayerType?: WithDefault<'none' | 'software' | 'hardware', 'none'>;
|
|
157
|
-
cacheMode?: WithDefault<
|
|
158
|
-
| 'LOAD_DEFAULT'
|
|
159
|
-
| 'LOAD_CACHE_ELSE_NETWORK'
|
|
160
|
-
| 'LOAD_NO_CACHE'
|
|
161
|
-
| 'LOAD_CACHE_ONLY',
|
|
162
|
-
'LOAD_DEFAULT'
|
|
163
|
-
>;
|
|
164
|
-
domStorageEnabled?: boolean;
|
|
165
|
-
downloadingMessage?: string;
|
|
166
|
-
forceDarkOn?: boolean;
|
|
167
|
-
geolocationEnabled?: boolean;
|
|
168
|
-
lackPermissionToDownloadMessage?: string;
|
|
169
|
-
messagingModuleName: string;
|
|
170
|
-
minimumFontSize?: Int32;
|
|
171
|
-
mixedContentMode?: WithDefault<'never' | 'always' | 'compatibility', 'never'>;
|
|
172
|
-
nestedScrollEnabled?: boolean;
|
|
173
|
-
onContentSizeChange?: DirectEventHandler<WebViewNativeEvent>;
|
|
174
|
-
onRenderProcessGone?: DirectEventHandler<WebViewRenderProcessGoneEvent>;
|
|
175
|
-
overScrollMode?: string;
|
|
176
|
-
saveFormDataDisabled?: boolean;
|
|
177
|
-
scalesPageToFit?: WithDefault<boolean, true>;
|
|
178
|
-
setBuiltInZoomControls?: WithDefault<boolean, true>;
|
|
179
|
-
setDisplayZoomControls?: boolean;
|
|
180
|
-
setSupportMultipleWindows?: WithDefault<boolean, true>;
|
|
181
|
-
textZoom?: Int32;
|
|
182
|
-
thirdPartyCookiesEnabled?: WithDefault<boolean, true>;
|
|
183
|
-
// Workaround to watch if listener if defined
|
|
184
|
-
hasOnScroll?: boolean;
|
|
185
|
-
injectedJavaScriptObject?: string;
|
|
186
|
-
// !Android only
|
|
187
|
-
paymentRequestEnabled?: boolean;
|
|
188
|
-
// iOS only
|
|
189
|
-
allowingReadAccessToURL?: string;
|
|
190
|
-
allowsBackForwardNavigationGestures?: boolean;
|
|
191
|
-
allowsInlineMediaPlayback?: boolean;
|
|
192
|
-
allowsPictureInPictureMediaPlayback?: boolean;
|
|
193
|
-
allowsAirPlayForMediaPlayback?: boolean;
|
|
194
|
-
allowsLinkPreview?: WithDefault<boolean, true>;
|
|
195
|
-
automaticallyAdjustContentInsets?: WithDefault<boolean, true>;
|
|
196
|
-
ignoreSilentHardwareSwitch?:boolean;
|
|
197
|
-
autoManageStatusBarEnabled?: WithDefault<boolean, true>;
|
|
198
|
-
bounces?: WithDefault<boolean, true>;
|
|
199
|
-
contentInset?: Readonly<{
|
|
200
|
-
top?: Double;
|
|
201
|
-
left?: Double;
|
|
202
|
-
bottom?: Double;
|
|
203
|
-
right?: Double;
|
|
204
|
-
}>;
|
|
205
|
-
contentInsetAdjustmentBehavior?: WithDefault<
|
|
206
|
-
'never' | 'automatic' | 'scrollableAxes' | 'always',
|
|
207
|
-
'never'
|
|
208
|
-
>;
|
|
209
|
-
contentMode?: WithDefault<
|
|
210
|
-
'recommended' | 'mobile' | 'desktop',
|
|
211
|
-
'recommended'
|
|
212
|
-
>;
|
|
213
|
-
dataDetectorTypes?: WithDefault<
|
|
214
|
-
ReadonlyArray<
|
|
215
|
-
| 'address'
|
|
216
|
-
| 'link'
|
|
217
|
-
| 'calendarEvent'
|
|
218
|
-
| 'trackingNumber'
|
|
219
|
-
| 'flightNumber'
|
|
220
|
-
| 'lookupSuggestion'
|
|
221
|
-
| 'phoneNumber'
|
|
222
|
-
| 'all'
|
|
223
|
-
| 'none'
|
|
224
|
-
>,
|
|
225
|
-
'phoneNumber'
|
|
226
|
-
>;
|
|
227
|
-
decelerationRate?: Double;
|
|
228
|
-
directionalLockEnabled?: WithDefault<boolean, true>;
|
|
229
|
-
enableApplePay?: boolean;
|
|
230
|
-
hideKeyboardAccessoryView?: boolean;
|
|
231
|
-
keyboardDisplayRequiresUserAction?: WithDefault<boolean, true>;
|
|
232
|
-
limitsNavigationsToAppBoundDomains?: boolean;
|
|
233
|
-
mediaCapturePermissionGrantType?: WithDefault<
|
|
234
|
-
| 'prompt'
|
|
235
|
-
| 'grant'
|
|
236
|
-
| 'deny'
|
|
237
|
-
| 'grantIfSameHostElsePrompt'
|
|
238
|
-
| 'grantIfSameHostElseDeny',
|
|
239
|
-
'prompt'
|
|
240
|
-
>;
|
|
241
|
-
pagingEnabled?: boolean;
|
|
242
|
-
pullToRefreshEnabled?: boolean;
|
|
243
|
-
refreshControlLightMode?: boolean;
|
|
244
|
-
scrollEnabled?: WithDefault<boolean, true>;
|
|
245
|
-
sharedCookiesEnabled?: boolean;
|
|
246
|
-
textInteractionEnabled?: WithDefault<boolean, true>;
|
|
247
|
-
useSharedProcessPool?: WithDefault<boolean, true>;
|
|
248
|
-
onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
|
|
249
|
-
onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
|
|
250
|
-
onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
|
|
251
|
-
|
|
252
|
-
menuItems?: ReadonlyArray<Readonly<{ label: string; key: string }>>;
|
|
253
|
-
suppressMenuItems?: Readonly<string>[];
|
|
254
|
-
// Workaround to watch if listener if defined
|
|
255
|
-
hasOnFileDownload?: boolean;
|
|
256
|
-
fraudulentWebsiteWarningEnabled?: WithDefault<boolean, true>;
|
|
257
|
-
// !iOS only
|
|
258
|
-
|
|
259
|
-
allowFileAccessFromFileURLs?: boolean;
|
|
260
|
-
allowUniversalAccessFromFileURLs?: boolean;
|
|
261
|
-
applicationNameForUserAgent?: string;
|
|
262
|
-
basicAuthCredential?: Readonly<{
|
|
263
|
-
username: string;
|
|
264
|
-
password: string;
|
|
265
|
-
}>;
|
|
266
|
-
cacheEnabled?: WithDefault<boolean, true>;
|
|
267
|
-
incognito?: boolean;
|
|
268
|
-
injectedJavaScript?: string;
|
|
269
|
-
injectedJavaScriptBeforeContentLoaded?: string;
|
|
270
|
-
injectedJavaScriptForMainFrameOnly?: WithDefault<boolean, true>;
|
|
271
|
-
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: WithDefault<
|
|
272
|
-
boolean,
|
|
273
|
-
true
|
|
274
|
-
>;
|
|
275
|
-
javaScriptCanOpenWindowsAutomatically?: boolean;
|
|
276
|
-
javaScriptEnabled?: WithDefault<boolean, true>;
|
|
277
|
-
webviewDebuggingEnabled?: boolean;
|
|
278
|
-
mediaPlaybackRequiresUserAction?: WithDefault<boolean, true>;
|
|
279
|
-
messagingEnabled: boolean;
|
|
280
|
-
shouldStartLoadWithRequestEnabled: boolean;
|
|
281
|
-
onLoadingError: DirectEventHandler<WebViewErrorEvent>;
|
|
282
|
-
onLoadingFinish: DirectEventHandler<WebViewNavigationEvent>;
|
|
283
|
-
onLoadingProgress: DirectEventHandler<WebViewNativeProgressEvent>;
|
|
284
|
-
onLoadingStart: DirectEventHandler<WebViewNavigationEvent>;
|
|
285
|
-
onHttpError: DirectEventHandler<WebViewHttpErrorEvent>;
|
|
286
|
-
onMessage: DirectEventHandler<WebViewMessageEvent>;
|
|
287
|
-
onOpenWindow?: DirectEventHandler<WebViewOpenWindowEvent>;
|
|
288
|
-
hasOnOpenWindowEvent?: boolean;
|
|
289
|
-
onScroll?: DirectEventHandler<ScrollEvent>;
|
|
290
|
-
onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
|
|
291
|
-
showsHorizontalScrollIndicator?: WithDefault<boolean, true>;
|
|
292
|
-
showsVerticalScrollIndicator?: WithDefault<boolean, true>;
|
|
293
|
-
indicatorStyle?: WithDefault<'default' | 'black' | 'white', 'default'>;
|
|
294
|
-
newSource: Readonly<{
|
|
295
|
-
uri?: string;
|
|
296
|
-
method?: string;
|
|
297
|
-
body?: string;
|
|
298
|
-
|
|
299
|
-
headers?: ReadonlyArray<Readonly<{ name: string; value: string }>>;
|
|
300
|
-
html?: string;
|
|
301
|
-
baseUrl?: string;
|
|
302
|
-
}>;
|
|
303
|
-
userAgent?: string;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export interface NativeCommands {
|
|
307
|
-
goBack: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
308
|
-
goForward: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
309
|
-
reload: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
310
|
-
stopLoading: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
311
|
-
injectJavaScript: (
|
|
312
|
-
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
313
|
-
javascript: string
|
|
314
|
-
) => void;
|
|
315
|
-
requestFocus: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
316
|
-
postMessage: (
|
|
317
|
-
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
318
|
-
data: string
|
|
319
|
-
) => void;
|
|
320
|
-
// Android Only
|
|
321
|
-
loadUrl: (
|
|
322
|
-
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
323
|
-
url: string
|
|
324
|
-
) => void;
|
|
325
|
-
clearFormData: (
|
|
326
|
-
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
327
|
-
) => void;
|
|
328
|
-
clearCache: (
|
|
329
|
-
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
330
|
-
includeDiskFiles: boolean
|
|
331
|
-
) => void;
|
|
332
|
-
clearHistory: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
333
|
-
// !Android Only
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
337
|
-
supportedCommands: [
|
|
338
|
-
'goBack',
|
|
339
|
-
'goForward',
|
|
340
|
-
'reload',
|
|
341
|
-
'stopLoading',
|
|
342
|
-
'injectJavaScript',
|
|
343
|
-
'requestFocus',
|
|
344
|
-
'postMessage',
|
|
345
|
-
'loadUrl',
|
|
346
|
-
'clearFormData',
|
|
347
|
-
'clearCache',
|
|
348
|
-
'clearHistory',
|
|
349
|
-
],
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
export default codegenNativeComponent<NativeProps>(
|
|
353
|
-
'RNCWebView'
|
|
354
|
-
) as HostComponent<NativeProps>;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
8
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
9
|
+
import {
|
|
10
|
+
DirectEventHandler,
|
|
11
|
+
Double,
|
|
12
|
+
Int32,
|
|
13
|
+
WithDefault,
|
|
14
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
15
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
16
|
+
|
|
17
|
+
export type WebViewNativeEvent = Readonly<{
|
|
18
|
+
url: string;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
title: string;
|
|
21
|
+
canGoBack: boolean;
|
|
22
|
+
canGoForward: boolean;
|
|
23
|
+
lockIdentifier: Double;
|
|
24
|
+
}>;
|
|
25
|
+
export type WebViewCustomMenuSelectionEvent = Readonly<{
|
|
26
|
+
label: string;
|
|
27
|
+
key: string;
|
|
28
|
+
selectedText: string;
|
|
29
|
+
}>;
|
|
30
|
+
export type WebViewMessageEvent = Readonly<{
|
|
31
|
+
url: string;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
title: string;
|
|
34
|
+
canGoBack: boolean;
|
|
35
|
+
canGoForward: boolean;
|
|
36
|
+
lockIdentifier: Double;
|
|
37
|
+
data: string;
|
|
38
|
+
}>;
|
|
39
|
+
export type WebViewOpenWindowEvent = Readonly<{
|
|
40
|
+
targetUrl: string;
|
|
41
|
+
}>;
|
|
42
|
+
export type WebViewHttpErrorEvent = Readonly<{
|
|
43
|
+
url: string;
|
|
44
|
+
loading: boolean;
|
|
45
|
+
title: string;
|
|
46
|
+
canGoBack: boolean;
|
|
47
|
+
canGoForward: boolean;
|
|
48
|
+
lockIdentifier: Double;
|
|
49
|
+
description: string;
|
|
50
|
+
statusCode: Int32;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type WebViewErrorEvent = Readonly<{
|
|
54
|
+
url: string;
|
|
55
|
+
loading: boolean;
|
|
56
|
+
title: string;
|
|
57
|
+
canGoBack: boolean;
|
|
58
|
+
canGoForward: boolean;
|
|
59
|
+
lockIdentifier: Double;
|
|
60
|
+
domain?: string;
|
|
61
|
+
code: Int32;
|
|
62
|
+
description: string;
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
export type WebViewNativeProgressEvent = Readonly<{
|
|
66
|
+
url: string;
|
|
67
|
+
loading: boolean;
|
|
68
|
+
title: string;
|
|
69
|
+
canGoBack: boolean;
|
|
70
|
+
canGoForward: boolean;
|
|
71
|
+
lockIdentifier: Double;
|
|
72
|
+
progress: Double;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export type WebViewNavigationEvent = Readonly<{
|
|
76
|
+
url: string;
|
|
77
|
+
loading: boolean;
|
|
78
|
+
title: string;
|
|
79
|
+
canGoBack: boolean;
|
|
80
|
+
canGoForward: boolean;
|
|
81
|
+
lockIdentifier: Double;
|
|
82
|
+
navigationType:
|
|
83
|
+
| 'click'
|
|
84
|
+
| 'formsubmit'
|
|
85
|
+
| 'backforward'
|
|
86
|
+
| 'reload'
|
|
87
|
+
| 'formresubmit'
|
|
88
|
+
| 'other';
|
|
89
|
+
mainDocumentURL?: string;
|
|
90
|
+
}>;
|
|
91
|
+
|
|
92
|
+
export type ShouldStartLoadRequestEvent = Readonly<{
|
|
93
|
+
url: string;
|
|
94
|
+
loading: boolean;
|
|
95
|
+
title: string;
|
|
96
|
+
canGoBack: boolean;
|
|
97
|
+
canGoForward: boolean;
|
|
98
|
+
lockIdentifier: Double;
|
|
99
|
+
navigationType:
|
|
100
|
+
| 'click'
|
|
101
|
+
| 'formsubmit'
|
|
102
|
+
| 'backforward'
|
|
103
|
+
| 'reload'
|
|
104
|
+
| 'formresubmit'
|
|
105
|
+
| 'other';
|
|
106
|
+
mainDocumentURL?: string;
|
|
107
|
+
isTopFrame: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
|
|
110
|
+
type ScrollEvent = Readonly<{
|
|
111
|
+
contentInset: {
|
|
112
|
+
bottom: Double;
|
|
113
|
+
left: Double;
|
|
114
|
+
right: Double;
|
|
115
|
+
top: Double;
|
|
116
|
+
};
|
|
117
|
+
contentOffset: {
|
|
118
|
+
y: Double;
|
|
119
|
+
x: Double;
|
|
120
|
+
};
|
|
121
|
+
contentSize: {
|
|
122
|
+
height: Double;
|
|
123
|
+
width: Double;
|
|
124
|
+
};
|
|
125
|
+
layoutMeasurement: {
|
|
126
|
+
height: Double;
|
|
127
|
+
width: Double;
|
|
128
|
+
};
|
|
129
|
+
targetContentOffset?: {
|
|
130
|
+
y: Double;
|
|
131
|
+
x: Double;
|
|
132
|
+
};
|
|
133
|
+
velocity?: {
|
|
134
|
+
y: Double;
|
|
135
|
+
x: Double;
|
|
136
|
+
};
|
|
137
|
+
zoomScale?: Double;
|
|
138
|
+
responderIgnoreScroll?: boolean;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
type WebViewRenderProcessGoneEvent = Readonly<{
|
|
142
|
+
didCrash: boolean;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
type WebViewDownloadEvent = Readonly<{
|
|
146
|
+
downloadUrl: string;
|
|
147
|
+
}>;
|
|
148
|
+
|
|
149
|
+
// type MenuItem = Readonly<{label: string, key: string}>;
|
|
150
|
+
|
|
151
|
+
export interface NativeProps extends ViewProps {
|
|
152
|
+
// Android only
|
|
153
|
+
allowFileAccess?: boolean;
|
|
154
|
+
allowsProtectedMedia?: boolean;
|
|
155
|
+
allowsFullscreenVideo?: boolean;
|
|
156
|
+
androidLayerType?: WithDefault<'none' | 'software' | 'hardware', 'none'>;
|
|
157
|
+
cacheMode?: WithDefault<
|
|
158
|
+
| 'LOAD_DEFAULT'
|
|
159
|
+
| 'LOAD_CACHE_ELSE_NETWORK'
|
|
160
|
+
| 'LOAD_NO_CACHE'
|
|
161
|
+
| 'LOAD_CACHE_ONLY',
|
|
162
|
+
'LOAD_DEFAULT'
|
|
163
|
+
>;
|
|
164
|
+
domStorageEnabled?: boolean;
|
|
165
|
+
downloadingMessage?: string;
|
|
166
|
+
forceDarkOn?: boolean;
|
|
167
|
+
geolocationEnabled?: boolean;
|
|
168
|
+
lackPermissionToDownloadMessage?: string;
|
|
169
|
+
messagingModuleName: string;
|
|
170
|
+
minimumFontSize?: Int32;
|
|
171
|
+
mixedContentMode?: WithDefault<'never' | 'always' | 'compatibility', 'never'>;
|
|
172
|
+
nestedScrollEnabled?: boolean;
|
|
173
|
+
onContentSizeChange?: DirectEventHandler<WebViewNativeEvent>;
|
|
174
|
+
onRenderProcessGone?: DirectEventHandler<WebViewRenderProcessGoneEvent>;
|
|
175
|
+
overScrollMode?: string;
|
|
176
|
+
saveFormDataDisabled?: boolean;
|
|
177
|
+
scalesPageToFit?: WithDefault<boolean, true>;
|
|
178
|
+
setBuiltInZoomControls?: WithDefault<boolean, true>;
|
|
179
|
+
setDisplayZoomControls?: boolean;
|
|
180
|
+
setSupportMultipleWindows?: WithDefault<boolean, true>;
|
|
181
|
+
textZoom?: Int32;
|
|
182
|
+
thirdPartyCookiesEnabled?: WithDefault<boolean, true>;
|
|
183
|
+
// Workaround to watch if listener if defined
|
|
184
|
+
hasOnScroll?: boolean;
|
|
185
|
+
injectedJavaScriptObject?: string;
|
|
186
|
+
// !Android only
|
|
187
|
+
paymentRequestEnabled?: boolean;
|
|
188
|
+
// iOS only
|
|
189
|
+
allowingReadAccessToURL?: string;
|
|
190
|
+
allowsBackForwardNavigationGestures?: boolean;
|
|
191
|
+
allowsInlineMediaPlayback?: boolean;
|
|
192
|
+
allowsPictureInPictureMediaPlayback?: boolean;
|
|
193
|
+
allowsAirPlayForMediaPlayback?: boolean;
|
|
194
|
+
allowsLinkPreview?: WithDefault<boolean, true>;
|
|
195
|
+
automaticallyAdjustContentInsets?: WithDefault<boolean, true>;
|
|
196
|
+
ignoreSilentHardwareSwitch?:boolean;
|
|
197
|
+
autoManageStatusBarEnabled?: WithDefault<boolean, true>;
|
|
198
|
+
bounces?: WithDefault<boolean, true>;
|
|
199
|
+
contentInset?: Readonly<{
|
|
200
|
+
top?: Double;
|
|
201
|
+
left?: Double;
|
|
202
|
+
bottom?: Double;
|
|
203
|
+
right?: Double;
|
|
204
|
+
}>;
|
|
205
|
+
contentInsetAdjustmentBehavior?: WithDefault<
|
|
206
|
+
'never' | 'automatic' | 'scrollableAxes' | 'always',
|
|
207
|
+
'never'
|
|
208
|
+
>;
|
|
209
|
+
contentMode?: WithDefault<
|
|
210
|
+
'recommended' | 'mobile' | 'desktop',
|
|
211
|
+
'recommended'
|
|
212
|
+
>;
|
|
213
|
+
dataDetectorTypes?: WithDefault<
|
|
214
|
+
ReadonlyArray<
|
|
215
|
+
| 'address'
|
|
216
|
+
| 'link'
|
|
217
|
+
| 'calendarEvent'
|
|
218
|
+
| 'trackingNumber'
|
|
219
|
+
| 'flightNumber'
|
|
220
|
+
| 'lookupSuggestion'
|
|
221
|
+
| 'phoneNumber'
|
|
222
|
+
| 'all'
|
|
223
|
+
| 'none'
|
|
224
|
+
>,
|
|
225
|
+
'phoneNumber'
|
|
226
|
+
>;
|
|
227
|
+
decelerationRate?: Double;
|
|
228
|
+
directionalLockEnabled?: WithDefault<boolean, true>;
|
|
229
|
+
enableApplePay?: boolean;
|
|
230
|
+
hideKeyboardAccessoryView?: boolean;
|
|
231
|
+
keyboardDisplayRequiresUserAction?: WithDefault<boolean, true>;
|
|
232
|
+
limitsNavigationsToAppBoundDomains?: boolean;
|
|
233
|
+
mediaCapturePermissionGrantType?: WithDefault<
|
|
234
|
+
| 'prompt'
|
|
235
|
+
| 'grant'
|
|
236
|
+
| 'deny'
|
|
237
|
+
| 'grantIfSameHostElsePrompt'
|
|
238
|
+
| 'grantIfSameHostElseDeny',
|
|
239
|
+
'prompt'
|
|
240
|
+
>;
|
|
241
|
+
pagingEnabled?: boolean;
|
|
242
|
+
pullToRefreshEnabled?: boolean;
|
|
243
|
+
refreshControlLightMode?: boolean;
|
|
244
|
+
scrollEnabled?: WithDefault<boolean, true>;
|
|
245
|
+
sharedCookiesEnabled?: boolean;
|
|
246
|
+
textInteractionEnabled?: WithDefault<boolean, true>;
|
|
247
|
+
useSharedProcessPool?: WithDefault<boolean, true>;
|
|
248
|
+
onContentProcessDidTerminate?: DirectEventHandler<WebViewNativeEvent>;
|
|
249
|
+
onCustomMenuSelection?: DirectEventHandler<WebViewCustomMenuSelectionEvent>;
|
|
250
|
+
onFileDownload?: DirectEventHandler<WebViewDownloadEvent>;
|
|
251
|
+
|
|
252
|
+
menuItems?: ReadonlyArray<Readonly<{ label: string; key: string }>>;
|
|
253
|
+
suppressMenuItems?: Readonly<string>[];
|
|
254
|
+
// Workaround to watch if listener if defined
|
|
255
|
+
hasOnFileDownload?: boolean;
|
|
256
|
+
fraudulentWebsiteWarningEnabled?: WithDefault<boolean, true>;
|
|
257
|
+
// !iOS only
|
|
258
|
+
|
|
259
|
+
allowFileAccessFromFileURLs?: boolean;
|
|
260
|
+
allowUniversalAccessFromFileURLs?: boolean;
|
|
261
|
+
applicationNameForUserAgent?: string;
|
|
262
|
+
basicAuthCredential?: Readonly<{
|
|
263
|
+
username: string;
|
|
264
|
+
password: string;
|
|
265
|
+
}>;
|
|
266
|
+
cacheEnabled?: WithDefault<boolean, true>;
|
|
267
|
+
incognito?: boolean;
|
|
268
|
+
injectedJavaScript?: string;
|
|
269
|
+
injectedJavaScriptBeforeContentLoaded?: string;
|
|
270
|
+
injectedJavaScriptForMainFrameOnly?: WithDefault<boolean, true>;
|
|
271
|
+
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: WithDefault<
|
|
272
|
+
boolean,
|
|
273
|
+
true
|
|
274
|
+
>;
|
|
275
|
+
javaScriptCanOpenWindowsAutomatically?: boolean;
|
|
276
|
+
javaScriptEnabled?: WithDefault<boolean, true>;
|
|
277
|
+
webviewDebuggingEnabled?: boolean;
|
|
278
|
+
mediaPlaybackRequiresUserAction?: WithDefault<boolean, true>;
|
|
279
|
+
messagingEnabled: boolean;
|
|
280
|
+
shouldStartLoadWithRequestEnabled: boolean;
|
|
281
|
+
onLoadingError: DirectEventHandler<WebViewErrorEvent>;
|
|
282
|
+
onLoadingFinish: DirectEventHandler<WebViewNavigationEvent>;
|
|
283
|
+
onLoadingProgress: DirectEventHandler<WebViewNativeProgressEvent>;
|
|
284
|
+
onLoadingStart: DirectEventHandler<WebViewNavigationEvent>;
|
|
285
|
+
onHttpError: DirectEventHandler<WebViewHttpErrorEvent>;
|
|
286
|
+
onMessage: DirectEventHandler<WebViewMessageEvent>;
|
|
287
|
+
onOpenWindow?: DirectEventHandler<WebViewOpenWindowEvent>;
|
|
288
|
+
hasOnOpenWindowEvent?: boolean;
|
|
289
|
+
onScroll?: DirectEventHandler<ScrollEvent>;
|
|
290
|
+
onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
|
|
291
|
+
showsHorizontalScrollIndicator?: WithDefault<boolean, true>;
|
|
292
|
+
showsVerticalScrollIndicator?: WithDefault<boolean, true>;
|
|
293
|
+
indicatorStyle?: WithDefault<'default' | 'black' | 'white', 'default'>;
|
|
294
|
+
newSource: Readonly<{
|
|
295
|
+
uri?: string;
|
|
296
|
+
method?: string;
|
|
297
|
+
body?: string;
|
|
298
|
+
|
|
299
|
+
headers?: ReadonlyArray<Readonly<{ name: string; value: string }>>;
|
|
300
|
+
html?: string;
|
|
301
|
+
baseUrl?: string;
|
|
302
|
+
}>;
|
|
303
|
+
userAgent?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface NativeCommands {
|
|
307
|
+
goBack: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
308
|
+
goForward: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
309
|
+
reload: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
310
|
+
stopLoading: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
311
|
+
injectJavaScript: (
|
|
312
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
313
|
+
javascript: string
|
|
314
|
+
) => void;
|
|
315
|
+
requestFocus: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
316
|
+
postMessage: (
|
|
317
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
318
|
+
data: string
|
|
319
|
+
) => void;
|
|
320
|
+
// Android Only
|
|
321
|
+
loadUrl: (
|
|
322
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
323
|
+
url: string
|
|
324
|
+
) => void;
|
|
325
|
+
clearFormData: (
|
|
326
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>
|
|
327
|
+
) => void;
|
|
328
|
+
clearCache: (
|
|
329
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
330
|
+
includeDiskFiles: boolean
|
|
331
|
+
) => void;
|
|
332
|
+
clearHistory: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
333
|
+
// !Android Only
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
337
|
+
supportedCommands: [
|
|
338
|
+
'goBack',
|
|
339
|
+
'goForward',
|
|
340
|
+
'reload',
|
|
341
|
+
'stopLoading',
|
|
342
|
+
'injectJavaScript',
|
|
343
|
+
'requestFocus',
|
|
344
|
+
'postMessage',
|
|
345
|
+
'loadUrl',
|
|
346
|
+
'clearFormData',
|
|
347
|
+
'clearCache',
|
|
348
|
+
'clearHistory',
|
|
349
|
+
],
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
export default codegenNativeComponent<NativeProps>(
|
|
353
|
+
'RNCWebView'
|
|
354
|
+
) as HostComponent<NativeProps>;
|