@geenius/tools 0.1.0 → 0.3.0
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/package.json +62 -3
- package/packages/convex/shared/README.md +1 -1
- package/packages/devtools/dist/index.d.ts +204 -0
- package/packages/devtools/dist/index.js +186 -0
- package/packages/devtools/dist/index.js.map +1 -0
- package/packages/devtools/react/README.md +1 -1
- package/packages/devtools/solidjs/README.md +1 -1
- package/packages/devtools/solidjs/dist/index.js +1830 -0
- package/packages/devtools/solidjs/dist/index.js.map +1 -0
- package/packages/env/dist/index.d.ts +151 -0
- package/packages/env/dist/index.js +93 -0
- package/packages/env/dist/index.js.map +1 -0
- package/packages/errors/dist/index.d.ts +177 -0
- package/packages/errors/dist/index.js +187 -0
- package/packages/errors/dist/index.js.map +1 -0
- package/packages/errors/react/README.md +1 -1
- package/packages/errors/solidjs/README.md +1 -1
- package/packages/logger/dist/index.d.ts +171 -0
- package/packages/logger/dist/index.js +216 -0
- package/packages/logger/dist/index.js.map +1 -0
- package/packages/logger/react/README.md +1 -1
- package/packages/logger/solidjs/README.md +1 -1
- package/packages/perf/dist/index.d.ts +168 -0
- package/packages/perf/dist/index.js +265 -0
- package/packages/perf/dist/index.js.map +1 -0
- package/packages/perf/react/README.md +1 -1
- package/packages/perf/solidjs/README.md +1 -1
- package/packages/shared/dist/index.d.ts +253 -0
- package/packages/shared/dist/index.js +278 -0
- package/packages/shared/dist/index.js.map +1 -0
- package/.changeset/config.json +0 -11
- package/.env.example +0 -2
- package/.github/CODEOWNERS +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -23
- package/.github/workflows/release.yml +0 -29
- package/.node-version +0 -1
- package/.nvmrc +0 -1
- package/.prettierrc +0 -7
- package/.project/ACCOUNT.yaml +0 -4
- package/.project/IDEAS.yaml +0 -7
- package/.project/PROJECT.yaml +0 -11
- package/.project/ROADMAP.yaml +0 -15
- package/CODE_OF_CONDUCT.md +0 -26
- package/CONTRIBUTING.md +0 -69
- package/SECURITY.md +0 -18
- package/SUPPORT.md +0 -14
- package/packages/convex/shared/package.json +0 -42
- package/packages/convex/shared/src/audit/index.ts +0 -5
- package/packages/convex/shared/src/audit/presets.ts +0 -165
- package/packages/convex/shared/src/audit/schema.ts +0 -85
- package/packages/convex/shared/src/audit/write.ts +0 -102
- package/packages/convex/shared/src/extract.ts +0 -75
- package/packages/convex/shared/src/index.ts +0 -41
- package/packages/convex/shared/src/messages.ts +0 -45
- package/packages/convex/shared/src/security.ts +0 -112
- package/packages/convex/shared/src/throw.ts +0 -184
- package/packages/convex/shared/src/types.ts +0 -57
- package/packages/convex/shared/src/utils.ts +0 -58
- package/packages/convex/shared/tsconfig.json +0 -28
- package/packages/convex/shared/tsup.config.ts +0 -12
- package/packages/devtools/package.json +0 -27
- package/packages/devtools/react/package.json +0 -53
- package/packages/devtools/react/src/components/DesignPreview.tsx +0 -59
- package/packages/devtools/react/src/components/DesignSwitcherDropdown.tsx +0 -99
- package/packages/devtools/react/src/components/DevSidebar.tsx +0 -247
- package/packages/devtools/react/src/components/DevToolbar.tsx +0 -242
- package/packages/devtools/react/src/components/GitHubIssueDialog.tsx +0 -402
- package/packages/devtools/react/src/components/InspectorOverlay.tsx +0 -312
- package/packages/devtools/react/src/components/PageLoadWaterfall.tsx +0 -144
- package/packages/devtools/react/src/components/PerformancePanel.tsx +0 -330
- package/packages/devtools/react/src/context/DevModeContext.tsx +0 -226
- package/packages/devtools/react/src/context/PerformanceContext.tsx +0 -143
- package/packages/devtools/react/src/data/designs.ts +0 -13
- package/packages/devtools/react/src/hooks/useGitHubLabels.ts +0 -47
- package/packages/devtools/react/src/hooks/useVirtualList.ts +0 -124
- package/packages/devtools/react/src/index.ts +0 -77
- package/packages/devtools/react/src/panels/ConvexSpy.tsx +0 -130
- package/packages/devtools/react/src/panels/DatabaseSeeder.tsx +0 -116
- package/packages/devtools/react/src/panels/DevModePhase2.tsx +0 -191
- package/packages/devtools/react/src/panels/DevModePhase3.tsx +0 -234
- package/packages/devtools/react/src/panels/FeatureFlagsToggle.tsx +0 -104
- package/packages/devtools/react/src/panels/QuickRouteJump.tsx +0 -152
- package/packages/devtools/react/src/services/github-service.ts +0 -247
- package/packages/devtools/react/tsconfig.json +0 -31
- package/packages/devtools/react/tsup.config.ts +0 -18
- package/packages/devtools/solidjs/package.json +0 -49
- package/packages/devtools/solidjs/src/components/DesignPreview.tsx +0 -51
- package/packages/devtools/solidjs/src/components/DesignSwitcherDropdown.tsx +0 -95
- package/packages/devtools/solidjs/src/components/DevSidebar.tsx +0 -247
- package/packages/devtools/solidjs/src/components/DevToolbar.tsx +0 -242
- package/packages/devtools/solidjs/src/components/GitHubIssueDialog.tsx +0 -400
- package/packages/devtools/solidjs/src/components/InspectorOverlay.tsx +0 -311
- package/packages/devtools/solidjs/src/components/PageLoadWaterfall.tsx +0 -144
- package/packages/devtools/solidjs/src/components/PerformancePanel.tsx +0 -330
- package/packages/devtools/solidjs/src/context/DevModeContext.tsx +0 -216
- package/packages/devtools/solidjs/src/context/PerformanceContext.tsx +0 -135
- package/packages/devtools/solidjs/src/data/designs.ts +0 -13
- package/packages/devtools/solidjs/src/hooks/createGitHubLabels.ts +0 -47
- package/packages/devtools/solidjs/src/index.ts +0 -64
- package/packages/devtools/solidjs/src/services/github-service.ts +0 -247
- package/packages/devtools/solidjs/tsconfig.json +0 -21
- package/packages/devtools/src/index.ts +0 -377
- package/packages/devtools/tsup.config.ts +0 -12
- package/packages/env/package.json +0 -30
- package/packages/env/src/index.ts +0 -264
- package/packages/env/tsup.config.ts +0 -12
- package/packages/errors/package.json +0 -27
- package/packages/errors/react/package.json +0 -72
- package/packages/errors/react/src/analytics.ts +0 -16
- package/packages/errors/react/src/components/ErrorBoundary.tsx +0 -248
- package/packages/errors/react/src/components/ErrorDisplay.tsx +0 -328
- package/packages/errors/react/src/components/ValidationErrors.tsx +0 -102
- package/packages/errors/react/src/config.ts +0 -199
- package/packages/errors/react/src/constants.ts +0 -74
- package/packages/errors/react/src/hooks/useErrorBoundary.ts +0 -92
- package/packages/errors/react/src/hooks/useErrorHandler.ts +0 -87
- package/packages/errors/react/src/index.ts +0 -96
- package/packages/errors/react/src/types.ts +0 -102
- package/packages/errors/react/src/utils/errorMessages.ts +0 -35
- package/packages/errors/react/src/utils/errorPolicy.ts +0 -139
- package/packages/errors/react/src/utils/extractAppError.ts +0 -174
- package/packages/errors/react/src/utils/formatError.ts +0 -112
- package/packages/errors/react/tsconfig.json +0 -25
- package/packages/errors/react/tsup.config.ts +0 -24
- package/packages/errors/solidjs/package.json +0 -46
- package/packages/errors/solidjs/src/components/ErrorDisplay.tsx +0 -179
- package/packages/errors/solidjs/src/config.ts +0 -98
- package/packages/errors/solidjs/src/hooks/createErrorHandler.ts +0 -107
- package/packages/errors/solidjs/src/index.ts +0 -61
- package/packages/errors/solidjs/src/types.ts +0 -34
- package/packages/errors/solidjs/src/utils/errorPolicy.ts +0 -56
- package/packages/errors/solidjs/src/utils/extractAppError.ts +0 -94
- package/packages/errors/solidjs/src/utils/formatError.ts +0 -33
- package/packages/errors/solidjs/tsconfig.json +0 -26
- package/packages/errors/solidjs/tsup.config.ts +0 -21
- package/packages/errors/src/index.ts +0 -320
- package/packages/errors/tsup.config.ts +0 -12
- package/packages/logger/package.json +0 -27
- package/packages/logger/react/package.json +0 -46
- package/packages/logger/react/src/index.ts +0 -4
- package/packages/logger/react/src/useMetrics.ts +0 -42
- package/packages/logger/react/src/usePerformanceLog.ts +0 -61
- package/packages/logger/react/tsconfig.json +0 -31
- package/packages/logger/react/tsup.config.ts +0 -12
- package/packages/logger/solidjs/package.json +0 -45
- package/packages/logger/solidjs/src/createMetrics.ts +0 -37
- package/packages/logger/solidjs/src/createPerformanceLog.ts +0 -58
- package/packages/logger/solidjs/src/index.ts +0 -4
- package/packages/logger/solidjs/tsconfig.json +0 -32
- package/packages/logger/solidjs/tsup.config.ts +0 -12
- package/packages/logger/src/index.ts +0 -363
- package/packages/logger/tsup.config.ts +0 -12
- package/packages/perf/package.json +0 -27
- package/packages/perf/react/package.json +0 -59
- package/packages/perf/react/src/components/PerformanceDashboard.tsx +0 -257
- package/packages/perf/react/src/hooks/useMonitoredQuery.ts +0 -89
- package/packages/perf/react/src/hooks/usePerformanceMetrics.ts +0 -78
- package/packages/perf/react/src/index.ts +0 -33
- package/packages/perf/react/src/services/PerformanceMonitor.ts +0 -313
- package/packages/perf/react/src/types.ts +0 -77
- package/packages/perf/react/tsconfig.json +0 -25
- package/packages/perf/react/tsup.config.ts +0 -19
- package/packages/perf/solidjs/package.json +0 -41
- package/packages/perf/solidjs/src/components/PerformanceDashboard.tsx +0 -207
- package/packages/perf/solidjs/src/hooks/createPerformanceMetrics.ts +0 -73
- package/packages/perf/solidjs/src/index.ts +0 -31
- package/packages/perf/solidjs/src/services/PerformanceMonitor.ts +0 -134
- package/packages/perf/solidjs/src/types.ts +0 -78
- package/packages/perf/solidjs/tsconfig.json +0 -26
- package/packages/perf/solidjs/tsup.config.ts +0 -14
- package/packages/perf/src/index.ts +0 -410
- package/packages/perf/tsup.config.ts +0 -12
- package/pnpm-workspace.yaml +0 -2
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/logger-solid — src/createPerformanceLog.ts
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
perfLog,
|
|
5
|
-
type LogCategory,
|
|
6
|
-
type PerformanceLogger,
|
|
7
|
-
} from '@geenius-tools/logger'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* SolidJS helper for component-scoped performance logging.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* import { createPerformanceLog } from '@geenius-tools/logger-solidjs'
|
|
15
|
-
*
|
|
16
|
-
* function MyComponent() {
|
|
17
|
-
* const perf = createPerformanceLog('MyComponent')
|
|
18
|
-
*
|
|
19
|
-
* onMount(() => {
|
|
20
|
-
* perf.logMount()
|
|
21
|
-
* })
|
|
22
|
-
*
|
|
23
|
-
* onCleanup(() => {
|
|
24
|
-
* perf.logUnmount()
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* const handleClick = async () => {
|
|
28
|
-
* const end = perf.start('fetch data', 'query')
|
|
29
|
-
* await fetchData()
|
|
30
|
-
* end()
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function createPerformanceLog(
|
|
36
|
-
componentName: string,
|
|
37
|
-
logger: PerformanceLogger = perfLog,
|
|
38
|
-
) {
|
|
39
|
-
return {
|
|
40
|
-
/** Log component mounted */
|
|
41
|
-
logMount: () =>
|
|
42
|
-
logger.log(componentName, 'Component mounted', undefined, 'component'),
|
|
43
|
-
/** Log component unmounted */
|
|
44
|
-
logUnmount: () =>
|
|
45
|
-
logger.log(componentName, 'Component unmounted', undefined, 'component'),
|
|
46
|
-
/** Track render count */
|
|
47
|
-
logRender: () => logger.renderCount(componentName),
|
|
48
|
-
/** Log an effect execution */
|
|
49
|
-
logEffect: (effectName: string) =>
|
|
50
|
-
logger.log(componentName, `Effect: ${effectName}`, undefined, 'effect'),
|
|
51
|
-
/** Start a timed operation, returns stop function */
|
|
52
|
-
start: (operation: string, category?: LogCategory) =>
|
|
53
|
-
logger.start(componentName, operation, category),
|
|
54
|
-
/** Generic log scoped to this component */
|
|
55
|
-
log: (message: string, data?: unknown, category?: LogCategory) =>
|
|
56
|
-
logger.log(componentName, message, data, category),
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"jsx": "preserve",
|
|
7
|
-
"jsxImportSource": "solid-js",
|
|
8
|
-
"lib": [
|
|
9
|
-
"ES2022",
|
|
10
|
-
"DOM",
|
|
11
|
-
"DOM.Iterable"
|
|
12
|
-
],
|
|
13
|
-
"strict": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"forceConsistentCasingInFileNames": true,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"declarationMap": true,
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"outDir": "./dist",
|
|
23
|
-
"rootDir": "./src"
|
|
24
|
-
},
|
|
25
|
-
"include": [
|
|
26
|
-
"src"
|
|
27
|
-
],
|
|
28
|
-
"exclude": [
|
|
29
|
-
"node_modules",
|
|
30
|
-
"dist"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: { index: 'src/index.ts' },
|
|
5
|
-
outDir: 'dist',
|
|
6
|
-
format: ['esm'],
|
|
7
|
-
dts: true,
|
|
8
|
-
sourcemap: true,
|
|
9
|
-
clean: true,
|
|
10
|
-
treeshake: true,
|
|
11
|
-
external: ['solid-js', '@geenius-tools/logger'],
|
|
12
|
-
})
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @geenius-tools/logger — Structured logging
|
|
3
|
-
*
|
|
4
|
-
* Provides structured logging with levels, formatting, and contextual data.
|
|
5
|
-
* Suitable for both client and server environments.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Log levels in order of severity
|
|
10
|
-
*/
|
|
11
|
-
export enum LogLevel {
|
|
12
|
-
DEBUG = 0,
|
|
13
|
-
INFO = 1,
|
|
14
|
-
WARN = 2,
|
|
15
|
-
ERROR = 3,
|
|
16
|
-
FATAL = 4,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Log entry structure
|
|
21
|
-
*/
|
|
22
|
-
export interface LogEntry {
|
|
23
|
-
/** Log level */
|
|
24
|
-
level: LogLevel
|
|
25
|
-
/** Log message */
|
|
26
|
-
message: string
|
|
27
|
-
/** Contextual data */
|
|
28
|
-
context?: Record<string, unknown>
|
|
29
|
-
/** Error object if applicable */
|
|
30
|
-
error?: Error | unknown
|
|
31
|
-
/** Timestamp */
|
|
32
|
-
timestamp: Date
|
|
33
|
-
/** Additional metadata */
|
|
34
|
-
metadata?: Record<string, unknown>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Log formatter function
|
|
39
|
-
*/
|
|
40
|
-
export type LogFormatter = (entry: LogEntry) => string
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Logger transport (where logs go)
|
|
44
|
-
*/
|
|
45
|
-
export interface LogTransport {
|
|
46
|
-
/** Log handler function */
|
|
47
|
-
log(entry: LogEntry): void | Promise<void>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Logger configuration
|
|
52
|
-
*/
|
|
53
|
-
export interface LoggerConfig {
|
|
54
|
-
/** Minimum log level to output (default: INFO) */
|
|
55
|
-
level?: LogLevel
|
|
56
|
-
/** Custom formatter (default: pretty print) */
|
|
57
|
-
formatter?: LogFormatter
|
|
58
|
-
/** Log transports */
|
|
59
|
-
transports?: LogTransport[]
|
|
60
|
-
/** Whether to include timestamps (default: true) */
|
|
61
|
-
timestamps?: boolean
|
|
62
|
-
/** Whether to include source location (default: false) */
|
|
63
|
-
sourceLocation?: boolean
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Structured logger with context and levels
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* const logger = createLogger({ level: LogLevel.DEBUG })
|
|
72
|
-
*
|
|
73
|
-
* logger.info('User signed in', { userId: '123' })
|
|
74
|
-
* logger.error('Database error', { error })
|
|
75
|
-
* logger.debug('Cache hit', { key: 'user:123' })
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export class Logger {
|
|
79
|
-
private level: LogLevel
|
|
80
|
-
private formatter: LogFormatter
|
|
81
|
-
private transports: LogTransport[]
|
|
82
|
-
private timestamps: boolean
|
|
83
|
-
private sourceLocation: boolean
|
|
84
|
-
private context: Map<string, unknown> = new Map()
|
|
85
|
-
|
|
86
|
-
constructor(config: LoggerConfig = {}) {
|
|
87
|
-
this.level = config.level ?? LogLevel.INFO
|
|
88
|
-
this.formatter = config.formatter ?? defaultFormatter
|
|
89
|
-
this.transports = config.transports ?? [consoleTransport]
|
|
90
|
-
this.timestamps = config.timestamps !== false
|
|
91
|
-
this.sourceLocation = config.sourceLocation ?? false
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Logs with debug level
|
|
96
|
-
*/
|
|
97
|
-
debug(message: string, context?: Record<string, unknown>) {
|
|
98
|
-
this.log(LogLevel.DEBUG, message, context)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Logs with info level
|
|
103
|
-
*/
|
|
104
|
-
info(message: string, context?: Record<string, unknown>) {
|
|
105
|
-
this.log(LogLevel.INFO, message, context)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Logs with warn level
|
|
110
|
-
*/
|
|
111
|
-
warn(message: string, context?: Record<string, unknown>) {
|
|
112
|
-
this.log(LogLevel.WARN, message, context)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Logs with error level
|
|
117
|
-
*/
|
|
118
|
-
error(message: string, error?: Error | unknown, context?: Record<string, unknown>) {
|
|
119
|
-
this.log(LogLevel.ERROR, message, context, error)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Logs with fatal level
|
|
124
|
-
*/
|
|
125
|
-
fatal(message: string, error?: Error | unknown, context?: Record<string, unknown>) {
|
|
126
|
-
this.log(LogLevel.FATAL, message, context, error)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Core logging method
|
|
131
|
-
*/
|
|
132
|
-
private log(
|
|
133
|
-
level: LogLevel,
|
|
134
|
-
message: string,
|
|
135
|
-
context?: Record<string, unknown>,
|
|
136
|
-
error?: Error | unknown
|
|
137
|
-
) {
|
|
138
|
-
if (level < this.level) {
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const mergedContext = {
|
|
143
|
-
...Object.fromEntries(this.context),
|
|
144
|
-
...context,
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const entry: LogEntry = {
|
|
148
|
-
level,
|
|
149
|
-
message,
|
|
150
|
-
context: Object.keys(mergedContext).length > 0 ? mergedContext : undefined,
|
|
151
|
-
error,
|
|
152
|
-
timestamp: new Date(),
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (this.sourceLocation) {
|
|
156
|
-
entry.metadata = {
|
|
157
|
-
...entry.metadata,
|
|
158
|
-
location: this.getSourceLocation(),
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const formatted = this.formatter(entry)
|
|
163
|
-
|
|
164
|
-
for (const transport of this.transports) {
|
|
165
|
-
try {
|
|
166
|
-
void transport.log(entry)
|
|
167
|
-
} catch {
|
|
168
|
-
// Silently fail to prevent logger errors from breaking app
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Sets context for all subsequent logs
|
|
175
|
-
*/
|
|
176
|
-
setContext(key: string, value: unknown) {
|
|
177
|
-
this.context.set(key, value)
|
|
178
|
-
return this
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Gets current context
|
|
183
|
-
*/
|
|
184
|
-
getContext(): Record<string, unknown> {
|
|
185
|
-
return Object.fromEntries(this.context)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Clears context
|
|
190
|
-
*/
|
|
191
|
-
clearContext() {
|
|
192
|
-
this.context.clear()
|
|
193
|
-
return this
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Creates a child logger with inherited context
|
|
198
|
-
*/
|
|
199
|
-
child(context: Record<string, unknown>): Logger {
|
|
200
|
-
const child = new Logger({
|
|
201
|
-
level: this.level,
|
|
202
|
-
formatter: this.formatter,
|
|
203
|
-
transports: this.transports,
|
|
204
|
-
timestamps: this.timestamps,
|
|
205
|
-
sourceLocation: this.sourceLocation,
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
// Inherit context
|
|
209
|
-
for (const [key, value] of this.context) {
|
|
210
|
-
child.setContext(key, value)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Add child context
|
|
214
|
-
for (const [key, value] of Object.entries(context)) {
|
|
215
|
-
child.setContext(key, value)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return child
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Gets source location from stack trace
|
|
223
|
-
*/
|
|
224
|
-
private getSourceLocation(): { file: string; line: number } {
|
|
225
|
-
const stack = new Error().stack || ''
|
|
226
|
-
const lines = stack.split('\n')
|
|
227
|
-
|
|
228
|
-
// Skip error message and this method
|
|
229
|
-
for (let i = 2; i < lines.length; i++) {
|
|
230
|
-
const line = lines[i]
|
|
231
|
-
if (line.includes('Logger.') || line.includes('logger.')) {
|
|
232
|
-
continue
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const match = line.match(/at\s+(?:.*?\s+)?\(?([^:\)]+):(\d+)/)
|
|
236
|
-
if (match) {
|
|
237
|
-
return {
|
|
238
|
-
file: match[1],
|
|
239
|
-
line: parseInt(match[2]),
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return { file: 'unknown', line: 0 }
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Default log formatter with colors (for terminal)
|
|
250
|
-
*/
|
|
251
|
-
const defaultFormatter: LogFormatter = (entry: LogEntry) => {
|
|
252
|
-
const levelName = LogLevel[entry.level]
|
|
253
|
-
const timestamp = entry.timestamp.toISOString()
|
|
254
|
-
|
|
255
|
-
let output = `[${timestamp}] [${levelName}] ${entry.message}`
|
|
256
|
-
|
|
257
|
-
if (entry.context && Object.keys(entry.context).length > 0) {
|
|
258
|
-
output += ` ${JSON.stringify(entry.context)}`
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (entry.error) {
|
|
262
|
-
const errorStr =
|
|
263
|
-
entry.error instanceof Error
|
|
264
|
-
? `${entry.error.name}: ${entry.error.message}`
|
|
265
|
-
: String(entry.error)
|
|
266
|
-
output += ` Error: ${errorStr}`
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return output
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Console transport for logging to stdout/stderr
|
|
274
|
-
*/
|
|
275
|
-
export const consoleTransport: LogTransport = {
|
|
276
|
-
log(entry: LogEntry) {
|
|
277
|
-
const formatted = defaultFormatter(entry)
|
|
278
|
-
|
|
279
|
-
if (entry.level >= LogLevel.ERROR) {
|
|
280
|
-
console.error(formatted)
|
|
281
|
-
} else if (entry.level === LogLevel.WARN) {
|
|
282
|
-
console.warn(formatted)
|
|
283
|
-
} else {
|
|
284
|
-
console.log(formatted)
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Creates a new logger instance
|
|
291
|
-
*
|
|
292
|
-
* @param config Logger configuration
|
|
293
|
-
* @returns Configured logger
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* ```ts
|
|
297
|
-
* const logger = createLogger({
|
|
298
|
-
* level: LogLevel.DEBUG,
|
|
299
|
-
* timestamps: true
|
|
300
|
-
* })
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
export function createLogger(config?: LoggerConfig): Logger {
|
|
304
|
-
return new Logger(config)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Global default logger instance
|
|
309
|
-
*/
|
|
310
|
-
let globalLogger: Logger | null = null
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Gets or creates global logger
|
|
314
|
-
*
|
|
315
|
-
* @param config Configuration for initial creation
|
|
316
|
-
* @returns Global logger instance
|
|
317
|
-
*/
|
|
318
|
-
export function getGlobalLogger(config?: LoggerConfig): Logger {
|
|
319
|
-
if (!globalLogger) {
|
|
320
|
-
globalLogger = createLogger(config)
|
|
321
|
-
}
|
|
322
|
-
return globalLogger
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Resets global logger (for testing)
|
|
327
|
-
*/
|
|
328
|
-
export function resetGlobalLogger() {
|
|
329
|
-
globalLogger = null
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Memory transport for testing and analysis
|
|
334
|
-
*/
|
|
335
|
-
export class MemoryTransport implements LogTransport {
|
|
336
|
-
private entries: LogEntry[] = []
|
|
337
|
-
|
|
338
|
-
log(entry: LogEntry) {
|
|
339
|
-
this.entries.push(entry)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/** Gets all logged entries */
|
|
343
|
-
getEntries(): LogEntry[] {
|
|
344
|
-
return [...this.entries]
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/** Gets entries by level */
|
|
348
|
-
getByLevel(level: LogLevel): LogEntry[] {
|
|
349
|
-
return this.entries.filter((e) => e.level === level)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/** Clears all entries */
|
|
353
|
-
clear() {
|
|
354
|
-
this.entries = []
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/** Gets count of entries */
|
|
358
|
-
size(): number {
|
|
359
|
-
return this.entries.length
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export { LogLevel } from './index'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/perf",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Performance monitoring utilities for Geenius projects",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"type-check": "tsc --noEmit",
|
|
17
|
-
"clean": "rm -rf dist .turbo"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"typescript": "~6.0.2",
|
|
21
|
-
"tsup": "^8.0.1"
|
|
22
|
-
},
|
|
23
|
-
"publishConfig": {
|
|
24
|
-
"access": "public"
|
|
25
|
-
},
|
|
26
|
-
"license": "MIT"
|
|
27
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/perf-react",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "React performance monitoring \u2014 dashboard, metrics hooks, query tracking",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"README.md"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsup",
|
|
22
|
-
"dev": "tsup --watch",
|
|
23
|
-
"typecheck": "tsc --noEmit"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@geenius-ui/react": "workspace:*",
|
|
27
|
-
"@tanstack/react-query": "^5.91.3",
|
|
28
|
-
"@types/react": "^19.0.0",
|
|
29
|
-
"@types/react-dom": "^19.0.0",
|
|
30
|
-
"lucide-react": "^0.577.0",
|
|
31
|
-
"react": "^19.2.4",
|
|
32
|
-
"react-dom": "^19.2.4",
|
|
33
|
-
"tsup": "^8.5.1",
|
|
34
|
-
"typescript": "~5.9.3"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
38
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
39
|
-
},
|
|
40
|
-
"peerDependenciesMeta": {
|
|
41
|
-
"lucide-react": {
|
|
42
|
-
"optional": true
|
|
43
|
-
},
|
|
44
|
-
"@geenius-ui/react": {
|
|
45
|
-
"optional": true
|
|
46
|
-
},
|
|
47
|
-
"@tanstack/react-query": {
|
|
48
|
-
"optional": true
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"author": "Antigravity HQ",
|
|
52
|
-
"license": "MIT",
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=20.0.0"
|
|
55
|
-
},
|
|
56
|
-
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
58
|
-
}
|
|
59
|
-
}
|