@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.
@@ -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
- exports.NativeDdSdk = NativeDdSdk;
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,"sources":["NativeDdSdk.ts"],"names":["NativeDdSdk","TurboModuleRegistry","get"],"mappings":";;;;;;;AAOA;;AAPA;AACA;AACA;AACA;AACA;AAaO,MAAMA,WAAW,GAAGC,iCAAoBC,GAApB,CACvB,OADuB,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 */\n\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\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 spec file so we don't end up with a duplicate definition of the native module.\n */\nexport interface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n}\nexport const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>(\n 'DdSdk'\n);\n"]}
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) {// Do nothing
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,"sources":["formatAllowedHosts.ts"],"names":["formatAllowedHosts","allowedHosts","JSON","stringify","e","NativeDdSdk","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"mappings":";;;;;;;AAKA;;AALA;AACA;AACA;AACA;AACA;AAGO,SAASA,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIC,wBAAJ,EAAiB;AACbA,+BAAYC,cAAZ,CACIC,eAAe,CAACH,CAAD,CADnB,EAEII,kBAAkB,CAACJ,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;;AAEA,MAAMK,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOhB,CAAP,EAAU,CACR;AACH;;AACD,SAAOW,KAAP;AACH,CA3BD","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 { NativeDdSdk } from '../NativeDdSdk';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeDdSdk) {\n NativeDdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
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;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AAU,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,"sources":["getInjectedJavaScriptBeforeContentLoaded.ts"],"names":["DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","allowedHosts","injectedJavaScriptBeforeContentLoaded"],"mappings":";;;;;;;AAKA;;AALA;AACA;AACA;AACA;AACA;AAGO,MAAMA,sBAAsB,GAAG,WAA/B;;;AAEA,MAAMC,wCAAwC,GAAG,CACpDC,YADoD,EAEpDC,qCAFoD,KAInD;AACL;AACA;AACA,iDAAiDH,sBAAuB;AACxE;AACA;AACA,iBAAiB,4CAAmBE,YAAnB,CAAiC;AAClD;AACA;AACA;AACA,QAAQC,qCAAsC;AAC9C;AACA;AACA;AACA;AACA,GAnBO","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 { formatAllowedHosts } from './formatAllowedHosts';\n\nexport const DATADOG_MESSAGE_PREFIX = '[DATADOG]';\n\nexport const getInjectedJavaScriptBeforeContentLoaded = (\n allowedHosts?: string[],\n injectedJavaScriptBeforeContentLoaded?: string\n): string =>\n `\n window.DatadogEventBridge = {\n send(msg) {\n window.ReactNativeWebView.postMessage(\"${DATADOG_MESSAGE_PREFIX} \" + msg)\n },\n getAllowedWebViewHosts() {\n return ${formatAllowedHosts(allowedHosts)}\n }\n };\n try{ \n ${injectedJavaScriptBeforeContentLoaded}\n }\n catch (error) {\n // The user defined code has crashed\n }\n `;\n"]}
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":[]}
@@ -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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- 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); }
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 === null || _NativeDdSdk.NativeDdSdk === void 0 ? void 0 : _NativeDdSdk.NativeDdSdk.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
25
+ _NativeDdSdk.NativeDdSdk?.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
29
26
  } else {
30
- userDefinedOnMessage === null || userDefinedOnMessage === void 0 ? void 0 : userDefinedOnMessage(event);
27
+ userDefinedOnMessage?.(event);
31
28
  }
32
29
  }, [userDefinedOnMessage]);
