import { promises as fs } from 'fs'; import * as path from 'path'; function getScalarBundleCandidates(): string[] { const processWithResources = process as NodeJS.Process & { resourcesPath?: string }; const candidates: string[] = []; if (processWithResources.resourcesPath) { candidates.push(path.join(processWithResources.resourcesPath, 'scalar', 'api-reference.js')); } candidates.push(path.join(process.cwd(), 'node_modules', '@scalar', 'api-reference', 'dist', 'browser', 'standalone.js')); try { candidates.push(path.join(path.dirname(require.resolve('@scalar/api-reference')), 'browser', 'standalone.js')); } catch { // ignore; the packaged app path above is the production path } return candidates; } export async function getScalarApiReferenceBundlePath(): Promise { for (const candidate of getScalarBundleCandidates()) { try { await fs.access(candidate); return candidate; } catch { // try the next candidate } } return null; } export function getDocsHtml(specUrl: string): string { const scalarConfig = { url: specUrl, theme: 'default', layout: 'modern', proxyUrl: '', telemetry: false, persistAuth: false, showDeveloperTools: 'never', hideDownloadButton: false, hideTestRequestButton: false, hideClientButton: false, externalUrls: { dashboardUrl: '', registryUrl: '', proxyUrl: '', apiBaseUrl: '' }, agent: { disabled: true, hideAddApi: true }, mcp: { disabled: true } }; return ` MetoYou Local API
`; }