react-native-bundle-discovery 1.0.0-rc.10
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/.discoveryrc.js +21 -0
- package/README.md +51 -0
- package/index.js +1 -0
- package/lib/bin.js +52 -0
- package/lib/customSerializer.js +167 -0
- package/package.json +43 -0
- package/pages/_common.js +266 -0
- package/pages/default.js +194 -0
- package/pages/module.js +296 -0
- package/pages/package.js +150 -0
- package/prepare.js +105 -0
- package/queryHelpers.js +329 -0
- package/setup.js +12 -0
- package/vendors/foamtree.js +9008 -0
- package/views/_theme.js +35 -0
- package/views/foamtree.js +135 -0
- package/views/global.css +127 -0
- package/views/highcharts.css +1302 -0
- package/views/highcharts.js +46 -0
package/views/_theme.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function isDark() {
|
|
2
|
+
const isSystemDarkMode = window?.matchMedia?.(
|
|
3
|
+
"(prefers-color-scheme: dark)",
|
|
4
|
+
)?.matches;
|
|
5
|
+
const userMode = localStorage.getItem("discoveryjs:color-scheme");
|
|
6
|
+
return userMode === "auto" ? isSystemDarkMode : userMode === "dark";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function doTheming(el) {
|
|
10
|
+
const dark = isDark();
|
|
11
|
+
el.classList.add("highcharts-light");
|
|
12
|
+
el.classList[!dark ? "add" : "remove"]("my-light");
|
|
13
|
+
el.classList[dark ? "add" : "remove"]("highcharts-dark");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// apply theme on import
|
|
17
|
+
if (isDark()) {
|
|
18
|
+
// require("highcharts/themes/dark-unica"); // no
|
|
19
|
+
// require("highcharts/themes/brand-dark");
|
|
20
|
+
// require("highcharts/themes/dark-blue");
|
|
21
|
+
// require("highcharts/themes/dark-green");
|
|
22
|
+
require("highcharts/themes/high-contrast-dark");
|
|
23
|
+
} else {
|
|
24
|
+
// require("highcharts/themes/avocado");
|
|
25
|
+
// require("highcharts/themes/brand-light");
|
|
26
|
+
// require("highcharts/themes/gray");
|
|
27
|
+
// require("highcharts/themes/grid-light"); // no
|
|
28
|
+
// require("highcharts/themes/grid");
|
|
29
|
+
// require("highcharts/themes/high-contrast-light");
|
|
30
|
+
// require("highcharts/themes/sand-signika"); // no
|
|
31
|
+
// require("highcharts/themes/skies");
|
|
32
|
+
// require("highcharts/themes/sunset");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { doTheming };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const { FoamTree } = require("../vendors/foamtree.js");
|
|
2
|
+
|
|
3
|
+
function injectTooltip(root) {
|
|
4
|
+
const t = root.querySelector(".tooltip");
|
|
5
|
+
if (t) return t;
|
|
6
|
+
|
|
7
|
+
const tooltip = document.createElement("div");
|
|
8
|
+
tooltip.className = "tooltip";
|
|
9
|
+
tooltip.id = "foamtree-tooltip";
|
|
10
|
+
root.appendChild(tooltip);
|
|
11
|
+
return tooltip;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function prependDuplicateTo(label) {
|
|
15
|
+
if (label.includes(" ~ ")) {
|
|
16
|
+
return "<b class='i-duplicate'>Duplicate</b> " + label.split(" ~ ")[1];
|
|
17
|
+
}
|
|
18
|
+
return label;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Based on https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/client/components/Treemap.jsx
|
|
22
|
+
discovery.view.define("foamtree", function (el, config, rawData, context) {
|
|
23
|
+
if (Array.isArray(rawData?.options?.series)) {
|
|
24
|
+
rawData.options.series.forEach((e) => {
|
|
25
|
+
if (e.data?.[0]?.value !== undefined) {
|
|
26
|
+
// mutate data by link
|
|
27
|
+
e.data = e.data.map((d) => d.value ?? null);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// console.log({ rawData });
|
|
33
|
+
|
|
34
|
+
// Render after element will be added to the DOM
|
|
35
|
+
// to avoid "FoamTree: element has zero dimensions: 0 x 0" error
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
try {
|
|
38
|
+
// Dirty hack to fix shadow DOM issue, xd
|
|
39
|
+
window.__el = el;
|
|
40
|
+
|
|
41
|
+
const root = el.closest(".discovery-root");
|
|
42
|
+
const tooltip = injectTooltip(root);
|
|
43
|
+
|
|
44
|
+
window.addEventListener("resize", () => ft.resize(), { passive: true });
|
|
45
|
+
|
|
46
|
+
root.addEventListener(
|
|
47
|
+
"mousemove",
|
|
48
|
+
(event) => {
|
|
49
|
+
if (tooltip.style.display === "none") return;
|
|
50
|
+
tooltip.style.left = event.pageX + 10 + "px";
|
|
51
|
+
tooltip.style.top = event.pageY + 10 + "px";
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
passive: true,
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
el.addEventListener("mouseover", () => {
|
|
58
|
+
tooltip.style.display = "block";
|
|
59
|
+
});
|
|
60
|
+
el.addEventListener("mouseout", () => {
|
|
61
|
+
tooltip.style.display = "none";
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const ft = new FoamTree({
|
|
65
|
+
element: el,
|
|
66
|
+
layout: "squarified",
|
|
67
|
+
stacking: "flattened",
|
|
68
|
+
pixelRatio: window.devicePixelRatio || 1,
|
|
69
|
+
maxGroups: Infinity,
|
|
70
|
+
maxGroupLevelsDrawn: Infinity,
|
|
71
|
+
maxGroupLabelLevelsDrawn: Infinity,
|
|
72
|
+
maxGroupLevelsAttached: Infinity,
|
|
73
|
+
wireframeLabelDrawing: "always",
|
|
74
|
+
groupMinDiameter: 0,
|
|
75
|
+
groupLabelVerticalPadding: 0.2,
|
|
76
|
+
rolloutDuration: 0,
|
|
77
|
+
pullbackDuration: 0,
|
|
78
|
+
fadeDuration: 0,
|
|
79
|
+
groupExposureZoomMargin: 0.2,
|
|
80
|
+
zoomMouseWheelDuration: 300,
|
|
81
|
+
openCloseDuration: 200,
|
|
82
|
+
onGroupClick(event) {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
ft.zoom(event.group);
|
|
85
|
+
},
|
|
86
|
+
onGroupDoubleClick: (e) => e.preventDefault(),
|
|
87
|
+
onGroupHover(event) {
|
|
88
|
+
// Ignoring hovering on `FoamTree` branding group and the root group
|
|
89
|
+
if (event.group && event.group === rawData.options.dataObject) {
|
|
90
|
+
return event.preventDefault();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const { group } = event;
|
|
94
|
+
|
|
95
|
+
if (group && group.type) {
|
|
96
|
+
const htmlContent = [
|
|
97
|
+
`<b class="tooltip-name">${group.type}</b>: ${prependDuplicateTo(group.label)}`,
|
|
98
|
+
`<b>Size</b>: ${group.size}`,
|
|
99
|
+
group.type === "folder" ? `<b>Files</b>: ${group.files}` : null,
|
|
100
|
+
]
|
|
101
|
+
.filter((e) => !!e)
|
|
102
|
+
.join("<br/>");
|
|
103
|
+
|
|
104
|
+
tooltip.style.display = "block";
|
|
105
|
+
tooltip.innerHTML = htmlContent;
|
|
106
|
+
} else {
|
|
107
|
+
tooltip.style.display = "none";
|
|
108
|
+
tooltip.innerHTML = "";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// if (group) {
|
|
112
|
+
// this.setState({
|
|
113
|
+
// showTooltip: true,
|
|
114
|
+
// tooltipContent: this.getTooltipContent(group)
|
|
115
|
+
// });
|
|
116
|
+
// } else {
|
|
117
|
+
// this.setState({showTooltip: false});
|
|
118
|
+
// }
|
|
119
|
+
},
|
|
120
|
+
...rawData.options,
|
|
121
|
+
});
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.error(e, rawData);
|
|
124
|
+
discovery.view.render(
|
|
125
|
+
el,
|
|
126
|
+
{
|
|
127
|
+
view: "alert-danger",
|
|
128
|
+
data: '"Error rendering chart, please check the console for more information."',
|
|
129
|
+
},
|
|
130
|
+
rawData,
|
|
131
|
+
context,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}, 0);
|
|
135
|
+
});
|
package/views/global.css
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
hr{
|
|
2
|
+
border: 1px solid rgb(222 222 222);
|
|
3
|
+
margin-top: 1rem;
|
|
4
|
+
margin-bottom: 1rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.inline-block{
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
.discovery-content>.page-default{
|
|
11
|
+
height: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
padding-top: 16px;
|
|
14
|
+
padding-bottom: 16px;
|
|
15
|
+
}
|
|
16
|
+
.view-tabs-content>.view-content-filter>.view-input{
|
|
17
|
+
padding-top: 12px;
|
|
18
|
+
padding-bottom: 12px;
|
|
19
|
+
margin: 0;
|
|
20
|
+
background-color: var(--discovery-background-color);
|
|
21
|
+
position: sticky;
|
|
22
|
+
top: 0;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
}
|
|
25
|
+
.main-tabs{
|
|
26
|
+
height: calc(100% - 20px);
|
|
27
|
+
margin-top: 12px;
|
|
28
|
+
}
|
|
29
|
+
.main-tabs .view-tabs-content{
|
|
30
|
+
height: calc(100% - 32px);
|
|
31
|
+
}
|
|
32
|
+
.foamtree-filter,
|
|
33
|
+
.view-foamtree{
|
|
34
|
+
width: 100%;
|
|
35
|
+
height: 100%;
|
|
36
|
+
}
|
|
37
|
+
.foamtree-filter>.content{
|
|
38
|
+
height: calc(100% - 60px);
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
.tooltip {
|
|
42
|
+
position: absolute;
|
|
43
|
+
z-index: 10;
|
|
44
|
+
display: none;
|
|
45
|
+
background-color: #fff;
|
|
46
|
+
border: 1px solid #ccc;
|
|
47
|
+
padding: 5px;
|
|
48
|
+
border-radius: 5px;
|
|
49
|
+
box-shadow: 0 0 5px #ccc;
|
|
50
|
+
}
|
|
51
|
+
.tooltip-name{
|
|
52
|
+
text-transform: capitalize;
|
|
53
|
+
}
|
|
54
|
+
.flex-no-wrap{
|
|
55
|
+
flex-wrap: nowrap;
|
|
56
|
+
}
|
|
57
|
+
.width-50p{
|
|
58
|
+
width: 50%;
|
|
59
|
+
}
|
|
60
|
+
.my-icon{
|
|
61
|
+
display: block;
|
|
62
|
+
height: 100%;
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
.my-icon-inline{
|
|
66
|
+
display: inline-block;
|
|
67
|
+
vertical-align: middle;
|
|
68
|
+
margin-left: 4px;
|
|
69
|
+
}
|
|
70
|
+
.my-icon-12{
|
|
71
|
+
width: 12px;
|
|
72
|
+
height: 12px;
|
|
73
|
+
}
|
|
74
|
+
.no-margin{
|
|
75
|
+
margin: 0;
|
|
76
|
+
}
|
|
77
|
+
.two-column>*{
|
|
78
|
+
width: 50%;
|
|
79
|
+
}
|
|
80
|
+
.m-v-8{
|
|
81
|
+
margin-top: 8px;
|
|
82
|
+
margin-bottom: 8px;
|
|
83
|
+
}
|
|
84
|
+
.i-duplicate{
|
|
85
|
+
display: inline-block;
|
|
86
|
+
background: #da444e;
|
|
87
|
+
color: #fff;
|
|
88
|
+
border-radius: 0.5em;
|
|
89
|
+
padding: 0 0.5em;
|
|
90
|
+
}
|
|
91
|
+
.m-l-0_5em{
|
|
92
|
+
margin-left: 0.5em;
|
|
93
|
+
}
|
|
94
|
+
.m-r-0_3em{
|
|
95
|
+
margin-right: 0.3em;
|
|
96
|
+
}
|
|
97
|
+
.copy-to-clipboard{
|
|
98
|
+
/* from: https://tabler.io/icons/icon/clipboard-copy */
|
|
99
|
+
background: url('data:image/svg+xml,%3Csvg%20%20xmlns=%22http://www.w3.org/2000/svg%22%20%20width=%2224%22%20%20height=%2224%22%20%20viewBox=%220%200%2024%2024%22%20%20fill=%22none%22%20%20stroke=%22currentColor%22%20%20stroke-width=%222%22%20%20stroke-linecap=%22round%22%20%20stroke-linejoin=%22round%22%20%20class=%22icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-clipboard-copy%22%3E%3Cpath%20stroke=%22none%22%20d=%22M0%200h24v24H0z%22%20fill=%22none%22/%3E%3Cpath%20d=%22M9%205h-2a2%202%200%200%200%20-2%202v12a2%202%200%200%200%202%202h3m9%20-9v-5a2%202%200%200%200%20-2%20-2h-2%22%20/%3E%3Cpath%20d=%22M13%2017v-1a1%201%200%200%201%201%20-1h1m3%200h1a1%201%200%200%201%201%201v1m0%203v1a1%201%200%200%201%20-1%201h-1m-3%200h-1a1%201%200%200%201%20-1%20-1v-1%22%20/%3E%3Cpath%20d=%22M9%203m0%202a2%202%200%200%201%202%20-2h2a2%202%200%200%201%202%202v0a2%202%200%200%201%20-2%202h-2a2%202%200%200%201%20-2%20-2z%22%20/%3E%3C/svg%3E');
|
|
100
|
+
background-repeat: no-repeat;
|
|
101
|
+
background-position: center;
|
|
102
|
+
display: inline-block;
|
|
103
|
+
height: 32px;
|
|
104
|
+
width: 32px;
|
|
105
|
+
}
|
|
106
|
+
.copy-to-clipboard::before {
|
|
107
|
+
position: absolute;
|
|
108
|
+
top: -8px;
|
|
109
|
+
font-size: 0.7rem;
|
|
110
|
+
border-radius: 4px;
|
|
111
|
+
display: inline-block;
|
|
112
|
+
padding: 1px 4px;
|
|
113
|
+
color: #fff;
|
|
114
|
+
left: 78%;
|
|
115
|
+
opacity: 0;
|
|
116
|
+
transition: opacity 0.3s ease-in-out;
|
|
117
|
+
}
|
|
118
|
+
.copy-to-clipboard.done::before {
|
|
119
|
+
content: "Copied!";
|
|
120
|
+
background: green;
|
|
121
|
+
opacity: 1;
|
|
122
|
+
}
|
|
123
|
+
.copy-to-clipboard.err::before {
|
|
124
|
+
content: "Error!";
|
|
125
|
+
background: red;
|
|
126
|
+
opacity: 1;
|
|
127
|
+
}
|