react-native-webview-bootpay 13.8.42 → 13.13.4-6.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 +0 -42
- package/android/src/main/AndroidManifest.xml +3 -1
- package/android/src/main/AndroidManifestNew.xml +97 -0
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebChromeClient.java +54 -10
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebView.java +101 -68
- package/android/src/main/java/kr/co/bootpay/webview/BPCWebViewClient.java +68 -60
- 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 +4 -12
- 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 +39 -30
- 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
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
#include "pch.h"
|
|
5
|
+
|
|
6
|
+
#ifndef USE_WINUI3
|
|
7
|
+
|
|
5
8
|
#include "JSValueXaml.h"
|
|
6
9
|
#include "ReactWebView.h"
|
|
7
10
|
#include "ReactWebView.g.cpp"
|
|
@@ -41,7 +44,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
41
44
|
if (auto self = ref.get()) {
|
|
42
45
|
self->OnNavigationStarting(sender, args);
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
m_navigationCompletedRevoker = m_webView.NavigationCompleted(
|
|
@@ -57,6 +60,14 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
57
60
|
self->OnNavigationFailed(sender, args);
|
|
58
61
|
}
|
|
59
62
|
});
|
|
63
|
+
|
|
64
|
+
m_domContentLoadedRevoker = m_webView.DOMContentLoaded(
|
|
65
|
+
winrt::auto_revoke, [ref = get_weak()](auto const& sender, auto const& args) {
|
|
66
|
+
if (auto self = ref.get())
|
|
67
|
+
{
|
|
68
|
+
self->OnDOMContentLoaded(sender, args);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
60
71
|
}
|
|
61
72
|
|
|
62
73
|
bool ReactWebView::Is17763OrHigher() {
|
|
@@ -118,9 +129,16 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
118
129
|
});
|
|
119
130
|
|
|
120
131
|
if (m_messagingEnabled) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
winrt::hstring windowAlert =
|
|
133
|
+
L"window.alert = function (msg) "
|
|
134
|
+
L"{__REACT_WEB_VIEW_BRIDGE.postMessage(`{\"type\":\"__alert\",\"message\":\"${msg}\"}`)};";
|
|
135
|
+
winrt::hstring postMessage =
|
|
136
|
+
L"window.postMessage = function (data) "
|
|
137
|
+
L"{__REACT_WEB_VIEW_BRIDGE.postMessage(typeof data == 'string' ? data : JSON.stringify(data))};";
|
|
138
|
+
winrt::hstring reactNativeWebviewPostMessage =
|
|
139
|
+
L"window.ReactNativeWebView = {postMessage: function (data) "
|
|
140
|
+
L"{__REACT_WEB_VIEW_BRIDGE.postMessage(typeof data == 'string' ? data : JSON.stringify(data))}};";
|
|
141
|
+
webView.InvokeScriptAsync(L"eval", {windowAlert + postMessage + reactNativeWebviewPostMessage});
|
|
124
142
|
}
|
|
125
143
|
}
|
|
126
144
|
|
|
@@ -152,7 +170,7 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
152
170
|
}
|
|
153
171
|
}
|
|
154
172
|
}
|
|
155
|
-
|
|
173
|
+
|
|
156
174
|
m_reactContext.DispatchEvent(
|
|
157
175
|
*this,
|
|
158
176
|
L"topMessage",
|
|
@@ -165,6 +183,53 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
165
183
|
});
|
|
166
184
|
}
|
|
167
185
|
|
|
186
|
+
void ReactWebView::PostMessage(winrt::hstring const& message) {
|
|
187
|
+
if (m_messagingEnabled) {
|
|
188
|
+
HandleMessageFromJS(message);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
void ReactWebView::OnDOMContentLoaded(winrt::WebView const& webView, winrt::WebViewDOMContentLoadedEventArgs const& /*args*/)
|
|
193
|
+
{
|
|
194
|
+
m_reactContext.DispatchEvent(
|
|
195
|
+
*this,
|
|
196
|
+
L"topDOMContentLoaded",
|
|
197
|
+
[&](winrt::IJSValueWriter const& eventDataWriter) noexcept
|
|
198
|
+
{
|
|
199
|
+
eventDataWriter.WriteObjectBegin();
|
|
200
|
+
WriteWebViewNavigationEventArg(webView, eventDataWriter);
|
|
201
|
+
eventDataWriter.WriteObjectEnd();
|
|
202
|
+
});
|
|
203
|
+
// Polyfill for missing globalThis:
|
|
204
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
205
|
+
webView.InvokeScriptAsync(
|
|
206
|
+
L"eval", {L"if(typeof globalThis === 'undefined') { var globalThis = Function('return this')(); }"});
|
|
207
|
+
// Polyfill for missing BigInt:
|
|
208
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
|
|
209
|
+
webView.InvokeScriptAsync(L"eval", {L"window.BigInt = function (data) { return Number(parseFloat(data)); }"});
|
|
210
|
+
// Polyfill for missing DOMRect: https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
|
|
211
|
+
webView.InvokeScriptAsync(
|
|
212
|
+
L"eval",
|
|
213
|
+
{L"window.DOMRect = function (x = 0, y = 0, width = 0, height = 0) { return Object.assign({ x: x, y: y, "
|
|
214
|
+
L"height: height, width: width, top: ((y > 0) ? y : (y + height)), right: ((x > 0) ? (x + width) : x), "
|
|
215
|
+
L"bottom: ((y > 0) ? (y + height) : y), left: ((x > 0) ? x : (x + width)) }); }"});
|
|
216
|
+
if (!m_injectedJavascript.empty())
|
|
217
|
+
{
|
|
218
|
+
webView.InvokeScriptAsync(L"eval", {m_injectedJavascript});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
void ReactWebView::SetInjectedJavascript(winrt::hstring const& payload)
|
|
223
|
+
{
|
|
224
|
+
m_injectedJavascript = payload;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void ReactWebView::RequestFocus()
|
|
228
|
+
{
|
|
229
|
+
FocusManager::TryFocusAsync(m_webView, FocusState::Programmatic);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
168
233
|
void ReactWebView::MessagingEnabled(bool enabled) noexcept{
|
|
169
234
|
m_messagingEnabled = enabled;
|
|
170
235
|
}
|
|
@@ -172,4 +237,6 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
172
237
|
bool ReactWebView::MessagingEnabled() const noexcept{
|
|
173
238
|
return m_messagingEnabled;
|
|
174
239
|
}
|
|
175
|
-
} // namespace winrt::ReactNativeWebView::implementation
|
|
240
|
+
} // namespace winrt::ReactNativeWebView::implementation
|
|
241
|
+
|
|
242
|
+
#endif // USE_WINUI3
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
+
#ifndef USE_WINUI3
|
|
7
|
+
|
|
6
8
|
#include "winrt/Microsoft.ReactNative.h"
|
|
7
9
|
#include "NativeModules.h"
|
|
8
10
|
#include "ReactWebView.g.h"
|
|
@@ -18,6 +20,9 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
18
20
|
ReactWebView(Microsoft::ReactNative::IReactContext const& reactContext);
|
|
19
21
|
void MessagingEnabled(bool enabled) noexcept;
|
|
20
22
|
bool MessagingEnabled() const noexcept;
|
|
23
|
+
void SetInjectedJavascript(winrt::hstring const& payload);
|
|
24
|
+
void RequestFocus();
|
|
25
|
+
void PostMessage(winrt::hstring const& message);
|
|
21
26
|
~ReactWebView();
|
|
22
27
|
|
|
23
28
|
private:
|
|
@@ -26,13 +31,16 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
26
31
|
Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
|
|
27
32
|
WebBridge m_webBridge{ nullptr };
|
|
28
33
|
winrt::event_token m_messageToken;
|
|
34
|
+
winrt::hstring m_injectedJavascript;
|
|
29
35
|
winrt::Windows::UI::Xaml::Controls::WebView::NavigationStarting_revoker m_navigationStartingRevoker{};
|
|
30
36
|
winrt::Windows::UI::Xaml::Controls::WebView::NavigationCompleted_revoker m_navigationCompletedRevoker{};
|
|
31
37
|
winrt::Windows::UI::Xaml::Controls::WebView::NavigationFailed_revoker m_navigationFailedRevoker{};
|
|
38
|
+
winrt::Windows::UI::Xaml::Controls::WebView::DOMContentLoaded_revoker m_domContentLoadedRevoker{};
|
|
32
39
|
|
|
33
40
|
void HandleMessageFromJS(winrt::hstring const& message);
|
|
34
41
|
void RegisterEvents();
|
|
35
42
|
void WriteWebViewNavigationEventArg(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
|
|
43
|
+
void OnDOMContentLoaded(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewDOMContentLoadedEventArgs const& args);
|
|
36
44
|
void OnNavigationStarting(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationStartingEventArgs const& args);
|
|
37
45
|
void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
|
|
38
46
|
void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);
|
|
@@ -43,4 +51,6 @@ namespace winrt::ReactNativeWebView::implementation {
|
|
|
43
51
|
|
|
44
52
|
namespace winrt::ReactNativeWebView::factory_implementation {
|
|
45
53
|
struct ReactWebView : ReactWebViewT<ReactWebView, implementation::ReactWebView> {};
|
|
46
|
-
} // namespace winrt::ReactNativeWebView::factory_implementation
|
|
54
|
+
} // namespace winrt::ReactNativeWebView::factory_implementation
|
|
55
|
+
|
|
56
|
+
#endif // USE_WINUI3
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
+
#include <NamespaceRedirect.h>
|
|
2
|
+
|
|
1
3
|
namespace ReactNativeWebView{
|
|
4
|
+
#if !defined(USE_WINUI3)
|
|
2
5
|
[default_interface]
|
|
3
6
|
runtimeclass ReactWebView : Windows.UI.Xaml.Controls.ContentPresenter{
|
|
4
7
|
ReactWebView(Microsoft.ReactNative.IReactContext context);
|
|
5
8
|
Boolean MessagingEnabled;
|
|
9
|
+
void SetInjectedJavascript(String payload);
|
|
10
|
+
void RequestFocus();
|
|
11
|
+
void PostMessage(String message);
|
|
6
12
|
};
|
|
13
|
+
#endif
|
|
7
14
|
#if __has_include(<VersionMacros.h>)
|
|
8
15
|
#include <VersionMacros.h>
|
|
9
16
|
#else
|
|
10
17
|
#define RNW_VERSION_AT_LEAST(x,y,z) false
|
|
11
18
|
#endif
|
|
12
19
|
|
|
13
|
-
#if RNW_VERSION_AT_LEAST(0,68,0) && defined(WINUI2_HAS_WEBVIEW2)
|
|
20
|
+
#if RNW_VERSION_AT_LEAST(0,68,0) && (defined(WINUI2_HAS_WEBVIEW2) || defined(USE_WINUI3))
|
|
14
21
|
[default_interface]
|
|
15
|
-
runtimeclass ReactWebView2 :
|
|
22
|
+
runtimeclass ReactWebView2 : XAML_NAMESPACE.Controls.ContentPresenter{
|
|
16
23
|
ReactWebView2(Microsoft.ReactNative.IReactContext context);
|
|
17
24
|
void NavigateToHtml(String html);
|
|
18
|
-
void
|
|
25
|
+
void NavigateWithWebResourceRequest(Microsoft.ReactNative.IJSValueReader request);
|
|
26
|
+
String InjectedJavascript;
|
|
19
27
|
Boolean MessagingEnabled;
|
|
28
|
+
Boolean LinkHandlingEnabled;
|
|
20
29
|
};
|
|
21
30
|
#endif
|
|
22
31
|
} // namespace ReactNativeWebView
|