noibu-react-native 0.2.35-rc.2 → 0.2.35-rc.3

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/dist/constants.js CHANGED
@@ -24,7 +24,7 @@ const CONTENT_TYPE = 'content-type';
24
24
  * Gets the script id from the cookie object, returns default if cannot be found
25
25
  */
26
26
  function GET_SCRIPT_ID() {
27
- return "1.0.104-rn-sdk-0.2.35-rc.2" ;
27
+ return "1.0.104-rn-sdk-0.2.35-rc.3" ;
28
28
  }
29
29
  /**
30
30
  * Gets the max metro recon number
@@ -3,8 +3,6 @@ import { Monitor, Singleton } from './BaseMonitor';
3
3
  export default class RequestMonitor extends Singleton implements Monitor {
4
4
  /** main method */
5
5
  monitor(): void;
6
- /** Decodes an ArrayBuffer into UTF-8 text. */
7
- private static decodeArrayBufferToText;
8
6
  /** Reads the response body once and returns both raw body and decoded text. */
9
7
  private static readResponseBody;
10
8
  /** Creates a fresh Response for the customer, preserving metadata. */
@@ -22,52 +22,34 @@ class RequestMonitor extends Singleton {
22
22
  RequestMonitor.setupGlobalXMLHttpWrapper();
23
23
  noibuLog('monitorRequests ended');
24
24
  }
25
- /** Decodes an ArrayBuffer into UTF-8 text. */
26
- static decodeArrayBufferToText(buffer) {
27
- try {
28
- if (typeof TextDecoder !== 'undefined') {
29
- return new TextDecoder('utf-8').decode(buffer);
30
- }
31
- }
32
- catch (_a) {
33
- // ignore and fall back to manual decode
34
- }
35
- const bytes = new Uint8Array(buffer);
36
- const chunkSize = 0x8000;
37
- let result = '';
38
- for (let i = 0; i < bytes.length; i += chunkSize) {
39
- const chunk = bytes.subarray(i, i + chunkSize);
40
- result += String.fromCharCode.apply(null, Array.from(chunk));
41
- }
42
- return result;
43
- }
44
25
  /** Reads the response body once and returns both raw body and decoded text. */
45
26
  static readResponseBody(response) {
46
27
  return __awaiter(this, void 0, void 0, function* () {
47
28
  if (!(response instanceof Response)) {
48
29
  return null;
49
30
  }
50
- const tryRead = (target) => __awaiter(this, void 0, void 0, function* () {
31
+ /**
32
+ * Read body as text only. In React Native's whatwg-fetch polyfill,
33
+ * arrayBuffer() is implemented via blob() which calls consumed() — setting
34
+ * bodyUsed — before the actual read. If the underlying FileReader fails,
35
+ * bodyUsed is already true and the text() fallback also fails. Using text()
36
+ * directly avoids this and also prevents the UTF-8 corruption caused by
37
+ * whatwg-fetch's byte-by-byte String.fromCharCode decoding of ArrayBuffers.
38
+ */
39
+ const tryReadText = (target) => __awaiter(this, void 0, void 0, function* () {
51
40
  try {
52
- const buffer = yield target.arrayBuffer();
53
- return { body: buffer, text: RequestMonitor.decodeArrayBufferToText(buffer) };
41
+ const text = yield target.text();
42
+ return { body: text, text };
54
43
  }
55
44
  catch (_a) {
56
- // Fall back to text() if arrayBuffer() is unsupported or fails
57
- try {
58
- const text = yield target.text();
59
- return { body: text, text };
60
- }
61
- catch (_b) {
62
- return null;
63
- }
45
+ return null;
64
46
  }
65
47
  });
66
48
  // Prefer reading from a clone to avoid mutating the original Response.
67
49
  try {
68
50
  if (!response.bodyUsed && typeof response.clone === 'function') {
69
51
  const clone = response.clone();
70
- const clonedResult = yield tryRead(clone);
52
+ const clonedResult = yield tryReadText(clone);
71
53
  if (clonedResult) {
72
54
  return clonedResult;
73
55
  }
@@ -79,7 +61,7 @@ class RequestMonitor extends Singleton {
79
61
  if (response.bodyUsed) {
80
62
  return null;
81
63
  }
82
- return tryRead(response);
64
+ return tryReadText(response);
83
65
  });
84
66
  }
85
67
  /** Creates a fresh Response for the customer, preserving metadata. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noibu-react-native",
3
- "version": "0.2.35-rc.2",
3
+ "version": "0.2.35-rc.3",
4
4
  "targetNjsVersion": "1.0.104",
5
5
  "description": "React-Native SDK for NoibuJS to collect errors in React-Native applications",
6
6
  "main": "dist/entry/index.js",