react-scanner-ui 0.0.8 ā 0.0.9
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/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +17 -20
- package/dist/server/index.js.map +1 -1
- package/dist/utils/config.js +5 -5
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/scannerConfig.d.ts +3 -7
- package/dist/utils/scannerConfig.d.ts.map +1 -1
- package/dist/utils/scannerConfig.js +25 -50
- package/dist/utils/scannerConfig.js.map +1 -1
- package/package.json +1 -2
- package/ui/components/ComponentTable.css +116 -28
- package/ui/components/ComponentTable.tsx +60 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgE7D"}
|
package/dist/server/index.js
CHANGED
|
@@ -32,14 +32,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.startServer = startServer;
|
|
40
37
|
const http_1 = require("http");
|
|
41
38
|
const path_1 = require("path");
|
|
42
|
-
const polka_1 = __importDefault(require("polka"));
|
|
43
39
|
const scannerConfig_1 = require("../utils/scannerConfig");
|
|
44
40
|
/**
|
|
45
41
|
* Get the path to the UI directory.
|
|
@@ -57,14 +53,6 @@ function getUiRoot() {
|
|
|
57
53
|
* (similar approach to Storybook's builder-vite)
|
|
58
54
|
*/
|
|
59
55
|
async function startServer(port) {
|
|
60
|
-
const server = (0, http_1.createServer)();
|
|
61
|
-
const app = (0, polka_1.default)({ server });
|
|
62
|
-
// API endpoint to get scan data (served before Vite middleware)
|
|
63
|
-
app.get("/api/scan-data", (_req, res) => {
|
|
64
|
-
res.setHeader("Content-Type", "application/json");
|
|
65
|
-
const result = (0, scannerConfig_1.getScanData)();
|
|
66
|
-
res.end(JSON.stringify(result));
|
|
67
|
-
});
|
|
68
56
|
// Dynamically import Vite to create dev server in middleware mode
|
|
69
57
|
const { createServer: createViteServer } = await Promise.resolve().then(() => __importStar(require("vite")));
|
|
70
58
|
const uiRoot = getUiRoot();
|
|
@@ -73,14 +61,23 @@ async function startServer(port) {
|
|
|
73
61
|
configFile: (0, path_1.resolve)(uiRoot, "vite.config.ts"),
|
|
74
62
|
server: {
|
|
75
63
|
middlewareMode: true,
|
|
76
|
-
hmr: {
|
|
77
|
-
server,
|
|
78
|
-
},
|
|
79
64
|
},
|
|
80
65
|
appType: "spa",
|
|
81
66
|
});
|
|
82
|
-
//
|
|
83
|
-
|
|
67
|
+
// Create HTTP server with manual routing
|
|
68
|
+
const server = (0, http_1.createServer)((req, res) => {
|
|
69
|
+
const url = req.url || "";
|
|
70
|
+
// Handle API routes FIRST - before Vite middleware
|
|
71
|
+
if (url === "/api/scan-data" || url.startsWith("/api/scan-data?")) {
|
|
72
|
+
res.setHeader("Content-Type", "application/json");
|
|
73
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
74
|
+
const result = (0, scannerConfig_1.getScanData)();
|
|
75
|
+
res.end(JSON.stringify(result));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Pass everything else to Vite
|
|
79
|
+
vite.middlewares(req, res);
|
|
80
|
+
});
|
|
84
81
|
// Handle server errors
|
|
85
82
|
server.on("error", (err) => {
|
|
86
83
|
console.error("Server error:", err);
|
|
@@ -96,13 +93,13 @@ async function startServer(port) {
|
|
|
96
93
|
};
|
|
97
94
|
process.on("SIGINT", shutdown);
|
|
98
95
|
process.on("SIGTERM", shutdown);
|
|
99
|
-
return new Promise((
|
|
96
|
+
return new Promise((resolvePromise, reject) => {
|
|
100
97
|
server.on("error", reject);
|
|
101
|
-
|
|
98
|
+
server.listen(port, "127.0.0.1", () => {
|
|
102
99
|
console.log(`\nš React Scanner UI is running at http://localhost:${port}\n`);
|
|
103
100
|
console.log(" ā Hot Module Replacement enabled");
|
|
104
101
|
console.log(" ā Press Ctrl+C to stop the server.\n");
|
|
105
|
-
|
|
102
|
+
resolvePromise();
|
|
106
103
|
});
|
|
107
104
|
});
|
|
108
105
|
}
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,kCAgEC;AAzFD,+BAIc;AACd,+BAA+B;AAC/B,0DAAqD;AAErD;;;GAGG;AACH,SAAS,SAAS;IAChB,qDAAqD;IACrD,kCAAkC;IAClC,MAAM,UAAU,GAAG,SAAS,CAAC;IAE7B,8EAA8E;IAC9E,OAAO,IAAA,cAAO,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,kEAAkE;IAClE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,wDAAa,MAAM,GAAC,CAAC;IAEhE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC;QAClC,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,IAAA,cAAO,EAAC,MAA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C;IAClB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEhC,OAAO,IAAI,OAAO,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAE3B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;YACpC,OAAO,CAAC,GAAG,CACT,wDAAwD,IAAI,IAAI,CACjE,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;YACxD,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/utils/config.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.createReactScannerConfig = createReactScannerConfig;
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
function createReactScannerConfig() {
|
|
7
|
-
const configPath = (0, path_1.join)(process.cwd(),
|
|
7
|
+
const configPath = (0, path_1.join)(process.cwd(), "react-scanner.config.js");
|
|
8
8
|
if ((0, fs_1.existsSync)(configPath)) {
|
|
9
|
-
console.log(
|
|
9
|
+
console.log("react-scanner.config.js already exists.");
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
const configContent = `module.exports = {
|
|
@@ -14,16 +14,16 @@ function createReactScannerConfig() {
|
|
|
14
14
|
includeSubComponents: true,
|
|
15
15
|
importedFrom: 'PLACEHOLDER_FOR_IMPORTED_FROM',
|
|
16
16
|
processors: [
|
|
17
|
-
['
|
|
17
|
+
['count-components-and-props', { outputTo: './.react-scanner-ui/scan-report.json' }],
|
|
18
18
|
],
|
|
19
19
|
};
|
|
20
20
|
`;
|
|
21
21
|
try {
|
|
22
22
|
(0, fs_1.writeFileSync)(configPath, configContent);
|
|
23
|
-
console.log(
|
|
23
|
+
console.log("Created react-scanner.config.js");
|
|
24
24
|
}
|
|
25
25
|
catch (error) {
|
|
26
|
-
console.error(
|
|
26
|
+
console.error("Failed to create react-scanner.config.js", error);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=config.js.map
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { isReactScannerInstalled, checkPeerDependency, promptInstallReactScanner
|
|
|
2
2
|
export { createReactScannerConfig } from "./config";
|
|
3
3
|
export { getServerPort, isPortAvailable } from "./port";
|
|
4
4
|
export type { PortOptions } from "./port";
|
|
5
|
-
export { readScannerConfig,
|
|
5
|
+
export { readScannerConfig, readScanData, getScanData } from "./scannerConfig";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getScanData = exports.readScanData = exports.
|
|
3
|
+
exports.getScanData = exports.readScanData = exports.readScannerConfig = exports.isPortAvailable = exports.getServerPort = exports.createReactScannerConfig = exports.installReactScanner = exports.promptInstallReactScanner = exports.checkPeerDependency = exports.isReactScannerInstalled = void 0;
|
|
4
4
|
var dependencies_1 = require("./dependencies");
|
|
5
5
|
Object.defineProperty(exports, "isReactScannerInstalled", { enumerable: true, get: function () { return dependencies_1.isReactScannerInstalled; } });
|
|
6
6
|
Object.defineProperty(exports, "checkPeerDependency", { enumerable: true, get: function () { return dependencies_1.checkPeerDependency; } });
|
|
@@ -13,8 +13,6 @@ Object.defineProperty(exports, "getServerPort", { enumerable: true, get: functio
|
|
|
13
13
|
Object.defineProperty(exports, "isPortAvailable", { enumerable: true, get: function () { return port_1.isPortAvailable; } });
|
|
14
14
|
var scannerConfig_1 = require("./scannerConfig");
|
|
15
15
|
Object.defineProperty(exports, "readScannerConfig", { enumerable: true, get: function () { return scannerConfig_1.readScannerConfig; } });
|
|
16
|
-
Object.defineProperty(exports, "getOutputDir", { enumerable: true, get: function () { return scannerConfig_1.getOutputDir; } });
|
|
17
|
-
Object.defineProperty(exports, "getLatestScanFile", { enumerable: true, get: function () { return scannerConfig_1.getLatestScanFile; } });
|
|
18
16
|
Object.defineProperty(exports, "readScanData", { enumerable: true, get: function () { return scannerConfig_1.readScanData; } });
|
|
19
17
|
Object.defineProperty(exports, "getScanData", { enumerable: true, get: function () { return scannerConfig_1.getScanData; } });
|
|
20
18
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,+CAKwB;AAJtB,uHAAA,uBAAuB,OAAA;AACvB,mHAAA,mBAAmB,OAAA;AACnB,yHAAA,yBAAyB,OAAA;AACzB,mHAAA,mBAAmB,OAAA;AAErB,mCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,+BAAwD;AAA/C,qGAAA,aAAa,OAAA;AAAE,uGAAA,eAAe,OAAA;AAEvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,+CAKwB;AAJtB,uHAAA,uBAAuB,OAAA;AACvB,mHAAA,mBAAmB,OAAA;AACnB,yHAAA,yBAAyB,OAAA;AACzB,mHAAA,mBAAmB,OAAA;AAErB,mCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,+BAAwD;AAA/C,qGAAA,aAAa,OAAA;AAAE,uGAAA,eAAe,OAAA;AAEvC,iDAA+E;AAAtE,kHAAA,iBAAiB,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,4GAAA,WAAW,OAAA"}
|
|
@@ -3,7 +3,7 @@ export interface ScannerConfig {
|
|
|
3
3
|
includeSubComponents?: boolean;
|
|
4
4
|
importedFrom?: string;
|
|
5
5
|
processors?: Array<[string, {
|
|
6
|
-
|
|
6
|
+
outputTo?: string;
|
|
7
7
|
}]>;
|
|
8
8
|
}
|
|
9
9
|
export interface ScanData {
|
|
@@ -17,13 +17,9 @@ export interface ScanData {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function readScannerConfig(): ScannerConfig | null;
|
|
19
19
|
/**
|
|
20
|
-
* Get the output
|
|
20
|
+
* Get the output file path from the scanner config
|
|
21
21
|
*/
|
|
22
|
-
export declare function
|
|
23
|
-
/**
|
|
24
|
-
* Get the latest scan file from the output directory
|
|
25
|
-
*/
|
|
26
|
-
export declare function getLatestScanFile(outputDir: string): string | null;
|
|
22
|
+
export declare function getOutputFile(config: ScannerConfig): string | null;
|
|
27
23
|
/**
|
|
28
24
|
* Read and parse the scan data from a JSON file
|
|
29
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scannerConfig.d.ts","sourceRoot":"","sources":["../../src/utils/scannerConfig.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE;QAAE,
|
|
1
|
+
{"version":3,"file":"scannerConfig.d.ts","sourceRoot":"","sources":["../../src/utils/scannerConfig.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,aAAa,EAAE,MAAM,GAAG;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,aAAa,GAAG,IAAI,CAmBxD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAgBlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAgB9D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI;IAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAqB7E"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readScannerConfig = readScannerConfig;
|
|
4
|
-
exports.
|
|
5
|
-
exports.getLatestScanFile = getLatestScanFile;
|
|
4
|
+
exports.getOutputFile = getOutputFile;
|
|
6
5
|
exports.readScanData = readScanData;
|
|
7
6
|
exports.getScanData = getScanData;
|
|
8
7
|
const fs_1 = require("fs");
|
|
@@ -11,9 +10,9 @@ const path_1 = require("path");
|
|
|
11
10
|
* Read and parse the react-scanner.config.js file
|
|
12
11
|
*/
|
|
13
12
|
function readScannerConfig() {
|
|
14
|
-
const configPath = (0, path_1.join)(process.cwd(),
|
|
13
|
+
const configPath = (0, path_1.join)(process.cwd(), "react-scanner.config.js");
|
|
15
14
|
if (!(0, fs_1.existsSync)(configPath)) {
|
|
16
|
-
console.error(
|
|
15
|
+
console.error("react-scanner.config.js not found. Run `react-scanner-ui init` first.");
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
18
|
try {
|
|
@@ -23,65 +22,42 @@ function readScannerConfig() {
|
|
|
23
22
|
return config;
|
|
24
23
|
}
|
|
25
24
|
catch (error) {
|
|
26
|
-
console.error(
|
|
25
|
+
console.error("Failed to read react-scanner.config.js:", error);
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
|
-
* Get the output
|
|
30
|
+
* Get the output file path from the scanner config
|
|
32
31
|
*/
|
|
33
|
-
function
|
|
32
|
+
function getOutputFile(config) {
|
|
34
33
|
if (!config.processors || !Array.isArray(config.processors)) {
|
|
35
34
|
return null;
|
|
36
35
|
}
|
|
37
36
|
for (const processor of config.processors) {
|
|
38
|
-
if (Array.isArray(processor) &&
|
|
39
|
-
|
|
37
|
+
if (Array.isArray(processor) &&
|
|
38
|
+
processor[0] === "count-components-and-props" &&
|
|
39
|
+
processor[1]?.outputTo) {
|
|
40
|
+
return processor[1].outputTo;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Get the latest scan file from the output directory
|
|
46
|
-
*/
|
|
47
|
-
function getLatestScanFile(outputDir) {
|
|
48
|
-
const absoluteOutputDir = (0, path_1.resolve)(process.cwd(), outputDir);
|
|
49
|
-
if (!(0, fs_1.existsSync)(absoluteOutputDir)) {
|
|
50
|
-
console.error(`Scan output directory not found: ${absoluteOutputDir}`);
|
|
51
|
-
console.error('Run react-scanner first to generate scan data.');
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const files = (0, fs_1.readdirSync)(absoluteOutputDir)
|
|
56
|
-
.filter((file) => file.endsWith('.json'))
|
|
57
|
-
.map((file) => ({
|
|
58
|
-
name: file,
|
|
59
|
-
path: (0, path_1.join)(absoluteOutputDir, file),
|
|
60
|
-
mtime: (0, fs_1.statSync)((0, path_1.join)(absoluteOutputDir, file)).mtime,
|
|
61
|
-
}))
|
|
62
|
-
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
63
|
-
if (files.length === 0) {
|
|
64
|
-
console.error('No scan files found in output directory.');
|
|
65
|
-
console.error('Run react-scanner first to generate scan data.');
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return files[0].path;
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.error('Failed to read scan output directory:', error);
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
45
|
/**
|
|
76
46
|
* Read and parse the scan data from a JSON file
|
|
77
47
|
*/
|
|
78
48
|
function readScanData(filePath) {
|
|
49
|
+
const absolutePath = (0, path_1.resolve)(process.cwd(), filePath);
|
|
50
|
+
if (!(0, fs_1.existsSync)(absolutePath)) {
|
|
51
|
+
console.error(`Scan data file not found: ${absolutePath}`);
|
|
52
|
+
console.error("Run react-scanner first to generate scan data.");
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
79
55
|
try {
|
|
80
|
-
const content = (0, fs_1.readFileSync)(
|
|
56
|
+
const content = (0, fs_1.readFileSync)(absolutePath, "utf-8");
|
|
81
57
|
return JSON.parse(content);
|
|
82
58
|
}
|
|
83
59
|
catch (error) {
|
|
84
|
-
console.error(
|
|
60
|
+
console.error("Failed to read scan data:", error);
|
|
85
61
|
return null;
|
|
86
62
|
}
|
|
87
63
|
}
|
|
@@ -91,19 +67,18 @@ function readScanData(filePath) {
|
|
|
91
67
|
function getScanData() {
|
|
92
68
|
const config = readScannerConfig();
|
|
93
69
|
if (!config) {
|
|
94
|
-
return { data: null, error:
|
|
95
|
-
}
|
|
96
|
-
const outputDir = getOutputDir(config);
|
|
97
|
-
if (!outputDir) {
|
|
98
|
-
return { data: null, error: 'Could not find output directory in config. Make sure you have a raw-report processor configured.' };
|
|
70
|
+
return { data: null, error: "Could not read react-scanner.config.js" };
|
|
99
71
|
}
|
|
100
|
-
const scanFile =
|
|
72
|
+
const scanFile = getOutputFile(config);
|
|
101
73
|
if (!scanFile) {
|
|
102
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
data: null,
|
|
76
|
+
error: "Could not find output file in config. Make sure you have a count-components-and-props processor configured with outputTo.",
|
|
77
|
+
};
|
|
103
78
|
}
|
|
104
79
|
const data = readScanData(scanFile);
|
|
105
80
|
if (!data) {
|
|
106
|
-
return { data: null, error:
|
|
81
|
+
return { data: null, error: "Failed to parse scan data." };
|
|
107
82
|
}
|
|
108
83
|
return { data, error: null };
|
|
109
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scannerConfig.js","sourceRoot":"","sources":["../../src/utils/scannerConfig.ts"],"names":[],"mappings":";;AAoBA,
|
|
1
|
+
{"version":3,"file":"scannerConfig.js","sourceRoot":"","sources":["../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AAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-scanner-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-scanner-ui": "dist/index.js"
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"@vitejs/plugin-react": "^4.3.4",
|
|
28
28
|
"commander": "^14.0.2",
|
|
29
29
|
"detect-port": "^1.6.1",
|
|
30
|
-
"polka": "^0.5.2",
|
|
31
30
|
"react": "^18.3.1",
|
|
32
31
|
"react-dom": "^18.3.1",
|
|
33
32
|
"vite": "^5.4.19"
|
|
@@ -1,61 +1,149 @@
|
|
|
1
1
|
.component-table {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
width: 100%;
|
|
3
|
+
border-collapse: collapse;
|
|
4
|
+
background-color: var(--color-bg-card);
|
|
5
|
+
box-shadow: var(--shadow-sm);
|
|
6
|
+
border-radius: var(--radius-md);
|
|
7
|
+
overflow: hidden;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.component-table th,
|
|
11
11
|
.component-table td {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
padding: 12px 16px;
|
|
13
|
+
text-align: left;
|
|
14
|
+
border-bottom: 1px solid var(--color-border);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.component-table th {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
background-color: var(--color-bg-header);
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
color: var(--color-text);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
user-select: none;
|
|
23
|
+
transition: background-color 0.15s ease;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.component-table th:hover {
|
|
27
|
-
|
|
27
|
+
background-color: #e9ecef;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.component-table th .sort-indicator {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
margin-left: 5px;
|
|
32
|
+
color: var(--color-text-muted);
|
|
33
|
+
font-size: 0.75em;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.component-table tbody tr:last-child td {
|
|
37
|
-
|
|
37
|
+
border-bottom: none;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.component-table tbody tr:hover td {
|
|
41
|
-
|
|
41
|
+
background-color: var(--color-bg-hover);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.component-table .count {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
font-family: var(--font-mono);
|
|
46
|
+
font-weight: 500;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.component-table .total-row {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
font-weight: 600;
|
|
51
|
+
background-color: var(--color-bg-total);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
.component-table .total-row td {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
border-top: 2px solid var(--color-border-strong);
|
|
56
|
+
border-bottom: none;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.component-table .total-row:hover td {
|
|
60
|
-
|
|
60
|
+
background-color: var(--color-bg-total);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Expandable rows */
|
|
64
|
+
.clickable-row {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
transition: background-color 0.15s ease;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.clickable-row.has-props:hover td {
|
|
70
|
+
background-color: var(--color-bg-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.clickable-row.expanded td {
|
|
74
|
+
background-color: var(--color-bg-hover);
|
|
75
|
+
border-bottom: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.expand-icon {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
width: 16px;
|
|
81
|
+
margin-right: 8px;
|
|
82
|
+
font-size: 0.7em;
|
|
83
|
+
color: var(--color-text-muted);
|
|
84
|
+
transition: transform 0.2s ease;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.expand-icon.expanded {
|
|
88
|
+
transform: rotate(90deg);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Props row */
|
|
92
|
+
.props-row td {
|
|
93
|
+
padding: 8px 16px 16px 16px;
|
|
94
|
+
background-color: var(--color-bg-hover);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.props-container {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: flex-start;
|
|
100
|
+
gap: 12px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.props-label {
|
|
104
|
+
font-size: 0.85em;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
color: var(--color-text-muted);
|
|
107
|
+
padding-top: 4px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.props-chips {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-wrap: wrap;
|
|
113
|
+
gap: 8px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.prop-chip {
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 6px;
|
|
120
|
+
padding: 4px 10px;
|
|
121
|
+
background-color: var(--color-bg-card);
|
|
122
|
+
border: 1px solid var(--color-border);
|
|
123
|
+
border-radius: 16px;
|
|
124
|
+
font-size: 0.85em;
|
|
125
|
+
color: var(--color-text);
|
|
126
|
+
transition:
|
|
127
|
+
background-color 0.15s ease,
|
|
128
|
+
border-color 0.15s ease;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.prop-chip:hover {
|
|
132
|
+
background-color: var(--color-bg-header);
|
|
133
|
+
border-color: var(--color-border-strong);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.prop-count {
|
|
137
|
+
display: inline-flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
min-width: 20px;
|
|
141
|
+
height: 20px;
|
|
142
|
+
padding: 0 6px;
|
|
143
|
+
background-color: var(--color-primary, #4a90d9);
|
|
144
|
+
color: white;
|
|
145
|
+
border-radius: 10px;
|
|
146
|
+
font-size: 0.8em;
|
|
147
|
+
font-weight: 600;
|
|
148
|
+
font-family: var(--font-mono);
|
|
61
149
|
}
|
|
@@ -19,6 +19,7 @@ export function ComponentTable({ data }: ComponentTableProps) {
|
|
|
19
19
|
key: "count",
|
|
20
20
|
direction: "desc",
|
|
21
21
|
});
|
|
22
|
+
const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());
|
|
22
23
|
|
|
23
24
|
const handleSort = (key: SortKey) => {
|
|
24
25
|
setSortConfig((prev) => ({
|
|
@@ -32,10 +33,23 @@ export function ComponentTable({ data }: ComponentTableProps) {
|
|
|
32
33
|
return sortConfig.direction === "asc" ? "ā²" : "ā¼";
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const toggleRow = (name: string) => {
|
|
37
|
+
setExpandedRows((prev) => {
|
|
38
|
+
const next = new Set(prev);
|
|
39
|
+
if (next.has(name)) {
|
|
40
|
+
next.delete(name);
|
|
41
|
+
} else {
|
|
42
|
+
next.add(name);
|
|
43
|
+
}
|
|
44
|
+
return next;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
35
48
|
// Transform data into array and sort
|
|
36
49
|
const components = Object.entries(data).map(([name, info]) => ({
|
|
37
50
|
name,
|
|
38
|
-
count: info.instances
|
|
51
|
+
count: info.instances,
|
|
52
|
+
props: info.props || {},
|
|
39
53
|
}));
|
|
40
54
|
|
|
41
55
|
components.sort((a, b) => {
|
|
@@ -63,7 +77,7 @@ export function ComponentTable({ data }: ComponentTableProps) {
|
|
|
63
77
|
<span className="sort-indicator">{getSortIndicator("name")}</span>
|
|
64
78
|
</th>
|
|
65
79
|
<th onClick={() => handleSort("count")}>
|
|
66
|
-
Count
|
|
80
|
+
Usage Count
|
|
67
81
|
<span className="sort-indicator">
|
|
68
82
|
{getSortIndicator("count")}
|
|
69
83
|
</span>
|
|
@@ -71,12 +85,50 @@ export function ComponentTable({ data }: ComponentTableProps) {
|
|
|
71
85
|
</tr>
|
|
72
86
|
</thead>
|
|
73
87
|
<tbody>
|
|
74
|
-
{components.map((component) =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
{components.map((component) => {
|
|
89
|
+
const isExpanded = expandedRows.has(component.name);
|
|
90
|
+
const hasProps = Object.keys(component.props).length > 0;
|
|
91
|
+
const sortedProps = Object.entries(component.props).sort(
|
|
92
|
+
([, a], [, b]) => b - a,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<>
|
|
97
|
+
<tr
|
|
98
|
+
key={component.name}
|
|
99
|
+
onClick={() => toggleRow(component.name)}
|
|
100
|
+
className={`clickable-row ${isExpanded ? "expanded" : ""} ${hasProps ? "has-props" : ""}`}
|
|
101
|
+
>
|
|
102
|
+
<td className="component-name">
|
|
103
|
+
<span
|
|
104
|
+
className={`expand-icon ${isExpanded ? "expanded" : ""}`}
|
|
105
|
+
>
|
|
106
|
+
{hasProps ? "ā¶" : ""}
|
|
107
|
+
</span>
|
|
108
|
+
{component.name}
|
|
109
|
+
</td>
|
|
110
|
+
<td className="count">{component.count}</td>
|
|
111
|
+
</tr>
|
|
112
|
+
{isExpanded && hasProps && (
|
|
113
|
+
<tr key={`${component.name}-props`} className="props-row">
|
|
114
|
+
<td colSpan={2}>
|
|
115
|
+
<div className="props-container">
|
|
116
|
+
<span className="props-label">Props:</span>
|
|
117
|
+
<div className="props-chips">
|
|
118
|
+
{sortedProps.map(([propName, propCount]) => (
|
|
119
|
+
<span key={propName} className="prop-chip">
|
|
120
|
+
{propName}
|
|
121
|
+
<span className="prop-count">{propCount}</span>
|
|
122
|
+
</span>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</td>
|
|
127
|
+
</tr>
|
|
128
|
+
)}
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
})}
|
|
80
132
|
<tr className="total-row">
|
|
81
133
|
<td>Total</td>
|
|
82
134
|
<td className="count">{totalCount}</td>
|