react-native-webview-bootpay 13.8.41 → 13.13.4-4.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -69
- package/android/build.gradle +1 -11
- package/android/gradle.properties +5 -47
- package/android/src/main/AndroidManifest.xml +9 -5
- package/android/src/main/AndroidManifestNew.xml +97 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +57 -11
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +70 -56
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewManagerImpl.kt +119 -65
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewMessagingModule.kt +9 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewModuleImpl.java +1 -1
- package/android/src/main/java/kr/co/bootpay/webview/BootpayUrlHelper.java +91 -75
- package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewManager.java +118 -109
- package/android/src/newarch/{com/reactnativecommunity → kr/co/bootpay}/webview/BPCWebViewModule.java +1 -1
- package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewManager.java +63 -58
- package/android/src/{main/java → oldarch}/kr/co/bootpay/webview/BPCWebViewModule.java +1 -1
- package/apple/BPCWebView.mm +21 -12
- package/apple/BPCWebViewImpl.h +10 -0
- package/apple/BPCWebViewImpl.m +267 -205
- package/apple/BPCWebViewManager.mm +5 -24
- package/apple/BPCWebViewModule.h +23 -0
- package/apple/BPCWebViewModule.mm +34 -0
- package/apple/RCTConvert+WKDataDetectorTypes.h +11 -0
- package/apple/RCTConvert+WKDataDetectorTypes.m +27 -0
- package/index.d.ts +54 -48
- package/ios/RNCWebView.xcodeproj/project.pbxproj +24 -24
- package/ios/RNCWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RNCWebView.xcodeproj/project.xcworkspace/xcuserdata/taesupyoon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNCWebView.xcodeproj/xcuserdata/taesupyoon.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/BPCWebViewNativeComponent.d.ts +24 -25
- package/lib/BPCWebViewNativeComponent.js +1 -1
- package/lib/{NativeBPCWebView.d.ts → NativeBPCWebViewModule.d.ts} +2 -5
- package/lib/{NativeBPCWebView.js → NativeBPCWebViewModule.js} +1 -1
- package/lib/WebView.android.d.ts +0 -1
- package/lib/WebView.android.js +1 -1
- package/lib/WebView.d.ts +0 -1
- package/lib/WebView.ios.d.ts +0 -1
- package/lib/WebView.ios.js +1 -1
- package/lib/WebView.js +1 -1
- package/lib/WebView.macos.d.ts +0 -1
- package/lib/WebView.macos.js +1 -1
- package/lib/WebView.styles.d.ts +37 -11
- package/lib/WebView.styles.js +1 -1
- package/lib/WebView.windows.d.ts +0 -1
- package/lib/WebView.windows.js +1 -1
- package/lib/WebViewNativeComponent.macos.d.ts +1 -2
- package/lib/WebViewNativeComponent.windows.d.ts +1 -2
- package/lib/WebViewShared.d.ts +0 -1
- package/lib/WebViewShared.js +1 -1
- package/lib/WebViewTypes.d.ts +51 -3
- package/lib/WebViewTypes.js +1 -1
- package/lib/index.d.ts +0 -1
- package/macos/RNCWebView.xcodeproj/project.pbxproj +36 -36
- package/package.json +12 -11
- package/react-native-webview-bootpay.podspec +2 -2
- package/react-native.config.js +1 -5
- package/src/BPCWebViewNativeComponent.ts +143 -79
- package/src/NativeBPCWebViewModule.ts +13 -0
- package/src/WebView.android.tsx +295 -190
- package/src/WebView.ios.tsx +253 -186
- package/src/WebView.macos.tsx +220 -152
- package/src/WebView.styles.ts +9 -12
- package/src/WebView.tsx +14 -7
- package/src/WebView.windows.tsx +180 -126
- package/src/WebViewNativeComponent.macos.ts +4 -5
- package/src/WebViewNativeComponent.windows.ts +6 -8
- package/src/WebViewShared.tsx +139 -91
- package/src/WebViewTypes.ts +80 -35
- package/src/__tests__/WebViewShared-test.js +170 -55
- package/windows/ReactNativeWebView/ReactNativeWebView.vcxproj +8 -17
- package/windows/ReactNativeWebView/ReactPackageProvider.cpp +5 -1
- package/windows/ReactNativeWebView/ReactWebView.cpp +73 -6
- package/windows/ReactNativeWebView/ReactWebView.h +11 -1
- package/windows/ReactNativeWebView/ReactWebView.idl +12 -3
- package/windows/ReactNativeWebView/ReactWebView2.cpp +294 -129
- package/windows/ReactNativeWebView/ReactWebView2.h +42 -5
- package/windows/ReactNativeWebView/ReactWebView2Manager.cpp +60 -34
- package/windows/ReactNativeWebView/ReactWebView2Manager.h +4 -4
- package/windows/ReactNativeWebView/ReactWebViewHelpers.cpp +70 -0
- package/windows/ReactNativeWebView/ReactWebViewHelpers.h +16 -0
- package/windows/ReactNativeWebView/ReactWebViewManager.cpp +22 -3
- package/windows/ReactNativeWebView/ReactWebViewManager.h +6 -1
- package/windows/ReactNativeWebView/pch.h +11 -7
- package/windows/ReactNativeWebView.sln +14 -14
- package/ios/main.jsbundle +0 -457
- package/lib/BPCWebViewNativeComponent.d.ts.map +0 -1
- package/lib/NativeBPCWebView.d.ts.map +0 -1
- package/lib/WebView.android.d.ts.map +0 -1
- package/lib/WebView.d.ts.map +0 -1
- package/lib/WebView.ios.d.ts.map +0 -1
- package/lib/WebView.macos.d.ts.map +0 -1
- package/lib/WebView.styles.d.ts.map +0 -1
- package/lib/WebView.windows.d.ts.map +0 -1
- package/lib/WebViewNativeComponent.macos.d.ts.map +0 -1
- package/lib/WebViewNativeComponent.windows.d.ts.map +0 -1
- package/lib/WebViewShared.d.ts.map +0 -1
- package/lib/WebViewTypes.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/src/NativeBPCWebView.ts +0 -14
- package/windows/ReactNativeWebView/packages.config +0 -5
- /package/android/src/main/java/kr/co/bootpay/webview/{BPCWebviewWrapper.kt → BPCWebViewWrapper.kt} +0 -0
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
#include "ReactWebView2.h"
|
|
7
7
|
#include "JSValueXaml.h"
|
|
8
8
|
|
|
9
|
+
namespace mux {
|
|
10
|
+
using namespace winrt::Microsoft::UI::Xaml::Controls;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
namespace winrt {
|
|
10
14
|
using namespace Microsoft::ReactNative;
|
|
11
15
|
using namespace Windows::Foundation;
|
|
12
16
|
using namespace Windows::Foundation::Collections;
|
|
13
|
-
using namespace Windows::UI;
|
|
14
|
-
using namespace Windows::UI::Xaml;
|
|
15
|
-
using namespace Windows::UI::Xaml::Controls;
|
|
16
|
-
using namespace Microsoft::UI::Xaml::Controls;
|
|
17
17
|
using namespace Windows::Web::Http;
|
|
18
18
|
using namespace Windows::Web::Http::Headers;
|
|
19
|
-
using namespace
|
|
20
|
-
using namespace
|
|
19
|
+
using namespace xaml;
|
|
20
|
+
using namespace xaml::Controls;
|
|
21
|
+
using namespace xaml::Input;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
namespace winrt::ReactNativeWebView::implementation {
|
|
@@ -48,6 +49,8 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
48
49
|
auto nativeProps = winrt::single_threaded_map<hstring, ViewManagerPropertyType>();
|
|
49
50
|
nativeProps.Insert(L"source", ViewManagerPropertyType::Map);
|
|
50
51
|
nativeProps.Insert(L"messagingEnabled", ViewManagerPropertyType::Boolean);
|
|
52
|
+
nativeProps.Insert(L"injectedJavaScript", ViewManagerPropertyType::String);
|
|
53
|
+
nativeProps.Insert(L"linkHandlingEnabled", ViewManagerPropertyType::String);
|
|
51
54
|
return nativeProps.GetView();
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -56,7 +59,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
56
59
|
IJSValueReader const& propertyMapReader) noexcept {
|
|
57
60
|
auto control = view.as<winrt::ContentPresenter>();
|
|
58
61
|
auto content = control.Content();
|
|
59
|
-
auto webView = content.as<
|
|
62
|
+
auto webView = content.as<mux::WebView2>();
|
|
60
63
|
const JSValueObject& propertyMap = JSValueObject::ReadFrom(propertyMapReader);
|
|
61
64
|
|
|
62
65
|
for (auto const& pair : propertyMap) {
|
|
@@ -66,7 +69,8 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
66
69
|
|
|
67
70
|
if (propertyName == "source") {
|
|
68
71
|
auto const& srcMap = propertyValue.AsObject();
|
|
69
|
-
|
|
72
|
+
auto reactWebView2 = view.as<winrt::ReactNativeWebView::ReactWebView2>();
|
|
73
|
+
std::string const fileScheme = "file://";
|
|
70
74
|
if (srcMap.find("uri") != srcMap.end()) {
|
|
71
75
|
auto uriString = srcMap.at("uri").AsString();
|
|
72
76
|
if (uriString.length() == 0) {
|
|
@@ -77,37 +81,18 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
77
81
|
if (srcMap.find("__packager_asset") != srcMap.end()) {
|
|
78
82
|
isPackagerAsset = srcMap.at("__packager_asset").AsBoolean();
|
|
79
83
|
}
|
|
80
|
-
if (isPackagerAsset && uriString.find(
|
|
84
|
+
if (isPackagerAsset && uriString.find(fileScheme) == 0) {
|
|
81
85
|
auto bundleRootPath = winrt::to_string(ReactNativeHost().InstanceSettings().BundleRootPath());
|
|
82
|
-
uriString.replace(0, std::size(
|
|
86
|
+
uriString.replace(0, std::size(fileScheme), bundleRootPath.empty() ? "ms-appx-web:///Bundle/" : bundleRootPath);
|
|
83
87
|
}
|
|
84
|
-
|
|
85
88
|
if (uriString.find("ms-appdata://") == 0 || uriString.find("ms-appx-web://") == 0) {
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const auto hasHeaders = srcMap.find("headers") != srcMap.end();
|
|
90
|
-
|
|
91
|
-
if (hasHeaders) {
|
|
92
|
-
auto headers = winrt::single_threaded_map<winrt::hstring, winrt::hstring>();
|
|
93
|
-
|
|
94
|
-
for (auto const& header : srcMap.at("headers").AsObject()) {
|
|
95
|
-
auto const& headerKey = header.first;
|
|
96
|
-
auto const& headerValue = header.second;
|
|
97
|
-
headers.Insert(winrt::to_hstring(headerKey), winrt::to_hstring(headerValue.AsString()));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const auto reactWebView2 = view.as<ReactNativeWebView::ReactWebView2>();
|
|
101
|
-
reactWebView2.NavigateWithHeaders(to_hstring(uriString), headers.GetView());
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
webView.Source(winrt::Uri(to_hstring(uriString)));
|
|
105
|
-
}
|
|
89
|
+
reactWebView2.NavigateToHtml(to_hstring(uriString));
|
|
90
|
+
} else {
|
|
91
|
+
reactWebView2.NavigateWithWebResourceRequest(MakeJSValueTreeReader(JSValue(srcMap.Copy())));
|
|
106
92
|
}
|
|
107
93
|
}
|
|
108
94
|
else if (srcMap.find("html") != srcMap.end()) {
|
|
109
95
|
auto htmlString = srcMap.at("html").AsString();
|
|
110
|
-
auto reactWebView2 = view.as<winrt::ReactNativeWebView::ReactWebView2>();
|
|
111
96
|
reactWebView2.NavigateToHtml(to_hstring(htmlString));
|
|
112
97
|
}
|
|
113
98
|
}
|
|
@@ -116,6 +101,17 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
116
101
|
auto reactWebView2 = view.as<ReactNativeWebView::ReactWebView2>();
|
|
117
102
|
reactWebView2.MessagingEnabled(messagingEnabled);
|
|
118
103
|
}
|
|
104
|
+
else if (propertyName == "injectedJavaScript")
|
|
105
|
+
{
|
|
106
|
+
auto injectedJavascript = propertyValue.AsString();
|
|
107
|
+
auto reactWebView2 = view.as<ReactNativeWebView::ReactWebView2>();
|
|
108
|
+
reactWebView2.InjectedJavascript(to_hstring(injectedJavascript));
|
|
109
|
+
}
|
|
110
|
+
else if (propertyName == "linkHandlingEnabled") {
|
|
111
|
+
auto linkHandlingEnabled = propertyValue.To<bool>();
|
|
112
|
+
auto reactWebView2 = view.as<ReactNativeWebView::ReactWebView2>();
|
|
113
|
+
reactWebView2.LinkHandlingEnabled(linkHandlingEnabled);
|
|
114
|
+
}
|
|
119
115
|
}
|
|
120
116
|
}
|
|
121
117
|
|
|
@@ -126,10 +122,15 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
126
122
|
|
|
127
123
|
ConstantProviderDelegate ReactWebView2Manager::ExportedCustomDirectEventTypeConstants() noexcept {
|
|
128
124
|
return [](winrt::IJSValueWriter const& constantWriter) {
|
|
125
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "DOMContentLoaded");
|
|
129
126
|
WriteCustomDirectEventTypeConstant(constantWriter, "LoadingStart");
|
|
130
127
|
WriteCustomDirectEventTypeConstant(constantWriter, "LoadingFinish");
|
|
131
128
|
WriteCustomDirectEventTypeConstant(constantWriter, "LoadingError");
|
|
132
129
|
WriteCustomDirectEventTypeConstant(constantWriter, "Message");
|
|
130
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "FrameNavigationStart");
|
|
131
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "FrameNavigationFinish");
|
|
132
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "OpenWindow");
|
|
133
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "SourceChanged");
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
136
|
|
|
@@ -141,6 +142,10 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
141
142
|
commands.Append(L"reload");
|
|
142
143
|
commands.Append(L"stopLoading");
|
|
143
144
|
commands.Append(L"injectJavaScript");
|
|
145
|
+
commands.Append(L"requestFocus");
|
|
146
|
+
commands.Append(L"clearCache");
|
|
147
|
+
commands.Append(L"postMessage");
|
|
148
|
+
commands.Append(L"loadUrl");
|
|
144
149
|
return commands.GetView();
|
|
145
150
|
}
|
|
146
151
|
|
|
@@ -150,7 +155,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
150
155
|
winrt::IJSValueReader const& commandArgsReader) noexcept {
|
|
151
156
|
auto control = view.as<winrt::ContentPresenter>();
|
|
152
157
|
auto content = control.Content();
|
|
153
|
-
auto webView = content.as<
|
|
158
|
+
auto webView = content.as<mux::WebView2>();
|
|
154
159
|
auto commandArgs = JSValue::ReadArrayFrom(commandArgsReader);
|
|
155
160
|
|
|
156
161
|
if (commandId == L"goForward") {
|
|
@@ -167,11 +172,32 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
167
172
|
webView.Reload();
|
|
168
173
|
}
|
|
169
174
|
else if (commandId == L"stopLoading") {
|
|
170
|
-
webView.CoreWebView2()
|
|
175
|
+
if (webView.CoreWebView2() != nullptr) {
|
|
176
|
+
webView.CoreWebView2().Stop();
|
|
177
|
+
}
|
|
171
178
|
}
|
|
172
179
|
else if (commandId == L"injectJavaScript") {
|
|
173
180
|
webView.ExecuteScriptAsync(winrt::to_hstring(commandArgs[0].AsString()));
|
|
174
181
|
}
|
|
182
|
+
else if (commandId == L"requestFocus") {
|
|
183
|
+
FocusManager::TryFocusAsync(webView, FocusState::Programmatic);
|
|
184
|
+
}
|
|
185
|
+
else if (commandId == L"clearCache") {
|
|
186
|
+
// There is no way to clear the cache in WebView2 because it is shared with Edge.
|
|
187
|
+
// The best we can do is clear the cookies, because we cannot access history or local storage.
|
|
188
|
+
auto cookieManager = webView.CoreWebView2().CookieManager();
|
|
189
|
+
cookieManager.DeleteAllCookies();
|
|
190
|
+
}
|
|
191
|
+
else if (commandId == L"loadUrl") {
|
|
192
|
+
auto uri = winrt::Uri(to_hstring(commandArgs[0].AsString()));
|
|
193
|
+
webView.Source(uri);
|
|
194
|
+
}
|
|
195
|
+
else if (commandId == L"postMessage") {
|
|
196
|
+
if (webView.CoreWebView2() != nullptr) {
|
|
197
|
+
auto message = commandArgs[0].AsString();
|
|
198
|
+
webView.CoreWebView2().PostWebMessageAsString(to_hstring(message));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
175
201
|
}
|
|
176
202
|
|
|
177
203
|
} // namespace winrt::ReactNativeWebView::implementation
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#include "NativeModules.h"
|
|
11
11
|
|
|
12
12
|
namespace winrt::ReactNativeWebView::implementation {
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
class ReactWebView2Manager : public winrt::implements<
|
|
15
15
|
ReactWebView2Manager,
|
|
16
16
|
winrt::Microsoft::ReactNative::IViewManager,
|
|
@@ -22,7 +22,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
22
22
|
ReactWebView2Manager();
|
|
23
23
|
// IViewManager
|
|
24
24
|
winrt::hstring Name() noexcept;
|
|
25
|
-
|
|
25
|
+
xaml::FrameworkElement CreateView() noexcept;
|
|
26
26
|
|
|
27
27
|
// IViewManagerWithReactContext
|
|
28
28
|
winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
|
|
@@ -34,7 +34,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
34
34
|
NativeProps() noexcept;
|
|
35
35
|
|
|
36
36
|
void UpdateProperties(
|
|
37
|
-
|
|
37
|
+
xaml::FrameworkElement const& view,
|
|
38
38
|
winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept;
|
|
39
39
|
|
|
40
40
|
// IViewManagerWithExportedEventTypeConstants
|
|
@@ -45,7 +45,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
45
45
|
winrt::Windows::Foundation::Collections::IVectorView<winrt::hstring> Commands() noexcept;
|
|
46
46
|
|
|
47
47
|
void DispatchCommand(
|
|
48
|
-
|
|
48
|
+
xaml::FrameworkElement const& view,
|
|
49
49
|
winrt::hstring const& commandId,
|
|
50
50
|
winrt::Microsoft::ReactNative::IJSValueReader const& commandArgsReader) noexcept;
|
|
51
51
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "pch.h"
|
|
7
|
+
#include "winrt/ReactNativeWebView.h"
|
|
8
|
+
|
|
9
|
+
using namespace winrt::ReactNativeWebView;
|
|
10
|
+
|
|
11
|
+
namespace winrt::ReactNativeWebView::implementation {
|
|
12
|
+
namespace ReactWebViewHelpers {
|
|
13
|
+
std::string TrimString(const std::string& str) {
|
|
14
|
+
std::string trimmedString = str;
|
|
15
|
+
|
|
16
|
+
// Trim from start
|
|
17
|
+
trimmedString.erase(0, trimmedString.find_first_not_of(" \t\n\r\f\v"));
|
|
18
|
+
|
|
19
|
+
// Trim from end
|
|
20
|
+
trimmedString.erase(trimmedString.find_last_not_of(" \t\n\r\f\v") + 1);
|
|
21
|
+
|
|
22
|
+
return trimmedString;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
std::vector<std::string> SplitString(
|
|
26
|
+
const std::string& str,
|
|
27
|
+
const std::string& delim) {
|
|
28
|
+
std::vector<std::string> tokens;
|
|
29
|
+
auto startPos = 0;
|
|
30
|
+
auto endPos = str.find(delim);
|
|
31
|
+
|
|
32
|
+
while (endPos != std::string::npos) {
|
|
33
|
+
auto token = str.substr(startPos, endPos - startPos);
|
|
34
|
+
tokens.push_back(TrimString(token));
|
|
35
|
+
|
|
36
|
+
startPos = endPos + delim.length();
|
|
37
|
+
endPos = str.find(delim, startPos);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
auto lastToken = str.substr(startPos);
|
|
41
|
+
tokens.push_back(TrimString(lastToken));
|
|
42
|
+
|
|
43
|
+
return tokens;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::map<std::string, std::string> ParseSetCookieHeader(
|
|
47
|
+
const std::string& setCookieHeader) {
|
|
48
|
+
std::map<std::string, std::string> cookie;
|
|
49
|
+
|
|
50
|
+
// Split the header into individual cookie strings
|
|
51
|
+
auto cookieStrings = SplitString(setCookieHeader, ";");
|
|
52
|
+
|
|
53
|
+
// Extract the cookie name and value from the first string
|
|
54
|
+
auto nameValuePair = SplitString(cookieStrings[0], "=");
|
|
55
|
+
cookie["Name"] = TrimString(nameValuePair[0]);
|
|
56
|
+
cookie["Value"] = TrimString(nameValuePair[1]);
|
|
57
|
+
|
|
58
|
+
// Extract the attributes from the remaining strings
|
|
59
|
+
for (std::size_t i = 1; i < cookieStrings.size(); ++i) {
|
|
60
|
+
auto attributeValuePair = SplitString(cookieStrings[i], "=");
|
|
61
|
+
auto attributeName = attributeValuePair[0];
|
|
62
|
+
auto attributeValue =
|
|
63
|
+
attributeValuePair.size() > 1 ? attributeValuePair[1] : "";
|
|
64
|
+
cookie[attributeName] = TrimString(attributeValue);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return cookie;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} // namespace winrt::ReactNativeWebView::implementation
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "winrt/ReactNativeWebView.h"
|
|
7
|
+
|
|
8
|
+
using namespace winrt::ReactNativeWebView;
|
|
9
|
+
|
|
10
|
+
namespace winrt::ReactNativeWebView::implementation {
|
|
11
|
+
namespace ReactWebViewHelpers {
|
|
12
|
+
std::string TrimString(const std::string& str);
|
|
13
|
+
std::vector<std::string> SplitString(const std::string& str, const std::string& delim);
|
|
14
|
+
std::map<std::string, std::string> ParseSetCookieHeader(const std::string& setCookieHeader);
|
|
15
|
+
}
|
|
16
|
+
} // namespace winrt::ReactNativeWebView::implementation
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
1
4
|
#include "pch.h"
|
|
5
|
+
|
|
6
|
+
#ifndef USE_WINUI3
|
|
7
|
+
|
|
2
8
|
#include "ReactWebViewManager.h"
|
|
3
9
|
#include "NativeModules.h"
|
|
4
10
|
#include "ReactWebView.h"
|
|
@@ -144,7 +150,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
144
150
|
auto reactWebView = view.as<ReactNativeWebView::ReactWebView>();
|
|
145
151
|
reactWebView.MessagingEnabled(messagingEnabled);
|
|
146
152
|
}
|
|
147
|
-
}
|
|
153
|
+
}
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
// IViewManagerWithExportedEventTypeConstants
|
|
@@ -158,6 +164,8 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
158
164
|
WriteCustomDirectEventTypeConstant(constantWriter, "LoadingFinish");
|
|
159
165
|
WriteCustomDirectEventTypeConstant(constantWriter, "LoadingError");
|
|
160
166
|
WriteCustomDirectEventTypeConstant(constantWriter, "Message");
|
|
167
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "DOMContentLoaded");
|
|
168
|
+
WriteCustomDirectEventTypeConstant(constantWriter, "Message");
|
|
161
169
|
};
|
|
162
170
|
}
|
|
163
171
|
|
|
@@ -169,6 +177,8 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
169
177
|
commands.Append(L"reload");
|
|
170
178
|
commands.Append(L"stopLoading");
|
|
171
179
|
commands.Append(L"injectJavaScript");
|
|
180
|
+
commands.Append(L"postMessage");
|
|
181
|
+
commands.Append(L"loadUrl");
|
|
172
182
|
return commands.GetView();
|
|
173
183
|
}
|
|
174
184
|
|
|
@@ -199,7 +209,16 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
199
209
|
}
|
|
200
210
|
else if (commandId == L"injectJavaScript") {
|
|
201
211
|
webView.InvokeScriptAsync(L"eval", { winrt::to_hstring(commandArgs[0].AsString()) });
|
|
202
|
-
}
|
|
212
|
+
}
|
|
213
|
+
else if (commandId == L"postMessage") {
|
|
214
|
+
auto reactWebView = view.as<ReactNativeWebView::ReactWebView>();
|
|
215
|
+
reactWebView.PostMessage(to_hstring(commandArgs[0].AsString()));
|
|
216
|
+
}
|
|
217
|
+
else if (commandId == L"loadUrl") {
|
|
218
|
+
webView.Navigate(winrt::Uri(to_hstring(commandArgs[0].AsString())));
|
|
219
|
+
}
|
|
203
220
|
}
|
|
204
221
|
|
|
205
|
-
} // namespace winrt::ReactWebView::implementation
|
|
222
|
+
} // namespace winrt::ReactWebView::implementation
|
|
223
|
+
|
|
224
|
+
#endif // USE_WINUI3
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
|
+
|
|
6
|
+
#ifndef USE_WINUI3
|
|
7
|
+
|
|
5
8
|
#include "winrt/Microsoft.ReactNative.h"
|
|
6
9
|
#include "NativeModules.h"
|
|
7
10
|
#include "ReactWebView.h"
|
|
8
11
|
|
|
9
12
|
namespace winrt::ReactNativeWebView::implementation {
|
|
10
|
-
|
|
13
|
+
|
|
11
14
|
class ReactWebViewManager : public winrt::implements<
|
|
12
15
|
ReactWebViewManager,
|
|
13
16
|
winrt::Microsoft::ReactNative::IViewManager,
|
|
@@ -51,3 +54,5 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
51
54
|
|
|
52
55
|
};
|
|
53
56
|
} // namespace winrt::ReactWebView::implementation
|
|
57
|
+
|
|
58
|
+
#endif // USE_WINUI3
|
|
@@ -8,26 +8,30 @@
|
|
|
8
8
|
#define RNW_VERSION_AT_LEAST(x,y,z) false
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
-
#if RNW_VERSION_AT_LEAST(0,68,0) && defined(WINUI2_HAS_WEBVIEW2)
|
|
11
|
+
#if RNW_VERSION_AT_LEAST(0,68,0) && (defined(WINUI2_HAS_WEBVIEW2) || defined(USE_WINUI3))
|
|
12
12
|
#define HAS_WEBVIEW2 1
|
|
13
13
|
#else
|
|
14
14
|
#define HAS_WEBVIEW2 0
|
|
15
15
|
#endif
|
|
16
16
|
|
|
17
17
|
#include <unknwn.h>
|
|
18
|
+
|
|
19
|
+
#include <CppWinRTIncludes.h>
|
|
20
|
+
#include <UI.Xaml.Controls.h>
|
|
21
|
+
#include <UI.Xaml.Input.h>
|
|
22
|
+
#include <UI.Xaml.Markup.h>
|
|
23
|
+
#include <UI.Xaml.Navigation.h>
|
|
24
|
+
|
|
18
25
|
#include <winrt/Windows.Data.Json.h>
|
|
19
26
|
#include <winrt/Windows.Foundation.h>
|
|
20
27
|
#include <winrt/Windows.Foundation.Collections.h>
|
|
21
28
|
#include <winrt/Windows.UI.Popups.h>
|
|
22
|
-
#include <winrt/Windows.UI.Xaml.h>
|
|
23
|
-
#include <winrt/Windows.UI.Xaml.Controls.h>
|
|
24
|
-
#include <winrt/Windows.UI.Xaml.Markup.h>
|
|
25
|
-
#include <winrt/Windows.UI.Xaml.Navigation.h>
|
|
26
29
|
#include <winrt/Windows.Web.Http.h>
|
|
27
30
|
#include <winrt/Windows.Web.Http.Headers.h>
|
|
28
31
|
#include <winrt/Microsoft.ReactNative.h>
|
|
29
32
|
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
33
|
+
#include <winrt/Windows.Security.Cryptography.h>
|
|
34
|
+
#include <winrt/Windows.Storage.Streams.h>
|
|
30
35
|
#if HAS_WEBVIEW2
|
|
31
36
|
#include <winrt/Microsoft.Web.WebView2.Core.h>
|
|
32
|
-
#
|
|
33
|
-
#endif
|
|
37
|
+
#endif
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
3
|
-
# Visual Studio Version
|
|
4
|
-
VisualStudioVersion =
|
|
3
|
+
# Visual Studio Version 17
|
|
4
|
+
VisualStudioVersion = 17.6.33815.320
|
|
5
5
|
MinimumVisualStudioVersion = 10.0.40219.1
|
|
6
6
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ReactNative", "ReactNative", "{6030669C-4F4D-4889-B38E-0299826D8C01}"
|
|
7
7
|
EndProject
|
|
@@ -32,18 +32,6 @@ EndProject
|
|
|
32
32
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReactNativeWebView", "ReactNativeWebView\ReactNativeWebView.vcxproj", "{00AA3765-C6A0-4713-B3F9-BFE47B9C83F5}"
|
|
33
33
|
EndProject
|
|
34
34
|
Global
|
|
35
|
-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
|
36
|
-
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{00aa3765-c6a0-4713-b3f9-bfe47b9c83f5}*SharedItemsImports = 4
|
|
37
|
-
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
|
|
38
|
-
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{84e05bfa-cbaf-4f0d-bfb6-4ce85742a57e}*SharedItemsImports = 9
|
|
39
|
-
..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{c38970c0-5fbf-4d69-90d8-cbac225ae895}*SharedItemsImports = 9
|
|
40
|
-
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
|
|
41
|
-
..\node_modules\react-native-windows\include\Include.vcxitems*{ef074ba1-2d54-4d49-a28e-5e040b47cd2e}*SharedItemsImports = 9
|
|
42
|
-
..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
43
|
-
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
44
|
-
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
45
|
-
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
46
|
-
EndGlobalSection
|
|
47
35
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
48
36
|
Debug|ARM64 = Debug|ARM64
|
|
49
37
|
Debug|x64 = Debug|x64
|
|
@@ -182,4 +170,16 @@ Global
|
|
|
182
170
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
183
171
|
SolutionGuid = {D1E18B0A-0D27-4F39-8A8B-7E3D784A99FC}
|
|
184
172
|
EndGlobalSection
|
|
173
|
+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
|
174
|
+
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{00aa3765-c6a0-4713-b3f9-bfe47b9c83f5}*SharedItemsImports = 4
|
|
175
|
+
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
|
|
176
|
+
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{84e05bfa-cbaf-4f0d-bfb6-4ce85742a57e}*SharedItemsImports = 9
|
|
177
|
+
..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{c38970c0-5fbf-4d69-90d8-cbac225ae895}*SharedItemsImports = 9
|
|
178
|
+
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
|
|
179
|
+
..\node_modules\react-native-windows\include\Include.vcxitems*{ef074ba1-2d54-4d49-a28e-5e040b47cd2e}*SharedItemsImports = 9
|
|
180
|
+
..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
181
|
+
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
182
|
+
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
183
|
+
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
|
|
184
|
+
EndGlobalSection
|
|
185
185
|
EndGlobal
|