import { getInjectedPlatformContext } from './platformContextHelpers' function normalizePluginRoutePrefix(prefix: string | undefined): string | undefined { const candidate = prefix?.trim() if (!candidate) return undefined const path = candidate.split('/').filter(Boolean).join('/') return path ? `/${path}/` : '/' } /** * Resolve the Vue Router base for a plugin frontend. * * Integrated plugins use the platform-injected mount prefix. Standalone and * development builds retain the caller's Vite base unchanged. */ export function resolvePluginFrontendBase(fallbackBase: string = '/'): string { const context = getInjectedPlatformContext() if (!context?.isIntegrated) return fallbackBase return normalizePluginRoutePrefix(context.plugin?.route_prefix) ?? fallbackBase }