@fluenti/nuxt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +311 -0
- package/dist/detectors-CFJvuwzi.cjs +2 -0
- package/dist/detectors-CFJvuwzi.cjs.map +1 -0
- package/dist/detectors-DhkfHBHr.js +84 -0
- package/dist/detectors-DhkfHBHr.js.map +1 -0
- package/dist/locale-head-BfsESdd7.cjs +2 -0
- package/dist/locale-head-BfsESdd7.cjs.map +1 -0
- package/dist/locale-head-CqUlvy3O.js +38 -0
- package/dist/locale-head-CqUlvy3O.js.map +1 -0
- package/dist/module.cjs +2 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.js +104 -0
- package/dist/module.js.map +1 -0
- package/dist/page-extend-DJ7wpuVj.js +25 -0
- package/dist/page-extend-DJ7wpuVj.js.map +1 -0
- package/dist/page-extend-OvV-ZhFB.cjs +2 -0
- package/dist/page-extend-OvV-ZhFB.cjs.map +1 -0
- package/dist/path-utils-BQIsp_or.cjs +2 -0
- package/dist/path-utils-BQIsp_or.cjs.map +1 -0
- package/dist/path-utils-BcvXLCGi.js +28 -0
- package/dist/path-utils-BcvXLCGi.js.map +1 -0
- package/dist/runtime/client.cjs +2 -0
- package/dist/runtime/client.cjs.map +1 -0
- package/dist/runtime/client.d.ts +25 -0
- package/dist/runtime/client.d.ts.map +1 -0
- package/dist/runtime/client.js +18 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/components/NuxtLinkLocale.cjs +2 -0
- package/dist/runtime/components/NuxtLinkLocale.cjs.map +1 -0
- package/dist/runtime/components/NuxtLinkLocale.d.ts +44 -0
- package/dist/runtime/components/NuxtLinkLocale.d.ts.map +1 -0
- package/dist/runtime/components/NuxtLinkLocale.js +28 -0
- package/dist/runtime/components/NuxtLinkLocale.js.map +1 -0
- package/dist/runtime/composables.cjs +2 -0
- package/dist/runtime/composables.cjs.map +1 -0
- package/dist/runtime/composables.d.ts +37 -0
- package/dist/runtime/composables.d.ts.map +1 -0
- package/dist/runtime/composables.js +25 -0
- package/dist/runtime/composables.js.map +1 -0
- package/dist/runtime/detectors/cookie.d.ts +4 -0
- package/dist/runtime/detectors/cookie.d.ts.map +1 -0
- package/dist/runtime/detectors/header.d.ts +4 -0
- package/dist/runtime/detectors/header.d.ts.map +1 -0
- package/dist/runtime/detectors/index.d.ts +12 -0
- package/dist/runtime/detectors/index.d.ts.map +1 -0
- package/dist/runtime/detectors/path.d.ts +4 -0
- package/dist/runtime/detectors/path.d.ts.map +1 -0
- package/dist/runtime/detectors/query.d.ts +4 -0
- package/dist/runtime/detectors/query.d.ts.map +1 -0
- package/dist/runtime/index.cjs +1 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/locale-head.d.ts +30 -0
- package/dist/runtime/locale-head.d.ts.map +1 -0
- package/dist/runtime/middleware/locale-redirect.cjs +2 -0
- package/dist/runtime/middleware/locale-redirect.cjs.map +1 -0
- package/dist/runtime/middleware/locale-redirect.d.ts +10 -0
- package/dist/runtime/middleware/locale-redirect.d.ts.map +1 -0
- package/dist/runtime/middleware/locale-redirect.js +19 -0
- package/dist/runtime/middleware/locale-redirect.js.map +1 -0
- package/dist/runtime/page-extend.d.ts +19 -0
- package/dist/runtime/page-extend.d.ts.map +1 -0
- package/dist/runtime/path-utils.d.ts +19 -0
- package/dist/runtime/path-utils.d.ts.map +1 -0
- package/dist/runtime/plugin.cjs +2 -0
- package/dist/runtime/plugin.cjs.map +1 -0
- package/dist/runtime/plugin.d.ts +9 -0
- package/dist/runtime/plugin.d.ts.map +1 -0
- package/dist/runtime/plugin.js +30 -0
- package/dist/runtime/plugin.js.map +1 -0
- package/dist/runtime/standalone-composables.d.ts +19 -0
- package/dist/runtime/standalone-composables.d.ts.map +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","names":[],"sources":["../src/runtime/standalone-composables.ts","../src/module.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { ComputedRef, Ref } from 'vue'\nimport { localePath, switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\nimport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\nimport { buildLocaleHead } from './locale-head'\n\n/**\n * Standalone composable for locale-prefixed paths (no Nuxt dependency).\n * Accepts explicit locale ref and config instead of reading from Nuxt context.\n */\nexport function useLocalePath(\n locale: Ref<string>,\n config: FluentNuxtRuntimeConfig,\n): (path: string, targetLocale?: string) => string {\n return (path: string, targetLocale?: string) => {\n return localePath(\n path,\n targetLocale ?? locale.value,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Standalone composable for switch-locale paths (no Nuxt dependency).\n * Accepts explicit current path ref and config.\n */\nexport function useSwitchLocalePath(\n currentPath: Ref<string>,\n config: FluentNuxtRuntimeConfig,\n): (locale: string) => string {\n return (newLocale: string) => {\n return switchLocalePath(\n currentPath.value,\n newLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Standalone composable for locale-aware head metadata (no Nuxt dependency).\n * Accepts explicit locale, path, and config refs.\n */\nexport function useLocaleHead(\n locale: Ref<string>,\n currentPath: Ref<string>,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): ComputedRef<LocaleHeadMeta> {\n return computed(() => {\n return buildLocaleHead(locale.value, currentPath.value, config, options)\n })\n}\n","import { defineNuxtModule, addPlugin, addImports, addComponent, addRouteMiddleware, createResolver } from '@nuxt/kit'\nimport type { FluentNuxtOptions } from './types'\nimport { extendPages } from './runtime/page-extend'\n\nexport type { FluentNuxtOptions, Strategy, FluentNuxtRuntimeConfig, DetectBrowserLanguageOptions, LocaleDetectContext, LocaleDetectorFn, BuiltinDetector, ISROptions } from './types'\nexport { localePath, extractLocaleFromPath, switchLocalePath } from './runtime/path-utils'\nexport { extendPages } from './runtime/page-extend'\nexport type { PageRoute } from './runtime/page-extend'\nexport { buildLocaleHead } from './runtime/locale-head'\nexport type { LocaleHeadMeta, LocaleHeadOptions } from './runtime/locale-head'\nexport { useLocalePath, useSwitchLocalePath, useLocaleHead } from './runtime/standalone-composables'\n\nexport const MODULE_NAME = '@fluenti/nuxt'\nexport const CONFIG_KEY = 'fluenti'\n\nexport default defineNuxtModule<FluentNuxtOptions>({\n meta: {\n name: MODULE_NAME,\n configKey: CONFIG_KEY,\n compatibility: { nuxt: '>=3.0.0' },\n },\n defaults: {\n locales: [],\n defaultLocale: 'en',\n strategy: 'prefix_except_default',\n },\n setup(options, nuxt) {\n const { resolve } = createResolver(import.meta.url)\n\n // --- Inject runtime config ---\n const detectOrder = options.detectOrder ?? ['path', 'cookie', 'header']\n nuxt.options.runtimeConfig.public['fluenti'] = {\n locales: options.locales,\n defaultLocale: options.defaultLocale,\n strategy: options.strategy ?? 'prefix_except_default',\n detectBrowserLanguage: options.detectBrowserLanguage,\n detectOrder,\n }\n\n // --- Auto-register @fluenti/vite-plugin ---\n if (options.autoVitePlugin !== false) {\n try {\n const vitePlugin = require('@fluenti/vite-plugin')\n const plugin = vitePlugin.default ?? vitePlugin\n nuxt.options.vite = nuxt.options.vite || {}\n nuxt.options.vite.plugins = nuxt.options.vite.plugins || []\n ;(nuxt.options.vite.plugins as unknown[]).push(\n plugin({ framework: 'vue' }),\n )\n } catch {\n // @fluenti/vite-plugin is an optional peer dependency\n }\n }\n\n // --- Register runtime plugin ---\n addPlugin({\n src: resolve('./runtime/plugin'),\n mode: 'all',\n })\n\n // --- Extend routes with locale prefixes ---\n if (options.strategy !== 'no_prefix') {\n nuxt.hook('pages:extend', (pages) => {\n extendPages(pages, {\n locales: options.locales,\n defaultLocale: options.defaultLocale,\n strategy: options.strategy ?? 'prefix_except_default',\n })\n })\n }\n\n // --- Register locale redirect middleware ---\n if (options.strategy === 'prefix') {\n addRouteMiddleware({\n name: 'fluenti-locale-redirect',\n path: resolve('./runtime/middleware/locale-redirect'),\n global: true,\n })\n }\n\n // --- Auto-import composables ---\n addImports([\n { name: 'useLocalePath', from: resolve('./runtime/composables') },\n { name: 'useSwitchLocalePath', from: resolve('./runtime/composables') },\n { name: 'useLocaleHead', from: resolve('./runtime/composables') },\n { name: 'useI18n', from: '@fluenti/vue' },\n ])\n\n // --- Register NuxtLinkLocale component ---\n const prefix = options.componentPrefix ?? ''\n addComponent({\n name: `${prefix}NuxtLinkLocale`,\n filePath: resolve('./runtime/components/NuxtLinkLocale'),\n })\n\n // --- SSG / ISR: configure nitro prerender and route rules ---\n const strategy = options.strategy ?? 'prefix_except_default'\n if (strategy !== 'no_prefix') {\n const nuxtOpts = nuxt.options as unknown as Record<string, unknown>\n\n // Enable link crawling so locale-prefixed routes are discovered during prerender\n const nitroOpts = (nuxtOpts['nitro'] ?? (nuxtOpts['nitro'] = {})) as Record<string, unknown>\n const prerender = (nitroOpts['prerender'] ?? (nitroOpts['prerender'] = {})) as Record<string, unknown>\n prerender['crawlLinks'] = prerender['crawlLinks'] ?? true\n\n // For 'prefix' strategy, / has no matching route (all routes are\n // locale-prefixed). Replace the default / initial route with\n // /<defaultLocale> so the prerenderer starts from a valid route.\n if (strategy === 'prefix') {\n const routes = (prerender['routes'] ?? ['/']) as string[]\n prerender['routes'] = routes.map((r) =>\n r === '/' ? `/${options.defaultLocale}` : r,\n )\n }\n\n // ISR: generate routeRules for each locale pattern\n if (options.isr?.enabled) {\n const routeRules = (nuxtOpts['routeRules'] ?? (nuxtOpts['routeRules'] = {})) as Record<string, Record<string, unknown>>\n const ttl = options.isr.ttl ?? 3600\n for (const locale of options.locales) {\n if (locale === options.defaultLocale && strategy === 'prefix_except_default') {\n routeRules['/**'] = { ...routeRules['/**'], isr: ttl }\n } else {\n routeRules[`/${locale}/**`] = { ...routeRules[`/${locale}/**`], isr: ttl }\n }\n }\n }\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,EACd,GACA,GACiD;AACjD,SAAQ,GAAc,MACb,EACL,GACA,KAAgB,EAAO,OACvB,EAAO,eACP,EAAO,SACR;;AAQL,SAAgB,EACd,GACA,GAC4B;AAC5B,SAAQ,MACC,EACL,EAAY,OACZ,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;;AAQL,SAAgB,EACd,GACA,GACA,GACA,GAC6B;AAC7B,QAAO,QACE,EAAgB,EAAO,OAAO,EAAY,OAAO,GAAQ,EAAQ,CACxE;;;;AC5CJ,IAAa,IAAc,iBACd,IAAa,WAE1B,IAAe,EAAoC;CACjD,MAAM;EACJ,MAAM;EACN,WAAW;EACX,eAAe,EAAE,MAAM,WAAW;EACnC;CACD,UAAU;EACR,SAAS,EAAE;EACX,eAAe;EACf,UAAU;EACX;CACD,MAAM,GAAS,GAAM;EACnB,IAAM,EAAE,eAAY,EAAe,OAAO,KAAK,IAAI,EAG7C,IAAc,EAAQ,eAAe;GAAC;GAAQ;GAAU;GAAS;AAUvE,MATA,EAAK,QAAQ,cAAc,OAAO,UAAa;GAC7C,SAAS,EAAQ;GACjB,eAAe,EAAQ;GACvB,UAAU,EAAQ,YAAY;GAC9B,uBAAuB,EAAQ;GAC/B;GACD,EAGG,EAAQ,mBAAmB,GAC7B,KAAI;GACF,IAAM,IAAA,EAAqB,uBAAuB,EAC5C,IAAS,EAAW,WAAW;AAGnC,GAFF,EAAK,QAAQ,OAAO,EAAK,QAAQ,QAAQ,EAAE,EAC3C,EAAK,QAAQ,KAAK,UAAU,EAAK,QAAQ,KAAK,WAAW,EAAE,EACzD,EAAK,QAAQ,KAAK,QAAsB,KACxC,EAAO,EAAE,WAAW,OAAO,CAAC,CAC7B;UACK;AAyCV,EAnCA,EAAU;GACR,KAAK,EAAQ,mBAAmB;GAChC,MAAM;GACP,CAAC,EAGE,EAAQ,aAAa,eACvB,EAAK,KAAK,iBAAiB,MAAU;AACnC,KAAY,GAAO;IACjB,SAAS,EAAQ;IACjB,eAAe,EAAQ;IACvB,UAAU,EAAQ,YAAY;IAC/B,CAAC;IACF,EAIA,EAAQ,aAAa,YACvB,EAAmB;GACjB,MAAM;GACN,MAAM,EAAQ,uCAAuC;GACrD,QAAQ;GACT,CAAC,EAIJ,EAAW;GACT;IAAE,MAAM;IAAiB,MAAM,EAAQ,wBAAwB;IAAE;GACjE;IAAE,MAAM;IAAuB,MAAM,EAAQ,wBAAwB;IAAE;GACvE;IAAE,MAAM;IAAiB,MAAM,EAAQ,wBAAwB;IAAE;GACjE;IAAE,MAAM;IAAW,MAAM;IAAgB;GAC1C,CAAC,EAIF,EAAa;GACX,MAAM,GAFO,EAAQ,mBAAmB,GAExB;GAChB,UAAU,EAAQ,sCAAsC;GACzD,CAAC;EAGF,IAAM,IAAW,EAAQ,YAAY;AACrC,MAAI,MAAa,aAAa;GAC5B,IAAM,IAAW,EAAK,SAGhB,IAAa,AAAsB,EAAS,UAAW,EAAE,EACzD,IAAa,AAA2B,EAAU,cAAe,EAAE;AAczE,OAbA,EAAU,aAAgB,EAAU,cAAiB,IAKjD,MAAa,aAEf,EAAU,UADM,EAAU,UAAa,CAAC,IAAI,EACf,KAAK,MAChC,MAAM,MAAM,IAAI,EAAQ,kBAAkB,EAC3C,GAIC,EAAQ,KAAK,SAAS;IACxB,IAAM,IAAc,AAA2B,EAAS,eAAgB,EAAE,EACpE,IAAM,EAAQ,IAAI,OAAO;AAC/B,SAAK,IAAM,KAAU,EAAQ,QAC3B,CAAI,MAAW,EAAQ,iBAAiB,MAAa,0BACnD,EAAW,SAAS;KAAE,GAAG,EAAW;KAAQ,KAAK;KAAK,GAEtD,EAAW,IAAI,EAAO,QAAQ;KAAE,GAAG,EAAW,IAAI,EAAO;KAAO,KAAK;KAAK;;;;CAMrF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/runtime/page-extend.ts
|
|
2
|
+
function e(e, n) {
|
|
3
|
+
let { locales: r, defaultLocale: i, strategy: a } = n;
|
|
4
|
+
if (a === "no_prefix") return;
|
|
5
|
+
let o = [...e];
|
|
6
|
+
for (let n of r) if (!(a === "prefix_except_default" && n === i)) for (let r of o) {
|
|
7
|
+
let i = t(r, n);
|
|
8
|
+
e.push(i);
|
|
9
|
+
}
|
|
10
|
+
a === "prefix" && e.splice(0, o.length);
|
|
11
|
+
}
|
|
12
|
+
function t(e, t) {
|
|
13
|
+
let n = {
|
|
14
|
+
...e,
|
|
15
|
+
path: `/${t}${e.path === "/" ? "" : e.path}`
|
|
16
|
+
};
|
|
17
|
+
return e.name && (n.name = `${e.name}___${t}`), e.children && (n.children = e.children.map((e) => {
|
|
18
|
+
let n = { ...e };
|
|
19
|
+
return e.name && (n.name = `${e.name}___${t}`), n;
|
|
20
|
+
})), n;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { e as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=page-extend-DJ7wpuVj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-extend-DJ7wpuVj.js","names":[],"sources":["../src/runtime/page-extend.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/** Page route definition used for route extension */\nexport interface PageRoute {\n path: string\n name?: string\n children?: PageRoute[]\n}\n\n/**\n * Extend page routes with locale-prefixed variants.\n * Mutates the pages array in place (Nuxt convention).\n *\n * This is a build-time utility used in the module's `pages:extend` hook.\n */\nexport function extendPages(\n pages: PageRoute[],\n options: { locales: string[]; defaultLocale: string; strategy: Strategy },\n): void {\n const { locales, defaultLocale, strategy } = options\n if (strategy === 'no_prefix') return\n\n const originalPages = [...pages]\n\n for (const locale of locales) {\n // For prefix_except_default, skip creating prefixed routes for the default locale\n if (strategy === 'prefix_except_default' && locale === defaultLocale) continue\n\n for (const page of originalPages) {\n const prefixedPage = prefixPage(page, locale)\n pages.push(prefixedPage)\n }\n }\n\n // For prefix strategy, remove the original unprefixed routes\n // (every locale including default must have a prefix)\n if (strategy === 'prefix') {\n // Remove all original pages (they'll only exist as prefixed versions)\n pages.splice(0, originalPages.length)\n }\n}\n\nfunction prefixPage(page: PageRoute, locale: string): PageRoute {\n const prefixed: PageRoute = {\n ...page,\n path: `/${locale}${page.path === '/' ? '' : page.path}`,\n }\n if (page.name) {\n prefixed.name = `${page.name}___${locale}`\n }\n\n if (page.children) {\n prefixed.children = page.children.map((child) => {\n const prefixedChild: PageRoute = { ...child }\n if (child.name) {\n prefixedChild.name = `${child.name}___${locale}`\n }\n return prefixedChild\n })\n }\n\n return prefixed\n}\n"],"mappings":";AAeA,SAAgB,EACd,GACA,GACM;CACN,IAAM,EAAE,YAAS,kBAAe,gBAAa;AAC7C,KAAI,MAAa,YAAa;CAE9B,IAAM,IAAgB,CAAC,GAAG,EAAM;AAEhC,MAAK,IAAM,KAAU,EAEf,aAAa,2BAA2B,MAAW,GAEvD,MAAK,IAAM,KAAQ,GAAe;EAChC,IAAM,IAAe,EAAW,GAAM,EAAO;AAC7C,IAAM,KAAK,EAAa;;AAM5B,CAAI,MAAa,YAEf,EAAM,OAAO,GAAG,EAAc,OAAO;;AAIzC,SAAS,EAAW,GAAiB,GAA2B;CAC9D,IAAM,IAAsB;EAC1B,GAAG;EACH,MAAM,IAAI,IAAS,EAAK,SAAS,MAAM,KAAK,EAAK;EAClD;AAeD,QAdI,EAAK,SACP,EAAS,OAAO,GAAG,EAAK,KAAK,KAAK,MAGhC,EAAK,aACP,EAAS,WAAW,EAAK,SAAS,KAAK,MAAU;EAC/C,IAAM,IAA2B,EAAE,GAAG,GAAO;AAI7C,SAHI,EAAM,SACR,EAAc,OAAO,GAAG,EAAM,KAAK,KAAK,MAEnC;GACP,GAGG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,n){let{locales:r,defaultLocale:i,strategy:a}=n;if(a===`no_prefix`)return;let o=[...e];for(let n of r)if(!(a===`prefix_except_default`&&n===i))for(let r of o){let i=t(r,n);e.push(i)}a===`prefix`&&e.splice(0,o.length)}function t(e,t){let n={...e,path:`/${t}${e.path===`/`?``:e.path}`};return e.name&&(n.name=`${e.name}___${t}`),e.children&&(n.children=e.children.map(e=>{let n={...e};return e.name&&(n.name=`${e.name}___${t}`),n})),n}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
2
|
+
//# sourceMappingURL=page-extend-OvV-ZhFB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-extend-OvV-ZhFB.cjs","names":[],"sources":["../src/runtime/page-extend.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/** Page route definition used for route extension */\nexport interface PageRoute {\n path: string\n name?: string\n children?: PageRoute[]\n}\n\n/**\n * Extend page routes with locale-prefixed variants.\n * Mutates the pages array in place (Nuxt convention).\n *\n * This is a build-time utility used in the module's `pages:extend` hook.\n */\nexport function extendPages(\n pages: PageRoute[],\n options: { locales: string[]; defaultLocale: string; strategy: Strategy },\n): void {\n const { locales, defaultLocale, strategy } = options\n if (strategy === 'no_prefix') return\n\n const originalPages = [...pages]\n\n for (const locale of locales) {\n // For prefix_except_default, skip creating prefixed routes for the default locale\n if (strategy === 'prefix_except_default' && locale === defaultLocale) continue\n\n for (const page of originalPages) {\n const prefixedPage = prefixPage(page, locale)\n pages.push(prefixedPage)\n }\n }\n\n // For prefix strategy, remove the original unprefixed routes\n // (every locale including default must have a prefix)\n if (strategy === 'prefix') {\n // Remove all original pages (they'll only exist as prefixed versions)\n pages.splice(0, originalPages.length)\n }\n}\n\nfunction prefixPage(page: PageRoute, locale: string): PageRoute {\n const prefixed: PageRoute = {\n ...page,\n path: `/${locale}${page.path === '/' ? '' : page.path}`,\n }\n if (page.name) {\n prefixed.name = `${page.name}___${locale}`\n }\n\n if (page.children) {\n prefixed.children = page.children.map((child) => {\n const prefixedChild: PageRoute = { ...child }\n if (child.name) {\n prefixedChild.name = `${child.name}___${locale}`\n }\n return prefixedChild\n })\n }\n\n return prefixed\n}\n"],"mappings":"AAeA,SAAgB,EACd,EACA,EACM,CACN,GAAM,CAAE,UAAS,gBAAe,YAAa,EAC7C,GAAI,IAAa,YAAa,OAE9B,IAAM,EAAgB,CAAC,GAAG,EAAM,CAEhC,IAAK,IAAM,KAAU,EAEf,SAAa,yBAA2B,IAAW,GAEvD,IAAK,IAAM,KAAQ,EAAe,CAChC,IAAM,EAAe,EAAW,EAAM,EAAO,CAC7C,EAAM,KAAK,EAAa,CAMxB,IAAa,UAEf,EAAM,OAAO,EAAG,EAAc,OAAO,CAIzC,SAAS,EAAW,EAAiB,EAA2B,CAC9D,IAAM,EAAsB,CAC1B,GAAG,EACH,KAAM,IAAI,IAAS,EAAK,OAAS,IAAM,GAAK,EAAK,OAClD,CAeD,OAdI,EAAK,OACP,EAAS,KAAO,GAAG,EAAK,KAAK,KAAK,KAGhC,EAAK,WACP,EAAS,SAAW,EAAK,SAAS,IAAK,GAAU,CAC/C,IAAM,EAA2B,CAAE,GAAG,EAAO,CAI7C,OAHI,EAAM,OACR,EAAc,KAAO,GAAG,EAAM,KAAK,KAAK,KAEnC,GACP,EAGG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,n,r){return r===`no_prefix`?e:r===`prefix_except_default`&&t===n?e.startsWith(`/`)?e:`/${e}`:`/${t}${e===`/`?``:e.startsWith(`/`)?e:`/${e}`}`}function t(e,t){let n=e.match(/^\/([^/]+)(.*)$/);if(!n)return{locale:null,pathWithoutLocale:e};let r=n[1],i=n[2]||`/`;return t.includes(r)?{locale:r,pathWithoutLocale:i||`/`}:{locale:null,pathWithoutLocale:e}}function n(n,r,i,a,o){if(o===`no_prefix`)return n;let{pathWithoutLocale:s}=t(n,i);return e(s,r,a,o)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=path-utils-BQIsp_or.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils-BQIsp_or.cjs","names":[],"sources":["../src/runtime/path-utils.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/**\n * Add a locale prefix to a path based on the routing strategy.\n */\nexport function localePath(\n path: string,\n locale: string,\n defaultLocale: string,\n strategy: Strategy,\n): string {\n if (strategy === 'no_prefix') return path\n\n // prefix_except_default: default locale gets no prefix\n if (strategy === 'prefix_except_default' && locale === defaultLocale) {\n return path.startsWith('/') ? path : `/${path}`\n }\n\n // prefix / prefix_and_default: always add prefix\n const cleanPath = path === '/' ? '' : (path.startsWith('/') ? path : `/${path}`)\n return `/${locale}${cleanPath}`\n}\n\n/**\n * Extract the locale code from the beginning of a path.\n * Returns the locale and the path without the locale prefix.\n */\nexport function extractLocaleFromPath(\n path: string,\n locales: string[],\n): { locale: string | null; pathWithoutLocale: string } {\n // Match /{locale} or /{locale}/...\n const match = path.match(/^\\/([^/]+)(.*)$/)\n if (!match) return { locale: null, pathWithoutLocale: path }\n\n const segment = match[1]!\n const rest = match[2] || '/'\n\n if (locales.includes(segment)) {\n return {\n locale: segment,\n pathWithoutLocale: rest || '/',\n }\n }\n\n return { locale: null, pathWithoutLocale: path }\n}\n\n/**\n * Generate a path for switching to a different locale,\n * preserving the current route path.\n */\nexport function switchLocalePath(\n currentPath: string,\n newLocale: string,\n locales: string[],\n defaultLocale: string,\n strategy: Strategy,\n): string {\n if (strategy === 'no_prefix') return currentPath\n\n // Extract current locale prefix (if any)\n const { pathWithoutLocale } = extractLocaleFromPath(currentPath, locales)\n\n // Build new path with the target locale\n return localePath(pathWithoutLocale, newLocale, defaultLocale, strategy)\n}\n"],"mappings":"AAKA,SAAgB,EACd,EACA,EACA,EACA,EACQ,CAUR,OATI,IAAa,YAAoB,EAGjC,IAAa,yBAA2B,IAAW,EAC9C,EAAK,WAAW,IAAI,CAAG,EAAO,IAAI,IAKpC,IAAI,IADO,IAAS,IAAM,GAAM,EAAK,WAAW,IAAI,CAAG,EAAO,IAAI,MAQ3E,SAAgB,EACd,EACA,EACsD,CAEtD,IAAM,EAAQ,EAAK,MAAM,kBAAkB,CAC3C,GAAI,CAAC,EAAO,MAAO,CAAE,OAAQ,KAAM,kBAAmB,EAAM,CAE5D,IAAM,EAAU,EAAM,GAChB,EAAO,EAAM,IAAM,IASzB,OAPI,EAAQ,SAAS,EAAQ,CACpB,CACL,OAAQ,EACR,kBAAmB,GAAQ,IAC5B,CAGI,CAAE,OAAQ,KAAM,kBAAmB,EAAM,CAOlD,SAAgB,EACd,EACA,EACA,EACA,EACA,EACQ,CACR,GAAI,IAAa,YAAa,OAAO,EAGrC,GAAM,CAAE,qBAAsB,EAAsB,EAAa,EAAQ,CAGzE,OAAO,EAAW,EAAmB,EAAW,EAAe,EAAS"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/runtime/path-utils.ts
|
|
2
|
+
function e(e, t, n, r) {
|
|
3
|
+
return r === "no_prefix" ? e : r === "prefix_except_default" && t === n ? e.startsWith("/") ? e : `/${e}` : `/${t}${e === "/" ? "" : e.startsWith("/") ? e : `/${e}`}`;
|
|
4
|
+
}
|
|
5
|
+
function t(e, t) {
|
|
6
|
+
let n = e.match(/^\/([^/]+)(.*)$/);
|
|
7
|
+
if (!n) return {
|
|
8
|
+
locale: null,
|
|
9
|
+
pathWithoutLocale: e
|
|
10
|
+
};
|
|
11
|
+
let r = n[1], i = n[2] || "/";
|
|
12
|
+
return t.includes(r) ? {
|
|
13
|
+
locale: r,
|
|
14
|
+
pathWithoutLocale: i || "/"
|
|
15
|
+
} : {
|
|
16
|
+
locale: null,
|
|
17
|
+
pathWithoutLocale: e
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function n(n, r, i, a, o) {
|
|
21
|
+
if (o === "no_prefix") return n;
|
|
22
|
+
let { pathWithoutLocale: s } = t(n, i);
|
|
23
|
+
return e(s, r, a, o);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { e as n, n as r, t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=path-utils-BcvXLCGi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils-BcvXLCGi.js","names":[],"sources":["../src/runtime/path-utils.ts"],"sourcesContent":["import type { Strategy } from '../types'\n\n/**\n * Add a locale prefix to a path based on the routing strategy.\n */\nexport function localePath(\n path: string,\n locale: string,\n defaultLocale: string,\n strategy: Strategy,\n): string {\n if (strategy === 'no_prefix') return path\n\n // prefix_except_default: default locale gets no prefix\n if (strategy === 'prefix_except_default' && locale === defaultLocale) {\n return path.startsWith('/') ? path : `/${path}`\n }\n\n // prefix / prefix_and_default: always add prefix\n const cleanPath = path === '/' ? '' : (path.startsWith('/') ? path : `/${path}`)\n return `/${locale}${cleanPath}`\n}\n\n/**\n * Extract the locale code from the beginning of a path.\n * Returns the locale and the path without the locale prefix.\n */\nexport function extractLocaleFromPath(\n path: string,\n locales: string[],\n): { locale: string | null; pathWithoutLocale: string } {\n // Match /{locale} or /{locale}/...\n const match = path.match(/^\\/([^/]+)(.*)$/)\n if (!match) return { locale: null, pathWithoutLocale: path }\n\n const segment = match[1]!\n const rest = match[2] || '/'\n\n if (locales.includes(segment)) {\n return {\n locale: segment,\n pathWithoutLocale: rest || '/',\n }\n }\n\n return { locale: null, pathWithoutLocale: path }\n}\n\n/**\n * Generate a path for switching to a different locale,\n * preserving the current route path.\n */\nexport function switchLocalePath(\n currentPath: string,\n newLocale: string,\n locales: string[],\n defaultLocale: string,\n strategy: Strategy,\n): string {\n if (strategy === 'no_prefix') return currentPath\n\n // Extract current locale prefix (if any)\n const { pathWithoutLocale } = extractLocaleFromPath(currentPath, locales)\n\n // Build new path with the target locale\n return localePath(pathWithoutLocale, newLocale, defaultLocale, strategy)\n}\n"],"mappings":";AAKA,SAAgB,EACd,GACA,GACA,GACA,GACQ;AAUR,QATI,MAAa,cAAoB,IAGjC,MAAa,2BAA2B,MAAW,IAC9C,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI,MAKpC,IAAI,IADO,MAAS,MAAM,KAAM,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;;AAQ3E,SAAgB,EACd,GACA,GACsD;CAEtD,IAAM,IAAQ,EAAK,MAAM,kBAAkB;AAC3C,KAAI,CAAC,EAAO,QAAO;EAAE,QAAQ;EAAM,mBAAmB;EAAM;CAE5D,IAAM,IAAU,EAAM,IAChB,IAAO,EAAM,MAAM;AASzB,QAPI,EAAQ,SAAS,EAAQ,GACpB;EACL,QAAQ;EACR,mBAAmB,KAAQ;EAC5B,GAGI;EAAE,QAAQ;EAAM,mBAAmB;EAAM;;AAOlD,SAAgB,EACd,GACA,GACA,GACA,GACA,GACQ;AACR,KAAI,MAAa,YAAa,QAAO;CAGrC,IAAM,EAAE,yBAAsB,EAAsB,GAAa,EAAQ;AAGzE,QAAO,EAAW,GAAmB,GAAW,GAAe,EAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../page-extend-OvV-ZhFB.cjs`),t=require(`../path-utils-BQIsp_or.cjs`),n=require(`../locale-head-BfsESdd7.cjs`);let r=require(`vue`);function i(e,n){return(r,i)=>t.n(r,i??e.value,n.defaultLocale,n.strategy)}function a(e,n){return r=>t.r(e.value,r,n.locales,n.defaultLocale,n.strategy)}function o(e,t,i,a){return(0,r.computed)(()=>n.t(e.value,t.value,i,a))}exports.buildLocaleHead=n.t,exports.extendPages=e.t,exports.extractLocaleFromPath=t.t,exports.localePath=t.n,exports.switchLocalePath=t.r,exports.useLocaleHead=o,exports.useLocalePath=i,exports.useSwitchLocalePath=a;
|
|
2
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.cjs","names":[],"sources":["../../src/runtime/client.ts"],"sourcesContent":["// Browser-safe exports — no Nuxt auto-imports (#imports) dependency.\n// Use this entry point in non-Nuxt environments (e.g. plain Vue SPA).\n\nimport { computed } from 'vue'\nimport type { ComputedRef, Ref } from 'vue'\nimport { localePath, switchLocalePath } from './path-utils'\nimport { buildLocaleHead } from './locale-head'\nimport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n// Path utilities (pure functions, framework-agnostic)\nexport { localePath, extractLocaleFromPath, switchLocalePath } from './path-utils'\n\n// Page route extension (build-time utility)\nexport { extendPages } from './page-extend'\nexport type { PageRoute } from './page-extend'\n\n// Locale head (pure function)\nexport { buildLocaleHead } from './locale-head'\nexport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\n\n// Re-export types\nexport type { FluentNuxtRuntimeConfig } from '../types'\n\n/**\n * Browser-safe composable for locale-prefixed paths.\n * Accepts explicit locale and config instead of using Nuxt auto-imports.\n */\nexport function useLocalePath(\n locale: Ref<string>,\n config: FluentNuxtRuntimeConfig,\n): (path: string, targetLocale?: string) => string {\n return (path: string, targetLocale?: string) => {\n return localePath(\n path,\n targetLocale ?? locale.value,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Browser-safe composable for switching locale paths.\n * Accepts explicit currentPath and config instead of using Nuxt auto-imports.\n */\nexport function useSwitchLocalePath(\n currentPath: Ref<string> | ComputedRef<string>,\n config: FluentNuxtRuntimeConfig,\n): (locale: string) => string {\n return (newLocale: string) => {\n return switchLocalePath(\n currentPath.value,\n newLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Browser-safe composable for locale head metadata.\n * Accepts explicit locale, currentPath, and config instead of using Nuxt auto-imports.\n */\nexport function useLocaleHead(\n locale: Ref<string>,\n currentPath: Ref<string> | ComputedRef<string>,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): ComputedRef<LocaleHeadMeta> {\n return computed(() => {\n return buildLocaleHead(locale.value, currentPath.value, config, options)\n })\n}\n"],"mappings":"wNA4BA,SAAgB,EACd,EACA,EACiD,CACjD,OAAQ,EAAc,IACb,EAAA,EACL,EACA,GAAgB,EAAO,MACvB,EAAO,cACP,EAAO,SACR,CAQL,SAAgB,EACd,EACA,EAC4B,CAC5B,MAAQ,IACC,EAAA,EACL,EAAY,MACZ,EACA,EAAO,QACP,EAAO,cACP,EAAO,SACR,CAQL,SAAgB,EACd,EACA,EACA,EACA,EAC6B,CAC7B,OAAA,EAAA,EAAA,cACS,EAAA,EAAgB,EAAO,MAAO,EAAY,MAAO,EAAQ,EAAQ,CACxE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { LocaleHeadMeta, LocaleHeadOptions } from './locale-head';
|
|
3
|
+
import { FluentNuxtRuntimeConfig } from '../types';
|
|
4
|
+
export { localePath, extractLocaleFromPath, switchLocalePath } from './path-utils';
|
|
5
|
+
export { extendPages } from './page-extend';
|
|
6
|
+
export type { PageRoute } from './page-extend';
|
|
7
|
+
export { buildLocaleHead } from './locale-head';
|
|
8
|
+
export type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head';
|
|
9
|
+
export type { FluentNuxtRuntimeConfig } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Browser-safe composable for locale-prefixed paths.
|
|
12
|
+
* Accepts explicit locale and config instead of using Nuxt auto-imports.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useLocalePath(locale: Ref<string>, config: FluentNuxtRuntimeConfig): (path: string, targetLocale?: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Browser-safe composable for switching locale paths.
|
|
17
|
+
* Accepts explicit currentPath and config instead of using Nuxt auto-imports.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useSwitchLocalePath(currentPath: Ref<string> | ComputedRef<string>, config: FluentNuxtRuntimeConfig): (locale: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Browser-safe composable for locale head metadata.
|
|
22
|
+
* Accepts explicit locale, currentPath, and config instead of using Nuxt auto-imports.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useLocaleHead(locale: Ref<string>, currentPath: Ref<string> | ComputedRef<string>, config: FluentNuxtRuntimeConfig, options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta>;
|
|
25
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/runtime/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAGvD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtE,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEvD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACnB,MAAM,EAAE,uBAAuB,GAC9B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CASjD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,EAC9C,MAAM,EAAE,uBAAuB,GAC9B,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAU5B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACnB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,EAC9C,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,WAAW,CAAC,cAAc,CAAC,CAI7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as e } from "../page-extend-DJ7wpuVj.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "../path-utils-BcvXLCGi.js";
|
|
3
|
+
import { t as i } from "../locale-head-CqUlvy3O.js";
|
|
4
|
+
import { computed as a } from "vue";
|
|
5
|
+
//#region src/runtime/client.ts
|
|
6
|
+
function o(e, n) {
|
|
7
|
+
return (r, i) => t(r, i ?? e.value, n.defaultLocale, n.strategy);
|
|
8
|
+
}
|
|
9
|
+
function s(e, t) {
|
|
10
|
+
return (r) => n(e.value, r, t.locales, t.defaultLocale, t.strategy);
|
|
11
|
+
}
|
|
12
|
+
function c(e, t, n, r) {
|
|
13
|
+
return a(() => i(e.value, t.value, n, r));
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as buildLocaleHead, e as extendPages, r as extractLocaleFromPath, t as localePath, n as switchLocalePath, c as useLocaleHead, o as useLocalePath, s as useSwitchLocalePath };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/runtime/client.ts"],"sourcesContent":["// Browser-safe exports — no Nuxt auto-imports (#imports) dependency.\n// Use this entry point in non-Nuxt environments (e.g. plain Vue SPA).\n\nimport { computed } from 'vue'\nimport type { ComputedRef, Ref } from 'vue'\nimport { localePath, switchLocalePath } from './path-utils'\nimport { buildLocaleHead } from './locale-head'\nimport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\nimport type { FluentNuxtRuntimeConfig } from '../types'\n\n// Path utilities (pure functions, framework-agnostic)\nexport { localePath, extractLocaleFromPath, switchLocalePath } from './path-utils'\n\n// Page route extension (build-time utility)\nexport { extendPages } from './page-extend'\nexport type { PageRoute } from './page-extend'\n\n// Locale head (pure function)\nexport { buildLocaleHead } from './locale-head'\nexport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\n\n// Re-export types\nexport type { FluentNuxtRuntimeConfig } from '../types'\n\n/**\n * Browser-safe composable for locale-prefixed paths.\n * Accepts explicit locale and config instead of using Nuxt auto-imports.\n */\nexport function useLocalePath(\n locale: Ref<string>,\n config: FluentNuxtRuntimeConfig,\n): (path: string, targetLocale?: string) => string {\n return (path: string, targetLocale?: string) => {\n return localePath(\n path,\n targetLocale ?? locale.value,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Browser-safe composable for switching locale paths.\n * Accepts explicit currentPath and config instead of using Nuxt auto-imports.\n */\nexport function useSwitchLocalePath(\n currentPath: Ref<string> | ComputedRef<string>,\n config: FluentNuxtRuntimeConfig,\n): (locale: string) => string {\n return (newLocale: string) => {\n return switchLocalePath(\n currentPath.value,\n newLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Browser-safe composable for locale head metadata.\n * Accepts explicit locale, currentPath, and config instead of using Nuxt auto-imports.\n */\nexport function useLocaleHead(\n locale: Ref<string>,\n currentPath: Ref<string> | ComputedRef<string>,\n config: FluentNuxtRuntimeConfig,\n options?: LocaleHeadOptions,\n): ComputedRef<LocaleHeadMeta> {\n return computed(() => {\n return buildLocaleHead(locale.value, currentPath.value, config, options)\n })\n}\n"],"mappings":";;;;;AA4BA,SAAgB,EACd,GACA,GACiD;AACjD,SAAQ,GAAc,MACb,EACL,GACA,KAAgB,EAAO,OACvB,EAAO,eACP,EAAO,SACR;;AAQL,SAAgB,EACd,GACA,GAC4B;AAC5B,SAAQ,MACC,EACL,EAAY,OACZ,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;;AAQL,SAAgB,EACd,GACA,GACA,GACA,GAC6B;AAC7B,QAAO,QACE,EAAgB,EAAO,OAAO,EAAY,OAAO,GAAQ,EAAQ,CACxE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`../composables.cjs`);let t=require(`vue`),n=require(`#components`);var r=(0,t.defineComponent)({name:`NuxtLinkLocale`,props:{to:{type:[String,Object],required:!0},locale:{type:String,default:void 0}},setup(r,{slots:i,attrs:a}){let o=e.useLocalePath(),s=(0,t.computed)(()=>o(typeof r.to==`string`?r.to:r.to.path??`/`,r.locale));return()=>(0,t.h)(n.NuxtLink,{...a,to:s.value},i)}});exports.NuxtLinkLocale=r,exports.default=r;
|
|
2
|
+
//# sourceMappingURL=NuxtLinkLocale.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NuxtLinkLocale.cjs","names":[],"sources":["../../../src/runtime/components/NuxtLinkLocale.ts"],"sourcesContent":["import { defineComponent, computed, h, type PropType } from 'vue'\nimport { NuxtLink } from '#components'\nimport { useLocalePath } from '../composables'\n\n/**\n * Locale-aware wrapper around NuxtLink.\n *\n * Automatically prefixes the `to` prop with the current locale\n * based on the routing strategy. Uses the real NuxtLink component\n * for client-side navigation and prefetching.\n *\n * @example\n * ```vue\n * <NuxtLinkLocale to=\"/about\">About</NuxtLinkLocale>\n * <NuxtLinkLocale to=\"/about\" locale=\"ja\">About (Japanese)</NuxtLinkLocale>\n * ```\n */\nconst NuxtLinkLocale = defineComponent({\n name: 'NuxtLinkLocale',\n props: {\n to: {\n type: [String, Object] as PropType<string | { path?: string }>,\n required: true,\n },\n locale: {\n type: String as PropType<string | undefined>,\n default: undefined,\n },\n },\n setup(props, { slots, attrs }) {\n const getLocalePath = useLocalePath()\n\n const localizedTo = computed(() => {\n const path = typeof props.to === 'string' ? props.to : props.to.path ?? '/'\n return getLocalePath(path, props.locale)\n })\n\n return () => h(\n NuxtLink,\n { ...attrs, to: localizedTo.value },\n slots,\n )\n },\n})\n\nexport { NuxtLinkLocale }\nexport default NuxtLinkLocale\n"],"mappings":"mLAiBA,IAAM,GAAA,EAAA,EAAA,iBAAiC,CACrC,KAAM,iBACN,MAAO,CACL,GAAI,CACF,KAAM,CAAC,OAAQ,OAAO,CACtB,SAAU,GACX,CACD,OAAQ,CACN,KAAM,OACN,QAAS,IAAA,GACV,CACF,CACD,MAAM,EAAO,CAAE,QAAO,SAAS,CAC7B,IAAM,EAAgB,EAAA,eAAe,CAE/B,GAAA,EAAA,EAAA,cAEG,EADM,OAAO,EAAM,IAAO,SAAW,EAAM,GAAK,EAAM,GAAG,MAAQ,IAC7C,EAAM,OAAO,CACxC,CAEF,WAAA,EAAA,EAAA,GACE,EAAA,SACA,CAAE,GAAG,EAAO,GAAI,EAAY,MAAO,CACnC,EACD,EAEJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Locale-aware wrapper around NuxtLink.
|
|
4
|
+
*
|
|
5
|
+
* Automatically prefixes the `to` prop with the current locale
|
|
6
|
+
* based on the routing strategy. Uses the real NuxtLink component
|
|
7
|
+
* for client-side navigation and prefetching.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```vue
|
|
11
|
+
* <NuxtLinkLocale to="/about">About</NuxtLinkLocale>
|
|
12
|
+
* <NuxtLinkLocale to="/about" locale="ja">About (Japanese)</NuxtLinkLocale>
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const NuxtLinkLocale: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
16
|
+
to: {
|
|
17
|
+
type: PropType<string | {
|
|
18
|
+
path?: string;
|
|
19
|
+
}>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
locale: {
|
|
23
|
+
type: PropType<string | undefined>;
|
|
24
|
+
default: undefined;
|
|
25
|
+
};
|
|
26
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
29
|
+
to: {
|
|
30
|
+
type: PropType<string | {
|
|
31
|
+
path?: string;
|
|
32
|
+
}>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
locale: {
|
|
36
|
+
type: PropType<string | undefined>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>> & Readonly<{}>, {
|
|
40
|
+
locale: string | undefined;
|
|
41
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
42
|
+
export { NuxtLinkLocale };
|
|
43
|
+
export default NuxtLinkLocale;
|
|
44
|
+
//# sourceMappingURL=NuxtLinkLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NuxtLinkLocale.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/NuxtLinkLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AAIjE;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,cAAc;;cAIY,QAAQ,CAAC,MAAM,GAAG;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;;cAI9C,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;;;;cAJlB,QAAQ,CAAC,MAAM,GAAG;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;;cAI9C,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;;4EAkBhD,CAAA;AAEF,OAAO,EAAE,cAAc,EAAE,CAAA;AACzB,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useLocalePath as e } from "../composables.js";
|
|
2
|
+
import { computed as t, defineComponent as n, h as r } from "vue";
|
|
3
|
+
import { NuxtLink as i } from "#components";
|
|
4
|
+
//#region src/runtime/components/NuxtLinkLocale.ts
|
|
5
|
+
var a = n({
|
|
6
|
+
name: "NuxtLinkLocale",
|
|
7
|
+
props: {
|
|
8
|
+
to: {
|
|
9
|
+
type: [String, Object],
|
|
10
|
+
required: !0
|
|
11
|
+
},
|
|
12
|
+
locale: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: void 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(n, { slots: a, attrs: o }) {
|
|
18
|
+
let s = e(), c = t(() => s(typeof n.to == "string" ? n.to : n.to.path ?? "/", n.locale));
|
|
19
|
+
return () => r(i, {
|
|
20
|
+
...o,
|
|
21
|
+
to: c.value
|
|
22
|
+
}, a);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { a as NuxtLinkLocale, a as default };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=NuxtLinkLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NuxtLinkLocale.js","names":[],"sources":["../../../src/runtime/components/NuxtLinkLocale.ts"],"sourcesContent":["import { defineComponent, computed, h, type PropType } from 'vue'\nimport { NuxtLink } from '#components'\nimport { useLocalePath } from '../composables'\n\n/**\n * Locale-aware wrapper around NuxtLink.\n *\n * Automatically prefixes the `to` prop with the current locale\n * based on the routing strategy. Uses the real NuxtLink component\n * for client-side navigation and prefetching.\n *\n * @example\n * ```vue\n * <NuxtLinkLocale to=\"/about\">About</NuxtLinkLocale>\n * <NuxtLinkLocale to=\"/about\" locale=\"ja\">About (Japanese)</NuxtLinkLocale>\n * ```\n */\nconst NuxtLinkLocale = defineComponent({\n name: 'NuxtLinkLocale',\n props: {\n to: {\n type: [String, Object] as PropType<string | { path?: string }>,\n required: true,\n },\n locale: {\n type: String as PropType<string | undefined>,\n default: undefined,\n },\n },\n setup(props, { slots, attrs }) {\n const getLocalePath = useLocalePath()\n\n const localizedTo = computed(() => {\n const path = typeof props.to === 'string' ? props.to : props.to.path ?? '/'\n return getLocalePath(path, props.locale)\n })\n\n return () => h(\n NuxtLink,\n { ...attrs, to: localizedTo.value },\n slots,\n )\n },\n})\n\nexport { NuxtLinkLocale }\nexport default NuxtLinkLocale\n"],"mappings":";;;;AAiBA,IAAM,IAAiB,EAAgB;CACrC,MAAM;CACN,OAAO;EACL,IAAI;GACF,MAAM,CAAC,QAAQ,OAAO;GACtB,UAAU;GACX;EACD,QAAQ;GACN,MAAM;GACN,SAAS,KAAA;GACV;EACF;CACD,MAAM,GAAO,EAAE,UAAO,YAAS;EAC7B,IAAM,IAAgB,GAAe,EAE/B,IAAc,QAEX,EADM,OAAO,EAAM,MAAO,WAAW,EAAM,KAAK,EAAM,GAAG,QAAQ,KAC7C,EAAM,OAAO,CACxC;AAEF,eAAa,EACX,GACA;GAAE,GAAG;GAAO,IAAI,EAAY;GAAO,EACnC,EACD;;CAEJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../path-utils-BQIsp_or.cjs`),t=require(`../locale-head-BfsESdd7.cjs`);let n=require(`vue`),r=require(`#imports`),i=require(`@fluenti/vue`);function a(){return(0,r.useRuntimeConfig)().public.fluenti}function o(){let{locale:t}=(0,i.useI18n)(),n=a();return(r,i)=>e.n(r,i??t.value,n.defaultLocale,n.strategy)}function s(){let t=(0,r.useRoute)(),n=a();return r=>e.r(t.path,r,n.locales,n.defaultLocale,n.strategy)}function c(e){let{locale:o}=(0,i.useI18n)(),s=(0,r.useRoute)(),c=a();return(0,n.computed)(()=>t.t(o.value,s.path,c,e))}exports.useLocaleHead=c,exports.useLocalePath=o,exports.useSwitchLocalePath=s;
|
|
2
|
+
//# sourceMappingURL=composables.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.cjs","names":[],"sources":["../../src/runtime/composables.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { ComputedRef } from 'vue'\nimport { useRoute, useRuntimeConfig } from '#imports'\nimport { useI18n } from '@fluenti/vue'\nimport { localePath, switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\nimport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\nimport { buildLocaleHead } from './locale-head'\n\n/** Resolve fluenti runtime config from Nuxt's public runtimeConfig */\nfunction useFluentiConfig(): FluentNuxtRuntimeConfig {\n const runtimeConfig = useRuntimeConfig()\n return runtimeConfig.public['fluenti'] as FluentNuxtRuntimeConfig\n}\n\n/**\n * Composable that returns a function to generate locale-prefixed paths.\n *\n * Zero-argument — automatically reads the current locale from @fluenti/vue\n * and routing config from Nuxt runtimeConfig.\n *\n * @example\n * ```ts\n * const localePath = useLocalePath()\n * localePath('/about') // '/ja/about' (current locale is 'ja')\n * localePath('/about', 'en') // '/about' (prefix_except_default, en is default)\n * ```\n */\nexport function useLocalePath(): (path: string, locale?: string) => string {\n const { locale } = useI18n()\n const config = useFluentiConfig()\n\n return (path: string, targetLocale?: string) => {\n return localePath(\n path,\n targetLocale ?? locale.value,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Composable that returns a function to get the current path in a different locale.\n *\n * @example\n * ```ts\n * const switchLocalePath = useSwitchLocalePath()\n * switchLocalePath('en') // '/about' (if on '/ja/about')\n * ```\n */\nexport function useSwitchLocalePath(): (locale: string) => string {\n const route = useRoute()\n const config = useFluentiConfig()\n\n return (newLocale: string) => {\n return switchLocalePath(\n route.path,\n newLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Composable that generates locale-aware HTML head metadata.\n *\n * @example\n * ```ts\n * const head = useLocaleHead({ addSeoAttributes: true, baseUrl: 'https://example.com' })\n * useHead(head.value) // Nuxt useHead\n * ```\n */\nexport function useLocaleHead(options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta> {\n const { locale } = useI18n()\n const route = useRoute()\n const config = useFluentiConfig()\n\n return computed(() => {\n return buildLocaleHead(locale.value, route.path, config, options)\n })\n}\n"],"mappings":"+NAUA,SAAS,GAA4C,CAEnD,OAAA,EAAA,EAAA,mBADwC,CACnB,OAAO,QAgB9B,SAAgB,GAA2D,CACzE,GAAM,CAAE,WAAA,EAAA,EAAA,UAAoB,CACtB,EAAS,GAAkB,CAEjC,OAAQ,EAAc,IACb,EAAA,EACL,EACA,GAAgB,EAAO,MACvB,EAAO,cACP,EAAO,SACR,CAaL,SAAgB,GAAkD,CAChE,IAAM,GAAA,EAAA,EAAA,WAAkB,CAClB,EAAS,GAAkB,CAEjC,MAAQ,IACC,EAAA,EACL,EAAM,KACN,EACA,EAAO,QACP,EAAO,cACP,EAAO,SACR,CAaL,SAAgB,EAAc,EAA0D,CACtF,GAAM,CAAE,WAAA,EAAA,EAAA,UAAoB,CACtB,GAAA,EAAA,EAAA,WAAkB,CAClB,EAAS,GAAkB,CAEjC,OAAA,EAAA,EAAA,cACS,EAAA,EAAgB,EAAO,MAAO,EAAM,KAAM,EAAQ,EAAQ,CACjE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { LocaleHeadMeta, LocaleHeadOptions } from './locale-head';
|
|
3
|
+
/**
|
|
4
|
+
* Composable that returns a function to generate locale-prefixed paths.
|
|
5
|
+
*
|
|
6
|
+
* Zero-argument — automatically reads the current locale from @fluenti/vue
|
|
7
|
+
* and routing config from Nuxt runtimeConfig.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const localePath = useLocalePath()
|
|
12
|
+
* localePath('/about') // '/ja/about' (current locale is 'ja')
|
|
13
|
+
* localePath('/about', 'en') // '/about' (prefix_except_default, en is default)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function useLocalePath(): (path: string, locale?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Composable that returns a function to get the current path in a different locale.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const switchLocalePath = useSwitchLocalePath()
|
|
23
|
+
* switchLocalePath('en') // '/about' (if on '/ja/about')
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useSwitchLocalePath(): (locale: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Composable that generates locale-aware HTML head metadata.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const head = useLocaleHead({ addSeoAttributes: true, baseUrl: 'https://example.com' })
|
|
33
|
+
* useHead(head.value) // Nuxt useHead
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function useLocaleHead(options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta>;
|
|
37
|
+
//# sourceMappingURL=composables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../../src/runtime/composables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAKtC,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAStE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAYzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAahE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAC,cAAc,CAAC,CAQtF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { n as e, r as t } from "../path-utils-BcvXLCGi.js";
|
|
2
|
+
import { t as n } from "../locale-head-CqUlvy3O.js";
|
|
3
|
+
import { computed as r } from "vue";
|
|
4
|
+
import { useRoute as i, useRuntimeConfig as a } from "#imports";
|
|
5
|
+
import { useI18n as o } from "@fluenti/vue";
|
|
6
|
+
//#region src/runtime/composables.ts
|
|
7
|
+
function s() {
|
|
8
|
+
return a().public.fluenti;
|
|
9
|
+
}
|
|
10
|
+
function c() {
|
|
11
|
+
let { locale: t } = o(), n = s();
|
|
12
|
+
return (r, i) => e(r, i ?? t.value, n.defaultLocale, n.strategy);
|
|
13
|
+
}
|
|
14
|
+
function l() {
|
|
15
|
+
let e = i(), n = s();
|
|
16
|
+
return (r) => t(e.path, r, n.locales, n.defaultLocale, n.strategy);
|
|
17
|
+
}
|
|
18
|
+
function u(e) {
|
|
19
|
+
let { locale: t } = o(), a = i(), c = s();
|
|
20
|
+
return r(() => n(t.value, a.path, c, e));
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { u as useLocaleHead, c as useLocalePath, l as useSwitchLocalePath };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=composables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables.js","names":[],"sources":["../../src/runtime/composables.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { ComputedRef } from 'vue'\nimport { useRoute, useRuntimeConfig } from '#imports'\nimport { useI18n } from '@fluenti/vue'\nimport { localePath, switchLocalePath } from './path-utils'\nimport type { FluentNuxtRuntimeConfig } from '../types'\nimport type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head'\nimport { buildLocaleHead } from './locale-head'\n\n/** Resolve fluenti runtime config from Nuxt's public runtimeConfig */\nfunction useFluentiConfig(): FluentNuxtRuntimeConfig {\n const runtimeConfig = useRuntimeConfig()\n return runtimeConfig.public['fluenti'] as FluentNuxtRuntimeConfig\n}\n\n/**\n * Composable that returns a function to generate locale-prefixed paths.\n *\n * Zero-argument — automatically reads the current locale from @fluenti/vue\n * and routing config from Nuxt runtimeConfig.\n *\n * @example\n * ```ts\n * const localePath = useLocalePath()\n * localePath('/about') // '/ja/about' (current locale is 'ja')\n * localePath('/about', 'en') // '/about' (prefix_except_default, en is default)\n * ```\n */\nexport function useLocalePath(): (path: string, locale?: string) => string {\n const { locale } = useI18n()\n const config = useFluentiConfig()\n\n return (path: string, targetLocale?: string) => {\n return localePath(\n path,\n targetLocale ?? locale.value,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Composable that returns a function to get the current path in a different locale.\n *\n * @example\n * ```ts\n * const switchLocalePath = useSwitchLocalePath()\n * switchLocalePath('en') // '/about' (if on '/ja/about')\n * ```\n */\nexport function useSwitchLocalePath(): (locale: string) => string {\n const route = useRoute()\n const config = useFluentiConfig()\n\n return (newLocale: string) => {\n return switchLocalePath(\n route.path,\n newLocale,\n config.locales,\n config.defaultLocale,\n config.strategy,\n )\n }\n}\n\n/**\n * Composable that generates locale-aware HTML head metadata.\n *\n * @example\n * ```ts\n * const head = useLocaleHead({ addSeoAttributes: true, baseUrl: 'https://example.com' })\n * useHead(head.value) // Nuxt useHead\n * ```\n */\nexport function useLocaleHead(options?: LocaleHeadOptions): ComputedRef<LocaleHeadMeta> {\n const { locale } = useI18n()\n const route = useRoute()\n const config = useFluentiConfig()\n\n return computed(() => {\n return buildLocaleHead(locale.value, route.path, config, options)\n })\n}\n"],"mappings":";;;;;;AAUA,SAAS,IAA4C;AAEnD,QADsB,GAAkB,CACnB,OAAO;;AAgB9B,SAAgB,IAA2D;CACzE,IAAM,EAAE,cAAW,GAAS,EACtB,IAAS,GAAkB;AAEjC,SAAQ,GAAc,MACb,EACL,GACA,KAAgB,EAAO,OACvB,EAAO,eACP,EAAO,SACR;;AAaL,SAAgB,IAAkD;CAChE,IAAM,IAAQ,GAAU,EAClB,IAAS,GAAkB;AAEjC,SAAQ,MACC,EACL,EAAM,MACN,GACA,EAAO,SACP,EAAO,eACP,EAAO,SACR;;AAaL,SAAgB,EAAc,GAA0D;CACtF,IAAM,EAAE,cAAW,GAAS,EACtB,IAAQ,GAAU,EAClB,IAAS,GAAkB;AAEjC,QAAO,QACE,EAAgB,EAAO,OAAO,EAAM,MAAM,GAAQ,EAAQ,CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/runtime/detectors/cookie.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,sCAAsC;AACtC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAWnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/runtime/detectors/header.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,2DAA2D;AAC3D,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAcnE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LocaleDetectContext, LocaleDetectorFn, FluentNuxtRuntimeConfig } from '../../types';
|
|
2
|
+
/** Map of built-in detector names to their implementations */
|
|
3
|
+
declare const builtinDetectors: Record<string, LocaleDetectorFn>;
|
|
4
|
+
/**
|
|
5
|
+
* Run the detection chain: iterate through detectOrder, then fire the hook.
|
|
6
|
+
*
|
|
7
|
+
* Returns the detected locale or the defaultLocale as fallback.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runDetectors(path: string, config: FluentNuxtRuntimeConfig, customDetectors?: Map<string, LocaleDetectorFn>, hookFn?: (ctx: LocaleDetectContext) => void | Promise<void>): Promise<string>;
|
|
10
|
+
export { builtinDetectors };
|
|
11
|
+
export type { LocaleDetectContext, LocaleDetectorFn };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/detectors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAMjG,8DAA8D;AAC9D,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAKtD,CAAA;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,uBAAuB,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC/C,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC1D,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAC3B,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/runtime/detectors/path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,iEAAiE;AACjE,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAMjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/runtime/detectors/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,2DAA2D;AAC3D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAUlE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../page-extend-OvV-ZhFB.cjs`),t=require(`../path-utils-BQIsp_or.cjs`),n=require(`../locale-head-BfsESdd7.cjs`),r=require(`./composables.cjs`),i=require(`./components/NuxtLinkLocale.cjs`);exports.NuxtLinkLocale=i.NuxtLinkLocale,exports.buildLocaleHead=n.t,exports.extendPages=e.t,exports.extractLocaleFromPath=t.t,exports.localePath=t.n,exports.switchLocalePath=t.r,exports.useLocaleHead=r.useLocaleHead,exports.useLocalePath=r.useLocalePath,exports.useSwitchLocalePath=r.useSwitchLocalePath;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { localePath, extractLocaleFromPath, switchLocalePath } from './path-utils';
|
|
2
|
+
export { extendPages } from './page-extend';
|
|
3
|
+
export type { PageRoute } from './page-extend';
|
|
4
|
+
export { buildLocaleHead } from './locale-head';
|
|
5
|
+
export type { LocaleHeadMeta, LocaleHeadOptions } from './locale-head';
|
|
6
|
+
export { useLocalePath, useSwitchLocalePath, useLocaleHead } from './composables';
|
|
7
|
+
export { NuxtLinkLocale } from './components/NuxtLinkLocale';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAGjF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { t as e } from "../page-extend-DJ7wpuVj.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "../path-utils-BcvXLCGi.js";
|
|
3
|
+
import { t as i } from "../locale-head-CqUlvy3O.js";
|
|
4
|
+
import { useLocaleHead as a, useLocalePath as o, useSwitchLocalePath as s } from "./composables.js";
|
|
5
|
+
import { NuxtLinkLocale as c } from "./components/NuxtLinkLocale.js";
|
|
6
|
+
export { c as NuxtLinkLocale, i as buildLocaleHead, e as extendPages, r as extractLocaleFromPath, t as localePath, n as switchLocalePath, a as useLocaleHead, o as useLocalePath, s as useSwitchLocalePath };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FluentNuxtRuntimeConfig } from '../types';
|
|
2
|
+
/** Head metadata for locale SEO */
|
|
3
|
+
export interface LocaleHeadMeta {
|
|
4
|
+
htmlAttrs: {
|
|
5
|
+
lang: string;
|
|
6
|
+
};
|
|
7
|
+
link: Array<{
|
|
8
|
+
rel: string;
|
|
9
|
+
hreflang: string;
|
|
10
|
+
href: string;
|
|
11
|
+
}>;
|
|
12
|
+
meta: Array<{
|
|
13
|
+
property: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface LocaleHeadOptions {
|
|
18
|
+
/** Add hreflang and og:locale SEO attributes */
|
|
19
|
+
addSeoAttributes?: boolean;
|
|
20
|
+
/** Base URL for absolute hreflang links (e.g. 'https://example.com') */
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pure function that builds locale-aware HTML head metadata.
|
|
25
|
+
*
|
|
26
|
+
* This is the framework-agnostic core logic. For the Nuxt composable,
|
|
27
|
+
* use `useLocaleHead()` from `composables.ts` instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildLocaleHead(locale: string, currentPath: string, config: FluentNuxtRuntimeConfig, options?: LocaleHeadOptions): LocaleHeadMeta;
|
|
30
|
+
//# sourceMappingURL=locale-head.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-head.d.ts","sourceRoot":"","sources":["../../src/runtime/locale-head.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEvD,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,IAAI,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC5D,IAAI,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACnD;AAED,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CAoDhB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../../path-utils-BQIsp_or.cjs`),t=require(`../../detectors-CFJvuwzi.cjs`);let n=require(`#imports`);var r=(0,n.defineNuxtRouteMiddleware)(async r=>{let i=(0,n.useRuntimeConfig)().public.fluenti;if(i.strategy===`no_prefix`)return;let{locale:a}=e.t(r.path,i.locales);if(a||i.strategy===`prefix_except_default`)return;let o=(0,n.useNuxtApp)(),s={...i,detectOrder:i.detectOrder.filter(e=>e!==`path`)},c=await t.t(r.path,s),l=e.n(r.path,c,i.defaultLocale,i.strategy);if(l!==r.path)return o.runWithContext(()=>(0,n.navigateTo)(l,{redirectCode:302}))});module.exports=r;
|
|
2
|
+
//# sourceMappingURL=locale-redirect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-redirect.cjs","names":[],"sources":["../../../src/runtime/middleware/locale-redirect.ts"],"sourcesContent":["import { defineNuxtRouteMiddleware, navigateTo, useNuxtApp, useRuntimeConfig } from '#imports'\nimport { extractLocaleFromPath, localePath } from '../path-utils'\nimport { runDetectors } from '../detectors'\nimport type { FluentNuxtRuntimeConfig } from '../../types'\n\n/**\n * Route middleware that redirects users to locale-prefixed URLs\n * based on the locale detection chain (detectors + hook).\n *\n * Only active when strategy is not 'no_prefix'.\n * Skips redirect when the URL already contains a valid locale prefix.\n */\nexport default defineNuxtRouteMiddleware(async (to) => {\n const config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n\n if (config.strategy === 'no_prefix') return\n\n // If the path already has a locale prefix, do nothing\n const { locale: pathLocale } = extractLocaleFromPath(to.path, config.locales)\n if (pathLocale) return\n\n // For prefix_except_default / prefix_and_default, an unprefixed path\n // means the default locale — no redirect needed for prefix_except_default\n if (config.strategy === 'prefix_except_default') return\n\n // Capture nuxtApp BEFORE any await — async local storage (composable\n // context) is lost after awaiting, so navigateTo would fail without this.\n const nuxtApp = useNuxtApp()\n\n // For 'prefix' strategy, we must redirect to a locale-prefixed URL\n // Run detectors excluding 'path' (since we know path has no locale)\n const configWithoutPath = {\n ...config,\n detectOrder: config.detectOrder.filter((d) => d !== 'path'),\n }\n const detectedLocale = await runDetectors(to.path, configWithoutPath)\n const targetPath = localePath(to.path, detectedLocale, config.defaultLocale, config.strategy)\n\n if (targetPath !== to.path) {\n return nuxtApp.runWithContext(() => navigateTo(targetPath, { redirectCode: 302 }))\n }\n})\n"],"mappings":"qHAYA,IAAA,GAAA,EAAA,EAAA,2BAAyC,KAAO,IAAO,CACrD,IAAM,GAAA,EAAA,EAAA,mBAA2B,CAAC,OAAO,QAEzC,GAAI,EAAO,WAAa,YAAa,OAGrC,GAAM,CAAE,OAAQ,GAAe,EAAA,EAAsB,EAAG,KAAM,EAAO,QAAQ,CAK7E,GAJI,GAIA,EAAO,WAAa,wBAAyB,OAIjD,IAAM,GAAA,EAAA,EAAA,aAAsB,CAItB,EAAoB,CACxB,GAAG,EACH,YAAa,EAAO,YAAY,OAAQ,GAAM,IAAM,OAAO,CAC5D,CACK,EAAiB,MAAM,EAAA,EAAa,EAAG,KAAM,EAAkB,CAC/D,EAAa,EAAA,EAAW,EAAG,KAAM,EAAgB,EAAO,cAAe,EAAO,SAAS,CAE7F,GAAI,IAAe,EAAG,KACpB,OAAO,EAAQ,oBAAA,EAAA,EAAA,YAAgC,EAAY,CAAE,aAAc,IAAK,CAAC,CAAC,EAEpF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route middleware that redirects users to locale-prefixed URLs
|
|
3
|
+
* based on the locale detection chain (detectors + hook).
|
|
4
|
+
*
|
|
5
|
+
* Only active when strategy is not 'no_prefix'.
|
|
6
|
+
* Skips redirect when the URL already contains a valid locale prefix.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: any;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=locale-redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-redirect.d.ts","sourceRoot":"","sources":["../../../src/runtime/middleware/locale-redirect.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;;AACH,wBA6BE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { n as e, t } from "../../path-utils-BcvXLCGi.js";
|
|
2
|
+
import { t as n } from "../../detectors-DhkfHBHr.js";
|
|
3
|
+
import { defineNuxtRouteMiddleware as r, navigateTo as i, useNuxtApp as a, useRuntimeConfig as o } from "#imports";
|
|
4
|
+
//#region src/runtime/middleware/locale-redirect.ts
|
|
5
|
+
var s = r(async (r) => {
|
|
6
|
+
let s = o().public.fluenti;
|
|
7
|
+
if (s.strategy === "no_prefix") return;
|
|
8
|
+
let { locale: c } = t(r.path, s.locales);
|
|
9
|
+
if (c || s.strategy === "prefix_except_default") return;
|
|
10
|
+
let l = a(), u = {
|
|
11
|
+
...s,
|
|
12
|
+
detectOrder: s.detectOrder.filter((e) => e !== "path")
|
|
13
|
+
}, d = await n(r.path, u), f = e(r.path, d, s.defaultLocale, s.strategy);
|
|
14
|
+
if (f !== r.path) return l.runWithContext(() => i(f, { redirectCode: 302 }));
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { s as default };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=locale-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-redirect.js","names":[],"sources":["../../../src/runtime/middleware/locale-redirect.ts"],"sourcesContent":["import { defineNuxtRouteMiddleware, navigateTo, useNuxtApp, useRuntimeConfig } from '#imports'\nimport { extractLocaleFromPath, localePath } from '../path-utils'\nimport { runDetectors } from '../detectors'\nimport type { FluentNuxtRuntimeConfig } from '../../types'\n\n/**\n * Route middleware that redirects users to locale-prefixed URLs\n * based on the locale detection chain (detectors + hook).\n *\n * Only active when strategy is not 'no_prefix'.\n * Skips redirect when the URL already contains a valid locale prefix.\n */\nexport default defineNuxtRouteMiddleware(async (to) => {\n const config = useRuntimeConfig().public['fluenti'] as FluentNuxtRuntimeConfig\n\n if (config.strategy === 'no_prefix') return\n\n // If the path already has a locale prefix, do nothing\n const { locale: pathLocale } = extractLocaleFromPath(to.path, config.locales)\n if (pathLocale) return\n\n // For prefix_except_default / prefix_and_default, an unprefixed path\n // means the default locale — no redirect needed for prefix_except_default\n if (config.strategy === 'prefix_except_default') return\n\n // Capture nuxtApp BEFORE any await — async local storage (composable\n // context) is lost after awaiting, so navigateTo would fail without this.\n const nuxtApp = useNuxtApp()\n\n // For 'prefix' strategy, we must redirect to a locale-prefixed URL\n // Run detectors excluding 'path' (since we know path has no locale)\n const configWithoutPath = {\n ...config,\n detectOrder: config.detectOrder.filter((d) => d !== 'path'),\n }\n const detectedLocale = await runDetectors(to.path, configWithoutPath)\n const targetPath = localePath(to.path, detectedLocale, config.defaultLocale, config.strategy)\n\n if (targetPath !== to.path) {\n return nuxtApp.runWithContext(() => navigateTo(targetPath, { redirectCode: 302 }))\n }\n})\n"],"mappings":";;;;AAYA,IAAA,IAAe,EAA0B,OAAO,MAAO;CACrD,IAAM,IAAS,GAAkB,CAAC,OAAO;AAEzC,KAAI,EAAO,aAAa,YAAa;CAGrC,IAAM,EAAE,QAAQ,MAAe,EAAsB,EAAG,MAAM,EAAO,QAAQ;AAK7E,KAJI,KAIA,EAAO,aAAa,wBAAyB;CAIjD,IAAM,IAAU,GAAY,EAItB,IAAoB;EACxB,GAAG;EACH,aAAa,EAAO,YAAY,QAAQ,MAAM,MAAM,OAAO;EAC5D,EACK,IAAiB,MAAM,EAAa,EAAG,MAAM,EAAkB,EAC/D,IAAa,EAAW,EAAG,MAAM,GAAgB,EAAO,eAAe,EAAO,SAAS;AAE7F,KAAI,MAAe,EAAG,KACpB,QAAO,EAAQ,qBAAqB,EAAW,GAAY,EAAE,cAAc,KAAK,CAAC,CAAC;EAEpF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Strategy } from '../types';
|
|
2
|
+
/** Page route definition used for route extension */
|
|
3
|
+
export interface PageRoute {
|
|
4
|
+
path: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
children?: PageRoute[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Extend page routes with locale-prefixed variants.
|
|
10
|
+
* Mutates the pages array in place (Nuxt convention).
|
|
11
|
+
*
|
|
12
|
+
* This is a build-time utility used in the module's `pages:extend` hook.
|
|
13
|
+
*/
|
|
14
|
+
export declare function extendPages(pages: PageRoute[], options: {
|
|
15
|
+
locales: string[];
|
|
16
|
+
defaultLocale: string;
|
|
17
|
+
strategy: Strategy;
|
|
18
|
+
}): void;
|
|
19
|
+
//# sourceMappingURL=page-extend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-extend.d.ts","sourceRoot":"","sources":["../../src/runtime/page-extend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GACxE,IAAI,CAsBN"}
|