@i18n-micro/vitepress 1.1.0 → 1.1.6
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/dist/adapter-CAJNI6Sw.js +127 -0
- package/dist/adapter-CAJNI6Sw.js.map +1 -0
- package/dist/adapter-eYZZOC9d.cjs +2 -0
- package/dist/adapter-eYZZOC9d.cjs.map +1 -0
- package/dist/config.cjs +13 -19
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +329 -336
- package/dist/config.mjs.map +1 -1
- package/dist/create-C_dXg23X.js +81 -0
- package/dist/create-C_dXg23X.js.map +1 -0
- package/dist/create-Cwu2djcO.cjs +2 -0
- package/dist/create-Cwu2djcO.cjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -31
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +2 -2
- package/dist/node.cjs.map +1 -1
- package/dist/node.mjs +22 -25
- package/dist/node.mjs.map +1 -1
- package/dist/theme.cjs +2 -2
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.mjs +35 -34
- package/dist/theme.mjs.map +1 -1
- package/dist/vitepress-locales-CwOlvAa0.cjs +2 -0
- package/dist/vitepress-locales-CwOlvAa0.cjs.map +1 -0
- package/dist/vitepress-locales-DOhKs3q5.js +27 -0
- package/dist/vitepress-locales-DOhKs3q5.js.map +1 -0
- package/package.json +14 -14
- package/dist/adapter-BJ-0ltIc.cjs +0 -2
- package/dist/adapter-BJ-0ltIc.cjs.map +0 -1
- package/dist/adapter-BnsyIKhp.js +0 -128
- package/dist/adapter-BnsyIKhp.js.map +0 -1
- package/dist/create-BgMbe0w1.cjs +0 -2
- package/dist/create-BgMbe0w1.cjs.map +0 -1
- package/dist/create-Dev8Q66O.js +0 -80
- package/dist/create-Dev8Q66O.js.map +0 -1
- package/dist/vitepress-locales-6msv22Sn.js +0 -27
- package/dist/vitepress-locales-6msv22Sn.js.map +0 -1
- package/dist/vitepress-locales-Cz4AutfI.cjs +0 -2
- package/dist/vitepress-locales-Cz4AutfI.cjs.map +0 -1
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../src/router/i18n-routing.ts","../src/seo/locale-head.ts","../src/plugin/load-messages.ts","../src/plugin/with-i18n.ts"],"sourcesContent":["import type { VitePressRouterAdapter } from './adapter'\n\n/**\n * Minimal shapes used by VitePress `themeConfig.i18nRouting`.\n * Kept loose so we do not hard-depend on VitePress internal DefaultTheme types at compile time.\n */\nexport interface VitePressI18nRoutingData {\n site?: {\n value?: {\n locales?: Record<string, { link?: string; lang?: string }>\n }\n }\n localeIndex?: { value?: string }\n}\n\nexport interface VitePressI18nRoutingRoute {\n path: string\n hash?: string\n query?: string\n data?: {\n relativePath?: string\n }\n}\n\nexport type VitePressI18nRoutingFn = (data: VitePressI18nRoutingData, route: VitePressI18nRoutingRoute, targetLocale: string) => string\n\nexport interface I18nRoutingFromAdapterOptions {\n defaultLocale: string\n localeCodes: string[]\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Stripped from `route.path` before rewriting locale;\n * result is base-relative (VitePress applies `withBase`).\n */\n base?: string\n}\n\nfunction isAdapter(value: VitePressRouterAdapter | I18nRoutingFromAdapterOptions): value is VitePressRouterAdapter {\n return 'switchLocalePath' in value && typeof (value as VitePressRouterAdapter).switchLocalePath === 'function'\n}\n\n/**\n * Bridge so VitePress navbar language menu and `<I18nSwitcher>` share path logic.\n * Pass the result to `themeConfig.i18nRouting`.\n *\n * `targetLocale` is a **VitePress locale key** (`root` / `fr`). URL prefixes use that key;\n * `localeKeyToCode` is only for resolving the i18n code when callers need it elsewhere.\n *\n * Returns a **self-contained** function (no closures) so VitePress can serialize it\n * into site data via `Function#toString()` + `new Function`.\n */\nexport function createI18nRoutingFromAdapter(adapterOrOptions: VitePressRouterAdapter | I18nRoutingFromAdapterOptions): VitePressI18nRoutingFn {\n const options: I18nRoutingFromAdapterOptions = isAdapter(adapterOrOptions)\n ? {\n defaultLocale: adapterOrOptions.defaultLocale,\n localeCodes: adapterOrOptions.localeCodes,\n localeKeyToCode: adapterOrOptions.localeKeyToCode ?? {},\n base: adapterOrOptions.base,\n }\n : adapterOrOptions\n\n const defaultLocale = options.defaultLocale\n const localeCodes = options.localeCodes\n const localeKeyToCode = options.localeKeyToCode ?? {}\n const base = options.base && options.base !== '/' ? options.base : ''\n\n // Inlined constants — required for VitePress themeConfig function serialization.\n // oxlint-disable-next-line typescript/no-implied-eval -- intentional for VP serializeFunctions\n return new Function(\n 'data',\n 'route',\n 'targetLocale',\n `\n const defaultLocale = ${JSON.stringify(defaultLocale)};\n const localeCodes = ${JSON.stringify(localeCodes)};\n const localeKeyToCode = ${JSON.stringify(localeKeyToCode)};\n const siteBase = ${JSON.stringify(base)};\n const keyFromCode = (code) => {\n for (const key of Object.keys(localeKeyToCode)) {\n if (localeKeyToCode[key] === code) return key;\n }\n return code === defaultLocale ? 'root' : code;\n };\n const prefixes = [];\n for (let i = 0; i < localeCodes.length; i++) {\n const code = localeCodes[i];\n if (code === defaultLocale) continue;\n const key = keyFromCode(code);\n const urlKey = key === 'root' ? code : key;\n prefixes.push(urlKey);\n if (urlKey !== code) prefixes.push(code);\n }\n // VitePress passes locale *keys* (root / fr). URL prefix is the key, not the i18n code.\n const urlPrefix = targetLocale === 'root' ? null : targetLocale;\n let path = (route && route.path) || '/';\n const hash = (route && route.hash) || '';\n const query = (route && route.query) || '';\n const hashIndex = path.indexOf('#');\n const queryIndex = path.indexOf('?');\n let cut = path.length;\n if (hashIndex >= 0) cut = Math.min(cut, hashIndex);\n if (queryIndex >= 0) cut = Math.min(cut, queryIndex);\n let pathname = path.slice(0, cut) || '/';\n const extras = path.slice(cut);\n if (siteBase) {\n const b = siteBase.endsWith('/') ? siteBase.slice(0, -1) : siteBase;\n if (pathname === b) pathname = '/';\n else if (pathname.indexOf(b + '/') === 0) pathname = pathname.slice(b.length) || '/';\n }\n const hadTrailingSlash = pathname === '/' || pathname.endsWith('/');\n const segments = pathname.split('/').filter(Boolean);\n if (segments[0] && prefixes.indexOf(segments[0]) >= 0) segments.shift();\n if (urlPrefix) segments.unshift(urlPrefix);\n let localized = segments.length === 0 ? '/' : '/' + segments.join('/');\n if (localized !== '/' && hadTrailingSlash) localized += '/';\n const q = extras.indexOf('?') >= 0\n ? ''\n : (query ? (query.charAt(0) === '?' ? query : '?' + query) : '');\n const h = hash\n ? (hash.charAt(0) === '#' ? hash : '#' + hash)\n : '';\n return localized + extras + q + h;\n `,\n ) as VitePressI18nRoutingFn\n}\n","import type { Locale } from '@i18n-micro/types'\nimport { resolveHreflangAlternates } from '@i18n-micro/utils/resolve-hreflang'\nimport { resolveOgLocale, warnUnresolvedOgLocale } from '@i18n-micro/utils/resolve-og-locale'\nimport { createI18nRoutingFromAdapter } from '../router/i18n-routing'\nimport { getLocaleFromPath, stripSiteBase } from '../router/adapter'\n\n/** VitePress `HeadConfig` tuple (tag + attrs). */\nexport type VitePressHeadTuple = [string, Record<string, string>]\n\nexport interface VitePressLocaleHeadObject {\n htmlAttrs: {\n lang?: string\n dir?: 'ltr' | 'rtl' | 'auto'\n }\n /** Ready for `transformHead` / `frontmatter.head`. */\n head: VitePressHeadTuple[]\n}\n\nexport interface BuildVitePressLocaleHeadOptions {\n /**\n * Current page path (with or without `site.base`). Query/hash optional.\n * Example: `/docs/fr/guide/` or `/fr/guide`.\n */\n path: string\n locales: Locale[]\n defaultLocale: string\n localeKeyToCode?: Record<string, string>\n /** VitePress `site.base` (e.g. `/docs/`). */\n base?: string\n /**\n * Public site origin **without** trailing slash (e.g. `https://example.com`).\n * Required for absolute `canonical` / `hreflang` / `og:url`.\n * When omitted, only `htmlAttrs` are produced.\n */\n metaBaseUrl?: string\n /** @default false — same as Nuxt / Vue `useLocaleHead`. */\n hreflangBaseLanguage?: boolean\n /** Query keys kept on canonical / alternate URLs. @default [] */\n canonicalQueryWhitelist?: string[]\n /** @default true */\n addDirAttribute?: boolean\n /** @default true */\n addSeoAttributes?: boolean\n /** @default 'id' */\n identifierAttribute?: string\n missingWarn?: boolean\n}\n\nfunction filterQuery(fullPath: string, whitelist: string[]): string {\n const hashIndex = fullPath.indexOf('#')\n const queryIndex = fullPath.indexOf('?')\n let cut = fullPath.length\n if (hashIndex >= 0) cut = Math.min(cut, hashIndex)\n if (queryIndex >= 0) cut = Math.min(cut, queryIndex)\n const pathname = fullPath.slice(0, cut) || '/'\n if (queryIndex < 0 || whitelist.length === 0) return pathname\n\n const params = new URLSearchParams(fullPath.slice(queryIndex, hashIndex >= 0 ? hashIndex : undefined))\n const filtered = new URLSearchParams()\n for (const key of whitelist) {\n if (params.has(key)) filtered.set(key, params.get(key)!)\n }\n const q = filtered.toString()\n return q ? `${pathname}?${q}` : pathname\n}\n\nfunction joinAbsolute(metaBaseUrl: string, siteBase: string | undefined, path: string): string {\n const origin = metaBaseUrl.replace(/\\/$/, '')\n const base = !siteBase || siteBase === '/' ? '' : siteBase.replace(/\\/$/, '')\n const p = path.startsWith('/') ? path : `/${path}`\n return `${origin}${base}${p}`\n}\n\n/**\n * Convert VitePress `pageData.relativePath` to a route path (cleanUrls-style).\n */\nexport function relativePathToRoutePath(relativePath: string): string {\n let path = relativePath.replace(/\\\\/g, '/')\n path = path.replace(/(^|\\/)index\\.md$/, '$1').replace(/\\.md$/, '')\n if (!path.startsWith('/')) path = `/${path}`\n if (path.length > 1 && path.endsWith('/')) path = path.slice(0, -1)\n return path || '/'\n}\n\n/**\n * Build i18n SEO head for VitePress — same tags as Nuxt `useLocaleHead` /\n * plugin `02.meta` (canonical, hreflang, x-default, og:locale / og:url / alternates).\n *\n * Framework-agnostic pure function; wired automatically by `withI18n` when `meta` is on.\n */\nexport function buildVitePressLocaleHead(options: BuildVitePressLocaleHeadOptions): VitePressLocaleHeadObject {\n const {\n locales,\n defaultLocale,\n localeKeyToCode = {},\n base,\n metaBaseUrl,\n hreflangBaseLanguage = false,\n canonicalQueryWhitelist = [],\n addDirAttribute = true,\n addSeoAttributes = true,\n identifierAttribute = 'id',\n missingWarn = true,\n } = options\n\n const path = stripSiteBase(options.path, base)\n const locale = getLocaleFromPath(\n path,\n locales.map((l) => l.code),\n defaultLocale,\n localeKeyToCode,\n undefined,\n )\n const currentLocale = locales.find((l) => l.code === locale)\n if (!currentLocale) {\n return { htmlAttrs: {}, head: [] }\n }\n\n const currentIso = currentLocale.iso || locale\n const currentDir = (currentLocale.dir || 'auto') as 'ltr' | 'rtl' | 'auto'\n const htmlAttrs: VitePressLocaleHeadObject['htmlAttrs'] = {\n lang: currentIso,\n ...(addDirAttribute ? { dir: currentDir } : {}),\n }\n\n if (!addSeoAttributes || !metaBaseUrl) {\n return { htmlAttrs, head: [] }\n }\n\n const switchLocalePath = createI18nRoutingFromAdapter({\n defaultLocale,\n localeCodes: locales.map((l) => l.code),\n localeKeyToCode,\n base,\n })\n\n const filteredPath = filterQuery(path, canonicalQueryWhitelist)\n // VitePress locale keys for i18nRouting: root vs code\n const currentVpKey =\n locale === defaultLocale\n ? 'root'\n : (() => {\n for (const [key, code] of Object.entries(localeKeyToCode)) {\n if (code === locale) return key === 'root' ? 'root' : key\n }\n return locale\n })()\n const canonicalPath = switchLocalePath({}, { path: filteredPath }, currentVpKey)\n const ogUrl = joinAbsolute(metaBaseUrl, base, canonicalPath)\n\n const localesForSeo = locales.filter((loc) => !loc.disabled && loc.seo !== false)\n const currentOg = resolveOgLocale(currentLocale)\n if (!currentOg) {\n warnUnresolvedOgLocale(currentLocale, { missingWarn, tag: 'og:locale' })\n }\n\n const head: VitePressHeadTuple[] = []\n\n head.push(['link', { [identifierAttribute]: 'i18n-can', rel: 'canonical', href: ogUrl }])\n\n if (currentOg) {\n head.push(['meta', { [identifierAttribute]: 'i18n-og', property: 'og:locale', content: currentOg }])\n }\n head.push(['meta', { [identifierAttribute]: 'i18n-og-url', property: 'og:url', content: ogUrl }])\n\n for (const loc of localesForSeo) {\n if (loc.code === locale) continue\n const ogAlt = resolveOgLocale(loc)\n if (!ogAlt) {\n warnUnresolvedOgLocale(loc, { missingWarn, tag: 'og:locale:alternate' })\n continue\n }\n head.push(['meta', { [identifierAttribute]: `i18n-og-alt-${ogAlt}`, property: 'og:locale:alternate', content: ogAlt }])\n }\n\n const hrefByCode = new Map<string, string>()\n for (const loc of localesForSeo) {\n const vpKey =\n loc.code === defaultLocale\n ? 'root'\n : (() => {\n for (const [key, code] of Object.entries(localeKeyToCode)) {\n if (code === loc.code) return key === 'root' ? loc.code : key\n }\n return loc.code\n })()\n const switched = switchLocalePath({}, { path: filteredPath }, vpKey)\n if (!switched) continue\n hrefByCode.set(String(loc.code), joinAbsolute(metaBaseUrl, base, switched))\n }\n\n for (const { hreflang, localeCode } of resolveHreflangAlternates(localesForSeo, { hreflangBaseLanguage })) {\n const href = hrefByCode.get(localeCode)\n if (!href) continue\n head.push(['link', { [identifierAttribute]: `i18n-alternate-${hreflang}`, rel: 'alternate', href, hreflang }])\n }\n\n const defaultLocaleObj = locales.find((l) => l.code === defaultLocale)\n if (defaultLocaleObj && defaultLocaleObj.seo !== false) {\n const xHref = hrefByCode.get(defaultLocale)\n if (xHref) {\n head.push(['link', { [identifierAttribute]: 'i18n-xd', rel: 'alternate', href: xHref, hreflang: 'x-default' }])\n }\n }\n\n return { htmlAttrs, head }\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { Translations } from '@i18n-micro/types'\nimport { storeLoadedTranslationFile, type TranslationFileBuckets } from '@i18n-micro/utils/parse-path'\n\n/** Sync FS walk for the Vite plugin — prefer `@i18n-micro/node` in scripts. */\nexport interface LoadMessagesOptions {\n translationDir: string\n rootDir?: string\n disablePageLocales?: boolean\n}\n\nexport type LoadedTranslations = TranslationFileBuckets<Translations>\n\nexport interface TranslationFileRef {\n relativePath: string\n absolutePath: string\n}\n\nfunction walkTranslationFiles(dir: string, onFile: (fullPath: string) => void): void {\n if (!existsSync(dir)) return\n\n for (const entry of readdirSync(dir)) {\n const fullPath = join(dir, entry)\n const stat = statSync(fullPath)\n if (stat.isDirectory()) {\n walkTranslationFiles(fullPath, onFile)\n continue\n }\n if (entry.endsWith('.json')) onFile(fullPath)\n }\n}\n\nexport function listTranslationFiles(options: LoadMessagesOptions): TranslationFileRef[] {\n const rootDir = options.rootDir ?? process.cwd()\n const dir = resolve(rootDir, options.translationDir)\n const files: TranslationFileRef[] = []\n\n walkTranslationFiles(dir, (fullPath) => {\n files.push({\n absolutePath: fullPath,\n relativePath: relative(dir, fullPath).split(sep).join('/'),\n })\n })\n\n return files.sort((a, b) => a.relativePath.localeCompare(b.relativePath))\n}\n\nexport function loadTranslationBuckets(options: LoadMessagesOptions): LoadedTranslations {\n const rootDir = options.rootDir ?? process.cwd()\n const dir = resolve(rootDir, options.translationDir)\n const buckets: LoadedTranslations = { root: {}, routes: {} }\n const disablePageLocales = options.disablePageLocales === true\n\n if (!existsSync(dir)) return buckets\n\n walkTranslationFiles(dir, (fullPath) => {\n const relativePath = relative(dir, fullPath).split(sep).join('/')\n try {\n const parsed: unknown = JSON.parse(readFileSync(fullPath, 'utf-8'))\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n console.error(\n `[i18n-micro/vitepress] Skipping ${relativePath}: expected a JSON object, got ${Array.isArray(parsed) ? 'array' : typeof parsed}`,\n )\n return\n }\n storeLoadedTranslationFile(buckets, relativePath, parsed as Translations, disablePageLocales)\n } catch (error) {\n console.error(`[i18n-micro/vitepress] Failed to load ${relativePath}:`, error)\n }\n })\n\n return buckets\n}\n","import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { Locale, Translations } from '@i18n-micro/types'\nimport { classifyTranslationRelativePath } from '@i18n-micro/utils/parse-path'\nimport type { Plugin } from 'vite'\nimport type { CreateI18nOptions } from '../runtime/create'\nimport { buildVitePressLocaleHead, relativePathToRoutePath } from '../seo/locale-head'\nimport { listTranslationFiles, loadTranslationBuckets } from './load-messages'\nimport { createI18nRoutingFromAdapter } from '../router/i18n-routing'\n\nexport interface WithI18nOptions extends CreateI18nOptions {\n /**\n * Directory with locale JSON (`en.json`, `pages/guide/demo/en.json`, …), relative to Vite root\n * (VitePress content / docs root). Used by `virtual:i18n-micro/messages`.\n * @default 'locales'\n */\n translationDir?: string\n /**\n * When true, treat `pages/**` as root-level dictionaries.\n * @default false\n */\n disablePageLocales?: boolean\n /**\n * When true, logs a warning if VitePress `locales` keys do not align with\n * configured i18n locale codes.\n * @default true\n */\n warnOnLocaleMismatch?: boolean\n /**\n * Inject `themeConfig.i18nRouting` from adapter options + `config.base`.\n * Set `false` to skip. Skipped automatically when `themeConfig.i18nRouting` is already set.\n * @default true\n */\n i18nRouting?: boolean\n /**\n * Emit i18n SEO tags via `transformHead` (canonical, hreflang, og:locale…) —\n * Nuxt `meta` / plugin `02.meta` analogue.\n * Absolute link tags require `metaBaseUrl`.\n * @default true when `metaBaseUrl` is set, otherwise false\n */\n meta?: boolean\n /**\n * Public origin without trailing slash (`https://example.com`).\n * Same role as Nuxt `metaBaseUrl`.\n */\n metaBaseUrl?: string\n /** Also emit bare-language hreflang from `iso` (Nuxt `hreflangBaseLanguage`). @default false */\n hreflangBaseLanguage?: boolean\n /** Query keys kept on canonical / alternate URLs. @default [] */\n canonicalQueryWhitelist?: string[]\n}\n\n/**\n * Minimal VitePress / Vite user config shape we merge into.\n * Avoid importing `vitepress` types so the package stays usable as a pure library dep.\n */\nexport interface VitePressUserConfigLike {\n base?: string\n locales?: Record<string, unknown>\n themeConfig?: Record<string, unknown> | null\n transformHead?: (...args: any[]) => any\n transformPageData?: (...args: any[]) => any\n vite?: {\n plugins?: Plugin[] | Plugin[][]\n ssr?: {\n noExternal?: string | true | Array<string | RegExp>\n [key: string]: unknown\n }\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\nexport interface VirtualI18nConfig {\n defaultLocale: string\n fallbackLocale: string\n locales: Locale[]\n localeCodes: string[]\n missingWarn: boolean\n syncWithVitePress: boolean\n translationDir: string\n disablePageLocales: boolean\n localeKeyToCode: Record<string, string>\n /** VitePress `site.base` (normalized, trailing slash preserved from config). */\n base?: string\n}\n\nconst VIRTUAL_CONFIG_ID = 'virtual:i18n-micro/config'\nconst RESOLVED_CONFIG_ID = `\\0${VIRTUAL_CONFIG_ID}`\nconst VIRTUAL_MESSAGES_ID = 'virtual:i18n-micro/messages'\nconst RESOLVED_MESSAGES_ID = `\\0${VIRTUAL_MESSAGES_ID}`\n\nfunction toPosix(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nfunction generateImportMessagesModule(rootDir: string, translationDir: string, disablePageLocales: boolean): string {\n const files = listTranslationFiles({ rootDir, translationDir })\n if (files.length === 0) {\n return 'export const messages = {}\\nexport const routeMessages = {}\\n'\n }\n\n const imports: string[] = []\n const rootEntries: string[] = []\n const routeVarNames = new Map<string, Map<string, string>>()\n let i = 0\n\n for (const file of files) {\n const parsed = classifyTranslationRelativePath(file.relativePath, disablePageLocales)\n if (parsed.type === 'ignore') continue\n\n const varName = `__i18n_${i++}`\n imports.push(`import ${varName} from ${JSON.stringify(toPosix(file.absolutePath))}`)\n\n if (parsed.type === 'root') {\n rootEntries.push(` ${JSON.stringify(parsed.locale)}: ${varName}`)\n continue\n }\n\n let byLocale = routeVarNames.get(parsed.pageName)\n if (!byLocale) {\n byLocale = new Map()\n routeVarNames.set(parsed.pageName, byLocale)\n }\n byLocale.set(parsed.locale, varName)\n }\n\n const routeEntries: string[] = []\n for (const [routeName, byLocale] of routeVarNames) {\n const localeEntries = [...byLocale.entries()].map(([locale, varName]) => ` ${JSON.stringify(locale)}: ${varName}`).join(',\\n')\n routeEntries.push(` ${JSON.stringify(routeName)}: {\\n${localeEntries}\\n }`)\n }\n\n return [\n ...imports,\n `export const messages = {\\n${rootEntries.join(',\\n')}\\n}`,\n `export const routeMessages = {\\n${routeEntries.join(',\\n')}\\n}`,\n '',\n ].join('\\n')\n}\n\nfunction generateInlineMessagesModule(messages: Record<string, Translations>, routeMessages: Record<string, Record<string, Translations>>): string {\n return [`export const messages = ${JSON.stringify(messages)}`, `export const routeMessages = ${JSON.stringify(routeMessages)}`, ''].join('\\n')\n}\n\nfunction createI18nVitePlugin(options: WithI18nOptions, siteBase?: string): Plugin {\n const defaultLocale = options.defaultLocale || options.locale\n const translationDir = options.translationDir ?? 'locales'\n const disablePageLocales = options.disablePageLocales === true\n const configData: VirtualI18nConfig = {\n defaultLocale,\n fallbackLocale: options.fallbackLocale || defaultLocale,\n locales: options.locales || [],\n localeCodes: (options.locales || []).map((l) => l.code),\n missingWarn: options.missingWarn ?? true,\n syncWithVitePress: options.syncWithVitePress !== false,\n translationDir,\n disablePageLocales,\n localeKeyToCode: options.localeKeyToCode ?? {},\n base: siteBase && siteBase !== '/' ? siteBase : undefined,\n }\n\n let rootDir = process.cwd()\n let useInline = Boolean(options.messages || options.routeMessages)\n let inlineRoot = options.messages ?? {}\n let inlineRoutes = options.routeMessages ?? {}\n let debounceTimer: ReturnType<typeof setTimeout> | undefined\n const needsDiskReload = () => !options.messages || !options.routeMessages\n\n const reloadInlineFromDisk = () => {\n // Fully inline config: skip disk I/O (and avoid spurious JSON parse errors).\n if (!needsDiskReload()) return\n const loaded = loadTranslationBuckets({\n rootDir,\n translationDir,\n disablePageLocales,\n })\n if (!options.messages) {\n inlineRoot = loaded.root\n }\n if (!options.routeMessages) {\n inlineRoutes = loaded.routes\n }\n }\n\n return {\n name: 'vite-plugin-i18n-vitepress',\n configResolved(config) {\n rootDir = config.root\n // Inline when caller passed messages and/or routeMessages.\n // routeMessages alone still loads root dictionaries from translationDir.\n useInline = Boolean(options.messages || options.routeMessages)\n if (useInline) {\n if (options.messages) inlineRoot = options.messages\n if (options.routeMessages) inlineRoutes = options.routeMessages\n if (needsDiskReload()) {\n reloadInlineFromDisk()\n }\n if (options.messages) inlineRoot = options.messages\n if (options.routeMessages) inlineRoutes = options.routeMessages\n }\n },\n configureServer(server) {\n // Both maps provided inline — nothing to watch on disk.\n if (useInline && !needsDiskReload()) return\n\n const dir = resolve(rootDir, translationDir)\n if (!existsSync(dir)) return\n\n server.watcher.add(dir)\n\n const invalidate = () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n if (useInline) reloadInlineFromDisk()\n const mod = server.moduleGraph.getModuleById(RESOLVED_MESSAGES_ID)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n server.ws.send({ type: 'full-reload' })\n }\n }, 50)\n }\n\n // add/unlink need virtual module regen; change is usually handled by JSON import HMR,\n // but we still invalidate when using inline payload that still reads disk.\n server.watcher.on('add', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n if (useInline && needsDiskReload()) {\n server.watcher.on('change', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n }\n },\n resolveId(id) {\n if (id === VIRTUAL_CONFIG_ID) return RESOLVED_CONFIG_ID\n if (id === VIRTUAL_MESSAGES_ID) return RESOLVED_MESSAGES_ID\n },\n load(id) {\n if (id === RESOLVED_CONFIG_ID) {\n return `export const config = ${JSON.stringify(configData)}`\n }\n if (id === RESOLVED_MESSAGES_ID) {\n if (useInline) {\n return generateInlineMessagesModule(inlineRoot, inlineRoutes)\n }\n return generateImportMessagesModule(rootDir, translationDir, disablePageLocales)\n }\n },\n }\n}\n\nexport function warnLocaleMismatch(config: VitePressUserConfigLike, options: WithI18nOptions): void {\n if (options.warnOnLocaleMismatch === false) return\n const vpLocales = config.locales\n if (!vpLocales || !options.locales?.length) return\n\n const defaultLocale = options.defaultLocale || options.locale\n const vpKeys = Object.keys(vpLocales)\n const codes = new Set(options.locales.map((l) => l.code))\n\n for (const key of vpKeys) {\n const expectedCode = key === 'root' ? defaultLocale : (options.localeKeyToCode?.[key] ?? key)\n if (!codes.has(expectedCode)) {\n console.warn(\n `[i18n-micro/vitepress] VitePress locale key \"${key}\" maps to \"${expectedCode}\", ` +\n `which is not in i18n locales (${[...codes].join(', ')}).`,\n )\n }\n }\n}\n\n/**\n * VitePress config helper: virtual modules + optional `i18nRouting` / SEO head.\n *\n * Registers:\n * - `virtual:i18n-micro/config`\n * - `virtual:i18n-micro/messages` (from `translationDir`, default `locales/`)\n *\n * By default also sets `themeConfig.i18nRouting` (pass `i18nRouting: false` to skip).\n * Pair with `defineI18nTheme(DefaultTheme)` from `@i18n-micro/vitepress/theme`.\n * Import from `@i18n-micro/vitepress/config` (Node / config files only).\n */\nexport function withI18n<T extends VitePressUserConfigLike>(config: T, options: WithI18nOptions): T {\n warnLocaleMismatch(config, options)\n\n const siteBase = typeof config.base === 'string' ? config.base : undefined\n const existingPlugins = config.vite?.plugins\n const plugins = [...(Array.isArray(existingPlugins) ? existingPlugins.flat() : []), createI18nVitePlugin(options, siteBase)]\n\n const prevSsr = config.vite?.ssr\n const prevNoExternal = prevSsr?.noExternal\n const noExternalList = [\n '@i18n-micro/vitepress',\n ...(Array.isArray(prevNoExternal) ? prevNoExternal : prevNoExternal && prevNoExternal !== true ? [prevNoExternal] : []),\n ]\n\n const defaultLocale = options.defaultLocale || options.locale\n const localeCodes = (options.locales || []).map((l) => l.code)\n const prevTheme = (config.themeConfig && typeof config.themeConfig === 'object' ? config.themeConfig : {}) as Record<string, unknown>\n const shouldInjectRouting = options.i18nRouting !== false && prevTheme.i18nRouting === undefined && localeCodes.length > 0\n\n const metaEnabled = options.meta ?? Boolean(options.metaBaseUrl)\n const locales = options.locales || []\n const prevTransformHead = config.transformHead\n const prevTransformPageData = config.transformPageData\n\n const transformHead = metaEnabled\n ? async (ctx: {\n pageData?: { relativePath?: string; frontmatter?: { i18n?: { disableMeta?: boolean } } }\n siteConfig?: { site?: { base?: string } }\n siteData?: { base?: string }\n }) => {\n const prev = typeof prevTransformHead === 'function' ? await prevTransformHead(ctx) : []\n const prevHead = Array.isArray(prev) ? prev : []\n if (ctx.pageData?.frontmatter?.i18n?.disableMeta === true) return prevHead\n\n const relativePath = ctx.pageData?.relativePath || 'index.md'\n const siteBase = (typeof config.base === 'string' ? config.base : undefined) ?? ctx.siteData?.base ?? ctx.siteConfig?.site?.base\n const built = buildVitePressLocaleHead({\n path: relativePathToRoutePath(relativePath),\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: siteBase,\n metaBaseUrl: options.metaBaseUrl,\n hreflangBaseLanguage: options.hreflangBaseLanguage,\n canonicalQueryWhitelist: options.canonicalQueryWhitelist,\n missingWarn: options.missingWarn,\n })\n return [...prevHead, ...built.head]\n }\n : prevTransformHead\n\n const transformPageData = metaEnabled\n ? async (\n pageData: {\n relativePath?: string\n frontmatter?: Record<string, unknown> & { i18n?: { disableMeta?: boolean } }\n },\n ctx?: unknown,\n ) => {\n if (typeof prevTransformPageData === 'function') {\n await prevTransformPageData(pageData, ctx)\n }\n if (pageData.frontmatter?.i18n?.disableMeta === true) return\n\n const built = buildVitePressLocaleHead({\n path: relativePathToRoutePath(pageData.relativePath || 'index.md'),\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: typeof config.base === 'string' ? config.base : undefined,\n metaBaseUrl: options.metaBaseUrl,\n hreflangBaseLanguage: options.hreflangBaseLanguage,\n canonicalQueryWhitelist: options.canonicalQueryWhitelist,\n missingWarn: options.missingWarn,\n addSeoAttributes: false,\n })\n if (built.htmlAttrs.lang) {\n pageData.frontmatter ??= {}\n // VitePress uses frontmatter for per-page lang when set\n if (!pageData.frontmatter.lang) {\n pageData.frontmatter.lang = built.htmlAttrs.lang\n }\n }\n }\n : prevTransformPageData\n\n return {\n ...config,\n ...(shouldInjectRouting\n ? {\n themeConfig: {\n ...prevTheme,\n i18nRouting: createI18nRoutingFromAdapter({\n defaultLocale,\n localeCodes,\n localeKeyToCode: options.localeKeyToCode,\n base: siteBase,\n }),\n },\n }\n : {}),\n ...(metaEnabled\n ? {\n transformHead,\n transformPageData,\n }\n : {}),\n vite: {\n ...config.vite,\n plugins,\n // Theme entry statically imports `virtual:i18n-micro/*`; Vite must bundle\n // the package during SSG so those IDs resolve (not left as bare Node imports).\n ssr: {\n ...prevSsr,\n noExternal: prevNoExternal === true ? true : noExternalList,\n },\n },\n }\n}\n"],"names":["isAdapter","value","createI18nRoutingFromAdapter","adapterOrOptions","options","defaultLocale","localeCodes","localeKeyToCode","base","filterQuery","fullPath","whitelist","hashIndex","queryIndex","cut","pathname","params","filtered","key","q","joinAbsolute","metaBaseUrl","siteBase","path","origin","p","relativePathToRoutePath","relativePath","buildVitePressLocaleHead","locales","hreflangBaseLanguage","canonicalQueryWhitelist","addDirAttribute","addSeoAttributes","identifierAttribute","missingWarn","stripSiteBase","locale","getLocaleFromPath","l","currentLocale","currentIso","currentDir","htmlAttrs","switchLocalePath","filteredPath","currentVpKey","code","canonicalPath","ogUrl","localesForSeo","loc","currentOg","resolveOgLocale","warnUnresolvedOgLocale","head","ogAlt","hrefByCode","vpKey","switched","hreflang","localeCode","resolveHreflangAlternates","href","defaultLocaleObj","xHref","walkTranslationFiles","dir","onFile","existsSync","entry","readdirSync","join","statSync","listTranslationFiles","rootDir","resolve","files","relative","sep","a","b","loadTranslationBuckets","buckets","disablePageLocales","parsed","readFileSync","storeLoadedTranslationFile","error","VIRTUAL_CONFIG_ID","RESOLVED_CONFIG_ID","VIRTUAL_MESSAGES_ID","RESOLVED_MESSAGES_ID","toPosix","generateImportMessagesModule","translationDir","imports","rootEntries","routeVarNames","file","classifyTranslationRelativePath","varName","byLocale","routeEntries","routeName","localeEntries","generateInlineMessagesModule","messages","routeMessages","createI18nVitePlugin","configData","useInline","inlineRoot","inlineRoutes","debounceTimer","needsDiskReload","reloadInlineFromDisk","loaded","config","server","invalidate","mod","id","warnLocaleMismatch","vpLocales","vpKeys","codes","expectedCode","withI18n","existingPlugins","plugins","prevSsr","prevNoExternal","noExternalList","prevTheme","shouldInjectRouting","metaEnabled","prevTransformHead","prevTransformPageData","transformHead","ctx","prev","prevHead","built","transformPageData","pageData"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ing.ts","../src/seo/locale-head.ts","../src/plugin/load-messages.ts","../src/plugin/with-i18n.ts"],"sourcesContent":["import type { VitePressRouterAdapter } from './adapter'\n\n/**\n * Minimal shapes used by VitePress `themeConfig.i18nRouting`.\n * Kept loose so we do not hard-depend on VitePress internal DefaultTheme types at compile time.\n */\nexport interface VitePressI18nRoutingData {\n site?: {\n value?: {\n locales?: Record<string, { link?: string; lang?: string }>\n }\n }\n localeIndex?: { value?: string }\n}\n\nexport interface VitePressI18nRoutingRoute {\n path: string\n hash?: string\n query?: string\n data?: {\n relativePath?: string\n }\n}\n\nexport type VitePressI18nRoutingFn = (data: VitePressI18nRoutingData, route: VitePressI18nRoutingRoute, targetLocale: string) => string\n\nexport interface I18nRoutingFromAdapterOptions {\n defaultLocale: string\n localeCodes: string[]\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Stripped from `route.path` before rewriting locale;\n * result is base-relative (VitePress applies `withBase`).\n */\n base?: string\n}\n\nfunction isAdapter(value: VitePressRouterAdapter | I18nRoutingFromAdapterOptions): value is VitePressRouterAdapter {\n return 'switchLocalePath' in value && typeof (value as VitePressRouterAdapter).switchLocalePath === 'function'\n}\n\n/**\n * Bridge so VitePress navbar language menu and `<I18nSwitcher>` share path logic.\n * Pass the result to `themeConfig.i18nRouting`.\n *\n * `targetLocale` is a **VitePress locale key** (`root` / `fr`). URL prefixes use that key;\n * `localeKeyToCode` is only for resolving the i18n code when callers need it elsewhere.\n *\n * Returns a **self-contained** function (no closures) so VitePress can serialize it\n * into site data via `Function#toString()` + `new Function`.\n */\nexport function createI18nRoutingFromAdapter(adapterOrOptions: VitePressRouterAdapter | I18nRoutingFromAdapterOptions): VitePressI18nRoutingFn {\n const options: I18nRoutingFromAdapterOptions = isAdapter(adapterOrOptions)\n ? {\n defaultLocale: adapterOrOptions.defaultLocale,\n localeCodes: adapterOrOptions.localeCodes,\n localeKeyToCode: adapterOrOptions.localeKeyToCode ?? {},\n base: adapterOrOptions.base,\n }\n : adapterOrOptions\n\n const defaultLocale = options.defaultLocale\n const localeCodes = options.localeCodes\n const localeKeyToCode = options.localeKeyToCode ?? {}\n const base = options.base && options.base !== '/' ? options.base : ''\n\n // Inlined constants — required for VitePress themeConfig function serialization.\n // oxlint-disable-next-line typescript/no-implied-eval -- intentional for VP serializeFunctions\n return new Function(\n 'data',\n 'route',\n 'targetLocale',\n `\n const defaultLocale = ${JSON.stringify(defaultLocale)};\n const localeCodes = ${JSON.stringify(localeCodes)};\n const localeKeyToCode = ${JSON.stringify(localeKeyToCode)};\n const siteBase = ${JSON.stringify(base)};\n const keyFromCode = (code) => {\n for (const key of Object.keys(localeKeyToCode)) {\n if (localeKeyToCode[key] === code) return key;\n }\n return code === defaultLocale ? 'root' : code;\n };\n const prefixes = [];\n for (let i = 0; i < localeCodes.length; i++) {\n const code = localeCodes[i];\n if (code === defaultLocale) continue;\n const key = keyFromCode(code);\n const urlKey = key === 'root' ? code : key;\n prefixes.push(urlKey);\n if (urlKey !== code) prefixes.push(code);\n }\n // VitePress passes locale *keys* (root / fr). URL prefix is the key, not the i18n code.\n const urlPrefix = targetLocale === 'root' ? null : targetLocale;\n let path = (route && route.path) || '/';\n const hash = (route && route.hash) || '';\n const query = (route && route.query) || '';\n const hashIndex = path.indexOf('#');\n const queryIndex = path.indexOf('?');\n let cut = path.length;\n if (hashIndex >= 0) cut = Math.min(cut, hashIndex);\n if (queryIndex >= 0) cut = Math.min(cut, queryIndex);\n let pathname = path.slice(0, cut) || '/';\n const extras = path.slice(cut);\n if (siteBase) {\n const b = siteBase.endsWith('/') ? siteBase.slice(0, -1) : siteBase;\n if (pathname === b) pathname = '/';\n else if (pathname.indexOf(b + '/') === 0) pathname = pathname.slice(b.length) || '/';\n }\n const hadTrailingSlash = pathname === '/' || pathname.endsWith('/');\n const segments = pathname.split('/').filter(Boolean);\n if (segments[0] && prefixes.indexOf(segments[0]) >= 0) segments.shift();\n if (urlPrefix) segments.unshift(urlPrefix);\n let localized = segments.length === 0 ? '/' : '/' + segments.join('/');\n if (localized !== '/' && hadTrailingSlash) localized += '/';\n const q = extras.indexOf('?') >= 0\n ? ''\n : (query ? (query.charAt(0) === '?' ? query : '?' + query) : '');\n const h = hash\n ? (hash.charAt(0) === '#' ? hash : '#' + hash)\n : '';\n return localized + extras + q + h;\n `,\n ) as VitePressI18nRoutingFn\n}\n","import type { Locale } from '@i18n-micro/types'\nimport { resolveHreflangAlternates } from '@i18n-micro/utils/resolve-hreflang'\nimport { resolveOgLocale, warnUnresolvedOgLocale } from '@i18n-micro/utils/resolve-og-locale'\nimport { createI18nRoutingFromAdapter } from '../router/i18n-routing'\nimport { getLocaleFromPath, stripSiteBase } from '../router/adapter'\n\n/** VitePress `HeadConfig` tuple (tag + attrs). */\nexport type VitePressHeadTuple = [string, Record<string, string>]\n\nexport interface VitePressLocaleHeadObject {\n htmlAttrs: {\n lang?: string\n dir?: 'ltr' | 'rtl' | 'auto'\n }\n /** Ready for `transformHead` / `frontmatter.head`. */\n head: VitePressHeadTuple[]\n}\n\nexport interface BuildVitePressLocaleHeadOptions {\n /**\n * Current page path (with or without `site.base`). Query/hash optional.\n * Example: `/docs/fr/guide/` or `/fr/guide`.\n */\n path: string\n locales: Locale[]\n defaultLocale: string\n localeKeyToCode?: Record<string, string>\n /** VitePress `site.base` (e.g. `/docs/`). */\n base?: string\n /**\n * Public site origin **without** trailing slash (e.g. `https://example.com`).\n * Required for absolute `canonical` / `hreflang` / `og:url`.\n * When omitted, only `htmlAttrs` are produced.\n */\n metaBaseUrl?: string\n /** @default false — same as Nuxt / Vue `useLocaleHead`. */\n hreflangBaseLanguage?: boolean\n /** Query keys kept on canonical / alternate URLs. @default [] */\n canonicalQueryWhitelist?: string[]\n /** @default true */\n addDirAttribute?: boolean\n /** @default true */\n addSeoAttributes?: boolean\n /** @default 'id' */\n identifierAttribute?: string\n missingWarn?: boolean\n}\n\nfunction filterQuery(fullPath: string, whitelist: string[]): string {\n const hashIndex = fullPath.indexOf('#')\n const queryIndex = fullPath.indexOf('?')\n let cut = fullPath.length\n if (hashIndex >= 0) cut = Math.min(cut, hashIndex)\n if (queryIndex >= 0) cut = Math.min(cut, queryIndex)\n const pathname = fullPath.slice(0, cut) || '/'\n if (queryIndex < 0 || whitelist.length === 0) return pathname\n\n const params = new URLSearchParams(fullPath.slice(queryIndex, hashIndex >= 0 ? hashIndex : undefined))\n const filtered = new URLSearchParams()\n for (const key of whitelist) {\n if (params.has(key)) filtered.set(key, params.get(key)!)\n }\n const q = filtered.toString()\n return q ? `${pathname}?${q}` : pathname\n}\n\nfunction joinAbsolute(metaBaseUrl: string, siteBase: string | undefined, path: string): string {\n const origin = metaBaseUrl.replace(/\\/$/, '')\n const base = !siteBase || siteBase === '/' ? '' : siteBase.replace(/\\/$/, '')\n const p = path.startsWith('/') ? path : `/${path}`\n return `${origin}${base}${p}`\n}\n\n/**\n * Convert VitePress `pageData.relativePath` to a route path (cleanUrls-style).\n */\nexport function relativePathToRoutePath(relativePath: string): string {\n let path = relativePath.replace(/\\\\/g, '/')\n path = path.replace(/(^|\\/)index\\.md$/, '$1').replace(/\\.md$/, '')\n if (!path.startsWith('/')) path = `/${path}`\n if (path.length > 1 && path.endsWith('/')) path = path.slice(0, -1)\n return path || '/'\n}\n\n/**\n * Build i18n SEO head for VitePress — same tags as Nuxt `useLocaleHead` /\n * plugin `02.meta` (canonical, hreflang, x-default, og:locale / og:url / alternates).\n *\n * Framework-agnostic pure function; wired automatically by `withI18n` when `meta` is on.\n */\nexport function buildVitePressLocaleHead(options: BuildVitePressLocaleHeadOptions): VitePressLocaleHeadObject {\n const {\n locales,\n defaultLocale,\n localeKeyToCode = {},\n base,\n metaBaseUrl,\n hreflangBaseLanguage = false,\n canonicalQueryWhitelist = [],\n addDirAttribute = true,\n addSeoAttributes = true,\n identifierAttribute = 'id',\n missingWarn = true,\n } = options\n\n const path = stripSiteBase(options.path, base)\n const locale = getLocaleFromPath(\n path,\n locales.map((l) => l.code),\n defaultLocale,\n localeKeyToCode,\n undefined,\n )\n const currentLocale = locales.find((l) => l.code === locale)\n if (!currentLocale) {\n return { htmlAttrs: {}, head: [] }\n }\n\n const currentIso = currentLocale.iso || locale\n const currentDir = (currentLocale.dir || 'auto') as 'ltr' | 'rtl' | 'auto'\n const htmlAttrs: VitePressLocaleHeadObject['htmlAttrs'] = {\n lang: currentIso,\n ...(addDirAttribute ? { dir: currentDir } : {}),\n }\n\n if (!addSeoAttributes || !metaBaseUrl) {\n return { htmlAttrs, head: [] }\n }\n\n const switchLocalePath = createI18nRoutingFromAdapter({\n defaultLocale,\n localeCodes: locales.map((l) => l.code),\n localeKeyToCode,\n base,\n })\n\n const filteredPath = filterQuery(path, canonicalQueryWhitelist)\n // VitePress locale keys for i18nRouting: root vs code\n const currentVpKey =\n locale === defaultLocale\n ? 'root'\n : (() => {\n for (const [key, code] of Object.entries(localeKeyToCode)) {\n if (code === locale) return key === 'root' ? 'root' : key\n }\n return locale\n })()\n const canonicalPath = switchLocalePath({}, { path: filteredPath }, currentVpKey)\n const ogUrl = joinAbsolute(metaBaseUrl, base, canonicalPath)\n\n const localesForSeo = locales.filter((loc) => !loc.disabled && loc.seo !== false)\n const currentOg = resolveOgLocale(currentLocale)\n if (!currentOg) {\n warnUnresolvedOgLocale(currentLocale, { missingWarn, tag: 'og:locale' })\n }\n\n const head: VitePressHeadTuple[] = []\n\n head.push(['link', { [identifierAttribute]: 'i18n-can', rel: 'canonical', href: ogUrl }])\n\n if (currentOg) {\n head.push(['meta', { [identifierAttribute]: 'i18n-og', property: 'og:locale', content: currentOg }])\n }\n head.push(['meta', { [identifierAttribute]: 'i18n-og-url', property: 'og:url', content: ogUrl }])\n\n for (const loc of localesForSeo) {\n if (loc.code === locale) continue\n const ogAlt = resolveOgLocale(loc)\n if (!ogAlt) {\n warnUnresolvedOgLocale(loc, { missingWarn, tag: 'og:locale:alternate' })\n continue\n }\n head.push(['meta', { [identifierAttribute]: `i18n-og-alt-${ogAlt}`, property: 'og:locale:alternate', content: ogAlt }])\n }\n\n const hrefByCode = new Map<string, string>()\n for (const loc of localesForSeo) {\n const vpKey =\n loc.code === defaultLocale\n ? 'root'\n : (() => {\n for (const [key, code] of Object.entries(localeKeyToCode)) {\n if (code === loc.code) return key === 'root' ? loc.code : key\n }\n return loc.code\n })()\n const switched = switchLocalePath({}, { path: filteredPath }, vpKey)\n if (!switched) continue\n hrefByCode.set(String(loc.code), joinAbsolute(metaBaseUrl, base, switched))\n }\n\n for (const { hreflang, localeCode } of resolveHreflangAlternates(localesForSeo, { hreflangBaseLanguage })) {\n const href = hrefByCode.get(localeCode)\n if (!href) continue\n head.push(['link', { [identifierAttribute]: `i18n-alternate-${hreflang}`, rel: 'alternate', href, hreflang }])\n }\n\n const defaultLocaleObj = locales.find((l) => l.code === defaultLocale)\n if (defaultLocaleObj && defaultLocaleObj.seo !== false) {\n const xHref = hrefByCode.get(defaultLocale)\n if (xHref) {\n head.push(['link', { [identifierAttribute]: 'i18n-xd', rel: 'alternate', href: xHref, hreflang: 'x-default' }])\n }\n }\n\n return { htmlAttrs, head }\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { Translations } from '@i18n-micro/types'\nimport { storeLoadedTranslationFile, type TranslationFileBuckets } from '@i18n-micro/utils/parse-path'\n\n/** Sync FS walk for the Vite plugin — prefer `@i18n-micro/node` in scripts. */\nexport interface LoadMessagesOptions {\n translationDir: string\n rootDir?: string\n disablePageLocales?: boolean\n}\n\nexport type LoadedTranslations = TranslationFileBuckets<Translations>\n\nexport interface TranslationFileRef {\n relativePath: string\n absolutePath: string\n}\n\nfunction walkTranslationFiles(dir: string, onFile: (fullPath: string) => void): void {\n if (!existsSync(dir)) return\n\n for (const entry of readdirSync(dir)) {\n const fullPath = join(dir, entry)\n const stat = statSync(fullPath)\n if (stat.isDirectory()) {\n walkTranslationFiles(fullPath, onFile)\n continue\n }\n if (entry.endsWith('.json')) onFile(fullPath)\n }\n}\n\nexport function listTranslationFiles(options: LoadMessagesOptions): TranslationFileRef[] {\n const rootDir = options.rootDir ?? process.cwd()\n const dir = resolve(rootDir, options.translationDir)\n const files: TranslationFileRef[] = []\n\n walkTranslationFiles(dir, (fullPath) => {\n files.push({\n absolutePath: fullPath,\n relativePath: relative(dir, fullPath).split(sep).join('/'),\n })\n })\n\n return files.sort((a, b) => a.relativePath.localeCompare(b.relativePath))\n}\n\nexport function loadTranslationBuckets(options: LoadMessagesOptions): LoadedTranslations {\n const rootDir = options.rootDir ?? process.cwd()\n const dir = resolve(rootDir, options.translationDir)\n const buckets: LoadedTranslations = { root: {}, routes: {} }\n const disablePageLocales = options.disablePageLocales === true\n\n if (!existsSync(dir)) return buckets\n\n walkTranslationFiles(dir, (fullPath) => {\n const relativePath = relative(dir, fullPath).split(sep).join('/')\n try {\n const parsed: unknown = JSON.parse(readFileSync(fullPath, 'utf-8'))\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n console.error(\n `[i18n-micro/vitepress] Skipping ${relativePath}: expected a JSON object, got ${Array.isArray(parsed) ? 'array' : typeof parsed}`,\n )\n return\n }\n storeLoadedTranslationFile(buckets, relativePath, parsed as Translations, disablePageLocales)\n } catch (error) {\n console.error(`[i18n-micro/vitepress] Failed to load ${relativePath}:`, error)\n }\n })\n\n return buckets\n}\n","import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { Locale, Translations } from '@i18n-micro/types'\nimport { classifyTranslationRelativePath } from '@i18n-micro/utils/parse-path'\nimport type { Plugin } from 'vite'\nimport type { CreateI18nOptions } from '../runtime/create'\nimport { buildVitePressLocaleHead, relativePathToRoutePath } from '../seo/locale-head'\nimport { listTranslationFiles, loadTranslationBuckets } from './load-messages'\nimport { createI18nRoutingFromAdapter } from '../router/i18n-routing'\n\nexport interface WithI18nOptions extends CreateI18nOptions {\n /**\n * Directory with locale JSON (`en.json`, `pages/guide/demo/en.json`, …), relative to Vite root\n * (VitePress content / docs root). Used by `virtual:i18n-micro/messages`.\n * @default 'locales'\n */\n translationDir?: string\n /**\n * When true, treat `pages/**` as root-level dictionaries.\n * @default false\n */\n disablePageLocales?: boolean\n /**\n * When true, logs a warning if VitePress `locales` keys do not align with\n * configured i18n locale codes.\n * @default true\n */\n warnOnLocaleMismatch?: boolean\n /**\n * Inject `themeConfig.i18nRouting` from adapter options + `config.base`.\n * Set `false` to skip. Skipped automatically when `themeConfig.i18nRouting` is already set.\n * @default true\n */\n i18nRouting?: boolean\n /**\n * Emit i18n SEO tags via `transformHead` (canonical, hreflang, og:locale…) —\n * Nuxt `meta` / plugin `02.meta` analogue.\n * Absolute link tags require `metaBaseUrl`.\n * @default true when `metaBaseUrl` is set, otherwise false\n */\n meta?: boolean\n /**\n * Public origin without trailing slash (`https://example.com`).\n * Same role as Nuxt `metaBaseUrl`.\n */\n metaBaseUrl?: string\n /** Also emit bare-language hreflang from `iso` (Nuxt `hreflangBaseLanguage`). @default false */\n hreflangBaseLanguage?: boolean\n /** Query keys kept on canonical / alternate URLs. @default [] */\n canonicalQueryWhitelist?: string[]\n}\n\n/**\n * Minimal VitePress / Vite user config shape we merge into.\n * Avoid importing `vitepress` types so the package stays usable as a pure library dep.\n */\nexport interface VitePressUserConfigLike {\n base?: string\n locales?: Record<string, unknown>\n themeConfig?: Record<string, unknown> | null\n transformHead?: (...args: any[]) => any\n transformPageData?: (...args: any[]) => any\n vite?: {\n plugins?: Plugin[] | Plugin[][]\n ssr?: {\n noExternal?: string | true | Array<string | RegExp>\n [key: string]: unknown\n }\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\nexport interface VirtualI18nConfig {\n defaultLocale: string\n fallbackLocale: string\n locales: Locale[]\n localeCodes: string[]\n missingWarn: boolean\n syncWithVitePress: boolean\n translationDir: string\n disablePageLocales: boolean\n localeKeyToCode: Record<string, string>\n /** VitePress `site.base` (normalized, trailing slash preserved from config). */\n base?: string\n}\n\nconst VIRTUAL_CONFIG_ID = 'virtual:i18n-micro/config'\nconst RESOLVED_CONFIG_ID = `\\0${VIRTUAL_CONFIG_ID}`\nconst VIRTUAL_MESSAGES_ID = 'virtual:i18n-micro/messages'\nconst RESOLVED_MESSAGES_ID = `\\0${VIRTUAL_MESSAGES_ID}`\n\nfunction toPosix(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nfunction generateImportMessagesModule(rootDir: string, translationDir: string, disablePageLocales: boolean): string {\n const files = listTranslationFiles({ rootDir, translationDir })\n if (files.length === 0) {\n return 'export const messages = {}\\nexport const routeMessages = {}\\n'\n }\n\n const imports: string[] = []\n const rootEntries: string[] = []\n const routeVarNames = new Map<string, Map<string, string>>()\n let i = 0\n\n for (const file of files) {\n const parsed = classifyTranslationRelativePath(file.relativePath, disablePageLocales)\n if (parsed.type === 'ignore') continue\n\n const varName = `__i18n_${i++}`\n imports.push(`import ${varName} from ${JSON.stringify(toPosix(file.absolutePath))}`)\n\n if (parsed.type === 'root') {\n rootEntries.push(` ${JSON.stringify(parsed.locale)}: ${varName}`)\n continue\n }\n\n let byLocale = routeVarNames.get(parsed.pageName)\n if (!byLocale) {\n byLocale = new Map()\n routeVarNames.set(parsed.pageName, byLocale)\n }\n byLocale.set(parsed.locale, varName)\n }\n\n const routeEntries: string[] = []\n for (const [routeName, byLocale] of routeVarNames) {\n const localeEntries = [...byLocale.entries()].map(([locale, varName]) => ` ${JSON.stringify(locale)}: ${varName}`).join(',\\n')\n routeEntries.push(` ${JSON.stringify(routeName)}: {\\n${localeEntries}\\n }`)\n }\n\n return [\n ...imports,\n `export const messages = {\\n${rootEntries.join(',\\n')}\\n}`,\n `export const routeMessages = {\\n${routeEntries.join(',\\n')}\\n}`,\n '',\n ].join('\\n')\n}\n\nfunction generateInlineMessagesModule(messages: Record<string, Translations>, routeMessages: Record<string, Record<string, Translations>>): string {\n return [`export const messages = ${JSON.stringify(messages)}`, `export const routeMessages = ${JSON.stringify(routeMessages)}`, ''].join('\\n')\n}\n\nfunction createI18nVitePlugin(options: WithI18nOptions, siteBase?: string): Plugin {\n const defaultLocale = options.defaultLocale || options.locale\n const translationDir = options.translationDir ?? 'locales'\n const disablePageLocales = options.disablePageLocales === true\n const configData: VirtualI18nConfig = {\n defaultLocale,\n fallbackLocale: options.fallbackLocale || defaultLocale,\n locales: options.locales || [],\n localeCodes: (options.locales || []).map((l) => l.code),\n missingWarn: options.missingWarn ?? true,\n syncWithVitePress: options.syncWithVitePress !== false,\n translationDir,\n disablePageLocales,\n localeKeyToCode: options.localeKeyToCode ?? {},\n base: siteBase && siteBase !== '/' ? siteBase : undefined,\n }\n\n let rootDir = process.cwd()\n let useInline = Boolean(options.messages || options.routeMessages)\n let inlineRoot = options.messages ?? {}\n let inlineRoutes = options.routeMessages ?? {}\n let debounceTimer: ReturnType<typeof setTimeout> | undefined\n const needsDiskReload = () => !options.messages || !options.routeMessages\n\n const reloadInlineFromDisk = () => {\n // Fully inline config: skip disk I/O (and avoid spurious JSON parse errors).\n if (!needsDiskReload()) return\n const loaded = loadTranslationBuckets({\n rootDir,\n translationDir,\n disablePageLocales,\n })\n if (!options.messages) {\n inlineRoot = loaded.root\n }\n if (!options.routeMessages) {\n inlineRoutes = loaded.routes\n }\n }\n\n return {\n name: 'vite-plugin-i18n-vitepress',\n configResolved(config) {\n rootDir = config.root\n // Inline when caller passed messages and/or routeMessages.\n // routeMessages alone still loads root dictionaries from translationDir.\n useInline = Boolean(options.messages || options.routeMessages)\n if (useInline) {\n if (options.messages) inlineRoot = options.messages\n if (options.routeMessages) inlineRoutes = options.routeMessages\n if (needsDiskReload()) {\n reloadInlineFromDisk()\n }\n if (options.messages) inlineRoot = options.messages\n if (options.routeMessages) inlineRoutes = options.routeMessages\n }\n },\n configureServer(server) {\n // Both maps provided inline — nothing to watch on disk.\n if (useInline && !needsDiskReload()) return\n\n const dir = resolve(rootDir, translationDir)\n if (!existsSync(dir)) return\n\n server.watcher.add(dir)\n\n const invalidate = () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n if (useInline) reloadInlineFromDisk()\n const mod = server.moduleGraph.getModuleById(RESOLVED_MESSAGES_ID)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n server.ws.send({ type: 'full-reload' })\n }\n }, 50)\n }\n\n // add/unlink need virtual module regen; change is usually handled by JSON import HMR,\n // but we still invalidate when using inline payload that still reads disk.\n server.watcher.on('add', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n if (useInline && needsDiskReload()) {\n server.watcher.on('change', (file) => {\n if (file.startsWith(dir) && file.endsWith('.json')) invalidate()\n })\n }\n },\n resolveId(id) {\n if (id === VIRTUAL_CONFIG_ID) return RESOLVED_CONFIG_ID\n if (id === VIRTUAL_MESSAGES_ID) return RESOLVED_MESSAGES_ID\n },\n load(id) {\n if (id === RESOLVED_CONFIG_ID) {\n return `export const config = ${JSON.stringify(configData)}`\n }\n if (id === RESOLVED_MESSAGES_ID) {\n if (useInline) {\n return generateInlineMessagesModule(inlineRoot, inlineRoutes)\n }\n return generateImportMessagesModule(rootDir, translationDir, disablePageLocales)\n }\n },\n }\n}\n\nexport function warnLocaleMismatch(config: VitePressUserConfigLike, options: WithI18nOptions): void {\n if (options.warnOnLocaleMismatch === false) return\n const vpLocales = config.locales\n if (!vpLocales || !options.locales?.length) return\n\n const defaultLocale = options.defaultLocale || options.locale\n const vpKeys = Object.keys(vpLocales)\n const codes = new Set(options.locales.map((l) => l.code))\n\n for (const key of vpKeys) {\n const expectedCode = key === 'root' ? defaultLocale : (options.localeKeyToCode?.[key] ?? key)\n if (!codes.has(expectedCode)) {\n console.warn(\n `[i18n-micro/vitepress] VitePress locale key \"${key}\" maps to \"${expectedCode}\", ` +\n `which is not in i18n locales (${[...codes].join(', ')}).`,\n )\n }\n }\n}\n\n/**\n * VitePress config helper: virtual modules + optional `i18nRouting` / SEO head.\n *\n * Registers:\n * - `virtual:i18n-micro/config`\n * - `virtual:i18n-micro/messages` (from `translationDir`, default `locales/`)\n *\n * By default also sets `themeConfig.i18nRouting` (pass `i18nRouting: false` to skip).\n * Pair with `defineI18nTheme(DefaultTheme)` from `@i18n-micro/vitepress/theme`.\n * Import from `@i18n-micro/vitepress/config` (Node / config files only).\n */\nexport function withI18n<T extends VitePressUserConfigLike>(config: T, options: WithI18nOptions): T {\n warnLocaleMismatch(config, options)\n\n const siteBase = typeof config.base === 'string' ? config.base : undefined\n const existingPlugins = config.vite?.plugins\n const plugins = [...(Array.isArray(existingPlugins) ? existingPlugins.flat() : []), createI18nVitePlugin(options, siteBase)]\n\n const prevSsr = config.vite?.ssr\n const prevNoExternal = prevSsr?.noExternal\n const noExternalList = [\n '@i18n-micro/vitepress',\n ...(Array.isArray(prevNoExternal) ? prevNoExternal : prevNoExternal && prevNoExternal !== true ? [prevNoExternal] : []),\n ]\n\n const defaultLocale = options.defaultLocale || options.locale\n const localeCodes = (options.locales || []).map((l) => l.code)\n const prevTheme = (config.themeConfig && typeof config.themeConfig === 'object' ? config.themeConfig : {}) as Record<string, unknown>\n const shouldInjectRouting = options.i18nRouting !== false && prevTheme.i18nRouting === undefined && localeCodes.length > 0\n\n const metaEnabled = options.meta ?? Boolean(options.metaBaseUrl)\n const locales = options.locales || []\n const prevTransformHead = config.transformHead\n const prevTransformPageData = config.transformPageData\n\n const transformHead = metaEnabled\n ? async (ctx: {\n pageData?: { relativePath?: string; frontmatter?: { i18n?: { disableMeta?: boolean } } }\n siteConfig?: { site?: { base?: string } }\n siteData?: { base?: string }\n }) => {\n const prev = typeof prevTransformHead === 'function' ? await prevTransformHead(ctx) : []\n const prevHead = Array.isArray(prev) ? prev : []\n if (ctx.pageData?.frontmatter?.i18n?.disableMeta === true) return prevHead\n\n const relativePath = ctx.pageData?.relativePath || 'index.md'\n const siteBase = (typeof config.base === 'string' ? config.base : undefined) ?? ctx.siteData?.base ?? ctx.siteConfig?.site?.base\n const built = buildVitePressLocaleHead({\n path: relativePathToRoutePath(relativePath),\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: siteBase,\n metaBaseUrl: options.metaBaseUrl,\n hreflangBaseLanguage: options.hreflangBaseLanguage,\n canonicalQueryWhitelist: options.canonicalQueryWhitelist,\n missingWarn: options.missingWarn,\n })\n return [...prevHead, ...built.head]\n }\n : prevTransformHead\n\n const transformPageData = metaEnabled\n ? async (\n pageData: {\n relativePath?: string\n frontmatter?: Record<string, unknown> & { i18n?: { disableMeta?: boolean } }\n },\n ctx?: unknown,\n ) => {\n if (typeof prevTransformPageData === 'function') {\n await prevTransformPageData(pageData, ctx)\n }\n if (pageData.frontmatter?.i18n?.disableMeta === true) return\n\n const built = buildVitePressLocaleHead({\n path: relativePathToRoutePath(pageData.relativePath || 'index.md'),\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: typeof config.base === 'string' ? config.base : undefined,\n metaBaseUrl: options.metaBaseUrl,\n hreflangBaseLanguage: options.hreflangBaseLanguage,\n canonicalQueryWhitelist: options.canonicalQueryWhitelist,\n missingWarn: options.missingWarn,\n addSeoAttributes: false,\n })\n if (built.htmlAttrs.lang) {\n pageData.frontmatter ??= {}\n // VitePress uses frontmatter for per-page lang when set\n if (!pageData.frontmatter.lang) {\n pageData.frontmatter.lang = built.htmlAttrs.lang\n }\n }\n }\n : prevTransformPageData\n\n return {\n ...config,\n ...(shouldInjectRouting\n ? {\n themeConfig: {\n ...prevTheme,\n i18nRouting: createI18nRoutingFromAdapter({\n defaultLocale,\n localeCodes,\n localeKeyToCode: options.localeKeyToCode,\n base: siteBase,\n }),\n },\n }\n : {}),\n ...(metaEnabled\n ? {\n transformHead,\n transformPageData,\n }\n : {}),\n vite: {\n ...config.vite,\n plugins,\n // Theme entry statically imports `virtual:i18n-micro/*`; Vite must bundle\n // the package during SSG so those IDs resolve (not left as bare Node imports).\n ssr: {\n ...prevSsr,\n noExternal: prevNoExternal === true ? true : noExternalList,\n },\n },\n }\n}\n"],"mappings":";;;;;;;;AAq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yBAAyB,EAAQ;GACjC,aAAa,EAAQ;EACvB,CAAC;EACD,OAAO,CAAC,GAAG,GAAU,GAAG,EAAM,IAAI;CACpC,IACA,GAEE,IAAoB,IACtB,OACE,GAIA,MACG;EAIH,IAHI,OAAO,KAA0B,cACnC,MAAM,EAAsB,GAAU,CAAG,GAEvC,EAAS,aAAa,MAAM,gBAAgB,IAAM;EAEtD,IAAM,IAAQ,EAAyB;GACrC,MAAM,EAAwB,EAAS,gBAAgB,UAAU;GACjE;GACA;GACA,iBAAiB,EAAQ;GACzB,MAAM,OAAO,EAAO,QAAS,WAAW,EAAO,OAAO,KAAA;GACtD,aAAa,EAAQ;GACrB,sBAAsB,EAAQ;GAC9B,yBAAyB,EAAQ;GACjC,aAAa,EAAQ;GACrB,kBAAkB;EACpB,CAAC;EACD,AAAI,EAAM,UAAU,SAClB,EAAS,gBAAgB,CAAC,GAErB,EAAS,YAAY,SACxB,EAAS,YAAY,OAAO,EAAM,UAAU;CAGlD,IACA;CAEJ,OAAO;EACL,GAAG;EACH,GAAI,IACA,EACE,aAAa;GACX,GAAG;GACH,aAAa,EAA6B;IACxC;IACA;IACA,iBAAiB,EAAQ;IACzB,MAAM;GACR,CAAC;EACH,EACF,IACA,CAAC;EACL,GAAI,IACA;GACE;GACA;EACF,IACA,CAAC;EACL,MAAM;GACJ,GAAG,EAAO;GACV;GAGA,KAAK;IACH,GAAG;IACH,YAAY,MAAmB,MAAc;GAC/C;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { t as e } from "./adapter-CAJNI6Sw.js";
|
|
2
|
+
import { mergeRouteTranslationsWithRoot as t } from "@i18n-micro/utils/parse-path";
|
|
3
|
+
import { createI18n as n } from "@i18n-micro/vue";
|
|
4
|
+
//#region src/runtime/create.ts
|
|
5
|
+
function r(e, n, r) {
|
|
6
|
+
if (r) for (let [i, a] of Object.entries(r)) for (let [r, o] of Object.entries(a)) e.global.addRouteTranslations(r, i, t(n?.[r], o), !1);
|
|
7
|
+
}
|
|
8
|
+
function i(t) {
|
|
9
|
+
let i = t.defaultLocale || t.locale, a = t.locales ?? [], o = t.syncWithVitePress !== !1, s = n({
|
|
10
|
+
locale: t.locale,
|
|
11
|
+
fallbackLocale: t.fallbackLocale ?? i,
|
|
12
|
+
messages: t.messages,
|
|
13
|
+
plural: t.plural,
|
|
14
|
+
missingWarn: t.missingWarn,
|
|
15
|
+
missingHandler: t.missingHandler,
|
|
16
|
+
locales: a,
|
|
17
|
+
defaultLocale: i
|
|
18
|
+
});
|
|
19
|
+
r(s, t.messages, t.routeMessages);
|
|
20
|
+
let c = e({
|
|
21
|
+
locales: a,
|
|
22
|
+
defaultLocale: i,
|
|
23
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
24
|
+
base: t.base
|
|
25
|
+
}), l = {
|
|
26
|
+
localizePath: c.localizePath,
|
|
27
|
+
switchLocalePath: c.switchLocalePath,
|
|
28
|
+
getLocaleFromPath: c.getLocaleFromPath,
|
|
29
|
+
removeLocaleFromPath: c.removeLocaleFromPath,
|
|
30
|
+
routeNameFromPath: c.routeNameFromPath
|
|
31
|
+
};
|
|
32
|
+
s.global.extend(l);
|
|
33
|
+
let u = new Set(Object.keys(t.routeMessages ?? {})), d = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
return Object.assign(s, l, {
|
|
35
|
+
get i18n() {
|
|
36
|
+
return s.global;
|
|
37
|
+
},
|
|
38
|
+
enhanceApp: (n) => {
|
|
39
|
+
let { app: r, router: c } = n, l = d.get(r);
|
|
40
|
+
if (!l) {
|
|
41
|
+
let n = e({
|
|
42
|
+
locales: a,
|
|
43
|
+
defaultLocale: i,
|
|
44
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
45
|
+
base: t.base,
|
|
46
|
+
getPath: () => {
|
|
47
|
+
let e = c.route;
|
|
48
|
+
return `${e.path}${e.query || ""}${e.hash || ""}`;
|
|
49
|
+
},
|
|
50
|
+
go: (e, t) => c.go(e, t)
|
|
51
|
+
});
|
|
52
|
+
r.use(s), s.setRoutingStrategy(n), l = {
|
|
53
|
+
adapter: n,
|
|
54
|
+
boundSyncHandler: null,
|
|
55
|
+
chainedPrevious: void 0
|
|
56
|
+
}, d.set(r, l);
|
|
57
|
+
}
|
|
58
|
+
if (!o) return;
|
|
59
|
+
let { adapter: f } = l, p = (e = c.route.path) => {
|
|
60
|
+
let t = f.getLocaleFromPath(e);
|
|
61
|
+
s.global.getLocale() !== t && (s.global.locale = t);
|
|
62
|
+
let n = f.routeNameFromPath(e);
|
|
63
|
+
s.global.setRoute(u.has(n) ? n : "index");
|
|
64
|
+
};
|
|
65
|
+
p();
|
|
66
|
+
let m = c.onAfterRouteChange;
|
|
67
|
+
m !== l.boundSyncHandler && (l.chainedPrevious = typeof m == "function" ? m : void 0), l.boundSyncHandler = async (e) => {
|
|
68
|
+
typeof l.chainedPrevious == "function" && await l.chainedPrevious(e);
|
|
69
|
+
let t = e.startsWith("http") ? (() => {
|
|
70
|
+
let t = new URL(e);
|
|
71
|
+
return t.pathname + t.search + t.hash;
|
|
72
|
+
})() : e;
|
|
73
|
+
p(t);
|
|
74
|
+
}, c.onAfterRouteChange = l.boundSyncHandler;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { i as t };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=create-C_dXg23X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-C_dXg23X.js","names":[],"sources":["../src/runtime/create.ts"],"sourcesContent":["import type { Locale, PluralFunc, Translations } from '@i18n-micro/types'\nimport { mergeRouteTranslationsWithRoot } from '@i18n-micro/utils/parse-path'\nimport { createI18n as createVueI18n, type I18nPlugin } from '@i18n-micro/vue'\nimport type { App, Ref } from 'vue'\nimport { createVitePressRouterAdapter, type PathMethods, type VitePressRouterAdapter, type VitePressRouterLike } from '../router/adapter'\n\nexport type { PathMethods }\n\nexport interface CreateI18nOptions {\n locale: string\n fallbackLocale?: string\n locales?: Locale[]\n defaultLocale?: string\n messages?: Record<string, Translations>\n /**\n * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale.\n * Loaded from `locales/pages/**` when using `withI18n`.\n */\n routeMessages?: Record<string, Record<string, Translations>>\n plural?: PluralFunc\n missingWarn?: boolean\n missingHandler?: (locale: string, key: string, routeName: string) => void\n /**\n * Sync i18n locale from the VitePress URL path on every navigation.\n * @default true\n */\n syncWithVitePress?: boolean\n /**\n * Map VitePress locale keys to i18n codes (`root` → default locale code).\n */\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher\n * do not treat the base segment as content / double-prefix links.\n */\n base?: string\n}\n\nexport interface VitePressSiteDataLike {\n locales?: Record<string, { lang?: string; link?: string; label?: string }>\n}\n\nexport type CreateI18nResult = I18nPlugin &\n PathMethods & {\n /** Same as `.global` (VueI18n + path methods). */\n i18n: I18nPlugin['global'] & PathMethods\n enhanceApp: (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => void\n }\n\nfunction applyRouteMessages(\n plugin: I18nPlugin,\n root: Record<string, Translations> | undefined,\n routeMessages: Record<string, Record<string, Translations>> | undefined,\n): void {\n if (!routeMessages) return\n for (const [routeName, byLocale] of Object.entries(routeMessages)) {\n for (const [locale, translations] of Object.entries(byLocale)) {\n plugin.global.addRouteTranslations(locale, routeName, mergeRouteTranslationsWithRoot(root?.[locale], translations), false)\n }\n }\n}\n\n/**\n * Universal VitePress i18n: Vue plugin + path helpers + `enhanceApp` sync.\n * Path methods are the router adapter’s own functions (no wrapper layer).\n */\nexport function createI18n(options: CreateI18nOptions): CreateI18nResult {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = options.locales ?? []\n const syncWithVitePress = options.syncWithVitePress !== false\n\n const plugin = createVueI18n({\n locale: options.locale,\n fallbackLocale: options.fallbackLocale ?? defaultLocale,\n messages: options.messages,\n plural: options.plural,\n missingWarn: options.missingWarn,\n missingHandler: options.missingHandler,\n locales,\n defaultLocale,\n })\n\n applyRouteMessages(plugin, options.messages, options.routeMessages)\n\n const paths = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n const pathMethods: PathMethods = {\n localizePath: paths.localizePath,\n switchLocalePath: paths.switchLocalePath,\n getLocaleFromPath: paths.getLocaleFromPath,\n removeLocaleFromPath: paths.removeLocaleFromPath,\n routeNameFromPath: paths.routeNameFromPath,\n }\n plugin.global.extend(pathMethods)\n\n const pageRouteNames = new Set(Object.keys(options.routeMessages ?? {}))\n\n const byApp = new WeakMap<\n object,\n {\n adapter: VitePressRouterAdapter\n boundSyncHandler: ((to: string) => unknown) | null\n chainedPrevious: ((to: string) => unknown) | undefined\n }\n >()\n\n const enhanceApp = (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => {\n const { app, router } = ctx\n\n let state = byApp.get(app)\n if (!state) {\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n getPath: () => {\n const route = router.route\n return `${route.path}${route.query || ''}${route.hash || ''}`\n },\n go: (href, navOptions) => router.go(href, navOptions),\n })\n\n app.use(plugin)\n plugin.setRoutingStrategy(adapter)\n state = { adapter, boundSyncHandler: null, chainedPrevious: undefined }\n byApp.set(app, state)\n }\n\n if (!syncWithVitePress) return\n\n const { adapter } = state\n const sync = (path = router.route.path) => {\n const nextLocale = adapter.getLocaleFromPath(path)\n if (plugin.global.getLocale() !== nextLocale) {\n plugin.global.locale = nextLocale\n }\n const derived = adapter.routeNameFromPath(path)\n plugin.global.setRoute(pageRouteNames.has(derived) ? derived : 'index')\n }\n\n sync()\n\n const current = router.onAfterRouteChange\n if (current !== state.boundSyncHandler) {\n state.chainedPrevious = typeof current === 'function' ? current : undefined\n }\n state.boundSyncHandler = async (to: string) => {\n if (typeof state.chainedPrevious === 'function') {\n await state.chainedPrevious(to)\n }\n const path = to.startsWith('http')\n ? (() => {\n const url = new URL(to)\n return url.pathname + url.search + url.hash\n })()\n : to\n sync(path)\n }\n router.onAfterRouteChange = state.boundSyncHandler\n }\n\n return Object.assign(plugin, pathMethods, {\n get i18n() {\n return plugin.global as I18nPlugin['global'] & PathMethods\n },\n enhanceApp,\n }) as CreateI18nResult\n}\n"],"mappings":";;;;AAiDA,SAAS,EACP,GACA,GACA,GACM;CACD,OACL,KAAK,IAAM,CAAC,GAAW,MAAa,OAAO,QAAQ,CAAa,GAC9D,KAAK,IAAM,CAAC,GAAQ,MAAiB,OAAO,QAAQ,CAAQ,GAC1D,EAAO,OAAO,qBAAqB,GAAQ,GAAW,EAA+B,IAAO,IAAS,CAAY,GAAG,EAAK;AAG/H;AAMA,SAAgB,EAAW,GAA8C;CACvE,IAAM,IAAgB,EAAQ,iBAAiB,EAAQ,QACjD,IAAU,EAAQ,WAAW,CAAC,GAC9B,IAAoB,EAAQ,sBAAsB,IAElD,IAAS,EAAc;EAC3B,QAAQ,EAAQ;EAChB,gBAAgB,EAAQ,kBAAkB;EAC1C,UAAU,EAAQ;EAClB,QAAQ,EAAQ;EAChB,aAAa,EAAQ;EACrB,gBAAgB,EAAQ;EACxB;EACA;CACF,CAAC;CAED,EAAmB,GAAQ,EAAQ,UAAU,EAAQ,aAAa;CAElE,IAAM,IAAQ,EAA6B;EACzC;EACA;EACA,iBAAiB,EAAQ;EACzB,MAAM,EAAQ;CAChB,CAAC,GACK,IAA2B;EAC/B,cAAc,EAAM;EACpB,kBAAkB,EAAM;EACxB,mBAAmB,EAAM;EACzB,sBAAsB,EAAM;EAC5B,mBAAmB,EAAM;CAC3B;CACA,EAAO,OAAO,OAAO,CAAW;CAEhC,IAAM,IAAiB,IAAI,IAAI,OAAO,KAAK,EAAQ,iBAAiB,CAAC,CAAC,CAAC,GAEjE,oBAAQ,IAAI,QAOhB;CA0DF,OAAO,OAAO,OAA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EAAO,qBAAqB,EAAM;EACpC;CAOA,CAAC;AACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./adapter-eYZZOC9d.cjs");let t=require("@i18n-micro/utils/parse-path"),n=require("@i18n-micro/vue");function r(e,n,r){if(r)for(let[i,a]of Object.entries(r))for(let[r,o]of Object.entries(a))e.global.addRouteTranslations(r,i,(0,t.mergeRouteTranslationsWithRoot)(n?.[r],o),!1)}function i(t){let i=t.defaultLocale||t.locale,a=t.locales??[],o=t.syncWithVitePress!==!1,s=(0,n.createI18n)({locale:t.locale,fallbackLocale:t.fallbackLocale??i,messages:t.messages,plural:t.plural,missingWarn:t.missingWarn,missingHandler:t.missingHandler,locales:a,defaultLocale:i});r(s,t.messages,t.routeMessages);let c=e.t({locales:a,defaultLocale:i,localeKeyToCode:t.localeKeyToCode,base:t.base}),l={localizePath:c.localizePath,switchLocalePath:c.switchLocalePath,getLocaleFromPath:c.getLocaleFromPath,removeLocaleFromPath:c.removeLocaleFromPath,routeNameFromPath:c.routeNameFromPath};s.global.extend(l);let u=new Set(Object.keys(t.routeMessages??{})),d=new WeakMap;return Object.assign(s,l,{get i18n(){return s.global},enhanceApp:n=>{let{app:r,router:c}=n,l=d.get(r);if(!l){let n=e.t({locales:a,defaultLocale:i,localeKeyToCode:t.localeKeyToCode,base:t.base,getPath:()=>{let e=c.route;return`${e.path}${e.query||``}${e.hash||``}`},go:(e,t)=>c.go(e,t)});r.use(s),s.setRoutingStrategy(n),l={adapter:n,boundSyncHandler:null,chainedPrevious:void 0},d.set(r,l)}if(!o)return;let{adapter:f}=l,p=(e=c.route.path)=>{let t=f.getLocaleFromPath(e);s.global.getLocale()!==t&&(s.global.locale=t);let n=f.routeNameFromPath(e);s.global.setRoute(u.has(n)?n:`index`)};p();let m=c.onAfterRouteChange;m!==l.boundSyncHandler&&(l.chainedPrevious=typeof m==`function`?m:void 0),l.boundSyncHandler=async e=>{typeof l.chainedPrevious==`function`&&await l.chainedPrevious(e);let t=e.startsWith(`http`)?(()=>{let t=new URL(e);return t.pathname+t.search+t.hash})():e;p(t)},c.onAfterRouteChange=l.boundSyncHandler}})}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
2
|
+
//# sourceMappingURL=create-Cwu2djcO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-Cwu2djcO.cjs","names":[],"sources":["../src/runtime/create.ts"],"sourcesContent":["import type { Locale, PluralFunc, Translations } from '@i18n-micro/types'\nimport { mergeRouteTranslationsWithRoot } from '@i18n-micro/utils/parse-path'\nimport { createI18n as createVueI18n, type I18nPlugin } from '@i18n-micro/vue'\nimport type { App, Ref } from 'vue'\nimport { createVitePressRouterAdapter, type PathMethods, type VitePressRouterAdapter, type VitePressRouterLike } from '../router/adapter'\n\nexport type { PathMethods }\n\nexport interface CreateI18nOptions {\n locale: string\n fallbackLocale?: string\n locales?: Locale[]\n defaultLocale?: string\n messages?: Record<string, Translations>\n /**\n * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale.\n * Loaded from `locales/pages/**` when using `withI18n`.\n */\n routeMessages?: Record<string, Record<string, Translations>>\n plural?: PluralFunc\n missingWarn?: boolean\n missingHandler?: (locale: string, key: string, routeName: string) => void\n /**\n * Sync i18n locale from the VitePress URL path on every navigation.\n * @default true\n */\n syncWithVitePress?: boolean\n /**\n * Map VitePress locale keys to i18n codes (`root` → default locale code).\n */\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher\n * do not treat the base segment as content / double-prefix links.\n */\n base?: string\n}\n\nexport interface VitePressSiteDataLike {\n locales?: Record<string, { lang?: string; link?: string; label?: string }>\n}\n\nexport type CreateI18nResult = I18nPlugin &\n PathMethods & {\n /** Same as `.global` (VueI18n + path methods). */\n i18n: I18nPlugin['global'] & PathMethods\n enhanceApp: (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => void\n }\n\nfunction applyRouteMessages(\n plugin: I18nPlugin,\n root: Record<string, Translations> | undefined,\n routeMessages: Record<string, Record<string, Translations>> | undefined,\n): void {\n if (!routeMessages) return\n for (const [routeName, byLocale] of Object.entries(routeMessages)) {\n for (const [locale, translations] of Object.entries(byLocale)) {\n plugin.global.addRouteTranslations(locale, routeName, mergeRouteTranslationsWithRoot(root?.[locale], translations), false)\n }\n }\n}\n\n/**\n * Universal VitePress i18n: Vue plugin + path helpers + `enhanceApp` sync.\n * Path methods are the router adapter’s own functions (no wrapper layer).\n */\nexport function createI18n(options: CreateI18nOptions): CreateI18nResult {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = options.locales ?? []\n const syncWithVitePress = options.syncWithVitePress !== false\n\n const plugin = createVueI18n({\n locale: options.locale,\n fallbackLocale: options.fallbackLocale ?? defaultLocale,\n messages: options.messages,\n plural: options.plural,\n missingWarn: options.missingWarn,\n missingHandler: options.missingHandler,\n locales,\n defaultLocale,\n })\n\n applyRouteMessages(plugin, options.messages, options.routeMessages)\n\n const paths = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n const pathMethods: PathMethods = {\n localizePath: paths.localizePath,\n switchLocalePath: paths.switchLocalePath,\n getLocaleFromPath: paths.getLocaleFromPath,\n removeLocaleFromPath: paths.removeLocaleFromPath,\n routeNameFromPath: paths.routeNameFromPath,\n }\n plugin.global.extend(pathMethods)\n\n const pageRouteNames = new Set(Object.keys(options.routeMessages ?? {}))\n\n const byApp = new WeakMap<\n object,\n {\n adapter: VitePressRouterAdapter\n boundSyncHandler: ((to: string) => unknown) | null\n chainedPrevious: ((to: string) => unknown) | undefined\n }\n >()\n\n const enhanceApp = (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => {\n const { app, router } = ctx\n\n let state = byApp.get(app)\n if (!state) {\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n getPath: () => {\n const route = router.route\n return `${route.path}${route.query || ''}${route.hash || ''}`\n },\n go: (href, navOptions) => router.go(href, navOptions),\n })\n\n app.use(plugin)\n plugin.setRoutingStrategy(adapter)\n state = { adapter, boundSyncHandler: null, chainedPrevious: undefined }\n byApp.set(app, state)\n }\n\n if (!syncWithVitePress) return\n\n const { adapter } = state\n const sync = (path = router.route.path) => {\n const nextLocale = adapter.getLocaleFromPath(path)\n if (plugin.global.getLocale() !== nextLocale) {\n plugin.global.locale = nextLocale\n }\n const derived = adapter.routeNameFromPath(path)\n plugin.global.setRoute(pageRouteNames.has(derived) ? derived : 'index')\n }\n\n sync()\n\n const current = router.onAfterRouteChange\n if (current !== state.boundSyncHandler) {\n state.chainedPrevious = typeof current === 'function' ? current : undefined\n }\n state.boundSyncHandler = async (to: string) => {\n if (typeof state.chainedPrevious === 'function') {\n await state.chainedPrevious(to)\n }\n const path = to.startsWith('http')\n ? (() => {\n const url = new URL(to)\n return url.pathname + url.search + url.hash\n })()\n : to\n sync(path)\n }\n router.onAfterRouteChange = state.boundSyncHandler\n }\n\n return Object.assign(plugin, pathMethods, {\n get i18n() {\n return plugin.global as I18nPlugin['global'] & PathMethods\n },\n enhanceApp,\n }) as CreateI18nResult\n}\n"],"mappings":"qHAiDA,SAAS,EACP,EACA,EACA,EACM,CACD,KACL,IAAK,GAAM,CAAC,EAAW,KAAa,OAAO,QAAQ,CAAa,EAC9D,IAAK,GAAM,CAAC,EAAQ,KAAiB,OAAO,QAAQ,CAAQ,EAC1D,EAAO,OAAO,qBAAqB,EAAQ,GAAA,EAAW,EAAA,+BAAA,CAA+B,IAAO,GAAS,CAAY,EAAG,EAAK,CAG/H,CAMA,SAAgB,EAAW,EAA8C,CACvE,IAAM,EAAgB,EAAQ,eAAiB,EAAQ,OACjD,EAAU,EAAQ,SAAW,CAAC,EAC9B,EAAoB,EAAQ,oBAAsB,GAElD,GAAA,EAAS,EAAA,WA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,EAAa,EAAQ,kBAAkB,CAAI,EAC7C,EAAO,OAAO,UAAU,IAAM,IAChC,EAAO,OAAO,OAAS,GAEzB,IAAM,EAAU,EAAQ,kBAAkB,CAAI,EAC9C,EAAO,OAAO,SAAS,EAAe,IAAI,CAAO,EAAI,EAAU,OAAO,CACxE,EAEA,EAAK,EAEL,IAAM,EAAU,EAAO,mBACnB,IAAY,EAAM,mBACpB,EAAM,gBAAkB,OAAO,GAAY,WAAa,EAAU,IAAA,IAEpE,EAAM,iBAAmB,KAAO,IAAe,CACzC,OAAO,EAAM,iBAAoB,YACnC,MAAM,EAAM,gBAAgB,CAAE,EAEhC,IAAM,EAAO,EAAG,WAAW,MAAM,OACtB,CACL,IAAM,EAAM,IAAI,IAAI,CAAE,EACtB,OAAO,EAAI,SAAW,EAAI,OAAS,EAAI,IACzC,EAAA,CAAG,EACH,EACJ,EAAK,CAAI,CACX,EACA,EAAO,mBAAqB,EAAM,gBACpC,CAOA,CAAC,CACH"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapter-eYZZOC9d.cjs"),t=require("./create-Cwu2djcO.cjs");let n=require("@i18n-micro/vue"),r=require("@i18n-micro/core");function i(e){if(!(`default`in e)||!Object.keys(e).every(e=>e==="default"||e==="__esModule"))return!1;let t=e.default;return typeof t==`object`&&!!t&&!Array.isArray(t)}function a(e){let t={};for(let[n,r]of Object.entries(e)){let e=(n.split(`/`).pop()||``).replace(/\.json$/,``);e&&(t[e]=r&&typeof r==`object`&&i(r)?r.default:r)}return t}Object.defineProperty(exports,"FormatService",{enumerable:!0,get:function(){return r.FormatService}}),Object.defineProperty(exports,"I18nGroup",{enumerable:!0,get:function(){return n.I18nGroup}}),Object.defineProperty(exports,"I18nLink",{enumerable:!0,get:function(){return n.I18nLink}}),Object.defineProperty(exports,"I18nSwitcher",{enumerable:!0,get:function(){return n.I18nSwitcher}}),Object.defineProperty(exports,"I18nT",{enumerable:!0,get:function(){return n.I18nT}}),exports.createI18n=t.t,Object.defineProperty(exports,"defaultPlural",{enumerable:!0,get:function(){return r.defaultPlural}}),exports.getLocaleFromPath=e.n,Object.defineProperty(exports,"interpolate",{enumerable:!0,get:function(){return r.interpolate}}),exports.messagesFromGlob=a,exports.routeNameFromPath=e.r,exports.stripSiteBase=e.i,Object.defineProperty(exports,"useI18n",{enumerable:!0,get:function(){return n.useI18n}});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/runtime/messages-from-glob.ts"],"sourcesContent":["import type { Translations } from '@i18n-micro/types'\n\n/**\n * Vite `import.meta.glob(..., { eager: true })` modules look like\n * `{ default: { …json } }` or `{ default: { … }, __esModule: true }`.\n * Do not treat a real dictionary that only has a `default` string key as a namespace.\n */\nfunction isModuleNamespace(mod: object): mod is { default: Translations } {\n if (!('default' in mod)) return false\n const keys = Object.keys(mod)\n if (!keys.every((key) => key === 'default' || key === '__esModule')) return false\n const value = (mod as { default: unknown }).default\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`.\n * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact.\n */\nexport function messagesFromGlob(modules: Record<string, { default: Translations } | Translations>): Record<string, Translations> {\n const messages: Record<string, Translations> = {}\n for (const [path, mod] of Object.entries(modules)) {\n const file = path.split('/').pop() || ''\n const code = file.replace(/\\.json$/, '')\n if (!code) continue\n if (mod && typeof mod === 'object' && isModuleNamespace(mod)) {\n messages[code] = mod.default\n } else {\n messages[code] = mod as Translations\n }\n }\n return messages\n}\n"],"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/runtime/messages-from-glob.ts"],"sourcesContent":["import type { Translations } from '@i18n-micro/types'\n\n/**\n * Vite `import.meta.glob(..., { eager: true })` modules look like\n * `{ default: { …json } }` or `{ default: { … }, __esModule: true }`.\n * Do not treat a real dictionary that only has a `default` string key as a namespace.\n */\nfunction isModuleNamespace(mod: object): mod is { default: Translations } {\n if (!('default' in mod)) return false\n const keys = Object.keys(mod)\n if (!keys.every((key) => key === 'default' || key === '__esModule')) return false\n const value = (mod as { default: unknown }).default\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`.\n * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact.\n */\nexport function messagesFromGlob(modules: Record<string, { default: Translations } | Translations>): Record<string, Translations> {\n const messages: Record<string, Translations> = {}\n for (const [path, mod] of Object.entries(modules)) {\n const file = path.split('/').pop() || ''\n const code = file.replace(/\\.json$/, '')\n if (!code) continue\n if (mod && typeof mod === 'object' && isModuleNamespace(mod)) {\n messages[code] = mod.default\n } else {\n messages[code] = mod as Translations\n }\n }\n return messages\n}\n"],"mappings":"+MAOA,SAAS,EAAkB,EAA+C,CAGxE,GAFI,EAAE,YAAa,IAEf,CADS,OAAO,KAAK,CACpB,CAAA,CAAK,MAAO,GAAQ,IAAQ,WAAa,IAAQ,YAAY,EAAG,MAAO,GAC5E,IAAM,EAAS,EAA6B,QAC5C,OAAyB,OAAO,GAAU,YAAnC,GAA+C,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAMA,SAAgB,EAAiB,EAAiG,CAChI,IAAM,EAAyC,CAAC,EAChD,IAAK,GAAM,CAAC,EAAM,KAAQ,OAAO,QAAQ,CAAO,EAAG,CAEjD,IAAM,GADO,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,GAAA,CACpB,QAAQ,UAAW,EAAE,EAClC,IACL,AAGE,EAAS,GAHP,GAAO,OAAO,GAAQ,UAAY,EAAkB,CAAG,EACxC,EAAI,QAEJ,EAErB,CACA,OAAO,CACT"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { I18nGroup as
|
|
4
|
-
import { FormatService as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { i as e, n as t, r as n } from "./adapter-CAJNI6Sw.js";
|
|
2
|
+
import { t as r } from "./create-C_dXg23X.js";
|
|
3
|
+
import { I18nGroup as i, I18nLink as a, I18nSwitcher as o, I18nT as s, useI18n as c } from "@i18n-micro/vue";
|
|
4
|
+
import { FormatService as l, defaultPlural as u, interpolate as d } from "@i18n-micro/core";
|
|
5
|
+
//#region src/runtime/messages-from-glob.ts
|
|
6
|
+
function f(e) {
|
|
7
|
+
if (!("default" in e) || !Object.keys(e).every((e) => e === "default" || e === "__esModule")) return !1;
|
|
8
|
+
let t = e.default;
|
|
9
|
+
return typeof t == "object" && !!t && !Array.isArray(t);
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
function p(e) {
|
|
12
|
+
let t = {};
|
|
13
|
+
for (let [n, r] of Object.entries(e)) {
|
|
14
|
+
let e = (n.split("/").pop() || "").replace(/\.json$/, "");
|
|
15
|
+
e && (t[e] = r && typeof r == "object" && f(r) ? r.default : r);
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
j as I18nSwitcher,
|
|
23
|
-
x as I18nT,
|
|
24
|
-
i as createI18n,
|
|
25
|
-
k as defaultPlural,
|
|
26
|
-
p as getLocaleFromPath,
|
|
27
|
-
v as interpolate,
|
|
28
|
-
f as messagesFromGlob,
|
|
29
|
-
m as routeNameFromPath,
|
|
30
|
-
d as stripSiteBase,
|
|
31
|
-
g as useI18n
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.mjs.map
|
|
19
|
+
//#endregion
|
|
20
|
+
export { l as FormatService, i as I18nGroup, a as I18nLink, o as I18nSwitcher, s as I18nT, r as createI18n, u as defaultPlural, t as getLocaleFromPath, d as interpolate, p as messagesFromGlob, n as routeNameFromPath, e as stripSiteBase, c as useI18n };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/runtime/messages-from-glob.ts"],"sourcesContent":["import type { Translations } from '@i18n-micro/types'\n\n/**\n * Vite `import.meta.glob(..., { eager: true })` modules look like\n * `{ default: { …json } }` or `{ default: { … }, __esModule: true }`.\n * Do not treat a real dictionary that only has a `default` string key as a namespace.\n */\nfunction isModuleNamespace(mod: object): mod is { default: Translations } {\n if (!('default' in mod)) return false\n const keys = Object.keys(mod)\n if (!keys.every((key) => key === 'default' || key === '__esModule')) return false\n const value = (mod as { default: unknown }).default\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`.\n * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact.\n */\nexport function messagesFromGlob(modules: Record<string, { default: Translations } | Translations>): Record<string, Translations> {\n const messages: Record<string, Translations> = {}\n for (const [path, mod] of Object.entries(modules)) {\n const file = path.split('/').pop() || ''\n const code = file.replace(/\\.json$/, '')\n if (!code) continue\n if (mod && typeof mod === 'object' && isModuleNamespace(mod)) {\n messages[code] = mod.default\n } else {\n messages[code] = mod as Translations\n }\n }\n return messages\n}\n"],"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/runtime/messages-from-glob.ts"],"sourcesContent":["import type { Translations } from '@i18n-micro/types'\n\n/**\n * Vite `import.meta.glob(..., { eager: true })` modules look like\n * `{ default: { …json } }` or `{ default: { … }, __esModule: true }`.\n * Do not treat a real dictionary that only has a `default` string key as a namespace.\n */\nfunction isModuleNamespace(mod: object): mod is { default: Translations } {\n if (!('default' in mod)) return false\n const keys = Object.keys(mod)\n if (!keys.every((key) => key === 'default' || key === '__esModule')) return false\n const value = (mod as { default: unknown }).default\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`.\n * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact.\n */\nexport function messagesFromGlob(modules: Record<string, { default: Translations } | Translations>): Record<string, Translations> {\n const messages: Record<string, Translations> = {}\n for (const [path, mod] of Object.entries(modules)) {\n const file = path.split('/').pop() || ''\n const code = file.replace(/\\.json$/, '')\n if (!code) continue\n if (mod && typeof mod === 'object' && isModuleNamespace(mod)) {\n messages[code] = mod.default\n } else {\n messages[code] = mod as Translations\n }\n }\n return messages\n}\n"],"mappings":";;;;;AAOA,SAAS,EAAkB,GAA+C;CAGxE,IAFI,EAAE,aAAa,MAEf,CADS,OAAO,KAAK,CACpB,CAAA,CAAK,OAAO,MAAQ,MAAQ,aAAa,MAAQ,YAAY,GAAG,OAAO;CAC5E,IAAM,IAAS,EAA6B;CAC5C,OAAyB,OAAO,KAAU,cAAnC,KAA+C,CAAC,MAAM,QAAQ,CAAK;AAC5E;AAMA,SAAgB,EAAiB,GAAiG;CAChI,IAAM,IAAyC,CAAC;CAChD,KAAK,IAAM,CAAC,GAAM,MAAQ,OAAO,QAAQ,CAAO,GAAG;EAEjD,IAAM,KADO,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,GAAA,CACpB,QAAQ,WAAW,EAAE;EAClC,MACL,AAGE,EAAS,KAHP,KAAO,OAAO,KAAQ,YAAY,EAAkB,CAAG,IACxC,EAAI,UAEJ;CAErB;CACA,OAAO;AACT"}
|
package/dist/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=node.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapter-eYZZOC9d.cjs"),t=require("./vitepress-locales-CwOlvAa0.cjs");let n=require("@i18n-micro/node");function r(t){let r=t.defaultLocale||t.locale,i=(t.locales?.length?t.locales:[t.locale]).map(e=>typeof e==`string`?{code:e}:e),a=e.t({locales:i,defaultLocale:r,localeKeyToCode:t.localeKeyToCode,base:t.base});return(0,n.createI18n)(t).extend({localizePath:a.localizePath,switchLocalePath:a.switchLocalePath,getLocaleFromPath:a.getLocaleFromPath,removeLocaleFromPath:a.removeLocaleFromPath,routeNameFromPath:a.routeNameFromPath})}exports.buildVitePressLocales=t.t,exports.createI18n=r,Object.defineProperty(exports,"loadRootTranslations",{enumerable:!0,get:function(){return n.loadRootTranslations}}),Object.defineProperty(exports,"loadTranslations",{enumerable:!0,get:function(){return n.loadTranslations}});
|
|
2
|
+
//# sourceMappingURL=node.cjs.map
|
package/dist/node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.cjs","sources":["../src/runtime/node-create.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createI18n as createNodeI18n, type I18n, type I18nOptions } from '@i18n-micro/node'\nimport { createVitePressRouterAdapter, type PathMethods } from '../router/adapter'\n\nexport type { I18nOptions, LoadedTranslations } from '@i18n-micro/node'\nexport { loadTranslations, loadRootTranslations } from '@i18n-micro/node'\nexport type { PathMethods }\n\nexport interface CreateI18nOptions extends I18nOptions {\n /** Locales for path helpers (`localizePath`, …). Defaults to `[{ code: locale }]`. */\n locales?: Locale[] | string[]\n defaultLocale?: string\n localeKeyToCode?: Record<string, string>\n base?: string\n}\n\nexport type NodeI18n = I18n & PathMethods\n\n/**\n * Node `createI18n` (`@i18n-micro/node`) + VitePress path methods from the router adapter.\n */\nexport function createI18n(options: CreateI18nOptions): NodeI18n {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = (options.locales?.length ? options.locales : [options.locale]).map((item) => (typeof item === 'string' ? { code: item } : item))\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n\n return createNodeI18n(options).extend({\n localizePath: adapter.localizePath,\n switchLocalePath: adapter.switchLocalePath,\n getLocaleFromPath: adapter.getLocaleFromPath,\n removeLocaleFromPath: adapter.removeLocaleFromPath,\n routeNameFromPath: adapter.routeNameFromPath,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"node.cjs","names":[],"sources":["../src/runtime/node-create.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createI18n as createNodeI18n, type I18n, type I18nOptions } from '@i18n-micro/node'\nimport { createVitePressRouterAdapter, type PathMethods } from '../router/adapter'\n\nexport type { I18nOptions, LoadedTranslations } from '@i18n-micro/node'\nexport { loadTranslations, loadRootTranslations } from '@i18n-micro/node'\nexport type { PathMethods }\n\nexport interface CreateI18nOptions extends I18nOptions {\n /** Locales for path helpers (`localizePath`, …). Defaults to `[{ code: locale }]`. */\n locales?: Locale[] | string[]\n defaultLocale?: string\n localeKeyToCode?: Record<string, string>\n base?: string\n}\n\nexport type NodeI18n = I18n & PathMethods\n\n/**\n * Node `createI18n` (`@i18n-micro/node`) + VitePress path methods from the router adapter.\n */\nexport function createI18n(options: CreateI18nOptions): NodeI18n {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = (options.locales?.length ? options.locales : [options.locale]).map((item) => (typeof item === 'string' ? { code: item } : item))\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n\n return createNodeI18n(options).extend({\n localizePath: adapter.localizePath,\n switchLocalePath: adapter.switchLocalePath,\n getLocaleFromPath: adapter.getLocaleFromPath,\n removeLocaleFromPath: adapter.removeLocaleFromPath,\n routeNameFromPath: adapter.routeNameFromPath,\n })\n}\n"],"mappings":"6LAqBA,SAAgB,EAAW,EAAsC,CAC/D,IAAM,EAAgB,EAAQ,eAAiB,EAAQ,OACjD,GAAW,EAAQ,SAAS,OAAS,EAAQ,QAAU,CAAC,EAAQ,MAAM,EAAA,CAAG,IAAK,GAAU,OAAO,GAAS,SAAW,CAAE,KAAM,CAAK,EAAI,CAAK,EACzI,EAAU,EAAA,EAA6B,CAC3C,UACA,gBACA,gBAAiB,EAAQ,gBACzB,KAAM,EAAQ,IAChB,CAAC,EAED,OAAA,EAAO,EAAA,WAAA,CAAe,CAAO,CAAC,CAAC,OAAO,CACpC,aAAc,EAAQ,aACtB,iBAAkB,EAAQ,iBAC1B,kBAAmB,EAAQ,kBAC3B,qBAAsB,EAAQ,qBAC9B,kBAAmB,EAAQ,iBAC7B,CAAC,CACH"}
|
package/dist/node.mjs
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { t as e } from "./adapter-CAJNI6Sw.js";
|
|
2
|
+
import { t } from "./vitepress-locales-DOhKs3q5.js";
|
|
3
|
+
import { createI18n as n, loadRootTranslations as r, loadTranslations as i } from "@i18n-micro/node";
|
|
4
|
+
//#region src/runtime/node-create.ts
|
|
5
|
+
function a(t) {
|
|
6
|
+
let r = t.defaultLocale || t.locale, i = (t.locales?.length ? t.locales : [t.locale]).map((e) => typeof e == "string" ? { code: e } : e), a = e({
|
|
7
|
+
locales: i,
|
|
8
|
+
defaultLocale: r,
|
|
9
|
+
localeKeyToCode: t.localeKeyToCode,
|
|
10
|
+
base: t.base
|
|
11
|
+
});
|
|
12
|
+
return n(t).extend({
|
|
13
|
+
localizePath: a.localizePath,
|
|
14
|
+
switchLocalePath: a.switchLocalePath,
|
|
15
|
+
getLocaleFromPath: a.getLocaleFromPath,
|
|
16
|
+
removeLocaleFromPath: a.removeLocaleFromPath,
|
|
17
|
+
routeNameFromPath: a.routeNameFromPath
|
|
18
|
+
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
L as loadTranslations
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=node.mjs.map
|
|
20
|
+
//#endregion
|
|
21
|
+
export { t as buildVitePressLocales, a as createI18n, r as loadRootTranslations, i as loadTranslations };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=node.mjs.map
|
package/dist/node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.mjs","sources":["../src/runtime/node-create.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createI18n as createNodeI18n, type I18n, type I18nOptions } from '@i18n-micro/node'\nimport { createVitePressRouterAdapter, type PathMethods } from '../router/adapter'\n\nexport type { I18nOptions, LoadedTranslations } from '@i18n-micro/node'\nexport { loadTranslations, loadRootTranslations } from '@i18n-micro/node'\nexport type { PathMethods }\n\nexport interface CreateI18nOptions extends I18nOptions {\n /** Locales for path helpers (`localizePath`, …). Defaults to `[{ code: locale }]`. */\n locales?: Locale[] | string[]\n defaultLocale?: string\n localeKeyToCode?: Record<string, string>\n base?: string\n}\n\nexport type NodeI18n = I18n & PathMethods\n\n/**\n * Node `createI18n` (`@i18n-micro/node`) + VitePress path methods from the router adapter.\n */\nexport function createI18n(options: CreateI18nOptions): NodeI18n {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = (options.locales?.length ? options.locales : [options.locale]).map((item) => (typeof item === 'string' ? { code: item } : item))\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n\n return createNodeI18n(options).extend({\n localizePath: adapter.localizePath,\n switchLocalePath: adapter.switchLocalePath,\n getLocaleFromPath: adapter.getLocaleFromPath,\n removeLocaleFromPath: adapter.removeLocaleFromPath,\n routeNameFromPath: adapter.routeNameFromPath,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"node.mjs","names":[],"sources":["../src/runtime/node-create.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createI18n as createNodeI18n, type I18n, type I18nOptions } from '@i18n-micro/node'\nimport { createVitePressRouterAdapter, type PathMethods } from '../router/adapter'\n\nexport type { I18nOptions, LoadedTranslations } from '@i18n-micro/node'\nexport { loadTranslations, loadRootTranslations } from '@i18n-micro/node'\nexport type { PathMethods }\n\nexport interface CreateI18nOptions extends I18nOptions {\n /** Locales for path helpers (`localizePath`, …). Defaults to `[{ code: locale }]`. */\n locales?: Locale[] | string[]\n defaultLocale?: string\n localeKeyToCode?: Record<string, string>\n base?: string\n}\n\nexport type NodeI18n = I18n & PathMethods\n\n/**\n * Node `createI18n` (`@i18n-micro/node`) + VitePress path methods from the router adapter.\n */\nexport function createI18n(options: CreateI18nOptions): NodeI18n {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = (options.locales?.length ? options.locales : [options.locale]).map((item) => (typeof item === 'string' ? { code: item } : item))\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n\n return createNodeI18n(options).extend({\n localizePath: adapter.localizePath,\n switchLocalePath: adapter.switchLocalePath,\n getLocaleFromPath: adapter.getLocaleFromPath,\n removeLocaleFromPath: adapter.removeLocaleFromPath,\n routeNameFromPath: adapter.routeNameFromPath,\n })\n}\n"],"mappings":";;;;AAqBA,SAAgB,EAAW,GAAsC;CAC/D,IAAM,IAAgB,EAAQ,iBAAiB,EAAQ,QACjD,KAAW,EAAQ,SAAS,SAAS,EAAQ,UAAU,CAAC,EAAQ,MAAM,EAAA,CAAG,KAAK,MAAU,OAAO,KAAS,WAAW,EAAE,MAAM,EAAK,IAAI,CAAK,GACzI,IAAU,EAA6B;EAC3C;EACA;EACA,iBAAiB,EAAQ;EACzB,MAAM,EAAQ;CAChB,CAAC;CAED,OAAO,EAAe,CAAO,CAAC,CAAC,OAAO;EACpC,cAAc,EAAQ;EACtB,kBAAkB,EAAQ;EAC1B,mBAAmB,EAAQ;EAC3B,sBAAsB,EAAQ;EAC9B,mBAAmB,EAAQ;CAC7B,CAAC;AACH"}
|
package/dist/theme.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=theme.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapter-eYZZOC9d.cjs"),t=require("./create-Cwu2djcO.cjs");let n=require("virtual:i18n-micro/config"),r=require("virtual:i18n-micro/messages");function i(i,a={}){let o=a.enhanceApp,s=i.enhanceApp,c=new WeakMap;return{...i,async enhanceApp(i){let l=c.get(i.app);if(!l){let o=a.config??n.config,s=a.messages??r.messages,u=a.routeMessages??r.routeMessages,d=o.localeCodes.length?o.localeCodes:o.locales.map(e=>e.code),f=a.localeKeyToCode??o.localeKeyToCode,p=e.n(i.router.route.path,d,o.defaultLocale,f,o.base);l=t.t({locale:p,defaultLocale:o.defaultLocale,fallbackLocale:o.fallbackLocale,locales:o.locales,messages:s,routeMessages:u,missingWarn:o.missingWarn??void 0,syncWithVitePress:o.syncWithVitePress,localeKeyToCode:f,base:o.base,plural:a.plural,missingHandler:a.missingHandler}),c.set(i.app,l)}l.enhanceApp(i),s&&await s(i),o&&await o(i),l.enhanceApp(i)}}}exports.defineI18nTheme=i;
|
|
2
|
+
//# sourceMappingURL=theme.cjs.map
|
package/dist/theme.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.cjs","sources":["../src/runtime/define-theme.ts"],"sourcesContent":["import type { PluralFunc, Translations } from '@i18n-micro/types'\nimport type { Theme } from 'vitepress'\nimport { config as virtualConfig } from 'virtual:i18n-micro/config'\nimport { messages as virtualMessages, routeMessages as virtualRouteMessages } from 'virtual:i18n-micro/messages'\nimport { createI18n, type CreateI18nResult } from './create'\nimport { getLocaleFromPath } from '../router/adapter'\nimport type { VirtualI18nConfig } from '../plugin/with-i18n'\n\ntype EnhanceAppContext = Parameters<NonNullable<Theme['enhanceApp']>>[0]\n\nexport interface DefineI18nThemeOptions {\n /**\n * Extra `enhanceApp` run after i18n is installed.\n */\n enhanceApp?: NonNullable<Theme['enhanceApp']>\n /**\n * Overrides not serializable into `virtual:i18n-micro/config`.\n */\n plural?: PluralFunc\n missingHandler?: (locale: string, key: string, routeName: string) => void\n localeKeyToCode?: Record<string, string>\n /**\n * Optional overrides (tests / advanced). Defaults come from `virtual:i18n-micro/*`\n * registered by `withI18n`.\n */\n config?: VirtualI18nConfig\n messages?: Record<string, Translations>\n routeMessages?: Record<string, Record<string, Translations>>\n}\n\n/**\n * Zero-boilerplate theme wiring. Requires `withI18n(...)` in `.vitepress/config`\n * so virtual config + messages modules exist.\n *\n * Uses **static** `virtual:i18n-micro/*` imports so VitePress SSG can rewrite them.\n * Import this helper from `@i18n-micro/vitepress/theme` (not the root entry) so Node\n * config evaluation never loads virtual modules.\n *\n * @example\n * ```ts\n * import DefaultTheme from 'vitepress/theme'\n * import { defineI18nTheme } from '@i18n-micro/vitepress/theme'\n *\n * export default defineI18nTheme(DefaultTheme)\n * ```\n */\nexport function defineI18nTheme<T extends Theme>(base: T, options: DefineI18nThemeOptions = {}): T {\n const userEnhance = options.enhanceApp\n const baseEnhance = base.enhanceApp\n\n // Per app instance (SSR-safe: WeakMap by app).\n const byApp = new WeakMap<object, CreateI18nResult>()\n\n return {\n ...base,\n async enhanceApp(ctx: EnhanceAppContext) {\n let installed = byApp.get(ctx.app)\n if (!installed) {\n // Cast via `unknown`: root typecheck also sees Astro's ambient `virtual:i18n-micro/config`.\n const config = (options.config ?? virtualConfig) as unknown as VirtualI18nConfig\n const messages = options.messages ?? (virtualMessages as Record<string, Translations>)\n const routeMessages = options.routeMessages ?? (virtualRouteMessages as Record<string, Record<string, Translations>>)\n\n const localeCodes = config.localeCodes.length ? config.localeCodes : config.locales.map((l) => l.code)\n const localeKeyToCode = options.localeKeyToCode ?? config.localeKeyToCode\n const initialLocale = getLocaleFromPath(ctx.router.route.path, localeCodes, config.defaultLocale, localeKeyToCode, config.base)\n\n installed = createI18n({\n locale: initialLocale,\n defaultLocale: config.defaultLocale,\n fallbackLocale: config.fallbackLocale,\n locales: config.locales,\n messages,\n routeMessages,\n missingWarn: config.missingWarn ?? undefined,\n syncWithVitePress: config.syncWithVitePress,\n localeKeyToCode,\n base: config.base,\n plural: options.plural,\n missingHandler: options.missingHandler,\n })\n byApp.set(ctx.app, installed)\n }\n\n // Install plugin first so base/user enhanceApp can use $t / components.\n installed.enhanceApp(ctx as unknown as Parameters<typeof installed.enhanceApp>[0])\n if (baseEnhance) await baseEnhance(ctx)\n if (userEnhance) await userEnhance(ctx)\n // Re-run so route sync wraps any onAfterRouteChange set by base/user.\n installed.enhanceApp(ctx as unknown as Parameters<typeof installed.enhanceApp>[0])\n },\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"theme.cjs","names":[],"sources":["../src/runtime/define-theme.ts"],"sourcesContent":["import type { PluralFunc, Translations } from '@i18n-micro/types'\nimport type { Theme } from 'vitepress'\nimport { config as virtualConfig } from 'virtual:i18n-micro/config'\nimport { messages as virtualMessages, routeMessages as virtualRouteMessages } from 'virtual:i18n-micro/messages'\nimport { createI18n, type CreateI18nResult } from './create'\nimport { getLocaleFromPath } from '../router/adapter'\nimport type { VirtualI18nConfig } from '../plugin/with-i18n'\n\ntype EnhanceAppContext = Parameters<NonNullable<Theme['enhanceApp']>>[0]\n\nexport interface DefineI18nThemeOptions {\n /**\n * Extra `enhanceApp` run after i18n is installed.\n */\n enhanceApp?: NonNullable<Theme['enhanceApp']>\n /**\n * Overrides not serializable into `virtual:i18n-micro/config`.\n */\n plural?: PluralFunc\n missingHandler?: (locale: string, key: string, routeName: string) => void\n localeKeyToCode?: Record<string, string>\n /**\n * Optional overrides (tests / advanced). Defaults come from `virtual:i18n-micro/*`\n * registered by `withI18n`.\n */\n config?: VirtualI18nConfig\n messages?: Record<string, Translations>\n routeMessages?: Record<string, Record<string, Translations>>\n}\n\n/**\n * Zero-boilerplate theme wiring. Requires `withI18n(...)` in `.vitepress/config`\n * so virtual config + messages modules exist.\n *\n * Uses **static** `virtual:i18n-micro/*` imports so VitePress SSG can rewrite them.\n * Import this helper from `@i18n-micro/vitepress/theme` (not the root entry) so Node\n * config evaluation never loads virtual modules.\n *\n * @example\n * ```ts\n * import DefaultTheme from 'vitepress/theme'\n * import { defineI18nTheme } from '@i18n-micro/vitepress/theme'\n *\n * export default defineI18nTheme(DefaultTheme)\n * ```\n */\nexport function defineI18nTheme<T extends Theme>(base: T, options: DefineI18nThemeOptions = {}): T {\n const userEnhance = options.enhanceApp\n const baseEnhance = base.enhanceApp\n\n // Per app instance (SSR-safe: WeakMap by app).\n const byApp = new WeakMap<object, CreateI18nResult>()\n\n return {\n ...base,\n async enhanceApp(ctx: EnhanceAppContext) {\n let installed = byApp.get(ctx.app)\n if (!installed) {\n // Cast via `unknown`: root typecheck also sees Astro's ambient `virtual:i18n-micro/config`.\n const config = (options.config ?? virtualConfig) as unknown as VirtualI18nConfig\n const messages = options.messages ?? (virtualMessages as Record<string, Translations>)\n const routeMessages = options.routeMessages ?? (virtualRouteMessages as Record<string, Record<string, Translations>>)\n\n const localeCodes = config.localeCodes.length ? config.localeCodes : config.locales.map((l) => l.code)\n const localeKeyToCode = options.localeKeyToCode ?? config.localeKeyToCode\n const initialLocale = getLocaleFromPath(ctx.router.route.path, localeCodes, config.defaultLocale, localeKeyToCode, config.base)\n\n installed = createI18n({\n locale: initialLocale,\n defaultLocale: config.defaultLocale,\n fallbackLocale: config.fallbackLocale,\n locales: config.locales,\n messages,\n routeMessages,\n missingWarn: config.missingWarn ?? undefined,\n syncWithVitePress: config.syncWithVitePress,\n localeKeyToCode,\n base: config.base,\n plural: options.plural,\n missingHandler: options.missingHandler,\n })\n byApp.set(ctx.app, installed)\n }\n\n // Install plugin first so base/user enhanceApp can use $t / components.\n installed.enhanceApp(ctx as unknown as Parameters<typeof installed.enhanceApp>[0])\n if (baseEnhance) await baseEnhance(ctx)\n if (userEnhance) await userEnhance(ctx)\n // Re-run so route sync wraps any onAfterRouteChange set by base/user.\n installed.enhanceApp(ctx as unknown as Parameters<typeof installed.enhanceApp>[0])\n },\n }\n}\n"],"mappings":"oOA8CA,SAAgB,EAAiC,EAAS,EAAkC,CAAC,EAAM,CACjG,IAAM,EAAc,EAAQ,WACtB,EAAc,EAAK,WAGnB,EAAQ,IAAI,QAElB,MAAO,CACL,GAAG,EACH,MAAM,WAAW,EAAwB,CACvC,IAAI,EAAY,EAAM,IAAI,EAAI,GAAG,EACjC,GAAI,CAAC,EAAW,CAEd,IAAM,EAAU,EAAQ,QAAU,EAAA,OAC5B,EAAW,EAAQ,UAAa,EAAA,SAChC,EAAgB,EAAQ,eAAkB,EAAA,cAE1C,EAAc,EAAO,YAAY,OAAS,EAAO,YAAc,EAAO,QAAQ,IAAK,GAAM,EAAE,IAAI,EAC/F,EAAkB,EAAQ,iBAAmB,EAAO,gBACpD,EAAgB,EAAA,EAAkB,EAAI,OAAO,MAAM,KAAM,EAAa,EAAO,cAAe,EAAiB,EAAO,IAAI,EAE9H,EAAY,EAAA,EAAW,CACrB,OAAQ,EACR,cAAe,EAAO,cACtB,eAAgB,EAAO,eACvB,QAAS,EAAO,QAChB,WACA,gBACA,YAAa,EAAO,aAAe,IAAA,GACnC,kBAAmB,EAAO,kBAC1B,kBACA,KAAM,EAAO,KACb,OAAQ,EAAQ,OAChB,eAAgB,EAAQ,cAC1B,CAAC,EACD,EAAM,IAAI,EAAI,IAAK,CAAS,CAC9B,CAGA,EAAU,WAAW,CAA4D,EAC7E,GAAa,MAAM,EAAY,CAAG,EAClC,GAAa,MAAM,EAAY,CAAG,EAEtC,EAAU,WAAW,CAA4D,CACnF,CACF,CACF"}
|