@react-native-ohos/react-native-webview 13.10.5-rc.2 → 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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/README.OpenSource +11 -0
  3. package/README.md +2 -2
  4. package/harmony/rn_webview/index.ets +4 -25
  5. package/harmony/rn_webview/oh-package.json5 +2 -2
  6. package/harmony/rn_webview/src/main/cpp/WebViewPackage.h +4 -24
  7. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/BaseReactNativeWebviewPackage.h +69 -69
  8. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/components/RNCWebViewJSIBinder.h +109 -116
  9. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebView.cpp +1 -3
  10. package/harmony/rn_webview/src/main/cpp/generated/RNOH/generated/turbo_modules/RNCWebViewModule.cpp +1 -3
  11. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ComponentDescriptors.h +7 -5
  12. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.cpp +231 -230
  13. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/EventEmitters.h +250 -272
  14. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.cpp +62 -110
  15. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/Props.h +494 -322
  16. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.cpp +4 -6
  17. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/ShadowNodes.h +7 -9
  18. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.cpp +5 -5
  19. package/harmony/rn_webview/src/main/cpp/generated/react/renderer/components/react_native_webview/States.h +14 -5
  20. package/harmony/rn_webview/src/main/ets/CutomReference.ts +3 -23
  21. package/harmony/rn_webview/src/main/ets/Logger.ts +3 -23
  22. package/harmony/rn_webview/src/main/ets/Magic.ets +3 -24
  23. package/harmony/rn_webview/src/main/ets/RNCWebView.ets +7 -81
  24. package/harmony/rn_webview/src/main/ets/RNCWebViewPackage.ets +5 -33
  25. package/harmony/rn_webview/src/main/ets/ShouldRequestUrl.ts +3 -23
  26. package/harmony/rn_webview/src/main/ets/WebViewBaseOperate.ets +3 -23
  27. package/harmony/rn_webview/src/main/ets/WebViewTurboModule.ets +3 -23
  28. package/harmony/rn_webview/src/main/ets/generated/components/RNCWebView.ts +47 -32
  29. package/harmony/rn_webview/ts.ets +3 -23
  30. package/harmony/rn_webview.har +0 -0
  31. package/package.json +11 -16
  32. package/src/NativeRNCWebView.ts +6 -0
  33. package/src/NativeRNCWebViewModule.ts +5 -3
  34. package/src/RNCWebViewNativeComponent.ts +158 -90
  35. package/src/WebView.harmony.tsx +17 -4
  36. package/src/WebView.tsx +6 -0
  37. package/src/codegenUtils.ts +5 -3
  38. package/src/index.ts +6 -0
  39. package/harmony/rn_webview/BuildProfile.ets +0 -41
  40. package/harmony/rn_webview/LICENSE +0 -21
  41. package/harmony/rn_webview/NOTICE +0 -33
  42. package/harmony/rn_webview/README.OpenSource +0 -11
  43. package/harmony/rn_webview/consumer-rules.txt +0 -0
  44. package/harmony/rn_webview/obfuscation-rules.txt +0 -18
@@ -9,329 +9,501 @@
9
9
  */
10
10
  #pragma once
11
11
 
12
+ #include <cinttypes>
12
13
  #include <react/renderer/components/view/ViewProps.h>
13
14
  #include <react/renderer/core/PropsParserContext.h>
15
+ #include <react/renderer/core/propsConversions.h>
14
16
  #include <vector>
15
17
 
