@bundle-stats/ui 4.14.0-beta.0 → 4.14.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/lib/components/asset-info/asset-info.js +1 -1
- package/lib/components/asset-info/asset-info.js.map +1 -1
- package/lib/components/bundle-modules/bundle-modules.js +16 -11
- package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib/components/bundle-modules/bundle-modules.utils.js +18 -4
- package/lib/components/bundle-modules/bundle-modules.utils.js.map +1 -1
- package/lib/components/bundle-modules/index.js +5 -5
- package/lib/components/bundle-modules/index.js.map +1 -1
- package/lib/components/entry-info/entry-info.js +16 -9
- package/lib/components/entry-info/entry-info.js.map +1 -1
- package/lib/components/entry-info/entry-info.module.css +34 -8
- package/lib/components/module-info/module-info.js +80 -16
- package/lib/components/module-info/module-info.js.map +1 -1
- package/lib/components/module-info/module-info.module.css +38 -0
- package/lib/components/package-info/package-info.js +1 -1
- package/lib/components/package-info/package-info.js.map +1 -1
- package/lib/components/run-info/run-info.module.css +1 -1
- package/lib/constants.js +21 -1
- package/lib/constants.js.map +1 -1
- package/lib/hooks/rows-sort.js.map +1 -1
- package/lib-esm/components/asset-info/asset-info.js +1 -1
- package/lib-esm/components/asset-info/asset-info.js.map +1 -1
- package/lib-esm/components/bundle-modules/bundle-modules.js +17 -12
- package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js +19 -4
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js.map +1 -1
- package/lib-esm/components/bundle-modules/index.js +5 -5
- package/lib-esm/components/bundle-modules/index.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.js +16 -9
- package/lib-esm/components/entry-info/entry-info.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.module.css +34 -8
- package/lib-esm/components/module-info/module-info.js +84 -19
- package/lib-esm/components/module-info/module-info.js.map +1 -1
- package/lib-esm/components/module-info/module-info.module.css +38 -0
- package/lib-esm/components/package-info/package-info.js +1 -1
- package/lib-esm/components/package-info/package-info.js.map +1 -1
- package/lib-esm/components/run-info/run-info.module.css +1 -1
- package/lib-esm/constants.js +20 -0
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/hooks/rows-sort.js.map +1 -1
- package/package.json +9 -9
- package/src/components/asset-info/asset-info.tsx +5 -2
- package/src/components/bundle-modules/bundle-modules.tsx +34 -22
- package/src/components/bundle-modules/bundle-modules.utils.ts +37 -14
- package/src/components/bundle-modules/index.tsx +15 -14
- package/src/components/entry-info/entry-info.module.css +34 -8
- package/src/components/entry-info/entry-info.tsx +47 -32
- package/src/components/module-info/module-info.module.css +38 -0
- package/src/components/module-info/module-info.stories.tsx +57 -3
- package/src/components/module-info/module-info.tsx +221 -40
- package/src/components/package-info/package-info.tsx +2 -3
- package/src/components/run-info/run-info.module.css +1 -1
- package/src/constants.ts +22 -1
- package/src/hooks/rows-sort.ts +17 -10
- package/src/types.d.ts +13 -0
- package/types/components/bundle-modules/bundle-modules.d.ts +4 -5
- package/types/components/bundle-modules/bundle-modules.utils.d.ts +3 -5
- package/types/components/entry-info/entry-info.d.ts +8 -10
- package/types/components/module-info/module-info.d.ts +4 -10
- package/types/constants.d.ts +21 -2
- package/types/hooks/rows-sort.d.ts +9 -14
- package/lib/components/bundle-modules/bundle-modules.constants.js +0 -10
- package/lib/components/bundle-modules/bundle-modules.constants.js.map +0 -1
- package/lib-esm/components/bundle-modules/bundle-modules.constants.js +0 -7
- package/lib-esm/components/bundle-modules/bundle-modules.constants.js.map +0 -1
- package/src/components/bundle-modules/bundle-modules.constants.ts +0 -5
- package/src/components/bundle-modules/bundle-modules.types.d.ts +0 -9
- package/types/components/bundle-modules/bundle-modules.constants.d.ts +0 -5
package/src/hooks/rows-sort.ts
CHANGED
|
@@ -5,15 +5,9 @@ import orderBy from 'lodash/orderBy';
|
|
|
5
5
|
import type { SortAction } from '../types';
|
|
6
6
|
import { SORT } from '../constants';
|
|
7
7
|
|
|
8
|
-
interface UseRowsSortParams {
|
|
9
|
-
rows: Array<unknown>;
|
|
10
|
-
initialField?: string;
|
|
11
|
-
initialDirection?: SortAction['direction'];
|
|
12
|
-
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
export const getSortFn =
|
|
16
|
-
(fieldPath: string, getCustomSort: UseRowsSortParams['getCustomSort']) =>
|
|
9
|
+
<TRow>(fieldPath: string, getCustomSort: UseRowsSortParams<TRow>['getCustomSort']) =>
|
|
10
|
+
(item: TRow) => {
|
|
17
11
|
if (!fieldPath) {
|
|
18
12
|
return getCustomSort(item);
|
|
19
13
|
}
|
|
@@ -21,12 +15,25 @@ export const getSortFn =
|
|
|
21
15
|
return get(item, fieldPath) || 0;
|
|
22
16
|
};
|
|
23
17
|
|
|
24
|
-
|
|
18
|
+
interface UseRowsSortParams<TRow> {
|
|
19
|
+
rows: Array<TRow>;
|
|
20
|
+
initialField?: string;
|
|
21
|
+
initialDirection?: SortAction['direction'];
|
|
22
|
+
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface UseRowsSort<TRow> {
|
|
26
|
+
items: Array<TRow>;
|
|
27
|
+
sort: SortAction;
|
|
28
|
+
updateSort: (params: SortAction) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const useRowsSort = <TRow>({
|
|
25
32
|
rows,
|
|
26
33
|
initialField = 'runs[0].delta',
|
|
27
34
|
initialDirection = 'desc',
|
|
28
35
|
getCustomSort,
|
|
29
|
-
}: UseRowsSortParams) => {
|
|
36
|
+
}: UseRowsSortParams<TRow>): UseRowsSort<TRow> => {
|
|
30
37
|
const [sort, updateSort] = useState({ field: initialField, direction: initialDirection });
|
|
31
38
|
|
|
32
39
|
const orderedRows = useMemo(
|
package/src/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ReportMetricRow } from '@bundle-stats/utils';
|
|
2
|
+
import type { Module } from '@bundle-stats/utils/types/webpack/types';
|
|
3
|
+
|
|
1
4
|
export interface SortAction {
|
|
2
5
|
field: string;
|
|
3
6
|
direction: 'asc' | 'desc' | '';
|
|
@@ -15,3 +18,13 @@ type FilterGroupFieldData = {
|
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
type FilterFieldsData = Record<string, FilterFieldData | FilterGroupFieldData>;
|
|
21
|
+
|
|
22
|
+
export type ReportMetricModuleRow = {
|
|
23
|
+
thirdParty: boolean;
|
|
24
|
+
duplicated: boolean;
|
|
25
|
+
fileType: string;
|
|
26
|
+
} & Omit<ReportMetricRow, 'runs'> & {
|
|
27
|
+
runs: Array<
|
|
28
|
+
(Module & ReportMetricRun & { size: number; sizeDuplicate: number; sizeTotal: number }) | null
|
|
29
|
+
>;
|
|
30
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type Job } from '@bundle-stats/utils';
|
|
3
3
|
import { WebpackChunk } from '@bundle-stats/utils';
|
|
4
|
-
import { SortAction } from '../../types';
|
|
5
|
-
import {
|
|
6
|
-
import type { ReportMetricModuleRow } from './bundle-modules.types';
|
|
4
|
+
import type { ReportMetricModuleRow, SortAction } from '../../types';
|
|
5
|
+
import { ModuleSizeMetric } from '../../constants';
|
|
7
6
|
interface BundleModulesProps extends React.ComponentProps<'div'> {
|
|
8
7
|
jobs?: Array<Job>;
|
|
9
8
|
items?: Array<ReportMetricModuleRow>;
|
|
@@ -21,8 +20,8 @@ interface BundleModulesProps extends React.ComponentProps<'div'> {
|
|
|
21
20
|
entryId?: string;
|
|
22
21
|
hideEntryInfo: () => void;
|
|
23
22
|
showEntryInfo: (entryId: string) => void;
|
|
24
|
-
moduleMetric:
|
|
25
|
-
setModuleMetric: (newValue:
|
|
23
|
+
moduleMetric: ModuleSizeMetric;
|
|
24
|
+
setModuleMetric: (newValue: ModuleSizeMetric) => void;
|
|
26
25
|
customComponentLink: React.ElementType;
|
|
27
26
|
}
|
|
28
27
|
export declare const BundleModules: (props: BundleModulesProps) => React.JSX.Element;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { ReportMetricModuleRow } from './bundle-modules.types';
|
|
5
|
-
export declare const addRowFlags: (row: Module & ReportMetricRow) => ReportMetricModuleRow;
|
|
1
|
+
import type { WebpackChunk, ReportMetricRow } from '@bundle-stats/utils';
|
|
2
|
+
import type { FilterFieldsData, ReportMetricModuleRow } from '../../types';
|
|
3
|
+
export declare const addRowFlags: (row: ReportMetricRow) => ReportMetricModuleRow;
|
|
6
4
|
export declare const getCustomSort: (item: ReportMetricRow) => (string | boolean)[];
|
|
7
5
|
export declare const generateGetRowFilter: ({ chunkIds }: {
|
|
8
6
|
chunkIds: Array<string>;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
+
import type { ElementType, ReactNode } from 'react';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
+
import type { ReportMetricRow } from '@bundle-stats/utils';
|
|
3
4
|
interface EntryInfoMetaLinkProps {
|
|
4
|
-
as?:
|
|
5
|
+
as?: ElementType;
|
|
5
6
|
}
|
|
6
7
|
export declare const EntryInfoMetaLink: (props: EntryInfoMetaLinkProps & React.ComponentProps<"a">) => React.JSX.Element;
|
|
7
8
|
interface EntryInfoMetaProps {
|
|
8
9
|
label: string;
|
|
9
|
-
|
|
10
|
-
interface EntryRun {
|
|
11
|
-
name: string;
|
|
10
|
+
tooltip?: ReactNode;
|
|
12
11
|
}
|
|
13
12
|
interface EntryInfoProps {
|
|
14
13
|
itemTitle?: React.ReactNode;
|
|
15
|
-
item:
|
|
16
|
-
label: string;
|
|
17
|
-
runs: Array<EntryRun & MetricRunInfo>;
|
|
18
|
-
};
|
|
14
|
+
item: ReportMetricRow;
|
|
19
15
|
labels: Array<string>;
|
|
20
16
|
runNameSelector?: string;
|
|
21
17
|
runNameLabel?: string;
|
|
18
|
+
runSizeLabel?: string;
|
|
22
19
|
tags?: React.ReactNode;
|
|
23
20
|
onClose: () => void;
|
|
21
|
+
renderRunInfo?: (item: ReportMetricRow) => React.ReactNode;
|
|
24
22
|
}
|
|
25
23
|
export declare const EntryInfo: {
|
|
26
24
|
(props: EntryInfoProps & React.ComponentProps<"div">): React.JSX.Element;
|
|
27
|
-
Meta: ({ className, label, children, }: EntryInfoMetaProps & React.ComponentProps<"p">) => React.JSX.Element;
|
|
25
|
+
Meta: ({ className, label, tooltip, children, }: EntryInfoMetaProps & React.ComponentProps<"p">) => React.JSX.Element;
|
|
28
26
|
};
|
|
29
27
|
export {};
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { MetaChunk } from '@bundle-stats/utils/types/webpack';
|
|
3
|
+
import type { ReportMetricModuleRow } from '../../types';
|
|
4
4
|
interface ModuleInfoProps {
|
|
5
|
-
item:
|
|
6
|
-
label: string;
|
|
7
|
-
changed?: boolean;
|
|
8
|
-
duplicated?: boolean;
|
|
9
|
-
thirdParty?: boolean;
|
|
10
|
-
fileType?: string;
|
|
11
|
-
runs: Array<Module & MetricRunInfo>;
|
|
12
|
-
};
|
|
5
|
+
item: ReportMetricModuleRow;
|
|
13
6
|
chunks?: Array<MetaChunk>;
|
|
14
7
|
chunkIds?: Array<string>;
|
|
15
8
|
labels: Array<string>;
|
|
9
|
+
metricLabel?: string;
|
|
16
10
|
customComponentLink?: React.ElementType;
|
|
17
11
|
onClose: () => void;
|
|
18
12
|
}
|
package/types/constants.d.ts
CHANGED
|
@@ -13,10 +13,29 @@ export declare const METRICS_WEBPACK_ASSETS: string[];
|
|
|
13
13
|
export declare const METRICS_WEBPACK_MODULES: string[];
|
|
14
14
|
export declare const METRICS_WEBPACK_PACKAGES: string[];
|
|
15
15
|
export declare const SORT: {
|
|
16
|
-
ASC:
|
|
17
|
-
DESC:
|
|
16
|
+
readonly ASC: "asc";
|
|
17
|
+
readonly DESC: "desc";
|
|
18
18
|
};
|
|
19
19
|
export declare enum MetricsDisplayType {
|
|
20
20
|
TABLE = "table",
|
|
21
21
|
TREEMAP = "treemap"
|
|
22
22
|
}
|
|
23
|
+
export declare enum ModuleSizeMetric {
|
|
24
|
+
SIZE = "value",
|
|
25
|
+
DUPLICATE_SIZE = "duplicateSize",
|
|
26
|
+
TOTAL_SIZE = "totalSize"
|
|
27
|
+
}
|
|
28
|
+
export declare const ModuleSizeMetrics: {
|
|
29
|
+
value: {
|
|
30
|
+
label: string;
|
|
31
|
+
tooltip: string;
|
|
32
|
+
};
|
|
33
|
+
totalSize: {
|
|
34
|
+
label: string;
|
|
35
|
+
tooltip: string;
|
|
36
|
+
};
|
|
37
|
+
duplicateSize: {
|
|
38
|
+
label: string;
|
|
39
|
+
tooltip: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import type { SortAction } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare const getSortFn: <TRow>(fieldPath: string, getCustomSort: UseRowsSortParams<TRow>["getCustomSort"]) => (item: TRow) => any;
|
|
3
|
+
interface UseRowsSortParams<TRow> {
|
|
4
|
+
rows: Array<TRow>;
|
|
4
5
|
initialField?: string;
|
|
5
6
|
initialDirection?: SortAction['direction'];
|
|
6
7
|
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sort:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
updateSort: import("react").Dispatch<import("react").SetStateAction<{
|
|
15
|
-
field: string;
|
|
16
|
-
direction: "" | "asc" | "desc";
|
|
17
|
-
}>>;
|
|
18
|
-
items: unknown[];
|
|
19
|
-
};
|
|
9
|
+
interface UseRowsSort<TRow> {
|
|
10
|
+
items: Array<TRow>;
|
|
11
|
+
sort: SortAction;
|
|
12
|
+
updateSort: (params: SortAction) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const useRowsSort: <TRow>({ rows, initialField, initialDirection, getCustomSort, }: UseRowsSortParams<TRow>) => UseRowsSort<TRow>;
|
|
20
15
|
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModuleMetric = void 0;
|
|
4
|
-
var ModuleMetric;
|
|
5
|
-
(function (ModuleMetric) {
|
|
6
|
-
ModuleMetric["SIZE"] = "value";
|
|
7
|
-
ModuleMetric["DUPLICATE_SIZE"] = "duplicateSize";
|
|
8
|
-
ModuleMetric["TOTAL_SIZE"] = "totalSize";
|
|
9
|
-
})(ModuleMetric || (exports.ModuleMetric = ModuleMetric = {}));
|
|
10
|
-
//# sourceMappingURL=bundle-modules.constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-modules.constants.js","sourceRoot":"","sources":["../../../src/components/bundle-modules/bundle-modules.constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,8BAAc,CAAA;IACd,gDAAgC,CAAA;IAChC,wCAAwB,CAAA;AAC1B,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export var ModuleMetric;
|
|
2
|
-
(function (ModuleMetric) {
|
|
3
|
-
ModuleMetric["SIZE"] = "value";
|
|
4
|
-
ModuleMetric["DUPLICATE_SIZE"] = "duplicateSize";
|
|
5
|
-
ModuleMetric["TOTAL_SIZE"] = "totalSize";
|
|
6
|
-
})(ModuleMetric || (ModuleMetric = {}));
|
|
7
|
-
//# sourceMappingURL=bundle-modules.constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-modules.constants.js","sourceRoot":"","sources":["../../../src/components/bundle-modules/bundle-modules.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,8BAAc,CAAA;IACd,gDAAgC,CAAA;IAChC,wCAAwB,CAAA;AAC1B,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Module } from '@bundle-stats/utils/lib-esm/webpack/types';
|
|
2
|
-
import type { ReportMetricRun } from '@bundle-stats/utils/types/report/types';
|
|
3
|
-
|
|
4
|
-
export type ReportMetricModuleRow = {
|
|
5
|
-
thirdParty: boolean;
|
|
6
|
-
duplicated: boolean;
|
|
7
|
-
fileType: string;
|
|
8
|
-
} & ReportMetricRun &
|
|
9
|
-
Module;
|