Rocky_Mountain_Vending/.pnpm-store/v10/files/59/6d6f5d7a364541ad56d793f7a695f10f14a48291e9271444c470f131d01d4d511f820643deecc78c7fe30933cb65922573f5bdbeaf2acef6481648bef781ea
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
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>
2026-02-12 16:22:15 -07:00

91 lines
3.1 KiB
Text

/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Lantern from '../../lib/lantern/lantern.js';
import {LighthouseError} from '../../lib/lh-error.js';
import {LoadSimulator} from '../load-simulator.js';
import {ProcessedNavigation} from '../processed-navigation.js';
import {PageDependencyGraph} from '../page-dependency-graph.js';
import {TraceEngineResult} from '../trace-engine-result.js';
/**
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.Artifacts.ComputedContext} context
*/
async function getComputationDataParamsFromDevtoolsLog(data, context) {
if (data.gatherContext.gatherMode !== 'navigation') {
throw new Error(`Lantern metrics can only be computed on navigations`);
}
const graph = await PageDependencyGraph.request({...data, fromTrace: false}, context);
const processedNavigation = await ProcessedNavigation.request(data.trace, context);
const simulator = data.simulator || (await LoadSimulator.request(data, context));
return {simulator, graph, processedNavigation};
}
/**
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.Artifacts.ComputedContext} context
*/
async function getComputationDataParamsFromTrace(data, context) {
if (data.gatherContext.gatherMode !== 'navigation') {
throw new Error(`Lantern metrics can only be computed on navigations`);
}
const graph = await PageDependencyGraph.request({...data, fromTrace: true}, context);
const traceEngineResult = await TraceEngineResult.request(data, context);
const frameId = traceEngineResult.parsedTrace.Meta.mainFrameId;
const navigationId =
traceEngineResult.parsedTrace.Meta.mainFrameNavigations[0].args.data?.navigationId;
if (!navigationId) {
throw new Error(`Lantern metrics could not be calculated due to missing navigation id`);
}
const processedNavigation = Lantern.TraceEngineComputationData.createProcessedNavigation(
traceEngineResult.parsedTrace, frameId, navigationId);
const simulator = data.simulator || (await LoadSimulator.request(data, context));
return {simulator, graph, processedNavigation};
}
/**
* @param {unknown} err
* @return {never}
*/
function lanternErrorAdapter(err) {
if (!(err instanceof Lantern.Core.LanternError)) {
throw err;
}
const code = /** @type {keyof LighthouseError.errors} */ (err.message);
if (LighthouseError.errors[code]) {
throw new LighthouseError(LighthouseError.errors[code]);
}
throw err;
}
/**
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.Artifacts.ComputedContext} context
*/
function getComputationDataParams(data, context) {
// TODO(15841): remove devtools impl when ready to make breaking change.
if (process.env.INTERNAL_LANTERN_USE_TRACE !== undefined) {
return getComputationDataParamsFromTrace(data, context);
} else {
// This is the default behavior.
return getComputationDataParamsFromDevtoolsLog(data, context);
}
}
export {
getComputationDataParamsFromTrace,
getComputationDataParamsFromDevtoolsLog,
getComputationDataParams,
lanternErrorAdapter,
};