@i18n-micro/types 1.2.2 → 1.2.4

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/README.md CHANGED
@@ -68,12 +68,15 @@ const routeParams: I18nRouteParams = {
68
68
  ### Types and Interfaces
69
69
 
70
70
  #### `Locale`
71
+
71
72
  Represents a locale configuration.
72
73
 
73
74
  #### `LocaleCode`
75
+
74
76
  Represents a locale code (e.g., `'en'`, `'de'`).
75
77
 
76
78
  #### `Strategies`
79
+
77
80
  Represents the available routing strategies.
78
81
 
79
82
  ```typescript
@@ -81,30 +84,39 @@ export type Strategies = 'no_prefix' | 'prefix_except_default' | 'prefix' | 'pre
81
84
  ```
82
85
 
83
86
  #### `ModuleOptions`
87
+
84
88
  Represents the configuration options for the `nuxt-i18n-micro` module.
85
89
 
86
90
  #### `ModuleOptionsExtend`
91
+
87
92
  Extends `ModuleOptions` with additional properties.
88
93
 
89
94
  #### `I18nRouteParams`
95
+
90
96
  Represents route parameters for different locales.
91
97
 
92
98
  #### `Params`
99
+
93
100
  Represents a key-value pair of parameters for interpolation.
94
101
 
95
102
  #### `PluralFunc`
103
+
96
104
  Represents a function for handling pluralization in translations.
97
105
 
98
106
  #### `GlobalLocaleRoutes`
107
+
99
108
  Represents global route configurations for different locales.
100
109
 
101
110
  #### `Translations`
111
+
102
112
  Represents a key-value pair of translations.
103
113
 
104
114
  #### `Translation`
115
+
105
116
  Represents a translation value, which can be a string, number, boolean, nested translations, or `null`.
106
117
 
107
118
  #### `PluralTranslations`
119
+
108
120
  Represents translations for singular and plural forms.
109
121
 
110
122
  ## Contributing
package/dist/index.d.cts CHANGED
@@ -213,6 +213,11 @@ export interface ModuleOptions {
213
213
  * @default true
214
214
  */
215
215
  components?: boolean;
216
+ /**
217
+ * Preload index-page translations in Nitro global middleware (server-only, private config).
218
+ * @default false
219
+ */
220
+ serverTranslationPreload?: boolean;
216
221
  /**
217
222
  * The locale to use when no locale can be determined from URL or user preferences.
218
223
  * Also used as the fallback locale for missing translations when `fallbackLocale` is not set.
@@ -244,6 +249,14 @@ export interface ModuleOptions {
244
249
  * @default 'locales'
245
250
  */
246
251
  translationDir?: string;
252
+ /**
253
+ * Controls how pre-merged translation payload files are emitted during build.
254
+ *
255
+ * Keep the defaults for the existing all-in-one behavior. For serverless or CDN-backed
256
+ * deployments, disable individual outputs to avoid duplicating large locale payloads in
257
+ * both Nitro server assets and public assets.
258
+ */
259
+ translationPayloads?: TranslationPayloadOptions;
247
260
  /**
248
261
  * Automatically detect the user's preferred language from the `Accept-Language` HTTP header.
249
262
  * Used in combination with `autoDetectPath` to decide when detection occurs.
@@ -404,6 +417,58 @@ export interface ModuleOptions {
404
417
  */
405
418
  experimental?: Record<string, unknown>;
406
419
  }
420
+ export interface TranslationPayloadOptions {
421
+ /**
422
+ * Translation payload strategy.
423
+ * - `premerged`: build-time page/locale matrix (default)
424
+ * - `source`: compact source files merged at runtime (recommended for large serverless apps)
425
+ * @default 'premerged'
426
+ */
427
+ mode?: 'premerged' | 'source';
428
+ /**
429
+ * Register translation payload files as Nitro server assets.
430
+ * In `premerged` mode this is the fully merged page/locale matrix.
431
+ * In `source` mode this is the compact layer-merged source directory.
432
+ * Required for the built-in local `_locales` server route unless translations are fetched
433
+ * from `apiBaseServerHost`.
434
+ * @default true
435
+ */
436
+ serverAssets?: boolean;
437
+ /**
438
+ * Register the built-in server route at `/{apiBaseUrl}/:page/:locale/data.json`.
439
+ * Disable this when translation payloads are served from an external host/CDN.
440
+ * @default true
441
+ */
442
+ serverHandler?: boolean;
443
+ /**
444
+ * Copy translation payload files into Nitro public assets during production builds.
445
+ * In `source` mode this copies the compact source directory, not a pre-merged matrix.
446
+ * @default true in `premerged` mode, `false` in `source` mode
447
+ */
448
+ publicAssets?: boolean;
449
+ /**
450
+ * Add translation data routes to Nuxt/Nitro prerender output.
451
+ * Disable this when `_locales` payloads are served from an external host/CDN or should not be
452
+ * materialized into public output.
453
+ * @default true in `premerged` mode, `false` in `source` mode
454
+ */
455
+ prerenderRoutes?: boolean;
456
+ /**
457
+ * Public output directory for copied translation payloads, relative to Nitro's public directory.
458
+ * Defaults to `translationDir`.
459
+ */
460
+ publicDir?: string;
461
+ /**
462
+ * Warn during build when generated payload file count exceeds this threshold.
463
+ * @default 500
464
+ */
465
+ warnFileCount?: number;
466
+ /**
467
+ * Warn during build when generated payload total size exceeds this threshold in bytes.
468
+ * @default 10485760 (10 MB)
469
+ */
470
+ warnSizeBytes?: number;
471
+ }
407
472
  /**
408
473
  * Extended module options injected into the Nuxt runtime config.
409
474
  * Includes resolved values and build-time metadata.
@@ -421,6 +486,8 @@ export interface ModuleOptionsExtend extends ModuleOptions {
421
486
  disablePageLocales: boolean;
422
487
  /** Resolved flag: whether locale-based redirects are enabled. */
423
488
  redirects?: boolean;
489
+ /** Resolved translation payload loading strategy. */
490
+ translationPayloadMode?: 'premerged' | 'source';
424
491
  }
