@bundle-stats/ui 4.17.0 → 4.18.0-beta.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.
- package/lib/components/asset-info/asset-info.i18n.js +11 -0
- package/lib/components/asset-info/asset-info.i18n.js.map +1 -0
- package/lib/components/asset-info/asset-info.js +16 -16
- package/lib/components/asset-info/asset-info.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.i18n.js +9 -1
- package/lib/components/bundle-assets/bundle-assets.i18n.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.js +9 -112
- package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.utils.js +136 -23
- package/lib/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib/components/bundle-assets/index.js +8 -26
- package/lib/components/bundle-assets/index.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.js.map +1 -1
- package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib/hooks/rows-sort.js +14 -2
- package/lib/hooks/rows-sort.js.map +1 -1
- package/lib/hooks/search-params.js.map +1 -1
- package/lib-esm/components/asset-info/asset-info.i18n.js +8 -0
- package/lib-esm/components/asset-info/asset-info.i18n.js.map +1 -0
- package/lib-esm/components/asset-info/asset-info.js +17 -17
- package/lib-esm/components/asset-info/asset-info.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.i18n.js +8 -0
- package/lib-esm/components/bundle-assets/bundle-assets.i18n.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.js +10 -113
- package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js +111 -22
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib-esm/components/bundle-assets/index.js +9 -24
- package/lib-esm/components/bundle-assets/index.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.js.map +1 -1
- package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib-esm/hooks/rows-sort.js +14 -2
- package/lib-esm/hooks/rows-sort.js.map +1 -1
- package/lib-esm/hooks/search-params.js.map +1 -1
- package/package.json +3 -3
- package/src/components/asset-info/asset-info.i18n.ts +7 -0
- package/src/components/asset-info/asset-info.tsx +36 -38
- package/src/components/bundle-assets/__tests__/add-metric-report-asset-row-data.ts +2 -2
- package/src/components/bundle-assets/bundle-assets.i18n.ts +8 -0
- package/src/components/bundle-assets/bundle-assets.stories.tsx +99 -0
- package/src/components/bundle-assets/{bundle-assets.jsx → bundle-assets.tsx} +67 -149
- package/src/components/bundle-assets/bundle-assets.utils.ts +276 -0
- package/src/components/bundle-assets/{index.jsx → index.tsx} +43 -29
- package/src/components/metrics-table/metrics-table.tsx +3 -3
- package/src/components/metrics-table-header/metrics-table-header.tsx +4 -4
- package/src/components/sort-button/sort-button.tsx +1 -1
- package/src/hooks/rows-sort.ts +21 -3
- package/src/hooks/search-params.js +0 -1
- package/src/types.d.ts +5 -1
- package/types/components/asset-info/asset-info.d.ts +4 -13
- package/types/components/asset-info/asset-info.i18n.d.ts +7 -0
- package/types/components/bundle-assets/bundle-assets.d.ts +24 -55
- package/types/components/bundle-assets/bundle-assets.i18n.d.ts +8 -0
- package/types/components/bundle-assets/bundle-assets.utils.d.ts +17 -5
- package/types/components/bundle-assets/index.d.ts +10 -22
- package/types/components/metrics-table/metrics-table.d.ts +3 -2
- package/types/components/metrics-table-header/metrics-table-header.d.ts +1 -2
- package/types/components/sort-button/sort-button.d.ts +1 -2
- package/types/hooks/rows-sort.d.ts +1 -1
- package/src/components/bundle-assets/bundle-assets.utils.js +0 -149
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import * as webpack from '@bundle-stats/utils/lib-esm/webpack';
|
|
3
|
+
import type { Job } from '@bundle-stats/utils';
|
|
4
4
|
import { ASSET_FILTERS } from '@bundle-stats/utils';
|
|
5
5
|
import {
|
|
6
6
|
getAssetEntryTypeFilters,
|
|
@@ -13,13 +13,37 @@ import { useSearchParams } from '../../hooks/search-params';
|
|
|
13
13
|
import { useEntryInfo } from '../../hooks/entry-info';
|
|
14
14
|
import { getJobsChunksData } from '../../utils/jobs';
|
|
15
15
|
import { BundleAssets as BundleAssetsComponent } from './bundle-assets';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
addMetricReportAssetRowData,
|
|
18
|
+
generateGetRowFilter,
|
|
19
|
+
getCustomSort,
|
|
20
|
+
} from './bundle-assets.utils';
|
|
21
|
+
import { ReportMetricAssetRow } from '../../types';
|
|
17
22
|
|
|
18
|
-
export
|
|
19
|
-
|
|
23
|
+
export type BundleAssetsProps = {
|
|
24
|
+
jobs: Array<Job>;
|
|
25
|
+
filters?: Record<string, boolean>;
|
|
26
|
+
search?: string;
|
|
27
|
+
sortBy?: string;
|
|
28
|
+
direction?: string;
|
|
29
|
+
setState: () => void;
|
|
30
|
+
};
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
export const BundleAssets = (props: BundleAssetsProps) => {
|
|
33
|
+
const {
|
|
34
|
+
jobs,
|
|
35
|
+
filters = undefined,
|
|
36
|
+
search = undefined,
|
|
37
|
+
sortBy = undefined,
|
|
38
|
+
direction = undefined,
|
|
39
|
+
setState,
|
|
40
|
+
...restProps
|
|
41
|
+
} = props;
|
|
22
42
|
|
|
43
|
+
// Get chunks data
|
|
44
|
+
const { chunks, chunkIds } = useMemo(() => getJobsChunksData(jobs), [jobs]);
|
|
45
|
+
|
|
46
|
+
// Get filters
|
|
23
47
|
const { defaultFilters, allEntriesFilters } = useMemo(
|
|
24
48
|
() => ({
|
|
25
49
|
defaultFilters: {
|
|
@@ -36,7 +60,8 @@ export const BundleAssets = (props) => {
|
|
|
36
60
|
[jobs],
|
|
37
61
|
);
|
|
38
62
|
|
|
39
|
-
|
|
63
|
+
// Get search params data
|
|
64
|
+
const searchProps = useSearchParams({
|
|
40
65
|
search,
|
|
41
66
|
filters,
|
|
42
67
|
defaultFilters,
|
|
@@ -44,19 +69,22 @@ export const BundleAssets = (props) => {
|
|
|
44
69
|
setState,
|
|
45
70
|
});
|
|
46
71
|
|
|
72
|
+
// Get metric rows
|
|
47
73
|
const { rows, totalRowCount } = useMemo(() => {
|
|
48
74
|
const result = webpack.compareBySection.assets(jobs, [addMetricReportAssetRowData]);
|
|
49
75
|
return { rows: result, totalRowCount: result.length };
|
|
50
76
|
}, [jobs]);
|
|
51
77
|
|
|
78
|
+
// Filter rows
|
|
52
79
|
const filteredRows = useRowsFilter({
|
|
53
80
|
rows,
|
|
54
|
-
searchPattern:
|
|
55
|
-
filters:
|
|
56
|
-
getRowFilter,
|
|
81
|
+
searchPattern: searchProps.searchPattern,
|
|
82
|
+
filters: searchProps.filters,
|
|
83
|
+
getRowFilter: generateGetRowFilter({ chunkIds }),
|
|
57
84
|
});
|
|
58
85
|
|
|
59
|
-
|
|
86
|
+
// Sort rows
|
|
87
|
+
const sortProps = useRowsSort<ReportMetricAssetRow>({
|
|
60
88
|
rows: filteredRows,
|
|
61
89
|
initialField: sortBy,
|
|
62
90
|
initialDirection: direction,
|
|
@@ -68,31 +96,17 @@ export const BundleAssets = (props) => {
|
|
|
68
96
|
|
|
69
97
|
return (
|
|
70
98
|
<BundleAssetsComponent
|
|
99
|
+
{...restProps}
|
|
100
|
+
{...searchProps}
|
|
71
101
|
jobs={jobs}
|
|
72
102
|
chunks={chunks}
|
|
73
|
-
{
|
|
74
|
-
{
|
|
75
|
-
{...sortParams}
|
|
103
|
+
sort={sortProps.sort}
|
|
104
|
+
items={sortProps.items}
|
|
76
105
|
allItems={rows}
|
|
77
106
|
totalRowCount={totalRowCount}
|
|
107
|
+
updateSort={sortProps.updateSort}
|
|
78
108
|
hideEntryInfo={hideEntryInfo}
|
|
79
109
|
showEntryInfo={showEntryInfo}
|
|
80
110
|
/>
|
|
81
111
|
);
|
|
82
112
|
};
|
|
83
|
-
|
|
84
|
-
BundleAssets.propTypes = {
|
|
85
|
-
jobs: PropTypes.arrayOf(PropTypes.object).isRequired, // eslint-disable-line react/forbid-prop-types
|
|
86
|
-
filters: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
|
87
|
-
search: PropTypes.string,
|
|
88
|
-
sortBy: PropTypes.string,
|
|
89
|
-
direction: PropTypes.string,
|
|
90
|
-
setState: PropTypes.func.isRequired,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
BundleAssets.defaultProps = {
|
|
94
|
-
filters: undefined,
|
|
95
|
-
search: undefined,
|
|
96
|
-
sortBy: undefined,
|
|
97
|
-
direction: undefined,
|
|
98
|
-
};
|
|
@@ -9,7 +9,7 @@ import { Table } from '../../ui/table';
|
|
|
9
9
|
import { Stack } from '../../layout/stack';
|
|
10
10
|
import { Metric } from '../metric';
|
|
11
11
|
import { Delta } from '../delta';
|
|
12
|
-
import { MetricsTableHeader } from '../metrics-table-header';
|
|
12
|
+
import { MetricsTableHeader, MetricsTableHeaderProps } from '../metrics-table-header';
|
|
13
13
|
import * as I18N from './metrics-table.i18n';
|
|
14
14
|
import css from './metrics-table.module.css';
|
|
15
15
|
|
|
@@ -74,8 +74,8 @@ interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'ti
|
|
|
74
74
|
items: Array<ReportMetricRow>;
|
|
75
75
|
title?: React.ReactNode;
|
|
76
76
|
showHeaderSum?: boolean;
|
|
77
|
-
sort?:
|
|
78
|
-
updateSort?:
|
|
77
|
+
sort?: MetricsTableHeaderProps['sort'];
|
|
78
|
+
updateSort?: MetricsTableHeaderProps['updateSort'];
|
|
79
79
|
renderRowHeader?: (item: ReportMetricRow) => React.ReactNode;
|
|
80
80
|
emptyMessage?: React.ReactNode;
|
|
81
81
|
showAllItems: boolean;
|
|
@@ -12,7 +12,7 @@ import { Table } from '../../ui/table';
|
|
|
12
12
|
import { Delta } from '../delta';
|
|
13
13
|
import { JobName } from '../job-name';
|
|
14
14
|
import { Metric } from '../metric';
|
|
15
|
-
import { SortButton } from '../sort-button';
|
|
15
|
+
import { SortButton, SortButtonProps } from '../sort-button';
|
|
16
16
|
import * as I18N from './metrics-table-header.i18n';
|
|
17
17
|
import css from './metrics-table-header.module.css';
|
|
18
18
|
|
|
@@ -53,8 +53,8 @@ interface ColumnSumProps {
|
|
|
53
53
|
rows: Array<ReportMetricRow>;
|
|
54
54
|
isBaseline: boolean;
|
|
55
55
|
runIndex: number;
|
|
56
|
-
sort?:
|
|
57
|
-
updateSort?:
|
|
56
|
+
sort?: SortButtonProps['sort'];
|
|
57
|
+
updateSort?: SortButtonProps['updateSort'];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const SumColumn = ({ rows, isBaseline, runIndex, updateSort, sort }: ColumnSumProps) => {
|
|
@@ -110,7 +110,7 @@ const SumColumn = ({ rows, isBaseline, runIndex, updateSort, sort }: ColumnSumPr
|
|
|
110
110
|
);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
interface MetricsTableHeaderProps {
|
|
113
|
+
export interface MetricsTableHeaderProps {
|
|
114
114
|
/**
|
|
115
115
|
* Metric column title
|
|
116
116
|
*/
|
|
@@ -36,7 +36,7 @@ const getDescAction = (label: string): SortInfo => {
|
|
|
36
36
|
return { direction: SORT.DESC, title: `Order ${label} descending` };
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
interface SortButtonProps {
|
|
39
|
+
export interface SortButtonProps {
|
|
40
40
|
fieldPath: string;
|
|
41
41
|
fieldName: string;
|
|
42
42
|
label: string;
|
package/src/hooks/rows-sort.ts
CHANGED
|
@@ -5,6 +5,21 @@ import orderBy from 'lodash/orderBy';
|
|
|
5
5
|
import type { SortAction } from '../types';
|
|
6
6
|
import { SORT } from '../constants';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Get sort direction field from a string param
|
|
10
|
+
*/
|
|
11
|
+
const getSortDirection = (directionParam: string | undefined): SortAction['direction'] => {
|
|
12
|
+
if (typeof directionParam === 'undefined') {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (['asc', 'desc'].includes(directionParam)) {
|
|
17
|
+
return directionParam as SortAction['direction'];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return '';
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
export const getSortFn =
|
|
9
24
|
<TRow>(fieldPath: string, getCustomSort: UseRowsSortParams<TRow>['getCustomSort']) =>
|
|
10
25
|
(item: TRow) => {
|
|
@@ -18,7 +33,7 @@ export const getSortFn =
|
|
|
18
33
|
interface UseRowsSortParams<TRow> {
|
|
19
34
|
rows: Array<TRow>;
|
|
20
35
|
initialField?: string;
|
|
21
|
-
initialDirection?:
|
|
36
|
+
initialDirection?: string;
|
|
22
37
|
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
23
38
|
setQueryState: (queryParams: {
|
|
24
39
|
sortBy: SortAction['field'];
|
|
@@ -35,11 +50,14 @@ interface UseRowsSort<TRow> {
|
|
|
35
50
|
export const useRowsSort = <TRow>({
|
|
36
51
|
rows,
|
|
37
52
|
initialField = 'runs[0].delta',
|
|
38
|
-
initialDirection
|
|
53
|
+
initialDirection,
|
|
39
54
|
getCustomSort,
|
|
40
55
|
setQueryState,
|
|
41
56
|
}: UseRowsSortParams<TRow>): UseRowsSort<TRow> => {
|
|
42
|
-
const [sort, setSort] = useState({
|
|
57
|
+
const [sort, setSort] = useState({
|
|
58
|
+
field: initialField,
|
|
59
|
+
direction: getSortDirection(initialDirection),
|
|
60
|
+
});
|
|
43
61
|
|
|
44
62
|
const updateSort = useCallback(
|
|
45
63
|
(newState: SortAction) => {
|
package/src/types.d.ts
CHANGED
|
@@ -12,9 +12,13 @@ interface FilterFieldData {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
interface ChildFilterFieldData extends FilterFieldData {
|
|
16
|
+
key: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
type FilterGroupFieldData = {
|
|
16
20
|
label: string;
|
|
17
|
-
children: Array<
|
|
21
|
+
children: Array<ChildFilterFieldData>;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
type FilterFieldsData = Record<string, FilterFieldData | FilterGroupFieldData>;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import type { ComponentProps, ElementType } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
3
|
+
import type { WebpackChunk } from '@bundle-stats/utils';
|
|
4
|
+
import type { ReportMetricAssetRow } from '../../types';
|
|
5
5
|
interface AssetInfoProps {
|
|
6
|
-
item:
|
|
7
|
-
|
|
8
|
-
changed?: boolean;
|
|
9
|
-
isChunk?: boolean;
|
|
10
|
-
isEntry?: boolean;
|
|
11
|
-
isInitial?: boolean;
|
|
12
|
-
isNotPredictive?: boolean;
|
|
13
|
-
fileType?: string;
|
|
14
|
-
runs: Array<AssetMetricRun & MetricRunInfo>;
|
|
15
|
-
};
|
|
16
|
-
chunks?: Array<MetaChunk>;
|
|
6
|
+
item: ReportMetricAssetRow;
|
|
7
|
+
chunks?: Array<WebpackChunk>;
|
|
17
8
|
labels: Array<string>;
|
|
18
9
|
customComponentLink?: ElementType;
|
|
19
10
|
onClose: () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ENTRY = "Entry";
|
|
2
|
+
export declare const INITIAL = "Initial";
|
|
3
|
+
export declare const CHUNK = "Chunk";
|
|
4
|
+
export declare const CHUNK_TOOLTIP = "The bundler's chunk from which the assets originated";
|
|
5
|
+
export declare const ENTRYPOINT = "Entrypoint";
|
|
6
|
+
export declare const FILE_TYPE = "File type";
|
|
7
|
+
export declare const FILE_TYPE_TOOLTIP = "Asset file type: JS, CSS, image, media, fonts, HTML, or other";
|
|
@@ -1,56 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}> | null | undefined)[]>;
|
|
25
|
-
}> | null | undefined)[]>;
|
|
26
|
-
export let updateFilters: PropTypes.Validator<(...args: any[]) => any>;
|
|
27
|
-
export let resetFilters: PropTypes.Validator<(...args: any[]) => any>;
|
|
28
|
-
export let resetAllFilters: PropTypes.Validator<(...args: any[]) => any>;
|
|
29
|
-
let totalRowCount_1: PropTypes.Requireable<number>;
|
|
30
|
-
export { totalRowCount_1 as totalRowCount };
|
|
31
|
-
export let filters: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
32
|
-
changed: PropTypes.Requireable<boolean>;
|
|
33
|
-
id: PropTypes.Requireable<string>;
|
|
34
|
-
}>>>;
|
|
35
|
-
let entryId_1: PropTypes.Requireable<string>;
|
|
36
|
-
export { entryId_1 as entryId };
|
|
37
|
-
let hasActiveFilters_1: PropTypes.Requireable<boolean>;
|
|
38
|
-
export { hasActiveFilters_1 as hasActiveFilters };
|
|
39
|
-
export let search: PropTypes.Validator<string>;
|
|
40
|
-
export let updateSearch: PropTypes.Validator<(...args: any[]) => any>;
|
|
41
|
-
export let sort: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
42
|
-
field: PropTypes.Requireable<string>;
|
|
43
|
-
direction: PropTypes.Requireable<string>;
|
|
44
|
-
}>>>;
|
|
45
|
-
export let updateSort: PropTypes.Validator<(...args: any[]) => any>;
|
|
46
|
-
export let allItems: PropTypes.Validator<(PropTypes.InferProps<{
|
|
47
|
-
key: PropTypes.Requireable<string>;
|
|
48
|
-
}> | null | undefined)[]>;
|
|
49
|
-
export let customComponentLink: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
50
|
-
export let hideEntryInfo: PropTypes.Validator<(...args: any[]) => any>;
|
|
51
|
-
export let showEntryInfo: PropTypes.Validator<(...args: any[]) => any>;
|
|
52
|
-
}
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import React, { ComponentProps } from 'react';
|
|
3
|
+
import type { Job, WebpackChunk } from '@bundle-stats/utils';
|
|
4
|
+
import type { ReportMetricAssetRow, SortAction } from '../../types';
|
|
5
|
+
import { Stack } from '../../layout/stack';
|
|
6
|
+
export interface BundleAssetsProps extends ComponentProps<typeof Stack> {
|
|
7
|
+
jobs: Array<Job>;
|
|
8
|
+
chunks: Array<WebpackChunk>;
|
|
9
|
+
items: Array<ReportMetricAssetRow>;
|
|
10
|
+
allItems: Array<ReportMetricAssetRow>;
|
|
11
|
+
filters: Record<string, boolean>;
|
|
12
|
+
updateFilters: (newFilters: Record<string, boolean>) => void;
|
|
13
|
+
resetFilters: () => void;
|
|
14
|
+
resetAllFilters: () => void;
|
|
15
|
+
totalRowCount?: number;
|
|
16
|
+
entryId?: string;
|
|
17
|
+
sort: SortAction;
|
|
18
|
+
updateSort: (params: SortAction) => void;
|
|
19
|
+
search: string;
|
|
20
|
+
updateSearch: (search: string) => void;
|
|
21
|
+
customComponentLink?: ElementType;
|
|
22
|
+
hideEntryInfo: () => void;
|
|
23
|
+
showEntryInfo: (entryId: string) => void;
|
|
53
24
|
}
|
|
54
|
-
|
|
55
|
-
import { ComponentLink } from '../component-link';
|
|
56
|
-
import PropTypes from 'prop-types';
|
|
25
|
+
export declare const BundleAssets: (props: BundleAssetsProps) => React.JSX.Element;
|
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export declare const SEARCH_PLACEHOLDER = "Search by asset path";
|
|
2
|
+
export declare const CHANGED = "Changed";
|
|
3
|
+
export declare const FILE_TYPE = "File type";
|
|
4
|
+
export declare const CHUNKS = "Chunks";
|
|
5
|
+
export declare const NO_CHUNK = "No chunk";
|
|
6
|
+
export declare const ENTRY = "Entry";
|
|
7
|
+
export declare const INITIAL = "Initial";
|
|
8
|
+
export declare const CHUNK = "Chunk";
|
|
9
|
+
export declare const OTHER = "Other";
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import type { ReportMetricRow, WebpackChunk } from '@bundle-stats/utils';
|
|
2
|
+
import type { FilterFieldsData, ReportMetricAssetRow, ReportMetricAssetRowMetaStatus } from '../../types';
|
|
3
|
+
export declare const getIsNotPredictive: (row: ReportMetricRow) => boolean;
|
|
4
|
+
export declare const getAssetMetaStatus: (values: Array<boolean | undefined>) => ReportMetricAssetRowMetaStatus | boolean;
|
|
5
|
+
export declare const addMetricReportAssetRowData: (row: ReportMetricRow) => ReportMetricAssetRow;
|
|
6
|
+
type GenerateGetRowFilterOptions = {
|
|
7
|
+
chunkIds: Array<string>;
|
|
8
|
+
};
|
|
9
|
+
export declare const getCustomSort: (item: ReportMetricAssetRow) => Array<boolean | string>;
|
|
10
|
+
type GetFiltersOptions = {
|
|
11
|
+
compareMode: boolean;
|
|
12
|
+
filters: Record<string, boolean>;
|
|
13
|
+
chunks: Array<WebpackChunk>;
|
|
14
|
+
};
|
|
15
|
+
export declare const getFilters: ({ compareMode, filters, chunks, }: GetFiltersOptions) => FilterFieldsData;
|
|
16
|
+
export declare const generateGetRowFilter: ({ chunkIds }: GenerateGetRowFilterOptions) => (filters: Record<string, unknown>) => (item: ReportMetricAssetRow) => boolean;
|
|
17
|
+
export {};
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
export function BundleAssets(props: any): React.JSX.Element;
|
|
2
|
-
export namespace BundleAssets {
|
|
3
|
-
namespace propTypes {
|
|
4
|
-
let jobs: PropTypes.Validator<(object | null | undefined)[]>;
|
|
5
|
-
let filters: PropTypes.Requireable<object>;
|
|
6
|
-
let search: PropTypes.Requireable<string>;
|
|
7
|
-
let sortBy: PropTypes.Requireable<string>;
|
|
8
|
-
let direction: PropTypes.Requireable<string>;
|
|
9
|
-
let setState: PropTypes.Validator<(...args: any[]) => any>;
|
|
10
|
-
}
|
|
11
|
-
namespace defaultProps {
|
|
12
|
-
let filters_1: undefined;
|
|
13
|
-
export { filters_1 as filters };
|
|
14
|
-
let search_1: undefined;
|
|
15
|
-
export { search_1 as search };
|
|
16
|
-
let sortBy_1: undefined;
|
|
17
|
-
export { sortBy_1 as sortBy };
|
|
18
|
-
let direction_1: undefined;
|
|
19
|
-
export { direction_1 as direction };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
1
|
import React from 'react';
|
|
23
|
-
import
|
|
2
|
+
import type { Job } from '@bundle-stats/utils';
|
|
3
|
+
export type BundleAssetsProps = {
|
|
4
|
+
jobs: Array<Job>;
|
|
5
|
+
filters?: Record<string, boolean>;
|
|
6
|
+
search?: string;
|
|
7
|
+
sortBy?: string;
|
|
8
|
+
direction?: string;
|
|
9
|
+
setState: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const BundleAssets: (props: BundleAssetsProps) => React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ReportMetricRow } from '@bundle-stats/utils';
|
|
3
3
|
import { Table } from '../../ui/table';
|
|
4
|
+
import { MetricsTableHeaderProps } from '../metrics-table-header';
|
|
4
5
|
interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'title'> {
|
|
5
6
|
runs: Array<{
|
|
6
7
|
label: string;
|
|
@@ -9,8 +10,8 @@ interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'ti
|
|
|
9
10
|
items: Array<ReportMetricRow>;
|
|
10
11
|
title?: React.ReactNode;
|
|
11
12
|
showHeaderSum?: boolean;
|
|
12
|
-
sort?:
|
|
13
|
-
updateSort?:
|
|
13
|
+
sort?: MetricsTableHeaderProps['sort'];
|
|
14
|
+
updateSort?: MetricsTableHeaderProps['updateSort'];
|
|
14
15
|
renderRowHeader?: (item: ReportMetricRow) => React.ReactNode;
|
|
15
16
|
emptyMessage?: React.ReactNode;
|
|
16
17
|
showAllItems: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ReportMetricRow } from '@bundle-stats/utils';
|
|
3
|
-
interface MetricsTableHeaderProps {
|
|
3
|
+
export interface MetricsTableHeaderProps {
|
|
4
4
|
metricTitle?: React.ReactNode;
|
|
5
5
|
showSum?: boolean;
|
|
6
6
|
jobs: Array<{
|
|
@@ -12,4 +12,3 @@ interface MetricsTableHeaderProps {
|
|
|
12
12
|
updateSort?: (val: any) => void;
|
|
13
13
|
}
|
|
14
14
|
export declare const MetricsTableHeader: (props: MetricsTableHeaderProps & React.ComponentProps<"thead">) => React.JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SortAction } from '../../types';
|
|
3
|
-
interface SortButtonProps {
|
|
3
|
+
export interface SortButtonProps {
|
|
4
4
|
fieldPath: string;
|
|
5
5
|
fieldName: string;
|
|
6
6
|
label: string;
|
|
@@ -8,4 +8,3 @@ interface SortButtonProps {
|
|
|
8
8
|
updateSort?: (params: SortAction) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const SortButton: (props: SortButtonProps & React.ComponentProps<"div">) => React.JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -3,7 +3,7 @@ export declare const getSortFn: <TRow>(fieldPath: string, getCustomSort: UseRows
|
|
|
3
3
|
interface UseRowsSortParams<TRow> {
|
|
4
4
|
rows: Array<TRow>;
|
|
5
5
|
initialField?: string;
|
|
6
|
-
initialDirection?:
|
|
6
|
+
initialDirection?: string;
|
|
7
7
|
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
8
8
|
setQueryState: (queryParams: {
|
|
9
9
|
sortBy: SortAction['field'];
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {import('@bundle-stats/utils').ReportMetricRow} ReportMetricRow
|
|
3
|
-
* @type {import('../../types').ReportMetricAssetRow} ReportMetricAssetRow
|
|
4
|
-
* @type {import('../../types').ReportMetricAssetRowMetaStatus} ReportMetricAssetRowFlagStatus
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, getFileType } from '@bundle-stats/utils';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Check if the asset cache is not predictive
|
|
11
|
-
*
|
|
12
|
-
* @param {ReportMetricRow} row
|
|
13
|
-
* @returns {boolean}
|
|
14
|
-
*/
|
|
15
|
-
export const getIsNotPredictive = (row) => {
|
|
16
|
-
const { key, runs } = row;
|
|
17
|
-
|
|
18
|
-
return runs.reduce((agg, current, index) => {
|
|
19
|
-
if (agg) {
|
|
20
|
-
return agg;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (index + 1 === runs.length) {
|
|
24
|
-
return agg;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
current &&
|
|
29
|
-
runs[index + 1] &&
|
|
30
|
-
key !== current.name &&
|
|
31
|
-
current.name === runs[index + 1].name &&
|
|
32
|
-
current.value !== runs[index + 1].value
|
|
33
|
-
) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return agg;
|
|
38
|
-
}, false);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {Array<boolean>}
|
|
43
|
-
* @returns {ReportMetricAssetRowFlagStatus | boolean}
|
|
44
|
-
*/
|
|
45
|
-
export const getAssetMetaStatus = (values) => {
|
|
46
|
-
if (!values.includes(true)) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// filter empty runs
|
|
51
|
-
const metaValues = values.filter((value) => typeof value !== 'undefined');
|
|
52
|
-
|
|
53
|
-
const current = metaValues[0];
|
|
54
|
-
const metaValuesLength = metaValues.length;
|
|
55
|
-
|
|
56
|
-
if (metaValuesLength === 1) {
|
|
57
|
-
return Boolean(current);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const baseline = metaValues[metaValuesLength - 1];
|
|
61
|
-
|
|
62
|
-
if (current && !baseline) {
|
|
63
|
-
return 'added';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!current && baseline) {
|
|
67
|
-
return 'removed';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Add asset row flags
|
|
75
|
-
*
|
|
76
|
-
* @param {ReportMetricRow} row
|
|
77
|
-
* @returns {ReportMetricAssetRow}
|
|
78
|
-
*/
|
|
79
|
-
export const addMetricReportAssetRowData = (row) => {
|
|
80
|
-
const { changed, runs } = row;
|
|
81
|
-
|
|
82
|
-
// Collect meta for each run
|
|
83
|
-
const runsEntry = [];
|
|
84
|
-
const runsInitial = [];
|
|
85
|
-
const runsChunk = [];
|
|
86
|
-
|
|
87
|
-
runs.forEach((run) => {
|
|
88
|
-
runsEntry.push(run?.isEntry);
|
|
89
|
-
runsInitial.push(run?.isInitial);
|
|
90
|
-
runsChunk.push(run?.isChunk);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const isEntry = getAssetMetaStatus(runsEntry);
|
|
94
|
-
const isInitial = getAssetMetaStatus(runsInitial);
|
|
95
|
-
const isChunk = getAssetMetaStatus(runsChunk);
|
|
96
|
-
const isAsset = !(isEntry || isInitial || isChunk);
|
|
97
|
-
const isNotPredictive = getIsNotPredictive(row);
|
|
98
|
-
const fileType = getFileType(row.key);
|
|
99
|
-
|
|
100
|
-
// Flag asset as changed if name and value are identical, if one of the meta tags is changed
|
|
101
|
-
const assetChanged =
|
|
102
|
-
changed ||
|
|
103
|
-
typeof isEntry !== 'boolean' ||
|
|
104
|
-
typeof isInitial !== 'boolean' ||
|
|
105
|
-
typeof isChunk !== 'boolean';
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
...row,
|
|
109
|
-
changed: assetChanged,
|
|
110
|
-
isEntry,
|
|
111
|
-
isInitial,
|
|
112
|
-
isChunk,
|
|
113
|
-
isAsset,
|
|
114
|
-
isNotPredictive,
|
|
115
|
-
fileType,
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const getRowFilter = (filters) => (item) => {
|
|
120
|
-
if (filters[ASSET_FILTERS.CHANGED] && !item.changed) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
!(
|
|
126
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.ENTRY}`] && item.isEntry) ||
|
|
127
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.INITIAL}`] && item.isInitial) ||
|
|
128
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.CHUNK}`] && item.isChunk) ||
|
|
129
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.OTHER}`] && item.isAsset)
|
|
130
|
-
)
|
|
131
|
-
) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!filters[`${ASSET_FILE_TYPE}.${item.fileType}`]) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return true;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const getCustomSort = (item) => [
|
|
143
|
-
!item.isNotPredictive,
|
|
144
|
-
!item.changed,
|
|
145
|
-
!item.isInitial,
|
|
146
|
-
!item.isEntry,
|
|
147
|
-
!item.isChunk,
|
|
148
|
-
item.key,
|
|
149
|
-
];
|