@javascriptcommon/react-native-webview 13.12.16

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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -0
  3. package/android/build.gradle +110 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +15 -0
  6. package/android/src/main/AndroidManifestNew.xml +13 -0
  7. package/android/src/main/java/com/reactnativecommunity/webview/RNCBasicAuthCredential.java +11 -0
  8. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java +372 -0
  9. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java +450 -0
  10. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java +328 -0
  11. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewConfig.java +11 -0
  12. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java +14 -0
  13. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +720 -0
  14. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewMessagingModule.kt +19 -0
  15. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java +554 -0
  16. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +56 -0
  17. package/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewWrapper.kt +39 -0
  18. package/android/src/main/java/com/reactnativecommunity/webview/URLUtil.java +179 -0
  19. package/android/src/main/java/com/reactnativecommunity/webview/events/TopCustomMenuSelectionEvent.kt +24 -0
  20. package/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +25 -0
  21. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt +25 -0
  22. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt +24 -0
  23. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt +24 -0
  24. package/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt +25 -0
  25. package/android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt +24 -0
  26. package/android/src/main/java/com/reactnativecommunity/webview/events/TopNewWindowEvent.kt +25 -0
  27. package/android/src/main/java/com/reactnativecommunity/webview/events/TopRenderProcessGoneEvent.kt +26 -0
  28. package/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt +29 -0
  29. package/android/src/main/res/xml/file_provider_paths.xml +6 -0
  30. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java +553 -0
  31. package/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java +63 -0
  32. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java +328 -0
  33. package/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java +59 -0
  34. package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
  35. package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
  36. package/apple/RNCWKProcessPoolManager.h +15 -0
  37. package/apple/RNCWKProcessPoolManager.m +36 -0
  38. package/apple/RNCWebView.h +35 -0
  39. package/apple/RNCWebView.mm +546 -0
  40. package/apple/RNCWebViewDecisionManager.h +20 -0
  41. package/apple/RNCWebViewDecisionManager.m +47 -0
  42. package/apple/RNCWebViewImpl.h +161 -0
  43. package/apple/RNCWebViewImpl.m +1979 -0
  44. package/apple/RNCWebViewManager.h +9 -0
  45. package/apple/RNCWebViewManager.mm +215 -0
  46. package/apple/RNCWebViewModule.h +23 -0
  47. package/apple/RNCWebViewModule.mm +34 -0
  48. package/index.d.ts +65 -0
  49. package/index.js +4 -0
  50. package/ios/RNCWebView.xcodeproj/project.pbxproj +273 -0
  51. package/lib/NativeRNCWebViewModule.d.ts +10 -0
  52. package/lib/NativeRNCWebViewModule.js +1 -0
  53. package/lib/RNCWebViewNativeComponent.d.ts +242 -0
  54. package/lib/RNCWebViewNativeComponent.js +1 -0
  55. package/lib/WebView.android.d.ts +6 -0
  56. package/lib/WebView.android.js +1 -0
  57. package/lib/WebView.d.ts +6 -0
  58. package/lib/WebView.ios.d.ts +6 -0
  59. package/lib/WebView.ios.js +1 -0
  60. package/lib/WebView.js +1 -0
  61. package/lib/WebView.macos.d.ts +6 -0
  62. package/lib/WebView.macos.js +1 -0
  63. package/lib/WebView.styles.d.ts +38 -0
  64. package/lib/WebView.styles.js +1 -0
  65. package/lib/WebView.windows.d.ts +17 -0
  66. package/lib/WebView.windows.js +1 -0
  67. package/lib/WebViewNativeComponent.macos.d.ts +3 -0
  68. package/lib/WebViewNativeComponent.macos.js +1 -0
  69. package/lib/WebViewNativeComponent.windows.d.ts +3 -0
  70. package/lib/WebViewNativeComponent.windows.js +1 -0
  71. package/lib/WebViewShared.d.ts +38 -0
  72. package/lib/WebViewShared.js +1 -0
  73. package/lib/WebViewTypes.d.ts +1093 -0
  74. package/lib/WebViewTypes.js +1 -0
  75. package/lib/index.d.ts +3 -0
  76. package/lib/index.js +1 -0
  77. package/macos/RNCWebView.xcodeproj/project.pbxproj +363 -0
  78. package/package.json +101 -0
  79. package/react-native-webview.podspec +46 -0
  80. package/react-native.config.js +44 -0
  81. package/src/NativeRNCWebViewModule.ts +15 -0
  82. package/src/RNCWebViewNativeComponent.ts +342 -0
  83. package/src/WebView.android.tsx +317 -0
  84. package/src/WebView.ios.tsx +299 -0
  85. package/src/WebView.macos.tsx +245 -0
  86. package/src/WebView.styles.ts +41 -0
  87. package/src/WebView.tsx +25 -0
  88. package/src/WebView.windows.tsx +210 -0
  89. package/src/WebViewNativeComponent.macos.ts +7 -0
  90. package/src/WebViewNativeComponent.windows.ts +8 -0
  91. package/src/WebViewShared.tsx +283 -0
  92. package/src/WebViewTypes.ts +1332 -0
  93. package/src/__tests__/WebViewShared-test.js +323 -0
  94. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +8 -0
  95. package/src/index.ts +4 -0
  96. package/windows/ExperimentalFeatures.props +11 -0
  97. package/windows/ReactNativeWebView/PropertySheet.props +16 -0
  98. package/windows/ReactNativeWebView/ReactNativeWebView.def +3 -0
  99. package/windows/ReactNativeWebView/ReactNativeWebView.filters +33 -0
  100. package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +189 -0
  101. package/windows/ReactNativeWebView/ReactPackageProvider.cpp +26 -0
  102. package/windows/ReactNativeWebView/ReactPackageProvider.h +20 -0
  103. package/windows/ReactNativeWebView/ReactPackageProvider.idl +7 -0
  104. package/windows/ReactNativeWebView/ReactWebView.cpp +242 -0
  105. package/windows/ReactNativeWebView/ReactWebView.h +56 -0
  106. package/windows/ReactNativeWebView/ReactWebView.idl +31 -0
  107. package/windows/ReactNativeWebView/ReactWebView2.cpp +473 -0
  108. package/windows/ReactNativeWebView/ReactWebView2.h +91 -0
  109. package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +205 -0
  110. package/windows/ReactNativeWebView/ReactWebView2Manager.h +57 -0
  111. package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
  112. package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
  113. package/windows/ReactNativeWebView/ReactWebViewManager.cpp +224 -0
  114. package/windows/ReactNativeWebView/ReactWebViewManager.h +58 -0
  115. package/windows/ReactNativeWebView/WebBridge.cpp +19 -0
  116. package/windows/ReactNativeWebView/WebBridge.h +24 -0
  117. package/windows/ReactNativeWebView/WebBridge.idl +11 -0
  118. package/windows/ReactNativeWebView/pch.cpp +1 -0
  119. package/windows/ReactNativeWebView/pch.h +37 -0
  120. package/windows/ReactNativeWebView.sln +185 -0
@@ -0,0 +1,323 @@
1
+ import { Linking } from 'react-native';
2
+
3
+ import {
4
+ defaultOriginWhitelist,
5
+ createOnShouldStartLoadWithRequest,
6
+ } from '../WebViewShared';
7
+
8
+ Linking.openURL.mockResolvedValue(undefined);
9
+ Linking.canOpenURL.mockResolvedValue(true);
10
+
11
+ // The tests that call createOnShouldStartLoadWithRequest will cause a promise
12
+ // to get kicked off (by calling the mocked `Linking.canOpenURL`) that the tests
13
+ // _need_ to get run to completion _before_ doing any `expect`ing. The reason
14
+ // is: once that promise is resolved another function should get run which will
15
+ // call `Linking.openURL`, and we want to test that.
16
+ //
17
+ // Normally we would probably do something like `await
18
+ // createShouldStartLoadWithRequest(...)` in the tests, but that doesn't work
19
+ // here because the promise that gets kicked off is not returned (because
20
+ // non-test code doesn't need to know about it).
21
+ //
22
+ // The tests thus need a way to "flush any pending promises" (to make sure
23
+ // pending promises run to completion) before doing any `expect`ing. `jest`
24
+ // doesn't provide a way to do this out of the box, but we can use this function
25
+ // to do it.
26
+ //
27
+ // See this issue for more discussion: https://github.com/facebook/jest/issues/2157
28
+ function flushPromises() {
29
+ return new Promise((resolve) => setImmediate(resolve));
30
+ }
31
+
32
+ describe('WebViewShared', () => {
33
+ test('exports defaultOriginWhitelist', () => {
34
+ expect(defaultOriginWhitelist).toMatchSnapshot();
35
+ });
36
+
37
+ describe('createOnShouldStartLoadWithRequest', () => {
38
+ const alwaysTrueOnShouldStartLoadWithRequest = (nativeEvent) => {
39
+ return true;
40
+ };
41
+
42
+ const alwaysFalseOnShouldStartLoadWithRequest = (nativeEvent) => {
43
+ return false;
44
+ };
45
+
46
+ const loadRequest = jest.fn();
47
+
48
+ test('loadRequest is called without onShouldStartLoadWithRequest override', async () => {
49
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
50
+ loadRequest,
51
+ defaultOriginWhitelist
52
+ );
53
+
54
+ onShouldStartLoadWithRequest({
55
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
56
+ });
57
+
58
+ await flushPromises();
59
+
60
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
61
+ expect(loadRequest).toHaveBeenCalledWith(
62
+ true,
63
+ 'https://www.example.com/',
64
+ 1
65
+ );
66
+ });
67
+
68
+ test('Linking.openURL is called without onShouldStartLoadWithRequest override', async () => {
69
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
70
+ loadRequest,
71
+ defaultOriginWhitelist
72
+ );
73
+
74
+ onShouldStartLoadWithRequest({
75
+ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 2 },
76
+ });
77
+
78
+ await flushPromises();
79
+
80
+ expect(Linking.openURL).toHaveBeenCalledWith('invalid://example.com/');
81
+ expect(loadRequest).toHaveBeenCalledWith(
82
+ false,
83
+ 'invalid://example.com/',
84
+ 2
85
+ );
86
+ });
87
+
88
+ test('loadRequest with true onShouldStartLoadWithRequest override is called', async () => {
89
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
90
+ loadRequest,
91
+ defaultOriginWhitelist,
92
+ alwaysTrueOnShouldStartLoadWithRequest
93
+ );
94
+
95
+ onShouldStartLoadWithRequest({
96
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
97
+ });
98
+
99
+ await flushPromises();
100
+
101
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
102
+ expect(loadRequest).toHaveBeenLastCalledWith(
103
+ true,
104
+ 'https://www.example.com/',
105
+ 1
106
+ );
107
+ });
108
+
109
+ test('Linking.openURL with true onShouldStartLoadWithRequest override is called for links not passing the whitelist', async () => {
110
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
111
+ loadRequest,
112
+ defaultOriginWhitelist,
113
+ alwaysTrueOnShouldStartLoadWithRequest
114
+ );
115
+
116
+ onShouldStartLoadWithRequest({
117
+ nativeEvent: { url: 'invalid://example.com/', lockIdentifier: 1 },
118
+ });
119
+
120
+ await flushPromises();
121
+
122
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
123
+ 'invalid://example.com/'
124
+ );
125
+ // We don't expect the URL to have been loaded in the WebView because it
126
+ // is not in the origin whitelist
127
+ expect(loadRequest).toHaveBeenLastCalledWith(
128
+ false,
129
+ 'invalid://example.com/',
130
+ 1
131
+ );
132
+ });
133
+
134
+ test('loadRequest with false onShouldStartLoadWithRequest override is called', async () => {
135
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
136
+ loadRequest,
137
+ defaultOriginWhitelist,
138
+ alwaysFalseOnShouldStartLoadWithRequest
139
+ );
140
+
141
+ onShouldStartLoadWithRequest({
142
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
143
+ });
144
+
145
+ await flushPromises();
146
+
147
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
148
+ expect(loadRequest).toHaveBeenLastCalledWith(
149
+ false,
150
+ 'https://www.example.com/',
151
+ 1
152
+ );
153
+ });
154
+
155
+ test('loadRequest with limited whitelist', async () => {
156
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
157
+ loadRequest,
158
+ ['https://*']
159
+ );
160
+
161
+ onShouldStartLoadWithRequest({
162
+ nativeEvent: { url: 'https://www.example.com/', lockIdentifier: 1 },
163
+ });
164
+
165
+ await flushPromises();
166
+
167
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
168
+ expect(loadRequest).toHaveBeenLastCalledWith(
169
+ true,
170
+ 'https://www.example.com/',
171
+ 1
172
+ );
173
+
174
+ onShouldStartLoadWithRequest({
175
+ nativeEvent: { url: 'http://insecure.com/', lockIdentifier: 2 },
176
+ });
177
+
178
+ await flushPromises();
179
+
180
+ expect(Linking.openURL).toHaveBeenLastCalledWith('http://insecure.com/');
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
+ });
190
+
191
+ await flushPromises();
192
+
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
+ });
205
+
206
+ await flushPromises();
207
+
208
+ expect(Linking.openURL).toHaveBeenLastCalledWith(
209
+ 'fakehttps://insecure.com/'
210
+ );
211
+ expect(loadRequest).toHaveBeenLastCalledWith(
212
+ false,
213
+ 'fakehttps://insecure.com/',
214
+ 4
215
+ );
216
+ });
217
+
218
+ test('loadRequest allows for valid URIs', async () => {
219
+ const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
220
+ loadRequest,
221
+ [
222
+ 'plus+https://*',
223
+ 'DOT.https://*',
224
+ 'dash-https://*',
225
+ '0invalid://*',
226
+ '+invalid://*',
227
+ ]
228
+ );
229
+
230
+ onShouldStartLoadWithRequest({
231
+ nativeEvent: {
232
+ url: 'plus+https://www.example.com/',
233
+ lockIdentifier: 1,
234
+ },
235
+ });
236
+
237
+ await flushPromises();
238
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
239
+ expect(loadRequest).toHaveBeenLastCalledWith(
240
+ true,
241
+ 'plus+https://www.example.com/',
242
+ 1
243
+ );
244
+
245
+ onShouldStartLoadWithRequest({
246
+ nativeEvent: { url: 'DOT.https://www.example.com/', lockIdentifier: 2 },
247
+ });
248
+
249
+ await flushPromises();
250
+
251
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
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
+ });
264
+
265
+ await flushPromises();
266
+
267
+ expect(Linking.openURL).toHaveBeenCalledTimes(0);
268
+ expect(loadRequest).toHaveBeenLastCalledWith(
269
+ true,
270
+ 'dash-https://www.example.com/',
271
+ 3
272
+ );
273
+
274
+ onShouldStartLoadWithRequest({
275
+ nativeEvent: { url: '0invalid://www.example.com/', lockIdentifier: 4 },
276
+ });
277
+
278
+ await flushPromises();
279
+
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
+ });
292
+
293
+ await flushPromises();
294
+
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
+ );
303
+
304
+ onShouldStartLoadWithRequest({
305
+ nativeEvent: {
306
+ url: 'FAKE+plus+https://www.example.com/',
307
+ lockIdentifier: 6,
308
+ },
309
+ });
310
+
311
+ await flushPromises();
312
+
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
+ );
321
+ });
322
+ });
323
+ });
@@ -0,0 +1,8 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`WebViewShared exports defaultOriginWhitelist 1`] = `
4
+ [
5
+ "http://*",
6
+ "https://*",
7
+ ]
8
+ `;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import WebView from './WebView';
2
+
3
+ export { WebView };
4
+ export default WebView;
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+
4
+ <!-- Flags can be added here to effect the compilation of Microsoft.ReactNative -->
5
+ <PropertyGroup Label="Microsoft.ReactNative Build Flags">
6
+ <UseWinUI3>false</UseWinUI3>
7
+ <UseHermes>false</UseHermes>
8
+ <WinUI2xVersion>2.8.0-prerelease.210927001</WinUI2xVersion>
9
+ </PropertyGroup>
10
+
11
+ </Project>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ImportGroup Label="PropertySheets" />
4
+ <PropertyGroup Label="UserMacros" />
5
+ <!--
6
+ To customize common C++/WinRT project properties:
7
+ * right-click the project node
8
+ * expand the Common Properties item
9
+ * select the C++/WinRT property page
10
+
11
+ For more advanced scenarios, and complete documentation, please see:
12
+ https://github.com/Microsoft/cppwinrt/tree/master/nuget
13
+ -->
14
+ <PropertyGroup />
15
+ <ItemDefinitionGroup />
16
+ </Project>
@@ -0,0 +1,3 @@
1
+ EXPORTS
2
+ DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3
+ DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ItemGroup>
4
+ <Filter Include="Resources">
5
+ <UniqueIdentifier>accd3aa8-1ba0-4223-9bbe-0c431709210b</UniqueIdentifier>
6
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
7
+ </Filter>
8
+ <Filter Include="Generated Files">
9
+ <UniqueIdentifier>{926ab91d-31b4-48c3-b9a4-e681349f27f0}</UniqueIdentifier>
10
+ </Filter>
11
+ </ItemGroup>
12
+ <ItemGroup>
13
+ <ClCompile Include="pch.cpp" />
14
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
15
+ <ClCompile Include="ReactPackageProvider.cpp" />
16
+ <ClCompile Include="WebViewManager.cpp" />
17
+ </ItemGroup>
18
+ <ItemGroup>
19
+ <ClInclude Include="pch.h" />
20
+ <ClInclude Include="ReactPackageProvider.h" />
21
+ <ClInclude Include="WebViewManager.h" />
22
+ </ItemGroup>
23
+ <ItemGroup>
24
+ <None Include="ReactNativeWebView.def" />
25
+ <None Include="packages.config" />
26
+ </ItemGroup>
27
+ <ItemGroup>
28
+ <None Include="PropertySheet.props" />
29
+ </ItemGroup>
30
+ <ItemGroup>
31
+ <Midl Include="ReactPackageProvider.idl" />
32
+ </ItemGroup>
33
+ </Project>
@@ -0,0 +1,189 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(SolutionDir)\ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)\ExperimentalFeatures.props')" />
4
+ <Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props')" />
5
+ <PropertyGroup Label="Globals">
6
+ <CppWinRTOptimized>true</CppWinRTOptimized>
7
+ <CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
8
+ <MinimalCoreWin>true</MinimalCoreWin>
9
+ <ProjectGuid>{00AA3765-C6A0-4713-B3F9-BFE47B9C83F5}</ProjectGuid>
10
+ <ProjectName>ReactNativeWebView</ProjectName>
11
+ <RootNamespace>ReactNativeWebView</RootNamespace>
12
+ <DefaultLanguage>en-US</DefaultLanguage>
13
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
14
+ <AppContainerApplication>true</AppContainerApplication>
15
+ <ApplicationType>Windows Store</ApplicationType>
16
+ <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
17
+ <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0</WindowsTargetPlatformVersion>
18
+ <WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
19
+ </PropertyGroup>
20
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21
+ <ItemGroup Label="ProjectConfigurations">
22
+ <ProjectConfiguration Include="Debug|ARM64">
23
+ <Configuration>Debug</Configuration>
24
+ <Platform>ARM64</Platform>
25
+ </ProjectConfiguration>
26
+ <ProjectConfiguration Include="Debug|Win32">
27
+ <Configuration>Debug</Configuration>
28
+ <Platform>Win32</Platform>
29
+ </ProjectConfiguration>
30
+ <ProjectConfiguration Include="Debug|x64">
31
+ <Configuration>Debug</Configuration>
32
+ <Platform>x64</Platform>
33
+ </ProjectConfiguration>
34
+ <ProjectConfiguration Include="Release|ARM64">
35
+ <Configuration>Release</Configuration>
36
+ <Platform>ARM64</Platform>
37
+ </ProjectConfiguration>
38
+ <ProjectConfiguration Include="Release|Win32">
39
+ <Configuration>Release</Configuration>
40
+ <Platform>Win32</Platform>
41
+ </ProjectConfiguration>
42
+ <ProjectConfiguration Include="Release|x64">
43
+ <Configuration>Release</Configuration>
44
+ <Platform>x64</Platform>
45
+ </ProjectConfiguration>
46
+ </ItemGroup>
47
+ <PropertyGroup Label="Configuration">
48
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
49
+ <PlatformToolset>v140</PlatformToolset>
50
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
51
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
52
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
53
+ <CharacterSet>Unicode</CharacterSet>
54
+ <GenerateManifest>false</GenerateManifest>
55
+ </PropertyGroup>
56
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
57
+ <UseDebugLibraries>true</UseDebugLibraries>
58
+ <LinkIncremental>true</LinkIncremental>
59
+ </PropertyGroup>
60
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
61
+ <UseDebugLibraries>false</UseDebugLibraries>
62
+ <WholeProgramOptimization>true</WholeProgramOptimization>
63
+ <LinkIncremental>false</LinkIncremental>
64
+ </PropertyGroup>
65
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
66
+ <ImportGroup Label="ExtensionSettings">
67
+ </ImportGroup>
68
+ <PropertyGroup>
69
+ <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
70
+ </PropertyGroup>
71
+ <ImportGroup Label="Shared">
72
+ <Import Project="$(ReactNativeWindowsDir)\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems" Label="Shared" />
73
+ </ImportGroup>
74
+ <ImportGroup Label="PropertySheets">
75
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
76
+ </ImportGroup>
77
+ <ImportGroup Label="PropertySheets">
78
+ <Import Project="PropertySheet.props" />
79
+ </ImportGroup>
80
+ <ImportGroup Label="ReactNativeWindowsPropertySheets">
81
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\external\Microsoft.ReactNative.Uwp.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" />
82
+ <Import Project="$(SolutionDir)\packages\$(WinUIPackageProps)" Condition="'$(WinUIPackageProps)'!='' And Exists('$(SolutionDir)\packages\$(WinUIPackageProps)')" />
83
+ </ImportGroup>
84
+ <PropertyGroup>
85
+ <WinUI2_HasWebView2 Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(WinUIPackageVersion)','2.8.0-prerelease.210927001'))">true</WinUI2_HasWebView2>
86
+ </PropertyGroup>
87
+ <PropertyGroup />
88
+ <ItemDefinitionGroup>
89
+ <ClCompile>
90
+ <PrecompiledHeader>Use</PrecompiledHeader>
91
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
92
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
93
+ <WarningLevel>Level4</WarningLevel>
94
+ <AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
95
+ <!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
96
+ <AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
97
+ <DisableSpecificWarnings>28204</DisableSpecificWarnings>
98
+ <PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
99
+ <AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
100
+ <LanguageStandard>stdcpp17</LanguageStandard>
101
+ </ClCompile>
102
+ <Link>
103
+ <SubSystem>Console</SubSystem>
104
+ <GenerateWindowsMetadata>true</GenerateWindowsMetadata>
105
+ <ModuleDefinitionFile>ReactNativeWebView.def</ModuleDefinitionFile>
106
+ </Link>
107
+ </ItemDefinitionGroup>
108
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
109
+ <ClCompile>
110
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
111
+ </ClCompile>
112
+ </ItemDefinitionGroup>
113
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
114
+ <ClCompile>
115
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
116
+ </ClCompile>
117
+ </ItemDefinitionGroup>
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>
125
+ </ItemDefinitionGroup>
126
+ <ItemGroup>
127
+ <ClInclude Include="ReactWebView.h" />
128
+ <ClInclude Include="ReactWebView2.h" />
129
+ <ClInclude Include="ReactWebView2Manager.h" />
130
+ <ClInclude Include="pch.h" />
131
+ <ClInclude Include="ReactPackageProvider.h">
132
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
133
+ </ClInclude>
134
+ <ClInclude Include="ReactWebViewHelpers.h" />
135
+ <ClInclude Include="ReactWebViewManager.h" />
136
+ <ClInclude Include="WebBridge.h" />
137
+ </ItemGroup>
138
+ <ItemGroup>
139
+ <ClCompile Include="ReactWebView.cpp" />
140
+ <ClCompile Include="ReactWebView2.cpp" />
141
+ <ClCompile Include="ReactWebView2Manager.cpp" />
142
+ <ClCompile Include="pch.cpp">
143
+ <PrecompiledHeader>Create</PrecompiledHeader>
144
+ </ClCompile>
145
+ <ClCompile Include="ReactPackageProvider.cpp">
146
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
147
+ </ClCompile>
148
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
149
+ <ClCompile Include="ReactWebViewHelpers.cpp" />
150
+ <ClCompile Include="ReactWebViewManager.cpp" />
151
+ <ClCompile Include="WebBridge.cpp" />
152
+ </ItemGroup>
153
+ <ItemGroup>
154
+ <Midl Include="ReactWebView.idl" />
155
+ <Midl Include="ReactPackageProvider.idl" />
156
+ <Midl Include="WebBridge.idl" />
157
+ </ItemGroup>
158
+ <ItemGroup>
159
+ <None Include="packages.config" />
160
+ <None Include="ReactNativeWebView.def" />
161
+ </ItemGroup>
162
+ <ItemGroup>
163
+ <None Include="PropertySheet.props" />
164
+ </ItemGroup>
165
+ <ItemGroup>
166
+ <ProjectReference Include="$(ReactNativeWindowsDir)\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
167
+ <Project>{f7d32bd0-2749-483e-9a0d-1635ef7e3136}</Project>
168
+ <Private>false</Private>
169
+ </ProjectReference>
170
+ </ItemGroup>
171
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172
+ <ImportGroup Label="ReactNativeWindowsTargets">
173
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
174
+ </ImportGroup>
175
+ <Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
176
+ <PropertyGroup>
177
+ <ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
178
+ </PropertyGroup>
179
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
180
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
181
+ </Target>
182
+ <ImportGroup Label="ExtensionTargets">
183
+ <Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
184
+ <Import Project="$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets" Condition="Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" />
185
+ <Import Project="$(SolutionDir)\packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets" Condition="'$(UseExperimentalNuget)'=='true' And Exists('$(SolutionDir)\packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets')" />
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')" />
187
+ </ImportGroup>
188
+ <Target Name="Deploy" />
189
+ </Project>
@@ -0,0 +1,26 @@
1
+ #include "pch.h"
2
+ #include "ReactPackageProvider.h"
3
+ #if __has_include("ReactPackageProvider.g.cpp")
4
+ #include "ReactPackageProvider.g.cpp"
5
+ #endif
6
+
7
+ #include "ReactWebView2Manager.h"
8
+ #ifndef USE_WINUI3
9
+ #include "ReactWebViewManager.h"
10
+ #endif
11
+
12
+ using namespace winrt::Microsoft::ReactNative;
13
+
14
+ namespace winrt::ReactNativeWebView::implementation {
15
+
16
+ void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept {
17
+ #ifndef USE_WINUI3
18
+ packageBuilder.AddViewManager(L"ReactWebViewManager", []() { return winrt::make<ReactWebViewManager>(); });
19
+ #endif
20
+
21
+ #if HAS_WEBVIEW2
22
+ packageBuilder.AddViewManager(L"ReactWebView2Manager", []() { return winrt::make<ReactWebView2Manager>(); });
23
+ #endif
24
+ }
25
+
26
+ } // namespace winrt::ReactNativeWebView::implementation
@@ -0,0 +1,20 @@
1
+ #pragma once
2
+ #include "ReactPackageProvider.g.h"
3
+
4
+ using namespace winrt::Microsoft::ReactNative;
5
+
6
+ namespace winrt::ReactNativeWebView::implementation {
7
+
8
+ struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider> {
9
+ ReactPackageProvider() = default;
10
+
11
+ void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept;
12
+ };
13
+
14
+ } // namespace winrt::ReactNativeWebView::implementation
15
+
16
+ namespace winrt::ReactNativeWebView::factory_implementation {
17
+
18
+ struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider, implementation::ReactPackageProvider> {};
19
+
20
+ } // namespace winrt::ReactNativeWebView::factory_implementation
@@ -0,0 +1,7 @@
1
+ namespace ReactNativeWebView {
2
+ [webhosthidden]
3
+ [default_interface]
4
+ runtimeclass ReactPackageProvider : Microsoft.ReactNative.IReactPackageProvider {
5
+ ReactPackageProvider();
6
+ };
7
+ } // namespace ReactNativeWebView