@buoy-gg/network 7.0.77 → 7.0.79
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/README.md +68 -2
- package/lib/commonjs/expo-network.js +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.web.js +1 -1
- package/lib/commonjs/netinfo.js +1 -0
- package/lib/commonjs/network/components/NetworkCopySettingsView.js +1 -1
- package/lib/commonjs/network/components/NetworkEventDetailView.js +2 -2
- package/lib/commonjs/network/components/NetworkEventDetailView.web.js +1 -1
- package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -2
- package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +1 -1
- package/lib/commonjs/network/components/NetworkListScreen.js +1 -1
- package/lib/commonjs/network/components/NetworkModal.js +1 -1
- package/lib/commonjs/network/components/NetworkSavedScreen.js +1 -1
- package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -1
- package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -1
- package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -1
- package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -1
- package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -1
- package/lib/commonjs/network/conditions/connectivity/netInfoFacade.js +1 -0
- package/lib/commonjs/network/conditions/connectivity/patchNetwork.js +1 -0
- package/lib/commonjs/network/conditions/pacer.js +1 -0
- package/lib/commonjs/network/conditions/profiles.js +1 -0
- package/lib/commonjs/network/conditions/remoteState.js +1 -0
- package/lib/commonjs/network/conditions/store.js +1 -1
- package/lib/commonjs/network/conditions/wait.js +1 -1
- package/lib/commonjs/network/conditions/xhr.js +1 -1
- package/lib/commonjs/network/overrides/engine.js +1 -1
- package/lib/commonjs/network/overrides/matchRule.js +1 -1
- package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -1
- package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -1
- package/lib/commonjs/network/utils/generateNetworkCopyText.js +1 -0
- package/lib/commonjs/network/utils/networkListener.js +4 -4
- package/lib/module/expo-network.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.web.js +1 -1
- package/lib/module/netinfo.js +1 -0
- package/lib/module/network/components/NetworkCopySettingsView.js +3 -3
- package/lib/module/network/components/NetworkEventDetailView.js +2 -2
- package/lib/module/network/components/NetworkEventDetailView.web.js +2 -2
- package/lib/module/network/components/NetworkEventItemCompact.js +2 -2
- package/lib/module/network/components/NetworkEventItemCompact.web.js +1 -1
- package/lib/module/network/components/NetworkListScreen.js +1 -1
- package/lib/module/network/components/NetworkModal.js +1 -1
- package/lib/module/network/components/NetworkSavedScreen.js +1 -1
- package/lib/module/network/conditions/NetworkConditionsControl.js +1 -1
- package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -1
- package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -1
- package/lib/module/network/conditions/NetworkFloatingTool.js +1 -1
- package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -1
- package/lib/module/network/conditions/connectivity/netInfoFacade.js +1 -0
- package/lib/module/network/conditions/connectivity/patchNetwork.js +1 -0
- package/lib/module/network/conditions/pacer.js +1 -0
- package/lib/module/network/conditions/profiles.js +1 -0
- package/lib/module/network/conditions/remoteState.js +1 -0
- package/lib/module/network/conditions/store.js +1 -1
- package/lib/module/network/conditions/wait.js +1 -1
- package/lib/module/network/conditions/xhr.js +1 -1
- package/lib/module/network/overrides/engine.js +1 -1
- package/lib/module/network/overrides/matchRule.js +1 -1
- package/lib/module/network/overrides/overrideRulesStore.js +1 -1
- package/lib/module/network/sync/networkSyncAdapter.js +1 -1
- package/lib/module/network/utils/generateNetworkCopyText.js +23 -22
- package/lib/module/network/utils/networkListener.js +4 -4
- package/lib/typescript/expo-network.d.ts +2 -0
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/index.web.d.ts +3 -2
- package/lib/typescript/netinfo.d.ts +3 -0
- package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts +5 -2
- package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts +4 -3
- package/lib/typescript/network/conditions/connectivity/netInfoFacade.d.ts +3 -0
- package/lib/typescript/network/conditions/connectivity/patchNetwork.d.ts +24 -0
- package/lib/typescript/network/conditions/pacer.d.ts +16 -0
- package/lib/typescript/network/conditions/profiles.d.ts +57 -0
- package/lib/typescript/network/conditions/remoteState.d.ts +4 -0
- package/lib/typescript/network/conditions/store.d.ts +45 -19
- package/lib/typescript/network/conditions/xhr.d.ts +1 -1
- package/lib/typescript/network/overrides/engine.d.ts +14 -0
- package/lib/typescript/network/overrides/matchRule.d.ts +3 -0
- package/lib/typescript/network/overrides/overrideRulesStore.d.ts +3 -0
- package/lib/typescript/network/overrides/types.d.ts +19 -0
- package/lib/typescript/network/sync/networkSyncAdapter.d.ts +27 -12
- package/lib/typescript/network/utils/networkListener.d.ts +4 -0
- package/lib/web/index.mjs +58 -57
- package/package.json +26 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.stopNetworkListener=exports.startNetworkListener=exports.removeAllNetworkListeners=exports.networkListener=exports.isNetworkListening=exports.isNetworkInterceptionLive=exports.getNetworkListenerCount=exports.addNetworkListener=exports.BUOY_XHR_INTERCEPTOR_FLAG=exports.BUOY_FETCH_INTERCEPTOR_FLAG=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _resolveRequestUrl=require("./resolveRequestUrl");var _requestId=require("./requestId");var _xhr=require("../conditions/xhr");var _store=require("../conditions/store");var _wait=require("../conditions/wait");var _engine=require("../overrides/engine");var _applyToXhr=require("../overrides/applyToXhr");var _applyToFetch=require("../overrides/applyToFetch");var _types=require("../overrides/types");var _httpCompletion=require("./httpCompletion");var _realNow=require("./realNow");let devOrigin;function injectedHeaders(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.stopNetworkListener=exports.startNetworkListener=exports.removeAllNetworkListeners=exports.networkListener=exports.isNetworkListening=exports.isNetworkInterceptionLive=exports.getNetworkListenerCount=exports.addNetworkListener=exports.BUOY_XHR_INTERCEPTOR_FLAG=exports.BUOY_FETCH_INTERCEPTOR_FLAG=void 0;var _pacer=require("../conditions/pacer");var _sharedUi=require("@buoy-gg/shared-ui");var _resolveRequestUrl=require("./resolveRequestUrl");var _requestId=require("./requestId");var _xhr=require("../conditions/xhr");var _store=require("../conditions/store");var _wait=require("../conditions/wait");var _engine=require("../overrides/engine");var _applyToXhr=require("../overrides/applyToXhr");var _applyToFetch=require("../overrides/applyToFetch");var _types=require("../overrides/types");var _httpCompletion=require("./httpCompletion");var _realNow=require("./realNow");let devOrigin;function injectedHeaders(b){const e=globalThis.__buoyHeaderInjectors;if(!e||e.length===0)return void 0;let t;for(const s of e){try{const l=s(b);if(l)t={...t,...l}}catch{}}return t}function devServerOrigin(){if(devOrigin!==void 0)return devOrigin;devOrigin=null;try{if(typeof __DEV__!=="undefined"&&!__DEV__)return devOrigin;const b=require("react-native");const e=b?.NativeModules?.SourceCode;const t=e?.getConstants?.().scriptURL??e?.scriptURL;if(typeof t==="string"&&/^https?:\/\//.test(t)){const s=new URL(t);devOrigin=`${s.protocol}//${s.host}`}}catch{devOrigin=null}return devOrigin}let insideFetchHandoff=false;const EARLY_NETWORK_KEY=Symbol.for("buoy.earlyNetwork");function headersToRecord(b){const e={};if(!b)return e;if(typeof Headers!=="undefined"&&b instanceof Headers)b.forEach((t,s)=>{e[s]=t});else if(Array.isArray(b))for(const[t,s]of b)e[t]=s;else Object.assign(e,b);return e}const BUOY_FETCH_INTERCEPTOR_FLAG=exports.BUOY_FETCH_INTERCEPTOR_FLAG="__buoyNetworkFetchIntercepted";const BUOY_XHR_INTERCEPTOR_FLAG=exports.BUOY_XHR_INTERCEPTOR_FLAG="__buoyNetworkXhrIntercepted";const STREAMED_CONTENT_TYPES=["text/event-stream","application/x-ndjson","application/stream+json"];const STREAMING_PLACEHOLDER="[streaming\u2026]";let angularPageSeen=false;function isAngularPage(){if(angularPageSeen)return true;const b=globalThis.document;angularPageSeen=!!b?.querySelector?.("[ng-version]");return angularPageSeen}function isStreamedContentType(b){if(!b)return false;const e=b.toLowerCase();return STREAMED_CONTENT_TYPES.some(t=>e.includes(t))}const INTERNAL_HOSTS_KEY="__BUOY_INTERNAL_HOSTS__";function isInternalBuoyHost(b){const e=globalThis[INTERNAL_HOSTS_KEY];if(!(e instanceof Set)||e.size===0)return false;let t;try{t=new URL(b).host.toLowerCase()}catch{return false}for(const s of e){if(typeof s==="string"&&s&&t===s.toLowerCase())return true}return false}class NetworkListener{listeners=[];isListening=false;patchedFetch=null;patchedXHROpen=null;patchedXHRSend=null;patchedXHRSetRequestHeader=null;fetchGeneration=0;xhrGeneration=0;constructor(){this.originalFetch=globalThis.fetch;this.originalXHROpen=XMLHttpRequest.prototype.open;this.originalXHRSend=XMLHttpRequest.prototype.send;this.originalXHRSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader}shouldIgnoreUrl(e){if((0,_sharedUi.isBuoyRequest)(e))return true;try{const t=new URL(e);if(t.hostname==="keygen.sh"||t.hostname.endsWith(".keygen.sh"))return true;if((t.hostname==="buoy.gg"||t.hostname==="www.buoy.gg")&&(t.pathname.startsWith("/api/license")||t.pathname.startsWith("/api/settings/")))return true;const s=t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="10.0.2.2";if(s&&["8081","8802"].includes(t.port))return true;const l=devServerOrigin();if(l&&`${t.protocol}//${t.host}`===l)return true}catch{return false}return isInternalBuoyHost(e)}emit(e){this.listeners.forEach(t=>{try{t(e)}catch(s){}})}parseUrl(e){let t=null;const s=e.indexOf("?");if(s>-1){t={};e.substring(s+1).split("&").forEach(l=>{const[u,i]=l.split("=");if(u&&i!==void 0){t[u]=decodeURIComponent(i.replace(/\+/g," "))}})}return{url:s>-1?e.substring(0,s):e,params:t}}async readStreamedBody(e,t=256*1024){const s=e.body;if(!s||typeof s.getReader!=="function"){const f=await e.text();return f.length>t?{body:`${f.slice(0,t)}
|
|
2
2
|
|
|
3
|
-
... [truncated]`,size:f.length}:{body:f,size:f.length}}const
|
|
3
|
+
... [truncated]`,size:f.length}:{body:f,size:f.length}}const l=s.getReader();const u=new TextDecoder;let i="";let h=0;let R=false;try{for(;;){const{done:f,value:a}=await l.read();if(f)break;h+=a?.byteLength??0;if(!R){i+=u.decode(a,{stream:true});if(h>=t){i=`${i.slice(0,t)}
|
|
4
4
|
|
|
5
|
-
... [truncated]`;
|
|
5
|
+
... [truncated]`;R=true;break}}}if(!R)i+=u.decode()}finally{try{void Promise.resolve(l.cancel()).catch(()=>{})}catch{}try{l.releaseLock()}catch{}}return{body:i,size:h}}async processResponseBody(e,t=1024*1024){try{const s=e.headers.get("content-length");if(s){const i=parseInt(s,10);if(!isNaN(i)&&i>t){return{body:`[Response too large: ${this.formatBytes(i)}]`,size:i,truncated:true}}}const l=await e.text();const u=l.length;if(u>t){const i=l.substring(0,t);const h=u-t;return{body:`${i}
|
|
6
6
|
|
|
7
|
-
... [truncated, ${this.formatBytes(l)} omitted]`,size:a,truncated:true}}try{return{body:JSON.parse(c),size:a,truncated:false}}catch{return{body:c,size:a,truncated:false}}}catch(r){return{body:"~~~ unable to read body ~~~",size:0,truncated:false}}}formatBytes(e){if(e===0)return"0 B";const t=1024;const r=["B","KB","MB","GB"];const c=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/Math.pow(t,c)*100)/100} ${r[c]}`}handleXHRResponse(e,t,r,c,a,n,l,m,f=false,i="xhr",d,L){const y=m?(0,_realNow.realNow)()-m:0;const h=e._buoyTtfb;const H=h===void 0?void 0:{ttfb:h,download:Math.max(0,y-h)};if(f||e.status===0){this.emit({type:"error",timestamp:new Date,duration:y,request:{id:t||"unknown",url:r,method:c,headers:a,data:n,params:l||void 0,client:i},error:{message:f?"Request failed":"Network error or request aborted"},override:d,condition:L});return}let s;let p=0;try{const o=e.response;if(e.responseType==="json"&&o){s=o;p=JSON.stringify(o).length}else if(e.responseType===""||e.responseType==="text"){if(e.responseText){p=e.responseText.length;try{s=JSON.parse(e.responseText)}catch{s=e.responseText}}}else if(e.responseType==="arraybuffer"){if(o){try{const q=new TextDecoder("utf-8").decode(o);p=q.length;try{s=JSON.parse(q)}catch{s=q}}catch(q){s=`[arraybuffer response - ${o.byteLength||0} bytes]`;p=o.byteLength||0}}else{s=`[arraybuffer response - no data]`;p=0}}else if(e.responseType==="blob"){if(o instanceof Blob){s=`[blob response - ${o.size} bytes, type: ${o.type||"unknown"}]`;p=o.size}else if(o){try{s=typeof o==="string"?JSON.parse(o):o;p=JSON.stringify(s).length}catch{s=`[blob response - unable to parse]`;p=0}}else{s=`[blob response - no data]`;p=0}}else if(o){if(typeof o==="string"){s=o;p=o.length;try{s=JSON.parse(o)}catch{}}else if(typeof o==="object"){s=o;p=JSON.stringify(o).length}else{s=String(o);p=String(o).length}}}catch(o){s="~~~ unable to read body ~~~"}const w={};try{const o=e.getAllResponseHeaders();if(o){o.split("\r\n").forEach(q=>{if(q){const R=q.indexOf(": ");if(R>0){const v=q.substring(0,R).toLowerCase();const u=q.substring(R+2);w[v]=u}}})}}catch{}if((0,_httpCompletion.xhrCompletionKind)(e.status)==="response"){this.emit({type:"response",timestamp:new Date,duration:y,timings:H,request:{id:t||"unknown",url:r,method:c,headers:a,data:n,params:l||void 0,client:i},response:{status:e.status,statusText:(0,_httpCompletion.httpStatusText)(e.status,e.statusText),headers:w,body:s,size:p},override:d,condition:L})}else{this.emit({type:"error",timestamp:new Date,duration:y,request:{id:t||"unknown",url:r,method:c,headers:a,data:n,params:l||void 0,client:i},response:{status:e.status,statusText:e.statusText,headers:w,body:s,size:p},error:{message:"Network Error"},override:d,condition:L})}}isFetchInterceptionLive(){return globalThis.fetch[BUOY_FETCH_INTERCEPTOR_FLAG]===true}isXhrInterceptionLive(){return XMLHttpRequest.prototype.send[BUOY_XHR_INTERCEPTOR_FLAG]===true}isInterceptionLive(){return this.isFetchInterceptionLive()&&this.isXhrInterceptionLive()}startListening(){const e=this.isListening&&this.isFetchInterceptionLive();const t=this.isListening&&this.isXhrInterceptionLive();if(e&&t){return}if(!e){this.installFetchInterceptor()}if(!t){this.installXhrInterceptor()}this.isListening=true;if(__DEV__){}}installFetchInterceptor(){const e=this;const t=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;const r=++this.fetchGeneration;const c=async(a,n)=>{const l=(0,_resolveRequestUrl.resolveRequestUrl)(typeof a==="string"?a:a instanceof URL?a.href:a.url);if(r!==e.fetchGeneration){return t(a,n)}if(n?.__buoyInternal||e.shouldIgnoreUrl(l)){const u=insideFetchHandoff;insideFetchHandoff=true;try{return t(a,n)}finally{insideFetchHandoff=u}}const m=(0,_realNow.realNow)();const f=(0,_requestId.nextRequestId)("fetch");const i=typeof a==="object"&&"method"in a?a:void 0;const d=n?.method??i?.method??"GET";const L=n?.signal!==void 0?n.signal:i?.signal;(0,_wait.throwIfAborted)(L);const y=(0,_store.snapshotNetworkCondition)(l);const{url:h,params:H}=e.parseUrl(l);let s={};const p=n?.headers??i?.headers;if(p){if(p instanceof Headers){p.forEach((u,b)=>{s[b]=u})}else if(Array.isArray(p)){p.forEach(([u,b])=>{s[u]=b})}else{s={...p}}}Object.assign(s,injectedHeaders(l));let w;if(n?.body){if(typeof n.body==="string"){try{w=JSON.parse(n.body)}catch{w=n.body}}else{w=n.body}}const o=s["X-Request-Client"]||s["x-request-client"]||"fetch";const q=y?.profile!=="offline"&&(0,_applyToFetch.canSynthesizeResponse)()?(0,_engine.accountCheckFor)(l,d,s,typeof n?.body==="string"?n.body:void 0):null;if(q)await q;const R=y?.profile!=="offline"&&(0,_applyToFetch.canSynthesizeResponse)()?(0,_engine.overrideForRequest)(l,d,s,typeof n?.body==="string"?n.body:void 0):null;const v=R?(0,_types.markForOutcome)(R):void 0;e.emit({type:"request",timestamp:new Date,request:{id:f||"unknown",url:h,method:d,headers:s,data:w,params:H||void 0,client:o},override:v,condition:y});if(n?.body===void 0&&i?.body&&!i.bodyUsed){try{const u=i.clone();void e.readStreamedBody(u).then(({body:b})=>{try{w=JSON.parse(b)}catch{w=b}e.emit({type:"request-body",timestamp:new Date,request:{id:f||"unknown",url:h,method:d,data:w,client:o}})}).catch(()=>{})}catch{}}try{if(y||R)await(0,_wait.waitBeforeDispatch)((y?.delayMs??0)+(R?.delayMs??0),L);(0,_wait.throwIfAborted)(L);if(y?.profile==="offline")throw new TypeError("Network request failed (Buoy Offline)");if(R?.kind==="fail")throw(0,_applyToFetch.synthesizeFetchError)(R);let u;if(R?.kind==="respond"){u=(0,_applyToFetch.synthesizeResponse)(l,R)}else{const T=insideFetchHandoff;insideFetchHandoff=true;let _;try{_=t(a,n)}finally{insideFetchHandoff=T}u=await _}const b=(0,_realNow.realNow)()-m;const N=typeof u.body?.getReader==="function"||isStreamedContentType(u.headers?.get?.("content-type"));const S=u.clone();const{body:x,size:k}=N?{body:STREAMING_PLACEHOLDER,size:0}:await e.processResponseBody(S);const X=(0,_realNow.realNow)()-m;const O=Math.max(0,X-b);const I=O>0?{ttfb:b,download:O}:void 0;const E={};u.headers.forEach((T,_)=>{E[_.toLowerCase()]=T});e.emit({type:"response",timestamp:new Date,duration:X,timings:I,request:{id:f||"unknown",url:h,method:d,headers:s,data:w,params:H||void 0,client:o},response:{status:u.status,statusText:u.statusText,headers:E,body:x,size:k},override:v,condition:y});if(N){const T=u.headers?.get?.("content-type");void e.readStreamedBody(S,isStreamedContentType(T)?void 0:1024*1024).then(_=>{let C=_.body;if(T?.includes("json")){try{C=JSON.parse(_.body)}catch{}}e.emit({type:"response",timestamp:new Date,duration:(0,_realNow.realNow)()-m,timings:I,request:{id:f||"unknown",url:h,method:d,headers:s,data:w,params:H||void 0,client:o},response:{status:u.status,statusText:u.statusText,headers:E,body:C,size:_.size},override:v,condition:y})}).catch(()=>{})}return u}catch(u){const b=(0,_realNow.realNow)()-m;e.emit({type:"error",timestamp:new Date,duration:b,request:{id:f||"unknown",url:h,method:d,headers:s,data:w,params:H||void 0,client:o},error:{message:u instanceof Error?u.message:"Network error",stack:u instanceof Error?u.stack:void 0},override:v,condition:y});throw u}};c[BUOY_FETCH_INTERCEPTOR_FLAG]=true;this.patchedFetch=c;globalThis.fetch=this.patchedFetch}installXhrInterceptor(){const e=this;const t=XMLHttpRequest.prototype.open;const r=XMLHttpRequest.prototype.send;const c=XMLHttpRequest.prototype.setRequestHeader;this.originalXHROpen=t;this.originalXHRSend=r;this.originalXHRSetRequestHeader=c;const a=++this.xhrGeneration;const n=new WeakMap;const l=function(i,d,L,y,h){const H=t.call(this,i,d,L??true,y,h);if(a===e.xhrGeneration){n.get(this)?.();const s=this;s._buoyRequestId=(0,_requestId.nextRequestId)("xhr");s._method=i;s._url=(0,_resolveRequestUrl.resolveRequestUrl)(d);s._buoyStartTime=(0,_realNow.realNow)();s._requestHeaders={}}return H};const m=function(i,d){const L=this;if(a===e.xhrGeneration&&L._requestHeaders){L._requestHeaders[i]=d}return c.call(this,i,d)};const f=function(i){if(a!==e.xhrGeneration||insideFetchHandoff){return r.call(this,i)}if((0,_applyToXhr.hasPendingStandardRequest)(this))throw new DOMException("The request has already been sent.","InvalidStateError");if(this.readyState!==1||this._sent){return r.call(this,i)}const d=this;const L=d._buoyRequestId;const y=d._method||"GET";const h=d._url||"";const H=(0,_realNow.realNow)();d._buoyStartTime=H;d._buoyTtfb=void 0;const s=d._requestHeaders||{};Object.assign(s,injectedHeaders(h));if(e.shouldIgnoreUrl(h)){return r.call(this,i)}const{url:p,params:w}=e.parseUrl(h);let o;if(i){if(typeof i==="string"){try{o=JSON.parse(i)}catch{o=i}}else{o=i}}const q=s["X-Request-Client"]||s["x-request-client"];const R=s["Accept"]||s["accept"]||"";const v=R.includes("application/json")&&R.includes("text/plain")&&R.includes("*/*")&&!isAngularPage();const u=q||(v?"axios":"xhr");const b=(0,_store.snapshotNetworkCondition)(h);const N=b?.profile==="offline"?null:(0,_engine.overrideForRequest)(h,y,s,typeof i==="string"?i:void 0);const S=N?(0,_types.markForOutcome)(N):void 0;e.emit({type:"request",timestamp:new Date,request:{id:L||"unknown",url:p,method:y,headers:s,data:o,params:w||void 0,client:u},override:S,condition:b});let x=false;const k=(_=false)=>{if(x)return;x=true;e.handleXHRResponse(this,L||"unknown",p,y,s,o,w,H||0,_,u,S,b);X()};const X=()=>{n.delete(this);this.removeEventListener("load",O);this.removeEventListener("error",I);this.removeEventListener("abort",E);this.removeEventListener("readystatechange",T)};n.set(this,X);const O=()=>{k(false)};const I=()=>{k(true)};const E=()=>{k(true)};const T=()=>{if(this.readyState===2){const _=this;if(_._buoyTtfb===void 0&&_._buoyStartTime){_._buoyTtfb=(0,_realNow.realNow)()-_._buoyStartTime}}if(this.readyState===4&&!x){k(false)}};this.addEventListener("load",O);this.addEventListener("error",I);this.addEventListener("abort",E);this.addEventListener("readystatechange",T);if(b){(0,_xhr.runConditionXhr)(this,h,b,N,()=>r.call(this,i));return}if(N){const _=(0,_applyToXhr.runOverride)(this,h,N,()=>r.call(this,i));if(_)return}return r.call(this,i)};f[BUOY_XHR_INTERCEPTOR_FLAG]=true;this.patchedXHROpen=l;this.patchedXHRSend=f;this.patchedXHRSetRequestHeader=m;XMLHttpRequest.prototype.open=this.patchedXHROpen;XMLHttpRequest.prototype.send=this.patchedXHRSend;XMLHttpRequest.prototype.setRequestHeader=this.patchedXHRSetRequestHeader}stopListening(){if(!this.isListening){return}this.fetchGeneration++;this.xhrGeneration++;if(this.patchedFetch&&globalThis.fetch===this.patchedFetch){globalThis.fetch=this.originalFetch}if(this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen){XMLHttpRequest.prototype.open=this.originalXHROpen}if(this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend){XMLHttpRequest.prototype.send=this.originalXHRSend}if(this.patchedXHRSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.patchedXHRSetRequestHeader){XMLHttpRequest.prototype.setRequestHeader=this.originalXHRSetRequestHeader}this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.patchedXHRSetRequestHeader=null;this.isListening=false;if(__DEV__){}}adoptEarlyRequests(){const e=globalThis.__BUOY_EARLY_NETWORK__;if(e?.version!==1)return;for(const t of e.adopt()){try{if(t.kind==="fetch")this.adoptEarlyFetch(t);else this.adoptEarlyXhr(t)}catch{}}}adoptEarlyFetch(e){const{input:t,init:r}=e;const c=typeof t==="object"&&"method"in t?t:void 0;const a=(0,_resolveRequestUrl.resolveRequestUrl)(typeof t==="string"?t:t instanceof URL?t.href:t.url);if(this.shouldIgnoreUrl(a))return;const n=(0,_requestId.nextRequestId)("fetch");const l=r?.method??c?.method??"GET";const{url:m,params:f}=this.parseUrl(a);const i=headersToRecord(r?.headers??c?.headers);let d=r?.body;if(typeof d==="string"){try{d=JSON.parse(d)}catch{}}const L=i["X-Request-Client"]||i["x-request-client"]||"fetch";const y=()=>({id:n,url:m,method:l,headers:i,data:d,params:f||void 0,client:L});this.emit({type:"request",timestamp:new Date(e.start),request:y()});if(e.requestCopy){void this.readStreamedBody(e.requestCopy).then(({body:h})=>{try{d=JSON.parse(h)}catch{d=h}this.emit({type:"request-body",timestamp:new Date,request:{id:n,url:m,method:l,data:d,client:L}})}).catch(()=>{})}void e.settled.then(async({response:h,clone:H,error:s,headersAt:p})=>{if(!h){this.emit({type:"error",timestamp:new Date,duration:p-e.start,request:y(),error:{message:s instanceof Error?s.message:"Network error",stack:s instanceof Error?s.stack:void 0}});return}const{body:w,size:o}=H?await this.processResponseBody(H):{body:STREAMING_PLACEHOLDER,size:0};const q=Math.max(0,(0,_realNow.realNow)()-e.start);const R=p-e.start;const v={};h.headers.forEach((u,b)=>{v[b.toLowerCase()]=u});this.emit({type:"response",timestamp:new Date,duration:q,timings:q>R?{ttfb:R,download:q-R}:void 0,request:y(),response:{status:h.status,statusText:h.statusText,headers:v,body:w,size:o}})})}adoptEarlyXhr(e){const t=(0,_resolveRequestUrl.resolveRequestUrl)(e.url);if(this.shouldIgnoreUrl(t))return;const r=(0,_requestId.nextRequestId)("xhr");const c=e.method.toUpperCase();const{url:a,params:n}=this.parseUrl(t);let l=e.body;if(typeof l==="string"){try{l=JSON.parse(l)}catch{}}const m=e.headers["X-Request-Client"]||e.headers["x-request-client"]||"xhr";this.emit({type:"request",timestamp:new Date(e.start),request:{id:r,url:a,method:c,headers:e.headers,data:l,params:n||void 0,client:m}});const f=e.xhr;const i=()=>{const d=(f._buoyEarlyEnd??(0,_realNow.realNow)())-e.start;this.handleXHRResponse(f,r,a,c,e.headers,l,n,(0,_realNow.realNow)()-d,false,m)};if(f.readyState===4)i();else f.addEventListener("loadend",i,{once:true})}addListener(e){this.listeners.push(e);return()=>{const t=this.listeners.indexOf(e);if(t>-1){this.listeners.splice(t,1)}}}removeAllListeners(){this.listeners=[]}get isActive(){return this.isListening}get listenerCount(){return this.listeners.length}}let _networkListener=null;const getNetworkListener=()=>{if(!_networkListener){_networkListener=new NetworkListener}return _networkListener};const networkListener=exports.networkListener=getNetworkListener;const startNetworkListener=()=>getNetworkListener().startListening();exports.startNetworkListener=startNetworkListener;const stopNetworkListener=()=>_networkListener?.stopListening();exports.stopNetworkListener=stopNetworkListener;const addNetworkListener=g=>getNetworkListener().addListener(g);exports.addNetworkListener=addNetworkListener;const removeAllNetworkListeners=()=>_networkListener?.removeAllListeners();exports.removeAllNetworkListeners=removeAllNetworkListeners;const isNetworkListening=()=>_networkListener?.isActive??false;exports.isNetworkListening=isNetworkListening;const getNetworkListenerCount=()=>_networkListener?.listenerCount??0;exports.getNetworkListenerCount=getNetworkListenerCount;const isNetworkInterceptionLive=()=>_networkListener?.isInterceptionLive()??false;exports.isNetworkInterceptionLive=isNetworkInterceptionLive;
|
|
7
|
+
... [truncated, ${this.formatBytes(h)} omitted]`,size:u,truncated:true}}try{return{body:JSON.parse(l),size:u,truncated:false}}catch{return{body:l,size:u,truncated:false}}}catch(s){return{body:"~~~ unable to read body ~~~",size:0,truncated:false}}}formatBytes(e){if(e===0)return"0 B";const t=1024;const s=["B","KB","MB","GB"];const l=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/Math.pow(t,l)*100)/100} ${s[l]}`}handleXHRResponse(e,t,s,l,u,i,h,R,f=false,a="xhr",r,y){const m=R?(0,_realNow.realNow)()-R:0;const c=e._buoyTtfb;const L=c===void 0?void 0:{ttfb:c,download:Math.max(0,m-c)};if(f||e.status===0){this.emit({type:"error",timestamp:new Date,duration:m,request:{id:t||"unknown",url:s,method:l,headers:u,data:i,params:h||void 0,client:a},error:{message:f?"Request failed":"Network error or request aborted"},override:r,condition:y});return}let o;let p=0;try{const n=e.response;if(e.responseType==="json"&&n){o=n;p=JSON.stringify(n).length}else if(e.responseType===""||e.responseType==="text"){if(e.responseText){p=e.responseText.length;try{o=JSON.parse(e.responseText)}catch{o=e.responseText}}}else if(e.responseType==="arraybuffer"){if(n){try{const g=new TextDecoder("utf-8").decode(n);p=g.length;try{o=JSON.parse(g)}catch{o=g}}catch(g){o=`[arraybuffer response - ${n.byteLength||0} bytes]`;p=n.byteLength||0}}else{o=`[arraybuffer response - no data]`;p=0}}else if(e.responseType==="blob"){if(n instanceof Blob){o=`[blob response - ${n.size} bytes, type: ${n.type||"unknown"}]`;p=n.size}else if(n){try{o=typeof n==="string"?JSON.parse(n):n;p=JSON.stringify(o).length}catch{o=`[blob response - unable to parse]`;p=0}}else{o=`[blob response - no data]`;p=0}}else if(n){if(typeof n==="string"){o=n;p=n.length;try{o=JSON.parse(n)}catch{}}else if(typeof n==="object"){o=n;p=JSON.stringify(n).length}else{o=String(n);p=String(n).length}}}catch(n){o="~~~ unable to read body ~~~"}if(y?.downloadBytesPerSecond&&(!e.responseType||e.responseType==="text"||e.responseType==="json")){const n=e._response;if(typeof n==="string")p=(0,_pacer.utf8Length)(n)}const _={};try{const n=e.getAllResponseHeaders();if(n){n.split("\r\n").forEach(g=>{if(g){const w=g.indexOf(": ");if(w>0){const k=g.substring(0,w).toLowerCase();const q=g.substring(w+2);_[k]=q}}})}}catch{}if((0,_httpCompletion.xhrCompletionKind)(e.status)==="response"){this.emit({type:"response",timestamp:new Date,duration:m,timings:L,request:{id:t||"unknown",url:s,method:l,headers:u,data:i,params:h||void 0,client:a},response:{status:e.status,statusText:(0,_httpCompletion.httpStatusText)(e.status,e.statusText),headers:_,body:o,size:p},override:r,condition:y})}else{this.emit({type:"error",timestamp:new Date,duration:m,request:{id:t||"unknown",url:s,method:l,headers:u,data:i,params:h||void 0,client:a},response:{status:e.status,statusText:e.statusText,headers:_,body:o,size:p},error:{message:"Network Error"},override:r,condition:y})}}isFetchInterceptionLive(){return globalThis.fetch[BUOY_FETCH_INTERCEPTOR_FLAG]===true}isXhrInterceptionLive(){return XMLHttpRequest.prototype.send[BUOY_XHR_INTERCEPTOR_FLAG]===true}isInterceptionLive(){return this.isFetchInterceptionLive()&&this.isXhrInterceptionLive()}startListening(){const e=this.isListening&&this.isFetchInterceptionLive();const t=this.isListening&&this.isXhrInterceptionLive();if(e&&t){return}if(!e){this.installFetchInterceptor()}if(!t){this.installXhrInterceptor()}this.isListening=true;if(__DEV__){}}installFetchInterceptor(){const e=this;const t=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;const s=++this.fetchGeneration;const l=async(u,i)=>{const h=(0,_resolveRequestUrl.resolveRequestUrl)(typeof u==="string"?u:u instanceof URL?u.href:u.url);if(s!==e.fetchGeneration){return t(u,i)}if(i?.__buoyInternal||e.shouldIgnoreUrl(h)){const d=insideFetchHandoff;insideFetchHandoff=true;try{return t(u,i)}finally{insideFetchHandoff=d}}const R=(0,_realNow.realNow)();const f=(0,_requestId.nextRequestId)("fetch");const a=typeof u==="object"&&"method"in u?u:void 0;const r=i?.method??a?.method??"GET";const y=i?.signal!==void 0?i.signal:a?.signal;(0,_wait.throwIfAborted)(y);const m=(0,_store.snapshotNetworkCondition)(h);const c=m?.uploadBytesPerSecond?{...m,uploadCap:(0,_pacer.uploadBodySize)(u,i)}:m;const{url:L,params:o}=e.parseUrl(h);let p={};const _=i?.headers??a?.headers;if(_){if(_ instanceof Headers){_.forEach((d,S)=>{p[S]=d})}else if(Array.isArray(_)){_.forEach(([d,S])=>{p[d]=S})}else{p={..._}}}Object.assign(p,injectedHeaders(h));let n;if(i?.body){if(typeof i.body==="string"){try{n=JSON.parse(i.body)}catch{n=i.body}}else{n=i.body}}const g=p["X-Request-Client"]||p["x-request-client"]||"fetch";if(c?.profile!=="offline"&&(0,_applyToFetch.canSynthesizeResponse)())await(0,_engine.overrideRulesReady)();let w=typeof i?.body==="string"?i.body:void 0;if(w===void 0&&i?.body===void 0&&a&&!a.bodyUsed&&r!=="GET"&&r!=="HEAD"&&(0,_engine.overrideRulesNeedBody)()){try{w=(await e.readStreamedBody(a.clone())).body}catch{}}const k=c?.profile!=="offline"&&(0,_applyToFetch.canSynthesizeResponse)()?(0,_engine.accountCheckFor)(h,r,p,w):null;if(k)await k;const q=c?.profile!=="offline"&&(0,_applyToFetch.canSynthesizeResponse)()?(0,_engine.overrideForRequest)(h,r,p,w):null;const N=q?(0,_types.markForOutcome)(q):void 0;e.emit({type:"request",timestamp:new Date,request:{id:f||"unknown",url:L,method:r,headers:p,data:n,params:o||void 0,client:g},override:N,condition:c});const X=d=>{try{n=JSON.parse(d)}catch{n=d}e.emit({type:"request-body",timestamp:new Date,request:{id:f||"unknown",url:L,method:r,data:n,client:g}})};if(i?.body===void 0&&a&&typeof w==="string"){X(w)}else if(!c?.uploadBytesPerSecond&&i?.body===void 0&&a&&!a.bodyUsed&&r!=="GET"&&r!=="HEAD"){try{const d=a.clone();void e.readStreamedBody(d).then(({body:S})=>{if(S)X(S)}).catch(()=>{})}catch{}}try{if(c||q)await(0,_wait.waitBeforeDispatch)((c?.delayMs??0)+(q?.delayMs??0),y);(0,_wait.throwIfAborted)(y);if(c?.profile==="offline")throw new TypeError("Network request failed (Buoy Offline)");if(q?.kind==="fail")throw(0,_applyToFetch.synthesizeFetchError)(q);if(c?.uploadBytesPerSecond){await(0,_pacer.paceByteCount)(c.uploadCap?.knownBytes??0,c.uploadBytesPerSecond,y);(0,_wait.throwIfAborted)(y)}let d;if(q?.kind==="respond"){d=(0,_applyToFetch.synthesizeResponse)(h,q)}else{const T=insideFetchHandoff;insideFetchHandoff=true;let H;try{H=t(u,i)}finally{insideFetchHandoff=T}d=await H}if(c?.downloadBytesPerSecond){const T={};d.headers.forEach((O,x)=>{T[x.toLowerCase()]=O});let H=0;let E=0;const z=[];const M=(O,x)=>{const B=new Uint8Array(E);let j=0;for(const J of z){B.set(J,j);j+=J.byteLength}let G=O?new TextDecoder().decode(B):STREAMING_PLACEHOLDER;if(O&&T["content-type"]?.includes("json")){try{G=JSON.parse(G)}catch{}}e.emit({type:x!==void 0?"error":"response",timestamp:new Date,duration:(0,_realNow.realNow)()-R,request:{id:f,url:L,method:r,headers:p,data:n,params:o||void 0,client:g},response:{status:d.status,statusText:d.statusText,headers:T,body:G,size:H},...x!==void 0?{error:{message:x instanceof Error?x.message:String(x)}}:{},override:N,condition:c})};M(false);return(0,_pacer.paceResponse)(d,c.downloadBytesPerSecond,y,(O,x)=>{if(O){H+=O.byteLength;const B=Math.min(O.byteLength,65536-E);if(B>0){z.push(O.slice(0,B));E+=B}}else M(true,x)},r.toUpperCase()==="HEAD")}const S=(0,_realNow.realNow)()-R;const I=typeof d.body?.getReader==="function"||isStreamedContentType(d.headers?.get?.("content-type"));const C=d.clone();const{body:D,size:P}=I?{body:STREAMING_PLACEHOLDER,size:0}:await e.processResponseBody(C);const A=(0,_realNow.realNow)()-R;const F=Math.max(0,A-S);const U=F>0?{ttfb:S,download:F}:void 0;const v={};d.headers.forEach((T,H)=>{v[H.toLowerCase()]=T});e.emit({type:"response",timestamp:new Date,duration:A,timings:U,request:{id:f||"unknown",url:L,method:r,headers:p,data:n,params:o||void 0,client:g},response:{status:d.status,statusText:d.statusText,headers:v,body:D,size:P},override:N,condition:c});if(I){const T=d.headers?.get?.("content-type");void e.readStreamedBody(C,isStreamedContentType(T)?void 0:1024*1024).then(H=>{let E=H.body;if(T?.includes("json")){try{E=JSON.parse(H.body)}catch{}}e.emit({type:"response",timestamp:new Date,duration:(0,_realNow.realNow)()-R,timings:U,request:{id:f||"unknown",url:L,method:r,headers:p,data:n,params:o||void 0,client:g},response:{status:d.status,statusText:d.statusText,headers:v,body:E,size:H.size},override:N,condition:c})}).catch(()=>{})}return d}catch(d){const S=(0,_realNow.realNow)()-R;e.emit({type:"error",timestamp:new Date,duration:S,request:{id:f||"unknown",url:L,method:r,headers:p,data:n,params:o||void 0,client:g},error:{message:d instanceof Error?d.message:"Network error",stack:d instanceof Error?d.stack:void 0},override:N,condition:c});throw d}};l[BUOY_FETCH_INTERCEPTOR_FLAG]=true;this.patchedFetch=l;globalThis.fetch=this.patchedFetch}installXhrInterceptor(){const e=this;const t=XMLHttpRequest.prototype.open;const s=XMLHttpRequest.prototype.send;const l=XMLHttpRequest.prototype.setRequestHeader;this.originalXHROpen=t;this.originalXHRSend=s;this.originalXHRSetRequestHeader=l;const u=++this.xhrGeneration;const i=new WeakMap;const h=function(a,r,y,m,c){const L=t.call(this,a,r,y??true,m,c);if(u===e.xhrGeneration){i.get(this)?.();const o=this;o._buoyRequestId=(0,_requestId.nextRequestId)("xhr");o._method=a;o._url=(0,_resolveRequestUrl.resolveRequestUrl)(r);o._buoyStartTime=(0,_realNow.realNow)();o._requestHeaders={};o._buoyAsync=y!==false;o._buoyRestoreAbort?.();o._buoyWaitedForRules=false;o._buoyHeldSend=false;o._buoyOpenSeq=(o._buoyOpenSeq??0)+1}return L};const R=function(a,r){const y=this;if(u===e.xhrGeneration&&y._requestHeaders){y._requestHeaders[a]=r}return l.call(this,a,r)};const f=function(a){if(u!==e.xhrGeneration||insideFetchHandoff){return s.call(this,a)}if((0,_applyToXhr.hasPendingStandardRequest)(this))throw new DOMException("The request has already been sent.","InvalidStateError");if(this.readyState!==1||this._sent){return s.call(this,a)}const r=this;if(r._buoyHeldSend)throw new DOMException("The request has already been sent.","InvalidStateError");if(!(0,_engine.overrideRulesLoaded)()&&r._buoyAsync!==false&&!r._buoyWaitedForRules){r._buoyWaitedForRules=true;r._buoyHeldSend=true;const v=r._buoyOpenSeq;let T=false;const H=Object.prototype.hasOwnProperty.call(this,"abort")?this.abort:void 0;const E=()=>{if(r._buoyRestoreAbort!==E)return;r._buoyRestoreAbort=void 0;if(H)this.abort=H;else delete this.abort};r._buoyRestoreAbort=E;const z=H??Object.getPrototypeOf(this).abort;this.abort=function(){T=true;r._buoyHeldSend=false;E();return z.call(this)};const M=()=>{E();if(T||r._buoyOpenSeq!==v)return;r._buoyHeldSend=false;if(this.readyState===1&&!this._sent)f.call(this,a)};void(0,_engine.overrideRulesReady)().then(M,M);return}const y=r._buoyRequestId;const m=r._method||"GET";const c=r._url||"";const L=(0,_realNow.realNow)();r._buoyStartTime=L;r._buoyTtfb=void 0;const o=r._requestHeaders||{};Object.assign(o,injectedHeaders(c));if(e.shouldIgnoreUrl(c)){return s.call(this,a)}const{url:p,params:_}=e.parseUrl(c);let n;if(a){if(typeof a==="string"){try{n=JSON.parse(a)}catch{n=a}}else{n=a}}const g=o["X-Request-Client"]||o["x-request-client"];const w=o["Accept"]||o["accept"]||"";const k=w.includes("application/json")&&w.includes("text/plain")&&w.includes("*/*")&&!isAngularPage();const q=g||(k?"axios":"xhr");const N=(0,_store.snapshotNetworkCondition)(c);const X=N?.uploadBytesPerSecond?{...N,uploadCap:(0,_pacer.uploadSize)(a)}:N;const d=X?.profile==="offline"?null:(0,_engine.overrideForRequest)(c,m,o,typeof a==="string"?a:void 0);const S=d?(0,_types.markForOutcome)(d):void 0;e.emit({type:"request",timestamp:new Date,request:{id:y||"unknown",url:p,method:m,headers:o,data:n,params:_||void 0,client:q},override:S,condition:X});let I=false;const C=(v=false)=>{if(I)return;I=true;e.handleXHRResponse(this,y||"unknown",p,m,o,n,_,L||0,v,q,S,X);D()};const D=()=>{i.delete(this);this.removeEventListener("load",P);this.removeEventListener("error",A);this.removeEventListener("abort",F);this.removeEventListener("readystatechange",U)};i.set(this,D);const P=()=>{C(false)};const A=()=>{C(true)};const F=()=>{C(true)};const U=()=>{if(this.readyState===2){const v=this;if(v._buoyTtfb===void 0&&v._buoyStartTime){v._buoyTtfb=(0,_realNow.realNow)()-v._buoyStartTime}}if(this.readyState===4&&!I){C(false)}};this.addEventListener("load",P);this.addEventListener("error",A);this.addEventListener("abort",F);this.addEventListener("readystatechange",U);if(X){(0,_xhr.runConditionXhr)(this,c,X,d,()=>s.call(this,a),a);return}if(d){const v=(0,_applyToXhr.runOverride)(this,c,d,()=>s.call(this,a));if(v)return}return s.call(this,a)};f[BUOY_XHR_INTERCEPTOR_FLAG]=true;this.patchedXHROpen=h;this.patchedXHRSend=f;this.patchedXHRSetRequestHeader=R;XMLHttpRequest.prototype.open=this.patchedXHROpen;XMLHttpRequest.prototype.send=this.patchedXHRSend;XMLHttpRequest.prototype.setRequestHeader=this.patchedXHRSetRequestHeader}stopListening(){if(!this.isListening){return}this.fetchGeneration++;this.xhrGeneration++;if(this.patchedFetch&&globalThis.fetch===this.patchedFetch){globalThis.fetch=this.originalFetch}if(this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen){XMLHttpRequest.prototype.open=this.originalXHROpen}if(this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend){XMLHttpRequest.prototype.send=this.originalXHRSend}if(this.patchedXHRSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.patchedXHRSetRequestHeader){XMLHttpRequest.prototype.setRequestHeader=this.originalXHRSetRequestHeader}this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.patchedXHRSetRequestHeader=null;this.isListening=false;if(__DEV__){}}adoptEarlyRequests(){const e=globalThis;const t=e[EARLY_NETWORK_KEY]??e.__BUOY_EARLY_NETWORK__;if(t?.version!==1)return;for(const s of t.adopt()){try{if(s.kind==="fetch")this.adoptEarlyFetch(s);else this.adoptEarlyXhr(s)}catch{}}}adoptEarlyFetch(e){const{input:t,init:s}=e;const l=typeof t==="object"&&"method"in t?t:void 0;const u=(0,_resolveRequestUrl.resolveRequestUrl)(typeof t==="string"?t:t instanceof URL?t.href:t.url);if(this.shouldIgnoreUrl(u))return;const i=(0,_requestId.nextRequestId)("fetch");const h=s?.method??l?.method??"GET";const{url:R,params:f}=this.parseUrl(u);const a=headersToRecord(s?.headers??l?.headers);let r=s?.body;if(typeof r==="string"){try{r=JSON.parse(r)}catch{}}const y=a["X-Request-Client"]||a["x-request-client"]||"fetch";const m=()=>({id:i,url:R,method:h,headers:a,data:r,params:f||void 0,client:y});this.emit({type:"request",timestamp:new Date(e.start),request:m()});if(e.requestCopy){void this.readStreamedBody(e.requestCopy).then(({body:c})=>{try{r=JSON.parse(c)}catch{r=c}this.emit({type:"request-body",timestamp:new Date,request:{id:i,url:R,method:h,data:r,client:y}})}).catch(()=>{})}void e.settled.then(async({response:c,clone:L,error:o,headersAt:p})=>{if(!c){this.emit({type:"error",timestamp:new Date,duration:p-e.start,request:m(),error:{message:o instanceof Error?o.message:"Network error",stack:o instanceof Error?o.stack:void 0}});return}const{body:_,size:n}=L?await this.processResponseBody(L):{body:STREAMING_PLACEHOLDER,size:0};const g=Math.max(0,(0,_realNow.realNow)()-e.start);const w=p-e.start;const k={};c.headers.forEach((q,N)=>{k[N.toLowerCase()]=q});this.emit({type:"response",timestamp:new Date,duration:g,timings:g>w?{ttfb:w,download:g-w}:void 0,request:m(),response:{status:c.status,statusText:c.statusText,headers:k,body:_,size:n}})})}adoptEarlyXhr(e){const t=(0,_resolveRequestUrl.resolveRequestUrl)(e.url);if(this.shouldIgnoreUrl(t))return;const s=(0,_requestId.nextRequestId)("xhr");const l=e.method.toUpperCase();const{url:u,params:i}=this.parseUrl(t);let h=e.body;if(typeof h==="string"){try{h=JSON.parse(h)}catch{}}const R=e.headers["X-Request-Client"]||e.headers["x-request-client"]||"xhr";this.emit({type:"request",timestamp:new Date(e.start),request:{id:s,url:u,method:l,headers:e.headers,data:h,params:i||void 0,client:R}});const f=e.xhr;const a=()=>{const r=(f._buoyEarlyEnd??(0,_realNow.realNow)())-e.start;this.handleXHRResponse(f,s,u,l,e.headers,h,i,(0,_realNow.realNow)()-r,false,R)};if(f.readyState===4)a();else f.addEventListener("loadend",a,{once:true})}addListener(e){this.listeners.push(e);return()=>{const t=this.listeners.indexOf(e);if(t>-1){this.listeners.splice(t,1)}}}removeAllListeners(){this.listeners=[]}get isActive(){return this.isListening}get listenerCount(){return this.listeners.length}}let _networkListener=null;const getNetworkListener=()=>{if(!_networkListener){_networkListener=new NetworkListener}return _networkListener};const networkListener=exports.networkListener=getNetworkListener;const startNetworkListener=()=>getNetworkListener().startListening();exports.startNetworkListener=startNetworkListener;const stopNetworkListener=()=>_networkListener?.stopListening();exports.stopNetworkListener=stopNetworkListener;const addNetworkListener=b=>getNetworkListener().addListener(b);exports.addNetworkListener=addNetworkListener;const removeAllNetworkListeners=()=>_networkListener?.removeAllListeners();exports.removeAllNetworkListeners=removeAllNetworkListeners;const isNetworkListening=()=>_networkListener?.isActive??false;exports.isNetworkListening=isNetworkListening;const getNetworkListenerCount=()=>_networkListener?.listenerCount??0;exports.getNetworkListenerCount=getNetworkListenerCount;const isNetworkInterceptionLive=()=>_networkListener?.isInterceptionLive()??false;exports.isNetworkInterceptionLive=isNetworkInterceptionLive;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{getEffectiveNetworkConnection as i,setConnectionSupport as t,subscribeNetworkConditions as s}from"./network/conditions/store";import{patchConnectionState as a}from"./network/conditions/connectivity/patchNetwork";let o=false;export function installExpoNetworkConditions(){if(o||typeof __DEV__==="undefined"||!__DEV__)return;try{const e=require("expo-network/build/ExpoNetwork").default;const r={get getCurrentState(){return e.getNetworkStateAsync},set getCurrentState(n){e.getNetworkStateAsync=n},eventEmitter:e};a(r,i,s,{eventName:"onNetworkStateChanged",expo:true,receiver:e});o=true;t("expoNetwork",{supported:true})}catch(e){t("expoNetwork",{supported:false,reason:e instanceof Error?e.message:"Expo Network hook could not load."})}}installExpoNetworkConditions();
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{networkToolPreset,createNetworkTool}from"./preset";export{startNetworkCapture}from"./network/utils/startNetworkCapture";export{NetworkModal,NetworkToolView}from"./network/components/NetworkModal";export{NetworkEventDetailView}from"./network/components/NetworkEventDetailView";export{NetworkEventItemCompact}from"./network/components/NetworkEventItemCompact";export{NetworkSavedScreen}from"./network/components/NetworkSavedScreen";export{NetworkSavedButton,NetworkDetailPinActions,NetworkHeaderBadgesView}from"./network/components/NetworkHeaderLive";export{useNetworkEvents}from"./network/hooks/useNetworkEvents";export{useNetworkEventList}from"./network/hooks/useNetworkEventList";export{useLiveNetworkEvent}from"./network/hooks/useLiveNetworkEvent";export{useNetworkBadgeCounts}from"./network/hooks/useNetworkBadgeCounts";export{useNetworkSaved}from"./network/hooks/useNetworkSaved";export{splitPinned}from"./network/utils/withPinnedFirst";export{networkSelectionStore,DEFAULT_SETTLE_MS}from"./network/utils/networkSelectionStore";export{TickProvider,useTickEveryMinute}from"./network/hooks/useTickEveryMinute";export{formatBytes,formatDuration,formatHttpStatus}from"./network/utils/formatting";export{overrideRulesStore}from"./network/overrides/overrideRulesStore";export{draftFromEvent}from"./network/overrides/presets";export{MAX_RULES as MAX_OVERRIDE_RULES,FREE_TIER_RULE_LIMIT as FREE_TIER_OVERRIDE_LIMIT,STATUS_MIN as OVERRIDE_STATUS_MIN,STATUS_MAX as OVERRIDE_STATUS_MAX}from"./network/overrides/types";export{useIgnoredPatterns,ignoredPatternsStore,urlMatchesIgnoredPattern,isUrlIgnored}from"@buoy-gg/shared-ui";export{networkSyncAdapter}from"./network/sync/networkSyncAdapter";export{NetworkBodyResolverProvider}from"./network/sync/networkBodyResolver";export{networkEventStore}from"./network/utils/networkEventStore";export{networkSavedStore,flagsForEventId,FREE_TIER_SAVED_LIMIT,MAX_PINNED,MAX_SAVED}from"./network/utils/networkSavedStore";export{generateCurl}from"./network/utils/generateCurl";export{networkListener,addNetworkListener,removeAllNetworkListeners}from"./network/utils/networkListener";export{NETWORK_CONDITIONS,getNetworkCondition,setNetworkCondition,subscribeNetworkConditions}from"./network/conditions/store";
|
|
1
|
+
"use strict";export{networkToolPreset,createNetworkTool}from"./preset";export{startNetworkCapture}from"./network/utils/startNetworkCapture";export{NetworkModal,NetworkToolView}from"./network/components/NetworkModal";export{NetworkEventDetailView}from"./network/components/NetworkEventDetailView";export{NetworkEventItemCompact}from"./network/components/NetworkEventItemCompact";export{NetworkSavedScreen}from"./network/components/NetworkSavedScreen";export{NetworkSavedButton,NetworkDetailPinActions,NetworkHeaderBadgesView}from"./network/components/NetworkHeaderLive";export{useNetworkEvents}from"./network/hooks/useNetworkEvents";export{useNetworkEventList}from"./network/hooks/useNetworkEventList";export{useLiveNetworkEvent}from"./network/hooks/useLiveNetworkEvent";export{useNetworkBadgeCounts}from"./network/hooks/useNetworkBadgeCounts";export{useNetworkSaved}from"./network/hooks/useNetworkSaved";export{splitPinned}from"./network/utils/withPinnedFirst";export{networkSelectionStore,DEFAULT_SETTLE_MS}from"./network/utils/networkSelectionStore";export{TickProvider,useTickEveryMinute}from"./network/hooks/useTickEveryMinute";export{formatBytes,formatDuration,formatHttpStatus}from"./network/utils/formatting";export{overrideRulesStore}from"./network/overrides/overrideRulesStore";export{draftFromEvent}from"./network/overrides/presets";export{MAX_RULES as MAX_OVERRIDE_RULES,FREE_TIER_RULE_LIMIT as FREE_TIER_OVERRIDE_LIMIT,STATUS_MIN as OVERRIDE_STATUS_MIN,STATUS_MAX as OVERRIDE_STATUS_MAX}from"./network/overrides/types";export{useIgnoredPatterns,ignoredPatternsStore,urlMatchesIgnoredPattern,isUrlIgnored}from"@buoy-gg/shared-ui";export{networkSyncAdapter}from"./network/sync/networkSyncAdapter";export{NetworkBodyResolverProvider}from"./network/sync/networkBodyResolver";export{networkEventStore}from"./network/utils/networkEventStore";export{networkSavedStore,flagsForEventId,FREE_TIER_SAVED_LIMIT,MAX_PINNED,MAX_SAVED}from"./network/utils/networkSavedStore";export{generateCurl}from"./network/utils/generateCurl";export{networkListener,addNetworkListener,removeAllNetworkListeners}from"./network/utils/networkListener";export{NETWORK_CONDITIONS,getNetworkCondition,setNetworkCondition,subscribeNetworkConditions,getNetworkConditions,setNetworkConditions,getNetworkConnection,getConditionsRevision,networkConditionsActive}from"./network/conditions/store";export{chooseConditionsSnapshot}from"./network/conditions/remoteState";
|
package/lib/module/index.web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{networkListener,startNetworkListener,stopNetworkListener,addNetworkListener,removeAllNetworkListeners,isNetworkListening}from"./network/utils/networkListener";export{networkEventStore}from"./network/utils/networkEventStore";export{networkSavedStore,flagsForEventId}from"./network/utils/networkSavedStore";export{useNetworkEvents,FREE_TIER_REQUEST_LIMIT}from"./network/hooks/useNetworkEvents";export{useNetworkEventList}from"./network/hooks/useNetworkEventList";export{useLiveNetworkEvent}from"./network/hooks/useLiveNetworkEvent";export{useNetworkBadgeCounts}from"./network/hooks/useNetworkBadgeCounts";export{useHasNetworkSelection,useSelectedNetworkEventId,useNetworkBodyEventId,useNetworkCursor}from"./network/hooks/useNetworkSelection";export{networkSelectionStore,toSelectionIds}from"./network/utils/networkSelectionStore";export{NetworkListScreen}from"./network/components/NetworkListScreen.web";export{NetworkEventItemCompact}from"./network/components/NetworkEventItemCompact.web";export{NetworkHeaderBadges,NetworkClearButton,NetworkSavedButton,NetworkDetailPinActions,NetworkHeaderCopyButton}from"./network/components/NetworkHeaderLive.web";export{NetworkEventDetailView}from"./network/components/NetworkEventDetailView.web";export{NetworkDetailStepper}from"./network/components/NetworkDetailStepper.web";export{NetworkDetailScreen}from"./network/components/NetworkDetailScreen.web";export{NetworkFilterViewV3}from"./network/components/NetworkFilterViewV3.web";export{NetworkFilterScreen}from"./network/components/NetworkFilterScreen.web";export{NetworkSavedScreen}from"./network/components/NetworkSavedScreen.web";export{NetworkCopySettingsView,DEFAULT_COPY_SETTINGS}from"./network/components/NetworkCopySettingsView.web";export{NetworkCopyScreen}from"./network/components/NetworkCopyScreen.web";export{generateNetworkCopyText}from"./network/utils/generateNetworkCopyText";export{selectSavedEvents}from"./network/utils/selectSavedEvents";export{FREE_TIER_SAVED_LIMIT,MAX_SAVED}from"./network/utils/networkSavedStore";export{NetworkOverridesScreen}from"./network/components/NetworkOverridesScreen.web";export{NetworkOverrideEditor}from"./network/components/NetworkOverrideEditor.web";export{NetworkNumberPrompt}from"./network/components/NetworkNumberPrompt.web";export{NetworkOverridesButton}from"./network/components/NetworkOverridesButton.web";export{NetworkOverrideHeaderButton}from"./network/components/NetworkOverrideHeaderButton.web";export{useOverrideRules}from"./network/hooks/useOverrideRules";export{overrideRulesStore}from"./network/overrides/overrideRulesStore";export{draftFromEvent,patternForUrl}from"./network/overrides/presets";export{FREE_TIER_RULE_LIMIT,MAX_RULES,STATUS_MAX,STATUS_MIN}from"./network/overrides/types";export{ruleMatches}from"./network/overrides/matchRule";export{filterNetworkEvents,applyIgnoredPatterns}from"./network/utils/filterNetworkEvents";export{splitPinned}from"./network/utils/withPinnedFirst";export{extractOperationName}from"./network/utils/extractOperationName";export{generateCurl}from"./network/utils/generateCurl";export{NETWORK_CONDITIONS,getNetworkCondition,setNetworkCondition,subscribeNetworkConditions}from"./network/conditions/store";
|
|
1
|
+
"use strict";export{networkListener,startNetworkListener,stopNetworkListener,addNetworkListener,removeAllNetworkListeners,isNetworkListening}from"./network/utils/networkListener";export{networkEventStore}from"./network/utils/networkEventStore";export{networkSavedStore,flagsForEventId}from"./network/utils/networkSavedStore";export{useNetworkEvents,FREE_TIER_REQUEST_LIMIT}from"./network/hooks/useNetworkEvents";export{useNetworkEventList}from"./network/hooks/useNetworkEventList";export{useLiveNetworkEvent}from"./network/hooks/useLiveNetworkEvent";export{useNetworkBadgeCounts}from"./network/hooks/useNetworkBadgeCounts";export{useHasNetworkSelection,useSelectedNetworkEventId,useNetworkBodyEventId,useNetworkCursor}from"./network/hooks/useNetworkSelection";export{networkSelectionStore,toSelectionIds}from"./network/utils/networkSelectionStore";export{NetworkListScreen}from"./network/components/NetworkListScreen.web";export{NetworkEventItemCompact}from"./network/components/NetworkEventItemCompact.web";export{NetworkHeaderBadges,NetworkClearButton,NetworkSavedButton,NetworkDetailPinActions,NetworkHeaderCopyButton}from"./network/components/NetworkHeaderLive.web";export{NetworkEventDetailView}from"./network/components/NetworkEventDetailView.web";export{NetworkDetailStepper}from"./network/components/NetworkDetailStepper.web";export{NetworkDetailScreen}from"./network/components/NetworkDetailScreen.web";export{NetworkFilterViewV3}from"./network/components/NetworkFilterViewV3.web";export{NetworkFilterScreen}from"./network/components/NetworkFilterScreen.web";export{NetworkSavedScreen}from"./network/components/NetworkSavedScreen.web";export{NetworkCopySettingsView,DEFAULT_COPY_SETTINGS}from"./network/components/NetworkCopySettingsView.web";export{NetworkCopyScreen}from"./network/components/NetworkCopyScreen.web";export{generateNetworkCopyText}from"./network/utils/generateNetworkCopyText";export{selectSavedEvents}from"./network/utils/selectSavedEvents";export{FREE_TIER_SAVED_LIMIT,MAX_SAVED}from"./network/utils/networkSavedStore";export{NetworkOverridesScreen}from"./network/components/NetworkOverridesScreen.web";export{NetworkOverrideEditor}from"./network/components/NetworkOverrideEditor.web";export{NetworkNumberPrompt}from"./network/components/NetworkNumberPrompt.web";export{NetworkOverridesButton}from"./network/components/NetworkOverridesButton.web";export{NetworkOverrideHeaderButton}from"./network/components/NetworkOverrideHeaderButton.web";export{useOverrideRules}from"./network/hooks/useOverrideRules";export{overrideRulesStore}from"./network/overrides/overrideRulesStore";export{draftFromEvent,patternForUrl}from"./network/overrides/presets";export{FREE_TIER_RULE_LIMIT,MAX_RULES,STATUS_MAX,STATUS_MIN}from"./network/overrides/types";export{ruleMatches}from"./network/overrides/matchRule";export{filterNetworkEvents,applyIgnoredPatterns}from"./network/utils/filterNetworkEvents";export{splitPinned}from"./network/utils/withPinnedFirst";export{extractOperationName}from"./network/utils/extractOperationName";export{generateCurl}from"./network/utils/generateCurl";export{NETWORK_CONDITIONS,getNetworkCondition,setNetworkCondition,subscribeNetworkConditions,getNetworkConditions,setNetworkConditions,getNetworkConnection,getConditionsRevision,networkConditionsActive}from"./network/conditions/store";export{chooseConditionsSnapshot}from"./network/conditions/remoteState";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{wrapNetInfoApi as r}from"./network/conditions/connectivity/netInfoFacade";import{getEffectiveNetworkConnection as i,setConnectionSupport as n,subscribeNetworkConditions as a}from"./network/conditions/store";import{patchConnectionState as f}from"./network/conditions/connectivity/patchNetwork";let o=false;export function installNetInfoConditions(){if(o||typeof __DEV__==="undefined"||!__DEV__)return;let e;try{const t=require("@react-native-community/netinfo/src/internal/nativeInterface").default;e=f(t,i,a);r(require("@react-native-community/netinfo"));o=true;n("netInfo",{supported:true})}catch(t){e?.();n("netInfo",{supported:false,reason:t instanceof Error?t.message:"NetInfo hook could not load."})}}installNetInfoConditions();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";import{DynamicFilterView as X,macOSColors as y,FileText as Y,FileCode as Q,Link as se,Zap as
|
|
1
|
+
"use strict";import{DynamicFilterView as X,macOSColors as y,FileText as Y,FileCode as Q,Link as se,Zap as oe,Settings as te,Hash as ie,Eye as ue,ToolbarCopyButton as ne,formatRelativeTime as le,useFeatureGate as de,ProFeatureBanner as ae,ExportPreview as ce,monoFont as g}from"@buoy-gg/shared-ui";import{DataViewer as pe}from"@buoy-gg/shared-ui/dataViewer";import{useCallback as q,useMemo as b,useState as me}from"react";import{Text as F,StyleSheet as fe,ScrollView as v,View as D}from"react-native";import{useTickEveryMinute as ye}from"../hooks/useTickEveryMinute";import{jsx as m,Fragment as he,jsxs as ee}from"react/jsx-runtime";export const DEFAULT_COPY_SETTINGS={includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"};const k={urls:{includeMethod:true,includeStatus:false,includeDuration:false,includeTimestamp:false,includeClient:false,includeSizes:false,includeErrors:false,includeRequestHeaders:false,includeResponseHeaders:false,includeRequestBody:false,includeResponseBody:false,bodySizeThreshold:10,format:"plaintext",filterMode:"all"},llm:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"},json:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"json",filterMode:"all"},full:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"markdown",filterMode:"all"}};function qe(r){for(const[l,a]of Object.entries(k)){const T=Object.keys(a).every(j=>a[j]===r[j]);if(T)return l}return null}const Re=100*1024;const Be=500*1024;function Se(r){if(r<1024)return`${r} B`;if(r<1024*1024)return`${(r/1024).toFixed(1)} KB`;return`${(r/(1024*1024)).toFixed(1)} MB`}export function NetworkCopySettingsView({settings:r,onSettingsChange:l,events:a=[]}){const{isPro:T}=de();const j=ye();const[P,re]=me(false);const c=a.length>0;const O=b(()=>{if(!c)return null;const d=a.map(t=>typeof t.timestamp==="number"?t.timestamp:new Date(t.timestamp).getTime());return Math.max(...d)},[a,c]);const x=b(()=>qe(r),[r]);const L=q(()=>{l(k.urls)},[l]);const z=q(()=>{l(k.llm)},[l]);const I=q(()=>{l(k.json)},[l]);const J=q(()=>{l(k.full)},[l]);const C=q((d,t)=>{const[u,n]=d.split("::");if(u==="preset"){switch(n){case"urls":L();break;case"llm":z();break;case"json":I();break;case"full":J();break}return}if(u==="requestInfo"){l({...r,[n]:!r[n]});return}if(u==="headers"){l({...r,[n]:!r[n]});return}if(u==="body"){if(n==="bodySizeThreshold"){l({...r,bodySizeThreshold:t})}else{l({...r,[n]:!r[n]})}return}if(u==="format"){l({...r,format:t});return}if(u==="filter"){l({...r,filterMode:t})}},[r,l,L,z,I,J]);const h=b(()=>({method:"POST",url:"https://api.example.com/v1/users",status:201,duration:342,timestamp:new Date().toISOString(),requestHeaders:{"Content-Type":"application/json","Authorization":"Bearer ***"},responseHeaders:{"Content-Type":"application/json","X-Request-ID":"abc123"},requestBody:{name:"John Doe",email:"john@example.com"},responseBody:{id:"user_123",name:"John Doe",email:"john@example.com",createdAt:"2025-01-10T12:00:00Z"}}),[]);const be=b(()=>{if(c){return a}return[h]},[c,a,h]);const H=b(()=>{const d=c?a:[h];let t=0;for(const u of d){if(r.includeMethod){t+=(u.url?.length||0)+10}if(r.includeStatus){t+=30}if(r.includeTimestamp){t+=30}if(r.includeRequestHeaders){try{t+=JSON.stringify(u.requestHeaders||{}).length}catch{t+=100}}if(r.includeRequestBody){const n="requestBody"in u?u.requestBody:u.requestData;try{t+=JSON.stringify(n||{}).length}catch{t+=100}}if(r.includeResponseBody){const n="responseBody"in u?u.responseBody:u.responseData;try{t+=JSON.stringify(n||{}).length}catch{t+=100}}}return t},[c,a,h,r]);const _=b(()=>{if(H>=Be)return"danger";if(H>=Re)return"warning";return"none"},[H]);const V=q(()=>{const d=c?a:[h];const{format:t,includeMethod:u,includeStatus:n,includeTimestamp:R,includeRequestHeaders:$,includeRequestBody:B,includeResponseBody:S}=r;const M=o=>{const e={};if(u){e.method=o.method;e.url=o.url}if(n){e.status=o.status;e.duration=o.duration}if(R){e.timestamp=o.timestamp}if($){e.requestHeaders=o.requestHeaders}if(B){e.requestBody="requestBody"in o?o.requestBody:o.requestData}if(S){e.responseBody="responseBody"in o?o.responseBody:o.responseData}return e};if(t==="json"){const o=d.map(M);return JSON.stringify(o,null,2)}if(t==="markdown"){const o=d.map((e,i)=>{const s=[];s.push(`# Request ${i+1}`);if(u){s.push(`
|
|
2
2
|
**${e.method}** ${e.url}`)}const f=[];if(n){f.push(`**Status:** ${e.status}`);f.push(`**Duration:** ${e.duration}ms`)}if(R){f.push(`**Timestamp:** ${e.timestamp}`)}if(f.length>0){s.push("\n"+f.join("\n"))}if($){const p=e.requestHeaders||{};s.push(`
|
|
3
3
|
## Request Headers
|
|
4
4
|
\`\`\`json
|
|
@@ -11,7 +11,7 @@ ${JSON.stringify(p||{},null,2)}
|
|
|
11
11
|
## Response Body
|
|
12
12
|
\`\`\`json
|
|
13
13
|
${JSON.stringify(p||{},null,2)}
|
|
14
|
-
\`\`\``)}return s.join("\n")});return
|
|
14
|
+
\`\`\``)}return s.join("\n")});return o.join("\n\n---\n\n")||"No data included"}const A=d.map((o,e)=>{const i=[];i.push(`Request ${e+1}:`);if(u){i.push(`${o.method} ${o.url}`)}if(n){i.push(`Status: ${o.status}`);i.push(`Duration: ${o.duration}ms`)}if(R){i.push(`Timestamp: ${o.timestamp}`)}if(B){const s="requestBody"in o?o.requestBody:o.requestData;i.push("\nRequest:");i.push(JSON.stringify(s||{},null,2))}if(S){const s="responseBody"in o?o.responseBody:o.responseData;i.push("\nResponse:");i.push(JSON.stringify(s||{},null,2))}return i.join("\n")});return A.join("\n\n---\n\n")||"No data included"},[c,a,h,r]);const U=q(()=>{const d=c?a:[h];const{format:t,includeMethod:u,includeStatus:n,includeTimestamp:R,includeRequestHeaders:$,includeRequestBody:B,includeResponseBody:S}=r;const M=e=>{const i={};if(u){i.method=e.method;i.url=e.url}if(n){i.status=e.status;i.duration=e.duration}if(R){i.timestamp=e.timestamp}if($){i.requestHeaders=e.requestHeaders}if(B){i.requestBody="requestBody"in e?e.requestBody:e.requestData}if(S){i.responseBody="responseBody"in e?e.responseBody:e.responseData}return i};if(t==="json"){const e=d.map(M);return m(pe,{data:e,title:"",showTypeFilter:false})}if(t==="markdown"){const e=d.map((s,f)=>{const p=[];p.push(`# Request ${f+1}`);if(u){p.push(`
|
|
15
15
|
**${s.method}** ${s.url}`)}const E=[];if(n){E.push(`**Status:** ${s.status}`);E.push(`**Duration:** ${s.duration}ms`)}if(R){E.push(`**Timestamp:** ${s.timestamp}`)}if(E.length>0){p.push("\n"+E.join("\n"))}if($){const N=s.requestHeaders||{};p.push(`
|
|
16
16
|
## Request Headers
|
|
17
17
|
\`\`\`json
|
|
@@ -24,4 +24,4 @@ ${JSON.stringify(N||{},null,2)}
|
|
|
24
24
|
## Response Body
|
|
25
25
|
\`\`\`json
|
|
26
26
|
${JSON.stringify(N||{},null,2)}
|
|
27
|
-
\`\`\``)}return p.join("\n")});const i=e.join("\n\n---\n\n");return m(v,{style:w.previewScroll,nestedScrollEnabled:true,children:m(F,{style:w.markdownText,selectable:T,children:i||"No data included"})})}const A=d.map((e,i)=>{const s=[];s.push(`Request ${i+1}:`);if(u){s.push(`${e.method} ${e.url}`)}if(n){s.push(`Status: ${e.status}`);s.push(`Duration: ${e.duration}ms`)}if(R){s.push(`Timestamp: ${e.timestamp}`)}if(B){const f="requestBody"in e?e.requestBody:e.requestData;s.push("\nRequest:");s.push(JSON.stringify(f||{},null,2))}if(S){const f="responseBody"in e?e.responseBody:e.responseData;s.push("\nResponse:");s.push(JSON.stringify(f||{},null,2))}return s.join("\n")});const
|
|
27
|
+
\`\`\``)}return p.join("\n")});const i=e.join("\n\n---\n\n");return m(v,{keyboardShouldPersistTaps:"handled",style:w.previewScroll,nestedScrollEnabled:true,children:m(F,{style:w.markdownText,selectable:T,children:i||"No data included"})})}const A=d.map((e,i)=>{const s=[];s.push(`Request ${i+1}:`);if(u){s.push(`${e.method} ${e.url}`)}if(n){s.push(`Status: ${e.status}`);s.push(`Duration: ${e.duration}ms`)}if(R){s.push(`Timestamp: ${e.timestamp}`)}if(B){const f="requestBody"in e?e.requestBody:e.requestData;s.push("\nRequest:");s.push(JSON.stringify(f||{},null,2))}if(S){const f="responseBody"in e?e.responseBody:e.responseData;s.push("\nResponse:");s.push(JSON.stringify(f||{},null,2))}return s.join("\n")});const o=A.join("\n\n---\n\n");return m(v,{keyboardShouldPersistTaps:"handled",style:w.previewScroll,nestedScrollEnabled:true,children:m(F,{style:w.plaintextText,selectable:T,children:o||"No data included"})})},[r,c,a,h,T]);const G=q(()=>{const d=c?a:[h];const t=d.length;return m(ce,{expanded:P,onExpandedChange:re,summary:`${t} request${t!==1?"s":""} \u2022 ~${Se(H)}`,warningLevel:_,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},renderBody:U})},[r,c,a,h,P,H,_,U]);const W=q(()=>{const d=c&&O?`Live data \u2022 Updated ${le(O,j)}`:"Mock data (no events captured)";return ee(he,{children:[m(F,{style:w.statusLabel,children:d}),m(ne,{value:V()})]})},[c,O,j,V]);const Z=q(()=>{return G()},[G]);const K=b(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::urls",label:"URLs",icon:se,color:y.semantic.info,value:"urls",isActive:x==="urls"},{id:"preset::llm",label:"LLM",icon:oe,color:y.semantic.success,value:"llm",isActive:x==="llm"},{id:"preset::json",label:"JSON",icon:Q,color:y.semantic.warning,value:"json",isActive:x==="json"},{id:"preset::full",label:"Full",icon:Y,color:y.semantic.info,value:"full",isActive:x==="full"},{id:"preset::custom",label:"Custom",icon:te,color:y.text.secondary,value:"custom",isActive:x===null}]},{id:"include",title:"Include",type:"custom",data:[{id:"requestInfo::includeMethod",label:"URL",value:"includeMethod",isActive:r.includeMethod},{id:"requestInfo::includeStatus",label:"Status",value:"includeStatus",isActive:r.includeStatus},{id:"requestInfo::includeTimestamp",label:"Time",value:"includeTimestamp",isActive:r.includeTimestamp},{id:"headers::includeRequestHeaders",label:"Headers",value:"includeRequestHeaders",isActive:r.includeRequestHeaders},{id:"body::includeRequestBody",label:"Req Body",value:"includeRequestBody",isActive:r.includeRequestBody},{id:"body::includeResponseBody",label:"Res Body",value:"includeResponseBody",isActive:r.includeResponseBody},{id:"requestInfo::includeErrors",label:"Errors",value:"includeErrors",isActive:r.includeErrors}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:Y,color:y.semantic.info,value:"markdown",isActive:r.format==="markdown"},{id:"format::json",label:"JSON",icon:Q,color:y.semantic.warning,value:"json",isActive:r.format==="json"},{id:"format::plaintext",label:"Text",icon:ie,color:y.text.secondary,value:"plaintext",isActive:r.format==="plaintext"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:ue,content:Z,headerActions:W},onFilterChange:C}),[r,C,Z,W,x]);if(!T){return ee(D,{style:w.gatedContainer,children:[m(ae,{featureName:"Network Export",description:"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]}),m(D,{style:w.gatedPreview,children:m(X,{...K})})]})}return m(X,{...K})}const w=fe.create({previewScroll:{maxHeight:300},markdownText:{fontFamily:g,fontSize:11,color:y.text.primary,lineHeight:18},plaintextText:{fontFamily:g,fontSize:11,color:y.text.primary,lineHeight:18},statusLabel:{fontSize:11,fontWeight:"600",color:y.text.muted,marginRight:8},gatedContainer:{flex:1,padding:12},gatedPreview:{flex:1}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";import{useState as
|
|
1
|
+
"use strict";import{useState as F,useEffect as U,useMemo as ee,memo as oe}from"react";import{View as l,Text as i,StyleSheet as te,ScrollView as re,TouchableOpacity as O}from"react-native";import{Clock as M,Upload as G,Download as J,AlertCircle as le,ChevronDown as _,ChevronUp as Q,Lock as ie,Unlock as ne,FileJson as E,Filter as ae,Globe as se,Link as ce,Copy as Y,FlaskConical as de,InlineCopyButton as K,macOSColors as N,night as t,useFeatureGate as ue,UpgradeModal as pe,monoFont as R}from"@buoy-gg/shared-ui";import{formatBytes as q,formatDuration as X,formatHttpStatus as ge}from"../utils/formatting";import{formatRelativeTime as he}from"@buoy-gg/shared-ui";import{DataViewer as H}from"@buoy-gg/shared-ui/dataViewer";import{formatGraphQLDisplay as fe}from"../utils/formatGraphQLVariables";import{useNetworkBodyResolver as ye}from"../sync/networkBodyResolver";import{jsx as e,jsxs as n,Fragment as W}from"react/jsx-runtime";const A=t.color.accent;const me=new Set;const be=()=>{};const Se=({timings:d,total:r})=>{const u=Math.max(1,r);const h=[{label:"Waiting (TTFB)",hint:"incl. queue, DNS, TLS",value:d.ttfb,color:N.semantic.warning},{label:"Content download",hint:void 0,value:d.download,color:N.semantic.success}];return e(l,{style:o.phaseList,children:h.map(s=>n(l,{style:o.phaseRow,children:[n(l,{style:o.phaseLabelGroup,children:[e(i,{style:o.phaseLabel,children:s.label}),s.hint?e(i,{style:o.phaseHint,children:s.hint}):null]}),e(l,{style:o.phaseTrack,children:e(l,{style:[o.phaseBar,{backgroundColor:s.color,width:`${Math.min(100,Math.max(1,s.value/u*100))}%`}]})}),e(i,{style:o.phaseValue,children:X(s.value)})]},s.label))})};const Z=()=>e(l,{style:o.bodyDeferred});const T=({title:d,icon:r,children:u,defaultOpen:h=false,count:s})=>{const[p,B]=F(h);return n(l,{style:o.collapsibleSection,children:[n(O,{style:o.collapsibleHeader,onPress:()=>B(!p),testID:`buoy-network-section-${d.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:d,children:[n(l,{style:o.collapsibleTitle,children:[r,e(i,{style:o.collapsibleTitleText,children:d}),s!==void 0?e(i,{style:o.collapsibleCount,children:s}):null]}),p?e(Q,{size:16,color:t.color.textSecondary}):e(_,{size:16,color:t.color.textSecondary})]}),p?e(l,{style:o.collapsibleContent,children:u}):null]})};const xe=({url:d,requestData:r,operationName:u,graphqlVariables:h,requestClient:s,isPro:p=false,onUpgradePress:B})=>{const g=I=>{try{const y=new URL(I);const x=String(y.protocol||"");const C=String(y.host||"");const V=x==="https:";let m=String(y.pathname||"");if(s==="graphql"&&u){const z=fe(u,h);m=`${m} (${z})`}else if(u){m=`${m} (${u})`}const w={};const b=y.searchParams;if(b&&typeof b.forEach==="function"){b.forEach((z,D)=>{w[D]=z})}return{protocol:x.replace(":",""),host:C,pathname:m,params:Object.keys(w).length>0?w:null,isSecure:V}}catch{return{protocol:"",host:d,pathname:"",params:null,isSecure:false}}};const c=ee(()=>g(d),[d,s,u,h]);const[f,k]=F(false);return n(l,{style:o.urlBreakdown,children:[n(l,{style:o.urlRow,children:[c.isSecure?e(ie,{size:12,color:N.semantic.success}):e(ne,{size:12,color:N.semantic.warning}),e(i,{style:o.urlDomain,children:c.host}),n(i,{style:o.urlProtocol,children:["(",c.protocol.toUpperCase(),")"]}),p?e(K,{value:d,buttonStyle:o.copyButton}):e(O,{style:o.copyButton,onPress:B,activeOpacity:.7,children:e(Y,{size:14,color:t.color.textSecondary})})]}),e(l,{style:o.urlPathRow,children:n(i,{style:o.urlPath,numberOfLines:2,children:[c.pathname,c.params?n(i,{style:o.urlQueryString,children:["?",new URLSearchParams(c.params).toString()]}):null]})}),c.params?n(l,{style:o.queryParamsCollapsible,children:[n(O,{style:o.queryParamsToggle,onPress:()=>k(!f),activeOpacity:.7,children:[e(i,{style:o.queryParamsToggleText,children:"Query Parameters"}),e(i,{style:o.collapsibleCount,children:Object.keys(c.params).length}),f?e(Q,{size:14,color:t.color.textSecondary}):e(_,{size:14,color:t.color.textSecondary})]}),f?e(H,{title:"",data:c.params,showTypeFilter:true,rawMode:true,initialExpanded:true}):null]}):null]})};export const NetworkEventDetailView=oe(function d({event:r,ignoredPatterns:u=me,onTogglePattern:h=be,showBodies:s=true}){const p=r.status?ge(r.status):null;const B=!r.status&&!r.error;const{isPro:g}=ue();const[c,f]=F(false);U(()=>{if(c&&g){f(false)}},[c,g]);const k=ye();const I=r.requestData===void 0&&(r.requestBodyOmitted===true||(r.requestSize??0)>0);const y=r.responseData===void 0&&(r.responseBodyOmitted===true||(r.responseSize??0)>0);const x=r.headersOmitted===true;const[C,V]=F(null);const[m,w]=F(false);U(()=>{V(null);if(!k||!I&&!y&&!x){w(false);return}let a=false;w(true);k(r.id).then(S=>{if(!a)V(S)}).catch(()=>{}).finally(()=>{if(!a)w(false)});return()=>{a=true}},[r.id,k,I,y,x]);const b=r.requestData??C?.requestData??void 0;const z=r.responseData??C?.responseData??void 0;const D=(x?C?.requestHeaders:void 0)??r.requestHeaders;const $=(x?C?.responseHeaders:void 0)??r.responseHeaders;const v=()=>{const a={method:r.method,url:r.url,status:r.status,statusText:r.statusText,timestamp:new Date(r.timestamp).toISOString(),duration:r.duration?`${r.duration}ms`:"N/A",requestHeaders:D,requestData:b,responseHeaders:$,responseData:z,requestSize:r.requestSize?q(r.requestSize):"N/A",responseSize:r.responseSize?q(r.responseSize):"N/A",error:r.error,client:r.requestClient};return`# Network Request Details
|
|
2
2
|
|
|
3
3
|
## Request
|
|
4
4
|
- **Method:** ${a.method}
|
|
@@ -32,4 +32,4 @@ ${JSON.stringify(a.responseHeaders,null,2)}
|
|
|
32
32
|
\`\`\`json
|
|
33
33
|
${JSON.stringify(a.responseData,null,2)}
|
|
34
34
|
\`\`\`
|
|
35
|
-
`};return n(W,{children:[n(re,{testID:"buoy-network-detail-scroll",style:t.container,children:[n(l,{style:t.requestDetailsSection,children:[n(l,{style:t.httpHeader,children:[e(l,{style:t.httpMethodBadge,children:e(i,{style:t.httpMethod,children:r.method})}),r.status?e(l,{style:[t.httpStatusBadge,{backgroundColor:`${p?.color}20`}],children:n(i,{style:[t.httpStatusText,{color:p?.color}],children:[p?.text," ",p?.meaning]})}):B?n(l,{style:t.pendingBadge,children:[e(M,{size:10,color:o.color.warning}),e(i,{style:t.pendingBadgeText,children:"Pending"})]}):null,r.condition&&n(i,{style:{color:"#FFCC66"},children:["Conditions: ",r.condition.profile," (+",r.condition.delayMs," ms)"]}),r.duration?n(l,{style:t.httpDuration,children:[e(M,{size:10,color:o.color.textTertiary}),e(i,{style:t.httpDurationText,children:X(r.duration)})]}):null,r.override?n(l,{style:t.overrideBadge,children:[e(de,{size:10,color:o.color.warning}),e(i,{style:t.overrideBadgeText,children:r.override.ruleName||"Overridden"})]}):null,g?e(K,{value:v,buttonStyle:t.copyFullButton}):e(O,{style:t.copyFullButton,onPress:()=>f(true),activeOpacity:.7,children:e(Y,{size:14,color:o.color.textSecondary})})]}),e(xe,{url:r.url,requestData:b,operationName:r.operationName,graphqlVariables:r.graphqlVariables,requestClient:r.requestClient,isPro:g,onUpgradePress:()=>f(true)}),r.error?n(l,{style:t.errorBox,children:[e(le,{size:12,color:o.color.danger}),e(i,{style:t.errorText,children:r.error})]}):null]}),n(l,{style:t.timingSection,children:[n(l,{style:t.timingRow,children:[e(M,{size:12,color:o.color.textSecondary}),e(i,{style:t.timingLabel,children:"Started:"}),e(i,{style:t.timingValue,children:he(r.timestamp)}),n(i,{style:t.timingExact,children:["(",new Date(r.timestamp).toLocaleTimeString(),")"]}),r.requestSize||r.responseSize?n(l,{style:t.sizeRow,children:[r.requestSize!==void 0?n(l,{style:t.sizeItem,children:[e(G,{size:10,color:o.color.info}),e(i,{style:t.sizeLabel,children:"Sent:"}),e(i,{style:t.sizeValue,children:q(r.requestSize)})]}):null,r.responseSize!==void 0?n(l,{style:t.sizeItem,children:[e(J,{size:10,color:A}),e(i,{style:t.sizeLabel,children:"Received:"}),e(i,{style:t.sizeValue,children:q(r.responseSize)})]}):null]}):null]}),r.timings?n(W,{children:[e(l,{style:t.phaseDivider}),e(Se,{timings:r.timings,total:r.duration??r.timings.ttfb+r.timings.download})]}):null]}),e(T,{title:"Request Headers",icon:e(G,{size:14,color:o.color.info}),defaultOpen:false,count:Object.keys(D).length,children:Object.keys(D).length>0?e(l,{style:t.dataViewerContainer,children:e(F,{title:"",data:D,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g})}):e(i,{style:t.emptyText,children:"No request headers"})}),e(T,{title:"Response Headers",icon:e(J,{size:14,color:A}),defaultOpen:false,count:Object.keys($).length,children:Object.keys($).length>0?e(l,{style:t.dataViewerContainer,children:e(F,{title:"",data:$,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g})}):e(i,{style:t.emptyText,children:"No response headers yet"})}),b!==void 0?e(T,{title:"Request Body",icon:e(E,{size:14,color:o.color.accent}),defaultOpen:false,children:e(l,{style:t.dataViewerContainer,children:s?e(F,{title:"",data:b,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g}):e(Z,{})})}):L?e(T,{title:"Request Body",icon:e(E,{size:14,color:o.color.accent}),defaultOpen:true,children:e(i,{style:t.emptyText,children:m?`Loading request body (${q(r.requestSize??0)})\u2026`:"Request body unavailable"})}):null,z!==void 0?e(T,{title:"Response Body",icon:e(E,{size:14,color:A}),defaultOpen:true,children:e(l,{style:t.dataViewerContainer,children:s?e(F,{title:"",data:z,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g}):e(Z,{})})}):y?e(T,{title:"Response Body",icon:e(E,{size:14,color:A}),defaultOpen:true,children:e(i,{style:t.emptyText,children:m?`Loading response body (${q(r.responseSize??0)})\u2026`:"Response body unavailable"})}):null,e(T,{title:"Filter Options",icon:e(ae,{size:14,color:o.color.warning}),defaultOpen:false,children:e(l,{style:t.filterOptionsContainer,children:(()=>{let a="";let S="";try{const j=new URL(r.url);a=j.hostname;S=j.pathname}catch{S=r.url}const I=u.has(a);const P=u.has(S);return n(W,{children:[n(O,{style:[t.filterOption,I&&t.filterOptionActive],onPress:()=>a&&h(a),children:[n(l,{style:t.filterOptionLeft,children:[e(se,{size:16,color:I?o.color.warning:o.color.textTertiary}),n(l,{style:t.filterOptionContent,children:[e(i,{style:t.filterOptionLabel,children:"Ignore Domain"}),e(i,{style:t.filterOptionValue,children:a||"N/A"})]})]}),e(l,{style:[t.filterToggle,I&&t.filterToggleActive],children:e(i,{style:[t.filterToggleText,I&&t.filterToggleTextActive],children:I?"IGNORED":"IGNORE"})})]}),n(O,{style:[t.filterOption,P&&t.filterOptionActive],onPress:()=>S&&h(S),children:[n(l,{style:t.filterOptionLeft,children:[e(ce,{size:16,color:P?o.color.warning:o.color.textTertiary}),n(l,{style:t.filterOptionContent,children:[e(i,{style:t.filterOptionLabel,children:"Ignore URL Pattern"}),e(i,{style:t.filterOptionValue,numberOfLines:1,children:S||"N/A"})]})]}),e(l,{style:[t.filterToggle,P&&t.filterToggleActive],children:e(i,{style:[t.filterToggleText,P&&t.filterToggleTextActive],children:P?"IGNORED":"IGNORE"})})]}),e(l,{style:t.filterInfoBox,children:e(i,{style:t.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]}),e(pe,{visible:c,onClose:()=>f(false),featureName:"Copy Request Details",description:"Copy network request details to share or debug issues.",benefits:["Copy full request details including headers and body","Export to JSON, Markdown, or plain text","Share request data with teammates","Feed data to AI assistants for debugging"]})]})});const t=oe.create({container:{flex:1,backgroundColor:"transparent"},requestDetailsSection:{marginHorizontal:12,marginTop:12,backgroundColor:o.color.surface,borderRadius:8,borderWidth:1,borderColor:o.color.border,padding:12},httpHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{backgroundColor:o.color.infoSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpMethod:{color:o.color.info,fontSize:11,fontWeight:"700",letterSpacing:.5},httpStatusBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpStatusText:{fontSize:11,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:o.color.warningSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},pendingBadgeText:{color:o.color.warning,fontSize:11,fontWeight:"600"},httpDuration:{flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:o.color.textSecondary,fontSize:11},overrideBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:6,paddingVertical:3,borderRadius:4,backgroundColor:o.color.warningSoft},overrideBadgeText:{color:o.color.warning,fontSize:10,fontWeight:"700"},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:o.color.bg,borderRadius:4,padding:8},urlRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:o.color.text,fontSize:12,fontWeight:"600",flex:1},urlProtocol:{color:o.color.textTertiary,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:o.color.textSecondary,fontSize:11,fontFamily:R},urlQueryString:{color:o.color.info,fontSize:11,fontFamily:R},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,backgroundColor:o.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:o.color.border,marginBottom:8},queryParamsToggleText:{flexGrow:0,color:o.color.text,fontSize:12,fontWeight:"600",letterSpacing:.3},timingSection:{marginHorizontal:12,marginTop:8,backgroundColor:o.color.surface,borderRadius:8,borderWidth:1,borderColor:o.color.border,padding:12},timingRow:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:o.color.textSecondary,fontSize:11},timingValue:{color:o.color.text,fontSize:11,fontWeight:"600"},timingExact:{color:o.color.textTertiary,fontSize:10,marginLeft:4},sizeRow:{flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:o.color.textTertiary,fontSize:10},sizeValue:{color:o.color.info,fontSize:10,fontFamily:R,fontWeight:"600"},phaseDivider:{height:1,backgroundColor:o.color.border,marginTop:12,marginBottom:12},phaseList:{gap:8},phaseRow:{flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150},phaseLabel:{fontSize:12,color:o.color.textSecondary},phaseHint:{fontSize:10,color:o.color.textTertiary},phaseTrack:{flex:1,height:7,borderRadius:4,backgroundColor:o.color.surfaceElevated,justifyContent:"center",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,textAlign:"right",fontSize:12,fontFamily:R,color:o.color.text},collapsibleSection:{marginHorizontal:12,marginTop:8,backgroundColor:o.color.surface,borderRadius:8,borderWidth:1,borderColor:o.color.border,overflow:"hidden"},collapsibleHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:o.color.surfaceElevated},collapsibleTitle:{flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:o.color.text,fontSize:13,fontWeight:"600"},collapsibleCount:{color:o.color.textTertiary,fontSize:11.5,fontFamily:R},collapsibleContent:{padding:12},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12},bodyDeferred:{height:120},errorBox:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.dangerSoft,padding:8,borderRadius:4,marginTop:8},errorText:{color:o.color.danger,fontSize:11,flex:1},emptyText:{color:o.color.textTertiary,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{gap:12},filterOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:o.color.surfaceElevated,borderRadius:8,padding:12,borderWidth:1,borderColor:o.color.border},filterOptionActive:{backgroundColor:o.color.warningSoft,borderColor:o.color.warning+"33"},filterOptionLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1},filterOptionContent:{flex:1},filterOptionLabel:{color:o.color.textSecondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:o.color.text,fontSize:13,fontFamily:R},filterToggle:{paddingHorizontal:10,paddingVertical:6,borderRadius:4,backgroundColor:o.color.bg,borderWidth:1,borderColor:o.color.border},filterToggleActive:{backgroundColor:o.color.warningSoft,borderColor:o.color.warning+"4D"},filterToggleText:{fontSize:10,fontWeight:"600",color:o.color.textTertiary,letterSpacing:.5},filterToggleTextActive:{color:o.color.warning},filterInfoBox:{backgroundColor:o.color.infoSoft,borderRadius:6,padding:10,borderWidth:1,borderColor:o.color.info+"33"},filterInfoText:{color:o.color.textSecondary,fontSize:11,lineHeight:16}});
|
|
35
|
+
`};return n(W,{children:[n(re,{keyboardShouldPersistTaps:"handled",testID:"buoy-network-detail-scroll",style:o.container,children:[n(l,{style:o.requestDetailsSection,children:[n(l,{style:o.httpHeader,children:[e(l,{style:o.httpMethodBadge,children:e(i,{style:o.httpMethod,children:r.method})}),r.status?e(l,{style:[o.httpStatusBadge,{backgroundColor:`${p?.color}20`}],children:n(i,{style:[o.httpStatusText,{color:p?.color}],children:[p?.text," ",p?.meaning]})}):B?n(l,{style:o.pendingBadge,children:[e(M,{size:10,color:t.color.warning}),e(i,{style:o.pendingBadgeText,children:"Pending"})]}):null,r.condition&&n(i,{style:{color:"#FFCC66"},children:["Conditions: ",r.condition.profile," (+",r.condition.delayMs," ms)"]}),r.condition?.uploadCap?.note&&e(i,{testID:"buoy-network-upload-cap-detail",style:{color:"#FFCC66"},children:r.condition.uploadCap.note}),r.duration?n(l,{style:o.httpDuration,children:[e(M,{size:10,color:t.color.textTertiary}),e(i,{style:o.httpDurationText,children:X(r.duration)})]}):null,r.override?n(l,{style:o.overrideBadge,children:[e(de,{size:10,color:t.color.warning}),e(i,{style:o.overrideBadgeText,children:r.override.ruleName||"Overridden"})]}):null,g?e(K,{value:v,buttonStyle:o.copyFullButton}):e(O,{style:o.copyFullButton,onPress:()=>f(true),activeOpacity:.7,children:e(Y,{size:14,color:t.color.textSecondary})})]}),e(xe,{url:r.url,requestData:b,operationName:r.operationName,graphqlVariables:r.graphqlVariables,requestClient:r.requestClient,isPro:g,onUpgradePress:()=>f(true)}),r.error?n(l,{style:o.errorBox,children:[e(le,{size:12,color:t.color.danger}),e(i,{style:o.errorText,children:r.error})]}):null]}),n(l,{style:o.timingSection,children:[n(l,{style:o.timingRow,children:[e(M,{size:12,color:t.color.textSecondary}),e(i,{style:o.timingLabel,children:"Started:"}),e(i,{style:o.timingValue,children:he(r.timestamp)}),n(i,{style:o.timingExact,children:["(",new Date(r.timestamp).toLocaleTimeString(),")"]}),r.requestSize||r.responseSize?n(l,{style:o.sizeRow,children:[r.requestSize!==void 0?n(l,{style:o.sizeItem,children:[e(G,{size:10,color:t.color.info}),e(i,{style:o.sizeLabel,children:"Sent:"}),e(i,{style:o.sizeValue,children:q(r.requestSize)})]}):null,r.responseSize!==void 0?n(l,{style:o.sizeItem,children:[e(J,{size:10,color:A}),e(i,{style:o.sizeLabel,children:"Received:"}),e(i,{style:o.sizeValue,children:q(r.responseSize)})]}):null]}):null]}),r.timings?n(W,{children:[e(l,{style:o.phaseDivider}),e(Se,{timings:r.timings,total:r.duration??r.timings.ttfb+r.timings.download})]}):null]}),e(T,{title:"Request Headers",icon:e(G,{size:14,color:t.color.info}),defaultOpen:false,count:Object.keys(D).length,children:Object.keys(D).length>0?e(l,{style:o.dataViewerContainer,children:e(H,{title:"",data:D,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g})}):e(i,{style:o.emptyText,children:"No request headers"})}),e(T,{title:"Response Headers",icon:e(J,{size:14,color:A}),defaultOpen:false,count:Object.keys($).length,children:Object.keys($).length>0?e(l,{style:o.dataViewerContainer,children:e(H,{title:"",data:$,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g})}):e(i,{style:o.emptyText,children:"No response headers yet"})}),b!==void 0?e(T,{title:"Request Body",icon:e(E,{size:14,color:t.color.accent}),defaultOpen:false,children:e(l,{style:o.dataViewerContainer,children:s?e(H,{title:"",data:b,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g}):e(Z,{})})}):I?e(T,{title:"Request Body",icon:e(E,{size:14,color:t.color.accent}),defaultOpen:true,children:e(i,{style:o.emptyText,children:m?`Loading request body (${q(r.requestSize??0)})\u2026`:"Request body unavailable"})}):null,z!==void 0?e(T,{title:"Response Body",icon:e(E,{size:14,color:A}),defaultOpen:true,children:e(l,{style:o.dataViewerContainer,children:s?e(H,{title:"",data:z,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!g}):e(Z,{})})}):y?e(T,{title:"Response Body",icon:e(E,{size:14,color:A}),defaultOpen:true,children:e(i,{style:o.emptyText,children:m?`Loading response body (${q(r.responseSize??0)})\u2026`:"Response body unavailable"})}):null,e(T,{title:"Filter Options",icon:e(ae,{size:14,color:t.color.warning}),defaultOpen:false,children:e(l,{style:o.filterOptionsContainer,children:(()=>{let a="";let S="";try{const j=new URL(r.url);a=j.hostname;S=j.pathname}catch{S=r.url}const L=u.has(a);const P=u.has(S);return n(W,{children:[n(O,{style:[o.filterOption,L&&o.filterOptionActive],onPress:()=>a&&h(a),children:[n(l,{style:o.filterOptionLeft,children:[e(se,{size:16,color:L?t.color.warning:t.color.textTertiary}),n(l,{style:o.filterOptionContent,children:[e(i,{style:o.filterOptionLabel,children:"Ignore Domain"}),e(i,{style:o.filterOptionValue,children:a||"N/A"})]})]}),e(l,{style:[o.filterToggle,L&&o.filterToggleActive],children:e(i,{style:[o.filterToggleText,L&&o.filterToggleTextActive],children:L?"IGNORED":"IGNORE"})})]}),n(O,{style:[o.filterOption,P&&o.filterOptionActive],onPress:()=>S&&h(S),children:[n(l,{style:o.filterOptionLeft,children:[e(ce,{size:16,color:P?t.color.warning:t.color.textTertiary}),n(l,{style:o.filterOptionContent,children:[e(i,{style:o.filterOptionLabel,children:"Ignore URL Pattern"}),e(i,{style:o.filterOptionValue,numberOfLines:1,children:S||"N/A"})]})]}),e(l,{style:[o.filterToggle,P&&o.filterToggleActive],children:e(i,{style:[o.filterToggleText,P&&o.filterToggleTextActive],children:P?"IGNORED":"IGNORE"})})]}),e(l,{style:o.filterInfoBox,children:e(i,{style:o.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]}),e(pe,{visible:c,onClose:()=>f(false),featureName:"Copy Request Details",description:"Copy network request details to share or debug issues.",benefits:["Copy full request details including headers and body","Export to JSON, Markdown, or plain text","Share request data with teammates","Feed data to AI assistants for debugging"]})]})});const o=te.create({container:{flex:1,backgroundColor:"transparent"},requestDetailsSection:{marginHorizontal:12,marginTop:12,backgroundColor:t.color.surface,borderRadius:8,borderWidth:1,borderColor:t.color.border,padding:12},httpHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{backgroundColor:t.color.infoSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpMethod:{color:t.color.info,fontSize:11,fontWeight:"700",letterSpacing:.5},httpStatusBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpStatusText:{fontSize:11,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:t.color.warningSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},pendingBadgeText:{color:t.color.warning,fontSize:11,fontWeight:"600"},httpDuration:{flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:t.color.textSecondary,fontSize:11},overrideBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:6,paddingVertical:3,borderRadius:4,backgroundColor:t.color.warningSoft},overrideBadgeText:{color:t.color.warning,fontSize:10,fontWeight:"700"},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:t.color.bg,borderRadius:4,padding:8},urlRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:t.color.text,fontSize:12,fontWeight:"600",flex:1},urlProtocol:{color:t.color.textTertiary,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:t.color.textSecondary,fontSize:11,fontFamily:R},urlQueryString:{color:t.color.info,fontSize:11,fontFamily:R},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,backgroundColor:t.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:t.color.border,marginBottom:8},queryParamsToggleText:{flexGrow:0,color:t.color.text,fontSize:12,fontWeight:"600",letterSpacing:.3},timingSection:{marginHorizontal:12,marginTop:8,backgroundColor:t.color.surface,borderRadius:8,borderWidth:1,borderColor:t.color.border,padding:12},timingRow:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:t.color.textSecondary,fontSize:11},timingValue:{color:t.color.text,fontSize:11,fontWeight:"600"},timingExact:{color:t.color.textTertiary,fontSize:10,marginLeft:4},sizeRow:{flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:t.color.textTertiary,fontSize:10},sizeValue:{color:t.color.info,fontSize:10,fontFamily:R,fontWeight:"600"},phaseDivider:{height:1,backgroundColor:t.color.border,marginTop:12,marginBottom:12},phaseList:{gap:8},phaseRow:{flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150},phaseLabel:{fontSize:12,color:t.color.textSecondary},phaseHint:{fontSize:10,color:t.color.textTertiary},phaseTrack:{flex:1,height:7,borderRadius:4,backgroundColor:t.color.surfaceElevated,justifyContent:"center",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,textAlign:"right",fontSize:12,fontFamily:R,color:t.color.text},collapsibleSection:{marginHorizontal:12,marginTop:8,backgroundColor:t.color.surface,borderRadius:8,borderWidth:1,borderColor:t.color.border,overflow:"hidden"},collapsibleHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:t.color.surfaceElevated},collapsibleTitle:{flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:t.color.text,fontSize:13,fontWeight:"600"},collapsibleCount:{color:t.color.textTertiary,fontSize:11.5,fontFamily:R},collapsibleContent:{padding:12},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12},bodyDeferred:{height:120},errorBox:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:t.color.dangerSoft,padding:8,borderRadius:4,marginTop:8},errorText:{color:t.color.danger,fontSize:11,flex:1},emptyText:{color:t.color.textTertiary,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{gap:12},filterOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:t.color.surfaceElevated,borderRadius:8,padding:12,borderWidth:1,borderColor:t.color.border},filterOptionActive:{backgroundColor:t.color.warningSoft,borderColor:t.color.warning+"33"},filterOptionLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1},filterOptionContent:{flex:1},filterOptionLabel:{color:t.color.textSecondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:t.color.text,fontSize:13,fontFamily:R},filterToggle:{paddingHorizontal:10,paddingVertical:6,borderRadius:4,backgroundColor:t.color.bg,borderWidth:1,borderColor:t.color.border},filterToggleActive:{backgroundColor:t.color.warningSoft,borderColor:t.color.warning+"4D"},filterToggleText:{fontSize:10,fontWeight:"600",color:t.color.textTertiary,letterSpacing:.5},filterToggleTextActive:{color:t.color.warning},filterInfoBox:{backgroundColor:t.color.infoSoft,borderRadius:6,padding:10,borderWidth:1,borderColor:t.color.info+"33"},filterInfoText:{color:t.color.textSecondary,fontSize:11,lineHeight:16}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";import{memo as U,useEffect as G,useMemo as J,useState as q}from"react";import{formatGraphQLDisplay as _}from"../utils/formatGraphQLVariables";import{useNetworkBodyResolver as Q}from"../sync/networkBodyResolver";import{DataViewer as R,InlineCopyButton as
|
|
1
|
+
"use strict";import{memo as U,useEffect as G,useMemo as J,useState as q}from"react";import{formatGraphQLDisplay as _}from"../utils/formatGraphQLVariables";import{useNetworkBodyResolver as Q}from"../sync/networkBodyResolver";import{DataViewer as R,InlineCopyButton as F}from"./DataViewer.web";import{jsx as e,jsxs as o,Fragment as A}from"react/jsx-runtime";const r={background:{base:"#0A0A0C",card:"#1A1A1C",hover:"#1D1D1F",input:"#26262A"},border:{default:"#2D2D2F"},text:{primary:"#F5F5F7",secondary:"#A1A1A6",muted:"#8E8E93"},semantic:{success:"#34C759",error:"#FF453A",errorBackground:"rgba(255, 69, 58, 0.15)",warning:"#FFEB3B",warningBackground:"rgba(255, 235, 59, 0.15)",info:"#00B8E6",infoBackground:"rgba(0, 184, 230, 0.1)"}};const $=r.semantic.success;function k(i){if(i===void 0||i===null)return"N/A";if(i===0)return"0 B";const t=1024;const c=["B","KB","MB","GB","TB"];const d=Math.floor(Math.log(i)/Math.log(t));return`${(i/Math.pow(t,d)).toFixed(1)} ${c[d]}`}function N(i){if(i===void 0||i===null)return"N/A";if(i<1e3)return`${i}ms`;if(i<6e4)return`${(i/1e3).toFixed(1)}s`;if(i<36e5){const d=Math.floor(i/6e4);const s=Math.floor(i%6e4/1e3);return s>0?`${d}m ${s}s`:`${d}m`}const t=Math.floor(i/36e5);const c=Math.floor(i%36e5/6e4);return c>0?`${t}h ${c}m`:`${t}h`}function Y(i,t=Date.now()){const c=i instanceof Date?i.getTime():i;const d=Math.floor((t-c)/1e3);if(d<0)return"just now";if(d<60)return d===0?"just now":`${d}s ago`;const s=Math.floor(d/60);if(s<60)return`${s}m ago`;const a=Math.floor(s/60);if(a<24)return`${a}h ago`;const u=Math.floor(a/24);return`${u}d ago`}function K(i){if(i>=100&&i<200){return{text:String(i),color:r.semantic.info,meaning:"Informational"}}if(i>=200&&i<300){const t={200:"OK",201:"Created",202:"Accepted",204:"No Content",206:"Partial Content"};return{text:String(i),color:r.semantic.success,meaning:t[i]||"Success"}}if(i>=300&&i<400){const t={301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",307:"Temporary Redirect",308:"Permanent Redirect"};return{text:String(i),color:r.semantic.warning,meaning:t[i]||"Redirect"}}if(i>=400&&i<500){const t={400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",408:"Request Timeout",409:"Conflict",410:"Gone",422:"Unprocessable Entity",429:"Too Many Requests"};return{text:String(i),color:r.semantic.error,meaning:t[i]||"Client Error"}}if(i>=500){const t={500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported"};return{text:String(i),color:r.semantic.error,meaning:t[i]||"Server Error"}}return{text:String(i),color:r.text.muted,meaning:"Unknown"}}function p({size:i=14,color:t="currentColor",children:c}){return e("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,display:"block"},children:c})}const L=i=>o(p,{...i,children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("polyline",{points:"12 6 12 12 16 14"})]});const P=i=>o(p,{...i,children:[e("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e("polyline",{points:"17 8 12 3 7 8"}),e("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]});const E=i=>o(p,{...i,children:[e("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e("polyline",{points:"7 10 12 15 17 10"}),e("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]});const Z=i=>o(p,{...i,children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]});const H=i=>e(p,{...i,children:e("path",{d:"m6 9 6 6 6-6"})});const W=i=>e(p,{...i,children:e("path",{d:"m18 15-6-6-6 6"})});const X=i=>o(p,{...i,children:[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});const ee=i=>o(p,{...i,children:[e("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]});const v=i=>o(p,{...i,children:[e("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),e("path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1"}),e("path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1"})]});const te=i=>e(p,{...i,children:e("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})});const ne=i=>o(p,{...i,children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),e("path",{d:"M2 12h20"})]});const re=i=>o(p,{...i,children:[e("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]});const ie=i=>o(p,{...i,children:[e("path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"}),e("path",{d:"M8.5 2h7"}),e("path",{d:"M7 16h10"})]});const oe=new Set;const le=()=>{};const ae=({timings:i,total:t})=>{const c=Math.max(1,t);const d=[{label:"Waiting (TTFB)",hint:"incl. queue, DNS, TLS",value:i.ttfb,color:r.semantic.warning},{label:"Content download",hint:void 0,value:i.download,color:r.semantic.success}];return e("div",{style:n.phaseList,children:d.map(s=>o("div",{style:n.phaseRow,children:[o("div",{style:n.phaseLabelGroup,children:[e("div",{style:n.phaseLabel,children:s.label}),s.hint?e("div",{style:n.phaseHint,children:s.hint}):null]}),e("div",{style:n.phaseTrack,children:e("div",{style:{...n.phaseBar,backgroundColor:s.color,width:`${Math.min(100,Math.max(1,s.value/c*100))}%`}})}),e("span",{style:n.phaseValue,children:N(s.value)})]},s.label))})};const V=()=>e("div",{style:n.bodyDeferred});const w=({title:i,icon:t,children:c,defaultOpen:d=false,count:s})=>{const[a,u]=q(d);return o("div",{style:n.collapsibleSection,children:[o("button",{type:"button",style:n.collapsibleHeader,onClick:()=>u(!a),"aria-expanded":a,children:[o("span",{style:n.collapsibleTitle,children:[t,e("span",{style:n.collapsibleTitleText,children:i}),s!==void 0?e("span",{style:n.collapsibleCount,children:s}):null]}),a?e(W,{size:16,color:r.text.secondary}):e(H,{size:16,color:r.text.secondary})]}),a?e("div",{style:n.collapsibleContent,children:c}):null]})};const se=({url:i,operationName:t,graphqlVariables:c,requestClient:d})=>{const s=C=>{try{const h=new URL(C);const y=String(h.protocol||"");const S=String(h.host||"");const O=y==="https:";let f=String(h.pathname||"");if(d==="graphql"&&t){const b=_(t,c);f=`${f} (${b})`}else if(t){f=`${f} (${t})`}const x={};const g=h.searchParams;if(g&&typeof g.forEach==="function"){g.forEach((b,z)=>{x[z]=b})}return{protocol:y.replace(":",""),host:S,pathname:f,params:Object.keys(x).length>0?x:null,isSecure:O}}catch{return{protocol:"",host:i,pathname:"",params:null,isSecure:false}}};const a=J(()=>s(i),[i,d,t,c]);const[u,T]=q(false);return o("div",{style:n.urlBreakdown,children:[o("div",{style:n.urlRow,children:[a.isSecure?e(X,{size:12,color:r.semantic.success}):e(ee,{size:12,color:r.semantic.warning}),e("span",{style:n.urlDomain,children:a.host}),o("span",{style:n.urlProtocol,children:["(",a.protocol.toUpperCase(),")"]}),e(F,{value:i,buttonStyle:n.copyButton})]}),e("div",{style:n.urlPathRow,children:o("span",{style:n.urlPath,children:[a.pathname,a.params?o("span",{style:n.urlQueryString,children:["?",new URLSearchParams(a.params).toString()]}):null]})}),a.params?o("div",{style:n.queryParamsCollapsible,children:[o("button",{type:"button",style:n.queryParamsToggle,onClick:()=>T(!u),"aria-expanded":u,children:[e("span",{style:n.queryParamsToggleText,children:"Query Parameters"}),e("span",{style:{...n.collapsibleCount,flex:1,textAlign:"left"},children:Object.keys(a.params).length}),u?e(W,{size:14,color:r.text.secondary}):e(H,{size:14,color:r.text.secondary})]}),u?e(R,{title:"",data:a.params,showTypeFilter:true,rawMode:true,initialExpanded:true}):null]}):null]})};export const NetworkEventDetailView=U(function i({event:t,ignoredPatterns:c=oe,onTogglePattern:d=le,showBodies:s=true}){const a=t.status?K(t.status):null;const u=!t.status&&!t.error;const T=Q();const C=t.requestData===void 0&&(t.requestBodyOmitted===true||(t.requestSize??0)>0);const h=t.responseData===void 0&&(t.responseBodyOmitted===true||(t.responseSize??0)>0);const y=t.headersOmitted===true;const[S,O]=q(null);const[f,x]=q(false);G(()=>{O(null);if(!T||!C&&!h&&!y){x(false);return}let l=false;x(true);T(t.id).then(m=>{if(!l)O(m)}).catch(()=>{}).finally(()=>{if(!l)x(false)});return()=>{l=true}},[t.id,T,C,h,y]);const g=t.requestData??S?.requestData??void 0;const b=t.responseData??S?.responseData??void 0;const z=(y?S?.requestHeaders:void 0)??t.requestHeaders;const M=(y?S?.responseHeaders:void 0)??t.responseHeaders;const j=()=>{const l={method:t.method,url:t.url,status:t.status,statusText:t.statusText,timestamp:new Date(t.timestamp).toISOString(),duration:t.duration?`${t.duration}ms`:"N/A",requestHeaders:z,requestData:g,responseHeaders:M,responseData:b,requestSize:t.requestSize?k(t.requestSize):"N/A",responseSize:t.responseSize?k(t.responseSize):"N/A",error:t.error,client:t.requestClient};return`# Network Request Details
|
|
2
2
|
|
|
3
3
|
## Request
|
|
4
4
|
- **Method:** ${l.method}
|
|
@@ -32,4 +32,4 @@ ${JSON.stringify(l.responseHeaders,null,2)}
|
|
|
32
32
|
\`\`\`json
|
|
33
33
|
${JSON.stringify(l.responseData,null,2)}
|
|
34
34
|
\`\`\`
|
|
35
|
-
`};return o("div",{style:t.container,children:[o("div",{style:t.requestDetailsSection,children:[o("div",{style:t.httpHeader,children:[e("span",{style:t.httpMethodBadge,children:e("span",{style:t.httpMethod,children:n.method})}),n.status?e("span",{style:{...t.httpStatusBadge,backgroundColor:`${a?.color}20`},children:o("span",{style:{...t.httpStatusText,color:a?.color},children:[a?.text," ",a?.meaning]})}):u?o("span",{style:t.pendingBadge,children:[e(L,{size:10,color:r.semantic.warning}),e("span",{style:t.pendingBadgeText,children:"Pending"})]}):null,n.duration?o("span",{style:t.httpDuration,children:[e(L,{size:10,color:r.text.muted}),e("span",{style:t.httpDurationText,children:N(n.duration)})]}):null,n.override?o("span",{style:t.overrideBadge,children:[e(ie,{size:10,color:r.semantic.warning}),e("span",{style:t.overrideBadgeText,children:n.override.ruleName||"Overridden"})]}):null,e(A,{value:j,buttonStyle:t.copyFullButton})]}),e(se,{url:n.url,requestData:g,operationName:n.operationName,graphqlVariables:n.graphqlVariables,requestClient:n.requestClient}),n.error?o("div",{style:t.errorBox,children:[e(Z,{size:12,color:r.semantic.error}),e("span",{style:t.errorText,children:n.error})]}):null]}),o("div",{style:t.timingSection,children:[o("div",{style:t.timingRow,children:[e(L,{size:12,color:r.text.secondary}),e("span",{style:t.timingLabel,children:"Started:"}),e("span",{style:t.timingValue,children:Y(n.timestamp)}),o("span",{style:t.timingExact,children:["(",new Date(n.timestamp).toLocaleTimeString(),")"]}),n.requestSize||n.responseSize?o("span",{style:t.sizeRow,children:[n.requestSize!==void 0?o("span",{style:t.sizeItem,children:[e(P,{size:10,color:r.semantic.info}),e("span",{style:t.sizeLabel,children:"Sent:"}),e("span",{style:t.sizeValue,children:k(n.requestSize)})]}):null,n.responseSize!==void 0?o("span",{style:t.sizeItem,children:[e(E,{size:10,color:$}),e("span",{style:t.sizeLabel,children:"Received:"}),e("span",{style:t.sizeValue,children:k(n.responseSize)})]}):null]}):null]}),n.timings?o(F,{children:[e("div",{style:t.phaseDivider}),e(ae,{timings:n.timings,total:n.duration??n.timings.ttfb+n.timings.download})]}):null]}),e(w,{title:"Request Headers",icon:e(P,{size:14,color:r.semantic.info}),defaultOpen:false,count:Object.keys(z).length,children:Object.keys(z).length>0?e("div",{style:t.dataViewerContainer,children:e(R,{title:"",data:z,showTypeFilter:true,rawMode:true,initialExpanded:true})}):e("div",{style:t.emptyText,children:"No request headers"})}),e(w,{title:"Response Headers",icon:e(E,{size:14,color:$}),defaultOpen:false,count:Object.keys(M).length,children:Object.keys(M).length>0?e("div",{style:t.dataViewerContainer,children:e(R,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}):e("div",{style:t.emptyText,children:"No response headers yet"})}),g!==void 0?e(w,{title:"Request Body",icon:e(v,{size:14,color:r.semantic.info}),defaultOpen:false,children:e("div",{style:t.dataViewerContainer,children:s?e(R,{title:"",data:g,showTypeFilter:true,rawMode:true,initialExpanded:true}):e(V,{})})}):D?e(w,{title:"Request Body",icon:e(v,{size:14,color:r.semantic.info}),defaultOpen:true,children:e("div",{style:t.emptyText,children:f?`Loading request body (${k(n.requestSize??0)})\u2026`:"Request body unavailable"})}):null,b!==void 0?e(w,{title:"Response Body",icon:e(v,{size:14,color:$}),defaultOpen:true,children:e("div",{style:t.dataViewerContainer,children:s?e(R,{title:"",data:b,showTypeFilter:true,rawMode:true,initialExpanded:true}):e(V,{})})}):h?e(w,{title:"Response Body",icon:e(v,{size:14,color:$}),defaultOpen:true,children:e("div",{style:t.emptyText,children:f?`Loading response body (${k(n.responseSize??0)})\u2026`:"Response body unavailable"})}):null,e(w,{title:"Filter Options",icon:e(te,{size:14,color:r.semantic.warning}),defaultOpen:false,children:e("div",{style:t.filterOptionsContainer,children:(()=>{let l="";let m="";try{const I=new URL(n.url);l=I.hostname;m=I.pathname}catch{m=n.url}const B=c.has(l);const C=c.has(m);return o(F,{children:[o("button",{type:"button",style:{...t.filterOption,...B?t.filterOptionActive:null},onClick:()=>l&&d(l),children:[o("span",{style:t.filterOptionLeft,children:[e(ne,{size:16,color:B?r.semantic.warning:r.text.muted}),o("span",{style:t.filterOptionContent,children:[e("span",{style:t.filterOptionLabel,children:"Ignore Domain"}),e("span",{style:t.filterOptionValue,children:l||"N/A"})]})]}),e("span",{style:{...t.filterToggle,...B?t.filterToggleActive:null},children:e("span",{style:{...t.filterToggleText,...B?t.filterToggleTextActive:null},children:B?"IGNORED":"IGNORE"})})]}),o("button",{type:"button",style:{...t.filterOption,...C?t.filterOptionActive:null},onClick:()=>m&&d(m),children:[o("span",{style:t.filterOptionLeft,children:[e(re,{size:16,color:C?r.semantic.warning:r.text.muted}),o("span",{style:t.filterOptionContent,children:[e("span",{style:t.filterOptionLabel,children:"Ignore URL Pattern"}),e("span",{style:{...t.filterOptionValue,...t.singleLine},children:m||"N/A"})]})]}),e("span",{style:{...t.filterToggle,...C?t.filterToggleActive:null},children:e("span",{style:{...t.filterToggleText,...C?t.filterToggleTextActive:null},children:C?"IGNORED":"IGNORE"})})]}),e("div",{style:t.filterInfoBox,children:e("span",{style:t.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]})});const t={container:{flex:1,minHeight:0,overflowY:"auto",backgroundColor:r.background.base},requestDetailsSection:{margin:"12px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,padding:12},httpHeader:{display:"flex",flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{display:"inline-flex",backgroundColor:r.semantic.infoBackground,padding:"4px 8px",borderRadius:4},httpMethod:{color:r.semantic.info,fontSize:11,fontWeight:700,letterSpacing:.5},httpStatusBadge:{display:"inline-flex",padding:"4px 8px",borderRadius:4,whiteSpace:"nowrap"},httpStatusText:{fontSize:11,fontWeight:600},pendingBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4,backgroundColor:r.semantic.warningBackground,padding:"4px 8px",borderRadius:4},pendingBadgeText:{color:r.semantic.warning,fontSize:11,fontWeight:600},httpDuration:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:r.text.secondary,fontSize:11},overrideBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4,padding:"3px 6px",borderRadius:4,backgroundColor:r.semantic.warningBackground},overrideBadgeText:{color:r.semantic.warning,fontSize:10,fontWeight:700},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:r.background.input,borderRadius:4,padding:8},urlRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:r.text.primary,fontSize:12,fontWeight:600,flex:1,minWidth:0,overflowWrap:"anywhere"},urlProtocol:{color:r.text.muted,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:r.text.secondary,fontSize:11,fontFamily:"ui-monospace, Menlo, monospace",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},urlQueryString:{color:r.semantic.info,fontSize:11,fontFamily:"ui-monospace, Menlo, monospace"},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,padding:"10px 12px",backgroundColor:r.background.hover,borderRadius:8,border:`1px solid ${r.border.default}`,marginBottom:8,cursor:"pointer",margin:"0 0 8px",font:"inherit"},queryParamsToggleText:{flexGrow:0,color:r.text.primary,fontSize:12,fontWeight:600,letterSpacing:.3,whiteSpace:"nowrap"},timingSection:{margin:"8px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,padding:12},timingRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:r.text.secondary,fontSize:11},timingValue:{color:r.text.primary,fontSize:11,fontWeight:600},timingExact:{color:r.text.muted,fontSize:10,marginLeft:4},sizeRow:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:r.text.muted,fontSize:10},sizeValue:{color:r.semantic.info,fontSize:10,fontFamily:"ui-monospace, Menlo, monospace",fontWeight:600},phaseDivider:{height:1,backgroundColor:r.border.default,marginTop:12,marginBottom:12},phaseList:{display:"flex",flexDirection:"column",gap:8},phaseRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150,flexShrink:0},phaseLabel:{fontSize:12,color:r.text.secondary},phaseHint:{fontSize:10,color:r.text.muted},phaseTrack:{flex:1,minWidth:0,height:7,borderRadius:4,backgroundColor:r.background.hover,display:"flex",justifyContent:"center",flexDirection:"column",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,flexShrink:0,textAlign:"right",fontSize:12,fontFamily:"ui-monospace, Menlo, monospace",color:r.text.primary},collapsibleSection:{margin:"8px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,overflow:"hidden"},collapsibleHeader:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:r.background.hover,border:"none",cursor:"pointer",margin:0,font:"inherit",textAlign:"left"},collapsibleTitle:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:r.text.primary,fontSize:13,fontWeight:600},collapsibleCount:{color:r.text.muted,fontSize:11.5,fontFamily:"ui-monospace, Menlo, monospace"},collapsibleContent:{padding:12},dataViewerContainer:{margin:-12},bodyDeferred:{height:120},errorBox:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,backgroundColor:r.semantic.errorBackground,padding:8,borderRadius:4,marginTop:8},errorText:{color:r.semantic.error,fontSize:11,flex:1,minWidth:0,overflowWrap:"anywhere"},emptyText:{color:r.text.muted,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{display:"flex",flexDirection:"column",gap:12},filterOption:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:r.background.hover,borderRadius:8,padding:12,border:`1px solid ${r.border.default}`,cursor:"pointer",margin:0,font:"inherit",textAlign:"left"},filterOptionActive:{backgroundColor:r.semantic.warningBackground,border:`1px solid ${r.semantic.warning}33`},filterOptionLeft:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:12,flex:1,minWidth:0},filterOptionContent:{display:"inline-flex",flexDirection:"column",flex:1,minWidth:0},filterOptionLabel:{color:r.text.secondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:r.text.primary,fontSize:13,fontFamily:"ui-monospace, Menlo, monospace",overflowWrap:"anywhere"},singleLine:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},filterToggle:{display:"inline-flex",padding:"6px 10px",borderRadius:4,backgroundColor:r.background.input,border:`1px solid ${r.border.default}`,flexShrink:0},filterToggleActive:{backgroundColor:`${r.semantic.warning}26`,border:`1px solid ${r.semantic.warning}4D`},filterToggleText:{fontSize:10,fontWeight:600,color:r.text.muted,letterSpacing:.5},filterToggleTextActive:{color:r.semantic.warning},filterInfoBox:{backgroundColor:r.semantic.infoBackground,borderRadius:6,padding:10,border:`1px solid ${r.semantic.info}33`},filterInfoText:{color:r.text.secondary,fontSize:11,lineHeight:"16px"}};
|
|
35
|
+
`};return o("div",{style:n.container,children:[o("div",{style:n.requestDetailsSection,children:[o("div",{style:n.httpHeader,children:[e("span",{style:n.httpMethodBadge,children:e("span",{style:n.httpMethod,children:t.method})}),t.status?e("span",{style:{...n.httpStatusBadge,backgroundColor:`${a?.color}20`},children:o("span",{style:{...n.httpStatusText,color:a?.color},children:[a?.text," ",a?.meaning]})}):u?o("span",{style:n.pendingBadge,children:[e(L,{size:10,color:r.semantic.warning}),e("span",{style:n.pendingBadgeText,children:"Pending"})]}):null,t.condition?.uploadCap?.note&&e("span",{style:{color:"#FFCC66"},children:t.condition.uploadCap.note}),t.duration?o("span",{style:n.httpDuration,children:[e(L,{size:10,color:r.text.muted}),e("span",{style:n.httpDurationText,children:N(t.duration)})]}):null,t.override?o("span",{style:n.overrideBadge,children:[e(ie,{size:10,color:r.semantic.warning}),e("span",{style:n.overrideBadgeText,children:t.override.ruleName||"Overridden"})]}):null,e(F,{value:j,buttonStyle:n.copyFullButton})]}),e(se,{url:t.url,requestData:g,operationName:t.operationName,graphqlVariables:t.graphqlVariables,requestClient:t.requestClient}),t.error?o("div",{style:n.errorBox,children:[e(Z,{size:12,color:r.semantic.error}),e("span",{style:n.errorText,children:t.error})]}):null]}),o("div",{style:n.timingSection,children:[o("div",{style:n.timingRow,children:[e(L,{size:12,color:r.text.secondary}),e("span",{style:n.timingLabel,children:"Started:"}),e("span",{style:n.timingValue,children:Y(t.timestamp)}),o("span",{style:n.timingExact,children:["(",new Date(t.timestamp).toLocaleTimeString(),")"]}),t.requestSize||t.responseSize?o("span",{style:n.sizeRow,children:[t.requestSize!==void 0?o("span",{style:n.sizeItem,children:[e(P,{size:10,color:r.semantic.info}),e("span",{style:n.sizeLabel,children:"Sent:"}),e("span",{style:n.sizeValue,children:k(t.requestSize)})]}):null,t.responseSize!==void 0?o("span",{style:n.sizeItem,children:[e(E,{size:10,color:$}),e("span",{style:n.sizeLabel,children:"Received:"}),e("span",{style:n.sizeValue,children:k(t.responseSize)})]}):null]}):null]}),t.timings?o(A,{children:[e("div",{style:n.phaseDivider}),e(ae,{timings:t.timings,total:t.duration??t.timings.ttfb+t.timings.download})]}):null]}),e(w,{title:"Request Headers",icon:e(P,{size:14,color:r.semantic.info}),defaultOpen:false,count:Object.keys(z).length,children:Object.keys(z).length>0?e("div",{style:n.dataViewerContainer,children:e(R,{title:"",data:z,showTypeFilter:true,rawMode:true,initialExpanded:true})}):e("div",{style:n.emptyText,children:"No request headers"})}),e(w,{title:"Response Headers",icon:e(E,{size:14,color:$}),defaultOpen:false,count:Object.keys(M).length,children:Object.keys(M).length>0?e("div",{style:n.dataViewerContainer,children:e(R,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}):e("div",{style:n.emptyText,children:"No response headers yet"})}),g!==void 0?e(w,{title:"Request Body",icon:e(v,{size:14,color:r.semantic.info}),defaultOpen:false,children:e("div",{style:n.dataViewerContainer,children:s?e(R,{title:"",data:g,showTypeFilter:true,rawMode:true,initialExpanded:true}):e(V,{})})}):C?e(w,{title:"Request Body",icon:e(v,{size:14,color:r.semantic.info}),defaultOpen:true,children:e("div",{style:n.emptyText,children:f?`Loading request body (${k(t.requestSize??0)})\u2026`:"Request body unavailable"})}):null,b!==void 0?e(w,{title:"Response Body",icon:e(v,{size:14,color:$}),defaultOpen:true,children:e("div",{style:n.dataViewerContainer,children:s?e(R,{title:"",data:b,showTypeFilter:true,rawMode:true,initialExpanded:true}):e(V,{})})}):h?e(w,{title:"Response Body",icon:e(v,{size:14,color:$}),defaultOpen:true,children:e("div",{style:n.emptyText,children:f?`Loading response body (${k(t.responseSize??0)})\u2026`:"Response body unavailable"})}):null,e(w,{title:"Filter Options",icon:e(te,{size:14,color:r.semantic.warning}),defaultOpen:false,children:e("div",{style:n.filterOptionsContainer,children:(()=>{let l="";let m="";try{const I=new URL(t.url);l=I.hostname;m=I.pathname}catch{m=t.url}const D=c.has(l);const B=c.has(m);return o(A,{children:[o("button",{type:"button",style:{...n.filterOption,...D?n.filterOptionActive:null},onClick:()=>l&&d(l),children:[o("span",{style:n.filterOptionLeft,children:[e(ne,{size:16,color:D?r.semantic.warning:r.text.muted}),o("span",{style:n.filterOptionContent,children:[e("span",{style:n.filterOptionLabel,children:"Ignore Domain"}),e("span",{style:n.filterOptionValue,children:l||"N/A"})]})]}),e("span",{style:{...n.filterToggle,...D?n.filterToggleActive:null},children:e("span",{style:{...n.filterToggleText,...D?n.filterToggleTextActive:null},children:D?"IGNORED":"IGNORE"})})]}),o("button",{type:"button",style:{...n.filterOption,...B?n.filterOptionActive:null},onClick:()=>m&&d(m),children:[o("span",{style:n.filterOptionLeft,children:[e(re,{size:16,color:B?r.semantic.warning:r.text.muted}),o("span",{style:n.filterOptionContent,children:[e("span",{style:n.filterOptionLabel,children:"Ignore URL Pattern"}),e("span",{style:{...n.filterOptionValue,...n.singleLine},children:m||"N/A"})]})]}),e("span",{style:{...n.filterToggle,...B?n.filterToggleActive:null},children:e("span",{style:{...n.filterToggleText,...B?n.filterToggleTextActive:null},children:B?"IGNORED":"IGNORE"})})]}),e("div",{style:n.filterInfoBox,children:e("span",{style:n.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]})});const n={container:{flex:1,minHeight:0,overflowY:"auto",backgroundColor:r.background.base},requestDetailsSection:{margin:"12px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,padding:12},httpHeader:{display:"flex",flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{display:"inline-flex",backgroundColor:r.semantic.infoBackground,padding:"4px 8px",borderRadius:4},httpMethod:{color:r.semantic.info,fontSize:11,fontWeight:700,letterSpacing:.5},httpStatusBadge:{display:"inline-flex",padding:"4px 8px",borderRadius:4,whiteSpace:"nowrap"},httpStatusText:{fontSize:11,fontWeight:600},pendingBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4,backgroundColor:r.semantic.warningBackground,padding:"4px 8px",borderRadius:4},pendingBadgeText:{color:r.semantic.warning,fontSize:11,fontWeight:600},httpDuration:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:r.text.secondary,fontSize:11},overrideBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4,padding:"3px 6px",borderRadius:4,backgroundColor:r.semantic.warningBackground},overrideBadgeText:{color:r.semantic.warning,fontSize:10,fontWeight:700},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:r.background.input,borderRadius:4,padding:8},urlRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:r.text.primary,fontSize:12,fontWeight:600,flex:1,minWidth:0,overflowWrap:"anywhere"},urlProtocol:{color:r.text.muted,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:r.text.secondary,fontSize:11,fontFamily:"ui-monospace, Menlo, monospace",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},urlQueryString:{color:r.semantic.info,fontSize:11,fontFamily:"ui-monospace, Menlo, monospace"},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,padding:"10px 12px",backgroundColor:r.background.hover,borderRadius:8,border:`1px solid ${r.border.default}`,marginBottom:8,cursor:"pointer",margin:"0 0 8px",font:"inherit"},queryParamsToggleText:{flexGrow:0,color:r.text.primary,fontSize:12,fontWeight:600,letterSpacing:.3,whiteSpace:"nowrap"},timingSection:{margin:"8px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,padding:12},timingRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:r.text.secondary,fontSize:11},timingValue:{color:r.text.primary,fontSize:11,fontWeight:600},timingExact:{color:r.text.muted,fontSize:10,marginLeft:4},sizeRow:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:r.text.muted,fontSize:10},sizeValue:{color:r.semantic.info,fontSize:10,fontFamily:"ui-monospace, Menlo, monospace",fontWeight:600},phaseDivider:{height:1,backgroundColor:r.border.default,marginTop:12,marginBottom:12},phaseList:{display:"flex",flexDirection:"column",gap:8},phaseRow:{display:"flex",flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150,flexShrink:0},phaseLabel:{fontSize:12,color:r.text.secondary},phaseHint:{fontSize:10,color:r.text.muted},phaseTrack:{flex:1,minWidth:0,height:7,borderRadius:4,backgroundColor:r.background.hover,display:"flex",justifyContent:"center",flexDirection:"column",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,flexShrink:0,textAlign:"right",fontSize:12,fontFamily:"ui-monospace, Menlo, monospace",color:r.text.primary},collapsibleSection:{margin:"8px 12px 0",backgroundColor:r.background.card,borderRadius:8,border:`1px solid ${r.border.default}`,overflow:"hidden"},collapsibleHeader:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:r.background.hover,border:"none",cursor:"pointer",margin:0,font:"inherit",textAlign:"left"},collapsibleTitle:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:r.text.primary,fontSize:13,fontWeight:600},collapsibleCount:{color:r.text.muted,fontSize:11.5,fontFamily:"ui-monospace, Menlo, monospace"},collapsibleContent:{padding:12},dataViewerContainer:{margin:-12},bodyDeferred:{height:120},errorBox:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,backgroundColor:r.semantic.errorBackground,padding:8,borderRadius:4,marginTop:8},errorText:{color:r.semantic.error,fontSize:11,flex:1,minWidth:0,overflowWrap:"anywhere"},emptyText:{color:r.text.muted,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{display:"flex",flexDirection:"column",gap:12},filterOption:{display:"flex",width:"100%",boxSizing:"border-box",flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:r.background.hover,borderRadius:8,padding:12,border:`1px solid ${r.border.default}`,cursor:"pointer",margin:0,font:"inherit",textAlign:"left"},filterOptionActive:{backgroundColor:r.semantic.warningBackground,border:`1px solid ${r.semantic.warning}33`},filterOptionLeft:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:12,flex:1,minWidth:0},filterOptionContent:{display:"inline-flex",flexDirection:"column",flex:1,minWidth:0},filterOptionLabel:{color:r.text.secondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:r.text.primary,fontSize:13,fontFamily:"ui-monospace, Menlo, monospace",overflowWrap:"anywhere"},singleLine:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},filterToggle:{display:"inline-flex",padding:"6px 10px",borderRadius:4,backgroundColor:r.background.input,border:`1px solid ${r.border.default}`,flexShrink:0},filterToggleActive:{backgroundColor:`${r.semantic.warning}26`,border:`1px solid ${r.semantic.warning}4D`},filterToggleText:{fontSize:10,fontWeight:600,color:r.text.muted,letterSpacing:.5},filterToggleTextActive:{color:r.semantic.warning},filterInfoBox:{backgroundColor:r.semantic.infoBackground,borderRadius:6,padding:10,border:`1px solid ${r.semantic.info}33`},filterInfoText:{color:r.text.secondary,fontSize:11,lineHeight:"16px"}};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import{memo as T}from"react";import{StyleSheet as z,View as n,Text as a}from"react-native";import{ChevronRight as S,Upload as
|
|
2
|
-
(${r.operationName})`}return l(E,{onPress:()=>d(r),onLongPress:m?()=>m(r):void 0,style:
|
|
1
|
+
"use strict";import{memo as T}from"react";import{StyleSheet as z,View as n,Text as a}from"react-native";import{ChevronRight as S,Upload as w,Download as R,Clock as k,AlertCircle as I,Bookmark as B,FlaskConical as D,Pin as q,DevToolsCard as E,MethodBadge as H,TypeBadge as L,night as i,macOSColors as s,monoFont as u}from"@buoy-gg/shared-ui";import{formatBytes as h,formatDuration as N}from"../utils/formatting";import{formatRelativeTime as W}from"@buoy-gg/shared-ui";import{useTickEveryMinute as F}from"../hooks/useTickEveryMinute";import{formatGraphQLDisplay as V}from"../utils/formatGraphQLVariables";import{jsx as o,jsxs as l}from"react/jsx-runtime";function j(t,r){if(r)return s.semantic.error;if(!t)return s.semantic.warning;if(t>=200&&t<300)return s.semantic.success;if(t>=300&&t<400)return s.semantic.info;if(t>=400)return s.semantic.error;return s.text.muted}function M(t){const r=t?.["content-type"]||t?.["Content-Type"]||"";if(r.includes("json"))return"JSON";if(r.includes("xml"))return"XML";if(r.includes("html"))return"HTML";if(r.includes("text"))return"TEXT";if(r.includes("image"))return"IMG";if(r.includes("video"))return"VIDEO";if(r.includes("audio"))return"AUDIO";if(r.includes("form"))return"FORM";return null}function y(t){switch(t){case"fetch":return{backgroundColor:"rgba(74, 144, 226, 0.15)",color:"#4A90E2"};case"graphql":return{backgroundColor:"rgba(229, 53, 171, 0.15)",color:"#E535AB"};case"grpc-web":return{backgroundColor:"rgba(16, 185, 129, 0.15)",color:"#10B981"};case"xhr":return{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#F59E0B"};default:return{backgroundColor:"rgba(147, 51, 234, 0.15)",color:"#9333EA"}}}function O({event:t,isPending:r,statusColor:d}){if(r){return l(n,{style:e.pendingBadge,children:[o(k,{size:10,color:i.color.warning}),o(a,{style:e.pendingText,children:"..."})]})}if(t.error){return l(n,{style:e.errorBadge,children:[o(I,{size:10,color:i.color.danger}),o(a,{style:e.errorText,children:"ERR"})]})}return o(n,{style:e.statusBadge,children:o(a,{style:[e.statusText,{color:d}],children:String(t.status)})})}function $({requestSize:t,responseSize:r}){if(!t&&!r)return null;return l(n,{style:e.sizeRow,children:[t?l(n,{style:e.sizeItem,children:[o(w,{size:8,color:i.color.info}),o(a,{style:e.sizeText,children:h(t)})]}):null,r?l(n,{style:e.sizeItem,children:[o(R,{size:8,color:i.color.accent}),o(a,{style:e.sizeText,children:h(r)})]}):null]})}function A({timestamp:t,duration:r}){const d=F();const g=W(t,d);return r?l(a,{style:e.bottomRightText,children:[N(r)," ",g]}):o(a,{style:e.bottomRightText,children:g})}export const NetworkEventItemCompact=T(function t({event:r,onPress:d,pinned:g=false,saved:C=false,overridden:x=false,onLongPress:m}){const p=j(r.status,r.error);const b=!r.status&&!r.error;const f=M(r.responseHeaders);let c=r.path||r.url.replace(/^https?:\/\/[^/]+/,"");if(r.requestClient==="graphql"){if(r.operationName){c=V(r.operationName,r.graphqlVariables)}else{c=c.replace(/\/graphql[^?]*/,"/graphql")}}else if(r.operationName){c=`${c}
|
|
2
|
+
(${r.operationName})`}return l(E,{onPress:()=>d(r),onLongPress:m?()=>m(r):void 0,style:e.cardWrapper,contentStyle:[e.container,{borderLeftColor:p}],testID:`buoy-network-row-${r.id}`,accessibilityLabel:`${r.method} ${r.path||r.url}`,children:[l(n,{style:e.topRightContainer,children:[g?o(q,{size:10,active:true,color:i.color.info}):null,C?o(B,{size:10,color:i.color.accent}):null,x||r.override?o(D,{size:10,color:i.color.warning}):null,o(O,{event:r,isPending:b,statusColor:p}),r.requestClient?o(n,{style:[e.topRightBadge,{backgroundColor:y(r.requestClient).backgroundColor}],children:o(a,{style:[e.clientText,{color:y(r.requestClient).color}],children:r.requestClient==="graphql"?"GQL":r.requestClient==="grpc-web"?"gRPC":r.requestClient==="xhr"?"XHR":r.requestClient})}):null]}),l(n,{style:e.leftSection,children:[o(H,{method:r.method,size:"small"}),o($,{requestSize:r.requestSize,responseSize:r.responseSize})]}),l(n,{style:e.middleSection,children:[o(a,{style:e.urlText,numberOfLines:2,children:c}),r.condition?.uploadCap?.note&&o(a,{testID:`buoy-network-upload-cap-${r.id}`,style:{color:i.color.warning,fontSize:10},children:r.condition.uploadCap.note})]}),l(n,{style:e.rightSection,children:[f?o(L,{type:f,size:"small"}):null,o(S,{size:14,color:i.color.textTertiary})]}),o(n,{style:e.bottomRightContainer,children:o(A,{timestamp:r.timestamp,duration:r.duration})})]})});NetworkEventItemCompact.displayName="NetworkEventItemCompact";const e=z.create({cardWrapper:{marginHorizontal:8},container:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(12, 12, 12, 0.9)",borderLeftWidth:3,borderLeftColor:"transparent",borderBottomWidth:1},leftSection:{marginRight:8,alignItems:"flex-start"},topRightContainer:{position:"absolute",top:1,right:1,flexDirection:"row",alignItems:"center",gap:4},topRightBadge:{paddingHorizontal:4,paddingVertical:2,borderRadius:4},middleSection:{flex:1,justifyContent:"center",paddingRight:8},urlText:{fontSize:12,color:i.color.text,lineHeight:16,fontFamily:u},rightSection:{flexDirection:"row",alignItems:"center",gap:6},bottomRightContainer:{position:"absolute",bottom:4,right:8},bottomRightText:{fontSize:9,color:i.color.textTertiary,fontFamily:u},statusBadge:{paddingHorizontal:4,paddingVertical:1,borderRadius:3},statusText:{fontSize:10,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:i.color.warningSoft,borderRadius:3},pendingText:{fontSize:10,color:i.color.warning,fontWeight:"600"},errorBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:i.color.dangerSoft,borderRadius:3},errorText:{fontSize:10,color:i.color.danger,fontWeight:"600"},durationText:{fontSize:9,color:i.color.textSecondary},sizeRow:{flexDirection:"row",gap:4,marginTop:4},sizeItem:{flexDirection:"row",alignItems:"center",gap:2},sizeText:{fontSize:8,color:i.color.textSecondary,fontFamily:u},clientText:{fontSize:8,fontWeight:"700",letterSpacing:.3,textTransform:"uppercase"}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";import{memo as k,useEffect as B,useState as C,useRef as T}from"react";import{formatGraphQLDisplay as M}from"../utils/formatGraphQLVariables";import{jsx as r,jsxs as a}from"react/jsx-runtime";const h={text:{muted:"#8E8E93"},semantic:{success:"#34C759",error:"#FF453A",warning:"#FFEB3B",info:"#00B8E6"}};const x={primary:"#20C997",success:"#20C997",warning:"#FFA94D",error:"#EF4444"};const n={cardScrim:"rgba(12, 12, 12, 0.9)",border:"#1A1A1C",separator:"rgba(255, 255, 255, 0.08)",text:"#ECEDEE",textSecondary:"#9BA1A6",textTertiary:"#636366",accent:"#20C997",danger:"#FF3B30",dangerSoft:"rgba(255, 59, 48, 0.10)",warning:"#FF8329",warningSoft:"rgba(255, 131, 41, 0.12)",info:"#1E6DFF"};function u({size:t=14,color:e="currentColor",children:i}){return r("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,display:"block"},children:i})}const z=t=>r(u,{...t,children:r("path",{d:"m9 18 6-6-6-6"})});const R=t=>a(u,{...t,children:[r("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),r("polyline",{points:"17 8 12 3 7 8"}),r("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]});const E=t=>a(u,{...t,children:[r("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),r("polyline",{points:"7 10 12 15 17 10"}),r("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]});const D=t=>a(u,{...t,children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("polyline",{points:"12 6 12 12 16 14"})]});const I=t=>a(u,{...t,children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),r("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]});const F=t=>r(u,{...t,children:r("path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"})});const $=t=>a(u,{...t,children:[r("path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"}),r("path",{d:"M8.5 2h7"}),r("path",{d:"M7 16h10"})]});const A=({active:t,...e})=>r(u,{...e,children:a("g",{transform:t?"rotate(-45 12 12) translate(12 12) scale(0.92) translate(-12 -12)":void 0,children:[r("path",{d:"M2.97 21.03 8.18 15.82"}),r("path",{d:"M4.4 10.81 13.19 19.6"}),r("path",{d:"M5.17 10.54 11.43 8.83"}),r("path",{d:"M13.46 18.83 15.17 12.57"}),r("rect",{x:"12.15",y:"5.4",width:"9.38",height:"3.52",rx:"1.07",transform:"rotate(-45 16.84 7.16)"})]})});function S(t){if(t===void 0||t===null)return"N/A";if(t===0)return"0 B";const e=1024;const i=["B","KB","MB","GB","TB"];const l=Math.floor(Math.log(t)/Math.log(e));return`${(t/Math.pow(e,l)).toFixed(1)} ${i[l]}`}function P(t){if(t===void 0||t===null)return"N/A";if(t<1e3){return`${t}ms`}if(t<6e4){return`${(t/1e3).toFixed(1)}s`}if(t<36e5){const l=Math.floor(t/6e4);const s=Math.floor(t%6e4/1e3);return s>0?`${l}m ${s}s`:`${l}m`}const e=Math.floor(t/36e5);const i=Math.floor(t%36e5/6e4);return i>0?`${e}h ${i}m`:`${e}h`}function W(t,e=Date.now()){const i=t instanceof Date?t.getTime():t;const l=Math.floor((e-i)/1e3);if(l<0){return"just now"}if(l<60){return l===0?"just now":`${l}s ago`}const s=Math.floor(l/60);if(s<60){return`${s}m ago`}const c=Math.floor(s/60);if(c<24){return`${c}h ago`}const d=Math.floor(c/24);return`${d}d ago`}const y=new Set;let m=null;function q(t){y.add(t);if(m==null){m=setInterval(()=>{const e=Date.now();y.forEach(i=>i(e))},5e3)}return()=>{y.delete(t);if(y.size===0&&m!=null){clearInterval(m);m=null}}}function L(){const[t,e]=C(()=>Date.now());B(()=>q(e),[]);return t}function N(t,e){if(e)return h.semantic.error;if(!t)return h.semantic.warning;if(t>=200&&t<300)return h.semantic.success;if(t>=300&&t<400)return h.semantic.info;if(t>=400)return h.semantic.error;return h.text.muted}function O(t){const e=t?.["content-type"]||t?.["Content-Type"]||"";if(e.includes("json"))return"JSON";if(e.includes("xml"))return"XML";if(e.includes("html"))return"HTML";if(e.includes("text"))return"TEXT";if(e.includes("image"))return"IMG";if(e.includes("video"))return"VIDEO";if(e.includes("audio"))return"AUDIO";if(e.includes("form"))return"FORM";return null}function w(t){switch(t){case"fetch":return{backgroundColor:"rgba(74, 144, 226, 0.15)",color:"#4A90E2"};case"graphql":return{backgroundColor:"rgba(229, 53, 171, 0.15)",color:"#E535AB"};case"grpc-web":return{backgroundColor:"rgba(16, 185, 129, 0.15)",color:"#10B981"};case"xhr":return{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#F59E0B"};default:return{backgroundColor:"rgba(147, 51, 234, 0.15)",color:"#9333EA"}}}const j={GET:x.success,POST:x.primary,PUT:x.warning,PATCH:n.textSecondary,DELETE:x.error,HEAD:n.textTertiary,OPTIONS:x.primary};function H({method:t}){const e=j[t.toUpperCase()]||"#6B7280";return r("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:45,boxSizing:"border-box",padding:"2px 6px",fontSize:11,fontWeight:700,color:e,backgroundColor:`${e}15`,border:`1px solid ${e}40`,borderRadius:4},children:t.toUpperCase()})}function U({type:t}){const e=n.textTertiary;return r("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",fontSize:11,fontWeight:600,color:e,backgroundColor:`${e}15`,border:`1px solid ${e}40`,borderRadius:4},children:t})}function G({onPress:t,onLongPress:e,children:i,contentStyle:l}){const[s,c]=C(false);const d=T(null);const p=T(false);const f=()=>{if(d.current!=null){clearTimeout(d.current);d.current=null}};return r("div",{style:{margin:"4px 8px"},children:r("button",{type:"button",onPointerDown:()=>{c(true);if(e){p.current=false;f();d.current=setTimeout(()=>{p.current=true;e()},500)}},onPointerUp:()=>{c(false);f()},onPointerLeave:()=>{c(false);f()},onPointerCancel:()=>{c(false);f()},onClick:()=>{if(p.current){p.current=false;return}t()},style:{position:"relative",display:"flex",width:"100%",boxSizing:"border-box",backgroundColor:n.cardScrim,borderRadius:8,border:`1px solid ${n.border}`,borderBottom:`1px solid ${n.separator}`,padding:12,minHeight:44,margin:0,textAlign:"left",cursor:"pointer",fontFamily:"inherit",color:"inherit",userSelect:"none",WebkitUserSelect:"none",opacity:s?.8:1,...l},children:i})})}function V({event:t,isPending:e,statusColor:i}){if(e){return a("span",{style:o.pendingBadge,children:[r(D,{size:10,color:n.warning}),r("span",{style:o.pendingText,children:"..."})]})}if(t.error){return a("span",{style:o.errorBadge,children:[r(I,{size:10,color:n.danger}),r("span",{style:o.errorText,children:"ERR"})]})}return r("span",{style:o.statusBadge,children:r("span",{style:{...o.statusText,color:i},children:String(t.status)})})}function _({requestSize:t,responseSize:e}){if(!t&&!e)return null;return a("span",{style:o.sizeRow,children:[t?a("span",{style:o.sizeItem,children:[r(R,{size:8,color:n.info}),r("span",{style:o.sizeText,children:S(t)})]}):null,e?a("span",{style:o.sizeItem,children:[r(E,{size:8,color:n.accent}),r("span",{style:o.sizeText,children:S(e)})]}):null]})}function X({timestamp:t,duration:e}){const i=L();const l=W(t,i);return e?a("span",{style:o.bottomRightText,children:[P(e)," ",l]}):r("span",{style:o.bottomRightText,children:l})}export const NetworkEventItemCompact=k(function t({event:e,onPress:i,pinned:l=false,saved:s=false,overridden:c=false,onLongPress:d}){const p=N(e.status,e.error);const f=!e.status&&!e.error;const b=O(e.responseHeaders);let g=e.path||e.url.replace(/^https?:\/\/[^/]+/,"");if(e.requestClient==="graphql"){if(e.operationName){g=M(e.operationName,e.graphqlVariables)}else{g=g.replace(/\/graphql[^?]*/,"/graphql")}}else if(e.operationName){g=`${g}
|
|
2
|
-
(${e.operationName})`}return a(G,{onPress:()=>i(e),onLongPress:d?()=>d(e):void 0,contentStyle:{flexDirection:"row",alignItems:"center",borderLeft:`3px solid ${p}`},children:[a("span",{style:o.topRightContainer,children:[l?r(A,{size:10,active:true,color:n.info}):null,s?r(F,{size:10,color:n.accent}):null,c||e.override?r($,{size:10,color:n.warning}):null,r(V,{event:e,isPending:f,statusColor:p}),e.requestClient?r("span",{style:{...o.topRightBadge,backgroundColor:w(e.requestClient).backgroundColor},children:r("span",{style:{...o.clientText,color:w(e.requestClient).color},children:e.requestClient==="graphql"?"GQL":e.requestClient==="grpc-web"?"gRPC":e.requestClient==="xhr"?"XHR":e.requestClient})}):null]}),a("span",{style:o.leftSection,children:[r(H,{method:e.method}),r(_,{requestSize:e.requestSize,responseSize:e.responseSize})]}),
|
|
2
|
+
(${e.operationName})`}return a(G,{onPress:()=>i(e),onLongPress:d?()=>d(e):void 0,contentStyle:{flexDirection:"row",alignItems:"center",borderLeft:`3px solid ${p}`},children:[a("span",{style:o.topRightContainer,children:[l?r(A,{size:10,active:true,color:n.info}):null,s?r(F,{size:10,color:n.accent}):null,c||e.override?r($,{size:10,color:n.warning}):null,r(V,{event:e,isPending:f,statusColor:p}),e.requestClient?r("span",{style:{...o.topRightBadge,backgroundColor:w(e.requestClient).backgroundColor},children:r("span",{style:{...o.clientText,color:w(e.requestClient).color},children:e.requestClient==="graphql"?"GQL":e.requestClient==="grpc-web"?"gRPC":e.requestClient==="xhr"?"XHR":e.requestClient})}):null]}),a("span",{style:o.leftSection,children:[r(H,{method:e.method}),r(_,{requestSize:e.requestSize,responseSize:e.responseSize})]}),a("span",{style:o.middleSection,children:[r("span",{style:o.urlText,children:g}),e.condition?.uploadCap?.note&&r("span",{style:{color:n.warning,fontSize:10},children:e.condition.uploadCap.note})]}),a("span",{style:o.rightSection,children:[b?r(U,{type:b}):null,r(z,{size:14,color:n.textTertiary})]}),r("span",{style:o.bottomRightContainer,children:r(X,{timestamp:e.timestamp,duration:e.duration})})]})});NetworkEventItemCompact.displayName="NetworkEventItemCompact";const o={leftSection:{display:"flex",flexDirection:"column",marginRight:8,alignItems:"flex-start"},topRightContainer:{position:"absolute",top:1,right:1,display:"flex",flexDirection:"row",alignItems:"center",gap:4},topRightBadge:{display:"inline-flex",padding:"2px 4px",borderRadius:4},middleSection:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center",paddingRight:8},urlText:{fontSize:12,color:n.text,lineHeight:"16px",fontFamily:"ui-monospace, Menlo, monospace",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",whiteSpace:"pre-wrap",wordBreak:"break-all"},rightSection:{display:"flex",flexDirection:"row",alignItems:"center",gap:6},bottomRightContainer:{position:"absolute",bottom:4,right:8},bottomRightText:{fontSize:9,color:n.textTertiary,fontFamily:"ui-monospace, Menlo, monospace",whiteSpace:"pre"},statusBadge:{display:"inline-flex",padding:"1px 4px",borderRadius:3},statusText:{fontSize:10,fontWeight:600},pendingBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:2,padding:"1px 4px",backgroundColor:n.warningSoft,borderRadius:3},pendingText:{fontSize:10,color:n.warning,fontWeight:600},errorBadge:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:2,padding:"1px 4px",backgroundColor:n.dangerSoft,borderRadius:3},errorText:{fontSize:10,color:n.danger,fontWeight:600},sizeRow:{display:"flex",flexDirection:"row",gap:4,marginTop:4},sizeItem:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:2},sizeText:{fontSize:8,color:n.textSecondary,fontFamily:"ui-monospace, Menlo, monospace"},clientText:{fontSize:8,fontWeight:700,letterSpacing:.3,textTransform:"uppercase"}};
|