vite-bundled-i18n 0.2.1 → 0.2.12

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
@@ -1,6 +1,6 @@
1
1
  # vite-bundled-i18n
2
2
 
3
- Route-aware internationalization for Vite. Each page loads only the translations it uses. Keys are fully typed. Production builds emit static, scope-matched bundles.
3
+ Route-aware internationalization for Vite. Each page loads only the translations it uses. Keys are fully typed with progressive autocomplete. Production builds emit static, scope-matched bundles.
4
4
 
5
5
  ```bash
6
6
  npm i vite-bundled-i18n
@@ -11,12 +11,14 @@ Requires Node `>=20` and Vite. React, Vue, and vanilla adapters are included —
11
11
  ## Features
12
12
 
13
13
  - **Scope bundles** — translations grouped by route (`products.index`) and loaded on demand
14
- - **Dictionary ownership** — named dictionaries claim keys by pattern with explicit priority
15
- - **Type generation** — TypeScript types for every key and placeholder, generated from source
14
+ - **Dictionary ownership** — named dictionaries claim keys by pattern, with `include`/`exclude` and priority
15
+ - **Progressive autocomplete** — nested types let the IDE suggest one level at a time (`t('feedback.` → `pages`, `actions`, ...)
16
+ - **Placeholder validation** — `t('cart.total', { amount: 9.99 })` is type-checked against `{{amount}}` in the JSON
16
17
  - **Compiled production output** — Vite plugin emits `__i18n/` assets as static JSON or compiled modules
17
18
  - **Multi-framework** — React, Vue, and vanilla JS share a single core
18
19
  - **SSR** — server-side rendering with automatic client hydration
19
- - **AST extraction** — finds translation keys in source without execution
20
+ - **AST extraction** — finds translation keys in source without execution, including `t()` passed as arguments to helper functions
21
+ - **Custom URL resolution** — `resolveUrl` callback for CDN, API endpoints, or any non-standard deployment
20
22
 
21
23
  ## Setup
22
24
 
@@ -31,6 +33,7 @@ export const i18nConfig = defineI18nConfig({
31
33
  dictionaries: {
32
34
  global: {
33
35
  include: ['shared.*', 'global.*', 'actions.*'],
36
+ exclude: ['shared.validation.*'], // optional — carve out large sub-namespaces
34
37
  priority: 1,
35
38
  pinned: true,
36
39
  },
@@ -67,12 +70,14 @@ export default defineConfig({
67
70
  locales: ['en', 'bg'],
68
71
  defaultLocale: 'en',
69
72
  generatedOutDir: '.i18n',
70
- typesOutPath: 'src/i18n-types.d.ts',
73
+ // typesOutPath defaults to '.i18n/i18n.d.ts' — add '.i18n' to tsconfig include
71
74
  }),
72
75
  ],
73
76
  })
74
77
  ```
75
78
 
79
+ Types are generated automatically on `npm run dev` (on server start and when locale files change) and during `npm run build`. No manual step needed.
80
+
76
81
  ### React
77
82
 
78
83
  ```tsx
@@ -93,8 +98,8 @@ createRoot(document.getElementById('root')!).render(
93
98
  import { useI18n } from 'vite-bundled-i18n/react'
94
99
 
95
100
  export function ProductsPage() {
96
- // t and translations.get are interchangeable — t is a shorthand alias.
97
- // Both accept a key, optional placeholders, and an optional fallback string.
101
+ // t() has full autocomplete — type 't('products.' and the IDE suggests the next segment.
102
+ // Placeholders are type-checked: t('cart.total', { amount }) enforces { amount: Primitive }.
98
103
  const { t, translations, ready } = useI18n('products.index')
99
104
 
100
105
  if (!ready) return <div>{t('shared.loading', 'Loading...')}</div>
@@ -108,6 +113,16 @@ export function ProductsPage() {
108
113
  }
109
114
  ```
110
115
 
116
+ Use `I18nBoundary` to avoid rules-of-hooks violations from early returns:
117
+
118
+ ```tsx
119
+ import { I18nBoundary } from 'vite-bundled-i18n/react'
120
+
121
+ <I18nBoundary scope="products.index" fallback={<Spinner />}>
122
+ <ProductsPage />
123
+ </I18nBoundary>
124
+ ```
125
+
111
126
  ### Vue
112
127
 
113
128
  ```ts
@@ -134,12 +149,20 @@ translations.has('actions.save')
134
149
  translations.namespace('global').get('nav.home')
135
150
  ```
136
151
 
152
+ ### Locale Switching
153
+
154
+ ```ts
155
+ await i18n.changeLocale('bg')
156
+ ```
157
+
158
+ All React/Vue consumers re-render automatically.
159
+
137
160
  ### Package Entries
138
161
 
139
162
  | Entry | Purpose |
140
163
  |-------|---------|
141
164
  | `vite-bundled-i18n` | Core runtime and configuration |
142
- | `vite-bundled-i18n/react` | React adapter (`I18nProvider`, `useI18n`) |
165
+ | `vite-bundled-i18n/react` | React adapter (`I18nProvider`, `useI18n`, `I18nBoundary`) |
143
166
  | `vite-bundled-i18n/vue` | Vue adapter (`createI18nPlugin`, `useI18n`) |
144
167
  | `vite-bundled-i18n/vanilla` | Framework-agnostic `getTranslations` |
145
168
  | `vite-bundled-i18n/server` | SSR utilities (`initServerI18n`) |
@@ -147,12 +170,13 @@ translations.namespace('global').get('nav.home')
147
170
 
148
171
  ## Dictionaries
149
172
 
150
- Dictionaries define key ownership — which translation keys belong to which bundle:
173
+ Dictionaries define key ownership — which namespaces are preloaded and available globally:
151
174
 
152
175
  ```ts
153
176
  dictionaries: {
154
177
  global: {
155
178
  include: ['shared.*', 'global.*', 'actions.*'],
179
+ exclude: ['shared.validation.*'], // carve out sub-namespaces you don't need client-side
156
180
  priority: 1,
157
181
  pinned: true,
158
182
  },
@@ -164,8 +188,29 @@ dictionaries: {
164
188
  ```
165
189
 
166
190
  - `include` accepts exact keys, namespace wildcards, and prefix patterns
167
- - Higher priority dictionaries claim keys first; lower priority dictionaries exclude already-owned keys
191
+ - `exclude` removes matching keys from the dictionary (applied after `include`)
192
+ - Higher priority dictionaries claim keys first; lower priority dictionaries skip already-owned keys
168
193
  - Pinned dictionaries remain in memory and are never evicted
194
+ - Dictionary bundles include ALL keys from matching namespaces — no tree-shaking. Scope bundles are the per-page optimization layer.
195
+
196
+ ## Custom URL Resolution
197
+
198
+ For non-standard deployments (custom API routes, CDN, single endpoint), use `resolveUrl`:
199
+
200
+ ```ts
201
+ const i18n = createI18n({
202
+ ...i18nConfig,
203
+ locale: 'en',
204
+ defaultLocale: 'en',
205
+ supportedLocales: ['en', 'bg'],
206
+ resolveUrl: (locale, type, name) => {
207
+ // type: 'dictionary' | 'scope' | 'namespace' | 'manifest'
208
+ return `/api/translations/${locale}/${type}/${name}`
209
+ },
210
+ })
211
+ ```
212
+
213
+ When not set, the runtime uses the build-injected base path from Vite's `base` config automatically.
169
214
 
170
215
  ## Data Files
171
216
 
@@ -180,7 +225,7 @@ export const nav = defineI18nData([
180
225
  ])
181
226
  ```
182
227
 
183
- The AST extractor recognizes these helpers and includes referenced keys in scope analysis.
228
+ The AST extractor recognizes these helpers and includes referenced keys in scope analysis. It also detects `t()` and `get()` calls in helper functions that receive the translation function as a parameter.
184
229
 
185
230
  ## Server-Side Rendering
186
231
 
@@ -205,7 +250,7 @@ __i18n/compiled/manifest.js
205
250
  __i18n/compiled/{locale}/...
206
251
  ```
207
252
 
208
- The runtime resolves these assets automatically in production — no additional configuration required.
253
+ The runtime resolves these assets automatically in production. For frameworks that serve built assets under a prefix (e.g. Laravel with `base: '/build/'`), the plugin reads Vite's resolved `base` config — no manual path configuration needed.
209
254
 
210
255
  ## Fetch Options
211
256
 
@@ -218,7 +263,7 @@ createI18n({
218
263
  })
219
264
  ```
220
265
 
221
- Accepts a static `RequestInit` object, a sync function, or an async function for dynamic auth tokens.
266
+ Accepts a static `RequestInit` object, a sync function, or an async function for dynamic auth tokens. Works alongside `resolveUrl` — `resolveUrl` controls WHERE to fetch, `requestInit` controls HOW.
222
267
 
223
268
  ## Cache
224
269
 
@@ -13,7 +13,7 @@ export interface CliConfig {
13
13
  rootDir?: string;
14
14
  /** Output directory for generated bundles. Defaults to '.i18n'. */
15
15
  outDir?: string;
16
- /** Output path for generated types. Defaults to 'src/i18n-types.d.ts'. */
16
+ /** Output path for generated types. Defaults to '.i18n/i18n.d.ts'. */
17
17
  typesOutPath?: string;
18
18
  /** Extraction scope. Defaults to 'global'. */
19
19
  extractionScope?: 'global' | 'scoped';
package/dist/cli/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { a as writeTypes, i as generateReports, n as compileAll, r as flattenLocaleKeys, s as generateBundles, t as walkAll } from "../walker-DZRQWGmZ.js";
2
+ import { a as writeTypes, i as generateReports, n as compileAll, r as flattenLocaleKeys, s as generateBundles, t as walkAll } from "../walker-B1niFoyW.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  //#region src/cli/commands.ts
6
6
  function resolveConfig(config) {
7
7
  const rootDir = config.rootDir ?? process.cwd();
8
+ const outDir = config.outDir ?? path.join(rootDir, ".i18n");
8
9
  return {
9
10
  rootDir,
10
- outDir: config.outDir ?? path.join(rootDir, ".i18n"),
11
- typesOutPath: config.typesOutPath ?? path.join(rootDir, "src", "i18n-types.d.ts"),
11
+ outDir,
12
+ typesOutPath: config.typesOutPath ?? path.join(outDir, "i18n.d.ts"),
12
13
  localesDir: path.isAbsolute(config.localesDir) ? config.localesDir : path.join(rootDir, config.localesDir),
13
14
  extractionScope: config.extractionScope ?? "global"
14
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["import path from 'node:path';\nimport { walkAll } from '../extractor/walker';\nimport { generateBundles } from '../extractor/bundle-generator';\nimport { writeTypes } from '../extractor/type-generator';\nimport { generateReports } from '../extractor/reports';\nimport { compileAll } from '../extractor/compiler';\nimport type { ProjectAnalysis } from '../extractor/walker-types';\nimport type { DictionaryConfig } from '../core/types';\nimport { flattenLocaleKeys } from '../extractor/reports';\n\nexport interface CliConfig {\n /** Glob patterns for page entry points. */\n pages: string[];\n /** Locales directory (relative to rootDir). */\n localesDir: string;\n /** All supported locale codes. */\n locales: string[];\n /** Default locale. */\n defaultLocale: string;\n /** Root directory. Defaults to process.cwd(). */\n rootDir?: string;\n /** Output directory for generated bundles. Defaults to '.i18n'. */\n outDir?: string;\n /** Output path for generated types. Defaults to 'src/i18n-types.d.ts'. */\n typesOutPath?: string;\n /** Extraction scope. Defaults to 'global'. */\n extractionScope?: 'global' | 'scoped';\n /** Optional dictionary configurations for compiled mode. */\n dictionaries?: Record<string, DictionaryConfig>;\n}\n\nfunction resolveConfig(config: CliConfig) {\n const rootDir = config.rootDir ?? process.cwd();\n const outDir = config.outDir ?? path.join(rootDir, '.i18n');\n const typesOutPath =\n config.typesOutPath ?? path.join(rootDir, 'src', 'i18n-types.d.ts');\n const localesDir = path.isAbsolute(config.localesDir)\n ? config.localesDir\n : path.join(rootDir, config.localesDir);\n const extractionScope = config.extractionScope ?? 'global';\n\n return { rootDir, outDir, typesOutPath, localesDir, extractionScope } as const;\n}\n\nfunction runWalker(config: CliConfig): ProjectAnalysis {\n const { rootDir, localesDir, extractionScope } = resolveConfig(config);\n\n return walkAll({\n pages: config.pages,\n rootDir,\n localesDir,\n defaultLocale: config.defaultLocale,\n extractionScope,\n });\n}\n\n/**\n * Pad a string to the given width.\n */\nfunction pad(str: string, width: number): string {\n return str + ' '.repeat(Math.max(0, width - str.length));\n}\n\n/**\n * Print a simple ASCII table to stdout.\n */\nfunction printTable(\n headers: string[],\n rows: string[][],\n): void {\n const colWidths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length)),\n );\n\n const sep =\n '\\u250c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u252c') +\n '\\u2510';\n const mid =\n '\\u251c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u253c') +\n '\\u2524';\n const bot =\n '\\u2514' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u2534') +\n '\\u2518';\n\n const formatRow = (cells: string[]) =>\n '\\u2502' +\n cells.map((c, i) => ' ' + pad(c, colWidths[i]) + ' ').join('\\u2502') +\n '\\u2502';\n\n console.log(sep);\n console.log(formatRow(headers));\n console.log(mid);\n for (const row of rows) {\n console.log(formatRow(row));\n }\n console.log(bot);\n}\n\n/**\n * Run the walker and print a summary table to stdout.\n * Returns the ProjectAnalysis for programmatic use.\n */\nexport function analyze(config: CliConfig): ProjectAnalysis {\n const { localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n console.log(\n `\\n${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s), ${analysis.availableNamespaces.length} namespace(s)`,\n );\n\n return analysis;\n}\n\n/**\n * Run the walker, then generate bundles and types.\n * Prints what was generated to stdout.\n */\nexport function generate(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath);\n\n console.log(`Generated ${bundles.length} bundle(s):`);\n for (const b of bundles) {\n console.log(` ${b.locale}/${b.name} — ${b.keyCount} keys (${b.prunedCount} pruned)`);\n }\n console.log(`Types written to ${typesOutPath}`);\n}\n\n/**\n * Run the walker, then generate diagnostic reports.\n * Prints summary to stdout.\n */\nexport function report(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}:`);\n console.log(' manifest.json');\n console.log(' missing.json');\n console.log(' unused.json');\n console.log(' stats.json');\n}\n\n/**\n * Run the walker, then compile pre-resolved flat Map modules.\n * Prints a summary to stdout.\n */\nexport function compile(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n const compiledOutDir = path.join(outDir, 'compiled');\n\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n\n // Count generated modules: one per route per locale, plus dictionary modules\n const routeModules = analysis.routes.length * config.locales.length;\n const dictModules =\n config.dictionaries && Object.keys(config.dictionaries).length > 0\n ? config.locales.length\n : 0;\n const total = routeModules + dictModules + 1; // +1 for manifest\n\n console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);\n}\n\n/**\n * Run analyze + generate + compile + report all at once.\n */\nexport function build(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n // Analyze: print table\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n // Generate bundles + types\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath);\n\n console.log(`\\nGenerated ${bundles.length} bundle(s)`);\n console.log(`Types written to ${typesOutPath}`);\n\n // Compile\n const compiledOutDir = path.join(outDir, 'compiled');\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n console.log(`Compiled modules written to ${compiledOutDir}`);\n\n // Reports\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}`);\n console.log(\n `\\nDone. ${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s).`,\n );\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { analyze, generate, compile, report, build } from './commands';\nimport type { CliConfig } from './commands';\n\nconst COMMANDS = ['analyze', 'generate', 'compile', 'report', 'build'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nfunction printUsage(): void {\n console.log('Usage: vite-bundled-i18n <command> [--config <path>]');\n console.log('');\n console.log('Commands:');\n console.log(' analyze — Walk imports and print a summary of key usage per route');\n console.log(' generate — Generate tree-shaken bundles and TypeScript types');\n console.log(' report — Generate diagnostic reports (manifest, missing, unused, stats)');\n console.log(' compile — Compile pre-resolved flat Map modules for production');\n console.log(' build — Run analyze + generate + compile + report in one step');\n console.log('');\n console.log('Options:');\n console.log(' --config <path> Path to config file (default: i18n.config.json)');\n}\n\nfunction loadConfig(configPath: string): CliConfig {\n const resolved = path.resolve(configPath);\n if (!fs.existsSync(resolved)) {\n console.error(`Config file not found: ${resolved}`);\n process.exit(1);\n }\n\n const raw = fs.readFileSync(resolved, 'utf-8');\n return JSON.parse(raw) as CliConfig;\n}\n\nfunction parseArgs(argv: string[]): { command: Command; configPath: string } {\n const args = argv.slice(2);\n let command: Command | undefined;\n let configPath = 'i18n.config.json';\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' && i + 1 < args.length) {\n configPath = args[++i];\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else if (!command && COMMANDS.includes(arg as Command)) {\n command = arg as Command;\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n\n if (!command) {\n printUsage();\n process.exit(1);\n }\n\n return { command: command!, configPath };\n}\n\nconst { command, configPath } = parseArgs(process.argv);\nconst config = loadConfig(configPath);\n\nconst commands: Record<Command, (cfg: CliConfig) => void> = {\n analyze,\n generate,\n compile,\n report,\n build,\n};\n\ncommands[command](config);\n"],"mappings":";;;;;AA+BA,SAAS,cAAc,QAAmB;CACxC,MAAM,UAAU,OAAO,WAAW,QAAQ,KAAK;AAS/C,QAAO;EAAE;EAAS,QARH,OAAO,UAAU,KAAK,KAAK,SAAS,QAAQ;EAQjC,cANxB,OAAO,gBAAgB,KAAK,KAAK,SAAS,OAAO,kBAAkB;EAM7B,YALrB,KAAK,WAAW,OAAO,WAAW,GACjD,OAAO,aACP,KAAK,KAAK,SAAS,OAAO,WAAW;EAGW,iBAF5B,OAAO,mBAAmB;EAE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Q,KAAK,EAAE;;AAGjB,QAAO;EAAW;EAAU;EAAY;;AAG1C,IAAM,EAAE,SAAS,eAAe,UAAU,QAAQ,KAAK;AACvD,IAAM,SAAS,WAAW,WAAW;CAEuB;CAC1D;CACA;CACA;CACA;CACA;CACD,EAEQ,SAAS,OAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["import path from 'node:path';\nimport { walkAll } from '../extractor/walker';\nimport { generateBundles } from '../extractor/bundle-generator';\nimport { writeTypes } from '../extractor/type-generator';\nimport { generateReports } from '../extractor/reports';\nimport { compileAll } from '../extractor/compiler';\nimport type { ProjectAnalysis } from '../extractor/walker-types';\nimport type { DictionaryConfig } from '../core/types';\nimport { flattenLocaleKeys } from '../extractor/reports';\n\nexport interface CliConfig {\n /** Glob patterns for page entry points. */\n pages: string[];\n /** Locales directory (relative to rootDir). */\n localesDir: string;\n /** All supported locale codes. */\n locales: string[];\n /** Default locale. */\n defaultLocale: string;\n /** Root directory. Defaults to process.cwd(). */\n rootDir?: string;\n /** Output directory for generated bundles. Defaults to '.i18n'. */\n outDir?: string;\n /** Output path for generated types. Defaults to '.i18n/i18n.d.ts'. */\n typesOutPath?: string;\n /** Extraction scope. Defaults to 'global'. */\n extractionScope?: 'global' | 'scoped';\n /** Optional dictionary configurations for compiled mode. */\n dictionaries?: Record<string, DictionaryConfig>;\n}\n\nfunction resolveConfig(config: CliConfig) {\n const rootDir = config.rootDir ?? process.cwd();\n const outDir = config.outDir ?? path.join(rootDir, '.i18n');\n const typesOutPath =\n config.typesOutPath ?? path.join(outDir, 'i18n.d.ts');\n const localesDir = path.isAbsolute(config.localesDir)\n ? config.localesDir\n : path.join(rootDir, config.localesDir);\n const extractionScope = config.extractionScope ?? 'global';\n\n return { rootDir, outDir, typesOutPath, localesDir, extractionScope } as const;\n}\n\nfunction runWalker(config: CliConfig): ProjectAnalysis {\n const { rootDir, localesDir, extractionScope } = resolveConfig(config);\n\n return walkAll({\n pages: config.pages,\n rootDir,\n localesDir,\n defaultLocale: config.defaultLocale,\n extractionScope,\n });\n}\n\n/**\n * Pad a string to the given width.\n */\nfunction pad(str: string, width: number): string {\n return str + ' '.repeat(Math.max(0, width - str.length));\n}\n\n/**\n * Print a simple ASCII table to stdout.\n */\nfunction printTable(\n headers: string[],\n rows: string[][],\n): void {\n const colWidths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length)),\n );\n\n const sep =\n '\\u250c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u252c') +\n '\\u2510';\n const mid =\n '\\u251c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u253c') +\n '\\u2524';\n const bot =\n '\\u2514' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u2534') +\n '\\u2518';\n\n const formatRow = (cells: string[]) =>\n '\\u2502' +\n cells.map((c, i) => ' ' + pad(c, colWidths[i]) + ' ').join('\\u2502') +\n '\\u2502';\n\n console.log(sep);\n console.log(formatRow(headers));\n console.log(mid);\n for (const row of rows) {\n console.log(formatRow(row));\n }\n console.log(bot);\n}\n\n/**\n * Run the walker and print a summary table to stdout.\n * Returns the ProjectAnalysis for programmatic use.\n */\nexport function analyze(config: CliConfig): ProjectAnalysis {\n const { localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n console.log(\n `\\n${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s), ${analysis.availableNamespaces.length} namespace(s)`,\n );\n\n return analysis;\n}\n\n/**\n * Run the walker, then generate bundles and types.\n * Prints what was generated to stdout.\n */\nexport function generate(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath);\n\n console.log(`Generated ${bundles.length} bundle(s):`);\n for (const b of bundles) {\n console.log(` ${b.locale}/${b.name} — ${b.keyCount} keys (${b.prunedCount} pruned)`);\n }\n console.log(`Types written to ${typesOutPath}`);\n}\n\n/**\n * Run the walker, then generate diagnostic reports.\n * Prints summary to stdout.\n */\nexport function report(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}:`);\n console.log(' manifest.json');\n console.log(' missing.json');\n console.log(' unused.json');\n console.log(' stats.json');\n}\n\n/**\n * Run the walker, then compile pre-resolved flat Map modules.\n * Prints a summary to stdout.\n */\nexport function compile(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n const compiledOutDir = path.join(outDir, 'compiled');\n\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n\n // Count generated modules: one per route per locale, plus dictionary modules\n const routeModules = analysis.routes.length * config.locales.length;\n const dictModules =\n config.dictionaries && Object.keys(config.dictionaries).length > 0\n ? config.locales.length\n : 0;\n const total = routeModules + dictModules + 1; // +1 for manifest\n\n console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);\n}\n\n/**\n * Run analyze + generate + compile + report all at once.\n */\nexport function build(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n // Analyze: print table\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n // Generate bundles + types\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath);\n\n console.log(`\\nGenerated ${bundles.length} bundle(s)`);\n console.log(`Types written to ${typesOutPath}`);\n\n // Compile\n const compiledOutDir = path.join(outDir, 'compiled');\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n console.log(`Compiled modules written to ${compiledOutDir}`);\n\n // Reports\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}`);\n console.log(\n `\\nDone. ${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s).`,\n );\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { analyze, generate, compile, report, build } from './commands';\nimport type { CliConfig } from './commands';\n\nconst COMMANDS = ['analyze', 'generate', 'compile', 'report', 'build'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nfunction printUsage(): void {\n console.log('Usage: vite-bundled-i18n <command> [--config <path>]');\n console.log('');\n console.log('Commands:');\n console.log(' analyze — Walk imports and print a summary of key usage per route');\n console.log(' generate — Generate tree-shaken bundles and TypeScript types');\n console.log(' report — Generate diagnostic reports (manifest, missing, unused, stats)');\n console.log(' compile — Compile pre-resolved flat Map modules for production');\n console.log(' build — Run analyze + generate + compile + report in one step');\n console.log('');\n console.log('Options:');\n console.log(' --config <path> Path to config file (default: i18n.config.json)');\n}\n\nfunction loadConfig(configPath: string): CliConfig {\n const resolved = path.resolve(configPath);\n if (!fs.existsSync(resolved)) {\n console.error(`Config file not found: ${resolved}`);\n process.exit(1);\n }\n\n const raw = fs.readFileSync(resolved, 'utf-8');\n return JSON.parse(raw) as CliConfig;\n}\n\nfunction parseArgs(argv: string[]): { command: Command; configPath: string } {\n const args = argv.slice(2);\n let command: Command | undefined;\n let configPath = 'i18n.config.json';\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' && i + 1 < args.length) {\n configPath = args[++i];\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else if (!command && COMMANDS.includes(arg as Command)) {\n command = arg as Command;\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n\n if (!command) {\n printUsage();\n process.exit(1);\n }\n\n return { command: command!, configPath };\n}\n\nconst { command, configPath } = parseArgs(process.argv);\nconst config = loadConfig(configPath);\n\nconst commands: Record<Command, (cfg: CliConfig) => void> = {\n analyze,\n generate,\n compile,\n report,\n build,\n};\n\ncommands[command](config);\n"],"mappings":";;;;;AA+BA,SAAS,cAAc,QAAmB;CACxC,MAAM,UAAU,OAAO,WAAW,QAAQ,KAAK;CAC/C,MAAM,SAAS,OAAO,UAAU,KAAK,KAAK,SAAS,QAAQ;AAQ3D,QAAO;EAAE;EAAS;EAAQ,cANxB,OAAO,gBAAgB,KAAK,KAAK,QAAQ,YAAY;EAMf,YALrB,KAAK,WAAW,OAAO,WAAW,GACjD,OAAO,aACP,KAAK,KAAK,SAAS,OAAO,WAAW;EAGW,iBAF5B,OAAO,mBAAmB;EAEmB;;AAGvE,SAAS,UAAU,QAAoC;CACrD,MAAM,EAAE,SAAS,YAAY,oBAAoB,cAAc,OAAO;AAEtE,QAAO,QAAQ;EACb,OAAO,OAAO;EACd;EACA;EACA,eAAe,OAAO;EACtB;EACD,CAAC;;;;;AAMJ,SAAS,IAAI,KAAa,OAAuB;AAC/C,QAAO,MAAM,IAAI,OAAO,KAAK,IAAI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
3
3
  export declare function buildBundlePath(base: string, locale: string, bundleName: string): string;
4
4
  export declare function fetchNamespace(localesDir: string, locale: string, namespace: string, requestInit?: RequestInit): Promise<NestedTranslations>;
5
5
  export declare function fetchBundle(base: string, locale: string, bundleName: string, requestInit?: RequestInit): Promise<Record<string, NestedTranslations>>;
6
+ export declare function fetchBundleFromUrl(url: string, requestInit?: RequestInit): Promise<Record<string, NestedTranslations>>;
7
+ export declare function fetchNamespaceFromUrl(url: string, requestInit?: RequestInit): Promise<NestedTranslations>;
@@ -28,11 +28,11 @@ export type NestedTranslations = {
28
28
  * @example
29
29
  * ```ts
30
30
  * // Generated by: npm run i18n -- generate
31
- * // src/i18n-types.d.ts
31
+ * // .i18n/i18n.d.ts
32
32
  * declare module 'vite-bundled-i18n' {
33
- * interface I18nKeyMap {
34
- * 'shared.ok': true;
35
- * 'products.show.title': true;
33
+ * interface I18nNestedKeys {
34
+ * shared: { ok: true };
35
+ * products: { show: { title: true } };
36
36
  * }
37
37
  * }
38
38
  * ```
@@ -66,10 +66,25 @@ export interface I18nScopeMap {
66
66
  */
67
67
  export type ValidScope = keyof I18nScopeMap extends never ? string : keyof I18nScopeMap & string;
68
68
  /**
69
- * Resolves to the union of registered translation keys when `I18nKeyMap`
70
- * has entries, or falls back to `string` when it's empty (no generated types).
69
+ * Recursive dot-path expansion for nested key tree interfaces.
70
+ * Converts `{ a: { b: true; c: { d: true } } }` to `'a.b' | 'a.c.d'`.
71
+ *
72
+ * Used to derive `TranslationKey` from `I18nNestedKeys` — this gives
73
+ * progressive autocomplete in the IDE (one level at a time) instead of
74
+ * dumping 2000+ flat strings into the completion list.
75
+ */
76
+ export type DotPath<T, Prefix extends string = ''> = {
77
+ [K in keyof T & string]: T[K] extends Record<string, unknown> ? DotPath<T[K], `${Prefix}${K}.`> : `${Prefix}${K}`;
78
+ }[keyof T & string];
79
+ /**
80
+ * Resolves to the union of registered translation keys.
81
+ *
82
+ * When `I18nNestedKeys` is populated (by the type generator), derives
83
+ * keys from the nested tree via `DotPath` — this gives progressive
84
+ * autocomplete in the IDE (one segment at a time). Falls back to
85
+ * `string` when no types are generated.
71
86
  */
72
- export type TranslationKey = keyof I18nKeyMap extends never ? string : keyof I18nKeyMap & string;
87
+ export type TranslationKey = keyof I18nNestedKeys extends never ? string : DotPath<I18nNestedKeys>;
73
88
  /**
74
89
  * Primitive value types accepted for interpolation placeholders.
75
90
  */
@@ -295,6 +310,17 @@ export interface I18nConfig {
295
310
  * differs from the Vite build `base`.
296
311
  */
297
312
  publicBase?: string;
313
+ /**
314
+ * Custom URL resolver for all translation fetches. When provided, this
315
+ * function controls WHERE translations are fetched from. Use alongside
316
+ * `requestInit` which controls HOW the fetch is made (headers, credentials).
317
+ *
318
+ * @param locale - The locale being fetched
319
+ * @param type - The bundle type: 'dictionary' | 'scope' | 'namespace' | 'manifest'
320
+ * @param name - The resource name (dict name, scope id, namespace, or 'manifest')
321
+ * @returns The URL to fetch from
322
+ */
323
+ resolveUrl?: (locale: string, type: 'dictionary' | 'scope' | 'namespace' | 'manifest', name: string) => string;
298
324
  }
299
325
  /**
300
326
  * The i18n instance returned by `createI18n()`.
@@ -188,16 +188,14 @@ function buildLoadPath(localesDir, locale, namespace) {
188
188
  function buildBundlePath(base, locale, bundleName) {
189
189
  return (base.endsWith("/") ? base : base + "/") + locale + "/" + bundleName + ".json";
190
190
  }
191
- async function fetchNamespace(localesDir, locale, namespace, requestInit) {
192
- const url = buildLoadPath(localesDir, locale, namespace);
191
+ async function fetchBundleFromUrl(url, requestInit) {
193
192
  const response = requestInit ? await fetch(url, requestInit) : await fetch(url);
194
- if (!response.ok) throw new Error(`Failed to load translations: ${url} (${response.status} ${response.statusText})`);
193
+ if (!response.ok) throw new Error(`Failed to load translation bundle: ${url} (${response.status} ${response.statusText})`);
195
194
  return response.json();
196
195
  }
197
- async function fetchBundle(base, locale, bundleName, requestInit) {
198
- const url = buildBundlePath(base, locale, bundleName);
196
+ async function fetchNamespaceFromUrl(url, requestInit) {
199
197
  const response = requestInit ? await fetch(url, requestInit) : await fetch(url);
200
- if (!response.ok) throw new Error(`Failed to load translation bundle: ${url} (${response.status} ${response.statusText})`);
198
+ if (!response.ok) throw new Error(`Failed to load translations: ${url} (${response.status} ${response.statusText})`);
201
199
  return response.json();
202
200
  }
203
201
  //#endregion
@@ -402,7 +400,7 @@ function createI18n(config) {
402
400
  const frozenConfig = Object.freeze({ ...config });
403
401
  const i18nBase = resolveI18nBase(config);
404
402
  const runtimeCache = resolveRuntimeCache(config);
405
- const compiledManifestUrl = config.compiled?.manifestUrl ?? (config.publicBase ? `${i18nBase}/compiled/manifest.js` : void 0) ?? getInjectedCompiledManifestUrl();
403
+ const compiledManifestUrl = config.resolveUrl ? config.resolveUrl(config.locale, "manifest", "manifest") : config.compiled?.manifestUrl ?? (config.publicBase ? `${i18nBase}/compiled/manifest.js` : void 0) ?? getInjectedCompiledManifestUrl();
406
404
  const useCompiledRuntime = shouldUseCompiledRuntime(config, compiledManifestUrl);
407
405
  let compiledRuntimeActive = useCompiledRuntime;
408
406
  let currentLocale = config.locale;
@@ -589,7 +587,7 @@ function createI18n(config) {
589
587
  }
590
588
  }
591
589
  const reqInit = await resolveRequestInit(config.requestInit);
592
- const bundle = await fetchBundle(i18nBase, locale, `_dict/${name}`, reqInit);
590
+ const bundle = await fetchBundleFromUrl(config.resolveUrl ? config.resolveUrl(locale, "dictionary", name) : buildBundlePath(i18nBase, locale, `_dict/${name}`), reqInit);
593
591
  for (const [namespace, data] of Object.entries(bundle)) store.addResources(locale, namespace, data, {
594
592
  source: "dictionary",
595
593
  pinned: runtimeCache.pinDictionaries
@@ -623,7 +621,8 @@ function createI18n(config) {
623
621
  return;
624
622
  }
625
623
  }
626
- const bundle = await fetchBundle(i18nBase, locale, scope, await resolveRequestInit(config.requestInit));
624
+ const reqInit = await resolveRequestInit(config.requestInit);
625
+ const bundle = await fetchBundleFromUrl(config.resolveUrl ? config.resolveUrl(locale, "scope", scope) : buildBundlePath(i18nBase, locale, scope), reqInit);
627
626
  for (const [namespace, data] of Object.entries(bundle)) store.addResources(locale, namespace, data, {
628
627
  source: "scope",
629
628
  pinned: false
@@ -640,7 +639,7 @@ function createI18n(config) {
640
639
  async function loadNamespaces(locale, namespaces) {
641
640
  for (const ns of namespaces) if (!store.hasNamespace(locale, ns)) try {
642
641
  const reqInit = await resolveRequestInit(config.requestInit);
643
- const data = await fetchNamespace(config.localesDir, locale, ns, reqInit);
642
+ const data = await fetchNamespaceFromUrl(config.resolveUrl ? config.resolveUrl(locale, "namespace", ns) : buildLoadPath(config.localesDir, locale, ns), reqInit);
644
643
  store.addResources(locale, ns, data, {
645
644
  source: "manual",
646
645
  pinned: false
@@ -910,4 +909,4 @@ function i18nKey(key) {
910
909
  //#endregion
911
910
  export { clearTranslations as a, mergeTranslations as c, createI18n as i, setTranslations as l, i18nKey as n, compiledHasKey as o, defineI18nConfig as r, compiledTranslate as s, defineI18nData as t };
912
911
 
913
- //# sourceMappingURL=data-DMyotm6N.js.map
912
+ //# sourceMappingURL=data-CX4qW9_K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-CX4qW9_K.js","names":[],"sources":["../src/core/store.ts","../src/core/resolver.ts","../src/core/interpolator.ts","../src/core/fetcher.ts","../src/core/compiled-runtime.ts","../src/core/createI18n.ts","../src/core/config.ts","../src/core/data.ts"],"sourcesContent":["import type { NestedTranslations } from './types';\n\ntype StoreSource = 'dictionary' | 'scope' | 'manual';\n\ninterface StoreEntry {\n locale: string;\n namespace: string;\n data: NestedTranslations;\n source: StoreSource;\n pinned: boolean;\n lastAccessedAt: number;\n approxSize: number;\n}\n\ninterface StoreStats {\n totalLocales: number;\n totalNamespaces: number;\n approxTotalBytes: number;\n pinnedNamespaces: number;\n}\n\n/**\n * The resource store's public interface.\n * Manages an in-memory map of `locale → namespace → translations`.\n */\nexport interface ResourceStore {\n /** Stores translation data for a locale and namespace. Overwrites if already present. */\n addResources: (\n locale: string,\n namespace: string,\n data: NestedTranslations,\n options?: { source?: StoreSource; pinned?: boolean },\n ) => void;\n /** Retrieves translation data for a locale and namespace. Returns undefined if not loaded. */\n getResource: (locale: string, namespace: string) => NestedTranslations | undefined;\n /** Checks whether a namespace has been loaded for a locale. */\n hasNamespace: (locale: string, namespace: string) => boolean;\n /** Removes a namespace from a locale. */\n removeNamespace: (locale: string, namespace: string) => void;\n /** Removes an entire locale from the store. */\n removeLocale: (locale: string) => void;\n /** Returns cache metadata for all entries. */\n getEntries: () => StoreEntry[];\n /** Returns store-level stats. */\n getStats: () => StoreStats;\n /** Removes all stored translation data. */\n clear: () => void;\n}\n\n/**\n * Creates a new in-memory resource store.\n *\n * The store holds loaded translation data in a two-level map:\n * `locale → namespace → NestedTranslations`. It provides no fetching logic —\n * data is added externally via `addResources` after being loaded by the fetcher.\n *\n * @returns A {@link ResourceStore} instance\n *\n * @example\n * ```ts\n * const store = createStore();\n * store.addResources('en', 'shared', { ok: 'OK', cancel: 'Cancel' });\n * store.getResource('en', 'shared'); // { ok: 'OK', cancel: 'Cancel' }\n * store.hasNamespace('en', 'shared'); // true\n * ```\n */\nexport function createStore(): ResourceStore {\n const data = new Map<string, Map<string, StoreEntry>>();\n\n const now = () => Date.now();\n const approxSizeOf = (resources: NestedTranslations) =>\n JSON.stringify(resources).length;\n\n return {\n addResources(locale, namespace, resources, options) {\n let localeMap = data.get(locale);\n if (!localeMap) {\n localeMap = new Map();\n data.set(locale, localeMap);\n }\n localeMap.set(namespace, {\n locale,\n namespace,\n data: resources,\n source: options?.source ?? 'manual',\n pinned: options?.pinned ?? false,\n lastAccessedAt: now(),\n approxSize: approxSizeOf(resources),\n });\n },\n\n getResource(locale, namespace) {\n const entry = data.get(locale)?.get(namespace);\n if (!entry) return undefined;\n entry.lastAccessedAt = now();\n return entry.data;\n },\n\n hasNamespace(locale, namespace) {\n return data.get(locale)?.has(namespace) ?? false;\n },\n\n removeNamespace(locale, namespace) {\n const localeMap = data.get(locale);\n if (!localeMap) return;\n localeMap.delete(namespace);\n if (localeMap.size === 0) {\n data.delete(locale);\n }\n },\n\n removeLocale(locale) {\n data.delete(locale);\n },\n\n getEntries() {\n return [...data.values()].flatMap((localeMap) => [...localeMap.values()]);\n },\n\n getStats() {\n const entries = [...data.values()].flatMap((localeMap) => [...localeMap.values()]);\n return {\n totalLocales: data.size,\n totalNamespaces: entries.length,\n approxTotalBytes: entries.reduce((sum, entry) => sum + entry.approxSize, 0),\n pinnedNamespaces: entries.filter((entry) => entry.pinned).length,\n };\n },\n\n clear() {\n data.clear();\n },\n };\n}\n","import type { NestedTranslations } from './types';\n\n/**\n * Extracts the namespace from a fully qualified key.\n *\n * The namespace is the first dot-separated segment. This determines\n * which JSON file to load (e.g., `'products'` loads `products.json`).\n *\n * @param key - Fully qualified key (e.g., `'products.show.title'`)\n * @returns The namespace name (e.g., `'products'`)\n *\n * @example\n * ```ts\n * inferNamespace('products.show.title'); // 'products'\n * inferNamespace('shared.ok'); // 'shared'\n * inferNamespace('checkout'); // 'checkout'\n * ```\n */\nexport function inferNamespace(key: string): string {\n const dotIndex = key.indexOf('.');\n return dotIndex === -1 ? key : key.slice(0, dotIndex);\n}\n\n/**\n * Extracts the subkey path from a fully qualified key (everything after the namespace).\n *\n * @param key - Fully qualified key (e.g., `'products.show.title'`)\n * @returns The subkey path (e.g., `'show.title'`), or empty string if no subkey\n *\n * @example\n * ```ts\n * extractSubkey('products.show.title'); // 'show.title'\n * extractSubkey('shared.ok'); // 'ok'\n * extractSubkey('checkout'); // ''\n * ```\n */\nexport function extractSubkey(key: string): string {\n const dotIndex = key.indexOf('.');\n return dotIndex === -1 ? '' : key.slice(dotIndex + 1);\n}\n\n/**\n * Resolves a dot-separated key path against a nested translations object.\n *\n * Traverses the object tree following each segment of the key path.\n * Returns the string value at the leaf, or `undefined` if the path\n * doesn't exist or resolves to a non-string (branch node).\n *\n * @param data - The nested translations object to search\n * @param keyPath - Dot-separated path (e.g., `'show.title'`)\n * @returns The translated string, or `undefined` if not found\n *\n * @example\n * ```ts\n * const data = { show: { title: 'Product Details' } };\n * resolveKey(data, 'show.title'); // 'Product Details'\n * resolveKey(data, 'show.missing'); // undefined\n * ```\n */\nexport function resolveKey(\n data: NestedTranslations,\n keyPath: string,\n): string | undefined {\n if (!keyPath) return undefined;\n\n const segments = keyPath.split('.');\n let current: NestedTranslations | string = data;\n\n for (const segment of segments) {\n if (typeof current !== 'object' || current === null) {\n return undefined;\n }\n current = current[segment];\n if (current === undefined) {\n return undefined;\n }\n }\n\n return typeof current === 'string' ? current : undefined;\n}\n","/**\n * Pattern matching `{{paramName}}` placeholders in translation strings.\n * Allows optional whitespace around the parameter name: `{{ name }}` works.\n */\nconst PLACEHOLDER_PATTERN = /\\{\\{\\s*(\\w+)\\s*\\}\\}/g;\n\n/**\n * Replaces `{{paramName}}` placeholders in a translation string with\n * values from the provided params object.\n *\n * Rules:\n * - `{{param}}` and `{{ param }}` both resolve to the `param` key\n * - Missing params leave the placeholder as-is (aids debugging)\n * - Values are converted to strings via `String(value)`\n * - If no params are provided, the string is returned unchanged\n *\n * @param text - The translation string containing `{{placeholders}}`\n * @param params - Optional object mapping parameter names to values\n * @returns The interpolated string\n *\n * @example\n * ```ts\n * interpolate('Hello {{name}}', { name: 'Alice' });\n * // 'Hello Alice'\n *\n * interpolate('Price: {{amount}}', { amount: 29.99 });\n * // 'Price: 29.99'\n *\n * interpolate('Hello {{name}}', {});\n * // 'Hello {{name}}' — missing param left as-is\n * ```\n */\nexport function interpolate(\n text: string,\n params?: Record<string, unknown>,\n): string {\n if (!params) return text;\n\n return text.replace(PLACEHOLDER_PATTERN, (match, key: string) => {\n const value = params[key];\n return value !== undefined ? String(value) : match;\n });\n}\n","import type { NestedTranslations } from './types';\n\nexport function buildLoadPath(\n localesDir: string,\n locale: string,\n namespace: string,\n): string {\n const base = localesDir.endsWith('/') ? localesDir.slice(0, -1) : localesDir;\n return `${base}/${locale}/${namespace}.json`;\n}\n\nexport function buildBundlePath(base: string, locale: string, bundleName: string): string {\n const normalized = base.endsWith('/') ? base : base + '/';\n return normalized + locale + '/' + bundleName + '.json';\n}\n\nexport async function fetchNamespace(\n localesDir: string,\n locale: string,\n namespace: string,\n requestInit?: RequestInit,\n): Promise<NestedTranslations> {\n const url = buildLoadPath(localesDir, locale, namespace);\n const response = requestInit\n ? await fetch(url, requestInit)\n : await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${url} (${response.status} ${response.statusText})`,\n );\n }\n\n return response.json() as Promise<NestedTranslations>;\n}\n\nexport async function fetchBundle(\n base: string,\n locale: string,\n bundleName: string,\n requestInit?: RequestInit,\n): Promise<Record<string, NestedTranslations>> {\n const url = buildBundlePath(base, locale, bundleName);\n return fetchBundleFromUrl(url, requestInit);\n}\n\nexport async function fetchBundleFromUrl(\n url: string,\n requestInit?: RequestInit,\n): Promise<Record<string, NestedTranslations>> {\n const response = requestInit\n ? await fetch(url, requestInit)\n : await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translation bundle: ${url} (${response.status} ${response.statusText})`,\n );\n }\n\n return response.json() as Promise<Record<string, NestedTranslations>>;\n}\n\nexport async function fetchNamespaceFromUrl(\n url: string,\n requestInit?: RequestInit,\n): Promise<NestedTranslations> {\n const response = requestInit\n ? await fetch(url, requestInit)\n : await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${url} (${response.status} ${response.statusText})`,\n );\n }\n\n return response.json() as Promise<NestedTranslations>;\n}\n","/**\n * Compiled runtime for i18n production mode.\n *\n * Replaces the full store + resolver + fetcher stack with a single flat\n * `Map<string, string>` that is populated at build time. Lookups are O(1)\n * — no namespace inference, no dot-path traversal, no fallback chain.\n */\n\n/** Matches `{{key}}` and `{{ key }}` placeholders (whitespace-tolerant). */\nconst PLACEHOLDER = /\\{\\{\\s*(\\w+)\\s*\\}\\}/g;\n\nlet currentMap: Map<string, string> = new Map();\n\nexport type CompiledTranslationMap = Map<string, string>;\nexport type CompiledModuleLoader = () => Promise<{ default: CompiledTranslationMap }>;\n\nexport interface CompiledManifestModule {\n scopes: Record<string, Record<string, CompiledModuleLoader>>;\n dictionaries?: Record<string, Record<string, CompiledModuleLoader>>;\n}\n\n/**\n * Replaces the active translation map entirely.\n *\n * Intended to be called once per locale load (e.g. on app boot or locale\n * switch). The map is copied so that mutations to the original do not\n * affect the runtime state.\n *\n * @param map - A flat `Map` of dot-path translation keys to their string values.\n */\nexport function setTranslations(map: Map<string, string>): void {\n currentMap = new Map(map);\n}\n\n/**\n * Merges additional translations into the current map.\n *\n * Existing keys are overwritten if they appear in the incoming map. This\n * is used when loading scope bundles (e.g. lazy-loaded route namespaces)\n * on top of a base dictionary that was set via {@link setTranslations}.\n *\n * @param map - A flat `Map` of dot-path translation keys to merge in.\n */\nexport function mergeTranslations(map: Map<string, string>): void {\n for (const [k, v] of map) {\n currentMap.set(k, v);\n }\n}\n\n/**\n * Clears all translations from the runtime map.\n *\n * Resets state to an empty map. Primarily intended for use in tests via\n * `beforeEach` to ensure isolation between test cases.\n */\nexport function clearTranslations(): void {\n currentMap = new Map();\n}\n\n/**\n * Returns `true` if the given key exists in the compiled translation map.\n *\n * Useful for conditional rendering or feature detection without triggering\n * a full translation lookup.\n *\n * @param key - The dot-path translation key to check.\n */\nexport function compiledHasKey(key: string): boolean {\n return currentMap.has(key);\n}\n\nexport function compiledTryTranslate(\n key: string,\n params?: Record<string, unknown>,\n): string | undefined {\n return compiledTryTranslateFromMap(currentMap, key, params);\n}\n\nexport function compiledHasKeyInMap(\n map: CompiledTranslationMap,\n key: string,\n): boolean {\n return map.has(key);\n}\n\nexport function compiledTryTranslateFromMap(\n map: CompiledTranslationMap,\n key: string,\n params?: Record<string, unknown>,\n): string | undefined {\n const value = map.get(key);\n if (value === undefined) return undefined;\n return params ? interpolate(value, params) : value;\n}\n\n/**\n * Resolves a translation key from the compiled flat map.\n *\n * Lookup is O(1) — no namespace inference, no dot-path traversal, no\n * fallback chain. If the key is found, its value is returned (with\n * optional `{{param}}` interpolation). If not found, `fallback` is used\n * (also interpolated if provided). If neither is available, the raw `key`\n * string is returned so the UI degrades gracefully.\n *\n * @param key - The dot-path translation key to look up.\n * @param params - Optional map of placeholder names to replacement values.\n * Placeholders are written as `{{name}}` or `{{ name }}`.\n * Placeholders whose name is absent from `params` are left\n * untouched in the output.\n * @param fallback - Optional string to use when `key` is not in the map.\n * Subject to the same `params` interpolation as a found value.\n * @returns The resolved (and optionally interpolated) string.\n */\nexport function compiledTranslate(\n key: string,\n params?: Record<string, unknown>,\n fallback?: string,\n): string {\n return compiledTranslateFromMap(currentMap, key, params, fallback);\n}\n\nexport function compiledTranslateFromMap(\n map: CompiledTranslationMap,\n key: string,\n params?: Record<string, unknown>,\n fallback?: string,\n): string {\n const value = map.get(key);\n\n if (value !== undefined) {\n return params ? interpolate(value, params) : value;\n }\n\n if (fallback !== undefined) {\n return params ? interpolate(fallback, params) : fallback;\n }\n\n return key;\n}\n\nexport async function loadCompiledManifest(\n url: string,\n): Promise<CompiledManifestModule> {\n const dynamicImport = new Function('u', 'return import(u)') as (\n specifier: string,\n ) => Promise<CompiledManifestModule>;\n return dynamicImport(url);\n}\n\n/**\n * Replaces all `{{placeholder}}` tokens in `text` with values from `params`.\n *\n * Tokens whose name is absent from `params` are left as-is. Matched values\n * are coerced to strings via `String()`.\n *\n * @param text - The template string containing zero or more placeholders.\n * @param params - The parameter map supplying replacement values.\n */\nfunction interpolate(text: string, params: Record<string, unknown>): string {\n return text.replace(PLACEHOLDER, (match, key: string) => {\n const value = params[key];\n return value !== undefined ? String(value) : match;\n });\n}\n","import type { I18nConfig, I18nInstance, NestedTranslations, KeyUsageEntry } from './types';\nimport { createStore } from './store';\nimport { resolveKey, inferNamespace, extractSubkey } from './resolver';\nimport { interpolate } from './interpolator';\nimport { buildBundlePath, buildLoadPath, fetchBundleFromUrl, fetchNamespaceFromUrl } from './fetcher';\nimport {\n compiledHasKeyInMap,\n compiledTranslateFromMap,\n compiledTryTranslateFromMap,\n loadCompiledManifest,\n type CompiledManifestModule,\n type CompiledTranslationMap,\n} from './compiled-runtime';\n\n/**\n * Resolves the requestInit config value to a concrete RequestInit object.\n * Handles static objects, sync functions, and async functions.\n */\nexport async function resolveRequestInit(\n requestInit: RequestInit | (() => RequestInit | Promise<RequestInit>) | undefined,\n): Promise<RequestInit | undefined> {\n if (requestInit === undefined) return undefined;\n if (typeof requestInit === 'function') return requestInit();\n return requestInit;\n}\n\nfunction resolveRuntimeCache(config: I18nConfig) {\n const runtime = config.cache?.runtime;\n\n if (runtime === 'none') {\n return { strategy: 'none', eviction: 'none', pinDictionaries: false } as const;\n }\n\n if (runtime === 'memory' || runtime == null) {\n return { strategy: 'memory', eviction: 'none', pinDictionaries: true } as const;\n }\n\n return {\n strategy: runtime.strategy ?? 'memory',\n eviction: runtime.eviction ?? 'none',\n maxLocales: runtime.maxLocales,\n maxNamespaces: runtime.maxNamespaces,\n maxBytes: runtime.maxBytes,\n pinDictionaries: runtime.pinDictionaries ?? true,\n } as const;\n}\n\nfunction getInjectedI18nBase(): string | undefined {\n return typeof __VITE_I18N_BASE__ !== 'undefined'\n ? __VITE_I18N_BASE__\n : undefined;\n}\n\n/**\n * Resolves the base path for bundle fetches.\n * Resolution order: config.publicBase > __VITE_I18N_BASE__ > '/__i18n'\n */\nfunction resolveI18nBase(config: I18nConfig): string {\n return config.publicBase ?? getInjectedI18nBase() ?? '/__i18n';\n}\n\nfunction getInjectedCompiledManifestUrl(): string | undefined {\n return typeof __VITE_I18N_COMPILED_MANIFEST__ !== 'undefined'\n ? __VITE_I18N_COMPILED_MANIFEST__\n : undefined;\n}\n\nfunction shouldUseCompiledRuntime(config: I18nConfig, manifestUrl?: string): boolean {\n if (config.compiled?.enabled === false) return false;\n if (config.compiled?.enabled === true) return true;\n if (config.compiled?.enabled === 'auto') return !!manifestUrl;\n return !!manifestUrl;\n}\n\n/**\n * Creates and configures an i18n instance.\n *\n * This is the main entry point for setting up translations. It assembles\n * the resource store, key resolver, interpolator, and fetcher into a\n * single {@link I18nInstance} with a unified API.\n *\n * Translation loading uses bundles:\n * - **Named dictionaries** — one HTTP request per dictionary name\n * (`/__i18n/{locale}/_dict/{name}.json`), loaded in declaration order.\n * - **Scope bundles** — one HTTP request per page scope\n * (`/__i18n/{locale}/{scope}.json`).\n *\n * The dev plugin (`i18nDevPlugin`) serves these by combining individual\n * namespace JSON files on the fly.\n *\n * @param config - The i18n configuration\n * @returns A configured {@link I18nInstance}\n *\n * @example\n * ```ts\n * const i18n = createI18n({\n * locale: 'en',\n * defaultLocale: 'en',\n * supportedLocales: ['en', 'bg'],\n * localesDir: '/locales',\n * dictionaries: {\n * global: { keys: ['shared', 'global', 'actions'] },\n * admin: { keys: ['admin'] },\n * },\n * });\n * ```\n */\nexport function createI18n(config: I18nConfig): I18nInstance {\n if (!config.locale || typeof config.locale !== 'string') {\n throw new Error('vite-bundled-i18n: locale must be a non-empty string');\n }\n if (!config.defaultLocale || typeof config.defaultLocale !== 'string') {\n throw new Error('vite-bundled-i18n: defaultLocale must be a non-empty string');\n }\n if (!Array.isArray(config.supportedLocales) || config.supportedLocales.length === 0) {\n throw new Error('vite-bundled-i18n: supportedLocales must be a non-empty array');\n }\n if (!config.supportedLocales.includes(config.defaultLocale)) {\n throw new Error(\n `vite-bundled-i18n: defaultLocale \"${config.defaultLocale}\" must be included in supportedLocales`,\n );\n }\n\n const store = createStore();\n const frozenConfig = Object.freeze({ ...config });\n const i18nBase = resolveI18nBase(config);\n const runtimeCache = resolveRuntimeCache(config);\n // Derive manifest URL. Resolution order:\n // 1. resolveUrl callback (if provided)\n // 2. explicit compiled.manifestUrl\n // 3. derived from publicBase\n // 4. build-injected __VITE_I18N_COMPILED_MANIFEST__\n const compiledManifestUrl = config.resolveUrl\n ? config.resolveUrl(config.locale, 'manifest', 'manifest')\n : (config.compiled?.manifestUrl\n ?? (config.publicBase ? `${i18nBase}/compiled/manifest.js` : undefined)\n ?? getInjectedCompiledManifestUrl());\n const useCompiledRuntime = shouldUseCompiledRuntime(config, compiledManifestUrl);\n let compiledRuntimeActive = useCompiledRuntime;\n\n let currentLocale = config.locale;\n const localeListeners = new Set<(locale: string) => void>();\n\n /** Tracks which scopes have been loaded per locale. */\n const loadedScopes = new Set<string>();\n\n /** Tracks which named dictionaries have been loaded per locale. */\n const loadedDicts = new Set<string>();\n\n /** Key usage log for dev diagnostics. */\n const keyUsage: KeyUsageEntry[] = [];\n\n /** The current scope set by useI18n, used for key tracking. */\n let activeScope: string | undefined;\n /** Tracks whether a consolidated fetch error has been emitted. */\n let fetchErrorEmitted = false;\n\n /** Dedup set for dev-mode missing key warnings. */\n const warnedMissingKeys = new Set<string>();\n\n function handleFetchError(): void {\n if (!fetchErrorEmitted) {\n fetchErrorEmitted = true;\n console.error(\n 'vite-bundled-i18n: Cannot load translations. ' +\n 'Ensure __i18n assets are accessible at the configured base path. ' +\n 'Are you running the Vite dev server, or have you built with the i18n plugin?'\n );\n }\n }\n\n let compiledManifestPromise: Promise<CompiledManifestModule | null> | null = null;\n const compiledLocaleMaps = new Map<string, CompiledTranslationMap>();\n\n function getCompiledLocaleMap(locale: string): CompiledTranslationMap {\n const existing = compiledLocaleMaps.get(locale);\n if (existing) return existing;\n const created = new Map<string, string>();\n compiledLocaleMaps.set(locale, created);\n return created;\n }\n\n async function getCompiledManifest(): Promise<CompiledManifestModule | null> {\n if (!useCompiledRuntime) return null;\n if (!compiledManifestUrl && !config.compiled?.loadManifest) return null;\n if (!compiledManifestPromise) {\n const manifestLoader = config.compiled?.loadManifest\n ? config.compiled.loadManifest\n : () => loadCompiledManifest(compiledManifestUrl!);\n compiledManifestPromise = manifestLoader().catch((error) => {\n compiledRuntimeActive = false;\n console.warn(\n `vite-bundled-i18n: Failed to load compiled manifest from \"${compiledManifestUrl}\". Falling back to JSON bundles.`,\n error,\n );\n return null;\n });\n }\n return compiledManifestPromise;\n }\n\n async function loadCompiledModule(\n locale: string,\n loader: (() => Promise<{ default: CompiledTranslationMap }>) | undefined,\n ): Promise<boolean> {\n if (!loader) return false;\n const module = await loader();\n const localeMap = getCompiledLocaleMap(locale);\n for (const [key, value] of module.default) {\n localeMap.set(key, value);\n }\n return true;\n }\n\n function clearLoadMarkersForNamespace(locale: string, namespace: string): void {\n for (const scopeKey of [...loadedScopes]) {\n const [scopeLocale, scope] = scopeKey.split(':');\n if (scopeLocale !== locale || !scope) continue;\n const scopeNamespace = scope.includes('.') ? scope.slice(0, scope.indexOf('.')) : scope;\n if (scopeNamespace === namespace) {\n loadedScopes.delete(scopeKey);\n }\n }\n\n for (const dictKey of [...loadedDicts]) {\n const [dictLocale, dictName] = dictKey.split(':');\n if (dictLocale !== locale || !dictName) continue;\n const dict = config.dictionaries?.[dictName];\n if ((dict?.keys ?? []).includes(namespace)) {\n loadedDicts.delete(dictKey);\n }\n }\n }\n\n function clearLoadMarkersForLocale(locale: string): void {\n for (const scopeKey of [...loadedScopes]) {\n if (scopeKey.startsWith(`${locale}:`)) {\n loadedScopes.delete(scopeKey);\n }\n }\n for (const dictKey of [...loadedDicts]) {\n if (dictKey.startsWith(`${locale}:`)) {\n loadedDicts.delete(dictKey);\n }\n }\n }\n\n function evictUnused(): void {\n if (runtimeCache.strategy === 'none' || runtimeCache.eviction === 'none') {\n return;\n }\n\n const entries = store.getEntries();\n const nonPinned = entries\n .filter((entry) => !entry.pinned)\n .sort((a, b) => a.lastAccessedAt - b.lastAccessedAt);\n\n const evictOne = () => {\n const candidate = nonPinned.shift();\n if (!candidate) return false;\n store.removeNamespace(candidate.locale, candidate.namespace);\n clearLoadMarkersForNamespace(candidate.locale, candidate.namespace);\n return true;\n };\n\n if (runtimeCache.maxLocales !== undefined) {\n while (store.getStats().totalLocales > runtimeCache.maxLocales) {\n const localeCandidates = new Map<string, number>();\n for (const entry of nonPinned) {\n const previous = localeCandidates.get(entry.locale) ?? Number.POSITIVE_INFINITY;\n localeCandidates.set(entry.locale, Math.min(previous, entry.lastAccessedAt));\n }\n\n const localeToEvict = [...localeCandidates.entries()]\n .filter(([locale]) => locale !== currentLocale)\n .sort((a, b) => a[1] - b[1])[0]?.[0];\n\n if (!localeToEvict) break;\n store.removeLocale(localeToEvict);\n clearLoadMarkersForLocale(localeToEvict);\n for (let i = nonPinned.length - 1; i >= 0; i--) {\n if (nonPinned[i].locale === localeToEvict) {\n nonPinned.splice(i, 1);\n }\n }\n }\n }\n\n if (runtimeCache.maxNamespaces !== undefined) {\n while (store.getStats().totalNamespaces > runtimeCache.maxNamespaces) {\n if (!evictOne()) break;\n }\n }\n\n if (runtimeCache.maxBytes !== undefined) {\n while (store.getStats().approxTotalBytes > runtimeCache.maxBytes) {\n if (!evictOne()) break;\n }\n }\n }\n\n /**\n * Resolves a fully qualified key against the store, with fallback chain.\n * Records the resolution in the key usage log for dev diagnostics.\n */\n function translate(\n locale: string,\n key: string,\n params?: Record<string, unknown>,\n fallback?: string,\n ): string {\n if (compiledRuntimeActive) {\n recordUsage(key, inferNamespace(key), locale, 'primary');\n return compiledTranslateFromMap(getCompiledLocaleMap(locale), key, params, fallback);\n }\n\n const namespace = inferNamespace(key);\n const subkey = extractSubkey(key);\n\n if (!subkey) {\n recordUsage(key, namespace, locale, 'fallback-string');\n if (fallback !== undefined) return interpolate(fallback, params);\n return key;\n }\n\n // Try requested locale\n const data = store.getResource(locale, namespace);\n if (data) {\n const value = resolveKey(data, subkey);\n if (value !== undefined) {\n recordUsage(key, namespace, locale, 'primary');\n return interpolate(value, params);\n }\n }\n\n // Fallback to default locale\n if (locale !== config.defaultLocale) {\n const fallbackData = store.getResource(config.defaultLocale, namespace);\n if (fallbackData) {\n const value = resolveKey(fallbackData, subkey);\n if (value !== undefined) {\n recordUsage(key, namespace, locale, 'fallback-locale');\n return interpolate(value, params);\n }\n }\n }\n\n // Return fallback string or key\n if (fallback !== undefined) {\n recordUsage(key, namespace, locale, 'fallback-string');\n return interpolate(fallback, params);\n }\n\n recordUsage(key, namespace, locale, 'key-as-value');\n if (import.meta.env?.DEV && !warnedMissingKeys.has(key)) {\n warnedMissingKeys.add(key);\n console.warn(\n `vite-bundled-i18n: Missing translation for \"${key}\" in locale \"${locale}\". Returning key as fallback.`\n );\n }\n return key;\n }\n\n /** Records a key lookup for dev diagnostics. */\n function recordUsage(\n key: string,\n namespace: string,\n locale: string,\n resolvedFrom: KeyUsageEntry['resolvedFrom'],\n ): void {\n keyUsage.push({ key, namespace, locale, resolvedFrom, scope: activeScope });\n }\n\n function hasKey(locale: string, key: string): boolean {\n if (compiledRuntimeActive) {\n return compiledHasKeyInMap(getCompiledLocaleMap(locale), key);\n }\n\n const namespace = inferNamespace(key);\n const subkey = extractSubkey(key);\n if (!subkey) return false;\n\n const data = store.getResource(locale, namespace);\n if (!data) return false;\n return resolveKey(data, subkey) !== undefined;\n }\n\n function tryTranslate(\n locale: string,\n key: string,\n params?: Record<string, unknown>,\n ): string | undefined {\n if (compiledRuntimeActive) {\n return compiledTryTranslateFromMap(getCompiledLocaleMap(locale), key, params);\n }\n\n const namespace = inferNamespace(key);\n const subkey = extractSubkey(key);\n if (!subkey) return undefined;\n\n const data = store.getResource(locale, namespace);\n if (data) {\n const value = resolveKey(data, subkey);\n if (value !== undefined) {\n return interpolate(value, params);\n }\n }\n\n if (locale !== config.defaultLocale) {\n const fallbackData = store.getResource(config.defaultLocale, namespace);\n if (fallbackData) {\n const value = resolveKey(fallbackData, subkey);\n if (value !== undefined) {\n return interpolate(value, params);\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Loads a single named dictionary bundle for a locale.\n * Fetches `/__i18n/{locale}/_dict/{name}.json` — one HTTP request\n * containing all namespaces for that dictionary.\n */\n async function loadDictionary(locale: string, name: string): Promise<void> {\n const dictKey = `${locale}:${name}`;\n if (loadedDicts.has(dictKey)) return;\n\n const dictConfig = config.dictionaries?.[name];\n if (!dictConfig) return;\n\n try {\n if (compiledRuntimeActive) {\n const manifest = await getCompiledManifest();\n const loaded = await loadCompiledModule(locale, manifest?.dictionaries?.[name]?.[locale]);\n if (loaded) {\n loadedDicts.add(dictKey);\n return;\n }\n }\n\n const reqInit = await resolveRequestInit(config.requestInit);\n const url = config.resolveUrl\n ? config.resolveUrl(locale, 'dictionary', name)\n : buildBundlePath(i18nBase, locale, `_dict/${name}`);\n const bundle = await fetchBundleFromUrl(url, reqInit);\n for (const [namespace, data] of Object.entries(bundle)) {\n store.addResources(locale, namespace, data, {\n source: 'dictionary',\n pinned: runtimeCache.pinDictionaries,\n });\n }\n loadedDicts.add(dictKey);\n evictUnused();\n } catch {\n handleFetchError();\n }\n }\n\n /**\n * Loads all configured dictionaries for a locale, in declaration order.\n * Each dictionary is one HTTP request.\n */\n async function loadAllDictionaries(locale: string): Promise<void> {\n if (!config.dictionaries) return;\n\n // Load in declaration order, sequentially (priority matters)\n for (const name of Object.keys(config.dictionaries)) {\n await loadDictionary(locale, name);\n }\n }\n\n /**\n * Loads a page/scope bundle for a locale.\n * Fetches `/__i18n/{locale}/{scope}.json` — one HTTP request\n * containing all namespaces needed by that page.\n */\n async function loadScope(locale: string, scope: string): Promise<void> {\n const scopeKey = `${locale}:${scope}`;\n if (loadedScopes.has(scopeKey)) return;\n\n try {\n if (compiledRuntimeActive) {\n const manifest = await getCompiledManifest();\n const loaded = await loadCompiledModule(locale, manifest?.scopes?.[scope]?.[locale]);\n if (loaded) {\n loadedScopes.add(scopeKey);\n return;\n }\n }\n\n const reqInit = await resolveRequestInit(config.requestInit);\n const url = config.resolveUrl\n ? config.resolveUrl(locale, 'scope', scope)\n : buildBundlePath(i18nBase, locale, scope);\n const bundle = await fetchBundleFromUrl(url, reqInit);\n for (const [namespace, data] of Object.entries(bundle)) {\n store.addResources(locale, namespace, data, {\n source: 'scope',\n pinned: false,\n });\n }\n loadedScopes.add(scopeKey);\n evictUnused();\n } catch {\n handleFetchError();\n }\n }\n\n /**\n * Loads namespace files individually. Kept for testing and non-plugin usage.\n */\n async function loadNamespaces(\n locale: string,\n namespaces: string[],\n ): Promise<void> {\n for (const ns of namespaces) {\n if (!store.hasNamespace(locale, ns)) {\n try {\n const reqInit = await resolveRequestInit(config.requestInit);\n const nsUrl = config.resolveUrl\n ? config.resolveUrl(locale, 'namespace', ns)\n : buildLoadPath(config.localesDir, locale, ns);\n const data = await fetchNamespaceFromUrl(nsUrl, reqInit);\n store.addResources(locale, ns, data, {\n source: 'manual',\n pinned: false,\n });\n evictUnused();\n } catch {\n handleFetchError();\n }\n }\n }\n }\n\n function addResources(\n locale: string,\n namespace: string,\n data: NestedTranslations,\n ): void {\n store.addResources(locale, namespace, data, {\n source: 'manual',\n pinned: false,\n });\n evictUnused();\n }\n\n function getResource(locale: string, namespace: string): NestedTranslations | undefined {\n if (compiledRuntimeActive) {\n const localeMap = compiledLocaleMaps.get(locale);\n if (!localeMap) return undefined;\n const prefix = `${namespace}.`;\n const nested: NestedTranslations = {};\n let found = false;\n\n for (const [key, value] of localeMap.entries()) {\n if (!key.startsWith(prefix)) continue;\n found = true;\n const parts = key.slice(prefix.length).split('.');\n let current: NestedTranslations = nested;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n const next = current[part];\n if (!next || typeof next === 'string') {\n current[part] = {};\n }\n current = current[part] as NestedTranslations;\n }\n current[parts[parts.length - 1]] = value;\n }\n\n return found ? nested : undefined;\n }\n\n return store.getResource(locale, namespace);\n }\n\n function getLoadedNamespaces(locale: string): string[] {\n if (compiledRuntimeActive) {\n const localeMap = compiledLocaleMaps.get(locale);\n if (!localeMap) return [];\n return [...new Set([...localeMap.keys()].map((key) => inferNamespace(key)))];\n }\n\n return store.getEntries()\n .filter((entry) => entry.locale === locale)\n .map((entry) => entry.namespace);\n }\n\n function isNamespaceLoaded(locale: string, namespace: string): boolean {\n if (compiledRuntimeActive) {\n return getLoadedNamespaces(locale).includes(namespace);\n }\n return store.hasNamespace(locale, namespace);\n }\n\n function isScopeLoaded(locale: string, scope: string): boolean {\n return loadedScopes.has(`${locale}:${scope}`);\n }\n\n function getCacheStats() {\n if (compiledRuntimeActive) {\n const totalLocales = compiledLocaleMaps.size;\n const totalNamespaces = new Set(\n [...compiledLocaleMaps.values()].flatMap((map) =>\n [...map.keys()].map((key) => inferNamespace(key)),\n ),\n ).size;\n const approxTotalBytes = [...compiledLocaleMaps.values()].reduce(\n (sum, map) =>\n sum + [...map.entries()].reduce((inner, [key, value]) => inner + key.length + value.length, 0),\n 0,\n );\n\n return {\n totalLocales,\n totalNamespaces,\n approxTotalBytes,\n pinnedNamespaces: 0,\n loadedScopes: loadedScopes.size,\n loadedDictionaries: loadedDicts.size,\n };\n }\n\n const stats = store.getStats();\n return {\n ...stats,\n loadedScopes: loadedScopes.size,\n loadedDictionaries: loadedDicts.size,\n };\n }\n\n function unloadLocale(locale: string): void {\n if (compiledRuntimeActive) {\n compiledLocaleMaps.delete(locale);\n clearLoadMarkersForLocale(locale);\n return;\n }\n store.removeLocale(locale);\n clearLoadMarkersForLocale(locale);\n }\n\n function unloadNamespace(locale: string, namespace: string): void {\n if (compiledRuntimeActive) {\n const localeMap = compiledLocaleMaps.get(locale);\n if (localeMap) {\n for (const key of [...localeMap.keys()]) {\n if (key === namespace || key.startsWith(`${namespace}.`)) {\n localeMap.delete(key);\n }\n }\n }\n clearLoadMarkersForNamespace(locale, namespace);\n return;\n }\n store.removeNamespace(locale, namespace);\n clearLoadMarkersForNamespace(locale, namespace);\n }\n\n function getDictionaryNamespaces(): string[] {\n if (!config.dictionaries) return [];\n const seen = new Set<string>();\n const result: string[] = [];\n for (const dict of Object.values(config.dictionaries)) {\n const patterns = [\n ...(dict.keys ?? []),\n ...((dict.include ?? []).map((pattern) => {\n const namespacePart = pattern.split('.')[0];\n return namespacePart.endsWith('*') ? namespacePart.slice(0, -1) : namespacePart;\n })),\n ];\n for (const ns of patterns) {\n if (!seen.has(ns)) {\n seen.add(ns);\n result.push(ns);\n }\n }\n }\n return result;\n }\n\n function getDictionaryNames(): string[] {\n if (!config.dictionaries) return [];\n return Object.keys(config.dictionaries);\n }\n\n function getLocale(): string {\n return currentLocale;\n }\n\n /**\n * Switches the active locale. Loads all dictionaries and previously\n * loaded scopes for the new locale before notifying listeners.\n */\n async function changeLocale(locale: string): Promise<void> {\n if (locale === currentLocale) return;\n\n if (compiledRuntimeActive) {\n compiledLocaleMaps.delete(locale);\n }\n\n // Load all dictionaries for the new locale (one request per dictionary)\n await loadAllDictionaries(locale);\n\n // Reload all previously loaded scopes for the new locale\n const uniqueScopes = new Set<string>();\n for (const scopeKey of loadedScopes) {\n const colonIdx = scopeKey.indexOf(':');\n if (colonIdx !== -1) {\n uniqueScopes.add(scopeKey.slice(colonIdx + 1));\n }\n }\n await Promise.all(\n [...uniqueScopes].map((scope) => loadScope(locale, scope)),\n );\n\n currentLocale = locale;\n for (const listener of localeListeners) {\n listener(locale);\n }\n }\n\n function onLocaleChange(callback: (locale: string) => void): () => void {\n localeListeners.add(callback);\n return () => {\n localeListeners.delete(callback);\n };\n }\n\n function getKeyUsage(): KeyUsageEntry[] {\n return keyUsage;\n }\n\n return {\n config: frozenConfig,\n translate,\n tryTranslate,\n hasKey,\n loadNamespaces,\n loadDictionary,\n loadAllDictionaries,\n loadScope,\n addResources,\n getResource,\n getLoadedNamespaces,\n isNamespaceLoaded,\n isScopeLoaded,\n getCacheStats,\n unloadLocale,\n unloadNamespace,\n evictUnused,\n getDictionaryNamespaces,\n getDictionaryNames,\n getLocale,\n changeLocale,\n onLocaleChange,\n getKeyUsage,\n };\n}\n","import type { DictionaryConfig } from './types';\n\n/**\n * Shared i18n configuration used by both the runtime (`createI18n`) and\n * the Vite dev plugin (`i18nDevPlugin`). Define this once in a shared\n * file and import it in both places to prevent config drift.\n *\n * This is the subset of config that must be identical between the\n * runtime and the plugin. Runtime-only fields (like `locale`) are\n * not included here.\n */\nexport interface I18nSharedConfig {\n /** Path to the locales directory. Relative to project root for the plugin, URL path for the runtime. */\n localesDir: string;\n /** Named groups of namespaces. Must be identical between runtime and plugin. */\n dictionaries?: Record<string, DictionaryConfig>;\n /** Extraction configuration shared between the plugin and CLI. */\n extraction?: {\n /** Additional property names to scan as translation key fields. */\n keyFields?: string[];\n };\n}\n\n/**\n * Defines the shared i18n configuration.\n *\n * Use this to create a config object that is imported by both `createI18n()`\n * and `i18nDevPlugin()`, ensuring they stay in sync.\n *\n * @param config - The shared configuration\n * @returns The same config object (identity function for type safety and readability)\n *\n * @example\n * ```ts\n * // src/i18n.config.ts\n * import { defineI18nConfig } from 'vite-bundled-i18n';\n *\n * export const i18nConfig = defineI18nConfig({\n * localesDir: 'locales',\n * dictionaries: {\n * global: { keys: ['shared', 'global', 'actions'] },\n * },\n * });\n * ```\n *\n * ```ts\n * // src/i18n.ts — runtime\n * import { createI18n } from 'vite-bundled-i18n';\n * import { i18nConfig } from './i18n.config';\n *\n * export const i18n = createI18n({\n * ...i18nConfig,\n * localesDir: '/' + i18nConfig.localesDir, // URL path for browser\n * locale: 'en',\n * defaultLocale: 'en',\n * supportedLocales: ['en', 'bg'],\n * });\n * ```\n *\n * ```ts\n * // vite.config.ts — plugin\n * import { i18nConfig } from './src/i18n.config';\n *\n * i18nDevPlugin(i18nConfig)\n * ```\n */\nexport function defineI18nConfig(config: I18nSharedConfig): I18nSharedConfig {\n validateConfig(config);\n return config;\n}\n\nfunction getDictionaryPatterns(dict: DictionaryConfig): string[] {\n const fromKeys = (dict.keys ?? []).map((key) => `${key}.*`);\n return [...fromKeys, ...(dict.include ?? [])];\n}\n\nfunction isValidPattern(pattern: string): boolean {\n if (!pattern || typeof pattern !== 'string') return false;\n if (pattern.includes('*')) {\n return pattern.endsWith('*') && pattern.indexOf('*') === pattern.length - 1;\n }\n return true;\n}\n\nfunction validateConfig(config: I18nSharedConfig): void {\n if (!config.localesDir || typeof config.localesDir !== 'string') {\n throw new Error('vite-bundled-i18n: localesDir must be a non-empty string');\n }\n\n if (config.dictionaries) {\n for (const [name, dict] of Object.entries(config.dictionaries)) {\n const hasKeys = dict.keys !== undefined;\n const hasInclude = dict.include !== undefined;\n\n if (hasKeys && !Array.isArray(dict.keys)) {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" must have a keys array`);\n }\n if (hasInclude && !Array.isArray(dict.include)) {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" must have an include array`);\n }\n if (hasKeys && (dict.keys?.length ?? 0) === 0 && !hasInclude) {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" has an empty keys array`);\n }\n if (hasKeys) {\n for (const key of dict.keys ?? []) {\n if (!key || typeof key !== 'string') {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" contains an invalid key: ${JSON.stringify(key)}`);\n }\n }\n }\n if (hasInclude) {\n for (const pattern of dict.include ?? []) {\n if (!pattern || typeof pattern !== 'string') {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" contains an invalid key pattern: ${JSON.stringify(pattern)}`);\n }\n }\n }\n\n const patterns = getDictionaryPatterns(dict);\n if (patterns.length === 0) {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" must define keys or include patterns`);\n }\n\n if (dict.priority !== undefined && typeof dict.priority !== 'number') {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" priority must be a number`);\n }\n\n for (const key of patterns) {\n if (!isValidPattern(key)) {\n throw new Error(`vite-bundled-i18n: dictionary \"${name}\" contains an invalid key pattern: ${JSON.stringify(key)}`);\n }\n }\n }\n\n // Warn about duplicate patterns across dictionaries\n const seen = new Map<string, string>(); // pattern → first dictionary name\n for (const [name, dict] of Object.entries(config.dictionaries)) {\n for (const pattern of getDictionaryPatterns(dict)) {\n const existing = seen.get(pattern);\n if (existing) {\n console.warn(\n `vite-bundled-i18n: pattern \"${pattern}\" appears in both dictionary \"${existing}\" and \"${name}\". This is allowed but may cause unexpected loading order.`,\n );\n } else {\n seen.set(pattern, name);\n }\n }\n }\n }\n}\n","import type { TranslationKey } from './types';\n\n/**\n * Marks a serializable data structure as i18n-owned without changing it.\n * Useful for navigation configs, tables, and other shared data files.\n */\nexport function defineI18nData<const T>(data: T): T {\n return data;\n}\n\n/**\n * Typed identity helper for translation keys in arbitrary field names.\n */\nexport function i18nKey<K extends TranslationKey>(key: K):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,4 +17,4 @@ export { defineI18nData, i18nKey } from './core/data';
17
17
  export { t, hasKey, scopedT, setGlobalInstance, getGlobalTranslations } from './core/t';
18
18
  export { initServerI18n } from './server';
19
19
  export type { I18nSharedConfig, } from './core/config';
20
- export type { NestedTranslations, I18nConfig, I18nInstance, DictionaryConfig, CacheConfig, RuntimeCacheConfig, CacheStats, CompiledConfig, I18nKeyMap, I18nParamsMap, Primitive, ParamsOf, TranslationKey, TFunction, TryTFunction, RequireTFunction, Translations, NamespacedTranslations, ScopedTFunction, UseI18nResult, KeyUsageEntry, I18nScopeMap, ValidScope, } from './core/types';
20
+ export type { NestedTranslations, I18nConfig, I18nInstance, DictionaryConfig, CacheConfig, RuntimeCacheConfig, CacheStats, CompiledConfig, I18nKeyMap, I18nParamsMap, Primitive, ParamsOf, TranslationKey, TFunction, TryTFunction, RequireTFunction, Translations, NamespacedTranslations, ScopedTFunction, UseI18nResult, KeyUsageEntry, I18nScopeMap, I18nNestedKeys, ValidScope, DotPath, } from './core/types';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as createI18n, n as i18nKey, r as defineI18nConfig, t as defineI18nData } from "./data-DMyotm6N.js";
1
+ import { i as createI18n, n as i18nKey, r as defineI18nConfig, t as defineI18nData } from "./data-CX4qW9_K.js";
2
2
  import { n as getTranslations, t as createTranslations } from "./getTranslations-D3q3OBTn.js";
3
3
  import { a as t, i as setGlobalInstance, n as hasKey, r as scopedT, t as getGlobalTranslations } from "./t-Bfb3ut7N.js";
4
- import { n as initServerI18n } from "./server-C9D7vcAO.js";
4
+ import { n as initServerI18n } from "./server-Boo9FghP.js";
5
5
  export { createI18n, createTranslations, defineI18nConfig, defineI18nData, getGlobalTranslations, getTranslations, hasKey, i18nKey, initServerI18n, scopedT, setGlobalInstance, t };
@@ -52,7 +52,7 @@ export interface I18nDevPluginOptions {
52
52
  assetsDir?: string;
53
53
  /** Default locale for type generation. Required for dev-time autocomplete. */
54
54
  defaultLocale?: string;
55
- /** Path to write generated types. Defaults to `src/i18n-types.d.ts`. */
55
+ /** Path to write generated types. Defaults to `.i18n/i18n.d.ts`. */
56
56
  typesOutPath?: string;
57
57
  }
58
58
  export declare function i18nDevPlugin(config: I18nDevPluginConfig, options?: I18nDevPluginOptions): Plugin;