Rocky_Mountain_Vending/.pnpm-store/v10/files/c5/8416dca963528e1edd10c30792f34ee96f0110fc0e32b7de2bc5f19d9ee6cfcaa765c6bdbb02be60625cfa217d389f280b34c6207a28bfcb35c076b799fd32
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

42 lines
1.7 KiB
Text

/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Lantern from '../lib/lantern/lantern.js';
import {makeComputedArtifact} from './computed-artifact.js';
import {NetworkRecords} from './network-records.js';
/**
* @fileoverview This artifact identifies the main resource on the page. Current solution assumes
* that the main resource is the first non-redirected one.
*/
class MainResource {
/**
* @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog}} data
* @param {LH.Artifacts.ComputedContext} context
* @return {Promise<LH.Artifacts.NetworkRequest>}
*/
static async compute_(data, context) {
const {mainDocumentUrl} = data.URL;
if (!mainDocumentUrl) throw new Error('mainDocumentUrl must exist to get the main resource');
const records = await NetworkRecords.request(data.devtoolsLog, context);
// We could have more than one record matching the main doucment url,
// if the page did `location.reload()`. Since `mainDocumentUrl` refers to the _last_
// document request, we should return the last candidate here. Besides, the browser
// would have evicted the first request by the time `MainDocumentRequest` (a consumer
// of this computed artifact) attempts to fetch the contents, resulting in a protocol error.
const mainResource =
Lantern.Core.NetworkAnalyzer.findLastDocumentForUrl(records, mainDocumentUrl);
if (!mainResource) {
throw new Error('Unable to identify the main resource');
}
return mainResource;
}
}
const MainResourceComputed = makeComputedArtifact(MainResource, ['URL', 'devtoolsLog']);
export {MainResourceComputed as MainResource};