devtools-tracing 1.2.2 → 1.3.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/.vscode/launch.json +20 -0
- package/README.md +57 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +76804 -18793
- package/dist/lib/front_end/third_party/codemirror.next/bundle.d.ts +39 -0
- package/dist/src/sourcemap.d.ts +27 -0
- package/examples/sourcemap.ts +121 -0
- package/package.json +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "Debug sourcemap example",
|
|
8
|
+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
9
|
+
"args": ["examples/sourcemap.ts", "${input:traceFile}"],
|
|
10
|
+
"console": "integratedTerminal"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"inputs": [
|
|
14
|
+
{
|
|
15
|
+
"id": "traceFile",
|
|
16
|
+
"type": "promptString",
|
|
17
|
+
"description": "Path to trace file (.json or .json.gz)"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/README.md
CHANGED
|
@@ -1,4 +1,59 @@
|
|
|
1
1
|
# devtools-tracing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Node.js library for programmatic analysis of Chrome DevTools performance traces. Re-exports the trace processing engine from [chrome-devtools-frontend](https://www.npmjs.com/package/chrome-devtools-frontend) and provides higher-level utilities for common tasks.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install devtools-tracing
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as zlib from 'node:zlib';
|
|
16
|
+
import { initDevToolsTracing, Trace } from 'devtools-tracing';
|
|
17
|
+
|
|
18
|
+
// Must be called once before using the library.
|
|
19
|
+
initDevToolsTracing();
|
|
20
|
+
|
|
21
|
+
const raw = fs.readFileSync('trace.json.gz');
|
|
22
|
+
const traceData = JSON.parse(
|
|
23
|
+
zlib.gunzipSync(raw).toString(),
|
|
24
|
+
) as Trace.Types.File.TraceFile;
|
|
25
|
+
|
|
26
|
+
const model = Trace.TraceModel.Model.createWithAllHandlers();
|
|
27
|
+
await model.parse(traceData.traceEvents, {
|
|
28
|
+
isCPUProfile: false,
|
|
29
|
+
isFreshRecording: false,
|
|
30
|
+
metadata: traceData.metadata,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const parsedTrace = model.parsedTrace(0);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
Run with a trace file (`.json` or `.json.gz`):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
# INP breakdown
|
|
42
|
+
npm run example:inp -- trace.json.gz
|
|
43
|
+
|
|
44
|
+
# Timeline category stats
|
|
45
|
+
npm run example:stats -- trace.json.gz
|
|
46
|
+
|
|
47
|
+
# Source map symbolication
|
|
48
|
+
npm run example:sourcemap -- trace.json.gz
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
See the [`examples/`](./examples) directory for full source.
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
A [build script](./generate.ts) extracts trace-related code from the `chrome-devtools-frontend` npm package into `lib/`, resolving dependencies via AST analysis and stubbing browser APIs. The result is bundled into a single CommonJS file via esbuild.
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
BSD-3-Clause, matching the license of [chrome-devtools-frontend](https://github.com/ChromeDevTools/devtools-frontend/blob/main/LICENSE).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { initDevToolsTracing } from './src/init.js';
|
|
2
2
|
export { statsForTimeRange, entryIsVisibleInTimeline } from './src/timeline.js';
|
|
3
|
+
export { createSourceMapResolver, symbolicateTrace } from './src/sourcemap.js';
|
|
4
|
+
export type { SymbolicateOptions, SymbolicateResult } from './src/sourcemap.js';
|
|
3
5
|
import * as Trace from './lib/front_end/models/trace/trace.js';
|
|
4
|
-
|
|
6
|
+
import * as SDK from './lib/front_end/core/sdk/sdk.js';
|
|
7
|
+
export { Trace, SDK };
|