react-native-bundle-discovery-ui 2.8.0 → 2.9.1

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 (40) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +12 -255
  3. package/assets/global.css +1606 -105
  4. package/dist/bin.js +63 -20
  5. package/dist/client/fonts.js +45 -0
  6. package/dist/client/issues.js +5 -0
  7. package/dist/client/pages/_common.js +279 -98
  8. package/dist/client/pages/_module.js +347 -0
  9. package/dist/client/pages/default.js +144 -63
  10. package/dist/client/pages/module.js +2 -309
  11. package/dist/client/pages/moduleDiff.js +76 -0
  12. package/dist/client/pages/package.js +172 -154
  13. package/dist/client/prepare.js +15 -0
  14. package/dist/client/queryHelpers.js +487 -91
  15. package/dist/client/sizeHeat.js +7 -0
  16. package/dist/client/views/{_theme.js → _colorScheme.js} +2 -9
  17. package/dist/client/views/_html.js +52 -0
  18. package/dist/client/views/codeDiff.js +66 -0
  19. package/dist/client/views/compare.js +237 -0
  20. package/dist/client/views/importGraph.js +255 -0
  21. package/dist/client/views/insights.js +81 -0
  22. package/dist/client/views/moduleOverview.js +122 -0
  23. package/dist/client/views/packageOverview.js +116 -0
  24. package/dist/client/views/persistedFilterInput.js +27 -0
  25. package/dist/client/views/reportBar.js +89 -0
  26. package/dist/client/views/treemap.js +598 -0
  27. package/dist/discoveryrc.js +27 -7
  28. package/dist/rsdoctor.js +19 -99
  29. package/dist/src-DV3VzcQY.js +1548 -0
  30. package/package.json +9 -5
  31. package/assets/highcharts.css +0 -1
  32. package/dist/client/_virtual/_rolldown/runtime.js +0 -37
  33. package/dist/client/views/foamtree.js +0 -103
  34. package/dist/client/views/highcharts.js +0 -33
  35. package/dist/src-DPAqywOJ.js +0 -201
  36. package/vendors/foamtree.js +0 -9008
  37. package/vendors/high-contrast-dark.js +0 -1
  38. package/vendors/highcharts-exporting.js +0 -13
  39. package/vendors/highcharts-networkgraph.js +0 -1
  40. package/vendors/highcharts.js +0 -10
