@bundle-stats/utils 4.7.5-beta.0 → 4.7.5-beta.3
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/browsertime/metrics.js +22 -22
- package/lib/browsertime/metrics.js.map +1 -1
- package/lib/config/index.js +1 -2
- package/lib/config/index.js.map +1 -1
- package/lib/config/metric-types.js +28 -0
- package/lib/config/metric-types.js.map +1 -0
- package/lib/constants.js +9 -19
- package/lib/constants.js.map +1 -1
- package/lib/lighthouse/metrics.js +13 -13
- package/lib/lighthouse/metrics.js.map +1 -1
- package/lib/report/add-row-metric-data.js +2 -2
- package/lib/report/add-row-metric-data.js.map +1 -1
- package/lib/report/create.js.map +1 -1
- package/lib/utils/delta.js +29 -26
- package/lib/utils/delta.js.map +1 -1
- package/lib/utils/metrics.js +47 -29
- package/lib/utils/metrics.js.map +1 -1
- package/lib/webpack/compare.js +11 -11
- package/lib/webpack/compare.js.map +1 -1
- package/lib/webpack/metrics.js +23 -23
- package/lib/webpack/metrics.js.map +1 -1
- package/lib-esm/browsertime/metrics.js +22 -22
- package/lib-esm/browsertime/metrics.js.map +1 -1
- package/lib-esm/config/index.js +1 -2
- package/lib-esm/config/index.js.map +1 -1
- package/lib-esm/config/metric-types.js +25 -0
- package/lib-esm/config/metric-types.js.map +1 -0
- package/lib-esm/constants.js +8 -18
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/lighthouse/metrics.js +13 -13
- package/lib-esm/lighthouse/metrics.js.map +1 -1
- package/lib-esm/report/add-row-metric-data.js +2 -2
- package/lib-esm/report/add-row-metric-data.js.map +1 -1
- package/lib-esm/report/create.js.map +1 -1
- package/lib-esm/utils/delta.js +29 -26
- package/lib-esm/utils/delta.js.map +1 -1
- package/lib-esm/utils/metrics.js +44 -27
- package/lib-esm/utils/metrics.js.map +1 -1
- package/lib-esm/webpack/compare.js +4 -4
- package/lib-esm/webpack/compare.js.map +1 -1
- package/lib-esm/webpack/metrics.js +24 -24
- package/lib-esm/webpack/metrics.js.map +1 -1
- package/package.json +4 -4
- package/src/browsertime/metrics.js +22 -22
- package/src/config/index.js +1 -2
- package/src/config/metric-types.ts +25 -0
- package/src/constants.ts +64 -28
- package/src/lighthouse/metrics.js +13 -15
- package/src/report/add-row-metric-data.ts +3 -2
- package/src/report/create.ts +1 -1
- package/src/utils/delta.ts +91 -0
- package/src/utils/metrics.ts +81 -0
- package/src/webpack/compare.js +19 -12
- package/src/webpack/metrics.ts +26 -41
- package/types/browsertime/metrics.d.ts +43 -23
- package/types/config/index.d.ts +1 -2
- package/types/config/metric-types.d.ts +2 -0
- package/types/constants.d.ts +24 -22
- package/types/lighthouse/metrics.d.ts +25 -17
- package/types/report/add-row-metric-data.d.ts +4 -3
- package/types/utils/delta.d.ts +4 -6
- package/types/utils/metrics.d.ts +4 -3
- package/types/webpack/metrics.d.ts +3 -11
- package/types/webpack/utils.d.ts +1 -1
- package/lib/config/delta.js +0 -13
- package/lib/config/delta.js.map +0 -1
- package/lib/config/metrics.js +0 -32
- package/lib/config/metrics.js.map +0 -1
- package/lib-esm/config/delta.js +0 -10
- package/lib-esm/config/delta.js.map +0 -1
- package/lib-esm/config/metrics.js +0 -29
- package/lib-esm/config/metrics.js.map +0 -1
- package/src/config/delta.js +0 -11
- package/src/config/metrics.js +0 -31
- package/src/utils/delta.js +0 -94
- package/src/utils/metrics.js +0 -92
- package/types/config/delta.d.ts +0 -9
- package/types/config/metrics.d.ts +0 -6
package/types/constants.d.ts
CHANGED
|
@@ -9,34 +9,34 @@ export declare enum InsightType {
|
|
|
9
9
|
INFO = "info",
|
|
10
10
|
WARNING = "warning"
|
|
11
11
|
}
|
|
12
|
-
export declare enum
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export declare enum MetricTypes {
|
|
13
|
+
Numeric = "METRIC_TYPE_NUMERIC",
|
|
14
|
+
Score = "METRIC_TYPE_SCORE",
|
|
15
|
+
FileSize = "METRIC_TYPE_FILE_SIZE",
|
|
16
|
+
Duration = "METRIC_TYPE_DURATION",
|
|
17
|
+
Percentage = "METRIC_TYPE_PERCENTAGE"
|
|
18
18
|
}
|
|
19
19
|
export interface MetricTypeConfig {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: MetricTypeType;
|
|
23
|
-
}
|
|
24
|
-
export interface MetricType extends MetricTypeConfig {
|
|
25
|
-
formatter: Function;
|
|
26
|
-
biggerIsBetter: boolean;
|
|
27
|
-
}
|
|
28
|
-
export declare enum MetricRunInfoDeltaType {
|
|
29
|
-
'HIGH_NEGATIVE' = "HIGH_NEGATIVE",
|
|
30
|
-
'NEGATIVE' = "NEGATIVE",
|
|
31
|
-
'LOW_NEGATIVE' = "LOW_NEGATIVE",
|
|
32
|
-
'NO_CHANGE' = "NO_CHANGE",
|
|
33
|
-
'LOW_POSITIVE' = "LOW_POSITIVE",
|
|
34
|
-
'POSITIVE' = "POSITIVE",
|
|
35
|
-
'HIGH_POSITIVE' = "HIGH_POSITIVE"
|
|
20
|
+
biggerIsBetter?: boolean | null;
|
|
21
|
+
formatter: (value: number | null) => string;
|
|
36
22
|
}
|
|
23
|
+
export interface MetricConfig {
|
|
24
|
+
label: string;
|
|
25
|
+
type: MetricTypes;
|
|
26
|
+
description?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
biggerIsBetter?: MetricTypeConfig['biggerIsBetter'];
|
|
29
|
+
skipDelta?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type Metric = MetricTypeConfig & MetricConfig;
|
|
32
|
+
export type MetricRunInfoDeltaType = 'HIGH_NEGATIVE' | 'NEGATIVE' | 'LOW_NEGATIVE' | 'NO_CHANGE' | 'LOW_POSITIVE' | 'POSITIVE' | 'HIGH_POSITIVE';
|
|
37
33
|
export interface MetricRun {
|
|
38
34
|
value: number;
|
|
39
35
|
}
|
|
36
|
+
export interface MetricRunDelta {
|
|
37
|
+
delta: number;
|
|
38
|
+
deltaPercentage: number;
|
|
39
|
+
}
|
|
40
40
|
export interface MetricRunInfo {
|
|
41
41
|
value: number;
|
|
42
42
|
displayValue: string;
|
|
@@ -45,6 +45,7 @@ export interface MetricRunInfo {
|
|
|
45
45
|
deltaType?: MetricRunInfoDeltaType;
|
|
46
46
|
displayDelta?: string;
|
|
47
47
|
displayDeltaPercentage?: string;
|
|
48
|
+
regression?: boolean | null;
|
|
48
49
|
}
|
|
49
50
|
export type JobSection<T = object> = Record<Source, T>;
|
|
50
51
|
export declare enum JobSectionId {
|
|
@@ -66,6 +67,7 @@ export interface JobInsight<T = object> {
|
|
|
66
67
|
}
|
|
67
68
|
export interface JobInsightAssetsSizeTotalData {
|
|
68
69
|
md: string;
|
|
70
|
+
text: string;
|
|
69
71
|
info: MetricRunInfo;
|
|
70
72
|
}
|
|
71
73
|
export type JobInsightDuplicatePackagesData = Record<string, Array<string>>;
|
|
@@ -1,65 +1,73 @@
|
|
|
1
1
|
export namespace metrics {
|
|
2
2
|
namespace score {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let label: string;
|
|
4
|
+
let type: MetricTypes;
|
|
5
5
|
}
|
|
6
6
|
namespace performanceScore {
|
|
7
7
|
let label_1: string;
|
|
8
8
|
export { label_1 as label };
|
|
9
|
-
|
|
9
|
+
let type_1: MetricTypes;
|
|
10
|
+
export { type_1 as type };
|
|
10
11
|
}
|
|
11
12
|
namespace accessibilityScore {
|
|
12
13
|
let label_2: string;
|
|
13
14
|
export { label_2 as label };
|
|
14
|
-
|
|
15
|
+
let type_2: MetricTypes;
|
|
16
|
+
export { type_2 as type };
|
|
15
17
|
}
|
|
16
18
|
namespace bestPracticesScore {
|
|
17
19
|
let label_3: string;
|
|
18
20
|
export { label_3 as label };
|
|
19
|
-
|
|
21
|
+
let type_3: MetricTypes;
|
|
22
|
+
export { type_3 as type };
|
|
20
23
|
}
|
|
21
24
|
namespace seoScore {
|
|
22
25
|
let label_4: string;
|
|
23
26
|
export { label_4 as label };
|
|
24
|
-
|
|
27
|
+
let type_4: MetricTypes;
|
|
28
|
+
export { type_4 as type };
|
|
25
29
|
}
|
|
26
30
|
namespace pwaScore {
|
|
27
31
|
let label_5: string;
|
|
28
32
|
export { label_5 as label };
|
|
29
|
-
|
|
33
|
+
let type_5: MetricTypes;
|
|
34
|
+
export { type_5 as type };
|
|
30
35
|
}
|
|
31
36
|
namespace speedIndex {
|
|
32
37
|
let label_6: string;
|
|
33
38
|
export { label_6 as label };
|
|
34
|
-
|
|
39
|
+
let type_6: MetricTypes;
|
|
40
|
+
export { type_6 as type };
|
|
35
41
|
}
|
|
36
42
|
namespace firstMeaningfulPaint {
|
|
37
43
|
let label_7: string;
|
|
38
44
|
export { label_7 as label };
|
|
39
|
-
|
|
45
|
+
let type_7: MetricTypes;
|
|
46
|
+
export { type_7 as type };
|
|
40
47
|
}
|
|
41
48
|
namespace timeToFirstByte {
|
|
42
49
|
let label_8: string;
|
|
43
50
|
export { label_8 as label };
|
|
44
|
-
|
|
51
|
+
let type_8: MetricTypes;
|
|
52
|
+
export { type_8 as type };
|
|
45
53
|
}
|
|
46
54
|
namespace firstInteractive {
|
|
47
55
|
let label_9: string;
|
|
48
56
|
export { label_9 as label };
|
|
49
|
-
|
|
57
|
+
let type_9: MetricTypes;
|
|
58
|
+
export { type_9 as type };
|
|
50
59
|
}
|
|
51
60
|
namespace totalByteWeight {
|
|
52
61
|
let label_10: string;
|
|
53
62
|
export { label_10 as label };
|
|
54
|
-
|
|
63
|
+
let type_10: MetricTypes;
|
|
64
|
+
export { type_10 as type };
|
|
55
65
|
}
|
|
56
66
|
namespace domSize {
|
|
57
67
|
let label_11: string;
|
|
58
68
|
export { label_11 as label };
|
|
59
|
-
|
|
69
|
+
let type_11: MetricTypes;
|
|
70
|
+
export { type_11 as type };
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
|
-
import {
|
|
63
|
-
import { METRIC_TYPE_DURATION } from '../config/metrics';
|
|
64
|
-
import { METRIC_TYPE_FILE_SIZE } from '../config/metrics';
|
|
65
|
-
import { METRIC_TYPE_NUMERIC } from '../config/metrics';
|
|
73
|
+
import { MetricTypes } from '../constants';
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as types from './types';
|
|
2
2
|
export declare const getAddRowMetricData: (metricType?: string) => (row: types.ReportRow) => {
|
|
3
|
-
biggerIsBetter:
|
|
4
|
-
label:
|
|
3
|
+
biggerIsBetter: boolean | null | undefined;
|
|
4
|
+
label: string;
|
|
5
5
|
changed: boolean;
|
|
6
6
|
runs: ({
|
|
7
7
|
value: number;
|
|
8
8
|
displayValue: string;
|
|
9
9
|
delta?: number | undefined;
|
|
10
10
|
deltaPercentage?: number | undefined;
|
|
11
|
-
deltaType?: import("
|
|
11
|
+
deltaType?: import("../constants").MetricRunInfoDeltaType | undefined;
|
|
12
12
|
displayDelta?: string | undefined;
|
|
13
13
|
displayDeltaPercentage?: string | undefined;
|
|
14
|
+
regression?: boolean | null | undefined;
|
|
14
15
|
name?: string | undefined;
|
|
15
16
|
} | null)[];
|
|
16
17
|
key: string;
|
package/types/utils/delta.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function formatDelta(value: number, formatter: Function): string;
|
|
6
|
-
export function getDeltaType(deltaValue: number, biggerIsBetter: boolean): string;
|
|
1
|
+
import type { MetricRun, MetricRunDelta, MetricRunInfoDeltaType, MetricTypeConfig } from '../constants';
|
|
2
|
+
export declare function getDelta(baseline?: MetricRun | null, current?: MetricRun | null): MetricRunDelta;
|
|
3
|
+
export declare function formatDelta(value: number, formatter: MetricTypeConfig['formatter']): string;
|
|
4
|
+
export declare function getDeltaType(deltaPercentageValue: number, biggerIsBetter?: MetricTypeConfig['biggerIsBetter']): MetricRunInfoDeltaType;
|
package/types/utils/metrics.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export function
|
|
1
|
+
import { MetricRunInfo, Metric, MetricTypes, MetricTypeConfig } from '../constants';
|
|
2
|
+
export declare function createGetMetricType(metrics: Record<string, unknown>): (key: string, type?: MetricTypes) => Metric;
|
|
3
|
+
export declare function getGlobalMetricType(key: string, type?: MetricTypes): Metric;
|
|
4
|
+
export declare function getMetricRunInfo(metricType: MetricTypeConfig, current: number, baseline?: number): MetricRunInfo;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { Metric } from './types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
description?: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
type: MetricTypeType;
|
|
8
|
-
biggerIsBetter?: boolean;
|
|
9
|
-
skipDelta?: boolean;
|
|
10
|
-
}
|
|
11
|
-
type WebpackMetrics = Partial<Record<Metric, WebpackMetricConfig>> & {
|
|
12
|
-
sizes: Partial<Record<Metric, WebpackMetricConfig>>;
|
|
2
|
+
import { MetricConfig } from '../constants';
|
|
3
|
+
type WebpackMetrics = Partial<Record<Metric, MetricConfig>> & {
|
|
4
|
+
sizes: Partial<Record<Metric, MetricConfig>>;
|
|
13
5
|
};
|
|
14
6
|
export declare const metrics: WebpackMetrics;
|
|
15
7
|
export {};
|
package/types/webpack/utils.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export function getModuleName(name: any): any;
|
|
|
3
3
|
export function calculateCacheInvalidation(rows: any): number;
|
|
4
4
|
export function getMetricAdded(runs: any): boolean;
|
|
5
5
|
export function getMetricDeleted(runs: any): boolean;
|
|
6
|
-
export const getMetricType:
|
|
6
|
+
export const getMetricType: (key: string, type?: import("..").MetricTypes | undefined) => import("..").Metric;
|
|
7
7
|
export function getPackagePublicName(packageId: string): string;
|
|
8
8
|
export function normalizeChunkId(chunkId: string | number): string;
|
package/lib/config/delta.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DELTA_TYPE_HIGH_POSITIVE = exports.DELTA_TYPE_LOW_POSITIVE = exports.DELTA_TYPE_HIGH_NEGATIVE = exports.DELTA_TYPE_LOW_NEGATIVE = exports.DELTA_TYPE_LEVEL_HIGH = exports.DELTA_TYPE_LEVEL_LOW = exports.DELTA_TYPE_POSITIVE = exports.DELTA_TYPE_NO_CHANGE = exports.DELTA_TYPE_NEGATIVE = void 0;
|
|
4
|
-
exports.DELTA_TYPE_NEGATIVE = 'NEGATIVE';
|
|
5
|
-
exports.DELTA_TYPE_NO_CHANGE = 'NO_CHANGE';
|
|
6
|
-
exports.DELTA_TYPE_POSITIVE = 'POSITIVE';
|
|
7
|
-
exports.DELTA_TYPE_LEVEL_LOW = 'LOW';
|
|
8
|
-
exports.DELTA_TYPE_LEVEL_HIGH = 'HIGH';
|
|
9
|
-
exports.DELTA_TYPE_LOW_NEGATIVE = `${exports.DELTA_TYPE_LEVEL_LOW}_${exports.DELTA_TYPE_NEGATIVE}`;
|
|
10
|
-
exports.DELTA_TYPE_HIGH_NEGATIVE = `${exports.DELTA_TYPE_LEVEL_HIGH}_${exports.DELTA_TYPE_NEGATIVE}`;
|
|
11
|
-
exports.DELTA_TYPE_LOW_POSITIVE = `${exports.DELTA_TYPE_LEVEL_LOW}_${exports.DELTA_TYPE_POSITIVE}`;
|
|
12
|
-
exports.DELTA_TYPE_HIGH_POSITIVE = `${exports.DELTA_TYPE_LEVEL_HIGH}_${exports.DELTA_TYPE_POSITIVE}`;
|
|
13
|
-
//# sourceMappingURL=delta.js.map
|
package/lib/config/delta.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delta.js","sourceRoot":"","sources":["../../src/config/delta.js"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,UAAU,CAAC;AACjC,QAAA,oBAAoB,GAAG,WAAW,CAAC;AACnC,QAAA,mBAAmB,GAAG,UAAU,CAAC;AAEjC,QAAA,oBAAoB,GAAG,KAAK,CAAC;AAC7B,QAAA,qBAAqB,GAAG,MAAM,CAAC;AAE/B,QAAA,uBAAuB,GAAG,GAAG,4BAAoB,IAAI,2BAAmB,EAAE,CAAC;AAC3E,QAAA,wBAAwB,GAAG,GAAG,6BAAqB,IAAI,2BAAmB,EAAE,CAAC;AAC7E,QAAA,uBAAuB,GAAG,GAAG,4BAAoB,IAAI,2BAAmB,EAAE,CAAC;AAC3E,QAAA,wBAAwB,GAAG,GAAG,6BAAqB,IAAI,2BAAmB,EAAE,CAAC"}
|
package/lib/config/metrics.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.METRIC_TYPES = exports.METRIC_TYPE_PERCENTAGE = exports.METRIC_TYPE_SCORE = exports.METRIC_TYPE_NUMERIC = exports.METRIC_TYPE_DURATION = exports.METRIC_TYPE_FILE_SIZE = void 0;
|
|
4
|
-
const format_1 = require("../utils/format");
|
|
5
|
-
exports.METRIC_TYPE_FILE_SIZE = 'METRIC_TYPE_FILE_SIZE';
|
|
6
|
-
exports.METRIC_TYPE_DURATION = 'METRIC_TYPE_DURATION';
|
|
7
|
-
exports.METRIC_TYPE_NUMERIC = 'METRIC_TYPE_NUMERIC';
|
|
8
|
-
exports.METRIC_TYPE_SCORE = 'METRIC_TYPE_SCORE';
|
|
9
|
-
exports.METRIC_TYPE_PERCENTAGE = 'METRIC_TYPE_PERCENTAGE';
|
|
10
|
-
exports.METRIC_TYPES = {
|
|
11
|
-
[exports.METRIC_TYPE_NUMERIC]: {
|
|
12
|
-
biggerIsBetter: false,
|
|
13
|
-
formatter: format_1.formatNumber,
|
|
14
|
-
},
|
|
15
|
-
[exports.METRIC_TYPE_SCORE]: {
|
|
16
|
-
biggerIsBetter: true,
|
|
17
|
-
formatter: format_1.formatNumber,
|
|
18
|
-
},
|
|
19
|
-
[exports.METRIC_TYPE_DURATION]: {
|
|
20
|
-
biggerIsBetter: false,
|
|
21
|
-
formatter: format_1.formatDuration,
|
|
22
|
-
},
|
|
23
|
-
[exports.METRIC_TYPE_FILE_SIZE]: {
|
|
24
|
-
biggerIsBetter: false,
|
|
25
|
-
formatter: format_1.formatFileSize,
|
|
26
|
-
},
|
|
27
|
-
[exports.METRIC_TYPE_PERCENTAGE]: {
|
|
28
|
-
biggerIsBetter: true,
|
|
29
|
-
formatter: format_1.formatPercentage,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=metrics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/config/metrics.js"],"names":[],"mappings":";;;AAAA,4CAAiG;AAEpF,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAGlD,QAAA,YAAY,GAAG;IAC1B,CAAC,2BAAmB,CAAC,EAAE;QACrB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,qBAAY;KACxB;IACD,CAAC,yBAAiB,CAAC,EAAE;QACnB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,qBAAY;KACxB;IACD,CAAC,4BAAoB,CAAC,EAAE;QACtB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,uBAAc;KAC1B;IACD,CAAC,6BAAqB,CAAC,EAAE;QACvB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,uBAAc;KAC1B;IACD,CAAC,8BAAsB,CAAC,EAAE;QACxB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,yBAAgB;KAC5B;CACF,CAAC"}
|
package/lib-esm/config/delta.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const DELTA_TYPE_NEGATIVE = 'NEGATIVE';
|
|
2
|
-
export const DELTA_TYPE_NO_CHANGE = 'NO_CHANGE';
|
|
3
|
-
export const DELTA_TYPE_POSITIVE = 'POSITIVE';
|
|
4
|
-
export const DELTA_TYPE_LEVEL_LOW = 'LOW';
|
|
5
|
-
export const DELTA_TYPE_LEVEL_HIGH = 'HIGH';
|
|
6
|
-
export const DELTA_TYPE_LOW_NEGATIVE = `${DELTA_TYPE_LEVEL_LOW}_${DELTA_TYPE_NEGATIVE}`;
|
|
7
|
-
export const DELTA_TYPE_HIGH_NEGATIVE = `${DELTA_TYPE_LEVEL_HIGH}_${DELTA_TYPE_NEGATIVE}`;
|
|
8
|
-
export const DELTA_TYPE_LOW_POSITIVE = `${DELTA_TYPE_LEVEL_LOW}_${DELTA_TYPE_POSITIVE}`;
|
|
9
|
-
export const DELTA_TYPE_HIGH_POSITIVE = `${DELTA_TYPE_LEVEL_HIGH}_${DELTA_TYPE_POSITIVE}`;
|
|
10
|
-
//# sourceMappingURL=delta.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delta.js","sourceRoot":"","sources":["../../src/config/delta.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,oBAAoB,IAAI,mBAAmB,EAAE,CAAC;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,qBAAqB,IAAI,mBAAmB,EAAE,CAAC;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,oBAAoB,IAAI,mBAAmB,EAAE,CAAC;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,qBAAqB,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { formatNumber, formatDuration, formatFileSize, formatPercentage } from '../utils/format';
|
|
2
|
-
export const METRIC_TYPE_FILE_SIZE = 'METRIC_TYPE_FILE_SIZE';
|
|
3
|
-
export const METRIC_TYPE_DURATION = 'METRIC_TYPE_DURATION';
|
|
4
|
-
export const METRIC_TYPE_NUMERIC = 'METRIC_TYPE_NUMERIC';
|
|
5
|
-
export const METRIC_TYPE_SCORE = 'METRIC_TYPE_SCORE';
|
|
6
|
-
export const METRIC_TYPE_PERCENTAGE = 'METRIC_TYPE_PERCENTAGE';
|
|
7
|
-
export const METRIC_TYPES = {
|
|
8
|
-
[METRIC_TYPE_NUMERIC]: {
|
|
9
|
-
biggerIsBetter: false,
|
|
10
|
-
formatter: formatNumber,
|
|
11
|
-
},
|
|
12
|
-
[METRIC_TYPE_SCORE]: {
|
|
13
|
-
biggerIsBetter: true,
|
|
14
|
-
formatter: formatNumber,
|
|
15
|
-
},
|
|
16
|
-
[METRIC_TYPE_DURATION]: {
|
|
17
|
-
biggerIsBetter: false,
|
|
18
|
-
formatter: formatDuration,
|
|
19
|
-
},
|
|
20
|
-
[METRIC_TYPE_FILE_SIZE]: {
|
|
21
|
-
biggerIsBetter: false,
|
|
22
|
-
formatter: formatFileSize,
|
|
23
|
-
},
|
|
24
|
-
[METRIC_TYPE_PERCENTAGE]: {
|
|
25
|
-
biggerIsBetter: true,
|
|
26
|
-
formatter: formatPercentage,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=metrics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/config/metrics.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjG,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAG/D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,CAAC,mBAAmB,CAAC,EAAE;QACrB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,YAAY;KACxB;IACD,CAAC,iBAAiB,CAAC,EAAE;QACnB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,YAAY;KACxB;IACD,CAAC,oBAAoB,CAAC,EAAE;QACtB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,cAAc;KAC1B;IACD,CAAC,qBAAqB,CAAC,EAAE;QACvB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,cAAc;KAC1B;IACD,CAAC,sBAAsB,CAAC,EAAE;QACxB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,gBAAgB;KAC5B;CACF,CAAC"}
|
package/src/config/delta.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const DELTA_TYPE_NEGATIVE = 'NEGATIVE';
|
|
2
|
-
export const DELTA_TYPE_NO_CHANGE = 'NO_CHANGE';
|
|
3
|
-
export const DELTA_TYPE_POSITIVE = 'POSITIVE';
|
|
4
|
-
|
|
5
|
-
export const DELTA_TYPE_LEVEL_LOW = 'LOW';
|
|
6
|
-
export const DELTA_TYPE_LEVEL_HIGH = 'HIGH';
|
|
7
|
-
|
|
8
|
-
export const DELTA_TYPE_LOW_NEGATIVE = `${DELTA_TYPE_LEVEL_LOW}_${DELTA_TYPE_NEGATIVE}`;
|
|
9
|
-
export const DELTA_TYPE_HIGH_NEGATIVE = `${DELTA_TYPE_LEVEL_HIGH}_${DELTA_TYPE_NEGATIVE}`;
|
|
10
|
-
export const DELTA_TYPE_LOW_POSITIVE = `${DELTA_TYPE_LEVEL_LOW}_${DELTA_TYPE_POSITIVE}`;
|
|
11
|
-
export const DELTA_TYPE_HIGH_POSITIVE = `${DELTA_TYPE_LEVEL_HIGH}_${DELTA_TYPE_POSITIVE}`;
|
package/src/config/metrics.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { formatNumber, formatDuration, formatFileSize, formatPercentage } from '../utils/format';
|
|
2
|
-
|
|
3
|
-
export const METRIC_TYPE_FILE_SIZE = 'METRIC_TYPE_FILE_SIZE';
|
|
4
|
-
export const METRIC_TYPE_DURATION = 'METRIC_TYPE_DURATION';
|
|
5
|
-
export const METRIC_TYPE_NUMERIC = 'METRIC_TYPE_NUMERIC';
|
|
6
|
-
export const METRIC_TYPE_SCORE = 'METRIC_TYPE_SCORE';
|
|
7
|
-
export const METRIC_TYPE_PERCENTAGE = 'METRIC_TYPE_PERCENTAGE';
|
|
8
|
-
|
|
9
|
-
/** @type {Record<string, import('../constants').MetricType>} */
|
|
10
|
-
export const METRIC_TYPES = {
|
|
11
|
-
[METRIC_TYPE_NUMERIC]: {
|
|
12
|
-
biggerIsBetter: false,
|
|
13
|
-
formatter: formatNumber,
|
|
14
|
-
},
|
|
15
|
-
[METRIC_TYPE_SCORE]: {
|
|
16
|
-
biggerIsBetter: true,
|
|
17
|
-
formatter: formatNumber,
|
|
18
|
-
},
|
|
19
|
-
[METRIC_TYPE_DURATION]: {
|
|
20
|
-
biggerIsBetter: false,
|
|
21
|
-
formatter: formatDuration,
|
|
22
|
-
},
|
|
23
|
-
[METRIC_TYPE_FILE_SIZE]: {
|
|
24
|
-
biggerIsBetter: false,
|
|
25
|
-
formatter: formatFileSize,
|
|
26
|
-
},
|
|
27
|
-
[METRIC_TYPE_PERCENTAGE]: {
|
|
28
|
-
biggerIsBetter: true,
|
|
29
|
-
formatter: formatPercentage,
|
|
30
|
-
},
|
|
31
|
-
};
|
package/src/utils/delta.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import round from 'lodash/round';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
DELTA_TYPE_NO_CHANGE,
|
|
5
|
-
DELTA_TYPE_NEGATIVE,
|
|
6
|
-
DELTA_TYPE_POSITIVE,
|
|
7
|
-
DELTA_TYPE_LEVEL_HIGH,
|
|
8
|
-
DELTA_TYPE_LEVEL_LOW,
|
|
9
|
-
} from '../config/delta';
|
|
10
|
-
|
|
11
|
-
export const getDelta = (baseline, current) => {
|
|
12
|
-
const baselineValue = (baseline && baseline.value) || 0;
|
|
13
|
-
const currentValue = (current && current.value) || 0;
|
|
14
|
-
|
|
15
|
-
if (baselineValue === currentValue) {
|
|
16
|
-
return {
|
|
17
|
-
delta: 0,
|
|
18
|
-
deltaPercentage: 0,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (baselineValue === 0) {
|
|
23
|
-
return {
|
|
24
|
-
delta: currentValue,
|
|
25
|
-
deltaPercentage: 100,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
delta: currentValue - baselineValue,
|
|
31
|
-
deltaPercentage: round((currentValue / baselineValue) * 100 - 100, 8),
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Format delta output
|
|
37
|
-
*
|
|
38
|
-
* @param {number} value Metric value
|
|
39
|
-
* @param {Function} formatter Metric type formatter
|
|
40
|
-
* @return {String} Delta output
|
|
41
|
-
*/
|
|
42
|
-
export const formatDelta = (value, formatter) => {
|
|
43
|
-
// eslint-disable-next-line no-nested-ternary
|
|
44
|
-
let sign = value > 0
|
|
45
|
-
? '+'
|
|
46
|
-
: (value < 0 ? '-' : '');
|
|
47
|
-
|
|
48
|
-
let absValue = Math.abs(value);
|
|
49
|
-
|
|
50
|
-
if (absValue > 0 && absValue < 0.01) {
|
|
51
|
-
sign = `~${sign}`;
|
|
52
|
-
absValue = 0.01;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (absValue > 0.01) {
|
|
56
|
-
absValue = round(absValue, 2);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return `${sign}${formatter(absValue)}`;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* Get delta type
|
|
65
|
-
*
|
|
66
|
-
* @param {number} deltaValue Delta value
|
|
67
|
-
* @param {Boolean} biggerIsBetter Metric flag
|
|
68
|
-
* @return {string} Delta type
|
|
69
|
-
*/
|
|
70
|
-
export const getDeltaType = (deltaValue, biggerIsBetter) => {
|
|
71
|
-
if (deltaValue === 0) {
|
|
72
|
-
return DELTA_TYPE_NO_CHANGE;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const absDiff = Math.abs(deltaValue);
|
|
76
|
-
let level = '';
|
|
77
|
-
|
|
78
|
-
if (absDiff <= 5) {
|
|
79
|
-
level = DELTA_TYPE_LEVEL_LOW;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (absDiff > 50) {
|
|
83
|
-
level = DELTA_TYPE_LEVEL_HIGH;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let type = '';
|
|
87
|
-
if ((deltaValue > 0 && biggerIsBetter) || (deltaValue < 0 && !biggerIsBetter)) {
|
|
88
|
-
type = DELTA_TYPE_POSITIVE;
|
|
89
|
-
} else {
|
|
90
|
-
type = DELTA_TYPE_NEGATIVE;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return `${level ? `${level}_` : ''}${type}`;
|
|
94
|
-
};
|
package/src/utils/metrics.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
|
|
3
|
-
import { METRIC_TYPE_NUMERIC, METRIC_TYPES } from '../config/metrics';
|
|
4
|
-
import { formatDelta, getDelta, getDeltaType } from './delta';
|
|
5
|
-
import { formatPercentage } from './format';
|
|
6
|
-
|
|
7
|
-
import { metrics as webpackMetricTypes } from '../webpack/metrics';
|
|
8
|
-
import { metrics as lighthouseMetricTypes } from '../lighthouse/metrics';
|
|
9
|
-
import { metrics as browsertimeMeticTypes } from '../browsertime/metrics';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create getMetricTypes handler
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} metrics
|
|
15
|
-
* @return {Function}
|
|
16
|
-
*/
|
|
17
|
-
export const createGetMetricType =
|
|
18
|
-
(metrics) =>
|
|
19
|
-
/**
|
|
20
|
-
* Get metric type data
|
|
21
|
-
*
|
|
22
|
-
* @param {String} key Metric key
|
|
23
|
-
* @param {String} [type] Default metric type
|
|
24
|
-
* @return {import('../constants').MetricType}
|
|
25
|
-
*/
|
|
26
|
-
// eslint-disable-next-line implicit-arrow-linebreak
|
|
27
|
-
(key, type) => {
|
|
28
|
-
/** @type {import('../constants').MetricTypeConfig} */
|
|
29
|
-
const metric = get(metrics, key);
|
|
30
|
-
|
|
31
|
-
if (metric && metric.type) {
|
|
32
|
-
return {
|
|
33
|
-
...METRIC_TYPES[metric.type],
|
|
34
|
-
...metric,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const resolvedType = type || METRIC_TYPE_NUMERIC;
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...METRIC_TYPES[resolvedType],
|
|
42
|
-
type: resolvedType,
|
|
43
|
-
label: key,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get global metric type
|
|
49
|
-
*
|
|
50
|
-
* @param {String} key Metric key
|
|
51
|
-
* @param {import('../constants').MetricTypeType} [type] Default metric type
|
|
52
|
-
* @return {import('../constants').MetricType}
|
|
53
|
-
*/
|
|
54
|
-
export const getGlobalMetricType = createGetMetricType({
|
|
55
|
-
webpack: webpackMetricTypes,
|
|
56
|
-
lighthouse: lighthouseMetricTypes,
|
|
57
|
-
browsertime: browsertimeMeticTypes,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* Get metric information
|
|
63
|
-
*
|
|
64
|
-
* @param {import('../constants').MetricType} metric Metric data
|
|
65
|
-
* @param {number} currentValue Current value
|
|
66
|
-
* @param {number} baselineValue Baseline value
|
|
67
|
-
*
|
|
68
|
-
* @return {import('../constants').MetricRunInfo}
|
|
69
|
-
*/
|
|
70
|
-
export const getMetricRunInfo = (metric, currentValue, baselineValue) => {
|
|
71
|
-
const { formatter, biggerIsBetter } = metric;
|
|
72
|
-
|
|
73
|
-
const runInfo = {
|
|
74
|
-
value: currentValue,
|
|
75
|
-
displayValue: formatter(currentValue),
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
if (typeof baselineValue === 'undefined') {
|
|
79
|
-
return runInfo;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const { delta, deltaPercentage } = getDelta({ value: baselineValue }, { value: currentValue });
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
...runInfo,
|
|
86
|
-
delta,
|
|
87
|
-
deltaPercentage,
|
|
88
|
-
displayDelta: formatDelta(delta, formatter),
|
|
89
|
-
displayDeltaPercentage: formatDelta(deltaPercentage, formatPercentage),
|
|
90
|
-
deltaType: getDeltaType(deltaPercentage, biggerIsBetter),
|
|
91
|
-
};
|
|
92
|
-
};
|
package/types/config/delta.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const DELTA_TYPE_NEGATIVE: "NEGATIVE";
|
|
2
|
-
export const DELTA_TYPE_NO_CHANGE: "NO_CHANGE";
|
|
3
|
-
export const DELTA_TYPE_POSITIVE: "POSITIVE";
|
|
4
|
-
export const DELTA_TYPE_LEVEL_LOW: "LOW";
|
|
5
|
-
export const DELTA_TYPE_LEVEL_HIGH: "HIGH";
|
|
6
|
-
export const DELTA_TYPE_LOW_NEGATIVE: string;
|
|
7
|
-
export const DELTA_TYPE_HIGH_NEGATIVE: string;
|
|
8
|
-
export const DELTA_TYPE_LOW_POSITIVE: string;
|
|
9
|
-
export const DELTA_TYPE_HIGH_POSITIVE: string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const METRIC_TYPE_FILE_SIZE: "METRIC_TYPE_FILE_SIZE";
|
|
2
|
-
export const METRIC_TYPE_DURATION: "METRIC_TYPE_DURATION";
|
|
3
|
-
export const METRIC_TYPE_NUMERIC: "METRIC_TYPE_NUMERIC";
|
|
4
|
-
export const METRIC_TYPE_SCORE: "METRIC_TYPE_SCORE";
|
|
5
|
-
export const METRIC_TYPE_PERCENTAGE: "METRIC_TYPE_PERCENTAGE";
|
|
6
|
-
export const METRIC_TYPES: Record<string, import('../constants').MetricType>;
|