react-native-webview-bootpay 13.8.42 → 13.13.4-6.alpha.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 (101) hide show
  1. package/README.md +53 -69
  2. package/android/build.gradle +1 -11
  3. package/android/gradle.properties +0 -42
  4. package/android/src/main/AndroidManifest.xml +3 -1
  5. package/android/src/main/AndroidManifestNew.xml +97 -0
  6. package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +54 -10
  7. package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
  8. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +68 -60
  9. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewManagerImpl.kt +119 -65
  10. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewMessagingModule.kt +9 -0
  11. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewModuleImpl.java +1 -1
  12. package/android/src/main/java/kr/co/bootpay/webview/BootpayUrlHelper.java +4 -12
  13. package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewManager.java +118 -109
  14. package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewModule.java +1 -1
  15. package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewManager.java +63 -58
  16. package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewModule.java +1 -1
  17. package/apple/BPCWebView.mm +39 -30
  18. package/apple/BPCWebViewImpl.h +10 -0
  19. package/apple/BPCWebViewImpl.m +267 -205
  20. package/apple/BPCWebViewManager.mm +5 -24
  21. package/apple/BPCWebViewModule.h +23 -0
  22. package/apple/BPCWebViewModule.mm +34 -0
  23. package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
  24. package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
  25. package/index.d.ts +54 -48
  26. package/ios/RNCWebView.xcodeproj/project.pbxproj +24 -24
  27. package/ios/RNCWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  28. package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcuserdata/taesupyoon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  29. package/ios/RNCWebView.xcodeproj/xcuserdata/taesupyoon.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  30. package/lib/BPCWebViewNativeComponent.d.ts +24 -25
  31. package/lib/BPCWebViewNativeComponent.js +1 -1
  32. package/lib/{NativeBPCWebView.d.ts → NativeBPCWebViewModule.d.ts} +2 -5
  33. package/lib/{NativeBPCWebView.js → NativeBPCWebViewModule.js} +1 -1
  34. package/lib/WebView.android.d.ts +0 -1
  35. package/lib/WebView.android.js +1 -1
  36. package/lib/WebView.d.ts +0 -1
  37. package/lib/WebView.ios.d.ts +0 -1
  38. package/lib/WebView.ios.js +1 -1
  39. package/lib/WebView.js +1 -1
  40. package/lib/WebView.macos.d.ts +0 -1
  41. package/lib/WebView.macos.js +1 -1
  42. package/lib/WebView.styles.d.ts +37 -11
  43. package/lib/WebView.styles.js +1 -1
  44. package/lib/WebView.windows.d.ts +0 -1
  45. package/lib/WebView.windows.js +1 -1
  46. package/lib/WebViewNativeComponent.macos.d.ts +1 -2
  47. package/lib/WebViewNativeComponent.windows.d.ts +1 -2
  48. package/lib/WebViewShared.d.ts +0 -1
  49. package/lib/WebViewShared.js +1 -1
  50. package/lib/WebViewTypes.d.ts +51 -3
  51. package/lib/WebViewTypes.js +1 -1
  52. package/lib/index.d.ts +0 -1
  53. package/macos/RNCWebView.xcodeproj/project.pbxproj +36 -36
  54. package/package.json +12 -11
  55. package/react-native-webview-bootpay.podspec +2 -2
  56. package/react-native.config.js +1 -5
  57. package/src/BPCWebViewNativeComponent.ts +143 -79
  58. package/src/NativeBPCWebViewModule.ts +13 -0
  59. package/src/WebView.android.tsx +295 -190
  60. package/src/WebView.ios.tsx +253 -186
  61. package/src/WebView.macos.tsx +220 -152
  62. package/src/WebView.styles.ts +9 -12
  63. package/src/WebView.tsx +14 -7
  64. package/src/WebView.windows.tsx +180 -126
  65. package/src/WebViewNativeComponent.macos.ts +4 -5
  66. package/src/WebViewNativeComponent.windows.ts +6 -8
  67. package/src/WebViewShared.tsx +139 -91
  68. package/src/WebViewTypes.ts +80 -35
  69. package/src/__tests__/WebViewShared-test.js +170 -55
  70. package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +8 -17
  71. package/windows/ReactNativeWebView/ReactPackageProvider.cpp +5 -1
  72. package/windows/ReactNativeWebView/ReactWebView.cpp +73 -6
  73. package/windows/ReactNativeWebView/ReactWebView.h +11 -1
  74. package/windows/ReactNativeWebView/ReactWebView.idl +12 -3
  75. package/windows/ReactNativeWebView/ReactWebView2.cpp +294 -129
  76. package/windows/ReactNativeWebView/ReactWebView2.h +42 -5
  77. package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +60 -34
  78. package/windows/ReactNativeWebView/ReactWebView2Manager.h +4 -4
  79. package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
  80. package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
  81. package/windows/ReactNativeWebView/ReactWebViewManager.cpp +22 -3
  82. package/windows/ReactNativeWebView/ReactWebViewManager.h +6 -1
  83. package/windows/ReactNativeWebView/pch.h +11 -7
  84. package/windows/ReactNativeWebView.sln +14 -14
  85. package/ios/main.jsbundle +0 -457
  86. package/lib/BPCWebViewNativeComponent.d.ts.map +0 -1
  87. package/lib/NativeBPCWebView.d.ts.map +0 -1
  88. package/lib/WebView.android.d.ts.map +0 -1
  89. package/lib/WebView.d.ts.map +0 -1
  90. package/lib/WebView.ios.d.ts.map +0 -1
  91. package/lib/WebView.macos.d.ts.map +0 -1
  92. package/lib/WebView.styles.d.ts.map +0 -1
  93. package/lib/WebView.windows.d.ts.map +0 -1
  94. package/lib/WebViewNativeComponent.macos.d.ts.map +0 -1
  95. package/lib/WebViewNativeComponent.windows.d.ts.map +0 -1
  96. package/lib/WebViewShared.d.ts.map +0 -1
  97. package/lib/WebViewTypes.d.ts.map +0 -1
  98. package/lib/index.d.ts.map +0 -1
  99. package/src/NativeBPCWebView.ts +0 -14
  100. package/windows/ReactNativeWebView/packages.config +0 -5
  101. /package/android/src/main/java/kr/co/bootpay/webview/{BPCWebviewWrapper.kt → BPCWebViewWrapper.kt} +0 -0
