Bladeren bron

Revert "Manage to build webview using Visual Studio"

This reverts commit 6f60262d21.
Tero Paananen 4 jaren geleden
bovenliggende
commit
8fabfe73d6

+ 0
- 1
example/windows/WebViewWindows.sln Bestand weergeven

@@ -45,7 +45,6 @@ EndProject
45 45
 Global
46 46
 	GlobalSection(SharedMSBuildProjectFiles) = preSolution
47 47
 		..\..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9
48
-		..\..\node_modules\react-native-windows\ReactWindowsCore\ReactWindowsCore.vcxitems*{11c084a3-a57c-4296-a679-cac17b603144}*SharedItemsImports = 4
49 48
 		..\..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
50 49
 		..\..\node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13
51 50
 		..\..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{729d9af8-cd9e-4427-9f6c-fb757e287729}*SharedItemsImports = 4

+ 1
- 1
package.json Bestand weergeven

@@ -65,7 +65,7 @@
65 65
     "react": "16.11.0",
66 66
     "react-native": "0.62.2",
67 67
     "react-native-macos": "0.60.0-microsoft.73",
68
-    "react-native-windows": "^0.62.5",
68
+    "react-native-windows": "^0.62.0-0",
69 69
     "semantic-release": "15.13.24",
70 70
     "typescript": "3.8.3",
71 71
     "appium": "1.17.0",

+ 0
- 3
windows/ReactNativeWebView.sln Bestand weergeven

@@ -32,9 +32,7 @@ EndProject
32 32
 Global
33 33
 	GlobalSection(SharedMSBuildProjectFiles) = preSolution
34 34
 		..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9
35
-		..\node_modules\react-native-windows\ReactWindowsCore\ReactWindowsCore.vcxitems*{11c084a3-a57c-4296-a679-cac17b603144}*SharedItemsImports = 4
36 35
 		..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4
37
-		..\node_modules\react-native-windows\Mso\Mso.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4
38 36
 		..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4
39 37
 		..\node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13
40 38
 		..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{729d9af8-cd9e-4427-9f6c-fb757e287729}*SharedItemsImports = 4
@@ -43,7 +41,6 @@ Global
43 41
 		..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
44 42
 		..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
45 43
 		..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
46
-		..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
47 44
 		..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
48 45
 		..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
49 46
 	EndGlobalSection

+ 20
- 17
windows/ReactNativeWebView/ReactWebView.cpp Bestand weergeven

@@ -26,10 +26,13 @@ namespace winrt::ReactNativeWebView::implementation {
26 26
 #else
27 27
         m_webView = winrt::WebView();
28 28
 #endif
29
-        this->Content(m_webView);
30 29
         RegisterEvents();
31 30
     }
32 31
 
32
+    winrt::WebView ReactWebView::GetView() {
33
+        return m_webView;
34
+    }
35
+
33 36
     void ReactWebView::RegisterEvents() {
34 37
         m_navigationStartingRevoker = m_webView.NavigationStarting(
35 38
             winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args) {
@@ -61,54 +64,54 @@ namespace winrt::ReactNativeWebView::implementation {
61 64
             });
62 65
     }
63 66
 
