react-native-webview-bootpay 11.6.51 → 11.18.11

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 (217) hide show
  1. package/README.md +83 -93
  2. package/android/.DS_Store +0 -0
  3. package/android/build/.transforms/4e87ba7f47baac309fba5367e008cf44/results.bin +1 -0
  4. package/android/build/.transforms/4e87ba7f47baac309fba5367e008cf44/transformed/classes/classes.dex +0 -0
  5. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +3 -5
  6. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +4 -2
  7. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +2 -0
  8. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  9. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  10. package/android/build/intermediates/compile_symbol_list/debug/R.txt +72 -8
  11. package/android/build/intermediates/compiled_local_resources/debug/out/xml_file_provider_paths.xml.flat +0 -0
  12. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +1 -1
  13. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +1 -1
  14. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +1 -1
  15. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +2 -2
  16. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +1 -1
  17. package/android/build/intermediates/javac/debug/classes/kr/co/bootpay/webview/BPCWebChromeClient.class +0 -0
  18. package/android/build/intermediates/javac/debug/classes/kr/co/bootpay/webview/BPCWebView.class +0 -0
  19. package/android/build/intermediates/javac/debug/classes/kr/co/bootpay/webview/BPCWebViewClient.class +0 -0
  20. package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
  21. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +198 -200
  22. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +100 -0
  23. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +5 -3
  24. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  25. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +66 -8
  26. package/android/build/kotlin/compileDebugKotlin/build-history.bin +0 -0
  27. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab +0 -0
  28. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  29. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  30. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.len +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  48. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab +0 -0
  49. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
  50. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
  51. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
  52. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  53. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
  54. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
  55. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  56. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  57. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  58. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  59. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  60. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  61. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  62. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab +0 -0
  63. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  64. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  65. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  66. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  67. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  68. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  69. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  70. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  71. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  72. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  73. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  74. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  75. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  76. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  77. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  78. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  79. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  80. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  81. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/{java-sources-proto-map.tab_i → subtypes.tab_i} +0 -0
  82. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  83. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  84. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  85. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  86. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  87. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  88. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  89. package/android/build/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  90. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/counters.tab +2 -0
  91. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab +0 -0
  92. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  93. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  94. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.len +0 -0
  95. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  96. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i +0 -0
  97. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  98. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab +0 -0
  99. package/android/build/kotlin/compileDebugKotlin/caches-jvm/{jvm/kotlin/java-sources-proto-map.tab → lookups/id-to-file.tab.keystream} +0 -0
  100. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  101. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.len +0 -0
  102. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  103. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i +0 -0
  104. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  105. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab +0 -0
  106. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream +0 -0
  107. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  108. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.len +0 -0
  109. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab.values.at +0 -0
  110. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i +0 -0
  111. package/android/build/kotlin/compileDebugKotlin/caches-jvm/lookups/lookups.tab_i.len +0 -0
  112. package/android/build/kotlin/compileDebugKotlin/last-build.bin +0 -0
  113. package/android/build/outputs/logs/manifest-merger-debug-report.txt +116 -128
  114. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  115. package/android/build/tmp/kotlin-classes/debug/META-INF/react-native-webview-bootpay_debug.kotlin_module +0 -0
  116. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/BPCWebViewPackage.class +0 -0
  117. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopHttpErrorEvent$Companion.class +0 -0
  118. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopHttpErrorEvent.class +0 -0
  119. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingErrorEvent$Companion.class +0 -0
  120. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingErrorEvent.class +0 -0
  121. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingFinishEvent$Companion.class +0 -0
  122. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingFinishEvent.class +0 -0
  123. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingProgressEvent$Companion.class +0 -0
  124. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingProgressEvent.class +0 -0
  125. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingStartEvent$Companion.class +0 -0
  126. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopLoadingStartEvent.class +0 -0
  127. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopMessageEvent$Companion.class +0 -0
  128. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopMessageEvent.class +0 -0
  129. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopRenderProcessGoneEvent$Companion.class +0 -0
  130. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopRenderProcessGoneEvent.class +0 -0
  131. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopShouldStartLoadWithRequestEvent$Companion.class +0 -0
  132. package/android/build/tmp/kotlin-classes/debug/kr/co/bootpay/webview/events/TopShouldStartLoadWithRequestEvent.class +0 -0
  133. package/android/build.gradle +7 -9
  134. package/android/gradle.properties +2 -1
  135. package/android/src/.DS_Store +0 -0
  136. package/android/src/main/.DS_Store +0 -0
  137. package/android/src/main/java/.DS_Store +0 -0
  138. package/android/src/main/java/kr/.DS_Store +0 -0
  139. package/android/src/main/java/kr/co/.DS_Store +0 -0
  140. package/android/src/main/java/kr/co/bootpay/.DS_Store +0 -0
  141. package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +2 -2
  142. package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +20 -4
  143. package/apple/BPCWebView.h +19 -0
  144. package/apple/BPCWebView.m +284 -104
  145. package/apple/BPCWebViewManager.h +2 -0
  146. package/apple/BPCWebViewManager.m +25 -1
  147. package/index.d.ts +5 -5
  148. package/ios/.DS_Store +0 -0
  149. package/ios/RNCWebView.xcodeproj/project.pbxproj +18 -18
  150. package/ios/RNCWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  151. package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  152. package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcuserdata/bootpay.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  153. package/ios/RNCWebView.xcodeproj/xcuserdata/bootpay.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  154. package/lib/WebView.android.d.ts +3 -0
  155. package/lib/WebView.android.d.ts.map +1 -1
  156. package/lib/WebView.android.js +22 -11
  157. package/lib/WebView.d.ts +2 -2
  158. package/lib/WebView.d.ts.map +1 -1
  159. package/lib/WebView.ios.d.ts +1 -0
  160. package/lib/WebView.ios.d.ts.map +1 -1
  161. package/lib/WebView.ios.js +23 -14
  162. package/lib/WebView.js +4 -4
  163. package/lib/WebView.macos.d.ts.map +1 -1
  164. package/lib/WebView.macos.js +21 -13
  165. package/lib/WebView.windows.d.ts +4 -2
  166. package/lib/WebView.windows.d.ts.map +1 -1
  167. package/lib/WebView.windows.js +22 -14
  168. package/lib/WebViewNativeComponent.android.d.ts +4 -0
  169. package/lib/WebViewNativeComponent.android.d.ts.map +1 -0
  170. package/lib/WebViewNativeComponent.android.js +3 -0
  171. package/lib/WebViewNativeComponent.ios.d.ts +4 -0
  172. package/lib/WebViewNativeComponent.ios.d.ts.map +1 -0
  173. package/lib/WebViewNativeComponent.ios.js +3 -0
  174. package/lib/WebViewNativeComponent.macos.d.ts +4 -0
  175. package/lib/WebViewNativeComponent.macos.d.ts.map +1 -0
  176. package/lib/WebViewNativeComponent.macos.js +3 -0
  177. package/lib/WebViewNativeComponent.windows.d.ts +4 -0
  178. package/lib/WebViewNativeComponent.windows.d.ts.map +1 -0
  179. package/lib/WebViewNativeComponent.windows.js +3 -0
  180. package/lib/WebViewShared.d.ts +1 -0
  181. package/lib/WebViewShared.d.ts.map +1 -1
  182. package/lib/WebViewShared.js +14 -12
  183. package/lib/WebViewTypes.d.ts +113 -2
  184. package/lib/WebViewTypes.d.ts.map +1 -1
  185. package/lib/WebViewTypes.js +3 -1
  186. package/lib/index.d.ts +4 -0
  187. package/lib/index.d.ts.map +1 -0
  188. package/lib/index.js +3 -0
  189. package/package.json +25 -27
  190. package/react-native-webview-bootpay.podspec +1 -3
  191. package/react-native.config.js +47 -61
  192. package/windows/ExperimentalFeatures.props +12 -0
  193. package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +37 -20
  194. package/windows/ReactNativeWebView/ReactPackageProvider.cpp +5 -1
  195. package/windows/ReactNativeWebView/ReactWebView.cpp +2 -6
  196. package/windows/ReactNativeWebView/ReactWebView.h +3 -2
  197. package/windows/ReactNativeWebView/ReactWebView.idl +13 -1
  198. package/windows/ReactNativeWebView/ReactWebView2.cpp +119 -0
  199. package/windows/ReactNativeWebView/ReactWebView2.h +43 -0
  200. package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +147 -0
  201. package/windows/ReactNativeWebView/ReactWebView2Manager.h +54 -0
  202. package/windows/ReactNativeWebView/ReactWebViewManager.cpp +36 -31
  203. package/windows/{WebViewBridgeComponent → ReactNativeWebView}/WebBridge.cpp +1 -1
  204. package/windows/{WebViewBridgeComponent → ReactNativeWebView}/WebBridge.h +2 -2
  205. package/windows/{WebViewBridgeComponent → ReactNativeWebView}/WebBridge.idl +1 -1
  206. package/windows/ReactNativeWebView/packages.config +2 -0
  207. package/windows/ReactNativeWebView/pch.h +6 -0
  208. package/windows/ReactNativeWebView.sln +81 -119
  209. package/android/build/tmp/kotlin-classes/debug/META-INF/rnWebView_debug.kotlin_module +0 -0
  210. package/windows/WebViewBridgeComponent/PropertySheet.props +0 -16
  211. package/windows/WebViewBridgeComponent/WebViewBridgeComponent.def +0 -3
  212. package/windows/WebViewBridgeComponent/WebViewBridgeComponent.vcxproj +0 -160
  213. package/windows/WebViewBridgeComponent/WebViewBridgeComponent.vcxproj.filters +0 -33
  214. package/windows/WebViewBridgeComponent/packages.config +0 -4
  215. package/windows/WebViewBridgeComponent/pch.cpp +0 -1
  216. package/windows/WebViewBridgeComponent/pch.h +0 -4
  217. package/windows/WebViewBridgeComponent/readme.txt +0 -23
