@exodus/react-native-webview 11.26.1-exodus.3 → 11.26.1-exodus.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.
@@ -1,15 +1,19 @@
1
1
  import escapeStringRegexp from 'escape-string-regexp';
2
2
  import React, { useCallback, useMemo, useRef, useState } from 'react';
3
- import { View, ActivityIndicator, Text, Platform } from 'react-native';
3
+ import { Linking, View, ActivityIndicator, Text, Platform } from 'react-native';
4
4
  import styles from './WebView.styles';
5
- const defaultOriginWhitelist = ['http://*', 'https://*'];
5
+ const defaultOriginWhitelist = ['https://*'];
6
6
  const extractOrigin = (url) => {
7
7
  const result = /^[A-Za-z][A-Za-z0-9+\-.]+:(\/\/)?[^/]*/.exec(url);
8
8
  return result === null ? '' : result[0];
9
9
  };
10
- const originWhitelistToRegex = (originWhitelist) => `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}`;
11
- const passesWhitelist = (compiledWhitelist, url) => {
10
+ const originWhitelistToRegex = (originWhitelist) => `^${escapeStringRegexp(originWhitelist).replace(/\\\*/g, '.*')}$`;
11
+ const _passesWhitelist = (compiledWhitelist, url) => {
12
12
  const origin = extractOrigin(url);
13
+ if (!origin)
14
+ return false;
15
+ if (origin !== new URL(url).origin)
16
+ return null;
13
17
  return compiledWhitelist.some(x => new RegExp(x).test(origin));
14
18
  };
15
19
  const compileWhitelist = (originWhitelist) => ['about:blank', ...(originWhitelist || [])].map(originWhitelistToRegex);
@@ -17,7 +21,16 @@ const createOnShouldStartLoadWithRequest = (loadRequest, originWhitelist, onShou
17
21
  return ({ nativeEvent }) => {
18
22
  let shouldStart = true;
19
23
  const { url, lockIdentifier } = nativeEvent;
20
- if (!passesWhitelist(compileWhitelist(originWhitelist), url)) {
24
+ if (!_passesWhitelist(compileWhitelist(originWhitelist), url)) {
25
+ Linking.canOpenURL(url).then((supported) => {
26
+ if (supported && /^https:\/\//.test(url)) {
27
+ return Linking.openURL(url);
28
+ }
29
+ console.warn(`Can't open url: ${url}`);
30
+ return undefined;
31
+ }).catch(e => {
32
+ console.warn('Error opening URL: ', e);
33
+ });
21
34
  shouldStart = false;
22
35
  }
23
36
  else if (onShouldStartLoadWithRequest) {
@@ -36,20 +49,30 @@ const defaultRenderError = (errorDomain, errorCode, errorDesc) => (<View style={
36
49
  <Text style={styles.errorText}>{`Description: ${errorDesc}`}</Text>
37
50
  </View>);
38
51
  export { defaultOriginWhitelist, createOnShouldStartLoadWithRequest, defaultRenderLoading, defaultRenderError, };
39
- export const useWebWiewLogic = ({ startInLoadingState, onNavigationStateChange, onLoadStart, onLoad, onLoadProgress, onLoadEnd, onError, onHttpErrorProp, onMessageProp, onRenderProcessGoneProp, onContentProcessDidTerminateProp, originWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback, }) => {
52
+ export const useWebWiewLogic = ({ startInLoadingState, onLoadStart, onLoad, onLoadEnd, onError, onMessageProp, originWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback, validateMeta, validateData, }) => {
40
53
  const [viewState, setViewState] = useState(startInLoadingState ? "LOADING" : "IDLE");
41
54
  const [lastErrorEvent, setLastErrorEvent] = useState(null);
42
55
  const startUrl = useRef(null);
43
- const updateNavigationState = useCallback((event) => {
44
- onNavigationStateChange === null || onNavigationStateChange === void 0 ? void 0 : onNavigationStateChange(event.nativeEvent);
45
- }, [onNavigationStateChange]);
56
+ const passesWhitelist = (url) => {
57
+ if (!url || typeof url !== 'string')
58
+ return false;
59
+ return _passesWhitelist(compileWhitelist(originWhitelist), url);
60
+ };
61
+ const passesWhitelistUse = useCallback(passesWhitelist, [originWhitelist]);
62
+ const extractMeta = (nativeEvent) => ({
63
+ url: String(nativeEvent.url),
64
+ loading: Boolean(nativeEvent.loading),
65
+ title: String(nativeEvent.title),
66
+ canGoBack: Boolean(nativeEvent.canGoBack),
67
+ canGoForward: Boolean(nativeEvent.canGoForward),
68
+ lockIdentifier: Number(nativeEvent.lockIdentifier),
69
+ });
46
70
  const onLoadingStart = useCallback((event) => {
47
71
  // Needed for android
48
72
  startUrl.current = event.nativeEvent.url;
49
73
  // !Needed for android
50
74
  onLoadStart === null || onLoadStart === void 0 ? void 0 : onLoadStart(event);
51
- updateNavigationState(event);
52
- }, [onLoadStart, updateNavigationState]);
75
+ }, [onLoadStart]);
53
76
  const onLoadingError = useCallback((event) => {
54
77
  event.persist();
55
78
  if (onError) {
@@ -66,42 +89,39 @@ export const useWebWiewLogic = ({ startInLoadingState, onNavigationStateChange,
66
89
  setViewState('ERROR');
67
90
  setLastErrorEvent(event.nativeEvent);
68
91
  }, [onError, onLoadEnd]);
69
- const onHttpError = useCallback((event) => {
70
- onHttpErrorProp === null || onHttpErrorProp === void 0 ? void 0 : onHttpErrorProp(event);
71
- }, [onHttpErrorProp]);
72
- // Android Only
73
- const onRenderProcessGone = useCallback((event) => {
74
- onRenderProcessGoneProp === null || onRenderProcessGoneProp === void 0 ? void 0 : onRenderProcessGoneProp(event);
75
- }, [onRenderProcessGoneProp]);
76
- // !Android Only
77
- // iOS Only
78
- const onContentProcessDidTerminate = useCallback((event) => {
79
- onContentProcessDidTerminateProp === null || onContentProcessDidTerminateProp === void 0 ? void 0 : onContentProcessDidTerminateProp(event);
80
- }, [onContentProcessDidTerminateProp]);
81
- // !iOS Only
82
92
  const onLoadingFinish = useCallback((event) => {
83
93
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(event);
84
94
  onLoadEnd === null || onLoadEnd === void 0 ? void 0 : onLoadEnd(event);
85
95
  const { nativeEvent: { url } } = event;
96
+ if (!passesWhitelistUse(url))
97
+ return;
86
98
  // on Android, only if url === startUrl
87
99
  if (Platform.OS !== "android" || url === startUrl.current) {
88
100
  setViewState('IDLE');
89
101
  }
90
102
  // !on Android, only if url === startUrl
91
- updateNavigationState(event);
92
- }, [onLoad, onLoadEnd, updateNavigationState]);
103
+ // REMOVED: updateNavigationState(event);
104
+ }, [onLoad, onLoadEnd, passesWhitelistUse]);
93
105
  const onMessage = useCallback((event) => {
94
- onMessageProp === null || onMessageProp === void 0 ? void 0 : onMessageProp(event);
95
- }, [onMessageProp]);
106
+ const { nativeEvent } = event;
107
+ if (!passesWhitelistUse(nativeEvent.url))
108
+ return;
109
+ // TODO: can/should we perform any other validation?
110
+ const data = JSON.stringify(validateData(JSON.parse(nativeEvent.data)));
111
+ const meta = validateMeta(extractMeta(nativeEvent));
112
+ onMessageProp === null || onMessageProp === void 0 ? void 0 : onMessageProp({ ...meta, data });
113
+ }, [onMessageProp, passesWhitelistUse, validateData, validateMeta]);
96
114
  const onLoadingProgress = useCallback((event) => {
97
115
  const { nativeEvent: { progress } } = event;
116
+ if (!passesWhitelistUse(event.nativeEvent.url))
117
+ return;
98
118
  // patch for Android only
99
119
  if (Platform.OS === "android" && progress === 1) {
100
120
  setViewState(prevViewState => prevViewState === 'LOADING' ? 'IDLE' : prevViewState);
101
121
  }
102
122
  // !patch for Android only
103
- onLoadProgress === null || onLoadProgress === void 0 ? void 0 : onLoadProgress(event);
104
- }, [onLoadProgress]);
123
+ // REMOVED: onLoadProgress?.(event);
124
+ }, [passesWhitelistUse]);
105
125
  const onShouldStartLoadWithRequest = useMemo(() => createOnShouldStartLoadWithRequest(onShouldStartLoadWithRequestCallback, originWhitelist, onShouldStartLoadWithRequestProp), [originWhitelist, onShouldStartLoadWithRequestProp, onShouldStartLoadWithRequestCallback]);
106
126
  return {
107
127
  onShouldStartLoadWithRequest,
@@ -109,12 +129,46 @@ export const useWebWiewLogic = ({ startInLoadingState, onNavigationStateChange,
109
129
  onLoadingProgress,
110
130
  onLoadingError,
111
131
  onLoadingFinish,
112
- onHttpError,
113
- onRenderProcessGone,
114
- onContentProcessDidTerminate,
115
132
  onMessage,
133
+ passesWhitelist,
116
134
  viewState,
117
135
  setViewState,
118
136
  lastErrorEvent,
119
137
  };
120
138
  };
139
+ export const versionPasses = (version, minimum) => {
140
+ if (!version || !minimum)
141
+ return false;
142
+ if (typeof version !== 'string' || typeof minimum !== 'string')
143
+ return false;
144
+ if (minimum.includes(', ')) {
145
+ // We have a set of possible versions
146
+ const variants = minimum.split(', ');
147
+ // Every entry but the last one should be with an upper bound
148
+ if (!variants.slice(0, -1).every(x => x.includes(' <')))
149
+ return false;
150
+ return variants.some(x => versionPasses(version, x)); // Any match passes
151
+ }
152
+ if (minimum.includes(' <')) {
153
+ const [min, max, ...rest] = minimum.split(' <');
154
+ if (rest.length > 0)
155
+ return false;
156
+ // Last check is required for correctness/formatting validation
157
+ return versionPasses(version, min) && !versionPasses(version, max) && versionPasses(max, version);
158
+ }
159
+ const versionRegex = /^[0-9]+(\.[0-9]+)*$/;
160
+ if (!versionRegex.test(version) || !versionRegex.test(minimum))
161
+ return false;
162
+ const versionParts = version.split('.').map(Number);
163
+ const minimumParts = minimum.split('.').map(Number);
164
+ const len = Math.max(versionParts.length, minimumParts.length);
165
+ for (let i = 0; i < len; i += 1) {
166
+ const ver = versionParts[i] || 0;
167
+ const min = minimumParts[i] || 0;
168
+ if (ver > min)
169
+ return true;
170
+ if (ver < min)
171
+ return false;
172
+ }
173
+ return true; // equals
174
+ };
@@ -58,9 +58,6 @@ export interface WebViewNavigation extends WebViewNativeEvent {
58
58
  export interface ShouldStartLoadRequest extends WebViewNavigation {
59
59
  isTopFrame: boolean;
60
60
  }
61
- export interface FileDownload {
62
- downloadUrl: string;
63
- }
64
61
  export declare type DecelerationRateConstant = 'normal' | 'fast';
65
62
  export interface WebViewMessage extends WebViewNativeEvent {
66
63
  data: string;
@@ -73,23 +70,12 @@ export interface WebViewError extends WebViewNativeEvent {
73
70
  code: number;
74
71
  description: string;
75
72
  }
76
- export interface WebViewHttpError extends WebViewNativeEvent {
77
- description: string;
78
- statusCode: number;
79
- }
80
- export interface WebViewRenderProcessGoneDetail {
81
- didCrash: boolean;
82
- }
83
73
  export declare type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
84
74
  export declare type WebViewProgressEvent = NativeSyntheticEvent<WebViewNativeProgressEvent>;
85
75
  export declare type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
86
76
  export declare type ShouldStartLoadRequestEvent = NativeSyntheticEvent<ShouldStartLoadRequest>;
87
- export declare type FileDownloadEvent = NativeSyntheticEvent<FileDownload>;
88
77
  export declare type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
89
78
  export declare type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
90
- export declare type WebViewTerminatedEvent = NativeSyntheticEvent<WebViewNativeEvent>;
91
- export declare type WebViewHttpErrorEvent = NativeSyntheticEvent<WebViewHttpError>;
92
- export declare type WebViewRenderProcessGoneEvent = NativeSyntheticEvent<WebViewRenderProcessGoneDetail>;
93
79
  export declare type WebViewScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
94
80
  export declare type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'trackingNumber' | 'flightNumber' | 'lookupSuggestion' | 'none' | 'all';
95
81
  export declare type OverScrollModeType = 'always' | 'content' | 'never';
@@ -155,13 +141,10 @@ export interface BasicAuthCredential {
155
141
  password: string;
156
142
  }
157
143
  export interface CommonNativeWebViewProps extends ViewProps {
158
- allowFileAccessFromFileURLs?: boolean;
159
144
  cacheEnabled?: boolean;
160
145
  incognito?: boolean;
161
146
  injectedJavaScript?: string;
162
147
  injectedJavaScriptBeforeContentLoaded?: string;
163
- injectedJavaScriptForMainFrameOnly?: boolean;
164
- injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
165
148
  mediaPlaybackRequiresUserAction?: boolean;
166
149
  messagingEnabled: boolean;
167
150
  onScroll?: (event: WebViewScrollEvent) => void;
@@ -169,7 +152,6 @@ export interface CommonNativeWebViewProps extends ViewProps {
169
152
  onLoadingFinish: (event: WebViewNavigationEvent) => void;
170
153
  onLoadingProgress: (event: WebViewProgressEvent) => void;
171
154
  onLoadingStart: (event: WebViewNavigationEvent) => void;
172
- onHttpError: (event: WebViewHttpErrorEvent) => void;
173
155
  onMessage: (event: WebViewMessageEvent) => void;
174
156
  onShouldStartLoadWithRequest: (event: ShouldStartLoadRequestEvent) => void;
175
157
  showsHorizontalScrollIndicator?: boolean;
@@ -179,15 +161,11 @@ export interface CommonNativeWebViewProps extends ViewProps {
179
161
  /**
180
162
  * Append to the existing user-agent. Overridden if `userAgent` is set.
181
163
  */
182
- applicationNameForUserAgent?: string;
183
164
  basicAuthCredential?: BasicAuthCredential;
184
165
  }
185
166
  export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
186
167
  cacheMode?: CacheMode;
187
- allowFileAccess?: boolean;
188
168
  scalesPageToFit?: boolean;
189
- allowsFullscreenVideo?: boolean;
190
- allowUniversalAccessFromFileURLs?: boolean;
191
169
  androidHardwareAccelerationDisabled?: boolean;
192
170
  androidLayerType?: AndroidLayerType;
193
171
  domStorageEnabled?: boolean;
@@ -195,7 +173,6 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
195
173
  javaScriptEnabled?: boolean;
196
174
  mixedContentMode?: 'never' | 'always' | 'compatibility';
197
175
  onContentSizeChange?: (event: WebViewEvent) => void;
198
- onRenderProcessGone?: (event: WebViewRenderProcessGoneEvent) => void;
199
176
  overScrollMode?: OverScrollModeType;
200
177
  saveFormDataDisabled?: boolean;
201
178
  setSupportMultipleWindows?: boolean;
@@ -216,12 +193,9 @@ export declare type ContentInsetAdjustmentBehavior = 'automatic' | 'scrollableAx
216
193
  export declare type MediaCapturePermissionGrantType = 'grantIfSameHostElsePrompt' | 'grantIfSameHostElseDeny' | 'deny' | 'grant' | 'prompt';
217
194
  export declare type ContentMode = 'recommended' | 'mobile' | 'desktop';
218
195
  export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
219
- allowingReadAccessToURL?: string;
220
196
  allowsBackForwardNavigationGestures?: boolean;
221
197
  allowsInlineMediaPlayback?: boolean;
222
- allowsAirPlayForMediaPlayback?: boolean;
223
198
  allowsLinkPreview?: boolean;
224
- allowUniversalAccessFromFileURLs?: boolean;
225
199
  automaticallyAdjustContentInsets?: boolean;
226
200
  autoManageStatusBarEnabled?: boolean;
227
201
  bounces?: boolean;
@@ -236,10 +210,6 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
236
210
  pagingEnabled?: boolean;
237
211
  scrollEnabled?: boolean;
238
212
  useSharedProcessPool?: boolean;
239
- onContentProcessDidTerminate?: (event: WebViewTerminatedEvent) => void;
240
- injectedJavaScriptForMainFrameOnly?: boolean;
241
- injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
242
- onFileDownload?: (event: FileDownloadEvent) => void;
243
213
  limitsNavigationsToAppBoundDomains?: boolean;
244
214
  sharedCookiesEnabled?: boolean;
245
215
  enableApplePay?: boolean;
@@ -352,11 +322,6 @@ export interface IOSWebViewProps extends WebViewSharedProps {
352
322
  * @platform ios
353
323
  */
354
324
  allowsInlineMediaPlayback?: boolean;
355
- /**
356
- * A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
357
- * @platform ios
358
- */
359
- allowsAirPlayForMediaPlayback?: boolean;
360
325
  /**
361
326
  * Hide the accessory view when the keyboard is open. Default is false to be
362
327
  * backward compatible.
@@ -393,12 +358,6 @@ export interface IOSWebViewProps extends WebViewSharedProps {
393
358
  * @platform ios
394
359
  */
395
360
  sharedCookiesEnabled?: boolean;
396
- /**
397
- * When set to true the hardware silent switch is ignored.
398
- * The default value is `false`.
399
- * @platform ios
400
- */
401
- ignoreSilentHardwareSwitch?: boolean;
402
361
  /**
403
362
  * Set true if StatusBar should be light when user watch video fullscreen.
404
363
  * The default value is `true`.
@@ -423,47 +382,6 @@ export interface IOSWebViewProps extends WebViewSharedProps {
423
382
  * @platform ios
424
383
  */
425
384
  keyboardDisplayRequiresUserAction?: boolean;
426
- /**
427
- * A String value that indicates which URLs the WebView's file can then
428
- * reference in scripts, AJAX requests, and CSS imports. This is only used
429
- * for WebViews that are loaded with a source.uri set to a `'file://'` URL.
430
- *
431
- * If not provided, the default is to only allow read access to the URL
432
- * provided in source.uri itself.
433
- * @platform ios
434
- */
435
- allowingReadAccessToURL?: string;
436
- /**
437
- * Boolean that sets whether JavaScript running in the context of a file
438
- * scheme URL should be allowed to access content from other file scheme URLs.
439
- * Including accessing content from other file scheme URLs
440
- * @platform ios
441
- */
442
- allowFileAccessFromFileURLs?: boolean;
443
- /**
444
- * Boolean that sets whether JavaScript running in the context of a file
445
- * scheme URL should be allowed to access content from any origin.
446
- * Including accessing content from other file scheme URLs
447
- * @platform ios
448
- */
449
- allowUniversalAccessFromFileURLs?: boolean;
450
- /**
451
- * Function that is invoked when the WebKit WebView content process gets terminated.
452
- * @platform ios
453
- */
454
- onContentProcessDidTerminate?: (event: WebViewTerminatedEvent) => void;
455
- /**
456
- * If `true` (default), loads the `injectedJavaScript` only into the main frame.
457
- * If `false`, loads it into all frames (e.g. iframes).
458
- * @platform ios
459
- */
460
- injectedJavaScriptForMainFrameOnly?: boolean;
461
- /**
462
- * If `true` (default), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
463
- * If `false`, loads it into all frames (e.g. iframes).
464
- * @platform ios
465
- */
466
- injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
467
385
  /**
468
386
  * Boolean value that determines whether a pull to refresh gesture is
469
387
  * available in the `WebView`. The default value is `false`.
@@ -472,23 +390,6 @@ export interface IOSWebViewProps extends WebViewSharedProps {
472
390
  *
473
391
  */
474
392
  pullToRefreshEnabled?: boolean;
475
- /**
476
- * Function that is invoked when the client needs to download a file.
477
- *
478
- * iOS 13+ only: If the webview navigates to a URL that results in an HTTP
479
- * response with a Content-Disposition header 'attachment...', then
480
- * this will be called.
481
- *
482
- * iOS 8+: If the MIME type indicates that the content is not renderable by the
483
- * webview, that will also cause this to be called. On iOS versions before 13,
484
- * this is the only condition that will cause this function to be called.
485
- *
486
- * The application will need to provide its own code to actually download
487
- * the file.
488
- *
489
- * If not provided, the default is to let the webview try to render the file.
490
- */
491
- onFileDownload?: (event: FileDownloadEvent) => void;
492
393
  /**
493
394
  * A Boolean value which, when set to `true`, indicates to WebKit that a WKWebView
494
395
  * will only navigate to app-bound domains. Once set, any attempt to navigate away
@@ -543,13 +444,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {
543
444
  onCustomMenuSelection?: (event: WebViewEvent) => void;
544
445
  }
545
446
  export interface AndroidWebViewProps extends WebViewSharedProps {
546
- onNavigationStateChange?: (event: WebViewNavigation) => void;
547
447
  onContentSizeChange?: (event: WebViewEvent) => void;
548
- /**
549
- * Function that is invoked when the `WebView` process crashes or is killed by the OS.
550
- * Works only on Android (minimum API level 26).
551
- */
552
- onRenderProcessGone?: (event: WebViewRenderProcessGoneEvent) => void;
553
448
  /**
554
449
  * https://developer.android.com/reference/android/webkit/WebSettings.html#setCacheMode(int)
555
450
  * Set the cacheMode. Possible values are:
@@ -584,25 +479,6 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
584
479
  * @platform android
585
480
  */
586
481
  geolocationEnabled?: boolean;
587
- /**
588
- * Boolean that sets whether JavaScript running in the context of a file
589
- * scheme URL should be allowed to access content from other file scheme URLs.
590
- * Including accessing content from other file scheme URLs
591
- * @platform android
592
- */
593
- allowFileAccessFromFileURLs?: boolean;
594
- /**
595
- * Boolean that sets whether JavaScript running in the context of a file
596
- * scheme URL should be allowed to access content from any origin.
597
- * Including accessing content from other file scheme URLs
598
- * @platform android
599
- */
600
- allowUniversalAccessFromFileURLs?: boolean;
601
- /**
602
- * Sets whether the webview allow access to file system.
603
- * @platform android
604
- */
605
- allowFileAccess?: boolean;
606
482
  /**
607
483
  * Used on Android only, controls whether form autocomplete data should be saved
608
484
  * @platform android
@@ -673,10 +549,6 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
673
549
  * @platform android
674
550
  */
675
551
  mixedContentMode?: 'never' | 'always' | 'compatibility';
676
- /**
677
- * Sets ability to open fullscreen videos on Android devices.
678
- */
679
- allowsFullscreenVideo?: boolean;
680
552
  /**
681
553
  * Configuring Dark Theme
682
554
  *
@@ -781,15 +653,6 @@ export interface WebViewSharedProps extends ViewProps {
781
653
  * Function that is invoked when the `WebView` load fails.
782
654
  */
783
655
  onError?: (event: WebViewErrorEvent) => void;
784
- /**
785
- * Function that is invoked when the `WebView` receives an error status code.
786
- * Works on iOS and Android (minimum API level 23).
787
- */
788
- onHttpError?: (event: WebViewHttpErrorEvent) => void;
789
- /**
790
- * Function that is invoked when the `WebView` loading starts or ends.
791
- */
792
- onNavigationStateChange?: (event: WebViewNavigation) => void;
793
656
  /**
794
657
  * Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`.
795
658
  * Setting this property will inject this global into your webview.
@@ -797,11 +660,7 @@ export interface WebViewSharedProps extends ViewProps {
797
660
  * `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be
798
661
  * available on the event object, `event.nativeEvent.data`. `data` must be a string.
799
662
  */
800
- onMessage?: (event: WebViewMessageEvent) => void;
801
- /**
802
- * Function that is invoked when the `WebView` is loading.
803
- */
804
- onLoadProgress?: (event: WebViewProgressEvent) => void;
663
+ onMessage?: (event: WebViewMessage) => void;
805
664
  /**
806
665
  * Boolean value that forces the `WebView` to show the loading view
807
666
  * on the first load.
@@ -817,16 +676,6 @@ export interface WebViewSharedProps extends ViewProps {
817
676
  * once the webview is initialized but before the view loads any content.
818
677
  */
819
678
  injectedJavaScriptBeforeContentLoaded?: string;
820
- /**
821
- * If `true` (default; mandatory for Android), loads the `injectedJavaScript` only into the main frame.
822
- * If `false` (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
823
- */
824
- injectedJavaScriptForMainFrameOnly?: boolean;
825
- /**
826
- * If `true` (default; mandatory for Android), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
827
- * If `false` (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
828
- */
829
- injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
830
679
  /**
831
680
  * Boolean value that determines whether a horizontal scroll indicator is
832
681
  * shown in the `WebView`. The default value is `true`.
@@ -860,14 +709,26 @@ export interface WebViewSharedProps extends ViewProps {
860
709
  * Should caching be enabled. Default is true.
861
710
  */
862
711
  cacheEnabled?: boolean;
863
- /**
864
- * Append to the existing user-agent. Overridden if `userAgent` is set.
865
- */
866
- applicationNameForUserAgent?: string;
867
712
  /**
868
713
  * An object that specifies the credentials of a user to be used for basic authentication.
869
714
  */
870
715
  basicAuthCredential?: BasicAuthCredential;
716
+ /**
717
+ * Event metadata validation.
718
+ */
719
+ validateMeta: (event: WebViewNativeEvent) => WebViewNativeEvent;
720
+ /**
721
+ * Event data validation.
722
+ */
723
+ validateData: (data: object) => object;
724
+ /**
725
+ * Webview will refuse to work on iOS versions below this one. Required for iOS.
726
+ */
727
+ minimumIOSVersion?: string;
728
+ /**
729
+ * Webview will refuse to work on Chrome versions below this one. Required for Android.
730
+ */
731
+ minimumChromeVersion?: string;
871
732
  }
872
733
  export {};
873
734
  //# sourceMappingURL=WebViewTypes.d.ts.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "Thibault Malbranche <malbranche.thibault@gmail.com>"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "11.26.1-exodus.3",
12
+ "version": "11.26.1-exodus.5",
13
13
  "homepage": "https://github.com/ExodusMovement/react-native-webview#readme",
14
14
  "scripts": {
15
15
  "android": "react-native run-android",
@@ -1,25 +0,0 @@
1
- package com.reactnativecommunity.webview.events
2
-
3
- import com.facebook.react.bridge.WritableMap
4
- import com.facebook.react.uimanager.events.Event
5
- import com.facebook.react.uimanager.events.RCTEventEmitter
6
-
7
- /**
8
- * Event emitted when a http error is received from the server.
9
- */
10
- class TopHttpErrorEvent(viewId: Int, private val mEventData: WritableMap) :
11
- Event<TopHttpErrorEvent>(viewId) {
12
- companion object {
13
- const val EVENT_NAME = "topHttpError"
14
- }
15
-
16
- override fun getEventName(): String = EVENT_NAME
17
-
18
- override fun canCoalesce(): Boolean = false
19
-
20
- override fun getCoalescingKey(): Short = 0
21
-
22
- override fun dispatch(rctEventEmitter: RCTEventEmitter) =
23
- rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
24
-
25
- }
@@ -1,26 +0,0 @@
1
- package com.reactnativecommunity.webview.events
2
-
3
- import com.facebook.react.bridge.WritableMap
4
- import com.facebook.react.uimanager.events.Event
5
- import com.facebook.react.uimanager.events.RCTEventEmitter
6
-
7
- /**
8
- * Event emitted when the WebView's process has crashed or
9
- was killed by the OS.
10
- */
11
- class TopRenderProcessGoneEvent(viewId: Int, private val mEventData: WritableMap) :
12
- Event<TopRenderProcessGoneEvent>(viewId) {
13
- companion object {
14
- const val EVENT_NAME = "topRenderProcessGone"
15
- }
16
-
17
- override fun getEventName(): String = EVENT_NAME
18
-
19
- override fun canCoalesce(): Boolean = false
20
-
21
- override fun getCoalescingKey(): Short = 0
22
-
23
- override fun dispatch(rctEventEmitter: RCTEventEmitter) =
24
- rctEventEmitter.receiveEvent(viewTag, eventName, mEventData)
25
-
26
- }