@@ -1,5 +1,3 @@
1
- /* eslint-disable react/no-multi-comp, max-classes-per-file */
2
-
3
1
  import { ReactElement, Component, ComponentProps } from 'react';
4
2
  import {
5
3
  NativeSyntheticEvent,
@@ -11,7 +9,7 @@ import {
11
9
  NativeScrollEvent,
12
10
  } from 'react-native';
13
11
 
14
- import type NativeWebViewComponent from './BPCWebViewNativeComponent'
12
+ import type NativeWebViewComponent from './BPCWebViewNativeComponent';
15
13
 
16
14
  type WebViewCommands =
17
15
  | 'goForward'
@@ -57,16 +55,13 @@ interface ErrorState extends BaseState {
57
55
 
58
56
  export type State = NormalState | ErrorState;
59
57
 
60
- // eslint-disable-next-line @typescript-eslint/no-type-alias, @typescript-eslint/no-explicit-any
61
58
  type Constructor<T> = new (...args: any[]) => T;
62
59
 
63
- // eslint-disable-next-line react/prefer-stateless-function
64
60
  declare class NativeWebViewMacOSComponent extends Component<MacOSNativeWebViewProps> {}
65
61
  declare const NativeWebViewMacOSBase: Constructor<NativeMethodsMixin> &
66
62
  typeof NativeWebViewMacOSComponent;
67
63
  export class NativeWebViewMacOS extends NativeWebViewMacOSBase {}
68
64
 
69
- // eslint-disable-next-line react/prefer-stateless-function
70
65
  declare class NativeWebViewWindowsComponent extends Component<WindowsNativeWebViewProps> {}
71
66
  declare const NativeWebViewWindowsBase: Constructor<NativeMethodsMixin> &
72
67
  typeof NativeWebViewWindowsComponent;
@@ -237,19 +232,19 @@ export interface WebViewCustomMenuItems {
237
232
  label: string;
238
233
  }
239
234
 
240
- export declare type SuppressMenuItem =
241
- | "cut"
242
- | "copy"
243
- | "paste"
244
- | "replace"
245
- | "bold"
246
- | "italic"
247
- | "underline"
248
- | "select"
249
- | "selectAll"
250
- | "translate"
251
- | "lookup"
252
- | "share";
235
+ export declare type SuppressMenuItem =
236
+ | 'cut'
237
+ | 'copy'
238
+ | 'paste'
239
+ | 'replace'
240
+ | 'bold'
241
+ | 'italic'
242
+ | 'underline'
243
+ | 'select'
244
+ | 'selectAll'
245
+ | 'translate'
246
+ | 'lookup'
247
+ | 'share';
253
248
 
254
249
  export type WebViewSource = WebViewSourceUri | WebViewSourceHtml;
255
250
 
@@ -261,9 +256,7 @@ export interface WebViewNativeConfig {
261
256
  /**
262
257
  * The native component used to render the WebView.
263
258
  */
264
- component?:
265
- | typeof NativeWebViewMacOS
266
- | typeof NativeWebViewComponent;
259
+ component?: typeof NativeWebViewMacOS | typeof NativeWebViewComponent;
267
260
  /**
268
261
  * Set props directly on the native component WebView. Enables custom props which the
269
262
  * original WebView doesn't pass through.
@@ -277,7 +270,7 @@ export interface WebViewNativeConfig {
277
270
  }
278
271
 
279
272
  export type OnShouldStartLoadWithRequest = (
280
- event: ShouldStartLoadRequest,
273
+ event: ShouldStartLoadRequest
281
274
  ) => boolean;
282
275
 
283
276
  export interface BasicAuthCredential {
@@ -314,7 +307,7 @@ export interface CommonNativeWebViewProps extends ViewProps {
314
307
  showsHorizontalScrollIndicator?: boolean;
315
308
  showsVerticalScrollIndicator?: boolean;
316
309
  // TODO: find a better way to type this.
317
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
310
+
318
311
  source: any;
319
312
  userAgent?: string;
320
313
  /**
@@ -345,6 +338,7 @@ export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
345
338
  allowUniversalAccessFromFileURLs?: boolean;
346
339
  allowsBackForwardNavigationGestures?: boolean;
347
340
  allowsInlineMediaPlayback?: boolean;
341
+ allowsPictureInPictureMediaPlayback?: boolean;
348
342
  allowsAirPlayForMediaPlayback?: boolean;
349
343
  allowsLinkPreview?: boolean;
350
344
  automaticallyAdjustContentInsets?: boolean;
@@ -362,10 +356,37 @@ export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
362
356
 
363
357
  export interface WindowsNativeWebViewProps extends CommonNativeWebViewProps {
364
358
  testID?: string;
359
+ linkHandlingEnabled?: boolean;
360
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
361
+ onSourceChanged?: (event: WebViewNavigationEvent) => void;
365
362
  }
366
363
 
367
364
  export interface WindowsWebViewProps extends WebViewSharedProps {
365
+ /**
366
+ * Boolean value that detenmines whether the web view should use the new chromium based edge webview.
367
+ */
368
368
  useWebView2?: boolean;
369
+ /**
370
+ * Function that is invoked when the `WebView` should open a new window.
371
+ *
372
+ * This happens when the JS calls `window.open('http://someurl', '_blank')`
373
+ * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
374
+ *
375
+ * Only works with `useWebView2` set to `true`.
376
+ *
377
+ * @platform windows
378
+ */
379
+ onOpenWindow?: (event: WebViewOpenWindowEvent) => void;
380
+
381
+ /**
382
+ * Function that is invoked when the `WebView` responds to a request to load a new resource.
383
+ * Works only on Windows.
384
+ *
385
+ * Only works with `useWebView2` set to `true`.
386
+ *
387
+ * @platform windows
388
+ */
389
+ onSourceChanged?: (event: WebViewNavigationEvent) => void;
369
390
  }
370
391
 
371
392
  export interface IOSWebViewProps extends WebViewSharedProps {
@@ -485,6 +506,13 @@ export interface IOSWebViewProps extends WebViewSharedProps {
485
506
  * @platform ios
486
507
  */
487
508
  allowsInlineMediaPlayback?: boolean;
509
+ /**
510
+ * Boolean value that indicates whether HTML5 videos can play Picture in Picture.
511
+ * The default value is `true`.
512
+ *
513
+ * @platform macos
514
+ */
515
+ allowsPictureInPictureMediaPlayback?: boolean;
488
516
  /**
489
517
  * A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
490
518
  * @platform ios
@@ -600,7 +628,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {
600
628
 
601
629
  /**
602
630
  * Function that is invoked when the `WebView` should open a new window.
603
- *
631
+ *
604
632
  * This happens when the JS calls `window.open('http://someurl', '_blank')`
605
633
  * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
606
634
  *
@@ -631,6 +659,15 @@ export interface IOSWebViewProps extends WebViewSharedProps {
631
659
  */
632
660
  pullToRefreshEnabled?: boolean;
633
661
 
662
+ /**
663
+ * Boolean value that determines whether a pull to refresh gesture is
664
+ * available in the `WebView`. The default value is `false`.
665
+ * If `true`, sets `bounces` automatically to `true`
666
+ * @platform ios
667
+ *
668
+ */
669
+ refreshControlLightMode?: boolean;
670
+
634
671
  /**
635
672
  * Function that is invoked when the client needs to download a file.
636
673
  *
@@ -711,11 +748,12 @@ export interface IOSWebViewProps extends WebViewSharedProps {
711
748
  * `selectedText`: the text selected on the document
712
749
  * @platform ios, android
713
750
  */
714
- onCustomMenuSelection?: (event: {nativeEvent: {
715
- label: string;
716
- key: string;
717
- selectedText: string;
718
- }
751
+ onCustomMenuSelection?: (event: {
752
+ nativeEvent: {
753
+ label: string;
754
+ key: string;
755
+ selectedText: string;
756
+ };
719
757
  }) => void;
720
758
 
721
759
  /**
@@ -786,6 +824,13 @@ export interface MacOSWebViewProps extends WebViewSharedProps {
786
824
  * @platform macos
787
825
  */
788
826
  allowsInlineMediaPlayback?: boolean;
827
+ /**
828
+ * Boolean value that indicates whether HTML5 videos can play Picture in Picture.
829
+ * The default value is `true`.
830
+ *
831
+ * @platform ios
832
+ */
833
+ allowsPictureInPictureMediaPlayback?: boolean;
789
834
  /**
790
835
  * A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
791
836
  * @platform macos
@@ -896,7 +941,7 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
896
941
 
897
942
  /**
898
943
  * Function that is invoked when the `WebView` should open a new window.
899
- *
944
+ *
900
945
  * This happens when the JS calls `window.open('http://someurl', '_blank')`
901
946
  * or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
902
947
  *
@@ -918,7 +963,7 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
918
963
  cacheMode?: CacheMode;
919
964
 
920
965
  /**
921
- * https://developer.android.com/reference/android/view/View#OVER_SCROLL_NEVER
966
+ * https://developer.android.com/reference/android/view/View#setOverScrollMode(int)
922
967
  * Sets the overScrollMode. Possible values are:
923
968
  *
924
969
  * - `'always'` (default)
@@ -1132,7 +1177,7 @@ export interface WebViewSharedProps extends ViewProps {
1132
1177
  renderError?: (
1133
1178
  errorDomain: string | undefined,
1134
1179
  errorCode: number,
1135
- errorDesc: string,
1180
+ errorDesc: string
1136
1181
  ) => ReactElement; // view to show if there's an error
1137
1182
 
1138
1183
  /**
@@ -1143,7 +1188,7 @@ export interface WebViewSharedProps extends ViewProps {
1143
1188
  /**
1144
1189
  * Function that is invoked when the `WebView` scrolls.
1145
1190
  */
1146
- onScroll?: ComponentProps<typeof NativeWebViewComponent>['onScroll'];
1191
+ onScroll?: ComponentProps<typeof NativeWebViewComponent>['onScroll'];
1147
1192
 
1148
1193
  /**
1149
1194
  * Function that is invoked when the `WebView` has finished loading.
@@ -1279,7 +1324,7 @@ export interface WebViewSharedProps extends ViewProps {
1279
1324
  * Inject a JavaScript object to be accessed as a JSON string via JavaScript in the WebView.
1280
1325
  */
1281
1326
  injectedJavaScriptObject?: object;
1282
-
1327
+
1283
1328
  /**
1284
1329
  * Enables WebView remote debugging using Chrome (Android) or Safari (iOS).
1285
1330
  */
@@ -26,10 +26,9 @@ Linking.canOpenURL.mockResolvedValue(true);
26
26
  //
27
27
  // See this issue for more discussion: https://github.com/facebook/jest/issues/2157
28
28
  function flushPromises() {
29
- return new Promise(resolve => setImmediate(resolve));
29
+ return new Promise((resolve) => setImmediate(resolve));
30
30
  }
31
31
 
32
-
33
32
  describe('WebViewShared', () => {
34
33
  test('exports defaultOriginWhitelist', () => {
35
34
  expect(defaultOriginWhitelist).toMatchSnapshot();
@@ -49,160 +48,276 @@ describe('WebViewShared', () => {
49
48
  test('loadRequest is called without onShouldStartLoadWithRequest override', async () => {
50
49
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
51
50
  loadRequest,
52
- defaultOriginWhitelist,
51
+ defaultOriginWhitelist
53
52
  );
54
53
 
55
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
56
-
54
+ onShouldStartLoadWithRequest({
55
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
56
+ });
57
+
57
58
  await flushPromises();
58
59
 
59
60
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
60
- expect(loadRequest).toHaveBeenCalledWith(true, 'https://www.example.com/', 1);
61
+ expect(loadRequest).toHaveBeenCalledWith(
62
+ true,
63
+ 'https://www.example.com/',
64
+ 1
65
+ );
61
66
  });
62
67
 
63
68
  test('Linking.openURL is called without onShouldStartLoadWithRequest override', async () => {
64
69
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
65
70
  loadRequest,
66
- defaultOriginWhitelist,
71
+ defaultOriginWhitelist
67
72
  );
68
73
 
69
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 2 } });
70
-
74
+ onShouldStartLoadWithRequest({
75
+ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 2 },
76
+ });
77
+
71
78
  await flushPromises();
72
79
 
73
80
  expect(Linking.openURL).toHaveBeenCalledWith('invalid://example.com/');
74
- expect(loadRequest).toHaveBeenCalledWith(false, 'invalid://example.com/', 2);
81
+ expect(loadRequest).toHaveBeenCalledWith(
82
+ false,
83
+ 'invalid://example.com/',
84
+ 2
85
+ );
75
86
  });
76
87
 
77
88
  test('loadRequest with true onShouldStartLoadWithRequest override is called', async () => {
78
89
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
79
90
  loadRequest,
80
91
  defaultOriginWhitelist,
81
- alwaysTrueOnShouldStartLoadWithRequest,
92
+ alwaysTrueOnShouldStartLoadWithRequest
82
93
  );
83
94
 
84
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
95
+ onShouldStartLoadWithRequest({
96
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
97
+ });
85
98
 
86
99
  await flushPromises();
87
100
 
88
101
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
89
- expect(loadRequest).toHaveBeenLastCalledWith(true, 'https://www.example.com/', 1);
102
+ expect(loadRequest).toHaveBeenLastCalledWith(
103
+ true,
104
+ 'https://www.example.com/',
105
+ 1
106
+ );
90
107
  });
91
108
 
92
109
  test('Linking.openURL with true onShouldStartLoadWithRequest override is called for links not passing the whitelist', async () => {
93
110
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
94
111
  loadRequest,
95
112
  defaultOriginWhitelist,
96
- alwaysTrueOnShouldStartLoadWithRequest,
113
+ alwaysTrueOnShouldStartLoadWithRequest
97
114
  );
98
115
 
99
- var a = 10;
100
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 1 } });
116
+ onShouldStartLoadWithRequest({
117
+ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 1 },
118
+ });
101
119
 
102
120
  await flushPromises();
103
121
 
104
- expect(Linking.openURL).toHaveBeenLastCalledWith('invalid://example.com/');
122
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
123
+ 'invalid://example.com/'
124
+ );
105
125
  // We don't expect the URL to have been loaded in the WebView because it
106
126
  // is not in the origin whitelist
107
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'invalid://example.com/', 1);
127
+ expect(loadRequest).toHaveBeenLastCalledWith(
128
+ false,
129
+ 'invalid://example.com/',
130
+ 1
131
+ );
108
132
  });
