@paulirish/trace_engine 0.0.6 → 0.0.8

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/analyze-trace.mjs CHANGED
@@ -5,19 +5,25 @@
5
5
  // Run this first:
6
6
  // front_end/models/trace/build-trace-engine-lib.sh
7
7
 
8
+ /* eslint-disable rulesdir/es_modules_import */
8
9
  import fs from 'node:fs';
9
10
  import zlib from 'node:zlib';
10
- // eslint-disable-next-line rulesdir/es_modules_import
11
- import * as TraceModel from './trace.mjs';
12
11
 
13
- polyfillDOMRect();
12
+ /** @typedef {import('../front_end/models/trace/trace.ts')} TraceEngine */
13
+
14
+ /** @type {TraceEngine} */
15
+ import * as TraceEngine from './trace.mjs';
14
16
 
17
+ polyfillDOMRect();
15
18
 
19
+ /**
20
+ * @param {string} filename
21
+ * @returns {Promise<TraceEngine.TraceModel>}
22
+ */
16
23
  export async function analyzeTrace(filename) {
17
24
  const traceEvents = loadTraceEventsFromFile(filename);
18
25
 
19
- // Primary usage:
20
- const processor = TraceModel.Processor.TraceProcessor.createWithAllHandlers(); // aka `fullTraceEngine`
26
+ const processor = TraceEngine.Processor.TraceProcessor.createWithAllHandlers(TraceEngine.Types.Configuration.DEFAULT); // aka `fullTraceEngine`
21
27
  await processor.parse(traceEvents);
22
28
  return processor.data;
23
29
  }
@@ -29,8 +35,8 @@ if (import.meta.url.endsWith(process?.argv[1])) {
29
35
 
30
36
  async function cli() {
31
37
  const filename = process.argv.at(2);
32
- const traceModel = await analyzeTrace(filename);
33
- console.log(traceModel);
38
+ const TraceEngine = await analyzeTrace(filename);
39
+ console.log(TraceEngine);
34
40
  }
35
41
 
36
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paulirish/trace_engine",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "main": "trace.mjs",
6
6
  "scripts": {
@@ -11,7 +11,7 @@ const filename = './test/invalid-animation-events.json.gz';
11
11
  const data = await analyzeTrace(filename);
12
12
 
13
13
  test('key values are populated', t => {
14
- assert.equal(data.Renderer.allRendererEvents.length > 90_000, true);
14
+ assert.equal(data.Renderer.allTraceEntries.length > 90_000, true);
15
15
  assert.equal(data.Screenshots.length > 2, true);
16
16
  assert.equal(data.Meta.threadsInProcess.size > 2, true);
17
17
  assert.equal(data.Meta.mainFrameNavigations.length > 0, true);