diff --git a/android/capacitor/src/main/assets/native-bridge.js b/android/capacitor/src/main/assets/native-bridge.js index 2d0f96e711..b0ab4993a4 100644 --- a/android/capacitor/src/main/assets/native-bridge.js +++ b/android/capacitor/src/main/assets/native-bridge.js @@ -167,21 +167,6 @@ const nativeBridge = (function (exports) { win.Capacitor = cap; win.Ionic.WebView = IonicWebView; }; - const safeStringify = (value) => { - const seen = new Set(); - return JSON.stringify(value, (_k, v) => { - if (seen.has(v)) { - if (v === null) - return null; - else - return '...'; - } - if (typeof v === 'object') { - seen.add(v); - } - return v; - }); - }; const initLogger = (win, cap) => { const BRIDGED_CONSOLE_METHODS = [ 'debug', @@ -248,7 +233,7 @@ const nativeBridge = (function (exports) { const serializeConsoleMessage = (msg) => { if (typeof msg === 'object') { try { - msg = safeStringify(msg); + msg = JSON.stringify(msg); } catch (e) { // ignore @@ -317,7 +302,7 @@ const nativeBridge = (function (exports) { postToNative = data => { var _a; try { - win.androidBridge.postMessage(safeStringify(data)); + win.androidBridge.postMessage(JSON.stringify(data)); } catch (e) { (_a = win === null || win === void 0 ? void 0 : win.console) === null || _a === void 0 ? void 0 : _a.error(e); @@ -348,7 +333,7 @@ const nativeBridge = (function (exports) { url: url, line: lineNo, col: columnNo, - errorObject: safeStringify(err), + errorObject: JSON.stringify(err), }, }; if (err !== null) { diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 4c71b8e91e..49505ab583 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -196,20 +196,6 @@ const initBridge = (w: any): void => { win.Ionic.WebView = IonicWebView; }; - const safeStringify = (value: any): string => { - const seen = new Set(); - return JSON.stringify(value, (_k, v) => { - if (seen.has(v)) { - if (v === null) return null; - else return '...'; - } - if (typeof v === 'object') { - seen.add(v); - } - return v; - }); - }; - const initLogger = (win: WindowCapacitor, cap: CapacitorInstance) => { const BRIDGED_CONSOLE_METHODS: (keyof Console)[] = [ 'debug', @@ -291,7 +277,7 @@ const initBridge = (w: any): void => { const serializeConsoleMessage = (msg: any): string => { if (typeof msg === 'object') { try { - msg = safeStringify(msg); + msg = JSON.stringify(msg); } catch (e) { // ignore } @@ -378,7 +364,7 @@ const initBridge = (w: any): void => { // android platform postToNative = data => { try { - win.androidBridge.postMessage(safeStringify(data)); + win.androidBridge.postMessage(JSON.stringify(data)); } catch (e) { win?.console?.error(e); } @@ -408,7 +394,7 @@ const initBridge = (w: any): void => { url: url, line: lineNo, col: columnNo, - errorObject: safeStringify(err), + errorObject: JSON.stringify(err), }, }; diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index 2d0f96e711..b0ab4993a4 100644 --- a/ios/Capacitor/Capacitor/assets/native-bridge.js +++ b/ios/Capacitor/Capacitor/assets/native-bridge.js @@ -167,21 +167,6 @@ const nativeBridge = (function (exports) { win.Capacitor = cap; win.Ionic.WebView = IonicWebView; }; - const safeStringify = (value) => { - const seen = new Set(); - return JSON.stringify(value, (_k, v) => { - if (seen.has(v)) { - if (v === null) - return null; - else - return '...'; - } - if (typeof v === 'object') { - seen.add(v); - } - return v; - }); - }; const initLogger = (win, cap) => { const BRIDGED_CONSOLE_METHODS = [ 'debug', @@ -248,7 +233,7 @@ const nativeBridge = (function (exports) { const serializeConsoleMessage = (msg) => { if (typeof msg === 'object') { try { - msg = safeStringify(msg); + msg = JSON.stringify(msg); } catch (e) { // ignore @@ -317,7 +302,7 @@ const nativeBridge = (function (exports) { postToNative = data => { var _a; try { - win.androidBridge.postMessage(safeStringify(data)); + win.androidBridge.postMessage(JSON.stringify(data)); } catch (e) { (_a = win === null || win === void 0 ? void 0 : win.console) === null || _a === void 0 ? void 0 : _a.error(e); @@ -348,7 +333,7 @@ const nativeBridge = (function (exports) { url: url, line: lineNo, col: columnNo, - errorObject: safeStringify(err), + errorObject: JSON.stringify(err), }, }; if (err !== null) {