33
- return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, _extends({}, props, {
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
- const WebView = /*#__PURE__*/(0, _react.forwardRef)(WebViewComponent);
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,"sources":["index.tsx"],"names":["WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","WebView"],"mappings":";;;;;;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,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,mHAAaC,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,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAE,wFACnCH,KAAK,CAACc,YAD6B,EAEnCd,KAAK,CAACe,qCAF6B,CAH3C;AAOI,IAAA,GAAG,EAAEd;AAPT,KADJ;AAWH,CA1BD;;AA4BO,MAAMe,OAAO,gBAAG,uBAAWjB,gBAAX,CAAhB;;eAEQiB,O","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 React, { forwardRef, useCallback } from 'react';\n\nimport { NativeDdSdk } from './NativeDdSdk';\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<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 ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n"]}
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,QAAA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EACD,oBACI,IAAAxB,WAAA,CAAAqC,GAAA,EAAC3C,mBAAA,CAAA4C,OAAS;IAAA,GACFhB,KAAK;IACTG,SAAS,EAAEA,SAAU;IACrBc,qCAAqC,EAAE,IAAAC,kFAAwC,EAC3ElB,KAAK,CAACmB,YAAY,EAClBnB,KAAK,CAACiB,qCACV,CAAE;IACFhB,GAAG,EAAEA;EAAI,CACZ,CAAC;AAEV,CAAC;AAEM,MAAMe,OAAO,GAAAI,OAAA,CAAAJ,OAAA,gBAAG,IAAAK,iBAAU,EAACtB,gBAAgB,CAAC;AAAC,IAAAuB,QAAA,GAAAF,OAAA,CAAAnC,OAAA,GAErC+B,OAAO","ignoreList":[]}
@@ -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,"sources":["NativeDdSdk.ts"],"names":["TurboModuleRegistry","NativeDdSdk","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;AACA;;AAKA,OAAO,MAAMC,WAAW,GAAGD,mBAAmB,CAACE,GAApB,CACvB,OADuB,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 */\n\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\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 spec file so we don't end up with a duplicate definition of the native module.\n */\nexport interface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n}\nexport const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>(\n 'DdSdk'\n);\n"]}
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) {// Do nothing
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,"sources":["formatAllowedHosts.ts"],"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,gBAA5B;AAEA,OAAO,SAASC,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIL,WAAJ,EAAiB;AACbA,MAAAA,WAAW,CAACM,cAAZ,CACIC,eAAe,CAACF,CAAD,CADnB,EAEIG,kBAAkB,CAACH,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;AAEA,MAAMI,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOf,CAAP,EAAU,CACR;AACH;;AACD,SAAOU,KAAP;AACH,CA3BD","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 { NativeDdSdk } from '../NativeDdSdk';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeDdSdk) {\n NativeDdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
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,MA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,SAAS,IAAIP,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,"sources":["getInjectedJavaScriptBeforeContentLoaded.ts"],"names":["formatAllowedHosts","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","allowedHosts","injectedJavaScriptBeforeContentLoaded"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,QAAmC,sBAAnC;AAEA,OAAO,MAAMC,sBAAsB,GAAG,WAA/B;AAEP,OAAO,MAAMC,wCAAwC,GAAG,CACpDC,YADoD,EAEpDC,qCAFoD,KAInD;AACL;AACA;AACA,iDAAiDH,sBAAuB;AACxE;AACA;AACA,iBAAiBD,kBAAkB,CAACG,YAAD,CAAe;AAClD;AACA;AACA;AACA,QAAQC,qCAAsC;AAC9C;AACA;AACA;AACA;AACA,GAnBO","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 { formatAllowedHosts } from './formatAllowedHosts';\n\nexport const DATADOG_MESSAGE_PREFIX = '[DATADOG]';\n\nexport const getInjectedJavaScriptBeforeContentLoaded = (\n allowedHosts?: string[],\n injectedJavaScriptBeforeContentLoaded?: string\n): string =>\n `\n window.DatadogEventBridge = {\n send(msg) {\n window.ReactNativeWebView.postMessage(\"${DATADOG_MESSAGE_PREFIX} \" + msg)\n },\n getAllowedWebViewHosts() {\n return ${formatAllowedHosts(allowedHosts)}\n }\n };\n try{ \n ${injectedJavaScriptBeforeContentLoaded}\n }\n catch (error) {\n // The user defined code has crashed\n }\n `;\n"]}
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":[]}
@@ -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 === null || NativeDdSdk === void 0 ? void 0 : NativeDdSdk.consumeWebviewEvent(message.substring(DATADOG_MESSAGE_PREFIX.length + 1));
17
+ NativeDdSdk?.consumeWebviewEvent(message.substring(DATADOG_MESSAGE_PREFIX.length + 1));
20
18
  } else {
21
- userDefinedOnMessage === null || userDefinedOnMessage === void 0 ? void 0 : userDefinedOnMessage(event);
19
+ userDefinedOnMessage?.(event);
22
20
  }
23
21
  }, [userDefinedOnMessage]);
24
- return /*#__PURE__*/React.createElement(RNWebView, _extends({}, props, {
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
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["WebView","RNWebView","React","forwardRef","useCallback","NativeDdSdk","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO,IAAIC,SAApB,QAAqC,sBAArC;AACA,OAAOC,KAAP,IAAgBC,UAAhB,EAA4BC,WAA5B,QAA+C,OAA/C;AAEA,SAASC,WAAT,QAA4B,eAA5B;AACA,SACIC,sBADJ,EAEIC,wCAFJ,QAGO,sDAHP;;AAUA,MAAMC,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAnC;AACA,QAAMA,SAAS,GAAGR,WAAW,CACxBS,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBX,sBAAnB,CAAJ,EAAgD;AAC5CD,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEa,mBAAb,CACIJ,OAAO,CAACK,SAAR,CAAkBb,sBAAsB,CAACc,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHT,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVwB,EAWzB,CAACF,oBAAD,CAXyB,CAA7B;AAaA,sBACI,oBAAC,SAAD,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAEL,wCAAwC,CAC3EE,KAAK,CAACY,YADqE,EAE3EZ,KAAK,CAACa,qCAFqE,CAHnF;AAOI,IAAA,GAAG,EAAEZ;AAPT,KADJ;AAWH,CA1BD;;AA4BA,OAAO,MAAMV,OAAO,gBAAGG,UAAU,CAACK,gBAAD,CAA1B;AAEP,eAAeR,OAAf","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 React, { forwardRef, useCallback } from 'react';\n\nimport { NativeDdSdk } from './NativeDdSdk';\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<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 ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n"]}
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":[]}
@@ -8,3 +8,4 @@ export interface PartialNativeDdSdkSpec extends TurboModule {
8
8
  telemetryError(message: string, stack: string, kind: string): Promise<void>;
9
9
  }
10
10
  export declare const NativeDdSdk: PartialNativeDdSdkSpec | null;
11
+ //# sourceMappingURL=NativeDdSdk.d.ts.map
@@ -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"}
@@ -1 +1,2 @@
1
1
  export declare function formatAllowedHosts(allowedHosts?: string[]): string;
2
+ //# sourceMappingURL=formatAllowedHosts.d.ts.map
@@ -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"}
@@ -10,3 +10,4 @@ export declare const WebView: React.ForwardRefExoticComponent<import("react-nati
10
10
  injectedJavaScriptBeforeContentLoaded?: string | undefined;
11
11
  } & React.RefAttributes<RNWebView<Props>>>;
12
12
  export default WebView;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -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.0",
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.17.1"
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": "3717f76f94bb68f6d871f84e38db5ba606eb7b06"
79
+ "gitHead": "5630e332e53904502cacc07d15012ce3009b2a55"
80
80
  }