@datadog/mobile-react-native-webview 2.4.0 → 2.4.2
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/NativeDdSdk.js +6 -4
- package/lib/commonjs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/__utils__/formatAllowedHosts.js +4 -11
- package/lib/commonjs/__utils__/formatAllowedHosts.js.map +1 -1
- package/lib/commonjs/__utils__/getInjectedJavaScriptBeforeContentLoaded.js +1 -5
- package/lib/commonjs/__utils__/getInjectedJavaScriptBeforeContentLoaded.js.map +1 -1
- package/lib/commonjs/index.js +15 -20
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeDdSdk.js +2 -0
- package/lib/module/NativeDdSdk.js.map +1 -1
- package/lib/module/__utils__/formatAllowedHosts.js +3 -8
- package/lib/module/__utils__/formatAllowedHosts.js.map +1 -1
- package/lib/module/__utils__/getInjectedJavaScriptBeforeContentLoaded.js.map +1 -1
- package/lib/module/index.js +7 -9
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeDdSdk.d.ts +1 -0
- package/lib/typescript/NativeDdSdk.d.ts.map +1 -0
- package/lib/typescript/__utils__/formatAllowedHosts.d.ts +1 -0
- package/lib/typescript/__utils__/formatAllowedHosts.d.ts.map +1 -0
- package/lib/typescript/__utils__/getInjectedJavaScriptBeforeContentLoaded.d.ts +1 -0
- package/lib/typescript/__utils__/getInjectedJavaScriptBeforeContentLoaded.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NativeDdSdk = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
10
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
11
|
* Copyright 2016-Present Datadog, Inc.
|
|
14
12
|
*/
|
|
15
|
-
const NativeDdSdk = _reactNative.TurboModuleRegistry.get('DdSdk');
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* We have to redefine the spec for the Native SDK here to be able to use the new architecture.
|
|
16
|
+
* We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const NativeDdSdk = exports.NativeDdSdk = _reactNative.TurboModuleRegistry.get('DdSdk');
|
|
18
20
|
//# sourceMappingURL=NativeDdSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NativeDdSdk","exports","TurboModuleRegistry","get"],"sourceRoot":"../../src","sources":["NativeDdSdk.ts"],"mappings":";;;;;;AAOA,IAAAA,YAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,gCAAmB,CAACC,GAAG,CAC9C,OACJ,CAAC","ignoreList":[]}
|
|
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatAllowedHosts = formatAllowedHosts;
|
|
7
|
-
|
|
8
7
|
var _NativeDdSdk = require("../NativeDdSdk");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
10
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
11
|
* Copyright 2016-Present Datadog, Inc.
|
|
14
12
|
*/
|
|
13
|
+
|
|
15
14
|
function formatAllowedHosts(allowedHosts) {
|
|
16
15
|
try {
|
|
17
16
|
return `'${JSON.stringify(allowedHosts)}'`;
|
|
@@ -19,21 +18,18 @@ function formatAllowedHosts(allowedHosts) {
|
|
|
19
18
|
if (_NativeDdSdk.NativeDdSdk) {
|
|
20
19
|
_NativeDdSdk.NativeDdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return "'[]'";
|
|
24
22
|
}
|
|
25
23
|
}
|
|
24
|
+
|
|
26
25
|
/**
|
|
27
26
|
* The next section is copied from packages/core/src/errorUtils
|
|
28
27
|
*/
|
|
29
28
|
|
|
30
|
-
|
|
31
29
|
const EMPTY_MESSAGE = 'Unknown Error';
|
|
32
30
|
const EMPTY_STACK_TRACE = '';
|
|
33
|
-
|
|
34
31
|
const getErrorMessage = error => {
|
|
35
32
|
let message = EMPTY_MESSAGE;
|
|
36
|
-
|
|
37
33
|
if (error === undefined || error === null) {
|
|
38
34
|
message = EMPTY_MESSAGE;
|
|
39
35
|
} else if (typeof error === 'object' && 'message' in error) {
|
|
@@ -41,13 +37,10 @@ const getErrorMessage = error => {
|
|
|
41
37
|
} else {
|
|
42
38
|
message = String(error);
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
return message;
|
|
46
41
|
};
|
|
47
|
-
|
|
48
42
|
const getErrorStackTrace = error => {
|
|
49
43
|
let stack = EMPTY_STACK_TRACE;
|
|
50
|
-
|
|
51
44
|
try {
|
|
52
45
|
if (error === undefined || error === null) {
|
|
53
46
|
stack = EMPTY_STACK_TRACE;
|
|
@@ -64,9 +57,9 @@ const getErrorStackTrace = error => {
|
|
|
64
57
|
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
65
58
|
}
|
|
66
59
|
}
|
|
67
|
-
} catch (e) {
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// Do nothing
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
return stack;
|
|
71
64
|
};
|
|
72
65
|
//# sourceMappingURL=formatAllowedHosts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_NativeDdSdk","require","formatAllowedHosts","allowedHosts","JSON","stringify","e","NativeDdSdk","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"sourceRoot":"../../../src","sources":["__utils__/formatAllowedHosts.ts"],"mappings":";;;;;;AAKA,IAAAA,YAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;AACA;;AAGO,SAASC,kBAAkBA,CAACC,YAAuB,EAAU;EAChE,IAAI;IACA,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACF,YAAY,CAAC,GAAG;EAC9C,CAAC,CAAC,OAAOG,CAAM,EAAE;IACb,IAAIC,wBAAW,EAAE;MACbA,wBAAW,CAACC,cAAc,CACtBC,eAAe,CAACH,CAAC,CAAC,EAClBI,kBAAkB,CAACJ,CAAC,CAAC,EACrB,mBACJ,CAAC;IACL;IACA,OAAO,MAAM;EACjB;AACJ;;AAEA;AACA;AACA;;AAEA,MAAMK,aAAa,GAAG,eAAe;AACrC,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,MAAMH,eAAe,GAAII,KAAsB,IAAa;EACxD,IAAIC,OAAO,GAAGH,aAAa;EAC3B,IAAIE,KAAK,KAAKE,SAAS,IAAIF,KAAK,KAAK,IAAI,EAAE;IACvCC,OAAO,GAAGH,aAAa;EAC3B,CAAC,MAAM,IAAI,OAAOE,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAIA,KAAK,EAAE;IACxDC,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAO,CAAC;EACnC,CAAC,MAAM;IACHA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAAC;EAC3B;EAEA,OAAOC,OAAO;AAClB,CAAC;AAED,MAAMJ,kBAAkB,GAAIG,KAAsB,IAAa;EAC3D,IAAII,KAAK,GAAGL,iBAAiB;EAE7B,IAAI;IACA,IAAIC,KAAK,KAAKE,SAAS,IAAIF,KAAK,KAAK,IAAI,EAAE;MACvCI,KAAK,GAAGL,iBAAiB;IAC7B,CAAC,MAAM,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAClCI,KAAK,GAAGL,iBAAiB;IAC7B,CAAC,MAAM,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAClC,IAAI,YAAY,IAAIA,KAAK,EAAE;QACvBI,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAU,CAAC;MACpC,CAAC,MAAM,IAAI,OAAO,IAAIL,KAAK,EAAE;QACzBI,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAK,CAAC;MAC/B,CAAC,MAAM,IAAI,gBAAgB,IAAIJ,KAAK,EAAE;QAClCI,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAc,CAAC;MACxC,CAAC,MAAM,IACH,WAAW,IAAIN,KAAK,IACpB,MAAM,IAAIA,KAAK,IACf,QAAQ,IAAIA,KAAK,EACnB;QACEI,KAAK,GAAG,MAAMJ,KAAK,CAACO,SAAS,IAAIP,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACS,MAAM,EAAE;MACjE;IACJ;EACJ,CAAC,CAAC,OAAOhB,CAAC,EAAE;IACR;EAAA;EAEJ,OAAOW,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getInjectedJavaScriptBeforeContentLoaded = exports.DATADOG_MESSAGE_PREFIX = void 0;
|
|
7
|
-
|
|
8
7
|
var _formatAllowedHosts = require("./formatAllowedHosts");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
10
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
11
|
* Copyright 2016-Present Datadog, Inc.
|
|
14
12
|
*/
|
|
15
|
-
const DATADOG_MESSAGE_PREFIX = '[DATADOG]';
|
|
16
|
-
exports.DATADOG_MESSAGE_PREFIX = DATADOG_MESSAGE_PREFIX;
|
|
17
13
|
|
|
14
|
+
const DATADOG_MESSAGE_PREFIX = exports.DATADOG_MESSAGE_PREFIX = '[DATADOG]';
|
|
18
15
|
const getInjectedJavaScriptBeforeContentLoaded = (allowedHosts, injectedJavaScriptBeforeContentLoaded) => `
|
|
19
16
|
window.DatadogEventBridge = {
|
|
20
17
|
send(msg) {
|
|
@@ -31,6 +28,5 @@ const getInjectedJavaScriptBeforeContentLoaded = (allowedHosts, injectedJavaScri
|
|
|
31
28
|
// The user defined code has crashed
|
|
32
29
|
}
|
|
33
30
|
`;
|
|
34
|
-
|
|
35
31
|
exports.getInjectedJavaScriptBeforeContentLoaded = getInjectedJavaScriptBeforeContentLoaded;
|
|
36
32
|
//# sourceMappingURL=getInjectedJavaScriptBeforeContentLoaded.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_formatAllowedHosts","require","DATADOG_MESSAGE_PREFIX","exports","getInjectedJavaScriptBeforeContentLoaded","allowedHosts","injectedJavaScriptBeforeContentLoaded","formatAllowedHosts"],"sourceRoot":"../../../src","sources":["__utils__/getInjectedJavaScriptBeforeContentLoaded.ts"],"mappings":";;;;;;AAKA,IAAAA,mBAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;AACA;;AAGO,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,WAAW;AAE1C,MAAME,wCAAwC,GAAGA,CACpDC,YAAuB,EACvBC,qCAA8C,KAE9C;AACJ;AACA;AACA,iDAAiDJ,sBAAsB;AACvE;AACA;AACA,iBAAiB,IAAAK,sCAAkB,EAACF,YAAY,CAAC;AACjD;AACA;AACA;AACA,QAAQC,qCAAqC;AAC7C;AACA;AACA;AACA;AACA,GAAG;AAACH,OAAA,CAAAC,wCAAA,GAAAA,wCAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,41 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WebView = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNativeWebview = require("react-native-webview");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _NativeDdSdk = require("./NativeDdSdk");
|
|
13
|
-
|
|
14
10
|
var _getInjectedJavaScriptBeforeContentLoaded = require("./__utils__/getInjectedJavaScriptBeforeContentLoaded");
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
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; }
|
|
14
|
+
/*
|
|
15
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
16
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
17
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
18
|
+
*/
|
|
21
19
|
|
|
22
20
|
const WebViewComponent = (props, ref) => {
|
|
23
21
|
const userDefinedOnMessage = props.onMessage;
|
|
24
22
|
const onMessage = (0, _react.useCallback)(event => {
|
|
25
23
|
const message = event.nativeEvent.data;
|
|
26
|
-
|
|
27
24
|
if (message.startsWith(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX)) {
|
|
28
|
-
_NativeDdSdk.NativeDdSdk
|
|
25
|
+
_NativeDdSdk.NativeDdSdk?.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
|
|
29
26
|
} else {
|
|
30
|
-
userDefinedOnMessage
|
|
27
|
+
userDefinedOnMessage?.(event);
|
|
31
28
|
}
|
|
32
29
|
}, [userDefinedOnMessage]);
|
|
33
|
-
return /*#__PURE__*/
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeWebview.WebView, {
|
|
31
|
+
...props,
|
|
34
32
|
onMessage: onMessage,
|
|
35
33
|
injectedJavaScriptBeforeContentLoaded: (0, _getInjectedJavaScriptBeforeContentLoaded.getInjectedJavaScriptBeforeContentLoaded)(props.allowedHosts, props.injectedJavaScriptBeforeContentLoaded),
|
|
36
34
|
ref: ref
|
|
37
|
-
})
|
|
35
|
+
});
|
|
38
36
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.WebView = WebView;
|
|
42
|
-
var _default = WebView;
|
|
43
|
-
exports.default = _default;
|
|
37
|
+
const WebView = exports.WebView = /*#__PURE__*/(0, _react.forwardRef)(WebViewComponent);
|
|
38
|
+
var _default = exports.default = WebView;
|
|
44
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_reactNativeWebview","require","_react","_interopRequireWildcard","_NativeDdSdk","_getInjectedJavaScriptBeforeContentLoaded","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","useCallback","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","NativeDdSdk","consumeWebviewEvent","substring","length","jsx","WebView","injectedJavaScriptBeforeContentLoaded","getInjectedJavaScriptBeforeContentLoaded","allowedHosts","exports","forwardRef","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAMA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,yCAAA,GAAAJ,OAAA;AAG8D,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV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
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import { TurboModuleRegistry } from 'react-native';
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* We have to redefine the spec for the Native SDK here to be able to use the new architecture.
|
|
9
11
|
* We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","NativeDdSdk","get"],"sourceRoot":"../../src","sources":["NativeDdSdk.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAGA,SAASA,mBAAmB,QAAQ,cAAc;;AAElD;AACA;AACA;AACA;;AAKA,OAAO,MAAMC,WAAW,GAAGD,mBAAmB,CAACE,GAAG,CAC9C,OACJ,CAAC","ignoreList":[]}
|
|
@@ -11,20 +11,18 @@ export function formatAllowedHosts(allowedHosts) {
|
|
|
11
11
|
if (NativeDdSdk) {
|
|
12
12
|
NativeDdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
return "'[]'";
|
|
16
15
|
}
|
|
17
16
|
}
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* The next section is copied from packages/core/src/errorUtils
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
const EMPTY_MESSAGE = 'Unknown Error';
|
|
23
23
|
const EMPTY_STACK_TRACE = '';
|
|
24
|
-
|
|
25
24
|
const getErrorMessage = error => {
|
|
26
25
|
let message = EMPTY_MESSAGE;
|
|
27
|
-
|
|
28
26
|
if (error === undefined || error === null) {
|
|
29
27
|
message = EMPTY_MESSAGE;
|
|
30
28
|
} else if (typeof error === 'object' && 'message' in error) {
|
|
@@ -32,13 +30,10 @@ const getErrorMessage = error => {
|
|
|
32
30
|
} else {
|
|
33
31
|
message = String(error);
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
return message;
|
|
37
34
|
};
|
|
38
|
-
|
|
39
35
|
const getErrorStackTrace = error => {
|
|
40
36
|
let stack = EMPTY_STACK_TRACE;
|
|
41
|
-
|
|
42
37
|
try {
|
|
43
38
|
if (error === undefined || error === null) {
|
|
44
39
|
stack = EMPTY_STACK_TRACE;
|
|
@@ -55,9 +50,9 @@ const getErrorStackTrace = error => {
|
|
|
55
50
|
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
|
-
} catch (e) {
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// Do nothing
|
|
59
55
|
}
|
|
60
|
-
|
|
61
56
|
return stack;
|
|
62
57
|
};
|
|
63
58
|
//# sourceMappingURL=formatAllowedHosts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["NativeDdSdk","formatAllowedHosts","allowedHosts","JSON","stringify","e","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"sourceRoot":"../../../src","sources":["__utils__/formatAllowedHosts.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C,OAAO,SAASC,kBAAkBA,CAACC,YAAuB,EAAU;EAChE,IAAI;IACA,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACF,YAAY,CAAC,GAAG;EAC9C,CAAC,CAAC,OAAOG,CAAM,EAAE;IACb,IAAIL,WAAW,EAAE;MACbA,WAAW,CAACM,cAAc,CACtBC,eAAe,CAACF,CAAC,CAAC,EAClBG,kBAAkB,CAACH,CAAC,CAAC,EACrB,mBACJ,CAAC;IACL;IACA,OAAO,MAAM;EACjB;AACJ;;AAEA;AACA;AACA;;AAEA,MAAMI,aAAa,G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P,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACS,MAAM,EAAE;MACjE;IACJ;EACJ,CAAC,CAAC,OAAOf,CAAC,EAAE;IACR;EAAA;EAEJ,OAAOU,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["formatAllowedHosts","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","allowedHosts","injectedJavaScriptBeforeContentLoaded"],"sourceRoot":"../../../src","sources":["__utils__/getInjectedJavaScriptBeforeContentLoaded.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,MAAMC,sBAAsB,GAAG,WAAW;AAEjD,OAAO,MAAMC,wCAAwC,GAAGA,CACpDC,YAAuB,EACvBC,qCAA8C,KAE9C;AACJ;AACA;AACA,iDAAiDH,sBAAsB;AACvE;AACA;AACA,iBAAiBD,kBAAkB,CAACG,YAAY,CAAC;AACjD;AACA;AACA;AACA,QAAQC,qCAAqC;AAC7C;AACA;AACA;AACA;AACA,GAAG","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
5
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
6
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
5
|
*/
|
|
6
|
+
|
|
8
7
|
import { WebView as RNWebView } from 'react-native-webview';
|
|
9
8
|
import React, { forwardRef, useCallback } from 'react';
|
|
10
9
|
import { NativeDdSdk } from './NativeDdSdk';
|
|
11
10
|
import { DATADOG_MESSAGE_PREFIX, getInjectedJavaScriptBeforeContentLoaded } from './__utils__/getInjectedJavaScriptBeforeContentLoaded';
|
|
12
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
const WebViewComponent = (props, ref) => {
|
|
14
13
|
const userDefinedOnMessage = props.onMessage;
|
|
15
14
|
const onMessage = useCallback(event => {
|
|
16
15
|
const message = event.nativeEvent.data;
|
|
17
|
-
|
|
18
16
|
if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {
|
|
19
|
-
NativeDdSdk
|
|
17
|
+
NativeDdSdk?.consumeWebviewEvent(message.substring(DATADOG_MESSAGE_PREFIX.length + 1));
|
|
20
18
|
} else {
|
|
21
|
-
userDefinedOnMessage
|
|
19
|
+
userDefinedOnMessage?.(event);
|
|
22
20
|
}
|
|
23
21
|
}, [userDefinedOnMessage]);
|
|
24
|
-
return /*#__PURE__*/
|
|
22
|
+
return /*#__PURE__*/_jsx(RNWebView, {
|
|
23
|
+
...props,
|
|
25
24
|
onMessage: onMessage,
|
|
26
25
|
injectedJavaScriptBeforeContentLoaded: getInjectedJavaScriptBeforeContentLoaded(props.allowedHosts, props.injectedJavaScriptBeforeContentLoaded),
|
|
27
26
|
ref: ref
|
|
28
|
-
})
|
|
27
|
+
});
|
|
29
28
|
};
|
|
30
|
-
|
|
31
29
|
export const WebView = /*#__PURE__*/forwardRef(WebViewComponent);
|
|
32
30
|
export default WebView;
|
|
33
31
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["WebView","RNWebView","React","forwardRef","useCallback","NativeDdSdk","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","jsx","_jsx","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","consumeWebviewEvent","substring","length","injectedJavaScriptBeforeContentLoaded","allowedHosts"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,IAAIC,SAAS,QAAQ,sBAAsB;AAC3D,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,QAAQ,OAAO;AAEtD,SAASC,WAAW,QAAQ,eAAe;AAC3C,SACIC,sBAAsB,EACtBC,wCAAwC,QACrC,sDAAsD;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO9D,MAAMC,gBAAgB,GAAGA,CAACC,KAAY,EAAEC,GAAgC,KAAK;EACzE,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAS;EAC5C,MAAMA,SAAS,GAAGV,WAAW,CACxBW,KAA0B,IAAK;IAC5B,MAAMC,OAAO,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IACtC,IAAIF,OAAO,CAACG,UAAU,CAACb,sBAAsB,CAAC,EAAE;MAC5CD,WAAW,EAAEe,mBAAmB,CAC5BJ,OAAO,CAACK,SAAS,CAACf,sBAAsB,CAACgB,MAAM,GAAG,CAAC,CACvD,CAAC;IACL,CAAC,MAAM;MACHT,oBAAoB,GAAGE,KAAK,CAAC;IACjC;EACJ,CAAC,EACD,CAACF,oBAAoB,CACzB,CAAC;EACD,oBACIJ,IAAA,CAACR,SAAS;IAAA,GACFU,KAAK;IACTG,SAAS,EAAEA,SAAU;IACrBS,qCAAqC,EAAEhB,wCAAwC,CAC3EI,KAAK,CAACa,YAAY,EAClBb,KAAK,CAACY,qCACV,CAAE;IACFX,GAAG,EAAEA;EAAI,CACZ,CAAC;AAEV,CAAC;AAED,OAAO,MAAMZ,OAAO,gBAAGG,UAAU,CAACO,gBAAgB,CAAC;AAEnD,eAAeV,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeDdSdk.d.ts","sourceRoot":"","sources":["../../src/NativeDdSdk.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACvD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AACD,eAAO,MAAM,WAAW,+BAEvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAllowedHosts.d.ts","sourceRoot":"","sources":["../../../src/__utils__/formatAllowedHosts.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAalE"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const DATADOG_MESSAGE_PREFIX = "[DATADOG]";
|
|
2
2
|
export declare const getInjectedJavaScriptBeforeContentLoaded: (allowedHosts?: string[], injectedJavaScriptBeforeContentLoaded?: string) => string;
|
|
3
|
+
//# sourceMappingURL=getInjectedJavaScriptBeforeContentLoaded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInjectedJavaScriptBeforeContentLoaded.d.ts","sourceRoot":"","sources":["../../../src/__utils__/getInjectedJavaScriptBeforeContentLoaded.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD,eAAO,MAAM,wCAAwC,kBAClC,MAAM,EAAE,0CACiB,MAAM,KAC/C,MAgBA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAuB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAkC,MAAM,OAAO,CAAC;AAQvD,KAAK,KAAK,GAAG,YAAY,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,qCAAqC,CAAC,EAAE,MAAM,CAAC;CAClD,CAAC;AA8BF,eAAO,MAAM,OAAO;;;0CAA+B,CAAC;AAEpD,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-webview",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "A client-side React Native module to interact with react-native-webview and Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@testing-library/react-native": "7.0.2",
|
|
42
|
-
"react-native-builder-bob": "0.
|
|
42
|
+
"react-native-builder-bob": "0.26.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@datadog/mobile-react-native": "^2.0.1",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
]
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "5630e332e53904502cacc07d15012ce3009b2a55"
|
|
80
80
|
}
|