@code-pushup/utils 0.103.0 → 0.105.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/package.json +3 -3
- package/src/lib/clock-epoch.d.ts +10 -0
- package/src/lib/clock-epoch.js +3 -0
- package/src/lib/clock-epoch.js.map +1 -1
- package/src/lib/performance-observer.d.ts +1 -1
- package/src/lib/sink-source.type.js +2 -0
- package/src/lib/sink-source.type.js.map +1 -0
- package/src/lib/trace-file-utils.d.ts +133 -0
- package/src/lib/trace-file-utils.js +179 -0
- package/src/lib/trace-file-utils.js.map +1 -0
- package/src/lib/trace-file.type.d.ts +279 -0
- package/src/lib/trace-file.type.js +2 -0
- package/src/lib/trace-file.type.js.map +1 -0
- package/src/lib/user-timing-extensibility-api-utils.d.ts +265 -18
- package/src/lib/user-timing-extensibility-api-utils.js +222 -7
- package/src/lib/user-timing-extensibility-api-utils.js.map +1 -1
- package/src/lib/user-timing-extensibility-api.type.d.ts +23 -2
- package/src/lib/sink-source.types.js +0 -2
- package/src/lib/sink-source.types.js.map +0 -1
- /package/src/lib/{sink-source.types.d.ts → sink-source.type.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.105.0",
|
|
4
4
|
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=18.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@code-pushup/models": "0.
|
|
30
|
+
"@code-pushup/models": "0.105.0",
|
|
31
31
|
"ansis": "^3.3.0",
|
|
32
32
|
"build-md": "^0.4.2",
|
|
33
33
|
"bundle-require": "^5.1.0",
|
package/src/lib/clock-epoch.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export declare function epochClock(init?: EpochClockOptions): {
|
|
|
26
26
|
fromEpochMs: (ms: number) => Microseconds;
|
|
27
27
|
fromEpochUs: (us: number) => Microseconds;
|
|
28
28
|
fromPerfMs: (perfMs: Milliseconds) => Microseconds;
|
|
29
|
+
fromEntry: (entry: {
|
|
30
|
+
startTime: Milliseconds;
|
|
31
|
+
entryType: string;
|
|
32
|
+
duration: Milliseconds;
|
|
33
|
+
}, useEndTime?: boolean) => number;
|
|
29
34
|
fromEntryStartTimeMs: (perfMs: Milliseconds) => Microseconds;
|
|
30
35
|
fromDateNowMs: (ms: number) => Microseconds;
|
|
31
36
|
};
|
|
@@ -39,6 +44,11 @@ export declare const defaultClock: {
|
|
|
39
44
|
fromEpochMs: (ms: number) => Microseconds;
|
|
40
45
|
fromEpochUs: (us: number) => Microseconds;
|
|
41
46
|
fromPerfMs: (perfMs: Milliseconds) => Microseconds;
|
|
47
|
+
fromEntry: (entry: {
|
|
48
|
+
startTime: Milliseconds;
|
|
49
|
+
entryType: string;
|
|
50
|
+
duration: Milliseconds;
|
|
51
|
+
}, useEndTime?: boolean) => number;
|
|
42
52
|
fromEntryStartTimeMs: (perfMs: Milliseconds) => Microseconds;
|
|
43
53
|
fromDateNowMs: (ms: number) => Microseconds;
|
|
44
54
|
};
|
package/src/lib/clock-epoch.js
CHANGED
|
@@ -17,6 +17,8 @@ export function epochClock(init = {}) {
|
|
|
17
17
|
const fromEpochMs = msToUs;
|
|
18
18
|
const fromPerfMs = (perfMs) => msToUs(timeOriginMs + perfMs);
|
|
19
19
|
const fromEntryStartTimeMs = fromPerfMs;
|
|
20
|
+
const fromEntry = (entry, useEndTime = false) => fromPerfMs(entry.startTime +
|
|
21
|
+
(entry.entryType === 'measure' && useEndTime ? entry.duration : 0));
|
|
20
22
|
const fromDateNowMs = fromEpochMs;
|
|
21
23
|
return {
|
|
22
24
|
timeOriginMs,
|
|
@@ -28,6 +30,7 @@ export function epochClock(init = {}) {
|
|
|
28
30
|
fromEpochMs,
|
|
29
31
|
fromEpochUs,
|
|
30
32
|
fromPerfMs,
|
|
33
|
+
fromEntry,
|
|
31
34
|
fromEntryStartTimeMs,
|
|
32
35
|
fromDateNowMs,
|
|
33
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock-epoch.js","sourceRoot":"","sources":["../../../src/lib/clock-epoch.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C,MAAM,MAAM,GAAG,CAAC,EAAU,EAAgB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACnE,MAAM,MAAM,GAAG,CAAC,EAAU,EAAgB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAa5D;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B,EAAE;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC;IAEjC,MAAM,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC;IAE5C,MAAM,UAAU,GAAG,GAAiB,EAAE,CACpC,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAE3C,MAAM,WAAW,GAAG,MAAM,CAAC;IAE3B,MAAM,WAAW,GAAG,MAAM,CAAC;IAE3B,MAAM,UAAU,GAAG,CAAC,MAAoB,EAAgB,EAAE,CACxD,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC;IAEhC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IACxC,MA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AU,GAAG,KAAK,EAClB,EAAE,CACF,UAAU,CACR,KAAK,CAAC,SAAS;QACb,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CACrE,CAAC;IACJ,MAAM,aAAa,GAAG,WAAW,CAAC;IAElC,OAAO;QACL,YAAY;QACZ,GAAG;QACH,GAAG;QAEH,UAAU;QACV,MAAM;QACN,MAAM;QAEN,WAAW;QACX,WAAW;QACX,UAAU;QACV,SAAS;QACT,oBAAoB;QACpB,aAAa;KACd,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PerformanceEntry } from 'node:perf_hooks';
|
|
2
|
-
import type { Buffered, Encoder, Observer, Sink } from './sink-source.
|
|
2
|
+
import type { Buffered, Encoder, Observer, Sink } from './sink-source.type';
|
|
3
3
|
export declare const DEFAULT_FLUSH_THRESHOLD = 20;
|
|
4
4
|
export type PerformanceObserverOptions<T> = {
|
|
5
5
|
sink: Sink<T, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sink-source.type.js","sourceRoot":"","sources":["../../../src/lib/sink-source.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { PerformanceMark, PerformanceMeasure } from 'node:perf_hooks';
|
|
2
|
+
import type { BeginEvent, CompleteEvent, EndEvent, InstantEvent, InstantEventArgs, InstantEventTracingStartedInBrowser, SpanEventArgs, TraceEvent, TraceEventContainer } from './trace-file.type.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a unique ID for linking begin and end span events in Chrome traces.
|
|
5
|
+
* @returns Object with local ID string for the id2 field
|
|
6
|
+
*/
|
|
7
|
+
export declare const nextId2: () => {
|
|
8
|
+
local: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Generates a unique frame tree node ID from process and thread IDs.
|
|
12
|
+
* @param pid - Process ID
|
|
13
|
+
* @param tid - Thread ID
|
|
14
|
+
* @returns Combined numeric ID
|
|
15
|
+
*/
|
|
16
|
+
export declare const frameTreeNodeId: (pid: number, tid: number) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a frame name string from process and thread IDs.
|
|
19
|
+
* @param pid - Process ID
|
|
20
|
+
* @param tid - Thread ID
|
|
21
|
+
* @returns Formatted frame name
|
|
22
|
+
*/
|
|
23
|
+
export declare const frameName: (pid: number, tid: number) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an instant trace event for marking a point in time.
|
|
26
|
+
* @param opt - Event configuration options
|
|
27
|
+
* @returns InstantEvent object
|
|
28
|
+
*/
|
|
29
|
+
export declare const getInstantEvent: (opt: {
|
|
30
|
+
name: string;
|
|
31
|
+
ts?: number;
|
|
32
|
+
pid?: number;
|
|
33
|
+
tid?: number;
|
|
34
|
+
args?: InstantEventArgs;
|
|
35
|
+
}) => InstantEvent;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a start tracing event with frame information.
|
|
38
|
+
* This event is needed at the beginning of the traceEvents array to make tell the UI profiling has started, and it should visualize the data.
|
|
39
|
+
* @param opt - Tracing configuration options
|
|
40
|
+
* @returns StartTracingEvent object
|
|
41
|
+
*/
|
|
42
|
+
export declare const getInstantEventTracingStartedInBrowser: (opt: {
|
|
43
|
+
url: string;
|
|
44
|
+
ts?: number;
|
|
45
|
+
pid?: number;
|
|
46
|
+
tid?: number;
|
|
47
|
+
}) => InstantEventTracingStartedInBrowser;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a complete trace event with duration.
|
|
50
|
+
* @param opt - Event configuration with name and duration
|
|
51
|
+
* @returns CompleteEvent object
|
|
52
|
+
*/
|
|
53
|
+
export declare const getCompleteEvent: (opt: {
|
|
54
|
+
name: string;
|
|
55
|
+
dur: number;
|
|
56
|
+
ts?: number;
|
|
57
|
+
pid?: number;
|
|
58
|
+
tid?: number;
|
|
59
|
+
}) => CompleteEvent;
|
|
60
|
+
/** Options for creating span events */
|
|
61
|
+
type SpanOpt = {
|
|
62
|
+
name: string;
|
|
63
|
+
id2: {
|
|
64
|
+
local: string;
|
|
65
|
+
};
|
|
66
|
+
ts?: number;
|
|
67
|
+
pid?: number;
|
|
68
|
+
tid?: number;
|
|
69
|
+
args?: SpanEventArgs;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Creates a begin span event.
|
|
73
|
+
* @param ph - Phase ('b' for begin)
|
|
74
|
+
* @param opt - Span event options
|
|
75
|
+
* @returns BeginEvent object
|
|
76
|
+
*/
|
|
77
|
+
export declare function getSpanEvent(ph: 'b', opt: SpanOpt): BeginEvent;
|
|
78
|
+
/**
|
|
79
|
+
* Creates an end span event.
|
|
80
|
+
* @param ph - Phase ('e' for end)
|
|
81
|
+
* @param opt - Span event options
|
|
82
|
+
* @returns EndEvent object
|
|
83
|
+
*/
|
|
84
|
+
export declare function getSpanEvent(ph: 'e', opt: SpanOpt): EndEvent;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a pair of begin and end span events.
|
|
87
|
+
* @param opt - Span configuration with start/end timestamps
|
|
88
|
+
* @returns Tuple of BeginEvent and EndEvent
|
|
89
|
+
*/
|
|
90
|
+
export declare const getSpan: (opt: {
|
|
91
|
+
name: string;
|
|
92
|
+
tsB: number;
|
|
93
|
+
tsE: number;
|
|
94
|
+
id2?: {
|
|
95
|
+
local: string;
|
|
96
|
+
};
|
|
97
|
+
pid?: number;
|
|
98
|
+
tid?: number;
|
|
99
|
+
args?: SpanEventArgs;
|
|
100
|
+
tsMarkerPadding?: number;
|
|
101
|
+
}) => [BeginEvent, EndEvent];
|
|
102
|
+
/**
|
|
103
|
+
* Converts a PerformanceMark to an instant trace event.
|
|
104
|
+
* @param entry - Performance mark entry
|
|
105
|
+
* @param opt - Optional overrides for name, pid, and tid
|
|
106
|
+
* @returns InstantEvent object
|
|
107
|
+
*/
|
|
108
|
+
export declare const markToInstantEvent: (entry: PerformanceMark, opt?: {
|
|
109
|
+
name?: string;
|
|
110
|
+
pid?: number;
|
|
111
|
+
tid?: number;
|
|
112
|
+
}) => InstantEvent;
|
|
113
|
+
/**
|
|
114
|
+
* Converts a PerformanceMeasure to a pair of span events.
|
|
115
|
+
* @param entry - Performance measure entry
|
|
116
|
+
* @param opt - Optional overrides for name, pid, and tid
|
|
117
|
+
* @returns Tuple of BeginEvent and EndEvent
|
|
118
|
+
*/
|
|
119
|
+
export declare const measureToSpanEvents: (entry: PerformanceMeasure, opt?: {
|
|
120
|
+
name?: string;
|
|
121
|
+
pid?: number;
|
|
122
|
+
tid?: number;
|
|
123
|
+
}) => [BeginEvent, EndEvent];
|
|
124
|
+
/**
|
|
125
|
+
* Creates a complete trace file container with metadata.
|
|
126
|
+
* @param opt - Trace file configuration
|
|
127
|
+
* @returns TraceEventContainer with events and metadata
|
|
128
|
+
*/
|
|
129
|
+
export declare const getTraceFile: (opt: {
|
|
130
|
+
traceEvents: TraceEvent[];
|
|
131
|
+
startTime?: string;
|
|
132
|
+
}) => TraceEventContainer;
|
|
133
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { threadId } from 'node:worker_threads';
|
|
3
|
+
import { defaultClock } from './clock-epoch.js';
|
|
4
|
+
/** Global counter for generating unique span IDs within a trace */
|
|
5
|
+
// eslint-disable-next-line functional/no-let
|
|
6
|
+
let id2Count = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a unique ID for linking begin and end span events in Chrome traces.
|
|
9
|
+
* @returns Object with local ID string for the id2 field
|
|
10
|
+
*/
|
|
11
|
+
export const nextId2 = () => ({ local: `0x${++id2Count}` });
|
|
12
|
+
/**
|
|
13
|
+
* Provides default values for trace event properties.
|
|
14
|
+
* @param opt - Optional overrides for pid, tid, and timestamp
|
|
15
|
+
* @returns Object with pid, tid, and timestamp
|
|
16
|
+
*/
|
|
17
|
+
const defaults = (opt) => ({
|
|
18
|
+
pid: opt?.pid ?? process.pid,
|
|
19
|
+
tid: opt?.tid ?? threadId,
|
|
20
|
+
ts: opt?.ts ?? defaultClock.epochNowUs(),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Generates a unique frame tree node ID from process and thread IDs.
|
|
24
|
+
* @param pid - Process ID
|
|
25
|
+
* @param tid - Thread ID
|
|
26
|
+
* @returns Combined numeric ID
|
|
27
|
+
*/
|
|
28
|
+
export const frameTreeNodeId = (pid, tid) => Number.parseInt(`${pid}0${tid}`, 10);
|
|
29
|
+
/**
|
|
30
|
+
* Generates a frame name string from process and thread IDs.
|
|
31
|
+
* @param pid - Process ID
|
|
32
|
+
* @param tid - Thread ID
|
|
33
|
+
* @returns Formatted frame name
|
|
34
|
+
*/
|
|
35
|
+
export const frameName = (pid, tid) => `FRAME0P${pid}T${tid}`;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an instant trace event for marking a point in time.
|
|
38
|
+
* @param opt - Event configuration options
|
|
39
|
+
* @returns InstantEvent object
|
|
40
|
+
*/
|
|
41
|
+
export const getInstantEvent = (opt) => ({
|
|
42
|
+
cat: 'blink.user_timing',
|
|
43
|
+
ph: 'i',
|
|
44
|
+
name: opt.name,
|
|
45
|
+
...defaults(opt),
|
|
46
|
+
args: opt.args ?? {},
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Creates a start tracing event with frame information.
|
|
50
|
+
* This event is needed at the beginning of the traceEvents array to make tell the UI profiling has started, and it should visualize the data.
|
|
51
|
+
* @param opt - Tracing configuration options
|
|
52
|
+
* @returns StartTracingEvent object
|
|
53
|
+
*/
|
|
54
|
+
export const getInstantEventTracingStartedInBrowser = (opt) => {
|
|
55
|
+
const { pid, tid, ts } = defaults(opt);
|
|
56
|
+
const id = frameTreeNodeId(pid, tid);
|
|
57
|
+
return {
|
|
58
|
+
cat: 'devtools.timeline',
|
|
59
|
+
ph: 'i',
|
|
60
|
+
name: 'TracingStartedInBrowser',
|
|
61
|
+
pid,
|
|
62
|
+
tid,
|
|
63
|
+
ts,
|
|
64
|
+
args: {
|
|
65
|
+
data: {
|
|
66
|
+
frameTreeNodeId: id,
|
|
67
|
+
frames: [
|
|
68
|
+
{
|
|
69
|
+
frame: frameName(pid, tid),
|
|
70
|
+
isInPrimaryMainFrame: true,
|
|
71
|
+
isOutermostMainFrame: true,
|
|
72
|
+
name: '',
|
|
73
|
+
processId: pid,
|
|
74
|
+
url: opt.url,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
persistentIds: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Creates a complete trace event with duration.
|
|
84
|
+
* @param opt - Event configuration with name and duration
|
|
85
|
+
* @returns CompleteEvent object
|
|
86
|
+
*/
|
|
87
|
+
export const getCompleteEvent = (opt) => ({
|
|
88
|
+
cat: 'devtools.timeline',
|
|
89
|
+
ph: 'X',
|
|
90
|
+
name: opt.name,
|
|
91
|
+
dur: opt.dur,
|
|
92
|
+
...defaults(opt),
|
|
93
|
+
args: {},
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Creates a span event (begin or end).
|
|
97
|
+
* @param ph - Phase ('b' or 'e')
|
|
98
|
+
* @param opt - Span event options
|
|
99
|
+
* @returns SpanEvent object
|
|
100
|
+
*/
|
|
101
|
+
export function getSpanEvent(ph, opt) {
|
|
102
|
+
return {
|
|
103
|
+
cat: 'blink.user_timing',
|
|
104
|
+
ph,
|
|
105
|
+
name: opt.name,
|
|
106
|
+
id2: opt.id2,
|
|
107
|
+
...defaults(opt),
|
|
108
|
+
args: opt.args?.data?.detail
|
|
109
|
+
? { data: { detail: opt.args.data.detail } }
|
|
110
|
+
: {},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a pair of begin and end span events.
|
|
115
|
+
* @param opt - Span configuration with start/end timestamps
|
|
116
|
+
* @returns Tuple of BeginEvent and EndEvent
|
|
117
|
+
*/
|
|
118
|
+
export const getSpan = (opt) => {
|
|
119
|
+
// tsMarkerPadding is here to make the measure slightly smaller so the markers align perfectly.
|
|
120
|
+
// Otherwise, the marker is visible at the start of the measure below the frame
|
|
121
|
+
// No padding Padding
|
|
122
|
+
// spans: ======== |======|
|
|
123
|
+
// marks: | |
|
|
124
|
+
const pad = opt.tsMarkerPadding ?? 1;
|
|
125
|
+
// b|e need to share the same id2
|
|
126
|
+
const id2 = opt.id2 ?? nextId2();
|
|
127
|
+
return [
|
|
128
|
+
getSpanEvent('b', {
|
|
129
|
+
...opt,
|
|
130
|
+
id2,
|
|
131
|
+
ts: opt.tsB + pad,
|
|
132
|
+
}),
|
|
133
|
+
getSpanEvent('e', {
|
|
134
|
+
...opt,
|
|
135
|
+
id2,
|
|
136
|
+
ts: opt.tsE - pad,
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Converts a PerformanceMark to an instant trace event.
|
|
142
|
+
* @param entry - Performance mark entry
|
|
143
|
+
* @param opt - Optional overrides for name, pid, and tid
|
|
144
|
+
* @returns InstantEvent object
|
|
145
|
+
*/
|
|
146
|
+
export const markToInstantEvent = (entry, opt) => getInstantEvent({
|
|
147
|
+
...opt,
|
|
148
|
+
name: opt?.name ?? entry.name,
|
|
149
|
+
ts: defaultClock.fromEntry(entry),
|
|
150
|
+
args: entry.detail ? { detail: entry.detail } : undefined,
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Converts a PerformanceMeasure to a pair of span events.
|
|
154
|
+
* @param entry - Performance measure entry
|
|
155
|
+
* @param opt - Optional overrides for name, pid, and tid
|
|
156
|
+
* @returns Tuple of BeginEvent and EndEvent
|
|
157
|
+
*/
|
|
158
|
+
export const measureToSpanEvents = (entry, opt) => getSpan({
|
|
159
|
+
...opt,
|
|
160
|
+
name: opt?.name ?? entry.name,
|
|
161
|
+
tsB: defaultClock.fromEntry(entry),
|
|
162
|
+
tsE: defaultClock.fromEntry(entry, true),
|
|
163
|
+
args: entry.detail ? { data: { detail: entry.detail } } : undefined,
|
|
164
|
+
});
|
|
165
|
+
/**
|
|
166
|
+
* Creates a complete trace file container with metadata.
|
|
167
|
+
* @param opt - Trace file configuration
|
|
168
|
+
* @returns TraceEventContainer with events and metadata
|
|
169
|
+
*/
|
|
170
|
+
export const getTraceFile = (opt) => ({
|
|
171
|
+
traceEvents: opt.traceEvents,
|
|
172
|
+
displayTimeUnit: 'ms',
|
|
173
|
+
metadata: {
|
|
174
|
+
source: 'Node.js UserTiming',
|
|
175
|
+
startTime: opt.startTime ?? new Date().toISOString(),
|
|
176
|
+
hardwareConcurrency: os.cpus().length,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=trace-file-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-file-utils.js","sourceRoot":"","sources":["../../../src/lib/trace-file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAchD,mEAAmE;AACnE,6CAA6C;AAC7C,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAiD,EAAE,EAAE,CAAC,CAAC;IACvE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG;IAC5B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,QAAQ;IACzB,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI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AC5B,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpD,mBAAmB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM;KACtC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import type { UserTimingDetail } from './user-timing-extensibility-api.type.js';
|
|
2
|
+
/**
|
|
3
|
+
* Arguments for instant trace events.
|
|
4
|
+
* @property {UserTimingDetail} [detail] - Optional user timing detail with DevTools payload
|
|
5
|
+
*/
|
|
6
|
+
export type InstantEventArgs = {
|
|
7
|
+
detail?: UserTimingDetail;
|
|
8
|
+
} & {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Arguments for span trace events (begin/end events).
|
|
13
|
+
* @property {object} [data] - Optional data object
|
|
14
|
+
* @property {UserTimingDetail} [data.detail] - Optional user timing detail with DevTools payload
|
|
15
|
+
*/
|
|
16
|
+
export type SpanEventArgs = {
|
|
17
|
+
data?: {
|
|
18
|
+
detail?: UserTimingDetail;
|
|
19
|
+
};
|
|
20
|
+
} & {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Arguments for complete trace events.
|
|
25
|
+
* @property {Record<string, unknown>} [detail] - Optional detail object with arbitrary properties
|
|
26
|
+
*/
|
|
27
|
+
export type CompleteEventArgs = {
|
|
28
|
+
detail?: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Arguments for start tracing events.
|
|
32
|
+
* @property {object} data - Tracing initialization data
|
|
33
|
+
* @property {number} data.frameTreeNodeId - Frame tree node identifier
|
|
34
|
+
* @property {Array} data.frames - Array of frame information
|
|
35
|
+
* @property {boolean} data.persistentIds - Whether IDs are persistent
|
|
36
|
+
*/
|
|
37
|
+
export type InstantEventTracingStartedInBrowserArgs = {
|
|
38
|
+
data: {
|
|
39
|
+
frameTreeNodeId: number;
|
|
40
|
+
frames: {
|
|
41
|
+
frame: string;
|
|
42
|
+
isInPrimaryMainFrame: boolean;
|
|
43
|
+
isOutermostMainFrame: boolean;
|
|
44
|
+
name: string;
|
|
45
|
+
processId: number;
|
|
46
|
+
url: string;
|
|
47
|
+
}[];
|
|
48
|
+
persistentIds: boolean;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Union type of all possible trace event arguments.
|
|
53
|
+
*/
|
|
54
|
+
export type TraceArgs = InstantEventArgs | SpanEventArgs | CompleteEventArgs | InstantEventTracingStartedInBrowserArgs;
|
|
55
|
+
/**
|
|
56
|
+
* Base properties shared by all trace events.
|
|
57
|
+
* @property {string} cat - Event category
|
|
58
|
+
* @property {string} name - Event name
|
|
59
|
+
* @property {number} pid - Process ID
|
|
60
|
+
* @property {number} tid - Thread ID
|
|
61
|
+
* @property {number} ts - Timestamp in epoch microseconds
|
|
62
|
+
* @property {TraceArgs} [args] - Optional event arguments
|
|
63
|
+
*/
|
|
64
|
+
export type BaseTraceEvent = {
|
|
65
|
+
cat: string;
|
|
66
|
+
name: string;
|
|
67
|
+
pid: number;
|
|
68
|
+
tid: number;
|
|
69
|
+
ts: number;
|
|
70
|
+
args: TraceArgs;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Start tracing event for Chrome DevTools tracing.
|
|
74
|
+
*/
|
|
75
|
+
export type InstantEventTracingStartedInBrowser = BaseTraceEvent & {
|
|
76
|
+
cat: 'devtools.timeline';
|
|
77
|
+
ph: 'i';
|
|
78
|
+
name: 'TracingStartedInBrowser';
|
|
79
|
+
args: InstantEventTracingStartedInBrowserArgs;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Complete trace event with duration.
|
|
83
|
+
* Represents a complete operation with start time and duration.
|
|
84
|
+
* @property {'X'} ph - Phase indicator for complete events
|
|
85
|
+
* @property {number} dur - Duration in microseconds
|
|
86
|
+
*/
|
|
87
|
+
export type CompleteEvent = BaseTraceEvent & {
|
|
88
|
+
ph: 'X';
|
|
89
|
+
dur: number;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Instant trace event representing a single point in time.
|
|
93
|
+
* Used for user timing marks and other instantaneous events.
|
|
94
|
+
* @property {'blink.user_timing'} cat - Fixed category for user timing events
|
|
95
|
+
* @property {'i'} ph - Phase indicator for instant events
|
|
96
|
+
* @property {never} [dur] - Duration is not applicable for instant events
|
|
97
|
+
* @property {InstantEventArgs} [args] - Optional event arguments
|
|
98
|
+
*/
|
|
99
|
+
export type InstantEvent = Omit<BaseTraceEvent, 'cat' | 'args'> & {
|
|
100
|
+
cat: 'blink.user_timing';
|
|
101
|
+
ph: 'i';
|
|
102
|
+
dur?: never;
|
|
103
|
+
args: InstantEventArgs;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Core properties for span trace events (begin/end pairs).
|
|
107
|
+
* @property {object} id2 - Span identifier
|
|
108
|
+
* @property {string} id2.local - Local span ID (unique to the process, same for b and e events)
|
|
109
|
+
* @property {SpanEventArgs} [args] - Optional event arguments
|
|
110
|
+
*/
|
|
111
|
+
type SpanCore = Omit<BaseTraceEvent, 'args'> & {
|
|
112
|
+
id2: {
|
|
113
|
+
local: string;
|
|
114
|
+
};
|
|
115
|
+
args: SpanEventArgs;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Begin event for a span (paired with an end event).
|
|
119
|
+
* @property {'b'} ph - Phase indicator for begin events
|
|
120
|
+
* @property {never} [dur] - Duration is not applicable for begin events
|
|
121
|
+
*/
|
|
122
|
+
export type BeginEvent = SpanCore & {
|
|
123
|
+
ph: 'b';
|
|
124
|
+
dur?: never;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* End event for a span (paired with a begin event).
|
|
128
|
+
* @property {'e'} ph - Phase indicator for end events
|
|
129
|
+
* @property {never} [dur] - Duration is not applicable for end events
|
|
130
|
+
*/
|
|
131
|
+
export type EndEvent = SpanCore & {
|
|
132
|
+
ph: 'e';
|
|
133
|
+
dur?: never;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Union type for span events (begin or end).
|
|
137
|
+
*/
|
|
138
|
+
export type SpanEvent = BeginEvent | EndEvent;
|
|
139
|
+
/**
|
|
140
|
+
* Union type of all trace event types.
|
|
141
|
+
*/
|
|
142
|
+
export type TraceEvent = InstantEvent | CompleteEvent | SpanEvent | InstantEventTracingStartedInBrowser;
|
|
143
|
+
/**
|
|
144
|
+
* Raw arguments format for trace events before processing.
|
|
145
|
+
* Either contains a detail string directly or nested in a data object.
|
|
146
|
+
*/
|
|
147
|
+
type RawArgs = {
|
|
148
|
+
detail?: string;
|
|
149
|
+
[key: string]: unknown;
|
|
150
|
+
} | {
|
|
151
|
+
data?: {
|
|
152
|
+
detail?: string;
|
|
153
|
+
};
|
|
154
|
+
[key: string]: unknown;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Raw trace event format before type conversion.
|
|
158
|
+
* Similar to TraceEvent but with unprocessed arguments.
|
|
159
|
+
*/
|
|
160
|
+
export type TraceEventRaw = Omit<TraceEvent, 'args'> & {
|
|
161
|
+
args: RawArgs;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Time window bounds (min, max) in trace time units (e.g. microseconds).
|
|
165
|
+
* @property {number} min - Minimum timestamp in the window
|
|
166
|
+
* @property {number} max - Maximum timestamp in the window
|
|
167
|
+
* @property {number} range - Calculated range (max - min)
|
|
168
|
+
*/
|
|
169
|
+
export type BreadcrumbWindow = {
|
|
170
|
+
min: number;
|
|
171
|
+
max: number;
|
|
172
|
+
range: number;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Custom label for a specific trace entry.
|
|
176
|
+
* @property {number | string} entryId - ID or index of the trace entry
|
|
177
|
+
* @property {string} label - Label text for the entry
|
|
178
|
+
* @property {string} [color] - Optional display color for the label
|
|
179
|
+
*/
|
|
180
|
+
export type EntryLabel = {
|
|
181
|
+
entryId: number | string;
|
|
182
|
+
label: string;
|
|
183
|
+
color?: string;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Link or relation between two trace entries.
|
|
187
|
+
* @property {number | string} fromEntryId - Source entry ID for the link
|
|
188
|
+
* @property {number | string} toEntryId - Target entry ID for the link
|
|
189
|
+
* @property {string} [linkType] - Optional type or description of the link
|
|
190
|
+
*/
|
|
191
|
+
export type EntryLink = {
|
|
192
|
+
fromEntryId: number | string;
|
|
193
|
+
toEntryId: number | string;
|
|
194
|
+
linkType?: string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* A time range annotated with a label.
|
|
198
|
+
* @property {number} startTime - Start timestamp of the range (microseconds)
|
|
199
|
+
* @property {number} endTime - End timestamp of the range (microseconds)
|
|
200
|
+
* @property {string} label - Annotation label for the time range
|
|
201
|
+
* @property {string} [color] - Optional display color for the range
|
|
202
|
+
*/
|
|
203
|
+
export type LabelledTimeRange = {
|
|
204
|
+
startTime: number;
|
|
205
|
+
endTime: number;
|
|
206
|
+
label: string;
|
|
207
|
+
color?: string;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Hidden or expandable entries information.
|
|
211
|
+
* @property {unknown[]} hiddenEntries - IDs or indexes of hidden entries
|
|
212
|
+
* @property {unknown[]} expandableEntries - IDs or indexes of expandable entries
|
|
213
|
+
*/
|
|
214
|
+
export type EntriesModifications = {
|
|
215
|
+
hiddenEntries: unknown[];
|
|
216
|
+
expandableEntries: unknown[];
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Initial breadcrumb information for time ranges and window.
|
|
220
|
+
* @property {BreadcrumbWindow} window - Time window bounds
|
|
221
|
+
* @property {unknown | null} child - Child breadcrumb or null
|
|
222
|
+
*/
|
|
223
|
+
export type InitialBreadcrumb = {
|
|
224
|
+
window: BreadcrumbWindow;
|
|
225
|
+
child: unknown | null;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Annotations such as labels and links between entries.
|
|
229
|
+
* @property {EntryLabel[]} entryLabels - Custom labels for entries
|
|
230
|
+
* @property {LabelledTimeRange[]} labelledTimeRanges - Time ranges annotated with labels
|
|
231
|
+
* @property {EntryLink[]} linksBetweenEntries - Links or relations between entries
|
|
232
|
+
*/
|
|
233
|
+
export type Annotations = {
|
|
234
|
+
entryLabels: EntryLabel[];
|
|
235
|
+
labelledTimeRanges: LabelledTimeRange[];
|
|
236
|
+
linksBetweenEntries: EntryLink[];
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Modifications made to trace data or UI in DevTools export
|
|
240
|
+
*/
|
|
241
|
+
export type Modifications = {
|
|
242
|
+
entriesModifications: EntriesModifications;
|
|
243
|
+
initialBreadcrumb: InitialBreadcrumb;
|
|
244
|
+
annotations: Annotations;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Top-level metadata for a trace file exported by Chrome DevTools.
|
|
248
|
+
* DevTools may add new fields over time.
|
|
249
|
+
*/
|
|
250
|
+
export type TraceMetadata = {
|
|
251
|
+
/** Usually "DevTools" for exports from the Performance panel */
|
|
252
|
+
source: string;
|
|
253
|
+
/** ISO timestamp when trace was recorded */
|
|
254
|
+
startTime: string;
|
|
255
|
+
/** May be present when recorded with throttling settings */
|
|
256
|
+
hardwareConcurrency?: number;
|
|
257
|
+
/** Common fields found in DevTools traces */
|
|
258
|
+
cpuThrottling?: number;
|
|
259
|
+
networkThrottling?: string;
|
|
260
|
+
enhancedTraceVersion?: number;
|
|
261
|
+
/** Allow additional custom metadata properties */
|
|
262
|
+
[key: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Structured container for trace events with metadata.
|
|
266
|
+
* @property {TraceEvent[]} traceEvents - Array of trace events
|
|
267
|
+
* @property {'ms' | 'ns'} [displayTimeUnit] - Time unit for display (milliseconds or nanoseconds)
|
|
268
|
+
* @property {TraceMetadata} [metadata] - Optional metadata about the trace
|
|
269
|
+
*/
|
|
270
|
+
export type TraceEventContainer = {
|
|
271
|
+
traceEvents: TraceEvent[];
|
|
272
|
+
displayTimeUnit?: 'ms' | 'ns';
|
|
273
|
+
metadata?: TraceMetadata;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Trace file format - either an array of events or a structured container.
|
|
277
|
+
*/
|
|
278
|
+
export type TraceFile = TraceEvent[] | TraceEventContainer;
|
|
279
|
+
export {};
|