@buoy-gg/console 7.0.67 → 7.0.69
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/devtools/origin.js +1 -1
- package/lib/commonjs/store/consoleLogStore.js +4 -4
- package/lib/module/devtools/origin.js +1 -1
- package/lib/module/store/consoleLogStore.js +4 -4
- package/lib/typescript/devtools/origin.d.ts +3 -1
- package/lib/web/index.mjs +11 -11
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.bracketGlyph=bracketGlyph;exports.colorForKey=colorForKey;exports.consoleWrapperDepth=consoleWrapperDepth;exports.parseOrigin=parseOrigin;exports.sourceKey=sourceKey;exports.sourceLabel=sourceLabel;const INTERNAL_FUNC=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/;const INTERNAL_FILE=/consoleLogStore/;function bareName(n){return n.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function isInternalFrame(n){if(n.func&&INTERNAL_FUNC.test(bareName(n.func))){return true}return Boolean(n.file&&INTERNAL_FILE.test(n.file))}function parseFrames(n){const e=[];for(const o of n.split("\n")){const u=o.trim();if(!u||u==="Error")continue;let t=u.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(t){e.push({func:t[1],file:t[2],line:Number(t[3])});continue}t=u.match(/^at\s+(.+?):(\d+):(\d+)$/);if(t){e.push({file:t[1],line:Number(t[2])});continue}t=u.match(/^(.*?)@(.+?):(\d+):(\d+)$/);if(t){e.push({func:t[1]||void 0,file:t[2],line:Number(t[3])});continue}}return e}function basename(n){if(!n)return void 0;const e=n.split(/\?|\/\/&/)[0];return e.split("/").pop()||e}function cleanFunctionName(n){if(!n)return void 0;const e=bareName(n);if(!e||e==="<anonymous>"||e==="anonymous")return void 0;return e}function firstComponent(n){if(!n)return void 0;for(const e of n.split("\n")){const o=e.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(o)return o[1]}return void 0}function consoleWrapperDepth(n,e){const o=new Set;let u=0;while(typeof n==="function"&&n!==e&&!o.has(n)){o.add(n);try{n=Reflect.get(n,"__sentry_original__")}catch{return 0}u+=1}return n===e?u:0}function parseOrigin(n,e,o=0){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.bracketGlyph=bracketGlyph;exports.colorForKey=colorForKey;exports.consoleWrapperDepth=consoleWrapperDepth;exports.parseOrigin=parseOrigin;exports.sourceKey=sourceKey;exports.sourceLabel=sourceLabel;const INTERNAL_FUNC=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/;const INTERNAL_FILE=/consoleLogStore/;function bareName(n){return n.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function isInternalFrame(n){if(n.func&&INTERNAL_FUNC.test(bareName(n.func))){return true}return Boolean(n.file&&INTERNAL_FILE.test(n.file))}function parseFrames(n){const e=[];for(const o of n.split("\n")){const u=o.trim();if(!u||u==="Error")continue;let t=u.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(t){e.push({func:t[1],file:t[2],line:Number(t[3])});continue}t=u.match(/^at\s+(.+?):(\d+):(\d+)$/);if(t){e.push({file:t[1],line:Number(t[2])});continue}t=u.match(/^(.*?)@(.+?):(\d+):(\d+)$/);if(t){e.push({func:t[1]||void 0,file:t[2],line:Number(t[3])});continue}}return e}function basename(n){if(!n)return void 0;const e=n.split(/\?|\/\/&/)[0];return e.split("/").pop()||e}function cleanFunctionName(n){if(!n)return void 0;const e=bareName(n);if(!e||e==="<anonymous>"||e==="anonymous")return void 0;return e}function firstComponent(n){if(!n)return void 0;for(const e of n.split("\n")){const o=e.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(o)return o[1]}return void 0}function consoleWrapperDepth(n,e){const o=new Set;let u=0;while(typeof n==="function"&&n!==e&&!o.has(n)){o.add(n);try{n=Reflect.get(n,"__sentry_original__")}catch{return 0}u+=1}return n===e?u:0}function parseOrigin(n,e,o=0,u=[]){const t=firstComponent(e);let r;if(n){const p=parseFrames(n);let a=0;for(const c of u){const m=p[a];if(c&&m?.func&&bareName(m.func)===c)a++}const d=p.slice(a).filter(c=>!isInternalFrame(c));r=d[o]}const l=cleanFunctionName(r?.func);const f=basename(r?.file);const s=r?.line;const i=f&&s!=null?`${f}:${s}`:void 0;if(!t&&!l&&!i)return void 0;return{component:t,functionName:l,callSite:i,file:f,line:s}}function sourceKey(n,e){if(e==="off"||!n)return e==="off"?null:"\u2014unknown\u2014";if(e==="component"){return n.component??n.functionName??n.callSite??"\u2014unknown\u2014"}if(e==="function"){return n.functionName??n.callSite??n.component??"\u2014anonymous\u2014"}return n.callSite??n.functionName??"\u2014unknown\u2014"}function sourceLabel(n,e){if(!n)return"(unknown)";if(e==="component"){if(n.component)return n.component;if(n.functionName)return`\u0192 ${n.functionName}`;return n.callSite??"(unknown)"}if(e==="function"){if(n.functionName)return n.functionName;return n.callSite??"(anonymous)"}if(e==="callsite"){if(n.functionName&&n.callSite)return`${n.functionName} \xB7 ${n.callSite}`;return n.callSite??(n.functionName?`\u0192 ${n.functionName}`:"(unknown)")}return""}function hashString(n){let e=0;for(let o=0;o<n.length;o++)e=e*31+n.charCodeAt(o)|0;return Math.abs(e)}function colorForKey(n){const e=hashString(n)%360;return`hsl(${e}, 70%, 66%)`}function bracketGlyph(n){switch(n){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}
|
|
@@ -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 n=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(r,
|
|
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,n){if((0,_sharedUi.isBuoyLog)(t))return;const o=new Error().stack;const r=(0,_origin.parseOrigin)(o,captureOwnerStack(),(0,_origin.consoleWrapperDepth)(console[e],n));const s=e==="error"?asComponentError(t[0]):null;if(s){const a=fatalKey(s.name,s.message);const c=s.componentStack?`
|
|
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 n=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(r,i){if(!i&&r&&r.__esModule)return r;var s,l,a={__proto__:null,default:r};if(null===r||"object"!=typeof r&&"function"!=typeof r)return a;if(s=i?o:n){if(s.has(r))return s.get(r);s.set(r,a)}for(const c in r)"default"!==c&&{}.hasOwnProperty.call(r,c)&&((l=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(r,c))&&(l.get||l.set)?s(a,c,l):a[c]=r[c]);return a})(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={};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(r=>r.trim()).filter(Boolean).map(r=>r.replace(/\s*\((?:https?:|\/).*$/,""));const n=t.slice(0,COMPONENT_STACK_FRAMES);const o=t.length-n.length;return n.map(r=>` ${r}`).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,n){if((0,_sharedUi.isBuoyLog)(t))return;const o=new Error().stack;const r=[record.name,n?.name??""];const i=(0,_origin.parseOrigin)(o,captureOwnerStack(),(0,_origin.consoleWrapperDepth)(console[e],n),r);const s=e==="error"?asComponentError(t[0]):null;if(s){const a=fatalKey(s.name,s.message);const c=s.componentStack?`
|
|
3
3
|
|
|
4
4
|
This error is located at:
|
|
5
|
-
${compactComponentStack(s.componentStack)}`:"";pushFatal({id:store.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",s],message:`[RENDER ERROR] ${a}${c}`,timestamp:Date.now(),stack:s.stack,origin:
|
|
5
|
+
${compactComponentStack(s.componentStack)}`:"";pushFatal({id:store.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",s],message:`[RENDER ERROR] ${a}${c}`,timestamp:Date.now(),stack:s.stack,origin:i},isDuplicateFatal(`[RENDER ERROR] ${a}`));return}const l={id:store.allocId(),method:e,level:METHOD_LEVEL[e],args:t,message:formatArgs(t),timestamp:Date.now(),stack:STACK_METHODS.has(e)?cleanStack(o):void 0,origin:i};store.add(l);scheduleSave();if(l.level==="error")store.flushSync()}const FATAL_DEDUPE_MS=2e3;let lastFatalKey="";let lastFatalAt=0;function fatalKey(e,t){const n=t.trim();if(e&&n.startsWith(`${e}: `))return n;return e?`${e}: ${n}`:n}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 n=e instanceof Error?e:void 0;const o=t===false?"[UNCAUGHT]":"[FATAL]";const r=n?fatalKey(n.name,n.message):formatArg(e);const i=isDuplicateFatal(`${o} ${r}`);pushFatal({id:store.allocId(),method:"error",level:"error",args:[o,e],message:`${o} ${r}`,timestamp:Date.now(),stack:n?.stack,fatal:true},i)}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(n=>{const o=n.lineNumber!=null?`${n.file??"?"}:${n.lineNumber}:${n.column??0}`:n.file??"?";return` at ${n.methodName||"<anonymous>"} (${o})`}).join("\n")}function recordNativeException(e){const t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]";const n=fatalKey(e.name??void 0,e.originalMessage??e.message??"Unknown error");const o=isDuplicateFatal(`${t} ${n}`);const r=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 i=`${t} ${n}${r}`;pushFatal({id:store.allocId(),method:"error",level:"error",args:[t,n,...r?[r.trim()]:[]],message:i,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 installFatalErrorCapture(){if(fatalInstalled)return;const e=installNativeExceptionCapture();const t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!=="function"){fatalInstalled=e;return}fatalInstalled=true;const n=typeof t.getGlobalHandler==="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((o,r)=>{try{if(!captureDisabledByUser)recordFatalError(o,r)}catch{}if(typeof n==="function")n(o,r)})}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 n(...o){record(e,o,n);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(n=>({...n,args:(0,_sanitize.sanitizeArgs)(n.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 n=JSON.parse(t);if(Array.isArray(n)&&n.length){store.update(o=>[...n,...o].filter(r=>!(0,_sharedUi.isBuoyLog)(r.args??[r.message])));store.bumpIdAbove(Math.max(...n.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)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const N=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/;const y=/consoleLogStore/;function l(n){return n.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function $(n){if(n.func&&N.test(l(n.func))){return true}return Boolean(n.file&&y.test(n.file))}function w(n){const e=[];for(const o of n.split("\n")){const u=o.trim();if(!u||u==="Error")continue;let t=u.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(t){e.push({func:t[1],file:t[2],line:Number(t[3])});continue}t=u.match(/^at\s+(.+?):(\d+):(\d+)$/);if(t){e.push({file:t[1],line:Number(t[2])});continue}t=u.match(/^(.*?)@(.+?):(\d+):(\d+)$/);if(t){e.push({func:t[1]||void 0,file:t[2],line:Number(t[3])});continue}}return e}function S(n){if(!n)return void 0;const e=n.split(/\?|\/\/&/)[0];return e.split("/").pop()||e}function b(n){if(!n)return void 0;const e=l(n);if(!e||e==="<anonymous>"||e==="anonymous")return void 0;return e}function _(n){if(!n)return void 0;for(const e of n.split("\n")){const o=e.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(o)return o[1]}return void 0}export function consoleWrapperDepth(n,e){const o=new Set;let u=0;while(typeof n==="function"&&n!==e&&!o.has(n)){o.add(n);try{n=Reflect.get(n,"__sentry_original__")}catch{return 0}u+=1}return n===e?u:0}export function parseOrigin(n,e,o=0,u=[]){const t=_(e);let c;if(n){const p=w(n);let s=0;for(const r of u){const d=p[s];if(r&&d?.func&&l(d.func)===r)s++}const h=p.slice(s).filter(r=>!$(r));c=h[o]}const i=b(c?.func);const f=S(c?.file);const a=c?.line;const m=f&&a!=null?`${f}:${a}`:void 0;if(!t&&!i&&!m)return void 0;return{component:t,functionName:i,callSite:m,file:f,line:a}}export function sourceKey(n,e){if(e==="off"||!n)return e==="off"?null:"\u2014unknown\u2014";if(e==="component"){return n.component??n.functionName??n.callSite??"\u2014unknown\u2014"}if(e==="function"){return n.functionName??n.callSite??n.component??"\u2014anonymous\u2014"}return n.callSite??n.functionName??"\u2014unknown\u2014"}export function sourceLabel(n,e){if(!n)return"(unknown)";if(e==="component"){if(n.component)return n.component;if(n.functionName)return`\u0192 ${n.functionName}`;return n.callSite??"(unknown)"}if(e==="function"){if(n.functionName)return n.functionName;return n.callSite??"(anonymous)"}if(e==="callsite"){if(n.functionName&&n.callSite)return`${n.functionName} \xB7 ${n.callSite}`;return n.callSite??(n.functionName?`\u0192 ${n.functionName}`:"(unknown)")}return""}function k(n){let e=0;for(let o=0;o<n.length;o++)e=e*31+n.charCodeAt(o)|0;return Math.abs(e)}export function colorForKey(n){const e=k(n)%360;return`hsl(${e}, 70%, 66%)`}export function bracketGlyph(n){switch(n){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";import{isBuoyLog as
|
|
2
|
-
\u2026+${r} more frames`:"")}function
|
|
1
|
+
"use strict";import{isBuoyLog as h,getAccountAccess as P,hasAccountAccess as l}from"@buoy-gg/shared-ui";import*as H from"react";import{createToolStore as B,persistentStorage as p}from"@buoy-gg/shared-ui";import{sanitizeArgs as G}from"./sanitize";import{consoleWrapperDepth as K,parseOrigin as j}from"../devtools/origin";const T=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"];const J=new Set(["error","warn","trace","assert"]);const V={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 W=1e3;const s=B({id:"console",max:W,order:"append",coalesce:"frame"});let d=false;let y=false;let g=false;const S={};function N(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 z(e){return e.map(N).join(" ")}function Y(e){if(!e)return void 0;return e.split("\n").slice(3).join("\n")||void 0}function X(){try{const e=Reflect.get(H,"captureOwnerStack");return typeof e==="function"?e()??void 0:void 0}catch{return void 0}}const q=8;function D(e){const t=e.split("\n").map(o=>o.trim()).filter(Boolean).map(o=>o.replace(/\s*\((?:https?:|\/).*$/,""));const n=t.slice(0,q);const r=t.length-n.length;return n.map(o=>` ${o}`).join("\n")+(r>0?`
|
|
2
|
+
\u2026+${r} more frames`:"")}function Q(e){if(!(e instanceof Error))return null;const t=e;return t.isComponentError||typeof t.componentStack==="string"?t:null}function _(e,t,n){if(h(t))return;const r=new Error().stack;const o=[_.name,n?.name??""];const c=j(r,X(),K(console[e],n),o);const a=e==="error"?Q(t[0]):null;if(a){const C=b(a.name,a.message);const M=a.componentStack?`
|
|
3
3
|
|
|
4
4
|
This error is located at:
|
|
5
|
-
${
|
|
5
|
+
${D(a.componentStack)}`:"";w({id:s.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",a],message:`[RENDER ERROR] ${C}${M}`,timestamp:Date.now(),stack:a.stack,origin:c},$(`[RENDER ERROR] ${C}`));return}const R={id:s.allocId(),method:e,level:V[e],args:t,message:z(t),timestamp:Date.now(),stack:J.has(e)?Y(r):void 0,origin:c};s.add(R);L();if(R.level==="error")s.flushSync()}const Z=2e3;let x="";let O=0;function b(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===x&&t-O<Z)return true;x=e;O=t;return false}function w(e,t=false){s.add(e);L();if(!t)s.flushSync(true)}function ee(e,t){const n=e instanceof Error?e:void 0;const r=t===false?"[UNCAUGHT]":"[FATAL]";const o=n?b(n.name,n.message):N(e);const c=$(`${r} ${o}`);w({id:s.allocId(),method:"error",level:"error",args:[r,e],message:`${r} ${o}`,timestamp:Date.now(),stack:n?.stack,fatal:true},c)}function te(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 ne(e){const t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]";const n=b(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
|
+
${D(e.componentStack)}`:"";const c=`${t} ${n}${o}`;w({id:s.allocId(),method:"error",level:"error",args:[t,n,...o?[o.trim()]:[]],message:c,timestamp:Date.now(),stack:te(e),fatal:true},r)}function re(){const e=globalThis.RN$registerExceptionListener;if(typeof e!=="function")return false;e(t=>{try{if(!g)ne(t)}catch{}});return true}export function installFatalErrorCapture(){if(y)return;const e=re();const t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!=="function"){y=e;return}y=true;const n=typeof t.getGlobalHandler==="function"?t.getGlobalHandler():void 0;t.setGlobalHandler((r,o)=>{try{if(!g)ee(r,o)}catch{}if(typeof n==="function")n(r,o)})}export function installConsoleCapture(){if(P().status==="locked")return;g=false;installFatalErrorCapture();if(d)return;d=true;for(const e of T){const t=console[e];if(typeof t!=="function")continue;S[e]=t;console[e]=function n(...r){_(e,r,n);t.apply(console,r)}}}export function uninstallConsoleCapture(){g=true;if(!d)return;d=false;for(const e of T){const t=S[e];if(t)console[e]=t;delete S[e]}}export function subscribe(e){return s.subscribe(e)}export function getEntries(){return s.getSnapshot()}export function clearEntries(){void A();s.clear()}export function replaceEntries(e){s.set(e.filter(t=>!h(t.args??[t.message])))}export function onClear(e){return s.onClear(e)}const F="@react_buoy_console_preserve";const v="@react_buoy_console_buffer";const oe=600;let i=false;let m=false;let f=0;let u=Promise.resolve();const k=new Set;let E=null;function I(){for(const e of k)e()}function L(){if(!i||!l())return;if(E)clearTimeout(E);E=setTimeout(U,oe)}async function U(){E=null;if(!i||!l())return;try{const e=s.getSnapshot().map(n=>({...n,args:G(n.args)}));const t=f;u=u.then(async()=>{if(t!==f||!i||!l())return;await p.setItem(v,JSON.stringify(e))}).catch(()=>{});await u}catch{}}async function A(){f++;m=false;try{u=u.then(()=>p.removeItem(v)).catch(()=>{});await u}catch{}}export async function initConsolePersistence(){if(m||!l())return;m=true;const e=f;try{i=await p.getItem(F)==="true"}catch{i=false}if(e!==f||!l()){m=false;return}I();if(!i){await A();return}try{const t=await p.getItem(v);if(e!==f||!l()){m=false;return}if(t){const n=JSON.parse(t);if(Array.isArray(n)&&n.length){s.update(r=>[...n,...r].filter(o=>!h(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;I();p.setItem(F,String(e)).catch(()=>{});if(e)U();else A()}export function subscribePreserveLog(e){k.add(e);return()=>{k.delete(e)}}
|
|
@@ -22,7 +22,9 @@ export interface LogOrigin {
|
|
|
22
22
|
/** Count Sentry forwarding wrappers outside our console capture function. */
|
|
23
23
|
export declare function consoleWrapperDepth(current: unknown, capture: unknown): number;
|
|
24
24
|
/** Derive the origin of a log from its captured JS stack + React owner stack. */
|
|
25
|
-
export declare function parseOrigin(stack?: string, ownerStack?: string, wrapperFrames?: number
|
|
25
|
+
export declare function parseOrigin(stack?: string, ownerStack?: string, wrapperFrames?: number,
|
|
26
|
+
/** Runtime names of the capture's own functions, which minifiers rename. */
|
|
27
|
+
ownFrames?: readonly string[]): LogOrigin | undefined;
|
|
26
28
|
/**
|
|
27
29
|
* Stable key used to group consecutive rows (null = ungrouped).
|
|
28
30
|
*
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use client";var Fe=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
`)){let n=r.trim();if(!n||n==="Error")continue;let o=n.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(o){t.push({func:o[1],file:o[2],line:Number(o[3])});continue}if(o=n.match(/^at\s+(.+?):(\d+):(\d+)$/),o){t.push({file:o[1],line:Number(o[2])});continue}if(o=n.match(/^(.*?)@(.+?):(\d+):(\d+)$/),o){t.push({func:o[1]||void 0,file:o[2],line:Number(o[3])});continue}}return t}function
|
|
3
|
-
`)){let r=t.trim().match(/^at\s+([A-Za-z_$][\w$]*)/);if(r)return r[1]}}function lr(e,t){let r=new Set,n=0;for(;typeof e=="function"&&e!==t&&!r.has(e);){r.add(e);try{e=Reflect.get(e,"__sentry_original__")}catch{return 0}n+=1}return e===t?n:0}function
|
|
1
|
+
"use client";var Fe=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Vt=Object.prototype.hasOwnProperty;var _t=(e,t)=>{for(var r in t)Fe(e,r,{get:t[r],enumerable:true})},Ge=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gt(t))!Vt.call(e,o)&&o!==r&&Fe(e,o,{get:()=>t[o],enumerable:!(n=Ft(t,o))||n.enumerable});return e},Kt=(e,t,r)=>(Ge(e,t,"default"),r&&Ge(r,t,"default"));var Ve=(()=>{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 _e,CONSOLE_ICON_COLOR as Ke}from"@buoy-gg/shared-ui/web";import{JsModal as Ut}from"@buoy-gg/shared-ui/web";import{useCallback as ge,useState as P}from"react";import{useMemo as Yt,useSyncExternalStore as Jt}from"react";import{isBuoyLog as pe,getAccountAccess as qt,hasAccountAccess as _}from"@buoy-gg/shared-ui/web";import*as Qt from"react";import{createToolStore as Xt,persistentStorage as X}from"@buoy-gg/shared-ui/web";function Z(e,t=2048){return e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`}function me(e,t,r){if(e===null)return null;if(typeof e=="string")return Z(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:Z(e.message),stack:e.stack?Z(e.stack,4*1024):e.stack};if(t>=6)return Array.isArray(e)?"[Array]":"{\u2026}";let n=e;if(r.has(n))return"[Circular]";r.add(n);try{if(Array.isArray(e)){let i=e.slice(0,100).map(l=>me(l,t+1,r));return e.length>100&&i.push(`\u2026 ${e.length-100} more`),i}let o={};for(let i of Object.keys(n).slice(0,100))try{o[i]=me(n[i],t+1,r)}catch{o[i]="[Unserializable]"}return o}finally{r.delete(n)}}function Ue(e){let t=new WeakSet;return e.map(r=>me(r,0,t))}var Zt=/^(buoyConsoleProxy|record|cleanStack|captureOwnerStack|formatArgs|formatArg)$/,er=/consoleLogStore/;function he(e){return e.replace(/\s+\[as [^\]]+\]$/,"").replace(/^(?:async\s+)?(?:new\s+)?(?:Object|console)\./,"").trim()}function tr(e){return e.func&&Zt.test(he(e.func))?true:!!(e.file&&er.test(e.file))}function rr(e){let t=[];for(let r of e.split(`
|
|
2
|
+
`)){let n=r.trim();if(!n||n==="Error")continue;let o=n.match(/^at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)$/);if(o){t.push({func:o[1],file:o[2],line:Number(o[3])});continue}if(o=n.match(/^at\s+(.+?):(\d+):(\d+)$/),o){t.push({file:o[1],line:Number(o[2])});continue}if(o=n.match(/^(.*?)@(.+?):(\d+):(\d+)$/),o){t.push({func:o[1]||void 0,file:o[2],line:Number(o[3])});continue}}return t}function or(e){if(!e)return;let t=e.split(/\?|\/\/&/)[0];return t.split("/").pop()||t}function nr(e){if(!e)return;let t=he(e);if(!(!t||t==="<anonymous>"||t==="anonymous"))return t}function ir(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 lr(e,t){let r=new Set,n=0;for(;typeof e=="function"&&e!==t&&!r.has(e);){r.add(e);try{e=Reflect.get(e,"__sentry_original__")}catch{return 0}n+=1}return e===t?n:0}function ar(e,t,r=0,n=[]){let o=ir(t),i;if(e){let u=rr(e),g=0;for(let x of n){let p=u[g];x&&p?.func&&he(p.func)===x&&g++}i=u.slice(g).filter(x=>!tr(x))[r]}let l=nr(i?.func),s=or(i?.file),a=i?.line,c=s&&a!=null?`${s}:${a}`:void 0;if(!(!o&&!l&&!c))return{component:o,functionName:l,callSite:c,file:s,line:a}}function sr(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 cr(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 ur(e){let t=0;for(let r=0;r<e.length;r++)t=t*31+e.charCodeAt(r)|0;return Math.abs(t)}function Ye(e){return`hsl(${ur(e)%360}, 70%, 66%)`}function Je(e){switch(e){case"top":return"\u250C";case"bottom":return"\u2514";case"single":return"\u2500";default:return"\u2502"}}var qe=["log","info","warn","error","debug","trace","dir","table","assert","group","groupCollapsed","groupEnd"],dr=new Set(["error","warn","trace","assert"]),fr={error:"error",assert:"error",warn:"warning",debug:"verbose",log:"info",info:"info",trace:"info",dir:"info",table:"info",group:"info",groupCollapsed:"info",groupEnd:"info"},gr=1e3,k=Xt({id:"console",max:gr,order:"append",coalesce:"frame"}),ae=false,ye=false,se=false,be={};function Qe(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 pr(e){return e.map(Qe).join(" ")}function mr(e){if(e)return e.split(`
|
|
4
4
|
`).slice(3).join(`
|
|
5
|
-
`)||void 0}function
|
|
6
|
-
`).map(o=>o.trim()).filter(Boolean).map(o=>o.replace(/\s*\((?:https?:|\/).*$/,"")),r=t.slice(0,
|
|
5
|
+
`)||void 0}function hr(){try{let e=Reflect.get(Qt,"captureOwnerStack");return typeof e=="function"?e()??void 0:void 0}catch{return}}var yr=8;function Xe(e){let t=e.split(`
|
|
6
|
+
`).map(o=>o.trim()).filter(Boolean).map(o=>o.replace(/\s*\((?:https?:|\/).*$/,"")),r=t.slice(0,yr),n=t.length-r.length;return r.map(o=>` ${o}`).join(`
|
|
7
7
|
`)+(n>0?`
|
|
8
|
-
\u2026+${n} more frames`:"")}function
|
|
8
|
+
\u2026+${n} more frames`:"")}function br(e){if(!(e instanceof Error))return null;let t=e;return t.isComponentError||typeof t.componentStack=="string"?t:null}function Ze(e,t,r){if(pe(t))return;let n=new Error().stack,o=[Ze.name,r?.name??""],i=ar(n,hr(),lr(console[e],r),o),l=e==="error"?br(t[0]):null;if(l){let a=ve(l.name,l.message),c=l.componentStack?`
|
|
9
9
|
|
|
10
10
|
This error is located at:
|
|
11
|
-
${Xe(l.componentStack)}`:"";
|
|
12
|
-
`)}function kr(e){let t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]",r=
|
|
11
|
+
${Xe(l.componentStack)}`:"";xe({id:k.allocId(),method:"error",level:"error",args:["[RENDER ERROR]",l],message:`[RENDER ERROR] ${a}${c}`,timestamp:Date.now(),stack:l.stack,origin:i},we(`[RENDER ERROR] ${a}`));return}let s={id:k.allocId(),method:e,level:fr[e],args:t,message:pr(t),timestamp:Date.now(),stack:dr.has(e)?mr(n):void 0,origin:i};k.add(s),it(),s.level==="error"&&k.flushSync()}var vr=2e3,et="",tt=0;function ve(e,t){let r=t.trim();return e&&r.startsWith(`${e}: `)?r:e?`${e}: ${r}`:r}function we(e){let t=Date.now();return e===et&&t-tt<vr?true:(et=e,tt=t,false)}function xe(e,t=false){k.add(e),it(),t||k.flushSync(true)}function wr(e,t){let r=e instanceof Error?e:void 0,n=t===false?"[UNCAUGHT]":"[FATAL]",o=r?ve(r.name,r.message):Qe(e),i=we(`${n} ${o}`);xe({id:k.allocId(),method:"error",level:"error",args:[n,e],message:`${n} ${o}`,timestamp:Date.now(),stack:r?.stack,fatal:true},i)}function xr(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 n=r.lineNumber!=null?`${r.file??"?"}:${r.lineNumber}:${r.column??0}`:r.file??"?";return` at ${r.methodName||"<anonymous>"} (${n})`}).join(`
|
|
12
|
+
`)}function kr(e){let t=e.isFatal===false?"[UNCAUGHT]":"[FATAL]",r=ve(e.name??void 0,e.originalMessage??e.message??"Unknown error"),n=we(`${t} ${r}`),o=typeof e.componentStack=="string"&&e.componentStack.trim()?`
|
|
13
13
|
|
|
14
14
|
This error is located at:
|
|
15
|
-
${Xe(e.componentStack)}`:"",l=`${t} ${r}${o}`;we({id:x.allocId(),method:"error",level:"error",args:[t,r,...o?[o.trim()]:[]],message:l,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 tt(){if(he)return;let e=Cr(),t=globalThis.ErrorUtils;if(typeof t?.setGlobalHandler!="function"){he=e;return}he=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(Jt().status!=="locked"&&(se=false,tt(),!ae)){ae=true;for(let e of qe){let t=console[e];typeof t=="function"&&(ye[e]=t,console[e]=function r(...n){br(e,n,r),t.apply(console,n)})}}}function xe(){if(se=true,!!ae){ae=false;for(let e of qe){let t=ye[e];t&&(console[e]=t),delete ye[e]}}}function ue(e){return x.subscribe(e)}function K(){return x.getSnapshot()}function ee(){Se(),x.clear()}function Sr(e){x.set(e.filter(t=>!pe(t.args??[t.message])))}function Er(e){return x.onClear(e)}var rt="@react_buoy_console_preserve",ke="@react_buoy_console_buffer",Tr=600,M=false,te=false,U=0,Y=Promise.resolve(),Ce=new Set,de=null;function ot(){for(let e of Ce)e()}function nt(){!M||!_()||(de&&clearTimeout(de),de=setTimeout(lt,Tr))}async function lt(){if(de=null,!(!M||!_()))try{let e=x.getSnapshot().map(r=>({...r,args:Ke(r.args)})),t=U;Y=Y.then(async()=>{t!==U||!M||!_()||await X.setItem(ke,JSON.stringify(e))}).catch(()=>{}),await Y}catch{}}async function Se(){U++,te=false;try{Y=Y.then(()=>X.removeItem(ke)).catch(()=>{}),await Y}catch{}}async function it(){if(te||!_())return;te=true;let e=U;try{M=await X.getItem(rt)==="true"}catch{M=false}if(e!==U||!_()){te=false;return}if(ot(),!M){await Se();return}try{let t=await X.getItem(ke);if(e!==U||!_()){te=false;return}if(t){let r=JSON.parse(t);Array.isArray(r)&&r.length&&(x.update(n=>[...r,...n].filter(o=>!pe(o.args??[o.message]))),x.bumpIdAbove(Math.max(...r.map(n=>n.id))))}}catch{}}function Ee(){return M}function at(e){M!==e&&(M=e,ot(),X.setItem(rt,String(e)).catch(()=>{}),e?lt():Se())}function st(e){return Ce.add(e),()=>{Ce.delete(e)}}var Te={verbose:true,info:true,warning:true,error:true},$e={...Te,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 l=n.match($r);if(l){t.push({key:l[1].toLowerCase(),text:l[2],negative:o});continue}let a=n.match(Lr);if(a)try{t.push({regex:new RegExp(a[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 ct={verbose:"Verbose",info:"Info",warning:"Warnings",error:"Errors"},Le=["verbose","info","warning","error"];function ut(e,t){return Le.every(r=>e[r]===t[r])}function Br(e){if(ut(e,Te))return"All levels";if(ut(e,$e))return"Default levels";let t=Le.filter(r=>e[r]);return t.length===0?"Hide all":t.length===1?`${ct[t[0]]} only`:"Custom levels"}var Ae=5,Nr=5;function Mr(e,t){for(let r of e){let n=ar(r.entry.origin,t);r.sourceKey=n,r.originColor=n?Ye(n):void 0,r.originLabel=t==="off"?void 0:sr(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,l=!n&&!o?"single":n?o?"mid":"bottom":"top";e[t].bracketGlyph=Je(l)}}function Rr(e,t){let r=[],n=new Map;for(let l of e){let a=l.sourceKey??"\u2014",s=n.get(a);s||(s=[],n.set(a,s),r.push(a)),s.push(l)}let o=[];for(let l of r){let a=n.get(l);for(let c of a)c.depth=0;let s=a.length>Nr,i=t[l]??false;s&&(o.push({key:`cluster:${l}`,entry:a[0].entry,depth:0,repeatCount:1,isGroupHeader:false,sourceKey:l,originColor:a[0].originColor,originLabel:a[0].originLabel,clusterHeader:{key:l,count:a.length,expanded:i}}),!i)||a.forEach((c,u)=>{let b=a.length===1?"single":u===0?"top":u===a.length-1?"bottom":"mid";c.bracketGlyph=Je(b),o.push(c)})}return o}function jr(e){let t=new Map,r=new Map;e.forEach((s,i)=>{let c=s.sourceKey;c!=null&&(t.has(c)||t.set(c,i),r.set(c,i))});let n=[...t.keys()].sort((s,i)=>t.get(s)-t.get(i)),o=new Map,l=[];for(let s of n){let i=l.findIndex(c=>c<t.get(s));i===-1&&(i=l.length<Ae?l.length:Ae-1,i>=l.length&&l.push(0)),o.set(s,i),l[i]=Math.max(l[i]??0,r.get(s))}let a=Math.max(1,Math.min(l.length,Ae));e.forEach((s,i)=>{let c=Array.from({length:a},()=>({glyph:" "}));for(let u of n){let b=o.get(u);b>=a||i>=t.get(u)&&i<=r.get(u)&&(c[b]={glyph:s.sourceKey===u?"\u25CF":"\u2502",color:Ye(u)})}s.lanes=c})}var Pr=new Set(["group","groupCollapsed"]);function zr(e,t){let{levelsMask:r,query:n,showTimestamps:o,collapsedOverrides:l}=t,a=Ar(n.trim()),s=[],i={verbose:0,info:0,warning:0,error:0},c=0,u=[],b=()=>u.some(h=>h.collapsed);for(let h of e){if(i[h.level]++,h.method==="groupEnd"){u.pop();continue}let D=Pr.has(h.method),V=b();if(!Or(h,r,a))c++;else if(!V){let L=s[s.length-1];!o&&!D&&L&&!L.isGroupHeader&&L.depth===u.length&&L.entry.method===h.method&&L.entry.message===h.message?L.repeatCount++:s.push({key:String(h.id),entry:h,depth:u.length,repeatCount:1,isGroupHeader:D,groupId:D?h.id:void 0,groupCollapsed:void 0})}if(D){let L=h.method==="groupCollapsed",W=l[h.id]??L,R=s[s.length-1];R&&R.groupId===h.id&&(R.groupCollapsed=W),u.push({id:h.id,collapsed:W||V})}}Mr(s,t.groupDimension);let $=s;return t.groupDimension!=="off"&&(t.layoutMode==="cluster"?$=Rr(s,t.clusterExpanded):t.layoutMode==="swimlane"?jr(s):Hr(s)),{rows:$,hiddenCount:c,levelCounts:i,totalCount:e.length}}function dt(e){let t=Yt(ue,K,K);return Ut(()=>zr(t,e),[t,e.levelsMask,e.query,e.showTimestamps,e.collapsedOverrides,e.groupDimension,e.layoutMode,e.clusterExpanded])}function ft(){let[e,t]=j(""),[r,n]=j(false),[o,l]=j({...$e}),[a,s]=j(false),[i,c]=j({}),[u,b]=j("chrono"),[$,h]=j("list"),[D,V]=j({}),{rows:L,hiddenCount:W}=dt({levelsMask:o,query:e,showTimestamps:a,collapsedOverrides:i,groupDimension:"function",layoutMode:u,clusterExpanded:D}),R=ge((le,ie)=>{c(zt=>({...zt,[le]:!ie}))},[]),ne=ge(le=>{V(ie=>({...ie,[le]:!(ie[le]??false)}))},[]),p=ge(()=>{ee(),c({})},[]),C=Br(o);return{query:e,setQuery:t,searchActive:r,setSearchActive:n,levelsMask:o,setLevelsMask:l,showTimestamps:a,setShowTimestamps:s,layoutMode:u,setLayoutMode:b,view:$,setView:h,rows:L,hiddenCount:W,onToggleGroup:R,onToggleCluster:ne,clear:p,levelSummary:C,isLevelCustom:C!=="All levels"&&C!=="Default levels"}}var gt={};Vt(gt,{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:()=>Ie,I18nManager:()=>Zr,Image:()=>go,ImageBackground:()=>po,InteractionManager:()=>to,Keyboard:()=>eo,KeyboardAvoidingView:()=>mo,LayoutAnimation:()=>ro,Linking:()=>oo,LogBox:()=>To,Modal:()=>Go,NativeEventEmitter:()=>no,NativeModules:()=>Gr,PanResponder:()=>lo,Picker:()=>ho,PixelRatio:()=>io,Platform:()=>ao,Pressable:()=>Wo,ProgressBar:()=>yo,RefreshControl:()=>bo,SafeAreaView:()=>vo,ScrollView:()=>yt,SectionList:()=>wo,Share:()=>so,StatusBar:()=>xo,StyleSheet:()=>S,Switch:()=>Vo,Text:()=>d,TextInput:()=>Po,Touchable:()=>ko,TouchableHighlight:()=>zo,TouchableNativeFeedback:()=>Co,TouchableOpacity:()=>T,TouchableWithoutFeedback:()=>Fo,UIManager:()=>co,Vibration:()=>uo,View:()=>m,VirtualizedList:()=>So,YellowBox:()=>Eo,findNodeHandle:()=>Uo,unstable_createElement:()=>Wr,useColorScheme:()=>Lo,useLocaleContext:()=>Ao,useWindowDimensions:()=>Io});_t(gt,Fr);import*as Fr from"react-native-web";import{unstable_createElement as Wr,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 lo,PixelRatio as io,Platform as ao,Share as so,StyleSheet as S,UIManager as co,Vibration as uo,CheckBox as fo,FlatList as Ie,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 Eo,LogBox as To,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 De,forwardRef as pt,useCallback as Do,useRef as Oo}from"react";import{useEffect as Bo,useState as No}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 Ro}from"react/jsx-runtime";var re=Symbol.for("@buoy-gg/portal-host"),mt=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 ht(){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,b=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==b&&b.appendChild(t)},n=new Map,o=u=>{(!t.contains(u.target)||!mt(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})},l=u=>{n.delete(u.code||u.key)},a=()=>n.clear(),s=()=>{let u=[...n.values()];n.clear();for(let b of u)document.dispatchEvent(new KeyboardEvent("keyup",{...b,bubbles:true}))},i=u=>{mt(u.target)&&u.stopPropagation()},c=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",l,true),window.addEventListener("blur",a),t.addEventListener("focusin",s),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),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",l,true),window.removeEventListener("blur",a),t.remove(),delete e[re]}},t}function jo({children:e}){let[t,r]=No(null);return Bo(()=>{let n=ht(),o=document[re];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Mo(Ro("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function A(e){let t=pt((n,o)=>{let{accessibilityState:l,accessibilityValue:a,...s}=n;for(let i of["busy","checked","disabled","expanded","selected"])l?.[i]!==void 0&&s[`aria-${i}`]===void 0&&(s[`aria-${i}`]=l[i]);for(let[i,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[i]!==void 0&&s[`aria-${c}`]===void 0&&(s[`aria-${c}`]=a[i]);return De(e,{...s,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m=A(E.View),d=A(E.Text),Po=A(E.TextInput),T=A(E.TouchableOpacity),zo=A(E.TouchableHighlight),Fo=A(E.TouchableWithoutFeedback),Wo=A(E.Pressable),yt=A(E.ScrollView),bt=pt((e,t)=>{let r=Oo(null),n=Do(o=>{if(o){let l=o;for(;l.parentElement&&l.parentElement!==document.body;)l=l.parentElement;l.parentElement===document.body&&(r.current=l,Object.assign(l.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ht().appendChild(l))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return De(jo,null,De(E.Modal,{...e,ref:n}))});bt.displayName="Modal";var Go=A(bt),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 l=document.createElement("h2");if(l.textContent=e,l.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(l),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],i=()=>{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=()=>{i(),c.onPress?.()},a.appendChild(u)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(i(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{ModalHeader as P,TabSelector as Jo,night as B,Search as qo,Filter as Qo,Trash2 as Xo}from"@buoy-gg/shared-ui/web";import{jsx as I,jsxs as Oe}from"react/jsx-runtime";var Zo=[{key:"chrono",label:"Timeline"},{key:"cluster",label:"Grouped"}];function vt({c:e,onBack:t}){if(e.view==="filters")return Oe(P,{children:[I(P.Navigation,{onBack:()=>e.setView("list")}),I(P.Content,{title:"Filters"})]});let r=e.rows.length>0;return Oe(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(Jo,{testIDPrefix:"buoy-console-tab",tabs:Zo,activeTab:e.layoutMode,onTabChange:n=>e.setLayoutMode(n)})}),Oe(P.Actions,{children:[I(T,{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?B.color.accent:B.color.textSecondary})}),I(T,{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?B.color.accent:B.color.textSecondary})}),I(T,{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?B.color.textSecondary:B.color.textTertiary})})]})]})}var J=S.create({actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:B.color.buttonSurface,borderWidth:1,borderColor:B.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:B.color.accentSoft,borderColor:B.color.accentBorderStrong},actionBtnDisabled:{opacity:.55}});import{useCallback as en,useRef as wt,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 z,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"},g=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"},xt={verbose:{text:g.tokenSubtle},info:{text:g.onSurface},warning:{background:g.surfaceYellow,text:g.onSurfaceYellow,icon:"warning"},error:{background:g.surfaceError,text:g.onErrorContainer,icon:"error"}};var kt=["black","red","green","yellow","blue","magenta","cyan","gray"],Ct=["darkgray","lightred","lightgreen","lightyellow","lightblue","lightmagenta","lightcyan","white"];function St(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 l=n.slice(0,o).trim().toLowerCase(),a=n.slice(o+1).trim();if(!a)continue;let s=a.match(/var\(--console-color-([a-z]+)\)/);switch(s&&(a=sn[s[1]]??a),l){case"color":t.color=a,r=true;break;case"background-color":case"background":t.backgroundColor=a,r=true;break;case"font-weight":t.fontWeight=a==="lighter"?"300":a,r=true;break;case"font-style":a==="italic"&&(t.fontStyle="italic",r=true);break;case"font-size":{let i=parseFloat(a);Number.isNaN(i)||(t.fontSize=i,r=true);break}case"text-decoration":case"text-decoration-line":a.includes("underline")&&a.includes("line-through")?t.textDecorationLine="underline line-through":a.includes("underline")?t.textDecorationLine="underline":a.includes("line-through")&&(t.textDecorationLine="line-through"),r=true;break;default:break}}return r?t:void 0}function un(e,t){let r=o=>{let l=t.get("text-decoration")??"";l.includes(o)||t.set("text-decoration",`${l} ${o}`)},n=o=>{let l=t.get("text-decoration")?.replace(` ${o}`,"");l?t.set("text-decoration",l):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 l=e.shift()??0,a=e.shift()??0,s=e.shift()??0;t.set(o===38?"color":"background-color",`rgb(${l},${a},${s})`)}break;case 39:case 49:t.delete(o===39?"color":"background-color");break;default:{let l=kt[o-30]??Ct[o-90];if(l!==void 0)t.set("color",`var(--console-color-${l})`);else{let a=kt[o-40]??Ct[o-100];a!==void 0&&t.set("background-color",`var(--console-color-${a})`)}break}}}}function dn(e,t){let r=e,n=[],o=new Map,l,a=i=>{if(!i)return;let c=n[n.length-1];if(c&&c.type==="string"&&fn(c.style,l)){c.value+=i;return}n.push({type:"string",value:i,style:l})},s=0;for(let i=Be.exec(r);i!==null;i=Be.exec(r)){a(i.input.substring(0,i.index));let c,u=i[1];switch(u){case"%":a("%"),c="";break;case"s":s<t.length&&(c=St(t[s++]));break;case"c":s<t.length&&(l=Et(St(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 b=t[s++],$=typeof b!="number"?NaN:b;u!=="f"&&($=Math.floor($)),c=$}break}case void 0:{let b=(i[2]||"0").split(";").map(h=>h?parseInt(h,10):0);un(b,o);let $=[...o.entries()].map(([h,D])=>`${h}:${D.trimStart()}`).join(";");l=Et($),c="";break}}c===void 0&&(a(i[0]),c=""),r=c+i.input.substring(i.index+i[0].length)}return a(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 Tt=5,$t=6;function Ne(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";if(e instanceof Error)return"error";let t=typeof e;return t==="number"?"number":t==="bigint"?"bigint":t==="boolean"?"boolean":t==="string"?"string":t==="function"?"function":t==="symbol"?"symbol":"object"}var mn={number:g.valueNumber,bigint:g.valueBigint,boolean:g.valueNumber,string:g.valueString,null:g.valueNullish,undefined:g.valueNullish,symbol:g.valueString,function:g.valueNode};function Lt(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 Me(e){switch(Ne(e)){case"string":return`'${e}'`;case"function":return`\u0192 ${e.name||""}`.trimEnd();case"symbol":return e.toString();case"bigint":return`${String(e)}n`;case"array":return`Array(${e.length})`;case"error":return e.name;case"object":{let t=Lt(e);return t?`${t} {\u2026}`:"{\u2026}"}default:return String(e)}}function hn(e){if(Array.isArray(e)){let l=e.slice(0,$t).map(s=>Me(s)).join(", "),a=e.length>$t?", \u2026":"";return`(${e.length}) [${l}${a}]`}let t=Object.entries(e),r=t.slice(0,Tt).map(([l,a])=>`${l}: ${Me(a)}`).join(", "),n=t.length>Tt?", \u2026":"",o=Lt(e);return`${o?`${o} `:""}{${r}${n}}`}function yn(e){let t=Ne(e);return t==="array"?e.length>0:t==="object"?Object.keys(e).length>0:t==="error"}var At=({open:e})=>O(d,{style:[v.triangle,e&&v.triangleOpen],children:"\u25B6"});function He({value:e,depth:t=0,testID:r}){let[n,o]=pn(false),l=Ne(e);if(l==="error"){let i=e,c=`${i.name}: ${i.message}`.split(`
|
|
16
|
-
`)[0],u=
|
|
17
|
-
`).filter(p=>p.trim()).map((p,C)=>y(d,{style:f.stackFrame,children:p.trim()},C))}):null]}),D=[f.wrapper,l.background?{backgroundColor:l.background}:f.dividerTop],V=Array.from({length:e.depth},(p,C)=>y(m,{style:f.nestingMarker},C)),L=e.lanes?y(m,{style:f.laneGutter,children:e.lanes.map((p,C)=>y(d,{style:[f.laneCell,p.color?{color:p.color}:null],children:p.glyph},C))}):e.bracketGlyph?y(d,{style:[f.originGutter,{color:e.originColor}],children:e.bracketGlyph}):null,W=Q(m,{style:f.rowWrapper,children:[L,V,h]}),R=`buoy-console-row-${String(o.args[0])}`,ne=[e.originLabel,u.find(p=>p.type==="string")?.value].filter(Boolean).join(" \u2014 ").slice(0,80);if(e.isGroupHeader&&e.groupId!==void 0){let p=e.groupId;return y(T,{style:D,activeOpacity:.7,onPress:()=>r(p,!!e.groupCollapsed),testID:R,accessibilityLabel:ne||"Console group",children:W})}return y(T,{style:D,activeOpacity:.7,onPress:()=>c(p=>!p),testID:R,accessibilityLabel:ne||"Console message",children:W})},(e,t)=>e.row.key===t.row.key&&e.row.lanes===t.row.lanes&&e.row.repeatCount===t.row.repeatCount&&e.row.groupCollapsed===t.row.groupCollapsed&&e.row.depth===t.row.depth&&e.row.bracketGlyph===t.row.bracketGlyph&&e.row.originLabel===t.row.originLabel&&e.row.clusterHeader?.count===t.row.clusterHeader?.count&&e.row.clusterHeader?.expanded===t.row.clusterHeader?.expanded&&e.showTimestamps===t.showTimestamps&&e.onToggleGroup===t.onToggleGroup&&e.onToggleCluster===t.onToggleCluster),f=S.create({wrapper:{paddingVertical:2,paddingRight:8,minHeight:18},dividerTop:{borderTopWidth:S.hairlineWidth,borderTopColor:g.divider},rowWrapper:{flexDirection:"row",alignItems:"flex-start"},originGutter:{width:11,fontFamily: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:S.hairlineWidth,borderRightColor:g.divider,marginLeft:2},messageColumn:{flex:1,flexDirection:"column",paddingLeft:6},messageLine:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start"},contentWrap:{flexDirection:"row",flexWrap:"wrap",alignItems:"flex-start",flexShrink:1},contentWrapClamped:{flexWrap:"nowrap",overflow:"hidden",maxHeight:16},text:{fontFamily:z,fontSize:12,lineHeight:16},groupTitle:{fontWeight:"bold"},clusterTitle:{fontWeight:"600"},clusterCount:{color:g.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:g.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:g.tokenSubtle,fontFamily:z,fontSize:11,lineHeight:15}});import{jsx as w,jsxs as Re}from"react/jsx-runtime";function Dt({c:e}){return e.view==="filters"?w(Cn,{c:e}):w(kn,{c:e})}function kn({c:e}){let t=wt(null),r=wt(true),n=en(({item:o})=>w(It,{row:o,showTimestamps:e.showTimestamps,onToggleGroup:e.onToggleGroup,onToggleCluster:e.onToggleCluster}),[e.showTimestamps,e.onToggleGroup,e.onToggleCluster]);return w(Ie,{testID:"buoy-console-list",ref:t,data:e.rows,keyExtractor:o=>o.key,renderItem:n,style:k.list,...on,onContentSizeChange:()=>{r.current&&t.current?.scrollToEnd({animated:false})},onScroll:o=>{let{contentOffset:l,contentSize:a,layoutMeasurement:s}=o.nativeEvent,i=a.height-(l.y+s.height);r.current=i<40},scrollEventThrottle:100})}function je({testID:e,on:t,label:r,subtext:n,onPress:o}){return Re(T,{testID:e,style:k.row,onPress:o,activeOpacity:.7,children:[w(m,{style:[k.checkbox,t&&k.checkboxOn],children:t?w(rn,{size:12,color:H.color.onAccent,strokeWidth:3}):null}),Re(m,{style:k.rowTextCol,children:[w(d,{style:k.rowLabel,children:r}),n?w(d,{style:k.rowSubtext,children:n}):null]})]})}function Ot({text:e}){return w(d,{style:k.sectionLabel,children:e})}function Cn({c:e}){let t=tn(st,Ee,Ee),r=n=>e.setLevelsMask({...e.levelsMask,[n]:!e.levelsMask[n]});return Re(yt,{testID:"buoy-console-filters",style:k.subView,contentContainerStyle:k.subViewContent,children:[w(Ot,{text:"Log levels"}),w(T,{testID:"buoy-console-levels-default",style:k.presetRow,onPress:()=>e.setLevelsMask({...$e}),children:w(d,{style:k.presetText,children:"Default (hide verbose)"})}),w(T,{testID:"buoy-console-levels-all",style:k.presetRow,onPress:()=>e.setLevelsMask({...Te}),children:w(d,{style:k.presetText,children:"All levels"})}),Le.map(n=>w(je,{testID:`buoy-console-level-${n}`,on:e.levelsMask[n],label:ct[n],onPress:()=>r(n)},n)),w(m,{style:k.divider}),w(Ot,{text:"Settings"}),w(je,{testID:"buoy-console-timestamps",on:e.showTimestamps,label:"Show timestamps",onPress:()=>e.setShowTimestamps(n=>!n)}),w(je,{testID:"buoy-console-preserve",on:t,label:"Preserve log",subtext:"Do not clear log on reload",onPress:()=>at(!t)})]})}var k=S.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:S.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 Pe}from"react/jsx-runtime";function Bt({visible:e,onClose:t,onBack:r,onMinimize:n,persistenceKey:o="@react_buoy_console_modal"}){let l=ft();return Pe(Kt,{visible:e,onClose:t,onMinimize:n,persistenceKey:o,header:{showToggleButton:true,customContent:Pe(vt,{c:l,onBack:r})},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Pe(Dt,{c:l})})}import{createToolFactory as Sn,defineToolPreset as En}from"@buoy-gg/shared-ui/web";import{jsx as Tn}from"react/jsx-runtime";var Nt=globalThis,$n=typeof Nt.ErrorUtils?.setGlobalHandler=="function"||typeof Nt.RN$registerExceptionListener=="function";$n&&typeof Ge<"u"&&Ge&&ce();var Mt=En({id:"console",name:"CONSOLE",description:"Captured console.* output",slot:"both",color:_e,icon:({size:e})=>Tn(Ve,{size:e}),component:Bt}),Ln=Sn(Mt);import{useEffect as An}from"react";import{getAccountAccess as In,subscribeAccountAccess as Dn}from"@buoy-gg/shared-ui/web";var Ht=0;function On(){return An(()=>{++Ht;let e=true,t=()=>{if(!e)return;let n=In();if(n.status==="locked"){xe(),ee();return}ce(),n.status==="admitted"&&it()},r=Dn(t);return t(),()=>{e=false,r(),--Ht===0&&xe()}},[]),null}import{macOSColors as Bn,windowDragProps as Nn}from"@buoy-gg/shared-ui/web";import{jsx as ze,jsxs as Mn}from"react/jsx-runtime";function Hn(){let e=ft();return Mn(m,{style:Rt.container,children:[ze(m,{style:Rt.headerBar,...Nn,children:ze(vt,{c:e})}),ze(Dt,{c:e})]})}var Rt=S.create({container:{flex:1,backgroundColor:"transparent"},headerBar:{paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:S.hairlineWidth,borderBottomColor:Bn.border.default}});import{useSyncExternalStore as Rn,useEffect as jn}from"react";function jt(){return jn(()=>{ce()},[]),{logs:Rn(ue,K,K)}}import{night as F,ToolEmptyState as Pn,monoFont as zn}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as fe}from"react/jsx-runtime";var Pt={verbose:"#9b9b9b",info:F.color.text,warning:"#e2c08d",error:"#f48771"};function Fn(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 Wn(){let{logs:e}=jt(),t=({item:r})=>fe(m,{style:N.row,children:[G(d,{style:N.time,children:Fn(r.timestamp)}),G(d,{style:[N.level,{color:Pt[r.level]}],children:r.level.toUpperCase()}),G(d,{style:[N.message,{color:Pt[r.level]}],numberOfLines:3,children:r.message})]});return fe(m,{style:N.container,children:[fe(m,{style:N.header,children:[fe(d,{style:N.headerTitle,children:["Console (",e.length,")"]}),G(T,{onPress:()=>ee(),style:N.clearButton,children:G(d,{style:N.clearText,children:"Clear"})})]}),G(Ie,{data:e,keyExtractor:r=>String(r.id),renderItem:t,ListEmptyComponent:G(Pn,{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?N.emptyContainer:void 0})]})}var N=S.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:S.hairlineWidth,borderBottomColor:F.color.border},headerTitle:{color:F.color.text,fontSize:13,fontWeight:"600"},clearButton:{paddingHorizontal:10,paddingVertical:4,borderRadius:4,backgroundColor:F.color.surfaceElevated},clearText:{color:F.color.text,fontSize:12},row:{flexDirection:"row",paddingHorizontal:12,paddingVertical:4,borderBottomWidth:S.hairlineWidth,borderBottomColor:F.color.separator,gap:8},time:{color:F.color.textTertiary,fontSize:11,fontVariant:["tabular-nums"],minWidth:86},level:{fontSize:11,fontWeight:"700",minWidth:44},message:{flex:1,fontSize:12,fontFamily:zn},empty:{color:F.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:Ke(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{_e as CONSOLE_ICON_COLOR,Ve as ConsoleIcon,Wn as ConsoleLogList,It as ConsoleMessageRow,Bt as ConsoleModal,On as ConsoleRoot,He as ConsoleValue,Hn as ConsoleView,ee as clearEntries,Xn as consoleSyncAdapter,g as consoleTheme,Mt as consoleToolPreset,Ln as createConsoleTool,K as getEntries,Ee as getPreserveLog,it as initConsolePersistence,ce as installConsoleCapture,tt as installFatalErrorCapture,xt as levelStyles,Er as onClear,Sr as replaceEntries,at as setPreserveLog,ue as subscribe,st as subscribePreserveLog,xe as uninstallConsoleCapture,jt as useConsoleLogs,dt as useConsoleMessages};
|
|
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],u=a.stack&&a.stack.trim()!==c.trim()?a.stack:void 0;return u?q(y,{style:v.objectContainer,children:[q($,{testID:r,style:v.objectHeader,activeOpacity:.6,onPress:()=>o(g=>!g),children:[O(It,{open:n}),O(d,{style:[v.mono,v.errorHead],numberOfLines:n?void 0:1,children:c})]}),n?O(d,{style:[v.mono,v.errorStack],children:u}):null]}):O(d,{style:[v.mono,{color:m.onErrorContainer}],numberOfLines:1,children:c})}if(!yn(e)){let a=mn[i]??m.onSurface;return O(d,{testID:r,style:[v.mono,{color:a}],children:He(e)})}let l=e,s=Array.isArray(l)?l.map((a,c)=>[String(c),a]):Object.entries(l);return q(y,{style:v.objectContainer,children:[q($,{testID:r,onPress:()=>o(a=>!a),activeOpacity:.6,style:v.objectHeader,children:[O(It,{open:n}),O(d,{style:[v.mono,v.preview],numberOfLines:n?void 0:1,children:hn(l)})]}),n&&t<6?O(y,{testID:r?`${r}-children`:void 0,style:v.children,children:s.map(([a,c])=>q(y,{style:v.propertyRow,children:[q(d,{style:[v.mono,v.propertyKey],children:[a,":"]}),O(y,{style:v.propertyValue,children:O(je,{testID:r?`${r}-${a}`:void 0,value:c,depth:t+1})})]},a))}):null]})}var bn={fontFamily:R,fontSize:12,lineHeight:16},v=T.create({mono:bn,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 Q}from"react/jsx-runtime";function vn(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 wn({icon:e,color:t}){return b(d,{style:[f.levelIcon,{color:t}],children:e==="warning"?"\u26A0":"\u2298"})}function xn({count:e,color:t}){return b(y,{style:[f.repeatBadge,{borderColor:t}],children:b(d,{testID:"buoy-console-repeat-count",style:[f.repeatBadgeText,{color:t}],children:e})})}var Dt=nn(function({row:e,showTimestamps:t,onToggleGroup:r,onToggleCluster:n}){let{entry:o}=e,i=kt[o.level],l=o.level==="error"||o.level==="warning",s=i.text,[a,c]=ln(o.method==="trace");if(e.clusterHeader){let h=e.clusterHeader;return b($,{testID:`buoy-console-cluster-${e.originLabel}`,style:[f.wrapper,f.dividerTop],activeOpacity:.7,onPress:()=>n(h.key),children:Q(y,{style:f.rowWrapper,children:[b(d,{style:[f.originGutter,{color:e.originColor}],children:h.expanded?"\u25BC":"\u25B6"}),b(y,{style:f.messageColumn,children:Q(y,{style:f.messageLine,children:[b(d,{style:[f.text,f.clusterTitle,{color:e.originColor}],children:e.originLabel}),Q(d,{testID:"buoy-console-cluster-count",style:f.clusterCount,children:[" \xB7 ",h.count," logs"]})]})})]})})}let u=gn(o.args),g=!!o.stack&&(l||o.method==="trace"),x=b(y,{testID:a?"buoy-console-content-expanded":"buoy-console-content-collapsed",style:[f.contentWrap,!a&&f.contentWrapClamped],children:u.map((h,S)=>h.type==="string"?b(d,{testID:`buoy-console-text-${S}`,style:[f.text,{color:s},e.isGroupHeader&&f.groupTitle,h.style],children:h.value},S):b(je,{testID:`buoy-console-value-${S}`,value:h.value,generic:h.mode==="generic"},S))}),p=Q(y,{style:f.messageColumn,children:[e.originLabel?b(d,{testID:"buoy-console-origin",style:[f.originLabel,{color:e.originColor}],numberOfLines:1,children:e.originLabel}):null,Q(y,{style:f.messageLine,children:[e.isGroupHeader?b(d,{style:[f.groupTriangle,{color:s}],children:e.groupCollapsed?"\u25B6":"\u25BC"}):null,i.icon?b(wn,{icon:i.icon,color:s}):null,t?b(d,{testID:"buoy-console-timestamp",style:f.timestamp,children:vn(o.timestamp)}):null,g?b(d,{style:[f.stackTriangle,{color:s}],children:a?"\u25BC":"\u25B6"}):null,x,e.repeatCount>1?b(xn,{count:e.repeatCount,color:s}):null]}),g&&a?b(y,{testID:"buoy-console-stack",style:f.stackTrace,children:(o.stack??"").split(`
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/console",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.69",
|
|
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.69"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "*"
|