@buoy-gg/console 7.0.74 → 7.0.76
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/commonjs/preset.js +1 -1
- package/lib/commonjs/store/browserBuild.js +1 -0
- package/lib/commonjs/store/browserBuild.web.js +1 -0
- package/lib/commonjs/store/consoleLogStore.js +4 -4
- package/lib/module/preset.js +1 -1
- package/lib/module/store/browserBuild.js +1 -0
- package/lib/module/store/browserBuild.web.js +1 -0
- package/lib/module/store/consoleLogStore.js +4 -4
- package/lib/typescript/store/browserBuild.d.ts +2 -0
- package/lib/typescript/store/browserBuild.web.d.ts +2 -0
- package/lib/typescript/store/consoleLogStore.d.ts +8 -5
- package/lib/web/index.mjs +12 -12
- package/package.json +2 -2
package/lib/commonjs/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createConsoleTool=exports.consoleToolPreset=void 0;var _ConsoleIcon=require("./components/ConsoleIcon");var _ConsoleModal=require("./components/ConsoleModal");var _consoleLogStore=require("./store/consoleLogStore");var _sharedUi=require("@buoy-gg/shared-ui");var _jsxRuntime=require("react/jsx-runtime");const rnGlobals=globalThis;const isReactNativeRuntime=typeof rnGlobals.ErrorUtils?.setGlobalHandler==="function"||typeof rnGlobals.RN$registerExceptionListener==="function";if(isReactNativeRuntime&&typeof __DEV__!=="undefined"&&__DEV__){(0,_consoleLogStore.installConsoleCapture)()}const consoleToolPreset=exports.consoleToolPreset=(0,_sharedUi.defineToolPreset)({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:_ConsoleIcon.CONSOLE_ICON_COLOR,icon:({size:o})=>(0,_jsxRuntime.jsx)(_ConsoleIcon.ConsoleIcon,{size:o}),component:_ConsoleModal.ConsoleModal});const createConsoleTool=exports.createConsoleTool=(0,_sharedUi.createToolFactory)(consoleToolPreset);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createConsoleTool=exports.consoleToolPreset=void 0;var _ConsoleIcon=require("./components/ConsoleIcon");var _ConsoleModal=require("./components/ConsoleModal");var _consoleLogStore=require("./store/consoleLogStore");var _sharedUi=require("@buoy-gg/shared-ui");var _jsxRuntime=require("react/jsx-runtime");const rnGlobals=globalThis;const isReactNativeRuntime=typeof rnGlobals.ErrorUtils?.setGlobalHandler==="function"||typeof rnGlobals.RN$registerExceptionListener==="function";if(isReactNativeRuntime&&typeof __DEV__!=="undefined"&&__DEV__){(0,_consoleLogStore.installConsoleCapture)()}else if(typeof __DEV__!=="undefined"&&__DEV__){(0,_consoleLogStore.installFatalErrorCapture)()}const consoleToolPreset=exports.consoleToolPreset=(0,_sharedUi.defineToolPreset)({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:_ConsoleIcon.CONSOLE_ICON_COLOR,icon:({size:o})=>(0,_jsxRuntime.jsx)(_ConsoleIcon.ConsoleIcon,{size:o}),component:_ConsoleModal.ConsoleModal});const createConsoleTool=exports.createConsoleTool=(0,_sharedUi.createToolFactory)(consoleToolPreset);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isBrowserBuild=void 0;const isBrowserBuild=exports.isBrowserBuild=false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isBrowserBuild=void 0;const isBrowserBuild=exports.isBrowserBuild=true;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearEntries=clearEntries;exports.getEntries=getEntries;exports.getPreserveLog=getPreserveLog;exports.initConsolePersistence=initConsolePersistence;exports.installConsoleCapture=installConsoleCapture;exports.installFatalErrorCapture=installFatalErrorCapture;exports.onClear=onClear;exports.replaceEntries=replaceEntries;exports.setPreserveLog=setPreserveLog;exports.subscribe=subscribe;exports.subscribePreserveLog=subscribePreserveLog;exports.uninstallConsoleCapture=uninstallConsoleCapture;var _sharedUi=require("@buoy-gg/shared-ui");var React=_interopRequireWildcard(require("react"));var _sanitize=require("./sanitize");var _origin=require("../devtools/origin");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var
|
|
2
|
-
\u2026+${o} more frames`:"")}function asComponentError(e){if(!(e instanceof Error))return null;const t=e;return t.isComponentError||typeof t.componentStack==="string"?t:null}function record(e,t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearEntries=clearEntries;exports.getEntries=getEntries;exports.getPreserveLog=getPreserveLog;exports.initConsolePersistence=initConsolePersistence;exports.installConsoleCapture=installConsoleCapture;exports.installFatalErrorCapture=installFatalErrorCapture;exports.onClear=onClear;exports.replaceEntries=replaceEntries;exports.setPreserveLog=setPreserveLog;exports.subscribe=subscribe;exports.subscribePreserveLog=subscribePreserveLog;exports.uninstallConsoleCapture=uninstallConsoleCapture;var _sharedUi=require("@buoy-gg/shared-ui");var React=_interopRequireWildcard(require("react"));var _sanitize=require("./sanitize");var _browserBuild=require("./browserBuild");var _origin=require("../devtools/origin");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(n,l){if(!l&&n&&n.__esModule)return n;var a,i,c={__proto__:null,default:n};if(null===n||"object"!=typeof n&&"function"!=typeof n)return c;if(a=l?o:r){if(a.has(n))return a.get(n);a.set(n,c)}for(const s in n)"default"!==s&&{}.hasOwnProperty.call(n,s)&&((i=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(n,s))&&(i.get||i.set)?a(c,s,i):c[s]=n[s]);return c})(e,t)}const METHODS=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"];const STACK_METHODS=new Set(["error","warn","trace","assert"]);const METHOD_LEVEL={error:"error",assert:"error",warn:"warning",debug:"verbose",log:"info",info:"info",trace:"info",dir:"info",table:"info",group:"info",groupCollapsed:"info",groupEnd:"info"};const MAX_ENTRIES=1e3;const store=(0,_sharedUi.createToolStore)({id:"console",max:MAX_ENTRIES,order:"append",coalesce:"frame"});let installed=false;let fatalInstalled=false;let captureDisabledByUser=false;const originals={};const loggedErrors=new WeakSet;const uncaughtErrors=new WeakSet;let browserErrorsInstalled=false;function formatArg(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 formatArgs(e){return e.map(formatArg).join(" ")}function cleanStack(e){if(!e)return void 0;return e.split("\n").slice(3).join("\n")||void 0}function captureOwnerStack(){try{const e=Reflect.get(React,"captureOwnerStack");return typeof e==="function"?e()??void 0:void 0}catch{return void 0}}const COMPONENT_STACK_FRAMES=8;function compactComponentStack(e){const t=e.split("\n").map(n=>n.trim()).filter(Boolean).map(n=>n.replace(/\s*\((?:https?:|\/).*$/,""));const r=t.slice(0,COMPONENT_STACK_FRAMES);const o=t.length-r.length;return r.map(n=>` ${n}`).join("\n")+(o>0?`
|
|
2
|
+
\u2026+${o} more frames`:"")}function asComponentError(e){if(!(e instanceof Error))return null;const t=e;return t.isComponentError||typeof t.componentStack==="string"?t:null}function record(e,t,r){if((0,_sharedUi.isBuoyLog)(t))return;const o=e==="error"?t.filter(s=>s instanceof Error):[];if(o.some(s=>uncaughtErrors.has(s)))return;for(const s of o)loggedErrors.add(s);const n=new Error().stack;const l=[record.name,r?.name??""];const a=(0,_origin.parseOrigin)(n,captureOwnerStack(),(0,_origin.consoleWrapperDepth)(console[e],r),l);const i=e==="error"?asComponentError(t[0]):null;if(i){const s=fatalKey(i.name,i.message);const u=i.componentStack?`
|
|
3
3
|
|
|
4
4
|
This error is located at:
|
|
5
|
-
${compactComponentStack(
|
|
5
|
+
${compactComponentStack(i.componentStack)}`:"";pushFatal({id:store.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",i],message:`[RENDER ERROR] ${s}${u}`,timestamp:Date.now(),stack:i.stack,origin:a},isDuplicateFatal(`[RENDER ERROR] ${s}`));return}const c={id:store.allocId(),method:e,level:METHOD_LEVEL[e],args:t,message:formatArgs(t),timestamp:Date.now(),stack:STACK_METHODS.has(e)?cleanStack(n):void 0,origin:a};store.add(c);scheduleSave();if(c.level==="error")store.flushSync()}const FATAL_DEDUPE_MS=2e3;let lastFatalKey="";let lastFatalAt=0;function fatalKey(e,t){const r=t.trim();if(e&&r.startsWith(`${e}: `))return r;return e?`${e}: ${r}`:r}function isDuplicateFatal(e){const t=Date.now();if(e===lastFatalKey&&t-lastFatalAt<FATAL_DEDUPE_MS)return true;lastFatalKey=e;lastFatalAt=t;return false}function pushFatal(e,t=false){store.add(e);scheduleSave();if(!t)store.flushSync(true)}function recordFatalError(e,t){const r=e instanceof Error?e:void 0;const o=r?fatalKey(r.name,r.message):formatArg(e);const n=isDuplicateFatal(`${t} ${o}`);pushFatal({id:store.allocId(),method:"error",level:"error",args:[t,e],message:`${t} ${o}`,timestamp:Date.now(),stack:r?.stack,fatal:true},n)}function formatNativeStack(e){const t=e.extraData?.rawStack;if(typeof t==="string"&&t.length>0)return t;if(!Array.isArray(e.stack)||e.stack.length===0)return void 0;return e.stack.map(r=>{const o=r.lineNumber!=null?`${r.file??"?"}:${r.lineNumber}:${r.column??0}`:r.file??"?";return` at ${r.methodName||"<anonymous>"} (${o})`}).join("\n")}function recordNativeException(e){const t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]";const r=fatalKey(e.name??void 0,e.originalMessage??e.message??"Unknown error");const o=isDuplicateFatal(`${t} ${r}`);const n=typeof e.componentStack==="string"&&e.componentStack.trim()?`
|
|
6
6
|
|
|
7
7
|
This error is located at:
|
|
8
|
-
${compactComponentStack(e.componentStack)}`:"";const
|
|
8
|
+
${compactComponentStack(e.componentStack)}`:"";const l=`${t} ${r}${n}`;pushFatal({id:store.allocId(),method:"error",level:"error",args:[t,r,...n?[n.trim()]:[]],message:l,timestamp:Date.now(),stack:formatNativeStack(e),fatal:true},o)}function installNativeExceptionCapture(){const e=globalThis.RN$registerExceptionListener;if(typeof e!=="function")return false;e(t=>{try{if(!captureDisabledByUser)recordNativeException(t)}catch{}});return true}function installBrowserErrorCapture(){const e=globalThis;if(browserErrorsInstalled||!_browserBuild.isBrowserBuild||typeof e.addEventListener!=="function")return;browserErrorsInstalled=true;const t=(r,o)=>{if(captureDisabledByUser)return;if(r instanceof Error){if(loggedErrors.has(r)||uncaughtErrors.has(r))return;uncaughtErrors.add(r)}try{recordFatalError(r,o)}catch{}};e.addEventListener("error",r=>t(r.error??r.message,"[UNCAUGHT]"));e.addEventListener("unhandledrejection",r=>t(r.reason,"[UNHANDLED REJECTION]"))}function installFatalErrorCapture(){installBrowserErrorCapture();if(fatalInstalled)return;const e=installNativeExceptionCapture();const t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!=="function"){fatalInstalled=e;return}fatalInstalled=true;const r=typeof t.getGlobalHandler==="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((o,n)=>{try{if(!captureDisabledByUser)recordFatalError(o,n===false?"[UNCAUGHT]":"[FATAL]")}catch{}if(typeof r==="function")r(o,n)})}function installConsoleCapture(){if((0,_sharedUi.getAccountAccess)().status==="locked")return;captureDisabledByUser=false;installFatalErrorCapture();if(installed)return;installed=true;for(const e of METHODS){const t=console[e];if(typeof t!=="function")continue;originals[e]=t;console[e]=function r(...o){record(e,o,r);t.apply(console,o)}}}function uninstallConsoleCapture(){captureDisabledByUser=true;if(!installed)return;installed=false;for(const e of METHODS){const t=originals[e];if(t)console[e]=t;delete originals[e]}}function subscribe(e){return store.subscribe(e)}function getEntries(){return store.getSnapshot()}function clearEntries(){void clearSavedBuffer();store.clear()}function replaceEntries(e){store.set(e.filter(t=>!(0,_sharedUi.isBuoyLog)(t.args??[t.message])))}function onClear(e){return store.onClear(e)}const PRESERVE_KEY="@react_buoy_console_preserve";const BUFFER_KEY="@react_buoy_console_buffer";const SAVE_DEBOUNCE_MS=600;let preserveLog=false;let persistenceReady=false;let persistenceGeneration=0;let bufferWrites=Promise.resolve();const preserveListeners=new Set;let saveTimer=null;function emitPreserve(){for(const e of preserveListeners)e()}function scheduleSave(){if(!preserveLog||!(0,_sharedUi.hasAccountAccess)())return;if(saveTimer)clearTimeout(saveTimer);saveTimer=setTimeout(saveBuffer,SAVE_DEBOUNCE_MS)}async function saveBuffer(){saveTimer=null;if(!preserveLog||!(0,_sharedUi.hasAccountAccess)())return;try{const e=store.getSnapshot().map(r=>({...r,args:(0,_sanitize.sanitizeArgs)(r.args)}));const t=persistenceGeneration;bufferWrites=bufferWrites.then(async()=>{if(t!==persistenceGeneration||!preserveLog||!(0,_sharedUi.hasAccountAccess)())return;await _sharedUi.persistentStorage.setItem(BUFFER_KEY,JSON.stringify(e))}).catch(()=>{});await bufferWrites}catch{}}async function clearSavedBuffer(){persistenceGeneration++;persistenceReady=false;try{bufferWrites=bufferWrites.then(()=>_sharedUi.persistentStorage.removeItem(BUFFER_KEY)).catch(()=>{});await bufferWrites}catch{}}async function initConsolePersistence(){if(persistenceReady||!(0,_sharedUi.hasAccountAccess)())return;persistenceReady=true;const e=persistenceGeneration;try{preserveLog=await _sharedUi.persistentStorage.getItem(PRESERVE_KEY)==="true"}catch{preserveLog=false}if(e!==persistenceGeneration||!(0,_sharedUi.hasAccountAccess)()){persistenceReady=false;return}emitPreserve();if(!preserveLog){await clearSavedBuffer();return}try{const t=await _sharedUi.persistentStorage.getItem(BUFFER_KEY);if(e!==persistenceGeneration||!(0,_sharedUi.hasAccountAccess)()){persistenceReady=false;return}if(t){const r=JSON.parse(t);if(Array.isArray(r)&&r.length){store.update(o=>[...r,...o].filter(n=>!(0,_sharedUi.isBuoyLog)(n.args??[n.message])));store.bumpIdAbove(Math.max(...r.map(o=>o.id)))}}}catch{}}function getPreserveLog(){return preserveLog}function setPreserveLog(e){if(preserveLog===e)return;preserveLog=e;emitPreserve();_sharedUi.persistentStorage.setItem(PRESERVE_KEY,String(e)).catch(()=>{});if(e)saveBuffer();else clearSavedBuffer()}function subscribePreserveLog(e){preserveListeners.add(e);return()=>{preserveListeners.delete(e)}}
|
package/lib/module/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{ConsoleIcon as t,CONSOLE_ICON_COLOR as
|
|
1
|
+
"use strict";import{ConsoleIcon as t,CONSOLE_ICON_COLOR as r}from"./components/ConsoleIcon";import{ConsoleModal as n}from"./components/ConsoleModal";import{installConsoleCapture as s,installFatalErrorCapture as i}from"./store/consoleLogStore";import{createToolFactory as l,defineToolPreset as c}from"@buoy-gg/shared-ui";import{jsx as a}from"react/jsx-runtime";const o=globalThis;const _=typeof o.ErrorUtils?.setGlobalHandler==="function"||typeof o.RN$registerExceptionListener==="function";if(_&&typeof __DEV__!=="undefined"&&__DEV__){s()}else if(typeof __DEV__!=="undefined"&&__DEV__){i()}export const consoleToolPreset=c({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:r,icon:({size:e})=>a(t,{size:e}),component:n});export const createConsoleTool=l(consoleToolPreset);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const isBrowserBuild=false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const isBrowserBuild=true;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";import{isBuoyLog as
|
|
2
|
-
\u2026+${r} more frames`:"")}function
|
|
1
|
+
"use strict";import{isBuoyLog as y,getAccountAccess as j,hasAccountAccess as l}from"@buoy-gg/shared-ui";import*as W from"react";import{createToolStore as J,persistentStorage as p}from"@buoy-gg/shared-ui";import{sanitizeArgs as V}from"./sanitize";import{isBrowserBuild as z}from"./browserBuild";import{consoleWrapperDepth as Y,parseOrigin as X}from"../devtools/origin";const D=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"];const q=new Set(["error","warn","trace","assert"]);const Q={error:"error",assert:"error",warn:"warning",debug:"verbose",log:"info",info:"info",trace:"info",dir:"info",table:"info",group:"info",groupCollapsed:"info",groupEnd:"info"};const Z=1e3;const s=J({id:"console",max:Z,order:"append",coalesce:"frame"});let g=false;let S=false;let m=false;const w={};const _=new WeakSet;const b=new WeakSet;let x=false;function L(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 ee(e){return e.map(L).join(" ")}function te(e){if(!e)return void 0;return e.split("\n").slice(3).join("\n")||void 0}function ne(){try{const e=Reflect.get(W,"captureOwnerStack");return typeof e==="function"?e()??void 0:void 0}catch{return void 0}}const re=8;function O(e){const t=e.split("\n").map(o=>o.trim()).filter(Boolean).map(o=>o.replace(/\s*\((?:https?:|\/).*$/,""));const n=t.slice(0,re);const r=t.length-n.length;return n.map(o=>` ${o}`).join("\n")+(r>0?`
|
|
2
|
+
\u2026+${r} more frames`:"")}function oe(e){if(!(e instanceof Error))return null;const t=e;return t.isComponentError||typeof t.componentStack==="string"?t:null}function I(e,t,n){if(y(t))return;const r=e==="error"?t.filter(a=>a instanceof Error):[];if(r.some(a=>b.has(a)))return;for(const a of r)_.add(a);const o=new Error().stack;const h=[I.name,n?.name??""];const N=X(o,ne(),Y(console[e],n),h);const c=e==="error"?oe(t[0]):null;if(c){const a=v(c.name,c.message);const K=c.componentStack?`
|
|
3
3
|
|
|
4
4
|
This error is located at:
|
|
5
|
-
${
|
|
5
|
+
${O(c.componentStack)}`:"";k({id:s.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",c],message:`[RENDER ERROR] ${a}${K}`,timestamp:Date.now(),stack:c.stack,origin:N},$(`[RENDER ERROR] ${a}`));return}const T={id:s.allocId(),method:e,level:Q[e],args:t,message:ee(t),timestamp:Date.now(),stack:q.has(e)?te(o):void 0,origin:N};s.add(T);P();if(T.level==="error")s.flushSync()}const se=2e3;let U="";let F=0;function v(e,t){const n=t.trim();if(e&&n.startsWith(`${e}: `))return n;return e?`${e}: ${n}`:n}function $(e){const t=Date.now();if(e===U&&t-F<se)return true;U=e;F=t;return false}function k(e,t=false){s.add(e);P();if(!t)s.flushSync(true)}function H(e,t){const n=e instanceof Error?e:void 0;const r=n?v(n.name,n.message):L(e);const o=$(`${t} ${r}`);k({id:s.allocId(),method:"error",level:"error",args:[t,e],message:`${t} ${r}`,timestamp:Date.now(),stack:n?.stack,fatal:true},o)}function ie(e){const t=e.extraData?.rawStack;if(typeof t==="string"&&t.length>0)return t;if(!Array.isArray(e.stack)||e.stack.length===0)return void 0;return e.stack.map(n=>{const r=n.lineNumber!=null?`${n.file??"?"}:${n.lineNumber}:${n.column??0}`:n.file??"?";return` at ${n.methodName||"<anonymous>"} (${r})`}).join("\n")}function ae(e){const t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]";const n=v(e.name??void 0,e.originalMessage??e.message??"Unknown error");const r=$(`${t} ${n}`);const o=typeof e.componentStack==="string"&&e.componentStack.trim()?`
|
|
6
6
|
|
|
7
7
|
This error is located at:
|
|
8
|
-
${
|
|
8
|
+
${O(e.componentStack)}`:"";const h=`${t} ${n}${o}`;k({id:s.allocId(),method:"error",level:"error",args:[t,n,...o?[o.trim()]:[]],message:h,timestamp:Date.now(),stack:ie(e),fatal:true},r)}function ce(){const e=globalThis.RN$registerExceptionListener;if(typeof e!=="function")return false;e(t=>{try{if(!m)ae(t)}catch{}});return true}function le(){const e=globalThis;if(x||!z||typeof e.addEventListener!=="function")return;x=true;const t=(n,r)=>{if(m)return;if(n instanceof Error){if(_.has(n)||b.has(n))return;b.add(n)}try{H(n,r)}catch{}};e.addEventListener("error",n=>t(n.error??n.message,"[UNCAUGHT]"));e.addEventListener("unhandledrejection",n=>t(n.reason,"[UNHANDLED REJECTION]"))}export function installFatalErrorCapture(){le();if(S)return;const e=ce();const t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!=="function"){S=e;return}S=true;const n=typeof t.getGlobalHandler==="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((r,o)=>{try{if(!m)H(r,o===false?"[UNCAUGHT]":"[FATAL]")}catch{}if(typeof n==="function")n(r,o)})}export function installConsoleCapture(){if(j().status==="locked")return;m=false;installFatalErrorCapture();if(g)return;g=true;for(const e of D){const t=console[e];if(typeof t!=="function")continue;w[e]=t;console[e]=function n(...r){I(e,r,n);t.apply(console,r)}}}export function uninstallConsoleCapture(){m=true;if(!g)return;g=false;for(const e of D){const t=w[e];if(t)console[e]=t;delete w[e]}}export function subscribe(e){return s.subscribe(e)}export function getEntries(){return s.getSnapshot()}export function clearEntries(){void C();s.clear()}export function replaceEntries(e){s.set(e.filter(t=>!y(t.args??[t.message])))}export function onClear(e){return s.onClear(e)}const B="@react_buoy_console_preserve";const A="@react_buoy_console_buffer";const fe=600;let i=false;let d=false;let f=0;let u=Promise.resolve();const R=new Set;let E=null;function M(){for(const e of R)e()}function P(){if(!i||!l())return;if(E)clearTimeout(E);E=setTimeout(G,fe)}async function G(){E=null;if(!i||!l())return;try{const e=s.getSnapshot().map(n=>({...n,args:V(n.args)}));const t=f;u=u.then(async()=>{if(t!==f||!i||!l())return;await p.setItem(A,JSON.stringify(e))}).catch(()=>{});await u}catch{}}async function C(){f++;d=false;try{u=u.then(()=>p.removeItem(A)).catch(()=>{});await u}catch{}}export async function initConsolePersistence(){if(d||!l())return;d=true;const e=f;try{i=await p.getItem(B)==="true"}catch{i=false}if(e!==f||!l()){d=false;return}M();if(!i){await C();return}try{const t=await p.getItem(A);if(e!==f||!l()){d=false;return}if(t){const n=JSON.parse(t);if(Array.isArray(n)&&n.length){s.update(r=>[...n,...r].filter(o=>!y(o.args??[o.message])));s.bumpIdAbove(Math.max(...n.map(r=>r.id)))}}}catch{}}export function getPreserveLog(){return i}export function setPreserveLog(e){if(i===e)return;i=e;M();p.setItem(B,String(e)).catch(()=>{});if(e)G();else C()}export function subscribePreserveLog(e){R.add(e);return()=>{R.delete(e)}}
|
|
@@ -21,9 +21,10 @@ export interface ConsoleLogEntry {
|
|
|
21
21
|
/** Where the log came from (component / function / call site). */
|
|
22
22
|
origin?: LogOrigin;
|
|
23
23
|
/**
|
|
24
|
-
* True when this entry came from React Native's global error handler
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* True when this entry came from React Native's global error handler or a
|
|
25
|
+
* browser `error` / `unhandledrejection` event (an uncaught — usually fatal —
|
|
26
|
+
* JS error), not from a `console.*` call. The message carries a matching
|
|
27
|
+
* `[FATAL]` / `[UNCAUGHT]` / `[UNHANDLED REJECTION]` prefix.
|
|
27
28
|
*/
|
|
28
29
|
fatal?: boolean;
|
|
29
30
|
}
|
|
@@ -35,10 +36,12 @@ type Listener = () => void;
|
|
|
35
36
|
* listener (New Architecture render crashes — see
|
|
36
37
|
* {@link installNativeExceptionCapture}). Both feed the same de-duplicated
|
|
37
38
|
* `[FATAL]` entry, so a crash reported through both seams shows up once.
|
|
39
|
+
* In the browser build it listens for window error events instead
|
|
40
|
+
* (see {@link installBrowserErrorCapture}).
|
|
38
41
|
*
|
|
39
42
|
* - Chains the previous handler (LogBox/redbox still fire; nothing swallowed).
|
|
40
|
-
* - Idempotent, and a silent no-op
|
|
41
|
-
*
|
|
43
|
+
* - Idempotent, and a silent no-op on the desktop dashboard (no React Native
|
|
44
|
+
* globals, and not the browser build).
|
|
42
45
|
* - Recording respects an explicit `uninstallConsoleCapture()` (user OFF), but
|
|
43
46
|
* the hooks themselves stay chained — they can't be safely removed.
|
|
44
47
|
*/
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use client";var
|
|
2
|
-
`)){let
|
|
3
|
-
`)){let r=t.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(r)return r[1]}}function
|
|
1
|
+
"use client";var Je=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var Xt=(e,t)=>{for(var r in t)Je(e,r,{get:t[r],enumerable:true})},Ye=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qt(t))!Zt.call(e,n)&&n!==r&&Je(e,n,{get:()=>t[n],enumerable:!(o=qt(t,n))||o.enumerable});return e},er=(e,t,r)=>(Ye(e,t,"default"),r&&Ye(r,t,"default"));var ue=(()=>{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 qe,CONSOLE_ICON_COLOR as Qe}from"@buoy-gg/shared-ui/web";import{JsModal as tr}from"@buoy-gg/shared-ui/web";import{useCallback as he,useState as R}from"react";import{useMemo as rr,useSyncExternalStore as or}from"react";import{isBuoyLog as ye,getAccountAccess as nr,hasAccountAccess as _}from"@buoy-gg/shared-ui/web";import*as ar from"react";import{createToolStore as ir,persistentStorage as ee}from"@buoy-gg/shared-ui/web";function te(e,t=2048){return e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`}function be(e,t,r){if(e===null)return null;if(typeof e=="string")return te(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:te(e.message),stack:e.stack?te(e.stack,4*1024):e.stack};if(t>=6)return Array.isArray(e)?"[Array]":"{\u2026}";let o=e;if(r.has(o))return"[Circular]";r.add(o);try{if(Array.isArray(e)){let a=e.slice(0,100).map(l=>be(l,t+1,r));return e.length>100&&a.push(`\u2026 ${e.length-100} more`),a}let n={};for(let a of Object.keys(o).slice(0,100))try{n[a]=be(o[a],t+1,r)}catch{n[a]="[Unserializable]"}return n}finally{r.delete(o)}}function Ze(e){let t=new WeakSet;return e.map(r=>be(r,0,t))}var lr=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/,sr=/consoleLogStore/;function ve(e){return e.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function cr(e){return e.func&&lr.test(ve(e.func))?true:!!(e.file&&sr.test(e.file))}function ur(e){let t=[];for(let r of e.split(`
|
|
2
|
+
`)){let o=r.trim();if(!o||o==="Error")continue;let n=o.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(n){t.push({func:n[1],file:n[2],line:Number(n[3])});continue}if(n=o.match(/^at\s+(.+?):(\d+):(\d+)$/),n){t.push({file:n[1],line:Number(n[2])});continue}if(n=o.match(/^(.*?)@(.+?):(\d+):(\d+)$/),n){t.push({func:n[1]||void 0,file:n[2],line:Number(n[3])});continue}}return t}function dr(e){if(!e)return;let t=e.split(/\?|\/\/&/)[0];return t.split("/").pop()||t}function fr(e){if(!e)return;let t=ve(e);if(!(!t||t==="<anonymous>"||t==="anonymous"))return t}function gr(e){if(e)for(let t of e.split(`
|
|
3
|
+
`)){let r=t.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(r)return r[1]}}function pr(e,t){let r=new Set,o=0;for(;typeof e=="function"&&e!==t&&!r.has(e);){r.add(e);try{e=Reflect.get(e,"__sentry_original__")}catch{return 0}o+=1}return e===t?o:0}function mr(e,t,r=0,o=[]){let n=gr(t),a;if(e){let c=ur(e),d=0;for(let v of o){let f=c[d];v&&f?.func&&ve(f.func)===v&&d++}a=c.slice(d).filter(v=>!cr(v))[r]}let l=fr(a?.func),s=dr(a?.file),i=a?.line,u=s&&i!=null?`${s}:${i}`:void 0;if(!(!n&&!l&&!u))return{component:n,functionName:l,callSite:u,file:s,line:i}}function hr(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 yr(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 br(e){let t=0;for(let r=0;r<e.length;r++)t=t*31+e.charCodeAt(r)|0;return Math.abs(t)}function Xe(e){return`hsl(${br(e)%360}, 70%, 66%)`}function et(e){switch(e){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}var tt=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"],vr=new Set(["error","warn","trace","assert"]),wr={error:"error",assert:"error",warn:"warning",debug:"verbose",log:"info",info:"info",trace:"info",dir:"info",table:"info",group:"info",groupCollapsed:"info",groupEnd:"info"},xr=1e3,k=ir({id:"console",max:xr,order:"append",coalesce:"frame"}),de=false,we=false,re=false,xe={},rt=new WeakSet,ke=new WeakSet,ot=false;function nt(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 kr(e){return e.map(nt).join(" ")}function Sr(e){if(e)return e.split(`
|
|
4
4
|
`).slice(3).join(`
|
|
5
|
-
`)||void 0}function
|
|
6
|
-
`).map(
|
|
7
|
-
`)+(
|
|
8
|
-
\u2026+${
|
|
5
|
+
`)||void 0}function Cr(){try{let e=Reflect.get(ar,"captureOwnerStack");return typeof e=="function"?e()??void 0:void 0}catch{return}}var Er=8;function at(e){let t=e.split(`
|
|
6
|
+
`).map(n=>n.trim()).filter(Boolean).map(n=>n.replace(/\s*\((?:https?:|\/).*$/,"")),r=t.slice(0,Er),o=t.length-r.length;return r.map(n=>` ${n}`).join(`
|
|
7
|
+
`)+(o>0?`
|
|
8
|
+
\u2026+${o} more frames`:"")}function Tr(e){if(!(e instanceof Error))return null;let t=e;return t.isComponentError||typeof t.componentStack=="string"?t:null}function it(e,t,r){if(ye(t))return;let o=e==="error"?t.filter(u=>u instanceof Error):[];if(o.some(u=>ke.has(u)))return;for(let u of o)rt.add(u);let n=new Error().stack,a=[it.name,r?.name??""],l=mr(n,Cr(),pr(console[e],r),a),s=e==="error"?Tr(t[0]):null;if(s){let u=Se(s.name,s.message),c=s.componentStack?`
|
|
9
9
|
|
|
10
10
|
This error is located at:
|
|
11
|
-
${
|
|
12
|
-
`)}function
|
|
11
|
+
${at(s.componentStack)}`:"";Ee({id:k.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",s],message:`[RENDER ERROR] ${u}${c}`,timestamp:Date.now(),stack:s.stack,origin:l},Ce(`[RENDER ERROR] ${u}`));return}let i={id:k.allocId(),method:e,level:wr[e],args:t,message:kr(t),timestamp:Date.now(),stack:vr.has(e)?Sr(n):void 0,origin:l};k.add(i),ft(),i.level==="error"&&k.flushSync()}var $r=2e3,lt="",st=0;function Se(e,t){let r=t.trim();return e&&r.startsWith(`${e}: `)?r:e?`${e}: ${r}`:r}function Ce(e){let t=Date.now();return e===lt&&t-st<$r?true:(lt=e,st=t,false)}function Ee(e,t=false){k.add(e),ft(),t||k.flushSync(true)}function ct(e,t){let r=e instanceof Error?e:void 0,o=r?Se(r.name,r.message):nt(e),n=Ce(`${t} ${o}`);Ee({id:k.allocId(),method:"error",level:"error",args:[t,e],message:`${t} ${o}`,timestamp:Date.now(),stack:r?.stack,fatal:true},n)}function Lr(e){let t=e.extraData?.rawStack;if(typeof t=="string"&&t.length>0)return t;if(!(!Array.isArray(e.stack)||e.stack.length===0))return e.stack.map(r=>{let o=r.lineNumber!=null?`${r.file??"?"}:${r.lineNumber}:${r.column??0}`:r.file??"?";return` at ${r.methodName||"<anonymous>"} (${o})`}).join(`
|
|
12
|
+
`)}function Ar(e){let t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]",r=Se(e.name??void 0,e.originalMessage??e.message??"Unknown error"),o=Ce(`${t} ${r}`),n=typeof e.componentStack=="string"&&e.componentStack.trim()?`
|
|
13
13
|
|
|
14
14
|
This error is located at:
|
|
15
|
-
${Xe(e.componentStack)}`:"",i=`${t} ${r}${o}`;xe({id:k.allocId(),method:"error",level:"error",args:[t,r,...o?[o.trim()]:[]],message:i,timestamp:Date.now(),stack:xr(e),fatal:true},n)}function Cr(){let e=globalThis.RN$registerExceptionListener;return typeof e!="function"?false:(e(t=>{try{se||kr(t)}catch{}}),true)}function rt(){if(ye)return;let e=Cr(),t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!="function"){ye=e;return}ye=true;let r=typeof t.getGlobalHandler=="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((n,o)=>{try{se||wr(n,o)}catch{}typeof r=="function"&&r(n,o)})}function ce(){if(qt().status!=="locked"&&(se=false,rt(),!ae)){ae=true;for(let e of qe){let t=console[e];typeof t=="function"&&(be[e]=t,console[e]=function r(...n){Ze(e,n,r),t.apply(console,n)})}}}function ke(){if(se=true,!!ae){ae=false;for(let e of qe){let t=be[e];t&&(console[e]=t),delete be[e]}}}function ue(e){return k.subscribe(e)}function K(){return k.getSnapshot()}function ee(){Te(),k.clear()}function Sr(e){k.set(e.filter(t=>!pe(t.args??[t.message])))}function Tr(e){return k.onClear(e)}var ot="@react_buoy_console_preserve",Ce="@react_buoy_console_buffer",Er=600,M=false,te=false,U=0,Y=Promise.resolve(),Se=new Set,de=null;function nt(){for(let e of Se)e()}function it(){!M||!_()||(de&&clearTimeout(de),de=setTimeout(lt,Er))}async function lt(){if(de=null,!(!M||!_()))try{let e=k.getSnapshot().map(r=>({...r,args:Ue(r.args)})),t=U;Y=Y.then(async()=>{t!==U||!M||!_()||await X.setItem(Ce,JSON.stringify(e))}).catch(()=>{}),await Y}catch{}}async function Te(){U++,te=false;try{Y=Y.then(()=>X.removeItem(Ce)).catch(()=>{}),await Y}catch{}}async function at(){if(te||!_())return;te=true;let e=U;try{M=await X.getItem(ot)==="true"}catch{M=false}if(e!==U||!_()){te=false;return}if(nt(),!M){await Te();return}try{let t=await X.getItem(Ce);if(e!==U||!_()){te=false;return}if(t){let r=JSON.parse(t);Array.isArray(r)&&r.length&&(k.update(n=>[...r,...n].filter(o=>!pe(o.args??[o.message]))),k.bumpIdAbove(Math.max(...r.map(n=>n.id))))}}catch{}}function Ee(){return M}function st(e){M!==e&&(M=e,nt(),X.setItem(ot,String(e)).catch(()=>{}),e?lt():Te())}function ct(e){return Se.add(e),()=>{Se.delete(e)}}var $e={verbose:true,info:true,warning:true,error:true},Le={...$e,verbose:false},$r=/^([\w-]+):(.+)$/,Lr=/^\/(.+)\/$/;function Ar(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($r);if(i){t.push({key:i[1].toLowerCase(),text:i[2],negative:o});continue}let l=n.match(Lr);if(l)try{t.push({regex:new RegExp(l[1],"im"),negative:o});continue}catch{}t.push({text:n,negative:o})}return t}function Ir(e,t){return e.message.toLowerCase().includes(t.toLowerCase())}function Dr(e,t){for(let r of t)if(r.regex){if(r.regex.test(e.message)===r.negative)return false}else if(r.text&&Ir(e,r.text)===r.negative)return false;return true}function Or(e,t,r){return e.method==="groupEnd"?true:t[e.level]?Dr(e,r):false}var ut={verbose:"Verbose",info:"Info",warning:"Warnings",error:"Errors"},Ae=["verbose","info","warning","error"];function dt(e,t){return Ae.every(r=>e[r]===t[r])}function Nr(e){if(dt(e,$e))return"All levels";if(dt(e,Le))return"Default levels";let t=Ae.filter(r=>e[r]);return t.length===0?"Hide all":t.length===1?`${ut[t[0]]} only`:"Custom levels"}var Ie=5,Br=5;function Mr(e,t){for(let r of e){let n=sr(r.entry.origin,t);r.sourceKey=n,r.originColor=n?Ye(n):void 0,r.originLabel=t==="off"?void 0:cr(r.entry.origin,t)}}function Hr(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=Je(i)}}function jr(e,t){let r=[],n=new Map;for(let i of e){let l=i.sourceKey??"\u2014",s=n.get(l);s||(s=[],n.set(l,s),r.push(l)),s.push(i)}let o=[];for(let i of r){let l=n.get(i);for(let c of l)c.depth=0;let s=l.length>Br,a=t[i]??false;s&&(o.push({key:`cluster:${i}`,entry:l[0].entry,depth:0,repeatCount:1,isGroupHeader:false,sourceKey:i,originColor:l[0].originColor,originLabel:l[0].originLabel,clusterHeader:{key:i,count:l.length,expanded:a}}),!a)||l.forEach((c,u)=>{let g=l.length===1?"single":u===0?"top":u===l.length-1?"bottom":"mid";c.bracketGlyph=Je(g),o.push(c)})}return o}function Pr(e){let t=new Map,r=new Map;e.forEach((s,a)=>{let c=s.sourceKey;c!=null&&(t.has(c)||t.set(c,a),r.set(c,a))});let n=[...t.keys()].sort((s,a)=>t.get(s)-t.get(a)),o=new Map,i=[];for(let s of n){let a=i.findIndex(c=>c<t.get(s));a===-1&&(a=i.length<Ie?i.length:Ie-1,a>=i.length&&i.push(0)),o.set(s,a),i[a]=Math.max(i[a]??0,r.get(s))}let l=Math.max(1,Math.min(i.length,Ie));e.forEach((s,a)=>{let c=Array.from({length:l},()=>({glyph:" "}));for(let u of n){let g=o.get(u);g>=l||a>=t.get(u)&&a<=r.get(u)&&(c[g]={glyph:s.sourceKey===u?"\u25CF":"\u2502",color:Ye(u)})}s.lanes=c})}var zr=new Set(["group","groupCollapsed"]);function Rr(e,t){let{levelsMask:r,query:n,showTimestamps:o,collapsedOverrides:i}=t,l=Ar(n.trim()),s=[],a={verbose:0,info:0,warning:0,error:0},c=0,u=[],g=()=>u.some(p=>p.collapsed);for(let p of e){if(a[p.level]++,p.method==="groupEnd"){u.pop();continue}let D=zr.has(p.method),V=g();if(!Or(p,r,l))c++;else if(!V){let L=s[s.length-1];!o&&!D&&L&&!L.isGroupHeader&&L.depth===u.length&&L.entry.method===p.method&&L.entry.message===p.message?L.repeatCount++:s.push({key:String(p.id),entry:p,depth:u.length,repeatCount:1,isGroupHeader:D,groupId:D?p.id:void 0,groupCollapsed:void 0})}if(D){let L=p.method==="groupCollapsed",F=i[p.id]??L,j=s[s.length-1];j&&j.groupId===p.id&&(j.groupCollapsed=F),u.push({id:p.id,collapsed:F||V})}}Mr(s,t.groupDimension);let x=s;return t.groupDimension!=="off"&&(t.layoutMode==="cluster"?x=jr(s,t.clusterExpanded):t.layoutMode==="swimlane"?Pr(s):Hr(s)),{rows:x,hiddenCount:c,levelCounts:a,totalCount:e.length}}function ft(e){let t=Jt(ue,K,K);return Yt(()=>Rr(t,e),[t,e.levelsMask,e.query,e.showTimestamps,e.collapsedOverrides,e.groupDimension,e.layoutMode,e.clusterExpanded])}function gt(){let[e,t]=P(""),[r,n]=P(false),[o,i]=P({...Le}),[l,s]=P(false),[a,c]=P({}),[u,g]=P("chrono"),[x,p]=P("list"),[D,V]=P({}),{rows:L,hiddenCount:F}=ft({levelsMask:o,query:e,showTimestamps:l,collapsedOverrides:a,groupDimension:"function",layoutMode:u,clusterExpanded:D}),j=ge((ie,le)=>{c(Wt=>({...Wt,[ie]:!le}))},[]),ne=ge(ie=>{V(le=>({...le,[ie]:!(le[ie]??false)}))},[]),h=ge(()=>{ee(),c({})},[]),S=Nr(o);return{query:e,setQuery:t,searchActive:r,setSearchActive:n,levelsMask:o,setLevelsMask:i,showTimestamps:l,setShowTimestamps:s,layoutMode:u,setLayoutMode:g,view:x,setView:p,rows:L,hiddenCount:F,onToggleGroup:j,onToggleCluster:ne,clear:h,levelSummary:S,isLevelCustom:S!=="All levels"&&S!=="Default levels"}}var pt={};_t(pt,{AccessibilityInfo:()=>Vr,ActivityIndicator:()=>_o,Alert:()=>Yo,Animated:()=>_r,AppRegistry:()=>Ur,AppState:()=>Yr,Appearance:()=>Kr,BackHandler:()=>Jr,Button:()=>Ko,CheckBox:()=>fo,Clipboard:()=>qr,DeviceEventEmitter:()=>$o,Dimensions:()=>Qr,Easing:()=>Xr,FlatList:()=>De,I18nManager:()=>Zr,Image:()=>go,ImageBackground:()=>po,InteractionManager:()=>to,Keyboard:()=>eo,KeyboardAvoidingView:()=>mo,LayoutAnimation:()=>ro,Linking:()=>oo,LogBox:()=>Eo,Modal:()=>Go,NativeEventEmitter:()=>no,NativeModules:()=>Gr,PanResponder:()=>io,Picker:()=>ho,PixelRatio:()=>lo,Platform:()=>ao,Pressable:()=>Fo,ProgressBar:()=>yo,RefreshControl:()=>bo,SafeAreaView:()=>vo,ScrollView:()=>bt,SectionList:()=>wo,Share:()=>so,StatusBar:()=>xo,StyleSheet:()=>T,Switch:()=>Vo,Text:()=>d,TextInput:()=>zo,Touchable:()=>ko,TouchableHighlight:()=>Ro,TouchableNativeFeedback:()=>Co,TouchableOpacity:()=>$,TouchableWithoutFeedback:()=>Wo,UIManager:()=>co,Vibration:()=>uo,View:()=>y,VirtualizedList:()=>So,YellowBox:()=>To,findNodeHandle:()=>Uo,unstable_createElement:()=>Fr,useColorScheme:()=>Lo,useLocaleContext:()=>Ao,useWindowDimensions:()=>Io});Kt(pt,Wr);import*as Wr from"react-native-web";import{unstable_createElement as Fr,NativeModules as Gr,AccessibilityInfo as Vr,Animated as _r,Appearance as Kr,AppRegistry as Ur,AppState as Yr,BackHandler as Jr,Clipboard as qr,Dimensions as Qr,Easing as Xr,I18nManager as Zr,Keyboard as eo,InteractionManager as to,LayoutAnimation as ro,Linking as oo,NativeEventEmitter as no,PanResponder as io,PixelRatio as lo,Platform as ao,Share as so,StyleSheet as T,UIManager as co,Vibration as uo,CheckBox as fo,FlatList as De,Image as go,ImageBackground as po,KeyboardAvoidingView as mo,Picker as ho,ProgressBar as yo,RefreshControl as bo,SafeAreaView as vo,SectionList as wo,StatusBar as xo,Touchable as ko,TouchableNativeFeedback as Co,VirtualizedList as So,YellowBox as To,LogBox as Eo,DeviceEventEmitter as $o,useColorScheme as Lo,useLocaleContext as Ao,useWindowDimensions as Io}from"react-native-web";import*as E from"react-native-web";import{createElement as Oe,forwardRef as mt,useCallback as Do,useRef as Oo}from"react";import{useEffect as No,useState as Bo}from"react";import{createPortal as Mo}from"react-dom";var Ho='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as jo}from"react/jsx-runtime";var re=Symbol.for("@buoy-gg/portal-host"),ht=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function yt(){let e=document;if(e[re])return e[re].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Ho});let r=()=>{let u=document.fullscreenElement,g=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==g&&g.appendChild(t)},n=new Map,o=u=>{(!t.contains(u.target)||!ht(u.target))&&n.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},i=u=>{n.delete(u.code||u.key)},l=()=>n.clear(),s=()=>{let u=[...n.values()];n.clear();for(let g of u)document.dispatchEvent(new KeyboardEvent("keyup",{...g,bubbles:true}))},a=u=>{ht(u.target)&&u.stopPropagation()},c=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",l),t.addEventListener("focusin",s),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",c,{passive:true}),e[re]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",l),t.remove(),delete e[re]}},t}function Po({children:e}){let[t,r]=Bo(null);return No(()=>{let n=yt(),o=document[re];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Mo(jo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function A(e){let t=mt((n,o)=>{let{accessibilityState:i,accessibilityValue:l,...s}=n;for(let a of["busy","checked","disabled","expanded","selected"])i?.[a]!==void 0&&s[`aria-${a}`]===void 0&&(s[`aria-${a}`]=i[a]);for(let[a,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[a]!==void 0&&s[`aria-${c}`]===void 0&&(s[`aria-${c}`]=l[a]);return Oe(e,{...s,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var y=A(E.View),d=A(E.Text),zo=A(E.TextInput),$=A(E.TouchableOpacity),Ro=A(E.TouchableHighlight),Wo=A(E.TouchableWithoutFeedback),Fo=A(E.Pressable),bt=A(E.ScrollView),vt=mt((e,t)=>{let r=Oo(null),n=Do(o=>{if(o){let i=o;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),yt().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Oe(Po,null,Oe(E.Modal,{...e,ref:n}))});vt.displayName="Modal";var Go=A(vt),Vo=A(E.Switch),_o=A(E.ActivityIndicator),Ko=A(E.Button),Uo=E.findNodeHandle,Yo={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 l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],a=()=>{o.close?.(),o.remove()};for(let c of s){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=()=>{a(),c.onPress?.()},l.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(a(),n?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{ModalHeader as z,TabSelector as Jo,night as N,Search as qo,Filter as Qo,Trash2 as Xo}from"@buoy-gg/shared-ui/web";import{jsx as I,jsxs as Ne}from"react/jsx-runtime";var Zo=[{key:"chrono",label:"Timeline"},{key:"cluster",label:"Grouped"}];function wt({c:e,onBack:t}){if(e.view==="filters")return Ne(z,{children:[I(z.Navigation,{onBack:()=>e.setView("list")}),I(z.Content,{title:"Filters"})]});let r=e.rows.length>0;return Ne(z,{children:[t?I(z.Navigation,{onBack:t}):null,I(z.Content,{title:"",noMargin:true,children:e.searchActive?I(z.Search,{testID:"buoy-console-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)}}):I(Jo,{testIDPrefix:"buoy-console-tab",tabs:Zo,activeTab:e.layoutMode,onTabChange:n=>e.setLayoutMode(n)})}),Ne(z.Actions,{children:[I($,{onPress:()=>e.setSearchActive(n=>!n),style:[J.actionBtn,e.searchActive&&J.actionBtnActive],testID:"buoy-console-search-open",accessibilityLabel:"Search logs",children:I(qo,{size:14,color:e.searchActive?N.color.accent:N.color.textSecondary})}),I($,{onPress:()=>e.setView("filters"),style:[J.actionBtn,e.isLevelCustom&&J.actionBtnActive],testID:"buoy-console-filters-open",accessibilityLabel:"Filters",children:I(Qo,{size:14,color:e.isLevelCustom?N.color.accent:N.color.textSecondary})}),I($,{onPress:e.clear,disabled:!r,style:[J.actionBtn,!r&&J.actionBtnDisabled],testID:"buoy-console-clear",accessibilityLabel:"Clear console",children:I(Xo,{size:14,color:r?N.color.textSecondary:N.color.textTertiary})})]})]})}var J=T.create({actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:N.color.buttonSurface,borderWidth:1,borderColor:N.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:N.color.accentSoft,borderColor:N.color.accentBorderStrong},actionBtnDisabled:{opacity:.55}});import{useCallback as en,useRef as xt,useSyncExternalStore as tn}from"react";import{night as H,Check as rn,LOG_LIST_PRESET as on}from"@buoy-gg/shared-ui/web";import{memo as nn}from"react";import{useState as ln}from"react";import{monoFont as R,night as oe}from"@buoy-gg/shared-ui/web";var an={baseContainer:"#0A0A0C",surfaceError:"rgba(255,69,58,0.15)",surfaceYellow:"rgba(255,235,59,0.13)",divider:oe.color.fillTertiary,inputBackground:oe.color.surfaceElevated,menuBackground:oe.color.surface,onSurface:oe.color.text,onSurfaceYellow:"#FFE9A3",onErrorContainer:"#FFB4AB",tokenSubtle:oe.color.textSecondary,primary:"#40CCFF",valueNumber:"#FF9F1C",valueString:"#7EE787",valueBigint:"#A1A1A6",valueNode:"#F5F5F7",valueNullish:"#8E8E93",valuePreview:"#A1A1A6"},m=an,sn={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"},kt={verbose:{text:m.tokenSubtle},info:{text:m.onSurface},warning:{background:m.surfaceYellow,text:m.onSurfaceYellow,icon:"warning"},error:{background:m.surfaceError,text:m.onErrorContainer,icon:"error"}};var Ct=["black","red","green","yellow","blue","magenta","cyan","gray"],St=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function Tt(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 Be=/%([%_Oocsdfi])|\x1B\[([\d;]*)m/;function cn(e){return Be.test(e)}function Et(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(),l=n.slice(o+1).trim();if(!l)continue;let s=l.match(/var\(--console-color-([a-z]+)\)/);switch(s&&(l=sn[s[1]]??l),i){case"color":t.color=l,r=true;break;case"background-color":case"background":t.backgroundColor=l,r=true;break;case"font-weight":t.fontWeight=l==="lighter"?"300":l,r=true;break;case"font-style":l==="italic"&&(t.fontStyle="italic",r=true);break;case"font-size":{let a=parseFloat(l);Number.isNaN(a)||(t.fontSize=a,r=true);break}case"text-decoration":case"text-decoration-line":l.includes("underline")&&l.includes("line-through")?t.textDecorationLine="underline line-through":l.includes("underline")?t.textDecorationLine="underline":l.includes("line-through")&&(t.textDecorationLine="line-through"),r=true;break;default:break}}return r?t:void 0}function un(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,l=e.shift()??0,s=e.shift()??0;t.set(o===38?"color":"background-color",`rgb(${i},${l},${s})`)}break;case 39:case 49:t.delete(o===39?"color":"background-color");break;default:{let i=Ct[o-30]??St[o-90];if(i!==void 0)t.set("color",`var(--console-color-${i})`);else{let l=Ct[o-40]??St[o-100];l!==void 0&&t.set("background-color",`var(--console-color-${l})`)}break}}}}function dn(e,t){let r=e,n=[],o=new Map,i,l=a=>{if(!a)return;let c=n[n.length-1];if(c&&c.type==="string"&&fn(c.style,i)){c.value+=a;return}n.push({type:"string",value:a,style:i})},s=0;for(let a=Be.exec(r);a!==null;a=Be.exec(r)){l(a.input.substring(0,a.index));let c,u=a[1];switch(u){case"%":l("%"),c="";break;case"s":s<t.length&&(c=Tt(t[s++]));break;case"c":s<t.length&&(i=Et(Tt(t[s++])),c="");break;case"o":case"O":s<t.length&&(n.push({type:"value",value:t[s++],mode:u==="O"?"generic":"optimal"}),c="");break;case"_":s<t.length&&(s++,c="");break;case"d":case"f":case"i":{if(s<t.length){let g=t[s++],x=typeof g!="number"?NaN:g;u!=="f"&&(x=Math.floor(x)),c=x}break}case void 0:{let g=(a[2]||"0").split(";").map(p=>p?parseInt(p,10):0);un(g,o);let x=[...o.entries()].map(([p,D])=>`${p}:${D.trimStart()}`).join(";");i=Et(x),c="";break}}c===void 0&&(l(a[0]),c=""),r=c+a.input.substring(a.index+a[0].length)}return l(r),{tokens:n,rest:t.slice(s)}}function fn(e,t){return e===t?true:!e||!t?false:JSON.stringify(e)===JSON.stringify(t)}function gn(e){if(e.length===0)return[];let t=[],r=e;if(typeof e[0]=="string"&&cn(e[0])){let n=dn(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 pn}from"react";import{jsx as O,jsxs as q}from"react/jsx-runtime";var $t=5,Lt=6;function Me(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 mn={number:m.valueNumber,bigint:m.valueBigint,boolean:m.valueNumber,string:m.valueString,null:m.valueNullish,undefined:m.valueNullish,symbol:m.valueString,function:m.valueNode};function At(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 He(e){switch(Me(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=At(e);return t?`${t} {\u2026}`:"{\u2026}"}default:return String(e)}}function hn(e){if(Array.isArray(e)){let i=e.slice(0,Lt).map(s=>He(s)).join(", "),l=e.length>Lt?", \u2026":"";return`(${e.length}) [${i}${l}]`}let t=Object.entries(e),r=t.slice(0,$t).map(([i,l])=>`${i}: ${He(l)}`).join(", "),n=t.length>$t?", \u2026":"",o=At(e);return`${o?`${o} `:""}{${r}${n}}`}function yn(e){let t=Me(e);return t==="array"?e.length>0:t==="object"?Object.keys(e).length>0:t==="error"}var It=({open:e})=>O(d,{style:[v.triangle,e&&v.triangleOpen],children:"\u25B6"});function je({value:e,depth:t=0,testID:r}){let[n,o]=pn(false),i=Me(e);if(i==="error"){let a=e,c=`${a.name}: ${a.message}`.split(`
|
|
16
|
-
`)[0],
|
|
17
|
-
`).filter(h=>h.trim()).map((h,S)=>b(d,{style:f.stackFrame,children:h.trim()},S))}):null]}),D=[f.wrapper,i.background?{backgroundColor:i.background}:f.dividerTop],V=Array.from({length:e.depth},(h,S)=>b(y,{style:f.nestingMarker},S)),L=e.lanes?b(y,{style:f.laneGutter,children:e.lanes.map((h,S)=>b(d,{style:[f.laneCell,h.color?{color:h.color}:null],children:h.glyph},S))}):e.bracketGlyph?b(d,{style:[f.originGutter,{color:e.originColor}],children:e.bracketGlyph}):null,F=Q(y,{style:f.rowWrapper,children:[L,V,p]}),j=`buoy-console-row-${String(o.args[0])}`,ne=[e.originLabel,u.find(h=>h.type==="string")?.value].filter(Boolean).join(" \u2014 ").slice(0,80);if(e.isGroupHeader&&e.groupId!==void 0){let h=e.groupId;return b($,{style:D,activeOpacity:.7,onPress:()=>r(h,!!e.groupCollapsed),testID:j,accessibilityLabel:ne||"Console group",children:F})}return b($,{style:D,activeOpacity:.7,onPress:()=>c(h=>!h),testID:j,accessibilityLabel:ne||"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=T.create({wrapper:{paddingVertical:2,paddingRight:8,minHeight:18},dividerTop:{borderTopWidth:T.hairlineWidth,borderTopColor:m.divider},rowWrapper:{flexDirection:"row",alignItems:"flex-start"},originGutter:{width:11,fontFamily:R,fontSize:13,lineHeight:18,textAlign:"center"},laneGutter:{flexDirection:"row"},laneCell:{width:9,fontFamily:R,fontSize:13,lineHeight:18,textAlign:"center"},originLabel:{fontFamily:R,fontSize:10,lineHeight:16,marginBottom:1,opacity:.9},nestingMarker:{width:14,alignSelf:"stretch",borderRightWidth:T.hairlineWidth,borderRightColor:m.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:R,fontSize:12,lineHeight:16},groupTitle:{fontWeight:"bold"},clusterTitle:{fontWeight:"600"},clusterCount:{color:m.tokenSubtle,fontFamily:R,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:m.tokenSubtle,fontFamily:R,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:m.tokenSubtle,fontFamily:R,fontSize:11,lineHeight:15}});import{jsx as w,jsxs as Pe}from"react/jsx-runtime";function Ot({c:e}){return e.view==="filters"?w(Cn,{c:e}):w(kn,{c:e})}function kn({c:e}){let t=xt(null),r=xt(true),n=en(({item:o})=>w(Dt,{row:o,showTimestamps:e.showTimestamps,onToggleGroup:e.onToggleGroup,onToggleCluster:e.onToggleCluster}),[e.showTimestamps,e.onToggleGroup,e.onToggleCluster]);return w(De,{testID:"buoy-console-list",ref:t,data:e.rows,keyExtractor:o=>o.key,renderItem:n,style:C.list,...on,onContentSizeChange:()=>{r.current&&t.current?.scrollToEnd({animated:false})},onScroll:o=>{let{contentOffset:i,contentSize:l,layoutMeasurement:s}=o.nativeEvent,a=l.height-(i.y+s.height);r.current=a<40},scrollEventThrottle:100})}function ze({testID:e,on:t,label:r,subtext:n,onPress:o}){return Pe($,{testID:e,style:C.row,onPress:o,activeOpacity:.7,children:[w(y,{style:[C.checkbox,t&&C.checkboxOn],children:t?w(rn,{size:12,color:H.color.onAccent,strokeWidth:3}):null}),Pe(y,{style:C.rowTextCol,children:[w(d,{style:C.rowLabel,children:r}),n?w(d,{style:C.rowSubtext,children:n}):null]})]})}function Nt({text:e}){return w(d,{style:C.sectionLabel,children:e})}function Cn({c:e}){let t=tn(ct,Ee,Ee),r=n=>e.setLevelsMask({...e.levelsMask,[n]:!e.levelsMask[n]});return Pe(bt,{testID:"buoy-console-filters",style:C.subView,contentContainerStyle:C.subViewContent,children:[w(Nt,{text:"Log levels"}),w($,{testID:"buoy-console-levels-default",style:C.presetRow,onPress:()=>e.setLevelsMask({...Le}),children:w(d,{style:C.presetText,children:"Default (hide verbose)"})}),w($,{testID:"buoy-console-levels-all",style:C.presetRow,onPress:()=>e.setLevelsMask({...$e}),children:w(d,{style:C.presetText,children:"All levels"})}),Ae.map(n=>w(ze,{testID:`buoy-console-level-${n}`,on:e.levelsMask[n],label:ut[n],onPress:()=>r(n)},n)),w(y,{style:C.divider}),w(Nt,{text:"Settings"}),w(ze,{testID:"buoy-console-timestamps",on:e.showTimestamps,label:"Show timestamps",onPress:()=>e.setShowTimestamps(n=>!n)}),w(ze,{testID:"buoy-console-preserve",on:t,label:"Preserve log",subtext:"Do not clear log on reload",onPress:()=>st(!t)})]})}var C=T.create({list:{flex:1,backgroundColor:"transparent"},subView:{flex:1,backgroundColor:"transparent"},subViewContent:{padding:12},sectionLabel:{color:H.color.textTertiary,fontSize:11,textTransform:"uppercase",letterSpacing:.5,marginTop:4,marginBottom:4,paddingHorizontal:8},presetRow:{paddingVertical:10,paddingHorizontal:8},presetText:{color:H.color.accent,fontSize:14,fontWeight:"600"},divider:{height:T.hairlineWidth,backgroundColor:H.color.border,marginVertical:6},row:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:8,gap:12},rowTextCol:{flexDirection:"column",flex:1},rowLabel:{color:H.color.text,fontSize:14},rowSubtext:{color:H.color.textTertiary,fontSize:12,marginTop:1},checkbox:{width:18,height:18,borderRadius:4,borderWidth:1,borderColor:H.color.fillTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:H.color.accent,borderColor:H.color.accent}});import{jsx as Re}from"react/jsx-runtime";function Bt({visible:e,onClose:t,onBack:r,onMinimize:n,persistenceKey:o="@react_buoy_console_modal"}){let i=gt();return Re(Ut,{visible:e,onClose:t,onMinimize:n,persistenceKey:o,header:{showToggleButton:true,customContent:Re(wt,{c:i,onBack:r})},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Re(Ot,{c:i})})}import{createToolFactory as Sn,defineToolPreset as Tn}from"@buoy-gg/shared-ui/web";import{jsx as En}from"react/jsx-runtime";var Mt=globalThis,$n=typeof Mt.ErrorUtils?.setGlobalHandler=="function"||typeof Mt.RN$registerExceptionListener=="function";$n&&typeof Ve<"u"&&Ve&&ce();var Ht=Tn({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:Ke,icon:({size:e})=>En(_e,{size:e}),component:Bt}),Ln=Sn(Ht);import{useEffect as An}from"react";import{getAccountAccess as In,subscribeAccountAccess as Dn}from"@buoy-gg/shared-ui/web";var jt=0;function On(){return An(()=>{++jt;let e=true,t=()=>{if(!e)return;let n=In();if(n.status==="locked"){ke(),ee();return}ce(),n.status==="admitted"&&at()},r=Dn(t);return t(),()=>{e=false,r(),--jt===0&&ke()}},[]),null}import{macOSColors as Nn,windowDragProps as Bn}from"@buoy-gg/shared-ui/web";import{jsx as We,jsxs as Mn}from"react/jsx-runtime";function Hn(){let e=gt();return Mn(y,{style:Pt.container,children:[We(y,{style:Pt.headerBar,...Bn,children:We(wt,{c:e})}),We(Ot,{c:e})]})}var Pt=T.create({container:{flex:1,backgroundColor:"transparent"},headerBar:{paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:T.hairlineWidth,borderBottomColor:Nn.border.default}});import{useSyncExternalStore as jn,useEffect as Pn}from"react";function zt(){return Pn(()=>{ce()},[]),{logs:jn(ue,K,K)}}import{night as W,ToolEmptyState as zn,monoFont as Rn}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as fe}from"react/jsx-runtime";var Rt={verbose:"#9b9b9b",info:W.color.text,warning:"#e2c08d",error:"#f48771"};function Wn(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 Fn(){let{logs:e}=zt(),t=({item:r})=>fe(y,{style:B.row,children:[G(d,{style:B.time,children:Wn(r.timestamp)}),G(d,{style:[B.level,{color:Rt[r.level]}],children:r.level.toUpperCase()}),G(d,{style:[B.message,{color:Rt[r.level]}],numberOfLines:3,children:r.message})]});return fe(y,{style:B.container,children:[fe(y,{style:B.header,children:[fe(d,{style:B.headerTitle,children:["Console (",e.length,")"]}),G($,{onPress:()=>ee(),style:B.clearButton,children:G(d,{style:B.clearText,children:"Clear"})})]}),G(De,{data:e,keyExtractor:r=>String(r.id),renderItem:t,ListEmptyComponent:G(zn,{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?B.emptyContainer:void 0})]})}var B=T.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:T.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:T.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:Rn},empty:{color:W.color.textTertiary,fontSize:13,textAlign:"center"},emptyContainer:{flexGrow:1,alignItems:"center",justifyContent:"center"}});import{createSyncAdapter as Gn,memoByIdentity as Vn,newestFitting as _n,sizeOrStub as Kn}from"@buoy-gg/shared-ui/web";var Un=1.5*1024*1024,Yn=16*1024,Jn=Object.freeze({__buoyTruncated:true,note:"Log payload omitted \u2014 inspect it on-device."}),qn=Vn(e=>{let t={...e,args:Ue(e.args),message:Z(e.message),stack:e.stack?Z(e.stack,4096):e.stack};return Kn(t,Yn,()=>({...t,args:[Jn]}))});function Qn(e){return _n(e,{toWire:qn,budget:Un,baseBytes:16})}var Xn=Gn({version:1,getSnapshot(){return{entries:Qn(K())}},subscribe(e){return ue(e)},actions:{clearEntries(){return ee(),{cleared:true}}}});export{Ke as CONSOLE_ICON_COLOR,_e as ConsoleIcon,Fn as ConsoleLogList,Dt as ConsoleMessageRow,Bt as ConsoleModal,On as ConsoleRoot,je as ConsoleValue,Hn as ConsoleView,ee as clearEntries,Xn as consoleSyncAdapter,m as consoleTheme,Ht as consoleToolPreset,Ln as createConsoleTool,K as getEntries,Ee as getPreserveLog,at as initConsolePersistence,ce as installConsoleCapture,rt as installFatalErrorCapture,kt as levelStyles,Tr as onClear,Sr as replaceEntries,st as setPreserveLog,ue as subscribe,ct as subscribePreserveLog,ke as uninstallConsoleCapture,zt as useConsoleLogs,ft as useConsoleMessages};
|
|
15
|
+
${at(e.componentStack)}`:"",a=`${t} ${r}${n}`;Ee({id:k.allocId(),method:"error",level:"error",args:[t,r,...n?[n.trim()]:[]],message:a,timestamp:Date.now(),stack:Lr(e),fatal:true},o)}function Ir(){let e=globalThis.RN$registerExceptionListener;return typeof e!="function"?false:(e(t=>{try{re||Ar(t)}catch{}}),true)}function Or(){let e=globalThis;if(ot||false||typeof e.addEventListener!="function")return;ot=true;let t=(r,o)=>{if(!re){if(r instanceof Error){if(rt.has(r)||ke.has(r))return;ke.add(r)}try{ct(r,o)}catch{}}};e.addEventListener("error",r=>t(r.error??r.message,"[UNCAUGHT]")),e.addEventListener("unhandledrejection",r=>t(r.reason,"[UNHANDLED REJECTION]"))}function Te(){if(Or(),we)return;let e=Ir(),t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!="function"){we=e;return}we=true;let r=typeof t.getGlobalHandler=="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((o,n)=>{try{re||ct(o,n===false?"[UNCAUGHT]":"[FATAL]")}catch{}typeof r=="function"&&r(o,n)})}function fe(){if(nr().status!=="locked"&&(re=false,Te(),!de)){de=true;for(let e of tt){let t=console[e];typeof t=="function"&&(xe[e]=t,console[e]=function r(...o){it(e,o,r),t.apply(console,o)})}}}function $e(){if(re=true,!!de){de=false;for(let e of tt){let t=xe[e];t&&(console[e]=t),delete xe[e]}}}function ge(e){return k.subscribe(e)}function K(){return k.getSnapshot()}function oe(){Ie(),k.clear()}function Dr(e){k.set(e.filter(t=>!ye(t.args??[t.message])))}function Nr(e){return k.onClear(e)}var ut="@react_buoy_console_preserve",Le="@react_buoy_console_buffer",Br=600,M=false,ne=false,U=0,J=Promise.resolve(),Ae=new Set,pe=null;function dt(){for(let e of Ae)e()}function ft(){!M||!_()||(pe&&clearTimeout(pe),pe=setTimeout(gt,Br))}async function gt(){if(pe=null,!(!M||!_()))try{let e=k.getSnapshot().map(r=>({...r,args:Ze(r.args)})),t=U;J=J.then(async()=>{t!==U||!M||!_()||await ee.setItem(Le,JSON.stringify(e))}).catch(()=>{}),await J}catch{}}async function Ie(){U++,ne=false;try{J=J.then(()=>ee.removeItem(Le)).catch(()=>{}),await J}catch{}}async function pt(){if(ne||!_())return;ne=true;let e=U;try{M=await ee.getItem(ut)==="true"}catch{M=false}if(e!==U||!_()){ne=false;return}if(dt(),!M){await Ie();return}try{let t=await ee.getItem(Le);if(e!==U||!_()){ne=false;return}if(t){let r=JSON.parse(t);Array.isArray(r)&&r.length&&(k.update(o=>[...r,...o].filter(n=>!ye(n.args??[n.message]))),k.bumpIdAbove(Math.max(...r.map(o=>o.id))))}}catch{}}function Oe(){return M}function mt(e){M!==e&&(M=e,dt(),ee.setItem(ut,String(e)).catch(()=>{}),e?gt():Ie())}function ht(e){return Ae.add(e),()=>{Ae.delete(e)}}var De={verbose:true,info:true,warning:true,error:true},Ne={...De,verbose:false},Mr=/^([\w-]+):(.+)$/,Hr=/^\/(.+)\/$/;function jr(e){let t=[];for(let r of e.split(/\s+/)){if(!r)continue;let o=r,n=false;o.startsWith("-")&&o.length>1&&(n=true,o=o.slice(1));let a=o.match(Mr);if(a){t.push({key:a[1].toLowerCase(),text:a[2],negative:n});continue}let l=o.match(Hr);if(l)try{t.push({regex:new RegExp(l[1],"im"),negative:n});continue}catch{}t.push({text:o,negative:n})}return t}function Rr(e,t){return e.message.toLowerCase().includes(t.toLowerCase())}function Pr(e,t){for(let r of t)if(r.regex){if(r.regex.test(e.message)===r.negative)return false}else if(r.text&&Rr(e,r.text)===r.negative)return false;return true}function zr(e,t,r){return e.method==="groupEnd"?true:t[e.level]?Pr(e,r):false}var yt={verbose:"Verbose",info:"Info",warning:"Warnings",error:"Errors"},Be=["verbose","info","warning","error"];function bt(e,t){return Be.every(r=>e[r]===t[r])}function Wr(e){if(bt(e,De))return"All levels";if(bt(e,Ne))return"Default levels";let t=Be.filter(r=>e[r]);return t.length===0?"Hide all":t.length===1?`${yt[t[0]]} only`:"Custom levels"}var Me=5,Fr=5;function Gr(e,t){for(let r of e){let o=hr(r.entry.origin,t);r.sourceKey=o,r.originColor=o?Xe(o):void 0,r.originLabel=t==="off"?void 0:yr(r.entry.origin,t)}}function Vr(e){for(let t=0;t<e.length;t++){let r=e[t].sourceKey;if(r==null){e[t].bracketGlyph=void 0;continue}let o=t>0&&e[t-1].sourceKey===r,n=t<e.length-1&&e[t+1].sourceKey===r,a=!o&&!n?"single":o?n?"mid":"bottom":"top";e[t].bracketGlyph=et(a)}}function _r(e,t){let r=[],o=new Map;for(let a of e){let l=a.sourceKey??"\u2014",s=o.get(l);s||(s=[],o.set(l,s),r.push(l)),s.push(a)}let n=[];for(let a of r){let l=o.get(a);for(let u of l)u.depth=0;let s=l.length>Fr,i=t[a]??false;s&&(n.push({key:`cluster:${a}`,entry:l[0].entry,depth:0,repeatCount:1,isGroupHeader:false,sourceKey:a,originColor:l[0].originColor,originLabel:l[0].originLabel,clusterHeader:{key:a,count:l.length,expanded:i}}),!i)||l.forEach((u,c)=>{let d=l.length===1?"single":c===0?"top":c===l.length-1?"bottom":"mid";u.bracketGlyph=et(d),n.push(u)})}return n}function Kr(e){let t=new Map,r=new Map;e.forEach((s,i)=>{let u=s.sourceKey;u!=null&&(t.has(u)||t.set(u,i),r.set(u,i))});let o=[...t.keys()].sort((s,i)=>t.get(s)-t.get(i)),n=new Map,a=[];for(let s of o){let i=a.findIndex(u=>u<t.get(s));i===-1&&(i=a.length<Me?a.length:Me-1,i>=a.length&&a.push(0)),n.set(s,i),a[i]=Math.max(a[i]??0,r.get(s))}let l=Math.max(1,Math.min(a.length,Me));e.forEach((s,i)=>{let u=Array.from({length:l},()=>({glyph:" "}));for(let c of o){let d=n.get(c);d>=l||i>=t.get(c)&&i<=r.get(c)&&(u[d]={glyph:s.sourceKey===c?"\u25CF":"\u2502",color:Xe(c)})}s.lanes=u})}var Ur=new Set(["group","groupCollapsed"]);function Jr(e,t){let{levelsMask:r,query:o,showTimestamps:n,collapsedOverrides:a}=t,l=jr(o.trim()),s=[],i={verbose:0,info:0,warning:0,error:0},u=0,c=[],d=()=>c.some(f=>f.collapsed);for(let f of e){if(i[f.level]++,f.method==="groupEnd"){c.pop();continue}let O=Ur.has(f.method),V=d();if(!zr(f,r,l))u++;else if(!V){let L=s[s.length-1];!n&&!O&&L&&!L.isGroupHeader&&L.depth===c.length&&L.entry.method===f.method&&L.entry.message===f.message?L.repeatCount++:s.push({key:String(f.id),entry:f,depth:c.length,repeatCount:1,isGroupHeader:O,groupId:O?f.id:void 0,groupCollapsed:void 0})}if(O){let L=f.method==="groupCollapsed",F=a[f.id]??L,j=s[s.length-1];j&&j.groupId===f.id&&(j.groupCollapsed=F),c.push({id:f.id,collapsed:F||V})}}Gr(s,t.groupDimension);let v=s;return t.groupDimension!=="off"&&(t.layoutMode==="cluster"?v=_r(s,t.clusterExpanded):t.layoutMode==="swimlane"?Kr(s):Vr(s)),{rows:v,hiddenCount:u,levelCounts:i,totalCount:e.length}}function vt(e){let t=or(ge,K,K);return rr(()=>Jr(t,e),[t,e.levelsMask,e.query,e.showTimestamps,e.collapsedOverrides,e.groupDimension,e.layoutMode,e.clusterExpanded])}function wt(){let[e,t]=R(""),[r,o]=R(false),[n,a]=R({...Ne}),[l,s]=R(false),[i,u]=R({}),[c,d]=R("chrono"),[v,f]=R("list"),[O,V]=R({}),{rows:L,hiddenCount:F}=vt({levelsMask:n,query:e,showTimestamps:l,collapsedOverrides:i,groupDimension:"function",layoutMode:c,clusterExpanded:O}),j=he((se,ce)=>{u(Yt=>({...Yt,[se]:!ce}))},[]),le=he(se=>{V(ce=>({...ce,[se]:!(ce[se]??false)}))},[]),h=he(()=>{oe(),u({})},[]),C=Wr(n);return{query:e,setQuery:t,searchActive:r,setSearchActive:o,levelsMask:n,setLevelsMask:a,showTimestamps:l,setShowTimestamps:s,layoutMode:c,setLayoutMode:d,view:v,setView:f,rows:L,hiddenCount:F,onToggleGroup:j,onToggleCluster:le,clear:h,levelSummary:C,isLevelCustom:C!=="All levels"&&C!=="Default levels"}}var xt={};Xt(xt,{AccessibilityInfo:()=>Zr,ActivityIndicator:()=>tn,Alert:()=>nn,Animated:()=>Jo,AppRegistry:()=>eo,AppState:()=>to,Appearance:()=>Xr,BackHandler:()=>ro,Button:()=>rn,CheckBox:()=>vo,Clipboard:()=>oo,DeviceEventEmitter:()=>Bo,Dimensions:()=>no,Easing:()=>ao,FlatList:()=>He,I18nManager:()=>io,Image:()=>wo,ImageBackground:()=>xo,InteractionManager:()=>so,Keyboard:()=>lo,KeyboardAvoidingView:()=>ko,LayoutAnimation:()=>co,Linking:()=>uo,LogBox:()=>No,Modal:()=>Xo,NativeEventEmitter:()=>fo,NativeModules:()=>Qr,PanResponder:()=>go,Picker:()=>So,PixelRatio:()=>po,Platform:()=>mo,Pressable:()=>Zo,ProgressBar:()=>Co,RefreshControl:()=>Eo,SafeAreaView:()=>To,ScrollView:()=>Tt,SectionList:()=>$o,Share:()=>ho,StatusBar:()=>Lo,StyleSheet:()=>T,Switch:()=>en,Text:()=>g,TextInput:()=>Yo,Touchable:()=>Ao,TouchableHighlight:()=>qo,TouchableNativeFeedback:()=>Io,TouchableOpacity:()=>$,TouchableWithoutFeedback:()=>Qo,UIManager:()=>yo,Vibration:()=>bo,View:()=>y,VirtualizedList:()=>Oo,YellowBox:()=>Do,findNodeHandle:()=>on,unstable_createElement:()=>qr,useColorScheme:()=>Mo,useLocaleContext:()=>Ho,useWindowDimensions:()=>jo});er(xt,Yr);import*as Yr from"react-native-web";import{unstable_createElement as qr,NativeModules as Qr,AccessibilityInfo as Zr,Appearance as Xr,AppRegistry as eo,AppState as to,BackHandler as ro,Clipboard as oo,Dimensions as no,Easing as ao,I18nManager as io,Keyboard as lo,InteractionManager as so,LayoutAnimation as co,Linking as uo,NativeEventEmitter as fo,PanResponder as go,PixelRatio as po,Platform as mo,Share as ho,UIManager as yo,Vibration as bo,CheckBox as vo,FlatList as He,Image as wo,ImageBackground as xo,KeyboardAvoidingView as ko,Picker as So,ProgressBar as Co,RefreshControl as Eo,SafeAreaView as To,SectionList as $o,StatusBar as Lo,Touchable as Ao,TouchableNativeFeedback as Io,VirtualizedList as Oo,YellowBox as Do,LogBox as No,DeviceEventEmitter as Bo,useColorScheme as Mo,useLocaleContext as Ho,useWindowDimensions as jo}from"react-native-web";import*as E from"react-native-web";import{createElement as je,forwardRef as kt,useCallback as Ro,useRef as Po}from"react";import{useEffect as zo,useState as Wo}from"react";import{createPortal as Fo}from"react-dom";var Go='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as Vo}from"react/jsx-runtime";var ae=Symbol.for("@buoy-gg/portal-host"),St=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Ct(){let e=document;if(e[ae])return e[ae].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Go});let r=()=>{let c=document.fullscreenElement,d=c&&c.tagName!=="CANVAS"?c:document.body;t.parentElement!==d&&d.appendChild(t)},o=new Map,n=c=>{(!t.contains(c.target)||!St(c.target))&&o.set(c.code||c.key,{key:c.key,code:c.code,location:c.location,keyCode:c.keyCode,which:c.which,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,shiftKey:c.shiftKey})},a=c=>{o.delete(c.code||c.key)},l=()=>o.clear(),s=()=>{let c=[...o.values()];o.clear();for(let d of c)document.dispatchEvent(new KeyboardEvent("keyup",{...d,bubbles:true}))},i=c=>{St(c.target)&&c.stopPropagation()},u=c=>c.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",l),t.addEventListener("focusin",s),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),t.addEventListener("wheel",u,{passive:true}),e[ae]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",l),t.remove(),delete e[ae]}},t}function _o({children:e}){let[t,r]=Wo(null);return zo(()=>{let o=Ct(),n=document[ae];return n.users++,r(o),()=>{--n.users===0&&n.dispose()}},[]),t?Fo(Vo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Y=E,Ko=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],q=e=>typeof e=="number"?`${e}px`:e;function Re(e){if(Array.isArray(e)){let d=e.map(Re);return d.some((v,f)=>v!==e[f])?d:e}if(!e||typeof e!="object"||!Ko.some(d=>e[d]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:o,shadowRadius:n,textShadowColor:a,textShadowOffset:l,textShadowRadius:s,...i}=e;if(t!=null||r!=null||o!=null||n!=null){let d=t??"black",v=o==null?d:`color-mix(in srgb, ${d} ${Math.min(o,1)*100}%, transparent)`,f=`${q(r?.width??0)} ${q(r?.height??0)} ${q(n??0)} ${v}`;i.boxShadow=typeof i.boxShadow=="string"?`${i.boxShadow}, ${f}`:i.boxShadow??f}let{width:u=0,height:c=0}=l??{};if(a&&(u||c||s)){let d=`${q(u)} ${q(c)} ${q(s??0)} ${a}`;i.textShadow=i.textShadow?`${i.textShadow}, ${d}`:d}return i}var Uo=Y.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Et(e,t){if(typeof e=="function")return o=>Et(e(o),t);let r=Re(e);return t?[r,Uo[t]]:r}var T={...Y.StyleSheet,create:e=>Y.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Re(r)])))};function A(e){let t=kt((o,n)=>{let{accessibilityState:a,accessibilityValue:l,pointerEvents:s,...i}=o;for(let c of["busy","checked","disabled","expanded","selected"])a?.[c]!==void 0&&i[`aria-${c}`]===void 0&&(i[`aria-${c}`]=a[c]);for(let[c,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[c]!==void 0&&i[`aria-${d}`]===void 0&&(i[`aria-${d}`]=l[c]);let u=Et(i.style,s);return u!==i.style&&(i.style=u),je(e,{...i,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var y=A(E.View),g=A(E.Text),Jo={...Y.Animated,View:Y.Animated.createAnimatedComponent(y),Text:Y.Animated.createAnimatedComponent(g)},Yo=A(E.TextInput),$=A(E.TouchableOpacity),qo=A(E.TouchableHighlight),Qo=A(E.TouchableWithoutFeedback),Zo=A(E.Pressable),Tt=A(E.ScrollView),$t=kt((e,t)=>{let r=Po(null),o=Ro(n=>{if(n){let a=n;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(r.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Ct().appendChild(a))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return je(_o,null,je(E.Modal,{...e,ref:o}))});$t.displayName="Modal";var Xo=A($t),en=A(E.Switch),tn=A(E.ActivityIndicator),rn=A(E.Button),on=E.findNodeHandle,nn={alert(e,t,r,o){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.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 a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(a),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(u)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],i=()=>{n.close?.(),n.remove()};for(let u of s){let c=document.createElement("button");c.type="button",c.textContent=u.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{i(),u.onPress?.()},l.appendChild(c)}n.addEventListener("cancel",u=>{u.preventDefault(),o?.cancelable!==false&&(i(),o?.onDismiss?.())}),n.appendChild(l),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{ModalHeader as P,TabSelector as an,night as N,Search as ln,Filter as sn,Trash2 as cn}from"@buoy-gg/shared-ui/web";import{jsx as I,jsxs as Pe}from"react/jsx-runtime";var un=[{key:"chrono",label:"Timeline"},{key:"cluster",label:"Grouped"}];function Lt({c:e,onBack:t}){if(e.view==="filters")return Pe(P,{children:[I(P.Navigation,{onBack:()=>e.setView("list")}),I(P.Content,{title:"Filters"})]});let r=e.rows.length>0;return Pe(P,{children:[t?I(P.Navigation,{onBack:t}):null,I(P.Content,{title:"",noMargin:true,children:e.searchActive?I(P.Search,{testID:"buoy-console-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)}}):I(an,{testIDPrefix:"buoy-console-tab",tabs:un,activeTab:e.layoutMode,onTabChange:o=>e.setLayoutMode(o)})}),Pe(P.Actions,{children:[I($,{onPress:()=>e.setSearchActive(o=>!o),style:[Q.actionBtn,e.searchActive&&Q.actionBtnActive],testID:"buoy-console-search-open",accessibilityLabel:"Search logs",children:I(ln,{size:14,color:e.searchActive?N.color.accent:N.color.textSecondary})}),I($,{onPress:()=>e.setView("filters"),style:[Q.actionBtn,e.isLevelCustom&&Q.actionBtnActive],testID:"buoy-console-filters-open",accessibilityLabel:"Filters",children:I(sn,{size:14,color:e.isLevelCustom?N.color.accent:N.color.textSecondary})}),I($,{onPress:e.clear,disabled:!r,style:[Q.actionBtn,!r&&Q.actionBtnDisabled],testID:"buoy-console-clear",accessibilityLabel:"Clear console",children:I(cn,{size:14,color:r?N.color.textSecondary:N.color.textTertiary})})]})]})}var Q=T.create({actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:N.color.buttonSurface,borderWidth:1,borderColor:N.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:N.color.accentSoft,borderColor:N.color.accentBorderStrong},actionBtnDisabled:{opacity:.55}});import{useCallback as dn,useRef as At,useSyncExternalStore as fn}from"react";import{night as H,Check as gn,LOG_LIST_PRESET as pn}from"@buoy-gg/shared-ui/web";import{memo as mn}from"react";import{useState as hn}from"react";import{monoFont as z,night as ie}from"@buoy-gg/shared-ui/web";var yn={baseContainer:"#0A0A0C",surfaceError:"rgba(255,69,58,0.15)",surfaceYellow:"rgba(255,235,59,0.13)",divider:ie.color.fillTertiary,inputBackground:ie.color.surfaceElevated,menuBackground:ie.color.surface,onSurface:ie.color.text,onSurfaceYellow:"#FFE9A3",onErrorContainer:"#FFB4AB",tokenSubtle:ie.color.textSecondary,primary:"#40CCFF",valueNumber:"#FF9F1C",valueString:"#7EE787",valueBigint:"#A1A1A6",valueNode:"#F5F5F7",valueNullish:"#8E8E93",valuePreview:"#A1A1A6"},m=yn,bn={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"},It={verbose:{text:m.tokenSubtle},info:{text:m.onSurface},warning:{background:m.surfaceYellow,text:m.onSurfaceYellow,icon:"warning"},error:{background:m.surfaceError,text:m.onErrorContainer,icon:"error"}};var Ot=["black","red","green","yellow","blue","magenta","cyan","gray"],Dt=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function Nt(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 ze=/%([%_Oocsdfi])|\x1B\[([\d;]*)m/;function vn(e){return ze.test(e)}function Bt(e){let t={},r=false;for(let o of e.split(";")){let n=o.indexOf(":");if(n===-1)continue;let a=o.slice(0,n).trim().toLowerCase(),l=o.slice(n+1).trim();if(!l)continue;let s=l.match(/var\(--console-color-([a-z]+)\)/);switch(s&&(l=bn[s[1]]??l),a){case"color":t.color=l,r=true;break;case"background-color":case"background":t.backgroundColor=l,r=true;break;case"font-weight":t.fontWeight=l==="lighter"?"300":l,r=true;break;case"font-style":l==="italic"&&(t.fontStyle="italic",r=true);break;case"font-size":{let i=parseFloat(l);Number.isNaN(i)||(t.fontSize=i,r=true);break}case"text-decoration":case"text-decoration-line":l.includes("underline")&&l.includes("line-through")?t.textDecorationLine="underline line-through":l.includes("underline")?t.textDecorationLine="underline":l.includes("line-through")&&(t.textDecorationLine="line-through"),r=true;break;default:break}}return r?t:void 0}function wn(e,t){let r=n=>{let a=t.get("text-decoration")??"";a.includes(n)||t.set("text-decoration",`${a} ${n}`)},o=n=>{let a=t.get("text-decoration")?.replace(` ${n}`,"");a?t.set("text-decoration",a):t.delete("text-decoration")};for(;e.length;){let n=e.shift();switch(n){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:o("underline");break;case 29:o("line-through");break;case 38:case 48:if(e.shift()===2){let a=e.shift()??0,l=e.shift()??0,s=e.shift()??0;t.set(n===38?"color":"background-color",`rgb(${a},${l},${s})`)}break;case 39:case 49:t.delete(n===39?"color":"background-color");break;default:{let a=Ot[n-30]??Dt[n-90];if(a!==void 0)t.set("color",`var(--console-color-${a})`);else{let l=Ot[n-40]??Dt[n-100];l!==void 0&&t.set("background-color",`var(--console-color-${l})`)}break}}}}function xn(e,t){let r=e,o=[],n=new Map,a,l=i=>{if(!i)return;let u=o[o.length-1];if(u&&u.type==="string"&&kn(u.style,a)){u.value+=i;return}o.push({type:"string",value:i,style:a})},s=0;for(let i=ze.exec(r);i!==null;i=ze.exec(r)){l(i.input.substring(0,i.index));let u,c=i[1];switch(c){case"%":l("%"),u="";break;case"s":s<t.length&&(u=Nt(t[s++]));break;case"c":s<t.length&&(a=Bt(Nt(t[s++])),u="");break;case"o":case"O":s<t.length&&(o.push({type:"value",value:t[s++],mode:c==="O"?"generic":"optimal"}),u="");break;case"_":s<t.length&&(s++,u="");break;case"d":case"f":case"i":{if(s<t.length){let d=t[s++],v=typeof d!="number"?NaN:d;c!=="f"&&(v=Math.floor(v)),u=v}break}case void 0:{let d=(i[2]||"0").split(";").map(f=>f?parseInt(f,10):0);wn(d,n);let v=[...n.entries()].map(([f,O])=>`${f}:${O.trimStart()}`).join(";");a=Bt(v),u="";break}}u===void 0&&(l(i[0]),u=""),r=u+i.input.substring(i.index+i[0].length)}return l(r),{tokens:o,rest:t.slice(s)}}function kn(e,t){return e===t?true:!e||!t?false:JSON.stringify(e)===JSON.stringify(t)}function Sn(e){if(e.length===0)return[];let t=[],r=e;if(typeof e[0]=="string"&&vn(e[0])){let o=xn(e[0],e.slice(1));t=o.tokens,r=o.rest}for(let o of r)t.length>0&&t.push({type:"string",value:" "}),typeof o=="string"?t.push({type:"string",value:o}):t.push({type:"value",value:o,mode:"optimal"});return t}import{useState as Cn}from"react";import{jsx as D,jsxs as Z}from"react/jsx-runtime";var Mt=5,Ht=6;function We(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:m.valueNumber,bigint:m.valueBigint,boolean:m.valueNumber,string:m.valueString,null:m.valueNullish,undefined:m.valueNullish,symbol:m.valueString,function:m.valueNode};function jt(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 Fe(e){switch(We(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=jt(e);return t?`${t} {\u2026}`:"{\u2026}"}default:return String(e)}}function Tn(e){if(Array.isArray(e)){let a=e.slice(0,Ht).map(s=>Fe(s)).join(", "),l=e.length>Ht?", \u2026":"";return`(${e.length}) [${a}${l}]`}let t=Object.entries(e),r=t.slice(0,Mt).map(([a,l])=>`${a}: ${Fe(l)}`).join(", "),o=t.length>Mt?", \u2026":"",n=jt(e);return`${n?`${n} `:""}{${r}${o}}`}function $n(e){let t=We(e);return t==="array"?e.length>0:t==="object"?Object.keys(e).length>0:t==="error"}var Rt=({open:e})=>D(g,{style:[w.triangle,e&&w.triangleOpen],children:"\u25B6"});function Ge({value:e,depth:t=0,testID:r}){let[o,n]=Cn(false),a=We(e);if(a==="error"){let i=e,u=`${i.name}: ${i.message}`.split(`
|
|
16
|
+
`)[0],c=i.stack&&i.stack.trim()!==u.trim()?i.stack:void 0;return c?Z(y,{style:w.objectContainer,children:[Z($,{testID:r,style:w.objectHeader,activeOpacity:.6,onPress:()=>n(d=>!d),children:[D(Rt,{open:o}),D(g,{style:[w.mono,w.errorHead],numberOfLines:o?void 0:1,children:u})]}),o?D(g,{style:[w.mono,w.errorStack],children:c}):null]}):D(g,{style:[w.mono,{color:m.onErrorContainer}],numberOfLines:1,children:u})}if(!$n(e)){let i=En[a]??m.onSurface;return D(g,{testID:r,style:[w.mono,{color:i}],children:Fe(e)})}let l=e,s=Array.isArray(l)?l.map((i,u)=>[String(u),i]):Object.entries(l);return Z(y,{style:w.objectContainer,children:[Z($,{testID:r,onPress:()=>n(i=>!i),activeOpacity:.6,style:w.objectHeader,children:[D(Rt,{open:o}),D(g,{style:[w.mono,w.preview],numberOfLines:o?void 0:1,children:Tn(l)})]}),o&&t<6?D(y,{testID:r?`${r}-children`:void 0,style:w.children,children:s.map(([i,u])=>Z(y,{style:w.propertyRow,children:[Z(g,{style:[w.mono,w.propertyKey],children:[i,":"]}),D(y,{style:w.propertyValue,children:D(Ge,{testID:r?`${r}-${i}`:void 0,value:u,depth:t+1})})]},i))}):null]})}var Ln={fontFamily:z,fontSize:12,lineHeight:16},w=T.create({mono:Ln,objectContainer:{flexDirection:"column"},objectHeader:{flexDirection:"row",alignItems:"flex-start"},triangle:{color:m.tokenSubtle,fontSize:8,lineHeight:16,width:12},triangleOpen:{transform:[{rotate:"90deg"}]},preview:{color:m.valuePreview,fontStyle:"italic",flexShrink:1},errorHead:{color:m.onErrorContainer,flexShrink:1},errorStack:{color:m.tokenSubtle,marginLeft:14,marginTop:1},children:{marginLeft:14,flexDirection:"column"},propertyRow:{flexDirection:"row",alignItems:"flex-start"},propertyKey:{color:m.valueNode,marginRight:6},propertyValue:{flexShrink:1}});import{jsx as b,jsxs as X}from"react/jsx-runtime";function An(e){let t=new Date(e),r=(o,n=2)=>String(o).padStart(n,"0");return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}.${r(t.getMilliseconds(),3)}`}function In({icon:e,color:t}){return b(g,{style:[p.levelIcon,{color:t}],children:e==="warning"?"\u26A0":"\u2298"})}function On({count:e,color:t}){return b(y,{style:[p.repeatBadge,{borderColor:t}],children:b(g,{testID:"buoy-console-repeat-count",style:[p.repeatBadgeText,{color:t}],children:e})})}var Pt=mn(function({row:e,showTimestamps:t,onToggleGroup:r,onToggleCluster:o}){let{entry:n}=e,a=It[n.level],l=n.level==="error"||n.level==="warning",s=a.text,[i,u]=hn(n.method==="trace");if(e.clusterHeader){let h=e.clusterHeader;return b($,{testID:`buoy-console-cluster-${e.originLabel}`,style:[p.wrapper,p.dividerTop],activeOpacity:.7,onPress:()=>o(h.key),children:X(y,{style:p.rowWrapper,children:[b(g,{style:[p.originGutter,{color:e.originColor}],children:h.expanded?"\u25BC":"\u25B6"}),b(y,{style:p.messageColumn,children:X(y,{style:p.messageLine,children:[b(g,{style:[p.text,p.clusterTitle,{color:e.originColor}],children:e.originLabel}),X(g,{testID:"buoy-console-cluster-count",style:p.clusterCount,children:[" \xB7 ",h.count," logs"]})]})})]})})}let c=Sn(n.args),d=!!n.stack&&(l||n.method==="trace"),v=b(y,{testID:i?"buoy-console-content-expanded":"buoy-console-content-collapsed",style:[p.contentWrap,!i&&p.contentWrapClamped],children:c.map((h,C)=>h.type==="string"?b(g,{testID:`buoy-console-text-${C}`,style:[p.text,{color:s},e.isGroupHeader&&p.groupTitle,h.style],children:h.value},C):b(Ge,{testID:`buoy-console-value-${C}`,value:h.value,generic:h.mode==="generic"},C))}),f=X(y,{style:p.messageColumn,children:[e.originLabel?b(g,{testID:"buoy-console-origin",style:[p.originLabel,{color:e.originColor}],numberOfLines:1,children:e.originLabel}):null,X(y,{style:p.messageLine,children:[e.isGroupHeader?b(g,{style:[p.groupTriangle,{color:s}],children:e.groupCollapsed?"\u25B6":"\u25BC"}):null,a.icon?b(In,{icon:a.icon,color:s}):null,t?b(g,{testID:"buoy-console-timestamp",style:p.timestamp,children:An(n.timestamp)}):null,d?b(g,{style:[p.stackTriangle,{color:s}],children:i?"\u25BC":"\u25B6"}):null,v,e.repeatCount>1?b(On,{count:e.repeatCount,color:s}):null]}),d&&i?b(y,{testID:"buoy-console-stack",style:p.stackTrace,children:(n.stack??"").split(`
|
|
17
|
+
`).filter(h=>h.trim()).map((h,C)=>b(g,{style:p.stackFrame,children:h.trim()},C))}):null]}),O=[p.wrapper,a.background?{backgroundColor:a.background}:p.dividerTop],V=Array.from({length:e.depth},(h,C)=>b(y,{style:p.nestingMarker},C)),L=e.lanes?b(y,{style:p.laneGutter,children:e.lanes.map((h,C)=>b(g,{style:[p.laneCell,h.color?{color:h.color}:null],children:h.glyph},C))}):e.bracketGlyph?b(g,{style:[p.originGutter,{color:e.originColor}],children:e.bracketGlyph}):null,F=X(y,{style:p.rowWrapper,children:[L,V,f]}),j=`buoy-console-row-${String(n.args[0])}`,le=[e.originLabel,c.find(h=>h.type==="string")?.value].filter(Boolean).join(" \u2014 ").slice(0,80);if(e.isGroupHeader&&e.groupId!==void 0){let h=e.groupId;return b($,{style:O,activeOpacity:.7,onPress:()=>r(h,!!e.groupCollapsed),testID:j,accessibilityLabel:le||"Console group",children:F})}return b($,{style:O,activeOpacity:.7,onPress:()=>u(h=>!h),testID:j,accessibilityLabel:le||"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),p=T.create({wrapper:{paddingVertical:2,paddingRight:8,minHeight:18},dividerTop:{borderTopWidth:T.hairlineWidth,borderTopColor:m.divider},rowWrapper:{flexDirection:"row",alignItems:"flex-start"},originGutter:{width:11,fontFamily:z,fontSize:13,lineHeight:18,textAlign:"center"},laneGutter:{flexDirection:"row"},laneCell:{width:9,fontFamily:z,fontSize:13,lineHeight:18,textAlign:"center"},originLabel:{fontFamily:z,fontSize:10,lineHeight:16,marginBottom:1,opacity:.9},nestingMarker:{width:14,alignSelf:"stretch",borderRightWidth:T.hairlineWidth,borderRightColor:m.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:z,fontSize:12,lineHeight:16},groupTitle:{fontWeight:"bold"},clusterTitle:{fontWeight:"600"},clusterCount:{color:m.tokenSubtle,fontFamily:z,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:m.tokenSubtle,fontFamily:z,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:m.tokenSubtle,fontFamily:z,fontSize:11,lineHeight:15}});import{jsx as x,jsxs as Ve}from"react/jsx-runtime";function zt({c:e}){return e.view==="filters"?x(Nn,{c:e}):x(Dn,{c:e})}function Dn({c:e}){let t=At(null),r=At(true),o=dn(({item:n})=>x(Pt,{row:n,showTimestamps:e.showTimestamps,onToggleGroup:e.onToggleGroup,onToggleCluster:e.onToggleCluster}),[e.showTimestamps,e.onToggleGroup,e.onToggleCluster]);return x(He,{testID:"buoy-console-list",ref:t,data:e.rows,keyExtractor:n=>n.key,renderItem:o,style:S.list,...pn,onContentSizeChange:()=>{r.current&&t.current?.scrollToEnd({animated:false})},onScroll:n=>{let{contentOffset:a,contentSize:l,layoutMeasurement:s}=n.nativeEvent,i=l.height-(a.y+s.height);r.current=i<40},scrollEventThrottle:100})}function _e({testID:e,on:t,label:r,subtext:o,onPress:n}){return Ve($,{testID:e,style:S.row,onPress:n,activeOpacity:.7,children:[x(y,{style:[S.checkbox,t&&S.checkboxOn],children:t?x(gn,{size:12,color:H.color.onAccent,strokeWidth:3}):null}),Ve(y,{style:S.rowTextCol,children:[x(g,{style:S.rowLabel,children:r}),o?x(g,{style:S.rowSubtext,children:o}):null]})]})}function Wt({text:e}){return x(g,{style:S.sectionLabel,children:e})}function Nn({c:e}){let t=fn(ht,Oe,Oe),r=o=>e.setLevelsMask({...e.levelsMask,[o]:!e.levelsMask[o]});return Ve(Tt,{testID:"buoy-console-filters",style:S.subView,contentContainerStyle:S.subViewContent,children:[x(Wt,{text:"Log levels"}),x($,{testID:"buoy-console-levels-default",style:S.presetRow,onPress:()=>e.setLevelsMask({...Ne}),children:x(g,{style:S.presetText,children:"Default (hide verbose)"})}),x($,{testID:"buoy-console-levels-all",style:S.presetRow,onPress:()=>e.setLevelsMask({...De}),children:x(g,{style:S.presetText,children:"All levels"})}),Be.map(o=>x(_e,{testID:`buoy-console-level-${o}`,on:e.levelsMask[o],label:yt[o],onPress:()=>r(o)},o)),x(y,{style:S.divider}),x(Wt,{text:"Settings"}),x(_e,{testID:"buoy-console-timestamps",on:e.showTimestamps,label:"Show timestamps",onPress:()=>e.setShowTimestamps(o=>!o)}),x(_e,{testID:"buoy-console-preserve",on:t,label:"Preserve log",subtext:"Do not clear log on reload",onPress:()=>mt(!t)})]})}var S=T.create({list:{flex:1,backgroundColor:"transparent"},subView:{flex:1,backgroundColor:"transparent"},subViewContent:{padding:12},sectionLabel:{color:H.color.textTertiary,fontSize:11,textTransform:"uppercase",letterSpacing:.5,marginTop:4,marginBottom:4,paddingHorizontal:8},presetRow:{paddingVertical:10,paddingHorizontal:8},presetText:{color:H.color.accent,fontSize:14,fontWeight:"600"},divider:{height:T.hairlineWidth,backgroundColor:H.color.border,marginVertical:6},row:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:8,gap:12},rowTextCol:{flexDirection:"column",flex:1},rowLabel:{color:H.color.text,fontSize:14},rowSubtext:{color:H.color.textTertiary,fontSize:12,marginTop:1},checkbox:{width:18,height:18,borderRadius:4,borderWidth:1,borderColor:H.color.fillTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:H.color.accent,borderColor:H.color.accent}});import{jsx as Ke}from"react/jsx-runtime";function Ft({visible:e,onClose:t,onBack:r,onMinimize:o,persistenceKey:n="@react_buoy_console_modal"}){let a=wt();return Ke(tr,{visible:e,onClose:t,onMinimize:o,persistenceKey:n,header:{showToggleButton:true,customContent:Ke(Lt,{c:a,onBack:r})},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ke(zt,{c:a})})}import{createToolFactory as Bn,defineToolPreset as Mn}from"@buoy-gg/shared-ui/web";import{jsx as Hn}from"react/jsx-runtime";var Gt=globalThis,jn=typeof Gt.ErrorUtils?.setGlobalHandler=="function"||typeof Gt.RN$registerExceptionListener=="function";jn&&typeof ue<"u"&&ue?fe():typeof ue<"u"&&ue&&Te();var Vt=Mn({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:Qe,icon:({size:e})=>Hn(qe,{size:e}),component:Ft}),Rn=Bn(Vt);import{useEffect as Pn}from"react";import{getAccountAccess as zn,subscribeAccountAccess as Wn}from"@buoy-gg/shared-ui/web";var _t=0;function Fn(){return Pn(()=>{++_t;let e=true,t=()=>{if(!e)return;let o=zn();if(o.status==="locked"){$e(),oe();return}fe(),o.status==="admitted"&&pt()},r=Wn(t);return t(),()=>{e=false,r(),--_t===0&&$e()}},[]),null}import{macOSColors as Gn,windowDragProps as Vn}from"@buoy-gg/shared-ui/web";import{jsx as Ue,jsxs as _n}from"react/jsx-runtime";function Kn(){let e=wt();return _n(y,{style:Kt.container,children:[Ue(y,{style:Kt.headerBar,...Vn,children:Ue(Lt,{c:e})}),Ue(zt,{c:e})]})}var Kt=T.create({container:{flex:1,backgroundColor:"transparent"},headerBar:{paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:T.hairlineWidth,borderBottomColor:Gn.border.default}});import{useSyncExternalStore as Un,useEffect as Jn}from"react";function Ut(){return Jn(()=>{fe()},[]),{logs:Un(ge,K,K)}}import{night as W,ToolEmptyState as Yn,monoFont as qn}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as me}from"react/jsx-runtime";var Jt={verbose:"#9b9b9b",info:W.color.text,warning:"#e2c08d",error:"#f48771"};function Qn(e){let t=new Date(e),r=(o,n=2)=>String(o).padStart(n,"0");return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}.${r(t.getMilliseconds(),3)}`}function Zn(){let{logs:e}=Ut(),t=({item:r})=>me(y,{style:B.row,children:[G(g,{style:B.time,children:Qn(r.timestamp)}),G(g,{style:[B.level,{color:Jt[r.level]}],children:r.level.toUpperCase()}),G(g,{style:[B.message,{color:Jt[r.level]}],numberOfLines:3,children:r.message})]});return me(y,{style:B.container,children:[me(y,{style:B.header,children:[me(g,{style:B.headerTitle,children:["Console (",e.length,")"]}),G($,{onPress:()=>oe(),style:B.clearButton,children:G(g,{style:B.clearText,children:"Clear"})})]}),G(He,{data:e,keyExtractor:r=>String(r.id),renderItem:t,ListEmptyComponent:G(Yn,{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?B.emptyContainer:void 0})]})}var B=T.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:T.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:T.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:qn},empty:{color:W.color.textTertiary,fontSize:13,textAlign:"center"},emptyContainer:{flexGrow:1,alignItems:"center",justifyContent:"center"}});import{createSyncAdapter as Xn,memoByIdentity as ea,newestFitting as ta,sizeOrStub as ra}from"@buoy-gg/shared-ui/web";var oa=1.5*1024*1024,na=16*1024,aa=Object.freeze({__buoyTruncated:true,note:"Log payload omitted \u2014 inspect it on-device."}),ia=ea(e=>{let t={...e,args:Ze(e.args),message:te(e.message),stack:e.stack?te(e.stack,4096):e.stack};return ra(t,na,()=>({...t,args:[aa]}))});function la(e){return ta(e,{toWire:ia,budget:oa,baseBytes:16})}var sa=Xn({version:1,getSnapshot(){return{entries:la(K())}},subscribe(e){return ge(e)},actions:{clearEntries(){return oe(),{cleared:true}}}});export{Qe as CONSOLE_ICON_COLOR,qe as ConsoleIcon,Zn as ConsoleLogList,Pt as ConsoleMessageRow,Ft as ConsoleModal,Fn as ConsoleRoot,Ge as ConsoleValue,Kn as ConsoleView,oe as clearEntries,sa as consoleSyncAdapter,m as consoleTheme,Vt as consoleToolPreset,Rn as createConsoleTool,K as getEntries,Oe as getPreserveLog,pt as initConsolePersistence,fe as installConsoleCapture,Te as installFatalErrorCapture,It as levelStyles,Nr as onClear,Dr as replaceEntries,mt as setPreserveLog,ge as subscribe,ht as subscribePreserveLog,$e as uninstallConsoleCapture,Ut as useConsoleLogs,vt 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.76",
|
|
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.76"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "*"
|