@react-native-ohos/react-native-webview 13.16.1 → 13.16.2-beta.5
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/CHANGELOG.md +132 -0
- package/LICENSE +20 -20
- package/README.OpenSource +10 -10
- package/README.md +396 -13
- package/harmony/rn_webview/.gitignore +6 -0
- package/harmony/rn_webview/BuildProfile.ets +17 -0
- 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-lock.json5 +28 -18
- 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 +96 -96
- package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +121 -120
- 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 +258 -258
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.h +277 -277
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +104 -103
- package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +510 -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 +199 -184
- package/harmony/rn_webview/src/main/ets/RNCWebView.ets +824 -688
- 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 +514 -501
- package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +62 -62
- package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +529 -525
- 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/lib/NativeRNCWebView.d.ts +10 -0
- package/lib/NativeRNCWebView.d.ts.map +1 -0
- package/lib/NativeRNCWebView.js +1 -0
- package/lib/NativeRNCWebViewModule.d.ts +9 -0
- package/lib/NativeRNCWebViewModule.d.ts.map +1 -0
- package/lib/NativeRNCWebViewModule.js +1 -0
- package/lib/RNCWebViewNativeComponent.d.ts +250 -0
- package/lib/RNCWebViewNativeComponent.d.ts.map +1 -0
- package/lib/RNCWebViewNativeComponent.js +1 -0
- package/lib/WebView.d.ts +4 -0
- package/lib/WebView.d.ts.map +1 -0
- package/lib/WebView.harmony.d.ts +16 -0
- package/lib/WebView.harmony.d.ts.map +1 -0
- package/lib/WebView.harmony.js +1 -0
- package/lib/WebView.js +1 -0
- package/lib/codegenUtils.d.ts +3 -0
- package/lib/codegenUtils.d.ts.map +1 -0
- package/lib/codegenUtils.js +0 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/package.json +101 -99
- package/src/NativeRNCWebView.ts +21 -21
- package/src/NativeRNCWebViewModule.ts +19 -19
- package/src/RNCWebViewNativeComponent.ts +356 -355
- package/src/WebView.harmony.tsx +348 -346
- package/src/WebView.tsx +10 -10
- package/src/codegenUtils.ts +10 -10
- package/src/index.ts +10 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
## 鸿蒙化Log
|
|
3
|
+
|
|
4
|
+
### 13.16.2-beta.5
|
|
5
|
+
- fix: 修改web链接校验方案
|
|
6
|
+
|
|
7
|
+
### 13.16.2-rc.4
|
|
8
|
+
- feat: 适配webview嵌套滚动
|
|
9
|
+
|
|
10
|
+
### 13.16.2-rc.3
|
|
11
|
+
- feat: 新增renderMode属性
|
|
12
|
+
|
|
13
|
+
### 13.16.2-beta.2
|
|
14
|
+
- feat: feat:react-native-webview适配文本长按禁用选择框
|
|
15
|
+
- feat:react-native-webview适配mediaCapturePermissionGrantType属性
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### 13.16.1
|
|
19
|
+
- release version 13.16.1
|
|
20
|
+
|
|
21
|
+
### 13.16.1-rc.1
|
|
22
|
+
- pre-release version 13.16.1-rc.1
|
|
23
|
+
- feat: Upgrade to the upstream community version
|
|
24
|
+
|
|
25
|
+
### v13.15.1-rc.2
|
|
26
|
+
- pre-release: @react-native-ohos/react-native-webview@13.15.1-rc.2
|
|
27
|
+
|
|
28
|
+
### v13.15.1-rc.1
|
|
29
|
+
- pre-release: @react-native-ohos/react-native-webview@13.15.1-rc.21
|
|
30
|
+
- feat: add OpenHarmony support for react-native-webview
|
|
31
|
+
|
|
32
|
+
## ReleaseLog
|
|
33
|
+
### v13.15.0
|
|
34
|
+
#### Features
|
|
35
|
+
- **android:** add support for enabling the Payment Request API ([#2278](https://github.com/react-native-webview/react-native-webview/issues/2278)) ([#3763](https://github.com/react-native-webview/react-native-webview/issues/3763)) ([4ea6d6b](https://github.com/react-native-webview/react-native-webview/commit/4ea6d6bcb20835eb46fbcf04a69b363ed9fd3b5f))
|
|
36
|
+
|
|
37
|
+
### v13.14.2
|
|
38
|
+
#### Bug Fixes
|
|
39
|
+
- **android:** suppressMenuItems native view config name with extra space ([#3780](https://github.com/react-native-webview/react-native-webview/issues/3780)) ([5a73948](https://github.com/react-native-webview/react-native-webview/commit/5a7394836a3e03aaf170ef3227ddf8dcd89241cf))
|
|
40
|
+
|
|
41
|
+
### v13.14.1
|
|
42
|
+
#### Bug Fixes
|
|
43
|
+
- support react-native-codegen properly ([#3777](https://github.com/react-native-webview/react-native-webview/issues/3777)) ([823e6ae](https://github.com/react-native-webview/react-native-webview/commit/823e6aeefb9216c4c3aa00f93bb840e5a925d690))
|
|
44
|
+
|
|
45
|
+
### v13.14.0
|
|
46
|
+
#### Features
|
|
47
|
+
- **ios:** Added support for scrollview indicatorStyle ([#3743](https://github.com/react-native-webview/react-native-webview/issues/3743)) ([6af6a83](https://github.com/react-native-webview/react-native-webview/commit/6af6a830aea5b57ca68c1935c927759244c7d6fd))
|
|
48
|
+
|
|
49
|
+
### v13.13.5
|
|
50
|
+
#### Bug Fixes
|
|
51
|
+
- **android:** onMessage exception on fallback path ([#3741](https://github.com/react-native-webview/react-native-webview/issues/3741)) ([73ff3a8](https://github.com/react-native-webview/react-native-webview/commit/73ff3a836bffcec2d6a7e1b39406bc31a34446b0))
|
|
52
|
+
|
|
53
|
+
### v13.13.4
|
|
54
|
+
#### Bug Fixes
|
|
55
|
+
- **ios, new-arch:** Fixed regression caused by new defaults applied ([#3731](https://github.com/react-native-webview/react-native-webview/issues/3731)) ([964ffcc](https://github.com/react-native-webview/react-native-webview/commit/964ffccf1102bfa757d7cee6039dc0bfe405b4a6))
|
|
56
|
+
|
|
57
|
+
### v13.13.3
|
|
58
|
+
#### Bug Fixes
|
|
59
|
+
- **newArch:** Set correct default values for "true" booleans ([#3726](https://github.com/react-native-webview/react-native-webview/issues/3726)) ([a2e1e4d](https://github.com/react-native-webview/react-native-webview/commit/a2e1e4d8525f115df17cdb0876335c6b04bbdd54))
|
|
60
|
+
|
|
61
|
+
### v13.13.2
|
|
62
|
+
#### Bug Fixes
|
|
63
|
+
- **iOS:** use canGoForward value for return values ([#3659](https://github.com/react-native-webview/react-native-webview/issues/3659)) ([b5c40c9](https://github.com/react-native-webview/react-native-webview/commit/b5c40c9a328818fd03731598ae2ef57ddd2169f8))
|
|
64
|
+
|
|
65
|
+
### v13.13.1
|
|
66
|
+
#### Bug Fixes
|
|
67
|
+
- **android,ios:** Sending correct url in onMessage callback ([#3609](https://github.com/react-native-webview/react-native-webview/issues/3609)) ([2c5096d](https://github.com/react-native-webview/react-native-webview/commit/2c5096d948f0e9e22ab020833004dd7ed9a74788))
|
|
68
|
+
|
|
69
|
+
### v13.13.0
|
|
70
|
+
#### Features
|
|
71
|
+
- support RN 0.77 ([#3661](https://github.com/react-native-webview/react-native-webview/issues/3661)) ([685b8c7](https://github.com/react-native-webview/react-native-webview/commit/685b8c78d5d6aacaff5c8ea3cac5847e3a397ae2)), closes [/github.com/facebook/react-native/commit/145c72f8163048f0eee30d5ce850911f5dad865c#diff-cab6c32d3e05344091c804ea93e8a220dabdd75ec2a258aaf4bde7751c13f844R29](https://github.com//github.com/facebook/react-native/commit/145c72f8163048f0eee30d5ce850911f5dad865c/issues/diff-cab6c32d3e05344091c804ea93e8a220dabdd75ec2a258aaf4bde7751c13f844R29)
|
|
72
|
+
|
|
73
|
+
### v13.12.5
|
|
74
|
+
Hey all, a little bit of context, I've been super busy with work these past months, and had less time to review webview stuff. The original PR was not merged by me but by another maintainer that did not measure the impact of the change. Thank y'all for pushing on those issues and PR, you are the best. I should have been more alert to the notifications still.
|
|
75
|
+
|
|
76
|
+
Regarding more general initialization issues: new arch introduced quite a few subtle changes and I wanted to rewrite a lot of things and drop support for old arch. I want to support preloading, keeping instances alive and more, but that takes time. In the meantime thanks for the help keeping it as functional as possible!
|
|
77
|
+
#### Bug Fixes
|
|
78
|
+
- **iOS:** revert ([`e8f3c0e`](https://github.com/react-native-webview/react-native-webview/commit/e8f3c0edee77bee3922db413ba87f1665e50e79b)) preload WebView on initial render in background tabs ([#3559](https://github.com/react-native-webview/react-native-webview/issues/3559) by [@sheat-git](https://github.com/sheat-git)) ([#3615](https://github.com/react-native-webview/react-native-webview/issues/3615)) ([fcbe0a5](https://github.com/react-native-webview/react-native-webview/commit/fcbe0a5cd68823fb990079305b3d20a9f7a32d67))
|
|
79
|
+
|
|
80
|
+
### v13.12.4
|
|
81
|
+
#### Bug Fixes
|
|
82
|
+
- **android:** allowFileAccess does not apply to initial loading ([#3598](https://github.com/react-native-webview/react-native-webview/issues/3598)) ([8ad2360](https://github.com/react-native-webview/react-native-webview/commit/8ad2360ccbd62de5112b90c41fcdee56129b6294))
|
|
83
|
+
|
|
84
|
+
### v13.12.3
|
|
85
|
+
#### Bug Fixes
|
|
86
|
+
- **iOS:** preload WebView on initial render in background tabs ([#3559](https://github.com/react-native-webview/react-native-webview/issues/3559) by [@sheat-git](https://github.com/sheat-git)) ([e8f3c0e](https://github.com/react-native-webview/react-native-webview/commit/e8f3c0edee77bee3922db413ba87f1665e50e79b)), closes [#2431](https://github.com/react-native-webview/react-native-webview/issues/2431) [#3476](https://github.com/react-native-webview/react-native-webview/issues/3476) [#3481](https://github.com/react-native-webview/react-native-webview/issues/3481)
|
|
87
|
+
|
|
88
|
+
### v13.12.2
|
|
89
|
+
#### Bug Fixes
|
|
90
|
+
- **android, new arch:** Do not execute commands twice ([#3552](https://github.com/react-native-webview/react-native-webview/issues/3552)) ([9953ca0](https://github.com/react-native-webview/react-native-webview/commit/9953ca0b185a3152df10be1ce4d7f1160f788e69))
|
|
91
|
+
|
|
92
|
+
### v13.12.1
|
|
93
|
+
#### Bug Fixes
|
|
94
|
+
- **apple:** Updates how HTTP errors are handled ([#3545](https://github.com/react-native-webview/react-native-webview/issues/3545)) ([a835fff](https://github.com/react-native-webview/react-native-webview/commit/a835fffbf0b6d956acd713a1ec5811ab9c3289ea))
|
|
95
|
+
|
|
96
|
+
### v13.12.0
|
|
97
|
+
#### Bug Fixes
|
|
98
|
+
- Implement missing methods of RNCWebViewManagerInterface in RNCWebViewManager ([#3536](https://github.com/react-native-webview/react-native-webview/issues/3536)) ([aab4030](https://github.com/react-native-webview/react-native-webview/commit/aab4030dfec98ee31f343915fa3e9d2b0d27da29))
|
|
99
|
+
#### Features
|
|
100
|
+
- add load method ([#3537](https://github.com/react-native-webview/react-native-webview/issues/3537)) ([7e49457](https://github.com/react-native-webview/react-native-webview/commit/7e49457d62234d475025fca5825502846c8eabbf))
|
|
101
|
+
|
|
102
|
+
### v13.11.1
|
|
103
|
+
#### Bug Fixes
|
|
104
|
+
- Update escape-string-regexp to 4.x ([#3170](https://github.com/react-native-webview/react-native-webview/issues/3170)) ([9e2304e](https://github.com/react-native-webview/react-native-webview/commit/9e2304ea3d0a40c3246103e8330d3164cd4c7108))
|
|
105
|
+
|
|
106
|
+
### v13.11.0
|
|
107
|
+
#### Features
|
|
108
|
+
- **iOS:** allowsPictureInPictureMediaPlayback added for iOS only ([#3497](https://github.com/react-native-webview/react-native-webview/issues/3497)) ([1d8205a](https://github.com/react-native-webview/react-native-webview/commit/1d8205af06dbb0bad0d8f208bb2a37ce5f732fd3))
|
|
109
|
+
|
|
110
|
+
### v13.10.7
|
|
111
|
+
#### Bug Fixes
|
|
112
|
+
- issue where cookies were not being saved when Android WebView app was forcibly terminated ([#3176](https://github.com/react-native-webview/react-native-webview/issues/3176)) ([28af371](https://github.com/react-native-webview/react-native-webview/commit/28af371d7e15ad78db8d580e97717eb139dff7c2))
|
|
113
|
+
|
|
114
|
+
### v13.10.6
|
|
115
|
+
#### Bug Fixes
|
|
116
|
+
- bug where setCookie completionHandler is never called ([#3470](https://github.com/react-native-webview/react-native-webview/issues/3470)) ([1b47805](https://github.com/react-native-webview/react-native-webview/commit/1b478056a7988990c5bad5ef108edbb19964d5df))
|
|
117
|
+
|
|
118
|
+
### v13.10.5
|
|
119
|
+
#### Bug Fixes
|
|
120
|
+
- **new-arch:** Refactor Turbomodule to have distinct module name to avoid confusion with Fabric component ([#3462](https://github.com/react-native-webview/react-native-webview/issues/3462)) ([55077a7](https://github.com/react-native-webview/react-native-webview/commit/55077a74d825cedf3fec2f3a9ab219b0a9f97bc3))
|
|
121
|
+
|
|
122
|
+
### v13.10.4
|
|
123
|
+
#### Bug Fixes
|
|
124
|
+
- **iOS:** Implement `[RCTConvert WKDataDetectorTypes:]` ([#3436](https://github.com/react-native-webview/react-native-webview/issues/3436)) ([d252578](https://github.com/react-native-webview/react-native-webview/commit/d252578486b7e0237ac60ad848a7654490eea8b7))
|
|
125
|
+
|
|
126
|
+
### v13.10.3
|
|
127
|
+
#### Bug Fixes
|
|
128
|
+
- **ios:** Fix crash when opening 4xx pages with no description. ([#3416](https://github.com/react-native-webview/react-native-webview/issues/3416)) ([91d76ec](https://github.com/react-native-webview/react-native-webview/commit/91d76ec2359373bec846c71efd2a46c3d7ad310d))
|
|
129
|
+
|
|
130
|
+
### v13.10.2
|
|
131
|
+
#### Bug Fixes
|
|
132
|
+
- **iOS:** Replace unsupported nullish coalescing operator for older iOS versions ([#3388](https://github.com/react-native-webview/react-native-webview/issues/3388)) ([d5749e0](https://github.com/react-native-webview/react-native-webview/commit/d5749e093e5309162d64aa814d4aa94e0df242a2))
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.OpenSource
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"Name": "react-native-webview",
|
|
4
|
-
"License": "MIT License",
|
|
5
|
-
"License File": " LICENSE ",
|
|
6
|
-
"Version Number": "13.15.1-rc.1",
|
|
7
|
-
"Owner" : "xiafeng@huawei.com",
|
|
8
|
-
"Upstream URL": "https://github.com/react-native-webview/react-native-webview",
|
|
9
|
-
"Description": "react-native-webview."
|
|
10
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-webview",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": " LICENSE ",
|
|
6
|
+
"Version Number": "13.15.1-rc.1",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/react-native-webview/react-native-webview",
|
|
9
|
+
"Description": "react-native-webview."
|
|
10
|
+
}
|
|
11
11
|
]
|
package/README.md
CHANGED
|
@@ -1,13 +1,396 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
> 模板版本:v0.4.0
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<h1 align="center"> <code>react-native-webview</code> </h1>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://github.com/react-native-webview/react-native-webview">
|
|
8
|
+
<img src="https://img.shields.io/badge/platforms-android%20%7C%20ios%20%7C%20windows%20%7C%20macos%20%7C%20harmony%20-lightgrey.svg" alt="Supported platforms" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://github.com/react-native-webview/react-native-webview/blob/master/LICENSE">
|
|
11
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-webview)
|
|
16
|
+
|
|
17
|
+
## 安装与使用
|
|
18
|
+
|
|
19
|
+
请到三方库的 Releases 发布地址查看配套的版本信息:
|
|
20
|
+
|
|
21
|
+
| 三方库名称 | 三方库版本 | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | npm地址
|
|
22
|
+
| ------------ |---------|---------------------------------------------------------------------------------------------|----------------------|--------------------|-------------------|----------------------------|----------------------------------|
|
|
23
|
+
|@react-native-ohos/react-native-webview| ~13.16.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-webview/releases) | 0.82.* | 否 | API20+ | 13.16.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-webview)|
|
|
24
|
+
|@react-native-ohos/react-native-webview| ~13.15.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-webview/releases) | 0.77.* | 否 | API20+ | 13.15.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-webview)|
|
|
25
|
+
|@react-native-ohos/react-native-webview| ~13.10.5 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-webview/releases) | 0.72.* | 是 |API20+ | 13.10.2 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-webview)|
|
|
26
|
+
|@react-native-oh-tpl/react-native-webview| <=13.10.4@deprecated | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-webview/releases) | 0.72.* | 否 | API12+ | 13.10.2 | [Npm Address](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-webview) |
|
|
27
|
+
|
|
28
|
+
对于未发布到npm的旧版本,请参考[安装指南](/tgz-usage.md)安装tgz包。
|
|
29
|
+
|
|
30
|
+
进入到工程目录并输入以下命令:
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<!-- tabs:start -->
|
|
34
|
+
|
|
35
|
+
#### **npm**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @react-native-ohos/react-native-webview
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### **yarn**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn add @react-native-ohos/react-native-webview
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
<!-- tabs:end -->
|
|
48
|
+
|
|
49
|
+
下面的代码展示了这个库的基本使用场景:
|
|
50
|
+
|
|
51
|
+
> [!WARNING] 使用时 import 的库名不变。
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { WebView } from "react-native-webview";
|
|
55
|
+
|
|
56
|
+
export default function WebViewDemo() {
|
|
57
|
+
return (
|
|
58
|
+
<WebView source={{ uri: "https://reactnative.dev/" }} />
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Link
|
|
64
|
+
|
|
65
|
+
| | Is supported autolink | Supported RN Version |
|
|
66
|
+
|--------------------------------------|-----------------------|----------------------|
|
|
67
|
+
| ~13.16.1 | No | 0.82 |
|
|
68
|
+
| ~13.15.1 | No | 0.77 |
|
|
69
|
+
| ~13.10.5 | Yes | 0.72 |
|
|
70
|
+
| <= 13.10.4@deprecated | No | 0.72 |
|
|
71
|
+
|
|
72
|
+
使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
|
|
73
|
+
|
|
74
|
+
如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
|
|
75
|
+
<details>
|
|
76
|
+
<summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
|
|
77
|
+
|
|
78
|
+
首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
|
|
79
|
+
|
|
80
|
+
### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
...
|
|
85
|
+
"overrides": {
|
|
86
|
+
"@rnoh/react-native-openharmony" : "./react_native_openharmony"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 2.引入原生端代码
|
|
92
|
+
|
|
93
|
+
目前有两种方法:
|
|
94
|
+
|
|
95
|
+
1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
|
|
96
|
+
2. 直接链接源码。
|
|
97
|
+
|
|
98
|
+
方法一:通过 har 包引入
|
|
99
|
+
|
|
100
|
+
> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
|
|
101
|
+
|
|
102
|
+
打开 `entry/oh-package.json5`,添加以下依赖
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
|
|
107
|
+
|
|
108
|
+
"@react-native-ohos/react-native-webview": "file:../../node_modules/@react-native-ohos/react-native-webview/harmony/rn_webview.har"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
点击右上角的 `sync` 按钮
|
|
113
|
+
|
|
114
|
+
或者在终端执行:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cd entry
|
|
118
|
+
ohpm install
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
方法二:直接链接源码
|
|
122
|
+
|
|
123
|
+
> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/link-source-code.md)
|
|
124
|
+
|
|
125
|
+
### 3.配置 CMakeLists 和引入 WebViewPackage
|
|
126
|
+
|
|
127
|
+
打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
|
|
128
|
+
|
|
129
|
+
```diff
|
|
130
|
+
project(rnapp)
|
|
131
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
132
|
+
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
133
|
+
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
134
|
+
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
|
|
135
|
+
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
136
|
+
+set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
137
|
+
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
|
|
138
|
+
set(LOG_VERBOSITY_LEVEL 1)
|
|
139
|
+
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
|
|
140
|
+
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
|
|
141
|
+
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
|
|
142
|
+
add_compile_definitions(WITH_HITRACE_SYSTRACE)
|
|
143
|
+
|
|
144
|
+
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
145
|
+
|
|
146
|
+
# RNOH_BEGIN: manual_package_linking_1
|
|
147
|
+
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
|
|
148
|
+
+ add_subdirectory("${OH_MODULE_DIR}/@react-native-ohos/react-native-webview/src/main/cpp" ./webview)
|
|
149
|
+
|
|
150
|
+
# RNOH_END: manual_package_linking_1
|
|
151
|
+
|
|
152
|
+
file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
|
|
153
|
+
|
|
154
|
+
add_library(rnoh_app SHARED
|
|
155
|
+
${GENERATED_CPP_FILES}
|
|
156
|
+
"./PackageProvider.cpp"
|
|
157
|
+
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
158
|
+
)
|
|
159
|
+
target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
160
|
+
|
|
161
|
+
# RNOH_BEGIN: manual_package_linking_2
|
|
162
|
+
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
|
|
163
|
+
+ target_link_libraries(rnoh_app PUBLIC rnoh_webview)
|
|
164
|
+
# RNOH_END: manual_package_linking_2
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
|
|
168
|
+
|
|
169
|
+
```diff
|
|
170
|
+
#include "RNOH/PackageProvider.h"
|
|
171
|
+
#include "SamplePackage.h"
|
|
172
|
+
+ #include "WebViewPackage.h"
|
|
173
|
+
|
|
174
|
+
using namespace rnoh;
|
|
175
|
+
|
|
176
|
+
std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
|
|
177
|
+
return {
|
|
178
|
+
std::make_shared<SamplePackage>(ctx),
|
|
179
|
+
+ std::make_shared<WebViewPackage>(ctx)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 4.在 ArkTs 侧引入 webview 组件
|
|
185
|
+
|
|
186
|
+
找到 **function buildCustomComponent()**,一般位于 `entry/src/main/ets/pages/index.ets` 或 `entry/src/main/ets/rn/LoadBundle.ets`,添加:
|
|
187
|
+
|
|
188
|
+
```diff
|
|
189
|
+
+ import { WebView, WEB_VIEW } from "@react-native-ohos/react-native-webview"
|
|
190
|
+
|
|
191
|
+
@Builder
|
|
192
|
+
function buildCustomComponent(ctx: ComponentBuilderContext) {
|
|
193
|
+
+ if (ctx.componentName === WEB_VIEW) {
|
|
194
|
+
+ WebView({
|
|
195
|
+
+ ctx: ctx.rnComponentContext,
|
|
196
|
+
+ tag: ctx.tag
|
|
197
|
+
+ })
|
|
198
|
+
+ }
|
|
199
|
+
...
|
|
200
|
+
}
|
|
201
|
+
...
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
> [!TIP] 本库使用了混合方案,需要添加组件名。
|
|
205
|
+
|
|
206
|
+
在`entry/src/main/ets/pages/index.ets` 或 `entry/src/main/ets/rn/LoadBundle.ets` 找到常量 `arkTsComponentNames` 在其数组里添加组件名
|
|
207
|
+
|
|
208
|
+
```diff
|
|
209
|
+
const arkTsComponentNames: Array<string> = [
|
|
210
|
+
SampleView.NAME,
|
|
211
|
+
GeneratedSampleView.NAME,
|
|
212
|
+
PropsDisplayer.NAME,
|
|
213
|
+
+ WEB_VIEW
|
|
214
|
+
];
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 5.在 ArkTs 侧引入 WebViewPackage
|
|
218
|
+
|
|
219
|
+
打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
|
|
220
|
+
|
|
221
|
+
```diff
|
|
222
|
+
import type {RNPackageContext, RNPackage} from 'rnoh/ts';
|
|
223
|
+
import {SamplePackage} from 'rnoh-sample-package/ts';
|
|
224
|
+
+ import { WebViewPackage } from '@react-native-ohos/react-native-webview/ts';
|
|
225
|
+
|
|
226
|
+
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
227
|
+
return [
|
|
228
|
+
new SamplePackage(ctx),
|
|
229
|
+
+ new WebViewPackage(ctx)
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
## 运行
|
|
236
|
+
|
|
237
|
+
点击右上角的 `sync` 按钮
|
|
238
|
+
|
|
239
|
+
或者在终端执行:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
cd entry
|
|
243
|
+
ohpm install
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
然后编译、运行即可。
|
|
247
|
+
|
|
248
|
+
## 约束与限制
|
|
249
|
+
|
|
250
|
+
### 兼容性
|
|
251
|
+
|
|
252
|
+
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
|
|
253
|
+
|
|
254
|
+
在以下版本验证通过:
|
|
255
|
+
|
|
256
|
+
1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
257
|
+
2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
|
|
258
|
+
3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
259
|
+
4. RNOH: 0.82.1; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
260
|
+
|
|
261
|
+
## 属性
|
|
262
|
+
> [!WARNING]ignoreSilentHardwareSwitch需要设置true网页播放才有声音
|
|
263
|
+
|
|
264
|
+
> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
|
|
265
|
+
|
|
266
|
+
> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
|
|
267
|
+
|
|
268
|
+
详情请查看[webview 官方文档](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md)
|
|
269
|
+
|
|
270
|
+
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
271
|
+
|----------------------------------------------------------| ------------------------------------------------------------ | -------- |----------|---------------------|------------------------------------------------------------------------------------|
|
|
272
|
+
| `source` | Loads static HTML or a URI (with optional headers) in the WebView | object | yes | All | partially (Only of: **Load uri :** uri headers **Static HTML :** html baseUrl) |
|
|
273
|
+
| `ref` | Used to get a reference to a component instance | object | yes | All | yes |
|
|
274
|
+
| `injectedJavaScript?` | Set this to provide JavaScript that will be injected into the web page after the document finishes loading | string | No | All | yes |
|
|
275
|
+
| `originWhitelist?` | List of origin strings to allow being navigated to. | string[] | No | iOS,Android,macOS | No |
|
|
276
|
+
| `scalesPageToFit?` | Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. | boolean | No | Android | yes |
|
|
277
|
+
| `startInLoadingState?` | Boolean value that forces the WebView to show the loading view on the first load. | boolean | No | iOS,Android,macOS | No |
|
|
278
|
+
| `style?` | A style object that allow you to customize the WebView style. | Style | No | ALL | yes |
|
|
279
|
+
| `domStorageEnabled?` | Boolean value to control whether DOM Storage is enabled. Used only in Android and harmony. | boolean | No | Android | yes |
|
|
280
|
+
| `javaScriptEnabled?` | Boolean value to enable JavaScript in the WebView. | boolean | No | All | yes |
|
|
281
|
+
| `showsHorizontalScrollIndicator?` | Boolean value that determines whether a horizontal scroll indicator is shown in the WebView. | boolean | No | iOS,Android,macOS | yes |
|
|
282
|
+
| `showsVerticalScrollIndicator` | Boolean value that determines whether a vertical scroll indicator is shown in the WebView. | boolean | No | iOS,Android,macOS | yes |
|
|
283
|
+
| `ignoreSilentHardwareSwitch` | Boolean value that When set to true the hardware silent switch is ignored. | boolean | No | iOS | yes |
|
|
284
|
+
| `cacheEnabled?` | Sets whether WebView should use browser caching. | boolean | No | iOS,Android,macOS | yes |
|
|
285
|
+
| `cacheMode?` | Overrides the way the cache is used. | string | No | Android | yes |
|
|
286
|
+
| `textZoom?` | If the user has set a custom font size in the Android and harmony system, an undesirable scale of the site interface in WebView occurs. | number | No | Android | yes |
|
|
287
|
+
| `incognito?` | Does not store any data within the lifetime of the WebView. | boolean | NO | All | yes |
|
|
288
|
+
| `mediaPlaybackRequiresUserAction?` | Boolean that determines whether HTML5 audio and video requires the user to tap them before they start playing. The default value is `true`. (Android API minimum version 17). | boolean | NO | iOS,Android,macOS | yes |
|
|
289
|
+
| `geolocationEnabled?` | Set whether Geolocation is enabled in the `WebView`. The default value is `false`. Used only in Android. | boolean | NO | Android | yes |
|
|
290
|
+
| `fraudulentWebsiteWarningEnabled?` | A Boolean value that indicates whether the web view shows warnings for suspected fraudulent content, such as malware or phishing attempts. The default value is `true`. (iOS 13+) | boolean | NO | iOS | yes (该接口不生效,调用不会产生任何实际效果,非法和欺诈网站是强制启用的,鸿蒙OS当前实现如此。) |
|
|
291
|
+
| `userAgent?` | Sets the user-agent for the `WebView`. | string | NO | iOS,Android,macOS | yes |
|
|
292
|
+
| `minimumFontSize?` | Android enforces a minimum font size based on this value. A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. Default value is 8. If you are using smaller font sizes and are having trouble fitting the whole window onto one screen, try setting this to a smaller value. | number | No | Android | yes |
|
|
293
|
+
| `forceDarkOn?` | Configuring Dark Theme | boolean | No | Android | yes |
|
|
294
|
+
| `injectedJavaScriptBeforeContentLoaded?` | Set this to provide JavaScript that will be injected into the web page after the document element is created, but before other subresources finish loading. | string | No | iOS,Android,macOS | yes |
|
|
295
|
+
| `automaticallyAdjustContentInsets?` | Controls whether to adjust the content inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value is `true` | boolean | No | iOS | No |
|
|
296
|
+
| `automaticallyAdjustsScrollIndicatorInsets?` | Controls whether to adjust the scroll indicator inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value `false`. (iOS 13+) | boolean | No | iOS | No |
|
|
297
|
+
| `injectedJavaScriptBeforeContentLoadedForMainFrameOnly?` | If `true` (default; mandatory for Android), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame. | boolean | No | iOS | No |
|
|
298
|
+
| `nativeConfig?` | Override the native component used to render the WebView. Enables a custom native WebView which uses the same JavaScript as the original WebView. | object | No | iOS, Android, macOS | No |
|
|
299
|
+
| `decelerationRate?` | A floating-point number that determines how quickly the scroll view decelerates after the user lifts their finger. You may also use the string shortcuts `"normal"` and `"fast"` which match the underlying iOS | number | No | iOS | No |
|
|
300
|
+
| `javaScriptCanOpenWindowsAutomatically?` | A Boolean value indicating whether JavaScript can open windows without user interaction. The default value is `false`. | boolean | No | iOS, Android, macOS | No |
|
|
301
|
+
| `AndroidLayerType?` | Specifies the layer type. | string | No | Android | No |
|
|
302
|
+
| `mixedContentMode?` |Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin. | string | No | Android | No |
|
|
303
|
+
| `allowsFullscreenVideo?` | Boolean that determines whether videos are allowed to be played in fullscreen. The default value is false. | boolean | NO | Android | NO |
|
|
304
|
+
| `allowsInlineMediaPlayback?` | Boolean that determines whether HTML5 videos play inline or use the native full-screen controller. The default value is `false`. | boolean | NO | iOS | NO |
|
|
305
|
+
| `allowsAirPlayForMediaPlayback?` | A Boolean value indicating whether AirPlay is allowed. The default value is `false`. | boolean | NO | iOS and macOS | NO |
|
|
306
|
+
| `contentInset?` | The amount by which the web view content is inset from the edges of the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}. | object | NO | iOS | NO |
|
|
307
|
+
| `contentInsetAdjustmentBehavior?` | This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is "never". Available on iOS 11 and later. Defaults to `never`. | string | NO | iOS | NO |
|
|
308
|
+
| `contentMode?` | Controls the type of content to load. Available on iOS 13 and later. Defaults to `recommended`, which loads mobile content on iPhone & iPad Mini but desktop content on larger iPads. | string | No | iOS | NO |
|
|
309
|
+
| `dataDetectorTypes?` | Determines the types of data converted to clickable URLs in the web view's content. By default only phone numbers are detected. | string, or array | NO | ios | NO |
|
|
310
|
+
| `setBuiltInZoomControls?` | Sets whether the WebView should use its built-in zoom mechanisms. The default value is `true`. Setting this to `false` will prevent the use of a pinch gesture to control zooming. | boolean | NO | Android | NO |
|
|
311
|
+
| `setDisplayZoomControls?` | Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms (see `setBuiltInZoomControls`). The default value is `false`. | boolean | NO | Android | NO |
|
|
312
|
+
| `directionalLockEnabled?` | A Boolean value that determines whether scrolling is disabled in a particular direction. The default value is `true`. | boolean | NO | iOS | NO |
|
|
313
|
+
| `allowFileAccessFromFileURLs?` | Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. The default value is `false`. | boolean | NO | iOS, Android, macOS | NO |
|
|
314
|
+
| `allowUniversalAccessFromFileURLs?` | boolean | NO | No | iOS, Android, macOS | No |
|
|
315
|
+
| `allowingReadAccessToURL` | A String value that indicates which URLs the WebView's file can then reference in scripts, AJAX requests, and CSS imports. This is only used in for WebViews that are loaded with a `source.uri` set to a `'file://'` URL. If not provided, the default is to only allow read access to the URL provided in `source.uri` itself. | string | NO | iOS and macOS | NO |
|
|
316
|
+
| `keyboardDisplayRequiresUserAction?` | If `false`, web content can programmatically display the keyboard. The default value is `true`. | boolean | NO | iOS and macOS | NO |
|
|
317
|
+
| `hideKeyboardAccessoryView?` | If `true`, this will hide the keyboard accessory view (< > and Done). | boolean | NO | iOS | NO |
|
|
318
|
+
| `allowsBackForwardNavigationGestures?` | If `true`, this will be able horizontal swipe gestures. The default value is `false`. | boolean | NO | iOS | No |
|
|
319
|
+
| `allowFileAccess?` | If `true`, this will allow access to the file system via `file://` URI's. The default value is `false`. | boolean | NO | Android | NO |
|
|
320
|
+
| `saveFormDataDisabled?` | Sets whether the WebView should disable saving form data. The default value is `false`. This function does not have any effect from Android API level 26 onwards as there is an Autofill feature which stores form data. | boolean | NO | Android | NO |
|
|
321
|
+
| `pagingEnabled?` | If the value of this property is `true`, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is `false`. | boolean | NO | iOS | NO |
|
|
322
|
+
| `allowsLinkPreview?` | A Boolean value that determines whether pressing on a link displays a preview of the destination for the link. In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is `true`; before that, the default value is `false` | boolean | NO | iOS and macOS | NO |
|
|
323
|
+
| `sharedCookiesEnabled?` | Set `true` if shared cookies from `[NSHTTPCookieStorage sharedHTTPCookieStorage]` should be used for every load request in the WebView. The default value is `false`. For more on cookies, read the [Guide](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#Managing-Cookies) | boolean | NO | iOS and macOS | NO |
|
|
324
|
+
| `limitsNavigationsToAppBoundDomains?` | If `true` indicates to WebKit that a WKWebView will only navigate to app-bound domains. Only applicable for iOS 14 or greater. | boolean | NO | iOS | No |
|
|
325
|
+
| `textInteractionEnabled?` | If false indicates to WebKit that a WKWebView will not interact with text, thus not showing a text selection loop. Only applicable for iOS 14.5 or greater. | boolean | NO | iOS | NO |
|
|
326
|
+
| `suppressMenuItems?` | Allows to suppress menu item from the default context menu. | array of strings | NO | iOS | NO |
|
|
327
|
+
| `mediaCapturePermissionGrantType?` | This property specifies how to handle media capture permission requests. Defaults to `prompt`, resulting in the user being prompted repeatedly. Available on iOS 15 and later. | string | NO | iOS | yes |
|
|
328
|
+
| `autoManageStatusBarEnabled?` | If set to `true`, the status bar will be automatically hidden/shown by WebView, specifically when full screen video is being watched. If `false`, WebView will not manage the status bar at all. The default value is `true`. | boolean | NO | iOS | NO |
|
|
329
|
+
| `basicAuthCredential`? | object that specifies the credentials of a user to be used for basic authentication. | object | NO | iOS, Android | NO |
|
|
330
|
+
| `useWebView2?` | Use WinUI WebView2 control instead of WebView control as the native webview. The WebView2 control is a WinUI control that renders web content using the Microsoft Edge (Chromium) rendering engine. Option can be toggled at runtime and supports Fast Refresh. | boolean | NO | Windows | NO |
|
|
331
|
+
| `applicationNameForUserAgent?` | Append to the existing user-agent. Setting `userAgent` will override this. | string | No | All | yes |
|
|
332
|
+
| `thirdPartyCookiesEnabled?` | Boolean value to enable third party cookies in the `WebView`. Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS. The default value is `true`. | boolean | No | All | yes |
|
|
333
|
+
| `menuItems?` | An array of custom menu item objects that will be shown when selecting text. An empty array will suppress the menu | array of objects | No | iOS,Android | yes |
|
|
334
|
+
| `paymentRequestEnabled<sup>13.15.1+</sup>` | Whether or not the webview has the Payment Request API enabled.The default value is `false`. | boolean | No | Android | No |
|
|
335
|
+
| `allowsPictureInPictureMediaPlayback<sup>13.15.1+</sup>` | Boolean value that indicates whether HTML5 videos can play Picture in Picture.The default value is `false`. | boolean | No | Android | No |
|
|
336
|
+
| `refreshControlLightMode<sup>13.15.1+</sup>` | (ios only) Boolean value that determines whether the refresh control color is white or not.The default value is `false`. | boolean | No | iOS | No |
|
|
337
|
+
| `indicatorStyle <sup>13.15.1+</sup>` | The colorstyle of the scroll indicator. | string | No | iOS, Android | No |
|
|
338
|
+
| `renderMode` | This property is used to control the rendering mode of web components and is a property unique to OpenHarmony. enum: `SYNC_RENDER`(default), `ASYNC_RENDER` | string | No | - | Yes |
|
|
339
|
+
| `scrollEnabled` | Boolean value that determines whether scrolling is enabled in the WebView. The default value is true. Setting this to false will prevent the webview from moving the document body when the keyboard appears over an input. The default value is `false`. | boolean | No | iOS and macOS | Yes |
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
## 事件回调
|
|
343
|
+
|
|
344
|
+
> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
|
|
345
|
+
|
|
346
|
+
> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
|
|
347
|
+
|
|
348
|
+
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
349
|
+
|---------------------------------------------------------------| ------------------------------------------------------------ | -------- | -------- | ----------------------- |-------------------|
|
|
350
|
+
| `onScroll?: (event) => void` | Function that is invoked when the scroll event is fired in the `WebView`. | function | No | iOS and macOS | yes |
|
|
351
|
+
| `onHttpError?: (event) => void` | Function that is invoked when the `WebView` receives an http error. | function | No | yes | yes |
|
|
352
|
+
| `onLoadStart?: (event) => void` | Function that is invoked when the `WebView` starts loading. | function | No | All | yes |
|
|
353
|
+
| `onLoad?: (event) => void` | Function that is invoked when the `WebView` has finished loading. | function | No | All | yes |
|
|
354
|
+
| `onOpenWindow?` | Function that is invoked when the `WebView` should open a new window. | function | No | iOS, Android, macOS | No |
|
|
355
|
+
| `onLoadEnd?: (event) => void` | Function that is invoked when the WebView load succeeds or fails used. | function | No | All | yes |
|
|
356
|
+
| `onLoadProgress?: (event) => void` | Function that is invoked when the WebView is loading. | function | No | All | yes |
|
|
357
|
+
| `onMessage?: (event) => void` | Function that is invoked when the webview calls window.ReactNativeWebView.postMessage. | function | No | iOS,Android,macOS | yes |
|
|
358
|
+
| `onShouldStartLoadWithRequest?: (event) => void` | Function that allows custom handling of any web view requests. This feature needs to be used in conjunction with worker threads, and the relevant configuration can be set according to step three of [the worker threads](https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/TurboModule.md#%E8%AE%BE%E7%BD%AE%E8%87%AA%E5%AE%9A%E4%B9%89turbomodule%E8%BF%90%E8%A1%8C%E5%9C%A8worker%E7%BA%BF%E7%A8%8B).| function | No | iOS,Android,macOS | yes |
|
|
359
|
+
| `onContentProcessDidTerminate: (event) => void` | Function that is invoked when the `WebView` content process is terminated. | function | No | iOS and macOS WKWebView | No |
|
|
360
|
+
| `renderLoading?` | Function that returns a loading indicator. The `startInLoadingState` prop must be set to `true` in order to use this prop. | function | No | iOS, Android, macOS | No |
|
|
361
|
+
| `onCustomMenuSelection?` | Function called when a custom menu item is selected. It receives a Native event, which includes three custom keys: `label`, `key` and `selectedText`. | function | NO | iOS, Android | yes |
|
|
362
|
+
| `onNavigationStateChange?: (event) => void` | Function that is invoked when the WebView loading starts or ends. | function | NO | iOS, Android | yes |
|
|
363
|
+
| `onError: (event) => void` | Callback function for handling load errors. | function | NO | iOS,Android | yes |
|
|
364
|
+
| `onLoadSubResourceError: (event) => void <sup>13.16.1+</sup>` | Function that is sub resource SSL error handling. | function | NO | Android | yes |
|
|
365
|
+
## 静态方法
|
|
366
|
+
|
|
367
|
+
> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
|
|
368
|
+
|
|
369
|
+
> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
|
|
370
|
+
|
|
371
|
+
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
372
|
+
| ---------------------------------- | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- |
|
|
373
|
+
| `goForward()` | Go forward one page in the web view's history. | function | No | All | yes |
|
|
374
|
+
| `goBack()` | Go back one page in the web view's history. | function | No | All | yes |
|
|
375
|
+
| `reload()` | Reloads the current page. | function | No | All | yes |
|
|
376
|
+
| `stopLoading()` | Stop loading the current page. | function | No | All | yes |
|
|
377
|
+
| `injectJavaScript(script: string)` | This function corresponds to the completion handler in Apple's recovery user interface ForPictureInPictureStop. IMPORTANT: This function must be called after calling onRestoreUserInterfaceForPictureInPictureStop. | function | No | All | yes |
|
|
378
|
+
| `requestFocus()` | Request the webView to ask for focus. (People working on TV apps might want having a look at this!) | function | No | All | yes |
|
|
379
|
+
| `postMessage(data:string)` | Post a message to WebView, handled by `onMessage`. | function | No | All | yes |
|
|
380
|
+
| `clearFormData()` | Removes the autocomplete popup from the currently focused form field, if present. | function | No | Android | No |
|
|
381
|
+
| `clearCache(status:boolean)` | Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used. | function | No | All | yes |
|
|
382
|
+
| `clearHistory()` | Tells this WebView to clear its internal back/forward list. | function | No | Android | yes |
|
|
383
|
+
|
|
384
|
+
## 遗留问题
|
|
385
|
+
|
|
386
|
+
- [ ] webview 部分属性未实现 HarmonyOS 化[issue#17](https://gitcode.com/openharmony-sig/rntpc_react-native-webview/issues/17)
|
|
387
|
+
- [ ] webview 部分属性未实现 HarmonyOS 化[issue#200](https://github.com/react-native-oh-library/react-native-webview/issues/200)
|
|
388
|
+
- [ ] V13.15.1 新增属性未实现 HarmonyOS 化[issue#2](https://gitcode.com/openharmony-sig/rntpc_react-native-webview/issues/2)
|
|
389
|
+
- [X] 中文乱码[issue#18](https://github.com/react-native-oh-library/react-native-webview/issues/18)
|
|
390
|
+
|
|
391
|
+
## 其他
|
|
392
|
+
|
|
393
|
+
## 开源协议
|
|
394
|
+
|
|
395
|
+
本项目基于 [The MIT License (MIT)](https://github.com/react-native-webview/react-native-webview/blob/master/LICENSE) ,请自由地享受和参与开源。
|
|
396
|
+
|