109
133
 
110
134
  test('loadRequest with false onShouldStartLoadWithRequest override is called', async () => {
111
135
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
112
136
  loadRequest,
113
137
  defaultOriginWhitelist,
114
- alwaysFalseOnShouldStartLoadWithRequest,
138
+ alwaysFalseOnShouldStartLoadWithRequest
115
139
  );
116
140
 
117
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
141
+ onShouldStartLoadWithRequest({
142
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
143
+ });
118
144
 
119
145
  await flushPromises();
120
146
 
121
147
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
122
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'https://www.example.com/', 1);
148
+ expect(loadRequest).toHaveBeenLastCalledWith(
149
+ false,
150
+ 'https://www.example.com/',
151
+ 1
152
+ );
123
153
  });
124
154
 
125
155
  test('loadRequest with limited whitelist', async () => {
126
156
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
127
157
  loadRequest,
128
- ['https://*'],
158
+ ['https://*']
129
159
  );
130
160
 
131
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 } });
132
-
161
+ onShouldStartLoadWithRequest({
162
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
163
+ });
164
+
133
165
  await flushPromises();
134
166
 
135
167
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
136
- expect(loadRequest).toHaveBeenLastCalledWith(true, 'https://www.example.com/', 1);
168
+ expect(loadRequest).toHaveBeenLastCalledWith(
169
+ true,
170
+ 'https://www.example.com/',
171
+ 1
172
+ );
137
173
 
