Socket
Book a DemoInstallSign in
Socket

@paulirish/trace_engine

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paulirish/trace_engine - npm Package Compare versions

Comparing version

to
0.0.14

3

core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json

@@ -36,4 +36,3 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -51,5 +51,4 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
]
}

@@ -37,4 +37,3 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -41,0 +40,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -49,2 +49,6 @@ import * as Helpers from './helpers/helpers.js';

/**
* Returns the array of entries that have a sign indicating that entries below are hidden.
**/
modifiedEntries(): Types.TraceEvents.TraceEventData[];
/**
* Applies an action to hide entries or removes entries

@@ -51,0 +55,0 @@ * from hidden entries array depending on the action.

@@ -81,2 +81,8 @@ // Copyright 2023 The Chromium Authors. All rights reserved.

/**
* Returns the array of entries that have a sign indicating that entries below are hidden.
**/
modifiedEntries() {
return this.#modifiedVisibleEntries;
}
/**
* Applies an action to hide entries or removes entries

@@ -102,3 +108,3 @@ * from hidden entries array depending on the action.

if (parentNode) {
this.#modifiedVisibleEntries.push(parentNode?.entry);
this.#addModifiedEntry(parentNode.entry);
}

@@ -116,6 +122,3 @@ break;

allDescendants.forEach(descendant => entriesToHide.add(descendant));
// If there are any children to hide, add selected entry to modifiedVisibleEntries array to identify in the UI that children of the selected entry are modified.
if (entriesToHide.size > 0) {
this.#modifiedVisibleEntries.push(action.entry);
}
this.#addModifiedEntry(action.entry);
break;

@@ -132,3 +135,3 @@ }

if (entriesToHide.size > 0) {
this.#modifiedVisibleEntries.push(action.entry);
this.#addModifiedEntry(action.entry);
}

@@ -152,2 +155,22 @@ break;

}
/**
* Add an entry to the array of entries that have a sign indicating that entries below are hidden.
* Also, remove all of the child entries of the new modified entry from the modified array. Do that because
* to draw the initiator from the closest visible entry, we need to get the closest entry that is
* marked as modified and we do not want to get some that are hidden.
*/
#addModifiedEntry(entry) {
this.#modifiedVisibleEntries.push(entry);
const entryNode = this.#entryToNode.get(entry);
if (!entryNode) {
// Invalid node was given, just ignore and move on.
return;
}
const allDescendants = this.#findAllDescendantsOfNode(entryNode);
if (allDescendants.length > 0) {
this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(entry => {
return !allDescendants.includes(entry);
});
}
}
// The direct parent might be hidden by other actions, therefore we look for the next visible parent.

@@ -154,0 +177,0 @@ #findNextVisibleParent(node) {

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -39,4 +39,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -43,0 +42,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -59,4 +59,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -63,0 +62,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -39,4 +39,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -43,0 +42,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -38,4 +38,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -42,0 +41,0 @@ "references": [

import type * as Types from '../types/types.js';
import { type NavigationInsightContext, type RequiredData } from './types.js';
export declare function deps(): ['NetworkRequests', 'Meta'];
export declare function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext): {
import { type InsightResult, type NavigationInsightContext, type RequiredData } from './types.js';
export declare function deps(): ['NetworkRequests', 'PageLoadMetrics'];
export declare function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext): InsightResult<{
renderBlockingRequests: Types.TraceEvents.SyntheticNetworkRequest[];
};
}>;
// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as Handlers from '../handlers/handlers.js';
import * as Helpers from '../helpers/helpers.js';
import { InsightWarning } from './types.js';
export function deps() {
return ['NetworkRequests', 'Meta'];
return ['NetworkRequests', 'PageLoadMetrics'];
}
export function generateInsight(traceParsedData, context) {
const firstPaintTs = traceParsedData.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)
?.get(context.navigationId)
?.get("FP" /* Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP */)
?.event?.ts;
if (!firstPaintTs) {
return {
renderBlockingRequests: [],
warnings: [InsightWarning.NO_FP],
};
}
const renderBlockingRequests = [];

@@ -14,2 +26,8 @@ for (const req of traceParsedData.NetworkRequests.byTime) {

}
if (req.args.data.renderBlocking !== 'blocking' && req.args.data.renderBlocking !== 'in_body_parser_blocking') {
continue;
}
if (req.args.data.syntheticData.finishTime > firstPaintTs) {
continue;
}
const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, traceParsedData.Meta.navigationsByFrameId);

@@ -19,5 +37,2 @@ if (navigation?.args.data?.navigationId !== context.navigationId) {

}
if (req.args.data.renderBlocking !== 'blocking') {
continue;
}
renderBlockingRequests.push(req);

@@ -24,0 +39,0 @@ }

@@ -11,7 +11,15 @@ import type * as Handlers from '../handlers/handlers.js';

