Rocky_Mountain_Vending/.pnpm-store/v10/files/dd/132d3c49c6773a77bd5836e20e15f2a6c6090a72b31b6e257277e489696d929909be5bda17b1409a27c9f25bafb245f32a768fca0f2484210ff9b5561bebf0
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

57 lines
1.7 KiB
Text

/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @param {Error} err
* @return {undefined}
*/
function handlePotentialMissingNodeError(err) {
if (
/No node.*found/.test(err.message) ||
/Node.*does not belong to the document/.test(err.message)
) {
return undefined;
}
throw err;
}
/**
* Resolves a backend node ID (from a trace event, protocol, etc) to the object ID for use with
* `Runtime.callFunctionOn`. `undefined` means the node could not be found.
*
* @param {LH.Gatherer.ProtocolSession} session
* @param {number} backendNodeId
* @return {Promise<string|undefined>}
*/
async function resolveNodeIdToObjectId(session, backendNodeId) {
try {
const resolveNodeResponse = await session.sendCommand('DOM.resolveNode', {backendNodeId});
return resolveNodeResponse.object.objectId;
} catch (err) {
return handlePotentialMissingNodeError(err);
}
}
/**
* Resolves a proprietary devtools node path (created from page-function.js) to the object ID for use
* with `Runtime.callFunctionOn`. `undefined` means the node could not be found.
* Requires `DOM.getDocument` to have been called since the object's creation or it will always be `undefined`.
*
* @param {LH.Gatherer.ProtocolSession} session
* @param {string} path
* @return {Promise<string|undefined>}
*/
async function resolveDevtoolsNodePathToObjectId(session, path) {
try {
const {nodeId} = await session.sendCommand('DOM.pushNodeByPathToFrontend', {path});
const {object: {objectId}} = await session.sendCommand('DOM.resolveNode', {nodeId});
return objectId;
} catch (err) {
return handlePotentialMissingNodeError(err);
}
}
export {resolveNodeIdToObjectId, resolveDevtoolsNodePathToObjectId};