@buoy-gg/network 7.0.78 → 7.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +76 -2
  2. package/lib/commonjs/expo-network.js +1 -0
  3. package/lib/commonjs/index.js +1 -1
  4. package/lib/commonjs/index.web.js +1 -1
  5. package/lib/commonjs/netinfo.js +1 -0
  6. package/lib/commonjs/network/components/NetworkEventDetailView.js +2 -2
  7. package/lib/commonjs/network/components/NetworkEventDetailView.web.js +2 -2
  8. package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -2
  9. package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +1 -1
  10. package/lib/commonjs/network/components/NetworkModal.js +1 -1
  11. package/lib/commonjs/network/components/sockets/NetworkSocketsButton.js +1 -0
  12. package/lib/commonjs/network/components/sockets/NetworkSocketsScreen.js +1 -0
  13. package/lib/commonjs/network/components/sockets/SocketFrameView.js +1 -0
  14. package/lib/commonjs/network/components/sockets/SocketListView.js +1 -0
  15. package/lib/commonjs/network/components/sockets/SocketRows.js +1 -0
  16. package/lib/commonjs/network/components/sockets/SocketTricksView.js +1 -0
  17. package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -1
  18. package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -1
  19. package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -1
  20. package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -1
  21. package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -1
  22. package/lib/commonjs/network/conditions/connectivity/netInfoFacade.js +1 -0
  23. package/lib/commonjs/network/conditions/connectivity/patchNetwork.js +1 -0
  24. package/lib/commonjs/network/conditions/pacer.js +1 -0
  25. package/lib/commonjs/network/conditions/profiles.js +1 -0
  26. package/lib/commonjs/network/conditions/remoteState.js +1 -0
  27. package/lib/commonjs/network/conditions/store.js +1 -1
  28. package/lib/commonjs/network/conditions/wait.js +1 -1
  29. package/lib/commonjs/network/conditions/xhr.js +1 -1
  30. package/lib/commonjs/network/hooks/useSocketsState.js +1 -0
  31. package/lib/commonjs/network/overrides/engine.js +1 -1
  32. package/lib/commonjs/network/overrides/matchRule.js +1 -1
  33. package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -1
  34. package/lib/commonjs/network/sockets/findProblems.js +1 -0
  35. package/lib/commonjs/network/sockets/foldFrames.js +1 -0
  36. package/lib/commonjs/network/sockets/format.js +1 -0
  37. package/lib/commonjs/network/sockets/readMessage.js +1 -0
  38. package/lib/commonjs/network/sockets/socketMoments.js +1 -0
  39. package/lib/commonjs/network/sockets/socketStore.js +1 -0
  40. package/lib/commonjs/network/sockets/socketsSyncAdapter.js +1 -0
  41. package/lib/commonjs/network/sockets/types.js +1 -0
  42. package/lib/commonjs/network/sockets/webSocketPatch.js +1 -0
  43. package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -1
  44. package/lib/commonjs/network/utils/generateNetworkCopyText.js +1 -0
  45. package/lib/commonjs/network/utils/networkEventStore.js +1 -1
  46. package/lib/commonjs/network/utils/networkListener.js +4 -4
  47. package/lib/commonjs/network/utils/startNetworkCapture.js +1 -1
  48. package/lib/commonjs/preset.js +1 -1
  49. package/lib/module/expo-network.js +1 -0
  50. package/lib/module/index.js +1 -1
  51. package/lib/module/index.web.js +1 -1
  52. package/lib/module/netinfo.js +1 -0
  53. package/lib/module/network/components/NetworkEventDetailView.js +2 -2
  54. package/lib/module/network/components/NetworkEventDetailView.web.js +2 -2
  55. package/lib/module/network/components/NetworkEventItemCompact.js +2 -2
  56. package/lib/module/network/components/NetworkEventItemCompact.web.js +1 -1
  57. package/lib/module/network/components/NetworkModal.js +1 -1
  58. package/lib/module/network/components/sockets/NetworkSocketsButton.js +1 -0
  59. package/lib/module/network/components/sockets/NetworkSocketsScreen.js +1 -0
  60. package/lib/module/network/components/sockets/SocketFrameView.js +1 -0
  61. package/lib/module/network/components/sockets/SocketListView.js +1 -0
  62. package/lib/module/network/components/sockets/SocketRows.js +1 -0
  63. package/lib/module/network/components/sockets/SocketTricksView.js +1 -0
  64. package/lib/module/network/conditions/NetworkConditionsControl.js +1 -1
  65. package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -1
  66. package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -1
  67. package/lib/module/network/conditions/NetworkFloatingTool.js +1 -1
  68. package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -1
  69. package/lib/module/network/conditions/connectivity/netInfoFacade.js +1 -0
  70. package/lib/module/network/conditions/connectivity/patchNetwork.js +1 -0
  71. package/lib/module/network/conditions/pacer.js +1 -0
  72. package/lib/module/network/conditions/profiles.js +1 -0
  73. package/lib/module/network/conditions/remoteState.js +1 -0
  74. package/lib/module/network/conditions/store.js +1 -1
  75. package/lib/module/network/conditions/wait.js +1 -1
  76. package/lib/module/network/conditions/xhr.js +1 -1
  77. package/lib/module/network/hooks/useSocketsState.js +1 -0
  78. package/lib/module/network/overrides/engine.js +1 -1
  79. package/lib/module/network/overrides/matchRule.js +1 -1
  80. package/lib/module/network/overrides/overrideRulesStore.js +1 -1
  81. package/lib/module/network/sockets/findProblems.js +1 -0
  82. package/lib/module/network/sockets/foldFrames.js +1 -0
  83. package/lib/module/network/sockets/format.js +1 -0
  84. package/lib/module/network/sockets/readMessage.js +1 -0
  85. package/lib/module/network/sockets/socketMoments.js +1 -0
  86. package/lib/module/network/sockets/socketStore.js +1 -0
  87. package/lib/module/network/sockets/socketsSyncAdapter.js +1 -0
  88. package/lib/module/network/sockets/types.js +1 -0
  89. package/lib/module/network/sockets/webSocketPatch.js +1 -0
  90. package/lib/module/network/sync/networkSyncAdapter.js +1 -1
  91. package/lib/module/network/utils/generateNetworkCopyText.js +23 -22
  92. package/lib/module/network/utils/networkEventStore.js +1 -1
  93. package/lib/module/network/utils/networkListener.js +4 -4
  94. package/lib/module/network/utils/startNetworkCapture.js +1 -1
  95. package/lib/module/preset.js +1 -1
  96. package/lib/typescript/expo-network.d.ts +2 -0
  97. package/lib/typescript/index.d.ts +14 -2
  98. package/lib/typescript/index.web.d.ts +7 -2
  99. package/lib/typescript/netinfo.d.ts +3 -0
  100. package/lib/typescript/network/components/sockets/NetworkSocketsButton.d.ts +17 -0
  101. package/lib/typescript/network/components/sockets/NetworkSocketsScreen.d.ts +19 -0
  102. package/lib/typescript/network/components/sockets/SocketFrameView.d.ts +9 -0
  103. package/lib/typescript/network/components/sockets/SocketListView.d.ts +9 -0
  104. package/lib/typescript/network/components/sockets/SocketRows.d.ts +19 -0
  105. package/lib/typescript/network/components/sockets/SocketTricksView.d.ts +23 -0
  106. package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts +5 -2
  107. package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts +4 -3
  108. package/lib/typescript/network/conditions/connectivity/netInfoFacade.d.ts +3 -0
  109. package/lib/typescript/network/conditions/connectivity/patchNetwork.d.ts +24 -0
  110. package/lib/typescript/network/conditions/pacer.d.ts +16 -0
  111. package/lib/typescript/network/conditions/profiles.d.ts +57 -0
  112. package/lib/typescript/network/conditions/remoteState.d.ts +4 -0
  113. package/lib/typescript/network/conditions/store.d.ts +45 -19
  114. package/lib/typescript/network/conditions/xhr.d.ts +1 -1
  115. package/lib/typescript/network/hooks/useSocketsState.d.ts +3 -0
  116. package/lib/typescript/network/overrides/engine.d.ts +14 -0
  117. package/lib/typescript/network/overrides/matchRule.d.ts +3 -0
  118. package/lib/typescript/network/overrides/overrideRulesStore.d.ts +22 -0
  119. package/lib/typescript/network/overrides/types.d.ts +33 -0
  120. package/lib/typescript/network/sockets/findProblems.d.ts +31 -0
  121. package/lib/typescript/network/sockets/foldFrames.d.ts +50 -0
  122. package/lib/typescript/network/sockets/format.d.ts +19 -0
  123. package/lib/typescript/network/sockets/readMessage.d.ts +41 -0
  124. package/lib/typescript/network/sockets/socketMoments.d.ts +24 -0
  125. package/lib/typescript/network/sockets/socketStore.d.ts +94 -0
  126. package/lib/typescript/network/sockets/socketsSyncAdapter.d.ts +66 -0
  127. package/lib/typescript/network/sockets/types.d.ts +139 -0
  128. package/lib/typescript/network/sockets/webSocketPatch.d.ts +57 -0
  129. package/lib/typescript/network/sync/networkSyncAdapter.d.ts +29 -12
  130. package/lib/typescript/network/types/index.d.ts +6 -0
  131. package/lib/typescript/network/utils/networkListener.d.ts +10 -0
  132. package/lib/web/index.mjs +60 -59
  133. package/package.json +26 -3
