@i18n-micro/types 1.2.6 → 1.2.8
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 +74 -20
- package/dist/index.d.ts +74 -20
- package/package.json +6 -4
package/dist/index.d.cts
CHANGED
|
@@ -251,11 +251,13 @@ export interface ModuleOptions {
|
|
|
251
251
|
*/
|
|
252
252
|
translationDir?: string;
|
|
253
253
|
/**
|
|
254
|
-
* Controls how
|
|
254
|
+
* Controls how translation payloads are emitted (Node: `public/<apiBaseUrl>`; Edge: Nitro `serverAssets`).
|
|
255
255
|
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* - **Node**: `serverAssets` means local SSR via `readFile` under `public/` (no Rollup `raw:`).
|
|
257
|
+
* - **Edge**: `serverAssets` registers Nitro `serverAssets` (`assets:i18n`); it does not force a public copy.
|
|
258
|
+
*
|
|
259
|
+
* Keep the defaults for the usual all-in-one setup. For large Edge catalogs prefer `mode: 'source'`.
|
|
260
|
+
* For CDN-backed deployments, disable local outputs and set `apiBaseClientHost` / `apiBaseServerHost`.
|
|
259
261
|
*/
|
|
260
262
|
translationPayloads?: TranslationPayloadOptions;
|
|
261
263
|
/**
|
|
@@ -401,6 +403,47 @@ export interface ModuleOptions {
|
|
|
401
403
|
* @default 0
|
|
402
404
|
*/
|
|
403
405
|
cacheTtl?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Named number formats per locale (Vue I18n-compatible).
|
|
408
|
+
* Enables `$tn(1000, 'currency')` style calls.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* numberFormats: {
|
|
412
|
+
* en: { currency: { style: 'currency', currency: 'USD' } },
|
|
413
|
+
* de: { currency: { style: 'currency', currency: 'EUR' } },
|
|
414
|
+
* }
|
|
415
|
+
*/
|
|
416
|
+
numberFormats?: Record<string, Record<string, Intl.NumberFormatOptions>>;
|
|
417
|
+
/**
|
|
418
|
+
* Named datetime formats per locale (Vue I18n-compatible `datetimeFormats`).
|
|
419
|
+
* Enables `$td(date, 'short')` style calls.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* datetimeFormats: {
|
|
423
|
+
* en: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
|
|
424
|
+
* de: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
|
|
425
|
+
* }
|
|
426
|
+
*/
|
|
427
|
+
datetimeFormats?: Record<string, Record<string, Intl.DateTimeFormatOptions>>;
|
|
428
|
+
/**
|
|
429
|
+
* HTTP `Cache-Control` max-age (seconds) for `/{apiBaseUrl}/:page/:locale/data.json`.
|
|
430
|
+
*
|
|
431
|
+
* Applies in full only while `dateBuild` busts the URL (`?v=...`), which is the default:
|
|
432
|
+
* the response is then `public, max-age=…, immutable` and safe for browsers and CDNs.
|
|
433
|
+
*
|
|
434
|
+
* - `dateBuild: 0`/`''` — the URL is stable, so this duration is *not* honoured; the
|
|
435
|
+
* response becomes `public, max-age=0, must-revalidate` instead. A long `max-age` on an
|
|
436
|
+
* unchanging URL pins the first payload a browser ever saw.
|
|
437
|
+
* - `0` — do not set `Cache-Control` at all (useful in local debugging)
|
|
438
|
+
* - Not applied in development (`import.meta.dev`) so HMR is not fought by the browser cache
|
|
439
|
+
* - Reaches only responses served through Nitro. Payloads copied into `public/` and served
|
|
440
|
+
* by the hosting platform take that platform's headers — see the Performance guide.
|
|
441
|
+
*
|
|
442
|
+
* Analogous to `@nuxtjs/i18n` experimental `httpCacheDuration` (v10.2.0), but as an
|
|
443
|
+
* explicit response header rather than Nitro `defineCachedEventHandler` maxAge.
|
|
444
|
+
* @default 31536000
|
|
445
|
+
*/
|
|
446
|
+
httpCacheDuration?: number;
|
|
404
447
|
/**
|
|
405
448
|
* Value used for cache-busting translation requests (`?v=...`).
|
|
406
449
|
*
|
|
@@ -421,17 +464,19 @@ export interface ModuleOptions {
|
|
|
421
464
|
export interface TranslationPayloadOptions {
|
|
422
465
|
/**
|
|
423
466
|
* Translation payload strategy.
|
|
424
|
-
* - `premerged`: build-time page/locale matrix (default)
|
|
425
|
-
* - `source`: compact source files merged at runtime (
|
|
467
|
+
* - `premerged`: build-time `{page}/{locale}/data.json` matrix (default)
|
|
468
|
+
* - `source`: compact source files merged at runtime (prefer on Edge / large catalogs)
|
|
426
469
|
* @default 'premerged'
|
|
427
470
|
*/
|
|
428
471
|
mode?: 'premerged' | 'source';
|
|
429
472
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
473
|
+
* Local SSR payloads: Node reads `public/<apiBaseUrl>` (forces public copy); Edge embeds via Nitro `serverAssets`.
|
|
474
|
+
*
|
|
475
|
+
* - **Node**: no Nitro `serverAssets` (avoids Rollup `raw:`). SSR reads
|
|
476
|
+
* `public/<apiBaseUrl|publicDir>` as `{page}/{locale}/data.json`; when this is `true`,
|
|
477
|
+
* a public copy is forced even if `publicAssets` is false.
|
|
478
|
+
* - **Edge** (`nitro.node === false`): Nitro `serverAssets` (`assets:i18n`) with the same
|
|
479
|
+
* layout as `mode`. Does **not** force a public copy — set `publicAssets: true` for CDN.
|
|
435
480
|
* @default true
|
|
436
481
|
*/
|
|
437
482
|
serverAssets?: boolean;
|
|
@@ -442,21 +487,21 @@ export interface TranslationPayloadOptions {
|
|
|
442
487
|
*/
|
|
443
488
|
serverHandler?: boolean;
|
|
444
489
|
/**
|
|
445
|
-
* Copy
|
|
446
|
-
*
|
|
447
|
-
*
|
|
490
|
+
* Copy payloads into Nitro public output. Premerged → `{page}/{locale}/data.json` under `apiBaseUrl`; source → compact tree.
|
|
491
|
+
*
|
|
492
|
+
* On Node this tree is also the SSR source when `serverAssets` forces a public copy.
|
|
493
|
+
* @default true in premerged mode, false in source mode
|
|
448
494
|
*/
|
|
449
495
|
publicAssets?: boolean;
|
|
450
496
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* materialized into public output.
|
|
454
|
-
* @default true in `premerged` mode, `false` in `source` mode
|
|
497
|
+
* Opt in to Nitro-prerender `/{apiBaseUrl}/.../data.json`. Usually redundant when premerged `publicAssets` already wrote those files.
|
|
498
|
+
* @default false
|
|
455
499
|
*/
|
|
456
500
|
prerenderRoutes?: boolean;
|
|
457
501
|
/**
|
|
458
|
-
* Public output
|
|
459
|
-
*
|
|
502
|
+
* Public output folder relative to Nitro public root. Defaults to `apiBaseUrl` (`_locales`).
|
|
503
|
+
*
|
|
504
|
+
* So static files match client fetch URLs (`/{apiBaseUrl}/{page}/{locale}/data.json`).
|
|
460
505
|
*/
|
|
461
506
|
publicDir?: string;
|
|
462
507
|
/**
|
|
@@ -517,6 +562,15 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
|
517
562
|
};
|
|
518
563
|
/** Preload index translations in Nitro global middleware. */
|
|
519
564
|
serverTranslationPreload?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Absolute buildDir path to payload files (`.nuxt/i18n-merged` or `.nuxt/i18n-source`).
|
|
567
|
+
* Used by the Node fs reader in `import.meta.dev` / `import.meta.prerender`.
|
|
568
|
+
*/
|
|
569
|
+
payloadFsDir: string;
|
|
570
|
+
/**
|
|
571
|
+
* Directory under Nitro `public/` for prod payload files (defaults to `translationDir`).
|
|
572
|
+
*/
|
|
573
|
+
payloadPublicRel: string;
|
|
520
574
|
}
|
|
521
575
|
/** Object shape for a translation value that contains singular/plural forms. */
|
|
522
576
|
export interface PluralTranslations {
|
package/dist/index.d.ts
CHANGED
|
@@ -251,11 +251,13 @@ export interface ModuleOptions {
|
|
|
251
251
|
*/
|
|
252
252
|
translationDir?: string;
|
|
253
253
|
/**
|
|
254
|
-
* Controls how
|
|
254
|
+
* Controls how translation payloads are emitted (Node: `public/<apiBaseUrl>`; Edge: Nitro `serverAssets`).
|
|
255
255
|
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* - **Node**: `serverAssets` means local SSR via `readFile` under `public/` (no Rollup `raw:`).
|
|
257
|
+
* - **Edge**: `serverAssets` registers Nitro `serverAssets` (`assets:i18n`); it does not force a public copy.
|
|
258
|
+
*
|
|
259
|
+
* Keep the defaults for the usual all-in-one setup. For large Edge catalogs prefer `mode: 'source'`.
|
|
260
|
+
* For CDN-backed deployments, disable local outputs and set `apiBaseClientHost` / `apiBaseServerHost`.
|
|
259
261
|
*/
|
|
260
262
|
translationPayloads?: TranslationPayloadOptions;
|
|
261
263
|
/**
|
|
@@ -401,6 +403,47 @@ export interface ModuleOptions {
|
|
|
401
403
|
* @default 0
|
|
402
404
|
*/
|
|
403
405
|
cacheTtl?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Named number formats per locale (Vue I18n-compatible).
|
|
408
|
+
* Enables `$tn(1000, 'currency')` style calls.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* numberFormats: {
|
|
412
|
+
* en: { currency: { style: 'currency', currency: 'USD' } },
|
|
413
|
+
* de: { currency: { style: 'currency', currency: 'EUR' } },
|
|
414
|
+
* }
|
|
415
|
+
*/
|
|
416
|
+
numberFormats?: Record<string, Record<string, Intl.NumberFormatOptions>>;
|
|
417
|
+
/**
|
|
418
|
+
* Named datetime formats per locale (Vue I18n-compatible `datetimeFormats`).
|
|
419
|
+
* Enables `$td(date, 'short')` style calls.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* datetimeFormats: {
|
|
423
|
+
* en: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
|
|
424
|
+
* de: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
|
|
425
|
+
* }
|
|
426
|
+
*/
|
|
427
|
+
datetimeFormats?: Record<string, Record<string, Intl.DateTimeFormatOptions>>;
|
|
428
|
+
/**
|
|
429
|
+
* HTTP `Cache-Control` max-age (seconds) for `/{apiBaseUrl}/:page/:locale/data.json`.
|
|
430
|
+
*
|
|
431
|
+
* Applies in full only while `dateBuild` busts the URL (`?v=...`), which is the default:
|
|
432
|
+
* the response is then `public, max-age=…, immutable` and safe for browsers and CDNs.
|
|
433
|
+
*
|
|
434
|
+
* - `dateBuild: 0`/`''` — the URL is stable, so this duration is *not* honoured; the
|
|
435
|
+
* response becomes `public, max-age=0, must-revalidate` instead. A long `max-age` on an
|
|
436
|
+
* unchanging URL pins the first payload a browser ever saw.
|
|
437
|
+
* - `0` — do not set `Cache-Control` at all (useful in local debugging)
|
|
438
|
+
* - Not applied in development (`import.meta.dev`) so HMR is not fought by the browser cache
|
|
439
|
+
* - Reaches only responses served through Nitro. Payloads copied into `public/` and served
|
|
440
|
+
* by the hosting platform take that platform's headers — see the Performance guide.
|
|
441
|
+
*
|
|
442
|
+
* Analogous to `@nuxtjs/i18n` experimental `httpCacheDuration` (v10.2.0), but as an
|
|
443
|
+
* explicit response header rather than Nitro `defineCachedEventHandler` maxAge.
|
|
444
|
+
* @default 31536000
|
|
445
|
+
*/
|
|
446
|
+
httpCacheDuration?: number;
|
|
404
447
|
/**
|
|
405
448
|
* Value used for cache-busting translation requests (`?v=...`).
|
|
406
449
|
*
|
|
@@ -421,17 +464,19 @@ export interface ModuleOptions {
|
|
|
421
464
|
export interface TranslationPayloadOptions {
|
|
422
465
|
/**
|
|
423
466
|
* Translation payload strategy.
|
|
424
|
-
* - `premerged`: build-time page/locale matrix (default)
|
|
425
|
-
* - `source`: compact source files merged at runtime (
|
|
467
|
+
* - `premerged`: build-time `{page}/{locale}/data.json` matrix (default)
|
|
468
|
+
* - `source`: compact source files merged at runtime (prefer on Edge / large catalogs)
|
|
426
469
|
* @default 'premerged'
|
|
427
470
|
*/
|
|
428
471
|
mode?: 'premerged' | 'source';
|
|
429
472
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
473
|
+
* Local SSR payloads: Node reads `public/<apiBaseUrl>` (forces public copy); Edge embeds via Nitro `serverAssets`.
|
|
474
|
+
*
|
|
475
|
+
* - **Node**: no Nitro `serverAssets` (avoids Rollup `raw:`). SSR reads
|
|
476
|
+
* `public/<apiBaseUrl|publicDir>` as `{page}/{locale}/data.json`; when this is `true`,
|
|
477
|
+
* a public copy is forced even if `publicAssets` is false.
|
|
478
|
+
* - **Edge** (`nitro.node === false`): Nitro `serverAssets` (`assets:i18n`) with the same
|
|
479
|
+
* layout as `mode`. Does **not** force a public copy — set `publicAssets: true` for CDN.
|
|
435
480
|
* @default true
|
|
436
481
|
*/
|
|
437
482
|
serverAssets?: boolean;
|
|
@@ -442,21 +487,21 @@ export interface TranslationPayloadOptions {
|
|
|
442
487
|
*/
|
|
443
488
|
serverHandler?: boolean;
|
|
444
489
|
/**
|
|
445
|
-
* Copy
|
|
446
|
-
*
|
|
447
|
-
*
|
|
490
|
+
* Copy payloads into Nitro public output. Premerged → `{page}/{locale}/data.json` under `apiBaseUrl`; source → compact tree.
|
|
491
|
+
*
|
|
492
|
+
* On Node this tree is also the SSR source when `serverAssets` forces a public copy.
|
|
493
|
+
* @default true in premerged mode, false in source mode
|
|
448
494
|
*/
|
|
449
495
|
publicAssets?: boolean;
|
|
450
496
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* materialized into public output.
|
|
454
|
-
* @default true in `premerged` mode, `false` in `source` mode
|
|
497
|
+
* Opt in to Nitro-prerender `/{apiBaseUrl}/.../data.json`. Usually redundant when premerged `publicAssets` already wrote those files.
|
|
498
|
+
* @default false
|
|
455
499
|
*/
|
|
456
500
|
prerenderRoutes?: boolean;
|
|
457
501
|
/**
|
|
458
|
-
* Public output
|
|
459
|
-
*
|
|
502
|
+
* Public output folder relative to Nitro public root. Defaults to `apiBaseUrl` (`_locales`).
|
|
503
|
+
*
|
|
504
|
+
* So static files match client fetch URLs (`/{apiBaseUrl}/{page}/{locale}/data.json`).
|
|
460
505
|
*/
|
|
461
506
|
publicDir?: string;
|
|
462
507
|
/**
|
|
@@ -517,6 +562,15 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
|
517
562
|
};
|
|
518
563
|
/** Preload index translations in Nitro global middleware. */
|
|
519
564
|
serverTranslationPreload?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Absolute buildDir path to payload files (`.nuxt/i18n-merged` or `.nuxt/i18n-source`).
|
|
567
|
+
* Used by the Node fs reader in `import.meta.dev` / `import.meta.prerender`.
|
|
568
|
+
*/
|
|
569
|
+
payloadFsDir: string;
|
|
570
|
+
/**
|
|
571
|
+
* Directory under Nitro `public/` for prod payload files (defaults to `translationDir`).
|
|
572
|
+
*/
|
|
573
|
+
payloadPublicRel: string;
|
|
520
574
|
}
|
|
521
575
|
/** Object shape for a translation value that contains singular/plural forms. */
|
|
522
576
|
export interface PluralTranslations {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-micro/types",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "TypeScript definitions for the Nuxt I18n Micro ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -51,14 +51,16 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"publint": "^0.3.17",
|
|
54
|
-
"vite": "^7.3.
|
|
55
|
-
"vite-plugin-dts": "^4.5.4"
|
|
54
|
+
"vite": "^7.3.6",
|
|
55
|
+
"vite-plugin-dts": "^4.5.4",
|
|
56
|
+
"vitest": "^4.1.10"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
58
59
|
"node": ">=18"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "vite build",
|
|
62
|
-
"check:package": "publint"
|
|
63
|
+
"check:package": "publint",
|
|
64
|
+
"test": "vitest run --typecheck"
|
|
63
65
|
}
|
|
64
66
|
}
|