Tero Paananen 4 år sedan
förälder
incheckning
a63799ddd9
No account linked to committer's email address

+ 32
- 12
example/App.tsx Visa fil

@@ -17,8 +17,17 @@ import Downloads from './examples/Downloads';
17 17
 import Uploads from './examples/Uploads';
18 18
 import Injection from './examples/Injection';
19 19
 import LocalPageLoad from './examples/LocalPageLoad';
20
+import WebGL from './examples/WebGL';
20 21
 
21 22
 const TESTS = {
23
+  WebGL: {
24
+    title: 'WebGL',
25
+    testId: 'webgl',
26
+    description: 'WebGL for Windows',
27
+    render() {
28
+      return <WebGL />;
29
+    },
30
+  },
22 31
   Alerts: {
23 32
     title: 'Alerts',
24 33
     testId: 'alerts',
@@ -78,7 +87,7 @@ const TESTS = {
78 87
 };
79 88
 
80 89
 type Props = {};
81
-type State = {restarting: boolean, currentTest: Object};
90
+type State = {restarting: boolean; currentTest: Object};
82 91
 
83 92
 export default class App extends Component<Props, State> {
84 93
   state = {
@@ -90,7 +99,7 @@ export default class App extends Component<Props, State> {
90 99
     this.setState({restarting: true}, () => this.setState({restarting: false}));
91 100
   };
92 101
 
93
-  _changeTest = testName => {
102
+  _changeTest = (testName) => {
94 103
     this.setState({currentTest: TESTS[testName]});
95 104
   };
96 105
 
@@ -138,16 +147,27 @@ export default class App extends Component<Props, State> {
138 147
             title="LocalPageLoad"
139 148
             onPress={() => this._changeTest('PageLoad')}
140 149
           />
141
-          {Platform.OS == "ios" && <Button
142
-            testID="testType_downloads"
143
-            title="Downloads"
144
-            onPress={() => this._changeTest('Downloads')}
145
-          />}
146
-          {Platform.OS === 'android' && <Button
147
-            testID="testType_uploads"
148
-            title="Uploads"
149
-            onPress={() => this._changeTest('Uploads')}
150
-          />}
150
+          {Platform.OS == 'ios' && (
151
+            <Button
152
+              testID="testType_downloads"
153
+              title="Downloads"
154
+              onPress={() => this._changeTest('Downloads')}
155
+            />
156
+          )}
157
+          {Platform.OS === 'android' && (
158
+            <Button
159
+              testID="testType_uploads"
160
+              title="Uploads"
161
+              onPress={() => this._changeTest('Uploads')}
162
+            />
163
+          )}
164
+          {Platform.OS === 'windows' && (
165
+            <Button
166
+              testID="testType_webGl"
167
+              title="WebGL"
168
+              onPress={() => this._changeTest('WebGL')}
169
+            />
170
+          )}
151 171
         </View>
152 172
 
153 173
         {restarting ? null : (

+ 22
- 0
example/examples/WebGL.tsx Visa fil

@@ -0,0 +1,22 @@
1
+import React, {Component} from 'react';
2
+import {View} from 'react-native';
3
+
4
+import WebView from 'react-native-webview';
5
+
6
+type Props = {};
7
+type State = {};
8
+
9
+export default class WebGL extends Component<Props, State> {
10
+  state = {};
11
+
12
+  render() {
13
+    return (
14
+      <View style={{flex: 1}}>
15
+        <WebView
16
+          source={{uri: 'https://webglsamples.org/aquarium/aquarium.html'}}
17
+          automaticallyAdjustContentInsets={false}
18
+        />
19
+      </View>
20
+    );
21
+  }
22
+}

+ 1
- 0
example/windows/WebViewWindows.sln Visa fil

@@ -45,6 +45,7 @@ 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
48 49
 		..\..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
49 50
 		..\..\node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13
50 51
 		..\..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{729d9af8-cd9e-4427-9f6c-fb757e287729}*SharedItemsImports = 4

+ 1
- 1
package.json Visa fil

@@ -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.0-0",
68
+    "react-native-windows": "0.62.6",
69 69
     "semantic-release": "15.13.24",
70 70
     "typescript": "3.8.3",
71 71
     "appium": "1.17.0",

+ 3
- 0
windows/ReactNativeWebView.sln Visa fil

@@ -32,7 +32,9 @@ 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
35 36
 		..\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
36 38
 		..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4
37 39
 		..\node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13
38 40
 		..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{729d9af8-cd9e-4427-9f6c-fb757e287729}*SharedItemsImports = 4
@@ -41,6 +43,7 @@ Global
41 43
 		..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
42 44
 		..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
43 45
 		..\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
44 47
 		..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
45 48
 		..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
46 49
 	EndGlobalSection

+ 17
- 0
windows/ReactNativeWebView/ReactWebView.cpp Visa fil

@@ -62,6 +62,13 @@ namespace winrt::ReactNativeWebView::implementation {
62 62
                     self->OnScriptNotify(sender, args);
63 63
                 }
64 64
             });
65
+    
66
+         m_permissionReguestRevoker = m_webView.PermissionRequested(
67
+            winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args) {
68
+                if (auto self = ref.get()) {
69
+                    self->OnPremissionRequested(sender, args);
70
+                }
71
+        });
65 72
     }
66 73
 
67 74
     void ReactWebView::WriteWebViewNavigationEventArg(winrt::IJSValueWriter const& eventDataWriter) {
@@ -132,6 +139,16 @@ namespace winrt::ReactNativeWebView::implementation {
132 139
         PostMessage(winrt::hstring(args.Value()));
133 140
     }
134 141
 
142
+    void ReactWebView::OnPremissionRequested(winrt::WebView const& webView, winrt::WebViewPermissionRequestedEventArgs const& args)
143
+    {
144
+      if (args.PermissionRequest().PermissionType() == WebViewPermissionType::ImmersiveView) {
145
+        // WebGL permission request
146
+        // https://docs.microsoft.com/en-us/microsoft-edge/webvr/webvr-in-webview
147
+        args.PermissionRequest().Allow();
148
+      }
149
+      args.PermissionRequest().Deny();
150
+    }
151
+
135 152
     void ReactWebView::PostMessage(winrt::hstring const& message) {
136 153
         m_reactContext.DispatchEvent(
137 154
             m_webView,

+ 3
- 0
windows/ReactNativeWebView/ReactWebView.h Visa fil

@@ -22,6 +22,7 @@ namespace winrt::ReactNativeWebView::implementation {
22 22
         winrt::Windows::UI::Xaml::Controls::WebView::NavigationCompleted_revoker m_navigationCompletedRevoker{};
23 23
         winrt::Windows::UI::Xaml::Controls::WebView::NavigationFailed_revoker m_navigationFailedRevoker{};
24 24
         winrt::Windows::UI::Xaml::Controls::WebView::ScriptNotify_revoker m_scriptNotifyRevoker{};
25
+        winrt::Windows::UI::Xaml::Controls::WebView::PermissionRequested_revoker m_permissionReguestRevoker{};
25 26
 
26 27
         void RegisterEvents();
27 28
         void WriteWebViewNavigationEventArg(winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
@@ -29,6 +30,8 @@ namespace winrt::ReactNativeWebView::implementation {
29 30
         void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
30 31
         void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);
31 32
         void OnScriptNotify(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::NotifyEventArgs const& args);
33
+        void OnPremissionRequested(winrt::Windows::UI::Xaml::Controls::WebView const& webView, winrt::Windows::UI::Xaml::Controls::WebViewPermissionRequestedEventArgs const& args);
34
+
32 35
     };
33 36
 } // namespace winrt::ReactNativeWebView::implementation
34 37
 

+ 6
- 38
yarn.lock Visa fil

@@ -4598,7 +4598,7 @@ debug@^3.1.0, debug@^3.1.1:
4598 4598
   dependencies:
4599 4599
     ms "^2.1.1"
4600 4600
 
4601
-debuglog@*, debuglog@^1.0.1:
4601
+debuglog@^1.0.1:
4602 4602
   version "1.0.1"
4603 4603
   resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
4604 4604
   integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -6530,7 +6530,7 @@ import-local@^2.0.0:
6530 6530
     pkg-dir "^3.0.0"
6531 6531
     resolve-cwd "^2.0.0"
6532 6532
 
6533
-imurmurhash@*, imurmurhash@^0.1.4:
6533
+imurmurhash@^0.1.4:
6534 6534
   version "0.1.4"
6535 6535
   resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
6536 6536
   integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -8008,11 +8008,6 @@ lockfile@^1.0.4:
8008 8008
   dependencies:
8009 8009
     signal-exit "^3.0.2"
8010 8010
 
8011
-lodash._baseindexof@*:
8012
-  version "3.1.0"
8013
-  resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
8014
-  integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
8015
-
8016 8011
 lodash._baseuniq@~4.6.0:
8017 8012
   version "4.6.0"
8018 8013
   resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -8021,33 +8016,11 @@ lodash._baseuniq@~4.6.0:
8021 8016
     lodash._createset "~4.0.0"
8022 8017
     lodash._root "~3.0.0"
8023 8018
 
8024
-lodash._bindcallback@*:
8025
-  version "3.0.1"
8026
-  resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
8027
-  integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
8028
-
8029
-lodash._cacheindexof@*:
8030
-  version "3.0.2"
8031
-  resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
8032
-  integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
8033
-
8034
-lodash._createcache@*:
8035
-  version "3.1.2"
8036
-  resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
8037
-  integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
8038
-  dependencies:
8039
-    lodash._getnative "^3.0.0"
8040
-
8041 8019
 lodash._createset@~4.0.0:
8042 8020
   version "4.0.3"
8043 8021
   resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
8044 8022
   integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
8045 8023
 
8046
-lodash._getnative@*, lodash._getnative@^3.0.0:
8047
-  version "3.9.1"
8048
-  resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
8049
-  integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
8050
-
8051 8024
 lodash._root@~3.0.0:
8052 8025
   version "3.0.1"
8053 8026
   resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
@@ -8118,11 +8091,6 @@ lodash.merge@^4.6.1:
8118 8091
   resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
8119 8092
   integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
8120 8093
 
8121
-lodash.restparam@*:
8122
-  version "3.6.1"
8123
-  resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
8124
-  integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
8125
-
8126 8094
 lodash.set@^4.3.2:
8127 8095
   version "4.3.2"
8128 8096
   resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
@@ -10923,10 +10891,10 @@ react-native-macos@0.60.0-microsoft.73:
10923 10891
     stacktrace-parser "^0.1.3"
10924 10892
     whatwg-fetch "^3.0.0"
10925 10893
 
10926
-react-native-windows@^0.62.0-0:
10927
-  version "0.62.0-preview.6"
10928
-  resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.62.0-preview.6.tgz#ff3f308220d6c2090c99aedcefe20ef05b62b4b5"
10929
-  integrity sha512-kjY2xC7wnuKVrJ9gr7+S/D9AR8BaC1QJt7ESSl2A7KM2PlkHuA7ufPD8zYep/a9JSFuM6G8LfhR4W0DBcZIt9g==
10894
+react-native-windows@0.62.6:
10895
+  version "0.62.6"
10896
+  resolved "https://registry.yarnpkg.com/react-native-windows/-/react-native-windows-0.62.6.tgz#a5bcd10ac4cae6ca5e63bff9b4b3368fd172770f"
10897
+  integrity sha512-vVWS5Sp+uh2+yFz4qR0kz3dExe4HZzsrThGtD3nMzfSJuVEJAFADGIyUOTrTEBrhZGqYbseU2Rs9UHNHSWGgAg==
10930 10898
   dependencies:
10931 10899
     "@babel/runtime" "^7.8.4"
10932 10900
     cli-spinners "^2.2.0"