react-doctor-cli-dev 1.0.9 → 1.0.12

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.
Files changed (38) hide show
  1. package/dashboard/index.html +253 -0
  2. package/dashboard/package-lock.json +913 -0
  3. package/dashboard/package.json +19 -0
  4. package/dashboard/public/favicon.svg +1 -0
  5. package/dashboard/public/icons.svg +24 -0
  6. package/dashboard/src/api.js +107 -0
  7. package/dashboard/src/assets/hero.png +0 -0
  8. package/dashboard/src/assets/javascript.svg +1 -0
  9. package/dashboard/src/assets/vite.svg +1 -0
  10. package/dashboard/src/css/main.css +441 -0
  11. package/dashboard/src/data.js +202 -0
  12. package/dashboard/src/main.js +53 -0
  13. package/dashboard/src/pages.js +797 -0
  14. package/dashboard/src/router.js +77 -0
  15. package/dashboard/src/utils.js +163 -0
  16. package/dashboard/vite.config.js +19 -0
  17. package/data/screenshots/5-docs-fullLoad.png +0 -0
  18. package/data/screenshots/6--fcp.png +0 -0
  19. package/data/screenshots/6--fullLoad.png +0 -0
  20. package/data/screenshots/6-white-fullLoad.png +0 -0
  21. package/package.json +4 -22
  22. package/shared/dist/index.d.ts +2 -0
  23. package/shared/dist/index.js +19 -0
  24. package/shared/dist/schemas.d.ts +91 -0
  25. package/shared/dist/schemas.js +82 -0
  26. package/shared/dist/types.d.ts +44 -0
  27. package/shared/dist/types.js +2 -0
  28. package/shared/package-lock.json +47 -0
  29. package/shared/package.json +21 -0
  30. package/shared/src/index.ts +4 -0
  31. package/shared/src/schemas.ts +136 -0
  32. package/shared/src/types.ts +137 -0
  33. package/shared/tsconfig.json +15 -0
  34. package/tsconfig.json +25 -0
  35. /package/{backend/data/screenshots/4--fcp.png → data/screenshots/5--fcp.png} +0 -0
  36. /package/{backend/data/screenshots/4--fullLoad.png → data/screenshots/5--fullLoad.png} +0 -0
  37. /package/{backend/data/screenshots/4-white-fullLoad.png → data/screenshots/5-white-fullLoad.png} +0 -0
  38. /package/{backend/data/screenshots/4-docs-fullLoad.png → data/screenshots/6-docs-fullLoad.png} +0 -0
