mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat: use @affine/debug (#1244)
This commit is contained in:
@@ -2,13 +2,11 @@
|
||||
"name": "@affine/debug",
|
||||
"private": true,
|
||||
"main": "./src/index.ts",
|
||||
"keywords": [],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/toeverything/AFFiNE.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/debug": "^4.1.7",
|
||||
"@affine/env": "workspace:*",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { getEnvironment } from '@affine/env';
|
||||
import debug from 'debug';
|
||||
|
||||
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
||||
|
||||
const SESSION_KEY = 'affine:debug';
|
||||
const development = process.env.NODE_ENV === 'development';
|
||||
const env = getEnvironment();
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
const SESSION_KEY = 'affine:debug';
|
||||
const development = env.isDebug;
|
||||
|
||||
if (env.isBrowser) {
|
||||
// enable debug logs if the URL search string contains `debug`
|
||||
// e.g. http://localhost:3000/?debug
|
||||
if (window.location.search.includes('debug')) {
|
||||
|
||||
10
packages/debug/tsconfig.json
Normal file
10
packages/debug/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["./src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
5
packages/logger/next-env.d.ts
vendored
5
packages/logger/next-env.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "@affine/logger",
|
||||
"version": "0.3.0",
|
||||
"description": "",
|
||||
"main": "./src/index.ts",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "tsc --project ./tsconfig.json"
|
||||
},
|
||||
"keywords": [],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/toeverything/AFFiNE.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^13.1.6",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.28",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
import { Logger } from '../src';
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Track Example</h1>
|
||||
<Logger />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export const Logger = () => {
|
||||
useEffect(() => {
|
||||
console.log('@affine/logger: Render Track');
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export { Logger } from './Logger';
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"]
|
||||
}
|
||||
Reference in New Issue
Block a user