@viteplus/versions 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -9
- package/components/fallback-component.spec.ts +172 -0
- package/components/fallback.component.ts +257 -0
- package/components/version-switcher.component.ts +116 -424
- package/components/version-switcher.component.vue +3 -8
- package/dist/index.d.ts +126 -11
- package/dist/index.js +2 -2
- package/dist/index.js.map +5 -5
- package/package.json +13 -8
package/dist/index.js.map
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/models/state.model.ts", "../src/components/locale.component.ts", "../src/constants/configuration.constant.ts", "../src/components/rewrites.component.ts", "../src/components/object.component.ts", "../src/index.ts", "../src/components/nav.component.ts", "../src/components/switcher.component.ts", "../src/components/sidebar.component.ts", "../src/components/
|
|
4
|
-
"sourceRoot": "https://github.com/viteplus/versions/tree/
|
|
5
|
-
"sourcesContent": ["/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { Dirent } from 'fs';\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { join, posix } from 'path';\nimport { Injectable } from '@remotex-labs/xinject';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { getLanguageOnly } from '@components/locale.component';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and the routes each version publishes.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * List of all available documentation versions.\n *\n * @remarks\n * This array is populated during initialization (`init()`) by reading the archive\n * and sources directories. Each element is a version string (e.g., `\"1.0\"`, `\"2.0\"`).\n *\n * @since 2.0.0\n */\n\n readonly versionsList: Array<string> = [];\n\n /**\n * Maps locale keys to their effective base paths.\n *\n * @remarks\n * - Keys are the locale identifiers as defined in the user configuration\n * (e.g., `\"de\"`, `\"root\"`).\n * - Values are the corresponding effective base paths or link prefixes\n * used inside the generated VitePress config.\n * - The `\"root\"` locale always maps to the default language of the site.\n *\n * This mapping is used internally to resolve and normalize locale-based\n * routing for both source files and versioned archives.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * Maps each version label to the routes that version publishes.\n *\n * @remarks\n * Keys are version labels, the current one taken from `versionsConfig.current`\n * and the archived ones from the folder names under {@link archivePath}.\n * Values are the published routes of that version, the same strings VitePress\n * receives back from `vitepressConfig.rewrites`.\n *\n * The version switcher reads this record to tell whether the page a reader is on\n * also exists in the version they picked, so it can fall back to that version's\n * home page instead of linking at a route that returns a 404.\n *\n * The record stays empty until `parseRoutesComponent` fills it.\n *\n * @example\n * ```ts\n * routesMap = {\n * 'v2.0.x': [ 'index.md', 'release.md', 'guide/index.md' ],\n * 'v1.0.x': [ 'v1.0.x/index.md', 'v1.0.x/release.md' ]\n * };\n * ```\n *\n * @since 2.1.0\n */\n\n readonly routesMap: Record<string, Array<string>> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.sources = sources;\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) {\n console.error(xterm.red('[ viteplus ]'), `Source directory ${ this.sourcesPath } does not exist\\n`);\n throw new Error(`Source directory ${ this.sourcesPath } does not exist`);\n }\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state model by scanning archive directory and setting up locale configuration.\n *\n * @returns The current instance for method chaining.\n *\n * @remarks\n * This method performs the initial setup sequence for a multi-version documentation system\n * by discovering available versions and preparing the locale infrastructure. It executes\n * three primary operations:\n *\n * 1. **Root Locale Initialization**: Sets up the root locale entry in {@link vitepressConfig.locales}\n * with an empty theme configuration, establishing the foundation for all locale-specific settings\n * 2. **Version Discovery**: Scans {@link archivePath} using {@link readdirSync} to identify all\n * subdirectories, which represent available documentation versions. Each subdirectory name\n * is added to {@link versionsList}\n * 3. **Locale Map Setup**: Calls {@link initializeLocalesMap} to establish the locale mapping\n * structure and populate versioned locale entries\n *\n * The archive directory structure is expected to contain version folders:\n * ```\n * archive/\n * \u251C\u2500\u2500 v1.0/\n * \u251C\u2500\u2500 v2.0/\n * \u2514\u2500\u2500 latest/\n * ```\n *\n * Each subdirectory discovered becomes a version entry, enabling the system to generate\n * versioned locale configurations and routing structures for multi-version documentation.\n *\n * The root locale is initialized first to ensure a consistent base exists before user-defined\n * locale configurations are applied through {@link initializeLocalesMap}.\n *\n * Method chaining support allows for fluent initialization patterns, making it easy to\n * combine multiple setup operations in a readable sequence.\n *\n * @example\n * ```ts\n * // Basic initialization\n * const state = new StateModel(config);\n * state.init();\n *\n * console.log(state.versionsList);\n * // ['v1.0', 'v2.0', 'v3.0', 'latest']\n *\n * console.log(state.vitepressConfig.locales['root']);\n * // { themeConfig: {} }\n *\n * // Method chaining pattern\n * const state = new StateModel(config)\n * .init();\n *\n * console.log(`Initialized with ${state.versionsList.length} versions`);\n *\n * // Use case: Dynamic version detection\n * const config = {\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n *\n * // Archive structure:\n * // versions/\n * // \u251C\u2500\u2500 v1.0.0/\n * // \u251C\u2500\u2500 v2.0.0/\n * // \u2514\u2500\u2500 latest/\n *\n * console.log(state.versionsList);\n * // ['v1.0.0', 'v2.0.0']\n *\n * // Locale entries created for each version\n * console.log(Object.keys(state.vitepressConfig.locales));\n * // ['root', 'v1.0.0', 'v2.0.0', 'latest', '/de/', 'de/v1.0.0', 'de/v2.0.0']\n *\n * // Use case: Error handling\n * try {\n * const state = new StateModel(config).init();\n * if (state.versionsList.length === 0) {\n * console.warn('No versions found in archive');\n * }\n * } catch (error) {\n * console.error('Failed to initialize state:', error);\n * }\n * ```\n *\n * @see archivePath\n * @see readdirSync\n * @see versionsList\n * @see vitepressConfig\n * @see initializeLocalesMap\n *\n * @since 2.0.0\n */\n\n init(): this {\n this.vitepressConfig.locales.root = { themeConfig: {} };\n const versionFolders = readdirSync(this.archivePath, { withFileTypes: true })\n .filter((entry: Dirent) => entry.isDirectory())\n .map((entry: Dirent) => entry.name);\n\n this.versionsList.push(...versionFolders);\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Initializes the locale entries in the VitePress configuration and builds a mapping\n * of locales to their links for all versions.\n *\n * @remarks\n * - Adds a `root` locale entry.\n * - Copies all user-defined locales into the VitePress config.\n * - Populates `localesMap` with locale keys and their corresponding links (or folder names).\n * - Ensures that for each documentation version, a locale entry exists in the VitePress config.\n * - Handles both root and non-root locales, creating versioned paths automatically.\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const locales = this.vitepressConfig.locales;\n const userLocales = this.configuration.locales;\n\n locales['root'] = {};\n if (Object.keys(userLocales).length > 0) {\n const keys = Object.keys(userLocales);\n const rootLocaleKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const index = getLanguageOnly(userLocales[key].lang ?? key);\n for (const version of this.versionsList) {\n if(key === rootLocaleKey) continue;\n const versionPath = posix.join(index, version);\n locales[versionPath] = {};\n }\n\n if (key === rootLocaleKey) {\n this.localesMap[userLocales[key].link ?? index] = 'root';\n } else {\n locales[key] = {};\n this.localesMap[userLocales[key].link ?? index] = key;\n }\n }\n }\n\n for (const version of this.versionsList) {\n locales[version] = {};\n }\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { LocaleInterface } from '@interfaces/locale.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Extracts the language code from a locale string.\n *\n * @param locale - The locale string to parse (e.g., 'en-US', 'fr_CA', 'zh-Hans-CN').\n * @returns The language code portion of the locale (e.g., 'en', 'fr', 'zh').\n *\n * @remarks\n * This function parses a locale string and returns only the primary language code,\n * discarding region, script, and variant information. It handles both standard\n * separators used in locale strings:\n * - Hyphen (`-`): BCP 47 standard (e.g., 'en-US', 'zh-Hans-CN')\n * - Underscore (`_`): POSIX/Java standard (e.g., 'en_US', 'pt_BR')\n *\n * The language code is always the first component of a locale identifier and\n * represents the base language without regional or script variations.\n *\n * Common use cases:\n * - Fallback language selection when a specific locale is unavailable\n * - Grouping locales by language family\n * - Simplifying locale matching for translations\n * - Language detection without regional specificity\n * - API requests that only accept language codes\n *\n * Locale format examples:\n * - Language only: 'en', 'fr', 'ja'\n * - Language + Region: 'en-US', 'fr-CA', 'pt-BR'\n * - Language + Script + Region: 'zh-Hans-CN', 'zh-Hant-TW'\n * - POSIX format: 'en_US', 'de_DE', 'es_MX'\n *\n * @example\n * ```ts\n * // BCP 47 format with region\n * console.log(getLanguageOnly('en-US')); // 'en'\n * console.log(getLanguageOnly('fr-CA')); // 'fr'\n * console.log(getLanguageOnly('pt-BR')); // 'pt'\n *\n * // POSIX format with underscore\n * console.log(getLanguageOnly('en_GB')); // 'en'\n * console.log(getLanguageOnly('de_DE')); // 'de'\n *\n * // Complex locale with script\n * console.log(getLanguageOnly('zh-Hans-CN')); // 'zh'\n * console.log(getLanguageOnly('zh-Hant-TW')); // 'zh'\n *\n * // Language code only (no separator)\n * console.log(getLanguageOnly('ja')); // 'ja'\n * console.log(getLanguageOnly('ko')); // 'ko'\n *\n * // Use case: Fallback language selection\n * const userLocale = 'es-MX';\n * const language = getLanguageOnly(userLocale); // 'es'\n * const translations = loadTranslations(language); // Load Spanish translations\n * ```\n *\n * @since 2.0.5\n */\n\nexport function getLanguageOnly(locale: string): string {\n return locale.split(/[-_]/)[0];\n}\n\n/**\n * Creates a sanitized copy of a locale object with navigation data removed.\n *\n * @param sourceLocale - The original locale object to sanitize {@link LocaleInterface}.\n * @returns A deep clone of the locale with navigation and sidebar data removed.\n *\n * @remarks\n * This function creates a deep copy of a locale object and removes potentially\n * large or sensitive theme configuration data, specifically navigation and sidebar\n * structures. This is useful for:\n * - Reducing payload size when sending locale data to clients\n * - Removing structure information that shouldn't be exposed\n * - Creating clean locale data for API responses\n * - Preparing locale data for serialization or storage\n *\n * The sanitization process:\n * 1. Creates a deep clone using {@link structuredClone} to avoid mutating the original\n * 2. Checks if `themeConfig` exists and contains properties\n * 3. Removes `nav` property (navigation menu structure)\n * 4. Removes `sidebar` property (sidebar navigation structure)\n * 5. Preserves all other locale data unchanged\n *\n * Properties preserved:\n * - All locale metadata (language, region, etc.)\n * - Translation strings and messages\n * - Theme configuration except nav and sidebar\n * - Any custom properties not related to navigation\n *\n * The original locale object is never modified, ensuring immutability and\n * preventing unintended side effects in the calling code.\n *\n * @example\n * ```ts\n * const originalLocale: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: {\n * nav: [\n * { text: 'Home', link: '/' },\n * { text: 'About', link: '/about' }\n * ],\n * sidebar: {\n * '/guide/': [{ text: 'Introduction', link: '/guide/intro' }]\n * },\n * footer: 'Copyright 2024'\n * }\n * };\n *\n * const sanitized = createSanitizedLocale(originalLocale);\n *\n * console.log(sanitized.themeConfig?.nav); // undefined\n * console.log(sanitized.themeConfig?.sidebar); // undefined\n * console.log(sanitized.themeConfig?.footer); // 'Copyright 2024'\n * console.log(originalLocale.themeConfig?.nav); // Still intact\n *\n * // Use case: API response\n * app.get('/api/locale/:lang', (req, res) => {\n * const locale = getLocale(req.params.lang);\n * const sanitized = createSanitizedLocale(locale);\n * res.json(sanitized); // Smaller payload without navigation data\n * });\n *\n * // Use case: Locale without theme config\n * const minimalLocale: LocaleInterface = {\n * lang: 'fr',\n * label: 'Fran\u00E7ais'\n * };\n * const result = createSanitizedLocale(minimalLocale);\n * // Returns clone unchanged (no themeConfig to sanitize)\n * ```\n *\n * @see LocaleInterface\n * @since 2.0.5\n */\n\nfunction createSanitizedLocale(sourceLocale: LocaleInterface): LocaleInterface {\n const cloned = Object.assign({}, sourceLocale);\n\n if (cloned.themeConfig && Object.keys(cloned.themeConfig).length > 0) {\n cloned.themeConfig = Object.assign({}, cloned.themeConfig);\n\n delete cloned.themeConfig.nav;\n delete cloned.themeConfig.sidebar;\n }\n\n return cloned;\n}\n\n/**\n * Generates a locale-specific URL path based on language configuration.\n *\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') to generate a link for.\n * @returns A URL path string: '/' for root locale, or '/<language>/' for non-root locales.\n *\n * @remarks\n * This function creates URL paths for locale-specific content in a multi-language\n * application. It follows a common pattern where:\n * - The root/default locale uses the base path '/'\n * - Other locales use language-prefixed paths like '/fr/', '/es/', '/de/'\n *\n * The function uses {@link getLanguageOnly} to extract just the language code from\n * the full locale string, ignoring region and script information. This ensures clean,\n * simple URLs like '/fr/' instead of '/fr-CA/' or '/zh/' instead of '/zh-Hans-CN/'.\n *\n * URL structure:\n * - Root locale: `'/'` - No language prefix (typically English or primary language)\n * - Non-root locale: `'/{lang}/'` - Language code with leading and trailing slashes\n *\n * @example\n * ```ts\n * // Root locale (typically English)\n * const rootLink = generateLocaleLink(true, 'en-US');\n * console.log(rootLink); // '/'\n *\n * // Non-root locales\n * const frenchLink = generateLocaleLink(false, 'fr-CA');\n * console.log(frenchLink); // '/fr/'\n *\n * const spanishLink = generateLocaleLink(false, 'es-MX');\n * console.log(spanishLink); // '/es/'\n *\n * const chineseLink = generateLocaleLink(false, 'zh-Hans-CN');\n * console.log(chineseLink); // '/zh/'\n *\n * // Use case: Locale switcher navigation\n * const locales = [\n * { lang: 'en-US', isRoot: true, label: 'English' },\n * { lang: 'fr-CA', isRoot: false, label: 'Fran\u00E7ais' },\n * { lang: 'es-MX', isRoot: false, label: 'Espa\u00F1ol' }\n * ];\n *\n * const links = locales.map(locale => ({\n * label: locale.label,\n * href: generateLocaleLink(locale.isRoot, locale.lang)\n * }));\n * // [\n * // { label: 'English', href: '/' },\n * // { label: 'Fran\u00E7ais', href: '/fr/' },\n * // { label: 'Espa\u00F1ol', href: '/es/' }\n * // ]\n *\n * // Use case: Building full page URLs\n * const currentLocale = { isRoot: false, lang: 'de-DE' };\n * const pagePath = 'docs/getting-started';\n * const fullUrl = generateLocaleLink(currentLocale.isRoot, currentLocale.lang) + pagePath;\n * console.log(fullUrl); // '/de/docs/getting-started'\n * ```\n *\n * @see getLanguageOnly\n * @since 2.0.5\n */\n\nfunction generateLocaleLink(isRoot: boolean, lang: string): string {\n return isRoot ? '/' : `/${ getLanguageOnly(lang) }/`;\n}\n\n/**\n * Creates a versioned locale configuration with minimal label and generated link.\n *\n * @param baseLocale - The base locale object to clone {@link LocaleInterface}.\n * @param isRoot - Whether this is the root/default locale.\n * @param lang - The full locale string (e.g., 'en-US', 'fr-CA') for link generation.\n * @returns A new locale object with modified label and link properties.\n *\n * @remarks\n * This function creates a locale configuration suitable for version-specific documentation\n * or multi-version site structures. It clones the base locale and modifies two key properties:\n * - Sets the label to a single space (hiding or minimizing visual display)\n * - Generates a locale-specific link using {@link generateLocaleLink}\n *\n * The single-space label is commonly used in documentation sites where:\n * - Locale switching is handled by icons or flags instead of text\n * - Visual space needs to be preserved without displaying text\n * - The locale selector UI requires a placeholder\n * - Multiple versions need consistent spacing without labels\n *\n * The function uses {@link structuredClone} to create a deep copy, ensuring the\n * original locale remains unmodified and preventing unintended side effects.\n *\n * @example\n * ```ts\n * const baseLocale: LocaleInterface = {\n * lang: 'fr-CA',\n * label: 'Fran\u00E7ais (Canada)',\n * themeConfig: {\n * nav: [...],\n * sidebar: {...}\n * }\n * };\n *\n * // Create versioned locale for non-root language\n * const versionedFr = createVersionedLocale(baseLocale, false, 'fr-CA');\n * console.log(versionedFr.label); // ' '\n * console.log(versionedFr.link); // '/fr/'\n *\n * // Create versioned locale for root language\n * const baseEn: LocaleInterface = {\n * lang: 'en-US',\n * label: 'English (US)',\n * themeConfig: {...}\n * };\n *\n * const versionedEn = createVersionedLocale(baseEn, true, 'en-US');\n * console.log(versionedEn.label); // ' '\n * console.log(versionedEn.link); // '/'\n *\n * // Use case: Multi-version documentation site\n * const versions = ['v1', 'v2', 'v3'];\n * const locales = ['en-US', 'fr-CA', 'es-MX'];\n *\n * const versionedLocales = versions.flatMap(version =>\n * locales.map((lang, idx) => ({\n * version,\n * locale: createVersionedLocale(\n * getBaseLocale(lang),\n * idx === 0, // First locale is root\n * lang\n * )\n * }))\n * );\n *\n * // Use case: Icon-based locale switcher\n * const localeConfigs = [\n * { base: enLocale, isRoot: true, lang: 'en-US', icon: '\uD83C\uDDFA\uD83C\uDDF8' },\n * { base: frLocale, isRoot: false, lang: 'fr-CA', icon: '\uD83C\uDDE8\uD83C\uDDE6' }\n * ].map(config =>\n * createVersionedLocale(config.base, config.isRoot, config.lang)\n * );\n * // Labels are minimal spaces, icons handle the display\n * ```\n *\n * @see LocaleInterface\n * @see structuredClone\n * @see generateLocaleLink\n *\n * @since 2.0.5\n */\n\nfunction createVersionedLocale(baseLocale: LocaleInterface, isRoot: boolean, lang: string): LocaleInterface {\n const locale = createSanitizedLocale(baseLocale);\n locale.label = ' ';\n locale.link = generateLocaleLink(isRoot, lang);\n\n return locale;\n}\n\n/**\n * Parses and configures locale settings for a multi-version, multi-language documentation site.\n *\n * @remarks\n * This function orchestrates the complete locale configuration process by combining\n * user-defined locale settings with version information to generate a comprehensive\n * locale map. It handles both root and non-root locales across multiple documentation\n * versions.\n *\n * The function operates on injected state from {@link StateModel} and processes:\n * - {@link versionsList}: Available documentation versions (e.g., ['v1', 'v2', 'v3'])\n * - {@link vitepressConfig}: VitePress configuration containing locale definitions\n * - {@link configuration}: User-provided locale configurations\n * - {@link localesMap}: Mapping between locale keys and indices\n *\n * Processing workflow:\n * 1. Injects application state to access configuration data\n * 2. Determines if 'root' key exists in user-provided locales\n * 3. Iterates through each locale in the locale map\n * 4. Creates sanitized base locale using {@link createSanitizedLocale} (removes nav/sidebar)\n * 5. Sets up the root locale entry with a generated link via {@link generateLocaleLink}\n * 6. Creates versioned locale entries for each version using {@link createVersionedLocale}\n *\n * Locale key structure:\n * - Root locale: Direct version keys (e.g., 'v1', 'v2')\n * - Non-root locales: Prefixed version keys (e.g., 'fr/v1', 'es/v2')\n *\n * The sanitization process removes navigation structures to reduce memory overhead\n * and prevent duplication of large theme configuration objects across versions.\n *\n * @example\n * ```ts\n * // Configuration state before parsing\n * const state = {\n * versionsList: ['v1', 'v2'],\n * localesMap: {\n * '/': 'root',\n * '/fr/': 'fr',\n * '/es/': 'es'\n * },\n * configuration: {\n * locales: {\n * root: {\n * lang: 'en-US',\n * label: 'English',\n * themeConfig: { nav: [...], sidebar: {...} }\n * },\n * fr: {\n * lang: 'fr-CA',\n * label: 'Fran\u00E7ais',\n * themeConfig: { nav: [...], sidebar: {...} }\n * }\n * }\n * }\n * };\n *\n * parseLocale();\n *\n * // Result in vitepressConfig.locales:\n * // {\n * // 'root': { lang: 'en-US', label: 'English', link: '/', ... },\n * // 'v1': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'v2': { lang: 'en-US', label: ' ', link: '/', ... },\n * // 'fr': { lang: 'fr-CA', label: 'Fran\u00E7ais', link: '/fr/', ... },\n * // 'fr/v1': { lang: 'fr-CA', label: ' ', link: '/fr/', ... },\n * // 'fr/v2': { lang: 'fr-CA', label: ' ', link: '/fr/', ... }\n * // }\n *\n * // Use case: Multi-version documentation with multiple languages\n * const state = inject(StateModel);\n * state.versionsList = ['latest', 'v3', 'v2'];\n * state.configuration.locales = {\n * '/': { lang: 'en-US', label: 'English' },\n * '/de/': { lang: 'de-DE', label: 'Deutsch' },\n * '/ja/': { lang: 'ja-JP', label: '\u65E5\u672C\u8A9E' }\n * };\n *\n * parseLocale();\n * // Generates 12 locale entries (3 versions \u00D7 3 languages + 3 base locales)\n * ```\n *\n * @see StateModel\n * @see generateLocaleLink\n * @see createSanitizedLocale\n * @see createVersionedLocale\n *\n * @since 2.0.5\n */\n\nexport function parseLocale(): void {\n const state = inject(StateModel);\n const { versionsList, vitepressConfig, configuration, localesMap } = state;\n const { locales } = vitepressConfig;\n const userLocales = configuration.locales;\n const hasRootInUserLocales = 'root' in userLocales;\n\n for (const [ key, index ] of Object.entries(localesMap)) {\n const isRoot = index === 'root';\n\n // Get source locale configuration\n const sourceLocale = hasRootInUserLocales\n ? userLocales[index]\n : userLocales[key];\n\n // Create a sanitized base locale (deep clone without nav/sidebar)\n const baseLocale = createSanitizedLocale(sourceLocale);\n const lang = baseLocale.lang ?? '';\n\n // Initialize and populate the root locale entry\n locales[index] = baseLocale;\n locales[index].link = generateLocaleLink(isRoot, lang);\n\n // Create versioned locale entries\n for (const version of versionsList) {\n const versionedKey = isRoot ? version : join(key, version);\n locales[versionedKey] = createVersionedLocale(baseLocale, isRoot, lang);\n }\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'fs';\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * The file system that the Vue SFC compiler reads imported types through.\n *\n * @remarks\n * `defineProps<PropsInterface>()` in the version switcher names a type from another file,\n * and the compiler has to read that file to turn the type into runtime props.\n * Without an `fs` option the compiler falls back to `ts.sys` of the `typescript` package,\n * which TypeScript 7 no longer ships and which is missing when TypeScript is not installed,\n * so the build fails with `No fs option provided to compileScript`.\n *\n * VitePress hands `vue.script` to `@vitejs/plugin-vue`, which passes it on to `compileScript`,\n * so this default gives the compiler Node's file system whatever TypeScript the site installs.\n * A site that sets its own `vue.script.fs` keeps it, since the user configuration is merged on top.\n *\n * @example\n * ```ts\n * scriptFileSystem.fileExists('/docs/.vitepress/theme/index.ts'); // true\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/42\n * @since 2.2.0\n */\n\nexport const scriptFileSystem = {\n fileExists: (file: string): boolean => existsSync(file),\n readFile: (file: string): string => readFileSync(file, 'utf8'),\n realpath: (file: string): string => realpathSync(file)\n};\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n * - A `vue.script.fs` that reads the file system through Node, see {@link scriptFileSystem}.\n * - A `vite.resolve.dedupe` of `vue` and `vitepress`, so the switcher component resolves both from the site\n * even when the package is linked from outside it, and shares the one Vue app and router the site runs.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n }\n },\n vue: {\n script: {\n fs: scriptFileSystem\n }\n },\n vite: {\n resolve: {\n dedupe: [ 'vue', 'vitepress' ]\n }\n }\n};\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { RouteResolverType } from '@interfaces/function.interface';\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { join as joinPath } from 'path';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\nimport { getAllMarkdownFilesRelative } from '@components/object.component';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // \u2192 \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version \u2192 extract it as `version`.\n * 2. If the first segment matches a locale \u2192 extract it as `lang`.\n * 3. Return both extracted values (empty strings if not found).\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` \u2192 `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` \u2192 `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` \u2192 `{ lang: 'fr', version: '' }`\n * - `/guide/` \u2192 `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Creates the resolver that maps a documentation source path to its published route.\n *\n * @returns A resolver that takes a source path and returns its rewritten route {@link RouteResolverType}\n *\n * @remarks\n * The resolver recognizes two prefixes and leaves every other path untouched.\n * A path under {@link StateModel.sources} belongs to the current version,\n * so it loses the prefix and keeps only its locale.\n * A path under {@link StateModel.archive} belongs to an archived version,\n * so {@link extractLocale} pulls the version and locale out of its leading segments.\n * Both cases hand the remaining source path to the `rewritesHook` of `versionsConfig`,\n * which decides the final segment order.\n *\n * The resolver reads the locale and version lists once and closes over them,\n * so it stays correct for every call without rescanning the state.\n *\n * @example\n * ```ts\n * const resolve = createRouteResolver();\n * resolve('src/guide/index.md'); // 'guide/index.md'\n * resolve('archive/v1.0.x/guide/index.md'); // 'v1.0.x/guide/index.md'\n * resolve('public/logo.png'); // 'public/logo.png'\n * ```\n *\n * @see extractLocale\n * @see parseRoutesComponent\n *\n * @since 2.1.0\n */\n\nexport function createRouteResolver(): RouteResolverType {\n const state = inject(StateModel);\n const localesList = Object.keys(state.localesMap);\n const versionsList = state.versionsList;\n const sourcesPrefix = `${ state.sources }/`;\n const archivePrefix = `${ state.archive }/`;\n\n return function (id: string): string {\n // Handle sources files\n if (id.startsWith(sourcesPrefix)) {\n const path = id.slice(sourcesPrefix.length);\n const localeKey = localesList.find(prefix => path.startsWith(prefix + '/'));\n\n if (localeKey) {\n const locale = state.localesMap[localeKey] === 'root' ? '' : localeKey;\n const filePath = path.slice(localeKey.length + 1);\n\n return state.versionsConfig.hooks.rewritesHook(filePath, '', locale);\n }\n\n return path;\n }\n\n // Handle archive files\n if (id.startsWith(archivePrefix)) {\n const path = id.slice(archivePrefix.length);\n const segments = path.split('/');\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n const source = segments.join('/');\n\n return state.versionsConfig.hooks.rewritesHook(\n source, version, state.localesMap[lang] === 'root' ? '' : lang\n );\n }\n\n return id;\n };\n}\n\n/**\n * Collects the routes that every version publishes, keyed by version label.\n *\n * @param resolve - The resolver that turns a source path into its published route\n * @returns A record mapping each version label to the routes that version publishes\n *\n * @remarks\n * The current version is read from {@link StateModel.sourcesPath} and keyed by `versionsConfig.current`,\n * and each archived version is read from its own folder under {@link StateModel.archivePath}.\n * Every file runs through the same resolver that builds `vitepressConfig.rewrites`,\n * so a route in this record always matches the URL VitePress serves.\n *\n * The version switcher uses this record to tell whether the page a reader is on also exists\n * in the version they picked, and falls back to that version's home page when it does not.\n *\n * @example\n * ```ts\n * parseVersionRoutes(createRouteResolver());\n * // {\n * // 'v2.0.x': [ 'index.md', 'release.md', 'guide/index.md' ],\n * // 'v1.0.x': [ 'v1.0.x/index.md', 'v1.0.x/release.md' ]\n * // }\n * ```\n *\n * @see createRouteResolver\n * @see getAllMarkdownFilesRelative\n *\n * @since 2.1.0\n */\n\nexport function parseVersionRoutes(resolve: RouteResolverType): Record<string, Array<string>> {\n const state = inject(StateModel);\n const routes: Record<string, Array<string>> = {};\n\n routes[state.versionsConfig.current] = getAllMarkdownFilesRelative(state.sourcesPath)\n .map(file => resolve(join(state.sources, file)));\n\n for (const version of state.versionsList) {\n routes[version] = getAllMarkdownFilesRelative(joinPath(state.archivePath, version))\n .map(file => resolve(join(state.archive, version, file)));\n }\n\n return routes;\n}\n\n/**\n * Wires route rewriting into the VitePress configuration and records the routes of every version.\n *\n * @remarks\n * Assigns `vitepressConfig.rewrites` the resolver from {@link createRouteResolver},\n * which VitePress calls once per source file while it builds the site.\n * Fills {@link StateModel.routesMap} with the output of {@link parseVersionRoutes},\n * so the version switcher can check a route before it links to it.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * state.vitepressConfig.rewrites('archive/v1.0.x/guide/index.md'); // 'v1.0.x/guide/index.md'\n * state.routesMap['v1.0.x']; // [ 'v1.0.x/guide/index.md', ... ]\n * ```\n *\n * @see createRouteResolver\n * @see parseVersionRoutes\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const state = inject(StateModel);\n const resolve = createRouteResolver();\n\n state.vitepressConfig.rewrites = resolve;\n Object.assign(state.routesMap, parseVersionRoutes(resolve));\n}\n", "/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val2) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { forceInject } from '@remotex-labs/xinject';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebars } from '@components/sidebar.component';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\nimport { parseCurrentVersionRedirect } from '@components/redirect.component';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseRoutesComponent();\n parseNavs();\n parseSidebars();\n parseCurrentVersionRedirect();\n\n return <UserConfig> state.vitepressConfig;\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link && typeof item.link === 'string' && !item.link.includes('http');\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // \u2192 { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // \u2192 { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning) {\n return {\n ...item,\n link: typeof item.link === 'string' ? join('/', version, item.link) : item.link\n };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // \u2192 [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string): Array<NavItemType> {\n const state = inject(StateModel);\n if (version === 'root') version = '';\n\n return items.map(item => {\n if ('component' in item && item.component) {\n return {\n ...item,\n props: {\n ...item.props,\n versioningPlugin: {\n routes: state.routesMap,\n versions: state.versionsList,\n currentVersion: state.versionsConfig.current\n }\n }\n };\n }\n\n return replaceLinksRecursive(version, item);\n });\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results \u2192 {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` \u2014 global navigation configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale\u2019s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.versionsConfig.current);\n if(switcher) globalResults.root.push(switcher);\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = locale === 'root' || state.localesMap[locale] === 'root' ? 'root' : locale;\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Retrieves the appropriate navigation configuration for a given locale key.\n *\n * @param navs - The navigation configurations mapped by locale keys.\n * @param key - The locale key to retrieve navigation for (e.g., 'root', 'fr', 'fr/v1.0.0').\n * @returns The navigation configuration for the locale, falling back to parent locale or root.\n *\n * @remarks\n * This function implements a fallback strategy for finding navigation configurations:\n * 1. If an exact match exists for the key, return it\n * 2. If the key contains '/' (versioned locale), extract the base locale and try that\n * 3. If no base locale exists, fall back to 'root'\n *\n * This allows versioned locales (e.g., 'fr/v1.0.0', 'de/v2.0') to inherit navigation\n * from their base locale ('fr', 'de') without duplicating configuration.\n *\n * Fallback hierarchy examples:\n * - `'fr'` \u2192 Direct match, returns `navs.fr`\n * - `'fr/v1.0.0'` \u2192 No direct match \u2192 Checks `'fr'` \u2192 Returns `navs.fr`\n * - `'es/v1.0.0'` \u2192 No direct match \u2192 Checks `'es'` (doesn't exist) \u2192 Returns `navs.root`\n * - `'root'` \u2192 Direct match, returns `navs.root`\n *\n * @example\n * ```ts\n * const navs = {\n * root: [{ text: 'Home', link: '/' }],\n * fr: [{ text: 'Accueil', link: '/fr/' }],\n * de: [{ text: 'Startseite', link: '/de/' }]\n * };\n *\n * // Exact match\n * getNavForLocale(navs, 'fr'); // Returns fr nav\n *\n * // Versioned locale - inherits from base\n * getNavForLocale(navs, 'fr/v1.0.0'); // Returns fr nav\n * getNavForLocale(navs, 'de/v2.0'); // Returns de nav\n *\n * // No base locale exists - falls back to root\n * getNavForLocale(navs, 'es/v1.0.0'); // Returns root nav\n *\n * // Root locale\n * getNavForLocale(navs, 'root'); // Returns root nav\n * ```\n *\n * @see {@link parseNavs} - Uses this function to populate navigation for all locales\n * @see {@link NavItemType} - The navigation item type structure\n *\n * @since 2.0.5\n */\n\nexport function getNavForLocale(navs: Record<string, Array<NavItemType>>, key: string): Array<NavItemType> {\n if (navs[key]) return navs[key];\n\n // If the key contains '/', try to get the base locale\n if (key.includes('/')) {\n const baseLocale = key.split('/')[0];\n\n if (navs[baseLocale]) {\n return navs[baseLocale];\n }\n }\n\n // Fall back to root\n return navs.root;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * This function ensures that all locales have a fully initialized and version-aware navigation structure.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const nav = getNavForLocale(navs, key);\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(nav, key);\n }\n}\n", "/**\n * Imports\n */\n\nimport type { NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object.\n * @param versions - An array of available version strings.\n * @param current - The current version label, defaults to `\"Latest\"`.\n *\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration.\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions`.\n * - If `includeCurrentVersion` is enabled, adds a link to the root (`\"/\"`)\n * for the currently active version, displayed as `\"Latest\"` or\n * `\"vX.Y.Z (latest)\"`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * This utility allows users to quickly switch between documentation versions\n * from the navigation bar.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\");\n *\n * // \u2192 {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/v2.0.0/\", text: \"v2.0.0\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function versionSwitcher(themeConfig: VersionsConfigInterface, versions: Array<string>, current: string = 'Latest'): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const items = [];\n if (includeCurrentVersion) {\n items.push({\n link: '/',\n text: current === 'Latest' ? current : `${ current } (latest)`,\n skipVersioning: true\n });\n }\n\n for (const version of versions) {\n items.push({ text: version, link: `/${ version }/`, skipVersioning: true });\n }\n\n return { text, items };\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { SidebarItemType } from '@viteplus/versions';\nimport type { SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Safely joins path segments, preventing empty or dot-only results.\n *\n * @param args - Variable number of path segments to join.\n * @returns A joined path string, or empty string if the result would be '.' or empty.\n *\n * @remarks\n * This function is a wrapper around Node.js's {@link join} from path/posix that addresses\n * a common edge case: when all input segments are empty or falsy, {@link join} returns\n * a single dot (`'.'`) representing the current directory. This function prevents that\n * behavior by returning an empty string instead.\n *\n * **Processing steps**:\n * 1. Filters out falsy values (empty strings, null, undefined, 0, false) using {@link Boolean}\n * 2. Joins remaining segments using {@link join}\n * 3. Returns empty string if result is `'.'`, otherwise returns the joined path\n *\n * **Use cases**:\n * - Building URL paths where empty segments should result in empty strings\n * - Constructing locale-aware paths with optional prefixes\n * - Generating version-specific routes where components may be absent\n * - Avoiding visual artifacts from dot paths in UI components\n *\n * The function is particularly useful in multi-version, multi-locale systems where\n * path components (locale, version, base path) may be conditionally empty, and you\n * need consistent empty-string results rather than dot notation.\n *\n * @example\n * ```ts\n * // Normal path joining\n * const path1 = safeJoin('docs', 'guide', 'intro');\n * console.log(path1); // 'docs/guide/intro'\n *\n * // With empty segments (filtered out)\n * const path2 = safeJoin('', 'docs', '', 'guide');\n * console.log(path2); // 'docs/guide'\n *\n * // All empty segments (returns empty string, not '.')\n * const path3 = safeJoin('', '', '');\n * console.log(path3); // '' (not '.')\n *\n * // Single segment\n * const path4 = safeJoin('docs');\n * console.log(path4); // 'docs'\n *\n * // Use case: Building versioned paths\n * const locale = ''; // Root locale (empty)\n * const version = ''; // Current version (empty)\n * const base = 'guide';\n *\n * const path = safeJoin(locale, version, base);\n * console.log(path); // 'guide' (not './guide' or '.')\n *\n * // Use case: Optional prefix paths\n * function buildPath(prefix: string, ...segments: string[]): string {\n * return '/' + safeJoin(prefix, ...segments);\n * }\n *\n * console.log(buildPath('', 'api', 'users')); // '/api/users'\n * console.log(buildPath('v2', 'api', 'users')); // '/v2/api/users'\n * console.log(buildPath('', '', '')); // '/' (not '/.')\n * ```\n *\n * @see join\n * @see Boolean\n *\n * @since 2.0.5\n */\n\nfunction safeJoin(...args: Array<string>): string {\n const joined = join(...args.filter(Boolean));\n\n return joined === '.' ? '' : joined;\n}\n\n/**\n * Populates sidebar items with version-specific base paths.\n *\n * @param sidebar - Array of sidebar items to process {@link SidebarItemType}.\n * @param version - The version string to apply to base paths, or 'root' for the default version.\n * @returns A new array of sidebar items with updated base paths.\n *\n * @remarks\n * This function transforms sidebar items by adding version-specific base paths to enable\n * multi-version documentation navigation. It processes each sidebar item according to\n * specific rules:\n *\n * **Skipped items** (returned unchanged):\n * - Items with `skipVersioning: true` flag\n * - Items with external links (starting with 'http')\n * - Items without links or nested items\n * - Items when a version is empty or 'root'\n *\n * **Processed items**:\n * - The base path is prepended with a version: `/{version}/{base}/`\n * - Original item properties are preserved via spread operator\n * - The normalized version replaces 'root' with empty string\n *\n * The base path structure follows the pattern: `/{version}/{originalBase}/`\n * using {@link join} from path/posix for consistent URL formatting across platforms.\n *\n * @example\n * ```ts\n * const sidebar: Array<SidebarItemType> = [\n * { text: 'Guide', link: '/guide/', base: '/docs' },\n * { text: 'API', link: '/api/', base: '/reference' },\n * { text: 'External', link: 'https://example.com' },\n * { text: 'Skip', link: '/skip/', skipVersioning: true }\n * ];\n *\n * const versioned = populateSidebar(sidebar, 'v2.0');\n * // [\n * // { text: 'Guide', link: '/guide/', base: '/v2.0/docs/' },\n * // { text: 'API', link: '/api/', base: '/v2.0/reference/' },\n * // { text: 'External', link: 'https://example.com' },\n * // { text: 'Skip', link: '/skip/', skipVersioning: true }\n * // ]\n *\n * // Root version (no prefix)\n * const rootVersioned = populateSidebar(sidebar, 'root');\n * // Base paths remain unchanged\n *\n * // Use case: Version-specific sidebar configuration\n * const versions = ['v1.0', 'v2.0', 'latest'];\n * const sidebarConfigs = versions.map(version => ({\n * version,\n * items: populateSidebar(baseSidebar, version)\n * }));\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.5\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n const normalizedVersion = version === 'root' ? '' : version;\n\n return sidebar.map(item => {\n if (item.skipVersioning || item?.link?.startsWith('http')) return item;\n if (!(item.link || item.items) || !normalizedVersion) return item;\n\n return {\n ...item,\n base: safeJoin('/', normalizedVersion, item.base ?? '', '/')\n };\n });\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version \u2192 return `{ lang: '', version }` (version-first pattern)\n * 2. If the first segment matches a locale \u2192 extract it as `lang` (locale-first pattern)\n * 3. If the second segment matches a version \u2192 extract it as `version`\n * 4. Return both extracted values (empty strings if not found)\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` \u2192 `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` \u2192 `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` \u2192 `{ lang: 'fr', version: '' }`\n * - `/guide/` \u2192 `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n if (localesList.length === 0) localesList = [ 'root' ];\n if (versionsList.includes(segments[0])) {\n return { lang: '', version: segments.shift()! };\n }\n\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Normalizes sidebar configuration into a structured format for multi-version documentation.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @param results - Accumulator object to store normalized sidebar entries {@link SidebarObjectType}.\n * @param sidebar - The sidebar configuration to normalize {@link SidebarType}.\n * @param prefix - Locale prefix for the sidebar (e.g., 'root', 'fr', 'de').\n *\n * @remarks\n * This function transforms sidebar configurations from various input formats into a\n * normalized structure that supports multi-version, multi-locale documentation. It\n * handles both array-based and object-based sidebar definitions.\n *\n * **Input formats supported**:\n * - **Array format**: Simple list of sidebar items for a single path\n * - **Object format**: Key-value pairs where keys are paths and values are sidebar items\n * - **Undefined**: Gracefully handles missing sidebar configuration\n *\n * **Normalization process**:\n * 1. Early return if the sidebar is undefined\n * 2. Convert the 'root' prefix to an empty string for URL normalization\n * 3. For array format: Store items under the normalized path\n * 4. For object format: Parse each key to extract locale/version using {@link extractLocale}\n * 5. Filter entries that don't match the current locale prefix\n * 6. Construct versioned paths and store items in the result accumulator\n *\n * **Results structure**:\n * ```ts\n * {\n * 'root': { '/': [...items], '/guide/': [...items] },\n * 'fr': { '/fr/': [...items], '/fr/guide/': [...items] },\n * 'fr/v2.0': { '/fr/v2.0/': [...items] }\n * }\n * ```\n *\n * The function uses state data to access:\n * - {@link StateModel.localesMap} for valid locale identifiers\n * - {@link StateModel.versionsList} for valid version identifiers\n *\n * @example\n * ```ts\n * const state = new StateModel(config).init();\n * const results: Record<string, SidebarObjectType> = {};\n *\n * // Array format sidebar\n * const arraySidebar = [\n * { text: 'Guide', link: '/guide/' },\n * { text: 'API', link: '/api/' }\n * ];\n * normalizeSidebar(state, results, arraySidebar, 'root');\n * // results = { 'root': { '/': [{ text: 'Guide', ... }, { text: 'API', ... }] } }\n *\n * // Object format sidebar\n * const objectSidebar = {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }],\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * };\n * normalizeSidebar(state, results, objectSidebar, 'root');\n *\n * // With locale prefix\n * normalizeSidebar(state, results, objectSidebar, 'fr');\n * // Only '/fr/guide/' entries are processed\n *\n * // Use case: Multi-locale sidebar processing\n * const results = {};\n * const locales = ['root', 'fr', 'de'];\n * for (const locale of locales) {\n * const sidebar = getLocaleSidebar(locale);\n * normalizeSidebar(state, results, sidebar, locale);\n * }\n * ```\n *\n * @see StateModel\n * @see SidebarType\n * @see extractLocale\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebar(state: StateModel, results: Record<string, SidebarObjectType>, sidebar?: SidebarType, prefix: string = ''): void {\n if (!sidebar) return;\n const normalizedPrefix = prefix === 'root' ? '' : prefix;\n\n if (Array.isArray(sidebar)) {\n const index = normalizedPrefix ? normalizedPrefix : '/';\n results[prefix] ??= {};\n results[prefix][index] ??= [];\n results[prefix][index].push(...sidebar);\n\n return;\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const segments = key.split('/').filter(Boolean);\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n\n if (lang && !prefix.startsWith(lang)) continue;\n\n const parent = version ? safeJoin(normalizedPrefix, version) : normalizedPrefix;\n const index = safeJoin(parent, ...segments) || '/';\n const parentIndex = parent || 'root';\n\n results[parentIndex] ??= {};\n results[parentIndex][index] ??= [];\n\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[parentIndex][index].push(...itemsArray);\n }\n}\n\n\n/**\n * Normalizes all sidebar configurations across locales and versions.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @returns A normalized sidebar structure organized by locale and path {@link SidebarObjectType}.\n *\n * @remarks\n * This function orchestrates the complete normalization of all sidebar configurations\n * in a multi-version, multi-locale documentation site. It processes sidebars from both\n * global theme configuration and locale-specific settings, then propagates them to all\n * versioned locale entries.\n *\n * **Processing stages**:\n * 1. **Initial Normalization**: Process sidebars from global theme config and each locale's\n * theme config using {@link normalizeSidebar}\n * 2. **Version Propagation**: For each locale entry in {@link StateModel.vitepressConfig},\n * if it lacks a normalized sidebar, inherit from its parent locale\n * 3. **Path Adjustment**: Adjust inherited paths to include the version/locale prefix\n *\n * **Data sources processed**:\n * - {@link StateModel.configuration.themeConfig.sidebar}: Global sidebar configuration\n * - Each locale's `themeConfig.sidebar`: Locale-specific sidebar configuration\n *\n * **Output structure**:\n * ```ts\n * {\n * 'root': { '/': [...], '/guide/': [...] },\n * 'v2.0': { '/v2.0/': [...], '/v2.0/guide/': [...] },\n * 'fr': { '/fr/': [...], '/fr/guide/': [...] },\n * 'fr/v2.0': { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n * }\n * ```\n *\n * The function ensures that every locale entry in the VitePress configuration has\n * appropriate sidebar items, either directly defined or inherited from parent locales.\n * This enables consistent navigation across all versions and locales.\n *\n * @example\n * ```ts\n * const state = new StateModel({\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Guide', link: '/guide/' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US' },\n * '/fr/': {\n * lang: 'fr-FR',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Guide', link: '/fr/guide/' }]\n * }\n * }\n * }\n * },\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * }\n * }).init();\n *\n * const normalized = normalizeSidebars(state);\n *\n * console.log(Object.keys(normalized));\n * // ['root', 'v1.0', 'v2.0', 'fr', 'fr/v1.0', 'fr/v2.0']\n *\n * console.log(normalized['v2.0']);\n * // { '/v2.0/': [...], '/v2.0/guide/': [...] }\n *\n * console.log(normalized['fr/v2.0']);\n * // { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n *\n * // Use case: Building a complete sidebar structure\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n *\n * // Apply to VitePress config\n * for (const [locale, paths] of Object.entries(sidebars)) {\n * vitepressConfig.locales[locale].themeConfig.sidebar = paths;\n * }\n * ```\n *\n * @see StateModel\n * @see extractLocale\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebars(state: StateModel): Record<string, SidebarObjectType> {\n const { vitepressConfig, configuration: { locales, themeConfig } } = state;\n const normalizedSidebar: Record<string, SidebarObjectType> = {};\n\n if (Object.keys(locales).length > 0) {\n for (const [ localeKey, locale ] of Object.entries(locales)) {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, localeKey);\n normalizeSidebar(state, normalizedSidebar, locale.themeConfig?.sidebar as SidebarObjectType, localeKey);\n }\n } else {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, 'root');\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n for (const index of Object.keys(vitepressConfig.locales)) {\n if (normalizedSidebar[index]) continue;\n\n const { lang } = extractLocale(index.split('/'), localesList, versionsList);\n const parent = normalizedSidebar[lang || 'root'];\n if (!parent) continue;\n\n normalizedSidebar[index] = {};\n for (const [ key, items ] of Object.entries(parent)) {\n const segments = key.split('/').filter(Boolean);\n extractLocale(segments, localesList, versionsList);\n normalizedSidebar[index][safeJoin(index, ...segments)] = [ ...items ];\n }\n }\n\n return normalizedSidebar;\n}\n\n/**\n * Parses and applies sidebar configurations to all locales in the VitePress configuration.\n *\n * @remarks\n * This function is the main entry point for sidebar processing in a multi-version,\n * multi-locale documentation system. It coordinates the complete sidebar normalization\n * and population workflow by:\n *\n * 1. **Injecting State**: Retrieves the {@link StateModel} singleton instance\n * 2. **Normalizing**: Calls {@link normalizeSidebars} to process all sidebar configurations\n * 3. **Applying**: Iterates through each locale in {@link StateModel.vitepressConfig.locales}\n * 4. **Populating**: Uses {@link populateSidebar} to add version-specific base paths\n * 5. **Merging**: Assigns processed sidebars to each locale's theme configuration\n *\n * **Sidebar structure handling**:\n * - Initializes `themeConfig` if it doesn't exist\n * - Converts array-based sidebars to object format for consistent processing\n * - Preserves existing sidebar structure when no normalized version exists\n * - Ensures sidebar is always in object format after processing\n *\n * The function modifies the VitePress configuration in place, updating each locale's\n * `themeConfig.sidebar` with the normalized and versioned sidebar items. This ensures\n * that all routes have appropriate navigation structures.\n *\n * **Processing flow**:\n * ```\n * User Config \u2192 normalizeSidebars() \u2192 Normalized Structure\n * \u2193\n * VitePress Config \u2190 populateSidebar() \u2190 Per-Locale Items\n * ```\n *\n * @example\n * ```ts\n * // Setup configuration\n * const config = {\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/fr/': {\n * lang: 'fr-FR',\n * label: 'Fran\u00E7ais',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * }\n * }\n * }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n * provide(StateModel, state);\n *\n * // Parse and apply sidebars\n * parseSidebars();\n *\n * // Result: Each locale now has versioned sidebars\n * console.log(state.vitepressConfig.locales['v2.0'].themeConfig.sidebar);\n * // {\n * // '/v2.0/': [{ text: 'Home', link: '/', base: '/v2.0/' }],\n * // '/v2.0/guide/': [{ text: 'Getting Started', link: '/guide/start', base: '/v2.0/guide/' }]\n * // }\n *\n * console.log(state.vitepressConfig.locales['fr/v2.0'].themeConfig.sidebar);\n * // {\n * // '/fr/v2.0/guide/': [{ text: 'Commencer', link: '/fr/guide/start', base: '/fr/v2.0/guide/' }]\n * // }\n *\n * // Use case: Integration in VitePress config hook\n * export default defineConfig({\n * async buildStart() {\n * parseSidebars();\n * },\n * // ... rest of config\n * });\n * ```\n *\n * @see StateModel\n * @see populateSidebar\n * @see normalizeSidebars\n *\n * @since 2.0.5\n */\n\nexport function parseSidebars(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n const sidebars = normalizeSidebars(state);\n for (const [ key, locale ] of Object.entries(locales)) {\n if (!sidebars[key]) continue;\n\n locale.themeConfig ??= {};\n if (!locale.themeConfig.sidebar || Array.isArray(locale.themeConfig.sidebar)) {\n locale.themeConfig.sidebar = {};\n }\n\n for (const [ index, items ] of Object.entries(sidebars[key])) {\n const { lang, version } = extractLocale(index.split('/'), localesList, versionsList);\n (locale.themeConfig.sidebar as SidebarObjectType)[index] = populateSidebar(\n items, safeJoin(lang, version)\n );\n }\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { HeadConfig } from 'vitepress';\n\n/**\n * Imports\n */\n\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Builds the pattern that matches a path naming the current version.\n *\n * @param base - The base path of the site, with a leading and a trailing slash\n * @param current - The label of the version that the site serves at its root\n * @param locales - The URL prefixes of the non-root locales, without their slashes\n * @returns A pattern whose first group is the part of the path to keep in front of the version\n *\n * @remarks\n * The version segment is matched right after the base, or after a locale when one leads the path,\n * which is where the default `rewritesHook` puts it.\n * Replacing a match with `$1` gives the unversioned path.\n *\n * Every `/` is escaped, so the pattern can sit in a `<script>` tag without closing it.\n *\n * @example\n * ```ts\n * const pattern = currentVersionPattern('/docs/', 'v2.0.x', [ 'de' ]);\n * '/docs/de/v2.0.x/guide/'.replace(pattern, '$1'); // '/docs/de/guide/'\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/43\n * @since 2.2.0\n */\n\nexport function currentVersionPattern(base: string, current: string, locales: Array<string>): RegExp {\n const escape = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\/]/g, '\\\\$&');\n const locale = locales.length ? `(?:(?:${ locales.map(escape).join('|') })\\\\/)?` : '';\n\n return new RegExp(`^(${ escape(base) }${ locale })${ escape(current) }(?:\\\\/|$)`);\n}\n\n/**\n * Adds the current version redirect to the head of every page.\n *\n * @remarks\n * The site serves the current version at its root, so `/v2.0.x/guide/` names no page.\n * A one-line script replaces the location with `/guide/`, keeping the query string and the hash,\n * and does nothing on any other path.\n * A built site renders it into every page, so it runs on the `404.html` that the host answers with,\n * and the dev server adds it in the browser, so it runs there too.\n * Once `v2.0.x` is archived, the archive serves the path itself and the script no longer matches it.\n *\n * Nothing is added when an archived version carries the same label as the current one,\n * since every path under that label is then a real archived page.\n * The `head` entries of the user configuration come first and are kept.\n *\n * @example\n * ```ts\n * parseCurrentVersionRedirect();\n * state.vitepressConfig.head; // [ ...userHead, [ 'script', {}, 'var p=location.pathname.replace(...' ] ]\n * ```\n *\n * @see currentVersionPattern\n * @since 2.2.0\n */\n\nexport function parseCurrentVersionRedirect(): void {\n const state = inject(StateModel);\n const { current } = state.versionsConfig;\n if (!current || state.versionsList.includes(current)) return;\n\n const base = `/${ state.vitepressConfig.base ?? '' }/`.replace(/\\/+/g, '/');\n const locales = Object.entries(state.localesMap)\n .filter(([ , key ]) => key !== 'root')\n .map(([ prefix ]) => prefix.replace(/^\\/+|\\/+$/g, ''));\n\n const pattern = currentVersionPattern(base, current, locales);\n const script: HeadConfig = [\n 'script', {},\n `var p=location.pathname.replace(${ pattern },'$1');` +\n 'p!==location.pathname&&location.replace(p+location.search+location.hash)'\n ];\n\n state.vitepressConfig.head = [ ...state.vitepressConfig.head ?? [], script ];\n}\n"],
|
|
6
|
-
"mappings": "2PAYA,OAAS,QAAAA,EAAM,SAAAC,OAAa,OAC5B,OAAS,cAAAC,OAAkB,wBAC3B,OAAS,SAAAC,OAAa,sCCJtB,OAAS,QAAAC,MAAY,aACrB,OAAS,UAAAC,MAAc,wBA4DhB,SAASC,EAAgBC,EAAwB,CACpD,OAAOA,EAAO,MAAM,MAAM,EAAE,CAAC,CACjC,CAFgBC,EAAAF,EAAA,mBA+EhB,SAASG,EAAsBC,EAAgD,CAC3E,IAAMC,EAAS,OAAO,OAAO,CAAC,EAAGD,CAAY,EAE7C,OAAIC,EAAO,aAAe,OAAO,KAAKA,EAAO,WAAW,EAAE,OAAS,IAC/DA,EAAO,YAAc,OAAO,OAAO,CAAC,EAAGA,E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WAAW,CACpF,CALgBG,EAAAL,GAAA,yBAgCT,SAASQ,GAAoC,CAChD,IAAMC,EAAQC,GAAOC,CAAU,EACzB,CAAE,QAAAT,CAAQ,EAAIO,EAAM,eAC1B,GAAI,CAACP,GAAWO,EAAM,aAAa,SAASP,CAAO,EAAG,OAEtD,IAAMD,EAAO,IAAKQ,EAAM,gBAAgB,MAAQ,EAAG,IAAI,QAAQ,OAAQ,GAAG,EACpEN,EAAU,OAAO,QAAQM,EAAM,UAAU,EAC1C,OAAO,CAAC,CAAE,CAAEG,CAAI,IAAMA,IAAQ,MAAM,EACpC,IAAI,CAAC,CAAEC,CAAO,IAAMA,EAAO,QAAQ,aAAc,EAAE,CAAC,EAEnDC,EAAUd,GAAsBC,EAAMC,EAASC,CAAO,EACtDY,EAAqB,CACvB,SAAU,CAAC,EACX,mCAAoCD,CAAQ,iFAEhD,EAEAL,EAAM,gBAAgB,KAAO,CAAE,GAAGA,EAAM,gBAAgB,MAAQ,CAAC,EAAGM,CAAO,CAC/E,CAlBgBV,EAAAG,EAAA,+BJtCT,SAASQ,GAAsBC,EAAyD,CAC3F,IAAMC,EAASC,EAAUC,EAAsBH,CAAiB,EAC1DI,EAAQC,GAAYC,EAAYL,CAAM,EAAE,KAAK,EACnD,OAAAM,EAAY,EAMZC,EAAqB,EACrBC,EAAU,EACVC,EAAc,EACdC,EAA4B,EAERP,EAAM,eAC9B,CAfgBQ,EAAAb,GAAA",
|
|
7
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/models/state.model.ts", "../src/components/locale.component.ts", "../src/constants/configuration.constant.ts", "../src/components/rewrites.component.ts", "../src/components/object.component.ts", "../src/index.ts", "../src/components/nav.component.ts", "../src/components/switcher.component.ts", "../src/components/sidebar.component.ts", "../src/components/latest.component.ts", "../src/components/links.component.ts"],
|
|
4
|
+
"sourceRoot": "https://github.com/viteplus/versions/tree/v3.1.0/",
|
|
5
|
+
"sourcesContent": ["/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\nimport type { VersionsConfigInterface, VitepressConfigInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { Injectable } from '@remotex-labs/xinject';\nimport { xterm } from '@remotex-labs/xansi/xterm.component';\nimport { getLanguageOnly } from '@components/locale.component';\nimport { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';\nimport { isAbsolute, join, posix, relative, resolve, sep } from 'path';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Manages the state of a versioned VitePress documentation project.\n *\n * @remarks\n * The `StateModel` class is responsible for:\n * - Managing source and archive directories for versioned documentation.\n * - Initializing the VitePress configuration (`VitepressConfigInterface`) from\n * a provided {@link ConfigurationInterface}.\n * - Maintaining a list of documentation versions and the routes each version publishes.\n * - Ensuring the necessary directories exist and are initialized.\n *\n * This service is designed as a singleton, making it safe to inject across\n * your application using `@Injectable({ scope: 'singleton' })`.\n *\n * @example\n * ```ts\n * import { StateModel } from \"@models/state.model\";\n *\n * const state = new StateModel(config).init();\n * console.log(state.versionsList);\n * ```\n *\n * @since 2.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class StateModel {\n /**\n * The root path of the documentation project,\n * based on the current working directory and optional srcDir.\n *\n * @since 2.0.0\n */\n\n readonly root: string;\n\n /**\n * The name of the sources directory from which current content.\n *\n * @default `src`\n * @since 2.0.0\n */\n\n readonly sources: string;\n\n /**\n * The name of the archive directory where old versions are stored.\n *\n * @default `archive`\n * @since 2.0.0\n */\n\n readonly archive: string;\n\n /**\n * Full path to the `sources` directory.\n *\n * @since 2.0.0\n */\n\n readonly sourcesPath: string;\n\n /**\n * Full path to the `archive` directory.\n *\n * @since 2.0.0\n */\n\n readonly archivePath: string;\n\n /**\n * The `versions` configuration object for the plugin.\n *\n * @remarks\n * This property holds the currently active versions configuration\n * as defined in {@link VersionsConfigInterface}. It includes settings\n * like the current version, sources, archive, hooks, and version switcher.\n *\n * @see VersionsConfigInterface\n * @since 2.0.0\n */\n\n readonly versionsConfig: VersionsConfigInterface;\n\n /**\n * The VitePress configuration object crafted from the user-provided configuration,\n * with versioning support added.\n *\n * @remarks\n * This object is based on the user configuration and extended to include\n * locales, rewrites, and versioning-aware settings. It is typed as\n * {@link VitepressConfigInterface}.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n readonly vitepressConfig: VitepressConfigInterface;\n\n /**\n * The names of every published version.\n *\n * @remarks\n * These are the names of {@link versionDirs} in the order that `init()` adds them:\n * the current version first, then every folder under {@link archivePath}\n * and every version that `versionsConfig.versions` gives its own `path`, newest first.\n * Numbers in a name compare by value, so `v2.10.x` comes before `v2.9.x`.\n *\n * @example\n * ```ts\n * state.versionsList; // [ 'next', 'v2.x', 'v1.x' ]\n * ```\n *\n * @since 2.0.0\n */\n\n get versionsList(): Array<string> {\n return Object.keys(this.versionDirs);\n }\n\n /**\n * Maps each version name to its folder, relative to {@link root} and in POSIX form.\n *\n * @remarks\n * The rewrites read every page of a version from this folder and publish it under the version name.\n *\n * @example\n * ```ts\n * state.versionDirs; // { next: 'src', 'v2.x': 'archive/v2.x', 'v0.x': 'legacy/v0' }\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\n readonly versionDirs: Record<string, string> = {};\n\n /**\n * The name of the stable version.\n *\n * @remarks\n * It is `versionsConfig.latest`, or `versionsConfig.current` when that is empty.\n * Its pages are served under its name like every version, its home page is also published at the root,\n * and an address that names no version moves to it. The switchers tag this version as the latest one.\n *\n * @example\n * ```ts\n * state.latest; // 'v2.x'\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\n latest: string = '';\n\n /**\n * Maps each version name to the text that the switchers show for it.\n *\n * @remarks\n * The text is the `label` of `versionsConfig.versions`, falling back to the version name.\n *\n * @example\n * ```ts\n * state.labels; // { 'v2.x': 'v2.x', 'v1.x': 'v1.x (LTS)' }\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\n readonly labels: Record<string, string> = {};\n\n /**\n * Maps the URL prefix of each locale to its key in the user configuration.\n *\n * @remarks\n * - Keys are the URL prefixes: the `link` of the locale without its slashes,\n * or else the language of its `lang` (or of its key), such as `de` for `de-DE`.\n * A source folder with that name holds the pages of the locale.\n * - Values are the keys of `configuration.locales`, and `\"root\"` for the root locale.\n *\n * @example\n * ```ts\n * localesMap = {\n * en: \"root\",\n * de: \"de\"\n * };\n * ```\n *\n * @since 2.0.0\n */\n\n readonly localesMap: Record<string, string> = {};\n\n /**\n * Maps each key of `configuration.locales` to the URL prefix of that locale.\n *\n * @remarks\n * The prefix of the root locale is an empty string, since its pages carry no locale segment.\n * Every other prefix is the key of that locale in {@link localesMap}.\n *\n * @example\n * ```ts\n * localePrefixes = { root: '', de: 'de', '/fr/': 'fr' };\n * ```\n *\n * @since 3.0.0\n */\n\n readonly localePrefixes: Record<string, string> = {};\n\n /**\n * The URL prefixes of every locale other than the root one.\n *\n * @example\n * ```ts\n * state.localeSegments; // [ 'de', 'fr' ]\n * ```\n *\n * @see localePrefixes\n * @since 3.0.0\n */\n\n get localeSegments(): Array<string> {\n return Object.values(this.localePrefixes).filter(Boolean);\n }\n\n /**\n * Maps each version label to the routes that version publishes.\n *\n * @remarks\n * Keys are the names of {@link versionsList}.\n * Values are the published routes of that version, the same strings VitePress\n * receives back from `vitepressConfig.rewrites`.\n *\n * The version switcher reads this record to tell whether the page a reader is on\n * also exists in the version they picked, so it can fall back to that version's\n * home page instead of linking at a route that returns a 404.\n *\n * The record stays empty until `parseRoutesComponent` fills it.\n *\n * @example\n * ```ts\n * routesMap = {\n * 'v2.0.x': [ 'v2.0.x/index.md', 'v2.0.x/guide/index.md' ],\n * 'v1.0.x': [ 'v1.0.x/index.md', 'v1.0.x/release.md' ]\n * };\n * ```\n *\n * @since 2.1.0\n */\n\n readonly routesMap: Record<string, Array<string>> = {};\n\n /**\n * Creates an instance of `StateModel`.\n *\n * @param configuration - Optional configuration object; defaults to {@link defaultConfiguration}.\n *\n * @throws Will throw an error if the sources directory does not exist.\n *\n * @remarks\n * Initializes the state of the documentation project by:\n * - Extracting `sources` and `archive` from the provided configuration.\n * - Constructing full paths for `root`, `sourcesPath`, and `archivePath`.\n * - Validating that the sources directory exists.\n * - Ensuring the archive directory exists and creating a `.gitkeep` file if necessary.\n * - Creating a VitePress configuration object with versioning support.\n *\n * @since 2.0.0\n */\n\n constructor(readonly configuration: ConfigurationInterface = defaultConfiguration) {\n const { sources, archive } = configuration.versionsConfig;\n\n this.root = join(process.cwd(), process.argv[3] ?? '', configuration.srcDir ?? '');\n this.sources = relative(this.root, resolve(this.root, sources)).split(sep).join('/');\n this.archive = archive;\n this.versionsConfig = configuration.versionsConfig;\n\n this.sourcesPath = join(this.root, this.sources);\n this.archivePath = join(this.root, this.archive);\n\n if (!existsSync(this.sourcesPath)) this.fail(`Source directory ${ this.sourcesPath } does not exist`);\n\n this.makeArchiveDirectory(this.archivePath);\n this.vitepressConfig = this.createVitepressConfig();\n }\n\n /**\n * Initializes the state model by collecting the published versions and resolving the locale prefixes.\n *\n * @returns The current instance for method chaining\n *\n * @throws Error - When two versions share a name or overlapping folders, when a `path` is no folder inside {@link root},\n * or when `versionsConfig.latest` or a key of `versionsConfig.versions` names no version\n *\n * @remarks\n * Every version is a name and a folder in {@link versionDirs}:\n * the current version reads from `sources`, an archived version from its folder under {@link archivePath},\n * and a version with its own `path` from that folder.\n * A misspelled name fails the build instead of leaving a version unpublished.\n *\n * @example\n * ```ts\n * // archive/ holds v1.0.x, and versionsConfig.current is 'v2.0.x'\n * const state = new StateModel(config).init();\n *\n * state.versionsList; // [ 'v2.0.x', 'v1.0.x' ]\n * state.latest; // 'v2.0.x'\n * ```\n *\n * @see versionDirs\n * @see initializeLocalesMap\n *\n * @since 2.0.0\n */\n\n init(): this {\n const { current, latest, versions } = this.versionsConfig;\n\n const others: Array<[ string, string ]> = [];\n for (const entry of readdirSync(this.archivePath, { withFileTypes: true })) {\n if (entry.isDirectory()) others.push([ entry.name, posix.join(this.archive, entry.name) ]);\n }\n\n for (const [ name, { path }] of Object.entries(versions)) {\n if (path) others.push([ name, this.versionFolder(name, path) ]);\n }\n\n // newest first, comparing the numbers in a name by value, so v2.10.x comes before v2.9.x\n others.sort(([ a ], [ b ]) => b.localeCompare(a, 'en', { numeric: true }));\n\n this.addVersion(current, this.sources);\n for (const [ name, folder ] of others) this.addVersion(name, folder);\n\n for (const name of [ latest, ...Object.keys(versions) ]) {\n if (name && !this.versionDirs[name]) this.fail(`Version ${ name } is neither the current version nor an archive folder`);\n }\n\n this.latest = latest || current;\n for (const version of this.versionsList) this.labels[version] = versions[version]?.label ?? version;\n this.initializeLocalesMap();\n\n return this;\n }\n\n /**\n * Reports a configuration error and stops loading the configuration.\n *\n * @param message - The description of the error\n *\n * @throws Error - Always, carrying the given message\n *\n * @remarks\n * The message goes to the console in red first,\n * so it stays visible above the stack trace that VitePress prints for the thrown error.\n * The components report their own configuration errors through it as well.\n *\n * @since 3.0.0\n */\n\n fail(message: string): never {\n console.error(xterm.red('[ viteplus ]'), `${ message }\\n`);\n throw new Error(message);\n }\n\n /**\n * Resolves the URL prefix of every configured locale.\n *\n * @remarks\n * The root locale is the `root` key, or else the first key of `configuration.locales`.\n * A `link` such as `/de/` gives the prefix `de`, so the slashes of a VitePress style link never reach a URL.\n * Two locales with one prefix, a prefix of more than one segment, or a prefix that names a version stop the build,\n * since the locale and the version of a page are read from its first two segments.\n * The locale entries of the VitePress configuration are built from these maps by `parseLocale`.\n *\n * @see localesMap\n * @see localePrefixes\n *\n * @since 2.0.0\n */\n\n private initializeLocalesMap(): void {\n const userLocales = this.configuration.locales;\n const keys = Object.keys(userLocales);\n const rootKey = 'root' in userLocales ? 'root' : keys[0];\n\n for (const key of keys) {\n const { lang, link } = userLocales[key];\n const prefix = link ? link.replace(/^\\/+|\\/+$/g, '') : getLanguageOnly(lang ?? key);\n const taken = Object.keys(this.localePrefixes).find(other => this.localePrefixes[other] === prefix);\n\n if (key !== rootKey && taken) this.fail(`Locales ${ taken } and ${ key } share the prefix ${ prefix }, give one a link of its own`);\n if (key !== rootKey && prefix.includes('/')) this.fail(`Locale ${ key } has the prefix ${ prefix }, a prefix has to be one segment`);\n if (key !== rootKey && this.versionDirs[prefix]) this.fail(`Locale ${ key } and a version share the name ${ prefix }, rename one of them`);\n\n this.localesMap[prefix] = key === rootKey ? 'root' : key;\n this.localePrefixes[key] = key === rootKey ? '' : prefix;\n }\n }\n\n /**\n * Publishes a version from a folder.\n *\n * @param name - The name of the version, which becomes its URL segment\n * @param folder - The folder of the version, relative to {@link root}\n *\n * @throws Error - When another version already carries the name,\n * or when its folder holds or sits inside the folder of another version\n *\n * @remarks\n * Two versions with one name would publish over each other's pages,\n * such as an archive folder named after the current version.\n * A folder inside another one, such as a `path` of `src/legacy`, would hand its pages to both versions.\n *\n * @since 3.0.0\n */\n\n private addVersion(name: string, folder: string): void {\n const taken = this.versionDirs[name];\n if (taken) this.fail(`Version ${ name } is published from both ${ taken } and ${ folder }, rename one of them`);\n\n for (const [ other, otherFolder ] of Object.entries(this.versionDirs)) {\n if (`${ folder }/`.startsWith(`${ otherFolder }/`) || `${ otherFolder }/`.startsWith(`${ folder }/`)) {\n this.fail(`Version ${ name } in ${ folder } overlaps version ${ other } in ${ otherFolder }, move it to a folder of its own`);\n }\n }\n\n this.versionDirs[name] = folder;\n }\n\n /**\n * Resolves the `path` of a version to its folder relative to {@link root}.\n *\n * @param name - The name of the version, for the error message\n * @param path - The `path` setting of the version\n * @returns The folder in POSIX form\n *\n * @throws Error - When the path is no existing folder inside {@link root}\n *\n * @remarks\n * VitePress builds only the files under its source directory, so a folder outside {@link root} is rejected.\n *\n * @since 3.0.0\n */\n\n private versionFolder(name: string, path: string): string {\n const folder = relative(this.root, resolve(this.root, path)).split(sep).join('/');\n if (!folder || folder.startsWith('..') || isAbsolute(folder) || !existsSync(join(this.root, folder))) {\n this.fail(`Path ${ path } of version ${ name } has to be an existing folder inside ${ this.root }`);\n }\n\n return folder;\n }\n\n /**\n * Ensures that the archive directory exists.\n *\n * @param path - The path to the archive directory.\n *\n * @remarks\n * - If the directory does not exist, it is created.\n * - A `.gitkeep` file is also added to ensure the directory is tracked by Git.\n *\n * @since 2.0.0\n */\n\n private makeArchiveDirectory(path: string): void {\n if (!path) return;\n\n if (!existsSync(path)) {\n mkdirSync(path);\n writeFileSync(join(path, '.gitkeep'), '');\n }\n }\n\n /**\n * Creates a VitePress configuration object from the user-provided configuration.\n *\n * @returns A `VitepressConfigInterface` object with versioning support added.\n *\n * @remarks\n * - Copies all configuration properties except for `locales`, `rewrites`, `themeConfig`, and `versionsConfig`.\n * - Initializes excluded properties (except `versionsConfig`) with empty objects.\n * - Returns a configuration object typed as {@link VitepressConfigInterface}, ready for VitePress usage.\n *\n * @see VitepressConfigInterface\n * @since 2.0.0\n */\n\n private createVitepressConfig(): VitepressConfigInterface {\n const result: Record<string, unknown> = {};\n const exclude: Array<keyof ConfigurationInterface> = [\n 'locales',\n 'rewrites',\n 'themeConfig',\n 'versionsConfig'\n ];\n\n for (const key of Object.keys(this.configuration) as Array<keyof ConfigurationInterface>) {\n if (!exclude.includes(key)) {\n result[key] = this.configuration[key];\n } else if (key === 'themeConfig') {\n const themeConfig = this.configuration.themeConfig ?? {};\n result.themeConfig = Object.fromEntries(\n Object.entries(themeConfig).filter(\n ([ prop ]) => prop !== 'nav' && prop !== 'sidebar'\n )\n );\n } else if (key !== 'versionsConfig') {\n result[key] = {};\n }\n }\n\n return <VitepressConfigInterface><unknown>result;\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { LocaleInterface } from '@interfaces/locale.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Extracts the language code from a locale string.\n *\n * @param locale - The locale string to parse (e.g., 'en-US', 'fr_CA', 'zh-Hans-CN').\n * @returns The language code portion of the locale (e.g., 'en', 'fr', 'zh').\n *\n * @remarks\n * This function parses a locale string and returns only the primary language code,\n * discarding region, script, and variant information. It handles both standard\n * separators used in locale strings:\n * - Hyphen (`-`): BCP 47 standard (e.g., 'en-US', 'zh-Hans-CN')\n * - Underscore (`_`): POSIX/Java standard (e.g., 'en_US', 'pt_BR')\n *\n * The language code is always the first component of a locale identifier and\n * represents the base language without regional or script variations.\n *\n * Common use cases:\n * - Fallback language selection when a specific locale is unavailable\n * - Grouping locales by language family\n * - Simplifying locale matching for translations\n * - Language detection without regional specificity\n * - API requests that only accept language codes\n *\n * Locale format examples:\n * - Language only: 'en', 'fr', 'ja'\n * - Language + Region: 'en-US', 'fr-CA', 'pt-BR'\n * - Language + Script + Region: 'zh-Hans-CN', 'zh-Hant-TW'\n * - POSIX format: 'en_US', 'de_DE', 'es_MX'\n *\n * @example\n * ```ts\n * // BCP 47 format with region\n * console.log(getLanguageOnly('en-US')); // 'en'\n * console.log(getLanguageOnly('fr-CA')); // 'fr'\n * console.log(getLanguageOnly('pt-BR')); // 'pt'\n *\n * // POSIX format with underscore\n * console.log(getLanguageOnly('en_GB')); // 'en'\n * console.log(getLanguageOnly('de_DE')); // 'de'\n *\n * // Complex locale with script\n * console.log(getLanguageOnly('zh-Hans-CN')); // 'zh'\n * console.log(getLanguageOnly('zh-Hant-TW')); // 'zh'\n *\n * // Language code only (no separator)\n * console.log(getLanguageOnly('ja')); // 'ja'\n * console.log(getLanguageOnly('ko')); // 'ko'\n *\n * // Use case: Fallback language selection\n * const userLocale = 'es-MX';\n * const language = getLanguageOnly(userLocale); // 'es'\n * const translations = loadTranslations(language); // Load Spanish translations\n * ```\n *\n * @since 2.0.5\n */\n\nexport function getLanguageOnly(locale: string): string {\n return locale.split(/[-_]/)[0];\n}\n\n/**\n * Creates a copy of a locale without its navigation.\n *\n * @param sourceLocale - The locale of the user configuration {@link LocaleInterface}\n * @returns A shallow copy of the locale with its own `themeConfig` that holds no `nav` or `sidebar`\n *\n * @remarks\n * The plugin builds the `nav` and `sidebar` of every locale entry itself.\n * Every copy gets its own `themeConfig` object, so writing the navigation of one entry never reaches\n * another entry or the user configuration. Values inside `themeConfig`, functions included, are shared by reference.\n *\n * @example\n * ```ts\n * const locale = createSanitizedLocale({ lang: 'de-DE', themeConfig: { nav: [], footer: 'Impressum' } });\n * // { lang: 'de-DE', themeConfig: { footer: 'Impressum' } }\n * ```\n *\n * @see LocaleInterface\n * @since 2.0.5\n */\n\nfunction createSanitizedLocale(sourceLocale: LocaleInterface = {}): LocaleInterface {\n const cloned = { ...sourceLocale };\n if (cloned.themeConfig) {\n cloned.themeConfig = { ...cloned.themeConfig };\n delete cloned.themeConfig.nav;\n delete cloned.themeConfig.sidebar;\n }\n\n return cloned;\n}\n\n/**\n * Builds the link of a locale from its URL prefix.\n *\n * @param prefix - The URL prefix of the locale, empty for the root locale\n * @returns `/` for the root locale, or `/<prefix>/` for any other\n *\n * @example\n * ```ts\n * generateLocaleLink(''); // '/'\n * generateLocaleLink('de'); // '/de/'\n * ```\n *\n * @since 2.0.5\n */\n\nfunction generateLocaleLink(prefix: string): string {\n return prefix ? `/${ prefix }/` : '/';\n}\n\n/**\n * Creates the locale entry of one version of a locale.\n *\n * @param baseLocale - The locale of the user configuration {@link LocaleInterface}\n * @param prefix - The URL prefix of the locale, empty for the root locale\n * @returns A copy of the locale with a blank label and the link of the locale\n *\n * @remarks\n * The blank label keeps the versioned entry out of the language menu,\n * and the link leads the language menu to the locale.\n *\n * @example\n * ```ts\n * createVersionedLocale({ lang: 'de-DE', label: 'Deutsch' }, 'de');\n * // { lang: 'de-DE', label: ' ', link: '/de/' }\n * ```\n *\n * @see createSanitizedLocale\n * @since 2.0.5\n */\n\nfunction createVersionedLocale(baseLocale: LocaleInterface, prefix: string): LocaleInterface {\n return { ...createSanitizedLocale(baseLocale), label: ' ', link: generateLocaleLink(prefix) };\n}\n\n/**\n * Builds every locale entry of the VitePress configuration.\n *\n * @remarks\n * Every locale gets an entry at its prefix, `root` for the root locale,\n * and one entry per version at `<prefix>/<version>`, the address its pages are published under.\n * The versioned entries come before the entry of their locale, since VitePress picks the first key that matches a page.\n * A site without locales gets an entry for `root` and for every version.\n *\n * Every entry also gets a `themeConfig.logoLink` to the home page of its version, `latest` for `root` and the bare locales,\n * unless the user sets one. The site title would otherwise link to `/`, which no version publishes,\n * and the router would show the not-found page when the title is clicked inside the site.\n *\n * @example\n * ```ts\n * // configuration.locales is { root: { lang: 'en' }, de: { lang: 'de-DE' } }, the versions are v1 and v2\n * parseLocale();\n * Object.keys(vitepressConfig.locales); // [ 'root', 'v1', 'v2', 'de/v1', 'de/v2', 'de' ]\n * ```\n *\n * @see StateModel.localePrefixes\n * @see createVersionedLocale\n *\n * @since 2.0.5\n */\n\nexport function parseLocale(): void {\n const { latest, versionsList, vitepressConfig: { locales, base = '/' }, configuration, localePrefixes } = inject(StateModel);\n const withLogoLink = (locale: LocaleInterface, prefix: string, version: string): LocaleInterface => {\n if (configuration.themeConfig?.logoLink || locale.themeConfig?.logoLink) return locale;\n\n return { ...locale, themeConfig: { ...locale.themeConfig, logoLink: join('/', base, prefix, version, '/') } };\n };\n\n locales.root = {};\n for (const [ key, prefix ] of Object.entries(localePrefixes)) {\n const baseLocale = createSanitizedLocale(configuration.locales[key]);\n for (const version of versionsList) {\n locales[join(prefix, version)] = withLogoLink(createVersionedLocale(baseLocale, prefix), prefix, version);\n }\n\n locales[prefix || 'root'] = withLogoLink({ ...baseLocale, link: generateLocaleLink(prefix) }, prefix, latest);\n }\n\n locales.root = withLogoLink(locales.root, '', latest);\n for (const version of versionsList) locales[version] ??= withLogoLink({}, '', version);\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { ConfigurationInterface } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { existsSync, readFileSync, realpathSync } from 'fs';\nimport { rewritesHook } from '@components/rewrites.component';\n\n/**\n * The file system that the Vue SFC compiler reads imported types through.\n *\n * @remarks\n * `defineProps<PropsInterface>()` in the version switcher names a type from another file,\n * and the compiler has to read that file to turn the type into runtime props.\n * Without an `fs` option the compiler falls back to `ts.sys` of the `typescript` package,\n * which TypeScript 7 no longer ships and which is missing when TypeScript is not installed,\n * so the build fails with `No fs option provided to compileScript`.\n *\n * VitePress hands `vue.script` to `@vitejs/plugin-vue`, which passes it on to `compileScript`,\n * so this default gives the compiler Node's file system whatever TypeScript the site installs.\n * A site that sets its own `vue.script.fs` keeps it, since the user configuration is merged on top.\n *\n * @example\n * ```ts\n * scriptFileSystem.fileExists('/docs/.vitepress/theme/index.ts'); // true\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/42\n * @since 2.2.0\n */\n\nexport const scriptFileSystem = {\n fileExists: (file: string): boolean => existsSync(file),\n readFile: (file: string): string => readFileSync(file, 'utf8'),\n realpath: (file: string): string => realpathSync(file)\n};\n\n/**\n * Default configuration object for the `versions` system.\n *\n * @remarks\n * Provides a baseline implementation of {@link ConfigurationInterface}.\n * This includes:\n * - Empty `locales` and `rewrites` mappings.\n * - A `versionsConfig` with:\n * - `current` set to `\"latest\"`, and an empty `latest` that makes `current` the stable version.\n * - `sources` pointing to `\"src\"`.\n * - `archive` pointing to `\"archive\"`.\n * - `hooks.rewritesHook` bound to the default {@link rewritesHook}.\n * - Empty `versions` settings, so every version keeps its name as its label.\n * - A `versionSwitcher` enabled with label `\"Switch Version\"` and\n * `includeCurrentVersion` set to `true`.\n * - A `vue.script.fs` that reads the file system through Node, see {@link scriptFileSystem}.\n * - A `vite.resolve.dedupe` of `vue` and `vitepress`, so the switcher component resolves both from the site\n * even when the package is linked from outside it, and shares the one Vue app and router the site runs.\n *\n * This default setup can be extended or overridden as needed when\n * customizing your documentation site.\n *\n * @example\n * ```ts\n * import { defaultConfiguration } from \"@config/default.configuration\";\n *\n * export default {\n * ...defaultConfiguration,\n * locales: {\n * en: { link: \"/en/\", label: \"English\" }\n * }\n * };\n * ```\n *\n * @since 2.0.0\n */\n\nexport const defaultConfiguration: ConfigurationInterface = {\n locales: {},\n rewrites: {},\n versionsConfig: {\n current: 'latest',\n latest: '',\n sources: 'src',\n archive: 'archive',\n hooks: {\n rewritesHook: rewritesHook\n },\n versionSwitcher: {\n text: 'Switch Version',\n includeCurrentVersion: true\n },\n versions: {}\n },\n vue: {\n script: {\n fs: scriptFileSystem\n }\n },\n vite: {\n resolve: {\n dedupe: [ 'vue', 'vitepress' ]\n }\n }\n};\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { RouteResolverType } from '@interfaces/function.interface';\n\n/**\n * imports\n */\n\nimport { join } from 'path/posix';\nimport { join as joinPath } from 'path';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\nimport { getAllMarkdownFilesRelative } from '@components/object.component';\n\n/**\n * Rewrites a documentation source path using version and locale.\n *\n * @remarks\n * This implementation joins the `version`, `locale`, and original `source`\n * into a normalized POSIX-style path. It is commonly used to generate\n * consistent URLs or filesystem paths for versioned and localized docs.\n *\n * @param source - The original file path or content identifier.\n * @param version - The version string of the documentation (e.g., `\"1.2.0\"`).\n * @param locale - The locale code (e.g., `\"en\"`, `\"de\"`).\n *\n * @returns The rewritten path string in the format `version/locale/source`.\n *\n * @example\n * ```ts\n * rewritesHook(\"guide/intro.md\", \"v2.0.0\", \"en\");\n * // \u2192 \"en/v2.0.0/guide/intro.md\"\n * ```\n *\n * @since 2.0.0\n */\n\nexport function rewritesHook(source: string, version: string, locale: string): string {\n return join(locale, version, source);\n}\n\n/**\n * Creates the resolver that maps a documentation source path to its published route.\n *\n * @returns A resolver that takes a source path and returns its rewritten route {@link RouteResolverType}\n *\n * @remarks\n * A path under a folder of {@link StateModel.versionDirs} belongs to that version.\n * The resolver drops the folder, takes a leading locale folder off the rest,\n * and hands both to the `rewritesHook` of `versionsConfig`, which decides the final segment order.\n * Every other path stays untouched.\n *\n * @example\n * ```ts\n * const resolve = createRouteResolver();\n * resolve('src/guide/index.md'); // 'next/guide/index.md'\n * resolve('archive/v1.0.x/de/index.md'); // 'de/v1.0.x/index.md'\n * resolve('public/logo.png'); // 'public/logo.png'\n * ```\n *\n * @see parseRoutesComponent\n * @since 2.1.0\n */\n\nexport function createRouteResolver(): RouteResolverType {\n const state = inject(StateModel);\n const { localesMap, versionsConfig } = state;\n const localesList = Object.keys(localesMap);\n const folders = Object.entries(state.versionDirs);\n\n return function (id: string): string {\n const match = folders.find(([ , folder ]) => id.startsWith(`${ folder }/`));\n if (!match) return id;\n\n const [ version, folder ] = match;\n const path = id.slice(folder.length + 1);\n const localeKey = localesList.find(prefix => path.startsWith(`${ prefix }/`));\n if (!localeKey) return versionsConfig.hooks.rewritesHook(path, version, '');\n\n const locale = localesMap[localeKey] === 'root' ? '' : localeKey;\n\n return versionsConfig.hooks.rewritesHook(path.slice(localeKey.length + 1), version, locale);\n };\n}\n\n/**\n * Collects the routes that every version publishes, keyed by version name.\n *\n * @param resolve - The resolver that turns a source path into its published route\n * @returns A record mapping each version name to the routes that version publishes\n *\n * @remarks\n * Every version is read from its folder in {@link StateModel.versionDirs},\n * and every file runs through the same resolver that builds `vitepressConfig.rewrites`,\n * so a route in this record always matches the URL VitePress serves.\n * The version switcher checks this record before it links to a page in another version.\n *\n * @example\n * ```ts\n * parseVersionRoutes(createRouteResolver());\n * // { 'v2.0.x': [ 'v2.0.x/index.md' ], 'v1.0.x': [ 'v1.0.x/index.md', 'v1.0.x/release.md' ] }\n * ```\n *\n * @see createRouteResolver\n * @see getAllMarkdownFilesRelative\n *\n * @since 2.1.0\n */\n\nexport function parseVersionRoutes(resolve: RouteResolverType): Record<string, Array<string>> {\n const { root, versionDirs } = inject(StateModel);\n\n const routes = (folder: string): Array<string> =>\n getAllMarkdownFilesRelative(joinPath(root, folder)).map(file => resolve(join(folder, file)));\n\n return Object.fromEntries(Object.entries(versionDirs).map(([ version, folder ]) => [ version, routes(folder) ]));\n}\n\n/**\n * Checks that the `rewritesHook` keeps the locale and the version at the front of every route.\n *\n * @throws Error - When the hook gives the home page of a version and locale a route\n * that does not start with `<locale>/<version>/`\n *\n * @remarks\n * The locale entries, the navigation, the version switchers, the link rewriting, and the root URL\n * all find the version right after the locale. A hook that puts the version first, or drops it,\n * would publish pages that none of them can place, so the build stops with the route the hook returned.\n *\n * @example\n * ```ts\n * // rewritesHook: (source, version, locale) => join(version, locale, source)\n * assertRewritesHook();\n * // Error: rewritesHook has to keep de/v2.x/ at the front of every route, it returned v2.x/de/index.md\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\nexport function assertRewritesHook(): void {\n const state = inject(StateModel);\n const { versionsList, localeSegments, versionsConfig } = state;\n\n for (const locale of [ '', ...localeSegments ]) {\n for (const version of versionsList) {\n const prefix = `${ join(locale, version) }/`;\n const route = versionsConfig.hooks.rewritesHook('index.md', version, locale);\n if (route.startsWith(prefix)) continue;\n\n state.fail(`rewritesHook has to keep ${ prefix } at the front of every route, it returned ${ route }`);\n }\n }\n}\n\n/**\n * Wires route rewriting into the VitePress configuration and records the routes of every version.\n *\n * @remarks\n * Checks the hook with {@link assertRewritesHook}, then\n * assigns `vitepressConfig.rewrites` the resolver from {@link createRouteResolver},\n * which VitePress calls once per source file while it builds the site.\n * Fills {@link StateModel.routesMap} with the output of {@link parseVersionRoutes},\n * so the version switcher can check a route before it links to it.\n *\n * @example\n * ```ts\n * parseRoutesComponent();\n * state.vitepressConfig.rewrites('archive/v1.0.x/guide/index.md'); // 'v1.0.x/guide/index.md'\n * state.routesMap['v1.0.x']; // [ 'v1.0.x/guide/index.md', ... ]\n * ```\n *\n * @see createRouteResolver\n * @see parseVersionRoutes\n * @see assertRewritesHook\n *\n * @since 2.0.0\n */\n\nexport function parseRoutesComponent(): void {\n const state = inject(StateModel);\n assertRewritesHook();\n\n const resolve = createRouteResolver();\n state.vitepressConfig.rewrites = resolve;\n Object.assign(state.routesMap, parseVersionRoutes(resolve));\n}\n", "/**\n * Imports\n */\n\nimport { readdirSync } from 'fs';\nimport { join, relative } from 'path/posix';\n\n/**\n * Deeply merges two object types into a single object.\n *\n * @typeParam T - The type of the first object.\n * @typeParam U - The type of the second object.\n *\n * @param obj1 - The base object whose properties will be merged.\n * @param obj2 - The object whose properties will overwrite or merge into `obj1`.\n * @returns A new object containing the deeply merged properties of both `obj1` and `obj2`.\n *\n * @remarks\n * - This function performs a deep merge, recursively merging nested objects.\n * - If a property exists in both `obj1` and `obj2`:\n * - If both values are plain objects, they are merged recursively.\n * - Otherwise, the value from `obj2` overwrites the value from `obj1`.\n * - Arrays are **not** merged; if a property is an array in `obj2`, it will replace\n * the corresponding property in `obj1`.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { c: 2, d: 3 } };\n * const obj2 = { b: { c: 42 }, e: 99 };\n *\n * const merged = deepMerge(obj1, obj2);\n * // Result: { a: 1, b: { c: 42, d: 3 }, e: 99 }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function deepMerge<T extends object, U extends object>(obj1: T, obj2: U): T & U {\n const result = <Record<string, unknown>> { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n const val2 = (obj2 as T & U)[key];\n const val1 = (obj1 as T & U)[key];\n\n if (\n val1 && typeof val1 === 'object' &&\n val2 && typeof val2 === 'object' &&\n !Array.isArray(val1) && !Array.isArray(val2)\n ) {\n result[key] = deepMerge(val1 as object, val2 as object);\n } else {\n result[key] = val2;\n }\n }\n }\n\n return result as T & U;\n}\n\n/**\n * Recursively collects all Markdown (`.md`) files within a given directory,\n * returning their paths relative to a specified root directory.\n *\n * @param rootDir - The root directory used as the base for relative paths.\n * @param currentDir - The current directory to scan. Defaults to `rootDir`.\n * @returns An array of relative file paths to Markdown files.\n *\n * @remarks\n * - This function traverses directories recursively.\n * - Only files with a `.md` extension are included in the results.\n * - Returned paths are **relative to `rootDir`**, regardless of how deep the files are nested.\n * - Uses Node.js `fs.readdirSync` with `withFileTypes: true` for efficient directory traversal.\n *\n * @example\n * ```ts\n * const markdownFiles = getAllMarkdownFilesRelative(\"/project/docs\");\n *\n * console.log(markdownFiles);\n * // Example output:\n * // [\n * // \"README.md\",\n * // \"guide/intro.md\",\n * // \"tutorial/setup.md\"\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function getAllMarkdownFilesRelative(rootDir: string, currentDir: string = rootDir): Array<string> {\n let results: Array<string> = [];\n const entries = readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n results = results.concat(getAllMarkdownFilesRelative(rootDir, fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const relativePath = relative(rootDir, fullPath);\n results.push(relativePath);\n }\n }\n\n return results;\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { UserConfig } from 'vitepress';\nimport type { PartialConfigurationType } from '@interfaces/configuration.interface';\n\n/**\n * Imports\n */\n\nimport { StateModel } from '@models/state.model';\nimport { forceInject } from '@remotex-labs/xinject';\nimport { parseNavs } from '@components/nav.component';\nimport { deepMerge } from '@components/object.component';\nimport { parseLocale } from '@components/locale.component';\nimport { parseSidebars } from '@components/sidebar.component';\nimport { parseLatestEntry } from '@components/latest.component';\nimport { parseVersionLinks } from '@components/links.component';\nimport { parseVersioningData } from '@components/switcher.component';\nimport { parseRoutesComponent } from '@components/rewrites.component';\nimport { defaultConfiguration } from '@constants/configuration.constant';\n\n/**\n * Export interfaces\n */\n\nexport type * from 'vitepress';\nexport type * from '@interfaces/nav.interface';\nexport type * from '@interfaces/theme.interface';\nexport type * from '@interfaces/locale.interface';\nexport type * from '@interfaces/sidebar.interface';\nexport type * from '@interfaces/configuration.interface';\n\nexport function defineVersionedConfig(userConfiguration: PartialConfigurationType): UserConfig {\n const config = deepMerge(defaultConfiguration, userConfiguration);\n const state = forceInject(StateModel, config).init();\n parseLocale();\n\n /**\n * Parse components\n */\n\n parseRoutesComponent();\n parseVersioningData();\n parseVersionLinks();\n parseLatestEntry();\n parseNavs();\n parseSidebars();\n\n return <UserConfig> state.vitepressConfig;\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { NavItemType, NavItemWithChildrenType } from '@interfaces/nav.interface';\nimport type { NavItemWithLinkType, NavObjectType, NavType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\nimport { versionSwitcher } from '@components/switcher.component';\n\n/**\n * Type guard to check if a navigation item has children.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithChildrenType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of an `item` property that is an array.\n * - Use this type guard to safely access child navigation items when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Docs\", items: [{ text: \"Guide\", link: \"/guide/\" }] };\n * if (isNavItemWithChildren(item)) {\n * console.log(item.items); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithChildren(item: NavItemType): item is NavItemWithChildrenType {\n return 'items' in item && Array.isArray(item.items);\n}\n\n/**\n * Type guard to check if a navigation item has a link.\n *\n * @param item - The navigation item to test.\n * @returns `true` if the item is a {@link NavItemWithLinkType}, `false` otherwise.\n *\n * @remarks\n * - This function checks for the presence of a `link` property.\n * - A link that names a scheme, such as `https:` or `mailto:`, or starts with `//` leaves the site and does not count.\n * A path that merely contains `http`, such as `/guide/http-client`, still counts.\n * - Use this type guard to safely access the `link` property when iterating\n * or transforming navigation trees.\n *\n * @example\n * ```ts\n * const item: NavItemType = { text: \"Home\", link: \"/\" };\n * if (isNavItemWithLink(item)) {\n * console.log(item.link); // Safe to access\n * }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function isNavItemWithLink(item: NavItemType): item is NavItemWithLinkType {\n return 'link' in item && !!item.link && typeof item.link === 'string' && !/^([a-z][\\w+.-]*:|\\/\\/)/i.test(item.link);\n}\n\n/**\n * Recursively prepends a version prefix to navigation item links.\n *\n * @param version - The version string to prefix (e.g., `\"v2.0.0\"`).\n * @param item - The navigation item to process, which can be a link, a group with children, or a component.\n * @param versions - The names of every published version, whose links are left as written.\n * @returns A new navigation item with updated `link` values where applicable.\n *\n * @remarks\n * - For {@link NavItemWithLinkType}, prepends the given `version` to the `link`\n * unless `skipVersioning` is `true`, the link already starts with one of `versions`,\n * or its last segment has an extension other than `.md` or `.html`, which marks a public file.\n * - For {@link NavItemWithChildrenType}, recursively traverses all children and applies\n * the same transformation.\n * - Component-based navigation items ({@link NavItemComponentType}) are returned as-is.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItem: NavItemWithLinkType = { text: \"Guide\", link: \"/guide/\" };\n * const result = replaceLinksRecursive(\"v2.0.0\", navItem);\n * // \u2192 { text: \"Guide\", link: \"/v2.0.0/guide/\" }\n *\n * const navGroup: NavItemWithChildrenType = {\n * text: \"Docs\",\n * items: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const groupResult = replaceLinksRecursive(\"v2.0.0\", navGroup);\n * // \u2192 { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function replaceLinksRecursive(version: string, item: NavItemType, versions: Array<string> = []): NavItemType {\n if (isNavItemWithChildren(item) && !item.skipVersioning) {\n return {\n ...item,\n items: item.items.map(child => replaceLinksRecursive(version, child, versions))\n };\n }\n\n if (isNavItemWithLink(item) && !item.skipVersioning && typeof item.link === 'string') {\n const pathname = item.link.replace(/[?#].*$/, '');\n const versioned = versions.includes(pathname.split('/').filter(Boolean)[0]);\n if (versioned || /\\.(?!(md|html)$)[^./]+$/.test(pathname)) return item;\n\n return { ...item, link: join('/', version, item.link) };\n }\n\n return item;\n}\n\n/**\n * Applies version prefixes to an array of navigation items.\n *\n * @param items - An array of navigation items to process.\n * @param version - The version string to prepend to links (e.g., `\"v2.0.0\"`).\n * - If `\"root\"` is provided, no version prefix is added.\n * @param versions - The names of every published version, whose links are left as written.\n * @returns A new array of navigation items with versioned links applied.\n *\n * @remarks\n * - Uses {@link replaceLinksRecursive} to traverse each navigation item.\n * - Only items that are link-based or have children are modified; component items remain unchanged.\n * The `VersionSwitcher` component reads the versions from `themeConfig.versioning`, see `parseVersioningData`.\n * - Preserves other properties of the navigation items.\n *\n * @example\n * ```ts\n * const navItems: NavItemType[] = [\n * { text: \"Guide\", link: \"/guide/\" },\n * { text: \"Docs\", items: [{ text: \"Intro\", link: \"/intro/\" }] }\n * ];\n * const versionedNav = populateNav(navItems, \"v2.0.0\");\n * // \u2192 [\n * // { text: \"Guide\", link: \"/v2.0.0/guide/\" },\n * // { text: \"Docs\", items: [{ text: \"Intro\", link: \"/v2.0.0/intro/\" }] }\n * // ]\n * ```\n *\n * @since 2.0.0\n */\n\nexport function populateNav(items: Array<NavItemType>, version: string, versions: Array<string> = []): Array<NavItemType> {\n if (version === 'root') version = '';\n\n return items.map(item => replaceLinksRecursive(version, item, versions));\n}\n\n/**\n * Normalizes a navigation structure into a flat, prefixed record.\n *\n * @param results - The target {@link NavObjectType} to populate with normalized items.\n * @param nav - The navigation structure to normalize. Can be:\n * - An array of navigation items (`NavItemType[]`), or\n * - A record mapping strings to arrays of navigation items (`NavObjectType`).\n * @param prefix - Optional prefix for keys when processing nested navigation objects.\n * Defaults to an empty string.\n * @param root - Optional root-level navigation items to include in all normalized entries.\n *\n * @remarks\n * - If `nav` is an array, it merges it with the root items (if any) and appends to `results.root`.\n * - If `nav` is a record:\n * - Each key is prefixed with `prefix` unless it is `'root'`.\n * - Items from `root` or `root.root` are merged into each key.\n * - All items are accumulated in the `results` object, preserving the hierarchy as flat keys.\n *\n * @example\n * ```ts\n * const nav: NavObjectType = {\n * root: [{ text: \"Home\", link: \"/\" }],\n * guide: [{ text: \"Intro\", link: \"/intro/\" }]\n * };\n * const results: NavObjectType = { root: [] };\n * normalizeNav(results, nav, \"v2.0.0\");\n * // results \u2192 {\n * // root: [{ text: \"Home\", link: \"/\" }],\n * // \"v2.0.0/guide\": [{ text: \"Intro\", link: \"/intro/\" }]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNav(results: NavObjectType, nav: NavType, prefix: string = '', root: NavObjectType = {}): void {\n if (Array.isArray(nav)) {\n const index = prefix ? prefix : 'root';\n\n results[index] ??= [];\n results[index].push(...nav);\n if (root[index]) results[index].push(...root[index]);\n else if (root.root) results[index].push(...root.root);\n\n return;\n }\n\n for (const [ key, items ] of Object.entries(nav)) {\n const subRoot = key === 'root' && prefix === '' ? 'root' : prefix;\n const index = key === 'root' ? subRoot : join(prefix, key);\n\n results[index] ??= [];\n results[index].push(...items);\n if (root[key]) results[index].push(...root[key]);\n else if (root.root) results[index].push(...root.root);\n }\n}\n\n/**\n * Normalizes all navigation structures across the global and locale-specific configurations.\n *\n * @param state - The current {@link StateModel} providing configuration data:\n * - `configuration.themeConfig.nav` \u2014 global navigation configuration.\n * - `configuration.locales` \u2014 locale-specific configurations with optional `nav`.\n *\n * @returns A flat record of navigation items keyed by locale or `'root'`, suitable for further processing.\n *\n * @remarks\n * - First, global navigation items are normalized into `globalResults`.\n * - If no locales are defined, `globalResults` is returned directly.\n * - Otherwise, iterates through all locale keys:\n * - Normalizes each locale\u2019s `nav` configuration.\n * - Merges in global navigation items as fallback where necessary.\n * - Ensures that all navigation entries are flattened and ready for versioning or rendering.\n *\n * @example\n * ```ts\n * const state = inject(StateModel);\n * const normalizedNavs = normalizeNavs(state);\n * // normalizedNavs \u2192 {\n * // root: [...global items],\n * // en: [...English locale items including global fallback],\n * // de: [...German locale items including global fallback]\n * // }\n * ```\n *\n * @since 2.0.0\n */\n\nexport function normalizeNavs(state: StateModel): Record<string, Array<NavItemType>> {\n const locales = state.configuration.locales;\n const localesKeys = Object.keys(locales);\n const globalResults: Record<string, Array<NavItemType>> = { root: [] };\n\n if (state.configuration.themeConfig?.nav) {\n normalizeNav(globalResults, state.configuration.themeConfig.nav as NavType);\n }\n\n const switcher = versionSwitcher(state.versionsConfig, state.versionsList, state.latest, state.labels);\n if(switcher) globalResults.root.push(switcher);\n\n if (!localesKeys.length) return globalResults;\n const results: Record<string, Array<NavItemType>> = { root: [] };\n\n for (const locale of localesKeys) {\n const prefix = state.localePrefixes[locale] || 'root';\n normalizeNav(results, (locales[locale].themeConfig?.nav ?? []) as NavType, prefix, globalResults);\n }\n\n return results;\n}\n\n/**\n * Retrieves the appropriate navigation configuration for a given locale key.\n *\n * @param navs - The navigation configurations mapped by locale keys.\n * @param key - The locale key to retrieve navigation for (e.g., 'root', 'fr', 'fr/v1.0.0').\n * @returns The navigation configuration for the locale, falling back to parent locale or root.\n *\n * @remarks\n * This function implements a fallback strategy for finding navigation configurations:\n * 1. If an exact match exists for the key, return it\n * 2. If the key contains '/' (versioned locale), extract the base locale and try that\n * 3. If no base locale exists, fall back to 'root'\n *\n * This allows versioned locales (e.g., 'fr/v1.0.0', 'de/v2.0') to inherit navigation\n * from their base locale ('fr', 'de') without duplicating configuration.\n *\n * Fallback hierarchy examples:\n * - `'fr'` \u2192 Direct match, returns `navs.fr`\n * - `'fr/v1.0.0'` \u2192 No direct match \u2192 Checks `'fr'` \u2192 Returns `navs.fr`\n * - `'es/v1.0.0'` \u2192 No direct match \u2192 Checks `'es'` (doesn't exist) \u2192 Returns `navs.root`\n * - `'root'` \u2192 Direct match, returns `navs.root`\n *\n * @example\n * ```ts\n * const navs = {\n * root: [{ text: 'Home', link: '/' }],\n * fr: [{ text: 'Accueil', link: '/fr/' }],\n * de: [{ text: 'Startseite', link: '/de/' }]\n * };\n *\n * // Exact match\n * getNavForLocale(navs, 'fr'); // Returns fr nav\n *\n * // Versioned locale - inherits from base\n * getNavForLocale(navs, 'fr/v1.0.0'); // Returns fr nav\n * getNavForLocale(navs, 'de/v2.0'); // Returns de nav\n *\n * // No base locale exists - falls back to root\n * getNavForLocale(navs, 'es/v1.0.0'); // Returns root nav\n *\n * // Root locale\n * getNavForLocale(navs, 'root'); // Returns root nav\n * ```\n *\n * @see {@link parseNavs} - Uses this function to populate navigation for all locales\n * @see {@link NavItemType} - The navigation item type structure\n *\n * @since 2.0.5\n */\n\nexport function getNavForLocale(navs: Record<string, Array<NavItemType>>, key: string): Array<NavItemType> {\n if (navs[key]) return navs[key];\n\n // If the key contains '/', try to get the base locale\n if (key.includes('/')) {\n const baseLocale = key.split('/')[0];\n\n if (navs[baseLocale]) {\n return navs[baseLocale];\n }\n }\n\n // Fall back to root\n return navs.root;\n}\n\n/**\n * Parses and populates the navigation structure for all locales.\n *\n * @remarks\n * - Retrieves normalized navigation items using {@link normalizeNavs}.\n * - Iterates through all locales defined in `vitepressConfig.locales`.\n * - For each locale:\n * - Falls back to global navigation (`navs.root`) if locale-specific navigation is not defined.\n * - A root locale only holds the home page of the latest version and the `404` page,\n * so it takes the navigation of the latest version, with every link pointed into that version.\n * - Ensures the locale\u2019s `themeConfig` exists.\n * - Populates the locale\u2019s `themeConfig.nav` using {@link populateNav}, applying versioning where applicable.\n *\n * @example\n * ```ts\n * parseNavs();\n * // state.vitepressConfig.locales \u2192 each locale has `themeConfig.nav` populated\n * ```\n *\n * @since 2.0.0\n */\n\nexport function parseNavs(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const navs = normalizeNavs(state);\n const rootLocales = [ 'root', ...Object.values(state.localePrefixes) ];\n\n for (const [ key, locale ] of Object.entries(locales)) {\n const version = rootLocales.includes(key) ? join(key === 'root' ? '' : key, state.latest) : key;\n\n locale.themeConfig ??= {};\n locale.themeConfig.nav = populateNav(getNavForLocale(navs, version), version, state.versionsList);\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { DefaultTheme } from 'vitepress';\nimport type { VersionsConfigInterface } from '@interfaces/configuration.interface';\nimport type { NavItemWithChildrenType, NavItemWithLinkType } from '@interfaces/nav.interface';\n\n/**\n * Imports\n */\n\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Builds a version switcher navigation item for the documentation site.\n *\n * @param themeConfig - The {@link VersionsConfigInterface} configuration object\n * @param versions - The names of every published version\n * @param latest - The name of the stable version\n * @param labels - The text to show for each version name, falling back to the name itself\n * @returns A {@link NavItemWithChildrenType} representing the version switcher,\n * or `undefined` if the switcher is disabled in the configuration\n *\n * @remarks\n * - If `themeConfig.versionSwitcher === false`, no switcher is created.\n * - The returned navigation item contains child links for each version in `versions` other than `latest`.\n * - If `includeCurrentVersion` is enabled, a link to the home page of `latest` comes first,\n * tagged `(latest)` unless its label already reads `latest`.\n * - All version links have `skipVersioning: true` to prevent further prefixing.\n *\n * Each link keeps the version name in its URL and shows the text from `labels`,\n * so a label never moves a page.\n *\n * @example\n * ```ts\n * const themeConfig: VersionsConfigInterface = {\n * versionSwitcher: { text: \"Versions\", includeCurrentVersion: true }\n * };\n *\n * const versions = [\"next\", \"v2.0.0\", \"v1.5.0\"];\n * const navItem = versionSwitcher(themeConfig, versions, \"v2.0.0\", { \"v1.5.0\": \"v1.5.0 (LTS)\" });\n *\n * // \u2192 {\n * // text: \"Versions\",\n * // items: [\n * // { link: \"/v2.0.0/\", text: \"v2.0.0 (latest)\", skipVersioning: true },\n * // { link: \"/next/\", text: \"next\", skipVersioning: true },\n * // { link: \"/v1.5.0/\", text: \"v1.5.0 (LTS)\", skipVersioning: true }\n * // ]\n * // }\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\nexport function versionSwitcher(\n themeConfig: VersionsConfigInterface, versions: Array<string>, latest: string, labels: Record<string, string> = {}\n): undefined | NavItemWithChildrenType {\n if (themeConfig.versionSwitcher === false) return;\n\n const { text, includeCurrentVersion } = themeConfig.versionSwitcher;\n const item = (version: string, label = labels[version] ?? version): NavItemWithLinkType =>\n ({ text: label, link: `/${ version }/`, skipVersioning: true });\n\n const items = versions.filter(version => version !== latest).map(version => item(version));\n if (includeCurrentVersion) {\n const label = labels[latest] ?? latest;\n items.unshift(item(latest, label.toLowerCase() === 'latest' ? label : `${ label } (latest)`));\n }\n\n return { text, items };\n}\n\n/**\n * Publishes the data that the `VersionSwitcher` component reads, once for the whole site.\n *\n * @remarks\n * The data lands in `themeConfig.versioning` of the site, which VitePress merges into the theme of every locale,\n * so `useData().theme` hands it to the component on every page,\n * and `installVersionFallback` reads it from the site data to send a missing address to the nearest page.\n * It used to ride in the props of every switcher nav item, which repeated the routes of every version\n * in each of the locale entries and grew the site data with locales \u00D7 versions \u00D7 routes.\n *\n * @example\n * ```ts\n * parseVersioningData();\n * vitepressConfig.themeConfig.versioning;\n * // { versions: [ 'v2.x', 'v1.x' ], latestVersion: 'v2.x', labels: { ... }, routes: { ... }, locales: [ 'de' ] }\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @since 3.0.0\n */\n\nexport function parseVersioningData(): void {\n const { vitepressConfig, routesMap, labels, versionsList, latest, localeSegments } = inject(StateModel);\n const versioning = { routes: routesMap, labels, versions: versionsList, latestVersion: latest, locales: localeSegments };\n\n vitepressConfig.themeConfig = <DefaultTheme.Config> { ...vitepressConfig.themeConfig, versioning };\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { SidebarItemType } from '@viteplus/versions';\nimport type { SidebarObjectType, SidebarType } from '@interfaces/sidebar.interface';\nimport type { PathSegmentsInterface } from '@components/interfaces/sidebar-component.interface';\n\n/**\n * Imports\n */\n\nimport { join } from 'path/posix';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Safely joins path segments, preventing empty or dot-only results.\n *\n * @param args - Variable number of path segments to join.\n * @returns A joined path string, or empty string if the result would be '.' or empty.\n *\n * @remarks\n * This function is a wrapper around Node.js's {@link join} from path/posix that addresses\n * a common edge case: when all input segments are empty or falsy, {@link join} returns\n * a single dot (`'.'`) representing the current directory. This function prevents that\n * behavior by returning an empty string instead.\n *\n * **Processing steps**:\n * 1. Filters out falsy values (empty strings, null, undefined, 0, false) using {@link Boolean}\n * 2. Joins remaining segments using {@link join}\n * 3. Returns empty string if result is `'.'`, otherwise returns the joined path\n *\n * **Use cases**:\n * - Building URL paths where empty segments should result in empty strings\n * - Constructing locale-aware paths with optional prefixes\n * - Generating version-specific routes where components may be absent\n * - Avoiding visual artifacts from dot paths in UI components\n *\n * The function is particularly useful in multi-version, multi-locale systems where\n * path components (locale, version, base path) may be conditionally empty, and you\n * need consistent empty-string results rather than dot notation.\n *\n * @example\n * ```ts\n * // Normal path joining\n * const path1 = safeJoin('docs', 'guide', 'intro');\n * console.log(path1); // 'docs/guide/intro'\n *\n * // With empty segments (filtered out)\n * const path2 = safeJoin('', 'docs', '', 'guide');\n * console.log(path2); // 'docs/guide'\n *\n * // All empty segments (returns empty string, not '.')\n * const path3 = safeJoin('', '', '');\n * console.log(path3); // '' (not '.')\n *\n * // Single segment\n * const path4 = safeJoin('docs');\n * console.log(path4); // 'docs'\n *\n * // Use case: Building versioned paths\n * const locale = ''; // Root locale (empty)\n * const version = ''; // Current version (empty)\n * const base = 'guide';\n *\n * const path = safeJoin(locale, version, base);\n * console.log(path); // 'guide' (not './guide' or '.')\n *\n * // Use case: Optional prefix paths\n * function buildPath(prefix: string, ...segments: string[]): string {\n * return '/' + safeJoin(prefix, ...segments);\n * }\n *\n * console.log(buildPath('', 'api', 'users')); // '/api/users'\n * console.log(buildPath('v2', 'api', 'users')); // '/v2/api/users'\n * console.log(buildPath('', '', '')); // '/' (not '/.')\n * ```\n *\n * @see join\n * @see Boolean\n *\n * @since 2.0.5\n */\n\nfunction safeJoin(...args: Array<string>): string {\n const joined = join(...args.filter(Boolean));\n\n return joined === '.' ? '' : joined;\n}\n\n/**\n * Populates sidebar items with version-specific base paths.\n *\n * @param sidebar - Array of sidebar items to process {@link SidebarItemType}.\n * @param version - The version string to apply to base paths, or 'root' for the default version.\n * @returns A new array of sidebar items with updated base paths.\n *\n * @remarks\n * This function transforms sidebar items by adding version-specific base paths to enable\n * multi-version documentation navigation. It processes each sidebar item according to\n * specific rules:\n *\n * **Skipped items** (returned unchanged):\n * - Items with `skipVersioning: true` flag\n * - Items with external links (starting with 'http')\n * - Items without links or nested items\n * - Items when a version is empty or 'root'\n *\n * **Processed items**:\n * - The base path is prepended with a version: `/{version}/{base}/`\n * - Original item properties are preserved via spread operator\n * - The normalized version replaces 'root' with empty string\n *\n * The base path structure follows the pattern: `/{version}/{originalBase}/`\n * using {@link join} from path/posix for consistent URL formatting across platforms.\n *\n * @example\n * ```ts\n * const sidebar: Array<SidebarItemType> = [\n * { text: 'Guide', link: '/guide/', base: '/docs' },\n * { text: 'API', link: '/api/', base: '/reference' },\n * { text: 'External', link: 'https://example.com' },\n * { text: 'Skip', link: '/skip/', skipVersioning: true }\n * ];\n *\n * const versioned = populateSidebar(sidebar, 'v2.0');\n * // [\n * // { text: 'Guide', link: '/guide/', base: '/v2.0/docs/' },\n * // { text: 'API', link: '/api/', base: '/v2.0/reference/' },\n * // { text: 'External', link: 'https://example.com' },\n * // { text: 'Skip', link: '/skip/', skipVersioning: true }\n * // ]\n *\n * // Root version (no prefix)\n * const rootVersioned = populateSidebar(sidebar, 'root');\n * // Base paths remain unchanged\n *\n * // Use case: Version-specific sidebar configuration\n * const versions = ['v1.0', 'v2.0', 'latest'];\n * const sidebarConfigs = versions.map(version => ({\n * version,\n * items: populateSidebar(baseSidebar, version)\n * }));\n * ```\n *\n * @see SidebarItemType\n * @since 2.0.5\n */\n\nexport function populateSidebar(sidebar: Array<SidebarItemType>, version: string): Array<SidebarItemType> {\n const normalizedVersion = version === 'root' ? '' : version;\n\n return sidebar.map(item => {\n if (item.skipVersioning || item?.link?.startsWith('http')) return item;\n if (!(item.link || item.items) || !normalizedVersion) return item;\n\n return {\n ...item,\n base: safeJoin('/', normalizedVersion, item.base ?? '', '/')\n };\n });\n}\n\n/**\n * Extracts locale and version information from URL path segments.\n *\n * @param segments - Array of URL path segments to parse (will be modified by shifting elements).\n * @param localesList - List of valid locale identifiers for matching.\n * @param versionsList - List of valid version identifiers for matching.\n * @returns An object containing extracted language and version {@link PathSegmentsInterface}.\n *\n * @remarks\n * This function parses URL path segments to identify and extract locale and version\n * information, supporting both version-first and locale-first URL structures. The\n * function operates on the segment array destructively, removing matched elements\n * via {@link Array.shift}.\n *\n * **Parsing logic**:\n * 1. If the first segment matches a version \u2192 return `{ lang: '', version }` (version-first pattern)\n * 2. If the first segment matches a locale \u2192 extract it as `lang` (locale-first pattern)\n * 3. If the second segment matches a version \u2192 extract it as `version`\n * 4. Return both extracted values (empty strings if not found)\n *\n * **URL patterns supported**:\n * - `/v2.0/guide/` \u2192 `{ lang: '', version: 'v2.0' }`\n * - `/fr/v2.0/guide/` \u2192 `{ lang: 'fr', version: 'v2.0' }`\n * - `/fr/guide/` \u2192 `{ lang: 'fr', version: '' }`\n * - `/guide/` \u2192 `{ lang: '', version: '' }`\n *\n * The segment array is mutated during extraction, with matched segments removed\n * from the beginning. This allows the following processing to work with the remaining\n * path components.\n *\n * @example\n * ```ts\n * const localesList = ['en', 'fr', 'de'];\n * const versionsList = ['v1.0', 'v2.0', 'latest'];\n *\n * // Version-first pattern\n * const segments1 = ['v2.0', 'guide', 'intro'];\n * const result1 = extractLocale(segments1, localesList, versionsList);\n * console.log(result1); // { lang: '', version: 'v2.0' }\n * console.log(segments1); // ['guide', 'intro']\n *\n * // Locale-first pattern\n * const segments2 = ['fr', 'v2.0', 'api', 'reference'];\n * const result2 = extractLocale(segments2, localesList, versionsList);\n * console.log(result2); // { lang: 'fr', version: 'v2.0' }\n * console.log(segments2); // ['api', 'reference']\n *\n * // No locale or version\n * const segments3 = ['docs', 'getting-started'];\n * const result3 = extractLocale(segments3, localesList, versionsList);\n * console.log(result3); // { lang: '', version: '' }\n * console.log(segments3); // ['docs', 'getting-started']\n *\n * // Use case: URL parsing for routing\n * const url = '/de/latest/guide/installation';\n * const segments = url.split('/').filter(Boolean);\n * const { lang, version } = extractLocale(\n * segments,\n * ['en', 'de', 'fr'],\n * ['latest', 'v1', 'v2']\n * );\n * const route = segments.join('/');\n * console.log({ lang, version, route });\n * // { lang: 'de', version: 'latest', route: 'guide/installation' }\n * ```\n *\n * @see PathSegmentsInterface\n * @since 2.0.5\n */\n\nexport function extractLocale(segments: Array<string>, localesList: Array<string>, versionsList: Array<string>): PathSegmentsInterface {\n if (localesList.length === 0) localesList = [ 'root' ];\n if (versionsList.includes(segments[0])) {\n return { lang: '', version: segments.shift()! };\n }\n\n const lang = localesList.includes(segments[0]) ? segments.shift()! : '';\n const version = versionsList.includes(segments[0]) ? segments.shift()! : '';\n\n return { lang, version };\n}\n\n/**\n * Normalizes sidebar configuration into a structured format for multi-version documentation.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @param results - Accumulator object to store normalized sidebar entries {@link SidebarObjectType}.\n * @param sidebar - The sidebar configuration to normalize {@link SidebarType}.\n * @param prefix - Locale prefix for the sidebar (e.g., 'root', 'fr', 'de').\n *\n * @remarks\n * This function transforms sidebar configurations from various input formats into a\n * normalized structure that supports multi-version, multi-locale documentation. It\n * handles both array-based and object-based sidebar definitions.\n *\n * **Input formats supported**:\n * - **Array format**: Simple list of sidebar items for a single path\n * - **Object format**: Key-value pairs where keys are paths and values are sidebar items\n * - **Undefined**: Gracefully handles missing sidebar configuration\n *\n * **Normalization process**:\n * 1. Early return if the sidebar is undefined\n * 2. Convert the 'root' prefix to an empty string for URL normalization\n * 3. For array format: Store items under the normalized path\n * 4. For object format: Parse each key to extract locale/version using {@link extractLocale}\n * 5. Filter entries that don't match the current locale prefix\n * 6. Construct versioned paths and store items in the result accumulator\n *\n * **Results structure**:\n * ```ts\n * {\n * 'root': { '/': [...items], '/guide/': [...items] },\n * 'fr': { '/fr/': [...items], '/fr/guide/': [...items] },\n * 'fr/v2.0': { '/fr/v2.0/': [...items] }\n * }\n * ```\n *\n * The function uses state data to access:\n * - {@link StateModel.localesMap} for valid locale identifiers\n * - {@link StateModel.versionsList} for valid version identifiers\n *\n * @example\n * ```ts\n * const state = new StateModel(config).init();\n * const results: Record<string, SidebarObjectType> = {};\n *\n * // Array format sidebar\n * const arraySidebar = [\n * { text: 'Guide', link: '/guide/' },\n * { text: 'API', link: '/api/' }\n * ];\n * normalizeSidebar(state, results, arraySidebar, 'root');\n * // results = { 'root': { '/': [{ text: 'Guide', ... }, { text: 'API', ... }] } }\n *\n * // Object format sidebar\n * const objectSidebar = {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }],\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * };\n * normalizeSidebar(state, results, objectSidebar, 'root');\n *\n * // With locale prefix\n * normalizeSidebar(state, results, objectSidebar, 'fr');\n * // Only '/fr/guide/' entries are processed\n *\n * // Use case: Multi-locale sidebar processing\n * const results = {};\n * const locales = ['root', 'fr', 'de'];\n * for (const locale of locales) {\n * const sidebar = getLocaleSidebar(locale);\n * normalizeSidebar(state, results, sidebar, locale);\n * }\n * ```\n *\n * @see StateModel\n * @see SidebarType\n * @see extractLocale\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebar(state: StateModel, results: Record<string, SidebarObjectType>, sidebar?: SidebarType, prefix: string = ''): void {\n if (!sidebar) return;\n const normalizedPrefix = prefix === 'root' ? '' : prefix;\n\n if (Array.isArray(sidebar)) {\n const index = normalizedPrefix ? normalizedPrefix : '/';\n results[prefix] ??= {};\n results[prefix][index] ??= [];\n results[prefix][index].push(...sidebar);\n\n return;\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n for (const [ key, items ] of Object.entries(sidebar)) {\n const segments = key.split('/').filter(Boolean);\n const { lang, version } = extractLocale(segments, localesList, versionsList);\n\n if (lang && !prefix.startsWith(lang)) continue;\n\n const parent = version ? safeJoin(normalizedPrefix, version) : normalizedPrefix;\n const index = safeJoin(parent, ...segments) || '/';\n const parentIndex = parent || 'root';\n\n results[parentIndex] ??= {};\n results[parentIndex][index] ??= [];\n\n const itemsArray = Array.isArray(items) ? items : [ items ];\n results[parentIndex][index].push(...itemsArray);\n }\n}\n\n\n/**\n * Normalizes all sidebar configurations across locales and versions.\n *\n * @param state - The state model containing configuration data {@link StateModel}.\n * @returns A normalized sidebar structure organized by locale and path {@link SidebarObjectType}.\n *\n * @remarks\n * This function orchestrates the complete normalization of all sidebar configurations\n * in a multi-version, multi-locale documentation site. It processes sidebars from both\n * global theme configuration and locale-specific settings, then propagates them to all\n * versioned locale entries.\n *\n * **Processing stages**:\n * 1. **Initial Normalization**: Process sidebars from global theme config and each locale's\n * theme config using {@link normalizeSidebar}\n * 2. **Version Propagation**: For each locale entry in {@link StateModel.vitepressConfig},\n * if it lacks a normalized sidebar, inherit from its parent locale\n * 3. **Path Adjustment**: Adjust inherited paths to include the version/locale prefix\n *\n * **Data sources processed**:\n * - {@link StateModel.configuration.themeConfig.sidebar}: Global sidebar configuration\n * - Each locale's `themeConfig.sidebar`: Locale-specific sidebar configuration\n *\n * **Output structure**:\n * ```ts\n * {\n * 'root': { '/': [...], '/guide/': [...] },\n * 'v2.0': { '/v2.0/': [...], '/v2.0/guide/': [...] },\n * 'fr': { '/fr/': [...], '/fr/guide/': [...] },\n * 'fr/v2.0': { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n * }\n * ```\n *\n * The function ensures that every locale entry in the VitePress configuration has\n * appropriate sidebar items, either directly defined or inherited from parent locales.\n * This enables consistent navigation across all versions and locales.\n *\n * @example\n * ```ts\n * const state = new StateModel({\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Guide', link: '/guide/' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US' },\n * '/fr/': {\n * lang: 'fr-FR',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Guide', link: '/fr/guide/' }]\n * }\n * }\n * }\n * },\n * versionsConfig: {\n * sources: 'src',\n * archive: 'versions'\n * }\n * }).init();\n *\n * const normalized = normalizeSidebars(state);\n *\n * console.log(Object.keys(normalized));\n * // ['root', 'v1.0', 'v2.0', 'fr', 'fr/v1.0', 'fr/v2.0']\n *\n * console.log(normalized['v2.0']);\n * // { '/v2.0/': [...], '/v2.0/guide/': [...] }\n *\n * console.log(normalized['fr/v2.0']);\n * // { '/fr/v2.0/': [...], '/fr/v2.0/guide/': [...] }\n *\n * // Use case: Building a complete sidebar structure\n * const state = inject(StateModel);\n * const sidebars = normalizeSidebars(state);\n *\n * // Apply to VitePress config\n * for (const [locale, paths] of Object.entries(sidebars)) {\n * vitepressConfig.locales[locale].themeConfig.sidebar = paths;\n * }\n * ```\n *\n * @see StateModel\n * @see extractLocale\n * @see normalizeSidebar\n * @see SidebarObjectType\n *\n * @since 2.0.5\n */\n\nexport function normalizeSidebars(state: StateModel): Record<string, SidebarObjectType> {\n const { vitepressConfig, configuration: { locales, themeConfig } } = state;\n const normalizedSidebar: Record<string, SidebarObjectType> = {};\n\n if (Object.keys(locales).length > 0) {\n for (const [ localeKey, locale ] of Object.entries(locales)) {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, localeKey);\n normalizeSidebar(state, normalizedSidebar, locale.themeConfig?.sidebar as SidebarObjectType, localeKey);\n }\n } else {\n normalizeSidebar(state, normalizedSidebar, themeConfig?.sidebar as SidebarObjectType, 'root');\n }\n\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n for (const index of Object.keys(vitepressConfig.locales)) {\n if (normalizedSidebar[index]) continue;\n\n const { lang } = extractLocale(index.split('/'), localesList, versionsList);\n const parent = normalizedSidebar[lang || 'root'];\n if (!parent) continue;\n\n normalizedSidebar[index] = {};\n for (const [ key, items ] of Object.entries(parent)) {\n const segments = key.split('/').filter(Boolean);\n extractLocale(segments, localesList, versionsList);\n normalizedSidebar[index][safeJoin(index, ...segments)] = [ ...items ];\n }\n }\n\n return normalizedSidebar;\n}\n\n/**\n * Parses and applies sidebar configurations to all locales in the VitePress configuration.\n *\n * @remarks\n * This function is the main entry point for sidebar processing in a multi-version,\n * multi-locale documentation system. It coordinates the complete sidebar normalization\n * and population workflow by:\n *\n * 1. **Injecting State**: Retrieves the {@link StateModel} singleton instance\n * 2. **Normalizing**: Calls {@link normalizeSidebars} to process all sidebar configurations\n * 3. **Applying**: Iterates through each locale in {@link StateModel.vitepressConfig.locales}\n * 4. **Populating**: Uses {@link populateSidebar} to add version-specific base paths\n * 5. **Merging**: Assigns processed sidebars to each locale's theme configuration\n *\n * **Sidebar structure handling**:\n * - Initializes `themeConfig` if it doesn't exist\n * - Converts array-based sidebars to object format for consistent processing\n * - Preserves existing sidebar structure when no normalized version exists\n * - Ensures sidebar is always in object format after processing\n *\n * The function modifies the VitePress configuration in place, updating each locale's\n * `themeConfig.sidebar` with the normalized and versioned sidebar items. This ensures\n * that all routes have appropriate navigation structures.\n *\n * **Processing flow**:\n * ```\n * User Config \u2192 normalizeSidebars() \u2192 Normalized Structure\n * \u2193\n * VitePress Config \u2190 populateSidebar() \u2190 Per-Locale Items\n * ```\n *\n * @example\n * ```ts\n * // Setup configuration\n * const config = {\n * themeConfig: {\n * sidebar: {\n * '/': [{ text: 'Home', link: '/' }],\n * '/guide/': [{ text: 'Getting Started', link: '/guide/start' }]\n * }\n * },\n * locales: {\n * root: { lang: 'en-US', label: 'English' },\n * '/fr/': {\n * lang: 'fr-FR',\n * label: 'Fran\u00E7ais',\n * themeConfig: {\n * sidebar: {\n * '/fr/guide/': [{ text: 'Commencer', link: '/fr/guide/start' }]\n * }\n * }\n * }\n * }\n * };\n *\n * const state = new StateModel(config).init();\n * provide(StateModel, state);\n *\n * // Parse and apply sidebars\n * parseSidebars();\n *\n * // Result: Each locale now has versioned sidebars\n * console.log(state.vitepressConfig.locales['v2.0'].themeConfig.sidebar);\n * // {\n * // '/v2.0/': [{ text: 'Home', link: '/', base: '/v2.0/' }],\n * // '/v2.0/guide/': [{ text: 'Getting Started', link: '/guide/start', base: '/v2.0/guide/' }]\n * // }\n *\n * console.log(state.vitepressConfig.locales['fr/v2.0'].themeConfig.sidebar);\n * // {\n * // '/fr/v2.0/guide/': [{ text: 'Commencer', link: '/fr/guide/start', base: '/fr/v2.0/guide/' }]\n * // }\n *\n * // Use case: Integration in VitePress config hook\n * export default defineConfig({\n * async buildStart() {\n * parseSidebars();\n * },\n * // ... rest of config\n * });\n * ```\n *\n * @see StateModel\n * @see populateSidebar\n * @see normalizeSidebars\n *\n * @since 2.0.5\n */\n\nexport function parseSidebars(): void {\n const state = inject(StateModel);\n const { vitepressConfig: { locales } } = state;\n const localesList = Object.values(state.localesMap);\n const versionsList = state.versionsList;\n\n const sidebars = normalizeSidebars(state);\n for (const [ key, locale ] of Object.entries(locales)) {\n if (!sidebars[key]) continue;\n\n locale.themeConfig ??= {};\n if (!locale.themeConfig.sidebar || Array.isArray(locale.themeConfig.sidebar)) {\n locale.themeConfig.sidebar = {};\n }\n\n for (const [ index, items ] of Object.entries(sidebars[key])) {\n const { lang, version } = extractLocale(index.split('/'), localesList, versionsList);\n (locale.themeConfig.sidebar as SidebarObjectType)[index] = populateSidebar(\n items, safeJoin(lang, version)\n );\n }\n }\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { SiteConfig } from 'vitepress';\n\n/**\n * Imports\n */\n\nimport { join } from 'path';\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\nimport { readFileSync, writeFileSync } from 'fs';\n\n/**\n * The data that {@link openLatestPage} reads in the browser.\n *\n * @since 3.1.0\n */\n\nexport interface LatestPageDataInterface {\n /**\n * The site base, with a slash at both ends, such as `/docs/`.\n *\n * @since 3.1.0\n */\n\n base: string;\n\n /**\n * The name of the stable version, see {@link StateModel.latest}.\n *\n * @since 3.1.0\n */\n\n latest: string;\n\n /**\n * Whether the site serves pages without `.html`.\n *\n * @since 3.1.0\n */\n\n cleanUrls: boolean;\n\n /**\n * The URL prefixes of every locale other than the root one.\n *\n * @since 3.1.0\n */\n\n locales: Array<string>;\n\n /**\n * The names of every published version.\n *\n * @since 3.1.0\n */\n\n versions: Array<string>;\n\n /**\n * The routes that the latest version publishes, such as `de/v2.x/guide.md`.\n *\n * @since 3.1.0\n */\n\n routes: Array<string>;\n}\n\n/**\n * Moves an address that names no version onto the same page of the latest version, before the app starts.\n *\n * @param data - The site data the move needs, see {@link LatestPageDataInterface}\n *\n * @remarks\n * Runs in the browser, inlined into a page by {@link latestScript}, so it reads `location` and changes the address\n * with `history.replaceState`, which VitePress's router then reads on its first load.\n * `/guide`, `/guide/` and `/guide.html` become the address of `guide.md` or `guide/index.md` in the latest version,\n * and `/de/guide` its German page. The query and the hash are kept.\n * An address that already names a version, lies outside the base, or has no page in the latest version stays as it is,\n * so it still shows the not-found page.\n *\n * It keeps to one function body with no named helpers, since it is inlined from its source text.\n *\n * @example\n * ```ts\n * // at /docs/guide?a#b, where v2.x publishes v2.x/guide/index.md\n * openLatestPage({ base: '/docs/', latest: 'v2.x', cleanUrls: false, locales: [], versions, routes });\n * location.href; // .../docs/v2.x/guide/?a#b\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/61\n * @since 3.1.0\n */\n\nexport function openLatestPage(data: LatestPageDataInterface): void {\n const pathname = location.pathname === data.base.slice(0, -1) ? data.base : location.pathname;\n if (pathname.indexOf(data.base) !== 0) return;\n\n const segments = decodeURI(pathname.slice(data.base.length)).split('/');\n const locale = data.locales.indexOf(segments[0]) > -1 ? `${ segments.shift() }/` : '';\n if (data.versions.indexOf(segments[0]) > -1) return;\n\n const page = segments.join('/').replace(/\\.html$/, '').replace(/\\/$/, '').replace(/(^|\\/)index$/, '');\n const prefix = `${ locale }${ data.latest }/`;\n const candidates = page ? [ `${ prefix }${ page }.md`, `${ prefix }${ page }/index.md` ] : [ `${ prefix }index.md` ];\n const route = candidates.find(candidate => data.routes.indexOf(candidate) > -1);\n if (!route) return;\n\n const path = route.replace(/(^|\\/)index\\.md$/, '$1').replace(/\\.md$/, data.cleanUrls ? '' : '.html');\n history.replaceState(history.state, '', `${ encodeURI(data.base + path) }${ location.search }${ location.hash }`);\n}\n\n/**\n * Builds the inline script that runs {@link openLatestPage} with the data of this site.\n *\n * @returns A `<script>` tag to place at the start of `<head>`\n *\n * @remarks\n * Only the routes of the latest version ride along, since no other version is a target.\n * Every `<` in the data is escaped, so a route can never close the script tag.\n *\n * @example\n * ```ts\n * latestScript();\n * // '<script>(function openLatestPage(data) { ... })({\"base\":\"/docs/\",\"latest\":\"v2.x\",...})</script>'\n * ```\n *\n * @since 3.1.0\n */\n\nexport function latestScript(): string {\n const { latest, localeSegments, versionsList, routesMap, vitepressConfig } = inject(StateModel);\n const { base = '/', cleanUrls = false } = vitepressConfig;\n const trimmed = base.replace(/^\\/+|\\/+$/g, '');\n const data: LatestPageDataInterface = {\n base: trimmed ? `/${ trimmed }/` : '/',\n latest,\n cleanUrls,\n locales: localeSegments,\n versions: versionsList,\n routes: routesMap[latest] ?? []\n };\n\n const json = JSON.stringify(data).replace(/</g, '\\\\u003c');\n\n return `<script>(${ openLatestPage.toString() })(${ json })</script>`;\n}\n\n/**\n * Opens the latest version at every address that names no version, without a second copy of its pages.\n *\n * @remarks\n * - The root of the site and of every locale serves the home page of {@link StateModel.latest},\n * copied there when the build ends unless a page is already there.\n * - Any other address that names no version, such as `/guide`, has no page on disk, so the host serves `404.html`.\n *\n * Both pages carry the script from {@link latestScript}, which moves the address to the same page of the latest version\n * before the app starts, so `/guide` opens `/<latest>/guide` without a reload, and only the root home page is copied.\n * The dev server adds the script to every page it serves, where it does nothing at an address that names a version.\n * The `vite` plugins and the `buildEnd` hook of the user configuration are kept, and that hook runs last.\n *\n * @example\n * ```ts\n * parseLatestEntry();\n * // opening / shows the home page of v2.0.x, with /v2.0.x/ in the address bar\n * // opening /guide shows the guide of v2.0.x, with /v2.0.x/guide.html in the address bar\n * ```\n *\n * @see https://github.com/viteplus/versions/issues/55\n * @see https://github.com/viteplus/versions/issues/61\n *\n * @since 3.0.0\n */\n\nexport function parseLatestEntry(): void {\n const { latest, localeSegments, vitepressConfig } = inject(StateModel);\n const { buildEnd, vite = {} } = vitepressConfig;\n const script = latestScript();\n const withScript = (html: string): string => html.replace('<head>', `<head>${ script }`);\n\n const plugin = {\n name: 'viteplus-versions:latest',\n transformIndexHtml: withScript\n };\n\n vitepressConfig.vite = { ...vite, plugins: [ ...vite.plugins ?? [], plugin ] };\n\n vitepressConfig.buildEnd = async (siteConfig: SiteConfig): Promise<void> => {\n const write = (from: string, to: string, flag: 'w' | 'wx'): void => {\n try {\n // 'wx' fails when a page already sits at the root, in one step and without a race\n writeFileSync(to, withScript(readFileSync(from, 'utf8')), { flag });\n } catch (error) {\n if (![ 'ENOENT', 'EEXIST' ].includes(<string> (<NodeJS.ErrnoException> error).code)) throw error;\n }\n };\n\n for (const locale of [ '', ...localeSegments ]) {\n write(join(siteConfig.outDir, locale, latest, 'index.html'), join(siteConfig.outDir, locale, 'index.html'), 'wx');\n }\n\n const notFound = join(siteConfig.outDir, '404.html');\n write(notFound, notFound, 'w');\n\n await buildEnd?.(siteConfig);\n };\n}\n", "/**\n * Type-only imports erased during TypeScript compilation.\n */\n\nimport type { MarkdownRenderer, PageData, TransformPageContext } from 'vitepress';\n\n/**\n * Imports\n */\n\nimport { inject } from '@remotex-labs/xinject';\nimport { StateModel } from '@models/state.model';\n\n/**\n * Moves an absolute page link into a version.\n *\n * @param href - The link as the markdown source writes it\n * @param version - The name of the version that the link should point into\n * @param versions - The names of every published version\n * @param locales - The URL prefixes of the non-root locales, without their slashes\n * @returns The link with `version` inserted after its leading locale, or the link unchanged\n *\n * @remarks\n * A link is left unchanged when it is not absolute, when it already names a version,\n * or when its last segment carries an extension other than `.md` or `.html`, which marks a public file.\n *\n * @example\n * ```ts\n * versionLink('/guide#setup', 'v2.x', versions, [ 'de' ]); // '/v2.x/guide#setup'\n * versionLink('/de/guide', 'v2.x', versions, [ 'de' ]); // '/de/v2.x/guide'\n * versionLink('/v1.x/guide', 'v2.x', versions, [ 'de' ]); // '/v1.x/guide'\n * versionLink('/files/a.pdf', 'v2.x', versions, [ 'de' ]); // '/files/a.pdf'\n * ```\n *\n * @since 3.0.0\n */\n\nexport function versionLink(href: string, version: string, versions: Array<string>, locales: Array<string>): string {\n if (!href.startsWith('/') || href.startsWith('//')) return href;\n\n const pathname = href.replace(/[?#].*$/, '');\n const segments = pathname.split('/');\n const index = versions.includes(segments[1]) || !locales.includes(segments[1]) ? 1 : 2;\n if (versions.includes(segments[index]) || /\\.(?!(md|html)$)[^./]+$/.test(pathname)) return href;\n\n const prefix = segments.slice(0, index).join('/');\n\n return `${ prefix }/${ version }${ href.slice(prefix.length) }`;\n}\n\n/**\n * Moves every `link` in the frontmatter of a page into a version.\n *\n * @param value - The frontmatter, or any value inside it, changed in place\n * @param version - The name of the version that the links should point into\n * @param versions - The names of every published version\n * @param locales - The URL prefixes of the non-root locales, without their slashes\n *\n * @remarks\n * The home layout reads its buttons and cards from the frontmatter, such as `hero.actions[].link` and\n * `features[].link`, and a page reads `prev` and `next` from it. Markdown-it never sees these links,\n * so every string under a key named `link`, at any depth, runs through {@link versionLink}.\n * Every other key, such as `hero.image.src`, is left alone.\n *\n * @example\n * ```ts\n * const frontmatter = { hero: { actions: [{ text: 'Get Started', link: '/guide' }] } };\n * versionFrontmatterLinks(frontmatter, 'v2.x', versions, []);\n * frontmatter.hero.actions[0].link; // '/v2.x/guide'\n * ```\n *\n * @see versionLink\n * @see https://github.com/viteplus/versions/issues/61\n *\n * @since 3.1.0\n */\n\nexport function versionFrontmatterLinks(value: unknown, version: string, versions: Array<string>, locales: Array<string>): void {\n if (!value || typeof value !== 'object') return;\n\n const record = <Record<string, unknown>> value;\n for (const [ key, item ] of Object.entries(record)) {\n if (key === 'link' && typeof item === 'string') record[key] = versionLink(item, version, versions, locales);\n else versionFrontmatterLinks(item, version, versions, locales);\n }\n}\n\n/**\n * Moves the absolute links of every page into the version of that page.\n *\n * @remarks\n * Every version publishes its pages under its own name, so a link such as `/guide` would leave the version.\n * A markdown-it core rule reads the version from the published path of the page,\n * which VitePress hands to markdown-it as `env.relativePath` once `rewrites` has run,\n * and passes every link of the page through {@link versionLink}.\n * The rule runs while VitePress parses the page, before the dead link check reads the links,\n * so content written with root links keeps pointing into its own version.\n * A `markdown.config` of the user configuration still runs after the rule.\n *\n * Links in the frontmatter, such as the buttons of a home page, go through {@link versionFrontmatterLinks}\n * in `transformPageData`, which reads the version from the published `relativePath` the same way.\n * A `transformPageData` of the user configuration runs after it and sees the versioned links.\n *\n * @example\n * ```ts\n * parseVersionLinks();\n * // in archive/v1.x/guide.md, [Release](/release) renders as /v1.x/release\n * // and a hero action with link: /guide in archive/v1.x/index.md opens /v1.x/guide\n * ```\n *\n * @see versionLink\n * @see https://github.com/viteplus/versions/issues/55\n *\n * @since 3.0.0\n */\n\nexport function parseVersionLinks(): void {\n const state = inject(StateModel);\n const { versionsList, localeSegments } = state;\n const { config, ...markdown } = state.vitepressConfig.markdown ?? {};\n const { transformPageData } = state.vitepressConfig;\n const versionOf = (page?: string): string | undefined =>\n page?.split('/').slice(0, 2).find(segment => versionsList.includes(segment));\n\n state.vitepressConfig.transformPageData = async (pageData: PageData, context: TransformPageContext): Promise<Partial<PageData> | void> => {\n const version = versionOf(pageData.relativePath);\n if (version) versionFrontmatterLinks(pageData.frontmatter, version, versionsList, localeSegments);\n\n return transformPageData?.(pageData, context);\n };\n\n state.vitepressConfig.markdown = {\n ...markdown,\n async config(md: MarkdownRenderer): Promise<void> {\n md.core.ruler.push('viteplus_version_links', ({ env, tokens }) => {\n const version = versionOf(env?.relativePath);\n if (!version) return;\n\n for (const token of tokens.flatMap(block => block.children ?? [])) {\n const href = token.type === 'link_open' && token.attrGet('href');\n if (href) token.attrSet('href', versionLink(href, version, versionsList, localeSegments));\n }\n });\n\n await config?.(md);\n }\n };\n}\n"],
|
|
6
|
+
"mappings": "2PAWA,OAAS,cAAAA,OAAkB,wBAC3B,OAAS,SAAAC,OAAa,sCCFtB,OAAS,QAAAC,MAAY,aACrB,OAAS,UAAAC,OAAc,wBA4DhB,SAASC,EAAgBC,EA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FT,SAASmB,GAAsBC,EAAyD,CAC3F,IAAMC,EAASC,EAAUC,EAAsBH,CAAiB,EAC1DI,EAAQC,GAAYC,EAAYL,CAAM,EAAE,KAAK,EACnD,OAAAM,EAAY,EAMZC,EAAqB,EACrBC,EAAoB,EACpBC,EAAkB,EAClBC,EAAiB,EACjBC,EAAU,EACVC,EAAc,EAEMT,EAAM,eAC9B,CAjBgBU,EAAAf,GAAA",
|
|
7
|
+
"names": ["Injectable", "xterm", "join", "inject", "getLanguageOnly", "locale", "__name", "createSanitizedLocale", "sourceLocale", "cloned", "generateLocaleLink", "prefix", "createVersionedLocale", "baseLocale", "parseLocale", "latest", "versionsList", "locales", "base", "configuration", "localePrefixes", "inject", "StateModel", "withLogoLink", "version", "join", "key", "existsSync", "mkdirSync", "readdirSync", "writeFileSync", "isAbsolute", "join", "posix", "relative", "resolve", "sep", "existsSync", "readFileSync", "realpathSync", "join", "joinPath", "inject", "readdirSync", "join", "relative", "deepMerge", "obj1", "obj2", "result", "key", "val2", "val1", "__name", "getAllMarkdownFilesRelative", "rootDir", "currentDir", "results", "entries", "readdirSync", "entry", "fullPath", "join", "relativePath", "relative", "rewritesHook", "source", "version", "locale", "join", "__name", "createRouteResolver", "state", "inject", "StateModel", "localesMap", "versionsConfig", "localesList", "folders", "id", "match", "folder", "path", "localeKey", "prefix", "parseVersionRoutes", "resolve", "root", "versionDirs", "routes", "getAllMarkdownFilesRelative", "joinPath", "file", "assertRewritesHook", "versionsList", "localeSegments", "route", "parseRoutesComponent", "scriptFileSystem", "__name", "file", "existsSync", "readFileSync", "realpathSync", "defaultConfiguration", "rewritesHook", "StateModel", "configuration", "defaultConfiguration", "sources", "archive", "join", "relative", "resolve", "sep", "existsSync", "current", "latest", "versions", "others", "entry", "readdirSync", "posix", "name", "path", "a", "b", "folder", "version", "message", "xterm", "userLocales", "keys", "rootKey", "key", "lang", "link", "prefix", "getLanguageOnly", "taken", "other", "otherFolder", "isAbsolute", "mkdirSync", "writeFileSync", "result", "exclude", "themeConfig", "prop", "__name", "__decorateClass", "Injectable", "forceInject", "join", "inject", "inject", "versionSwitcher", "themeConfig", "versions", "latest", "labels", "text", "includeCurrentVersion", "item", "__name", "version", "label", "items", "parseVersioningData", "vitepressConfig", "routesMap", "versionsList", "localeSegments", "inject", "StateModel", "versioning", "isNavItemWithChildren", "item", "__name", "isNavItemWithLink", "replaceLinksRecursive", "version", "versions", "child", "pathname", "join", "populateNav", "items", "normalizeNav", "results", "nav", "prefix", "root", "index", "key", "normalizeNavs", "state", "locales", "localesKeys", "globalResults", "switcher", "versionSwitcher", "locale", "getNavForLocale", "navs", "baseLocale", "parseNavs", "inject", "StateModel", "rootLocales", "join", "inject", "safeJoin", "args", "joined", "join", "__name", "populateSidebar", "sidebar", "version", "normalizedVersion", "item", "extractLocale", "segments", "localesList", "versionsList", "lang", "normalizeSidebar", "state", "results", "prefix", "normalizedPrefix", "index", "key", "items", "parent", "parentIndex", "itemsArray", "normalizeSidebars", "vitepressConfig", "locales", "themeConfig", "normalizedSidebar", "localeKey", "locale", "parseSidebars", "inject", "StateModel", "sidebars", "join", "inject", "readFileSync", "writeFileSync", "openLatestPage", "data", "pathname", "segments", "locale", "page", "prefix", "route", "candidate", "path", "__name", "latestScript", "latest", "localeSegments", "versionsList", "routesMap", "vitepressConfig", "inject", "StateModel", "base", "cleanUrls", "trimmed", "json", "parseLatestEntry", "buildEnd", "vite", "script", "withScript", "html", "plugin", "siteConfig", "write", "from", "to", "flag", "writeFileSync", "readFileSync", "error", "join", "notFound", "inject", "versionLink", "href", "version", "versions", "locales", "pathname", "segments", "index", "prefix", "__name", "versionFrontmatterLinks", "value", "record", "key", "item", "parseVersionLinks", "state", "inject", "StateModel", "versionsList", "localeSegments", "config", "markdown", "transformPageData", "versionOf", "page", "segment", "pageData", "context", "md", "env", "tokens", "token", "block", "defineVersionedConfig", "userConfiguration", "config", "deepMerge", "defaultConfiguration", "state", "forceInject", "StateModel", "parseLocale", "parseRoutesComponent", "parseVersioningData", "parseVersionLinks", "parseLatestEntry", "parseNavs", "parseSidebars", "__name"]
|
|
8
8
|
}
|