425
492
  /**
426
493
  * Private (server-only) module options passed to Nitro plugins and server middleware.
@@ -447,6 +514,8 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
447
514
  routesLocaleLinks?: {
448
515
  [key: string]: string;
449
516
  };
517
+ /** Preload index translations in Nitro global middleware. */
518
+ serverTranslationPreload?: boolean;
450
519
  }
451
520
  /** Object shape for a translation value that contains singular/plural forms. */
452
521
  export interface PluralTranslations {
package/dist/index.d.ts CHANGED
@@ -213,6 +213,11 @@ export interface ModuleOptions {
213
213
  * @default true
214
214
  */
215
215
  components?: boolean;
216
+ /**
217
+ * Preload index-page translations in Nitro global middleware (server-only, private config).
218
+ * @default false
219
+ */
220
+ serverTranslationPreload?: boolean;
216
221
  /**
217
222
  * The locale to use when no locale can be determined from URL or user preferences.
218
223
  * Also used as the fallback locale for missing translations when `fallbackLocale` is not set.
@@ -244,6 +249,14 @@ export interface ModuleOptions {
244
249
  * @default 'locales'
245
250
  */
246
251
  translationDir?: string;
252
+ /**
253
+ * Controls how pre-merged translation payload files are emitted during build.
254
+ *
255
+ * Keep the defaults for the existing all-in-one behavior. For serverless or CDN-backed
256
+ * deployments, disable individual outputs to avoid duplicating large locale payloads in
257
+ * both Nitro server assets and public assets.
258
+ */
259
+ translationPayloads?: TranslationPayloadOptions;
247
260
  /**
248
261
  * Automatically detect the user's preferred language from the `Accept-Language` HTTP header.
249
262
  * Used in combination with `autoDetectPath` to decide when detection occurs.
@@ -404,6 +417,58 @@ export interface ModuleOptions {
404
417
  */
405
418
  experimental?: Record<string, unknown>;
406
419
  }
420
+ export interface TranslationPayloadOptions {
421
+ /**
422
+ * Translation payload strategy.
423
+ * - `premerged`: build-time page/locale matrix (default)
424
+ * - `source`: compact source files merged at runtime (recommended for large serverless apps)
425
+ * @default 'premerged'
426
+ */
427
+ mode?: 'premerged' | 'source';
428
+ /**
429
+ * Register translation payload files as Nitro server assets.
430
+ * In `premerged` mode this is the fully merged page/locale matrix.
431
+ * In `source` mode this is the compact layer-merged source directory.
432
+ * Required for the built-in local `_locales` server route unless translations are fetched
433
+ * from `apiBaseServerHost`.
434
+ * @default true
435
+ */
436
+ serverAssets?: boolean;
437
+ /**
438
+ * Register the built-in server route at `/{apiBaseUrl}/:page/:locale/data.json`.
439
+ * Disable this when translation payloads are served from an external host/CDN.
440
+ * @default true
441
+ */
442
+ serverHandler?: boolean;
443
+ /**
444
+ * Copy translation payload files into Nitro public assets during production builds.
445
+ * In `source` mode this copies the compact source directory, not a pre-merged matrix.
446
+ * @default true in `premerged` mode, `false` in `source` mode
447
+ */
448
+ publicAssets?: boolean;
449
+ /**
450
+ * Add translation data routes to Nuxt/Nitro prerender output.
451
+ * Disable this when `_locales` payloads are served from an external host/CDN or should not be
452
+ * materialized into public output.
453
+ * @default true in `premerged` mode, `false` in `source` mode
454
+ */
455
+ prerenderRoutes?: boolean;
456
+ /**
457
+ * Public output directory for copied translation payloads, relative to Nitro's public directory.
458
+ * Defaults to `translationDir`.
459
+ */
460
+ publicDir?: string;
461
+ /**
462
+ * Warn during build when generated payload file count exceeds this threshold.
463
+ * @default 500
464
+ */
465
+ warnFileCount?: number;
466
+ /**
467
+ * Warn during build when generated payload total size exceeds this threshold in bytes.
468
+ * @default 10485760 (10 MB)
469
+ */
470
+ warnSizeBytes?: number;
471
+ }
407
472
  /**
408
473
  * Extended module options injected into the Nuxt runtime config.
409
474
  * Includes resolved values and build-time metadata.
@@ -421,6 +486,8 @@ export interface ModuleOptionsExtend extends ModuleOptions {
421
486
  disablePageLocales: boolean;
422
487
  /** Resolved flag: whether locale-based redirects are enabled. */
423
488
  redirects?: boolean;
489
+ /** Resolved translation payload loading strategy. */
490
+ translationPayloadMode?: 'premerged' | 'source';
424
491
  }
