change: improving adb connection

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-07-02 16:54:25 +07:00
parent fbbf0c12f4
commit d0a3b553a5
10 changed files with 320 additions and 56 deletions

View file

@ -15,18 +15,26 @@
* inspector.error('auth failure', uid) // always visible
*/
import { configureSync, getConfig, getConsoleSink, withFilter, getLogger } from '@logtape/logtape';
// ---------------------------------------------------------------------------
// Environment helpers
// ---------------------------------------------------------------------------
const IS_DEV = import.meta.env.DEV;
const ENV_LOG_LEVEL = (import.meta.env.PUBLIC_APP_LOG_LEVEL as string) || (IS_DEV ? 'trace' : 'info');
import type { LogLevel } from '@logtape/logtape';
// ---------------------------------------------------------------------------
// LogTape configuration (idempotent — uses getConfig() not a local flag)
// ---------------------------------------------------------------------------
/**
* Resolve the log level lazily (not at module-eval time).
*
* import.meta.env is undefined when Vite loads vite.config.ts, so we
* must not read it at the top level. Deferring to first use ensures
* Vite has finished initialising by the time we read it.
*/
function resolveLogLevel(): LogLevel {
const env = import.meta.env as Record<string, string | boolean | undefined> | undefined;
const isDev = env?.DEV ?? (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production');
const configured = env?.PUBLIC_APP_LOG_LEVEL as string | undefined;
return (configured || (isDev ? 'trace' : 'info')) as LogLevel;
}
function ensureConfigured() {
// Vite evaluates the config module twice during build (SSR + client).
// A local `_configured` boolean resets between evaluations, so we
@ -41,7 +49,7 @@ function ensureConfigured() {
{
category: ['supra-app'],
sinks: ['console'],
lowestLevel: ENV_LOG_LEVEL as 'trace' | 'debug' | 'info' | 'warning' | 'error' | 'fatal',
lowestLevel: resolveLogLevel(),
},
{
category: ['supra-app', 'inspector'],