@@ -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 A}from"./DataViewer.web";import{jsx as e,jsxs as o,Fragment as F}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 n=1024;const c=["B","KB","MB","GB","TB"];const d=Math.floor(Math.log(i)/Math.log(n));return`${(i/Math.pow(n,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 n=Math.floor(i/36e5);const c=Math.floor(i%36e5/6e4);return c>0?`${n}h ${c}m`:`${n}h`}function Y(i,n=Date.now()){const c=i instanceof Date?i.getTime():i;const d=Math.floor((n-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 n={200:"OK",201:"Created",202:"Accepted",204:"No Content",206:"Partial Content"};return{text:String(i),color:r.semantic.success,meaning:n[i]||"Success"}}if(i>=300&&i<400){const n={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:n[i]||"Redirect"}}if(i>=400&&i<500){const n={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:n[i]||"Client Error"}}if(i>=500){const n={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:n[i]||"Server Error"}}return{text:String(i),color:r.text.muted,meaning:"Unknown"}}function p({size:i=14,color:n="currentColor",children:c}){return e("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:n,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:n})=>{const c=Math.max(1,n);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:t.phaseList,children:d.map(s=>o("div",{style:t.phaseRow,children:[o("div",{style:t.phaseLabelGroup,children:[e("div",{style:t.phaseLabel,children:s.label}),s.hint?e("div",{style:t.phaseHint,children:s.hint}):null]}),e("div",{style:t.phaseTrack,children:e("div",{style:{...t.phaseBar,backgroundColor:s.color,width:`${Math.min(100,Math.max(1,s.value/c*100))}%`}})}),e("span",{style:t.phaseValue,children:N(s.value)})]},s.label))})};const V=()=>e("div",{style:t.bodyDeferred});const w=({title:i,icon:n,children:c,defaultOpen:d=false,count:s})=>{const[a,u]=q(d);return o("div",{style:t.collapsibleSection,children:[o("button",{type:"button",style:t.collapsibleHeader,onClick:()=>u(!a),"aria-expanded":a,children:[o("span",{style:t.collapsibleTitle,children:[n,e("span",{style:t.collapsibleTitleText,children:i}),s!==void 0?e("span",{style:t.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:t.collapsibleContent,children:c}):null]})};const se=({url:i,operationName:n,graphqlVariables:c,requestClient:d})=>{const s=D=>{try{const h=new URL(D);const y=String(h.protocol||"");const S=String(h.host||"");const O=y==="https:";let f=String(h.pathname||"");if(d==="graphql"&&n){const b=_(n,c);f=`${f} (${b})`}else if(n){f=`${f} (${n})`}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,n,c]);const[u,T]=q(false);return o("div",{style:t.urlBreakdown,children:[o("div",{style:t.urlRow,children:[a.isSecure?e(X,{size:12,color:r.semantic.success}):e(ee,{size:12,color:r.semantic.warning}),e("span",{style:t.urlDomain,children:a.host}),o("span",{style:t.urlProtocol,children:["(",a.protocol.toUpperCase(),")"]}),e(A,{value:i,buttonStyle:t.copyButton})]}),e("div",{style:t.urlPathRow,children:o("span",{style:t.urlPath,children:[a.pathname,a.params?o("span",{style:t.urlQueryString,children:["?",new URLSearchParams(a.params).toString()]}):null]})}),a.params?o("div",{style:t.queryParamsCollapsible,children:[o("button",{type:"button",style:t.queryParamsToggle,onClick:()=>T(!u),"aria-expanded":u,children:[e("span",{style:t.queryParamsToggleText,children:"Query Parameters"}),e("span",{style:{...t.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:n,ignoredPatterns:c=oe,onTogglePattern:d=le,showBodies:s=true}){const a=n.status?K(n.status):null;const u=!n.status&&!n.error;const T=Q();const D=n.requestData===void 0&&(n.requestBodyOmitted===true||(n.requestSize??0)>0);const h=n.responseData===void 0&&(n.responseBodyOmitted===true||(n.responseSize??0)>0);const y=n.headersOmitted===true;const[S,O]=q(null);const[f,x]=q(false);G(()=>{O(null);if(!T||!D&&!h&&!y){x(false);return}let l=false;x(true);T(n.id).then(m=>{if(!l)O(m)}).catch(()=>{}).finally(()=>{if(!l)x(false)});return()=>{l=true}},[n.id,T,D,h,y]);const g=n.requestData??S?.requestData??void 0;const b=n.responseData??S?.responseData??void 0;const z=(y?S?.requestHeaders:void 0)??n.requestHeaders;const M=(y?S?.responseHeaders:void 0)??n.responseHeaders;const j=()=>{const l={method:n.method,url:n.url,status:n.status,statusText:n.statusText,timestamp:new Date(n.timestamp).toISOString(),duration:n.duration?`${n.duration}ms`:"N/A",requestHeaders:z,requestData:g,responseHeaders:M,responseData:b,requestSize:n.requestSize?k(n.requestSize):"N/A",responseSize:n.responseSize?k(n.responseSize):"N/A",error:n.error,client:n.requestClient};return`# Network Request Details
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!==void 0?t.responseData:S?.responseData;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 R,Download as w,Clock as k,AlertCircle as I,Bookmark as B,FlaskConical as q,Pin as D,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 e,jsxs as l}from"react/jsx-runtime";function j(o,r){if(r)return s.semantic.error;if(!o)return s.semantic.warning;if(o>=200&&o<300)return s.semantic.success;if(o>=300&&o<400)return s.semantic.info;if(o>=400)return s.semantic.error;return s.text.muted}function M(o){const r=o?.["content-type"]||o?.["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(o){switch(o){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:o,isPending:r,statusColor:d}){if(r){return l(n,{style:t.pendingBadge,children:[e(k,{size:10,color:i.color.warning}),e(a,{style:t.pendingText,children:"..."})]})}if(o.error){return l(n,{style:t.errorBadge,children:[e(I,{size:10,color:i.color.danger}),e(a,{style:t.errorText,children:"ERR"})]})}return e(n,{style:t.statusBadge,children:e(a,{style:[t.statusText,{color:d}],children:String(o.status)})})}function A({requestSize:o,responseSize:r}){if(!o&&!r)return null;return l(n,{style:t.sizeRow,children:[o?l(n,{style:t.sizeItem,children:[e(R,{size:8,color:i.color.info}),e(a,{style:t.sizeText,children:h(o)})]}):null,r?l(n,{style:t.sizeItem,children:[e(w,{size:8,color:i.color.accent}),e(a,{style:t.sizeText,children:h(r)})]}):null]})}function P({timestamp:o,duration:r}){const d=F();const g=W(o,d);return r?l(a,{style:t.bottomRightText,children:[N(r)," ",g]}):e(a,{style:t.bottomRightText,children:g})}export const NetworkEventItemCompact=T(function o({event:r,onPress:d,pinned:g=false,saved:x=false,overridden:C=false,onLongPress:m}){const f=j(r.status,r.error);const b=!r.status&&!r.error;const p=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:t.cardWrapper,contentStyle:[t.container,{borderLeftColor:f}],testID:`buoy-network-row-${r.id}`,accessibilityLabel:`${r.method} ${r.path||r.url}`,children:[l(n,{style:t.topRightContainer,children:[g?e(D,{size:10,active:true,color:i.color.info}):null,x?e(B,{size:10,color:i.color.accent}):null,C||r.override?e(q,{size:10,color:i.color.warning}):null,e(O,{event:r,isPending:b,statusColor:f}),r.requestClient?e(n,{style:[t.topRightBadge,{backgroundColor:y(r.requestClient).backgroundColor}],children:e(a,{style:[t.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:t.leftSection,children:[e(H,{method:r.method,size:"small"}),e(A,{requestSize:r.requestSize,responseSize:r.responseSize})]}),e(n,{style:t.middleSection,children:e(a,{style:t.urlText,numberOfLines:2,children:c})}),l(n,{style:t.rightSection,children:[p?e(L,{type:p,size:"small"}):null,e(S,{size:14,color:i.color.textTertiary})]}),e(n,{style:t.bottomRightContainer,children:e(P,{timestamp:r.timestamp,duration:r.duration})})]})});NetworkEventItemCompact.displayName="NetworkEventItemCompact";const t=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
+ "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})]}),r("span",{style:o.middleSection,children:r("span",{style:o.urlText,children:g})}),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"}};
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"}};
@@ -1 +1 @@
1
- "use strict";import{createRemoteConditionsSource as _e,openNetworkFloatingTool as Ve}from"../conditions/NetworkFloatingTool";import{useState as n,useRef as x,useEffect as P,useCallback as G}from"react";import{View as E,StyleSheet as qe,TouchableOpacity as He}from"react-native";import{Search as Le,Wifi as Ue,Filter as ze,Bookmark as je,JsModal as Ke,ModalHeader as o,devToolsStorageKeys as D,macOSColors as We,night as u,persistentStorage as de,NightSegmented as Je,useFeatureGate as $e,UpgradeModal as Ge,PowerToggleButton as Xe,useIgnoredPatterns as Ye,windowDragProps as Qe}from"@buoy-gg/shared-ui";import{NetworkFilterViewV3 as Ze}from"./NetworkFilterViewV3";import{TickProvider as ue}from"../hooks/useTickEveryMinute";import{NetworkEventDetailView as et}from"./NetworkEventDetailView";import{NetworkCopySettingsView as tt,DEFAULT_COPY_SETTINGS as rt}from"./NetworkCopySettingsView";import{NetworkHeaderBadges as ot,NetworkClearButton as nt,NetworkDetailPinActions as st,NetworkHeaderCopyButton as at}from"./NetworkHeaderLive";import{NetworkListScreen as it}from"./NetworkListScreen";import{NetworkSavedScreen as lt}from"./NetworkSavedScreen";import{NetworkOverridesScreen as ct}from"./NetworkOverridesScreen";import{NetworkOverridesButton as dt}from"./NetworkOverridesButton";import{NetworkOverrideHeaderButton as ut}from"./NetworkOverrideHeaderButton";import{NetworkHeaderMenu as pt,NetworkHeaderMenuButton as ft,NetworkHeaderMenuItem as X}from"./NetworkHeaderMenu";import{NetworkDetailStepper as gt}from"./NetworkDetailStepper";import{useNetworkEventList as pe}from"../hooks/useNetworkEventList";import{useLiveNetworkEvent as ht}from"../hooks/useLiveNetworkEvent";import{useHasNetworkSelection as mt,useNetworkBodyEventId as St,useSelectedNetworkEventId as vt}from"../hooks/useNetworkSelection";import{networkSelectionStore as _}from"../utils/networkSelectionStore";import{FREE_TIER_SAVED_LIMIT as wt,MAX_SAVED as yt}from"../utils/networkSavedStore";import{FREE_TIER_RULE_LIMIT as kt,MAX_RULES as Pt}from"../overrides/types";import{jsx as e,jsxs as l,Fragment as bt}from"react/jsx-runtime";function Ct({visible:r,paused:p,ignoredPatternValues:f,onTogglePattern:g,isPro:v,filter:c,ignoredPatterns:h,fromSaved:m,savedSearch:w,applySafeAreaInset:i}){const y=vt();const V=St();const C=y!=null&&y===V;const s=ht(y,{paused:p||!r});P(()=>{if(r&&s&&C){_.reportRendered(s.id)}},[r,s,C]);if(!r)return null;return l(E,{style:b.detailRoot,children:[s?e(et,{event:s,ignoredPatterns:f,onTogglePattern:g,showBodies:C}):e(E,{style:b.detailBodyFallback}),e(gt,{paused:p,filter:c,ignoredPatterns:h,isPro:v,fromSaved:m,savedSearch:w,applySafeAreaInset:i})]})}function Rt({visible:r,paused:p,isPro:f,filter:g,onFilterChange:v,ignoredPatterns:c,onRemovePattern:h,onAddPattern:m,onTogglePatternMode:w,isTeamPattern:i}){const{events:y}=pe({filter:g,ignoredPatterns:c,paused:p,visible:r,isPro:f});if(!r)return null;return e(Ze,{events:y,filter:g,onFilterChange:v,ignoredPatterns:c,onRemovePattern:h,onAddPattern:m,onTogglePatternMode:w,isTeamPattern:i})}function It({visible:r,paused:p,isPro:f,filter:g,ignoredPatterns:v,settings:c,onSettingsChange:h}){const{events:m}=pe({filter:g,ignoredPatterns:v,paused:p,visible:r,isPro:f});if(!r)return null;return e(tt,{settings:c,onSettingsChange:h,events:m})}function fe({visible:r,onClose:p,onBack:f,onMinimize:g,enableSharedModalDimensions:v=false,inline:c=false,paused:h,onPausedChange:m,remoteConditions:w}){const{isPro:i}=$e();const[y,V]=n(false);const C=h!=null&&m!=null;const s=C?h:y;const ge=t=>{const a=typeof t==="function"?t(s):t;if(C)m(a);else V(a)};const[d,q]=n({});const S=mt();const[k,Y]=n(false);const[A,Q]=n(false);const[B,H]=n(false);const[Z,R]=n(false);const[he,me]=n(0);const[M]=n(_e);P(()=>{M.update(w)},[M,w]);P(()=>()=>M.update(void 0),[M]);const I=true;const[Se,L]=n(null);const[U,ee]=n("filters");const[te,ve]=n("");const[z,j]=n(false);const Tt=x(false);const[re,we]=n("");const ye=x(null);const{patterns:N,values:ke,add:Pe,remove:be,toggle:Ce,toggleMode:Re,isTeamOnly:Ie}=Ye();const[F,oe]=n(rt);const K=x(false);const[W,J]=n(false);const[T,Ne]=n("export");const O=t=>{Ne(t);J(true)};P(()=>{if(W&&i){J(false)}},[W,i]);P(()=>{if(!r||K.current)return;const t=async()=>{try{const a=await de.getItem(D.network.copyOptions());if(a){const De=JSON.parse(a);oe(De)}}catch(a){}finally{K.current=true}};t()},[r]);P(()=>{if(!K.current)return;const t=async()=>{try{await de.setItem(D.network.copyOptions(),JSON.stringify(F))}catch(a){}};t()},[F]);const Te=()=>{_.clear()};const ne=G(t=>{_.select(t.id)},[]);const Ee=G((t,a)=>{L(a?{...t,id:a}:t);H(true);_.clear()},[]);const Me=G(()=>L(null),[]);const se=x(null);const ae=t=>{ve(t);q(a=>({...a,searchText:t}))};const Fe=t=>{q(a=>({...a,status:a.status===t?void 0:t}))};const[ie,Oe]=n("bottomSheet");const Ae=t=>{Oe(t)};P(()=>{if(z){requestAnimationFrame(()=>{ye.current?.focus()})}},[z]);const le=()=>{if(k){return l(o,{children:[e(o.Navigation,{onBack:()=>Y(false)}),e(o.Content,{title:"",noMargin:true,children:e(Je,{size:"sm",tabs:[{key:"filters",label:"Filters"},{key:"copy",label:"Copy"}],activeKey:U,onChange:t=>ee(t)})})]})}if(S){return l(o,{children:[e(o.Navigation,{onBack:Te}),e(o.Content,{title:"Request Details",centered:true}),l(o.Actions,{children:[I?e(ut,{onOpen:Ee}):null,e(st,{isPro:i,onUpgradePress:()=>O("saved")})]})]})}if(B&&I){return l(o,{children:[e(o.Navigation,{onBack:()=>{if(se.current?.())return;H(false);L(null)}}),e(o.Content,{title:"Response Overrides",centered:true})]})}if(A){return l(o,{children:[e(o.Navigation,{onBack:()=>Q(false)}),e(o.Content,{title:"Saved Requests",centered:true})]})}return l(o,{children:[f&&e(o.Navigation,{onBack:f}),e(o.Content,{title:"",children:z?e(o.Search,{value:te,onChangeText:ae,onCancel:()=>{ae("");j(false)},onDismiss:()=>j(false),dismissOnBlur:true,clearOnlyWhenText:true,placeholder:"Search URL, method, operation, error...",accessibilityLabel:"Search network requests",iconSize:14,testID:"buoy-network-search-input",clearTestID:"buoy-network-search-clear",inputProps:{"sentry-label":"ignore network search header"}}):e(ot,{activeStatus:d.status,onToggleStatus:Fe,ignoredPatterns:N,paused:s})}),l(o.Actions,{children:[e(He,{"sentry-label":"ignore open search",testID:"buoy-network-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",onPress:()=>j(true),style:b.headerActionButton,children:e(Le,{size:14,color:u.color.textSecondary})}),I?e(dt,{onPress:()=>H(true)}):null,e(Xe,{isEnabled:!s,onToggle:()=>ge(t=>!t),accessibilityLabel:s?"Resume network capture":"Pause network capture",testID:"buoy-network-power"}),e(nt,{paused:s}),e(ft,{onPress:()=>R(t=>!t),isOpen:Z,hasIndicator:$})]})]})};const $=!!(d.status||d.method||d.contentType);const Be=v?D.modal.root():D.network.modal();if(!r)return null;const xe=S||!k;const ce=l(bt,{children:[l(E,{style:b.container,children:[e(Ct,{visible:S,paused:s,ignoredPatternValues:ke,onTogglePattern:Ce,isPro:i,filter:d,ignoredPatterns:N,fromSaved:A,savedSearch:re,applySafeAreaInset:!c&&ie==="bottomSheet"}),e(Rt,{visible:k&&U==="filters"&&!S,paused:s,isPro:i,filter:d,onFilterChange:q,ignoredPatterns:N,onRemovePattern:be,onAddPattern:Pe,onTogglePatternMode:Re,isTeamPattern:Ie}),e(It,{visible:k&&U==="copy"&&!S,paused:s,isPro:i,filter:d,ignoredPatterns:N,settings:F,onSettingsChange:oe}),e(ct,{visible:I&&B&&!S&&!k,isPro:i,onUpgradePress:()=>O("overrides"),pendingDraft:Se,onPendingConsumed:Me,backHandlerRef:se,applySafeAreaInset:!c&&ie==="bottomSheet"}),e(lt,{visible:A&&!S&&!k&&!(B&&I),isPro:i,copySettings:F,search:re,onSearchChange:we,onEventPress:ne,onUpgradePress:()=>O("saved")}),e(it,{visible:!S&&!k&&!A&&!(B&&I),paused:s,filter:d,ignoredPatterns:N,isPro:i,searchText:te,onEventPress:ne,onUpgradePress:()=>O("export")})]}),Z?l(pt,{onClose:()=>R(false),children:[e(X,{icon:e(Ue,{size:14,color:u.color.textSecondary}),label:"Network throttling",testID:"buoy-network-menu-throttling",onPress:()=>{R(false);Ve(w?M:void 0);if(!c)me(t=>t+1)}}),e(X,{icon:e(ze,{size:14,color:$?u.color.accent:u.color.textSecondary}),label:"Filters",detail:$?"Active":void 0,onPress:()=>{R(false);ee("filters");Y(true)}}),e(X,{icon:e(je,{size:14,color:u.color.textSecondary}),label:"Saved requests",onPress:()=>{R(false);Q(true)}}),e(E,{style:b.menuCopyRow,children:e(at,{isPro:i,filter:d,ignoredPatterns:N,copySettings:F,paused:s,onUpgradePress:()=>{R(false);O("export")},label:"Copy requests"})})]}):null,e(Ge,{visible:W,onClose:()=>J(false),featureName:T==="saved"?"Saved Requests":T==="overrides"?"Response Overrides":"Network Export",description:T==="saved"?"Keep the requests that matter. Saved requests survive Clear, app restarts, and the 500-request history cap.":T==="overrides"?"Force any endpoint to fail, stall or return something else \u2014 no backend changes, no code changes. Free keeps one active rule.":"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:T==="overrides"?[`Run ${Pt} rules at once (free keeps ${kt})`,"Force a 500, a 401 or an empty list in one tap","Simulate offline, timeouts and slow connections","Rules survive an app reload, so you can test the boot path"]:T==="saved"?[`Save up to ${yt} requests (free keeps ${wt})`,"Failed requests stay put through a Clear","Snapshots survive an app restart","Export saved requests to teammates or AI assistants"]:["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"]})]});if(c){return l(E,{style:b.inlineRoot,children:[e(E,{style:b.inlineHeader,...Qe,children:le()}),ce]})}return e(Ke,{visible:r,onClose:p,onMinimize:g,minimizeRequest:he,persistenceKey:Be,variant:"night",header:{showToggleButton:true,customContent:le()},onModeChange:Ae,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:xe,styles:{},children:ce})}const b=qe.create({container:{flex:1,backgroundColor:"transparent"},detailRoot:{flex:1,minHeight:0},detailBodyFallback:{flex:1},inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:We.border.default,backgroundColor:"transparent"},menuCopyRow:{paddingHorizontal:6},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:u.color.buttonSurface,borderWidth:1,borderColor:u.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:u.color.accentSoft,borderColor:u.color.accentBorderStrong}});export function NetworkModal(r){return e(ue,{children:e(fe,{...r})})}export function NetworkToolView(r={}){return e(ue,{children:e(fe,{...r,inline:true,visible:true,onClose:Nt})})}const Nt=()=>{};
1
+ "use strict";import{createRemoteConditionsSource as je,openNetworkFloatingTool as he}from"../conditions/NetworkFloatingTool";import{useState as n,useRef as A,useEffect as C,useCallback as Q}from"react";import{View as B,StyleSheet as Ke,TouchableOpacity as We}from"react-native";import{Search as Je,Wifi as ge,Filter as $e,Bookmark as Ge,Activity as Xe,JsModal as Ye,ModalHeader as o,devToolsStorageKeys as _,macOSColors as Qe,night as d,persistentStorage as me,NightSegmented as Ze,useFeatureGate as et,UpgradeModal as tt,PowerToggleButton as ot,useIgnoredPatterns as rt,windowDragProps as nt}from"@buoy-gg/shared-ui";import{NetworkFilterViewV3 as st}from"./NetworkFilterViewV3";import{TickProvider as Se}from"../hooks/useTickEveryMinute";import{NetworkEventDetailView as at}from"./NetworkEventDetailView";import{NetworkCopySettingsView as it,DEFAULT_COPY_SETTINGS as lt}from"./NetworkCopySettingsView";import{NetworkHeaderBadges as ct,NetworkClearButton as dt,NetworkDetailPinActions as ut,NetworkHeaderCopyButton as pt}from"./NetworkHeaderLive";import{NetworkListScreen as ft}from"./NetworkListScreen";import{NetworkSavedScreen as ht}from"./NetworkSavedScreen";import{NetworkOverridesScreen as gt}from"./NetworkOverridesScreen";import{NetworkOverridesButton as mt}from"./NetworkOverridesButton";import{NetworkOverrideHeaderButton as St}from"./NetworkOverrideHeaderButton";import{NetworkSocketsButton as kt}from"./sockets/NetworkSocketsButton";import{NetworkSocketsScreen as wt}from"./sockets/NetworkSocketsScreen";import{NetworkHeaderMenu as vt,NetworkHeaderMenuButton as yt,NetworkHeaderMenuItem as O}from"./NetworkHeaderMenu";import{NetworkDetailStepper as Pt}from"./NetworkDetailStepper";import{useNetworkEventList as ke}from"../hooks/useNetworkEventList";import{useLiveNetworkEvent as bt}from"../hooks/useLiveNetworkEvent";import{useHasNetworkSelection as Ct,useNetworkBodyEventId as Rt,useSelectedNetworkEventId as Nt}from"../hooks/useNetworkSelection";import{networkSelectionStore as H}from"../utils/networkSelectionStore";import{FREE_TIER_SAVED_LIMIT as It,MAX_SAVED as Tt}from"../utils/networkSavedStore";import{FREE_TIER_RULE_LIMIT as Et,MAX_RULES as Mt}from"../overrides/types";import{jsx as e,jsxs as l,Fragment as Bt}from"react/jsx-runtime";function Ft({visible:r,paused:h,ignoredPatternValues:g,onTogglePattern:m,isPro:P,filter:c,ignoredPatterns:S,fromSaved:k,savedSearch:w,applySafeAreaInset:a}){const b=Nt();const q=Rt();const N=b!=null&&b===q;const s=bt(b,{paused:h||!r});C(()=>{if(r&&s&&N){H.reportRendered(s.id)}},[r,s,N]);if(!r)return null;return l(B,{style:R.detailRoot,children:[s?e(at,{event:s,ignoredPatterns:g,onTogglePattern:m,showBodies:N}):e(B,{style:R.detailBodyFallback}),e(Pt,{paused:h,filter:c,ignoredPatterns:S,isPro:P,fromSaved:k,savedSearch:w,applySafeAreaInset:a})]})}function xt({visible:r,paused:h,isPro:g,filter:m,onFilterChange:P,ignoredPatterns:c,onRemovePattern:S,onAddPattern:k,onTogglePatternMode:w,isTeamPattern:a}){const{events:b}=ke({filter:m,ignoredPatterns:c,paused:h,visible:r,isPro:g});if(!r)return null;return e(st,{events:b,filter:m,onFilterChange:P,ignoredPatterns:c,onRemovePattern:S,onAddPattern:k,onTogglePatternMode:w,isTeamPattern:a})}function At({visible:r,paused:h,isPro:g,filter:m,ignoredPatterns:P,settings:c,onSettingsChange:S}){const{events:k}=ke({filter:m,ignoredPatterns:P,paused:h,visible:r,isPro:g});if(!r)return null;return e(it,{settings:c,onSettingsChange:S,events:k})}function we({visible:r,onClose:h,onBack:g,onMinimize:m,enableSharedModalDimensions:P=false,inline:c=false,paused:S,onPausedChange:k,remoteConditions:w}){const{isPro:a}=et();const[b,q]=n(false);const N=S!=null&&k!=null;const s=N?S:b;const ve=t=>{const i=typeof t==="function"?t(s):t;if(N)k(i);else q(i)};const[u,L]=n({});const p=Ct();const[v,Z]=n(false);const[D,ee]=n(false);const[V,z]=n(false);const[F,U]=n(false);const[ye,Pe]=n("Sockets");const[te,y]=n(false);const[be,oe]=n(0);const[I]=n(je);C(()=>{I.update(w)},[I,w]);C(()=>()=>I.update(void 0),[I]);const T=true;const[Ce,j]=n(null);const[K,re]=n("filters");const[ne,Re]=n("");const[W,J]=n(false);const Dt=A(false);const[se,Ne]=n("");const Ie=A(null);const{patterns:E,values:Te,add:Ee,remove:Me,toggle:Be,toggleMode:Fe,isTeamOnly:xe}=rt();const[x,ae]=n(lt);const $=A(false);const[G,X]=n(false);const[f,Ae]=n("export");const M=t=>{Ae(t);X(true)};C(()=>{if(G&&a){X(false)}},[G,a]);C(()=>{if(!r||$.current)return;const t=async()=>{try{const i=await me.getItem(_.network.copyOptions());if(i){const Ue=JSON.parse(i);ae(Ue)}}catch(i){}finally{$.current=true}};t()},[r]);C(()=>{if(!$.current)return;const t=async()=>{try{await me.setItem(_.network.copyOptions(),JSON.stringify(x))}catch(i){}};t()},[x]);const Oe=()=>{H.clear()};const ie=Q(t=>{H.select(t.id)},[]);const De=Q((t,i)=>{j(i?{...t,id:i}:t);z(true);H.clear()},[]);const Ve=Q(()=>j(null),[]);const le=A(null);const ce=A(null);const de=t=>{Re(t);L(i=>({...i,searchText:t}))};const _e=t=>{L(i=>({...i,status:i.status===t?void 0:t}))};const[ue,He]=n("bottomSheet");const qe=t=>{He(t)};C(()=>{if(W){requestAnimationFrame(()=>{Ie.current?.focus()})}},[W]);const pe=()=>{if(v){return l(o,{children:[e(o.Navigation,{onBack:()=>Z(false)}),e(o.Content,{title:"",noMargin:true,children:e(Ze,{size:"sm",tabs:[{key:"filters",label:"Filters"},{key:"copy",label:"Copy"}],activeKey:K,onChange:t=>re(t)})})]})}if(p){return l(o,{children:[e(o.Navigation,{onBack:Oe}),e(o.Content,{title:"Request Details",centered:true}),l(o.Actions,{children:[T?e(St,{onOpen:De}):null,e(ut,{isPro:a,onUpgradePress:()=>M("saved")})]})]})}if(F){return l(o,{children:[e(o.Navigation,{onBack:()=>{if(ce.current?.())return;U(false)}}),e(o.Content,{title:ye,centered:true})]})}if(V&&T){return l(o,{children:[e(o.Navigation,{onBack:()=>{if(le.current?.())return;z(false);j(null)}}),e(o.Content,{title:"Response Overrides",centered:true})]})}if(D){return l(o,{children:[e(o.Navigation,{onBack:()=>ee(false)}),e(o.Content,{title:"Saved Requests",centered:true})]})}return l(o,{children:[g&&e(o.Navigation,{onBack:g}),e(o.Content,{title:"",children:W?e(o.Search,{value:ne,onChangeText:de,onCancel:()=>{de("");J(false)},onDismiss:()=>J(false),dismissOnBlur:true,clearOnlyWhenText:true,placeholder:"Search URL, method, operation, error...",accessibilityLabel:"Search network requests",iconSize:14,testID:"buoy-network-search-input",clearTestID:"buoy-network-search-clear",inputProps:{"sentry-label":"ignore network search header"}}):e(ct,{activeStatus:u.status,onToggleStatus:_e,ignoredPatterns:E,paused:s})}),l(o.Actions,{children:[e(We,{"sentry-label":"ignore open search",testID:"buoy-network-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",onPress:()=>J(true),style:R.headerActionButton,children:e(Je,{size:14,color:d.color.textSecondary})}),e(kt,{paused:s,onPress:()=>U(true)}),T?e(mt,{onPress:()=>z(true)}):null,e(ot,{isEnabled:!s,onToggle:()=>ve(t=>!t),accessibilityLabel:s?"Resume network capture":"Pause network capture",testID:"buoy-network-power"}),e(dt,{paused:s}),e(yt,{onPress:()=>y(t=>!t),isOpen:te,hasIndicator:Y})]})]})};const Y=!!(u.status||u.method||u.contentType);const Le=P?_.modal.root():_.network.modal();if(!r)return null;const ze=p||!v;const fe=l(Bt,{children:[l(B,{style:R.container,children:[e(Ft,{visible:p,paused:s,ignoredPatternValues:Te,onTogglePattern:Be,isPro:a,filter:u,ignoredPatterns:E,fromSaved:D,savedSearch:se,applySafeAreaInset:!c&&ue==="bottomSheet"}),e(xt,{visible:v&&K==="filters"&&!p,paused:s,isPro:a,filter:u,onFilterChange:L,ignoredPatterns:E,onRemovePattern:Me,onAddPattern:Ee,onTogglePatternMode:Fe,isTeamPattern:xe}),e(At,{visible:v&&K==="copy"&&!p,paused:s,isPro:a,filter:u,ignoredPatterns:E,settings:x,onSettingsChange:ae}),e(gt,{visible:T&&V&&!p&&!v&&!F,isPro:a,onUpgradePress:()=>M("overrides"),pendingDraft:Ce,onPendingConsumed:Ve,backHandlerRef:le,applySafeAreaInset:!c&&ue==="bottomSheet"}),e(wt,{visible:F&&!p&&!v,paused:s,isPro:a,onUpgradePress:()=>M("sockets"),backHandlerRef:ce,onTitleChange:Pe}),e(ht,{visible:D&&!p&&!v&&!F&&!(V&&T),isPro:a,copySettings:x,search:se,onSearchChange:Ne,onEventPress:ie,onUpgradePress:()=>M("saved")}),e(ft,{visible:!p&&!v&&!D&&!F&&!(V&&T),paused:s,filter:u,ignoredPatterns:E,isPro:a,searchText:ne,onEventPress:ie,onUpgradePress:()=>M("export")})]}),te?l(vt,{onClose:()=>y(false),children:[e(O,{icon:e(ge,{size:14,color:d.color.textSecondary}),label:"Network throttling",testID:"buoy-network-menu-throttling",onPress:()=>{y(false);he(w?I:void 0);if(!c)oe(t=>t+1)}}),e(O,{icon:e(ge,{size:14,color:d.color.textSecondary}),label:"Speed and link state",testID:"buoy-network-menu-conditions",onPress:()=>{y(false);he(w?I:void 0,true);if(!c)oe(t=>t+1)}}),e(O,{icon:e($e,{size:14,color:Y?d.color.accent:d.color.textSecondary}),label:"Filters",detail:Y?"Active":void 0,onPress:()=>{y(false);re("filters");Z(true)}}),e(O,{icon:e(Ge,{size:14,color:d.color.textSecondary}),label:"Saved requests",onPress:()=>{y(false);ee(true)}}),e(O,{icon:e(Xe,{size:14,color:d.color.textSecondary}),label:"Sockets",testID:"buoy-network-menu-sockets",onPress:()=>{y(false);U(true)}}),e(B,{style:R.menuCopyRow,children:e(pt,{isPro:a,filter:u,ignoredPatterns:E,copySettings:x,paused:s,onUpgradePress:()=>{y(false);M("export")},label:"Copy requests"})})]}):null,e(tt,{visible:G,onClose:()=>X(false),featureName:f==="saved"?"Saved Requests":f==="overrides"?"Response Overrides":f==="sockets"?"Socket Tricks":"Network Export",description:f==="saved"?"Keep the requests that matter. Saved requests survive Clear, app restarts, and the 500-request history cap.":f==="overrides"?"Force any endpoint to fail, stall or return something else \u2014 no backend changes, no code changes. Free keeps one active rule.":f==="sockets"?"Push fake server messages into your app, and drop, freeze or block its sockets. Your app's real code handles each one.":"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:f==="sockets"?["Push a fake message, like auth.expired, in one tap","Drop a socket with 1006 or kick it out with 1008","Freeze a socket to test your ping check","Block every reconnect to test your backoff"]:f==="overrides"?[`Run ${Mt} rules at once (free keeps ${Et})`,"Force a 500, a 401 or an empty list in one tap","Simulate offline, timeouts and slow connections","Rules survive an app reload, so you can test the boot path"]:f==="saved"?[`Save up to ${Tt} requests (free keeps ${It})`,"Failed requests stay put through a Clear","Snapshots survive an app restart","Export saved requests to teammates or AI assistants"]:["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"]})]});if(c){return l(B,{style:R.inlineRoot,children:[e(B,{style:R.inlineHeader,...nt,children:pe()}),fe]})}return e(Ye,{visible:r,onClose:h,onMinimize:m,minimizeRequest:be,persistenceKey:Le,variant:"night",header:{showToggleButton:true,customContent:pe()},onModeChange:qe,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:ze,styles:{},children:fe})}const R=Ke.create({container:{flex:1,backgroundColor:"transparent"},detailRoot:{flex:1,minHeight:0},detailBodyFallback:{flex:1},inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Qe.border.default,backgroundColor:"transparent"},menuCopyRow:{paddingHorizontal:6},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:d.color.buttonSurface,borderWidth:1,borderColor:d.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong}});export function NetworkModal(r){return e(Se,{children:e(we,{...r})})}export function NetworkToolView(r={}){return e(Se,{children:e(we,{...r,inline:true,visible:true,onClose:Ot})})}const Ot=()=>{};
@@ -0,0 +1 @@
1
+ "use strict";import{StyleSheet as d,Text as g,TouchableOpacity as u,View as p}from"react-native";import{Activity as h,night as o}from"@buoy-gg/shared-ui";import{useSocketsState as f}from"../../hooks/useSocketsState";import{jsx as c,jsxs as m}from"react/jsx-runtime";export function NetworkSocketsButton({onPress:i,paused:l}){const t=f(l);if(t.connections.length===0)return null;const r=t.connections.some(b=>b.state==="open");const s=t.tests.blocked||t.tests.offline||t.tests.frozen.length>0;const e=t.problems.length;const a=s?o.color.warning:r?o.color.accent:o.color.textSecondary;return m(u,{onPress:i,"sentry-label":"ignore open sockets",testID:"buoy-network-sockets",accessibilityRole:"button",accessibilityLabel:`Sockets${r?", one open":""}${e?`, ${e} ${e===1?"problem":"problems"}`:""}${s?", a trick is on":""}`,style:[n.button,s?n.testing:r?n.open:null],children:[c(h,{size:14,color:a}),e>0?c(p,{style:n.badge,children:c(g,{style:n.badgeText,children:e})}):null]})}const n=d.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center",backgroundColor:o.color.buttonSurface,borderWidth:1,borderColor:o.color.border},open:{backgroundColor:o.color.accentSoft,borderColor:o.color.accentBorder},testing:{backgroundColor:o.color.warningSoft,borderColor:o.color.warning+"77"},badge:{position:"absolute",top:1,right:1,minWidth:12,height:12,borderRadius:6,paddingHorizontal:3,alignItems:"center",justifyContent:"center",backgroundColor:o.color.danger},badgeText:{fontSize:8,fontWeight:"800",color:"#FFFFFF"}});
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect as l,useState as d}from"react";import{StyleSheet as x,View as w}from"react-native";import{SocketFrameView as I}from"./SocketFrameView";import{SocketListView as j}from"./SocketListView";import{SocketTricksView as F}from"./SocketTricksView";import{jsx as m,jsxs as T}from"react/jsx-runtime";export function NetworkSocketsScreen({visible:o,paused:k,isPro:i,onUpgradePress:c,backHandlerRef:s,onTitleChange:a}){const[e,u]=d(null);const[t,n]=d(null);const f=t?"Tricks":e?"Message":"Sockets";l(()=>{a?.(f)},[a,f]);l(()=>{if(!s)return;s.current=t||e?()=>{if(t)n(null);else u(null);return true}:null;return()=>{s.current=null}},[s,t,e]);l(()=>{if(o)return;u(null);n(null)},[o]);const p=r=>{if(!i)return c();n({socketId:r,data:""})};const S=r=>n({socketId:r.socketId,data:r.data??""});if(!o)return null;return T(w,{style:V.container,children:[m(j,{visible:!t&&!e,paused:k,search:"",onOpenFrame:r=>u(r.id),onOpenTricks:p}),m(I,{visible:!t&&!!e,frameId:e,isPro:i,onUpgradePress:c,onEdit:S}),m(F,{visible:!!t,draft:t,isPro:i,onUpgradePress:c})]})}const V=x.create({container:{flex:1}});
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect as B,useState as z}from"react";import{ScrollView as W,StyleSheet as C,Text as r,View as f}from"react-native";import{InlineCopyButton as j,NightBadge as s,NightButton as F,monoFont as g,night as l}from"@buoy-gg/shared-ui";import{clockTime as H,prettyData as R,shortDuration as I}from"../../sockets/format";import{socketStore as S}from"../../sockets/socketStore";import{jsx as e,jsxs as p}from"react/jsx-runtime";function T({frame:n,label:i}){const c=R(n);return p(f,{style:o.box,children:[p(f,{style:o.boxHead,children:[e(r,{style:o.boxLabel,children:i}),e(r,{style:o.boxTime,children:H(n.timestamp)}),e(j,{value:c})]}),e(r,{selectable:true,style:o.code,testID:`buoy-socket-data-${n.id}`,children:c||"(empty)"}),n.truncated?e(r,{style:o.boxNote,children:"Cut at 64 KB. The rest was not kept."}):null]})}function N({visible:n}){if(!n)return null;return e(f,{style:o.missing,children:e(r,{style:o.note,children:"This message is gone. It was cleared or pushed out by newer ones."})})}function $({loaded:n,isPro:i,onUpgradePress:c,onEdit:k}){const[b,h]=z(null);const t=n?.frame;B(()=>h(null),[t?.id]);if(!t)return null;const y=t.direction==="out";const m=n?.partner??null;const a=t.replyTo?m:t;const d=t.replyTo?t:m;const u=S.getState().problems.find(x=>x.frameIds.includes(t.id));const w=async()=>{if(!i)return c();const x=t.data??"";const D=await S.act(y?{action:"send",socketId:t.socketId,data:x}:{action:"inject",socketId:t.socketId,data:x});h(D.message)};return p(W,{contentContainerStyle:o.content,testID:"buoy-socket-detail",children:[p(f,{style:o.titleRow,children:[e(r,{style:[o.dir,y?o.up:o.down],children:y?"\u2191":"\u2193"}),e(r,{style:o.title,numberOfLines:2,children:t.type??"message"})]}),p(f,{style:o.badges,children:[u?e(s,{label:u.kind==="no-reply"?"No reply":"Problem",tone:"danger"}):null,a?.replyMs!==void 0?e(s,{label:`Reply in ${I(a.replyMs)}`,tone:"accent"}):null,t.correlationId?e(s,{label:`id ${t.correlationId}`,tone:"info"}):null,e(s,{label:`Socket ${t.socketId}`}),t.size!==void 0?e(s,{label:`${t.size} B`}):null,t.fake==="inject"?e(s,{label:"Fake: pushed by Buoy",tone:"info"}):null,t.fake==="send"?e(s,{label:"Sent by Buoy",tone:"info"}):null,t.held?e(s,{label:"Held back",tone:"warning"}):null,t.sentWhileClosed?e(s,{label:"Sent while closed",tone:"danger"}):null]}),a?e(T,{frame:a,label:a.direction==="out"?"\u2191 Sent":"\u2193 Got"}):null,a&&d?e(r,{style:o.gap,children:I(d.timestamp-a.timestamp)}):null,d?e(T,{frame:d,label:"\u2193 Reply"}):null,p(f,{style:o.buttons,children:[e(F,{label:y?"Send again":"Push to app again",variant:"primary",onPress:w,testID:"buoy-socket-replay"}),e(F,{label:"Edit in Tricks",onPress:()=>i?k(t):c(),testID:"buoy-socket-edit"})]}),u?e(r,{style:o.problem,children:u.message}):null,b?e(r,{style:o.result,children:b}):null,t.data?.includes("[hidden]")?e(r,{style:o.note,children:"Buoy hid secrets in this message. Sending it again sends the word [hidden] in their place."}):null]})}export function SocketFrameView({visible:n,frameId:i,isPro:c,onUpgradePress:k,onEdit:b}){const[h,t]=z(null);const[y,m]=z(false);B(()=>{t(null);m(false);if(!n||!i)return;let u=true;void S.loadFrame(i).then(w=>{if(!u)return;t(w);m(true)});return()=>{u=false}},[n,i]);if(!n)return null;const a=i?S.getFrame(i):void 0;const d=h??(a?{frame:a,partner:null}:null);return p(f,{style:o.fill,children:[e(N,{visible:y&&!d}),e($,{loaded:d,isPro:c,onUpgradePress:k,onEdit:b})]})}const o=C.create({fill:{flex:1},content:{padding:12,gap:10,paddingBottom:32},missing:{padding:24},titleRow:{flexDirection:"row",alignItems:"center",gap:8},dir:{fontSize:16,fontWeight:"700",fontFamily:g},up:{color:"#6EA1FF"},down:{color:l.color.accent},title:{flexShrink:1,fontSize:15,fontWeight:"600",color:l.color.text,fontFamily:g},badges:{flexDirection:"row",flexWrap:"wrap",gap:6},box:{borderWidth:1,borderColor:l.color.border,borderRadius:8,backgroundColor:l.color.surface,overflow:"hidden"},boxHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:9,paddingVertical:6,borderBottomWidth:1,borderBottomColor:l.color.separator},boxLabel:{flex:1,fontSize:10,fontWeight:"700",color:l.color.textSecondary,letterSpacing:.4},boxTime:{fontSize:10,color:l.color.textTertiary,fontFamily:g},boxNote:{paddingHorizontal:9,paddingBottom:8,fontSize:11,color:l.color.textTertiary},code:{padding:9,fontSize:11,lineHeight:16,color:l.color.text,fontFamily:g},gap:{textAlign:"center",fontSize:11,color:l.color.textSecondary,fontFamily:g},buttons:{flexDirection:"row",flexWrap:"wrap",gap:8},result:{fontSize:12,color:l.color.textSecondary},problem:{fontSize:12,color:l.color.danger,fontWeight:"600"},note:{fontSize:11,color:l.color.textTertiary}});
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect as H,useState as h}from"react";import{FlatList as _,ScrollView as A,StyleSheet as F,Text as d,TouchableOpacity as z,View as u}from"react-native";import{EVENT_LIST_PRESET as M,NightChip as m,ToolEmptyState as V,Zap as j,monoFont as U,night as i,resolveListEmptyState as J}from"@buoy-gg/shared-ui";import{useSocketsState as G}from"../../hooks/useSocketsState";import{foldFrames as X,topTypePrefixes as Z}from"../../sockets/foldFrames";import{clockTime as q,connectionStatus as D,shortUrl as K}from"../../sockets/format";import{SocketLifecycleRow as Q,SocketMessageRow as Y}from"./SocketRows";import{jsx as n,jsxs as c}from"react/jsx-runtime";const ee=2;const te=2*6e4;const oe=o=>o.frame.id;function le(o){const[p,r]=h(Date.now);H(()=>{if(!o)return;r(Date.now());const s=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(s)},[o]);return p}function ne({conn:o,selected:p,onPress:r,showPings:s,onTogglePings:f}){const l=o.state==="open";const a=le(l);const y=l?t.pillOk:o.state==="closed"?t.pillWarn:t.pillPlain;const g=l?t.pillOkText:o.state==="closed"?t.pillWarnText:t.pillPlainText;return c(z,{activeOpacity:.8,onPress:r,"sentry-label":"ignore pick socket",testID:`buoy-socket-card-${o.id}`,accessibilityRole:"button",accessibilityLabel:`Socket ${o.id}, ${D(o,a)}`,style:[t.card,p?t.cardSelected:null],children:[n(d,{style:t.cardUrl,numberOfLines:1,children:K(o.url)}),c(u,{style:t.pills,children:[n(u,{style:[t.pill,y],children:c(d,{style:[t.pillText,g],children:[l?"\u25CF ":"",D(o,a)]})}),o.frozen?n(u,{style:[t.pill,t.pillWarn],children:n(d,{style:[t.pillText,t.pillWarnText],children:"Frozen"})}):null,o.attempt>1?n(u,{style:[t.pill,t.pillPlain],children:c(d,{style:[t.pillText,t.pillPlainText],children:["Try #",o.attempt]})}):null,n(u,{style:[t.pill,t.pillPlain],children:c(d,{style:[t.pillText,t.pillPlainText],children:["\u2191",o.sent," \u2193",o.received]})}),o.pings>0?n(z,{onPress:f,"sentry-label":"ignore toggle socket pings",testID:`buoy-socket-pings-${o.id}`,style:[t.pill,t.pillPlain],children:c(d,{style:[t.pillText,t.pillPlainText],children:["\u2665 ",o.pings," ",o.pings===1?"heartbeat":"heartbeats"," ",s?"shown":"hidden"]})}):null]})]})}function se({problems:o}){const p=Date.now();const r=o.filter(s=>p-s.at<te&&(s.frameIds.length===0||s.kind==="reconnect-storm"||s.kind==="auth-loop"||s.kind==="cant-connect"));if(r.length===0)return null;return n(u,{style:t.banner,testID:"buoy-socket-problems",children:r.slice(0,3).map(s=>c(d,{style:t.bannerText,numberOfLines:2,children:["\u26A0 ",s.message," \xB7 ",q(s.at)]},`${s.kind}-${s.at}`))})}export function SocketListView({visible:o,paused:p,search:r,onOpenFrame:s,onOpenTricks:f}){const l=G(p||!o);const[a,y]=h(null);const[g,x]=h({kind:"all"});const[S,N]=h(false);const[T,O]=h(()=>new Set);if(!o)return null;const P=l.connections.filter(e=>e.state!=="closed");const w=l.connections.find(e=>e.id===a&&e.state==="closed");const I=P.length?P:l.connections.filter(e=>e.state==="closed").slice(0,1);const E=[...w&&!I.includes(w)?[w]:[],...I].slice(0,ee);const W=X(l,{socketId:a,filter:g,showPings:S,search:r,expanded:T});const L=e=>O(new Set(T).add(e));const $=new Map(l.connections.map(e=>[e.id,e.attempt]));const R=Z(l.frames);const C=new Set(l.problems.flatMap(e=>e.frameIds)).size;const b=e=>JSON.stringify(e)===JSON.stringify(g);const k=e=>x(b(e)?{kind:"all"}:e);const v=({item:e})=>e.frame.kind==="message"?n(Y,{row:e,onOpen:s,onExpand:L}):n(Q,{row:e,attempt:$.get(e.frame.socketId)});const B=c(u,{style:t.header,children:[E.map(e=>n(ne,{conn:e,selected:a===e.id,onPress:()=>y(a===e.id?null:e.id),showPings:S,onTogglePings:()=>N(!S)},e.id)),n(se,{problems:l.problems}),c(A,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:t.chips,children:[n(m,{label:"Tricks",icon:n(j,{size:11,color:i.color.warning}),onPress:()=>f(a??l.connections.find(e=>e.state==="open")?.id??null),testID:"buoy-socket-tricks"}),n(m,{label:`All ${l.frames.length}`,selected:g.kind==="all",onPress:()=>x({kind:"all"}),testID:"buoy-socket-chip-all"}),C>0?n(m,{label:`Problems ${C}`,selected:g.kind==="problems",onPress:()=>k({kind:"problems"}),testID:"buoy-socket-chip-problems"}):null,n(m,{label:"\u2191 Sent",selected:b({kind:"direction",direction:"out"}),onPress:()=>k({kind:"direction",direction:"out"}),testID:"buoy-socket-chip-sent"}),n(m,{label:"\u2193 Got",selected:b({kind:"direction",direction:"in"}),onPress:()=>k({kind:"direction",direction:"in"}),testID:"buoy-socket-chip-got"}),R.map(e=>n(m,{label:e.match(/[.:/]$/)?`${e}*`:e,selected:b({kind:"type",prefix:e}),onPress:()=>k({kind:"type",prefix:e}),testID:`buoy-socket-chip-type-${e}`},e))]}),l.tests.blocked||l.tests.offline||l.tests.frozen.length>0?n(d,{style:t.testNote,numberOfLines:1,children:l.tests.offline?"Offline mode is on":l.tests.blocked?"New sockets are blocked":"A socket is frozen"}):null]});return n(_,{...M,testID:"buoy-socket-list",accessibilityLabel:"Socket messages",data:W,renderItem:v,keyExtractor:oe,ListHeaderComponent:B,ListEmptyComponent:n(V,{testID:"buoy-socket-empty",...J({subject:"messages",search:r,total:l.frames.length,capturing:l.capturingSince!==null||l.connections.length>0,waiting:{otto:"fishing",title:"No socket messages",message:"Messages show here when your app opens a WebSocket."},paused:{title:"Not watching sockets",message:"Buoy watches sockets in dev builds once the Network tool loads."}})}),contentContainerStyle:t.listContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:true})}const t=F.create({listContent:{paddingBottom:24},header:{gap:6,paddingTop:8,paddingBottom:4},card:{marginHorizontal:10,padding:9,gap:6,borderRadius:10,borderWidth:1,borderColor:i.color.border,backgroundColor:i.color.surface},cardSelected:{borderColor:i.color.accentBorderStrong,backgroundColor:i.color.accentSoft},cardUrl:{fontSize:11,color:i.color.text,fontFamily:U},pills:{flexDirection:"row",flexWrap:"wrap",gap:5},pill:{paddingHorizontal:6,paddingVertical:2,borderRadius:5},pillText:{fontSize:10,fontWeight:"600"},pillOk:{backgroundColor:i.color.accentSoft},pillOkText:{color:i.color.accent},pillWarn:{backgroundColor:i.color.warningSoft},pillWarnText:{color:i.color.warning},pillPlain:{backgroundColor:i.color.fill},pillPlainText:{color:i.color.textSecondary},banner:{marginHorizontal:10,padding:8,gap:3,borderRadius:8,backgroundColor:i.color.dangerSoft,borderWidth:1,borderColor:"rgba(255,59,48,0.3)"},bannerText:{fontSize:11,color:i.color.danger,fontWeight:"600"},chips:{gap:6,paddingHorizontal:10},testNote:{paddingHorizontal:12,fontSize:11,color:i.color.warning,fontWeight:"600"}});
@@ -0,0 +1 @@
1
+ "use strict";import{StyleSheet as f,Text as a,TouchableOpacity as S,View as c}from"react-native";import{monoFont as p,night as t}from"@buoy-gg/shared-ui";import{clockTime as y,closeLabel as L,previewText as T,shortDuration as C}from"../../sockets/format";import{jsx as i,jsxs as s}from"react/jsx-runtime";const m="#6EA1FF";function h({label:o,tone:l}){return i(c,{style:[n.tag,k[l].box],children:i(a,{style:[n.tagText,k[l].text],numberOfLines:1,children:o})})}function w(o){const l=o.frame;const e=[];if(o.problem)e.push({label:x[o.problem.kind],tone:"bad"});if(l.replyMs!==void 0)e.push({label:`\u2713 ${C(l.replyMs)}`,tone:"ok"});if(l.fake==="inject")e.push({label:"Fake",tone:"info"});if(l.fake==="send")e.push({label:"Buoy sent",tone:"info"});if(l.held)e.push({label:"Held",tone:"warn"});if(l.sentWhileClosed)e.push({label:"Closed",tone:"bad"});return e}const x={"no-reply":"No reply","reconnect-storm":"Storm","auth-loop":"Sign-in loop","cant-connect":"Can't connect","two-sockets":"Two sockets","sent-while-closed":"Sent while closed"};export function SocketMessageRow({row:o,onOpen:l,onExpand:e}){const r=o.frame;const b=r.direction==="out";const d=r.type??(r.binary?"binary":"message");const g=o.count>1&&o.foldKey!==void 0;return s(S,{activeOpacity:.7,onPress:()=>g?e(o.foldKey):l(r),"sentry-label":"ignore open socket message",testID:`buoy-socket-row-${r.id}`,accessibilityRole:"button",accessibilityLabel:g?`${o.count} ${d} messages, tap to show each`:`${b?"Sent":"Got"} ${d}`,style:[n.row,o.problem?n.rowProblem:null],children:[i(a,{style:[n.dir,{color:b?m:t.color.accent}],children:b?"\u2191":"\u2193"}),s(c,{style:n.middle,children:[s(c,{style:n.titleLine,children:[i(a,{style:n.type,numberOfLines:1,children:d}),o.count>1?i(h,{label:`\xD7${o.count}`,tone:"plain"}):null]}),s(a,{style:n.preview,numberOfLines:1,children:[r.correlationId?`${r.correlationId} \xB7 `:"",T(r)]})]}),s(c,{style:n.right,children:[i(c,{style:n.tags,children:w(o).slice(0,2).map(u=>i(h,{label:u.label,tone:u.tone},u.label))}),i(a,{style:n.time,children:y(r.timestamp)})]})]})}export function SocketLifecycleRow({row:o,attempt:l}){const e=o.frame;const r=e.kind==="open"?`Open${l&&l>1?` #${l}`:""}`:e.kind==="error"?"Error":L(e.code,e.neverOpened);const b=e.byBuoy&&!/buoy/i.test(e.reason??"")?"by Buoy":null;const d=[o.problem?`\u26A0 ${x[o.problem.kind]}`:null,e.kind==="close"?e.reason:null,e.kind==="close"?b:null].filter(Boolean).join(" \xB7 ");const g=o.problem||e.kind==="error"?t.color.danger:e.kind==="open"?t.color.accent:t.color.warning;return s(c,{style:n.life,testID:`buoy-socket-life-${e.id}`,children:[i(c,{style:n.lifeLine}),s(a,{style:n.lifeText,numberOfLines:1,children:[i(a,{style:[n.lifeLabel,{color:g}],children:r}),d?` \xB7 ${d}`:""," \xB7 ",y(e.timestamp)]}),i(c,{style:n.lifeLine})]})}const k={ok:f.create({box:{backgroundColor:t.color.accentSoft},text:{color:t.color.accent}}),bad:f.create({box:{backgroundColor:t.color.dangerSoft},text:{color:t.color.danger}}),warn:f.create({box:{backgroundColor:t.color.warningSoft},text:{color:t.color.warning}}),info:f.create({box:{backgroundColor:t.color.infoSoft},text:{color:m}}),plain:f.create({box:{backgroundColor:t.color.fill},text:{color:t.color.textSecondary}})};const n=f.create({row:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingHorizontal:10,marginHorizontal:8,backgroundColor:"rgba(12, 12, 12, 0.9)",borderBottomWidth:1,borderBottomColor:t.color.separator,borderLeftWidth:3,borderLeftColor:"transparent"},rowProblem:{borderLeftColor:t.color.danger,backgroundColor:"rgba(40, 12, 12, 0.9)"},dir:{width:14,fontSize:13,fontWeight:"700",fontFamily:p,textAlign:"center"},middle:{flex:1,minWidth:0,gap:1},titleLine:{flexDirection:"row",alignItems:"center",gap:6},type:{flexShrink:1,fontSize:12,fontWeight:"600",color:t.color.text,fontFamily:p},preview:{fontSize:10,color:t.color.textTertiary,fontFamily:p},right:{alignItems:"flex-end",gap:3},tags:{flexDirection:"row",gap:4},tag:{paddingHorizontal:5,paddingVertical:1,borderRadius:4},tagText:{fontSize:9.5,fontWeight:"700"},time:{fontSize:9,color:t.color.textTertiary,fontFamily:p},life:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:6,paddingHorizontal:12},lifeLine:{flex:1,height:1,backgroundColor:t.color.separator},lifeText:{fontSize:10.5,color:t.color.textSecondary,flexShrink:1},lifeLabel:{fontWeight:"700"}});
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect as z,useState as f}from"react";import{ScrollView as C,StyleSheet as R,Text as s,TextInput as W,TouchableOpacity as v,View as i}from"react-native";import{NightButton as k,NightChip as B,NightSectionLabel as g,NightSwitch as x,monoFont as P,night as r}from"@buoy-gg/shared-ui";import{useSocketsState as j}from"../../hooks/useSocketsState";import{shortUrl as N}from"../../sockets/format";import{socketStore as O}from"../../sockets/socketStore";import{jsx as e,jsxs as n}from"react/jsx-runtime";const V=[{code:1006,title:"Drop it",detail:"1006 \xB7 like lost signal",testID:"buoy-socket-drop"},{code:1008,title:"Kick out",detail:"1008 \xB7 like a bad token",testID:"buoy-socket-kick"},{code:1001,title:"Server going away",detail:"1001 \xB7 like a deploy",testID:"buoy-socket-going-away"}];export function SocketTricksView({visible:u,draft:p,isPro:S,onUpgradePress:D}){const a=j(!u);const[I,b]=f(null);const[d,w]=f("");const[y,m]=f(null);z(()=>{if(!u||!p)return;b(p.socketId);w(p.data);m(null)},[u,p]);if(!u)return null;const h=a.connections.filter(o=>o.state==="open"||o.state==="connecting");const l=h.find(o=>o.id===I)??h[0]??null;const c=async o=>{if(!S)return D();m(await O.act(o))};const T=a.tests.blocked||a.tests.frozen.length>0;return n(C,{contentContainerStyle:t.content,keyboardShouldPersistTaps:"handled",testID:"buoy-socket-tricks-screen",children:[e(s,{style:t.lede,children:"Make the socket misbehave on purpose. Your app's real code handles each one."}),e(g,{children:"Socket"}),h.length===0?e(s,{style:t.note,children:"No socket is open. Open one in your app, or turn Block off."}):null,h.length>0?e(i,{style:t.chips,children:h.map(o=>e(B,{label:`${o.id} \xB7 ${N(o.url)}`,selected:l?.id===o.id,onPress:()=>b(o.id),testID:`buoy-socket-target-${o.id}`},o.id))}):null,e(g,{children:"Message"}),e(W,{value:d,onChangeText:w,multiline:true,autoCapitalize:"none",autoCorrect:false,placeholder:'{"type":"chat.message","payload":{"text":"hi"}}',placeholderTextColor:r.color.placeholder,style:t.input,testID:"buoy-socket-message-input",accessibilityLabel:"Message to push or send"}),n(i,{style:t.row,children:[e(k,{label:"Push to app",variant:"primary",disabled:!l||!d.trim(),onPress:()=>l&&c({action:"inject",socketId:l.id,data:d}),testID:"buoy-socket-inject"}),e(k,{label:"Send to server",disabled:!l||!d.trim(),onPress:()=>l&&c({action:"send",socketId:l.id,data:d}),testID:"buoy-socket-send"})]}),e(g,{children:"Break the socket"}),e(i,{style:t.grid,children:V.map(o=>n(v,{disabled:!l,onPress:()=>l&&c({action:"close",socketId:l.id,code:o.code}),"sentry-label":"ignore socket break",testID:o.testID,accessibilityRole:"button",style:[t.cell,!l?t.cellOff:null],children:[e(s,{style:t.cellTitle,children:o.title}),e(s,{style:t.cellDetail,children:o.detail})]},o.code))}),e(s,{style:t.note,children:'On iOS, a real lost link often closes as 1001 "Stream end encountered", not 1006. Check for both.'}),n(i,{style:t.switchRow,children:[n(i,{style:t.switchText,children:[e(s,{style:t.switchTitle,children:"Freeze"}),e(s,{style:t.cellDetail,children:"Looks open, but nothing gets through. Tests your app's ping check."})]}),e(x,{value:!!l?.frozen,disabled:!l,onValueChange:o=>l&&c({action:"freeze",socketId:l.id,frozen:o}),testID:"buoy-socket-freeze"})]}),n(i,{style:t.switchRow,children:[n(i,{style:t.switchText,children:[e(s,{style:t.switchTitle,children:"Block"}),e(s,{style:t.cellDetail,children:"Drops open sockets, and every new one fails. Tests your backoff."})]}),e(x,{value:a.tests.blocked,onValueChange:o=>c({action:"block",blocked:o}),testID:"buoy-socket-block"})]}),a.tests.offline?e(s,{style:t.warn,children:"Network's offline mode is on, so sockets act offline too."}):null,e(i,{style:t.row,children:e(k,{label:"Reset all",variant:"tertiary",disabled:!T,onPress:()=>c({action:"reset"}),testID:"buoy-socket-reset"})}),y?e(s,{style:[t.result,y.ok?null:t.warn],testID:"buoy-socket-result",children:y.message}):null]})}const t=R.create({content:{padding:12,gap:10,paddingBottom:40},lede:{fontSize:12,color:r.color.textSecondary},note:{fontSize:12,color:r.color.textTertiary},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},input:{minHeight:96,padding:10,borderRadius:8,borderWidth:1,borderColor:r.color.border,backgroundColor:r.color.surface,color:r.color.text,fontFamily:P,fontSize:12,textAlignVertical:"top"},row:{flexDirection:"row",flexWrap:"wrap",gap:8},grid:{flexDirection:"row",flexWrap:"wrap",gap:8},cell:{flexGrow:1,flexBasis:"45%",padding:9,gap:2,borderRadius:8,borderWidth:1,borderColor:r.color.border,backgroundColor:r.color.surface},cellOff:{opacity:.4},cellTitle:{fontSize:12,fontWeight:"700",color:r.color.text},cellDetail:{fontSize:10.5,color:r.color.textTertiary},switchRow:{flexDirection:"row",alignItems:"center",gap:10},switchText:{flex:1,gap:2},switchTitle:{fontSize:13,fontWeight:"600",color:r.color.text},warn:{fontSize:12,color:r.color.warning,fontWeight:"600"},result:{fontSize:12,color:r.color.textSecondary}});
@@ -1 +1 @@
1
- "use strict";import{useEffect as j,useRef as x,useState as h,useSyncExternalStore as k}from"react";import{ActivityIndicator as q,StyleSheet as A,Text as i,TouchableOpacity as R,View as p}from"react-native";import{ChevronDown as L,Check as O,night as e}from"@buoy-gg/shared-ui";import{conditionsCanApply as T,getNetworkCondition as z,setNetworkCondition as P,subscribeNetworkConditions as N}from"./store";import{jsx as r,jsxs as f}from"react/jsx-runtime";const H=[{profile:"normal",label:"No throttling"},{profile:"slow",label:"Slow"},{profile:"verySlow",label:"Very slow"},{profile:"offline",label:"Offline"}];const E={normal:"No added delay",slow:"+500 ms before each new request",verySlow:"+2 seconds before each new request",offline:"New requests fail before sending"};export function NetworkConditionsControl({remote:s}){const D=k(N,z,z);const I=k(N,T,T);const[u,b]=h(false);const[w,S]=h();const[c,m]=h(false);const g=x(false);const d=x(true);j(()=>{d.current=true;return()=>{d.current=false}},[]);const n=s?s.profile:D;const a=s?s.available:I;const C=n!==null&&n!=="normal";const y=n==="offline"?e.color.danger:C?e.color.warning:e.color.accent;async function W(t){if(!a||g.current)return;if(t===n){b(false);return}g.current=true;m(true);S(void 0);try{if(s)await s.onChange(t);else P(t);if(d.current)b(false)}catch(l){if(d.current)S(l instanceof Error?l.message:String(l))}finally{g.current=false;if(d.current)m(false)}}const v=H.find(t=>t.profile===n)?.label??"Unavailable";return f(p,{style:o.container,testID:"buoy-network-throttling-screen",children:[r(i,{style:o.heading,children:"Connection profile"}),f(R,{testID:"buoy-network-conditions",accessibilityRole:"button",accessibilityLabel:`Network throttling: ${v}`,accessibilityState:{expanded:u,disabled:!a||c},disabled:!a||c,onPress:()=>b(t=>!t),style:[o.dropdown,u&&o.dropdownOpen,!a&&o.disabled],children:[r(i,{style:[o.value,C&&{color:y}],children:v}),c?r(q,{size:"small",color:e.color.textSecondary}):r(L,{size:16,color:e.color.textSecondary})]}),u&&r(p,{accessibilityRole:"radiogroup",accessibilityLabel:"Connection profile",style:o.options,children:H.map(t=>{const l=n===t.profile;return f(R,{testID:`buoy-network-condition-${t.profile}`,accessibilityRole:"radio",accessibilityLabel:t.label,accessibilityState:{checked:l,disabled:!a||c},disabled:!a||c,onPress:()=>void W(t.profile),style:[o.option,l&&o.selected],children:[f(p,{style:o.optionBody,children:[r(i,{style:[o.optionTitle,l&&{color:y}],children:t.label}),r(i,{style:o.caption,children:E[t.profile]})]}),l&&r(O,{size:16,color:y})]},t.profile)})}),r(i,{style:o.caption,accessibilityLiveRegion:"polite",children:c?"Applying to device\u2026":!a?s?"Conditions unavailable on this device":"Requires a signed-in account and a development build":n?E[n]:"Waiting for device status"}),!!w&&r(i,{accessibilityRole:"alert",style:o.error,children:w}),f(p,{style:o.help,children:[r(i,{style:o.heading,children:"How it works"}),r(i,{style:o.caption,children:"Affects new HTTP requests through global fetch and XHR. Slow adds a wait before sending; download speed stays unchanged."}),r(i,{style:o.caption,children:"Stays active when you close this tool or pause capture. Choose No throttling to stop. Reloading the app resets it."})]})]})}const o=A.create({container:{padding:e.gutter,gap:10},heading:{fontSize:e.font.caption,fontWeight:"600",color:e.color.textSecondary},dropdown:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingHorizontal:12,paddingVertical:10,borderRadius:e.radius.segment,borderWidth:1,borderColor:e.color.separator,backgroundColor:e.color.surfaceElevated},dropdownOpen:{borderColor:e.color.accentBorderStrong},value:{flex:1,fontSize:e.font.body,color:e.color.text},options:{padding:4,borderRadius:e.radius.row,borderWidth:1,borderColor:e.color.border,backgroundColor:e.color.surface},option:{flexDirection:"row",alignItems:"center",gap:12,minHeight:54,padding:10,borderRadius:e.radius.segment},optionBody:{flex:1,gap:4},optionTitle:{fontSize:e.font.caption,fontWeight:"600",color:e.color.text},selected:{backgroundColor:e.color.surfaceElevated},disabled:{opacity:.45},caption:{fontSize:e.font.caption,lineHeight:19,color:e.color.textSecondary},help:{marginTop:14,paddingTop:16,gap:10,borderTopWidth:1,borderTopColor:e.color.separator},error:{fontSize:e.font.caption,lineHeight:18,color:e.color.danger}});
1
+ "use strict";import{useEffect as O,useRef as N,useState as w,useSyncExternalStore as I}from"react";import{ActivityIndicator as V,StyleSheet as $,Text as i,TouchableOpacity as k,View as S}from"react-native";import{ChevronDown as _,Check as J,night as t}from"@buoy-gg/shared-ui";import{conditionsCanApply as W,getNetworkCondition as A,setNetworkCondition as X,subscribeNetworkConditions as R,getNetworkConditions as M,getConditionsRevision as K,setNetworkConditions as Q}from"./store";import{jsx as n,jsxs as h}from"react/jsx-runtime";const L=[{profile:"normal",label:"No throttling"},{profile:"slow",label:"Slow"},{profile:"verySlow",label:"Very slow"},{profile:"offline",label:"Offline"},{profile:"slow3g",label:"Slow 3G"},{profile:"slow4g",label:"Slow 4G"},{profile:"fast4g",label:"Fast 4G"}];const j={normal:"No added delay",slow:"+500 ms before each new request",verySlow:"+2 seconds before each new request",offline:"New requests fail before sending",slow3g:"50 KB/s down, 50 KB/s up; +2000 ms",slow4g:"180 KB/s down, 84.375 KB/s up; +562.5 ms",fast4g:"1012.5 KB/s down, 168.75 KB/s up; +165 ms"};export function NetworkConditionsControl({remote:r,compact:P=false}){I(R,K,K);const l=r?r.state:M();const[U,T]=w(false);const q=I(R,A,A);const F=I(R,W,W);const[C,m]=w(false);const[E,y]=w();const[c,g]=w(false);const u=N(false);const p=N(true);const d=N(0);O(()=>{d.current++;u.current=false;g(false);y(void 0)},[r?.targetId]);O(()=>{p.current=true;return()=>{p.current=false}},[]);const f=r?r.profile:q;const s=r?r.available:F;const z=l?.active??(f!==null&&f!=="normal");const v=f==="offline"?t.color.danger:z?t.color.warning:t.color.accent;async function G(o){if(!s||u.current)return;if(o===f&&(o!=="normal"||!l?.active)){m(false);return}const a=++d.current;u.current=true;g(true);y(void 0);try{if(r)await r.onChange(o);else X(o);if(p.current&&d.current===a)m(false)}catch(b){if(p.current&&d.current===a)y(b instanceof Error?b.message:String(b))}finally{if(d.current===a){u.current=false;if(p.current)g(false)}}}const D=[["auto","Follow speed"],["real","Real link"],["offline","Offline"],["wifi","Wi-Fi"],["cellular","Cellular"],["noInternet","No internet"]];const B=(!r||!!r.onConnectionChange)&&(l?.capabilities.netInfo.supported||l?.capabilities.expoNetwork.supported);const H=L.find(o=>o.profile===f)?.label??"Unavailable";return h(S,{style:e.container,testID:"buoy-network-throttling-screen",children:[n(i,{style:e.heading,children:"Connection profile"}),h(k,{testID:"buoy-network-conditions",accessibilityRole:"button",accessibilityLabel:`Network throttling: ${H}`,accessibilityState:{expanded:C,disabled:!s||c},disabled:!s||c,onPress:()=>m(o=>!o),style:[e.dropdown,C&&e.dropdownOpen,!s&&e.disabled],children:[n(i,{style:[e.value,z&&{color:v}],children:H}),c?n(V,{size:"small",color:t.color.textSecondary}):n(_,{size:16,color:t.color.textSecondary})]}),C&&n(S,{accessibilityRole:"radiogroup",accessibilityLabel:"Connection profile",style:e.options,children:L.map(o=>{const a=f===o.profile;return h(k,{testID:`buoy-network-condition-${o.profile}`,accessibilityRole:"radio",accessibilityLabel:o.label,accessibilityState:{checked:a,disabled:!s||c},disabled:!s||c,onPress:()=>void G(o.profile),style:[e.option,a&&e.selected],children:[h(S,{style:e.optionBody,children:[n(i,{style:[e.optionTitle,a&&{color:v}],children:o.label}),n(i,{style:e.caption,children:j[o.profile]})]}),a&&n(J,{size:16,color:v})]},o.profile)})}),n(i,{style:e.caption,accessibilityLiveRegion:"polite",children:c?"Applying to device\u2026":!s?r?"Conditions unavailable on this device":"Requires a signed-in account and a development build":f?j[f]:"Waiting for device status"}),!!E&&n(i,{accessibilityRole:"alert",style:e.error,children:E}),n(k,{testID:"buoy-network-link-state",accessibilityRole:"button",accessibilityLabel:"App link state",disabled:!s||c||!B,onPress:()=>T(o=>!o),style:e.dropdown,children:h(i,{style:e.value,children:["App link: ",D.find(([o])=>o===l?.connection)?.[1]??"Unavailable"]})}),U&&D.map(([o,a])=>n(k,{testID:`buoy-network-link-${o}`,accessibilityRole:"radio",accessibilityState:{checked:l?.connection===o,disabled:c||!s},disabled:c||!s,style:e.option,onPress:async()=>{if(u.current)return;const b=++d.current;u.current=true;g(true);y(void 0);try{if(r)await r.onConnectionChange?.(o);else Q({connection:o});if(p.current&&d.current===b)T(false)}catch(x){if(p.current&&d.current===b)y(x instanceof Error?x.message:String(x))}finally{if(d.current===b){u.current=false;if(p.current)g(false)}}},children:n(i,{style:e.optionTitle,children:a})},o)),!B&&n(i,{style:e.caption,children:l?.capabilities.netInfo.reason??"This device has no link hook."}),!P&&h(S,{style:e.help,children:[n(i,{style:e.heading,children:"How it works"}),l&&h(i,{style:e.caption,children:["NetInfo: ",l.capabilities.netInfo.supported?"Hook on":l.capabilities.netInfo.reason??"No hook",". Expo Network: ",l.capabilities.expoNetwork.supported?"Hook on":l.capabilities.expoNetwork.reason??"No hook","."]}),n(i,{style:e.caption,children:"Down caps pace bytes to the app in JS. The socket stays at its real speed."}),n(i,{style:e.caption,children:"Up caps wait before send for known bytes. Upload time is simulated. The socket is not paced. Unknown sizes pass through with latency only. Each call shows any cap gap."}),n(i,{style:e.caption,children:"Caps apply per call through global fetch and RN XHR. Offline also drops WebSockets; speeds don't slow them. Native images, native SDKs and file transfers are not affected."}),n(i,{style:e.caption,children:"Link state changes what NetInfo and Expo Network report. It does not change the radio or web calls."}),n(i,{style:e.caption,children:"Stays on when this tool closes or capture pauses. No throttling clears both controls. App reload clears them too."})]})]})}const e=$.create({container:{padding:t.gutter,gap:10},heading:{fontSize:t.font.caption,fontWeight:"600",color:t.color.textSecondary},dropdown:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingHorizontal:12,paddingVertical:10,borderRadius:t.radius.segment,borderWidth:1,borderColor:t.color.separator,backgroundColor:t.color.surfaceElevated},dropdownOpen:{borderColor:t.color.accentBorderStrong},value:{flex:1,fontSize:t.font.body,color:t.color.text},options:{padding:4,borderRadius:t.radius.row,borderWidth:1,borderColor:t.color.border,backgroundColor:t.color.surface},option:{flexDirection:"row",alignItems:"center",gap:12,minHeight:54,padding:10,borderRadius:t.radius.segment},optionBody:{flex:1,gap:4},optionTitle:{fontSize:t.font.caption,fontWeight:"600",color:t.color.text},selected:{backgroundColor:t.color.surfaceElevated},disabled:{opacity:.45},caption:{fontSize:t.font.caption,lineHeight:19,color:t.color.textSecondary},help:{marginTop:14,paddingTop:16,gap:10,borderTopWidth:1,borderTopColor:t.color.separator},error:{fontSize:t.font.caption,lineHeight:18,color:t.color.danger}});
@@ -1 +1 @@
1
- "use strict";import{act as n,createElement as r}from"react";import{createRoot as p}from"react-dom/client";import{afterEach as C,beforeEach as v,expect as t,it as u,vi as l}from"vitest";import{NetworkConditionsControl as k}from"./NetworkConditionsControl";l.mock("@buoy-gg/shared-ui",async()=>({ChevronDown:()=>null,Check:()=>null,night:(await l.importActual("../../../../shared/src/ui/night/nightTheme")).night}));l.mock("react-native",()=>({StyleSheet:{create:e=>e},View:({children:e})=>r("div",null,e),Text:({children:e})=>r("span",null,e),ActivityIndicator:()=>r("span",null,"pending"),TouchableOpacity:({children:e,onPress:a,disabled:d,accessibilityLabel:h,accessibilityState:b,testID:w})=>r("button",{onClick:a,disabled:d,"aria-label":h,"aria-checked":b?.checked,"data-testid":w},e)}));l.mock("./store",()=>({NETWORK_CONDITIONS:{normal:{label:"Normal"},slow:{label:"Slow"},verySlow:{label:"Very slow"},offline:{label:"Offline"}},getNetworkCondition:()=>"normal",conditionsCanApply:()=>true,subscribeNetworkConditions:()=>()=>{},setNetworkCondition:l.fn()}));let f;let i;v(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;i=document.createElement("div");f=p(i)});C(()=>n(()=>f.unmount()));const o=e=>i.querySelector(`[data-testid="buoy-network-condition-${e}"]`);function c(e){n(()=>f.render(r(k,{remote:e})))}const m=()=>i.querySelector('[data-testid="buoy-network-conditions"]');const s=()=>n(()=>m().click());u("defaults to a closed No throttling dropdown and closes when the current option is chosen",()=>{const e=l.fn();c({profile:"normal",available:true,onChange:e});t(m().textContent).toBe("No throttling");t(o("normal")).toBeNull();s();t(["normal","slow","verySlow","offline"].every(a=>!!o(a))).toBe(true);n(()=>o("normal").click());t(o("normal")).toBeNull();t(e).not.toHaveBeenCalled()});u("blocks duplicate remote changes and waits for the device profile before selecting it",async()=>{let e;const a=l.fn(()=>new Promise(d=>{e=d}));c({profile:"normal",available:true,onChange:a});s();n(()=>o("slow").click());t(o("offline").disabled).toBe(true);t(o("normal").getAttribute("aria-checked")).toBe("true");n(()=>o("offline").click());t(a).toHaveBeenCalledExactlyOnceWith("slow");await n(async()=>e());c({profile:"slow",available:true,onChange:a});t(m().textContent).toBe("Slow");t(o("slow")).toBeNull();s();t(o("slow").getAttribute("aria-checked")).toBe("true")});u("reports a remote error, permits retry, and disables unavailable devices",async()=>{const e=l.fn().mockRejectedValue(new Error("Device disconnected"));c({profile:"normal",available:true,onChange:e});s();await n(async()=>o("offline").click());t(i.textContent).toContain("Device disconnected");t(o("offline").disabled).toBe(false);c({profile:null,available:false,onChange:e});t(o("normal").disabled).toBe(true);t(i.textContent).toContain("Conditions unavailable on this device")});
1
+ "use strict";import{act as a,createElement as f}from"react";import{createRoot as C}from"react-dom/client";import{afterEach as m,beforeEach as b,expect as t,it as c,vi as n}from"vitest";import{NetworkConditionsControl as v}from"./NetworkConditionsControl";n.mock("@buoy-gg/shared-ui",async()=>({ChevronDown:()=>null,Check:()=>null,night:(await n.importActual("../../../../shared/src/ui/night/nightTheme")).night}));n.mock("react-native",()=>({StyleSheet:{create:e=>e},View:({children:e})=>f("div",null,e),Text:({children:e})=>f("span",null,e),ActivityIndicator:()=>f("span",null,"pending"),TouchableOpacity:({children:e,onPress:i,disabled:d,accessibilityLabel:w,accessibilityState:h,testID:k})=>f("button",{onClick:i,disabled:d,"aria-label":w,"aria-checked":h?.checked,"data-testid":k},e)}));n.mock("./store",()=>({NETWORK_CONDITIONS:{normal:{label:"Normal"},slow:{label:"Slow"},verySlow:{label:"Very slow"},offline:{label:"Offline"}},getConditionsRevision:()=>0,getNetworkConditions:()=>({capabilities:{netInfo:{supported:false},expoNetwork:{supported:false}}}),setNetworkConditions:n.fn(),getNetworkCondition:()=>"normal",conditionsCanApply:()=>true,subscribeNetworkConditions:()=>()=>{},setNetworkCondition:n.fn()}));let p;let l;b(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;l=document.createElement("div");p=C(l)});m(()=>a(()=>p.unmount()));const o=e=>l.querySelector(`[data-testid="buoy-network-condition-${e}"]`);function r(e){a(()=>p.render(f(v,{remote:e})))}const u=()=>l.querySelector('[data-testid="buoy-network-conditions"]');const s=()=>a(()=>u().click());c("defaults to a closed No throttling dropdown and closes when the current option is chosen",()=>{const e=n.fn();r({profile:"normal",available:true,onChange:e});t(u().textContent).toBe("No throttling");t(o("normal")).toBeNull();s();t(["normal","slow","verySlow","offline"].every(i=>!!o(i))).toBe(true);a(()=>o("normal").click());t(o("normal")).toBeNull();t(e).not.toHaveBeenCalled()});c("blocks duplicate remote changes and waits for the device profile before selecting it",async()=>{let e;const i=n.fn(()=>new Promise(d=>{e=d}));r({profile:"normal",available:true,onChange:i});s();a(()=>o("slow").click());t(o("offline").disabled).toBe(true);t(o("normal").getAttribute("aria-checked")).toBe("true");a(()=>o("offline").click());t(i).toHaveBeenCalledExactlyOnceWith("slow");await a(async()=>e());r({profile:"slow",available:true,onChange:i});t(u().textContent).toBe("Slow");t(o("slow")).toBeNull();s();t(o("slow").getAttribute("aria-checked")).toBe("true")});c("reports a remote error, permits retry, and disables unavailable devices",async()=>{const e=n.fn().mockRejectedValue(new Error("Device disconnected"));r({profile:"normal",available:true,onChange:e});s();await a(async()=>o("offline").click());t(l.textContent).toContain("Device disconnected");t(o("offline").disabled).toBe(false);r({profile:null,available:false,onChange:e});t(o("normal").disabled).toBe(true);t(l.textContent).toContain("Conditions unavailable on this device")});c("offers all v2 speed profiles on the remote control",async()=>{const e=n.fn().mockResolvedValue(void 0);r({profile:"normal",available:true,onChange:e});s();for(const i of["slow3g","slow4g","fast4g"])t(o(i)).not.toBeNull();await a(async()=>o("slow4g").click());t(e).toHaveBeenCalledExactlyOnceWith("slow4g");t(l.textContent).toContain("socket is not paced")});c("forwards a link change and keeps device readback as the selected state",async()=>{const e=n.fn().mockResolvedValue(void 0);const i={version:2,connection:"real",capabilities:{netInfo:{supported:true},expoNetwork:{supported:false}}};r({profile:"normal",available:true,onChange:n.fn(),state:i,onConnectionChange:e});a(()=>l.querySelector('[data-testid="buoy-network-link-state"]').click());await a(async()=>l.querySelector('[data-testid="buoy-network-link-cellular"]').click());t(e).toHaveBeenCalledExactlyOnceWith("cellular");t(l.textContent).toContain("App link: Real link")});c("shows a late peer gap even when the other hook works",()=>{const e={version:2,connection:"real",capabilities:{netInfo:{supported:false,reason:"Link hook loaded too late."},expoNetwork:{supported:true}}};r({profile:"normal",available:true,onChange:n.fn(),state:e,onConnectionChange:n.fn()});t(l.textContent).toContain("NetInfo: Link hook loaded too late.");t(l.textContent).toContain("Expo Network: Hook on")});c("ignores an old device action result after switching devices",async()=>{let e;r({targetId:"first",profile:"normal",available:true,onChange:()=>new Promise((i,d)=>{e=d})});s();a(()=>o("slow3g").click());r({targetId:"second",profile:"fast4g",available:true,onChange:n.fn()});await a(async()=>e(new Error("Old device failed")));t(l.textContent).not.toContain("Old device failed");t(u().textContent).toBe("Fast 4G");t(u().disabled).toBe(false)});
@@ -1 +1 @@
1
- "use strict";import{useSyncExternalStore as s}from"react";import{Text as l,View as e}from"react-native";import{NetworkIcon as c}from"@buoy-gg/shared-ui";import{getNetworkCondition as i,subscribeNetworkConditions as m,NETWORK_CONDITIONS as n}from"./store";import{jsx as t,jsxs as f}from"react/jsx-runtime";export function NetworkConditionsIcon({size:r}){const o=s(m,i,i);return f(e,{accessibilityLabel:o==="normal"?"Network":`Network: ${n[o].label}`,children:[t(c,{size:r}),o!=="normal"&&t(e,{pointerEvents:"none",style:{position:"absolute",top:-6,right:-8,width:48,alignItems:"flex-end"},children:t(l,{testID:"buoy-network-condition-indicator",numberOfLines:1,style:{color:"#FFCC66",fontSize:10,fontWeight:"700"},children:o==="offline"?"OFF":`+${n[o].delayMs}`})})]})}
1
+ "use strict";import{useSyncExternalStore as e}from"react";import{Text as a,View as i}from"react-native";import{NetworkIcon as d}from"@buoy-gg/shared-ui";import{getNetworkCondition as n,subscribeNetworkConditions as r,NETWORK_CONDITIONS as s,getConditionsRevision as l,networkConditionsActive as f}from"./store";import{jsx as t,jsxs as p}from"react/jsx-runtime";export function NetworkConditionsIcon({size:c}){e(r,l,l);const m=f();const o=e(r,n,n);return p(i,{accessibilityLabel:o==="normal"?"Network":`Network: ${s[o].label}`,children:[t(d,{size:c}),m&&t(i,{pointerEvents:"none",style:{position:"absolute",top:-6,right:-8,width:48,alignItems:"flex-end"},children:t(a,{testID:"buoy-network-condition-indicator",numberOfLines:1,style:{color:"#FFCC66",fontSize:10,fontWeight:"700"},children:o==="normal"?"LINK":o==="offline"?"OFF":`+${s[o].delayMs}`})})]})}
@@ -1 +1 @@
1
- "use strict";import{useEffect as L,useRef as _,useState as E,useSyncExternalStore as R}from"react";import{ActivityIndicator as U,StyleSheet as G,Text as p,TouchableOpacity as O,View as d,useWindowDimensions as J}from"react-native";import{FloatingTool as K,night as e,openFloatingTool as Q,persistentStorage as X,registerPersistentFloatingTool as Y}from"@buoy-gg/shared-ui";import{conditionsCanApply as H,getNetworkCondition as V,setNetworkCondition as Z,subscribeNetworkConditions as z}from"./store";import{jsx as t,jsxs as F}from"react/jsx-runtime";export function createRemoteConditionsSource(){let l;const a=new Set;return{getSnapshot:()=>l,subscribe:s=>{a.add(s);return()=>{a.delete(s)}},update(s){l=s;a.forEach(r=>r())}}}const ee=()=>()=>{};const j=()=>void 0;const y=[{id:"normal",label:"No throttling",detail:"No added delay"},{id:"slow",label:"Slow",detail:"+500 ms before sending"},{id:"verySlow",label:"Very slow",detail:"+2 seconds before sending"},{id:"offline",label:"Offline",detail:"New requests fail"}];const te={id:"network-throttling",render:l=>t(NetworkFloatingTool,{...l})};export function registerLocalNetworkFloatingTool(){if(typeof __DEV__==="undefined"||!__DEV__)return()=>{};return Y(te,X)}if(typeof __DEV__!=="undefined"&&__DEV__&&typeof navigator!=="undefined"&&navigator.product==="ReactNative"){registerLocalNetworkFloatingTool()}export function openNetworkFloatingTool(l){Q({id:"network-throttling",render:a=>t(NetworkFloatingTool,{...a,source:l})})}export function NetworkFloatingTool({id:l,revealToken:a,dismiss:s,source:r}){const W=R(z,V,V);const A=R(z,H,H);const m=R(r?.subscribe??ee,r?.getSnapshot??j,j);const g=r?m?.profile??null:W;const h=r?m?.available===true:A;const[c,w]=E(false);const[D,S]=E();const b=_(false);const f=_(0);const u=_(true);const{width:$}=J();L(()=>{u.current=true;return()=>{u.current=false}},[]);L(()=>{f.current+=1;b.current=false;w(false);S(void 0)},[r,m?.targetId]);const B=g!==null&&g!=="normal";const i=g??"normal";const v=y.find(n=>n.id===i);const I=y[(y.findIndex(n=>n.id===i)+1)%y.length];const P=!h||i==="offline"?0:i==="verySlow"?1:i==="slow"?2:4;const M=c?"Applying\u2026":!h?"Unavailable":i==="normal"?"0 ms":i==="slow"?"+500 ms":i==="verySlow"?"+2000 ms":"Blocked";async function N(n,x=false){if(b.current)return;const k=++f.current;b.current=true;w(true);S(void 0);const T=r?.getSnapshot();try{if(r){if(!T?.available)throw new Error("Device unavailable. Open Network again to reconnect these controls.");await T.onChange(n)}else Z(n);if(u.current&&f.current===k){if(x)s()}}catch(C){if(u.current&&f.current===k)S(C instanceof Error?C.message:String(C))}finally{if(f.current===k){b.current=false;if(u.current)w(false)}}}const q=D?t(d,{style:o.menu,children:t(p,{accessibilityRole:"alert",style:o.error,children:D})}):void 0;return t(K,{id:l,revealToken:a,variant:"strip",dragFromSurface:true,accessibilityLabel:`Move or hide network throttling. ${B?"Active":"Off"}`,accessory:q,children:F(d,{style:[o.row,{width:Math.max(220,Math.min(292,$-64))}],children:[t(O,{testID:"throttling-cycle",accessibilityRole:"button",accessibilityLabel:`Network: ${v.label}. Switch to ${I.label}`,accessibilityState:{disabled:c||!h},disabled:c||!h,onPress:()=>void N(I.id),style:o.signalButton,children:c?t(U,{size:"small",color:e.color.accent}):F(d,{testID:`throttling-signal-${i}`,style:o.signal,children:[[7,12,18,24].map((n,x)=>t(d,{style:{width:4,height:n,borderRadius:2,backgroundColor:x<P?i==="offline"?e.color.danger:e.color.accent:e.color.fillTertiary}},n)),i==="offline"&&t(d,{style:o.slash})]})}),t(d,{style:o.profile,children:t(p,{testID:"throttling-profile",accessibilityLabel:`Connection profile: ${v.label}`,accessibilityLiveRegion:"polite",numberOfLines:1,style:o.profileLabel,children:v.label})}),t(p,{testID:"throttling-status",numberOfLines:1,accessibilityLiveRegion:"polite",style:o.status,children:M}),t(d,{style:o.separator}),t(O,{testID:"throttling-close",accessibilityRole:"button",accessibilityLabel:"Close and turn off throttling",disabled:c,accessibilityState:{disabled:c},onPress:()=>{if(g==="normal")s();else void N("normal",true)},style:[o.action,c&&o.disabled],children:t(p,{style:o.actionText,children:"Close"})})]})})}const o=G.create({row:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,minHeight:48},signalButton:{width:36,minHeight:44,alignItems:"center",justifyContent:"center"},signal:{flexDirection:"row",alignItems:"flex-end",gap:3,height:24},slash:{position:"absolute",width:30,height:2,backgroundColor:e.color.danger,top:11,left:-2,transform:[{rotate:"-45deg"}]},separator:{height:20,width:1,backgroundColor:e.color.separator,marginHorizontal:2},status:{color:e.color.textSecondary,fontSize:10,lineHeight:15,flexShrink:1},profile:{flex:1,flexDirection:"row",alignItems:"center",gap:6,minHeight:44},profileLabel:{color:e.color.text,fontSize:13,fontWeight:"500",flexShrink:1},action:{minHeight:36,minWidth:52,borderRadius:e.radius.input,borderWidth:1,borderColor:e.color.accentBorderStrong,alignItems:"center",justifyContent:"center",paddingHorizontal:10},actionText:{color:e.color.accent,fontSize:12,fontWeight:"600"},disabled:{opacity:.4},menu:{marginVertical:8,padding:6,borderRadius:e.radius.card,borderWidth:1,borderColor:e.color.separator,backgroundColor:e.color.surface,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.25,shadowRadius:16,elevation:8},error:{color:e.color.danger,fontSize:12,lineHeight:18,padding:10}});
1
+ "use strict";import{useEffect as O,useRef as T,useState as L,useSyncExternalStore as m}from"react";import{ActivityIndicator as ee,StyleSheet as te,Text as b,TouchableOpacity as H,View as c,ScrollView as oe,useWindowDimensions as ie,Platform as V}from"react-native";import{FloatingTool as ne,night as t,openFloatingTool as re,persistentStorage as le,registerPersistentFloatingTool as ae}from"@buoy-gg/shared-ui";import{conditionsCanApply as $,getNetworkCondition as A,setNetworkCondition as se,subscribeNetworkConditions as z,getConditionsRevision as q,getNetworkConditions as ce,NETWORK_CONDITIONS as K}from"./store";import{NetworkConditionsControl as de}from"./NetworkConditionsControl";import{jsx as e,jsxs as w}from"react/jsx-runtime";export function createRemoteConditionsSource(){let a;const s=new Set;return{getSnapshot:()=>a,subscribe:l=>{s.add(l);return()=>{s.delete(l)}},update(l){a=l;s.forEach(n=>n())}}}const fe=()=>()=>{};const U=()=>void 0;const S=[{id:"normal",label:"No throttling",detail:"No added delay"},{id:"slow",label:"Slow",detail:"+500 ms before sending"},{id:"verySlow",label:"Very slow",detail:"+2 seconds before sending"},{id:"offline",label:"Offline",detail:"New requests fail"}];const ge={id:"network-throttling",render:a=>e(NetworkFloatingTool,{...a})};export function registerLocalNetworkFloatingTool(){if(typeof __DEV__==="undefined"||!__DEV__)return()=>{};return ae(ge,le)}if(typeof __DEV__!=="undefined"&&__DEV__&&typeof navigator!=="undefined"&&navigator.product==="ReactNative"){registerLocalNetworkFloatingTool()}export function openNetworkFloatingTool(a,s=false){re({id:"network-throttling",render:l=>e(NetworkFloatingTool,{...l,source:a,showControls:s})})}export function NetworkFloatingTool({id:a,revealToken:s,dismiss:l,source:n,showControls:v=false}){m(z,q,q);const G=ce();const J=m(z,A,A);const Q=m(z,$,$);const f=m(n?.subscribe??fe,n?.getSnapshot??U,U);const x=n?f?.profile??null:J;const p=n?f?.available===true:Q;const[g,F]=L(v);O(()=>{F(v)},[v,s]);const[d,k]=L(false);const[C,D]=L();const y=T(false);const u=T(0);const h=T(true);const{width:M,height:X}=ie();O(()=>{h.current=true;return()=>{h.current=false}},[]);O(()=>{u.current+=1;y.current=false;k(false);D(void 0)},[n,f?.targetId]);const _=n?f?.state?.active??(x!==null&&x!=="normal"):G.active;const i=x??"normal";const R=S.find(r=>r.id===i)??{label:K[i].label};const P=S[(S.findIndex(r=>r.id===i)+1)%S.length];const Y=!p||i==="offline"?0:i==="verySlow"?1:i==="slow"?2:4;const Z=d?"Applying\u2026":!p?"Unavailable":i==="normal"?_?"Link set":"0 ms":i==="slow"?"+500 ms":i==="verySlow"?"+2000 ms":i==="offline"?"Blocked":`${Math.round((K[i].downloadBytesPerSecond??0)/1e3)} kB/s`;async function W(r,I=false){if(y.current)return;const N=++u.current;y.current=true;k(true);D(void 0);const B=n?.getSnapshot();try{if(n){if(!B?.available)throw new Error("Device unavailable. Open Network again to reconnect these controls.");await B.onChange(r)}else se(r);if(h.current&&u.current===N){if(I)l()}}catch(E){if(h.current&&u.current===N)D(E instanceof Error?E.message:String(E))}finally{if(u.current===N){y.current=false;if(h.current)k(false)}}}const j=C||g?w(c,{style:o.menu,children:[!!C&&e(b,{accessibilityRole:"alert",style:o.error,children:C}),g&&e(oe,{testID:"throttling-controls-scroll",style:{maxHeight:Math.min(420,X-180)},children:e(de,{remote:n?f??{profile:null,available:false,onChange:async()=>{throw new Error("Device unavailable.")}}:void 0})})]}):void 0;return e(ne,{id:a,revealToken:s,variant:"strip",dragFromSurface:V.OS!=="android"||!g,accessibilityLabel:`Move or hide network throttling. ${_?"Active":"Off"}`,accessory:V.OS==="android"?void 0:j,children:w(c,{style:{width:Math.max(220,Math.min(336,M-64))},children:[w(c,{style:[o.row,{width:Math.max(220,Math.min(336,M-64))}],children:[e(H,{testID:"throttling-cycle",accessibilityRole:"button",accessibilityLabel:`Network: ${R.label}. Switch to ${P.label}`,accessibilityState:{disabled:d||!p},disabled:d||!p,onPress:()=>void W(P.id),style:o.signalButton,children:d?e(ee,{size:"small",color:t.color.accent}):w(c,{testID:`throttling-signal-${i}`,style:o.signal,children:[[7,12,18,24].map((r,I)=>e(c,{style:{width:4,height:r,borderRadius:2,backgroundColor:I<Y?i==="offline"?t.color.danger:t.color.accent:t.color.fillTertiary}},r)),i==="offline"&&e(c,{style:o.slash})]})}),e(c,{style:o.profile,children:e(b,{testID:"throttling-profile",accessibilityLabel:`Connection profile: ${R.label}`,accessibilityLiveRegion:"polite",numberOfLines:1,style:o.profileLabel,children:R.label})}),e(b,{testID:"throttling-status",numberOfLines:1,accessibilityLiveRegion:"polite",style:o.status,children:Z}),e(H,{testID:"throttling-edit",accessibilityRole:"button",accessibilityLabel:g?"Hide speed and link controls":"Edit speed and link state",onPress:()=>F(r=>!r),style:o.action,children:e(b,{style:o.actionText,children:g?"Done":"Edit"})}),e(c,{style:o.separator}),e(H,{testID:"throttling-close",accessibilityRole:"button",accessibilityLabel:"Close and turn off throttling",disabled:d,accessibilityState:{disabled:d},onPress:()=>{if(!_)l();else void W("normal",true)},style:[o.action,d&&o.disabled],children:e(b,{style:o.actionText,children:"Close"})})]}),V.OS==="android"&&j]})})}const o=te.create({row:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,minHeight:48},signalButton:{width:36,minHeight:44,alignItems:"center",justifyContent:"center"},signal:{flexDirection:"row",alignItems:"flex-end",gap:3,height:24},slash:{position:"absolute",width:30,height:2,backgroundColor:t.color.danger,top:11,left:-2,transform:[{rotate:"-45deg"}]},separator:{height:20,width:1,backgroundColor:t.color.separator,marginHorizontal:2},status:{color:t.color.textSecondary,fontSize:10,lineHeight:15,flexShrink:1},profile:{flex:1,flexDirection:"row",alignItems:"center",gap:6,minHeight:44},profileLabel:{color:t.color.text,fontSize:13,fontWeight:"500",flexShrink:1},action:{minHeight:36,minWidth:52,borderRadius:t.radius.input,borderWidth:1,borderColor:t.color.accentBorderStrong,alignItems:"center",justifyContent:"center",paddingHorizontal:10},actionText:{color:t.color.accent,fontSize:12,fontWeight:"600"},disabled:{opacity:.4},menu:{marginVertical:8,padding:6,borderRadius:t.radius.card,borderWidth:1,borderColor:t.color.separator,backgroundColor:t.color.surface,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.25,shadowRadius:16,elevation:8},error:{color:t.color.danger,fontSize:12,lineHeight:18,padding:10}});
@@ -1 +1 @@
1
- "use strict";import{act as l,createElement as u}from"react";import{createRoot as y}from"react-dom/client";import{afterEach as b,beforeEach as B,expect as t,it as c,vi as a}from"vitest";import{NetworkFloatingTool as k,createRemoteConditionsSource as m}from"./NetworkFloatingTool";const n=a.hoisted(()=>({profile:"normal",available:true,listeners:new Set,set:a.fn()}));a.mock("./store",()=>({getNetworkCondition:()=>n.profile,conditionsCanApply:()=>n.available,subscribeNetworkConditions:e=>{n.listeners.add(e);return()=>n.listeners.delete(e)},setNetworkCondition:e=>{n.set(e);n.profile=e;n.listeners.forEach(o=>o())}}));a.mock("@buoy-gg/shared-ui",async()=>({night:(await a.importActual("../../../../shared/src/ui/night/nightTheme")).night,ChevronDown:()=>null,Check:()=>null,openFloatingTool:a.fn(),FloatingTool:({children:e,accessory:o})=>u("div",null,e,o)}));a.mock("react-native",()=>({StyleSheet:{create:e=>e},useWindowDimensions:()=>({width:390,height:844}),View:({children:e,testID:o})=>u("div",{"data-testid":o},e),Text:({children:e,testID:o})=>u("span",{"data-testid":o},e),ActivityIndicator:()=>null,TouchableOpacity:({children:e,onPress:o,disabled:r,testID:s,accessibilityLabel:C})=>u("button",{onClick:o,disabled:r,"data-testid":s,"aria-label":C},e)}));let w;let d;const h=a.fn();B(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;n.profile="normal";n.available=true;n.set.mockClear();h.mockClear();d=document.createElement("div");w=y(d)});b(()=>l(()=>w.unmount()));const g=e=>d.querySelector(`[data-testid="${e}"]`);const p=async e=>l(async()=>g(e).click());const i=()=>d.querySelector('[data-testid="throttling-status"]')?.textContent;function f(e){l(()=>w.render(u(k,{id:"network-throttling",revealToken:1,dismiss:h,source:e})))}async function v(e){const o=["normal","slow","verySlow","offline"];const r=(o.indexOf(e)-o.indexOf(n.profile)+o.length)%o.length;for(let s=0;s<r;s++)await p("throttling-cycle")}c("cycles and applies every profile immediately, including wrapping to normal",async()=>{f();for(const[e,o]of[["slow","+500 ms"],["verySlow","+2000 ms"],["offline","Blocked"],["normal","0 ms"]]){await p("throttling-cycle");t(n.profile).toBe(e);t(d.querySelector(`[data-testid="throttling-signal-${e}"]`)).not.toBeNull();t(i()).toBe(o)}t(n.set).toHaveBeenCalledTimes(4)});c("keeps the profile label informational when tapped",async()=>{f();await p("throttling-profile");t(n.set).not.toHaveBeenCalled();t(n.profile).toBe("normal");t(g("throttling-profile").closest("button")).toBeNull()});c("changes active profiles and stops before dismissal",async()=>{n.profile="slow";f();await v("offline");t(n.profile).toBe("offline");await p("throttling-close");t(n.profile).toBe("normal");t(h).toHaveBeenCalledOnce()});c("reflects external changes and disables cycling when account admission is revoked",()=>{f();l(()=>{n.profile="offline";n.listeners.forEach(e=>e())});t(i()).toBe("Blocked");l(()=>{n.profile="normal";n.available=false;n.listeners.forEach(e=>e())});t(i()).toBe("Unavailable");t(g("throttling-cycle").disabled).toBe(true)});c("keeps remote failures visible and does not claim a profile was applied",async()=>{const e=m();const o=a.fn().mockRejectedValue(new Error("Connection lost"));e.update({profile:"normal",available:true,onChange:o});f(e);await v("slow");t(d.textContent).toContain("Connection lost");t(i()).toBe("0 ms");t(n.set).not.toHaveBeenCalled()});c("prevents duplicate remote operations and follows confirmed snapshots",async()=>{const e=m();let o;const r=a.fn(()=>new Promise(s=>{o=s}));e.update({profile:"normal",available:true,onChange:r});f(e);await p("throttling-cycle");await p("throttling-cycle");t(r).toHaveBeenCalledOnce();t(i()).toBe("Applying\u2026");await l(async()=>o());t(i()).toBe("0 ms");l(()=>e.update({profile:"slow",available:true,onChange:r}));t(i()).toBe("+500 ms");l(()=>e.update(void 0));t(i()).toBe("Unavailable")});c("ignores a previous device's completion after switching devices",async()=>{const e=m();let o;e.update({targetId:"first",profile:"normal",available:true,onChange:()=>new Promise((r,s)=>{o=s})});f(e);await v("slow");l(()=>e.update({targetId:"second",profile:"normal",available:true,onChange:a.fn()}));await l(async()=>o(new Error("Old device failed")));t(d.textContent).not.toContain("Old device failed");t(i()).toBe("0 ms");t(g("throttling-profile").textContent).toBe("No throttling")});c("keeps the strip open when stopping a remote device fails",async()=>{const e=m();e.update({profile:"offline",available:true,onChange:a.fn().mockRejectedValue(new Error("Could not stop"))});f(e);await p("throttling-close");t(h).not.toHaveBeenCalled();t(i()).toBe("Blocked");t(d.textContent).toContain("Could not stop")});
1
+ "use strict";import{act as c,createElement as u}from"react";import{createRoot as y}from"react-dom/client";import{afterEach as b,beforeEach as k,expect as t,it as d,vi as a}from"vitest";import{NetworkFloatingTool as B,createRemoteConditionsSource as m}from"./NetworkFloatingTool";const n=a.hoisted(()=>({platform:"web",profile:"normal",available:true,listeners:new Set,set:a.fn()}));a.mock("./store",()=>({getConditionsRevision:()=>0,getNetworkConditions:()=>({active:n.profile!=="normal",capabilities:{netInfo:{supported:false},expoNetwork:{supported:false}}}),NETWORK_CONDITIONS:{fast4g:{label:"Fast 4G",downloadBytesPerSecond:1012500}},getNetworkCondition:()=>n.profile,conditionsCanApply:()=>n.available,subscribeNetworkConditions:e=>{n.listeners.add(e);return()=>n.listeners.delete(e)},setNetworkCondition:e=>{n.set(e);n.profile=e;n.listeners.forEach(o=>o())}}));a.mock("@buoy-gg/shared-ui",async()=>({night:(await a.importActual("../../../../shared/src/ui/night/nightTheme")).night,ChevronDown:()=>null,Check:()=>null,openFloatingTool:a.fn(),FloatingTool:({children:e,accessory:o})=>u("div",null,e,o)}));a.mock("react-native",()=>({Platform:{get OS(){return n.platform}},StyleSheet:{create:e=>e},useWindowDimensions:()=>({width:390,height:844}),View:({children:e,testID:o})=>u("div",{"data-testid":o},e),Text:({children:e,testID:o})=>u("span",{"data-testid":o},e),ScrollView:({children:e})=>u("div",null,e),ActivityIndicator:()=>null,TouchableOpacity:({children:e,onPress:o,disabled:r,testID:s,accessibilityLabel:h})=>u("button",{onClick:o,disabled:r,"data-testid":s,"aria-label":h},e)}));let v;let p;const g=a.fn();k(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;n.platform="web";n.profile="normal";n.available=true;n.set.mockClear();g.mockClear();p=document.createElement("div");v=y(p)});b(()=>c(()=>v.unmount()));const w=e=>p.querySelector(`[data-testid="${e}"]`);const l=async e=>c(async()=>w(e).click());const i=()=>p.querySelector('[data-testid="throttling-status"]')?.textContent;function f(e){c(()=>v.render(u(B,{id:"network-throttling",revealToken:1,dismiss:g,source:e})))}async function C(e){const o=["normal","slow","verySlow","offline"];const r=(o.indexOf(e)-o.indexOf(n.profile)+o.length)%o.length;for(let s=0;s<r;s++)await l("throttling-cycle")}d("cycles and applies every profile immediately, including wrapping to normal",async()=>{f();for(const[e,o]of[["slow","+500 ms"],["verySlow","+2000 ms"],["offline","Blocked"],["normal","0 ms"]]){await l("throttling-cycle");t(n.profile).toBe(e);t(p.querySelector(`[data-testid="throttling-signal-${e}"]`)).not.toBeNull();t(i()).toBe(o)}t(n.set).toHaveBeenCalledTimes(4)});d("keeps the profile label informational when tapped",async()=>{f();await l("throttling-profile");t(n.set).not.toHaveBeenCalled();t(n.profile).toBe("normal");t(w("throttling-profile").closest("button")).toBeNull()});d("changes active profiles and stops before dismissal",async()=>{n.profile="slow";f();await C("offline");t(n.profile).toBe("offline");await l("throttling-close");t(n.profile).toBe("normal");t(g).toHaveBeenCalledOnce()});d("reflects external changes and disables cycling when account admission is revoked",()=>{f();c(()=>{n.profile="offline";n.listeners.forEach(e=>e())});t(i()).toBe("Blocked");c(()=>{n.profile="normal";n.available=false;n.listeners.forEach(e=>e())});t(i()).toBe("Unavailable");t(w("throttling-cycle").disabled).toBe(true)});d("keeps remote failures visible and does not claim a profile was applied",async()=>{const e=m();const o=a.fn().mockRejectedValue(new Error("Connection lost"));e.update({profile:"normal",available:true,onChange:o});f(e);await C("slow");t(p.textContent).toContain("Connection lost");t(i()).toBe("0 ms");t(n.set).not.toHaveBeenCalled()});d("prevents duplicate remote operations and follows confirmed snapshots",async()=>{const e=m();let o;const r=a.fn(()=>new Promise(s=>{o=s}));e.update({profile:"normal",available:true,onChange:r});f(e);await l("throttling-cycle");await l("throttling-cycle");t(r).toHaveBeenCalledOnce();t(i()).toBe("Applying\u2026");await c(async()=>o());t(i()).toBe("0 ms");c(()=>e.update({profile:"slow",available:true,onChange:r}));t(i()).toBe("+500 ms");c(()=>e.update(void 0));t(i()).toBe("Unavailable")});d("ignores a previous device's completion after switching devices",async()=>{const e=m();let o;e.update({targetId:"first",profile:"normal",available:true,onChange:()=>new Promise((r,s)=>{o=s})});f(e);await C("slow");c(()=>e.update({targetId:"second",profile:"normal",available:true,onChange:a.fn()}));await c(async()=>o(new Error("Old device failed")));t(p.textContent).not.toContain("Old device failed");t(i()).toBe("0 ms");t(w("throttling-profile").textContent).toBe("No throttling")});d("keeps the strip open when stopping a remote device fails",async()=>{const e=m();e.update({profile:"offline",available:true,onChange:a.fn().mockRejectedValue(new Error("Could not stop"))});f(e);await l("throttling-close");t(g).not.toHaveBeenCalled();t(i()).toBe("Blocked");t(p.textContent).toContain("Could not stop")});d.each(["web","android"])("opens the full remote control on %s and forwards v2 changes",async e=>{n.platform=e;const o=m();const r=a.fn().mockResolvedValue(void 0);const s=a.fn().mockResolvedValue(void 0);const h={version:2,active:false,connection:"real",capabilities:{netInfo:{supported:true},expoNetwork:{supported:false}}};o.update({profile:"normal",available:true,onChange:r,onConnectionChange:s,state:h});f(o);await l("throttling-edit");await l("buoy-network-conditions");await l("buoy-network-condition-fast4g");t(r).toHaveBeenCalledExactlyOnceWith("fast4g");t(i()).toBe("0 ms");c(()=>o.update({profile:"fast4g",available:true,onChange:r,onConnectionChange:s,state:{...h,active:true}}));t(i()).toBe("1013 kB/s");await l("buoy-network-link-state");await l("buoy-network-link-cellular");t(s).toHaveBeenCalledExactlyOnceWith("cellular");await l("throttling-edit");t(w("buoy-network-conditions")).toBeNull();t(i()).toBe("1013 kB/s")});
@@ -0,0 +1 @@
1
+ "use strict";import{useSyncExternalStore as l}from"react";import{getEffectiveNetworkConnection as d,getConditionsRevision as i,subscribeNetworkConditions as m}from"../store";import{maskConnection as b}from"./patchNetwork";export function wrapNetInfoApi(o){const s=e=>b(e,d());const n={};for(const e of["fetch","refresh"]){const t=o[e];n[e]=(...r)=>Promise.resolve(t(...r)).then(s)}const u=o.addEventListener;n.addEventListener=e=>u(t=>e(s(t)));const a=o.useNetInfo;n.useNetInfo=(...e)=>{const t=a(...e);l(m,i,i);return s(t)};const c=[];try{for(const[e,t]of Object.entries(n)){for(const r of new Set([o,o.default].filter(Boolean))){const f=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(r,e,{configurable:true,writable:true,enumerable:true,value:t});c.push(()=>{if(f)Object.defineProperty(r,e,f);else delete r[e]})}}}catch(e){c.reverse().forEach(t=>t());throw e}}
@@ -0,0 +1 @@
1
+ "use strict";export function maskConnection(t,n,i=false){if(n==="auto"||n==="real")return{...t};const r=n==="offline"?"none":n==="cellular"?"cellular":"wifi";return{type:i?r.toUpperCase():r,...!i?{details:n==="offline"?null:{isConnectionExpensive:n==="cellular",...n==="cellular"?{cellularGeneration:null,carrier:null}:{}}}:{},isConnected:n!=="offline",isInternetReachable:n!=="offline"&&n!=="noInternet"}}export function patchConnectionState(t,n,i,r={}){const o=r.eventName??"netInfo.networkStatusDidChange";if((t.eventEmitter.listenerCount?.(o)??0)>0)throw new Error("Link hook loaded too late. Load it before app code, then reload.");const y=t.getCurrentState;const s=t.eventEmitter.addListener;const l=new Set;let a={type:r.expo?"UNKNOWN":"unknown",isConnected:null,isInternetReachable:null};let u=0;let f=false;let C=n();const d=e=>maskConnection(e,n(),r.expo);const p=()=>{if(!f)l.forEach(e=>e(d(a)))};const x=s.call(t.eventEmitter,o,e=>{u++;a=e;p()});const h=async(...e)=>{const c=u;const b=await y.apply(r.receiver??t,e);if(e[0])return d(b);if(c===u)a=b;return d(a)};const E=(e,c)=>{if(e!==o)return s.call(t.eventEmitter,e,c);l.add(c);return{remove:()=>{l.delete(c)}}};let w;const S=()=>{f=true;try{w?.()}finally{try{x.remove()}finally{l.clear();if(t.getCurrentState===h)t.getCurrentState=y;if(t.eventEmitter.addListener===E)t.eventEmitter.addListener=s}}};try{t.getCurrentState=h;t.eventEmitter.addListener=E;w=i(()=>{const e=n();if(e!==C){C=e;p()}})}catch(e){S();throw e}void h(...r.expo?[]:[void 0]).then(p).catch(()=>{});return()=>{if(f)return;try{l.forEach(e=>e({...a}))}finally{S()}}}
@@ -0,0 +1 @@
1
+ "use strict";import{realNow as w}from"../utils/realNow";import{waitBeforeDispatch as B,throwIfAborted as m}from"./wait";export const chunkSize=e=>Math.max(1,Math.min(16384,Math.floor(e*.02)));export const utf8Length=e=>new TextEncoder().encode(e).byteLength;export function bodyByteLength(e){if(e==null)return 0;if(typeof e==="string")return utf8Length(e);if(e instanceof ArrayBuffer)return e.byteLength;if(ArrayBuffer.isView(e))return e.byteLength;if(typeof Blob!=="undefined"&&e instanceof Blob)return e.size;if(typeof URLSearchParams!=="undefined"&&e instanceof URLSearchParams)return utf8Length(e.toString());return null}export async function paceByteCount(e,f,o,d){const y=chunkSize(f);const a=w();for(let i=0;i<e;){const b=Math.min(y,e-i);await B(Math.max(0,a+(i+b)/f*1e3-w()),o);m(o);i+=b;d?.(i,e)}}export function uploadBodySize(e,f){try{const o=typeof e==="object"&&"method"in e?e:void 0;const d=f?.body!==void 0?f.body:o&&"_bodyInit"in o?o._bodyInit:o?.body;return uploadSize(d)}catch{return L(0)}}function L(e){return{knownBytes:e,status:e>0?"partial":"not-applied",note:e>0?"upload cap partial: size unknown":"upload cap not applied: size unknown"}}export function uploadSize(e){let f=0;try{const o=bodyByteLength(e);if(o!==null)return{knownBytes:o,status:"applied"};if(e&&typeof e==="object"){const d=e;const y=Array.isArray(d._parts)?d._parts:typeof FormData!=="undefined"&&e instanceof FormData&&d.entries?d.entries():void 0;if(y){for(const[,a]of y){try{const i=bodyByteLength(a);if(i!==null)f+=i;else if(a&&typeof a==="object"&&"uri"in a&&"size"in a&&typeof a.size==="number"&&Number.isSafeInteger(a.size)&&a.size>=0)f+=a.size}catch{}}}}}catch{}return L(f)}export function createBytePacer(e){let f=0;return async(o,d)=>{const y=o/e*1e3;const a=w();const i=Math.max(0,y-f);if(i>0)await B(i,d);m(d);f=Math.min(chunkSize(e)/e*1e3,Math.max(0,f+w()-a-y))}}export function pacedStream(e,f,o,d){const y=createBytePacer(f);let a;const i=()=>{a?.releaseLock();a=void 0};const b=t=>{void(a?a.cancel(t):e.cancel(t)).catch(()=>{});i()};const l=new AbortController;let r;let n=0;let s=false;let u;const c=(t,p=false)=>{if(s)return;s=true;o?.removeEventListener("abort",h);l.abort();r=void 0;if(p)u.error(t);else{i();u.close()}d?.(null,t)};const h=()=>{const t=o?.reason!==void 0?o.reason:Object.assign(new Error("The request was aborted."),{name:"AbortError"});c(t,true);b(t)};return new ReadableStream({start(t){u=t;o?.addEventListener("abort",h,{once:true});if(o?.aborted)h()},async pull(){try{if(!r||n===r.byteLength){const x=await(a??=e.getReader()).read();if(s)return;if(x.done){c();return}r=x.value;n=0}const t=Math.min(chunkSize(f),r.byteLength-n);const p=r.subarray(n,n+t);await y(t,l.signal);if(s)return;n+=t;d?.(p);u.enqueue(p)}catch(t){if(!s){c(t,true);b(t)}}},cancel(t){if(!s){s=true;o?.removeEventListener("abort",h);l.abort();r=void 0;d?.(null,t??new Error("Body read stopped."))}b(t)}},{highWaterMark:0})}export function paceResponse(e,f,o,d,y=false){if(y||[204,205,304].includes(e.status)||e.body===null){d?.(null);return e}let a;let i=false;const b=()=>{if(!a){let r;let n=false;const s=new ReadableStream({async pull(u){i=true;try{if(e.body?.getReader){r??=e.body.getReader();const c=await r.read();if(n)return;if(c.done){n=true;r.releaseLock();r=void 0;u.close()}else u.enqueue(c.value)}else{const c=new Uint8Array(await e.arrayBuffer());if(n)return;u.enqueue(c);n=true;u.close()}}catch(c){if(!n){n=true;r?.releaseLock();r=void 0;u.error(c)}}},cancel(u){i=true;n=true;const c=r?r.cancel(u):e.body?.cancel?.(u);r?.releaseLock();r=void 0;return c}},{highWaterMark:0});a=pacedStream(s,f,o,d)}return a};const l=async(r=true)=>{if(i||a?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");i=true;const n=b().getReader();const s=[];let u=0;try{for(;;){const t=await n.read();if(t.done)break;if(r){s.push(t.value);u+=t.value.byteLength}}}finally{n.releaseLock()}const c=new Uint8Array(u);let h=0;for(const t of s){c.set(t,h);h+=t.byteLength}return c};return new Proxy(e,{get(r,n){if(n==="body")return b();if(n==="bodyUsed")return i||e.bodyUsed;if(n==="arrayBuffer")return async()=>(await l()).buffer;if(n==="bytes")return l;if(n==="text")return async()=>new TextDecoder().decode(await l());if(n==="json")return async()=>JSON.parse(new TextDecoder().decode(await l()));if(n==="blob")return async()=>{if(i||a?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");m(o);let u=false;try{new Blob([new Uint8Array(0)]);u=true}catch{}if(u)return new Blob([await l()],{type:r.headers.get("content-type")??""});const c=r.clone();let h;Object.defineProperty(c,"arrayBuffer",{configurable:true,value:async()=>{if(c.body&&!c.body.locked)void c.body.cancel().catch(()=>{});h??=l();return(await h).buffer}});try{const t=c.blob();void t.catch(()=>{});await(h??l(false));m(o);return await t}finally{if(c.body&&!c.body.locked)void c.body.cancel().catch(()=>{})}};if(n==="formData")return async()=>{const u=await l();return new Response(u,{headers:r.headers}).formData()};if(n==="clone")return()=>{if(i||a?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");return paceResponse(r.clone(),f,o)};const s=Reflect.get(r,n,r);return typeof s==="function"?s.bind(r):s}})}
@@ -0,0 +1 @@
1
+ "use strict";export const NETWORK_CONDITIONS={normal:{label:"Normal",delayMs:0},offline:{label:"Offline (requests)",delayMs:0},slow:{label:"Slow (+500 ms)",delayMs:500},verySlow:{label:"Very slow (+2000 ms)",delayMs:2e3},slow3g:{label:"Slow 3G",delayMs:2e3,downloadBytesPerSecond:5e4,uploadBytesPerSecond:5e4},slow4g:{label:"Slow 4G",delayMs:562.5,downloadBytesPerSecond:18e4,uploadBytesPerSecond:84375},fast4g:{label:"Fast 4G",delayMs:165,downloadBytesPerSecond:1012500,uploadBytesPerSecond:168750}};export const CONNECTIONS=["auto","real","offline","wifi","cellular","noInternet"];export const CONDITIONS_SCOPE={download:"Paces bytes to the app in JS. The socket stays at its real speed.",upload:"Waits before send for known body bytes. Unknown sizes pass through with latency only. Multipart overhead is not counted. Each call marks a partial or skipped cap. Upload time is simulated; the socket is not paced.",transports:"Affects global fetch and RN XHR. Offline also drops WebSockets; speeds don't slow them. Native images, native SDKs and file transfers are not affected."};
@@ -0,0 +1 @@
1
+ "use strict";export function chooseConditionsSnapshot(i,r){if(!i)return null;if(!r||r.runtimeId!==i.runtimeId||r.revision<i.revision)return i;return r}
@@ -1 +1 @@
1
- "use strict";import{hasAccountAccess as n,subscribeAccountAccess as i}from"@buoy-gg/shared-ui";import{addNetworkListener as l,startNetworkListener as a,getNetworkListenerCount as c,stopNetworkListener as d}from"../utils/networkListener";export const NETWORK_CONDITIONS={normal:{label:"Normal",delayMs:0},offline:{label:"Offline (requests)",delayMs:0},slow:{label:"Slow (+500 ms)",delayMs:500},verySlow:{label:"Very slow (+2000 ms)",delayMs:2e3}};export const networkConditionsRuntimeId=`${Date.now()}-${Math.random().toString(36).slice(2)}`;let o="normal";let t;const r=new Set;export const conditionsCanApply=()=>typeof __DEV__!=="undefined"&&__DEV__&&n();export const getNetworkCondition=()=>o;export const subscribeNetworkConditions=e=>{r.add(e);return()=>{r.delete(e)}};export function setNetworkCondition(e){if(typeof e!=="string"||!Object.prototype.hasOwnProperty.call(NETWORK_CONDITIONS,e)){throw new Error("Choose normal, offline, slow, or verySlow.")}if(e!=="normal"&&!conditionsCanApply()){throw new Error("Network conditions require an admitted account and a development build.")}if(e===o)return o;if(e!=="normal"&&!t){a();t=l(()=>{})}else if(e==="normal"){t?.();t=void 0;if(c()===0)d()}o=e;r.forEach(s=>s());return o}export function snapshotNetworkCondition(e){if(o==="normal"||!conditionsCanApply()||!/^https?:\/\//i.test(e))return;return Object.freeze({profile:o,delayMs:NETWORK_CONDITIONS[o].delayMs})}i(()=>{if(!n())setNetworkCondition("normal");r.forEach(e=>e())});
1
+ "use strict";import{hasAccountAccess as u,subscribeAccountAccess as w}from"@buoy-gg/shared-ui";import{addNetworkListener as N,startNetworkListener as C,getNetworkListenerCount as k,stopNetworkListener as h}from"../utils/networkListener";import{NETWORK_CONDITIONS as d,CONNECTIONS as m,CONDITIONS_SCOPE as x}from"./profiles";export{NETWORK_CONDITIONS,CONDITIONS_SCOPE}from"./profiles";const c={netInfo:{supported:false,reason:"Load the NetInfo hook before app code."},expoNetwork:{supported:false,reason:"Load the Expo Network hook before app code."}};let r="auto";let l=0;export const getNetworkConnection=()=>r;export const getConditionsRevision=()=>l;export const getEffectiveNetworkConnection=()=>!conditionsCanApply()?"real":r==="auto"?n==="offline"?"offline":"real":r;export const networkConditionsActive=()=>n!=="normal"||!["auto","real"].includes(r);export function setConnectionSupport(o,e){c[o]=e;l++;s.forEach(t=>t())}export function getNetworkConditions(){const o=d[n];return{version:2,runtimeId:networkConditionsRuntimeId,revision:l,profile:n,connection:r,available:conditionsCanApply(),active:networkConditionsActive(),delayMs:o.delayMs,downloadBytesPerSecond:o.downloadBytesPerSecond??null,uploadBytesPerSecond:o.uploadBytesPerSecond??null,capabilities:{...c,fetch:"JS body delivery",xhr:"RN progress and body delivery",upload:"time-simulated",webSocket:"offline only",nativeImages:false,nativeModules:false},scope:x}}export function setNetworkConditions(o){if(!o||typeof o!=="object"||Array.isArray(o))throw new Error("Choose a speed or link state.");const e=o;if(Object.keys(e).some(a=>a!=="profile"&&a!=="connection")||!("profile"in e)&&!("connection"in e))throw new Error("Choose a speed or link state.");const t="profile"in e?e.profile:n;const i="connection"in e?e.connection:t==="normal"&&"profile"in e?"auto":r;if(typeof t!=="string"||!Object.prototype.hasOwnProperty.call(d,t))throw new Error("Choose a valid speed profile.");if(!m.includes(i))throw new Error("Choose a valid link state.");if((t!=="normal"||!["auto","real"].includes(i))&&!conditionsCanApply())throw new Error("Use a signed-in account and a dev build.");if(!["auto","real"].includes(i)&&!c.netInfo.supported&&!c.expoNetwork.supported)throw new Error("Load a link hook before app code.");if(t===n&&i===r)return getNetworkConditions();const f=t!=="normal";if(f&&!p){C();p=N(()=>{})}if(!f){p?.();p=void 0;if(k()===0)h()}n=t;r=i;l++;s.forEach(a=>a());return getNetworkConditions()}export const networkConditionsRuntimeId=`${Date.now()}-${Math.random().toString(36).slice(2)}`;let n="normal";let p;const s=new Set;export const conditionsCanApply=()=>typeof __DEV__!=="undefined"&&__DEV__&&u();export const getNetworkCondition=()=>n;export const subscribeNetworkConditions=o=>{s.add(o);return()=>{s.delete(o)}};export function setNetworkCondition(o){return setNetworkConditions({profile:o}).profile}export function snapshotNetworkCondition(o){if(n==="normal"||!conditionsCanApply()||!/^https?:\/\//i.test(o))return;const{label:e,...t}=d[n];return Object.freeze({profile:n,...t})}w(()=>{if(!u())setNetworkCondition("normal");s.forEach(o=>o())});