425
492
  /**
426
493
  * Private (server-only) module options passed to Nitro plugins and server middleware.
@@ -447,6 +514,8 @@ export interface ModulePrivateOptionsExtend extends ModuleOptions {
447
514
  routesLocaleLinks?: {
448
515
  [key: string]: string;
449
516
  };
517
+ /** Preload index translations in Nitro global middleware. */
518
+ serverTranslationPreload?: boolean;
450
519
  }
451
520
  /** Object shape for a translation value that contains singular/plural forms. */
452
521
  export interface PluralTranslations {
package/package.json CHANGED
@@ -1,27 +1,35 @@
1
1
  {
2
2
  "name": "@i18n-micro/types",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "TypeScript definitions for the Nuxt I18n Micro ecosystem.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/s00d/nuxt-i18n-micro.git",
8
- "directory": "packages/types"
5
+ "keywords": [
6
+ "i18n",
7
+ "nuxt",
8
+ "types",
9
+ "typescript"
10
+ ],
11
+ "homepage": "https://github.com/s00d/nuxt-i18n-micro/tree/main/packages/types#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/s00d/nuxt-i18n-micro/issues"
9
14
  },
10
15
  "license": "MIT",
11
- "type": "module",
12
- "sideEffects": false,
13
16
  "author": {
14
17
  "name": "s00d",
15
18
  "email": "Virus191288@gmail.com",
16
19
  "url": "https://s00d.github.io/"
17
20
  },
18
- "homepage": "https://github.com/s00d/nuxt-i18n-micro/tree/main/packages/types#readme",
19
- "bugs": {
20
- "url": "https://github.com/s00d/nuxt-i18n-micro/issues"
21
- },
22
- "engines": {
23
- "node": ">=18"
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/s00d/nuxt-i18n-micro.git",
24
+ "directory": "packages/types"
24
25
  },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "type": "module",
32
+ "sideEffects": false,
25
33
  "main": "dist/index.cjs",
26
34
  "types": "dist/index.d.ts",
27
35
  "exports": {
@@ -38,25 +46,17 @@
38
46
  },
39
47
  "./package.json": "./package.json"
40
48
  },
41
- "files": [
42
- "dist",
43
- "README.md",
44
- "LICENSE"
45
- ],
46
49
  "publishConfig": {
47
50
  "access": "public"
48
51
  },
49
- "keywords": [
50
- "nuxt",
51
- "i18n",
52
- "typescript",
53
- "types"
54
- ],
55
52
  "devDependencies": {
56
53
  "publint": "^0.3.17",
57
54
  "vite": "^7.3.1",
58
55
  "vite-plugin-dts": "^4.5.4"
59
56
  },
57
+ "engines": {
58
+ "node": ">=18"
59
+ },
60
60
  "scripts": {
61
61
  "build": "vite build",
62
62
  "check:package": "publint"