@@ -0,0 +1,136 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // STATIC ANALYSIS TYPES
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ /**
6
+ * A single issue found in a React component by the static analyzer.
7
+ */
8
+ export interface ComponentIssue {
9
+ id: string; // e.g. "large-component-App.tsx-12"
10
+ component: string; // e.g. "UserDashboard"
11
+ file: string; // file path
12
+ line: number; // line number where issue was found
13
+ column?: number; // column number (optional)
14
+ severity: "critical" | "warning" | "info";
15
+ message: string; // what's wrong
16
+ suggestion: string; // how to fix it
17
+ }
18
+
19
+ /**
20
+ * Full report produced by the Static Analyzer.
21
+ * Saved to: core/reports/staticreport.json
22
+ */
23
+ export interface StaticReport {
24
+ timestamp: string;
25
+ componentCount: number;
26
+ filesAnalyzed: number;
27
+ filesFailed: number;
28
+ issues: ComponentIssue[];
29
+ grade: string;
30
+ }
31
+
32
+ // ─────────────────────────────────────────────────────────────
33
+ // RUNTIME PROFILER TYPES
34
+ // ─────────────────────────────────────────────────────────────
35
+
36
+ /**
37
+ * The 5 Core Web Vitals collected by the web-vitals library.
38
+ * All timing values are in milliseconds except CLS (a score).
39
+ *
40
+ * LCP — Largest Contentful Paint → good: < 2500ms
41
+ * FCP — First Contentful Paint → good: < 1800ms
42
+ * CLS — Cumulative Layout Shift → good: < 0.1
43
+ * INP — Interaction to Next Paint → good: < 200ms
44
+ * TTFB — Time to First Byte → good: < 800ms
45
+ */
46
+ export interface WebVitals {
47
+ lcp: number;
48
+ fcp: number;
49
+ cls: number;
50
+ inp: number;
51
+ ttfb: number;
52
+ }
53
+
54
+ /**
55
+ * System-level resource stats collected via Puppeteer and
56
+ * the browser's native Performance API.
57
+ *
58
+ * domNodes: number of HTML elements in the page
59
+ * jsHeapMB: JavaScript heap memory used (MB as string with 2 decimals)
60
+ * payloadMB: total network payload transferred (MB as string)
61
+ * topOffender: the single heaviest file downloaded — name and size in MB
62
+ */
63
+ export interface SystemStats {
64
+ domNodes: number;
65
+ jsHeapMB: string;
66
+ payloadMB: string;
67
+ topOffender: {
68
+ name: string;
69
+ size: number;
70
+ } | null;
71
+ }
72
+
73
+ /**
74
+ * Full runtime profiling report for a single route.
75
+ * Saved to: core/reports/runtimereport.json
76
+ *
77
+ * metrics: the 5 core web vitals
78
+ * rerenders: how many times each component re-rendered
79
+ * key = component name, value = render count
80
+ * e.g. { "UserDashboard": 12, "Button": 3 }
81
+ * commitDurations: how long each React commit took in ms
82
+ * a commit = one full render + reconcile + paint cycle
83
+ * e.g. [4.2, 1.1, 8.7]
84
+ * renderTime: total time from navigation start to networkidle0 in ms
85
+ * stats: system-level resource usage
86
+ * deviceType: which device preset was used for this audit
87
+ */
88
+ export interface RuntimeReport {
89
+ timestamp: string;
90
+ url: string;
91
+ deviceType: "desktop" | "mobile";
92
+ metrics: WebVitals;
93
+ rerenders: Record<string, number>;
94
+ commitDurations: number[];
95
+ renderTime: number;
96
+ stats: SystemStats;
97
+ }
98
+
99
+ // ─────────────────────────────────────────────────────────────
100
+ // RULE ENGINE TYPES
101
+ // ─────────────────────────────────────────────────────────────
102
+
103
+ /**
104
+ * A suggestion produced by the Rule Engine after reading
105
+ * both the static and runtime reports.
106
+ *
107
+ * Example:
108
+ * IF LCP > 2500 AND component uses <img> without lazy loading
109
+ * THEN suggest: "Use lazy loading for images in Home.tsx"
110
+ */
111
+ export interface Suggestion {
112
+ id: string;
113
+ title: string;
114
+ description: string;
115
+ severity: "critical" | "warning" | "info";
116
+ affectedComponent?: string;
117
+ fix: string;
118
+ }
119
+
120
+ // ─────────────────────────────────────────────────────────────
121
+ // FINAL COMBINED REPORT
122
+ // ─────────────────────────────────────────────────────────────
123
+
124
+ /**
125
+ * The complete report that the Report Compiler builds by merging
126
+ * static analysis + runtime profiling + rule engine suggestions.
127
+ * This is what gets sent to the backend API and shown in the dashboard.
128
+ */
129
+ export interface FinalReport {
130
+ projectName: string;
131
+ analyzedAt: string;
132
+ static: StaticReport;
133
+ runtime: Record<string, RuntimeReport>; // keyed by route: "/" | "/about" | etc.
134
+ suggestions: Suggestion[];
135
+ performanceScore: number; // 0–100
136
+ }
@@ -0,0 +1,137 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // STATIC ANALYSIS TYPES
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ export interface ComponentIssue {
6
+ id: string;
7
+ component: string;
8
+ file: string;
9
+ line: number;
10
+ column?: number;
11
+ severity: "critical" | "warning" | "info";
12
+ message: string;
13
+ suggestion: string;
14
+ }
15
+
16
+ export interface StaticReport {
17
+ timestamp: string;
18
+ componentCount: number;
19
+ filesAnalyzed: number;
20
+ filesFailed: number;
21
+ issues: ComponentIssue[];
22
+ grade: string;
23
+ }
24
+
25
+ // ─────────────────────────────────────────────────────────────
26
+ // RUNTIME PROFILER TYPES
27
+ // ─────────────────────────────────────────────────────────────
28
+
29
+ export interface WebVitals {
30
+ lcp: number; // Largest Contentful Paint — good: < 2500ms
31
+ fcp: number; // First Contentful Paint — good: < 1800ms
32
+ cls: number; // Cumulative Layout Shift — good: < 0.1
33
+ inp: number; // Interaction to Next Paint — good: < 200ms
34
+ ttfb: number; // Time to First Byte — good: < 800ms
35
+ }
36
+
37
+ export interface SystemStats {
38
+ domNodes: number;
39
+ jsHeapMB: string;
40
+ payloadMB: string;
41
+ topOffender: { name: string; size: number } | null;
42
+ }
43
+
44
+ /**
45
+ * A JS error or React console warning captured during page load.
46
+ *
47
+ * type: "error" — uncaught JS exception or console.error()
48
+ * "warning" — console.warn() — usually React warnings like
49
+ * "Each child in a list should have a unique key"
50
+ *
51
+ * message: the full error/warning text
52
+ * source: "pageerror" (uncaught exception) | "console" (console.error/warn)
53
+ */
54
+ export interface PageError {
55
+ type: "error" | "warning";
56
+ message: string;
57
+ source: "pageerror" | "console";
58
+ }
59
+
60
+ /**
61
+ * A screenshot taken at a specific moment during page load.
62
+ *
63
+ * label: human-readable name — "fcp", "lcp", "fullLoad"
64
+ * dataUrl: base64-encoded PNG prefixed with "data:image/png;base64,"
65
+ * Ready to use directly as an <img src="..."> in the dashboard.
66
+ * takenAt: ms since navigation start when the screenshot was taken
67
+ */
68
+ export interface Screenshot {
69
+ label: string;
70
+ dataUrl: string;
71
+ takenAt: number;
72
+ }
73
+
74
+ /**
75
+ * Full runtime profiling report for a single route + device combination.
76
+ *
77
+ * NEW fields added:
78
+ * performanceScore — 0–100 overall score weighted from all metrics
79
+ * errors — JS errors and React warnings captured during load
80
+ * screenshots — visual filmstrip: FCP moment, LCP moment, full load
81
+ * cpuThrottling — which CPU throttle preset was active (1 = none, 4 = slow)
82
+ */
83
+ export interface RuntimeReport {
84
+ timestamp: string;
85
+ url: string;
86
+ deviceType: "desktop" | "mobile";
87
+
88
+ // Web vitals
89
+ metrics: WebVitals;
90
+
91
+ // React profiler
92
+ rerenders: Record<string, number>;
93
+ commitDurations: number[];
94
+ renderTime: number;
95
+
96
+ // System stats
97
+ stats: SystemStats;
98
+
99
+ // NEW: performance score
100
+ performanceScore: number;
101
+
102
+ // NEW: JS errors and console warnings
103
+ errors: PageError[];
104
+
105
+ // NEW: screenshots at key moments
106
+ screenshots: Screenshot[];
107
+
108
+ // NEW: which CPU throttle was active (1 = real speed, 4 = 4x slowdown)
109
+ cpuThrottling: number;
110
+ networkThrottle: string;
111
+ }
112
+
113
+ // ─────────────────────────────────────────────────────────────
114
+ // RULE ENGINE TYPES
115
+ // ─────────────────────────────────────────────────────────────
116
+
117
+ export interface Suggestion {
118
+ id: string;
119
+ title: string;
120
+ description: string;
121
+ severity: "critical" | "warning" | "info";
122
+ affectedComponent?: string;
123
+ fix: string;
124
+ }
125
+
126
+ // ─────────────────────────────────────────────────────────────
127
+ // FINAL COMBINED REPORT
128
+ // ─────────────────────────────────────────────────────────────
129
+
130
+ export interface FinalReport {
131
+ projectName: string;
132
+ analyzedAt: string;
133
+ static: StaticReport;
134
+ runtime: Record<string, RuntimeReport>;
135
+ suggestions: Suggestion[];
136
+ performanceScore: number;
137
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "skipLibCheck": true
12
+ },
13
+ "include": ["src/**/*"],
14
+ "exclude": ["node_modules", "dist"]
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "resolveJsonModule": true,
12
+ "forceConsistentCasingInFileNames": true
13
+ },
14
+ "include": [
15
+ "core/**/*",
16
+ "shared/**/*"
17
+ ],
18
+ "exclude": [
19
+ "node_modules",
20
+ "dist",
21
+ "cli",
22
+ "frontend",
23
+ "backend"
24
+ ]
25
+ }