16
- namespace facebook {
17
- namespace react {
18
- enum class RNCWebViewAndroidLayerType {
19
- None,
20
- Software,
21
- Hardware
22
- };
23
- static RNCWebViewAndroidLayerType parseAndroidLayerType(const std::string& string)
24
- {
25
- if (string == "none") {
26
- return RNCWebViewAndroidLayerType::None;
27
- }
28
- if (string == "software") {
29
- return RNCWebViewAndroidLayerType::Software;
30
- }
31
- if (string == "hardware") {
32
- return RNCWebViewAndroidLayerType::Hardware;
33
- }
34
- throw std::runtime_error("Unexpected value for RNCWebViewAndroidLayerType: " + string);
35
- }
36
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
37
- RNCWebViewAndroidLayerType &result)
38
- {
39
- auto string = (std::string)value;
40
- result = parseAndroidLayerType(string);
41
- }
42
-
43
- static inline std::string toString(const RNCWebViewAndroidLayerType &value)
44
- {
45
- switch (value) {
46
- case RNCWebViewAndroidLayerType::None:
47
- return "none";
48
- case RNCWebViewAndroidLayerType::Software:
49
- return "software";
50
- case RNCWebViewAndroidLayerType::Hardware:
51
- return "hardware";
52
- }
53
- }
54
- enum class RNCWebViewCacheMode {
55
- LOAD_DEFAULT,
56
- LOAD_CACHE_ELSE_NETWORK,
57
- LOAD_NO_CACHE,
58
- LOAD_CACHE_ONLY
59
- };
60
- static RNCWebViewCacheMode parseCacheMode(const std::string& string)
61
- {
62
- if (string == "LOAD_DEFAULT") {
63
- return RNCWebViewCacheMode::LOAD_DEFAULT;
64
- }
65
- if (string == "LOAD_CACHE_ELSE_NETWORK") {
66
- return RNCWebViewCacheMode::LOAD_CACHE_ELSE_NETWORK;
67
- }
68
- if (string == "LOAD_NO_CACHE") {
69
- return RNCWebViewCacheMode::LOAD_NO_CACHE;
70
- }
71
- if (string == "LOAD_CACHE_ONLY") {
72
- return RNCWebViewCacheMode::LOAD_CACHE_ONLY;
73
- }
74
- throw std::runtime_error("Unexpected value for RNCWebViewCacheMode: " + string);
75
- }
76
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
77
- RNCWebViewCacheMode &result)
78
- {
79
- auto string = (std::string)value;
80
- result = parseCacheMode(string);
81
- }
82
- static inline std::string toString(const RNCWebViewCacheMode &value)
83
- {
84
- switch (value) {
85
- case RNCWebViewCacheMode::LOAD_DEFAULT: return "LOAD_DEFAULT";
86
- case RNCWebViewCacheMode::LOAD_CACHE_ELSE_NETWORK: return "LOAD_CACHE_ELSE_NETWORK";
87
- case RNCWebViewCacheMode::LOAD_NO_CACHE: return "LOAD_NO_CACHE";
88
- case RNCWebViewCacheMode::LOAD_CACHE_ONLY: return "LOAD_CACHE_ONLY";
89
- }
90
- }
91
- enum class RNCWebViewMixedContentMode {
92
- Never,
93
- Always,
94
- Compatibility
95
- };
96
- static RNCWebViewMixedContentMode parseMixedContentMode(const std::string& string)
97
- {
98
- if (string == "never") {
99
- return RNCWebViewMixedContentMode::Never;
100
- }
101
- if (string == "always") {
102
- return RNCWebViewMixedContentMode::Always;
103
- }
104
- if (string == "compatibility") {
105
- return RNCWebViewMixedContentMode::Compatibility;
106
- }
107
- throw std::runtime_error("Unexpected value for RNCWebViewMixedContentMode: " + string);
108
- }
109
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
110
- RNCWebViewMixedContentMode &result)
111
- {
112
- auto string = (std::string)value;
113
- result = parseMixedContentMode(string);
114
- }
115
-
116
- static inline std::string toString(const RNCWebViewMixedContentMode &value)
117
- {
118
- switch (value) {
119
- case RNCWebViewMixedContentMode::Never:
120
- return "never";
121
- case RNCWebViewMixedContentMode::Always:
122
- return "always";
123
- case RNCWebViewMixedContentMode::Compatibility:
124
- return "compatibility";
125
- }
126
- }
127
- enum class RNCWebViewContentInsetAdjustmentBehavior {
128
- Never,
129
- Automatic,
130
- ScrollableAxes,
131
- Always
132
- };
133
- static RNCWebViewContentInsetAdjustmentBehavior parseBehavior(const std::string& string)
134
- {
135
- if (string == "never") {
136
- return RNCWebViewContentInsetAdjustmentBehavior::Never;
137
- }
138
- if (string == "automatic") {
139
- return RNCWebViewContentInsetAdjustmentBehavior::Automatic;
140
- }
141
- if (string == "scrollableAxes") {
142
- return RNCWebViewContentInsetAdjustmentBehavior::ScrollableAxes;
143
- }
144
- if (string == "always") {
145
- return RNCWebViewContentInsetAdjustmentBehavior::Always;
146
- }
147
- throw std::runtime_error("Unexpected value for RNCWebViewContentInsetAdjustmentBehavior: " + string);
148
- }
149
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
150
- RNCWebViewContentInsetAdjustmentBehavior &result)
151
- {
152
- auto string = (std::string)value;
153
- result = parseBehavior(string);
154
- }
155
- static inline std::string toString(const RNCWebViewContentInsetAdjustmentBehavior &value)
156
- {
157
- switch (value) {
158
- case RNCWebViewContentInsetAdjustmentBehavior::Never:
159
- return "never";
160
- case RNCWebViewContentInsetAdjustmentBehavior::Automatic:
161
- return "automatic";
162
- case RNCWebViewContentInsetAdjustmentBehavior::ScrollableAxes:
163
- return "scrollableAxes";
164
- case RNCWebViewContentInsetAdjustmentBehavior::Always:
165
- return "always";
166
- }
167
- }
168
- enum class RNCWebViewContentMode {
169
- Recommended,
170
- Mobile,
171
- Desktop
172
- };
173
- static RNCWebViewContentMode parseContentMode(const std::string& string)
174
- {
175
- if (string == "recommended") {
176
- return RNCWebViewContentMode::Recommended;
177
- }
178
- if (string == "mobile") {
179
- return RNCWebViewContentMode::Mobile;
180
- }
181
- if (string == "desktop") {
182
- return RNCWebViewContentMode::Desktop;
183
- }
184
- throw std::runtime_error("Unexpected value for RNCWebViewContentMode: " + string);
185
- }
186
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
187
- RNCWebViewContentMode &result)
188
- {
189
- auto string = (std::string)value;
190
- result = parseContentMode(string);
191
- }
192
- static inline std::string toString(const RNCWebViewContentMode &value)
193
- {
194
- switch (value) {
195
- case RNCWebViewContentMode::Recommended:
196
- return "recommended";
197
- case RNCWebViewContentMode::Mobile:
198
- return "mobile";
199
- case RNCWebViewContentMode::Desktop:
200
- return "desktop";
201
- }
202
- }
203
- enum class RNCWebViewMediaCapturePermissionGrantType {
204
- Prompt,
205
- Grant,
206
- Deny,
207
- GrantIfSameHostElsePrompt,
208
- GrantIfSameHostElseDeny
209
- };
210
- static RNCWebViewMediaCapturePermissionGrantType parseMCPGType(const std::string& string)
211
- {
212
- if (string == "prompt") {
213
- return RNCWebViewMediaCapturePermissionGrantType::Prompt;
214
- }
215
- if (string == "grant") {
216
- return RNCWebViewMediaCapturePermissionGrantType::Grant;
217
- }
218
- if (string == "deny") {
219
- return RNCWebViewMediaCapturePermissionGrantType::Deny;
220
- }
221
- if (string == "grantIfSameHostElsePrompt") {
222
- return RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElsePrompt;
223
- }
224
- if (string == "grantIfSameHostElseDeny") {
225
- return RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElseDeny;
226
- }
227
- throw std::runtime_error("Unexpected value for RNCWebViewMediaCapturePermissionGrantType: " + string);
228
- }
229
- static inline void fromRawValue(const PropsParserContext &context, const RawValue &value,
230
- RNCWebViewMediaCapturePermissionGrantType &result)
231
- {
232
- auto string = (std::string)value;
233
- result = parseMCPGType(string);
234
- }
235
- static inline std::string toString(const RNCWebViewMediaCapturePermissionGrantType &value)
236
- {
237
- switch (value) {
238
- case RNCWebViewMediaCapturePermissionGrantType::Prompt: return "prompt";
239
- case RNCWebViewMediaCapturePermissionGrantType::Grant: return "grant";
240
- case RNCWebViewMediaCapturePermissionGrantType::Deny: return "deny";
241
- case RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElsePrompt:
242
- return "grantIfSameHostElsePrompt";
243
- case RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElseDeny:
244
- return "grantIfSameHostElseDeny";
245
- }
246
- }
247
-
248
- class RNCWebViewProps final : public ViewProps {
249
- public:
250
- RNCWebViewProps() = default;
251
- RNCWebViewProps(const PropsParserContext &context, const RNCWebViewProps &sourceProps,
252
- const RawProps &rawProps);
253
-
254
- #pragma mark - Props
255
-
256
- bool allowFileAccess{false};
257
- bool allowsProtectedMedia{false};
258
- bool allowsFullscreenVideo{false};
259
- RNCWebViewAndroidLayerType androidLayerType{RNCWebViewAndroidLayerType::None};
260
- RNCWebViewCacheMode cacheMode{RNCWebViewCacheMode::LOAD_DEFAULT};
261
- bool domStorageEnabled{false};
262
- std::string downloadingMessage{};
263
- bool forceDarkOn{false};
264
- bool geolocationEnabled{false};
265
- std::string lackPermissionToDownloadMessage{};
266
- std::string messagingModuleName{};
267
- int minimumFontSize{0};
268
- RNCWebViewMixedContentMode mixedContentMode{RNCWebViewMixedContentMode::Never};
269
- bool nestedScrollEnabled{false};
270
- std::string overScrollMode{};
271
- bool saveFormDataDisabled{false};
272
- bool scalesPageToFit{false};
273
- bool setBuiltInZoomControls{false};
274
- bool setDisplayZoomControls{false};
275
- bool setSupportMultipleWindows{false};
276
- int textZoom{0};
277
- bool thirdPartyCookiesEnabled{false};
278
- bool hasOnScroll{false};
279
- std::string injectedJavaScriptObject{};
280
- std::string allowingReadAccessToURL{};
281
- bool allowsBackForwardNavigationGestures{false};
282
- bool allowsInlineMediaPlayback{false};
283
- bool allowsAirPlayForMediaPlayback{false};
284
- bool allowsLinkPreview{false};
285
- bool automaticallyAdjustContentInsets{false};
286
- bool ignoreSilentHardwareSwitch{false};
287
- bool autoManageStatusBarEnabled{false};
288
- bool bounces{false};
289
- folly::dynamic contentInset{};
290
- RNCWebViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior{
291
- RNCWebViewContentInsetAdjustmentBehavior::Never};
292
- RNCWebViewContentMode contentMode{RNCWebViewContentMode::Recommended};
293
- folly::dynamic dataDetectorTypes{};
294
- double decelerationRate{0.0};
295
- bool directionalLockEnabled{false};
296
- bool enableApplePay{false};
297
- bool hideKeyboardAccessoryView{false};
298
- bool keyboardDisplayRequiresUserAction{false};
299
- bool limitsNavigationsToAppBoundDomains{false};
300
- RNCWebViewMediaCapturePermissionGrantType mediaCapturePermissionGrantType{
301
- RNCWebViewMediaCapturePermissionGrantType::Prompt};
302
- bool pagingEnabled{false};
303
- bool pullToRefreshEnabled{false};
304
- bool scrollEnabled{false};
305
- bool sharedCookiesEnabled{false};
306
- bool textInteractionEnabled{false};
307
- bool useSharedProcessPool{false};
308
- folly::dynamic menuItems{};
309
- std::vector<folly::dynamic> suppressMenuItems{};
310
- bool hasOnFileDownload{false};
311
- bool fraudulentWebsiteWarningEnabled{false};
312
- bool allowFileAccessFromFileURLs{false};
313
- bool allowUniversalAccessFromFileURLs{false};
314
- std::string applicationNameForUserAgent{};
315
- folly::dynamic basicAuthCredential{};
316
- bool cacheEnabled{false};
317
- bool incognito{false};
318
- std::string injectedJavaScript{};
319
- std::string injectedJavaScriptBeforeContentLoaded{};
320
- bool injectedJavaScriptForMainFrameOnly{false};
321
- bool injectedJavaScriptBeforeContentLoadedForMainFrameOnly{false};
322
- bool javaScriptCanOpenWindowsAutomatically{false};
323
- bool javaScriptEnabled{false};
324
- bool webviewDebuggingEnabled{false};
325
- bool mediaPlaybackRequiresUserAction{false};
326
- bool messagingEnabled{false};
327
- bool shouldStartLoadWithRequestEnabled{false};
328
- bool hasOnOpenWindowEvent{false};
329
- bool showsHorizontalScrollIndicator{false};
330
- bool showsVerticalScrollIndicator{false};
331
- folly::dynamic newSource{};
332
- std::string userAgent{};
333
- folly::dynamic schemeList{};
334
- };
335
-
336
- } // namespace react
337
- } // namespace facebook
18
+ namespace facebook::react {
19
+
20
+ enum class RNCWebViewAndroidLayerType { None, Software, Hardware };
21
+
22
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewAndroidLayerType &result) {
23
+ auto string = (std::string)value;
24
+ if (string == "none") { result = RNCWebViewAndroidLayerType::None; return; }
25
+ if (string == "software") { result = RNCWebViewAndroidLayerType::Software; return; }
26
+ if (string == "hardware") { result = RNCWebViewAndroidLayerType::Hardware; return; }
27
+ abort();
28
+ }
29
+
30
+ static inline std::string toString(const RNCWebViewAndroidLayerType &value) {
31
+ switch (value) {
32
+ case RNCWebViewAndroidLayerType::None: return "none";
33
+ case RNCWebViewAndroidLayerType::Software: return "software";
34
+ case RNCWebViewAndroidLayerType::Hardware: return "hardware";
35
+ }
36
+ }
37
+ enum class RNCWebViewCacheMode { LOAD_DEFAULT, LOAD_CACHE_ELSE_NETWORK, LOAD_NO_CACHE, LOAD_CACHE_ONLY };
38
+
39
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewCacheMode &result) {
40
+ auto string = (std::string)value;
41
+ if (string == "LOAD_DEFAULT") { result = RNCWebViewCacheMode::LOAD_DEFAULT; return; }
42
+ if (string == "LOAD_CACHE_ELSE_NETWORK") { result = RNCWebViewCacheMode::LOAD_CACHE_ELSE_NETWORK; return; }
43
+ if (string == "LOAD_NO_CACHE") { result = RNCWebViewCacheMode::LOAD_NO_CACHE; return; }
44
+ if (string == "LOAD_CACHE_ONLY") { result = RNCWebViewCacheMode::LOAD_CACHE_ONLY; return; }
45
+ abort();
46
+ }
47
+
48
+ static inline std::string toString(const RNCWebViewCacheMode &value) {
49
+ switch (value) {
50
+ case RNCWebViewCacheMode::LOAD_DEFAULT: return "LOAD_DEFAULT";
51
+ case RNCWebViewCacheMode::LOAD_CACHE_ELSE_NETWORK: return "LOAD_CACHE_ELSE_NETWORK";
52
+ case RNCWebViewCacheMode::LOAD_NO_CACHE: return "LOAD_NO_CACHE";
53
+ case RNCWebViewCacheMode::LOAD_CACHE_ONLY: return "LOAD_CACHE_ONLY";
54
+ }
55
+ }
56
+ enum class RNCWebViewMixedContentMode { Never, Always, Compatibility };
57
+
58
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewMixedContentMode &result) {
59
+ auto string = (std::string)value;
60
+ if (string == "never") { result = RNCWebViewMixedContentMode::Never; return; }
61
+ if (string == "always") { result = RNCWebViewMixedContentMode::Always; return; }
62
+ if (string == "compatibility") { result = RNCWebViewMixedContentMode::Compatibility; return; }
63
+ abort();
64
+ }
65
+
66
+ static inline std::string toString(const RNCWebViewMixedContentMode &value) {
67
+ switch (value) {
68
+ case RNCWebViewMixedContentMode::Never: return "never";
69
+ case RNCWebViewMixedContentMode::Always: return "always";
70
+ case RNCWebViewMixedContentMode::Compatibility: return "compatibility";
71
+ }
72
+ }
73
+ enum class RNCWebViewContentInsetAdjustmentBehavior { Never, Automatic, ScrollableAxes, Always };
74
+
75
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewContentInsetAdjustmentBehavior &result) {
76
+ auto string = (std::string)value;
77
+ if (string == "never") { result = RNCWebViewContentInsetAdjustmentBehavior::Never; return; }
78
+ if (string == "automatic") { result = RNCWebViewContentInsetAdjustmentBehavior::Automatic; return; }
79
+ if (string == "scrollableAxes") { result = RNCWebViewContentInsetAdjustmentBehavior::ScrollableAxes; return; }
80
+ if (string == "always") { result = RNCWebViewContentInsetAdjustmentBehavior::Always; return; }
81
+ abort();
82
+ }
83
+
84
+ static inline std::string toString(const RNCWebViewContentInsetAdjustmentBehavior &value) {
85
+ switch (value) {
86
+ case RNCWebViewContentInsetAdjustmentBehavior::Never: return "never";
87
+ case RNCWebViewContentInsetAdjustmentBehavior::Automatic: return "automatic";
88
+ case RNCWebViewContentInsetAdjustmentBehavior::ScrollableAxes: return "scrollableAxes";
89
+ case RNCWebViewContentInsetAdjustmentBehavior::Always: return "always";
90
+ }
91
+ }
92
+ enum class RNCWebViewContentMode { Recommended, Mobile, Desktop };
93
+
94
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewContentMode &result) {
95
+ auto string = (std::string)value;
96
+ if (string == "recommended") { result = RNCWebViewContentMode::Recommended; return; }
97
+ if (string == "mobile") { result = RNCWebViewContentMode::Mobile; return; }
98
+ if (string == "desktop") { result = RNCWebViewContentMode::Desktop; return; }
99
+ abort();
100
+ }
101
+
102
+ static inline std::string toString(const RNCWebViewContentMode &value) {
103
+ switch (value) {
104
+ case RNCWebViewContentMode::Recommended: return "recommended";
105
+ case RNCWebViewContentMode::Mobile: return "mobile";
106
+ case RNCWebViewContentMode::Desktop: return "desktop";
107
+ }
108
+ }
109
+ using RNCWebViewDataDetectorTypesMask = uint32_t;
110
+
111
+ struct RNCWebViewDataDetectorTypesMaskWrapped {
112
+ RNCWebViewDataDetectorTypesMask value;
113
+ };
114
+
115
+ enum class RNCWebViewDataDetectorTypes: RNCWebViewDataDetectorTypesMask {
116
+ Address = 1 << 0,
117
+ Link = 1 << 1,
118
+ CalendarEvent = 1 << 2,
119
+ TrackingNumber = 1 << 3,
120
+ FlightNumber = 1 << 4,
121
+ LookupSuggestion = 1 << 5,
122
+ PhoneNumber = 1 << 6,
123
+ All = 1 << 7,
124
+ None = 1 << 8
125
+ };
126
+
127
+ constexpr bool operator&(
128
+ RNCWebViewDataDetectorTypesMask const lhs,
129
+ enum RNCWebViewDataDetectorTypes const rhs) {
130
+ return lhs & static_cast<RNCWebViewDataDetectorTypesMask>(rhs);
131
+ }
132
+
133
+ constexpr RNCWebViewDataDetectorTypesMask operator|(
134
+ RNCWebViewDataDetectorTypesMask const lhs,
135
+ enum RNCWebViewDataDetectorTypes const rhs) {
136
+ return lhs | static_cast<RNCWebViewDataDetectorTypesMask>(rhs);
137
+ }
138
+
139
+ constexpr void operator|=(
140
+ RNCWebViewDataDetectorTypesMask &lhs,
141
+ enum RNCWebViewDataDetectorTypes const rhs) {
142
+ lhs = lhs | static_cast<RNCWebViewDataDetectorTypesMask>(rhs);
143
+ }
144
+
145
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewDataDetectorTypesMaskWrapped &wrapped) {
146
+ auto items = std::vector<std::string>{value};
147
+ for (const auto &item : items) {
148
+ if (item == "address") {
149
+ wrapped.value |= RNCWebViewDataDetectorTypes::Address;
150
+ continue;
151
+ }
152
+ if (item == "link") {
153
+ wrapped.value |= RNCWebViewDataDetectorTypes::Link;
154
+ continue;
155
+ }
156
+ if (item == "calendarEvent") {
157
+ wrapped.value |= RNCWebViewDataDetectorTypes::CalendarEvent;
158
+ continue;
159
+ }
160
+ if (item == "trackingNumber") {
161
+ wrapped.value |= RNCWebViewDataDetectorTypes::TrackingNumber;
162
+ continue;
163
+ }
164
+ if (item == "flightNumber") {
165
+ wrapped.value |= RNCWebViewDataDetectorTypes::FlightNumber;
166
+ continue;
167
+ }
168
+ if (item == "lookupSuggestion") {
169
+ wrapped.value |= RNCWebViewDataDetectorTypes::LookupSuggestion;
170
+ continue;
171
+ }
172
+ if (item == "phoneNumber") {
173
+ wrapped.value |= RNCWebViewDataDetectorTypes::PhoneNumber;
174
+ continue;
175
+ }
176
+ if (item == "all") {
177
+ wrapped.value |= RNCWebViewDataDetectorTypes::All;
178
+ continue;
179
+ }
180
+ if (item == "none") {
181
+ wrapped.value |= RNCWebViewDataDetectorTypes::None;
182
+ continue;
183
+ }
184
+ abort();
185
+ }
186
+ }
187
+
188
+ static inline std::string toString(const RNCWebViewDataDetectorTypesMaskWrapped &wrapped) {
189
+ auto result = std::string{};
190
+ auto separator = std::string{", "};
191
+
192
+ if (wrapped.value & RNCWebViewDataDetectorTypes::Address) {
193
+ result += "address" + separator;
194
+ }
195
+ if (wrapped.value & RNCWebViewDataDetectorTypes::Link) {
196
+ result += "link" + separator;
197
+ }
198
+ if (wrapped.value & RNCWebViewDataDetectorTypes::CalendarEvent) {
199
+ result += "calendarEvent" + separator;
200
+ }
201
+ if (wrapped.value & RNCWebViewDataDetectorTypes::TrackingNumber) {
202
+ result += "trackingNumber" + separator;
203
+ }
204
+ if (wrapped.value & RNCWebViewDataDetectorTypes::FlightNumber) {
205
+ result += "flightNumber" + separator;
206
+ }
207
+ if (wrapped.value & RNCWebViewDataDetectorTypes::LookupSuggestion) {
208
+ result += "lookupSuggestion" + separator;
209
+ }
210
+ if (wrapped.value & RNCWebViewDataDetectorTypes::PhoneNumber) {
211
+ result += "phoneNumber" + separator;
212
+ }
213
+ if (wrapped.value & RNCWebViewDataDetectorTypes::All) {
214
+ result += "all" + separator;
215
+ }
216
+ if (wrapped.value & RNCWebViewDataDetectorTypes::None) {
217
+ result += "none" + separator;
218
+ }
219
+ if (!result.empty()) {
220
+ result.erase(result.length() - separator.length());
221
+ }
222
+ return result;
223
+ }
224
+ enum class RNCWebViewMediaCapturePermissionGrantType { Prompt, Grant, Deny, GrantIfSameHostElsePrompt, GrantIfSameHostElseDeny };
225
+
226
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewMediaCapturePermissionGrantType &result) {
227
+ auto string = (std::string)value;
228
+ if (string == "prompt") { result = RNCWebViewMediaCapturePermissionGrantType::Prompt; return; }
229
+ if (string == "grant") { result = RNCWebViewMediaCapturePermissionGrantType::Grant; return; }
230
+ if (string == "deny") { result = RNCWebViewMediaCapturePermissionGrantType::Deny; return; }
231
+ if (string == "grantIfSameHostElsePrompt") { result = RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElsePrompt; return; }
232
+ if (string == "grantIfSameHostElseDeny") { result = RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElseDeny; return; }
233
+ abort();
234
+ }
235
+
236
+ static inline std::string toString(const RNCWebViewMediaCapturePermissionGrantType &value) {
237
+ switch (value) {
238
+ case RNCWebViewMediaCapturePermissionGrantType::Prompt: return "prompt";
239
+ case RNCWebViewMediaCapturePermissionGrantType::Grant: return "grant";
240
+ case RNCWebViewMediaCapturePermissionGrantType::Deny: return "deny";
241
+ case RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElsePrompt: return "grantIfSameHostElsePrompt";
242
+ case RNCWebViewMediaCapturePermissionGrantType::GrantIfSameHostElseDeny: return "grantIfSameHostElseDeny";
243
+ }
244
+ }
245
+ enum class RNCWebViewIndicatorStyle { Default, Black, White };
246
+
247
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewIndicatorStyle &result) {
248
+ auto string = (std::string)value;
249
+ if (string == "default") { result = RNCWebViewIndicatorStyle::Default; return; }
250
+ if (string == "black") { result = RNCWebViewIndicatorStyle::Black; return; }
251
+ if (string == "white") { result = RNCWebViewIndicatorStyle::White; return; }
252
+ abort();
253
+ }
254
+
255
+ static inline std::string toString(const RNCWebViewIndicatorStyle &value) {
256
+ switch (value) {
257
+ case RNCWebViewIndicatorStyle::Default: return "default";
258
+ case RNCWebViewIndicatorStyle::Black: return "black";
259
+ case RNCWebViewIndicatorStyle::White: return "white";
260
+ }
261
+ }
262
+ struct RNCWebViewContentInsetStruct {
263
+ double top{0.0};
264
+ double left{0.0};
265
+ double bottom{0.0};
266
+ double right{0.0};
267
+ };
268
+
269
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewContentInsetStruct &result) {
270
+ auto map = (std::unordered_map<std::string, RawValue>)value;
271
+
272
+ auto tmp_top = map.find("top");
273
+ if (tmp_top != map.end()) {
274
+ fromRawValue(context, tmp_top->second, result.top);
275
+ }
276
+ auto tmp_left = map.find("left");
277
+ if (tmp_left != map.end()) {
278
+ fromRawValue(context, tmp_left->second, result.left);
279
+ }
280
+ auto tmp_bottom = map.find("bottom");
281
+ if (tmp_bottom != map.end()) {
282
+ fromRawValue(context, tmp_bottom->second, result.bottom);
283
+ }
284
+ auto tmp_right = map.find("right");
285
+ if (tmp_right != map.end()) {
286
+ fromRawValue(context, tmp_right->second, result.right);
287
+ }
288
+ }
289
+
290
+ static inline std::string toString(const RNCWebViewContentInsetStruct &value) {
291
+ return "[Object RNCWebViewContentInsetStruct]";
292
+ }
293
+
294
+ struct RNCWebViewMenuItemsStruct {
295
+ std::string label{};
296
+ std::string key{};
297
+ };
298
+
299
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewMenuItemsStruct &result) {
300
+ auto map = (std::unordered_map<std::string, RawValue>)value;
301
+
302
+ auto tmp_label = map.find("label");
303
+ if (tmp_label != map.end()) {
304
+ fromRawValue(context, tmp_label->second, result.label);
305
+ }
306
+ auto tmp_key = map.find("key");
307
+ if (tmp_key != map.end()) {
308
+ fromRawValue(context, tmp_key->second, result.key);
309
+ }
310
+ }
311
+
312
+ static inline std::string toString(const RNCWebViewMenuItemsStruct &value) {
313
+ return "[Object RNCWebViewMenuItemsStruct]";
314
+ }
315
+
316
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNCWebViewMenuItemsStruct> &result) {
317
+ auto items = (std::vector<RawValue>)value;
318
+ for (const auto &item : items) {
319
+ RNCWebViewMenuItemsStruct newItem;
320
+ fromRawValue(context, item, newItem);
321
+ result.emplace_back(newItem);
322
+ }
323
+ }
324
+
325
+
326
+ struct RNCWebViewBasicAuthCredentialStruct {
327
+ std::string username{};
328
+ std::string password{};
329
+ };
330
+
331
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewBasicAuthCredentialStruct &result) {
332
+ auto map = (std::unordered_map<std::string, RawValue>)value;
333
+
334
+ auto tmp_username = map.find("username");
335
+ if (tmp_username != map.end()) {
336
+ fromRawValue(context, tmp_username->second, result.username);
337
+ }
338
+ auto tmp_password = map.find("password");
339
+ if (tmp_password != map.end()) {
340
+ fromRawValue(context, tmp_password->second, result.password);
341
+ }
342
+ }
343
+
344
+ static inline std::string toString(const RNCWebViewBasicAuthCredentialStruct &value) {
345
+ return "[Object RNCWebViewBasicAuthCredentialStruct]";
346
+ }
347
+
348
+ struct RNCWebViewNewSourceHeadersStruct {
349
+ std::string name{};
350
+ std::string value{};
351
+ };
352
+
353
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewNewSourceHeadersStruct &result) {
354
+ auto map = (std::unordered_map<std::string, RawValue>)value;
355
+
356
+ auto tmp_name = map.find("name");
357
+ if (tmp_name != map.end()) {
358
+ fromRawValue(context, tmp_name->second, result.name);
359
+ }
360
+ auto tmp_value = map.find("value");
361
+ if (tmp_value != map.end()) {
362
+ fromRawValue(context, tmp_value->second, result.value);
363
+ }
364
+ }
365
+
366
+ static inline std::string toString(const RNCWebViewNewSourceHeadersStruct &value) {
367
+ return "[Object RNCWebViewNewSourceHeadersStruct]";
368
+ }
369
+
370
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNCWebViewNewSourceHeadersStruct> &result) {
371
+ auto items = (std::vector<RawValue>)value;
372
+ for (const auto &item : items) {
373
+ RNCWebViewNewSourceHeadersStruct newItem;
374
+ fromRawValue(context, item, newItem);
375
+ result.emplace_back(newItem);
376
+ }
377
+ }
378
+
379
+
380
+ struct RNCWebViewNewSourceStruct {
381
+ std::string uri{};
382
+ std::string method{};
383
+ std::string body{};
384
+ std::vector<RNCWebViewNewSourceHeadersStruct> headers{};
385
+ std::string html{};
386
+ std::string baseUrl{};
387
+ };
388
+
389
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNCWebViewNewSourceStruct &result) {
390
+ auto map = (std::unordered_map<std::string, RawValue>)value;
391
+
392
+ auto tmp_uri = map.find("uri");
393
+ if (tmp_uri != map.end()) {
394
+ fromRawValue(context, tmp_uri->second, result.uri);
395
+ }
396
+ auto tmp_method = map.find("method");
397
+ if (tmp_method != map.end()) {
398
+ fromRawValue(context, tmp_method->second, result.method);
399
+ }
400
+ auto tmp_body = map.find("body");
401
+ if (tmp_body != map.end()) {
402
+ fromRawValue(context, tmp_body->second, result.body);
403
+ }
404
+ auto tmp_headers = map.find("headers");
405
+ if (tmp_headers != map.end()) {
406
+ fromRawValue(context, tmp_headers->second, result.headers);
407
+ }
408
+ auto tmp_html = map.find("html");
409
+ if (tmp_html != map.end()) {
410
+ fromRawValue(context, tmp_html->second, result.html);
411
+ }
412
+ auto tmp_baseUrl = map.find("baseUrl");
413
+ if (tmp_baseUrl != map.end()) {
414
+ fromRawValue(context, tmp_baseUrl->second, result.baseUrl);
415
+ }
416
+ }
417
+
418
+ static inline std::string toString(const RNCWebViewNewSourceStruct &value) {
419
+ return "[Object RNCWebViewNewSourceStruct]";
420
+ }
421
+ class RNCWebViewProps final : public ViewProps {
422
+ public:
423
+ RNCWebViewProps() = default;
424
+ RNCWebViewProps(const PropsParserContext& context, const RNCWebViewProps &sourceProps, const RawProps &rawProps);
425
+
426
+ #pragma mark - Props
427
+
428
+ bool allowFileAccess{false};
429
+ bool allowsProtectedMedia{false};
430
+ bool allowsFullscreenVideo{false};
431
+ RNCWebViewAndroidLayerType androidLayerType{RNCWebViewAndroidLayerType::None};
432
+ RNCWebViewCacheMode cacheMode{RNCWebViewCacheMode::LOAD_DEFAULT};
433
+ bool domStorageEnabled{false};
434
+ std::string downloadingMessage{};
435
+ bool forceDarkOn{false};
436
+ bool geolocationEnabled{false};
437
+ std::string lackPermissionToDownloadMessage{};
438
+ std::string messagingModuleName{};
439
+ int minimumFontSize{0};
440
+ RNCWebViewMixedContentMode mixedContentMode{RNCWebViewMixedContentMode::Never};
441
+ bool nestedScrollEnabled{false};
442
+ std::string overScrollMode{};
443
+ bool saveFormDataDisabled{false};
444
+ bool scalesPageToFit{true};
445
+ bool setBuiltInZoomControls{true};
446
+ bool setDisplayZoomControls{false};
447
+ bool setSupportMultipleWindows{true};
448
+ int textZoom{0};
449
+ bool thirdPartyCookiesEnabled{true};
450
+ bool hasOnScroll{false};
451
+ std::string injectedJavaScriptObject{};
452
+ bool paymentRequestEnabled{false};
453
+ std::string allowingReadAccessToURL{};
454
+ bool allowsBackForwardNavigationGestures{false};
455
+ bool allowsInlineMediaPlayback{false};
456
+ bool allowsPictureInPictureMediaPlayback{false};
457
+ bool allowsAirPlayForMediaPlayback{false};
458
+ bool allowsLinkPreview{true};
459
+ bool automaticallyAdjustContentInsets{true};
460
+ bool ignoreSilentHardwareSwitch{false};
461
+ bool autoManageStatusBarEnabled{true};
462
+ bool bounces{true};
463
+ RNCWebViewContentInsetStruct contentInset{};
464
+ RNCWebViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior{RNCWebViewContentInsetAdjustmentBehavior::Never};
465
+ RNCWebViewContentMode contentMode{RNCWebViewContentMode::Recommended};
466
+ RNCWebViewDataDetectorTypesMask dataDetectorTypes{static_cast<RNCWebViewDataDetectorTypesMask>(RNCWebViewDataDetectorTypes::PhoneNumber)};
467
+ double decelerationRate{0.0};
468
+ bool directionalLockEnabled{true};
469
+ bool enableApplePay{false};
470
+ bool hideKeyboardAccessoryView{false};
471
+ bool keyboardDisplayRequiresUserAction{true};
472
+ bool limitsNavigationsToAppBoundDomains{false};
473
+ RNCWebViewMediaCapturePermissionGrantType mediaCapturePermissionGrantType{RNCWebViewMediaCapturePermissionGrantType::Prompt};
474
+ bool pagingEnabled{false};
475
+ bool pullToRefreshEnabled{false};
476
+ bool refreshControlLightMode{false};
477
+ bool scrollEnabled{true};
478
+ bool sharedCookiesEnabled{false};
479
+ bool textInteractionEnabled{true};
480
+ bool useSharedProcessPool{true};
481
+ std::vector<RNCWebViewMenuItemsStruct> menuItems{};
482
+ std::vector<std::string> suppressMenuItems{};
483
+ bool hasOnFileDownload{false};
484
+ bool fraudulentWebsiteWarningEnabled{true};
485
+ bool allowFileAccessFromFileURLs{false};
486
+ bool allowUniversalAccessFromFileURLs{false};
487
+ std::string applicationNameForUserAgent{};
488
+ RNCWebViewBasicAuthCredentialStruct basicAuthCredential{};
489
+ bool cacheEnabled{true};
490
+ bool incognito{false};
491
+ std::string injectedJavaScript{};
492
+ std::string injectedJavaScriptBeforeContentLoaded{};
493
+ bool injectedJavaScriptForMainFrameOnly{true};
494
+ bool injectedJavaScriptBeforeContentLoadedForMainFrameOnly{true};
495
+ bool javaScriptCanOpenWindowsAutomatically{false};
496
+ bool javaScriptEnabled{true};
497
+ bool webviewDebuggingEnabled{false};
498
+ bool mediaPlaybackRequiresUserAction{true};
499
+ bool messagingEnabled{false};
500
+ bool shouldStartLoadWithRequestEnabled{false};
501
+ bool hasOnOpenWindowEvent{false};
502
+ bool showsHorizontalScrollIndicator{true};
503
+ bool showsVerticalScrollIndicator{true};
504
+ RNCWebViewIndicatorStyle indicatorStyle{RNCWebViewIndicatorStyle::Default};
505
+ RNCWebViewNewSourceStruct newSource{};
506
+ std::string userAgent{};
507
+ };
508
+
509
+ } // namespace facebook::react