@datadog/mobile-react-native-webview 2.7.1 → 2.8.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/DatadogSDKReactNativeWebView.podspec +16 -5
- package/android/build.gradle +1 -1
- package/ios/Sources/DatadogSDKReactNativeWebView.h +1 -1
- package/ios/Sources/RCTDatadogWebView.h +1 -1
- package/ios/Sources/RCTDatadogWebViewManager.h +1 -1
- package/ios/Sources/RCTDatadogWebViewManager.mm +6 -1
- package/lib/commonjs/index.js +1 -2
- package/lib/commonjs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/WebviewDatadogInjectedJS.test.tsx +46 -13
|
@@ -18,9 +18,13 @@ Pod::Spec.new do |s|
|
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
20
|
|
|
21
|
+
if ENV['USE_FRAMEWORKS'] == 'static'
|
|
22
|
+
s.dependency "react-native-webview"
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
# /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
|
|
22
|
-
s.dependency 'DatadogWebViewTracking', '~> 2.
|
|
23
|
-
s.dependency 'DatadogInternal', '~> 2.
|
|
26
|
+
s.dependency 'DatadogWebViewTracking', '~> 2.27.0'
|
|
27
|
+
s.dependency 'DatadogInternal', '~> 2.27.0'
|
|
24
28
|
s.dependency 'DatadogSDKReactNative'
|
|
25
29
|
|
|
26
30
|
s.test_spec 'Tests' do |test_spec|
|
|
@@ -31,16 +35,23 @@ Pod::Spec.new do |s|
|
|
|
31
35
|
test_spec.platforms = { :ios => "13.4", :tvos => "13.4" }
|
|
32
36
|
end
|
|
33
37
|
|
|
38
|
+
xcconfig = {
|
|
39
|
+
"HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/react-native-webview/**"
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
# This guard prevents installing the dependencies when we run `pod install` in the old architecture.
|
|
36
43
|
# The `install_modules_dependencies` function is only available from RN 0.71, the new architecture is not
|
|
37
44
|
# supported on earlier RN versions.
|
|
38
45
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
39
|
-
|
|
46
|
+
|
|
47
|
+
xcconfig.merge!({
|
|
40
48
|
"DEFINES_MODULE" => "YES",
|
|
41
|
-
"OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1"
|
|
42
|
-
|
|
49
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1",
|
|
50
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
51
|
+
})
|
|
43
52
|
|
|
44
53
|
install_modules_dependencies(s)
|
|
45
54
|
end
|
|
55
|
+
|
|
56
|
+
s.pod_target_xcconfig = xcconfig
|
|
46
57
|
end
|
package/android/build.gradle
CHANGED
|
@@ -189,7 +189,7 @@ dependencies {
|
|
|
189
189
|
implementation "com.facebook.react:react-android:$reactNativeVersion"
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
implementation "com.datadoghq:dd-sdk-android-webview:2.
|
|
192
|
+
implementation "com.datadoghq:dd-sdk-android-webview:2.19.2"
|
|
193
193
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
194
194
|
|
|
195
195
|
implementation project(path: ':datadog_mobile-react-native')
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
#import <DatadogSDKReactNative/DatadogSDKReactNative-umbrella.h>
|
|
9
9
|
#import "RCTDatadogWebViewManager.h"
|
|
10
10
|
#import "RCTDatadogWebView.h"
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
#if __has_include("DatadogSDKReactNativeWebView-Swift.h")
|
|
13
|
+
#import <DatadogSDKReactNativeWebView-Swift.h>
|
|
14
|
+
#else
|
|
15
|
+
#import <DatadogSDKReactNativeWebView/DatadogSDKReactNativeWebView-Swift.h>
|
|
16
|
+
#endif
|
|
12
17
|
|
|
13
18
|
@interface RCTDatadogWebViewManager () <RNCWebViewDelegate, RCTDatadogWebViewDelegate>
|
|
14
19
|
@property (nonatomic, strong) NSMutableSet *allowedHosts;
|
package/lib/commonjs/index.js
CHANGED
|
@@ -13,8 +13,7 @@ var _envUtils = require("./utils/env-utils");
|
|
|
13
13
|
var _webviewJsUtils = require("./utils/webview-js-utils");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
function
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
17
|
/*
|
|
19
18
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
20
19
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeWebview","require","_react","_interopRequireWildcard","_NativeDdLogs","_interopRequireDefault","_NativeDdSdk","_NativeDdWebView","_envUtils","_webviewJsUtils","_jsxRuntime","e","__esModule","default","
|
|
1
|
+
{"version":3,"names":["_reactNativeWebview","require","_react","_interopRequireWildcard","_NativeDdLogs","_interopRequireDefault","_NativeDdSdk","_NativeDdWebView","_envUtils","_webviewJsUtils","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","useCallback","event","handleDatadogMessage","ddMessage","type","message","logUserCodeErrors","NativeDdLogs","error","NativeDdSdk","consumeWebviewEvent","nativeEvent","data","jsonMsg","JSON","parse","source","err","getInjectedJavascriptBeforeContentLoaded","isNewArchitecture","getWebViewEventBridgingJS","allowedHosts","injectedJavaScriptBeforeContentLoaded","wrapJsCodeInTryAndCatch","jsx","WebView","nativeConfig","component","NativeDdWebView","injectedJavaScript","exports","forwardRef","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAMA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AAGkC,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAI,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,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EAAEJ,wCAAwC,CAAC,CAAE;IAClFrB,GAAG,EAAEA;EAAI,CACZ,CAAC;AAEV,CAAC;AAEM,MAAM4B,OAAO,GAAAK,OAAA,CAAAL,OAAA,gBAAG,IAAAM,iBAAU,EAACpC,gBAAgB,CAAC;;AAEnD;AAAA,IAAAqC,QAAA,GAAAF,OAAA,CAAApD,OAAA,GACe+C,OAAO","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-webview",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "A client-side React Native module to interact with react-native-webview and Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"javaPackageName": "com.datadog.reactnative.webview"
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "a864b56f9adf689b4e65cd463529a03ba51cafc8"
|
|
98
98
|
}
|
|
@@ -9,6 +9,7 @@ import { WebView as RNWebView } from 'react-native-webview';
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
|
|
11
11
|
import { WebView } from '../index';
|
|
12
|
+
import { isNewArchitecture } from '../utils/env-utils';
|
|
12
13
|
|
|
13
14
|
import { dedent } from './__utils__/string-utils';
|
|
14
15
|
|
|
@@ -166,19 +167,51 @@ describe('Webview', () => {
|
|
|
166
167
|
mockedWebView.mock.calls[0][0]
|
|
167
168
|
.injectedJavaScriptBeforeContentLoaded ?? ''
|
|
168
169
|
);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
let expected;
|
|
171
|
+
|
|
172
|
+
if (isNewArchitecture()) {
|
|
173
|
+
expected = dedent(`
|
|
174
|
+
window.DatadogEventBridge = {
|
|
175
|
+
send(msg) {
|
|
176
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
177
|
+
source: 'DATADOG',
|
|
178
|
+
type: 'NATIVE_EVENT',
|
|
179
|
+
message: msg
|
|
180
|
+
}));
|
|
181
|
+
true;
|
|
182
|
+
},
|
|
183
|
+
getAllowedWebViewHosts() {
|
|
184
|
+
return '["localhost","example.com"]'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
try{
|
|
188
|
+
testInjectedJavaScript()
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
192
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
193
|
+
source: 'DATADOG',
|
|
194
|
+
type: 'ERROR',
|
|
195
|
+
message: errorMsg
|
|
196
|
+
}));
|
|
197
|
+
true;
|
|
198
|
+
}
|
|
199
|
+
`);
|
|
200
|
+
} else {
|
|
201
|
+
expected = dedent(`
|
|
202
|
+
try{
|
|
203
|
+
testInjectedJavaScript()
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
207
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
208
|
+
source: 'DATADOG',
|
|
209
|
+
type: 'ERROR',
|
|
210
|
+
message: errorMsg
|
|
211
|
+
}));
|
|
212
|
+
true;
|
|
213
|
+
}`);
|
|
214
|
+
}
|
|
182
215
|
|
|
183
216
|
expect(realInjectedJs).toBe(expected);
|
|
184
217
|
});
|