react-native-bundle-discovery-ui 2.7.0 → 2.9.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 +32 -0
- package/README.md +12 -227
- package/assets/global.css +769 -53
- package/dist/bin.js +61 -16
- package/dist/client/issues.js +5 -0
- package/dist/client/pages/_common.js +258 -86
- package/dist/client/pages/_module.js +347 -0
- package/dist/client/pages/default.js +145 -62
- package/dist/client/pages/module.js +2 -309
- package/dist/client/pages/moduleDiff.js +76 -0
- package/dist/client/pages/package.js +172 -154
- package/dist/client/prepare.js +15 -0
- package/dist/client/queryHelpers.js +445 -81
- package/dist/client/views/{_theme.js → _colorScheme.js} +2 -9
- package/dist/client/views/_html.js +52 -0
- package/dist/client/views/codeDiff.js +66 -0
- package/dist/client/views/compare.js +237 -0
- package/dist/client/views/importGraph.js +255 -0
- package/dist/client/views/insights.js +80 -0
- package/dist/client/views/moduleOverview.js +134 -0
- package/dist/client/views/packageOverview.js +114 -0
- package/dist/client/views/persistedFilterInput.js +27 -0
- package/dist/client/views/reportBar.js +89 -0
- package/dist/client/views/treemap.js +598 -0
- package/dist/discoveryrc.js +26 -7
- package/dist/rsdoctor.js +5 -101
- package/dist/src-Bp8pPQrQ.js +1545 -0
- package/package.json +5 -3
- package/assets/highcharts.css +0 -1
- package/dist/client/_virtual/_rolldown/runtime.js +0 -37
- package/dist/client/views/foamtree.js +0 -103
- package/dist/client/views/highcharts.js +0 -33
- package/dist/src-BSLX-He2.js +0 -36
- package/vendors/foamtree.js +0 -9008
- package/vendors/high-contrast-dark.js +0 -1
- package/vendors/highcharts-exporting.js +0 -13
- package/vendors/highcharts-networkgraph.js +0 -1
- package/vendors/highcharts.js +0 -10
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const require_views__html = require("./_html.js");
|
|
2
|
+
//#region src/client/views/moduleOverview.ts
|
|
3
|
+
function renderHeader(o) {
|
|
4
|
+
const chips = [
|
|
5
|
+
o.pkg
|
|
6
|
+
? require_views__html.chip(
|
|
7
|
+
`${require_views__html.escapeHTML(o.pkg.name)}${o.pkg.version ? ` <b>v${require_views__html.escapeHTML(o.pkg.version)}</b>` : ""}`,
|
|
8
|
+
"pkg",
|
|
9
|
+
discovery.encodePageHash("package", o.pkg.name),
|
|
10
|
+
)
|
|
11
|
+
: o.injectedBy
|
|
12
|
+
? ""
|
|
13
|
+
: require_views__html.chip("Source code", "src"),
|
|
14
|
+
o.injectedBy
|
|
15
|
+
? require_views__html.chip(`Injected by ${o.injectedBy}`, "warn")
|
|
16
|
+
: "",
|
|
17
|
+
o.pkg?.metadata?.deprecated
|
|
18
|
+
? require_views__html.chip("Deprecated", "danger")
|
|
19
|
+
: "",
|
|
20
|
+
o.pkg?.metadata && !o.pkg.metadata.isLatest && o.pkg.metadata.latestVersion
|
|
21
|
+
? require_views__html.chip(
|
|
22
|
+
`Latest v${require_views__html.escapeHTML(o.pkg.metadata.latestVersion)}`,
|
|
23
|
+
"warn",
|
|
24
|
+
)
|
|
25
|
+
: "",
|
|
26
|
+
o.isEntry ? require_views__html.chip("Entry point", "entry") : "",
|
|
27
|
+
o.duplicates
|
|
28
|
+
? require_views__html.chip(`Duplicated ×${o.duplicates + 1}`, "danger")
|
|
29
|
+
: "",
|
|
30
|
+
].join("");
|
|
31
|
+
return `
|
|
32
|
+
<div class="mo-header">
|
|
33
|
+
<span class="mo-ext" style="background:${extColor(o.ext)}">${require_views__html.escapeHTML(o.ext)}</span>
|
|
34
|
+
<div class="mo-title">
|
|
35
|
+
<div class="mo-dir">${require_views__html.escapeHTML(o.dir)}</div>
|
|
36
|
+
<div class="mo-file">${require_views__html.escapeHTML(o.file)}</div>
|
|
37
|
+
<div class="mo-chips">${chips}</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>`;
|
|
40
|
+
}
|
|
41
|
+
function extColor(ext) {
|
|
42
|
+
const colors = {
|
|
43
|
+
js: "#f1e05a",
|
|
44
|
+
ts: "#3178c6",
|
|
45
|
+
tsx: "#3178c6",
|
|
46
|
+
json: "#e34c26",
|
|
47
|
+
svg: "#e69f0d",
|
|
48
|
+
css: "#563d7c",
|
|
49
|
+
png: "#e44b23",
|
|
50
|
+
};
|
|
51
|
+
return `${colors[ext] ?? colors.js}55`;
|
|
52
|
+
}
|
|
53
|
+
function renderCards(o) {
|
|
54
|
+
const delta = o.sourceSize ? o.outputSize / o.sourceSize - 1 : 0;
|
|
55
|
+
const deltaText =
|
|
56
|
+
delta === 0
|
|
57
|
+
? "unchanged by transform"
|
|
58
|
+
: delta < 0
|
|
59
|
+
? `<span class="mo-good">${require_views__html.formatPercent(-delta)} smaller</span> after transform`
|
|
60
|
+
: `<span class="mo-bad">${require_views__html.formatPercent(delta)} larger</span> after transform`;
|
|
61
|
+
const otherPackages = o.importerPackages - (o.importedByOwnCode ? 1 : 0);
|
|
62
|
+
const importers = [
|
|
63
|
+
o.importedByOwnCode ? "your code" : "",
|
|
64
|
+
otherPackages > 0
|
|
65
|
+
? require_views__html.plural(otherPackages, "package")
|
|
66
|
+
: "",
|
|
67
|
+
]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.join(" + ");
|
|
70
|
+
return `<div class="mo-cards">${[
|
|
71
|
+
require_views__html.card({
|
|
72
|
+
label: "Output size",
|
|
73
|
+
value: require_views__html.formatBytes(o.outputSize),
|
|
74
|
+
sub: `${require_views__html.formatPercent(o.bundleShare)} of bundle · #${o.rank.toLocaleString()} of ${o.modulesCount.toLocaleString()}`,
|
|
75
|
+
kind: "accent",
|
|
76
|
+
bar: o.largestShare,
|
|
77
|
+
}),
|
|
78
|
+
require_views__html.card({
|
|
79
|
+
label: "Source size",
|
|
80
|
+
value: require_views__html.formatBytes(o.sourceSize),
|
|
81
|
+
sub: o.sourceSize ? deltaText : void 0,
|
|
82
|
+
}),
|
|
83
|
+
require_views__html.card({
|
|
84
|
+
label: "Source lines",
|
|
85
|
+
value: o.sourceLines.toLocaleString(),
|
|
86
|
+
sub:
|
|
87
|
+
o.outputLines > 1
|
|
88
|
+
? `${require_views__html.plural(o.outputLines, "line")} after transform`
|
|
89
|
+
: "minified to a single line",
|
|
90
|
+
}),
|
|
91
|
+
o.pkg
|
|
92
|
+
? require_views__html.card({
|
|
93
|
+
label: "Share of package",
|
|
94
|
+
value: require_views__html.formatPercent(o.pkg.share),
|
|
95
|
+
sub: `of ${require_views__html.escapeHTML(o.pkg.name)} · ${require_views__html.formatBytes(o.pkg.size)} in ${require_views__html.plural(o.pkg.files, "file")}`,
|
|
96
|
+
bar: o.pkg.share,
|
|
97
|
+
})
|
|
98
|
+
: "",
|
|
99
|
+
require_views__html.card({
|
|
100
|
+
label: "Imports",
|
|
101
|
+
value: require_views__html.plural(o.imports.length, "module"),
|
|
102
|
+
sub: o.missingImports
|
|
103
|
+
? `${o.missingImports} not in the bundle`
|
|
104
|
+
: o.imports.length
|
|
105
|
+
? "direct dependencies"
|
|
106
|
+
: "no dependencies",
|
|
107
|
+
}),
|
|
108
|
+
require_views__html.card({
|
|
109
|
+
label: "Imported by",
|
|
110
|
+
value: require_views__html.plural(o.importedBy, "module"),
|
|
111
|
+
sub: o.importedBy
|
|
112
|
+
? `from ${importers}`
|
|
113
|
+
: o.isEntry
|
|
114
|
+
? "entry point"
|
|
115
|
+
: o.injectedBy
|
|
116
|
+
? `loaded by ${o.injectedBy}`
|
|
117
|
+
: "nothing imports it",
|
|
118
|
+
}),
|
|
119
|
+
o.duplicates
|
|
120
|
+
? require_views__html.card({
|
|
121
|
+
label: "Duplicates",
|
|
122
|
+
value: require_views__html.plural(o.duplicates, "copy", "copies"),
|
|
123
|
+
sub: `${require_views__html.formatBytes(o.duplicatesSize)} could be saved`,
|
|
124
|
+
kind: "danger",
|
|
125
|
+
})
|
|
126
|
+
: "",
|
|
127
|
+
].join("")}</div>`;
|
|
128
|
+
}
|
|
129
|
+
discovery.view.define("module-overview", (el, _config, data) => {
|
|
130
|
+
const overview = data;
|
|
131
|
+
if (!overview) return;
|
|
132
|
+
el.innerHTML = renderHeader(overview) + renderCards(overview);
|
|
133
|
+
});
|
|
134
|
+
//#endregion
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const require_views__html = require("./_html.js");
|
|
2
|
+
//#region src/client/views/packageOverview.ts
|
|
3
|
+
function formatDate(isoDate) {
|
|
4
|
+
return new Date(isoDate).toISOString().slice(0, 10);
|
|
5
|
+
}
|
|
6
|
+
function externalChip(text, href) {
|
|
7
|
+
return `<a class="mo-chip mo-chip-link" href="${require_views__html.escapeHTML(href)}" target="_blank" rel="noopener noreferrer">${text} ↗</a>`;
|
|
8
|
+
}
|
|
9
|
+
function renderHeader(o) {
|
|
10
|
+
const id = o.versions.length === 1 ? `${o.name}@${o.versions[0]}` : o.name;
|
|
11
|
+
const npmPath =
|
|
12
|
+
o.versions.length === 1 ? `${o.name}/v/${o.versions[0]}` : o.name;
|
|
13
|
+
const chips = [
|
|
14
|
+
...o.versions.map((version) =>
|
|
15
|
+
require_views__html.chip(
|
|
16
|
+
`v${require_views__html.escapeHTML(version)}`,
|
|
17
|
+
"pkg",
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
o.deprecated.length ? require_views__html.chip("Deprecated", "danger") : "",
|
|
21
|
+
o.isOutdated && o.latestVersion
|
|
22
|
+
? require_views__html.chip(
|
|
23
|
+
`Latest v${require_views__html.escapeHTML(o.latestVersion)}`,
|
|
24
|
+
"warn",
|
|
25
|
+
)
|
|
26
|
+
: "",
|
|
27
|
+
o.copies.length > 1
|
|
28
|
+
? require_views__html.chip(`Duplicated ×${o.copies.length}`, "danger")
|
|
29
|
+
: "",
|
|
30
|
+
...o.findings.map((f) =>
|
|
31
|
+
require_views__html.chip(
|
|
32
|
+
`💡 ${require_views__html.escapeHTML(f.title)}`,
|
|
33
|
+
"warn",
|
|
34
|
+
discovery.encodePageHash("default", "insights"),
|
|
35
|
+
),
|
|
36
|
+
),
|
|
37
|
+
].join("");
|
|
38
|
+
const links = [
|
|
39
|
+
externalChip("npm", `https://www.npmjs.com/package/${npmPath}`),
|
|
40
|
+
externalChip("bundlephobia", `https://bundlephobia.com/package/${id}`),
|
|
41
|
+
externalChip("packagephobia", `https://packagephobia.com/result?p=${id}`),
|
|
42
|
+
`<a class="po-badge" href="https://bundlejs.com/?q=${require_views__html.escapeHTML(id)}" target="_blank" rel="noopener noreferrer"><img alt="bundlejs size" src="https://deno.bundlejs.com/?q=${require_views__html.escapeHTML(id)}&badge=detailed" /></a>`,
|
|
43
|
+
].join("");
|
|
44
|
+
return `
|
|
45
|
+
<div class="mo-header">
|
|
46
|
+
<span class="mo-ext po-icon">npm</span>
|
|
47
|
+
<div class="mo-title">
|
|
48
|
+
<div class="mo-dir">${o.paths.map(require_views__html.escapeHTML).join(" · ")}</div>
|
|
49
|
+
<div class="mo-file">${require_views__html.escapeHTML(o.name)}</div>
|
|
50
|
+
<div class="mo-chips">${chips}</div>
|
|
51
|
+
<div class="mo-chips po-links">${links}</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>`;
|
|
54
|
+
}
|
|
55
|
+
function renderCards(o) {
|
|
56
|
+
const otherPackages = o.importerPackages;
|
|
57
|
+
const importers = [
|
|
58
|
+
o.importedByOwnCode ? "your code" : "",
|
|
59
|
+
otherPackages > 0
|
|
60
|
+
? require_views__html.plural(otherPackages, "package")
|
|
61
|
+
: "",
|
|
62
|
+
]
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join(" + ");
|
|
65
|
+
return `<div class="mo-cards">${[
|
|
66
|
+
require_views__html.card({
|
|
67
|
+
label: "Bundle size",
|
|
68
|
+
value: require_views__html.formatBytes(o.size),
|
|
69
|
+
sub: `${require_views__html.formatPercent(o.bundleShare)} of bundle · #${o.rank.toLocaleString()} of ${require_views__html.plural(o.packagesCount, "package")}`,
|
|
70
|
+
kind: "accent",
|
|
71
|
+
bar: o.largestShare,
|
|
72
|
+
}),
|
|
73
|
+
require_views__html.card({
|
|
74
|
+
label: "Files",
|
|
75
|
+
value: require_views__html.plural(o.filesCount, "module"),
|
|
76
|
+
sub: `largest: ${require_views__html.escapeHTML(o.largestFile.slice(o.largestFile.lastIndexOf("/") + 1))} · ${require_views__html.formatBytes(o.largestFileSize)}`,
|
|
77
|
+
}),
|
|
78
|
+
o.copies.length > 1
|
|
79
|
+
? require_views__html.card({
|
|
80
|
+
label: "Copies",
|
|
81
|
+
value: require_views__html.plural(o.copies.length, "copy", "copies"),
|
|
82
|
+
sub: `${require_views__html.formatBytes(o.copiesSavings)} could be saved`,
|
|
83
|
+
kind: "danger",
|
|
84
|
+
})
|
|
85
|
+
: require_views__html.card({
|
|
86
|
+
label: "Copies",
|
|
87
|
+
value: "1 copy",
|
|
88
|
+
sub: "bundled only once",
|
|
89
|
+
}),
|
|
90
|
+
require_views__html.card({
|
|
91
|
+
label: "Imported by",
|
|
92
|
+
value: require_views__html.plural(o.importedBy, "module"),
|
|
93
|
+
sub: o.importedBy ? `from ${importers}` : "loaded by the bundler",
|
|
94
|
+
}),
|
|
95
|
+
o.publishedAt
|
|
96
|
+
? require_views__html.card({
|
|
97
|
+
label: "Published",
|
|
98
|
+
value: formatDate(o.publishedAt),
|
|
99
|
+
sub: o.deprecated.length
|
|
100
|
+
? '<span class="mo-bad">deprecated</span>'
|
|
101
|
+
: o.isOutdated && o.latestVersion
|
|
102
|
+
? `<span class="mo-bad">outdated</span> · latest v${require_views__html.escapeHTML(o.latestVersion)}`
|
|
103
|
+
: '<span class="mo-good">latest version</span>',
|
|
104
|
+
kind: o.deprecated.length ? "danger" : "",
|
|
105
|
+
})
|
|
106
|
+
: "",
|
|
107
|
+
].join("")}</div>`;
|
|
108
|
+
}
|
|
109
|
+
discovery.view.define("package-overview", (el, _config, data) => {
|
|
110
|
+
const overview = data;
|
|
111
|
+
if (!overview) return;
|
|
112
|
+
el.innerHTML = renderHeader(overview) + renderCards(overview);
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/client/views/persistedFilterInput.ts
|
|
2
|
+
const persistedValues = /* @__PURE__ */ new Map();
|
|
3
|
+
discovery.view.define(
|
|
4
|
+
"persisted-filter-input",
|
|
5
|
+
async function renderPersistedFilterInput(el, config, data, context) {
|
|
6
|
+
const { persistKey, onChange, ...rest } = config;
|
|
7
|
+
let inputEl = null;
|
|
8
|
+
await this.render(
|
|
9
|
+
el,
|
|
10
|
+
{
|
|
11
|
+
...rest,
|
|
12
|
+
view: "input",
|
|
13
|
+
type: "regexp",
|
|
14
|
+
value: persistedValues.get(persistKey) ?? "",
|
|
15
|
+
onChange(value, name) {
|
|
16
|
+
persistedValues.set(persistKey, inputEl?.value.trim() ?? "");
|
|
17
|
+
onChange?.(value, name);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
data,
|
|
21
|
+
context,
|
|
22
|
+
);
|
|
23
|
+
inputEl = el.querySelector("input");
|
|
24
|
+
},
|
|
25
|
+
{ tag: false },
|
|
26
|
+
);
|
|
27
|
+
//#endregion
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const require_views__html = require("./_html.js");
|
|
2
|
+
//#region src/client/views/reportBar.ts
|
|
3
|
+
const PLATFORM_NAMES = {
|
|
4
|
+
ios: "iOS",
|
|
5
|
+
android: "Android",
|
|
6
|
+
web: "Web",
|
|
7
|
+
macos: "macOS",
|
|
8
|
+
windows: "Windows",
|
|
9
|
+
};
|
|
10
|
+
function platformName(platform) {
|
|
11
|
+
return (
|
|
12
|
+
PLATFORM_NAMES[platform] ??
|
|
13
|
+
platform.charAt(0).toUpperCase() + platform.slice(1)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function chip(text, kind, title) {
|
|
17
|
+
return `<span class="rb-chip rb-chip-${kind}"${title ? ` title="${require_views__html.escapeHTML(title)}"` : ""}>${text}</span>`;
|
|
18
|
+
}
|
|
19
|
+
function renderBuild(s) {
|
|
20
|
+
const chips = [
|
|
21
|
+
s.platform
|
|
22
|
+
? chip(
|
|
23
|
+
require_views__html.escapeHTML(platformName(s.platform)),
|
|
24
|
+
"platform",
|
|
25
|
+
)
|
|
26
|
+
: "",
|
|
27
|
+
];
|
|
28
|
+
if (s.dev === true)
|
|
29
|
+
chips.push(
|
|
30
|
+
chip(
|
|
31
|
+
"⚠ Dev bundle",
|
|
32
|
+
"warn",
|
|
33
|
+
"__DEV__ is true: the bundle has dev-only code, so sizes are bigger than in production. Build with --dev false.",
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
else if (s.dev === false)
|
|
37
|
+
chips.push(chip("Production", "ok", "__DEV__: false"));
|
|
38
|
+
if (s.minify === false)
|
|
39
|
+
chips.push(
|
|
40
|
+
chip(
|
|
41
|
+
"⚠ Not minified",
|
|
42
|
+
"warn",
|
|
43
|
+
"Minify is off: sizes are bigger than in a release build. Build with --minify true.",
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
else if (s.minify === true)
|
|
47
|
+
chips.push(chip("Minified", "ok", "Minify: true"));
|
|
48
|
+
return `<div class="rb-build">${chips.join("")}</div>`;
|
|
49
|
+
}
|
|
50
|
+
function renderSize(s) {
|
|
51
|
+
const sourceShare = s.totalSize ? s.sourceSize / s.totalSize : 0;
|
|
52
|
+
const nodeModulesShare = s.totalSize ? s.nodeModulesSize / s.totalSize : 0;
|
|
53
|
+
const title = `Your code: ${require_views__html.formatBytes(s.sourceSize)}\nnode_modules: ${require_views__html.formatBytes(s.nodeModulesSize)}`;
|
|
54
|
+
return `
|
|
55
|
+
<div class="rb-size" title="${require_views__html.escapeHTML(title)}">
|
|
56
|
+
<b class="rb-total">${require_views__html.formatBytes(s.totalSize)}</b>
|
|
57
|
+
<span class="rb-split">
|
|
58
|
+
<span class="rb-split-own" style="width:${(sourceShare * 100).toFixed(2)}%" title="${require_views__html.escapeHTML(`Your code: ${require_views__html.formatBytes(s.sourceSize)} (${require_views__html.formatPercent(sourceShare)})`)}"></span>
|
|
59
|
+
<span class="rb-split-nm" style="width:${(nodeModulesShare * 100).toFixed(2)}%" title="${require_views__html.escapeHTML(`node_modules: ${require_views__html.formatBytes(s.nodeModulesSize)} (${require_views__html.formatPercent(nodeModulesShare)})`)}"></span>
|
|
60
|
+
</span>
|
|
61
|
+
<span class="rb-legend">
|
|
62
|
+
<span><i class="rb-dot rb-dot-own"></i>Your code ${chip(require_views__html.formatPercent(sourceShare), "own")}</span>
|
|
63
|
+
<span><i class="rb-dot rb-dot-nm"></i>node_modules ${chip(require_views__html.formatPercent(nodeModulesShare), "nm")}</span>
|
|
64
|
+
</span>
|
|
65
|
+
</div>`;
|
|
66
|
+
}
|
|
67
|
+
function renderDate(s) {
|
|
68
|
+
if (!s.date) return "";
|
|
69
|
+
const date = new Date(s.date);
|
|
70
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
71
|
+
const text = date.toLocaleString(void 0, {
|
|
72
|
+
month: "short",
|
|
73
|
+
day: "numeric",
|
|
74
|
+
year:
|
|
75
|
+
date.getFullYear() === /* @__PURE__ */ new Date().getFullYear()
|
|
76
|
+
? void 0
|
|
77
|
+
: "numeric",
|
|
78
|
+
hour: "2-digit",
|
|
79
|
+
minute: "2-digit",
|
|
80
|
+
});
|
|
81
|
+
return `<div class="rb-date" title="${require_views__html.escapeHTML(date.toISOString())}">Built ${require_views__html.escapeHTML(text)}</div>`;
|
|
82
|
+
}
|
|
83
|
+
discovery.view.define("report-bar", (el, _config, data) => {
|
|
84
|
+
const summary = data;
|
|
85
|
+
if (!summary) return;
|
|
86
|
+
el.innerHTML =
|
|
87
|
+
renderBuild(summary) + renderSize(summary) + renderDate(summary);
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|