@@ -13,16 +13,37 @@ const props = defineProps<{
13
13
b: ArtifactDescription ;
14
14
}>();
15
15
16
+ interface ComponentSize {
17
+ name: string ;
18
+ before: number | undefined ;
19
+ after: number | undefined ;
20
+ }
21
+
22
+ const allComponents: ComponentSize [] = [
23
+ ... new Set ([
24
+ ... Object .keys (props .a .component_sizes ),
25
+ ... Object .keys (props .b .component_sizes ),
26
+ ]),
27
+ ].map ((name ) => {
28
+ const before = props .a .component_sizes [name ];
29
+ const after = props .b .component_sizes [name ];
30
+ return {
31
+ name ,
32
+ before ,
33
+ after ,
34
+ };
35
+ });
36
+
16
37
// Sort binaries first, libraries later. Then within each category, sort alphabetically.
17
- const components = Object . keys ( props . a . component_sizes ) .sort ((a , b ) => {
18
- const aLib = a . startsWith ( " lib " );
19
- const bLib = b . startsWith ( " lib " );
38
+ const components = allComponents .sort ((a , b ) => {
39
+ const aLib = isLibrary ( a . name );
40
+ const bLib = isLibrary ( b . name );
20
41
if (aLib && ! bLib ) {
21
42
return 1 ;
22
43
} else if (! aLib && bLib ) {
23
44
return - 1 ;
24
45
} else {
25
- return a .localeCompare (b );
46
+ return a .name . localeCompare (b . name );
26
47
}
27
48
});
28
49
@@ -54,6 +75,13 @@ function formatChangeTitle(
54
75
return (b - a ).toLocaleString ();
55
76
}
56
77
78
+ function formatTitle(value : number | undefined ): string {
79
+ if (! isValidValue (value )) {
80
+ return " Missing value" ;
81
+ }
82
+ return value .toLocaleString ();
83
+ }
84
+
57
85
function formatChange(a : number | undefined , b : number | undefined ): string {
58
86
if (! isValidValue (a ) || ! isValidValue (b )) {
59
87
return " -" ;
@@ -111,68 +139,33 @@ function generateTitle(component: string): string {
111
139
<tbody >
112
140
<tr v-for =" component in components" >
113
141
<td class =" component" >
114
- {{ formatName(component) }}
115
- <Tooltip >{{ generateTitle(component) }}</Tooltip >
142
+ {{ formatName(component.name ) }}
143
+ <Tooltip >{{ generateTitle(component.name ) }}</Tooltip >
116
144
</td >
117
145
<td >
118
- {{ isLibrary(component) ? "Library" : "Binary" }}
146
+ {{ isLibrary(component.name ) ? "Library" : "Binary" }}
119
147
</td >
120
148
<td >
121
- <div
122
- class =" aligned"
123
- :title =" a.component_sizes[component].toLocaleString()"
124
- >
125
- {{ formatValue(a.component_sizes[component]) }}
149
+ <div class =" aligned" :title =" formatTitle(component.before)" >
150
+ {{ formatValue(component.before) }}
126
151
</div >
127
152
</td >
128
153
<td >
129
- <div
130
- class =" aligned"
131
- :title =" b.component_sizes[component].toLocaleString()"
132
- >
133
- {{ formatValue(b.component_sizes[component]) }}
154
+ <div class =" aligned" :title =" formatTitle(component.after)" >
155
+ {{ formatValue(component.after) }}
134
156
</div >
135
157
</td >
136
- <td
137
- :class ="
138
- getClass(
139
- a.component_sizes[component],
140
- b.component_sizes[component]
141
- )
142
- "
143
- >
158
+ <td :class =" getClass(component.before, component.after)" >
144
159
<div
145
160
class =" aligned"
146
- :title ="
147
- formatChangeTitle(
148
- a.component_sizes[component],
149
- b.component_sizes[component]
150
- )
151
- "
161
+ :title =" formatChangeTitle(component.before, component.after)"
152
162
>
153
- {{
154
- formatChange(
155
- a.component_sizes[component],
156
- b.component_sizes[component]
157
- )
158
- }}
163
+ {{ formatChange(component.before, component.after) }}
159
164
</div >
160
165
</td >
161
- <td
162
- :class ="
163
- getClass(
164
- a.component_sizes[component],
165
- b.component_sizes[component]
166
- )
167
- "
168
- >
166
+ <td :class =" getClass(component.before, component.after)" >
169
167
<div class =" aligned" >
170
- {{
171
- formatPercentChange(
172
- a.component_sizes[component],
173
- b.component_sizes[component]
174
- )
175
- }}
168
+ {{ formatPercentChange(component.before, component.after) }}
176
169
</div >
177
170
</td >
178
171
</tr >
0 commit comments