react-native-inapp-inspector 2.3.25 → 2.4.0

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.
Files changed (123) hide show
  1. package/README.md +26 -5
  2. package/dist/commonjs/components/AnalyticsDetail.js +9 -6
  3. package/dist/commonjs/components/AppHeaderLogo.js +4 -6
  4. package/dist/commonjs/components/Inspector/AnalyticsFilterModal.js +1 -1
  5. package/dist/commonjs/components/Inspector/AnalyticsTab.js +11 -15
  6. package/dist/commonjs/components/Inspector/ConsoleTab.js +11 -14
  7. package/dist/commonjs/components/Inspector/CrashDetail.js +7 -6
  8. package/dist/commonjs/components/Inspector/CrashTab.js +14 -14
  9. package/dist/commonjs/components/Inspector/DebuggingTab.js +6 -6
  10. package/dist/commonjs/components/Inspector/DeviceInfoTab.js +77 -43
  11. package/dist/commonjs/components/Inspector/FabLauncher.js +8 -9
  12. package/dist/commonjs/components/Inspector/InspectorHeader.js +93 -70
  13. package/dist/commonjs/components/Inspector/LogDetail.js +10 -7
  14. package/dist/commonjs/components/Inspector/MainScreen.js +67 -29
  15. package/dist/commonjs/components/Inspector/NetworkDetail.js +29 -28
  16. package/dist/commonjs/components/Inspector/NetworkFilterModal.js +1 -1
  17. package/dist/commonjs/components/Inspector/NetworkTab.js +87 -85
  18. package/dist/commonjs/components/Inspector/PushCard.d.ts +4 -0
  19. package/dist/commonjs/components/Inspector/PushCard.js +89 -0
  20. package/dist/commonjs/components/Inspector/PushDetail.d.ts +4 -0
  21. package/dist/commonjs/components/Inspector/PushDetail.js +190 -0
  22. package/dist/commonjs/components/Inspector/PushTab.d.ts +3 -0
  23. package/dist/commonjs/components/Inspector/PushTab.js +45 -0
  24. package/dist/commonjs/components/Inspector/ReduxDetail.js +16 -13
  25. package/dist/commonjs/components/Inspector/ReduxTab.js +13 -23
  26. package/dist/commonjs/components/Inspector/SettingsPanel.js +253 -105
  27. package/dist/commonjs/components/Inspector/StorageTab.js +35 -35
  28. package/dist/commonjs/components/Inspector/TabBar.js +9 -8
  29. package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +2 -2
  30. package/dist/commonjs/components/JsonViewer.js +77 -90
  31. package/dist/commonjs/components/ModuleErrorBoundary.d.ts +24 -0
  32. package/dist/commonjs/components/ModuleErrorBoundary.js +33 -0
  33. package/dist/commonjs/components/NetworkIcons.d.ts +3 -3
  34. package/dist/commonjs/components/NetworkIcons.js +10 -6
  35. package/dist/commonjs/components/SegmentedTabs.d.ts +4 -1
  36. package/dist/commonjs/components/SegmentedTabs.js +12 -8
  37. package/dist/commonjs/components/ShareButton.d.ts +11 -0
  38. package/dist/commonjs/components/ShareButton.js +6 -0
  39. package/dist/commonjs/constants/version.d.ts +1 -1
  40. package/dist/commonjs/constants/version.js +1 -1
  41. package/dist/commonjs/customHooks/crashHandler.js +4 -4
  42. package/dist/commonjs/customHooks/networkLogger.js +1 -1
  43. package/dist/commonjs/customHooks/pushNotificationLogger.d.ts +19 -0
  44. package/dist/commonjs/customHooks/pushNotificationLogger.js +1 -0
  45. package/dist/commonjs/helpers/memoryManager.d.ts +2 -1
  46. package/dist/commonjs/helpers/memoryManager.js +1 -1
  47. package/dist/commonjs/helpers/settingsStore.d.ts +1 -0
  48. package/dist/commonjs/helpers/settingsStore.js +1 -1
  49. package/dist/commonjs/helpers/shareFormatter.d.ts +13 -0
  50. package/dist/commonjs/helpers/shareFormatter.js +7 -0
  51. package/dist/commonjs/i18n/locales/en.json +1 -1
  52. package/dist/commonjs/index.d.ts +5 -2
  53. package/dist/commonjs/index.js +4 -4
  54. package/dist/commonjs/push.d.ts +4 -0
  55. package/dist/commonjs/push.js +1 -0
  56. package/dist/commonjs/types/enums.d.ts +30 -0
  57. package/dist/commonjs/types/enums.js +1 -1
  58. package/dist/commonjs/types/index.d.ts +10 -0
  59. package/dist/commonjs/types/interfaces.d.ts +63 -7
  60. package/dist/esm/components/AnalyticsDetail.js +28 -25
  61. package/dist/esm/components/AppHeaderLogo.js +5 -7
  62. package/dist/esm/components/Inspector/AnalyticsFilterModal.js +14 -14
  63. package/dist/esm/components/Inspector/AnalyticsTab.js +35 -39
  64. package/dist/esm/components/Inspector/ConsoleTab.js +50 -53
  65. package/dist/esm/components/Inspector/CrashDetail.js +11 -10
  66. package/dist/esm/components/Inspector/CrashTab.js +14 -14
  67. package/dist/esm/components/Inspector/DebuggingTab.js +10 -10
  68. package/dist/esm/components/Inspector/DeviceInfoTab.js +208 -174
  69. package/dist/esm/components/Inspector/FabLauncher.js +41 -42
  70. package/dist/esm/components/Inspector/InspectorHeader.js +138 -115
  71. package/dist/esm/components/Inspector/LogDetail.js +24 -21
  72. package/dist/esm/components/Inspector/MainScreen.js +100 -62
  73. package/dist/esm/components/Inspector/NetworkDetail.js +88 -87
  74. package/dist/esm/components/Inspector/NetworkFilterModal.js +8 -8
  75. package/dist/esm/components/Inspector/NetworkTab.js +136 -134
  76. package/dist/esm/components/Inspector/PushCard.d.ts +4 -0
  77. package/dist/esm/components/Inspector/PushCard.js +89 -0
  78. package/dist/esm/components/Inspector/PushDetail.d.ts +4 -0
  79. package/dist/esm/components/Inspector/PushDetail.js +190 -0
  80. package/dist/esm/components/Inspector/PushTab.d.ts +3 -0
  81. package/dist/esm/components/Inspector/PushTab.js +45 -0
  82. package/dist/esm/components/Inspector/ReduxDetail.js +40 -37
  83. package/dist/esm/components/Inspector/ReduxTab.js +103 -113
  84. package/dist/esm/components/Inspector/SettingsPanel.js +406 -258
  85. package/dist/esm/components/Inspector/StorageTab.js +158 -158
  86. package/dist/esm/components/Inspector/TabBar.js +28 -27
  87. package/dist/esm/components/Inspector/UpdateAvailableModal.js +1 -1
  88. package/dist/esm/components/JsonViewer.js +101 -114
  89. package/dist/esm/components/ModuleErrorBoundary.d.ts +24 -0
  90. package/dist/esm/components/ModuleErrorBoundary.js +33 -0
  91. package/dist/esm/components/NetworkIcons.d.ts +3 -3
  92. package/dist/esm/components/NetworkIcons.js +7 -3
  93. package/dist/esm/components/SegmentedTabs.d.ts +4 -1
  94. package/dist/esm/components/SegmentedTabs.js +12 -8
  95. package/dist/esm/components/ShareButton.d.ts +11 -0
  96. package/dist/esm/components/ShareButton.js +6 -0
  97. package/dist/esm/constants/version.d.ts +1 -1
  98. package/dist/esm/constants/version.js +1 -1
  99. package/dist/esm/customHooks/crashHandler.js +6 -6
  100. package/dist/esm/customHooks/networkLogger.js +1 -1
  101. package/dist/esm/customHooks/pushNotificationLogger.d.ts +19 -0
  102. package/dist/esm/customHooks/pushNotificationLogger.js +1 -0
  103. package/dist/esm/helpers/memoryManager.d.ts +2 -1
  104. package/dist/esm/helpers/memoryManager.js +1 -1
  105. package/dist/esm/helpers/settingsStore.d.ts +1 -0
  106. package/dist/esm/helpers/settingsStore.js +1 -1
  107. package/dist/esm/helpers/shareFormatter.d.ts +13 -0
  108. package/dist/esm/helpers/shareFormatter.js +7 -0
  109. package/dist/esm/i18n/locales/en.json +1 -1
  110. package/dist/esm/index.d.ts +5 -2
  111. package/dist/esm/index.js +7 -7
  112. package/dist/esm/push.d.ts +4 -0
  113. package/dist/esm/push.js +1 -0
  114. package/dist/esm/types/enums.d.ts +30 -0
  115. package/dist/esm/types/enums.js +1 -1
  116. package/dist/esm/types/index.d.ts +10 -0
  117. package/dist/esm/types/interfaces.d.ts +63 -7
  118. package/package.json +53 -10
  119. package/src/native/NativeInspector.ts +0 -1
  120. package/dist/commonjs/components/BrandSquareIcon.d.ts +0 -5
  121. package/dist/commonjs/components/BrandSquareIcon.js +0 -112
  122. package/dist/esm/components/BrandSquareIcon.d.ts +0 -5
  123. package/dist/esm/components/BrandSquareIcon.js +0 -112