138
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'http://insecure.com/', lockIdentifier: 2 } });
174
+ onShouldStartLoadWithRequest({
175
+ nativeEvent: { url: 'http://insecure.com/', lockIdentifier: 2 },
176
+ });
139
177
 
140
178
  await flushPromises();
141
179
 
142
180
  expect(Linking.openURL).toHaveBeenLastCalledWith('http://insecure.com/');
143
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'http://insecure.com/', 2);
181
+ expect(loadRequest).toHaveBeenLastCalledWith(
182
+ false,
183
+ 'http://insecure.com/',
184
+ 2
185
+ );
186
+
187
+ onShouldStartLoadWithRequest({
188
+ nativeEvent: { url: 'git+https://insecure.com/', lockIdentifier: 3 },
189
+ });
144
190
 
145
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'git+https://insecure.com/', lockIdentifier: 3 } });
146
-
147
191
  await flushPromises();
148
192
 
149
- expect(Linking.openURL).toHaveBeenLastCalledWith('git+https://insecure.com/');
150
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'git+https://insecure.com/', 3);
193
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
194
+ 'git+https://insecure.com/'
195
+ );
196
+ expect(loadRequest).toHaveBeenLastCalledWith(
197
+ false,
198
+ 'git+https://insecure.com/',
199
+ 3
200
+ );
201
+
202
+ onShouldStartLoadWithRequest({
203
+ nativeEvent: { url: 'fakehttps://insecure.com/', lockIdentifier: 4 },
204
+ });
151
205
 
