@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,73 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/perf-solidjs — src/hooks/createPerformanceMetrics.ts
|
|
2
|
-
|
|
3
|
-
import { createSignal, createEffect, onCleanup } from 'solid-js'
|
|
4
|
-
import { PerformanceMonitor } from '../services/PerformanceMonitor'
|
|
5
|
-
import type { PerformanceMetrics } from '../types'
|
|
6
|
-
|
|
7
|
-
export interface CreatePerformanceMetricsOptions {
|
|
8
|
-
timeRange?: number
|
|
9
|
-
pollingInterval?: number
|
|
10
|
-
autoRefresh?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* SolidJS signal for performance metrics
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const { metrics, isLoading, refresh, clearMetrics } = createPerformanceMetrics({
|
|
18
|
-
* timeRange: 60 * 60 * 1000,
|
|
19
|
-
* })
|
|
20
|
-
*
|
|
21
|
-
* return <div>Score: {metrics()?.score}</div>
|
|
22
|
-
*/
|
|
23
|
-
export function createPerformanceMetrics(
|
|
24
|
-
options: CreatePerformanceMetricsOptions = {},
|
|
25
|
-
) {
|
|
26
|
-
const {
|
|
27
|
-
timeRange = 24 * 60 * 60 * 1000,
|
|
28
|
-
pollingInterval = 5000,
|
|
29
|
-
autoRefresh = true,
|
|
30
|
-
} = options
|
|
31
|
-
|
|
32
|
-
const [metrics, setMetrics] = createSignal<PerformanceMetrics | null>(null)
|
|
33
|
-
const [isLoading, setIsLoading] = createSignal(true)
|
|
34
|
-
const [error, setError] = createSignal<Error | null>(null)
|
|
35
|
-
|
|
36
|
-
const fetchMetrics = () => {
|
|
37
|
-
try {
|
|
38
|
-
const end = Date.now()
|
|
39
|
-
const start = end - timeRange
|
|
40
|
-
setMetrics(PerformanceMonitor.getMetrics({ start, end }))
|
|
41
|
-
setError(null)
|
|
42
|
-
} catch (err) {
|
|
43
|
-
setError(err instanceof Error ? err : new Error('Failed to fetch metrics'))
|
|
44
|
-
} finally {
|
|
45
|
-
setIsLoading(false)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
createEffect(() => {
|
|
50
|
-
fetchMetrics()
|
|
51
|
-
|
|
52
|
-
if (autoRefresh) {
|
|
53
|
-
const interval = setInterval(fetchMetrics, pollingInterval)
|
|
54
|
-
onCleanup(() => clearInterval(interval))
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const clearMetrics = () => {
|
|
59
|
-
PerformanceMonitor.clear()
|
|
60
|
-
fetchMetrics()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const exportMetrics = () => PerformanceMonitor.exportMetrics()
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
metrics,
|
|
67
|
-
isLoading,
|
|
68
|
-
error,
|
|
69
|
-
refresh: fetchMetrics,
|
|
70
|
-
clearMetrics,
|
|
71
|
-
exportMetrics,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/perf-solidjs — src/index.ts
|
|
2
|
-
|
|
3
|
-
// ===== Types =====
|
|
4
|
-
export type {
|
|
5
|
-
CacheMetrics,
|
|
6
|
-
QueryMetrics,
|
|
7
|
-
PageLoadMetrics,
|
|
8
|
-
ErrorMetrics,
|
|
9
|
-
PerformanceMetrics,
|
|
10
|
-
PerformanceConfig,
|
|
11
|
-
CacheHitEvent,
|
|
12
|
-
CacheMissEvent,
|
|
13
|
-
} from './types'
|
|
14
|
-
|
|
15
|
-
// ===== Service =====
|
|
16
|
-
export { PerformanceMonitor } from './services/PerformanceMonitor'
|
|
17
|
-
|
|
18
|
-
// ===== Hooks =====
|
|
19
|
-
export { createPerformanceMetrics } from './hooks/createPerformanceMetrics'
|
|
20
|
-
export type { CreatePerformanceMetricsOptions } from './hooks/createPerformanceMetrics'
|
|
21
|
-
|
|
22
|
-
// ===== Components =====
|
|
23
|
-
export { PerformanceDashboard } from './components/PerformanceDashboard'
|
|
24
|
-
export type {
|
|
25
|
-
PerformanceDashboardProps,
|
|
26
|
-
PerformanceMetricsData,
|
|
27
|
-
CacheMetrics as DashboardCacheMetrics,
|
|
28
|
-
QueryMetric,
|
|
29
|
-
ErrorMetric,
|
|
30
|
-
} from './components/PerformanceDashboard'
|
|
31
|
-
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/perf-solidjs — src/services/PerformanceMonitor.ts
|
|
2
|
-
// Same PerformanceMonitor service as perf-react (framework-agnostic singleton)
|
|
3
|
-
// Re-implemented here to avoid cross-package dependency
|
|
4
|
-
|
|
5
|
-
import type {
|
|
6
|
-
PerformanceMetrics,
|
|
7
|
-
PerformanceConfig,
|
|
8
|
-
CacheMetrics,
|
|
9
|
-
QueryMetrics,
|
|
10
|
-
PageLoadMetrics,
|
|
11
|
-
ErrorMetrics,
|
|
12
|
-
CacheHitEvent,
|
|
13
|
-
CacheMissEvent,
|
|
14
|
-
} from '../types'
|
|
15
|
-
|
|
16
|
-
interface QueryEntry { key: string; duration: number; timestamp: number; error?: Error; cached: boolean }
|
|
17
|
-
interface CacheEntry { type: 'hit' | 'miss'; queryKey: string; duration: number; fetchDuration?: number; timestamp: number; cacheType: 'ssr' | 'client' | 'memory' }
|
|
18
|
-
interface ErrorEntry { type: string; message: string; stack?: string; timestamp: number; source: string }
|
|
19
|
-
interface PageLoadEntry { route: string; ttfb: number; fcp: number; lcp: number; tti: number; loadTime: number; ssr: boolean; timestamp: number }
|
|
20
|
-
|
|
21
|
-
const DEFAULT_CONFIG: PerformanceConfig = {
|
|
22
|
-
enableCacheTracking: true, enableQueryTracking: true,
|
|
23
|
-
enablePageLoadTracking: true, enableErrorTracking: true,
|
|
24
|
-
sampleRate: 1, maxMetrics: 1000,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class PerformanceMonitor {
|
|
28
|
-
private static queries: QueryEntry[] = []
|
|
29
|
-
private static cacheEntries: CacheEntry[] = []
|
|
30
|
-
private static errors: ErrorEntry[] = []
|
|
31
|
-
private static pageLoads: PageLoadEntry[] = []
|
|
32
|
-
private static config: PerformanceConfig = DEFAULT_CONFIG
|
|
33
|
-
|
|
34
|
-
static configure(config: Partial<PerformanceConfig>): void {
|
|
35
|
-
PerformanceMonitor.config = { ...PerformanceMonitor.config, ...config }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static trackQuery(queryKey: string, duration: number, error?: Error, cached = false): void {
|
|
39
|
-
if (!PerformanceMonitor.config.enableQueryTracking) return
|
|
40
|
-
if (Math.random() > (PerformanceMonitor.config.sampleRate ?? 1)) return
|
|
41
|
-
PerformanceMonitor.queries.push({ key: queryKey, duration, timestamp: Date.now(), error, cached })
|
|
42
|
-
const max = PerformanceMonitor.config.maxMetrics ?? 1000
|
|
43
|
-
if (PerformanceMonitor.queries.length > max) PerformanceMonitor.queries = PerformanceMonitor.queries.slice(-max)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static trackCacheHit(event: CacheHitEvent): void {
|
|
47
|
-
if (!PerformanceMonitor.config.enableCacheTracking) return
|
|
48
|
-
PerformanceMonitor.cacheEntries.push({ type: 'hit', ...event })
|
|
49
|
-
const max = PerformanceMonitor.config.maxMetrics ?? 1000
|
|
50
|
-
if (PerformanceMonitor.cacheEntries.length > max) PerformanceMonitor.cacheEntries = PerformanceMonitor.cacheEntries.slice(-max)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static trackCacheMiss(event: CacheMissEvent): void {
|
|
54
|
-
if (!PerformanceMonitor.config.enableCacheTracking) return
|
|
55
|
-
PerformanceMonitor.cacheEntries.push({ type: 'miss', ...event })
|
|
56
|
-
const max = PerformanceMonitor.config.maxMetrics ?? 1000
|
|
57
|
-
if (PerformanceMonitor.cacheEntries.length > max) PerformanceMonitor.cacheEntries = PerformanceMonitor.cacheEntries.slice(-max)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static trackError(error: Error, source: string): void {
|
|
61
|
-
if (!PerformanceMonitor.config.enableErrorTracking) return
|
|
62
|
-
PerformanceMonitor.errors.push({ type: error.name || 'Error', message: error.message, stack: error.stack, timestamp: Date.now(), source })
|
|
63
|
-
const max = PerformanceMonitor.config.maxMetrics ?? 1000
|
|
64
|
-
if (PerformanceMonitor.errors.length > max) PerformanceMonitor.errors = PerformanceMonitor.errors.slice(-max)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static trackPageLoad(metrics: Omit<PageLoadEntry, 'timestamp'>): void {
|
|
68
|
-
if (!PerformanceMonitor.config.enablePageLoadTracking) return
|
|
69
|
-
PerformanceMonitor.pageLoads.push({ ...metrics, timestamp: Date.now() })
|
|
70
|
-
const max = PerformanceMonitor.config.maxMetrics ?? 1000
|
|
71
|
-
if (PerformanceMonitor.pageLoads.length > max) PerformanceMonitor.pageLoads = PerformanceMonitor.pageLoads.slice(-max)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static getMetrics(timeRange: { start: number; end: number }): PerformanceMetrics {
|
|
75
|
-
const { start, end } = timeRange
|
|
76
|
-
const rq = PerformanceMonitor.queries.filter(q => q.timestamp >= start && q.timestamp <= end)
|
|
77
|
-
const rc = PerformanceMonitor.cacheEntries.filter(c => c.timestamp >= start && c.timestamp <= end)
|
|
78
|
-
const re = PerformanceMonitor.errors.filter(e => e.timestamp >= start && e.timestamp <= end)
|
|
79
|
-
const rp = PerformanceMonitor.pageLoads.filter(p => p.timestamp >= start && p.timestamp <= end)
|
|
80
|
-
|
|
81
|
-
const hits = rc.filter(c => c.type === 'hit')
|
|
82
|
-
const misses = rc.filter(c => c.type === 'miss')
|
|
83
|
-
const total = hits.length + misses.length
|
|
84
|
-
|
|
85
|
-
const cache: CacheMetrics = {
|
|
86
|
-
totalRequests: total, hits: hits.length, misses: misses.length,
|
|
87
|
-
hitRate: total > 0 ? (hits.length / total) * 100 : 0,
|
|
88
|
-
avgHitTime: hits.length > 0 ? hits.reduce((s, h) => s + h.duration, 0) / hits.length : 0,
|
|
89
|
-
avgMissTime: misses.length > 0 ? misses.reduce((s, m) => s + (m.fetchDuration ?? m.duration), 0) / misses.length : 0,
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const qMap = new Map<string, QueryEntry[]>()
|
|
93
|
-
for (const q of rq) { const arr = qMap.get(q.key) || []; arr.push(q); qMap.set(q.key, arr) }
|
|
94
|
-
|
|
95
|
-
const queries: QueryMetrics[] = Array.from(qMap.entries()).map(([key, entries]) => {
|
|
96
|
-
const d = entries.map(e => e.duration)
|
|
97
|
-
return {
|
|
98
|
-
queryKey: key, executions: entries.length,
|
|
99
|
-
avgDuration: d.reduce((s, v) => s + v, 0) / d.length,
|
|
100
|
-
minDuration: Math.min(...d), maxDuration: Math.max(...d),
|
|
101
|
-
errors: entries.filter(e => e.error).length,
|
|
102
|
-
lastExecuted: Math.max(...entries.map(e => e.timestamp)),
|
|
103
|
-
cached: entries.some(e => e.cached),
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const eMap = new Map<string, ErrorEntry[]>()
|
|
108
|
-
for (const e of re) { const k = `${e.type}:${e.message}`; const a = eMap.get(k) || []; a.push(e); eMap.set(k, a) }
|
|
109
|
-
|
|
110
|
-
const errors: ErrorMetrics[] = Array.from(eMap.entries()).map(([, entries]) => ({
|
|
111
|
-
type: entries[0].type, message: entries[0].message, stack: entries[0].stack,
|
|
112
|
-
count: entries.length, firstSeen: Math.min(...entries.map(e => e.timestamp)),
|
|
113
|
-
lastSeen: Math.max(...entries.map(e => e.timestamp)), affectedUsers: 1,
|
|
114
|
-
}))
|
|
115
|
-
|
|
116
|
-
const pageLoads: PageLoadMetrics[] = rp
|
|
117
|
-
let score = 100
|
|
118
|
-
if (cache.hitRate < 80) score -= 20
|
|
119
|
-
if (queries.some(q => q.avgDuration > 1000)) score -= 15
|
|
120
|
-
if (errors.length > 0) score -= Math.min(errors.length * 5, 30)
|
|
121
|
-
if (pageLoads.some(p => p.lcp > 2500)) score -= 15
|
|
122
|
-
|
|
123
|
-
return { cache, queries, pageLoads, errors, score: Math.max(0, score), timeRange: { start, end } }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
static clear(): void {
|
|
127
|
-
PerformanceMonitor.queries = []; PerformanceMonitor.cacheEntries = []; PerformanceMonitor.errors = []; PerformanceMonitor.pageLoads = []
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
static exportMetrics(): string {
|
|
131
|
-
const end = Date.now()
|
|
132
|
-
return JSON.stringify(PerformanceMonitor.getMetrics({ start: end - 86400000, end }), null, 2)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/perf-solidjs — src/types.ts
|
|
2
|
-
// Self-contained perf types (same as perf-react)
|
|
3
|
-
|
|
4
|
-
export interface CacheMetrics {
|
|
5
|
-
totalRequests: number
|
|
6
|
-
hits: number
|
|
7
|
-
misses: number
|
|
8
|
-
hitRate: number
|
|
9
|
-
avgHitTime: number
|
|
10
|
-
avgMissTime: number
|
|
11
|
-
cacheSize?: number
|
|
12
|
-
evictions?: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface QueryMetrics {
|
|
16
|
-
queryKey: string
|
|
17
|
-
executions: number
|
|
18
|
-
avgDuration: number
|
|
19
|
-
minDuration: number
|
|
20
|
-
maxDuration: number
|
|
21
|
-
errors: number
|
|
22
|
-
lastExecuted: number
|
|
23
|
-
cached: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface PageLoadMetrics {
|
|
27
|
-
route: string
|
|
28
|
-
ttfb: number
|
|
29
|
-
fcp: number
|
|
30
|
-
lcp: number
|
|
31
|
-
tti: number
|
|
32
|
-
loadTime: number
|
|
33
|
-
ssr: boolean
|
|
34
|
-
timestamp: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ErrorMetrics {
|
|
38
|
-
type: string
|
|
39
|
-
message: string
|
|
40
|
-
stack?: string
|
|
41
|
-
count: number
|
|
42
|
-
firstSeen: number
|
|
43
|
-
lastSeen: number
|
|
44
|
-
affectedUsers: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface PerformanceMetrics {
|
|
48
|
-
cache: CacheMetrics
|
|
49
|
-
queries: QueryMetrics[]
|
|
50
|
-
pageLoads: PageLoadMetrics[]
|
|
51
|
-
errors: ErrorMetrics[]
|
|
52
|
-
score: number
|
|
53
|
-
timeRange: { start: number; end: number }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PerformanceConfig {
|
|
57
|
-
enableCacheTracking?: boolean
|
|
58
|
-
enableQueryTracking?: boolean
|
|
59
|
-
enablePageLoadTracking?: boolean
|
|
60
|
-
enableErrorTracking?: boolean
|
|
61
|
-
sampleRate?: number
|
|
62
|
-
maxMetrics?: number
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface CacheHitEvent {
|
|
66
|
-
queryKey: string
|
|
67
|
-
duration: number
|
|
68
|
-
timestamp: number
|
|
69
|
-
cacheType: 'ssr' | 'client' | 'memory'
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface CacheMissEvent {
|
|
73
|
-
queryKey: string
|
|
74
|
-
duration: number
|
|
75
|
-
timestamp: number
|
|
76
|
-
cacheType: 'ssr' | 'client' | 'memory'
|
|
77
|
-
fetchDuration: number
|
|
78
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"jsx": "preserve",
|
|
7
|
-
"jsxImportSource": "solid-js",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationDir": "./dist",
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"src"
|
|
21
|
-
],
|
|
22
|
-
"exclude": [
|
|
23
|
-
"node_modules",
|
|
24
|
-
"dist"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: { index: 'src/index.ts' },
|
|
5
|
-
format: ['esm'],
|
|
6
|
-
dts: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
outDir: 'dist',
|
|
9
|
-
sourcemap: true,
|
|
10
|
-
external: ['solid-js', 'solid-js/web', 'solid-js/store'],
|
|
11
|
-
esbuildOptions(options) {
|
|
12
|
-
options.jsx = 'preserve'
|
|
13
|
-
},
|
|
14
|
-
})
|