Rocky_Mountain_Vending/.pnpm-store/v10/files/72/f63b47e23286261a45bf1f554fb1b995a85e9dd6db4f955517caced8a007b914c6e8c591a9cc1258ebbf40927afc6af53e9088ac64263578723efc136d126a
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

71 lines
2.2 KiB
Text

/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import Parser from 'metaviewport-parser';
import {makeComputedArtifact} from './computed-artifact.js';
class ViewportMeta {
/**
* @param {LH.GathererArtifacts['MetaElements']} MetaElements
* @return {Promise<ViewportMetaResult>}
*/
static async compute_(MetaElements) {
const viewportMeta = MetaElements.find(meta => meta.name === 'viewport');
if (!viewportMeta) {
return {
hasViewportTag: false,
isMobileOptimized: false,
parserWarnings: [],
rawContentString: undefined,
};
}
const warnings = [];
const rawContentString = viewportMeta.content || '';
const parsedProps = Parser.parseMetaViewPortContent(rawContentString);
if (Object.keys(parsedProps.unknownProperties).length) {
warnings.push(`Invalid properties found: ${JSON.stringify(parsedProps.unknownProperties)}`);
}
if (Object.keys(parsedProps.invalidValues).length) {
warnings.push(`Invalid values found: ${JSON.stringify(parsedProps.invalidValues)}`);
}
const viewportProps = parsedProps.validProperties;
const initialScale = Number(viewportProps['initial-scale']);
if (!isNaN(initialScale) && initialScale < 1) {
return {
hasViewportTag: true,
isMobileOptimized: false,
parserWarnings: warnings,
rawContentString,
};
}
const isMobileOptimized = Boolean(viewportProps.width || initialScale);
return {
hasViewportTag: true,
isMobileOptimized,
parserWarnings: warnings,
rawContentString,
};
}
}
const ViewportMetaComputed = makeComputedArtifact(ViewportMeta, null);
export {ViewportMetaComputed as ViewportMeta};
/**
* @typedef {object} ViewportMetaResult
* @property {boolean} hasViewportTag Whether the page has any viewport tag.
* @property {boolean} isMobileOptimized Whether the viewport tag is optimized for mobile screens.
* @property {Array<string>} parserWarnings Warnings if the parser encountered invalid content in the viewport tag.
* @property {string|undefined} rawContentString The `content` attribute value, if a viewport was defined.
*/