@@ -3,7 +3,6 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = "react-native-webview-bootpay"
7
6
  s.name = package['name']
8
7
  s.version = package['version']
9
8
  s.summary = package['description']
@@ -13,8 +12,7 @@ Pod::Spec.new do |s|
13
12
  s.homepage = package['homepage']
14
13
  s.platforms = { :ios => "9.0", :osx => "10.13" }
15
14
 
16
- # s.source = { :git => "https://github.com/react-native-webview/react-native-webview.git", :tag => "v#{s.version}" }
17
- s.source = { :git => "https://github.com/bootpay/react-native-webview-bootpay.git", :tag => "#{s.version}" }
15
+ s.source = { :git => "https://github.com/react-native-webview/react-native-webview.git", :tag => "v#{s.version}" }
18
16
  s.source_files = "apple/**/*.{h,m}"
19
17
 
20
18
  s.dependency 'React-Core'
@@ -1,67 +1,53 @@
1
- /**
2
- * This cli config is needed for the coexistance of react-native and other
3
- * out-of-tree implementations such react-native-macos.
4
- * The following issue is tracked by
5
- * https://github.com/react-native-community/discussions-and-proposals/issues/182
6
- *
7
- * The work-around involves having a metro.config.js for each out-of-tree
8
- * platform, i.e. metro.config.js for react-native and
9
- * metro.config.macos.js for react-native-macos.
10
- * This react-native.config.js looks for a --use-react-native-macos
11
- * switch and when present pushes --config=metro.config.macos.js
12
- * and specifies reactNativePath: 'node_modules/react-native-macos'.
13
- * The metro.config.js has to blacklist 'node_modules/react-native-macos',
14
- * and conversely metro.config.macos.js has to blacklist 'node_modules/react-native'.
15
- */
16
- 'use strict';
17
-
18
- const path = require('path');
19
-
20
- const macSwitch = '--use-react-native-macos';
21
- const windowsSwitch = '--use-react-native-windows';
22
-
23
- if (process.argv.includes(macSwitch)) {
24
- process.argv = process.argv.filter(arg => arg !== macSwitch);
25
- process.argv.push('--config=metro.config.macos.js');
26
- module.exports = {
27
- reactNativePath: 'node_modules/react-native-macos',
28
- };
29
- }
30
- else if (process.argv.includes(windowsSwitch)) {
31
- process.argv = process.argv.filter(arg => arg !== windowsSwitch);
32
- process.argv.push('--config=metro.config.windows.js');
33
- module.exports = {
34
- reactNativePath: 'node_modules/react-native-windows',
35
- };
36
- }
37
- else {
38
- module.exports = {
39
- project: {
1
+ const project = (() => {
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ try {
5
+ const {
6
+ androidManifestPath,
7
+ iosProjectPath,
8
+ windowsProjectPath,
9
+ } = require('react-native-test-app');
10
+ return {
11
+ android: {
12
+ sourceDir: path.join('example', 'android'),
13
+ manifestPath: androidManifestPath(
14
+ path.join(__dirname, 'example', 'android'),
15
+ ),
16
+ },
40
17
  ios: {
41
- project: 'example/ios/',
18
+ project: iosProjectPath('example/ios'),
42
19
  },
43
- android: {
44
- sourceDir: 'example/android',
20
+ windows: fs.existsSync('example/windows/WebviewExample.sln') && {
21
+ sourceDir: path.join('example', 'windows'),
22
+ solutionFile: 'WebviewExample.sln',
23
+ project: windowsProjectPath(path.join(__dirname, 'example', 'windows')),
45
24
  },
46
- },
47
- };
48
- }
25
+ };
26
+ } catch (_) {
27
+ return undefined;
28
+ }
29
+ })();
49
30
 
50
- module.exports.dependency = {
51
- platforms: {
52
- windows: {
53
- sourceDir: 'windows',
54
- solutionFile: 'ReactNativeWebView.sln',
55
- projects: [
56
- {
57
- projectFile: 'ReactNativeWebView/ReactNativeWebView.vcxproj',
58
- directDependency: true,
59
- },
60
- {
61
- projectFile: 'WebViewBridgeComponent/WebViewBridgeComponent.vcxproj',
62
- directDependency: false,
63
- }
64
- ],
31
+ module.exports = {
32
+ dependencies: {
33
+ // Help rn-cli find and autolink this library
34
+ 'react-native-webview-bootpay': {
35
+ root: __dirname,
36
+ },
37
+ },
38
+ dependency: {
39
+ platforms: {
40
+ windows: {
41
+ sourceDir: 'windows',
42
+ solutionFile: 'ReactNativeWebView.sln',
43
+ projects: [
44
+ {
45
+ projectFile: 'ReactNativeWebView/ReactNativeWebView.vcxproj',
46
+ directDependency: true,
47
+ },
48
+ ],
49
+ },
65
50
  },
66
51
  },
67
- };
52
+ ...(project ? { project } : undefined),
53
+ };
@@ -0,0 +1,12 @@
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
+ <WebView2Version>1.0.1020.30</WebView2Version>
10
+ </PropertyGroup>
11
+
12
+ </Project>
@@ -1,11 +1,12 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
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')" />
3
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')" />
4
5
  <PropertyGroup Label="Globals">
5
6
  <CppWinRTOptimized>true</CppWinRTOptimized>
6
7
  <CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
7
8
  <MinimalCoreWin>true</MinimalCoreWin>
8
- <ProjectGuid>{729d9af8-cd9e-4427-9f6c-fb757e287729}</ProjectGuid>
9
+ <ProjectGuid>{00AA3765-C6A0-4713-B3F9-BFE47B9C83F5}</ProjectGuid>
9
10
  <ProjectName>ReactNativeWebView</ProjectName>
10
11
  <RootNamespace>ReactNativeWebView</RootNamespace>
11
12
  <DefaultLanguage>en-US</DefaultLanguage>
@@ -18,10 +19,6 @@
18
19
  </PropertyGroup>
19
20
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
20
21
  <ItemGroup Label="ProjectConfigurations">
21
- <ProjectConfiguration Include="Debug|ARM">
22
- <Configuration>Debug</Configuration>
23
- <Platform>ARM</Platform>
24
- </ProjectConfiguration>
25
22
  <ProjectConfiguration Include="Debug|ARM64">
26
23
  <Configuration>Debug</Configuration>
27
24
  <Platform>ARM64</Platform>
@@ -34,10 +31,6 @@
34
31
  <Configuration>Debug</Configuration>
35
32
  <Platform>x64</Platform>
36
33
  </ProjectConfiguration>
37
- <ProjectConfiguration Include="Release|ARM">
38
- <Configuration>Release</Configuration>
39
- <Platform>ARM</Platform>
40
- </ProjectConfiguration>
41
34
  <ProjectConfiguration Include="Release|ARM64">
42
35
  <Configuration>Release</Configuration>
43
36
  <Platform>ARM64</Platform>
@@ -56,6 +49,7 @@
56
49
  <PlatformToolset>v140</PlatformToolset>
57
50
  <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
58
51
  <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
52
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '17.0'">v143</PlatformToolset>
59
53
  <CharacterSet>Unicode</CharacterSet>
60
54
  <GenerateManifest>false</GenerateManifest>
61
55
  </PropertyGroup>
@@ -83,6 +77,10 @@
83
77
  <ImportGroup Label="PropertySheets">
84
78
  <Import Project="PropertySheet.props" />
85
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>
86
84
  <PropertyGroup Label="UserMacros" />
87
85
  <PropertyGroup />
88
86
  <ItemDefinitionGroup>
@@ -116,20 +114,20 @@
116
114
  </ClCompile>
117
115
  </ItemDefinitionGroup>
118
116
  <ItemGroup>
119
- <ClInclude Include="ReactWebView.h">
120
- <DependentUpon>ReactWebView.idl</DependentUpon>
121
- </ClInclude>
122
- <ClInclude Include="ReactWebViewManager.h" />
117
+ <ClInclude Include="ReactWebView.h" />
118
+ <ClInclude Include="ReactWebView2.h" />
119
+ <ClInclude Include="ReactWebView2Manager.h" />
123
120
  <ClInclude Include="pch.h" />
124
121
  <ClInclude Include="ReactPackageProvider.h">
125
122
  <DependentUpon>ReactPackageProvider.idl</DependentUpon>
126
123
  </ClInclude>
124
+ <ClInclude Include="ReactWebViewManager.h" />
125
+ <ClInclude Include="WebBridge.h" />
127
126
  </ItemGroup>
128
127
  <ItemGroup>
129
- <ClCompile Include="ReactWebView.cpp">
130
- <DependentUpon>ReactWebView.idl</DependentUpon>
131
- </ClCompile>
132
- <ClCompile Include="ReactWebViewManager.cpp" />
128
+ <ClCompile Include="ReactWebView.cpp" />
129
+ <ClCompile Include="ReactWebView2.cpp" />
130
+ <ClCompile Include="ReactWebView2Manager.cpp" />
133
131
  <ClCompile Include="pch.cpp">
134
132
  <PrecompiledHeader>Create</PrecompiledHeader>
135
133
  </ClCompile>
@@ -137,15 +135,19 @@
137
135
  <DependentUpon>ReactPackageProvider.idl</DependentUpon>
138
136
  </ClCompile>
139
137
  <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
138
+ <ClCompile Include="ReactWebViewManager.cpp" />
139
+ <ClCompile Include="WebBridge.cpp" />
140
140
  </ItemGroup>
141
141
  <ItemGroup>
142
142
  <Midl Include="ReactWebView.idl" />
143
143
  <Midl Include="ReactPackageProvider.idl" />
144
+ <Midl Include="WebBridge.idl" />
144
145
  </ItemGroup>
145
146
  <ItemGroup>
146
147
  <None Include="packages.config" />
147
148
  <None Include="ReactNativeWebView.def" />
148
149
  </ItemGroup>
150
+
149
151
  <ItemGroup>
150
152
  <None Include="PropertySheet.props" />
151
153
  </ItemGroup>
@@ -154,13 +156,24 @@
154
156
  <Project>{f7d32bd0-2749-483e-9a0d-1635ef7e3136}</Project>
155
157
  <Private>false</Private>
156
158
  </ProjectReference>
157
- <ProjectReference Include="..\WebViewBridgeComponent\WebViewBridgeComponent.vcxproj">
158
- <Project>{176323cd-97ce-4b0f-9d11-a2b77bda829b}</Project>
159
- </ProjectReference>
160
159
  </ItemGroup>
161
160
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
161
+ <ImportGroup Label="ReactNativeWindowsTargets">
162
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
163
+ </ImportGroup>
164
+ <Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
165
+ <PropertyGroup>
166
+ <ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
167
+ </PropertyGroup>
168
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
169
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
170
+ </Target>
162
171
  <ImportGroup Label="ExtensionTargets">
163
172
  <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')" />
173
+ <Import Project="$(SolutionDir)packages\Microsoft.Web.WebView2.1.0.1020.30\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('$(SolutionDir)packages\Microsoft.Web.WebView2.1.0.1020.30\build\native\Microsoft.Web.WebView2.targets')" />
174
+ <Import Project="$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets" Condition="Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" />
175
+ <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')" />
176
+ <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')" />
164
177
  </ImportGroup>
165
178
  <Target Name="Deploy" />
166
179
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -169,5 +182,9 @@
169
182
  </PropertyGroup>
170
183
  <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'))" />
171
184
  <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'))" />
185
+ <Error Condition="!Exists('$(SolutionDir)packages\Microsoft.Web.WebView2.1.0.1020.30\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Web.WebView2.1.0.1020.30\build\native\Microsoft.Web.WebView2.targets'))" />
186
+ <Error Condition="!Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets'))" />
187
+ <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'))" />
188
+ <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'))" />
172
189
  </Target>
173
190
  </Project>
@@ -4,6 +4,7 @@
4
4
  #include "ReactPackageProvider.g.cpp"
5
5
  #endif
6
6
 
7
+ #include "ReactWebView2Manager.h"
7
8
  #include "ReactWebViewManager.h"
8
9
 
9
10
  using namespace winrt::Microsoft::ReactNative;
@@ -12,6 +13,9 @@ namespace winrt::ReactNativeWebView::implementation {
12
13
 
13
14
  void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept {
14
15
  packageBuilder.AddViewManager(L"ReactWebViewManager", []() { return winrt::make<ReactWebViewManager>(); });
16
+ #if RNW_VERSION_AT_LEAST(0,68,0)
17
+ packageBuilder.AddViewManager(L"ReactWebView2Manager", []() { return winrt::make<ReactWebView2Manager>(); });
18
+ #endif
15
19
  }
16
20
 
17
- } // namespace winrt::ReactNativeWebView::implementation
21
+ } // namespace winrt::ReactNativeWebView::implementation
@@ -23,11 +23,7 @@ namespace winrt {
23
23
  namespace winrt::ReactNativeWebView::implementation {
24
24
 
25
25
  ReactWebView::ReactWebView(winrt::IReactContext const& reactContext) : m_reactContext(reactContext) {
26
- #ifdef CHAKRACORE_UWP
27
- m_webView = winrt::WebView(winrt::WebViewExecutionMode::SeparateProcess);
28
- #else
29
26
  m_webView = winrt::WebView();
30
- #endif
31
27
  this->Content(m_webView);
32
28
  RegisterEvents();
33
29
  }
@@ -63,7 +59,7 @@ namespace winrt::ReactNativeWebView::implementation {
63
59
  });
64
60
  }
65
61
 
66
- bool Is17763OrHigher() {
62
+ bool ReactWebView::Is17763OrHigher() {
67
63
  static std::optional<bool> hasUniversalAPIContract_v7;
68
64
 
69
65
  if (!hasUniversalAPIContract_v7.has_value()) {
@@ -123,7 +119,7 @@ namespace winrt::ReactNativeWebView::implementation {
123
119
 
124
120
  if (m_messagingEnabled) {
125
121
  winrt::hstring windowAlert = L"window.alert = function (msg) {__REACT_WEB_VIEW_BRIDGE.postMessage(`{\"type\":\"__alert\",\"message\":\"${msg}\"}`)};";
126
- winrt::hstring postMessage = L"window.BootpayRNWebView = {postMessage: function (data) {__REACT_WEB_VIEW_BRIDGE.postMessage(String(data))}};";
122
+ winrt::hstring postMessage = L"window.ReactNativeWebView = {postMessage: function (data) {__REACT_WEB_VIEW_BRIDGE.postMessage(String(data))}};";
127
123
  webView.InvokeScriptAsync(L"eval", { windowAlert + postMessage });
128
124
  }
129
125
  }
@@ -7,9 +7,9 @@
7
7
  #include "NativeModules.h"
8
8
  #include "ReactWebView.g.h"
9
9
 
10
- #include "winrt/WebViewBridgeComponent.h"
10
+ #include "winrt/ReactNativeWebView.h"
11
11
 
12
- using namespace winrt::WebViewBridgeComponent;
12
+ using namespace winrt::ReactNativeWebView;
13
13
 
14
14
  namespace winrt::ReactNativeWebView::implementation {
15
15
 
@@ -36,6 +36,7 @@ namespace winrt::ReactNativeWebView::implementation {
36
36
  void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
37
37
  void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);
38
38
  void OnMessagePosted(hstring const& message);
39
+ bool Is17763OrHigher();
39
40
  };
40
41
  } // namespace winrt::ReactNativeWebView::implementation
41
42
 
@@ -1,7 +1,19 @@
1
1
  namespace ReactNativeWebView{
2
2
  [default_interface]
3
- runtimeclass ReactWebView : Windows.UI.Xaml.Controls.UserControl{
3
+ runtimeclass ReactWebView : Windows.UI.Xaml.Controls.ContentPresenter{
4
4
  ReactWebView(Microsoft.ReactNative.IReactContext context);
5
5
  void SetMessagingEnabled(Boolean enabled);
6
6
  };
7
+ #if __has_include(<VersionMacros.h>)
8
+ #include <VersionMacros.h>
9
+ #else
10
+ #define RNW_VERSION_AT_LEAST(x,y,z) false
11
+ #endif
12
+ #if RNW_VERSION_AT_LEAST(0,68,0)
13
+ [default_interface]
14
+ runtimeclass ReactWebView2 : Windows.UI.Xaml.Controls.ContentPresenter{
15
+ ReactWebView2(Microsoft.ReactNative.IReactContext context);
16
+ void NavigateToHtml(String html);
17
+ };
18
+ #endif
7
19
  } // namespace ReactNativeWebView
@@ -0,0 +1,119 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "pch.h"
5
+ #if RNW_VERSION_AT_LEAST(0,68,0)
6
+ #include "JSValueXaml.h"
7
+ #include "ReactWebView2.h"
8
+ #include "ReactWebView2.g.cpp"
9
+ #include <winrt/Windows.Foundation.Metadata.h>
10
+ #include <optional>
11
+
12
+ namespace winrt {
13
+ using namespace Microsoft::ReactNative;
14
+ using namespace Windows::Foundation;
15
+ using namespace Windows::UI;
16
+ using namespace Windows::UI::Xaml;
17
+ using namespace Windows::UI::Xaml::Controls;
18
+ using namespace Microsoft::UI::Xaml::Controls;
19
+ using namespace Microsoft::Web::WebView2::Core;
20
+ } // namespace winrt
21
+
22
+ namespace winrt::ReactNativeWebView::implementation {
23
+
24
+ ReactWebView2::ReactWebView2(winrt::IReactContext const& reactContext) : m_reactContext(reactContext) {
25
+ m_webView = winrt::WebView2();
26
+ this->Content(m_webView);
27
+ RegisterEvents();
28
+ }
29
+
30
+ ReactWebView2::~ReactWebView2(){}
31
+
32
+ void ReactWebView2::RegisterEvents() {
33
+ m_navigationStartingRevoker = m_webView.NavigationStarting(
34
+ winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args) {
35
+ if (auto self = ref.get()) {
36
+ self->OnNavigationStarting(sender, args);
37
+ }
38
+
39
+ });
40
+
41
+ m_navigationCompletedRevoker = m_webView.NavigationCompleted(
42
+ winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args) {
43
+ if (auto self = ref.get()) {
44
+ self->OnNavigationCompleted(sender, args);
45
+ }
46
+ });
47
+
48
+ m_CoreWebView2InitializedRevoker = m_webView.CoreWebView2Initialized(
49
+ winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args){
50
+ if (auto self = ref.get()) {
51
+ self->OnCoreWebView2Initialized(sender, args);
52
+ }
53
+ });
54
+ }
55
+
56
+ bool ReactWebView2::Is17763OrHigher() {
57
+ static std::optional<bool> hasUniversalAPIContract_v7;
58
+
59
+ if (!hasUniversalAPIContract_v7.has_value()) {
60
+ hasUniversalAPIContract_v7 = winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", 7);
61
+ }
62
+ return hasUniversalAPIContract_v7.value();
63
+ }
64
+
65
+ void ReactWebView2::WriteWebViewNavigationEventArg(winrt::WebView2 const& sender, winrt::IJSValueWriter const& eventDataWriter) {
66
+ auto tag = this->GetValue(winrt::FrameworkElement::TagProperty()).as<winrt::IPropertyValue>().GetInt64();
67
+ WriteProperty(eventDataWriter, L"canGoBack", sender.CanGoBack());
68
+ WriteProperty(eventDataWriter, L"canGoForward", sender.CanGoForward());
69
+ if (Is17763OrHigher()) {
70
+ WriteProperty(eventDataWriter, L"loading", !sender.IsLoaded());
71
+ }
72
+ WriteProperty(eventDataWriter, L"target", tag);
73
+ if (auto uri = sender.Source()) {
74
+ WriteProperty(eventDataWriter, L"url", uri.AbsoluteCanonicalUri());
75
+ }
76
+ }
77
+
78
+ void ReactWebView2::OnNavigationStarting(winrt::WebView2 const& webView, winrt::CoreWebView2NavigationStartingEventArgs const& args) {
79
+ m_reactContext.DispatchEvent(
80
+ *this,
81
+ L"topLoadingStart",
82
+ [&](winrt::IJSValueWriter const& eventDataWriter) noexcept {
83
+ eventDataWriter.WriteObjectBegin();
84
+ WriteWebViewNavigationEventArg(webView, eventDataWriter);
85
+ eventDataWriter.WriteObjectEnd();
86
+ });
87
+ }
88
+
89
+ void ReactWebView2::OnNavigationCompleted(winrt::WebView2 const& webView, winrt::CoreWebView2NavigationCompletedEventArgs const& args) {
90
+ m_reactContext.DispatchEvent(
91
+ *this,
92
+ L"topLoadingFinish",
93
+ [&](winrt::IJSValueWriter const& eventDataWriter) noexcept {
94
+ eventDataWriter.WriteObjectBegin();
95
+ WriteWebViewNavigationEventArg(webView, eventDataWriter);
96
+ eventDataWriter.WriteObjectEnd();
97
+ });
98
+ }
99
+
100
+ void ReactWebView2::OnCoreWebView2Initialized(winrt::Microsoft::UI::Xaml::Controls::WebView2 const& sender, winrt::Microsoft::UI::Xaml::Controls::CoreWebView2InitializedEventArgs const& args) {
101
+ assert(sender.CoreWebView2());
102
+ if (m_navigateToHtml != L"") {
103
+ m_webView.NavigateToString(m_navigateToHtml);
104
+ m_navigateToHtml = L"";
105
+ }
106
+ }
107
+
108
+ void ReactWebView2::NavigateToHtml(winrt::hstring html) {
109
+ if (m_webView.CoreWebView2()) {
110
+ m_webView.NavigateToString(html);
111
+ }
112
+ else {
113
+ m_webView.EnsureCoreWebView2Async();
114
+ m_navigateToHtml = html;
115
+ }
116
+ }
117
+
118
+ } // namespace winrt::ReactNativeWebView::implementation
119
+ #endif
@@ -0,0 +1,43 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ #if RNW_VERSION_AT_LEAST(0,68,0)
4
+ #pragma once
5
+
6
+ #include "winrt/Microsoft.ReactNative.h"
7
+ #include "NativeModules.h"
8
+ #include "ReactWebView2.g.h"
9
+
10
+ #include "winrt/ReactNativeWebView.h"
11
+
12
+ using namespace winrt::ReactNativeWebView;
13
+
14
+ namespace winrt::ReactNativeWebView::implementation {
15
+
16
+ class ReactWebView2 : public ReactWebView2T<ReactWebView2> {
17
+ public:
18
+ ReactWebView2(Microsoft::ReactNative::IReactContext const& reactContext);
19
+ void NavigateToHtml(winrt::hstring html);
20
+ ~ReactWebView2();
21
+
22
+ private:
23
+ winrt::hstring m_navigateToHtml = L"";
24
+
25
+ winrt::Microsoft::UI::Xaml::Controls::WebView2 m_webView{ nullptr };
26
+ Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
27
+ winrt::event_token m_messageToken;
28
+ winrt::Microsoft::UI::Xaml::Controls::WebView2::NavigationStarting_revoker m_navigationStartingRevoker{};
29
+ winrt::Microsoft::UI::Xaml::Controls::WebView2::NavigationCompleted_revoker m_navigationCompletedRevoker{};
30
+ winrt::Microsoft::UI::Xaml::Controls::WebView2::CoreWebView2Initialized_revoker m_CoreWebView2InitializedRevoker{};
31
+ void RegisterEvents();
32
+ void WriteWebViewNavigationEventArg(winrt::Microsoft::UI::Xaml::Controls::WebView2 const& sender, winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
33
+ void OnNavigationStarting(winrt::Microsoft::UI::Xaml::Controls::WebView2 const& sender, winrt::Microsoft::Web::WebView2::Core::CoreWebView2NavigationStartingEventArgs const& args);
34
+ void OnNavigationCompleted(winrt::Microsoft::UI::Xaml::Controls::WebView2 const& sender, winrt::Microsoft::Web::WebView2::Core::CoreWebView2NavigationCompletedEventArgs const& args);
35
+ void OnCoreWebView2Initialized(winrt::Microsoft::UI::Xaml::Controls::WebView2 const& sender, winrt::Microsoft::UI::Xaml::Controls::CoreWebView2InitializedEventArgs const& args);
36
+ bool Is17763OrHigher();
37
+ };
38
+ } // namespace winrt::ReactNativeWebView2::implementation
39
+
40
+ namespace winrt::ReactNativeWebView::factory_implementation {
41
+ struct ReactWebView2 : ReactWebView2T<ReactWebView2, implementation::ReactWebView2> {};
42
+ } // namespace winrt::ReactNativeWebView2::factory_implementation
43
+ #endif