@react-native-ohos/react-native-webview 13.10.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/harmony/rn_webview/BuildProfile.ets +41 -0
  4. package/harmony/rn_webview/LICENSE +21 -0
  5. package/harmony/rn_webview/NOTICE +33 -0
  6. package/harmony/rn_webview/OAT.xml +45 -0
  7. package/harmony/rn_webview/README.OpenSource +11 -0
  8. package/harmony/rn_webview/build-profile.json5 +28 -0
  9. package/harmony/rn_webview/consumer-rules.txt +0 -0
  10. package/harmony/rn_webview/hvigorfile.ts +1 -0
  11. package/harmony/rn_webview/index.ets +34 -0
  12. package/harmony/rn_webview/obfuscation-rules.txt +18 -0
  13. package/harmony/rn_webview/oh-package.json5 +13 -0
  14. package/harmony/rn_webview/src/main/cpp/CMakeLists.txt +9 -0
  15. package/harmony/rn_webview/src/main/cpp/WebViewPackage.h +37 -0
  16. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/BaseReactNativeWebviewPackage.h +95 -0
  17. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +126 -0
  18. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.cpp +20 -0
  19. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.h +16 -0
  20. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.cpp +19 -0
  21. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.h +16 -0
  22. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ComponentDescriptors.h +22 -0
  23. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.cpp +240 -0
  24. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.h +285 -0
  25. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +151 -0
  26. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +337 -0
  27. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.cpp +19 -0
  28. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.h +34 -0
  29. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.cpp +16 -0
  30. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.h +20 -0
  31. package/harmony/rn_webview/src/main/ets/CutomReference.ts +50 -0
  32. package/harmony/rn_webview/src/main/ets/Logger.ts +64 -0
  33. package/harmony/rn_webview/src/main/ets/Magic.ets +205 -0
  34. package/harmony/rn_webview/src/main/ets/RNCWebView.ets +607 -0
  35. package/harmony/rn_webview/src/main/ets/RNCWebViewPackage.ets +66 -0
  36. package/harmony/rn_webview/src/main/ets/ShouldRequestUrl.ts +68 -0
  37. package/harmony/rn_webview/src/main/ets/WebViewBaseOperate.ets +463 -0
  38. package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +78 -0
  39. package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +509 -0
  40. package/harmony/rn_webview/src/main/ets/generated/components/ts.ts +5 -0
  41. package/harmony/rn_webview/src/main/ets/generated/index.ets +5 -0
  42. package/harmony/rn_webview/src/main/ets/generated/ts.ts +6 -0
  43. package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebView.ts +18 -0
  44. package/harmony/rn_webview/src/main/ets/generated/turboModules/RNCWebViewModule.ts +16 -0
  45. package/harmony/rn_webview/src/main/ets/generated/turboModules/ts.ts +6 -0
  46. package/harmony/rn_webview/src/main/module.json5 +11 -0
  47. package/harmony/rn_webview/src/main/resources/base/element/string.json +40 -0
  48. package/harmony/rn_webview/src/main/resources/en_US/element/string.json +40 -0
  49. package/harmony/rn_webview/src/main/resources/zh_CN/element/string.json +40 -0
  50. package/harmony/rn_webview/src/test/List.test.ets +5 -0
  51. package/harmony/rn_webview/src/test/LocalUnit.test.ets +33 -0
  52. package/harmony/rn_webview/ts.ets +29 -0
  53. package/harmony/rn_webview.har +0 -0
  54. package/package.json +107 -0
  55. package/src/NativeRNCWebView.ts +16 -0
  56. package/src/NativeRNCWebViewModule.ts +17 -0
  57. package/src/RNCWebViewNativeComponent.ts +286 -0
  58. package/src/WebView.harmony.tsx +330 -0
  59. package/src/WebView.tsx +4 -0
  60. package/src/codegenUtils.ts +9 -0
  61. package/src/index.ts +4 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import hilog from '@ohos.hilog';
