vite-bundled-i18n 0.1.0

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/dist/cli/commands.d.ts +46 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.js +231 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/core/args.d.ts +15 -0
  8. package/dist/core/compiled-runtime.d.ts +75 -0
  9. package/dist/core/config.d.ts +65 -0
  10. package/dist/core/createI18n.d.ts +40 -0
  11. package/dist/core/data.d.ts +10 -0
  12. package/dist/core/fetcher.d.ts +5 -0
  13. package/dist/core/getTranslations.d.ts +20 -0
  14. package/dist/core/interpolator.d.ts +27 -0
  15. package/dist/core/resolver.d.ts +51 -0
  16. package/dist/core/store.d.ts +61 -0
  17. package/dist/core/t.d.ts +53 -0
  18. package/dist/core/types.d.ts +396 -0
  19. package/dist/data-Trz4mxne.js +894 -0
  20. package/dist/data-Trz4mxne.js.map +1 -0
  21. package/dist/extractor/ast-utils.d.ts +19 -0
  22. package/dist/extractor/bundle-generator.d.ts +46 -0
  23. package/dist/extractor/compiler.d.ts +47 -0
  24. package/dist/extractor/dictionary-ownership.d.ts +18 -0
  25. package/dist/extractor/extract.d.ts +12 -0
  26. package/dist/extractor/patterns.d.ts +10 -0
  27. package/dist/extractor/reports.d.ts +109 -0
  28. package/dist/extractor/scope-bundles.d.ts +9 -0
  29. package/dist/extractor/type-generator.d.ts +34 -0
  30. package/dist/extractor/types.d.ts +45 -0
  31. package/dist/extractor/walker-types.d.ts +44 -0
  32. package/dist/extractor/walker.d.ts +38 -0
  33. package/dist/getTranslations-D3q3OBTn.js +120 -0
  34. package/dist/getTranslations-D3q3OBTn.js.map +1 -0
  35. package/dist/index.d.ts +20 -0
  36. package/dist/index.js +5 -0
  37. package/dist/plugin/buildPlugin.d.ts +39 -0
  38. package/dist/plugin/devPlugin.d.ts +51 -0
  39. package/dist/plugin.d.ts +16 -0
  40. package/dist/plugin.js +226 -0
  41. package/dist/plugin.js.map +1 -0
  42. package/dist/react/DevToolbar.d.ts +22 -0
  43. package/dist/react/I18nProvider.d.ts +20 -0
  44. package/dist/react/context.d.ts +19 -0
  45. package/dist/react/useI18n.d.ts +33 -0
  46. package/dist/react.d.ts +11 -0
  47. package/dist/react.js +626 -0
  48. package/dist/react.js.map +1 -0
  49. package/dist/server-BpEocC73.js +58 -0
  50. package/dist/server-BpEocC73.js.map +1 -0
  51. package/dist/server-entry.d.ts +7 -0
  52. package/dist/server.d.ts +22 -0
  53. package/dist/server.js +4 -0
  54. package/dist/t-Bfb3ut7N.js +75 -0
  55. package/dist/t-Bfb3ut7N.js.map +1 -0
  56. package/dist/vanilla.d.ts +43 -0
  57. package/dist/vanilla.js +39 -0
  58. package/dist/vanilla.js.map +1 -0
  59. package/dist/vue.d.ts +31 -0
  60. package/dist/vue.js +87 -0
  61. package/dist/vue.js.map +1 -0
  62. package/dist/walker-DqlV3VrX.js +1307 -0
  63. package/dist/walker-DqlV3VrX.js.map +1 -0
  64. package/package.json +121 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicolas Vlachos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,322 @@