type InsightRunnersType = typeof InsightsRunners;
export declare enum InsightWarning {
NO_FP = "NO_FP"
}
export type InsightResult<R extends Record<string, unknown>> = R & {
warnings?: InsightWarning[];
};
/**
* Contains insights for a specific navigation.
*/
export type NavigationInsightData = {
[I in keyof InsightRunnersType]?: ReturnType<InsightRunnersType[I]['generateInsight']>;
export type NavigationInsightData<H extends {
[key: string]: Handlers.Types.TraceEventHandler;
}> = {
[I in keyof EnabledInsightRunners<H>]: ReturnType<EnabledInsightRunners<H>[I]> | Error;
};

@@ -21,15 +29,19 @@ /**

*/
export type TraceInsightData = Map<string, NavigationInsightData>;
export type TraceInsightData<H extends {
[key: string]: Handlers.Types.TraceEventHandler;
}> = Map<string, NavigationInsightData<H>>;
/**
* Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset/undefined.
* Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset.
*/
export type EnabledInsightRunners<EnabledModelHandlers extends {
export type EnabledInsightRunners<H extends {
[key: string]: Handlers.Types.TraceEventHandler;
}> = {
[I in keyof InsightRunnersType]?: (traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>, context: NavigationInsightContext) => ReturnType<InsightRunnersType[I]['generateInsight']>;
[I in keyof InsightRunnersType]: [
Handlers.Types.EnabledHandlerDataWithMeta<H>
] extends [Parameters<InsightRunnersType[I]['generateInsight']>[0]] ? (traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<H>, context: NavigationInsightContext) => ReturnType<InsightRunnersType[I]['generateInsight']> : never;
};
/**
* Represents the narrow set of dependencies defined by an insight's `deps()` function.
* Represents the narrow set of dependencies defined by an insight's `deps()` function. `Meta` is always included regardless of `deps()`.
*/
export type RequiredData<D extends () => Array<keyof typeof Handlers.ModelHandlers>> = Pick<Handlers.Types.EnabledHandlerDataWithMeta<typeof Handlers.ModelHandlers>, ReturnType<D>[number]>;
export type RequiredData<D extends () => Array<keyof typeof Handlers.ModelHandlers>> = Handlers.Types.EnabledHandlerDataWithMeta<Pick<typeof Handlers.ModelHandlers, ReturnType<D>[number]>>;
export {};
// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export {};
export var InsightWarning;
(function (InsightWarning) {
InsightWarning["NO_FP"] = "NO_FP";
})(InsightWarning || (InsightWarning = {}));
//# sourceMappingURL=types.js.map

@@ -66,3 +66,3 @@ import * as Handlers from './handlers/handlers.js';

traceParsedData(index?: number): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers> | null;
traceInsights(index?: number): Insights.Types.TraceInsightData | null;
traceInsights(index?: number): Insights.Types.TraceInsightData<EnabledModelHandlers> | null;
metadata(index: number): Types.File.MetaData | null;

@@ -84,3 +84,3 @@ traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[] | null;

traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers> | null;
traceInsights: Insights.Types.TraceInsightData | null;
traceInsights: Insights.Types.TraceInsightData<Handlers> | null;
};

@@ -87,0 +87,0 @@ export declare const enum ModelUpdateType {

@@ -28,3 +28,3 @@ import * as Handlers from './handlers/handlers.js';

get traceParsedData(): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers> | null;
get insights(): Insights.Types.TraceInsightData | null;
get insights(): Insights.Types.TraceInsightData<EnabledModelHandlers> | null;
}

@@ -31,0 +31,0 @@ /**

@@ -18,3 +18,2 @@ // Copyright 2023 The Chromium Authors. All rights reserved.

// the model handlers the user passes in and the Meta handler.
// eslint-disable-next-line @typescript-eslint/naming-convention
#traceHandlers;

@@ -183,3 +182,10 @@ #status = "IDLE" /* Status.IDLE */;

for (const [name, generateInsight] of Object.entries(enabledInsightRunners)) {
Object.assign(navInsightData, { [name]: generateInsight(this.traceParsedData, context) });
let insightResult;
try {
insightResult = generateInsight(this.traceParsedData, context);
}
catch (err) {
insightResult = err;
}
Object.assign(navInsightData, { [name]: insightResult });
}

@@ -186,0 +192,0 @@ this.#insights.set(context.navigationId, navInsightData);

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

@@ -37,4 +37,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -41,0 +40,0 @@ "references": [

@@ -40,4 +40,3 @@ {

"../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -44,0 +43,0 @@ "references": [

@@ -36,4 +36,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -40,0 +39,0 @@ "references": [

// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// eslint-disable-next-line @typescript-eslint/naming-convention
export function MicroSeconds(value) {
return value;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
export function MilliSeconds(value) {
return value;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
export function Seconds(value) {

@@ -14,0 +11,0 @@ return value;

@@ -39,4 +39,3 @@ {

"../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
"../../../../../../../node_modules/@types/filesystem/index.d.ts",
"../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
"../../../../../../../node_modules/@types/filesystem/index.d.ts"
],

@@ -43,0 +42,0 @@ "references": [

{
"name": "@paulirish/trace_engine",
"version": "0.0.13",
"version": "0.0.14",
"description": "",
"main": "models/trace/trace.js",
"scripts": {
"test": "node test/test-trace-engine.mjs"
},
"type": "module",

@@ -10,0 +6,0 @@ "keywords": [],

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet