Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
1.5 KiB
Text
58 lines
1.5 KiB
Text
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {Audit} from './audit.js';
|
|
import {MainThreadTasks as MainThreadTasksComputed} from '../computed/main-thread-tasks.js';
|
|
|
|
class MainThreadTasks extends Audit {
|
|
/**
|
|
* @return {LH.Audit.Meta}
|
|
*/
|
|
static get meta() {
|
|
return {
|
|
id: 'main-thread-tasks',
|
|
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
|
|
title: 'Tasks',
|
|
description: 'Lists the toplevel main thread tasks that executed during page load.',
|
|
requiredArtifacts: ['Trace'],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param {LH.Artifacts} artifacts
|
|
* @param {LH.Audit.Context} context
|
|
* @return {Promise<LH.Audit.Product>}
|
|
*/
|
|
static async audit(artifacts, context) {
|
|
const trace = artifacts.Trace;
|
|
const tasks = await MainThreadTasksComputed.request(trace, context);
|
|
|
|
const results = tasks
|
|
// Filter to just the sizable toplevel tasks; toplevel tasks are tasks without a parent.
|
|
.filter(task => task.duration > 5 && !task.parent)
|
|
.map(task => {
|
|
return {
|
|
duration: task.duration,
|
|
startTime: task.startTime,
|
|
};
|
|
});
|
|
|
|
/** @type {LH.Audit.Details.Table['headings']} */
|
|
const headings = [
|
|
{key: 'startTime', valueType: 'ms', granularity: 1, label: 'Start Time'},
|
|
{key: 'duration', valueType: 'ms', granularity: 1, label: 'End Time'},
|
|
];
|
|
|
|
const tableDetails = Audit.makeTableDetails(headings, results);
|
|
|
|
return {
|
|
score: 1,
|
|
details: tableDetails,
|
|
};
|
|
}
|
|
}
|
|
|
|
export default MainThreadTasks;
|