@buoy-gg/console 7.0.55 → 7.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/web/index.mjs +4 -4
- package/package.json +2 -2
package/lib/web/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var ze=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var jt=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:true})},De=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rt(t))!It.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=Ht(t,o))||n.enumerable});return e},zt=(e,t,r)=>(De(e,t,"default"),r&&De(r,t,"default"));var Pe=process.env.NODE_ENV!=="production";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{ConsoleIcon as We,CONSOLE_ICON_COLOR as Fe}from"@buoy-gg/shared-ui/web";import{JsModal as Dt}from"@buoy-gg/shared-ui/web";import{useCallback as fe,useState as z}from"react";import{useMemo as Pt,useSyncExternalStore as Wt}from"react";import{getAccountAccess as Ft,hasAccountAccess as _}from"@buoy-gg/shared-ui/web";import*as Vt from"react";import{createToolStore as Gt,persistentStorage as Z}from"@buoy-gg/shared-ui/web";function X(e,t=2048){return e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`}function ge(e,t,r){if(e===null)return null;if(typeof e=="string")return X(e);if(typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:String(e);if(typeof e>"u")return"undefined";if(typeof e=="bigint")return`${String(e)}n`;if(typeof e=="function")return`\u0192 ${e.name||"(anonymous)"}`;if(typeof e=="symbol")return e.toString();if(e instanceof Error)return{name:e.name,message:X(e.message),stack:e.stack?X(e.stack,4*1024):e.stack};if(t>=6)return Array.isArray(e)?"[Array]":"{\u2026}";let n=e;if(r.has(n))return"[Circular]";r.add(n);try{if(Array.isArray(e)){let i=e.slice(0,100).map(a=>ge(a,t+1,r));return e.length>100&&i.push(`\u2026 ${e.length-100} more`),i}let o={};for(let i of Object.keys(n).slice(0,100))try{o[i]=ge(n[i],t+1,r)}catch{o[i]="[Unserializable]"}return o}finally{r.delete(n)}}function Ve(e){let t=new WeakSet;return e.map(r=>ge(r,0,t))}var _t=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/,Kt=/consoleLogStore/;function Ge(e){return e.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function Ut(e){return e.func&&_t.test(Ge(e.func))?true:!!(e.file&&Kt.test(e.file))}function Yt(e){let t=[];for(let r of e.split(`
|
|
1
|
+
"use client";var ze=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var jt=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:true})},De=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rt(t))!It.call(e,o)&&o!==r&&ze(e,o,{get:()=>t[o],enumerable:!(n=Ht(t,o))||n.enumerable});return e},zt=(e,t,r)=>(De(e,t,"default"),r&&De(r,t,"default"));var Pe=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{ConsoleIcon as We,CONSOLE_ICON_COLOR as Fe}from"@buoy-gg/shared-ui/web";import{JsModal as Dt}from"@buoy-gg/shared-ui/web";import{useCallback as fe,useState as z}from"react";import{useMemo as Pt,useSyncExternalStore as Wt}from"react";import{getAccountAccess as Ft,hasAccountAccess as _}from"@buoy-gg/shared-ui/web";import*as Vt from"react";import{createToolStore as Gt,persistentStorage as Z}from"@buoy-gg/shared-ui/web";function X(e,t=2048){return e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`}function ge(e,t,r){if(e===null)return null;if(typeof e=="string")return X(e);if(typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:String(e);if(typeof e>"u")return"undefined";if(typeof e=="bigint")return`${String(e)}n`;if(typeof e=="function")return`\u0192 ${e.name||"(anonymous)"}`;if(typeof e=="symbol")return e.toString();if(e instanceof Error)return{name:e.name,message:X(e.message),stack:e.stack?X(e.stack,4*1024):e.stack};if(t>=6)return Array.isArray(e)?"[Array]":"{\u2026}";let n=e;if(r.has(n))return"[Circular]";r.add(n);try{if(Array.isArray(e)){let i=e.slice(0,100).map(a=>ge(a,t+1,r));return e.length>100&&i.push(`\u2026 ${e.length-100} more`),i}let o={};for(let i of Object.keys(n).slice(0,100))try{o[i]=ge(n[i],t+1,r)}catch{o[i]="[Unserializable]"}return o}finally{r.delete(n)}}function Ve(e){let t=new WeakSet;return e.map(r=>ge(r,0,t))}var _t=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/,Kt=/consoleLogStore/;function Ge(e){return e.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function Ut(e){return e.func&&_t.test(Ge(e.func))?true:!!(e.file&&Kt.test(e.file))}function Yt(e){let t=[];for(let r of e.split(`
|
|
2
2
|
`)){let n=r.trim();if(!n||n==="Error")continue;let o=n.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(o){t.push({func:o[1],file:o[2],line:Number(o[3])});continue}if(o=n.match(/^at\s+(.+?):(\d+):(\d+)$/),o){t.push({file:o[1],line:Number(o[2])});continue}if(o=n.match(/^(.*?)@(.+?):(\d+):(\d+)$/),o){t.push({func:o[1]||void 0,file:o[2],line:Number(o[3])});continue}}return t}function Jt(e){if(!e)return;let t=e.split("?")[0];return t.split("/").pop()||t}function qt(e){if(!e)return;let t=Ge(e);if(!(!t||t==="<anonymous>"||t==="anonymous"))return t}function Qt(e){if(e)for(let t of e.split(`
|
|
3
3
|
`)){let r=t.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(r)return r[1]}}function Zt(e,t){let r=Qt(t),n;e&&(n=Yt(e).find(s=>!Ut(s)));let o=qt(n?.func),i=Jt(n?.file),a=n?.line,l=i&&a!=null?`${i}:${a}`:void 0;if(!(!r&&!o&&!l))return{component:r,functionName:o,callSite:l,file:i,line:a}}function Xt(e,t){return t==="off"||!e?t==="off"?null:"\u2014unknown\u2014":t==="component"?e.component??e.functionName??e.callSite??"\u2014unknown\u2014":t==="function"?e.functionName??e.callSite??e.component??"\u2014anonymous\u2014":e.callSite??e.functionName??"\u2014unknown\u2014"}function er(e,t){return e?t==="component"?e.component?e.component:e.functionName?`\u0192 ${e.functionName}`:e.callSite??"(unknown)":t==="function"?e.functionName?e.functionName:e.callSite??"(anonymous)":t==="callsite"?e.functionName&&e.callSite?`${e.functionName} \xB7 ${e.callSite}`:e.callSite??(e.functionName?`\u0192 ${e.functionName}`:"(unknown)"):"":"(unknown)"}function tr(e){let t=0;for(let r=0;r<e.length;r++)t=t*31+e.charCodeAt(r)|0;return Math.abs(t)}function _e(e){return`hsl(${tr(e)%360}, 70%, 66%)`}function Ke(e){switch(e){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}var Ue=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"],rr=new Set(["error","warn","trace","assert"]),or={error:"error",assert:"error",warn:"warning",debug:"verbose",log:"info",info:"info",trace:"info",dir:"info",table:"info",group:"info",groupCollapsed:"info",groupEnd:"info"},nr=1e3,x=Gt({id:"console",max:nr,order:"append",coalesce:"frame"}),le=false,pe=false,ae=false,me={};function Ye(e){if(typeof e=="string")return e;if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="function")return`\u0192 ${e.name||"(anonymous)"}`;try{return JSON.stringify(e)}catch{return String(e)}}function ir(e){return e.map(Ye).join(" ")}function lr(e){if(e)return e.split(`
|
|
4
4
|
`).slice(3).join(`
|
|
@@ -12,6 +12,6 @@ ${Je(o.componentStack)}`:"";be({id:x.allocId(),method:"error",level:"error",args
|
|
|
12
12
|
`)}function pr(e){let t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]",r=he(e.name??void 0,e.originalMessage??e.message??"Unknown error"),n=ye(`${t} ${r}`),o=typeof e.componentStack=="string"&&e.componentStack.trim()?`
|
|
13
13
|
|
|
14
14
|
This error is located at:
|
|
15
|
-
${Je(e.componentStack)}`:"",i=`${t} ${r}${o}`;be({id:x.allocId(),method:"error",level:"error",args:[t,r,...o?[o.trim()]:[]],message:i,timestamp:Date.now(),stack:gr(e),fatal:true},n)}function mr(){let e=globalThis.RN$registerExceptionListener;return typeof e!="function"?false:(e(t=>{try{ae||pr(t)}catch{}}),true)}function Ze(){if(pe)return;let e=mr(),t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!="function"){pe=e;return}pe=true;let r=typeof t.getGlobalHandler=="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((n,o)=>{try{ae||fr(n,o)}catch{}typeof r=="function"&&r(n,o)})}function se(){if(Ft().status!=="locked"&&(ae=false,Ze(),!le)){le=true;for(let e of Ue){let t=console[e];typeof t=="function"&&(me[e]=t,console[e]=function(...r){ur(e,r),t.apply(console,r)})}}}function ve(){if(ae=true,!!le){le=false;for(let e of Ue){let t=me[e];t&&(console[e]=t),delete me[e]}}}function ce(e){return x.subscribe(e)}function K(){return x.getSnapshot()}function ee(){ke(),x.clear()}function hr(e){x.set(e)}function yr(e){return x.onClear(e)}var Xe="@react_buoy_console_preserve",we="@react_buoy_console_buffer",br=600,R=false,te=false,U=0,Y=Promise.resolve(),xe=new Set,ue=null;function et(){for(let e of xe)e()}function tt(){!R||!_()||(ue&&clearTimeout(ue),ue=setTimeout(rt,br))}async function rt(){if(ue=null,!(!R||!_()))try{let e=x.getSnapshot().map(r=>({...r,args:Ve(r.args)})),t=U;Y=Y.then(async()=>{t!==U||!R||!_()||await Z.setItem(we,JSON.stringify(e))}).catch(()=>{}),await Y}catch{}}async function ke(){U++,te=false;try{Y=Y.then(()=>Z.removeItem(we)).catch(()=>{}),await Y}catch{}}async function ot(){if(te||!_())return;te=true;let e=U;try{R=await Z.getItem(Xe)==="true"}catch{R=false}if(e!==U||!_()){te=false;return}if(et(),!R){await ke();return}try{let t=await Z.getItem(we);if(e!==U||!_()){te=false;return}if(t){let r=JSON.parse(t);Array.isArray(r)&&r.length&&(x.update(n=>[...r,...n]),x.bumpIdAbove(Math.max(...r.map(n=>n.id))))}}catch{}}function Se(){return R}function nt(e){R!==e&&(R=e,et(),Z.setItem(Xe,String(e)).catch(()=>{}),e?rt():ke())}function it(e){return xe.add(e),()=>{xe.delete(e)}}var Ce={verbose:true,info:true,warning:true,error:true},Te={...Ce,verbose:false},vr=/^([\w-]+):(.+)$/,wr=/^\/(.+)\/$/;function xr(e){let t=[];for(let r of e.split(/\s+/)){if(!r)continue;let n=r,o=false;n.startsWith("-")&&n.length>1&&(o=true,n=n.slice(1));let i=n.match(vr);if(i){t.push({key:i[1].toLowerCase(),text:i[2],negative:o});continue}let a=n.match(wr);if(a)try{t.push({regex:new RegExp(a[1],"im"),negative:o});continue}catch{}t.push({text:n,negative:o})}return t}function kr(e,t){return e.message.toLowerCase().includes(t.toLowerCase())}function Sr(e,t){for(let r of t)if(r.regex){if(r.regex.test(e.message)===r.negative)return false}else if(r.text&&kr(e,r.text)===r.negative)return false;return true}function Cr(e,t,r){return e.method==="groupEnd"?true:t[e.level]?Sr(e,r):false}var lt={verbose:"Verbose",info:"Info",warning:"Warnings",error:"Errors"},Ee=["verbose","info","warning","error"];function at(e,t){return Ee.every(r=>e[r]===t[r])}function Tr(e){if(at(e,Ce))return"All levels";if(at(e,Te))return"Default levels";let t=Ee.filter(r=>e[r]);return t.length===0?"Hide all":t.length===1?`${lt[t[0]]} only`:"Custom levels"}var $e=5,Er=5;function $r(e,t){for(let r of e){let n=Xt(r.entry.origin,t);r.sourceKey=n,r.originColor=n?_e(n):void 0,r.originLabel=t==="off"?void 0:er(r.entry.origin,t)}}function Ar(e){for(let t=0;t<e.length;t++){let r=e[t].sourceKey;if(r==null){e[t].bracketGlyph=void 0;continue}let n=t>0&&e[t-1].sourceKey===r,o=t<e.length-1&&e[t+1].sourceKey===r,i=!n&&!o?"single":n?o?"mid":"bottom":"top";e[t].bracketGlyph=Ke(i)}}function Lr(e,t){let r=[],n=new Map;for(let i of e){let a=i.sourceKey??"\u2014",l=n.get(a);l||(l=[],n.set(a,l),r.push(a)),l.push(i)}let o=[];for(let i of r){let a=n.get(i);for(let c of a)c.depth=0;let l=a.length>Er,s=t[i]??false;l&&(o.push({key:`cluster:${i}`,entry:a[0].entry,depth:0,repeatCount:1,isGroupHeader:false,sourceKey:i,originColor:a[0].originColor,originLabel:a[0].originLabel,clusterHeader:{key:i,count:a.length,expanded:s}}),!s)||a.forEach((c,u)=>{let w=a.length===1?"single":u===0?"top":u===a.length-1?"bottom":"mid";c.bracketGlyph=Ke(w),o.push(c)})}return o}function Or(e){let t=new Map,r=new Map;e.forEach((l,s)=>{let c=l.sourceKey;c!=null&&(t.has(c)||t.set(c,s),r.set(c,s))});let n=[...t.keys()].sort((l,s)=>t.get(l)-t.get(s)),o=new Map,i=[];for(let l of n){let s=i.findIndex(c=>c<t.get(l));s===-1&&(s=i.length<$e?i.length:$e-1,s>=i.length&&i.push(0)),o.set(l,s),i[s]=Math.max(i[s]??0,r.get(l))}let a=Math.max(1,Math.min(i.length,$e));e.forEach((l,s)=>{let c=Array.from({length:a},()=>({glyph:" "}));for(let u of n){let w=o.get(u);w>=a||s>=t.get(u)&&s<=r.get(u)&&(c[w]={glyph:l.sourceKey===u?"\u25CF":"\u2502",color:_e(u)})}l.lanes=c})}var Br=new Set(["group","groupCollapsed"]);function Nr(e,t){let{levelsMask:r,query:n,showTimestamps:o,collapsedOverrides:i}=t,a=xr(n.trim()),l=[],s={verbose:0,info:0,warning:0,error:0},c=0,u=[],w=()=>u.some(h=>h.collapsed);for(let h of e){if(s[h.level]++,h.method==="groupEnd"){u.pop();continue}let B=Br.has(h.method),G=w();if(!Cr(h,r,a))c++;else if(!G){let $=l[l.length-1];!o&&!B&&$&&!$.isGroupHeader&&$.depth===u.length&&$.entry.method===h.method&&$.entry.message===h.message?$.repeatCount++:l.push({key:String(h.id),entry:h,depth:u.length,repeatCount:1,isGroupHeader:B,groupId:B?h.id:void 0,groupCollapsed:void 0})}if(B){let $=h.method==="groupCollapsed",F=i[h.id]??$,j=l[l.length-1];j&&j.groupId===h.id&&(j.groupCollapsed=F),u.push({id:h.id,collapsed:F||G})}}$r(l,t.groupDimension);let E=l;return t.groupDimension!=="off"&&(t.layoutMode==="cluster"?E=Lr(l,t.clusterExpanded):t.layoutMode==="swimlane"?Or(l):Ar(l)),{rows:E,hiddenCount:c,levelCounts:s,totalCount:e.length}}function st(e){let t=Wt(ce,K,K);return Pt(()=>Nr(t,e),[t,e.levelsMask,e.query,e.showTimestamps,e.collapsedOverrides,e.groupDimension,e.layoutMode,e.clusterExpanded])}function ct(){let[e,t]=z(""),[r,n]=z(false),[o,i]=z({...Te}),[a,l]=z(false),[s,c]=z({}),[u,w]=z("chrono"),[E,h]=z("list"),[B,G]=z({}),{rows:$,hiddenCount:F}=st({levelsMask:o,query:e,showTimestamps:a,collapsedOverrides:s,groupDimension:"function",layoutMode:u,clusterExpanded:B}),j=fe((ne,ie)=>{c(Mt=>({...Mt,[ne]:!ie}))},[]),oe=fe(ne=>{G(ie=>({...ie,[ne]:!(ie[ne]??false)}))},[]),p=fe(()=>{ee(),c({})},[]),A=Tr(o);return{query:e,setQuery:t,searchActive:r,setSearchActive:n,levelsMask:o,setLevelsMask:i,showTimestamps:a,setShowTimestamps:l,layoutMode:u,setLayoutMode:w,view:E,setView:h,rows:$,hiddenCount:F,onToggleGroup:j,onToggleCluster:oe,clear:p,levelSummary:A,isLevelCustom:A!=="All levels"&&A!=="Default levels"}}var ut={};jt(ut,{AccessibilityInfo:()=>Ir,ActivityIndicator:()=>Bo,Alert:()=>Ho,Animated:()=>jr,AppRegistry:()=>Dr,AppState:()=>Pr,Appearance:()=>zr,BackHandler:()=>Wr,Button:()=>No,CheckBox:()=>oo,Clipboard:()=>Fr,DeviceEventEmitter:()=>vo,Dimensions:()=>Vr,Easing:()=>Gr,FlatList:()=>Ae,I18nManager:()=>_r,Image:()=>no,ImageBackground:()=>io,InteractionManager:()=>Ur,Keyboard:()=>Kr,KeyboardAvoidingView:()=>lo,LayoutAnimation:()=>Yr,Linking:()=>Jr,LogBox:()=>bo,Modal:()=>Lo,NativeEventEmitter:()=>qr,NativeModules:()=>Rr,PanResponder:()=>Qr,Picker:()=>ao,PixelRatio:()=>Zr,Platform:()=>Xr,Pressable:()=>Ao,ProgressBar:()=>so,RefreshControl:()=>co,SafeAreaView:()=>uo,ScrollView:()=>dt,SectionList:()=>fo,Share:()=>eo,StatusBar:()=>go,StyleSheet:()=>S,Switch:()=>Oo,Text:()=>d,TextInput:()=>To,Touchable:()=>po,TouchableHighlight:()=>Eo,TouchableNativeFeedback:()=>mo,TouchableOpacity:()=>T,TouchableWithoutFeedback:()=>$o,UIManager:()=>to,Vibration:()=>ro,View:()=>m,VirtualizedList:()=>ho,YellowBox:()=>yo,findNodeHandle:()=>Mo,unstable_createElement:()=>Hr,useColorScheme:()=>wo,useLocaleContext:()=>xo,useWindowDimensions:()=>ko});zt(ut,Mr);import*as Mr from"react-native-web";import{unstable_createElement as Hr,NativeModules as Rr,AccessibilityInfo as Ir,Animated as jr,Appearance as zr,AppRegistry as Dr,AppState as Pr,BackHandler as Wr,Clipboard as Fr,Dimensions as Vr,Easing as Gr,I18nManager as _r,Keyboard as Kr,InteractionManager as Ur,LayoutAnimation as Yr,Linking as Jr,NativeEventEmitter as qr,PanResponder as Qr,PixelRatio as Zr,Platform as Xr,Share as eo,StyleSheet as S,UIManager as to,Vibration as ro,CheckBox as oo,FlatList as Ae,Image as no,ImageBackground as io,KeyboardAvoidingView as lo,Picker as ao,ProgressBar as so,RefreshControl as co,SafeAreaView as uo,SectionList as fo,StatusBar as go,Touchable as po,TouchableNativeFeedback as mo,VirtualizedList as ho,YellowBox as yo,LogBox as bo,DeviceEventEmitter as vo,useColorScheme as wo,useLocaleContext as xo,useWindowDimensions as ko}from"react-native-web";import*as C from"react-native-web";import{createElement as So,forwardRef as Co}from"react";function L(e){let t=Co((n,o)=>{let{accessibilityState:i,accessibilityValue:a,...l}=n;for(let s of["busy","checked","disabled","expanded","selected"])i?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=i[s]);for(let[s,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[s]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=a[s]);return So(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=L(C.View),d=L(C.Text),To=L(C.TextInput),T=L(C.TouchableOpacity),Eo=L(C.TouchableHighlight),$o=L(C.TouchableWithoutFeedback),Ao=L(C.Pressable),dt=L(C.ScrollView),Lo=L(C.Modal),Oo=L(C.Switch),Bo=L(C.ActivityIndicator),No=L(C.Button),Mo=C.findNodeHandle,Ho={alert(e,t,r,n){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],s=()=>{o.close?.(),o.remove()};for(let c of l){let u=document.createElement("button");u.type="button",u.textContent=c.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{s(),c.onPress?.()},a.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(s(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{ModalHeader as D,TabSelector as Ro,night as M,Search as Io,Filter as jo,Trash2 as zo}from"@buoy-gg/shared-ui/web";import{jsx as O,jsxs as Le}from"react/jsx-runtime";var Do=[{key:"chrono",label:"Timeline"},{key:"cluster",label:"Grouped"}];function ft({c:e,onBack:t}){if(e.view==="filters")return Le(D,{children:[O(D.Navigation,{onBack:()=>e.setView("list")}),O(D.Content,{title:"Filters"})]});let r=e.rows.length>0;return Le(D,{children:[t?O(D.Navigation,{onBack:t}):null,O(D.Content,{title:"",noMargin:true,children:e.searchActive?O(D.Search,{value:e.query,onChangeText:e.setQuery,onCancel:()=>e.setQuery(""),clearOnlyWhenText:true,placeholder:"Filter logs\u2026 /regex/ -exclude",iconSize:14,inputProps:{onSubmitEditing:()=>e.setSearchActive(false)}}):O(Ro,{tabs:Do,activeTab:e.layoutMode,onTabChange:n=>e.setLayoutMode(n)})}),Le(D.Actions,{children:[O(T,{onPress:()=>e.setSearchActive(n=>!n),style:[J.actionBtn,e.searchActive&&J.actionBtnActive],accessibilityLabel:"Search logs",children:O(Io,{size:14,color:e.searchActive?M.color.accent:M.color.textSecondary})}),O(T,{onPress:()=>e.setView("filters"),style:[J.actionBtn,e.isLevelCustom&&J.actionBtnActive],accessibilityLabel:"Filters",children:O(jo,{size:14,color:e.isLevelCustom?M.color.accent:M.color.textSecondary})}),O(T,{onPress:e.clear,disabled:!r,style:[J.actionBtn,!r&&J.actionBtnDisabled],accessibilityLabel:"Clear console",children:O(zo,{size:14,color:r?M.color.textSecondary:M.color.textTertiary})})]})]})}var J=S.create({actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:M.color.buttonSurface,borderWidth:1,borderColor:M.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:M.color.accentSoft,borderColor:M.color.accentBorderStrong},actionBtnDisabled:{opacity:.55}});import{useCallback as Po,useRef as gt,useSyncExternalStore as Wo}from"react";import{night as I,Check as Fo,LOG_LIST_PRESET as Vo}from"@buoy-gg/shared-ui/web";import{memo as Go}from"react";import{useState as _o}from"react";import{monoFont as P,night as re}from"@buoy-gg/shared-ui/web";var Ko={baseContainer:"#0A0A0C",surfaceError:"rgba(255,69,58,0.15)",surfaceYellow:"rgba(255,235,59,0.13)",divider:re.color.fillTertiary,inputBackground:re.color.surfaceElevated,menuBackground:re.color.surface,onSurface:re.color.text,onSurfaceYellow:"#FFE9A3",onErrorContainer:"#FFB4AB",tokenSubtle:re.color.textSecondary,primary:"#40CCFF",valueNumber:"#FF9F1C",valueString:"#7EE787",valueBigint:"#A1A1A6",valueNode:"#F5F5F7",valueNullish:"#8E8E93",valuePreview:"#A1A1A6"},g=Ko,Uo={black:"#000",red:"rgb(237 78 76)",green:"rgb(1 200 1)",yellow:"rgb(210 192 87)",blue:"rgb(39 116 240)",magenta:"rgb(161 66 244)",cyan:"rgb(18 181 203)",gray:"rgb(207 208 208)",darkgray:"rgb(137 137 137)",lightred:"rgb(242 139 130)",lightgreen:"rgb(161 247 181)",lightyellow:"rgb(221 251 85)",lightblue:"rgb(102 157 246)",lightmagenta:"rgb(214 112 214)",lightcyan:"rgb(132 240 255)",white:"#fff"},pt={verbose:{text:g.tokenSubtle},info:{text:g.onSurface},warning:{background:g.surfaceYellow,text:g.onSurfaceYellow,icon:"warning"},error:{background:g.surfaceError,text:g.onErrorContainer,icon:"error"}};var mt=["black","red","green","yellow","blue","magenta","cyan","gray"],ht=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function yt(e){if(typeof e=="string")return e;if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e=="function")return`\u0192 ${e.name||"(anonymous)"}`;try{return JSON.stringify(e)}catch{return String(e)}}var Oe=/%([%_Oocsdfi])|\x1B\[([\d;]*)m/;function Yo(e){return Oe.test(e)}function bt(e){let t={},r=false;for(let n of e.split(";")){let o=n.indexOf(":");if(o===-1)continue;let i=n.slice(0,o).trim().toLowerCase(),a=n.slice(o+1).trim();if(!a)continue;let l=a.match(/var\(--console-color-([a-z]+)\)/);switch(l&&(a=Uo[l[1]]??a),i){case"color":t.color=a,r=true;break;case"background-color":case"background":t.backgroundColor=a,r=true;break;case"font-weight":t.fontWeight=a==="lighter"?"300":a,r=true;break;case"font-style":a==="italic"&&(t.fontStyle="italic",r=true);break;case"font-size":{let s=parseFloat(a);Number.isNaN(s)||(t.fontSize=s,r=true);break}case"text-decoration":case"text-decoration-line":a.includes("underline")&&a.includes("line-through")?t.textDecorationLine="underline line-through":a.includes("underline")?t.textDecorationLine="underline":a.includes("line-through")&&(t.textDecorationLine="line-through"),r=true;break;default:break}}return r?t:void 0}function Jo(e,t){let r=o=>{let i=t.get("text-decoration")??"";i.includes(o)||t.set("text-decoration",`${i} ${o}`)},n=o=>{let i=t.get("text-decoration")?.replace(` ${o}`,"");i?t.set("text-decoration",i):t.delete("text-decoration")};for(;e.length;){let o=e.shift();switch(o){case 0:t.clear();break;case 1:t.set("font-weight","bold");break;case 2:t.set("font-weight","lighter");break;case 3:t.set("font-style","italic");break;case 4:r("underline");break;case 9:r("line-through");break;case 22:t.delete("font-weight");break;case 23:t.delete("font-style");break;case 24:n("underline");break;case 29:n("line-through");break;case 38:case 48:if(e.shift()===2){let i=e.shift()??0,a=e.shift()??0,l=e.shift()??0;t.set(o===38?"color":"background-color",`rgb(${i},${a},${l})`)}break;case 39:case 49:t.delete(o===39?"color":"background-color");break;default:{let i=mt[o-30]??ht[o-90];if(i!==void 0)t.set("color",`var(--console-color-${i})`);else{let a=mt[o-40]??ht[o-100];a!==void 0&&t.set("background-color",`var(--console-color-${a})`)}break}}}}function qo(e,t){let r=e,n=[],o=new Map,i,a=s=>{if(!s)return;let c=n[n.length-1];if(c&&c.type==="string"&&Qo(c.style,i)){c.value+=s;return}n.push({type:"string",value:s,style:i})},l=0;for(let s=Oe.exec(r);s!==null;s=Oe.exec(r)){a(s.input.substring(0,s.index));let c,u=s[1];switch(u){case"%":a("%"),c="";break;case"s":l<t.length&&(c=yt(t[l++]));break;case"c":l<t.length&&(i=bt(yt(t[l++])),c="");break;case"o":case"O":l<t.length&&(n.push({type:"value",value:t[l++],mode:u==="O"?"generic":"optimal"}),c="");break;case"_":l<t.length&&(l++,c="");break;case"d":case"f":case"i":{if(l<t.length){let w=t[l++],E=typeof w!="number"?NaN:w;u!=="f"&&(E=Math.floor(E)),c=E}break}case void 0:{let w=(s[2]||"0").split(";").map(h=>h?parseInt(h,10):0);Jo(w,o);let E=[...o.entries()].map(([h,B])=>`${h}:${B.trimStart()}`).join(";");i=bt(E),c="";break}}c===void 0&&(a(s[0]),c=""),r=c+s.input.substring(s.index+s[0].length)}return a(r),{tokens:n,rest:t.slice(l)}}function Qo(e,t){return e===t?true:!e||!t?false:JSON.stringify(e)===JSON.stringify(t)}function Zo(e){if(e.length===0)return[];let t=[],r=e;if(typeof e[0]=="string"&&Yo(e[0])){let n=qo(e[0],e.slice(1));t=n.tokens,r=n.rest}for(let n of r)t.length>0&&t.push({type:"string",value:" "}),typeof n=="string"?t.push({type:"string",value:n}):t.push({type:"value",value:n,mode:"optimal"});return t}import{useState as Xo}from"react";import{jsx as N,jsxs as q}from"react/jsx-runtime";var vt=5,wt=6;function Be(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";if(e instanceof Error)return"error";let t=typeof e;return t==="number"?"number":t==="bigint"?"bigint":t==="boolean"?"boolean":t==="string"?"string":t==="function"?"function":t==="symbol"?"symbol":"object"}var en={number:g.valueNumber,bigint:g.valueBigint,boolean:g.valueNumber,string:g.valueString,null:g.valueNullish,undefined:g.valueNullish,symbol:g.valueString,function:g.valueNode};function xt(e){if(Array.isArray(e))return"";let t=Object.getPrototypeOf(e);if(!t)return"Object";let r=t.constructor?.name;return!r||r==="Object"?"":r}function Ne(e){switch(Be(e)){case"string":return`'${e}'`;case"function":return`\u0192 ${e.name||""}`.trimEnd();case"symbol":return e.toString();case"bigint":return`${String(e)}n`;case"array":return`Array(${e.length})`;case"error":return e.name;case"object":{let t=xt(e);return t?`${t} {\u2026}`:"{\u2026}"}default:return String(e)}}function tn(e){if(Array.isArray(e)){let i=e.slice(0,wt).map(l=>Ne(l)).join(", "),a=e.length>wt?", \u2026":"";return`(${e.length}) [${i}${a}]`}let t=Object.entries(e),r=t.slice(0,vt).map(([i,a])=>`${i}: ${Ne(a)}`).join(", "),n=t.length>vt?", \u2026":"",o=xt(e);return`${o?`${o} `:""}{${r}${n}}`}function rn(e){let t=Be(e);return t==="array"?e.length>0:t==="object"?Object.keys(e).length>0:t==="error"}var kt=({open:e})=>N(d,{style:[b.triangle,e&&b.triangleOpen],children:"\u25B6"});function Me({value:e,depth:t=0}){let[r,n]=Xo(false),o=Be(e);if(o==="error"){let l=e,s=`${l.name}: ${l.message}`.split(`
|
|
16
|
-
`)[0],c=l.stack&&l.stack.trim()!==s.trim()?l.stack:void 0;return c?q(m,{style:b.objectContainer,children:[q(T,{style:b.objectHeader,activeOpacity:.6,onPress:()=>n(u=>!u),children:[
|
|
17
|
-
`).filter(p=>p.trim()).map((p,A)=>y(d,{style:f.stackFrame,children:p.trim()},A))}):null]}),B=[f.wrapper,i.background?{backgroundColor:i.background}:f.dividerTop],G=Array.from({length:e.depth},(p,A)=>y(m,{style:f.nestingMarker},A)),$=e.lanes?y(m,{style:f.laneGutter,children:e.lanes.map((p,A)=>y(d,{style:[f.laneCell,p.color?{color:p.color}:null],children:p.glyph},A))}):e.bracketGlyph?y(d,{style:[f.originGutter,{color:e.originColor}],children:e.bracketGlyph}):null,F=Q(m,{style:f.rowWrapper,children:[$,G,h]}),j=`buoy-console-row-${o.id}`,oe=[e.originLabel,u.find(p=>p.type==="string")?.value].filter(Boolean).join(" \u2014 ").slice(0,80);if(e.isGroupHeader&&e.groupId!==void 0){let p=e.groupId;return y(T,{style:B,activeOpacity:.7,onPress:()=>r(p,!!e.groupCollapsed),testID:j,accessibilityLabel:oe||"Console group",children:F})}return y(T,{style:B,activeOpacity:.7,onPress:()=>c(p=>!p),testID:j,accessibilityLabel:oe||"Console message",children:F})},(e,t)=>e.row.key===t.row.key&&e.row.lanes===t.row.lanes&&e.row.repeatCount===t.row.repeatCount&&e.row.groupCollapsed===t.row.groupCollapsed&&e.row.depth===t.row.depth&&e.row.bracketGlyph===t.row.bracketGlyph&&e.row.originLabel===t.row.originLabel&&e.row.clusterHeader?.count===t.row.clusterHeader?.count&&e.row.clusterHeader?.expanded===t.row.clusterHeader?.expanded&&e.showTimestamps===t.showTimestamps&&e.onToggleGroup===t.onToggleGroup&&e.onToggleCluster===t.onToggleCluster),f=S.create({wrapper:{paddingVertical:2,paddingRight:8,minHeight:18},dividerTop:{borderTopWidth:S.hairlineWidth,borderTopColor:g.divider},rowWrapper:{flexDirection:"row",alignItems:"flex-start"},originGutter:{width:11,fontFamily:P,fontSize:13,lineHeight:18,textAlign:"center"},laneGutter:{flexDirection:"row"},laneCell:{width:9,fontFamily:P,fontSize:13,lineHeight:18,textAlign:"center"},originLabel:{fontFamily:P,fontSize:10,lineHeight:16,marginBottom:1,opacity:.9},nestingMarker:{width:14,alignSelf:"stretch",borderRightWidth:S.hairlineWidth,borderRightColor:g.divider,marginLeft:2},messageColumn:{flex:1,flexDirection:"column",paddingLeft:6},messageLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start"},contentWrap:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start",flexShrink:1},contentWrapClamped:{flexWrap:"nowrap",overflow:"hidden",maxHeight:16},text:{fontFamily:P,fontSize:12,lineHeight:16},groupTitle:{fontWeight:"bold"},clusterTitle:{fontWeight:"600"},clusterCount:{color:g.tokenSubtle,fontFamily:P,fontSize:12,lineHeight:16},groupTriangle:{fontSize:9,lineHeight:16,marginRight:4},stackTriangle:{fontSize:8,lineHeight:16,marginRight:4},levelIcon:{fontSize:12,lineHeight:16,marginRight:5},timestamp:{color:g.tokenSubtle,fontFamily:P,fontSize:11,lineHeight:16,marginRight:6},repeatBadge:{borderWidth:1,borderRadius:9,paddingHorizontal:5,minWidth:16,alignItems:"center",justifyContent:"center",marginLeft:6,marginTop:1},repeatBadgeText:{fontSize:10,fontWeight:"700",lineHeight:14},stackTrace:{marginTop:2,marginLeft:12},stackFrame:{color:g.tokenSubtle,fontFamily:P,fontSize:11,lineHeight:15}});import{jsx as v,jsxs as He}from"react/jsx-runtime";function Ct({c:e}){return e.view==="filters"?v(cn,{c:e}):v(sn,{c:e})}function sn({c:e}){let t=gt(null),r=gt(true),n=Po(({item:o})=>v(St,{row:o,showTimestamps:e.showTimestamps,onToggleGroup:e.onToggleGroup,onToggleCluster:e.onToggleCluster}),[e.showTimestamps,e.onToggleGroup,e.onToggleCluster]);return v(Ae,{ref:t,data:e.rows,keyExtractor:o=>o.key,renderItem:n,style:k.list,...Vo,onContentSizeChange:()=>{r.current&&t.current?.scrollToEnd({animated:false})},onScroll:o=>{let{contentOffset:i,contentSize:a,layoutMeasurement:l}=o.nativeEvent,s=a.height-(i.y+l.height);r.current=s<40},scrollEventThrottle:100})}function Re({on:e,label:t,subtext:r,onPress:n}){return He(T,{style:k.row,onPress:n,activeOpacity:.7,children:[v(m,{style:[k.checkbox,e&&k.checkboxOn],children:e?v(Fo,{size:12,color:I.color.onAccent,strokeWidth:3}):null}),He(m,{style:k.rowTextCol,children:[v(d,{style:k.rowLabel,children:t}),r?v(d,{style:k.rowSubtext,children:r}):null]})]})}function Tt({text:e}){return v(d,{style:k.sectionLabel,children:e})}function cn({c:e}){let t=Wo(it,Se,Se),r=n=>e.setLevelsMask({...e.levelsMask,[n]:!e.levelsMask[n]});return He(dt,{style:k.subView,contentContainerStyle:k.subViewContent,children:[v(Tt,{text:"Log levels"}),v(T,{style:k.presetRow,onPress:()=>e.setLevelsMask({...Te}),children:v(d,{style:k.presetText,children:"Default (hide verbose)"})}),v(T,{style:k.presetRow,onPress:()=>e.setLevelsMask({...Ce}),children:v(d,{style:k.presetText,children:"All levels"})}),Ee.map(n=>v(Re,{on:e.levelsMask[n],label:lt[n],onPress:()=>r(n)},n)),v(m,{style:k.divider}),v(Tt,{text:"Settings"}),v(Re,{on:e.showTimestamps,label:"Show timestamps",onPress:()=>e.setShowTimestamps(n=>!n)}),v(Re,{on:t,label:"Preserve log",subtext:"Do not clear log on reload",onPress:()=>nt(!t)})]})}var k=S.create({list:{flex:1,backgroundColor:"transparent"},subView:{flex:1,backgroundColor:"transparent"},subViewContent:{padding:12},sectionLabel:{color:I.color.textTertiary,fontSize:11,textTransform:"uppercase",letterSpacing:.5,marginTop:4,marginBottom:4,paddingHorizontal:8},presetRow:{paddingVertical:10,paddingHorizontal:8},presetText:{color:I.color.accent,fontSize:14,fontWeight:"600"},divider:{height:S.hairlineWidth,backgroundColor:I.color.border,marginVertical:6},row:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:8,gap:12},rowTextCol:{flexDirection:"column",flex:1},rowLabel:{color:I.color.text,fontSize:14},rowSubtext:{color:I.color.textTertiary,fontSize:12,marginTop:1},checkbox:{width:18,height:18,borderRadius:4,borderWidth:1,borderColor:I.color.fillTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:I.color.accent,borderColor:I.color.accent}});import{jsx as Ie}from"react/jsx-runtime";function Et({visible:e,onClose:t,onBack:r,onMinimize:n,persistenceKey:o}){let i=ct();return Ie(Dt,{visible:e,onClose:t,onMinimize:n,persistenceKey:o,header:{showToggleButton:true,customContent:Ie(ft,{c:i,onBack:r})},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ie(Ct,{c:i})})}import{createToolFactory as un,defineToolPreset as dn}from"@buoy-gg/shared-ui/web";import{jsx as fn}from"react/jsx-runtime";var $t=globalThis,gn=typeof $t.ErrorUtils?.setGlobalHandler=="function"||typeof $t.RN$registerExceptionListener=="function";gn&&typeof Pe<"u"&&Pe&&se();var At=dn({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:Fe,icon:({size:e})=>fn(We,{size:e}),component:Et}),pn=un(At);import{useEffect as mn}from"react";import{getAccountAccess as hn,subscribeAccountAccess as yn}from"@buoy-gg/shared-ui/web";var Lt=0;function bn(){return mn(()=>{++Lt;let e=true,t=()=>{if(!e)return;let n=hn();if(n.status==="locked"){ve(),ee();return}se(),n.status==="admitted"&&ot()},r=yn(t);return t(),()=>{e=false,r(),--Lt===0&&ve()}},[]),null}import{macOSColors as vn,windowDragProps as wn}from"@buoy-gg/shared-ui/web";import{jsx as je,jsxs as xn}from"react/jsx-runtime";function kn(){let e=ct();return xn(m,{style:Ot.container,children:[je(m,{style:Ot.headerBar,...wn,children:je(ft,{c:e})}),je(Ct,{c:e})]})}var Ot=S.create({container:{flex:1,backgroundColor:"transparent"},headerBar:{paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:S.hairlineWidth,borderBottomColor:vn.border.default}});import{useSyncExternalStore as Sn,useEffect as Cn}from"react";function Bt(){return Cn(()=>{se()},[]),{logs:Sn(ce,K,K)}}import{night as W,ToolEmptyState as Tn,monoFont as En}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as de}from"react/jsx-runtime";var Nt={verbose:"#9b9b9b",info:W.color.text,warning:"#e2c08d",error:"#f48771"};function $n(e){let t=new Date(e),r=(n,o=2)=>String(n).padStart(o,"0");return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}.${r(t.getMilliseconds(),3)}`}function An(){let{logs:e}=Bt(),t=({item:r})=>de(m,{style:H.row,children:[V(d,{style:H.time,children:$n(r.timestamp)}),V(d,{style:[H.level,{color:Nt[r.level]}],children:r.level.toUpperCase()}),V(d,{style:[H.message,{color:Nt[r.level]}],numberOfLines:3,children:r.message})]});return de(m,{style:H.container,children:[de(m,{style:H.header,children:[de(d,{style:H.headerTitle,children:["Console (",e.length,")"]}),V(T,{onPress:()=>ee(),style:H.clearButton,children:V(d,{style:H.clearText,children:"Clear"})})]}),V(Ae,{data:e,keyExtractor:r=>String(r.id),renderItem:t,ListEmptyComponent:V(Tn,{testID:"buoy-console-empty",otto:"printing",title:"No console logs captured yet",message:"console.log, .warn and .error from your app land here as they run."}),contentContainerStyle:e.length===0?H.emptyContainer:void 0})]})}var H=S.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:S.hairlineWidth,borderBottomColor:W.color.border},headerTitle:{color:W.color.text,fontSize:13,fontWeight:"600"},clearButton:{paddingHorizontal:10,paddingVertical:4,borderRadius:4,backgroundColor:W.color.surfaceElevated},clearText:{color:W.color.text,fontSize:12},row:{flexDirection:"row",paddingHorizontal:12,paddingVertical:4,borderBottomWidth:S.hairlineWidth,borderBottomColor:W.color.separator,gap:8},time:{color:W.color.textTertiary,fontSize:11,fontVariant:["tabular-nums"],minWidth:86},level:{fontSize:11,fontWeight:"700",minWidth:44},message:{flex:1,fontSize:12,fontFamily:En},empty:{color:W.color.textTertiary,fontSize:13,textAlign:"center"},emptyContainer:{flexGrow:1,alignItems:"center",justifyContent:"center"}});import{createSyncAdapter as Ln,memoByIdentity as On,newestFitting as Bn,sizeOrStub as Nn}from"@buoy-gg/shared-ui/web";var Mn=1.5*1024*1024,Hn=16*1024,Rn=Object.freeze({__buoyTruncated:true,note:"Log payload omitted \u2014 inspect it on-device."}),In=On(e=>{let t={...e,args:Ve(e.args),message:X(e.message),stack:e.stack?X(e.stack,4096):e.stack};return Nn(t,Hn,()=>({...t,args:[Rn]}))});function jn(e){return Bn(e,{toWire:In,budget:Mn,baseBytes:16})}var zn=Ln({version:1,getSnapshot(){return{entries:jn(K())}},subscribe(e){return ce(e)},actions:{clearEntries(){return ee(),{cleared:true}}}});export{Fe as CONSOLE_ICON_COLOR,We as ConsoleIcon,An as ConsoleLogList,St as ConsoleMessageRow,Et as ConsoleModal,bn as ConsoleRoot,Me as ConsoleValue,kn as ConsoleView,ee as clearEntries,zn as consoleSyncAdapter,g as consoleTheme,At as consoleToolPreset,pn as createConsoleTool,K as getEntries,Se as getPreserveLog,ot as initConsolePersistence,se as installConsoleCapture,Ze as installFatalErrorCapture,pt as levelStyles,yr as onClear,hr as replaceEntries,nt as setPreserveLog,ce as subscribe,it as subscribePreserveLog,ve as uninstallConsoleCapture,Bt as useConsoleLogs,st as useConsoleMessages};
|
|
15
|
+
${Je(e.componentStack)}`:"",i=`${t} ${r}${o}`;be({id:x.allocId(),method:"error",level:"error",args:[t,r,...o?[o.trim()]:[]],message:i,timestamp:Date.now(),stack:gr(e),fatal:true},n)}function mr(){let e=globalThis.RN$registerExceptionListener;return typeof e!="function"?false:(e(t=>{try{ae||pr(t)}catch{}}),true)}function Ze(){if(pe)return;let e=mr(),t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!="function"){pe=e;return}pe=true;let r=typeof t.getGlobalHandler=="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((n,o)=>{try{ae||fr(n,o)}catch{}typeof r=="function"&&r(n,o)})}function se(){if(Ft().status!=="locked"&&(ae=false,Ze(),!le)){le=true;for(let e of Ue){let t=console[e];typeof t=="function"&&(me[e]=t,console[e]=function(...r){ur(e,r),t.apply(console,r)})}}}function ve(){if(ae=true,!!le){le=false;for(let e of Ue){let t=me[e];t&&(console[e]=t),delete me[e]}}}function ce(e){return x.subscribe(e)}function K(){return x.getSnapshot()}function ee(){ke(),x.clear()}function hr(e){x.set(e)}function yr(e){return x.onClear(e)}var Xe="@react_buoy_console_preserve",we="@react_buoy_console_buffer",br=600,R=false,te=false,U=0,Y=Promise.resolve(),xe=new Set,ue=null;function et(){for(let e of xe)e()}function tt(){!R||!_()||(ue&&clearTimeout(ue),ue=setTimeout(rt,br))}async function rt(){if(ue=null,!(!R||!_()))try{let e=x.getSnapshot().map(r=>({...r,args:Ve(r.args)})),t=U;Y=Y.then(async()=>{t!==U||!R||!_()||await Z.setItem(we,JSON.stringify(e))}).catch(()=>{}),await Y}catch{}}async function ke(){U++,te=false;try{Y=Y.then(()=>Z.removeItem(we)).catch(()=>{}),await Y}catch{}}async function ot(){if(te||!_())return;te=true;let e=U;try{R=await Z.getItem(Xe)==="true"}catch{R=false}if(e!==U||!_()){te=false;return}if(et(),!R){await ke();return}try{let t=await Z.getItem(we);if(e!==U||!_()){te=false;return}if(t){let r=JSON.parse(t);Array.isArray(r)&&r.length&&(x.update(n=>[...r,...n]),x.bumpIdAbove(Math.max(...r.map(n=>n.id))))}}catch{}}function Se(){return R}function nt(e){R!==e&&(R=e,et(),Z.setItem(Xe,String(e)).catch(()=>{}),e?rt():ke())}function it(e){return xe.add(e),()=>{xe.delete(e)}}var Ce={verbose:true,info:true,warning:true,error:true},Te={...Ce,verbose:false},vr=/^([\w-]+):(.+)$/,wr=/^\/(.+)\/$/;function xr(e){let t=[];for(let r of e.split(/\s+/)){if(!r)continue;let n=r,o=false;n.startsWith("-")&&n.length>1&&(o=true,n=n.slice(1));let i=n.match(vr);if(i){t.push({key:i[1].toLowerCase(),text:i[2],negative:o});continue}let a=n.match(wr);if(a)try{t.push({regex:new RegExp(a[1],"im"),negative:o});continue}catch{}t.push({text:n,negative:o})}return t}function kr(e,t){return e.message.toLowerCase().includes(t.toLowerCase())}function Sr(e,t){for(let r of t)if(r.regex){if(r.regex.test(e.message)===r.negative)return false}else if(r.text&&kr(e,r.text)===r.negative)return false;return true}function Cr(e,t,r){return e.method==="groupEnd"?true:t[e.level]?Sr(e,r):false}var lt={verbose:"Verbose",info:"Info",warning:"Warnings",error:"Errors"},Ee=["verbose","info","warning","error"];function at(e,t){return Ee.every(r=>e[r]===t[r])}function Tr(e){if(at(e,Ce))return"All levels";if(at(e,Te))return"Default levels";let t=Ee.filter(r=>e[r]);return t.length===0?"Hide all":t.length===1?`${lt[t[0]]} only`:"Custom levels"}var $e=5,Er=5;function $r(e,t){for(let r of e){let n=Xt(r.entry.origin,t);r.sourceKey=n,r.originColor=n?_e(n):void 0,r.originLabel=t==="off"?void 0:er(r.entry.origin,t)}}function Ar(e){for(let t=0;t<e.length;t++){let r=e[t].sourceKey;if(r==null){e[t].bracketGlyph=void 0;continue}let n=t>0&&e[t-1].sourceKey===r,o=t<e.length-1&&e[t+1].sourceKey===r,i=!n&&!o?"single":n?o?"mid":"bottom":"top";e[t].bracketGlyph=Ke(i)}}function Lr(e,t){let r=[],n=new Map;for(let i of e){let a=i.sourceKey??"\u2014",l=n.get(a);l||(l=[],n.set(a,l),r.push(a)),l.push(i)}let o=[];for(let i of r){let a=n.get(i);for(let c of a)c.depth=0;let l=a.length>Er,s=t[i]??false;l&&(o.push({key:`cluster:${i}`,entry:a[0].entry,depth:0,repeatCount:1,isGroupHeader:false,sourceKey:i,originColor:a[0].originColor,originLabel:a[0].originLabel,clusterHeader:{key:i,count:a.length,expanded:s}}),!s)||a.forEach((c,u)=>{let w=a.length===1?"single":u===0?"top":u===a.length-1?"bottom":"mid";c.bracketGlyph=Ke(w),o.push(c)})}return o}function Or(e){let t=new Map,r=new Map;e.forEach((l,s)=>{let c=l.sourceKey;c!=null&&(t.has(c)||t.set(c,s),r.set(c,s))});let n=[...t.keys()].sort((l,s)=>t.get(l)-t.get(s)),o=new Map,i=[];for(let l of n){let s=i.findIndex(c=>c<t.get(l));s===-1&&(s=i.length<$e?i.length:$e-1,s>=i.length&&i.push(0)),o.set(l,s),i[s]=Math.max(i[s]??0,r.get(l))}let a=Math.max(1,Math.min(i.length,$e));e.forEach((l,s)=>{let c=Array.from({length:a},()=>({glyph:" "}));for(let u of n){let w=o.get(u);w>=a||s>=t.get(u)&&s<=r.get(u)&&(c[w]={glyph:l.sourceKey===u?"\u25CF":"\u2502",color:_e(u)})}l.lanes=c})}var Nr=new Set(["group","groupCollapsed"]);function Br(e,t){let{levelsMask:r,query:n,showTimestamps:o,collapsedOverrides:i}=t,a=xr(n.trim()),l=[],s={verbose:0,info:0,warning:0,error:0},c=0,u=[],w=()=>u.some(h=>h.collapsed);for(let h of e){if(s[h.level]++,h.method==="groupEnd"){u.pop();continue}let N=Nr.has(h.method),G=w();if(!Cr(h,r,a))c++;else if(!G){let $=l[l.length-1];!o&&!N&&$&&!$.isGroupHeader&&$.depth===u.length&&$.entry.method===h.method&&$.entry.message===h.message?$.repeatCount++:l.push({key:String(h.id),entry:h,depth:u.length,repeatCount:1,isGroupHeader:N,groupId:N?h.id:void 0,groupCollapsed:void 0})}if(N){let $=h.method==="groupCollapsed",F=i[h.id]??$,j=l[l.length-1];j&&j.groupId===h.id&&(j.groupCollapsed=F),u.push({id:h.id,collapsed:F||G})}}$r(l,t.groupDimension);let E=l;return t.groupDimension!=="off"&&(t.layoutMode==="cluster"?E=Lr(l,t.clusterExpanded):t.layoutMode==="swimlane"?Or(l):Ar(l)),{rows:E,hiddenCount:c,levelCounts:s,totalCount:e.length}}function st(e){let t=Wt(ce,K,K);return Pt(()=>Br(t,e),[t,e.levelsMask,e.query,e.showTimestamps,e.collapsedOverrides,e.groupDimension,e.layoutMode,e.clusterExpanded])}function ct(){let[e,t]=z(""),[r,n]=z(false),[o,i]=z({...Te}),[a,l]=z(false),[s,c]=z({}),[u,w]=z("chrono"),[E,h]=z("list"),[N,G]=z({}),{rows:$,hiddenCount:F}=st({levelsMask:o,query:e,showTimestamps:a,collapsedOverrides:s,groupDimension:"function",layoutMode:u,clusterExpanded:N}),j=fe((ne,ie)=>{c(Mt=>({...Mt,[ne]:!ie}))},[]),oe=fe(ne=>{G(ie=>({...ie,[ne]:!(ie[ne]??false)}))},[]),p=fe(()=>{ee(),c({})},[]),A=Tr(o);return{query:e,setQuery:t,searchActive:r,setSearchActive:n,levelsMask:o,setLevelsMask:i,showTimestamps:a,setShowTimestamps:l,layoutMode:u,setLayoutMode:w,view:E,setView:h,rows:$,hiddenCount:F,onToggleGroup:j,onToggleCluster:oe,clear:p,levelSummary:A,isLevelCustom:A!=="All levels"&&A!=="Default levels"}}var ut={};jt(ut,{AccessibilityInfo:()=>Ir,ActivityIndicator:()=>No,Alert:()=>Ho,Animated:()=>jr,AppRegistry:()=>Dr,AppState:()=>Pr,Appearance:()=>zr,BackHandler:()=>Wr,Button:()=>Bo,CheckBox:()=>oo,Clipboard:()=>Fr,DeviceEventEmitter:()=>vo,Dimensions:()=>Vr,Easing:()=>Gr,FlatList:()=>Ae,I18nManager:()=>_r,Image:()=>no,ImageBackground:()=>io,InteractionManager:()=>Ur,Keyboard:()=>Kr,KeyboardAvoidingView:()=>lo,LayoutAnimation:()=>Yr,Linking:()=>Jr,LogBox:()=>bo,Modal:()=>Lo,NativeEventEmitter:()=>qr,NativeModules:()=>Rr,PanResponder:()=>Qr,Picker:()=>ao,PixelRatio:()=>Zr,Platform:()=>Xr,Pressable:()=>Ao,ProgressBar:()=>so,RefreshControl:()=>co,SafeAreaView:()=>uo,ScrollView:()=>dt,SectionList:()=>fo,Share:()=>eo,StatusBar:()=>go,StyleSheet:()=>S,Switch:()=>Oo,Text:()=>d,TextInput:()=>To,Touchable:()=>po,TouchableHighlight:()=>Eo,TouchableNativeFeedback:()=>mo,TouchableOpacity:()=>T,TouchableWithoutFeedback:()=>$o,UIManager:()=>to,Vibration:()=>ro,View:()=>m,VirtualizedList:()=>ho,YellowBox:()=>yo,findNodeHandle:()=>Mo,unstable_createElement:()=>Hr,useColorScheme:()=>wo,useLocaleContext:()=>xo,useWindowDimensions:()=>ko});zt(ut,Mr);import*as Mr from"react-native-web";import{unstable_createElement as Hr,NativeModules as Rr,AccessibilityInfo as Ir,Animated as jr,Appearance as zr,AppRegistry as Dr,AppState as Pr,BackHandler as Wr,Clipboard as Fr,Dimensions as Vr,Easing as Gr,I18nManager as _r,Keyboard as Kr,InteractionManager as Ur,LayoutAnimation as Yr,Linking as Jr,NativeEventEmitter as qr,PanResponder as Qr,PixelRatio as Zr,Platform as Xr,Share as eo,StyleSheet as S,UIManager as to,Vibration as ro,CheckBox as oo,FlatList as Ae,Image as no,ImageBackground as io,KeyboardAvoidingView as lo,Picker as ao,ProgressBar as so,RefreshControl as co,SafeAreaView as uo,SectionList as fo,StatusBar as go,Touchable as po,TouchableNativeFeedback as mo,VirtualizedList as ho,YellowBox as yo,LogBox as bo,DeviceEventEmitter as vo,useColorScheme as wo,useLocaleContext as xo,useWindowDimensions as ko}from"react-native-web";import*as C from"react-native-web";import{createElement as So,forwardRef as Co}from"react";function L(e){let t=Co((n,o)=>{let{accessibilityState:i,accessibilityValue:a,...l}=n;for(let s of["busy","checked","disabled","expanded","selected"])i?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=i[s]);for(let[s,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[s]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=a[s]);return So(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=L(C.View),d=L(C.Text),To=L(C.TextInput),T=L(C.TouchableOpacity),Eo=L(C.TouchableHighlight),$o=L(C.TouchableWithoutFeedback),Ao=L(C.Pressable),dt=L(C.ScrollView),Lo=L(C.Modal),Oo=L(C.Switch),No=L(C.ActivityIndicator),Bo=L(C.Button),Mo=C.findNodeHandle,Ho={alert(e,t,r,n){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],s=()=>{o.close?.(),o.remove()};for(let c of l){let u=document.createElement("button");u.type="button",u.textContent=c.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{s(),c.onPress?.()},a.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(s(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{ModalHeader as D,TabSelector as Ro,night as M,Search as Io,Filter as jo,Trash2 as zo}from"@buoy-gg/shared-ui/web";import{jsx as O,jsxs as Le}from"react/jsx-runtime";var Do=[{key:"chrono",label:"Timeline"},{key:"cluster",label:"Grouped"}];function ft({c:e,onBack:t}){if(e.view==="filters")return Le(D,{children:[O(D.Navigation,{onBack:()=>e.setView("list")}),O(D.Content,{title:"Filters"})]});let r=e.rows.length>0;return Le(D,{children:[t?O(D.Navigation,{onBack:t}):null,O(D.Content,{title:"",noMargin:true,children:e.searchActive?O(D.Search,{value:e.query,onChangeText:e.setQuery,onCancel:()=>e.setQuery(""),clearOnlyWhenText:true,placeholder:"Filter logs\u2026 /regex/ -exclude",iconSize:14,inputProps:{onSubmitEditing:()=>e.setSearchActive(false)}}):O(Ro,{tabs:Do,activeTab:e.layoutMode,onTabChange:n=>e.setLayoutMode(n)})}),Le(D.Actions,{children:[O(T,{onPress:()=>e.setSearchActive(n=>!n),style:[J.actionBtn,e.searchActive&&J.actionBtnActive],accessibilityLabel:"Search logs",children:O(Io,{size:14,color:e.searchActive?M.color.accent:M.color.textSecondary})}),O(T,{onPress:()=>e.setView("filters"),style:[J.actionBtn,e.isLevelCustom&&J.actionBtnActive],accessibilityLabel:"Filters",children:O(jo,{size:14,color:e.isLevelCustom?M.color.accent:M.color.textSecondary})}),O(T,{onPress:e.clear,disabled:!r,style:[J.actionBtn,!r&&J.actionBtnDisabled],accessibilityLabel:"Clear console",children:O(zo,{size:14,color:r?M.color.textSecondary:M.color.textTertiary})})]})]})}var J=S.create({actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:M.color.buttonSurface,borderWidth:1,borderColor:M.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:M.color.accentSoft,borderColor:M.color.accentBorderStrong},actionBtnDisabled:{opacity:.55}});import{useCallback as Po,useRef as gt,useSyncExternalStore as Wo}from"react";import{night as I,Check as Fo,LOG_LIST_PRESET as Vo}from"@buoy-gg/shared-ui/web";import{memo as Go}from"react";import{useState as _o}from"react";import{monoFont as P,night as re}from"@buoy-gg/shared-ui/web";var Ko={baseContainer:"#0A0A0C",surfaceError:"rgba(255,69,58,0.15)",surfaceYellow:"rgba(255,235,59,0.13)",divider:re.color.fillTertiary,inputBackground:re.color.surfaceElevated,menuBackground:re.color.surface,onSurface:re.color.text,onSurfaceYellow:"#FFE9A3",onErrorContainer:"#FFB4AB",tokenSubtle:re.color.textSecondary,primary:"#40CCFF",valueNumber:"#FF9F1C",valueString:"#7EE787",valueBigint:"#A1A1A6",valueNode:"#F5F5F7",valueNullish:"#8E8E93",valuePreview:"#A1A1A6"},g=Ko,Uo={black:"#000",red:"rgb(237 78 76)",green:"rgb(1 200 1)",yellow:"rgb(210 192 87)",blue:"rgb(39 116 240)",magenta:"rgb(161 66 244)",cyan:"rgb(18 181 203)",gray:"rgb(207 208 208)",darkgray:"rgb(137 137 137)",lightred:"rgb(242 139 130)",lightgreen:"rgb(161 247 181)",lightyellow:"rgb(221 251 85)",lightblue:"rgb(102 157 246)",lightmagenta:"rgb(214 112 214)",lightcyan:"rgb(132 240 255)",white:"#fff"},pt={verbose:{text:g.tokenSubtle},info:{text:g.onSurface},warning:{background:g.surfaceYellow,text:g.onSurfaceYellow,icon:"warning"},error:{background:g.surfaceError,text:g.onErrorContainer,icon:"error"}};var mt=["black","red","green","yellow","blue","magenta","cyan","gray"],ht=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function yt(e){if(typeof e=="string")return e;if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e=="function")return`\u0192 ${e.name||"(anonymous)"}`;try{return JSON.stringify(e)}catch{return String(e)}}var Oe=/%([%_Oocsdfi])|\x1B\[([\d;]*)m/;function Yo(e){return Oe.test(e)}function bt(e){let t={},r=false;for(let n of e.split(";")){let o=n.indexOf(":");if(o===-1)continue;let i=n.slice(0,o).trim().toLowerCase(),a=n.slice(o+1).trim();if(!a)continue;let l=a.match(/var\(--console-color-([a-z]+)\)/);switch(l&&(a=Uo[l[1]]??a),i){case"color":t.color=a,r=true;break;case"background-color":case"background":t.backgroundColor=a,r=true;break;case"font-weight":t.fontWeight=a==="lighter"?"300":a,r=true;break;case"font-style":a==="italic"&&(t.fontStyle="italic",r=true);break;case"font-size":{let s=parseFloat(a);Number.isNaN(s)||(t.fontSize=s,r=true);break}case"text-decoration":case"text-decoration-line":a.includes("underline")&&a.includes("line-through")?t.textDecorationLine="underline line-through":a.includes("underline")?t.textDecorationLine="underline":a.includes("line-through")&&(t.textDecorationLine="line-through"),r=true;break;default:break}}return r?t:void 0}function Jo(e,t){let r=o=>{let i=t.get("text-decoration")??"";i.includes(o)||t.set("text-decoration",`${i} ${o}`)},n=o=>{let i=t.get("text-decoration")?.replace(` ${o}`,"");i?t.set("text-decoration",i):t.delete("text-decoration")};for(;e.length;){let o=e.shift();switch(o){case 0:t.clear();break;case 1:t.set("font-weight","bold");break;case 2:t.set("font-weight","lighter");break;case 3:t.set("font-style","italic");break;case 4:r("underline");break;case 9:r("line-through");break;case 22:t.delete("font-weight");break;case 23:t.delete("font-style");break;case 24:n("underline");break;case 29:n("line-through");break;case 38:case 48:if(e.shift()===2){let i=e.shift()??0,a=e.shift()??0,l=e.shift()??0;t.set(o===38?"color":"background-color",`rgb(${i},${a},${l})`)}break;case 39:case 49:t.delete(o===39?"color":"background-color");break;default:{let i=mt[o-30]??ht[o-90];if(i!==void 0)t.set("color",`var(--console-color-${i})`);else{let a=mt[o-40]??ht[o-100];a!==void 0&&t.set("background-color",`var(--console-color-${a})`)}break}}}}function qo(e,t){let r=e,n=[],o=new Map,i,a=s=>{if(!s)return;let c=n[n.length-1];if(c&&c.type==="string"&&Qo(c.style,i)){c.value+=s;return}n.push({type:"string",value:s,style:i})},l=0;for(let s=Oe.exec(r);s!==null;s=Oe.exec(r)){a(s.input.substring(0,s.index));let c,u=s[1];switch(u){case"%":a("%"),c="";break;case"s":l<t.length&&(c=yt(t[l++]));break;case"c":l<t.length&&(i=bt(yt(t[l++])),c="");break;case"o":case"O":l<t.length&&(n.push({type:"value",value:t[l++],mode:u==="O"?"generic":"optimal"}),c="");break;case"_":l<t.length&&(l++,c="");break;case"d":case"f":case"i":{if(l<t.length){let w=t[l++],E=typeof w!="number"?NaN:w;u!=="f"&&(E=Math.floor(E)),c=E}break}case void 0:{let w=(s[2]||"0").split(";").map(h=>h?parseInt(h,10):0);Jo(w,o);let E=[...o.entries()].map(([h,N])=>`${h}:${N.trimStart()}`).join(";");i=bt(E),c="";break}}c===void 0&&(a(s[0]),c=""),r=c+s.input.substring(s.index+s[0].length)}return a(r),{tokens:n,rest:t.slice(l)}}function Qo(e,t){return e===t?true:!e||!t?false:JSON.stringify(e)===JSON.stringify(t)}function Zo(e){if(e.length===0)return[];let t=[],r=e;if(typeof e[0]=="string"&&Yo(e[0])){let n=qo(e[0],e.slice(1));t=n.tokens,r=n.rest}for(let n of r)t.length>0&&t.push({type:"string",value:" "}),typeof n=="string"?t.push({type:"string",value:n}):t.push({type:"value",value:n,mode:"optimal"});return t}import{useState as Xo}from"react";import{jsx as B,jsxs as q}from"react/jsx-runtime";var vt=5,wt=6;function Ne(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";if(e instanceof Error)return"error";let t=typeof e;return t==="number"?"number":t==="bigint"?"bigint":t==="boolean"?"boolean":t==="string"?"string":t==="function"?"function":t==="symbol"?"symbol":"object"}var en={number:g.valueNumber,bigint:g.valueBigint,boolean:g.valueNumber,string:g.valueString,null:g.valueNullish,undefined:g.valueNullish,symbol:g.valueString,function:g.valueNode};function xt(e){if(Array.isArray(e))return"";let t=Object.getPrototypeOf(e);if(!t)return"Object";let r=t.constructor?.name;return!r||r==="Object"?"":r}function Be(e){switch(Ne(e)){case"string":return`'${e}'`;case"function":return`\u0192 ${e.name||""}`.trimEnd();case"symbol":return e.toString();case"bigint":return`${String(e)}n`;case"array":return`Array(${e.length})`;case"error":return e.name;case"object":{let t=xt(e);return t?`${t} {\u2026}`:"{\u2026}"}default:return String(e)}}function tn(e){if(Array.isArray(e)){let i=e.slice(0,wt).map(l=>Be(l)).join(", "),a=e.length>wt?", \u2026":"";return`(${e.length}) [${i}${a}]`}let t=Object.entries(e),r=t.slice(0,vt).map(([i,a])=>`${i}: ${Be(a)}`).join(", "),n=t.length>vt?", \u2026":"",o=xt(e);return`${o?`${o} `:""}{${r}${n}}`}function rn(e){let t=Ne(e);return t==="array"?e.length>0:t==="object"?Object.keys(e).length>0:t==="error"}var kt=({open:e})=>B(d,{style:[b.triangle,e&&b.triangleOpen],children:"\u25B6"});function Me({value:e,depth:t=0}){let[r,n]=Xo(false),o=Ne(e);if(o==="error"){let l=e,s=`${l.name}: ${l.message}`.split(`
|
|
16
|
+
`)[0],c=l.stack&&l.stack.trim()!==s.trim()?l.stack:void 0;return c?q(m,{style:b.objectContainer,children:[q(T,{style:b.objectHeader,activeOpacity:.6,onPress:()=>n(u=>!u),children:[B(kt,{open:r}),B(d,{style:[b.mono,b.errorHead],numberOfLines:r?void 0:1,children:s})]}),r?B(d,{style:[b.mono,b.errorStack],children:c}):null]}):B(d,{style:[b.mono,{color:g.onErrorContainer}],numberOfLines:1,children:s})}if(!rn(e)){let l=en[o]??g.onSurface;return B(d,{style:[b.mono,{color:l}],children:Be(e)})}let i=e,a=Array.isArray(i)?i.map((l,s)=>[String(s),l]):Object.entries(i);return q(m,{style:b.objectContainer,children:[q(T,{onPress:()=>n(l=>!l),activeOpacity:.6,style:b.objectHeader,children:[B(kt,{open:r}),B(d,{style:[b.mono,b.preview],numberOfLines:r?void 0:1,children:tn(i)})]}),r&&t<6?B(m,{style:b.children,children:a.map(([l,s])=>q(m,{style:b.propertyRow,children:[q(d,{style:[b.mono,b.propertyKey],children:[l,":"]}),B(m,{style:b.propertyValue,children:B(Me,{value:s,depth:t+1})})]},l))}):null]})}var on={fontFamily:P,fontSize:12,lineHeight:16},b=S.create({mono:on,objectContainer:{flexDirection:"column"},objectHeader:{flexDirection:"row",alignItems:"flex-start"},triangle:{color:g.tokenSubtle,fontSize:8,lineHeight:16,width:12},triangleOpen:{transform:[{rotate:"90deg"}]},preview:{color:g.valuePreview,fontStyle:"italic",flexShrink:1},errorHead:{color:g.onErrorContainer,flexShrink:1},errorStack:{color:g.tokenSubtle,marginLeft:14,marginTop:1},children:{marginLeft:14,flexDirection:"column"},propertyRow:{flexDirection:"row",alignItems:"flex-start"},propertyKey:{color:g.valueNode,marginRight:6},propertyValue:{flexShrink:1}});import{jsx as y,jsxs as Q}from"react/jsx-runtime";function nn(e){let t=new Date(e),r=(n,o=2)=>String(n).padStart(o,"0");return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}.${r(t.getMilliseconds(),3)}`}function ln({icon:e,color:t}){return y(d,{style:[f.levelIcon,{color:t}],children:e==="warning"?"\u26A0":"\u2298"})}function an({count:e,color:t}){return y(m,{style:[f.repeatBadge,{borderColor:t}],children:y(d,{style:[f.repeatBadgeText,{color:t}],children:e})})}var St=Go(function({row:e,showTimestamps:t,onToggleGroup:r,onToggleCluster:n}){let{entry:o}=e,i=pt[o.level],a=o.level==="error"||o.level==="warning",l=i.text,[s,c]=_o(o.method==="trace");if(e.clusterHeader){let p=e.clusterHeader;return y(T,{style:[f.wrapper,f.dividerTop],activeOpacity:.7,onPress:()=>n(p.key),children:Q(m,{style:f.rowWrapper,children:[y(d,{style:[f.originGutter,{color:e.originColor}],children:p.expanded?"\u25BC":"\u25B6"}),y(m,{style:f.messageColumn,children:Q(m,{style:f.messageLine,children:[y(d,{style:[f.text,f.clusterTitle,{color:e.originColor}],children:e.originLabel}),Q(d,{style:f.clusterCount,children:[" \xB7 ",p.count," logs"]})]})})]})})}let u=Zo(o.args),w=!!o.stack&&(a||o.method==="trace"),E=y(m,{style:[f.contentWrap,!s&&f.contentWrapClamped],children:u.map((p,A)=>p.type==="string"?y(d,{style:[f.text,{color:l},e.isGroupHeader&&f.groupTitle,p.style],children:p.value},A):y(Me,{value:p.value,generic:p.mode==="generic"},A))}),h=Q(m,{style:f.messageColumn,children:[e.originLabel?y(d,{style:[f.originLabel,{color:e.originColor}],numberOfLines:1,children:e.originLabel}):null,Q(m,{style:f.messageLine,children:[e.isGroupHeader?y(d,{style:[f.groupTriangle,{color:l}],children:e.groupCollapsed?"\u25B6":"\u25BC"}):null,i.icon?y(ln,{icon:i.icon,color:l}):null,t?y(d,{style:f.timestamp,children:nn(o.timestamp)}):null,w?y(d,{style:[f.stackTriangle,{color:l}],children:s?"\u25BC":"\u25B6"}):null,E,e.repeatCount>1?y(an,{count:e.repeatCount,color:l}):null]}),w&&s?y(m,{style:f.stackTrace,children:(o.stack??"").split(`
|
|
17
|
+
`).filter(p=>p.trim()).map((p,A)=>y(d,{style:f.stackFrame,children:p.trim()},A))}):null]}),N=[f.wrapper,i.background?{backgroundColor:i.background}:f.dividerTop],G=Array.from({length:e.depth},(p,A)=>y(m,{style:f.nestingMarker},A)),$=e.lanes?y(m,{style:f.laneGutter,children:e.lanes.map((p,A)=>y(d,{style:[f.laneCell,p.color?{color:p.color}:null],children:p.glyph},A))}):e.bracketGlyph?y(d,{style:[f.originGutter,{color:e.originColor}],children:e.bracketGlyph}):null,F=Q(m,{style:f.rowWrapper,children:[$,G,h]}),j=`buoy-console-row-${o.id}`,oe=[e.originLabel,u.find(p=>p.type==="string")?.value].filter(Boolean).join(" \u2014 ").slice(0,80);if(e.isGroupHeader&&e.groupId!==void 0){let p=e.groupId;return y(T,{style:N,activeOpacity:.7,onPress:()=>r(p,!!e.groupCollapsed),testID:j,accessibilityLabel:oe||"Console group",children:F})}return y(T,{style:N,activeOpacity:.7,onPress:()=>c(p=>!p),testID:j,accessibilityLabel:oe||"Console message",children:F})},(e,t)=>e.row.key===t.row.key&&e.row.lanes===t.row.lanes&&e.row.repeatCount===t.row.repeatCount&&e.row.groupCollapsed===t.row.groupCollapsed&&e.row.depth===t.row.depth&&e.row.bracketGlyph===t.row.bracketGlyph&&e.row.originLabel===t.row.originLabel&&e.row.clusterHeader?.count===t.row.clusterHeader?.count&&e.row.clusterHeader?.expanded===t.row.clusterHeader?.expanded&&e.showTimestamps===t.showTimestamps&&e.onToggleGroup===t.onToggleGroup&&e.onToggleCluster===t.onToggleCluster),f=S.create({wrapper:{paddingVertical:2,paddingRight:8,minHeight:18},dividerTop:{borderTopWidth:S.hairlineWidth,borderTopColor:g.divider},rowWrapper:{flexDirection:"row",alignItems:"flex-start"},originGutter:{width:11,fontFamily:P,fontSize:13,lineHeight:18,textAlign:"center"},laneGutter:{flexDirection:"row"},laneCell:{width:9,fontFamily:P,fontSize:13,lineHeight:18,textAlign:"center"},originLabel:{fontFamily:P,fontSize:10,lineHeight:16,marginBottom:1,opacity:.9},nestingMarker:{width:14,alignSelf:"stretch",borderRightWidth:S.hairlineWidth,borderRightColor:g.divider,marginLeft:2},messageColumn:{flex:1,flexDirection:"column",paddingLeft:6},messageLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start"},contentWrap:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start",flexShrink:1},contentWrapClamped:{flexWrap:"nowrap",overflow:"hidden",maxHeight:16},text:{fontFamily:P,fontSize:12,lineHeight:16},groupTitle:{fontWeight:"bold"},clusterTitle:{fontWeight:"600"},clusterCount:{color:g.tokenSubtle,fontFamily:P,fontSize:12,lineHeight:16},groupTriangle:{fontSize:9,lineHeight:16,marginRight:4},stackTriangle:{fontSize:8,lineHeight:16,marginRight:4},levelIcon:{fontSize:12,lineHeight:16,marginRight:5},timestamp:{color:g.tokenSubtle,fontFamily:P,fontSize:11,lineHeight:16,marginRight:6},repeatBadge:{borderWidth:1,borderRadius:9,paddingHorizontal:5,minWidth:16,alignItems:"center",justifyContent:"center",marginLeft:6,marginTop:1},repeatBadgeText:{fontSize:10,fontWeight:"700",lineHeight:14},stackTrace:{marginTop:2,marginLeft:12},stackFrame:{color:g.tokenSubtle,fontFamily:P,fontSize:11,lineHeight:15}});import{jsx as v,jsxs as He}from"react/jsx-runtime";function Ct({c:e}){return e.view==="filters"?v(cn,{c:e}):v(sn,{c:e})}function sn({c:e}){let t=gt(null),r=gt(true),n=Po(({item:o})=>v(St,{row:o,showTimestamps:e.showTimestamps,onToggleGroup:e.onToggleGroup,onToggleCluster:e.onToggleCluster}),[e.showTimestamps,e.onToggleGroup,e.onToggleCluster]);return v(Ae,{ref:t,data:e.rows,keyExtractor:o=>o.key,renderItem:n,style:k.list,...Vo,onContentSizeChange:()=>{r.current&&t.current?.scrollToEnd({animated:false})},onScroll:o=>{let{contentOffset:i,contentSize:a,layoutMeasurement:l}=o.nativeEvent,s=a.height-(i.y+l.height);r.current=s<40},scrollEventThrottle:100})}function Re({on:e,label:t,subtext:r,onPress:n}){return He(T,{style:k.row,onPress:n,activeOpacity:.7,children:[v(m,{style:[k.checkbox,e&&k.checkboxOn],children:e?v(Fo,{size:12,color:I.color.onAccent,strokeWidth:3}):null}),He(m,{style:k.rowTextCol,children:[v(d,{style:k.rowLabel,children:t}),r?v(d,{style:k.rowSubtext,children:r}):null]})]})}function Tt({text:e}){return v(d,{style:k.sectionLabel,children:e})}function cn({c:e}){let t=Wo(it,Se,Se),r=n=>e.setLevelsMask({...e.levelsMask,[n]:!e.levelsMask[n]});return He(dt,{style:k.subView,contentContainerStyle:k.subViewContent,children:[v(Tt,{text:"Log levels"}),v(T,{style:k.presetRow,onPress:()=>e.setLevelsMask({...Te}),children:v(d,{style:k.presetText,children:"Default (hide verbose)"})}),v(T,{style:k.presetRow,onPress:()=>e.setLevelsMask({...Ce}),children:v(d,{style:k.presetText,children:"All levels"})}),Ee.map(n=>v(Re,{on:e.levelsMask[n],label:lt[n],onPress:()=>r(n)},n)),v(m,{style:k.divider}),v(Tt,{text:"Settings"}),v(Re,{on:e.showTimestamps,label:"Show timestamps",onPress:()=>e.setShowTimestamps(n=>!n)}),v(Re,{on:t,label:"Preserve log",subtext:"Do not clear log on reload",onPress:()=>nt(!t)})]})}var k=S.create({list:{flex:1,backgroundColor:"transparent"},subView:{flex:1,backgroundColor:"transparent"},subViewContent:{padding:12},sectionLabel:{color:I.color.textTertiary,fontSize:11,textTransform:"uppercase",letterSpacing:.5,marginTop:4,marginBottom:4,paddingHorizontal:8},presetRow:{paddingVertical:10,paddingHorizontal:8},presetText:{color:I.color.accent,fontSize:14,fontWeight:"600"},divider:{height:S.hairlineWidth,backgroundColor:I.color.border,marginVertical:6},row:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:8,gap:12},rowTextCol:{flexDirection:"column",flex:1},rowLabel:{color:I.color.text,fontSize:14},rowSubtext:{color:I.color.textTertiary,fontSize:12,marginTop:1},checkbox:{width:18,height:18,borderRadius:4,borderWidth:1,borderColor:I.color.fillTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:I.color.accent,borderColor:I.color.accent}});import{jsx as Ie}from"react/jsx-runtime";function Et({visible:e,onClose:t,onBack:r,onMinimize:n,persistenceKey:o}){let i=ct();return Ie(Dt,{visible:e,onClose:t,onMinimize:n,persistenceKey:o,header:{showToggleButton:true,customContent:Ie(ft,{c:i,onBack:r})},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ie(Ct,{c:i})})}import{createToolFactory as un,defineToolPreset as dn}from"@buoy-gg/shared-ui/web";import{jsx as fn}from"react/jsx-runtime";var $t=globalThis,gn=typeof $t.ErrorUtils?.setGlobalHandler=="function"||typeof $t.RN$registerExceptionListener=="function";gn&&typeof Pe<"u"&&Pe&&se();var At=dn({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:Fe,icon:({size:e})=>fn(We,{size:e}),component:Et}),pn=un(At);import{useEffect as mn}from"react";import{getAccountAccess as hn,subscribeAccountAccess as yn}from"@buoy-gg/shared-ui/web";var Lt=0;function bn(){return mn(()=>{++Lt;let e=true,t=()=>{if(!e)return;let n=hn();if(n.status==="locked"){ve(),ee();return}se(),n.status==="admitted"&&ot()},r=yn(t);return t(),()=>{e=false,r(),--Lt===0&&ve()}},[]),null}import{macOSColors as vn,windowDragProps as wn}from"@buoy-gg/shared-ui/web";import{jsx as je,jsxs as xn}from"react/jsx-runtime";function kn(){let e=ct();return xn(m,{style:Ot.container,children:[je(m,{style:Ot.headerBar,...wn,children:je(ft,{c:e})}),je(Ct,{c:e})]})}var Ot=S.create({container:{flex:1,backgroundColor:"transparent"},headerBar:{paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:S.hairlineWidth,borderBottomColor:vn.border.default}});import{useSyncExternalStore as Sn,useEffect as Cn}from"react";function Nt(){return Cn(()=>{se()},[]),{logs:Sn(ce,K,K)}}import{night as W,ToolEmptyState as Tn,monoFont as En}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as de}from"react/jsx-runtime";var Bt={verbose:"#9b9b9b",info:W.color.text,warning:"#e2c08d",error:"#f48771"};function $n(e){let t=new Date(e),r=(n,o=2)=>String(n).padStart(o,"0");return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}.${r(t.getMilliseconds(),3)}`}function An(){let{logs:e}=Nt(),t=({item:r})=>de(m,{style:H.row,children:[V(d,{style:H.time,children:$n(r.timestamp)}),V(d,{style:[H.level,{color:Bt[r.level]}],children:r.level.toUpperCase()}),V(d,{style:[H.message,{color:Bt[r.level]}],numberOfLines:3,children:r.message})]});return de(m,{style:H.container,children:[de(m,{style:H.header,children:[de(d,{style:H.headerTitle,children:["Console (",e.length,")"]}),V(T,{onPress:()=>ee(),style:H.clearButton,children:V(d,{style:H.clearText,children:"Clear"})})]}),V(Ae,{data:e,keyExtractor:r=>String(r.id),renderItem:t,ListEmptyComponent:V(Tn,{testID:"buoy-console-empty",otto:"printing",title:"No console logs captured yet",message:"console.log, .warn and .error from your app land here as they run."}),contentContainerStyle:e.length===0?H.emptyContainer:void 0})]})}var H=S.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:S.hairlineWidth,borderBottomColor:W.color.border},headerTitle:{color:W.color.text,fontSize:13,fontWeight:"600"},clearButton:{paddingHorizontal:10,paddingVertical:4,borderRadius:4,backgroundColor:W.color.surfaceElevated},clearText:{color:W.color.text,fontSize:12},row:{flexDirection:"row",paddingHorizontal:12,paddingVertical:4,borderBottomWidth:S.hairlineWidth,borderBottomColor:W.color.separator,gap:8},time:{color:W.color.textTertiary,fontSize:11,fontVariant:["tabular-nums"],minWidth:86},level:{fontSize:11,fontWeight:"700",minWidth:44},message:{flex:1,fontSize:12,fontFamily:En},empty:{color:W.color.textTertiary,fontSize:13,textAlign:"center"},emptyContainer:{flexGrow:1,alignItems:"center",justifyContent:"center"}});import{createSyncAdapter as Ln,memoByIdentity as On,newestFitting as Nn,sizeOrStub as Bn}from"@buoy-gg/shared-ui/web";var Mn=1.5*1024*1024,Hn=16*1024,Rn=Object.freeze({__buoyTruncated:true,note:"Log payload omitted \u2014 inspect it on-device."}),In=On(e=>{let t={...e,args:Ve(e.args),message:X(e.message),stack:e.stack?X(e.stack,4096):e.stack};return Bn(t,Hn,()=>({...t,args:[Rn]}))});function jn(e){return Nn(e,{toWire:In,budget:Mn,baseBytes:16})}var zn=Ln({version:1,getSnapshot(){return{entries:jn(K())}},subscribe(e){return ce(e)},actions:{clearEntries(){return ee(),{cleared:true}}}});export{Fe as CONSOLE_ICON_COLOR,We as ConsoleIcon,An as ConsoleLogList,St as ConsoleMessageRow,Et as ConsoleModal,bn as ConsoleRoot,Me as ConsoleValue,kn as ConsoleView,ee as clearEntries,zn as consoleSyncAdapter,g as consoleTheme,At as consoleToolPreset,pn as createConsoleTool,K as getEntries,Se as getPreserveLog,ot as initConsolePersistence,se as installConsoleCapture,Ze as installFatalErrorCapture,pt as levelStyles,yr as onClear,hr as replaceEntries,nt as setPreserveLog,ce as subscribe,it as subscribePreserveLog,ve as uninstallConsoleCapture,Nt as useConsoleLogs,st as useConsoleMessages};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/console",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.57",
|
|
4
4
|
"description": "Inspect captured JavaScript console messages in React Native. Capture and release-build support depend on setup and plan.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
15
|
+
"@buoy-gg/shared-ui": "^7.0.57"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "*"
|