@@ -0,0 +1,122 @@
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", "deprecated")
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">${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 renderCards(o) {
42
+ const delta = o.sourceSize ? o.outputSize / o.sourceSize - 1 : 0;
43
+ const deltaText =
44
+ delta === 0
45
+ ? "unchanged by transform"
46
+ : delta < 0
47
+ ? `<span class="mo-good">${require_views__html.formatPercent(-delta)} smaller</span> after transform`
48
+ : `<span class="mo-bad">${require_views__html.formatPercent(delta)} larger</span> after transform`;
49
+ const otherPackages = o.importerPackages - (o.importedByOwnCode ? 1 : 0);
50
+ const importers = [
51
+ o.importedByOwnCode ? "your code" : "",
52
+ otherPackages > 0
53
+ ? require_views__html.plural(otherPackages, "package")
54
+ : "",
55
+ ]
56
+ .filter(Boolean)
57
+ .join(" + ");
58
+ return `<div class="mo-cards">${[
59
+ require_views__html.card({
60
+ label: "Output size",
61
+ value: require_views__html.formatBytes(o.outputSize),
62
+ sub: `${require_views__html.formatPercent(o.bundleShare)} of bundle · #${o.rank.toLocaleString()} of ${o.modulesCount.toLocaleString()}`,
63
+ kind: "accent",
64
+ bar: o.largestShare,
65
+ }),
66
+ require_views__html.card({
67
+ label: "Source size",
68
+ value: require_views__html.formatBytes(o.sourceSize),
69
+ sub: o.sourceSize ? deltaText : void 0,
70
+ }),
71
+ require_views__html.card({
72
+ label: "Source lines",
73
+ value: o.sourceLines.toLocaleString(),
74
+ sub:
75
+ o.outputLines > 1
76
+ ? `${require_views__html.plural(o.outputLines, "line")} after transform`
77
+ : "minified to a single line",
78
+ }),
79
+ o.pkg
80
+ ? require_views__html.card({
81
+ label: "Share of package",
82
+ value: require_views__html.formatPercent(o.pkg.share),
83
+ 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")}`,
84
+ bar: o.pkg.share,
85
+ })
86
+ : "",
87
+ require_views__html.card({
88
+ label: "Imports",
89
+ value: require_views__html.plural(o.imports.length, "module"),
90
+ sub: o.missingImports
91
+ ? `${o.missingImports} not in the bundle`
92
+ : o.imports.length
93
+ ? "direct dependencies"
94
+ : "no dependencies",
95
+ }),
96
+ require_views__html.card({
97
+ label: "Imported by",
98
+ value: require_views__html.plural(o.importedBy, "module"),
99
+ sub: o.importedBy
100
+ ? `from ${importers}`
101
+ : o.isEntry
102
+ ? "entry point"
103
+ : o.injectedBy
104
+ ? `loaded by ${o.injectedBy}`
105
+ : "nothing imports it",
106
+ }),
107
+ o.duplicates
108
+ ? require_views__html.card({
109
+ label: "Duplicates",
110
+ value: require_views__html.plural(o.duplicates, "copy", "copies"),
111
+ sub: `${require_views__html.formatBytes(o.duplicatesSize)} could be saved`,
112
+ kind: "danger",
113
+ })
114
+ : "",
115
+ ].join("")}</div>`;
116
+ }
117
+ discovery.view.define("module-overview", (el, _config, data) => {
118
+ const overview = data;
119
+ if (!overview) return;
120
+ el.innerHTML = renderHeader(overview) + renderCards(overview);
121
+ });
122
+ //#endregion
@@ -0,0 +1,116 @@
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
21
+ ? require_views__html.chip("Deprecated", "deprecated")
22
+ : "",
23
+ o.isOutdated && o.latestVersion
24
+ ? require_views__html.chip(
25
+ `Latest v${require_views__html.escapeHTML(o.latestVersion)}`,
26
+ "warn",
27
+ )
28
+ : "",
29
+ o.copies.length > 1
30
+ ? require_views__html.chip(`Duplicated ×${o.copies.length}`, "danger")
31
+ : "",
32
+ ...o.findings.map((f) =>
33
+ require_views__html.chip(
34
+ `💡 ${require_views__html.escapeHTML(f.title)}`,
35
+ "warn",
36
+ discovery.encodePageHash("default", "insights"),
37
+ ),
38
+ ),
39
+ ].join("");
40
+ const links = [
41
+ externalChip("npm", `https://www.npmjs.com/package/${npmPath}`),
42
+ externalChip("bundlephobia", `https://bundlephobia.com/package/${id}`),
43
+ externalChip("packagephobia", `https://packagephobia.com/result?p=${id}`),
44
+ `<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>`,
45
+ ].join("");
46
+ return `
47
+ <div class="mo-header">
48
+ <span class="mo-ext po-icon">npm</span>
49
+ <div class="mo-title">
50
+ <div class="mo-dir">${o.paths.map(require_views__html.escapeHTML).join(" · ")}</div>
51
+ <div class="mo-file">${require_views__html.escapeHTML(o.name)}</div>
52
+ <div class="mo-chips">${chips}</div>
53
+ <div class="mo-chips po-links">${links}</div>
54
+ </div>
55
+ </div>`;
56
+ }
57
+ function renderCards(o) {
58
+ const otherPackages = o.importerPackages;
59
+ const importers = [
60
+ o.importedByOwnCode ? "your code" : "",
61
+ otherPackages > 0
62
+ ? require_views__html.plural(otherPackages, "package")
63
+ : "",
64
+ ]
65
+ .filter(Boolean)
66
+ .join(" + ");
67
+ return `<div class="mo-cards">${[
68
+ require_views__html.card({
69
+ label: "Bundle size",
70
+ value: require_views__html.formatBytes(o.size),
71
+ sub: `${require_views__html.formatPercent(o.bundleShare)} of bundle · #${o.rank.toLocaleString()} of ${require_views__html.plural(o.packagesCount, "package")}`,
72
+ kind: "accent",
73
+ bar: o.largestShare,
74
+ }),
75
+ require_views__html.card({
76
+ label: "Files",
77
+ value: require_views__html.plural(o.filesCount, "module"),
78
+ sub: `largest: ${require_views__html.escapeHTML(o.largestFile.slice(o.largestFile.lastIndexOf("/") + 1))} · ${require_views__html.formatBytes(o.largestFileSize)}`,
79
+ }),
80
+ o.copies.length > 1
81
+ ? require_views__html.card({
82
+ label: "Copies",
83
+ value: require_views__html.plural(o.copies.length, "copy", "copies"),
84
+ sub: `${require_views__html.formatBytes(o.copiesSavings)} could be saved`,
85
+ kind: "danger",
86
+ })
87
+ : require_views__html.card({
88
+ label: "Copies",
89
+ value: "1 copy",
90
+ sub: "bundled only once",
91
+ }),
92
+ require_views__html.card({
93
+ label: "Imported by",
94
+ value: require_views__html.plural(o.importedBy, "module"),
95
+ sub: o.importedBy ? `from ${importers}` : "loaded by the bundler",
96
+ }),
97
+ o.publishedAt
98
+ ? require_views__html.card({
99
+ label: "Published",
100
+ value: formatDate(o.publishedAt),
101
+ sub: o.deprecated.length
102
+ ? '<span class="mo-bad">deprecated</span>'
103
+ : o.isOutdated && o.latestVersion
104
+ ? `<span class="mo-bad">outdated</span> · latest v${require_views__html.escapeHTML(o.latestVersion)}`
105
+ : '<span class="mo-good">latest version</span>',
106
+ kind: o.deprecated.length ? "danger" : "",
107
+ })
108
+ : "",
109
+ ].join("")}</div>`;
110
+ }
111
+ discovery.view.define("package-overview", (el, _config, data) => {
112
+ const overview = data;
113
+ if (!overview) return;
114
+ el.innerHTML = renderHeader(overview) + renderCards(overview);
115
+ });
116
+ //#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