@@ -1,7 +1,7 @@
1
- import{LogBox as M,NativeModules as v,TurboModuleRegistry as D,NativeEventEmitter as F,Platform as y,AppState as L,Dimensions as B}from"react-native";import{CrashExportFormat as A,CrashType as d}from"../types/enums";import{addLogFromCrash as H}from"./consoleLogger";import{showNativeFloatingButton as U,setNativeFloatingButtonBadge as _}from"../native/NativeInspector";import{t as s}from"../i18n";export{A as CrashExportFormat};let E=[],k=!1,R=0,l=[],g=[];const I=50;let S=100;const T=Date.now();let N=!1;export const setCrashModuleEnabled=e=>{N=e},getCrashModuleEnabled=()=>N,setMaxCrashLogsLimit=e=>{S=Math.max(10,e),l.length>S&&(l=l.slice(0,S))},getMaxCrashLogsLimit=()=>S,pruneCrashRecords=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(l.length/2),n=l.length-t;return n>0&&(l=l.slice(0,t)),g.length>20&&(g=g.slice(0,20)),Math.max(0,n)},addCrashBreadcrumb=(e,t,n)=>{if(N)try{const o={type:e,message:t,timestamp:Date.now(),data:n};g.unshift(o),g.length>I&&(g=g.slice(0,I))}catch{}},recordNavigationBreadcrumb=(e,t)=>{addCrashBreadcrumb("navigation",s("crash.breadcrumbNavigation",{from:e||"/",to:t||"/"}),{from:e,to:t})},recordNetworkBreadcrumb=(e,t,n,o)=>{const r=n!=null?` [${n}]`:"",a=o!=null?` (${Math.round(o)}ms)`:"";addCrashBreadcrumb("network",`${t.toUpperCase()} ${e}${r}${a}`,{url:e,method:t,status:n,duration:o})},recordReduxBreadcrumb=(e,t)=>{addCrashBreadcrumb("redux",s("crash.breadcrumbAction",{actionType:e}),{type:e,payloadSummary:typeof t=="object"&&t!==null?Object.keys(t):typeof t})},recordUserActionBreadcrumb=(e,t)=>{addCrashBreadcrumb("user",e,t)},clearCrashBreadcrumbs=()=>{g=[]},getCrashBreadcrumbs=()=>[...g],parseCrashStackTrace=e=>{if(!e||typeof e!="string")return[];const t=e.split(`
2
- `),n=[];for(const o of t){const r=o.trim();if(!r||r.includes("crashHandler.ts")||r.includes("handleInterceptedCrash")||r.includes("addLogFromCrash")||r.includes("setupGlobalCrashHandler"))continue;const a=r.match(/^([^@]+)@(.*):(\d+):(\d+)$/);if(a){const[,c,i,u,m]=a,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("hermes")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(m,10),raw:r,isAppCode:x});continue}const h=r.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);if(h){const[,c,i,u,m]=h,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(m,10),raw:r,isAppCode:x});continue}const f=r.match(/^at\s+(.+):(\d+):(\d+)$/);if(f){const[,c,i,u]=f,m=c.split("?")[0].split("/").pop()||c,b=!c.includes("node_modules")&&!c.includes("react-native");n.push({method:"<anonymous>",file:m,lineNumber:parseInt(i,10),column:parseInt(u,10),raw:r,isAppCode:b});continue}const $=r.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);if($){const[,c,i,u]=$,m=!c.startsWith("com.facebook.react")&&!c.startsWith("android.");n.push({method:c,file:i,lineNumber:parseInt(u,10),column:0,raw:r,isAppCode:m});continue}const p=r.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);if(p){const[,c,i,u]=p,m=!c.startsWith("lib")&&!c.startsWith("Core")&&!c.startsWith("React");n.push({method:u,file:c,lineNumber:0,column:0,raw:r,isAppCode:m});continue}n.push({method:r.startsWith("at ")?r.slice(3):r,file:"runtime",lineNumber:0,column:0,raw:r,isAppCode:!1})}return n};const J=()=>{try{const e=globalThis.performance;if(e&&e.memory)return{usedJSHeapSize:Math.round(e.memory.usedJSHeapSize/(1024*1024)),totalJSHeapSize:Math.round(e.memory.totalJSHeapSize/(1024*1024))}}catch{}},P=()=>{try{const e=B.get("window");return`${Math.round(e.width)}x${Math.round(e.height)} (${e.scale}x)`}catch{return s("crash.unknown")}};export const computeCrashFingerprint=e=>{const t=e.type||"js",n=e.name||"Error",o=e.parsedStack&&e.parsedStack.length>0?e.parsedStack[0]:null,r=o?`${o.file}:${o.lineNumber}`:"unknown";return`${t}_${n}_${r}`},getCrashRecords=()=>[...l],clearCrashRecords=()=>{l=[],emitCrashEvent({error:null,message:"__CLEARED__",timestamp:Date.now()})},subscribeCrashEvents=e=>(E.push(e),()=>{E=E.filter(t=>t!==e)}),emitCrashEvent=e=>{if(e.message!=="__CLEARED__"){const t=Date.now();if(t-R<250)return;R=t}E.forEach(t=>{try{t(e)}catch{}})},handleInterceptedCrash=(e,t,n=!1,o,r)=>{try{const a=e instanceof Error||typeof e=="object"&&e!==null?e:new Error(String(e||s("crash.runtimeException"))),h=a.message||(typeof e=="string"?e:s("crash.runtimeException"));let f="";typeof t=="string"?f=t:Array.isArray(t)?f=t.map(C=>`at ${C.methodName||"<anonymous>"} (${C.file||"unknown"}:${C.lineNumber||0}:${C.column||0})`).join(`
3
- `):f=a.stack||new Error().stack||"";let $=o||d.Js;const p=h.toLowerCase();o||(p.includes("native")||p.includes("sigsegv")||p.includes("nsrange")||p.includes("nullpointerexception")||p.includes("fatal signal")?$=d.Native:p.includes("promise")||p.includes("unhandled rejection")||p.includes("unhandledrejection")?$=d.Promise:p.includes("render")||p.includes("errorboundary")||r?$=d.Render:$=d.Js);const c=new Date,i=c.toLocaleDateString(),u=c.toLocaleTimeString(),m=parseCrashStackTrace(f),b=H(a,`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${h}`,f,n),x=typeof globalThis.HermesInternal<"u",j=typeof globalThis.nativeFabricUIManager<"u",w={id:`crash_${Date.now()}_${Math.random().toString(36).substr(2,6)}`,error:a,isFatal:n,type:$,message:h,name:a.name||(n?s("crash.errorNameFatal"):s("crash.errorNameUnhandled")),stack:f,parsedStack:m,componentStack:r||void 0,timestamp:Date.now(),dateStr:i,timeStr:u,deviceInfo:{platform:y.OS,osVersion:String(y.Version),rnVersion:y.constants?.reactNativeVersion?`${y.constants.reactNativeVersion.major}.${y.constants.reactNativeVersion.minor}.${y.constants.reactNativeVersion.patch}`:s("crash.unknown"),isHermes:x,isFabric:j,appState:L.currentState||"active"},memoryInfo:J(),breadcrumbs:[...g],logId:b?.id};l.unshift(w),l.length>S&&(l=l.slice(0,S)),emitCrashEvent({error:a,isFatal:n,message:`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${h}`,stack:f,timestamp:Date.now(),logId:b?.id,crashRecord:w});try{U(),_(!0)}catch{}return w}catch{return{id:`crash_${Date.now()}`,isFatal:!0,type:d.Js,message:String(e||s("crash.unknownException")),timestamp:Date.now(),dateStr:new Date().toLocaleDateString(),timeStr:new Date().toLocaleTimeString()}}},recordCustomCrash=(e,t)=>handleInterceptedCrash(e,typeof e=="object"?e.stack:void 0,t?.isFatal??!1,t?.type||d.Custom,t?.componentStack),simulateTestCrash=(e=d.Js,t,n)=>{const o=new Error(t||z(e));return handleInterceptedCrash(e===d.Native?o.message:o,n||o.stack,e===d.Native,e,e===d.Render?V():void 0)};const z=e=>{switch(e){case"native":return s("crash.simNativeMessage");case"promise":return s("crash.simPromiseMessage");case"render":return s("crash.simRenderMessage");default:return s("crash.simJsMessage")}},V=()=>{try{const e=new Error;if(e.stack)return e.stack.split(`
1
+ import{LogBox as M,NativeModules as v,TurboModuleRegistry as D,NativeEventEmitter as F,Platform as y,AppState as L,Dimensions as B}from"react-native";import{CrashExportFormat as A,CrashType as m}from"../types/enums";import{addLogFromCrash as H}from"./consoleLogger";import{showNativeFloatingButton as U,setNativeFloatingButtonBadge as _}from"../native/NativeInspector";import{t as s}from"../i18n";export{A as CrashExportFormat};let E=[],k=!1,I=0,l=[],f=[];const R=50;let S=100;const T=Date.now();let N=!1;export const setCrashModuleEnabled=e=>{N=e},getCrashModuleEnabled=()=>N,setMaxCrashLogsLimit=e=>{S=Math.max(10,e),l.length>S&&(l=l.slice(0,S))},getMaxCrashLogsLimit=()=>S,pruneCrashRecords=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(l.length/2),n=l.length-t;return n>0&&(l=l.slice(0,t)),f.length>20&&(f=f.slice(0,20)),Math.max(0,n)},addCrashBreadcrumb=(e,t,n)=>{if(N)try{const o={type:e,message:t,timestamp:Date.now(),data:n};f.unshift(o),f.length>R&&(f=f.slice(0,R))}catch{}},recordNavigationBreadcrumb=(e,t)=>{addCrashBreadcrumb("navigation",s("crash.breadcrumbNavigation",{from:e||"/",to:t||"/"}),{from:e,to:t})},recordNetworkBreadcrumb=(e,t,n,o)=>{const r=n!=null?` [${n}]`:"",a=o!=null?` (${Math.round(o)}ms)`:"";addCrashBreadcrumb("network",`${t.toUpperCase()} ${e}${r}${a}`,{url:e,method:t,status:n,duration:o})},recordReduxBreadcrumb=(e,t)=>{addCrashBreadcrumb("redux",s("crash.breadcrumbAction",{actionType:e}),{type:e,payloadSummary:typeof t=="object"&&t!==null?Object.keys(t):typeof t})},recordUserActionBreadcrumb=(e,t)=>{addCrashBreadcrumb("user",e,t)},clearCrashBreadcrumbs=()=>{f=[]},getCrashBreadcrumbs=()=>[...f],parseCrashStackTrace=e=>{if(!e||typeof e!="string")return[];const t=e.split(`
2
+ `),n=[];for(const o of t){const r=o.trim();if(!r||r.includes("crashHandler.ts")||r.includes("handleInterceptedCrash")||r.includes("addLogFromCrash")||r.includes("setupGlobalCrashHandler"))continue;const a=r.match(/^([^@]+)@(.*):(\d+):(\d+)$/);if(a){const[,c,i,u,g]=a,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("hermes")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(g,10),raw:r,isAppCode:x});continue}const d=r.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);if(d){const[,c,i,u,g]=d,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(g,10),raw:r,isAppCode:x});continue}const h=r.match(/^at\s+(.+):(\d+):(\d+)$/);if(h){const[,c,i,u]=h,g=c.split("?")[0].split("/").pop()||c,b=!c.includes("node_modules")&&!c.includes("react-native");n.push({method:"<anonymous>",file:g,lineNumber:parseInt(i,10),column:parseInt(u,10),raw:r,isAppCode:b});continue}const $=r.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);if($){const[,c,i,u]=$,g=!c.startsWith("com.facebook.react")&&!c.startsWith("android.");n.push({method:c,file:i,lineNumber:parseInt(u,10),column:0,raw:r,isAppCode:g});continue}const p=r.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);if(p){const[,c,,i]=p,u=!c.startsWith("lib")&&!c.startsWith("Core")&&!c.startsWith("React");n.push({method:i,file:c,lineNumber:0,column:0,raw:r,isAppCode:u});continue}n.push({method:r.startsWith("at ")?r.slice(3):r,file:"runtime",lineNumber:0,column:0,raw:r,isAppCode:!1})}return n};const J=()=>{try{const e=globalThis.performance;if(e&&e.memory)return{usedJSHeapSize:Math.round(e.memory.usedJSHeapSize/(1024*1024)),totalJSHeapSize:Math.round(e.memory.totalJSHeapSize/(1024*1024))}}catch{}},z=()=>{try{const e=B.get("window");return`${Math.round(e.width)}x${Math.round(e.height)} (${e.scale}x)`}catch{return s("crash.unknown")}};export const computeCrashFingerprint=e=>{const t=e.type||"js",n=e.name||"Error",o=e.parsedStack&&e.parsedStack.length>0?e.parsedStack[0]:null,r=o?`${o.file}:${o.lineNumber}`:"unknown";return`${t}_${n}_${r}`},getCrashRecords=()=>[...l],clearCrashRecords=()=>{l=[],emitCrashEvent({error:null,message:"__CLEARED__",timestamp:Date.now()})},subscribeCrashEvents=e=>(E.push(e),()=>{E=E.filter(t=>t!==e)}),emitCrashEvent=e=>{if(e.message!=="__CLEARED__"){const t=Date.now();if(t-I<250)return;I=t}E.forEach(t=>{try{t(e)}catch{}})},handleInterceptedCrash=(e,t,n=!1,o,r)=>{try{const a=e instanceof Error||typeof e=="object"&&e!==null?e:new Error(String(e||s("crash.runtimeException"))),d=a.message||(typeof e=="string"?e:s("crash.runtimeException"));let h="";typeof t=="string"?h=t:Array.isArray(t)?h=t.map(C=>`at ${C.methodName||"<anonymous>"} (${C.file||"unknown"}:${C.lineNumber||0}:${C.column||0})`).join(`
3
+ `):h=a.stack||new Error().stack||"";let $=o||m.Js;const p=d.toLowerCase();o||(p.includes("native")||p.includes("sigsegv")||p.includes("nsrange")||p.includes("nullpointerexception")||p.includes("fatal signal")?$=m.Native:p.includes("promise")||p.includes("unhandled rejection")||p.includes("unhandledrejection")?$=m.Promise:p.includes("render")||p.includes("errorboundary")||r?$=m.Render:$=m.Js);const c=new Date,i=c.toLocaleDateString(),u=c.toLocaleTimeString(),g=parseCrashStackTrace(h),b=H(a,`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${d}`,h,n),x=typeof globalThis.HermesInternal<"u",j=typeof globalThis.nativeFabricUIManager<"u",w={id:`crash_${Date.now()}_${Math.random().toString(36).substr(2,6)}`,error:a,isFatal:n,type:$,message:d,name:a.name||(n?s("crash.errorNameFatal"):s("crash.errorNameUnhandled")),stack:h,parsedStack:g,componentStack:r||void 0,timestamp:Date.now(),dateStr:i,timeStr:u,deviceInfo:{platform:y.OS,osVersion:String(y.Version),rnVersion:y.constants?.reactNativeVersion?`${y.constants.reactNativeVersion.major}.${y.constants.reactNativeVersion.minor}.${y.constants.reactNativeVersion.patch}`:s("crash.unknown"),isHermes:x,isFabric:j,appState:L.currentState||"active"},memoryInfo:J(),breadcrumbs:[...f],logId:b?.id};l.unshift(w),l.length>S&&(l=l.slice(0,S)),emitCrashEvent({error:a,isFatal:n,message:`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${d}`,stack:h,timestamp:Date.now(),logId:b?.id,crashRecord:w});try{U(),_(!0)}catch{}return w}catch{return{id:`crash_${Date.now()}`,isFatal:!0,type:m.Js,message:String(e||s("crash.unknownException")),timestamp:Date.now(),dateStr:new Date().toLocaleDateString(),timeStr:new Date().toLocaleTimeString()}}},recordCustomCrash=(e,t)=>handleInterceptedCrash(e,typeof e=="object"?e.stack:void 0,t?.isFatal??!1,t?.type||m.Custom,t?.componentStack),simulateTestCrash=(e=m.Js,t,n)=>{const o=new Error(t||P(e));return handleInterceptedCrash(e===m.Native?o.message:o,n||o.stack,e===m.Native,e,e===m.Render?V():void 0)};const P=e=>{switch(e){case"native":return s("crash.simNativeMessage");case"promise":return s("crash.simPromiseMessage");case"render":return s("crash.simRenderMessage");default:return s("crash.simJsMessage")}},V=()=>{try{const e=new Error;if(e.stack)return e.stack.split(`
4
4
  `).slice(1,6).map(t=>` ${t.trim()}`).join(`
5
- `)}catch{}};export const exportCrashReport=(e,t="text")=>{if(t==="json")return JSON.stringify(e,null,2);const n=Math.round((e.timestamp-T)/1e3);if(t==="markdown"){const r=[];return r.push(`## ${s("crash.mdReportTitle",{name:e.name||"Error"})}`),r.push(`> **${e.message}**`),r.push(""),r.push(`- **${s("crash.reportType")}** \`${e.type.toUpperCase()}\``),r.push(`- **${s("crash.reportFatal")}** \`${e.isFatal?s("crash.mdSeverityFatal"):s("crash.mdSeverityHandled")}\``),r.push(`- **${s("crash.reportTimestamp")}** ${e.dateStr} ${e.timeStr}`),r.push(`- **${s("crash.reportUptime")}** ${n}s`),r.push(`- **${s("crash.reportPlatform")}** ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),r.push(`- **${s("crash.reportReactNative")}** v${e.deviceInfo?.rnVersion||"N/A"}`),r.push(`- **${s("crash.jsEngine")}** ${e.deviceInfo?.isHermes?s("crash.hermesEngine"):s("crash.jsc")}`),r.push(`- **${s("crash.reportArchitecture")}** ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),e.memoryInfo&&r.push(`- **${s("crash.reportJsMemory")}** ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),r.push(""),r.push(`### ${s("crash.mdStackTrace")}`),r.push("```"),r.push(e.stack||s("crash.reportNoStackTrace")),r.push("```"),e.componentStack&&(r.push(""),r.push(`### ${s("crash.mdComponentHierarchy")}`),r.push("```"),r.push(e.componentStack),r.push("```")),e.breadcrumbs&&e.breadcrumbs.length>0&&(r.push(""),r.push(`### ${s("crash.mdRecentBreadcrumbs")}`),e.breadcrumbs.forEach(a=>{const h=new Date(a.timestamp).toLocaleTimeString();r.push(`- \`[${h}]\` **[${a.type.toUpperCase()}]** ${a.message}`)})),r.join(`
6
- `)}const o=[];return o.push("===================================================="),o.push(` ${s("crash.reportTitle")} `),o.push("===================================================="),o.push(`${s("crash.reportErrorName")} ${e.name||"Error"}`),o.push(`${s("crash.reportMessage")} ${e.message}`),o.push(`${s("crash.reportType")} ${e.type.toUpperCase()}`),o.push(`${s("crash.reportFatal")} ${e.isFatal?s("crash.reportFatalYes"):s("crash.reportFatalNo")}`),o.push(`${s("crash.reportTimestamp")} ${e.dateStr} ${e.timeStr} (${e.timestamp})`),o.push(`${s("crash.reportUptime")} ${s("crash.reportUptimeValue",{seconds:n})}`),o.push(`${s("crash.reportPlatform")} ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),o.push(`${s("crash.reportReactNative")} ${e.deviceInfo?.rnVersion||"N/A"}`),o.push(`${s("crash.reportHermes")} ${e.deviceInfo?.isHermes?s("crash.reportEnabled"):s("crash.reportDisabled")}`),o.push(`${s("crash.reportArchitecture")} ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),o.push(`${s("crash.reportScreenSize")} ${P()}`),o.push(`${s("crash.reportAppState")} ${e.deviceInfo?.appState||"active"}`),e.memoryInfo&&o.push(`${s("crash.reportJsMemory")} ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),o.push("----------------------------------------------------"),o.push(`${s("crash.reportStackTrace")}`),o.push(e.stack||s("crash.reportNoStackTrace")),e.componentStack&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportComponentHierarchy")}`),o.push(e.componentStack)),e.breadcrumbs&&e.breadcrumbs.length>0&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportRecentBreadcrumbs")}`),e.breadcrumbs.forEach(r=>{const a=new Date(r.timestamp).toLocaleTimeString();o.push(` [${a}] [${r.type.toUpperCase()}] ${r.message}`)})),o.push("===================================================="),o.join(`
7
- `)},setupGlobalCrashHandler=()=>{if(!k){k=!0;try{M&&typeof M.ignoreAllLogs=="function"&&M.ignoreAllLogs(!0)}catch{}try{const e=require("react-native/Libraries/LogBox/Data/LogBoxData");e&&typeof e.setDisabled=="function"&&e.setDisabled(!0)}catch{}try{const e=v?.NetworkInspectorModule;e&&(typeof e.enableNativeCrashProtection=="function"&&e.enableNativeCrashProtection(),new F(e).addListener("onNativeCrash",n=>{const r=`[${(n?.platform||y.OS).toUpperCase()} ${s("crash.nativeCrashTitle")}] ${n?.message||s("crash.nativeUncaughtException")}`,a=n?.stack||"";handleInterceptedCrash(r,a,!0,"native")}))}catch{}try{const e=D||globalThis.__turboModuleProxy,t=v?.ExceptionsManager||(e?.get?e.get("ExceptionsManager"):null);if(t){t.reportFatalException=(o,r,a)=>{handleInterceptedCrash(o,r,!0,"native");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportSoftException=(o,r,a)=>{handleInterceptedCrash(o,r,!1,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportException=o=>{const r=o?.message||o?.title||s("crash.nativeException"),a=o?.stack||o?.rawStack;handleInterceptedCrash(r,a,o?.isFatal??!0,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.updateExceptionMessage=()=>{};try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}}const n=v?.RedBox||v?.RCTRedBox||(e?.get?e.get("RedBox")||e.get("RCTRedBox"):null);n&&(typeof n.showErrorMessage=="function"&&(n.showErrorMessage=()=>{}),typeof n.showUserError=="function"&&(n.showUserError=()=>{}),typeof n.dismiss=="function"&&n.dismiss())}catch{}try{const t=globalThis.ErrorUtils;t&&(typeof t.setGlobalHandler=="function"&&t.setGlobalHandler((n,o)=>{handleInterceptedCrash(n,n?.stack,o??!1,"js")}),typeof t.reportFatalError=="function"&&(t.reportFatalError=n=>{handleInterceptedCrash(n,n?.stack,!0,"js")}),typeof t.reportError=="function"&&(t.reportError=n=>{handleInterceptedCrash(n,n?.stack,!1,"js")}))}catch{}try{const e=globalThis,t=n=>{try{const o=n?.reason||n?.detail?.reason||n,r=o?.message||String(o||s("crash.unhandledPromiseRejection")),a=o?.stack||(n?.stack??new Error().stack);handleInterceptedCrash(o,a,!1,"promise")}catch{}};typeof e.addEventListener=="function"&&e.addEventListener("unhandledrejection",t),typeof e.onunhandledrejection<"u"&&(e.onunhandledrejection=t)}catch{}}};
5
+ `)}catch{}};export const exportCrashReport=(e,t="text")=>{if(t==="json")return JSON.stringify(e,null,2);const n=Math.round((e.timestamp-T)/1e3);if(t==="markdown"){const r=[];return r.push(`## ${s("crash.mdReportTitle",{name:e.name||"Error"})}`),r.push(`> **${e.message}**`),r.push(""),r.push(`- **${s("crash.reportType")}** \`${e.type.toUpperCase()}\``),r.push(`- **${s("crash.reportFatal")}** \`${e.isFatal?s("crash.mdSeverityFatal"):s("crash.mdSeverityHandled")}\``),r.push(`- **${s("crash.reportTimestamp")}** ${e.dateStr} ${e.timeStr}`),r.push(`- **${s("crash.reportUptime")}** ${n}s`),r.push(`- **${s("crash.reportPlatform")}** ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),r.push(`- **${s("crash.reportReactNative")}** v${e.deviceInfo?.rnVersion||"N/A"}`),r.push(`- **${s("crash.jsEngine")}** ${e.deviceInfo?.isHermes?s("crash.hermesEngine"):s("crash.jsc")}`),r.push(`- **${s("crash.reportArchitecture")}** ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),e.memoryInfo&&r.push(`- **${s("crash.reportJsMemory")}** ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),r.push(""),r.push(`### ${s("crash.mdStackTrace")}`),r.push("```"),r.push(e.stack||s("crash.reportNoStackTrace")),r.push("```"),e.componentStack&&(r.push(""),r.push(`### ${s("crash.mdComponentHierarchy")}`),r.push("```"),r.push(e.componentStack),r.push("```")),e.breadcrumbs&&e.breadcrumbs.length>0&&(r.push(""),r.push(`### ${s("crash.mdRecentBreadcrumbs")}`),e.breadcrumbs.forEach(a=>{const d=new Date(a.timestamp).toLocaleTimeString();r.push(`- \`[${d}]\` **[${a.type.toUpperCase()}]** ${a.message}`)})),r.join(`
6
+ `)}const o=[];return o.push("===================================================="),o.push(` ${s("crash.reportTitle")} `),o.push("===================================================="),o.push(`${s("crash.reportErrorName")} ${e.name||"Error"}`),o.push(`${s("crash.reportMessage")} ${e.message}`),o.push(`${s("crash.reportType")} ${e.type.toUpperCase()}`),o.push(`${s("crash.reportFatal")} ${e.isFatal?s("crash.reportFatalYes"):s("crash.reportFatalNo")}`),o.push(`${s("crash.reportTimestamp")} ${e.dateStr} ${e.timeStr} (${e.timestamp})`),o.push(`${s("crash.reportUptime")} ${s("crash.reportUptimeValue",{seconds:n})}`),o.push(`${s("crash.reportPlatform")} ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),o.push(`${s("crash.reportReactNative")} ${e.deviceInfo?.rnVersion||"N/A"}`),o.push(`${s("crash.reportHermes")} ${e.deviceInfo?.isHermes?s("crash.reportEnabled"):s("crash.reportDisabled")}`),o.push(`${s("crash.reportArchitecture")} ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),o.push(`${s("crash.reportScreenSize")} ${z()}`),o.push(`${s("crash.reportAppState")} ${e.deviceInfo?.appState||"active"}`),e.memoryInfo&&o.push(`${s("crash.reportJsMemory")} ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),o.push("----------------------------------------------------"),o.push(`${s("crash.reportStackTrace")}`),o.push(e.stack||s("crash.reportNoStackTrace")),e.componentStack&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportComponentHierarchy")}`),o.push(e.componentStack)),e.breadcrumbs&&e.breadcrumbs.length>0&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportRecentBreadcrumbs")}`),e.breadcrumbs.forEach(r=>{const a=new Date(r.timestamp).toLocaleTimeString();o.push(` [${a}] [${r.type.toUpperCase()}] ${r.message}`)})),o.push("===================================================="),o.join(`
7
+ `)},setupGlobalCrashHandler=()=>{if(!k){k=!0;try{M&&typeof M.ignoreAllLogs=="function"&&M.ignoreAllLogs(!0)}catch{}try{const e=require("react-native/Libraries/LogBox/Data/LogBoxData");e&&typeof e.setDisabled=="function"&&e.setDisabled(!0)}catch{}try{const e=v?.NetworkInspectorModule;e&&(typeof e.enableNativeCrashProtection=="function"&&e.enableNativeCrashProtection(),new F(e).addListener("onNativeCrash",n=>{const r=`[${(n?.platform||y.OS).toUpperCase()} ${s("crash.nativeCrashTitle")}] ${n?.message||s("crash.nativeUncaughtException")}`,a=n?.stack||"";handleInterceptedCrash(r,a,!0,"native")}))}catch{}try{const e=D||globalThis.__turboModuleProxy,t=v?.ExceptionsManager||(e?.get?e.get("ExceptionsManager"):null);if(t){t.reportFatalException=(o,r,a)=>{handleInterceptedCrash(o,r,!0,"native");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportSoftException=(o,r,a)=>{handleInterceptedCrash(o,r,!1,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportException=o=>{const r=o?.message||o?.title||s("crash.nativeException"),a=o?.stack||o?.rawStack;handleInterceptedCrash(r,a,o?.isFatal??!0,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.updateExceptionMessage=()=>{};try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}}const n=v?.RedBox||v?.RCTRedBox||(e?.get?e.get("RedBox")||e.get("RCTRedBox"):null);n&&(typeof n.showErrorMessage=="function"&&(n.showErrorMessage=()=>{}),typeof n.showUserError=="function"&&(n.showUserError=()=>{}),typeof n.dismiss=="function"&&n.dismiss())}catch{}try{const t=globalThis.ErrorUtils;t&&(typeof t.setGlobalHandler=="function"&&t.setGlobalHandler((n,o)=>{handleInterceptedCrash(n,n?.stack,o??!1,"js")}),typeof t.reportFatalError=="function"&&(t.reportFatalError=n=>{handleInterceptedCrash(n,n?.stack,!0,"js")}),typeof t.reportError=="function"&&(t.reportError=n=>{handleInterceptedCrash(n,n?.stack,!1,"js")}))}catch{}try{const e=globalThis,t=n=>{try{const o=n?.reason||n?.detail?.reason||n,r=o?.stack||(n?.stack??new Error().stack);handleInterceptedCrash(o,r,!1,"promise")}catch{}};typeof e.addEventListener=="function"&&e.addEventListener("unhandledrejection",t),typeof e.onunhandledrejection<"u"&&(e.onunhandledrejection=t)}catch{}}};
@@ -1 +1 @@
1
- import b from"axios";import{setupGlobalCrashHandler as k}from"./crashHandler";let a=[],x=[],H=0,T=!0,f=null;export const setRouteInfoProvider=e=>{f=e},setNetworkModuleEnabled=e=>{T=e},getNetworkModuleEnabled=()=>T;const A=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","CONNECT","TRACE"],C=[/\/symbolicate(?:\?|$)/i,/\/index\.bundle(?:\?|$)/i,/\/open-debugger(?:\?|$)/i,/:(?:8081|8082|8083|19000|19001)\/(?:index\.bundle|symbolicate|hot|message|status)/i,/google-analytics\.com\/mp\/collect/i,/analytics\.google\.com/i];function w(e){return e?C.some(t=>t.test(e)):!1}function U(e){if(!e||typeof e!="string")return;const t=e.trim().split(/[\r\n]+/),s={};return t.forEach(n=>{const o=n.indexOf(":");if(o>0){const i=n.substring(0,o).trim().toLowerCase(),r=n.substring(o+1).trim();s[i]=r}}),Object.keys(s).length>0?s:void 0}function m(e){if(!e)return;if(typeof e.forEach=="function"){const n={};return e.forEach((o,i)=>{n[i]=o}),Object.keys(n).length>0?n:void 0}if(Array.isArray(e)){const n={};return e.forEach(([o,i])=>{n[o]=i}),Object.keys(n).length>0?n:void 0}const t=e,s={};return Object.entries(t).forEach(([n,o])=>{o!=null&&(s[n]=String(o))}),Object.keys(s).length>0?s:void 0}function D(e){if(!e)return e;if(e&&e._parts&&Array.isArray(e._parts)){const t={};return e._parts.forEach(s=>{const n=s[0],o=s[1];o&&typeof o=="object"&&o.uri?t[n]={_isFile:!0,name:o.name||"unknown",type:o.type||"unknown",uri:o.uri}:t[n]=o}),{_isFormData:!0,...t}}return e}export const subscribeNetworkLogs=e=>(x.push(e),e([...a]),()=>{x=x.filter(t=>t!==e)}),clearNetworkLogs=()=>{a=[],I()},getNetworkLogs=()=>[...a];let E=250;export const setMaxNetworkLogsLimit=e=>{E=Math.max(10,e),a.length>E&&(a=a.slice(0,E),I())},getMaxNetworkLogsLimit=()=>E,pruneNetworkLogs=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(a.length/2),s=a.length-t;return s>0&&(a=a.slice(0,t),I()),Math.max(0,s)};const I=()=>{const e=[...a];x.forEach(t=>t(e))},h=e=>{if(!T)return;const t=e.method?.toUpperCase();if(t&&!A.includes(t)||w(e.url))return;const s=a.findIndex(n=>n.id===e.id);s>=0?a[s]={...a[s],...e}:a.unshift(e),a=a.slice(0,E),I()};let O=!1;export const setupNetworkLogger=()=>{if(globalThis.__NETWORK_LOGGER_INITIALIZED__)return;globalThis.__NETWORK_LOGGER__=h;const e=globalThis.XMLHttpRequest;if(e&&e.prototype&&!globalThis.__XHR_LOGGER_INITIALIZED__){globalThis.__XHR_LOGGER_INITIALIZED__=!0;const s=e.prototype.open,n=e.prototype.send,o=e.prototype.setRequestHeader;e.prototype.open=function(i,r,c,d,u){return this.__logMethod=(i||"GET").toUpperCase(),this.__logUrl=typeof r=="string"?r:String(r),this.__logRequestHeaders={},this.__logStartTime=Date.now(),s.apply(this,[i,r,c!==!1,d,u])},e.prototype.setRequestHeader=function(i,r){return i&&r!=null&&(this.__logRequestHeaders||(this.__logRequestHeaders={}),this.__logRequestHeaders[i.toLowerCase()]=String(r)),o.apply(this,[i,r])},e.prototype.send=function(i){if(!T||O||this.__inAppInspectorTracked)return n.apply(this,[i]);const r=this.__logUrl||"",c=this.__logMethod||"GET";if(w(r))return n.apply(this,[i]);const d=H++;this.__logId=d;const u=this.__logStartTime||Date.now(),l=this.__logRequestHeaders;let _="xhr";(l?.["apollographql-client-name"]||r.toLowerCase().includes("/graphql"))&&(_="apollo");const y=f?f():null;h({id:d,url:r,method:c,startTime:u,client:_,routeInfo:y||void 0,request:c==="GET"?void 0:D(i),requestHeaders:Object.keys(l||{}).length>0?l:void 0});const g=()=>{if(this.__logFinished)return;this.__logFinished=!0;const R=Date.now()-u;let p=null;try{if(this.responseType===""||this.responseType==="text"){const N=this.responseText;try{p=JSON.parse(N)}catch{p=N}}else this.responseType==="json"?p=this.response:this.responseType==="blob"?p=`[Blob: ${this.response?.size||0} bytes]`:p=`[${this.responseType||"Unknown"} Data]`}catch{p=this.response||null}const q=this.getAllResponseHeaders?this.getAllResponseHeaders():"",G=U(q);h({id:d,url:r,method:c,status:this.status,response:p,duration:R,startTime:u,client:_,responseHeaders:G})},L=()=>{if(this.__logFinished)return;this.__logFinished=!0;const R=Date.now()-u;h({id:d,url:r,method:c,status:this.status||0,response:"Network request failed",duration:R,startTime:u,client:_})};return this.addEventListener("load",g),this.addEventListener("error",L),this.addEventListener("abort",L),this.addEventListener("timeout",L),n.apply(this,[i])}}const t=globalThis.fetch;t&&(globalThis.fetch=async(s,n={})=>{if(!T)return t(s,n);const o=(n?.method||"GET").toUpperCase(),i=H++,r=Date.now(),c=typeof s=="string"?s:s?.url;if(w(c))return t(s,n);let d,u="fetch";try{d=m(n?.headers),d?.["apollographql-client-name"]||c?.toLowerCase().includes("/graphql")?u="apollo":d?.["x-requested-with"]?.toLowerCase().includes("xmlhttprequest")&&(u="xhr");const l=f?f():null;h({id:i,url:c,method:o,startTime:r,client:u,routeInfo:l||void 0,request:o==="GET"?void 0:D(n?.body),requestHeaders:d})}catch{}try{O=!0;let l;try{l=await t(s,n)}finally{O=!1}const _=Date.now()-r;try{const y=m(l.headers);let g=null;if((y?.["content-type"]||y?.["Content-Type"]||"").includes("image/"))g="[Image Data]";else try{const p=await l.clone().text();try{g=JSON.parse(p)}catch{g=p}}catch{}h({id:i,url:c,method:o,status:l.status,response:g,duration:_,startTime:r,client:u,responseHeaders:y})}catch{}return l}catch(l){try{h({id:i,url:c,method:o,status:0,startTime:r,response:l,client:u,duration:Date.now()-r})}catch{}throw l}});try{if(b){addAxiosInterceptors(b);const s=b.create;typeof s=="function"&&(b.create=function(...n){const o=s.apply(this,n);return addAxiosInterceptors(o),o})}}catch{}try{k()}catch{}globalThis.__NETWORK_LOGGER_INITIALIZED__=!0},addAxiosInterceptors=e=>{e.interceptors.request.use(async t=>{const s=(t.method||"GET").toUpperCase(),n=H++,o=Date.now();let i=t.url??"";if(i.startsWith("http")||(i=`${t.baseURL??""}${i}`),w(i))return t;t.__logId=n,t.__logStart=o;const r=f?f():null;return h({id:n,url:i,method:s,startTime:o,client:"axios",routeInfo:r||void 0,request:s==="GET"?void 0:D(t.data),requestHeaders:m(t.headers)}),t}),e.interceptors.response.use(t=>{const s=t.config||{},n=s.__logId,o=s.__logStart,i=(s.method||"GET").toUpperCase();if(n==null)return t;let r=s.url??"";return r.startsWith("http")||(r=`${s.baseURL??""}${r}`),h({id:n,url:r,method:i,status:t.status,response:t.data,startTime:o||Date.now(),duration:o!=null?Date.now()-o:void 0,client:"axios",responseHeaders:m(t.headers)}),t},t=>{const s=t.config||{},n=s.__logId,o=s.__logStart,i=(s.method||"GET").toUpperCase();if(n!=null){let r=s.url??"";r.startsWith("http")||(r=`${s.baseURL??""}${r}`),h({id:n,url:r,method:i,status:t.response?.status??0,response:t.response?.data??t.message,startTime:o||Date.now(),duration:o!=null?Date.now()-o:void 0,client:"axios",responseHeaders:m(t.response?.headers)})}return Promise.reject(t)})};if(typeof globalThis<"u")try{setupNetworkLogger()}catch{}
1
+ import R from"axios";import{setupGlobalCrashHandler as k}from"./crashHandler";let c=[],b=[],w=0,T=!0,f=null;export const setRouteInfoProvider=e=>{f=e},setNetworkModuleEnabled=e=>{T=e},getNetworkModuleEnabled=()=>T;const A=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","CONNECT","TRACE"],C=[/\/symbolicate(?:\?|$)/i,/\/index\.bundle(?:\?|$)/i,/\/open-debugger(?:\?|$)/i,/:(?:8081|8082|8083|19000|19001)\/(?:index\.bundle|symbolicate|hot|message|status)/i,/google-analytics\.com\/mp\/collect/i,/analytics\.google\.com/i];function x(e){return e?C.some(t=>t.test(e)):!1}function U(e){if(!e||typeof e!="string")return;const t=e.trim().split(/[\r\n]+/),s={};return t.forEach(n=>{const o=n.indexOf(":");if(o>0){const i=n.substring(0,o).trim().toLowerCase(),r=n.substring(o+1).trim();s[i]=r}}),Object.keys(s).length>0?s:void 0}function m(e){if(!e)return;if(typeof e.forEach=="function"){const n={};return e.forEach((o,i)=>{n[i]=o}),Object.keys(n).length>0?n:void 0}if(Array.isArray(e)){const n={};return e.forEach(([o,i])=>{n[o]=i}),Object.keys(n).length>0?n:void 0}const t=e,s={};return Object.entries(t).forEach(([n,o])=>{o!=null&&(s[n]=String(o))}),Object.keys(s).length>0?s:void 0}function I(e){if(!e)return e;if(e&&e._parts&&Array.isArray(e._parts)){const t={};return e._parts.forEach(s=>{const n=s[0],o=s[1];o&&typeof o=="object"&&o.uri?t[n]={_isFile:!0,name:o.name||"unknown",type:o.type||"unknown",uri:o.uri}:t[n]=o}),{_isFormData:!0,...t}}return e}export const subscribeNetworkLogs=e=>(b.push(e),e([...c]),()=>{b=b.filter(t=>t!==e)}),clearNetworkLogs=()=>{c=[],H()},getNetworkLogs=()=>[...c];let N=1/0;export const setMaxNetworkLogsLimit=e=>{N=e},getMaxNetworkLogsLimit=()=>N,pruneNetworkLogs=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(c.length/2),s=c.length-t;return s>0&&(c=c.slice(0,t),H()),Math.max(0,s)};const H=()=>{const e=[...c];b.forEach(t=>t(e))},h=e=>{if(!T)return;const t=e.method?.toUpperCase();if(t&&!A.includes(t)||x(e.url))return;const s=c.findIndex(n=>n.id===e.id);s>=0?c[s]={...c[s],...e}:c.unshift(e),H()};let D=!1;export const setupNetworkLogger=()=>{if(globalThis.__NETWORK_LOGGER_INITIALIZED__)return;globalThis.__NETWORK_LOGGER__=h;const e=globalThis.XMLHttpRequest;if(e&&e.prototype&&!globalThis.__XHR_LOGGER_INITIALIZED__){globalThis.__XHR_LOGGER_INITIALIZED__=!0;const s=e.prototype.open,n=e.prototype.send,o=e.prototype.setRequestHeader;e.prototype.open=function(i,r,u,d,l){return this.__logMethod=(i||"GET").toUpperCase(),this.__logUrl=typeof r=="string"?r:String(r),this.__logRequestHeaders={},this.__logStartTime=Date.now(),s.apply(this,[i,r,u!==!1,d,l])},e.prototype.setRequestHeader=function(i,r){return i&&r!=null&&(this.__logRequestHeaders||(this.__logRequestHeaders={}),this.__logRequestHeaders[i.toLowerCase()]=String(r)),o.apply(this,[i,r])},e.prototype.send=function(i){if(!T||D||this.__inAppInspectorTracked)return n.apply(this,[i]);const r=this.__logUrl||"",u=this.__logMethod||"GET";if(x(r))return n.apply(this,[i]);const d=w++;this.__logId=d;const l=this.__logStartTime||Date.now(),a=this.__logRequestHeaders;let _="xhr";(a?.["apollographql-client-name"]||r.toLowerCase().includes("/graphql"))&&(_="apollo");const y=f?f():null;h({id:d,url:r,method:u,startTime:l,client:_,routeInfo:y||void 0,request:u==="GET"?void 0:I(i),requestHeaders:Object.keys(a||{}).length>0?a:void 0});const g=()=>{if(this.__logFinished)return;this.__logFinished=!0;const L=Date.now()-l;let p=null;try{if(this.responseType===""||this.responseType==="text"){const O=this.responseText;try{p=JSON.parse(O)}catch{p=O}}else this.responseType==="json"?p=this.response:this.responseType==="blob"?p=`[Blob: ${this.response?.size||0} bytes]`:p=`[${this.responseType||"Unknown"} Data]`}catch{p=this.response||null}const q=this.getAllResponseHeaders?this.getAllResponseHeaders():"",G=U(q);h({id:d,url:r,method:u,status:this.status,response:p,duration:L,startTime:l,client:_,responseHeaders:G})},E=()=>{if(this.__logFinished)return;this.__logFinished=!0;const L=Date.now()-l;h({id:d,url:r,method:u,status:this.status||0,response:"Network request failed",duration:L,startTime:l,client:_})};return this.addEventListener("load",g),this.addEventListener("error",E),this.addEventListener("abort",E),this.addEventListener("timeout",E),n.apply(this,[i])}}const t=globalThis.fetch;t&&(globalThis.fetch=async(s,n={})=>{if(!T)return t(s,n);const o=(n?.method||"GET").toUpperCase(),i=w++,r=Date.now(),u=typeof s=="string"?s:s?.url;if(x(u))return t(s,n);let d,l="fetch";try{d=m(n?.headers),d?.["apollographql-client-name"]||u?.toLowerCase().includes("/graphql")?l="apollo":d?.["x-requested-with"]?.toLowerCase().includes("xmlhttprequest")&&(l="xhr");const a=f?f():null;h({id:i,url:u,method:o,startTime:r,client:l,routeInfo:a||void 0,request:o==="GET"?void 0:I(n?.body),requestHeaders:d})}catch{}try{D=!0;let a;try{a=await t(s,n)}finally{D=!1}const _=Date.now()-r;try{const y=m(a.headers);let g=null;if((y?.["content-type"]||y?.["Content-Type"]||"").includes("image/"))g="[Image Data]";else try{const p=await a.clone().text();try{g=JSON.parse(p)}catch{g=p}}catch{}h({id:i,url:u,method:o,status:a.status,response:g,duration:_,startTime:r,client:l,responseHeaders:y})}catch{}return a}catch(a){try{h({id:i,url:u,method:o,status:0,startTime:r,response:a,client:l,duration:Date.now()-r})}catch{}throw a}});try{if(R){addAxiosInterceptors(R);const s=R.create;typeof s=="function"&&(R.create=function(...n){const o=s.apply(this,n);return addAxiosInterceptors(o),o})}}catch{}try{k()}catch{}globalThis.__NETWORK_LOGGER_INITIALIZED__=!0},addAxiosInterceptors=e=>{e.interceptors.request.use(async t=>{const s=(t.method||"GET").toUpperCase(),n=w++,o=Date.now();let i=t.url??"";if(i.startsWith("http")||(i=`${t.baseURL??""}${i}`),x(i))return t;t.__logId=n,t.__logStart=o;const r=f?f():null;return h({id:n,url:i,method:s,startTime:o,client:"axios",routeInfo:r||void 0,request:s==="GET"?void 0:I(t.data),requestHeaders:m(t.headers)}),t}),e.interceptors.response.use(t=>{const s=t.config||{},n=s.__logId,o=s.__logStart,i=(s.method||"GET").toUpperCase();if(n==null)return t;let r=s.url??"";return r.startsWith("http")||(r=`${s.baseURL??""}${r}`),h({id:n,url:r,method:i,status:t.status,response:t.data,startTime:o||Date.now(),duration:o!=null?Date.now()-o:void 0,client:"axios",responseHeaders:m(t.headers)}),t},t=>{const s=t.config||{},n=s.__logId,o=s.__logStart,i=(s.method||"GET").toUpperCase();if(n!=null){let r=s.url??"";r.startsWith("http")||(r=`${s.baseURL??""}${r}`),h({id:n,url:r,method:i,status:t.response?.status??0,response:t.response?.data??t.message,startTime:o||Date.now(),duration:o!=null?Date.now()-o:void 0,client:"axios",responseHeaders:m(t.response?.headers)})}return Promise.reject(t)})};if(typeof globalThis<"u")try{setupNetworkLogger()}catch{}
@@ -0,0 +1,19 @@
1
+ import type { PushNotificationRecord } from '../types';
2
+ export declare function normalizePushPayload(raw: any, options?: Partial<PushNotificationRecord>): PushNotificationRecord;
3
+ export declare function recordPushNotification(payload: any, options?: Partial<PushNotificationRecord>): PushNotificationRecord;
4
+ export declare function recordSalesforcePush(payload: any, options?: Partial<PushNotificationRecord>): PushNotificationRecord;
5
+ export declare function getPushRecords(): PushNotificationRecord[];
6
+ export declare function clearPushRecords(): void;
7
+ export declare function prunePushRecords(keepCount?: number): void;
8
+ export declare function setMaxPushRecordsLimit(limit: number): void;
9
+ export declare function getMaxPushRecordsLimit(): number;
10
+ export declare const emitPushEvent: typeof recordPushNotification;
11
+ export declare function subscribePushEvents(callback: (records: PushNotificationRecord[]) => void): () => void;
12
+ export declare function getDiscoveredPushSources(): string[];
13
+ export declare function simulateTestPush(preset?: 'salesforce' | 'fcm' | 'apns' | 'deeplink' | 'rich_media' | 'custom', customData?: any): PushNotificationRecord;
14
+ export declare function autoSetupPushLogger(options?: {
15
+ messaging?: any;
16
+ notifee?: any;
17
+ expoNotifications?: any;
18
+ marketingCloud?: any;
19
+ }): () => void;
@@ -0,0 +1 @@
1
+ import{AppState as p}from"react-native";let n=[],r=50;const l=new Set;function u(){const e=[...n];l.forEach(t=>{try{t(e)}catch{}})}function g(){return`push_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}export function normalizePushPayload(e,t){if(!e||typeof e!="object")return{id:t?.id||g(),title:t?.title||"Notification",body:t?.body||String(e||""),source:t?.source||"custom",domain:t?.domain||"custom",appState:t?.appState||(p.currentState==="active"?"foreground":"background"),action:t?.action||"received",timestamp:t?.timestamp||Date.now(),data:t?.data||{},rawPayload:e};const o=e.notification||e.aps?.alert||e.alert||e,i=e.data||e.custom||e.customKeys||e.userInfo||e.payload||{},a=t?.id||e.id||e.messageId||e.message_id||e._m||e.identifier||e["gcm.message_id"]||e["google.message_id"]||g(),h=t?.title||(typeof o=="object"?o.title||o.subject||o.headline:null)||i.title||e.title||(typeof e.alert=="string"?e.alert:void 0)||"Push Notification",y=t?.body||(typeof o=="object"?o.body||o.message||o.text||o.alert:null)||i.body||i.message||e.body||e.message||(typeof e.alert=="string"?e.alert:void 0)||"",b=t?.subtitle||(typeof o=="object"?o.subtitle||o.subTitle:null)||i.subtitle||e.subtitle,_=t?.imageUrl||(typeof o=="object"?o.imageUrl||o.image||o.bigPicture:null)||i.imageUrl||i.image||e.imageUrl||e.image||e.fcm_options?.image,f=t?.sound||(typeof o=="object"?o.sound:null)||i.sound||e.sound||e.aps?.sound,m=t?.badge??(typeof e.badge=="number"?e.badge:null)??(typeof e.aps?.badge=="number"?e.aps.badge:null),v=t?.channelId||(typeof o=="object"?o.channelId||o.android?.channelId:null)||i.channelId||e.channelId,S=t?.priority||e.priority||(e.highPriority?"high":void 0);let s=t?.source||"push",c=t?.domain;e._m||e._sid||e._od||e._h||e._r||i._m||i._sid||i.customKeys?(s="salesforce",c="Salesforce Marketing Cloud"):e.ab_||i.ab_||e.braze_id?(s="braze",c="Braze"):e.custom?.i||e.os_||i.os_?(s="onesignal",c="OneSignal"):e.experienceId||e.projectId?(s="expo",c="Expo Notifications"):e["gcm.message_id"]||e.fcm_options||e.from?(s="fcm",c="Firebase Cloud Messaging"):e.aps?(s="apns",c="Apple Push Notification Service"):t?.source&&(s=t.source,c=t.domain||t.source);const d={};s==="salesforce"&&((e._m||i._m)&&(d.messageId=e._m||i._m),(e._sid||i._sid)&&(d.sendId=e._sid||i._sid),(e._od||i._od)&&(d.openDirectUrl=e._od||i._od),(e._h||i._h)&&(d.cloudPageUrl=e._h||i._h),(e._r||i._r)&&(d.receiptUrl=e._r||i._r),(e.customKeys||i.customKeys)&&(d.customKeys=e.customKeys||i.customKeys));const P={...typeof e=="object"?e:{},...typeof i=="object"?i:{},...t?.data||{}},x=p.currentState==="active"?"foreground":"background";return{id:String(a),title:h,body:y,subtitle:b,source:s,domain:c||s,appState:t?.appState||x,action:t?.action||"received",actionId:t?.actionId,userText:t?.userText,timestamp:t?.timestamp||Date.now(),data:P,rawPayload:e,channelId:v,imageUrl:_,sound:f?String(f):void 0,badge:m!=null?Number(m):void 0,collapseKey:e.collapseKey||e.collapse_key,priority:S,customDomainAttributes:Object.keys(d).length>0?d:void 0}}export function recordPushNotification(e,t){const o=normalizePushPayload(e,t);return n.unshift(o),n.length>r&&(n=n.slice(0,r)),u(),o}export function recordSalesforcePush(e,t){return recordPushNotification(e,{source:"salesforce",domain:"Salesforce Marketing Cloud",...t})}export function getPushRecords(){return[...n]}export function clearPushRecords(){n=[],u()}export function prunePushRecords(e=20){n.length>e&&(n=n.slice(0,e),u())}export function setMaxPushRecordsLimit(e){r=Math.max(10,Math.min(e,500)),n.length>r&&(n=n.slice(0,r),u())}export function getMaxPushRecordsLimit(){return r}export const emitPushEvent=recordPushNotification;export function subscribePushEvents(e){return l.add(e),e([...n]),()=>{l.delete(e)}}export function getDiscoveredPushSources(){const e=new Set;return n.forEach(t=>{t.source&&e.add(t.source.toLowerCase())}),Array.from(e)}export function simulateTestPush(e="salesforce",t){const o=Date.now();switch(e){case"salesforce":return recordPushNotification({_m:`sfmc_msg_${Math.floor(Math.random()*9e5+1e5)}`,_sid:"journey_flash_sale_q3",_od:"app://deals/flash-50-off",_h:"https://cloud.email.salesforce.com/pages/view",_r:`receipt_${o}`,title:"\u{1F525} Salesforce Flash 50% Off Sale!",body:"Special VIP weekend access unlocked! Tap to claim your discount.",customKeys:{campaign:"LaborDayPromo",discountCode:"FLASH50",tier:"Diamond VIP",loyaltyPoints:1250},channelId:"promotions",priority:"high"},{source:"salesforce",domain:"Salesforce Marketing Cloud",appState:"foreground",action:"received"});case"fcm":return recordPushNotification({"gcm.message_id":`fcm_${Math.floor(Math.random()*9e6)}`,notification:{title:"\u{1F4E6} Order #98421 Out for Delivery",body:"Your courier is 5 minutes away with your package.",imageUrl:"https://images.unsplash.com/photo-1549465220-1a8b9238cd48?w=300",channelId:"deliveries"},data:{orderId:"ORD-98421",courier:"Express Delivery",trackingUrl:"https://track.example.com/98421"}},{source:"fcm",domain:"Firebase Cloud Messaging",appState:"background",action:"received"});case"apns":return recordPushNotification({aps:{alert:{title:"\u{1F4AC} New Message from Alex",subtitle:"Direct Message",body:"Hey! Are you ready for the team sync at 11 AM?"},badge:3,sound:"chime.aiff","thread-id":"chat_thread_102"},customData:{senderId:"user_alex_84",chatRoomId:"room_dev_sync"}},{source:"apns",domain:"Apple Push (APNs)",appState:"foreground",action:"received"});case"deeplink":return recordPushNotification({id:`dl_${o}`,title:"\u{1F680} Deep Link Received",body:"Tap to navigate to the new payment analytics dashboard.",data:{deepLink:"myapp://analytics/payments?period=monthly",screen:"AnalyticsDetail",sourceCampaign:"in_app_reminder"}},{source:"deeplink",domain:"Custom Deep Link",appState:"foreground",action:"opened"});case"rich_media":return recordPushNotification({id:`rich_${o}`,title:"\u{1F3AC} New Video Available",body:"Watch the product keynote highlights now in HD.",imageUrl:"https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=500",data:{videoId:"vid_launch_2026",category:"Keynotes",duration:340}},{source:"rich_media",domain:"Media Service",appState:"foreground",action:"received"});default:return recordPushNotification(t||{id:`custom_${o}`,title:"\u26A1 Custom Domain Push",body:"This is a flexible dynamic push payload from an arbitrary backend.",data:{domain:"api.mycustomservice.io",event:"custom_alert",nestedData:{level:"high",score:98.4}}},{source:"custom",domain:"Custom API"})}}export function autoSetupPushLogger(e){const t=[];if(e?.messaging)try{const o=typeof e.messaging=="function"?e.messaging():e.messaging;if(typeof o.onMessage=="function"){const i=o.onMessage(async a=>{recordPushNotification(a,{source:"fcm",appState:"foreground",action:"received"})});typeof i=="function"&&t.push(i)}if(typeof o.onNotificationOpenedApp=="function"){const i=o.onNotificationOpenedApp(a=>{recordPushNotification(a,{source:"fcm",appState:"background",action:"opened"})});typeof i=="function"&&t.push(i)}}catch{}if(e?.notifee)try{if(typeof e.notifee.onForegroundEvent=="function"){const o=e.notifee.onForegroundEvent(({type:i,detail:a})=>{recordPushNotification(a.notification,{source:"notifee",appState:"foreground",action:i===1?"opened":"received",actionId:a.pressAction?.id})});typeof o=="function"&&t.push(o)}}catch{}if(e?.marketingCloud)try{typeof e.marketingCloud.setNotificationOpenedListener=="function"&&e.marketingCloud.setNotificationOpenedListener(o=>{recordSalesforcePush(o,{action:"opened",appState:"foreground"})})}catch{}return()=>{t.forEach(o=>{try{o()}catch{}})}}
@@ -5,11 +5,12 @@ export interface MemoryPruneSummary {
5
5
  prunedRedux: number;
6
6
  prunedAnalytics: number;
7
7
  prunedCrashes: number;
8
+ prunedPush: number;
8
9
  totalPruned: number;
9
10
  triggeredBy: 'memory-warning' | 'manual' | 'ram-threshold';
10
11
  }
11
12
  type MemoryWarningListener = (summary: MemoryPruneSummary) => void;
12
- export declare const pruneAllLogs: (triggeredBy?: MemoryPruneSummary["triggeredBy"], targetRetentionPct?: number) => MemoryPruneSummary;
13
+ export declare const pruneAllLogs: (triggeredBy?: MemoryPruneSummary["triggeredBy"], _targetRetentionPct?: number) => MemoryPruneSummary;
13
14
  export declare const setupMemoryWarningHandler: () => (() => void);
14
15
  export declare const subscribeMemoryWarning: (listener: MemoryWarningListener) => (() => void);
15
16
  export declare const getLastPruneTimestamp: () => number;
@@ -1 +1 @@
1
- import{AppState as y}from"react-native";import{pruneNetworkLogs as f}from"../customHooks/networkLogger";import{pruneConsoleLogs as g}from"../customHooks/consoleLogger";import{pruneReduxHistory as h}from"../customHooks/reduxLogger";import{pruneAnalyticsLogs as x}from"../customHooks/analyticsLogger";import{pruneCrashRecords as M,addCrashBreadcrumb as L}from"../customHooks/crashHandler";import{showToast as w}from"./toast";const s=new Set;let r=null,t=!1,a=0;export const pruneAllLogs=(e="manual",n=.5)=>{const A=Math.max(.1,Math.min(1,n)),m=f(void 0),c=g(void 0),u=h(void 0),i=x(void 0),p=M(void 0),d=m+c+u+i+p;if(a=Date.now(),typeof globalThis.gc=="function")try{globalThis.gc()}catch{}const o={timestamp:a,prunedNetwork:m,prunedConsole:c,prunedRedux:u,prunedAnalytics:i,prunedCrashes:p,totalPruned:d,triggeredBy:e};try{L("system",`[MemoryManager] Low memory auto-prune executed (${e}). Freed ${d} log records.`,o)}catch{}return s.forEach(l=>{try{l(o)}catch{}}),o},setupMemoryWarningHandler=()=>{if(t)return()=>{};t=!0;try{r=y.addEventListener("memoryWarning",e=>{const n=pruneAllLogs("memory-warning",.5);try{w(`Memory Warning: Auto-pruned ${n.totalPruned} inspector logs`)}catch{}})}catch{}return()=>{if(r){try{r.remove()}catch{}r=null}t=!1}},subscribeMemoryWarning=e=>(s.add(e),()=>{s.delete(e)}),getLastPruneTimestamp=()=>a,isMemoryHandlerActive=()=>t;
1
+ import{AppState as f}from"react-native";import{pruneNetworkLogs as g}from"../customHooks/networkLogger";import{pruneConsoleLogs as h}from"../customHooks/consoleLogger";import{pruneReduxHistory as x}from"../customHooks/reduxLogger";import{pruneAnalyticsLogs as L}from"../customHooks/analyticsLogger";import{pruneCrashRecords as w,addCrashBreadcrumb as A}from"../customHooks/crashHandler";import{prunePushRecords as M}from"../customHooks/pushNotificationLogger";import{showToast as P}from"./toast";const o=new Set;let r=null,t=!1,s=0;export const pruneAllLogs=(e="manual",a=.5)=>{const u=g(void 0),c=h(void 0),m=x(void 0),i=L(void 0),p=w(void 0),d=0;M(20);const l=u+c+m+i+p+d;if(s=Date.now(),typeof globalThis.gc=="function")try{globalThis.gc()}catch{}const n={timestamp:s,prunedNetwork:u,prunedConsole:c,prunedRedux:m,prunedAnalytics:i,prunedCrashes:p,prunedPush:d,totalPruned:l,triggeredBy:e};try{A("system",`[MemoryManager] Low memory auto-prune executed (${e}). Freed ${l} log records.`,n)}catch{}return o.forEach(y=>{try{y(n)}catch{}}),n},setupMemoryWarningHandler=()=>{if(t)return()=>{};t=!0;try{r=f.addEventListener("memoryWarning",e=>{const a=pruneAllLogs("memory-warning",.5);try{P(`Memory Warning: Auto-pruned ${a.totalPruned} inspector logs`)}catch{}})}catch{}return()=>{if(r){try{r.remove()}catch{}r=null}t=!1}},subscribeMemoryWarning=e=>(o.add(e),()=>{o.delete(e)}),getLastPruneTimestamp=()=>s,isMemoryHandlerActive=()=>t;
@@ -11,6 +11,7 @@ export interface RamLimitsProfile {
11
11
  maxConsoleLogs: number;
12
12
  maxAnalyticsEvents: number;
13
13
  maxCrashRecords: number;
14
+ maxPushRecords: number;
14
15
  profileName: 'High-End' | 'Standard' | 'Compact' | 'Ultra-Light';
15
16
  freeRamMb: number;
16
17
  }
