fix: remove dependencies in @affine/debug (#2708)

This commit is contained in:
Himself65 2023-06-07 15:41:42 +08:00 committed by GitHub
parent d28c887237
commit cd5c4b5cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 13 deletions

View File

@ -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, {

View File

@ -3,7 +3,6 @@
"private": true,
"main": "./src/index.ts",
"dependencies": {
"@affine/env": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {

View File

@ -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 {

View File

@ -8,11 +8,6 @@
"noEmit": false,
"outDir": "lib"
},
"references": [
{
"path": "../env"
}
],
"include": ["./src"],
"exclude": ["node_modules"]
}

View File

@ -158,7 +158,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/debug@workspace:packages/debug"
dependencies:
"@affine/env": "workspace:*"
"@types/debug": ^4.1.8
debug: ^4.3.4
languageName: unknown