1
+ # vite-bundled-i18n
2
+
3
+ Route-aware i18n for Vite apps.
4
+
5
+ It gives you:
6
+
7
+ - one translator API across React and non-React code
8
+ - named dictionaries with ownership and priority
9
+ - scope bundles for pages like `products.index`
10
+ - generated key and placeholder types
11
+ - production `__i18n/...` assets emitted by Vite
12
+ - optional compiled-map runtime loading in production
13
+
14
+ ## Install
15
+
16
+ Requirements:
17
+
18
+ - Node `>=20`
19
+ - a Vite app for plugin/build integration
20
+ - `react` and `react-dom` only if you use the React adapter
21
+
22
+ ```bash
23
+ npm install vite-bundled-i18n
24
+ ```
25
+
26
+ If you use React:
27
+
28
+ ```bash
29
+ npm install react react-dom
30
+ ```
31
+
32
+ If you use Vue:
33
+
34
+ ```bash
35
+ npm install vue
36
+ ```
37
+
38
+ For local package validation:
39
+
40
+ ```bash
41
+ # in this repo
42
+ npm run build
43
+ npm pack
44
+
45
+ # in your app
46
+ npm install /absolute/path/to/vite-bundled-i18n-0.1.0.tgz
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```ts
52
+ // src/i18n.config.ts
53
+ import { defineI18nConfig } from 'vite-bundled-i18n'
54
+
55
+ export const i18nConfig = defineI18nConfig({
56
+ localesDir: 'locales',
57
+ dictionaries: {
58
+ global: {
59
+ include: ['shared.*', 'global.*', 'actions.*'],
60
+ priority: 1,
61
+ pinned: true,
62
+ },
63
+ },
64
+ })
65
+ ```
66
+
67
+ ```ts
68
+ // src/i18n.ts
69
+ import { createI18n } from 'vite-bundled-i18n'
70
+ import { i18nConfig } from './i18n.config'
71
+
72
+ export const i18n = createI18n({
73
+ ...i18nConfig,
74
+ localesDir: '/locales',
75
+ locale: 'en',
76
+ defaultLocale: 'en',
77
+ supportedLocales: ['en', 'bg'],
78
+ })
79
+ ```
80
+
81
+ ```ts
82
+ // vite.config.ts
83
+ import { defineConfig } from 'vite'
84
+ import react from '@vitejs/plugin-react'
85
+ import { i18nPlugin } from 'vite-bundled-i18n/plugin'
86
+ import { i18nConfig } from './src/i18n.config'
87
+
88
+ export default defineConfig({
89
+ plugins: [
90
+ react(),
91
+ i18nPlugin(i18nConfig, {
92
+ pages: ['src/pages/**/*.tsx'],
93
+ locales: ['en', 'bg'],
94
+ defaultLocale: 'en',
95
+ generatedOutDir: '.i18n',
96
+ typesOutPath: 'src/i18n-types.d.ts',
97
+ }),
98
+ ],
99
+ })
100
+ ```
101
+
102
+ ```tsx
103
+ // src/main.tsx
104
+ import { createRoot } from 'react-dom/client'
105
+ import { I18nProvider } from 'vite-bundled-i18n/react'
106
+ import { i18n } from './i18n'
107
+ import App from './App'
108
+
109
+ createRoot(document.getElementById('root')!).render(
110
+ <I18nProvider instance={i18n}>
111
+ <App />
112
+ </I18nProvider>,
113
+ )
114
+ ```
115
+
116
+ ```tsx
117
+ import { useI18n } from 'vite-bundled-i18n/react'
118
+
119
+ export function ProductsPage() {
120
+ const { t, translations, ready } = useI18n('products.index')
121
+
122
+ if (!ready) return <div>{t('shared.loading', 'Loading...')}</div>
123
+
124
+ return (
125
+ <section>
126
+ <h1>{translations.get('products.index.heading', 'All Products')}</h1>
127
+ <p>{t('products.index.subheading', { count: 24 }, 'Browse {{count}} items')}</p>
128
+ </section>
129
+ )
130
+ }
131
+ ```
132
+
133
+ ### Vue Quick Start
134
+
135
+ ```ts
136
+ import { createApp } from 'vue'
137
+ import { createI18nPlugin } from 'vite-bundled-i18n/vue'
138
+ import { i18n } from './i18n'
139
+
140
+ const app = createApp(App)
141
+ app.use(createI18nPlugin(i18n))
142
+ app.mount('#app')
143
+ ```
144
+
145
+ ## Public API Shape
146
+
147
+ The main API is the translator object:
148
+
149
+ ```ts
150
+ const translations = await getTranslations(i18n, 'products.index')
151
+
152
+ translations.t('products.index.heading')
153
+ translations.get('products.show.price', { amount: 29.99 })
154
+ translations.tryGet('shared.ok')
155
+ translations.has('actions.save')
156
+ translations.namespace('global').get('nav.home')
157
+ ```
158
+
159
+ React returns the same shape plus top-level aliases:
160
+
161
+ ```ts
162
+ const { t, get, has, tryGet, require, translations, ready, locale } = useI18n()
163
+ ```
164
+
165
+ Package entries:
166
+
167
+ - `vite-bundled-i18n`
168
+ - `vite-bundled-i18n/react`
169
+ - `vite-bundled-i18n/vanilla`
170
+ - `vite-bundled-i18n/vue`
171
+ - `vite-bundled-i18n/server`
172
+ - `vite-bundled-i18n/plugin`
173
+
174
+ ## Data Files
175
+
176
+ For data/config code, keep keys in data and resolve later:
177
+
178
+ ```ts
179
+ import { defineI18nData, i18nKey } from 'vite-bundled-i18n'
180
+
181
+ export const nav = defineI18nData([
182
+ { href: '/', labelKey: i18nKey('global.nav.home') },
183
+ { href: '/cart', labelKey: i18nKey('global.nav.cart') },
184
+ ])
185
+ ```
186
+
187
+ The extractor understands these helpers.
188
+
189
+ Avoid module-top-level eager translation:
190
+
191
+ ```ts
192
+ // Avoid
193
+ export const nav = [{ label: t('global.nav.home') }]
194
+ ```
195
+
196
+ Store keys in data and resolve them later.
197
+
198
+ ## Dictionaries
199
+
200
+ Dictionaries are key-ownership rules, not component-file ownership rules:
201
+
202
+ ```ts
203
+ dictionaries: {
204
+ global: {
205
+ include: ['shared.*', 'global.*', 'actions.*'],
206
+ priority: 1,
207
+ pinned: true,
208
+ },
209
+ admin: {
210
+ include: ['admin.*'],
211
+ priority: 10,
212
+ },
213
+ }
214
+ ```
215
+
216
+ Notes:
217
+
218
+ - `include` supports exact keys, namespace wildcards, and prefix patterns
219
+ - higher priority dictionaries claim keys first
220
+ - lower priority dictionaries exclude already-owned keys
221
+ - legacy `keys: ['shared']` is still supported
222
+
223
+ ## Server / SSR
224
+
225
+ ```ts
226
+ import { initServerI18n } from 'vite-bundled-i18n/server'
227
+
228
+ const { translations, scriptTag } = await initServerI18n(config, 'products.show')
229
+ const html = renderToString(<App translations={translations} />)
230
+ // Inject scriptTag into HTML
231
+ ```
232
+
233
+ On the client, both `I18nProvider` (React) and `createI18nPlugin` (Vue) automatically detect and consume `window.__I18N_RESOURCES__` — no manual wiring needed.
234
+
235
+ ## Production Output
236
+
237
+ During `vite build`, the plugin emits:
238
+
239
+ - `__i18n/{locale}/_dict/{name}.json`
240
+ - `__i18n/{locale}/{scope}.json`
241
+ - `__i18n/compiled/manifest.js`
242
+ - `__i18n/compiled/{locale}/...` compiled map modules
243
+
244
+ The runtime can use emitted JSON bundles or the compiled manifest path automatically in production.
245
+
246
+ ## Fetch Options
247
+
248
+ Configure `requestInit` on `createI18n()` to set headers, credentials, or cache mode:
249
+
250
+ ```ts
251
+ createI18n({
252
+ ...config,
253
+ requestInit: { credentials: 'include' },
254
+ })
255
+ ```
256
+
257
+ Supports static objects, sync functions, and async functions for dynamic auth tokens.
258
+
259
+ ## Cache
260
+
261
+ The runtime stores translations in memory by namespace.
262
+
263
+ - dictionaries can be pinned
264
+ - repeated scope and dictionary loads are deduplicated
265
+ - non-pinned namespaces can be evicted with LRU policy
266
+ - fallback locale lookup still applies
267
+
268
+ Example:
269
+
270
+ ```ts
271
+ cache: {
272
+ runtime: {
273
+ strategy: 'memory',
274
+ eviction: 'lru',
275
+ maxNamespaces: 50,
276
+ pinDictionaries: true,
277
+ },
278
+ }
279
+ ```
280
+
281
+ ## Release Flow
282
+
283
+ Recommended local release sequence:
284
+
285
+ ```bash
286
+ npm run lint
287
+ npm test
288
+ npm run build
289
+ npm pack
290
+ ```
291
+
292
+ Publish:
293
+
294
+ ```bash
295
+ npm publish
296
+ ```
297
+
298
+ ## Docs
299
+
300
+ - [Getting Started](./docs/getting-started.md)
301
+ - [API Reference](./docs/api.md)
302
+ - [Architecture](./docs/architecture.md)
303
+ - [Examples](./docs/examples.md)
304
+
305
+ ## Repo Demo
306
+
307
+ The root Vite app in `src/` is also the reference demo for this package.
308
+
309
+ Run:
310
+
311
+ ```bash
312
+ npm install
313
+ npm run dev
314
+ ```
315
+
316
+ Build:
317
+
318
+ ```bash
319
+ npm run build
320
+ ```
321
+
322
+ That emits the demo app to `demo-dist/` and the generated translation assets to `demo-dist/__i18n/`.
@@ -0,0 +1,46 @@
1
+ import type { ProjectAnalysis } from '../extractor/walker-types';
2
+ import type { DictionaryConfig } from '../core/types';
3
+ export interface CliConfig {
4
+ /** Glob patterns for page entry points. */
5
+ pages: string[];
6
+ /** Locales directory (relative to rootDir). */
7
+ localesDir: string;
8
+ /** All supported locale codes. */
9
+ locales: string[];
10
+ /** Default locale. */
11
+ defaultLocale: string;
12
+ /** Root directory. Defaults to process.cwd(). */
13
+ rootDir?: string;
14
+ /** Output directory for generated bundles. Defaults to '.i18n'. */
15
+ outDir?: string;
16
+ /** Output path for generated types. Defaults to 'src/i18n-types.d.ts'. */
17
+ typesOutPath?: string;
18
+ /** Extraction scope. Defaults to 'global'. */
19
+ extractionScope?: 'global' | 'scoped';
20
+ /** Optional dictionary configurations for compiled mode. */
21
+ dictionaries?: Record<string, DictionaryConfig>;
22
+ }
23
+ /**
24
+ * Run the walker and print a summary table to stdout.
25
+ * Returns the ProjectAnalysis for programmatic use.
26
+ */
27
+ export declare function analyze(config: CliConfig): ProjectAnalysis;
28
+ /**
29
+ * Run the walker, then generate bundles and types.
30
+ * Prints what was generated to stdout.
31
+ */
32
+ export declare function generate(config: CliConfig): void;
33
+ /**
34
+ * Run the walker, then generate diagnostic reports.
35
+ * Prints summary to stdout.
36
+ */
37
+ export declare function report(config: CliConfig): void;
38
+ /**
39
+ * Run the walker, then compile pre-resolved flat Map modules.
40
+ * Prints a summary to stdout.
41
+ */
42
+ export declare function compile(config: CliConfig): void;
43
+ /**
44
+ * Run analyze + generate + compile + report all at once.
45
+ */
46
+ export declare function build(config: CliConfig): void;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,231 @@
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-DqlV3VrX.js";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ //#region src/cli/commands.ts
6
+ function resolveConfig(config) {
7
+ const rootDir = config.rootDir ?? process.cwd();
8
+ return {
9
+ rootDir,
10
+ outDir: config.outDir ?? path.join(rootDir, ".i18n"),
11
+ typesOutPath: config.typesOutPath ?? path.join(rootDir, "src", "i18n-types.d.ts"),
12
+ localesDir: path.isAbsolute(config.localesDir) ? config.localesDir : path.join(rootDir, config.localesDir),
13
+ extractionScope: config.extractionScope ?? "global"
14
+ };
15
+ }
16
+ function runWalker(config) {
17
+ const { rootDir, localesDir, extractionScope } = resolveConfig(config);
18
+ return walkAll({
19
+ pages: config.pages,
20
+ rootDir,
21
+ localesDir,
22
+ defaultLocale: config.defaultLocale,
23
+ extractionScope
24
+ });
25
+ }
26
+ /**
27
+ * Pad a string to the given width.
28
+ */
29
+ function pad(str, width) {
30
+ return str + " ".repeat(Math.max(0, width - str.length));
31
+ }
32
+ /**
33
+ * Print a simple ASCII table to stdout.
34
+ */
35
+ function printTable(headers, rows) {
36
+ const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)));
37
+ const sep = "┌" + colWidths.map((w) => "─".repeat(w + 2)).join("┬") + "┐";
38
+ const mid = "├" + colWidths.map((w) => "─".repeat(w + 2)).join("┼") + "┤";
39
+ const bot = "└" + colWidths.map((w) => "─".repeat(w + 2)).join("┴") + "┘";
40
+ const formatRow = (cells) => "│" + cells.map((c, i) => " " + pad(c, colWidths[i]) + " ").join("│") + "│";
41
+ console.log(sep);
42
+ console.log(formatRow(headers));
43
+ console.log(mid);
44
+ for (const row of rows) console.log(formatRow(row));
45
+ console.log(bot);
46
+ }
47
+ /**
48
+ * Run the walker and print a summary table to stdout.
49
+ * Returns the ProjectAnalysis for programmatic use.
50
+ */
51
+ function analyze(config) {
52
+ const { localesDir } = resolveConfig(config);
53
+ const analysis = runWalker(config);
54
+ const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);
55
+ const totalAvailable = Array.from(availableKeys.values()).reduce((sum, keys) => sum + keys.length, 0);
56
+ printTable([
57
+ "Route",
58
+ "Used Keys",
59
+ "Available",
60
+ "Pruned"
61
+ ], analysis.routes.map((route) => {
62
+ const usedCount = route.keys.filter((k) => !k.dynamic).length;
63
+ return [
64
+ route.routeId,
65
+ String(usedCount),
66
+ String(totalAvailable),
67
+ String(totalAvailable - usedCount)
68
+ ];
69
+ }));
70
+ console.log(`\n${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s), ${analysis.availableNamespaces.length} namespace(s)`);
71
+ return analysis;
72
+ }
73
+ /**
74
+ * Run the walker, then generate bundles and types.
75
+ * Prints what was generated to stdout.
76
+ */
77
+ function generate(config) {
78
+ const { outDir, typesOutPath, localesDir } = resolveConfig(config);
79
+ const bundles = generateBundles(runWalker(config), {
80
+ localesDir,
81
+ locales: config.locales,
82
+ outDir
83
+ });
84
+ writeTypes(localesDir, config.defaultLocale, typesOutPath);
85
+ console.log(`Generated ${bundles.length} bundle(s):`);
86
+ for (const b of bundles) console.log(` ${b.locale}/${b.name} — ${b.keyCount} keys (${b.prunedCount} pruned)`);
87
+ console.log(`Types written to ${typesOutPath}`);
88
+ }
89
+ /**
90
+ * Run the walker, then generate diagnostic reports.
91
+ * Prints summary to stdout.
92
+ */
93
+ function report(config) {
94
+ const { outDir, localesDir } = resolveConfig(config);
95
+ generateReports(runWalker(config), localesDir, config.defaultLocale, outDir, config.dictionaries);
96
+ console.log(`Reports written to ${outDir}:`);
97
+ console.log(" manifest.json");
98
+ console.log(" missing.json");
99
+ console.log(" unused.json");
100
+ console.log(" stats.json");
101
+ }
102
+ /**
103
+ * Run the walker, then compile pre-resolved flat Map modules.
104
+ * Prints a summary to stdout.
105
+ */
106
+ function compile(config) {
107
+ const { outDir, localesDir } = resolveConfig(config);
108
+ const analysis = runWalker(config);
109
+ const compiledOutDir = path.join(outDir, "compiled");
110
+ compileAll(analysis, {
111
+ localesDir,
112
+ locales: config.locales,
113
+ defaultLocale: config.defaultLocale,
114
+ outDir: compiledOutDir,
115
+ dictionaries: config.dictionaries
116
+ });
117
+ const total = analysis.routes.length * config.locales.length + (config.dictionaries && Object.keys(config.dictionaries).length > 0 ? config.locales.length : 0) + 1;
118
+ console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);
119
+ }
120
+ /**
121
+ * Run analyze + generate + compile + report all at once.
122
+ */
123
+ function build(config) {
124
+ const { outDir, typesOutPath, localesDir } = resolveConfig(config);
125
+ const analysis = runWalker(config);
126
+ const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);
127
+ const totalAvailable = Array.from(availableKeys.values()).reduce((sum, keys) => sum + keys.length, 0);
128
+ printTable([
129
+ "Route",
130
+ "Used Keys",
131
+ "Available",
132
+ "Pruned"
133
+ ], analysis.routes.map((route) => {
134
+ const usedCount = route.keys.filter((k) => !k.dynamic).length;
135
+ return [
136
+ route.routeId,
137
+ String(usedCount),
138
+ String(totalAvailable),
139
+ String(totalAvailable - usedCount)
140
+ ];
141
+ }));
142
+ const bundles = generateBundles(analysis, {
143
+ localesDir,
144
+ locales: config.locales,
145
+ outDir
146
+ });
147
+ writeTypes(localesDir, config.defaultLocale, typesOutPath);
148
+ console.log(`\nGenerated ${bundles.length} bundle(s)`);
149
+ console.log(`Types written to ${typesOutPath}`);
150
+ const compiledOutDir = path.join(outDir, "compiled");
151
+ compileAll(analysis, {
152
+ localesDir,
153
+ locales: config.locales,
154
+ defaultLocale: config.defaultLocale,
155
+ outDir: compiledOutDir,
156
+ dictionaries: config.dictionaries
157
+ });
158
+ console.log(`Compiled modules written to ${compiledOutDir}`);
159
+ generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);
160
+ console.log(`Reports written to ${outDir}`);
161
+ console.log(`\nDone. ${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s).`);
162
+ }
163
+ //#endregion
164
+ //#region src/cli/index.ts
165
+ var COMMANDS = [
166
+ "analyze",
167
+ "generate",
168
+ "compile",
169
+ "report",
170
+ "build"
171
+ ];
172
+ function printUsage() {
173
+ console.log("Usage: vite-bundled-i18n <command> [--config <path>]");
174
+ console.log("");
175
+ console.log("Commands:");
176
+ console.log(" analyze — Walk imports and print a summary of key usage per route");
177
+ console.log(" generate — Generate tree-shaken bundles and TypeScript types");
178
+ console.log(" report — Generate diagnostic reports (manifest, missing, unused, stats)");
179
+ console.log(" compile — Compile pre-resolved flat Map modules for production");
180
+ console.log(" build — Run analyze + generate + compile + report in one step");
181
+ console.log("");
182
+ console.log("Options:");
183
+ console.log(" --config <path> Path to config file (default: i18n.config.json)");
184
+ }
185
+ function loadConfig(configPath) {
186
+ const resolved = path.resolve(configPath);
187
+ if (!fs.existsSync(resolved)) {
188
+ console.error(`Config file not found: ${resolved}`);
189
+ process.exit(1);
190
+ }
191
+ const raw = fs.readFileSync(resolved, "utf-8");
192
+ return JSON.parse(raw);
193
+ }
194
+ function parseArgs(argv) {
195
+ const args = argv.slice(2);
196
+ let command;
197
+ let configPath = "i18n.config.json";
198
+ for (let i = 0; i < args.length; i++) {
199
+ const arg = args[i];
200
+ if (arg === "--config" && i + 1 < args.length) configPath = args[++i];
201
+ else if (arg === "--help" || arg === "-h") {
202
+ printUsage();
203
+ process.exit(0);
204
+ } else if (!command && COMMANDS.includes(arg)) command = arg;
205
+ else {
206
+ console.error(`Unknown argument: ${arg}`);
207
+ printUsage();
208
+ process.exit(1);
209
+ }
210
+ }
211
+ if (!command) {
212
+ printUsage();
213
+ process.exit(1);
214
+ }
215
+ return {
216
+ command,
217
+ configPath
218
+ };
219
+ }
220
+ var { command, configPath } = parseArgs(process.argv);
221
+ var config = loadConfig(configPath);
222
+ ({
223
+ analyze,
224
+ generate,
225
+ compile,
226
+ report,
227
+ build
228
+ })[command](config);
229
+ //#endregion
230
+
231
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;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,GAAG,QAAQ,IAAI,OAAO,CAAC;;;;;AAM1D,SAAS,WACP,SACA,MACM;CACN,MAAM,YAAY,QAAQ,KAAK,GAAG,MAChC,KAAK,IAAI,EAAE,QA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;AAC3F,SAAQ,IAAI,qEAAqE;AACjF,SAAQ,IAAI,sEAAsE;AAClF,SAAQ,IAAI,GAAG;AACf,SAAQ,IAAI,WAAW;AACvB,SAAQ,IAAI,qEAAqE;;AAGnF,SAAS,WAAW,YAA+B;CACjD,MAAM,WAAW,KAAK,QAAQ,WAAW;AACzC,KAAI,CAAC,GAAG,WAAW,SAAS,EAAE;AAC5B,UAAQ,MAAM,0BAA0B,WAAW;AACnD,UAAQ,KAAK,EAAE;;CAGjB,MAAM,MAAM,GAAG,aAAa,UAAU,QAAQ;AAC9C,QAAO,KAAK,MAAM,IAAI;;AAGxB,SAAS,UAAU,MAA0D;CAC3E,MAAM,OAAO,KAAK,MAAM,EAAE;CAC1B,IAAI;CACJ,IAAI,aAAa;AAEjB,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,cAAc,IAAI,IAAI,KAAK,OACrC,cAAa,KAAK,EAAE;WACX,QAAQ,YAAY,QAAQ,MAAM;AAC3C,eAAY;AACZ,WAAQ,KAAK,EAAE;aACN,CAAC,WAAW,SAAS,SAAS,IAAe,CACtD,WAAU;OACL;AACL,WAAQ,MAAM,qBAAqB,MAAM;AACzC,eAAY;AACZ,WAAQ,KAAK,EAAE;;;AAInB,KAAI,CAAC,SAAS;AACZ,cAAY;AACZ,UAAQ,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"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Resolves the overloaded arguments of translation functions into a normalized form.
3
+ *
4
+ * The second argument can be either a fallback string or a params object.
5
+ * Detection rules:
6
+ * - `undefined` or `null` -> no params, no fallback
7
+ * - `string` -> fallback
8
+ * - plain object (`{}`) -> params
9
+ * - anything else (arrays, numbers, booleans) -> ignored, treated as no params
10
+ */
11
+ export declare function resolveArgs(args: [string] | [string, string] | [string, Record<string, unknown>] | [string, Record<string, unknown>, string]): {
12
+ key: string;
13
+ params?: Record<string, unknown>;
14
+ fallback?: string;
15
+ };