@@ -1 +1 @@
1
- import{Platform as n,Settings as c}from"react-native";import{getNativeStorageItem as u,setNativeStorageItem as m,isNativeModuleAvailable as i}from"../native/NativeInspector";const l=new Map;let s=null;export function setCustomStorage(t){s=t}const e="rn-inapp-inspector.settings.v1";export async function loadSettings(){try{if(s){const r=await s.getItem(e);if(!r)return{};const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}if(i()){const r=await u(e);if(r){const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}}if(n.OS==="ios"){const r=c.get(e);if(!r)return{};if(typeof r=="string"){const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}return r&&typeof r=="object"?r:{}}const t=l.get(e);if(!t)return{};const a=JSON.parse(t);return a&&typeof a=="object"?a:{}}catch{return{}}}export function saveSettings(t){try{const a=JSON.stringify(t);if(s){s.setItem(e,a);return}if(i()&&m(e,a),n.OS==="ios"){c.set({[e]:a});return}l.set(e,a)}catch{}}export async function clearPersistedSettings(){try{if(s){typeof s.removeItem=="function"?await s.removeItem(e):await s.setItem(e,"");return}if(i()&&await m(e,null),n.OS==="ios"){c.set({[e]:null});return}l.delete(e)}catch{}}export const isPersistentStorageAvailable=()=>s!==null||i()||n.OS==="ios";export function getCustomStorage(){return s}export function calculateRamBasedLimits(t){return t>=3e3?{maxNetworkLogs:500,maxConsoleLogs:500,maxAnalyticsEvents:300,maxCrashRecords:150,profileName:"High-End",freeRamMb:t}:t>=1500?{maxNetworkLogs:300,maxConsoleLogs:300,maxAnalyticsEvents:200,maxCrashRecords:100,profileName:"Standard",freeRamMb:t}:t>=600?{maxNetworkLogs:200,maxConsoleLogs:200,maxAnalyticsEvents:100,maxCrashRecords:50,profileName:"Compact",freeRamMb:t}:{maxNetworkLogs:100,maxConsoleLogs:100,maxAnalyticsEvents:50,maxCrashRecords:25,profileName:"Ultra-Light",freeRamMb:t}}
1
+ import{Platform as n,Settings as c}from"react-native";import{getNativeStorageItem as l,setNativeStorageItem as u,isNativeModuleAvailable as i}from"../native/NativeInspector";const m=new Map;let s=null;export function setCustomStorage(t){s=t}const e="rn-inapp-inspector.settings.v1";export async function loadSettings(){try{if(s){const r=await s.getItem(e);if(!r)return{};const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}if(i()){const r=await l(e);if(r){const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}}if(n.OS==="ios"){const r=c.get(e);if(!r)return{};if(typeof r=="string"){const o=JSON.parse(r);return o&&typeof o=="object"?o:{}}return r&&typeof r=="object"?r:{}}const t=m.get(e);if(!t)return{};const a=JSON.parse(t);return a&&typeof a=="object"?a:{}}catch{return{}}}export function saveSettings(t){try{const a=JSON.stringify(t);if(s){s.setItem(e,a);return}if(i()&&u(e,a),n.OS==="ios"){c.set({[e]:a});return}m.set(e,a)}catch{}}export async function clearPersistedSettings(){try{if(s){typeof s.removeItem=="function"?await s.removeItem(e):await s.setItem(e,"");return}if(i()&&await u(e,null),n.OS==="ios"){c.set({[e]:null});return}m.delete(e)}catch{}}export const isPersistentStorageAvailable=()=>s!==null||i()||n.OS==="ios";export function getCustomStorage(){return s}export function calculateRamBasedLimits(t){return t>=3e3?{maxNetworkLogs:500,maxConsoleLogs:500,maxAnalyticsEvents:300,maxCrashRecords:150,maxPushRecords:100,profileName:"High-End",freeRamMb:t}:t>=1500?{maxNetworkLogs:300,maxConsoleLogs:300,maxAnalyticsEvents:200,maxCrashRecords:100,maxPushRecords:75,profileName:"Standard",freeRamMb:t}:t>=600?{maxNetworkLogs:200,maxConsoleLogs:200,maxAnalyticsEvents:100,maxCrashRecords:50,maxPushRecords:50,profileName:"Compact",freeRamMb:t}:{maxNetworkLogs:100,maxConsoleLogs:100,maxAnalyticsEvents:50,maxCrashRecords:25,maxPushRecords:25,profileName:"Ultra-Light",freeRamMb:t}}
@@ -0,0 +1,13 @@
1
+ import type { AnalyticsEvent, ConsoleLog, CrashRecord, NetworkLog, PushNotificationRecord, ReduxHistoryEntry } from '../types';
2
+ export declare function formatApiReport(log: NetworkLog): string;
3
+ export declare function formatPushReport(record: PushNotificationRecord): string;
4
+ export declare function formatCrashReport(crash: CrashRecord): string;
5
+ export declare function formatAnalyticsReport(event: AnalyticsEvent): string;
6
+ export declare function formatReduxReport(action: ReduxHistoryEntry): string;
7
+ export declare function formatLogReport(log: ConsoleLog): string;
8
+ export declare function shareApiReport(log: NetworkLog): Promise<void>;
9
+ export declare function sharePushReport(record: PushNotificationRecord): Promise<void>;
10
+ export declare function shareCrashReport(crash: CrashRecord): Promise<void>;
11
+ export declare function shareAnalyticsReport(event: AnalyticsEvent): Promise<void>;
12
+ export declare function shareReduxReport(action: ReduxHistoryEntry): Promise<void>;
13
+ export declare function shareLogReport(log: ConsoleLog): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import{Alert as h,Share as m}from"react-native";import{formatDateTime as i,getCurlCommand as f}from"./index";function a(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}export function formatApiReport(e){const s=(e.method||"GET").toUpperCase(),t=e.status===0?"Failed / Network Error":e.status!=null?`${e.status} ${e.status===200?"OK":""}`.trim():"Pending",u=e.duration!=null?`${e.duration}ms`:"N/A",o=i(e.startTime||Date.now()),n=f(e),p=["\u{1F680} API INSPECTION REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4CC} Method: ${s}`,`\u{1F4CA} Status: ${t}`,`\u23F1\uFE0F Duration: ${u}`,`\u{1F552} Time: ${o}`];return e.client&&p.push(`\u{1F50C} Client: ${e.client.toUpperCase()}`),p.push(`\u{1F310} URL: ${e.url||"N/A"}`),p.push(""),e.requestHeaders&&Object.keys(e.requestHeaders).length>0&&(p.push("\u{1F4CB} Request Headers:"),p.push(a(e.requestHeaders)),p.push("")),e.request!=null&&e.request!==""&&(p.push("\u{1F4DD} Request Body:"),p.push(a(e.request)),p.push("")),e.responseHeaders&&Object.keys(e.responseHeaders).length>0&&(p.push("\u{1F4D1} Response Headers:"),p.push(a(e.responseHeaders)),p.push("")),e.response!=null&&e.response!==""&&(p.push("\u{1F4E5} Response Data:"),p.push(a(e.response)),p.push("")),n&&(p.push("\u{1F4BB} cURL Command:"),p.push(n),p.push("")),p.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),p.push("Generated by React Native InApp Inspector"),p.join(`
2
+ `)}export function formatPushReport(e){const s=i(e.timestamp||Date.now()),t=(e.source||"push").toUpperCase(),u=(e.appState||"unknown").toUpperCase(),o=(e.action||"received").toUpperCase(),n=["\u{1F514} PUSH NOTIFICATION REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4CC} Title: ${e.title||"(No Title)"}`,`\u{1F4DD} Body: ${e.body||"(No Body)"}`,`\u{1F3E2} Source: ${t}${e.domain?` (${e.domain})`:""}`,`\u{1F194} Message ID: ${e.id||"N/A"}`,`\u{1F4F1} App State: ${u}`,`\u{1F3AF} Action: ${o}`,`\u{1F552} Time: ${s}`];return e.subtitle&&n.push(`\u{1F4D1} Subtitle: ${e.subtitle}`),e.channelId&&n.push(`\u{1F3F7}\uFE0F Channel: ${e.channelId}`),e.priority&&n.push(`\u26A1 Priority: ${e.priority}`),e.badge!=null&&n.push(`\u{1F522} Badge: ${e.badge}`),e.sound&&n.push(`\u{1F50A} Sound: ${e.sound}`),e.imageUrl&&n.push(`\u{1F5BC}\uFE0F Image: ${e.imageUrl}`),n.push(""),e.data&&Object.keys(e.data).length>0&&(n.push("\u{1F4E6} Custom Data Payload:"),n.push(a(e.data)),n.push("")),e.customDomainAttributes&&Object.keys(e.customDomainAttributes).length>0&&(n.push("\u{1F3E2} Domain Attributes:"),n.push(a(e.customDomainAttributes)),n.push("")),e.rawPayload!=null&&(n.push("\u2699\uFE0F Raw Payload:"),n.push(a(e.rawPayload)),n.push("")),n.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),n.push("Generated by React Native InApp Inspector"),n.join(`
3
+ `)}export function formatCrashReport(e){const s=`${e.dateStr||""} ${e.timeStr||""}`.trim()||i(e.timestamp),t=["\u{1F4A5} CRASH REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u26A0\uFE0F Error: ${e.name||"Error"}: ${e.message||"Unknown error"}`,`\u{1F6A8} Fatal: ${e.isFatal?"YES (Fatal)":"NO (Caught)"}`,`\u{1F3F7}\uFE0F Type: ${(e.type||"js").toUpperCase()}`,`\u{1F552} Time: ${s}`];return e.deviceInfo&&t.push(`\u{1F4F1} Platform: ${e.deviceInfo.platform||"N/A"} (OS: ${e.deviceInfo.osVersion||"N/A"}, RN: ${e.deviceInfo.rnVersion||"N/A"})`),e.memoryInfo?.usedJSHeapSize&&t.push(`\u{1F4BE} Used Heap: ${Math.round(e.memoryInfo.usedJSHeapSize/(1024*1024))} MB`),t.push(""),e.stack&&(t.push("\u{1F4DC} Stack Trace:"),t.push(e.stack),t.push("")),e.breadcrumbs&&e.breadcrumbs.length>0&&(t.push(`\u{1F43E} Breadcrumbs (${e.breadcrumbs.length}):`),e.breadcrumbs.slice(-10).forEach(u=>{t.push(` \u2022 [${u.type}] ${u.message} (${i(u.timestamp)})`)}),t.push("")),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push("Generated by React Native InApp Inspector"),t.join(`
4
+ `)}export function formatAnalyticsReport(e){const s=i(e.timestamp),t=["\u{1F4CA} ANALYTICS EVENT REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4CC} Event Name: ${e.name||"Unknown"}`,`\u{1F3E2} Source: ${(e.source||"manual").toUpperCase()}`,`\u{1F552} Timestamp: ${s}`];return e.screenName&&t.push(`\u{1F4F1} Screen Name: ${e.screenName}`),e.userId&&t.push(`\u{1F464} User ID: ${e.userId}`),e.trackingId&&t.push(`\u{1F194} Tracking ID: ${e.trackingId}`),t.push(""),e.params&&Object.keys(e.params).length>0&&(t.push("\u{1F4E6} Event Parameters:"),t.push(a(e.params)),t.push("")),e.userProperties&&Object.keys(e.userProperties).length>0&&(t.push("\u{1F464} User Properties:"),t.push(a(e.userProperties)),t.push("")),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push("Generated by React Native InApp Inspector"),t.join(`
5
+ `)}export function formatReduxReport(e){const s=typeof e.timestamp=="number"?i(e.timestamp):e.timestamp,t=["\u{1F504} REDUX ACTION REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4CC} Action Type: ${e.type||"UNKNOWN"}`,`\u{1F552} Timestamp: ${s}`];return e.caller&&t.push(`\u{1F4CD} Caller: ${e.caller}`),e.originType&&t.push(`\u2699\uFE0F Origin: ${e.originType}`),e.affectedSlices&&e.affectedSlices.length>0&&t.push(`\u{1F370} Slices: ${e.affectedSlices.join(", ")}`),t.push(""),t.push("\u{1F4E6} Action Payload:"),t.push(a(e.payload)),t.push(""),e.prevState!==void 0&&(t.push("\u23EE\uFE0F Previous State:"),t.push(a(e.prevState)),t.push("")),e.nextState!==void 0&&(t.push("\u23ED\uFE0F Next State:"),t.push(a(e.nextState)),t.push("")),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push("Generated by React Native InApp Inspector"),t.join(`
6
+ `)}export function formatLogReport(e){const s=i(e.timestamp),t=["\u{1F4DC} CONSOLE LOG REPORT","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4CC} Level: ${(e.type||"info").toUpperCase()}`,`\u{1F552} Timestamp: ${s}`,`\u{1F4AC} Message: ${e.message||""}`];return e.caller&&t.push(`\u{1F4CD} Caller: ${e.caller}`),t.push(""),e.rawArgs&&e.rawArgs.length>0&&(t.push("\u{1F4E6} Arguments:"),t.push(a(e.rawArgs)),t.push("")),(e.stack||e.errorStack)&&(t.push("\u{1F4DC} Stack Trace:"),t.push(e.stack||e.errorStack||""),t.push("")),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push("Generated by React Native InApp Inspector"),t.join(`
7
+ `)}async function r(e,s){try{await m.share({title:e,message:s},{dialogTitle:e})}catch(t){t?.message!=="User did not share"&&h.alert("Share Error",t?.message||"Failed to open share sheet")}}export async function shareApiReport(e){const s=formatApiReport(e),t=`API: ${e.method||"GET"} ${e.url?.substring(0,40)||""}`;await r(t,s)}export async function sharePushReport(e){const s=formatPushReport(e),t=`Push: ${e.title||e.id||"Notification"}`;await r(t,s)}export async function shareCrashReport(e){const s=formatCrashReport(e),t=`Crash: ${e.name||e.message||"Error"}`;await r(t,s)}export async function shareAnalyticsReport(e){const s=formatAnalyticsReport(e),t=`Analytics: ${e.name||"Event"}`;await r(t,s)}export async function shareReduxReport(e){const s=formatReduxReport(e),t=`Redux: ${e.type||"Action"}`;await r(t,s)}export async function shareLogReport(e){const s=formatLogReport(e),t=`Log: ${(e.type||"info").toUpperCase()} - ${e.message?.substring(0,30)||""}`;await r(t,s)}