react-native-bundle-discovery-ui 2.6.0 → 2.7.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/CHANGELOG.md +7 -0
- package/README.md +168 -117
- package/assets/global.css +171 -0
- package/dist/bin.js +271 -0
- package/dist/client/_virtual/_rolldown/runtime.js +37 -0
- package/{pages → dist/client/pages}/_common.js +13 -26
- package/{pages → dist/client/pages}/default.js +24 -34
- package/{pages → dist/client/pages}/module.js +6 -19
- package/{pages → dist/client/pages}/package.js +13 -61
- package/dist/client/prepare.js +63 -0
- package/{queryHelpers.js → dist/client/queryHelpers.js} +75 -126
- package/dist/client/setup.js +9 -0
- package/dist/client/views/_theme.js +18 -0
- package/{views → dist/client/views}/foamtree.js +14 -47
- package/dist/client/views/highcharts.js +33 -0
- package/{views → dist/client/views}/prettify.js +2 -0
- package/dist/discoveryrc.js +26 -0
- package/dist/rolldown-runtime-VH7oDXx4.js +42 -0
- package/{lib → dist}/rsdoctor.js +27 -74
- package/{lib/isRsdoctorReport.js → dist/src-BSLX-He2.js} +19 -16
- package/package.json +27 -28
- package/.discoveryrc.js +0 -22
- package/lib/bin.js +0 -94
- package/lib/build.js +0 -123
- package/lib/server.js +0 -90
- package/prepare.js +0 -102
- package/setup.js +0 -12
- package/views/_theme.js +0 -35
- package/views/global.css +0 -169
- package/views/highcharts.js +0 -43
- /package/{views → assets}/highcharts.css +0 -0
package/dist/bin.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
|
|
3
|
+
const require_src = require("./src-BSLX-He2.js");
|
|
4
|
+
const require_discoveryrc = require("./discoveryrc.js");
|
|
5
|
+
let minimist = require("minimist");
|
|
6
|
+
minimist = require_rolldown_runtime.__toESM(minimist);
|
|
7
|
+
let node_fs = require("node:fs");
|
|
8
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
9
|
+
let node_path = require("node:path");
|
|
10
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
11
|
+
let _discoveryjs_cli = require("@discoveryjs/cli");
|
|
12
|
+
let chalk = require("chalk");
|
|
13
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
14
|
+
let _discoveryjs_cli_lib_shared_utils_js = require("@discoveryjs/cli/lib/shared/utils.js");
|
|
15
|
+
//#region src/build.ts
|
|
16
|
+
function buildHtmlPage(filePath, output, clean, singleFile, verbose) {
|
|
17
|
+
if (verbose)
|
|
18
|
+
console.info(
|
|
19
|
+
`Building HTML page from file: ${chalk.default.green(filePath)} options: ${JSON.stringify(
|
|
20
|
+
{
|
|
21
|
+
output,
|
|
22
|
+
clean,
|
|
23
|
+
singleFile,
|
|
24
|
+
},
|
|
25
|
+
null,
|
|
26
|
+
2,
|
|
27
|
+
)}`,
|
|
28
|
+
);
|
|
29
|
+
if (!filePath) {
|
|
30
|
+
console.error(
|
|
31
|
+
`Usage: '${chalk.default.green("npx react-native-bundle-discovery build <path-to-file>")}', Please provide a path to a JSON file.`,
|
|
32
|
+
);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
|
|
36
|
+
if (verbose)
|
|
37
|
+
console.info(
|
|
38
|
+
`Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`,
|
|
39
|
+
);
|
|
40
|
+
let fullJsonPath;
|
|
41
|
+
try {
|
|
42
|
+
fullJsonPath = require.resolve(jsonFilePath);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error(
|
|
45
|
+
`❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`,
|
|
46
|
+
);
|
|
47
|
+
console.error(err.message);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
|
|
51
|
+
if (verbose)
|
|
52
|
+
console.info(
|
|
53
|
+
`Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`,
|
|
54
|
+
);
|
|
55
|
+
const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
|
|
56
|
+
node_fs.default.writeFileSync(
|
|
57
|
+
configFile,
|
|
58
|
+
`const {transformRSDoctorData} = require("${transformRcdoctor}");
|
|
59
|
+
module.exports = ${JSON.stringify(
|
|
60
|
+
{
|
|
61
|
+
...require_discoveryrc,
|
|
62
|
+
data: "<tmp>",
|
|
63
|
+
},
|
|
64
|
+
null,
|
|
65
|
+
1,
|
|
66
|
+
).replace(
|
|
67
|
+
`"<tmp>"`,
|
|
68
|
+
require_src.isRsdoctorReportPath(fullJsonPath)
|
|
69
|
+
? `() => transformRSDoctorData(require("${fullJsonPath}"))`
|
|
70
|
+
: `() => require("${fullJsonPath}")`,
|
|
71
|
+
)};`,
|
|
72
|
+
);
|
|
73
|
+
if (verbose)
|
|
74
|
+
console.info(`Building HTML page with options:`, {
|
|
75
|
+
output,
|
|
76
|
+
clean,
|
|
77
|
+
singleFile,
|
|
78
|
+
});
|
|
79
|
+
const _config = {
|
|
80
|
+
name: "Bundle Discovery",
|
|
81
|
+
mode: "single",
|
|
82
|
+
colorScheme: "auto",
|
|
83
|
+
download: true,
|
|
84
|
+
upload: false,
|
|
85
|
+
embed: false,
|
|
86
|
+
encodings: false,
|
|
87
|
+
};
|
|
88
|
+
const _options = {
|
|
89
|
+
singleFile,
|
|
90
|
+
clean,
|
|
91
|
+
output,
|
|
92
|
+
cache: true,
|
|
93
|
+
cachedir: node_path.default.resolve(__dirname, "./.discoveryjs-cache"),
|
|
94
|
+
checkCacheTtl: false,
|
|
95
|
+
minify: true,
|
|
96
|
+
dataCompression: true,
|
|
97
|
+
sourcemap: false,
|
|
98
|
+
embed: "by-config",
|
|
99
|
+
experimentalJsonxl: false,
|
|
100
|
+
scriptFormat: "esm",
|
|
101
|
+
scriptExternal: [],
|
|
102
|
+
data: true,
|
|
103
|
+
excludeModelOnDataFail: false,
|
|
104
|
+
prettyData: false,
|
|
105
|
+
modelDownload: false,
|
|
106
|
+
modelDataUpload: true,
|
|
107
|
+
modelResetCache: false,
|
|
108
|
+
serveOnlyAssets: true,
|
|
109
|
+
dev: true,
|
|
110
|
+
config: configFile,
|
|
111
|
+
configFile,
|
|
112
|
+
};
|
|
113
|
+
return (0, _discoveryjs_cli.build)(_options, _config, configFile).then(() => {
|
|
114
|
+
console.log(`========================================`);
|
|
115
|
+
console.log(
|
|
116
|
+
`✅ HTML page built successfully at: ${chalk.default.green(node_path.default.resolve(output, "index.html").replace(`${process.cwd()}/`, ""))}`,
|
|
117
|
+
);
|
|
118
|
+
console.log(`========================================`);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/server.ts
|
|
123
|
+
function serve(filePath, port, verbose) {
|
|
124
|
+
const PORT = process.env.PORT || port;
|
|
125
|
+
if (verbose)
|
|
126
|
+
console.info(
|
|
127
|
+
`start server with file: ${filePath} on port: ${port} ${process.env.PORT ? `(${chalk.default.yellow("PORT")} env)` : ""}`,
|
|
128
|
+
);
|
|
129
|
+
if (!filePath) {
|
|
130
|
+
console.error(
|
|
131
|
+
`Usage: '${chalk.default.green("npx react-native-bundle-discovery server <path-to-file>")}', Please provide a path to a JSON file.`,
|
|
132
|
+
);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
const jsonFilePath = node_path.default.resolve(process.cwd(), filePath);
|
|
136
|
+
if (verbose)
|
|
137
|
+
console.info(
|
|
138
|
+
`Loading JSON file from: ${chalk.default.green(jsonFilePath)}, base directory: ${chalk.default.green(process.cwd())}`,
|
|
139
|
+
);
|
|
140
|
+
let fullJsonPath;
|
|
141
|
+
try {
|
|
142
|
+
fullJsonPath = require.resolve(jsonFilePath);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error(
|
|
145
|
+
`❌Error loading file: ${chalk.default.red(jsonFilePath)}\n\n`,
|
|
146
|
+
);
|
|
147
|
+
console.error(err.message);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
const configFile = node_path.default.resolve(__dirname, "./.tmp.js");
|
|
151
|
+
if (verbose)
|
|
152
|
+
console.info(
|
|
153
|
+
`Creating temporary config file at: ${chalk.default.green(configFile)}, for discovery.js`,
|
|
154
|
+
);
|
|
155
|
+
const transformRcdoctor = node_path.default.join(__dirname, "rsdoctor.js");
|
|
156
|
+
node_fs.default.writeFileSync(
|
|
157
|
+
configFile,
|
|
158
|
+
`const {transformRSDoctorData} = require("${transformRcdoctor}");
|
|
159
|
+
module.exports = ${JSON.stringify(
|
|
160
|
+
{
|
|
161
|
+
...require_discoveryrc,
|
|
162
|
+
data: "<tmp>",
|
|
163
|
+
},
|
|
164
|
+
null,
|
|
165
|
+
1,
|
|
166
|
+
).replace(
|
|
167
|
+
`"<tmp>"`,
|
|
168
|
+
require_src.isRsdoctorReportPath(fullJsonPath)
|
|
169
|
+
? `() => transformRSDoctorData(require("${fullJsonPath}"))`
|
|
170
|
+
: `() => require("${fullJsonPath}")`,
|
|
171
|
+
)};`,
|
|
172
|
+
);
|
|
173
|
+
if (verbose)
|
|
174
|
+
console.info(
|
|
175
|
+
`Running server with config: ${chalk.default.green(configFile)}`,
|
|
176
|
+
);
|
|
177
|
+
return (0, _discoveryjs_cli_lib_shared_utils_js.silent)(() =>
|
|
178
|
+
(0, _discoveryjs_cli.createServer)({
|
|
179
|
+
cache: false,
|
|
180
|
+
minify: true,
|
|
181
|
+
dev: false,
|
|
182
|
+
config: configFile,
|
|
183
|
+
configFile,
|
|
184
|
+
}).then((server) =>
|
|
185
|
+
server.listen(PORT, () => {
|
|
186
|
+
console.log(
|
|
187
|
+
`[react-native-bundle-discovery]: 🚀 Server listen on ${chalk.default.green.underline(chalk.default.green(`http://localhost:${PORT}`))}`,
|
|
188
|
+
);
|
|
189
|
+
}),
|
|
190
|
+
),
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/bin.ts
|
|
195
|
+
function printHelp() {
|
|
196
|
+
console.log(`react-native-bundle-discovery-ui
|
|
197
|
+
|
|
198
|
+
Usage:
|
|
199
|
+
react-native-bundle-discovery-ui <file> [port] [--verbose] # <- server can be omitted
|
|
200
|
+
react-native-bundle-discovery-ui server <file> [port] [--verbose]
|
|
201
|
+
|
|
202
|
+
react-native-bundle-discovery-ui build <file> [--output <path>] [--clean] [--single-file] [--verbose]
|
|
203
|
+
|
|
204
|
+
Commands:
|
|
205
|
+
server <file> [port] Run a web server to show a Metro bundler stat report
|
|
206
|
+
build <file> Build a HTML report from the Metro bundler stat file
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
-v, --verbose Run with verbose logging
|
|
210
|
+
-o, --output <path> Path for a build result (default: .bundle-discovery)
|
|
211
|
+
-c, --clean Clean output directory before writing build files (default: true)
|
|
212
|
+
-s, --single-file Output report build as a single HTML file (default: true)
|
|
213
|
+
-p, --port <port> Port for server command (same as [port], default: 8079)
|
|
214
|
+
-h, --help Show help
|
|
215
|
+
`);
|
|
216
|
+
}
|
|
217
|
+
function fail(message) {
|
|
218
|
+
console.error(message);
|
|
219
|
+
console.error("Use --help to see usage.");
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
function main() {
|
|
223
|
+
const argv = (0, minimist.default)(process.argv.slice(2), {
|
|
224
|
+
alias: {
|
|
225
|
+
v: "verbose",
|
|
226
|
+
h: "help",
|
|
227
|
+
o: "output",
|
|
228
|
+
c: "clean",
|
|
229
|
+
s: "single-file",
|
|
230
|
+
p: "port",
|
|
231
|
+
},
|
|
232
|
+
boolean: ["verbose", "help", "clean", "single-file"],
|
|
233
|
+
string: ["output"],
|
|
234
|
+
default: {
|
|
235
|
+
clean: true,
|
|
236
|
+
"single-file": true,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
const command = argv._[0];
|
|
240
|
+
const isServerCommand = command === "server";
|
|
241
|
+
const isBuildCommand = command === "build";
|
|
242
|
+
const isImplicitServerCommand =
|
|
243
|
+
Boolean(command) && !isServerCommand && !isBuildCommand;
|
|
244
|
+
if (argv.help || !command) {
|
|
245
|
+
printHelp();
|
|
246
|
+
process.exit(0);
|
|
247
|
+
}
|
|
248
|
+
if (isServerCommand || isImplicitServerCommand) {
|
|
249
|
+
const file = isImplicitServerCommand ? argv._[0] : argv._[1];
|
|
250
|
+
if (!file) fail("Missing required argument: <file>");
|
|
251
|
+
const rawPort =
|
|
252
|
+
argv.port ?? (isImplicitServerCommand ? argv._[1] : argv._[2]) ?? 8079;
|
|
253
|
+
const port = Number(rawPort);
|
|
254
|
+
if (!Number.isFinite(port)) fail(`Invalid port: ${rawPort}`);
|
|
255
|
+
return serve(file, port, Boolean(argv.verbose));
|
|
256
|
+
}
|
|
257
|
+
if (isBuildCommand) {
|
|
258
|
+
const file = argv._[1];
|
|
259
|
+
if (!file) fail("Missing required argument: <file>");
|
|
260
|
+
return buildHtmlPage(
|
|
261
|
+
file,
|
|
262
|
+
argv.output,
|
|
263
|
+
argv.clean,
|
|
264
|
+
argv["single-file"],
|
|
265
|
+
Boolean(argv.verbose),
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
fail(`Unknown command: ${command}`);
|
|
269
|
+
}
|
|
270
|
+
main();
|
|
271
|
+
//#endregion
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if ((from && typeof from === "object") || typeof from === "function")
|
|
10
|
+
for (
|
|
11
|
+
var keys = __getOwnPropNames(from), i = 0, n = keys.length, key;
|
|
12
|
+
i < n;
|
|
13
|
+
i++
|
|
14
|
+
) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (
|
|
25
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
26
|
+
__copyProps(
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default")
|
|
28
|
+
? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
})
|
|
32
|
+
: target,
|
|
33
|
+
mod,
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.__toESM = __toESM;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/client/pages/_common.ts
|
|
1
3
|
const platformColor = `transformOptions.platform = 'android' ? 'rgba(194, 239, 116, .4)' : 'rgba(119, 31, 218, .4)'`;
|
|
2
|
-
|
|
3
4
|
function getPackage(entry) {
|
|
4
5
|
return `
|
|
5
6
|
$packages: $.packages;
|
|
@@ -29,15 +30,12 @@ function getPackage(entry) {
|
|
|
29
30
|
}),
|
|
30
31
|
}))`;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
33
|
const metadataTooltip = {
|
|
34
34
|
view: "text",
|
|
35
35
|
when: "metadata.createdAt",
|
|
36
36
|
data: "'Published ' + metadata.createdAt.formatDate() + ' (' + metadata.createdAt.timeAgo() + ')'",
|
|
37
37
|
};
|
|
38
38
|
const outdatedColor = "rgba(255, 165, 0, 0.35)";
|
|
39
|
-
|
|
40
|
-
// Compact npm metadata badges (`metadata` from the report)
|
|
41
39
|
function getMetadataBadges({
|
|
42
40
|
deprecated,
|
|
43
41
|
outdated,
|
|
@@ -66,7 +64,6 @@ function getMetadataBadges({
|
|
|
66
64
|
: null,
|
|
67
65
|
].filter(Boolean);
|
|
68
66
|
}
|
|
69
|
-
|
|
70
67
|
function getPackageList({
|
|
71
68
|
data,
|
|
72
69
|
itemPkgName,
|
|
@@ -88,7 +85,6 @@ function getPackageList({
|
|
|
88
85
|
itemPkgName,
|
|
89
86
|
"text: ' '",
|
|
90
87
|
"pill-badge:{ text: size.formatBytes(), color: 'rgba(120, 177, 9, 0.35)' }",
|
|
91
|
-
// Summary of all instances (visible when the tree is collapsed)
|
|
92
88
|
...getMetadataBadges({
|
|
93
89
|
deprecated: "pkgInstances.metadata.deprecated[0]",
|
|
94
90
|
outdated: "pkgInstances.[metadata and not metadata.isLatest]",
|
|
@@ -113,7 +109,6 @@ function getPackageList({
|
|
|
113
109
|
view: "tree-leaf",
|
|
114
110
|
limit: subLimit,
|
|
115
111
|
content: [
|
|
116
|
-
//
|
|
117
112
|
"text:pkgName",
|
|
118
113
|
"text:' '",
|
|
119
114
|
{
|
|
@@ -144,7 +139,6 @@ function getPackageList({
|
|
|
144
139
|
},
|
|
145
140
|
};
|
|
146
141
|
}
|
|
147
|
-
|
|
148
142
|
function getTreeModule({ hasTextMatch = false, hasPercent = false } = {}) {
|
|
149
143
|
return [
|
|
150
144
|
"pill-badge:{ text: ext, color: ext.getExtColor() }",
|
|
@@ -177,9 +171,7 @@ function getTreeModule({ hasTextMatch = false, hasPercent = false } = {}) {
|
|
|
177
171
|
].filter(Boolean);
|
|
178
172
|
}
|
|
179
173
|
function getModulesTree({ data, limit }) {
|
|
180
|
-
if (!data)
|
|
181
|
-
throw new Error("[getModulesTree]: data is required");
|
|
182
|
-
}
|
|
174
|
+
if (!data) throw new Error("[getModulesTree]: data is required");
|
|
183
175
|
return {
|
|
184
176
|
view: "content-filter",
|
|
185
177
|
data,
|
|
@@ -250,7 +242,6 @@ function getModulesTree({ data, limit }) {
|
|
|
250
242
|
},
|
|
251
243
|
};
|
|
252
244
|
}
|
|
253
|
-
|
|
254
245
|
const metadata = {
|
|
255
246
|
platform: {
|
|
256
247
|
when: "transformOptions.platform",
|
|
@@ -288,9 +279,7 @@ const metadata = {
|
|
|
288
279
|
data: "{ prefix: 'Minify: ', text: transformOptions.minify }",
|
|
289
280
|
},
|
|
290
281
|
};
|
|
291
|
-
|
|
292
282
|
const externalLinkHtml = `<svg class="my-icon my-icon-link" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" ><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"></path></svg>`;
|
|
293
|
-
|
|
294
283
|
function getCopyToClipboardButton({ textToCopy, className, text }) {
|
|
295
284
|
return {
|
|
296
285
|
view: "button",
|
|
@@ -303,22 +292,20 @@ function getCopyToClipboardButton({ textToCopy, className, text }) {
|
|
|
303
292
|
.writeText(data.textToCopy)
|
|
304
293
|
.then(() => {
|
|
305
294
|
elm.classList.add("done");
|
|
306
|
-
elm.__timer = setTimeout(() => elm.classList.remove("done"),
|
|
295
|
+
elm.__timer = setTimeout(() => elm.classList.remove("done"), 2e3);
|
|
307
296
|
})
|
|
308
297
|
.catch(() => {
|
|
309
298
|
elm.classList.add("err");
|
|
310
|
-
elm.__timer = setTimeout(() => elm.classList.remove("err"),
|
|
299
|
+
elm.__timer = setTimeout(() => elm.classList.remove("err"), 2e3);
|
|
311
300
|
});
|
|
312
301
|
},
|
|
313
302
|
};
|
|
314
303
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
metadata,
|
|
324
|
-
};
|
|
304
|
+
//#endregion
|
|
305
|
+
exports.externalLinkHtml = externalLinkHtml;
|
|
306
|
+
exports.getCopyToClipboardButton = getCopyToClipboardButton;
|
|
307
|
+
exports.getModulesTree = getModulesTree;
|
|
308
|
+
exports.getPackage = getPackage;
|
|
309
|
+
exports.getPackageList = getPackageList;
|
|
310
|
+
exports.getTreeModule = getTreeModule;
|
|
311
|
+
exports.metadata = metadata;
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
getModulesTree,
|
|
4
|
-
getPackage,
|
|
5
|
-
getPackageList,
|
|
6
|
-
getCopyToClipboardButton,
|
|
7
|
-
} = require("./_common");
|
|
8
|
-
|
|
1
|
+
const require_pages__common = require("./_common.js");
|
|
2
|
+
//#region src/client/pages/default.ts
|
|
9
3
|
const topMetaData = [
|
|
10
|
-
metadata.platform,
|
|
11
|
-
metadata.size,
|
|
12
|
-
metadata.source_code_size,
|
|
13
|
-
metadata.node_modules_size,
|
|
14
|
-
metadata.is_dev,
|
|
15
|
-
metadata.is_minified,
|
|
4
|
+
require_pages__common.metadata.platform,
|
|
5
|
+
require_pages__common.metadata.size,
|
|
6
|
+
require_pages__common.metadata.source_code_size,
|
|
7
|
+
require_pages__common.metadata.node_modules_size,
|
|
8
|
+
require_pages__common.metadata.is_dev,
|
|
9
|
+
require_pages__common.metadata.is_minified,
|
|
16
10
|
];
|
|
17
|
-
|
|
18
11
|
const TABS = {
|
|
19
12
|
TREEMAP_FOAMTREE: "treemap-foamtree",
|
|
20
13
|
MODULES: "modules",
|
|
21
14
|
PACKAGES: "packages",
|
|
22
15
|
DUPLICATES: "duplicates",
|
|
23
16
|
};
|
|
24
|
-
|
|
25
17
|
function parseHashRef(url = window.location.href) {
|
|
26
18
|
return new URL(url).hash.split(":")?.[1];
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
discovery.page.define("default", [
|
|
30
21
|
...topMetaData,
|
|
31
|
-
|
|
32
22
|
{
|
|
33
23
|
view: "tabs",
|
|
34
24
|
name: "mainTabs",
|
|
@@ -64,26 +54,28 @@ discovery.page.define("default", [
|
|
|
64
54
|
],
|
|
65
55
|
content: {
|
|
66
56
|
view: "switch",
|
|
67
|
-
context(
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
context(_data, context) {
|
|
58
|
+
const isHashChangeEvent = /* @__PURE__ */ new Error("").stack.includes(
|
|
59
|
+
"Promise.all",
|
|
60
|
+
);
|
|
70
61
|
discovery.overridePageHashStateWithAnchor({
|
|
71
62
|
id: "default",
|
|
72
63
|
ref: isHashChangeEvent ? discovery.pageRef : context.mainTabs,
|
|
73
64
|
});
|
|
74
65
|
discovery.cancelScheduledRender();
|
|
75
|
-
|
|
76
66
|
const id = discovery.pageRef ?? TABS.TREEMAP_FOAMTREE;
|
|
77
|
-
|
|
78
67
|
setTimeout(() => {
|
|
79
68
|
discovery.dom.root
|
|
80
69
|
.querySelectorAll(".main-tabs>div>.onclick")
|
|
81
|
-
.forEach((e) =>
|
|
70
|
+
.forEach((e) => {
|
|
71
|
+
e.classList.remove("active");
|
|
72
|
+
});
|
|
82
73
|
discovery.dom.root
|
|
83
74
|
.querySelectorAll(`.main-tabs .main-tabs-${id}`)
|
|
84
|
-
.forEach((e) =>
|
|
75
|
+
.forEach((e) => {
|
|
76
|
+
e.classList.add("active");
|
|
77
|
+
});
|
|
85
78
|
}, 50);
|
|
86
|
-
|
|
87
79
|
return {
|
|
88
80
|
...context,
|
|
89
81
|
id,
|
|
@@ -119,7 +111,7 @@ discovery.page.define("default", [
|
|
|
119
111
|
},
|
|
120
112
|
{
|
|
121
113
|
when: `#.id="${TABS.MODULES}"`,
|
|
122
|
-
content: getModulesTree({
|
|
114
|
+
content: require_pages__common.getModulesTree({
|
|
123
115
|
limit: 200,
|
|
124
116
|
data: `
|
|
125
117
|
$entryPoint: $.entryPointPath;
|
|
@@ -142,7 +134,7 @@ discovery.page.define("default", [
|
|
|
142
134
|
{
|
|
143
135
|
when: `#.id="${TABS.PACKAGES}"`,
|
|
144
136
|
content: [
|
|
145
|
-
getCopyToClipboardButton({
|
|
137
|
+
require_pages__common.getCopyToClipboardButton({
|
|
146
138
|
text: "Copy list",
|
|
147
139
|
className: "copy-before-ask-chatgpt",
|
|
148
140
|
textToCopy: `"- " + modules.filter(=> path has "node_modules").group(=> path.getModulesName()).map(=> $.key).join("\\n- ")`,
|
|
@@ -158,11 +150,10 @@ discovery.page.define("default", [
|
|
|
158
150
|
},
|
|
159
151
|
{
|
|
160
152
|
view: "content-filter",
|
|
161
|
-
|
|
162
|
-
data: `${getPackage(`modules.filter(=> path has "node_modules")`)}.sort(pkgInstances desc, size desc)`,
|
|
153
|
+
data: `${require_pages__common.getPackage(`modules.filter(=> path has "node_modules")`)}.sort(pkgInstances desc, size desc)`,
|
|
163
154
|
className: "packages-content",
|
|
164
155
|
name: "filterByPathStr",
|
|
165
|
-
content: getPackageList({
|
|
156
|
+
content: require_pages__common.getPackageList({
|
|
166
157
|
showCopiesBadge: true,
|
|
167
158
|
expanded: false,
|
|
168
159
|
limit: 200,
|
|
@@ -183,7 +174,7 @@ discovery.page.define("default", [
|
|
|
183
174
|
},
|
|
184
175
|
{
|
|
185
176
|
when: `#.id="${TABS.DUPLICATES}"`,
|
|
186
|
-
content: getModulesTree({
|
|
177
|
+
content: require_pages__common.getModulesTree({
|
|
187
178
|
data: `
|
|
188
179
|
// values
|
|
189
180
|
$duplicatesOnly: modules.filter(=> duplicates);
|
|
@@ -206,6 +197,5 @@ discovery.page.define("default", [
|
|
|
206
197
|
],
|
|
207
198
|
},
|
|
208
199
|
},
|
|
209
|
-
|
|
210
|
-
// END
|
|
211
200
|
]);
|
|
201
|
+
//#endregion
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
getTreeModule,
|
|
4
|
-
getCopyToClipboardButton,
|
|
5
|
-
} = require("./_common");
|
|
6
|
-
|
|
1
|
+
const require_pages__common = require("./_common.js");
|
|
2
|
+
//#region src/client/pages/module.ts
|
|
7
3
|
function getMetroWarn({ when, href, linkText, content }) {
|
|
8
4
|
return {
|
|
9
5
|
view: "alert-warning",
|
|
@@ -24,7 +20,6 @@ function getMetroWarn({ when, href, linkText, content }) {
|
|
|
24
20
|
].filter(Boolean),
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
discovery.page.define("module", {
|
|
29
24
|
view: "context",
|
|
30
25
|
data: `{
|
|
@@ -39,20 +34,17 @@ discovery.page.define("module", {
|
|
|
39
34
|
{
|
|
40
35
|
view: "h2",
|
|
41
36
|
content: [
|
|
42
|
-
//
|
|
43
37
|
'text: "Module: "',
|
|
44
38
|
"text: $.currentModule.path",
|
|
45
|
-
getCopyToClipboardButton({
|
|
39
|
+
require_pages__common.getCopyToClipboardButton({
|
|
46
40
|
textToCopy: `$.currentModule.path`,
|
|
47
41
|
className: "m-l-0_5em",
|
|
48
42
|
}),
|
|
49
43
|
],
|
|
50
44
|
},
|
|
51
|
-
|
|
52
45
|
{
|
|
53
46
|
view: "tabs",
|
|
54
47
|
name: "tabs",
|
|
55
|
-
// value: "networkGraph", //FIXME
|
|
56
48
|
tabs: [
|
|
57
49
|
{
|
|
58
50
|
value: "mcontent",
|
|
@@ -191,11 +183,6 @@ discovery.page.define("module", {
|
|
|
191
183
|
isGraphTooBig: $tmp.data.size() > $limit,
|
|
192
184
|
}`,
|
|
193
185
|
content: [
|
|
194
|
-
// TODO use for debugging
|
|
195
|
-
// {
|
|
196
|
-
// view: "struct",
|
|
197
|
-
// expanded: 2,
|
|
198
|
-
// },
|
|
199
186
|
{
|
|
200
187
|
when: "isGraphTooBig",
|
|
201
188
|
view: "block",
|
|
@@ -262,7 +249,6 @@ discovery.page.define("module", {
|
|
|
262
249
|
},
|
|
263
250
|
}`,
|
|
264
251
|
},
|
|
265
|
-
|
|
266
252
|
{
|
|
267
253
|
view: "block",
|
|
268
254
|
content: [
|
|
@@ -286,7 +272,7 @@ discovery.page.define("module", {
|
|
|
286
272
|
view: "tree",
|
|
287
273
|
expanded: false,
|
|
288
274
|
itemConfig: {
|
|
289
|
-
content: getTreeModule({
|
|
275
|
+
content: require_pages__common.getTreeModule({
|
|
290
276
|
hasTextMatch: true,
|
|
291
277
|
}),
|
|
292
278
|
children: `$.children`,
|
|
@@ -304,7 +290,7 @@ discovery.page.define("module", {
|
|
|
304
290
|
},
|
|
305
291
|
{
|
|
306
292
|
when: '#.tabs="mduplicates"',
|
|
307
|
-
content: getModulesTree({
|
|
293
|
+
content: require_pages__common.getModulesTree({
|
|
308
294
|
data: `
|
|
309
295
|
$totalSize: modules.sum(=>output.sizeInBytes);
|
|
310
296
|
$toModule: => {
|
|
@@ -322,3 +308,4 @@ discovery.page.define("module", {
|
|
|
322
308
|
},
|
|
323
309
|
],
|
|
324
310
|
});
|
|
311
|
+
//#endregion
|