@datadog/mobile-react-native-webview 1.7.1 → 1.8.0-rc0
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/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +8 -2
- package/lib/module/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +12 -2
package/lib/commonjs/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const WebView = props => {
|
|
|
25
25
|
const message = event.nativeEvent.data;
|
|
26
26
|
|
|
27
27
|
if (message.startsWith(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX)) {
|
|
28
|
-
|
|
28
|
+
NativeDdSdk === null || NativeDdSdk === void 0 ? void 0 : NativeDdSdk.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
|
|
29
29
|
} else {
|
|
30
30
|
userDefinedOnMessage === null || userDefinedOnMessage === void 0 ? void 0 : userDefinedOnMessage(event);
|
|
31
31
|
}
|
|
@@ -38,5 +38,12 @@ const WebView = props => {
|
|
|
38
38
|
|
|
39
39
|
exports.WebView = WebView;
|
|
40
40
|
var _default = WebView;
|
|
41
|
+
/**
|
|
42
|
+
* We have to redefine the spec for the Native SDK here to be able to use the new architecture.
|
|
43
|
+
* We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
|
|
44
|
+
*/
|
|
45
|
+
|
|
41
46
|
exports.default = _default;
|
|
47
|
+
|
|
48
|
+
const NativeDdSdk = _reactNative.TurboModuleRegistry.get('DdSdk');
|
|
42
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["WebView","props","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["WebView","props","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","TurboModuleRegistry","get"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;;;;;;;;AAUO,MAAMA,OAAO,GAAIC,KAAD,IAAkB;AACrC,QAAMC,oBAAoB,GAAGD,KAAK,CAACE,SAAnC;AACA,QAAMA,SAAS,GAAG,wBACbC,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBC,gEAAnB,CAAJ,EAAgD;AAC5CC,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEC,mBAAb,CACIN,OAAO,CAACO,SAAR,CAAkBH,iEAAuBI,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHX,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVa,EAWd,CAACF,oBAAD,CAXc,CAAlB;AAaA,sBACI,6BAAC,2BAAD,eACQD,KADR;AAEI,IAAA,SAAS,EAAEE,SAFf;AAGI,IAAA,qCAAqC,EAAE,wFACnCF,KAAK,CAACa,YAD6B,EAEnCb,KAAK,CAACc,qCAF6B;AAH3C,KADJ;AAUH,CAzBM;;;eA2BQf,O;AAEf;AACA;AACA;AACA;;;;AAIA,MAAMU,WAAW,GAAGM,iCAAoBC,GAApB,CAAgD,OAAhD,CAApB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\nimport React, { useCallback } from 'react';\n\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nexport const WebView = (props: Props) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n />\n );\n};\n\nexport default WebView;\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n}\nconst NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -6,7 +6,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
8
|
import { WebView as RNWebView } from 'react-native-webview';
|
|
9
|
-
import {
|
|
9
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
10
10
|
import React, { useCallback } from 'react';
|
|
11
11
|
import { DATADOG_MESSAGE_PREFIX, getInjectedJavaScriptBeforeContentLoaded } from './__utils__/getInjectedJavaScriptBeforeContentLoaded';
|
|
12
12
|
export const WebView = props => {
|
|
@@ -15,7 +15,7 @@ export const WebView = props => {
|
|
|
15
15
|
const message = event.nativeEvent.data;
|
|
16
16
|
|
|
17
17
|
if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {
|
|
18
|
-
|
|
18
|
+
NativeDdSdk === null || NativeDdSdk === void 0 ? void 0 : NativeDdSdk.consumeWebviewEvent(message.substring(DATADOG_MESSAGE_PREFIX.length + 1));
|
|
19
19
|
} else {
|
|
20
20
|
userDefinedOnMessage === null || userDefinedOnMessage === void 0 ? void 0 : userDefinedOnMessage(event);
|
|
21
21
|
}
|
|
@@ -26,4 +26,10 @@ export const WebView = props => {
|
|
|
26
26
|
}));
|
|
27
27
|
};
|
|
28
28
|
export default WebView;
|
|
29
|
+
/**
|
|
30
|
+
* We have to redefine the spec for the Native SDK here to be able to use the new architecture.
|
|
31
|
+
* We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
const NativeDdSdk = TurboModuleRegistry.get('DdSdk');
|
|
29
35
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["WebView","RNWebView","
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["WebView","RNWebView","TurboModuleRegistry","React","useCallback","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","props","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","get"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO,IAAIC,SAApB,QAAqC,sBAArC;AAEA,SAASC,mBAAT,QAAoC,cAApC;AACA,OAAOC,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AAEA,SACIC,sBADJ,EAEIC,wCAFJ,QAGO,sDAHP;AAUA,OAAO,MAAMN,OAAO,GAAIO,KAAD,IAAkB;AACrC,QAAMC,oBAAoB,GAAGD,KAAK,CAACE,SAAnC;AACA,QAAMA,SAAS,GAAGL,WAAW,CACxBM,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBT,sBAAnB,CAAJ,EAAgD;AAC5CU,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEC,mBAAb,CACIL,OAAO,CAACM,SAAR,CAAkBZ,sBAAsB,CAACa,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHV,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVwB,EAWzB,CAACF,oBAAD,CAXyB,CAA7B;AAaA,sBACI,oBAAC,SAAD,eACQD,KADR;AAEI,IAAA,SAAS,EAAEE,SAFf;AAGI,IAAA,qCAAqC,EAAEH,wCAAwC,CAC3EC,KAAK,CAACY,YADqE,EAE3EZ,KAAK,CAACa,qCAFqE;AAHnF,KADJ;AAUH,CAzBM;AA2BP,eAAepB,OAAf;AAEA;AACA;AACA;AACA;;AAIA,MAAMe,WAAW,GAAGb,mBAAmB,CAACmB,GAApB,CAAgD,OAAhD,CAApB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\nimport React, { useCallback } from 'react';\n\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nexport const WebView = (props: Props) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n />\n );\n};\n\nexport default WebView;\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n}\nconst NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-webview",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-rc0",
|
|
4
4
|
"description": "A client-side React Native module to interact with react-native-webview and Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
]
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "ddc6223ac9ac6b2d03884db91d1ce22e8c68f756"
|
|
74
74
|
}
|
package/src/index.tsx
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';
|
|
7
7
|
import { WebView as RNWebView } from 'react-native-webview';
|
|
8
|
-
import {
|
|
8
|
+
import type { TurboModule } from 'react-native';
|
|
9
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
10
|
import React, { useCallback } from 'react';
|
|
10
11
|
|
|
11
12
|
import {
|
|
@@ -24,7 +25,7 @@ export const WebView = (props: Props) => {
|
|
|
24
25
|
(event: WebViewMessageEvent) => {
|
|
25
26
|
const message = event.nativeEvent.data;
|
|
26
27
|
if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {
|
|
27
|
-
|
|
28
|
+
NativeDdSdk?.consumeWebviewEvent(
|
|
28
29
|
message.substring(DATADOG_MESSAGE_PREFIX.length + 1)
|
|
29
30
|
);
|
|
30
31
|
} else {
|
|
@@ -46,3 +47,12 @@ export const WebView = (props: Props) => {
|
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
export default WebView;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* We have to redefine the spec for the Native SDK here to be able to use the new architecture.
|
|
53
|
+
* We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
|
|
54
|
+
*/
|
|
55
|
+
interface PartialNativeDdSdkSpec extends TurboModule {
|
|
56
|
+
consumeWebviewEvent(message: string): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');
|