64
-    void ReactWebView::WriteWebViewNavigationEventArg(winrt::WebView const& sender, winrt::IJSValueWriter const& eventDataWriter) {
65
-        auto tag = this->GetValue(winrt::FrameworkElement::TagProperty()).as<winrt::IPropertyValue>().GetInt64();
66
-        WriteProperty(eventDataWriter, L"canGoBack", sender.CanGoBack());
67
-        WriteProperty(eventDataWriter, L"canGoForward", sender.CanGoForward());
68
-        WriteProperty(eventDataWriter, L"loading", !sender.IsLoaded());
67
+    void ReactWebView::WriteWebViewNavigationEventArg(winrt::IJSValueWriter const& eventDataWriter) {
68
+        auto tag = m_webView.GetValue(winrt::FrameworkElement::TagProperty()).as<winrt::IPropertyValue>().GetInt64();
69
+        WriteProperty(eventDataWriter, L"canGoBack", m_webView.CanGoBack());
70
+        WriteProperty(eventDataWriter, L"canGoForward", m_webView.CanGoForward());
71
+        WriteProperty(eventDataWriter, L"loading", !m_webView.IsLoaded());
69 72
         WriteProperty(eventDataWriter, L"target", tag);
70
-        WriteProperty(eventDataWriter, L"title", sender.DocumentTitle());
71
-        if (auto uri = sender.Source()) {
72
-          WriteProperty(eventDataWriter, L"url", uri.AbsoluteCanonicalUri());
73
+        WriteProperty(eventDataWriter, L"title", m_webView.DocumentTitle());
74
+        if (auto uri = m_webView.Source()) {
75
+            WriteProperty(eventDataWriter, L"url", uri.AbsoluteCanonicalUri());
73 76
         }
74 77
     }
75 78
 
76 79
     void ReactWebView::OnNavigationStarting(winrt::WebView const& webView, winrt::WebViewNavigationStartingEventArgs const& /*args*/) {
77 80
         m_reactContext.DispatchEvent(
78
-            *this,
81
+            webView,
79 82
             L"topLoadingStart",
80 83
             [&](winrt::IJSValueWriter const& eventDataWriter) noexcept {
81 84
                 eventDataWriter.WriteObjectBegin();
82
-                WriteWebViewNavigationEventArg(webView, eventDataWriter);
85
+                WriteWebViewNavigationEventArg(eventDataWriter);
83 86
                 eventDataWriter.WriteObjectEnd();
84 87
             });
85 88
     }
86 89
 
87 90
     void ReactWebView::OnNavigationCompleted(winrt::WebView const& webView, winrt::WebViewNavigationCompletedEventArgs const& /*args*/) {
88 91
         m_reactContext.DispatchEvent(
89
-            *this,
92
+            webView,
90 93
             L"topLoadingFinish",
91 94
             [&](winrt::IJSValueWriter const& eventDataWriter) noexcept {
92 95
                 eventDataWriter.WriteObjectBegin();
93
-                WriteWebViewNavigationEventArg(webView, eventDataWriter);
96
+                WriteWebViewNavigationEventArg(eventDataWriter);
94 97
                 eventDataWriter.WriteObjectEnd();
95 98
             });
96 99
 
97 100
         winrt::hstring windowAlert = L"window.alert = function (msg) {window.external.notify(`{\"type\":\"__alert\",\"message\":\"${msg}\"}`)};";
98 101
         winrt::hstring postMessage = L"window.ReactNativeWebView = {postMessage: function (data) {window.external.notify(String(data))}};";
99
-        webView.InvokeScriptAsync(L"eval", { windowAlert + postMessage });
102
+        m_webView.InvokeScriptAsync(L"eval", { windowAlert + postMessage });
100 103
     }
101 104
 
102 105
     void ReactWebView::OnNavigationFailed(winrt::IInspectable const& /*sender*/, winrt::WebViewNavigationFailedEventArgs const& args) {
103 106
         m_reactContext.DispatchEvent(
104
-            *this,
107
+            m_webView,
105 108
             L"topLoadingError",
106 109
             [&](winrt::IJSValueWriter const& eventDataWriter) noexcept {
107 110
                 auto httpCode = static_cast<int32_t>(args.WebErrorStatus());
108 111
                 eventDataWriter.WriteObjectBegin();
109 112
                 {
110 113
                     WriteProperty(eventDataWriter, L"code", httpCode);
111
-                    WriteWebViewNavigationEventArg(m_webView, eventDataWriter);
114
+                    WriteWebViewNavigationEventArg(eventDataWriter);
112 115
                 }
113 116
                 eventDataWriter.WriteObjectEnd();
114 117
             });
@@ -131,7 +134,7 @@ namespace winrt::ReactNativeWebView::implementation {
131 134
 
132 135
     void ReactWebView::PostMessage(winrt::hstring const& message) {
133 136
         m_reactContext.DispatchEvent(
134
-            *this,
137
+            m_webView,
135 138
             L"topMessage",
136 139
             [&](winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter) noexcept {
137 140
                 eventDataWriter.WriteObjectBegin();

+ 2
- 1
windows/ReactNativeWebView/ReactWebView.h Bestand weergeven

@@ -12,6 +12,7 @@ namespace winrt::ReactNativeWebView::implementation {
12 12
     class ReactWebView : public ReactWebViewT<ReactWebView> {
13 13
     public:
14 14
         ReactWebView(Microsoft::ReactNative::IReactContext const& reactContext);
15
+        winrt::Windows::UI::Xaml::Controls::WebView GetView();
15 16
         void PostMessage(winrt::hstring const& message);
16 17
 
17 18
     private:
@@ -23,7 +24,7 @@ namespace winrt::ReactNativeWebView::implementation {
23 24
         winrt::Windows::UI::Xaml::Controls::WebView::ScriptNotify_revoker m_scriptNotifyRevoker{};
24 25
 
25 26
         void RegisterEvents();
26
-        void WriteWebViewNavigationEventArg(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
27
+        void WriteWebViewNavigationEventArg(winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
27 28
         void OnNavigationStarting(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationStartingEventArgs const& args);
28 29
         void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
29 30
         void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);

+ 1
- 0
windows/ReactNativeWebView/ReactWebView.idl Bestand weergeven

@@ -2,6 +2,7 @@ namespace ReactNativeWebView{
2 2
     [default_interface]
3 3
     runtimeclass ReactWebView : Windows.UI.Xaml.Controls.UserControl{
4 4
         ReactWebView(Microsoft.ReactNative.IReactContext context);
5
+        Windows.UI.Xaml.Controls.WebView GetView();
5 6
         void PostMessage(String message);
6 7
     };
7 8
 } // namespace ReactNativeWebView

+ 5
- 11
windows/ReactNativeWebView/ReactWebViewManager.cpp Bestand weergeven

@@ -23,8 +23,8 @@ namespace winrt::ReactNativeWebView::implementation {
23 23
     }
24 24
 
25 25
     winrt::FrameworkElement ReactWebViewManager::CreateView() noexcept {
26
-      auto view = winrt::ReactNativeWebView::ReactWebView(m_reactContext);
27
-      return view;
26
+        m_reactWebView = *winrt::make_self<ReactWebView>(m_reactContext);
27
+        return m_reactWebView.GetView();
28 28
     }
29 29
 
30 30
     // IViewManagerWithReactContext
@@ -46,9 +46,7 @@ namespace winrt::ReactNativeWebView::implementation {
46 46
     void ReactWebViewManager::UpdateProperties(
47 47
         FrameworkElement const& view,
48 48
         IJSValueReader const& propertyMapReader) noexcept {
49
-        auto control = view.try_as<winrt::UserControl>();
50
-        auto content = control.Content();
51
-        if (auto webView = content.try_as<winrt::WebView>()) {
49
+        if (auto webView = view.try_as<winrt::WebView>()) {
52 50
             const JSValueObject& propertyMap = JSValueObject::ReadFrom(propertyMapReader);
53 51
 
54 52
             for (auto const& pair : propertyMap) {
@@ -118,10 +116,8 @@ namespace winrt::ReactNativeWebView::implementation {
118 116
         FrameworkElement const& view,
119 117
         winrt::hstring const& commandId,
120 118
         winrt::IJSValueReader const& commandArgsReader) noexcept {
121
-        auto control = view.try_as<winrt::UserControl>();
122
-        auto content = control.Content();
123 119
         auto commandArgs = JSValue::ReadArrayFrom(commandArgsReader);
124
-        if (auto webView = content.try_as<winrt::WebView>()) {
120
+        if (auto webView = view.try_as<winrt::WebView>()) {
125 121
             if (commandId == L"goForward") {
126 122
                 if (webView.CanGoForward()) {
127 123
                     webView.GoForward();
@@ -141,9 +137,7 @@ namespace winrt::ReactNativeWebView::implementation {
141 137
             else if (commandId == L"injectJavaScript") {
142 138
                 webView.InvokeScriptAsync(L"eval", { winrt::to_hstring(commandArgs[0].AsString()) });
143 139
             } else if(commandId == L"postMessage") {
144
-                if (auto reactWebView = view.try_as<ReactNativeWebView::ReactWebView>()) {
145
-                    reactWebView.PostMessage(winrt::to_hstring(commandArgs[0].AsString()));
146
-                }
140
+                m_reactWebView.PostMessage(winrt::to_hstring(commandArgs[0].AsString()));
147 141
             }
148 142
         }
149 143
     }

+ 1
- 0
windows/ReactNativeWebView/ReactWebViewManager.h Bestand weergeven

@@ -47,6 +47,7 @@ namespace winrt::ReactNativeWebView::implementation {
47 47
             winrt::Microsoft::ReactNative::IJSValueReader const& commandArgsReader) noexcept;
48 48
 
49 49
     private:
50
+        winrt::ReactNativeWebView::ReactWebView m_reactWebView{ nullptr };
50 51
         winrt::Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
51 52
 
52 53
     };

+ 1307
- 1367
yarn.lock
Diff onderdrukt omdat het te groot bestand
Bestand weergeven