152
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'fakehttps://insecure.com/', lockIdentifier: 4 } });
153
-
154
206
  await flushPromises();
155
207
 
156
- expect(Linking.openURL).toHaveBeenLastCalledWith('fakehttps://insecure.com/');
157
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'fakehttps://insecure.com/', 4);
208
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
209
+ 'fakehttps://insecure.com/'
210
+ );
211
+ expect(loadRequest).toHaveBeenLastCalledWith(
212
+ false,
213
+ 'fakehttps://insecure.com/',
214
+ 4
215
+ );
158
216
  });
159
217
 
160
218
  test('loadRequest allows for valid URIs', async () => {
161
219
  const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
162
- loadRequest,
163
- ['plus+https://*', 'DOT.https://*', 'dash-https://*', '0invalid://*', '+invalid://*'],
220
+ loadRequest,
221
+ [
222
+ 'plus+https://*',
223
+ 'DOT.https://*',
224
+ 'dash-https://*',
225
+ '0invalid://*',
226
+ '+invalid://*',
227
+ ]
164
228
  );
165
229
 
166
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'plus+https://www.example.com/', lockIdentifier: 1 } });
167
-
230
+ onShouldStartLoadWithRequest({
231
+ nativeEvent: {
232
+ url: 'plus+https://www.example.com/',
233
+ lockIdentifier: 1,
234
+ },
235
+ });
236
+
168
237
  await flushPromises();
