mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 02:01:42 +03:00
fix: remove dependencies in @affine/debug
(#2708)
This commit is contained in:
parent
d28c887237
commit
cd5c4b5cb7
@ -20,7 +20,7 @@ export interface PageViewDBV1 extends DBSchema {
|
||||
}
|
||||
|
||||
const pageViewDBPromise: Promise<IDBPDatabase<PageViewDBV1>> =
|
||||
environment.isServer
|
||||
typeof window === 'undefined'
|
||||
? // never resolve in SSR
|
||||
new Promise<any>(() => {})
|
||||
: openDB<PageViewDBV1>('page-view', 1, {
|
||||
|
@ -3,7 +3,6 @@
|
||||
"private": true,
|
||||
"main": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"@affine/env": "workspace:*",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,12 +1,9 @@
|
||||
import { env } from '@affine/env';
|
||||
import debug from 'debug';
|
||||
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
||||
|
||||
|
||||
const SESSION_KEY = 'affine:debug';
|
||||
const development = env.isDebug;
|
||||
|
||||
if (env.isBrowser) {
|
||||
if (typeof window !== 'undefined') {
|
||||
// enable debug logs if the URL search string contains `debug`
|
||||
// e.g. http://localhost:3000/?debug
|
||||
if (window.location.search.includes('debug')) {
|
||||
@ -15,11 +12,16 @@ if (env.isBrowser) {
|
||||
// we need to store the debug flag in sessionStorage
|
||||
sessionStorage.setItem(SESSION_KEY, 'true');
|
||||
}
|
||||
if (sessionStorage.getItem(SESSION_KEY) === 'true' || development) {
|
||||
if (sessionStorage.getItem(SESSION_KEY) === 'true') {
|
||||
// enable all debug logs by default
|
||||
debug.enable('*');
|
||||
console.warn('Debug logs enabled');
|
||||
}
|
||||
} else {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
debug.enable('*');
|
||||
console.warn('Debug logs enabled');
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugLogger {
|
||||
|
@ -8,11 +8,6 @@
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../env"
|
||||
}
|
||||
],
|
||||
"include": ["./src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user