nuxt-intlayer 9.5.9 → 9.5.11
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/esm/index.mjs.map +1 -1
- package/dist/esm/module.mjs +7 -4
- package/dist/esm/module.mjs.map +1 -1
- package/dist/esm/runtime/intlayer-plugin.mjs +10 -7
- package/dist/esm/runtime/intlayer-plugin.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/module.d.ts +11 -1
- package/dist/types/module.d.ts.map +1 -1
- package/dist/types/runtime/intlayer-plugin.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { module } from './module';\n\nexport default module;\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { module } from './module';\n\nexport type { NuxtIntlayerModuleOptions } from './module';\n\nexport default module;\n"],"mappings":";;;AAIA,kBAAe"}
|
package/dist/esm/module.mjs
CHANGED
|
@@ -22,10 +22,13 @@ import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
const module = defineNuxtModule({
|
|
25
|
-
meta: {
|
|
26
|
-
|
|
25
|
+
meta: {
|
|
26
|
+
name: "nuxt-intlayer",
|
|
27
|
+
configKey: "intlayer"
|
|
28
|
+
},
|
|
29
|
+
setup(options, nuxt) {
|
|
27
30
|
const configuration = getConfiguration();
|
|
28
|
-
nuxt.options.typescript = nuxt.options.typescript
|
|
31
|
+
nuxt.options.typescript = nuxt.options.typescript ?? {};
|
|
29
32
|
nuxt.options.typescript.tsConfig = nuxt.options.typescript.tsConfig || {};
|
|
30
33
|
nuxt.options.typescript.tsConfig.include = nuxt.options.typescript.tsConfig.include || [];
|
|
31
34
|
if (!nuxt.options.typescript.tsConfig.include.includes("../.intlayer/types/**/*.ts")) nuxt.options.typescript.tsConfig.include.push("../.intlayer/types/**/*.ts");
|
|
@@ -48,7 +51,7 @@ const module = defineNuxtModule({
|
|
|
48
51
|
});
|
|
49
52
|
nuxt.hook("vite:extendConfig", (viteConfig, { isServer }) => {
|
|
50
53
|
if (isServer) (viteConfig.plugins ?? []).push(intlayerProxy());
|
|
51
|
-
viteConfig.plugins?.push(intlayer());
|
|
54
|
+
viteConfig.plugins?.push(intlayer({ compatCallers: options.compatCallers }));
|
|
52
55
|
});
|
|
53
56
|
nuxt.hook("pages:extend", (pages) => {
|
|
54
57
|
const { internationalization: { locales, defaultLocale }, routing: { mode } } = configuration;
|
package/dist/esm/module.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.mjs","names":[],"sources":["../../src/module.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/node';\nimport { getPrefix } from '@intlayer/core/localization';\nimport { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';\nimport type { NuxtModule } from '@nuxt/schema';\nimport { intlayer
|
|
1
|
+
{"version":3,"file":"module.mjs","names":[],"sources":["../../src/module.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/node';\nimport { getPrefix } from '@intlayer/core/localization';\nimport { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';\nimport type { NuxtModule } from '@nuxt/schema';\nimport {\n type IntlayerPluginOptions,\n intlayer,\n intlayerProxy,\n} from 'vite-intlayer';\n\n/** Options of the `nuxt-intlayer` module (`intlayer` key of `nuxt.config`). */\nexport type NuxtIntlayerModuleOptions = {\n /**\n * Compat-adapter callers forwarded to the Vite plugin, so their call sites\n * take part in build optimization. Set by compat modules such as\n * `@intlayer/nuxtjs-i18n`, which install this module.\n */\n compatCallers?: IntlayerPluginOptions['compatCallers'];\n};\n\n/**\n * Nuxt module that integrates Intlayer into Nuxt applications.\n *\n * It handles:\n * 1. Configuring TypeScript to include Intlayer's generated types.\n * 2. Registering runtime plugins for Vue Intlayer and HTML lang management.\n * 3. Extending Vite configuration with Intlayer and Intlayer Proxy plugins.\n * 4. Extending Nuxt pages to support locale-aware routing based on the configuration.\n *\n * @example\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['nuxt-intlayer'],\n * });\n * ```\n */\nexport const module: NuxtModule<NuxtIntlayerModuleOptions> =\n defineNuxtModule<NuxtIntlayerModuleOptions>({\n meta: {\n name: 'nuxt-intlayer',\n configKey: 'intlayer',\n },\n setup(options, nuxt) {\n const configuration = getConfiguration();\n\n nuxt.options.typescript =\n nuxt.options.typescript ?? ({} as typeof nuxt.options.typescript);\n nuxt.options.typescript.tsConfig = nuxt.options.typescript.tsConfig || {};\n nuxt.options.typescript.tsConfig.include =\n nuxt.options.typescript.tsConfig.include || [];\n\n if (\n !nuxt.options.typescript.tsConfig.include.includes(\n '../.intlayer/types/**/*.ts'\n )\n ) {\n nuxt.options.typescript.tsConfig.include.push(\n '../.intlayer/types/**/*.ts'\n );\n }\n\n /**\n * -------------------------------------------------\n * RUNTIME PLUGIN REGISTRATION\n * -------------------------------------------------\n * Automatically install `vue-intlayer` on the client\n * so developers don't need to add the plugin manually\n * in every Nuxt project.\n */\n const resolver = createResolver(import.meta.url);\n\n addPlugin({\n src: resolver.resolve('./runtime/intlayer-plugin'),\n mode: 'all',\n });\n\n addPlugin({\n src: resolver.resolve('./runtime/html-lang'),\n mode: 'all',\n });\n\n // // Inject the intlayer middleware plugin into Nuxt's Vite config\n nuxt.hook('vite:extendConfig', (viteConfig, { isServer }) => {\n if (isServer) {\n // We only need the middleware on the server side during development\n // viteConfig.plugins can be undefined at this stage\n (viteConfig.plugins ?? []).push(intlayerProxy());\n }\n\n viteConfig.plugins?.push(\n intlayer({ compatCallers: options.compatCallers })\n );\n });\n\n // After setting up aliases, extend Nuxt pages with locale-aware routes\n nuxt.hook('pages:extend', (pages) => {\n const {\n internationalization: { locales, defaultLocale },\n routing: { mode },\n } = configuration;\n\n // Build a RegExp string with supported locales (e.g. \"en|fr|de\") to ensure the param only accepts known locales\n const filteredLocales = locales.filter((locale) => {\n const { localePrefix } = getPrefix(locale, {\n mode,\n defaultLocale,\n });\n return localePrefix !== undefined;\n });\n const localeGroupRegex = filteredLocales.map(String).join('|');\n\n // If no locales remain to prefix (e.g., only default locale and prefixDefault is false) skip extension\n if (!localeGroupRegex) return;\n\n // Clone the original page list to avoid infinite loops when pushing\n const originalPages = [...pages];\n\n for (const page of originalPages) {\n // Skip already localised routes (prevent double processing)\n if (page.path.startsWith('/:locale')) continue;\n\n // Determine the paths we need to add depending on prefixDefault flag\n // We always add the dynamic \":locale\" prefixed variant so that `/fr/about` works\n const dynPathPrefix = `/:locale(${localeGroupRegex})`;\n const isIndex = page.path === '/';\n const prefixedPath = isIndex\n ? `${dynPathPrefix}`\n : `${dynPathPrefix}${page.path}`;\n\n // If prefixDefault is false and this is the default locale, we keep the original\n // route (already in pages) and add the dynamic variant which will match non default\n // locales. When prefixDefault is true, we still keep the original route for SSR\n // convenience (middleware will redirect anyway) but also expose locale variants.\n\n // Create a shallow copy of the page with the new path\n pages.push({\n ...page,\n path: prefixedPath,\n name: page.name ? `${page.name}___i18n` : undefined,\n });\n }\n });\n },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,SACX,iBAA4C;CAC1C,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,MAAM,SAAS,MAAM;EACnB,MAAM,gBAAgB,iBAAiB;EAEvC,KAAK,QAAQ,aACX,KAAK,QAAQ,cAAe,CAAC;EAC/B,KAAK,QAAQ,WAAW,WAAW,KAAK,QAAQ,WAAW,YAAY,CAAC;EACxE,KAAK,QAAQ,WAAW,SAAS,UAC/B,KAAK,QAAQ,WAAW,SAAS,WAAW,CAAC;EAE/C,IACE,CAAC,KAAK,QAAQ,WAAW,SAAS,QAAQ,SACxC,4BACF,GAEA,KAAK,QAAQ,WAAW,SAAS,QAAQ,KACvC,4BACF;;;;;;;;;EAWF,MAAM,WAAW,eAAe,YAAY,GAAG;EAE/C,UAAU;GACR,KAAK,SAAS,QAAQ,2BAA2B;GACjD,MAAM;EACR,CAAC;EAED,UAAU;GACR,KAAK,SAAS,QAAQ,qBAAqB;GAC3C,MAAM;EACR,CAAC;EAGD,KAAK,KAAK,sBAAsB,YAAY,EAAE,eAAe;GAC3D,IAAI,UAGF,CAAC,WAAW,WAAW,CAAC,EAAC,CAAE,KAAK,cAAc,CAAC;GAGjD,WAAW,SAAS,KAClB,SAAS,EAAE,eAAe,QAAQ,cAAc,CAAC,CACnD;EACF,CAAC;EAGD,KAAK,KAAK,iBAAiB,UAAU;GACnC,MAAM,EACJ,sBAAsB,EAAE,SAAS,iBACjC,SAAS,EAAE,WACT;GAUJ,MAAM,mBAPkB,QAAQ,QAAQ,WAAW;IACjD,MAAM,EAAE,iBAAiB,UAAU,QAAQ;KACzC;KACA;IACF,CAAC;IACD,OAAO,iBAAiB;GAC1B,CACuC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG;GAG7D,IAAI,CAAC,kBAAkB;GAGvB,MAAM,gBAAgB,CAAC,GAAG,KAAK;GAE/B,KAAK,MAAM,QAAQ,eAAe;IAEhC,IAAI,KAAK,KAAK,WAAW,UAAU,GAAG;IAItC,MAAM,gBAAgB,YAAY,iBAAiB;IAEnD,MAAM,eADU,KAAK,SAAS,MAE1B,GAAG,kBACH,GAAG,gBAAgB,KAAK;IAQ5B,MAAM,KAAK;KACT,GAAG;KACH,MAAM;KACN,MAAM,KAAK,OAAO,GAAG,KAAK,KAAK,WAAW;IAC5C,CAAC;GACH;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
|
-
import { useRoute } from "#imports";
|
|
2
|
+
import { useRoute, useRouter } from "#imports";
|
|
3
|
+
import { internationalization, routing } from "@intlayer/config/built";
|
|
3
4
|
import { createIntlayerClient, installIntlayer } from "vue-intlayer";
|
|
4
5
|
|
|
5
6
|
//#region src/runtime/intlayer-plugin.ts
|
|
@@ -17,14 +18,16 @@ var intlayer_plugin_default = defineNuxtPlugin((nuxtApp) => {
|
|
|
17
18
|
*/
|
|
18
19
|
installIntlayer(nuxtApp.vueApp);
|
|
19
20
|
const { setLocale } = createIntlayerClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const isPrefixedRouting = routing?.mode === "prefix-no-default" || routing?.mode === "prefix-all";
|
|
22
|
+
/** Applies a route's `:locale` param (if any) to Intlayer. */
|
|
23
|
+
const syncLocale = (localeParam) => {
|
|
23
24
|
if (localeParam) setLocale(localeParam);
|
|
25
|
+
else if (isPrefixedRouting) setLocale(internationalization.defaultLocale);
|
|
24
26
|
};
|
|
25
|
-
syncLocale();
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
syncLocale(useRoute().params.locale);
|
|
28
|
+
useRouter().afterEach((to, _from, failure) => {
|
|
29
|
+
if (failure) return;
|
|
30
|
+
syncLocale(to.params.locale);
|
|
28
31
|
});
|
|
29
32
|
});
|
|
30
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayer-plugin.mjs","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { createIntlayerClient, installIntlayer } from 'vue-intlayer';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute } from '#imports';\n\n/**\n * Nuxt client plugin injected by `nuxt-intlayer` module.\n * It installs the Intlayer Vue composables in the current Nuxt application and keeps\n * the active locale in sync with the current route (e.g. `/fr/about` → `fr`).\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n /**\n * Register the Intlayer provider. We don't pass an explicit locale here so it\n * will fallback to the `defaultLocale` defined in the user configuration.\n * We will synchronise the active locale afterwards, once the current route\n * information is reliably available.\n */\n installIntlayer(nuxtApp.vueApp);\n\n // Obtain a reference to the singleton Intlayer client so we can update the\n // locale reactively whenever the route changes.\n const { setLocale } = createIntlayerClient();\n\n
|
|
1
|
+
{"version":3,"file":"intlayer-plugin.mjs","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport { internationalization, routing } from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { createIntlayerClient, installIntlayer } from 'vue-intlayer';\nimport { defineNuxtPlugin } from '#app';\nimport { useRoute, useRouter } from '#imports';\n\n/**\n * Nuxt client plugin injected by `nuxt-intlayer` module.\n * It installs the Intlayer Vue composables in the current Nuxt application and keeps\n * the active locale in sync with the current route (e.g. `/fr/about` → `fr`).\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n /**\n * Register the Intlayer provider. We don't pass an explicit locale here so it\n * will fallback to the `defaultLocale` defined in the user configuration.\n * We will synchronise the active locale afterwards, once the current route\n * information is reliably available.\n */\n installIntlayer(nuxtApp.vueApp);\n\n // Obtain a reference to the singleton Intlayer client so we can update the\n // locale reactively whenever the route changes.\n const { setLocale } = createIntlayerClient();\n\n // With prefixed routing, a route without `:locale` is the default locale.\n // Resetting it matters on the server, where the client singleton outlives\n // the request: `/` rendered after `/fr` would otherwise stay in French.\n const isPrefixedRouting =\n routing?.mode === 'prefix-no-default' || routing?.mode === 'prefix-all';\n\n /** Applies a route's `:locale` param (if any) to Intlayer. */\n const syncLocale = (localeParam: Locale | undefined) => {\n if (localeParam) {\n setLocale(localeParam);\n } else if (isPrefixedRouting) {\n setLocale(internationalization.defaultLocale);\n }\n };\n\n // Initial sync (client & server) once the plugin is executed.\n syncLocale(useRoute().params.locale as Locale | undefined);\n\n // Keep Intlayer locale in sync on every navigation. The target route is\n // read from the router: `useRoute()` still holds the previous route until\n // the new page has rendered, so plain links (`/fr`, back / forward) would\n // otherwise keep the old locale.\n useRouter().afterEach((to, _from, failure) => {\n if (failure) return;\n\n syncLocale(to.params.locale as Locale | undefined);\n });\n});\n"],"mappings":";;;;;;;;;;;AAaA,8BAAe,kBAAkB,YAAY;;;;;;;CAO3C,gBAAgB,QAAQ,MAAM;CAI9B,MAAM,EAAE,cAAc,qBAAqB;CAK3C,MAAM,oBACJ,SAAS,SAAS,uBAAuB,SAAS,SAAS;;CAG7D,MAAM,cAAc,gBAAoC;EACtD,IAAI,aACF,UAAU,WAAW;OAChB,IAAI,mBACT,UAAU,qBAAqB,aAAa;CAEhD;CAGA,WAAW,SAAS,CAAC,CAAC,OAAO,MAA4B;CAMzD,UAAU,CAAC,CAAC,WAAW,IAAI,OAAO,YAAY;EAC5C,IAAI,SAAS;EAEb,WAAW,GAAG,OAAO,MAA4B;CACnD,CAAC;AACH,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { module } from "./module.js";
|
|
2
|
-
export { module as default };
|
|
1
|
+
import { NuxtIntlayerModuleOptions, module } from "./module.js";
|
|
2
|
+
export { type NuxtIntlayerModuleOptions, module as default };
|
package/dist/types/module.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { NuxtModule } from "@nuxt/schema";
|
|
2
|
+
import { IntlayerPluginOptions } from "vite-intlayer";
|
|
2
3
|
//#region src/module.d.ts
|
|
4
|
+
/** Options of the `nuxt-intlayer` module (`intlayer` key of `nuxt.config`). */
|
|
5
|
+
export type NuxtIntlayerModuleOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Compat-adapter callers forwarded to the Vite plugin, so their call sites
|
|
8
|
+
* take part in build optimization. Set by compat modules such as
|
|
9
|
+
* `@intlayer/nuxtjs-i18n`, which install this module.
|
|
10
|
+
*/
|
|
11
|
+
compatCallers?: IntlayerPluginOptions['compatCallers'];
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* Nuxt module that integrates Intlayer into Nuxt applications.
|
|
5
15
|
*
|
|
@@ -17,6 +27,6 @@ import { NuxtModule } from "@nuxt/schema";
|
|
|
17
27
|
* });
|
|
18
28
|
* ```
|
|
19
29
|
*/
|
|
20
|
-
export declare const module: NuxtModule
|
|
30
|
+
export declare const module: NuxtModule<NuxtIntlayerModuleOptions>;
|
|
21
31
|
//#endregion
|
|
22
32
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","names":[],"sources":["../../src/module.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"module.d.ts","names":[],"sources":["../../src/module.ts"],"mappings":";;;;YAWY;;;;;;EAMV,gBAAgB;;;;;;;;;;;;;;;;;;;qBAoBL,QAAQ,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayer-plugin.d.ts","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"intlayer-plugin.d.ts","names":[],"sources":["../../../src/runtime/intlayer-plugin.ts"],"mappings":";;;;;;cAQA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Nuxt applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@intlayer/config": "9.5.
|
|
82
|
-
"@intlayer/core": "9.5.
|
|
83
|
-
"@intlayer/types": "9.5.
|
|
84
|
-
"vite-intlayer": "9.5.
|
|
85
|
-
"vue-intlayer": "9.5.
|
|
81
|
+
"@intlayer/config": "9.5.11",
|
|
82
|
+
"@intlayer/core": "9.5.11",
|
|
83
|
+
"@intlayer/types": "9.5.11",
|
|
84
|
+
"vite-intlayer": "9.5.11",
|
|
85
|
+
"vue-intlayer": "9.5.11"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/node": "^22",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"rimraf": "6.1.3",
|
|
94
94
|
"tsdown": "0.23.0",
|
|
95
95
|
"typescript": "7.0.2",
|
|
96
|
-
"vitest": "5.0.
|
|
96
|
+
"vitest": "5.0.2"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@nuxt/kit": ">=3.0.0",
|