@i18n-micro/types 1.2.7 → 1.2.10

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/index.d.cts CHANGED
@@ -162,10 +162,10 @@ export interface ModuleOptions {
162
162
  strategy?: Strategies;
163
163
  /**
164
164
  * Base URL for SEO meta tags (canonical, og:url, hreflang).
165
- * - `undefined` — dynamically resolved from the current request URL
165
+ * - A concrete URL string (e.g. `'https://example.com'`) — used as-is (highest priority).
166
+ * - `undefined` — falls back to `site.url` from `nuxt-site-config` when that module is
167
+ * present, otherwise the current request origin
166
168
  * (`useRequestURL().origin` on server, `window.location.origin` on client).
167
- * Best for multi-domain deployments.
168
- * - A concrete URL string (e.g. `'https://example.com'`) — used as-is.
169
169
  * @default undefined
170
170
  */
171
171
  metaBaseUrl?: string;
@@ -183,6 +183,13 @@ export interface ModuleOptions {
183
183
  * @default true
184
184
  */
185
185
  metaTrustForwardedProto?: boolean;
186
+ /**
187
+ * Also emit a bare-language `hreflang` derived from each locale's `iso`
188
+ * (e.g. `es-ES` → also `es`). The first regional locale in `locales` claims
189
+ * the bare tag for that language. Routing `code` is never used — only `iso || code`.
190
+ * @default false
191
+ */
192
+ hreflangBaseLanguage?: boolean;
186
193
  /**
187
194
  * Register the `defineI18nRoute()` macro plugin, enabling per-page `defineI18nRoute()` calls.
188
195
  * @default true
@@ -251,11 +258,13 @@ export interface ModuleOptions {
251
258
  */
252
259
  translationDir?: string;
253
260
  /**
254
- * Controls how pre-merged translation payload files are emitted during build.
261
+ * Controls how translation payloads are emitted (Node: `public/<apiBaseUrl>`; Edge: Nitro `serverAssets`).
262
+ *
263
+ * - **Node**: `serverAssets` means local SSR via `readFile` under `public/` (no Rollup `raw:`).
264
+ * - **Edge**: `serverAssets` registers Nitro `serverAssets` (`assets:i18n`); it does not force a public copy.
255
265
  *
256
- * Keep the defaults for the existing all-in-one behavior. For serverless or CDN-backed
257
- * deployments, disable individual outputs to avoid duplicating large locale payloads in
258
- * both Nitro server assets and public assets.
266
+ * Keep the defaults for the usual all-in-one setup. For large Edge catalogs prefer `mode: 'source'`.
267
+ * For CDN-backed deployments, disable local outputs and set `apiBaseClientHost` / `apiBaseServerHost`.
259
268
  */
260
269
  translationPayloads?: TranslationPayloadOptions;
261
270
  /**
@@ -265,9 +274,14 @@ export interface ModuleOptions {
265
274
  */
266
275
  autoDetectLanguage?: boolean;
267
276
  /**
268
- * URL path on which automatic language detection and redirect occur.
269
- * - `'/'` — detect only on the root path.
270
- * - `'*'` — detect and redirect on every path (including locale-prefixed ones).
277
+ * Where cookie / Accept-Language preference redirects may run (when `redirects` is enabled).
278
+ * - `'/'` — only `/` (deep links in the default locale stay reachable; default)
279
+ * - `'no_prefix'` — only paths without a locale prefix
280
+ * - `'*'` — every path, including rewriting an explicit locale prefix
281
+ * (e.g. `/fr/about` → `/de/about` when the cookie prefers `de`)
282
+ * - any other string — exact path match (e.g. `'/welcome'`)
283
+ *
284
+ * Prefixed strategy cleanup (e.g. `/en` → `/` under `prefix_except_default`) is not gated.
271
285
  * @default '/'
272
286
  */
273
287
  autoDetectPath?: string;
@@ -292,13 +306,17 @@ export interface ModuleOptions {
292
306
  [key: string]: string;
293
307
  };
294
308
  /**
295
- * Custom pluralization function or a path to a file exporting one.
296
- * When a string path is provided, the file is imported at build time.
297
- * The function receives `(key, count, params, locale, getter)` and should return
298
- * the correct plural form as a string, or `null` to fall back to the built-in logic.
299
- * @default built-in pluralization (singular/plural by count)
309
+ * Custom pluralization function.
310
+ * Receives `(key, count, params, locale, getter)` and should return the selected
311
+ * plural form as a string, or `null`/`undefined` to fall back to the built-in
312
+ * `defaultPlural` logic (so you can override only some locales).
313
+ *
314
+ * For the Nuxt module the function is serialized with `.toString()` into
315
+ * `.nuxt/i18n.plural.mjs` — it must be self-contained (no imports / outer scope).
316
+ * A file path string is **not** supported.
317
+ * @default built-in pluralization (form index by count)
300
318
  */
301
- plural?: string | PluralFunc;
319
+ plural?: PluralFunc;
302
320
  /**
303
321
  * Disable per-page translation files.
304
322
  * When `true`, only global translations (`{locale}.json`) are loaded;
@@ -462,17 +480,19 @@ export interface ModuleOptions {
462
480
  export interface TranslationPayloadOptions {
463
481
  /**
464
482
  * Translation payload strategy.
465
- * - `premerged`: build-time page/locale matrix (default)
466
- * - `source`: compact source files merged at runtime (recommended for large serverless apps)
483
+ * - `premerged`: build-time `{page}/{locale}/data.json` matrix (default)
484
+ * - `source`: compact source files merged at runtime (prefer on Edge / large catalogs)
467
485
  * @default 'premerged'
468
486
  */
469
487
  mode?: 'premerged' | 'source';
470
488
  /**
471
- * Register translation payload files as Nitro server assets.
472
- * In `premerged` mode this is the fully merged page/locale matrix.
473
- * In `source` mode this is the compact layer-merged source directory.
474
- * Required for the built-in local `_locales` server route unless translations are fetched
475
- * from `apiBaseServerHost`.
489
+ * Local SSR payloads: Node reads `public/<apiBaseUrl>` (forces public copy); Edge embeds via Nitro `serverAssets`.
490
+ *
491
+ * - **Node**: no Nitro `serverAssets` (avoids Rollup `raw:`). SSR reads
492
+ * `public/<apiBaseUrl|publicDir>` as `{page}/{locale}/data.json`; when this is `true`,
493
+ * a public copy is forced even if `publicAssets` is false.
494
+ * - **Edge** (`nitro.node === false`): Nitro `serverAssets` (`assets:i18n`) with the same
495
+ * layout as `mode`. Does **not** force a public copy — set `publicAssets: true` for CDN.
476
496
  * @default true
477
497
  */
478
498
  serverAssets?: boolean;
@@ -483,21 +503,21 @@ export interface TranslationPayloadOptions {
483
503
  */
484
504
  serverHandler?: boolean;
485
505
  /**
486
- * Copy translation payload files into Nitro public assets during production builds.
487
- * In `source` mode this copies the compact source directory, not a pre-merged matrix.
506
+ * Copy payloads into Nitro public output. Premerged → `{page}/{locale}/data.json` under `apiBaseUrl`; source → compact tree.
507
+ *
508
+ * On Node this tree is also the SSR source when `serverAssets` forces a public copy.
488
509
  * @default true in premerged mode, false in source mode
489
510
  */
490
511
  publicAssets?: boolean;
491
512
  /**
492
- * Add translation data routes to Nuxt/Nitro prerender output.
493
- * Disable this when `_locales` payloads are served from an external host/CDN or should not be
494
- * materialized into public output.
495
- * @default true in premerged mode, false in source mode
513
+ * Opt in to Nitro-prerender `/{apiBaseUrl}/.../data.json`. Usually redundant when premerged `publicAssets` already wrote those files.
514
+ * @default false
496
515
  */
497
516
  prerenderRoutes?: boolean;
498
517
  /**
499
- * Public output directory for copied translation payloads, relative to Nitro's public directory.
500
- * Defaults to `translationDir`.
518
+ * Public output folder relative to Nitro public root. Defaults to `apiBaseUrl` (`_locales`).
519
+ *
520
+ * So static files match client fetch URLs (`/{apiBaseUrl}/{page}/{locale}/data.json`).
501
521
  */
502
522
  publicDir?: string;
503
523
  /**
@@ -558,6 +578,15 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
558
578
  };
559
579
  /** Preload index translations in Nitro global middleware. */
560
580
  serverTranslationPreload?: boolean;
581
+ /**
582
+ * Absolute buildDir path to payload files (`.nuxt/i18n-merged` or `.nuxt/i18n-source`).
583
+ * Used by the Node fs reader in `import.meta.dev` / `import.meta.prerender`.
584
+ */
585
+ payloadFsDir: string;
586
+ /**
587
+ * Directory under Nitro `public/` for prod payload files (defaults to `translationDir`).
588
+ */
589
+ payloadPublicRel: string;
561
590
  }
562
591
  /** Object shape for a translation value that contains singular/plural forms. */
563
592
  export interface PluralTranslations {
package/dist/index.d.ts CHANGED
@@ -162,10 +162,10 @@ export interface ModuleOptions {
162
162
  strategy?: Strategies;
163
163
  /**
164
164
  * Base URL for SEO meta tags (canonical, og:url, hreflang).
165
- * - `undefined` — dynamically resolved from the current request URL
165
+ * - A concrete URL string (e.g. `'https://example.com'`) — used as-is (highest priority).
166
+ * - `undefined` — falls back to `site.url` from `nuxt-site-config` when that module is
167
+ * present, otherwise the current request origin
166
168
  * (`useRequestURL().origin` on server, `window.location.origin` on client).
167
- * Best for multi-domain deployments.
168
- * - A concrete URL string (e.g. `'https://example.com'`) — used as-is.
169
169
  * @default undefined
170
170
  */
171
171
  metaBaseUrl?: string;
@@ -183,6 +183,13 @@ export interface ModuleOptions {
183
183
  * @default true
184
184
  */
185
185
  metaTrustForwardedProto?: boolean;
186
+ /**
187
+ * Also emit a bare-language `hreflang` derived from each locale's `iso`
188
+ * (e.g. `es-ES` → also `es`). The first regional locale in `locales` claims
189
+ * the bare tag for that language. Routing `code` is never used — only `iso || code`.
190
+ * @default false
191
+ */
192
+ hreflangBaseLanguage?: boolean;
186
193
  /**
187
194
  * Register the `defineI18nRoute()` macro plugin, enabling per-page `defineI18nRoute()` calls.
188
195
  * @default true
@@ -251,11 +258,13 @@ export interface ModuleOptions {
251
258
  */
252
259
  translationDir?: string;
253
260
  /**
254
- * Controls how pre-merged translation payload files are emitted during build.
261
+ * Controls how translation payloads are emitted (Node: `public/<apiBaseUrl>`; Edge: Nitro `serverAssets`).
262
+ *
263
+ * - **Node**: `serverAssets` means local SSR via `readFile` under `public/` (no Rollup `raw:`).
264
+ * - **Edge**: `serverAssets` registers Nitro `serverAssets` (`assets:i18n`); it does not force a public copy.
255
265
  *
256
- * Keep the defaults for the existing all-in-one behavior. For serverless or CDN-backed
257
- * deployments, disable individual outputs to avoid duplicating large locale payloads in
258
- * both Nitro server assets and public assets.
266
+ * Keep the defaults for the usual all-in-one setup. For large Edge catalogs prefer `mode: 'source'`.
267
+ * For CDN-backed deployments, disable local outputs and set `apiBaseClientHost` / `apiBaseServerHost`.
259
268
  */
260
269
  translationPayloads?: TranslationPayloadOptions;
261
270
  /**
@@ -265,9 +274,14 @@ export interface ModuleOptions {
265
274
  */
266
275
  autoDetectLanguage?: boolean;
267
276
  /**
268
- * URL path on which automatic language detection and redirect occur.
269
- * - `'/'` — detect only on the root path.
270
- * - `'*'` — detect and redirect on every path (including locale-prefixed ones).
277
+ * Where cookie / Accept-Language preference redirects may run (when `redirects` is enabled).
278
+ * - `'/'` — only `/` (deep links in the default locale stay reachable; default)
279
+ * - `'no_prefix'` — only paths without a locale prefix
280
+ * - `'*'` — every path, including rewriting an explicit locale prefix
281
+ * (e.g. `/fr/about` → `/de/about` when the cookie prefers `de`)
282
+ * - any other string — exact path match (e.g. `'/welcome'`)
283
+ *
284
+ * Prefixed strategy cleanup (e.g. `/en` → `/` under `prefix_except_default`) is not gated.
271
285
  * @default '/'
272
286
  */
273
287
  autoDetectPath?: string;
@@ -292,13 +306,17 @@ export interface ModuleOptions {
292
306
  [key: string]: string;
293
307
  };
294
308
  /**
295
- * Custom pluralization function or a path to a file exporting one.
296
- * When a string path is provided, the file is imported at build time.
297
- * The function receives `(key, count, params, locale, getter)` and should return
298
- * the correct plural form as a string, or `null` to fall back to the built-in logic.
299
- * @default built-in pluralization (singular/plural by count)
309
+ * Custom pluralization function.
310
+ * Receives `(key, count, params, locale, getter)` and should return the selected
311
+ * plural form as a string, or `null`/`undefined` to fall back to the built-in
312
+ * `defaultPlural` logic (so you can override only some locales).
313
+ *
314
+ * For the Nuxt module the function is serialized with `.toString()` into
315
+ * `.nuxt/i18n.plural.mjs` — it must be self-contained (no imports / outer scope).
316
+ * A file path string is **not** supported.
317
+ * @default built-in pluralization (form index by count)
300
318
  */
301
- plural?: string | PluralFunc;
319
+ plural?: PluralFunc;
302
320
  /**
303
321
  * Disable per-page translation files.
304
322
  * When `true`, only global translations (`{locale}.json`) are loaded;
@@ -462,17 +480,19 @@ export interface ModuleOptions {
462
480
  export interface TranslationPayloadOptions {
463
481
  /**
464
482
  * Translation payload strategy.
465
- * - `premerged`: build-time page/locale matrix (default)
466
- * - `source`: compact source files merged at runtime (recommended for large serverless apps)
483
+ * - `premerged`: build-time `{page}/{locale}/data.json` matrix (default)
484
+ * - `source`: compact source files merged at runtime (prefer on Edge / large catalogs)
467
485
  * @default 'premerged'
468
486
  */
469
487
  mode?: 'premerged' | 'source';
470
488
  /**
471
- * Register translation payload files as Nitro server assets.
472
- * In `premerged` mode this is the fully merged page/locale matrix.
473
- * In `source` mode this is the compact layer-merged source directory.
474
- * Required for the built-in local `_locales` server route unless translations are fetched
475
- * from `apiBaseServerHost`.
489
+ * Local SSR payloads: Node reads `public/<apiBaseUrl>` (forces public copy); Edge embeds via Nitro `serverAssets`.
490
+ *
491
+ * - **Node**: no Nitro `serverAssets` (avoids Rollup `raw:`). SSR reads
492
+ * `public/<apiBaseUrl|publicDir>` as `{page}/{locale}/data.json`; when this is `true`,
493
+ * a public copy is forced even if `publicAssets` is false.
494
+ * - **Edge** (`nitro.node === false`): Nitro `serverAssets` (`assets:i18n`) with the same
495
+ * layout as `mode`. Does **not** force a public copy — set `publicAssets: true` for CDN.
476
496
  * @default true
477
497
  */
478
498
  serverAssets?: boolean;
@@ -483,21 +503,21 @@ export interface TranslationPayloadOptions {
483
503
  */
484
504
  serverHandler?: boolean;
485
505
  /**
486
- * Copy translation payload files into Nitro public assets during production builds.
487
- * In `source` mode this copies the compact source directory, not a pre-merged matrix.
506
+ * Copy payloads into Nitro public output. Premerged → `{page}/{locale}/data.json` under `apiBaseUrl`; source → compact tree.
507
+ *
508
+ * On Node this tree is also the SSR source when `serverAssets` forces a public copy.
488
509
  * @default true in premerged mode, false in source mode
489
510
  */
490
511
  publicAssets?: boolean;
491
512
  /**
492
- * Add translation data routes to Nuxt/Nitro prerender output.
493
- * Disable this when `_locales` payloads are served from an external host/CDN or should not be
494
- * materialized into public output.
495
- * @default true in premerged mode, false in source mode
513
+ * Opt in to Nitro-prerender `/{apiBaseUrl}/.../data.json`. Usually redundant when premerged `publicAssets` already wrote those files.
514
+ * @default false
496
515
  */
497
516
  prerenderRoutes?: boolean;
498
517
  /**
499
- * Public output directory for copied translation payloads, relative to Nitro's public directory.
500
- * Defaults to `translationDir`.
518
+ * Public output folder relative to Nitro public root. Defaults to `apiBaseUrl` (`_locales`).
519
+ *
520
+ * So static files match client fetch URLs (`/{apiBaseUrl}/{page}/{locale}/data.json`).
501
521
  */
502
522
  publicDir?: string;
503
523
  /**
@@ -558,6 +578,15 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
558
578
  };
559
579
  /** Preload index translations in Nitro global middleware. */
560
580
  serverTranslationPreload?: boolean;
581
+ /**
582
+ * Absolute buildDir path to payload files (`.nuxt/i18n-merged` or `.nuxt/i18n-source`).
583
+ * Used by the Node fs reader in `import.meta.dev` / `import.meta.prerender`.
584
+ */
585
+ payloadFsDir: string;
586
+ /**
587
+ * Directory under Nitro `public/` for prod payload files (defaults to `translationDir`).
588
+ */
589
+ payloadPublicRel: string;
561
590
  }
562
591
  /** Object shape for a translation value that contains singular/plural forms. */
563
592
  export interface PluralTranslations {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-micro/types",
3
- "version": "1.2.7",
3
+ "version": "1.2.10",
4
4
  "description": "TypeScript definitions for the Nuxt I18n Micro ecosystem.",
5
5
  "keywords": [
6
6
  "i18n",