169
238
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
170
- expect(loadRequest).toHaveBeenLastCalledWith(true, 'plus+https://www.example.com/', 1);
239
+ expect(loadRequest).toHaveBeenLastCalledWith(
240
+ true,
241
+ 'plus+https://www.example.com/',
242
+ 1
243
+ );
171
244
 
172
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'DOT.https://www.example.com/', lockIdentifier: 2 } });
245
+ onShouldStartLoadWithRequest({
246
+ nativeEvent: { url: 'DOT.https://www.example.com/', lockIdentifier: 2 },
247
+ });
173
248
 
174
249
  await flushPromises();
175
250
 
176
251
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
177
- expect(loadRequest).toHaveBeenLastCalledWith(true, 'DOT.https://www.example.com/', 2);
252
+ expect(loadRequest).toHaveBeenLastCalledWith(
253
+ true,
254
+ 'DOT.https://www.example.com/',
255
+ 2
256
+ );
257
+
258
+ onShouldStartLoadWithRequest({
259
+ nativeEvent: {
260
+ url: 'dash-https://www.example.com/',
261
+ lockIdentifier: 3,
262
+ },
263
+ });
178
264
 
179
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'dash-https://www.example.com/', lockIdentifier: 3 } });
180
-
181
265
  await flushPromises();