26
+
27
+ class Logger {
28
+ private domain: number;
29
+ private prefix: string;
30
+ private format: string = '%{public}s, %{public}s';
31
+ private isDebug: boolean;
32
+
33
+ /**
34
+ * constructor.
35
+ *
36
+ * @param Prefix Identifies the log tag.
37
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
38
+ */
39
+ constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
40
+ this.prefix = prefix;
41
+ this.domain = domain;
42
+ this.isDebug = isDebug;
43
+ }
44
+
45
+ debug(...args: string[]): void {
46
+ if (this.isDebug) {
47
+ hilog.debug(this.domain, this.prefix, this.format, args);
48
+ }
49
+ }
50
+
51
+ info(...args: string[]): void {
52
+ hilog.info(this.domain, this.prefix, this.format, args);
53
+ }
54
+
55
+ warn(...args: string[]): void {
56
+ hilog.warn(this.domain, this.prefix, this.format, args);
57
+ }
58
+
59
+ error(...args: string[]): void {
60
+ hilog.error(this.domain, this.prefix, this.format, args);
61
+ }
62
+ }
63
+
64
+ export default new Logger('WebView', 0xFF00, false)
@@ -0,0 +1,205 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Descriptor, ViewBaseProps, ViewDescriptorWrapperBase, ViewRawProps } from '@rnoh/react-native-openharmony'
26
+
27
+ export class WebViewNewSourceHeader {
28
+ name?: string
29
+ value?: string
30
+ }
31
+
32
+
33
+ export class WebViewNewSource {
34
+ uri?: string | Resource
35
+ method?: string
36
+ body?: string
37
+ headers?: WebViewNewSourceHeader[]
38
+ html?: string
39
+ baseUrl?: string
40
+ }
41
+
42
+ export interface AlertEvent {
43
+ url: string;
44
+ message: string;
45
+ result: JsResult;
46
+ }
47
+
48
+ export const TAG = "WebView"
49
+
50
+ export const WEB_VIEW = "RNCWebView"
51
+
52
+ export const JAVASCRIPT_INTERFACE = "ReactNativeWebView";
53
+
54
+ export interface WebViewProps extends ViewRawProps {
55
+ width: number
56
+ height: number
57
+ newSource: WebViewNewSource
58
+ javaScriptEnabled: boolean
59
+ injectedJavaScript: string
60
+ messagingEnabled: boolean
61
+ showsHorizontalScrollIndicator: boolean
62
+ showsVerticalScrollIndicator: boolean
63
+ textZoom: number
64
+ cacheEnabled: boolean
65
+ cacheMode: CACHE_MODE
66
+ domStorageEnabled: boolean
67
+ scalesPageToFit: boolean
68
+ messagingModuleName: string
69
+ webviewDebuggingEnabled: boolean
70
+ scrollEnabled: boolean
71
+ incognito: boolean
72
+ userAgent: string
73
+ shouldStartLoadWithRequestEnabled: boolean
74
+ originWhitelist: Array<string>
75
+ thirdPartyCookiesEnabled: boolean
76
+ fraudulentWebsiteWarningEnabled: boolean
77
+ ignoreSilentHardwareSwitch: boolean
78
+ forceDarkOn: boolean
79
+ minimumFontSize: number
80
+ bounces: boolean
81
+ injectedJavaScriptBeforeContentLoaded: string
82
+ overScrollMode: WebViewOverScrollMode,
83
+ mediaPlaybackRequiresUserAction: boolean
84
+ geolocationEnabled: boolean
85
+ applicationNameForUserAgent: string
86
+ pullToRefreshEnabled: boolean
87
+ schemeList: Array<string>
88
+ }
89
+
90
+
91
+ export class RNCWebViewBridge {
92
+ postMessage!: (data: string) => void;
93
+ }
94
+
95
+ export class WebViewEventParams {
96
+ type: string
97
+ url?: string
98
+ loading?: boolean
99
+ title?: string
100
+ canGoBack?: boolean
101
+ canGoForward?: boolean
102
+ lockIdentifier?: number
103
+ data?: string
104
+
105
+ constructor(type: string) {
106
+ this.type = type
107
+ }
108
+ }
109
+
110
+ export enum CACHE_MODE {
111
+ 'LOAD_DEFAULT' = 'LOAD_DEFAULT',
112
+ 'LOAD_CACHE_ELSE_NETWORK' = 'LOAD_CACHE_ELSE_NETWORK',
113
+ 'LOAD_NO_CACHE' = 'LOAD_NO_CACHE',
114
+ 'LOAD_CACHE_ONLY' = 'LOAD_CACHE_ONLY',
115
+ }
116
+
117
+ export class ResultType {
118
+ url: string
119
+ loading: boolean
120
+ title: string
121
+ canGoBack: boolean
122
+ canGoForward: boolean
123
+ lockIdentifier: number
124
+ data: string
125
+
126
+ constructor(url: string, loading: boolean, title: string, canGoBack: boolean, canGoForward: boolean,
127
+ lockIdentifier: number, data: string) {
128
+ this.url = url
129
+ this.loading = loading
130
+ this.title = title
131
+ this.canGoBack = canGoBack
132
+ this.canGoForward = canGoForward
133
+ this.lockIdentifier = lockIdentifier
134
+ this.data = data
135
+ }
136
+ }
137
+
138
+ interface WebViewState {}
139
+
140
+ export type WebViewDescriptor = Descriptor<"WebView", ViewBaseProps, WebViewState, WebViewProps>
141
+
142
+ export class WebViewViewDescriptorWrapper extends ViewDescriptorWrapperBase<"WebView", ViewBaseProps, WebViewState, WebViewProps> {
143
+ }
144
+
145
+
146
+ export const ZERO: number = 0
147
+
148
+ export const EIGHT: number = 8;
149
+
150
+ export const ONE_HUNDRED: number = 100
151
+
152
+ export const REFRESH_OFFSET: number = 120
153
+
154
+ export const MINHEIGHT: number = 1
155
+
156
+ export interface ProgressInterface {
157
+ progress: number;
158
+ }
159
+
160
+ export interface LoadingErrorInterface {
161
+ code: number,
162
+ description: string
163
+ }
164
+
165
+ export interface ScrollInterface {
166
+ x: number,
167
+ y: number
168
+ }
169
+
170
+ export enum WebViewOverScrollMode {
171
+ ALWAYS = "always",
172
+ NEVER = "never"
173
+ }
174
+
175
+ export enum COMMAND_NAME {
176
+ INJECTJAVASCRIPT = 'injectJavaScript',
177
+ POSTMESSAGE = 'postMessage',
178
+ RELOAD = 'reload',
179
+ GOBACK = 'goBack',
180
+ GOFORWARD = 'goForward',
181
+ REQUESTFOCUS = 'requestFocus',
182
+ CLEARCACHE = 'clearCache',
183
+ CLEARHISTORY = 'clearHistory',
184
+ STOPLOADING = 'stopLoading',
185
+ LOADURL = 'loadUrl'
186
+ }
187
+
188
+ interface RenderExitReasonMessageItem {
189
+ errorDomain: string
190
+ errorDesc: string
191
+ }
192
+
193
+ export const RenderExitReasonMessage = new Map<number, RenderExitReasonMessageItem>()
194
+
195
+ RenderExitReasonMessage.set(0,
196
+ { errorDomain: 'ProcessAbnormalTermination', errorDesc: "The rendering process exits abnormally." })
197
+ RenderExitReasonMessage.set(1,
198
+ { errorDomain: 'ProcessWasKilled', errorDesc: "SIGKILL is received or manually terminated." })
199
+ RenderExitReasonMessage.set(2,
200
+ { errorDomain: 'ProcessCrashed', errorDesc: "The rendering process crashes and exits, such as a segment error." })
201
+ RenderExitReasonMessage.set(3,
202
+ { errorDomain: 'ProcessOom', errorDesc: "The program is out of memory." })
203
+ RenderExitReasonMessage.set(4,
204
+ { errorDomain: 'ProcessExitUnknown', errorDesc: "Other reasons." })
205
+