Rocky_Mountain_Vending/.pnpm-store/v10/files/b3/2708bb5d1530e1dbe5d4e667221715c75b5647d2e4999ae9368b57fede3d48f42bdaedf95bf56af306de5d935379e2ef4c1b0f78582b3df67c37665c199b2a
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

85 lines
No EOL
2.8 KiB
Text

import fs from 'fs/promises';
import path from 'path';
import url from 'url';
import dataUriToBuffer from 'next/dist/compiled/data-uri-to-buffer';
function getSourceMapUrl(fileContents) {
const regex = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm;
let match = null;
for(;;){
let next = regex.exec(fileContents);
if (next == null) {
break;
}
match = next;
}
if (!(match && match[1])) {
return null;
}
return match[1].toString();
}
export async function getSourceMapFromFile(filename) {
filename = filename.startsWith('file://') ? url.fileURLToPath(filename) : filename;
let fileContents;
try {
fileContents = await fs.readFile(filename, 'utf-8');
} catch (error) {
throw Object.defineProperty(new Error(`Failed to read file contents of ${filename}.`, {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E466",
enumerable: false,
configurable: true
});
}
const sourceUrl = getSourceMapUrl(fileContents);
if (!sourceUrl) {
return undefined;
}
if (sourceUrl.startsWith('data:')) {
let buffer;
try {
buffer = dataUriToBuffer(sourceUrl);
} catch (error) {
throw Object.defineProperty(new Error(`Failed to parse source map URL for ${filename}.`, {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E199",
enumerable: false,
configurable: true
});
}
if (buffer.type !== 'application/json') {
throw Object.defineProperty(new Error(`Unknown source map type for ${filename}: ${buffer.typeFull}.`), "__NEXT_ERROR_CODE", {
value: "E113",
enumerable: false,
configurable: true
});
}
try {
return JSON.parse(buffer.toString());
} catch (error) {
throw Object.defineProperty(new Error(`Failed to parse source map for ${filename}.`, {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E318",
enumerable: false,
configurable: true
});
}
}
const sourceMapFilename = path.resolve(path.dirname(filename), decodeURIComponent(sourceUrl));
try {
const sourceMapContents = await fs.readFile(sourceMapFilename, 'utf-8');
return JSON.parse(sourceMapContents.toString());
} catch (error) {
throw Object.defineProperty(new Error(`Failed to parse source map ${sourceMapFilename}.`, {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E220",
enumerable: false,
configurable: true
});
}
}
//# sourceMappingURL=get-source-map-from-file.js.map