182
266
 
183
267
  expect(Linking.openURL).toHaveBeenCalledTimes(0);
184
- expect(loadRequest).toHaveBeenLastCalledWith(true, 'dash-https://www.example.com/', 3);
268
+ expect(loadRequest).toHaveBeenLastCalledWith(
269
+ true,
270
+ 'dash-https://www.example.com/',
271
+ 3
272
+ );
185
273
 
186
- onShouldStartLoadWithRequest({ nativeEvent: { url: '0invalid://www.example.com/', lockIdentifier: 4 } });
274
+ onShouldStartLoadWithRequest({
275
+ nativeEvent: { url: '0invalid://www.example.com/', lockIdentifier: 4 },
276
+ });
187
277
 
188
278
  await flushPromises();
189
279
 
190
- expect(Linking.openURL).toHaveBeenLastCalledWith('0invalid://www.example.com/');
191
- expect(loadRequest).toHaveBeenLastCalledWith(false, '0invalid://www.example.com/', 4);
280
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
281
+ '0invalid://www.example.com/'
282
+ );
283
+ expect(loadRequest).toHaveBeenLastCalledWith(
284
+ false,
285
+ '0invalid://www.example.com/',
286
+ 4
287
+ );
288
+
289
+ onShouldStartLoadWithRequest({
290
+ nativeEvent: { url: '+invalid://www.example.com/', lockIdentifier: 5 },
291
+ });
192
292
 
193
- onShouldStartLoadWithRequest({ nativeEvent: { url: '+invalid://www.example.com/', lockIdentifier: 5 } });
194
-
195
293
  await flushPromises();
196
294
 
197
- expect(Linking.openURL).toHaveBeenLastCalledWith('+invalid://www.example.com/');
198
- expect(loadRequest).toHaveBeenLastCalledWith(false, '+invalid://www.example.com/', 5);
295
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
296
+ '+invalid://www.example.com/'
297
+ );
298
+ expect(loadRequest).toHaveBeenLastCalledWith(
299
+ false,
300
+ '+invalid://www.example.com/',
301
+ 5
302
+ );
199
303
 
200
- onShouldStartLoadWithRequest({ nativeEvent: { url: 'FAKE+plus+https://www.example.com/', lockIdentifier: 6 } });
304
+ onShouldStartLoadWithRequest({
305
+ nativeEvent: {
306
+ url: 'FAKE+plus+https://www.example.com/',
307
+ lockIdentifier: 6,
308
+ },
309
+ });
201
310
 
202
311
  await flushPromises();
203
312
 
204
- expect(Linking.openURL).toHaveBeenLastCalledWith('FAKE+plus+https://www.example.com/');
205
- expect(loadRequest).toHaveBeenLastCalledWith(false, 'FAKE+plus+https://www.example.com/', 6);
313
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
314
+ 'FAKE+plus+https://www.example.com/'
315
+ );
316
+ expect(loadRequest).toHaveBeenLastCalledWith(
317
+ false,
318
+ 'FAKE+plus+https://www.example.com/',
319
+ 6
320
+ );
206
321
  });
207
322
  });
208
323
  });
@@ -116,12 +116,12 @@
116
116
  </ClCompile>
117
117
  </ItemDefinitionGroup>
118
118
  <ItemDefinitionGroup Condition="'$(WinUI2_HasWebView2)'=='true'">
119
- <ClCompile>
120
- <PreprocessorDefinitions>WINUI2_HAS_WEBVIEW2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121
- </ClCompile>
122
- <Midl>
123
- <PreprocessorDefinitions>WINUI2_HAS_WEBVIEW2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124
- </Midl>
119
+ <ClCompile>
120
+ <PreprocessorDefinitions>WINUI2_HAS_WEBVIEW2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121
+ </ClCompile>
122
+ <Midl>
123
+ <PreprocessorDefinitions>WINUI2_HAS_WEBVIEW2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124
+ </Midl>
125
125
  </ItemDefinitionGroup>
126
126
  <ItemGroup>
127
127
  <ClInclude Include="ReactWebView.h" />
@@ -131,6 +131,7 @@
131
131
  <ClInclude Include="ReactPackageProvider.h">
132
132
  <DependentUpon>ReactPackageProvider.idl</DependentUpon>
133
133
  </ClInclude>
134
+ <ClInclude Include="ReactWebViewHelpers.h" />
134
135
  <ClInclude Include="ReactWebViewManager.h" />
135
136
  <ClInclude Include="WebBridge.h" />
136
137
  </ItemGroup>
@@ -145,6 +146,7 @@
145
146
  <DependentUpon>ReactPackageProvider.idl</DependentUpon>
146
147
  </ClCompile>
147
148
  <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
149
+ <ClCompile Include="ReactWebViewHelpers.cpp" />
148
150
  <ClCompile Include="ReactWebViewManager.cpp" />
149
151
  <ClCompile Include="WebBridge.cpp" />
150
152
  </ItemGroup>
@@ -157,7 +159,6 @@
157
159
  <None Include="packages.config" />
158
160
  <None Include="ReactNativeWebView.def" />
159
161
  </ItemGroup>
160
-
161
162
  <ItemGroup>
162
163
  <None Include="PropertySheet.props" />
163
164
  </ItemGroup>
@@ -185,14 +186,4 @@
185
186
  <Import Project="$(SolutionDir)\packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets" Condition="'$(UseExperimentalNuget)'=='true' And Exists('$(SolutionDir)\packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets')" />
186
187
  </ImportGroup>
187
188
  <Target Name="Deploy" />
188
- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
189
- <PropertyGroup>
190
- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
191
- </PropertyGroup>
192
- <Error Condition="!Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props'))" />
193
- <Error Condition="!Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets'))" />
194
- <Error Condition="!Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets'))" />
195
- <Error Condition="'$(UseExperimentalNuget)'=='true' And !Exists('$(SolutionDir)\packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets'))" />
196
- <Error Condition="'$(UseExperimentalNuget)'=='true' And !Exists('$(SolutionDir)\packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets'))" />
197
- </Target>
198
189
  </Project>
@@ -5,18 +5,22 @@
5
5
  #endif
6
6
 
7
7
  #include "ReactWebView2Manager.h"
8
+ #ifndef USE_WINUI3
8
9
  #include "ReactWebViewManager.h"
10
+ #endif
9
11
 
10
12
  using namespace winrt::Microsoft::ReactNative;
11
13
 
12
14
  namespace winrt::ReactNativeWebView::implementation {
13
15
 
14
16
  void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept {
17
+ #ifndef USE_WINUI3
15
18
  packageBuilder.AddViewManager(L"ReactWebViewManager", []() { return winrt::make<ReactWebViewManager>(); });
19
+ #endif
16
20
 
17
21
  #if HAS_WEBVIEW2
18
22
  packageBuilder.AddViewManager(L"ReactWebView2Manager", []() { return winrt::make<ReactWebView2Manager>(); });
19
23
  #endif
20
24
  }
21
25
 
22
- } // namespace winrt::ReactNativeWebView::implementation
26
+ } // namespace winrt::ReactNativeWebView::implementation