i18next-cli 1.69.1 → 1.70.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.
- package/README.md +9 -1
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/ast-visitors.js +147 -113
- package/dist/cjs/extractor/parsers/call-expression-handler.js +3 -2
- package/dist/cjs/extractor/parsers/expression-resolver.js +13 -4
- package/dist/cjs/extractor/parsers/scope-manager.js +6 -0
- package/dist/cjs/instrumenter/core/instrumenter.js +9 -3
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/ast-visitors.js +147 -113
- package/dist/esm/extractor/parsers/call-expression-handler.js +3 -2
- package/dist/esm/extractor/parsers/expression-resolver.js +13 -4
- package/dist/esm/extractor/parsers/scope-manager.js +6 -0
- package/dist/esm/instrumenter/core/instrumenter.js +9 -3
- package/package.json +19 -19
- package/types/extractor/core/ast-visitors.d.ts +11 -0
- package/types/extractor/core/ast-visitors.d.ts.map +1 -1
- package/types/extractor/parsers/call-expression-handler.d.ts.map +1 -1
- package/types/extractor/parsers/expression-resolver.d.ts +2 -0
- package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
- package/types/extractor/parsers/scope-manager.d.ts.map +1 -1
- package/types/instrumenter/core/instrumenter.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -598,7 +598,15 @@ The command walks through six steps:
|
|
|
598
598
|
|
|
599
599
|
**Non-React stacks (Vue, Svelte, …):** the instrument step transforms React/JSX out of the box. For other stacks, add a plugin that covers your file type (community: [i18next-cli-vue](https://github.com/PBK-B/i18next-cli-vue), [i18next-cli-plugin-svelte](https://github.com/dreamscached/i18next-cli-plugin-svelte) — or write your own via the [Plugin System](#plugin-system) `instrumentOnLoad`/`onLoad` hooks). With a matching plugin configured, `localize` runs the full flow; without one, the instrument step is skipped with guidance and the remaining steps (extract → Locize → auto-translate) still run.
|
|
600
600
|
|
|
601
|
-
**Agent
|
|
601
|
+
**Agent Skill (recommended):** install the flow as a skill and your agent picks it up on its own, no copy-pasting:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
npx skills add i18next/i18next-cli
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Then just ask it to *"add i18n to this project"*. See [`skills/i18next-localization`](./skills/i18next-localization/SKILL.md) — it ships in this repo, so it stays version-matched to the commands it drives.
|
|
608
|
+
|
|
609
|
+
**Agent prompt:** the same flow is also available as a copy-paste prompt for AI coding agents (Claude Code, Cursor, …):
|
|
602
610
|
|
|
603
611
|
```bash
|
|
604
612
|
npx i18next-cli localize --print-agent-prompt
|
package/dist/cjs/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ const program = new commander.Command();
|
|
|
37
37
|
program
|
|
38
38
|
.name('i18next-cli')
|
|
39
39
|
.description('A unified, high-performance i18next CLI.')
|
|
40
|
-
.version('1.
|
|
40
|
+
.version('1.70.0'); // This string is replaced with the actual version at build time by rollup
|
|
41
41
|
// new: global config override option
|
|
42
42
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
43
43
|
program
|
|
@@ -230,22 +230,24 @@ class ASTVisitors {
|
|
|
230
230
|
if (pat.type === 'ObjectPattern') {
|
|
231
231
|
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation;
|
|
232
232
|
const members = this.expressionResolver.resolveTypeMembers(patType);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
233
|
+
for (const prop of (pat.properties ?? [])) {
|
|
234
|
+
// `{ size }` / `{ size = 'all' }` → AssignmentPatternProperty (local name is the key)
|
|
235
|
+
// `{ size: s }` / `{ size: s = 'all' }` → KeyValuePatternProperty
|
|
236
|
+
const memberName = prop?.key?.value;
|
|
237
|
+
let localNode = prop?.type === 'KeyValuePatternProperty' ? prop.value : prop?.key;
|
|
238
|
+
if (localNode?.type === 'AssignmentPattern')
|
|
239
|
+
localNode = localNode.left;
|
|
240
|
+
const localName = localNode?.type === 'Identifier' ? localNode.value : undefined;
|
|
241
|
+
if (!memberName || !localName)
|
|
242
|
+
continue;
|
|
243
|
+
// `({ t }: { t: TFunction<'ns'> })` → bind `t` to that namespace
|
|
244
|
+
this.bindTFunctionParam(localName, this.getMemberTypeNode(patType, memberName));
|
|
245
|
+
if (!members?.[memberName])
|
|
246
|
+
continue;
|
|
247
|
+
this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
|
|
248
|
+
if (!paramTemporaries)
|
|
249
|
+
paramTemporaries = [];
|
|
250
|
+
paramTemporaries.push(localName);
|
|
249
251
|
}
|
|
250
252
|
continue;
|
|
251
253
|
}
|
|
@@ -292,103 +294,7 @@ class ASTVisitors {
|
|
|
292
294
|
else {
|
|
293
295
|
typeAnn = undefined;
|
|
294
296
|
}
|
|
295
|
-
|
|
296
|
-
const extractTypeName = (ta) => {
|
|
297
|
-
if (!ta)
|
|
298
|
-
return undefined;
|
|
299
|
-
// Identifier style: { type: 'Identifier', value: 'TFunction' } OR { name: 'TFunction' }
|
|
300
|
-
if (ta.typeName && (ta.typeName.type === 'Identifier'))
|
|
301
|
-
return ta.typeName.value ?? ta.typeName.name;
|
|
302
|
-
if (ta.typeName && ta.typeName.type === 'TsQualifiedName') {
|
|
303
|
-
// Qualified like Foo.TFunction -> try right side
|
|
304
|
-
const right = (ta.typeName.right ?? ta.typeName);
|
|
305
|
-
return right?.value ?? right?.name;
|
|
306
|
-
}
|
|
307
|
-
if (ta.typeName && typeof ta.typeName === 'string')
|
|
308
|
-
return ta.typeName;
|
|
309
|
-
if (ta.type === 'Identifier')
|
|
310
|
-
return ta.value ?? ta.name;
|
|
311
|
-
if (ta.id)
|
|
312
|
-
return ta.id?.value ?? ta.id?.name ?? ta.id;
|
|
313
|
-
return undefined;
|
|
314
|
-
};
|
|
315
|
-
const extractStringLiteralValue = (node) => {
|
|
316
|
-
if (!node)
|
|
317
|
-
return undefined;
|
|
318
|
-
// Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
|
|
319
|
-
if (node?.type === 'TsTypeQuery') {
|
|
320
|
-
const name = node.exprName?.value ?? node.exprName?.name;
|
|
321
|
-
if (name)
|
|
322
|
-
return this.scopeManager.resolveSimpleStringIdentifier(name);
|
|
323
|
-
}
|
|
324
|
-
// shapes: TsLiteralType -> { literal: { type: 'StringLiteral', value: 'x' } }
|
|
325
|
-
if (node.type === 'TsLiteralType' && node.literal)
|
|
326
|
-
return node.literal.value ?? node.literal.raw;
|
|
327
|
-
if (node.type === 'StringLiteral' || node.type === 'Str' || node.type === 'Literal')
|
|
328
|
-
return node.value ?? node.raw ?? node.value;
|
|
329
|
-
if (node.literal && (node.literal.type === 'StringLiteral' || node.literal.type === 'Str'))
|
|
330
|
-
return node.literal.value;
|
|
331
|
-
// some SWC builds put the string directly on .value
|
|
332
|
-
if (typeof node.value === 'string')
|
|
333
|
-
return node.value;
|
|
334
|
-
// handle wrapped parameter like { params: [ ... ] } where a literal might be one level deeper
|
|
335
|
-
if (node.params && Array.isArray(node.params) && node.params[0])
|
|
336
|
-
return extractStringLiteralValue(node.params[0]);
|
|
337
|
-
if (node.typeArguments && Array.isArray(node.typeArguments) && node.typeArguments[0])
|
|
338
|
-
return extractStringLiteralValue(node.typeArguments[0]);
|
|
339
|
-
if (node.typeParameters && Array.isArray(node.typeParameters) && node.typeParameters[0])
|
|
340
|
-
return extractStringLiteralValue(node.typeParameters[0]);
|
|
341
|
-
if (node.typeParams && Array.isArray(node.typeParams) && node.typeParams[0])
|
|
342
|
-
return extractStringLiteralValue(node.typeParams[0]);
|
|
343
|
-
return undefined;
|
|
344
|
-
};
|
|
345
|
-
// Detect TsTypeReference like: TFunction<"my-custom-namespace">
|
|
346
|
-
if (typeAnn && (typeAnn.type === 'TsTypeReference' || typeAnn.type === 'TsTypeRef' || typeAnn.type === 'TsTypeReference')) {
|
|
347
|
-
const finalTypeName = extractTypeName(typeAnn);
|
|
348
|
-
if (finalTypeName === 'TFunction') {
|
|
349
|
-
// support multiple AST shapes for type parameters:
|
|
350
|
-
// - typeAnn.typeParameters?.params?.[0]
|
|
351
|
-
// - typeAnn.typeArguments?.params?.[0]
|
|
352
|
-
// - typeAnn.typeParams?.[0] / typeAnn.params?.[0]
|
|
353
|
-
const candidates = [
|
|
354
|
-
typeAnn.typeParameters?.params?.[0],
|
|
355
|
-
typeAnn.typeParameters?.[0],
|
|
356
|
-
typeAnn.typeArguments?.params?.[0],
|
|
357
|
-
typeAnn.typeArguments?.[0],
|
|
358
|
-
typeAnn.typeParams?.params?.[0],
|
|
359
|
-
typeAnn.typeParams?.[0],
|
|
360
|
-
typeAnn.params?.[0],
|
|
361
|
-
typeAnn.args?.[0],
|
|
362
|
-
typeAnn.typeParameters, // fallback if it's directly the literal
|
|
363
|
-
typeAnn.typeArguments,
|
|
364
|
-
typeAnn.typeParams,
|
|
365
|
-
];
|
|
366
|
-
let tp;
|
|
367
|
-
for (const c of candidates) {
|
|
368
|
-
if (c) {
|
|
369
|
-
tp = c;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
const ns = extractStringLiteralValue(tp);
|
|
374
|
-
// Extract the second type parameter for KPrefix
|
|
375
|
-
// We need to find the second element from the same type parameter list
|
|
376
|
-
const typeParams = typeAnn.typeParameters?.params ??
|
|
377
|
-
typeAnn.typeArguments?.params ??
|
|
378
|
-
typeAnn.typeParams?.params ??
|
|
379
|
-
undefined;
|
|
380
|
-
let kpFromType;
|
|
381
|
-
if (typeParams && typeParams.length >= 2) {
|
|
382
|
-
kpFromType = extractStringLiteralValue(typeParams[1]);
|
|
383
|
-
}
|
|
384
|
-
if (ns || kpFromType) {
|
|
385
|
-
this.scopeManager.setVarInScope(paramKey, {
|
|
386
|
-
defaultNs: ns,
|
|
387
|
-
keyPrefix: kpFromType // honour TFunction<Ns, KPrefix>
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
297
|
+
this.bindTFunctionParam(paramKey, typeAnn);
|
|
392
298
|
// Capture parameter type annotations as temporary variables in the
|
|
393
299
|
// expression resolver so that dynamic bracket expressions like
|
|
394
300
|
// `t(($) => $.table.columns[field])` can resolve `field` to its
|
|
@@ -650,6 +556,134 @@ class ASTVisitors {
|
|
|
650
556
|
this.scopeManager.exitClassScope();
|
|
651
557
|
}
|
|
652
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* If `typeAnn` is a `TFunction<Ns, KPrefix>` type reference, register
|
|
561
|
+
* `paramKey` in the current scope with that namespace / keyPrefix.
|
|
562
|
+
*/
|
|
563
|
+
bindTFunctionParam(paramKey, typeAnn) {
|
|
564
|
+
// Small helpers to robustly extract the referenced type name and literal string
|
|
565
|
+
const extractTypeName = (ta) => {
|
|
566
|
+
if (!ta)
|
|
567
|
+
return undefined;
|
|
568
|
+
// Identifier style: { type: 'Identifier', value: 'TFunction' } OR { name: 'TFunction' }
|
|
569
|
+
if (ta.typeName && (ta.typeName.type === 'Identifier'))
|
|
570
|
+
return ta.typeName.value ?? ta.typeName.name;
|
|
571
|
+
if (ta.typeName && ta.typeName.type === 'TsQualifiedName') {
|
|
572
|
+
// Qualified like Foo.TFunction -> try right side
|
|
573
|
+
const right = (ta.typeName.right ?? ta.typeName);
|
|
574
|
+
return right?.value ?? right?.name;
|
|
575
|
+
}
|
|
576
|
+
if (ta.typeName && typeof ta.typeName === 'string')
|
|
577
|
+
return ta.typeName;
|
|
578
|
+
if (ta.type === 'Identifier')
|
|
579
|
+
return ta.value ?? ta.name;
|
|
580
|
+
if (ta.id)
|
|
581
|
+
return ta.id?.value ?? ta.id?.name ?? ta.id;
|
|
582
|
+
return undefined;
|
|
583
|
+
};
|
|
584
|
+
const extractStringLiteralValue = (node) => {
|
|
585
|
+
if (!node)
|
|
586
|
+
return undefined;
|
|
587
|
+
// Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
|
|
588
|
+
if (node?.type === 'TsTypeQuery') {
|
|
589
|
+
const name = node.exprName?.value ?? node.exprName?.name;
|
|
590
|
+
if (name)
|
|
591
|
+
return this.scopeManager.resolveSimpleStringIdentifier(name);
|
|
592
|
+
}
|
|
593
|
+
// shapes: TsLiteralType -> { literal: { type: 'StringLiteral', value: 'x' } }
|
|
594
|
+
if (node.type === 'TsLiteralType' && node.literal)
|
|
595
|
+
return node.literal.value ?? node.literal.raw;
|
|
596
|
+
if (node.type === 'StringLiteral' || node.type === 'Str' || node.type === 'Literal')
|
|
597
|
+
return node.value ?? node.raw ?? node.value;
|
|
598
|
+
if (node.literal && (node.literal.type === 'StringLiteral' || node.literal.type === 'Str'))
|
|
599
|
+
return node.literal.value;
|
|
600
|
+
// some SWC builds put the string directly on .value
|
|
601
|
+
if (typeof node.value === 'string')
|
|
602
|
+
return node.value;
|
|
603
|
+
// handle wrapped parameter like { params: [ ... ] } where a literal might be one level deeper
|
|
604
|
+
if (node.params && Array.isArray(node.params) && node.params[0])
|
|
605
|
+
return extractStringLiteralValue(node.params[0]);
|
|
606
|
+
if (node.typeArguments && Array.isArray(node.typeArguments) && node.typeArguments[0])
|
|
607
|
+
return extractStringLiteralValue(node.typeArguments[0]);
|
|
608
|
+
if (node.typeParameters && Array.isArray(node.typeParameters) && node.typeParameters[0])
|
|
609
|
+
return extractStringLiteralValue(node.typeParameters[0]);
|
|
610
|
+
if (node.typeParams && Array.isArray(node.typeParams) && node.typeParams[0])
|
|
611
|
+
return extractStringLiteralValue(node.typeParams[0]);
|
|
612
|
+
return undefined;
|
|
613
|
+
};
|
|
614
|
+
// Detect TsTypeReference like: TFunction<"my-custom-namespace">
|
|
615
|
+
if (typeAnn && (typeAnn.type === 'TsTypeReference' || typeAnn.type === 'TsTypeRef' || typeAnn.type === 'TsTypeReference')) {
|
|
616
|
+
const finalTypeName = extractTypeName(typeAnn);
|
|
617
|
+
if (finalTypeName === 'TFunction') {
|
|
618
|
+
// support multiple AST shapes for type parameters:
|
|
619
|
+
// - typeAnn.typeParameters?.params?.[0]
|
|
620
|
+
// - typeAnn.typeArguments?.params?.[0]
|
|
621
|
+
// - typeAnn.typeParams?.[0] / typeAnn.params?.[0]
|
|
622
|
+
const candidates = [
|
|
623
|
+
typeAnn.typeParameters?.params?.[0],
|
|
624
|
+
typeAnn.typeParameters?.[0],
|
|
625
|
+
typeAnn.typeArguments?.params?.[0],
|
|
626
|
+
typeAnn.typeArguments?.[0],
|
|
627
|
+
typeAnn.typeParams?.params?.[0],
|
|
628
|
+
typeAnn.typeParams?.[0],
|
|
629
|
+
typeAnn.params?.[0],
|
|
630
|
+
typeAnn.args?.[0],
|
|
631
|
+
typeAnn.typeParameters, // fallback if it's directly the literal
|
|
632
|
+
typeAnn.typeArguments,
|
|
633
|
+
typeAnn.typeParams,
|
|
634
|
+
];
|
|
635
|
+
let tp;
|
|
636
|
+
for (const c of candidates) {
|
|
637
|
+
if (c) {
|
|
638
|
+
tp = c;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const ns = extractStringLiteralValue(tp);
|
|
643
|
+
// Extract the second type parameter for KPrefix
|
|
644
|
+
// We need to find the second element from the same type parameter list
|
|
645
|
+
const typeParams = typeAnn.typeParameters?.params ??
|
|
646
|
+
typeAnn.typeArguments?.params ??
|
|
647
|
+
typeAnn.typeParams?.params ??
|
|
648
|
+
undefined;
|
|
649
|
+
let kpFromType;
|
|
650
|
+
if (typeParams && typeParams.length >= 2) {
|
|
651
|
+
kpFromType = extractStringLiteralValue(typeParams[1]);
|
|
652
|
+
}
|
|
653
|
+
if (ns || kpFromType) {
|
|
654
|
+
this.scopeManager.setVarInScope(paramKey, {
|
|
655
|
+
defaultNs: ns,
|
|
656
|
+
keyPrefix: kpFromType // honour TFunction<Ns, KPrefix>
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Find the raw type node of a named member on an object-shaped type
|
|
664
|
+
* annotation (inline `{ t: TFunction<'ns'> }` or a local interface / type
|
|
665
|
+
* alias name).
|
|
666
|
+
*/
|
|
667
|
+
getMemberTypeNode(tsType, memberName) {
|
|
668
|
+
if (!tsType)
|
|
669
|
+
return undefined;
|
|
670
|
+
let members;
|
|
671
|
+
if (tsType.type === 'TsTypeLiteral')
|
|
672
|
+
members = tsType.members;
|
|
673
|
+
else if (tsType.type === 'TsTypeReference' && tsType.typeName?.type === 'Identifier') {
|
|
674
|
+
members = this.expressionResolver.getObjectTypeMembersRaw(tsType.typeName.value);
|
|
675
|
+
}
|
|
676
|
+
if (!Array.isArray(members))
|
|
677
|
+
return undefined;
|
|
678
|
+
for (const m of members) {
|
|
679
|
+
if (m?.type !== 'TsPropertySignature')
|
|
680
|
+
continue;
|
|
681
|
+
const name = m.key?.type === 'Identifier' || m.key?.type === 'StringLiteral' ? m.key.value : undefined;
|
|
682
|
+
if (name === memberName)
|
|
683
|
+
return m.typeAnnotation?.typeAnnotation ?? m.typeAnnotation;
|
|
684
|
+
}
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
653
687
|
/**
|
|
654
688
|
* If `node` is a call like `ARRAY.map(param => ...)` where ARRAY is a known
|
|
655
689
|
* string-array constant, returns the callback's first parameter name and the
|
|
@@ -676,8 +676,9 @@ class CallExpressionHandler {
|
|
|
676
676
|
extractKeysFromSelector(node) {
|
|
677
677
|
let body = node.body;
|
|
678
678
|
// Handle block bodies, e.g., $ => { return $.key; }
|
|
679
|
-
|
|
680
|
-
|
|
679
|
+
// swc >=1.16 types function bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
680
|
+
if (body.type === 'BlockStatement' || body.type === 'FunctionBody') {
|
|
681
|
+
const returnStmt = body.stmts.find((s) => s.type === 'ReturnStatement');
|
|
681
682
|
if (returnStmt?.type === 'ReturnStatement' && returnStmt.argument) {
|
|
682
683
|
body = returnStmt.argument;
|
|
683
684
|
}
|
|
@@ -30,6 +30,8 @@ class ExpressionResolver {
|
|
|
30
30
|
// type aliases. Maps typeName -> { memberName: possible string values }.
|
|
31
31
|
// e.g. `interface IProps { size: ChangeType }` -> { IProps: { size: ['all','next'] } }
|
|
32
32
|
objectTypeTable = new Map();
|
|
33
|
+
// Raw TS member nodes of local interfaces / object type aliases, keyed by type name.
|
|
34
|
+
objectTypeMembersRaw = new Map();
|
|
33
35
|
// Temporary per-scope bindings for identifiers holding an object-shaped type,
|
|
34
36
|
// e.g. `function f(props: IProps)` -> { props: { size: ['all','next'] } }.
|
|
35
37
|
temporaryObjectVariables = new Map();
|
|
@@ -236,6 +238,7 @@ class ExpressionResolver {
|
|
|
236
238
|
return;
|
|
237
239
|
// `type IProps = { size: ChangeType }` — object shape, not a string union.
|
|
238
240
|
if (tsType.type === 'TsTypeLiteral') {
|
|
241
|
+
this.objectTypeMembersRaw.set(name, tsType.members);
|
|
239
242
|
const members = this.collectObjectTypeMembers(tsType.members);
|
|
240
243
|
if (members)
|
|
241
244
|
this.objectTypeTable.set(name, members);
|
|
@@ -264,6 +267,8 @@ class ExpressionResolver {
|
|
|
264
267
|
const name = node?.id?.type === 'Identifier' ? node.id.value : undefined;
|
|
265
268
|
if (!name)
|
|
266
269
|
return;
|
|
270
|
+
if (Array.isArray(node?.body?.body))
|
|
271
|
+
this.objectTypeMembersRaw.set(name, node.body.body);
|
|
267
272
|
const members = this.collectObjectTypeMembers(node?.body?.body);
|
|
268
273
|
if (members)
|
|
269
274
|
this.objectTypeTable.set(name, members);
|
|
@@ -300,6 +305,9 @@ class ExpressionResolver {
|
|
|
300
305
|
* Resolve a type annotation that refers to an object shape (interface, object
|
|
301
306
|
* type alias, or inline type literal) to its member → string values map.
|
|
302
307
|
*/
|
|
308
|
+
getObjectTypeMembersRaw(name) {
|
|
309
|
+
return this.objectTypeMembersRaw.get(name);
|
|
310
|
+
}
|
|
303
311
|
resolveTypeMembers(tsType) {
|
|
304
312
|
try {
|
|
305
313
|
if (!tsType)
|
|
@@ -447,9 +455,10 @@ class ExpressionResolver {
|
|
|
447
455
|
}
|
|
448
456
|
}
|
|
449
457
|
};
|
|
450
|
-
// Arrow functions with an expression body (no
|
|
451
|
-
// have their return expression directly as `body`.
|
|
452
|
-
|
|
458
|
+
// Arrow functions with an expression body (no block) — `() => expr` —
|
|
459
|
+
// have their return expression directly as `body`. swc >=1.16 types function
|
|
460
|
+
// bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
461
|
+
if (body.type !== 'BlockStatement' && body.type !== 'FunctionBody') {
|
|
453
462
|
const vals = this.resolvePossibleStringValuesFromExpression(body);
|
|
454
463
|
if (vals.length > 0)
|
|
455
464
|
return Array.from(new Set(vals));
|
|
@@ -611,7 +620,7 @@ class ExpressionResolver {
|
|
|
611
620
|
try {
|
|
612
621
|
let body = expression.body;
|
|
613
622
|
// Handle block body with return statement
|
|
614
|
-
if (body.type === 'BlockStatement') {
|
|
623
|
+
if (body.type === 'BlockStatement' || body.type === 'FunctionBody') {
|
|
615
624
|
const returnStmt = body.stmts.find((s) => s.type === 'ReturnStatement');
|
|
616
625
|
if (returnStmt?.type === 'ReturnStatement' && returnStmt.argument) {
|
|
617
626
|
body = returnStmt.argument;
|
|
@@ -550,6 +550,12 @@ class ScopeManager {
|
|
|
550
550
|
return { defaultNs: this.resolveSimpleStringIdentifier(nsNode.value) };
|
|
551
551
|
if (nsNode.type === 'MemberExpression')
|
|
552
552
|
return { defaultNs: this.resolveSimpleMemberExpression(nsNode) };
|
|
553
|
+
// `useTranslation(ns ?? 'fallback')` / `useTranslation(ns || 'fallback')`:
|
|
554
|
+
// prefer a statically resolvable left side, otherwise use the fallback.
|
|
555
|
+
if (nsNode.type === 'BinaryExpression' && (nsNode.operator === '??' || nsNode.operator === '||')) {
|
|
556
|
+
const left = this.resolveNsArg(nsNode.left);
|
|
557
|
+
return left.defaultNs !== undefined ? left : this.resolveNsArg(nsNode.right);
|
|
558
|
+
}
|
|
553
559
|
if (nsNode.type === 'ArrayExpression') {
|
|
554
560
|
const namespaces = [];
|
|
555
561
|
for (const el of nsNode.elements) {
|
|
@@ -406,7 +406,7 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
406
406
|
// FunctionDeclaration with uppercase name
|
|
407
407
|
if (node.type === 'FunctionDeclaration' && node.identifier?.value && /^[A-Z]/.test(node.identifier.value)) {
|
|
408
408
|
const body = node.body;
|
|
409
|
-
if (body
|
|
409
|
+
if (isBlockBody(body) && body.span) {
|
|
410
410
|
components.push({
|
|
411
411
|
name: node.identifier.value,
|
|
412
412
|
bodyStart: body.span.start,
|
|
@@ -422,7 +422,7 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
422
422
|
// VariableDeclarator path (e.g. `const Foo = function Foo() {}`).
|
|
423
423
|
if (node.type === 'FunctionExpression' && node.identifier?.value && /^[A-Z]/.test(node.identifier.value)) {
|
|
424
424
|
const body = node.body;
|
|
425
|
-
if (body
|
|
425
|
+
if (isBlockBody(body) && body.span) {
|
|
426
426
|
const alreadyRegistered = components.some(c => c.bodyStart === body.span.start && c.bodyEnd === body.span.end);
|
|
427
427
|
if (!alreadyRegistered) {
|
|
428
428
|
components.push({
|
|
@@ -474,9 +474,15 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* swc >=1.16 types function bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
479
|
+
*/
|
|
480
|
+
function isBlockBody(body) {
|
|
481
|
+
return body?.type === 'BlockStatement' || body?.type === 'FunctionBody';
|
|
482
|
+
}
|
|
477
483
|
/**
|
|
478
484
|
* Helper: extracts a ComponentBoundary from an ArrowFunctionExpression or FunctionExpression
|
|
479
|
-
* that has a
|
|
485
|
+
* that has a block body.
|
|
480
486
|
*/
|
|
481
487
|
function addComponentFromFunctionNode(name, fnNode, content, components) {
|
|
482
488
|
const body = fnNode.body;
|
package/dist/esm/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const program = new Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name('i18next-cli')
|
|
33
33
|
.description('A unified, high-performance i18next CLI.')
|
|
34
|
-
.version('1.
|
|
34
|
+
.version('1.70.0'); // This string is replaced with the actual version at build time by rollup
|
|
35
35
|
// new: global config override option
|
|
36
36
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
37
37
|
program
|
|
@@ -228,22 +228,24 @@ class ASTVisitors {
|
|
|
228
228
|
if (pat.type === 'ObjectPattern') {
|
|
229
229
|
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation;
|
|
230
230
|
const members = this.expressionResolver.resolveTypeMembers(patType);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
231
|
+
for (const prop of (pat.properties ?? [])) {
|
|
232
|
+
// `{ size }` / `{ size = 'all' }` → AssignmentPatternProperty (local name is the key)
|
|
233
|
+
// `{ size: s }` / `{ size: s = 'all' }` → KeyValuePatternProperty
|
|
234
|
+
const memberName = prop?.key?.value;
|
|
235
|
+
let localNode = prop?.type === 'KeyValuePatternProperty' ? prop.value : prop?.key;
|
|
236
|
+
if (localNode?.type === 'AssignmentPattern')
|
|
237
|
+
localNode = localNode.left;
|
|
238
|
+
const localName = localNode?.type === 'Identifier' ? localNode.value : undefined;
|
|
239
|
+
if (!memberName || !localName)
|
|
240
|
+
continue;
|
|
241
|
+
// `({ t }: { t: TFunction<'ns'> })` → bind `t` to that namespace
|
|
242
|
+
this.bindTFunctionParam(localName, this.getMemberTypeNode(patType, memberName));
|
|
243
|
+
if (!members?.[memberName])
|
|
244
|
+
continue;
|
|
245
|
+
this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
|
|
246
|
+
if (!paramTemporaries)
|
|
247
|
+
paramTemporaries = [];
|
|
248
|
+
paramTemporaries.push(localName);
|
|
247
249
|
}
|
|
248
250
|
continue;
|
|
249
251
|
}
|
|
@@ -290,103 +292,7 @@ class ASTVisitors {
|
|
|
290
292
|
else {
|
|
291
293
|
typeAnn = undefined;
|
|
292
294
|
}
|
|
293
|
-
|
|
294
|
-
const extractTypeName = (ta) => {
|
|
295
|
-
if (!ta)
|
|
296
|
-
return undefined;
|
|
297
|
-
// Identifier style: { type: 'Identifier', value: 'TFunction' } OR { name: 'TFunction' }
|
|
298
|
-
if (ta.typeName && (ta.typeName.type === 'Identifier'))
|
|
299
|
-
return ta.typeName.value ?? ta.typeName.name;
|
|
300
|
-
if (ta.typeName && ta.typeName.type === 'TsQualifiedName') {
|
|
301
|
-
// Qualified like Foo.TFunction -> try right side
|
|
302
|
-
const right = (ta.typeName.right ?? ta.typeName);
|
|
303
|
-
return right?.value ?? right?.name;
|
|
304
|
-
}
|
|
305
|
-
if (ta.typeName && typeof ta.typeName === 'string')
|
|
306
|
-
return ta.typeName;
|
|
307
|
-
if (ta.type === 'Identifier')
|
|
308
|
-
return ta.value ?? ta.name;
|
|
309
|
-
if (ta.id)
|
|
310
|
-
return ta.id?.value ?? ta.id?.name ?? ta.id;
|
|
311
|
-
return undefined;
|
|
312
|
-
};
|
|
313
|
-
const extractStringLiteralValue = (node) => {
|
|
314
|
-
if (!node)
|
|
315
|
-
return undefined;
|
|
316
|
-
// Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
|
|
317
|
-
if (node?.type === 'TsTypeQuery') {
|
|
318
|
-
const name = node.exprName?.value ?? node.exprName?.name;
|
|
319
|
-
if (name)
|
|
320
|
-
return this.scopeManager.resolveSimpleStringIdentifier(name);
|
|
321
|
-
}
|
|
322
|
-
// shapes: TsLiteralType -> { literal: { type: 'StringLiteral', value: 'x' } }
|
|
323
|
-
if (node.type === 'TsLiteralType' && node.literal)
|
|
324
|
-
return node.literal.value ?? node.literal.raw;
|
|
325
|
-
if (node.type === 'StringLiteral' || node.type === 'Str' || node.type === 'Literal')
|
|
326
|
-
return node.value ?? node.raw ?? node.value;
|
|
327
|
-
if (node.literal && (node.literal.type === 'StringLiteral' || node.literal.type === 'Str'))
|
|
328
|
-
return node.literal.value;
|
|
329
|
-
// some SWC builds put the string directly on .value
|
|
330
|
-
if (typeof node.value === 'string')
|
|
331
|
-
return node.value;
|
|
332
|
-
// handle wrapped parameter like { params: [ ... ] } where a literal might be one level deeper
|
|
333
|
-
if (node.params && Array.isArray(node.params) && node.params[0])
|
|
334
|
-
return extractStringLiteralValue(node.params[0]);
|
|
335
|
-
if (node.typeArguments && Array.isArray(node.typeArguments) && node.typeArguments[0])
|
|
336
|
-
return extractStringLiteralValue(node.typeArguments[0]);
|
|
337
|
-
if (node.typeParameters && Array.isArray(node.typeParameters) && node.typeParameters[0])
|
|
338
|
-
return extractStringLiteralValue(node.typeParameters[0]);
|
|
339
|
-
if (node.typeParams && Array.isArray(node.typeParams) && node.typeParams[0])
|
|
340
|
-
return extractStringLiteralValue(node.typeParams[0]);
|
|
341
|
-
return undefined;
|
|
342
|
-
};
|
|
343
|
-
// Detect TsTypeReference like: TFunction<"my-custom-namespace">
|
|
344
|
-
if (typeAnn && (typeAnn.type === 'TsTypeReference' || typeAnn.type === 'TsTypeRef' || typeAnn.type === 'TsTypeReference')) {
|
|
345
|
-
const finalTypeName = extractTypeName(typeAnn);
|
|
346
|
-
if (finalTypeName === 'TFunction') {
|
|
347
|
-
// support multiple AST shapes for type parameters:
|
|
348
|
-
// - typeAnn.typeParameters?.params?.[0]
|
|
349
|
-
// - typeAnn.typeArguments?.params?.[0]
|
|
350
|
-
// - typeAnn.typeParams?.[0] / typeAnn.params?.[0]
|
|
351
|
-
const candidates = [
|
|
352
|
-
typeAnn.typeParameters?.params?.[0],
|
|
353
|
-
typeAnn.typeParameters?.[0],
|
|
354
|
-
typeAnn.typeArguments?.params?.[0],
|
|
355
|
-
typeAnn.typeArguments?.[0],
|
|
356
|
-
typeAnn.typeParams?.params?.[0],
|
|
357
|
-
typeAnn.typeParams?.[0],
|
|
358
|
-
typeAnn.params?.[0],
|
|
359
|
-
typeAnn.args?.[0],
|
|
360
|
-
typeAnn.typeParameters, // fallback if it's directly the literal
|
|
361
|
-
typeAnn.typeArguments,
|
|
362
|
-
typeAnn.typeParams,
|
|
363
|
-
];
|
|
364
|
-
let tp;
|
|
365
|
-
for (const c of candidates) {
|
|
366
|
-
if (c) {
|
|
367
|
-
tp = c;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
const ns = extractStringLiteralValue(tp);
|
|
372
|
-
// Extract the second type parameter for KPrefix
|
|
373
|
-
// We need to find the second element from the same type parameter list
|
|
374
|
-
const typeParams = typeAnn.typeParameters?.params ??
|
|
375
|
-
typeAnn.typeArguments?.params ??
|
|
376
|
-
typeAnn.typeParams?.params ??
|
|
377
|
-
undefined;
|
|
378
|
-
let kpFromType;
|
|
379
|
-
if (typeParams && typeParams.length >= 2) {
|
|
380
|
-
kpFromType = extractStringLiteralValue(typeParams[1]);
|
|
381
|
-
}
|
|
382
|
-
if (ns || kpFromType) {
|
|
383
|
-
this.scopeManager.setVarInScope(paramKey, {
|
|
384
|
-
defaultNs: ns,
|
|
385
|
-
keyPrefix: kpFromType // honour TFunction<Ns, KPrefix>
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
295
|
+
this.bindTFunctionParam(paramKey, typeAnn);
|
|
390
296
|
// Capture parameter type annotations as temporary variables in the
|
|
391
297
|
// expression resolver so that dynamic bracket expressions like
|
|
392
298
|
// `t(($) => $.table.columns[field])` can resolve `field` to its
|
|
@@ -648,6 +554,134 @@ class ASTVisitors {
|
|
|
648
554
|
this.scopeManager.exitClassScope();
|
|
649
555
|
}
|
|
650
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* If `typeAnn` is a `TFunction<Ns, KPrefix>` type reference, register
|
|
559
|
+
* `paramKey` in the current scope with that namespace / keyPrefix.
|
|
560
|
+
*/
|
|
561
|
+
bindTFunctionParam(paramKey, typeAnn) {
|
|
562
|
+
// Small helpers to robustly extract the referenced type name and literal string
|
|
563
|
+
const extractTypeName = (ta) => {
|
|
564
|
+
if (!ta)
|
|
565
|
+
return undefined;
|
|
566
|
+
// Identifier style: { type: 'Identifier', value: 'TFunction' } OR { name: 'TFunction' }
|
|
567
|
+
if (ta.typeName && (ta.typeName.type === 'Identifier'))
|
|
568
|
+
return ta.typeName.value ?? ta.typeName.name;
|
|
569
|
+
if (ta.typeName && ta.typeName.type === 'TsQualifiedName') {
|
|
570
|
+
// Qualified like Foo.TFunction -> try right side
|
|
571
|
+
const right = (ta.typeName.right ?? ta.typeName);
|
|
572
|
+
return right?.value ?? right?.name;
|
|
573
|
+
}
|
|
574
|
+
if (ta.typeName && typeof ta.typeName === 'string')
|
|
575
|
+
return ta.typeName;
|
|
576
|
+
if (ta.type === 'Identifier')
|
|
577
|
+
return ta.value ?? ta.name;
|
|
578
|
+
if (ta.id)
|
|
579
|
+
return ta.id?.value ?? ta.id?.name ?? ta.id;
|
|
580
|
+
return undefined;
|
|
581
|
+
};
|
|
582
|
+
const extractStringLiteralValue = (node) => {
|
|
583
|
+
if (!node)
|
|
584
|
+
return undefined;
|
|
585
|
+
// Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
|
|
586
|
+
if (node?.type === 'TsTypeQuery') {
|
|
587
|
+
const name = node.exprName?.value ?? node.exprName?.name;
|
|
588
|
+
if (name)
|
|
589
|
+
return this.scopeManager.resolveSimpleStringIdentifier(name);
|
|
590
|
+
}
|
|
591
|
+
// shapes: TsLiteralType -> { literal: { type: 'StringLiteral', value: 'x' } }
|
|
592
|
+
if (node.type === 'TsLiteralType' && node.literal)
|
|
593
|
+
return node.literal.value ?? node.literal.raw;
|
|
594
|
+
if (node.type === 'StringLiteral' || node.type === 'Str' || node.type === 'Literal')
|
|
595
|
+
return node.value ?? node.raw ?? node.value;
|
|
596
|
+
if (node.literal && (node.literal.type === 'StringLiteral' || node.literal.type === 'Str'))
|
|
597
|
+
return node.literal.value;
|
|
598
|
+
// some SWC builds put the string directly on .value
|
|
599
|
+
if (typeof node.value === 'string')
|
|
600
|
+
return node.value;
|
|
601
|
+
// handle wrapped parameter like { params: [ ... ] } where a literal might be one level deeper
|
|
602
|
+
if (node.params && Array.isArray(node.params) && node.params[0])
|
|
603
|
+
return extractStringLiteralValue(node.params[0]);
|
|
604
|
+
if (node.typeArguments && Array.isArray(node.typeArguments) && node.typeArguments[0])
|
|
605
|
+
return extractStringLiteralValue(node.typeArguments[0]);
|
|
606
|
+
if (node.typeParameters && Array.isArray(node.typeParameters) && node.typeParameters[0])
|
|
607
|
+
return extractStringLiteralValue(node.typeParameters[0]);
|
|
608
|
+
if (node.typeParams && Array.isArray(node.typeParams) && node.typeParams[0])
|
|
609
|
+
return extractStringLiteralValue(node.typeParams[0]);
|
|
610
|
+
return undefined;
|
|
611
|
+
};
|
|
612
|
+
// Detect TsTypeReference like: TFunction<"my-custom-namespace">
|
|
613
|
+
if (typeAnn && (typeAnn.type === 'TsTypeReference' || typeAnn.type === 'TsTypeRef' || typeAnn.type === 'TsTypeReference')) {
|
|
614
|
+
const finalTypeName = extractTypeName(typeAnn);
|
|
615
|
+
if (finalTypeName === 'TFunction') {
|
|
616
|
+
// support multiple AST shapes for type parameters:
|
|
617
|
+
// - typeAnn.typeParameters?.params?.[0]
|
|
618
|
+
// - typeAnn.typeArguments?.params?.[0]
|
|
619
|
+
// - typeAnn.typeParams?.[0] / typeAnn.params?.[0]
|
|
620
|
+
const candidates = [
|
|
621
|
+
typeAnn.typeParameters?.params?.[0],
|
|
622
|
+
typeAnn.typeParameters?.[0],
|
|
623
|
+
typeAnn.typeArguments?.params?.[0],
|
|
624
|
+
typeAnn.typeArguments?.[0],
|
|
625
|
+
typeAnn.typeParams?.params?.[0],
|
|
626
|
+
typeAnn.typeParams?.[0],
|
|
627
|
+
typeAnn.params?.[0],
|
|
628
|
+
typeAnn.args?.[0],
|
|
629
|
+
typeAnn.typeParameters, // fallback if it's directly the literal
|
|
630
|
+
typeAnn.typeArguments,
|
|
631
|
+
typeAnn.typeParams,
|
|
632
|
+
];
|
|
633
|
+
let tp;
|
|
634
|
+
for (const c of candidates) {
|
|
635
|
+
if (c) {
|
|
636
|
+
tp = c;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
const ns = extractStringLiteralValue(tp);
|
|
641
|
+
// Extract the second type parameter for KPrefix
|
|
642
|
+
// We need to find the second element from the same type parameter list
|
|
643
|
+
const typeParams = typeAnn.typeParameters?.params ??
|
|
644
|
+
typeAnn.typeArguments?.params ??
|
|
645
|
+
typeAnn.typeParams?.params ??
|
|
646
|
+
undefined;
|
|
647
|
+
let kpFromType;
|
|
648
|
+
if (typeParams && typeParams.length >= 2) {
|
|
649
|
+
kpFromType = extractStringLiteralValue(typeParams[1]);
|
|
650
|
+
}
|
|
651
|
+
if (ns || kpFromType) {
|
|
652
|
+
this.scopeManager.setVarInScope(paramKey, {
|
|
653
|
+
defaultNs: ns,
|
|
654
|
+
keyPrefix: kpFromType // honour TFunction<Ns, KPrefix>
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Find the raw type node of a named member on an object-shaped type
|
|
662
|
+
* annotation (inline `{ t: TFunction<'ns'> }` or a local interface / type
|
|
663
|
+
* alias name).
|
|
664
|
+
*/
|
|
665
|
+
getMemberTypeNode(tsType, memberName) {
|
|
666
|
+
if (!tsType)
|
|
667
|
+
return undefined;
|
|
668
|
+
let members;
|
|
669
|
+
if (tsType.type === 'TsTypeLiteral')
|
|
670
|
+
members = tsType.members;
|
|
671
|
+
else if (tsType.type === 'TsTypeReference' && tsType.typeName?.type === 'Identifier') {
|
|
672
|
+
members = this.expressionResolver.getObjectTypeMembersRaw(tsType.typeName.value);
|
|
673
|
+
}
|
|
674
|
+
if (!Array.isArray(members))
|
|
675
|
+
return undefined;
|
|
676
|
+
for (const m of members) {
|
|
677
|
+
if (m?.type !== 'TsPropertySignature')
|
|
678
|
+
continue;
|
|
679
|
+
const name = m.key?.type === 'Identifier' || m.key?.type === 'StringLiteral' ? m.key.value : undefined;
|
|
680
|
+
if (name === memberName)
|
|
681
|
+
return m.typeAnnotation?.typeAnnotation ?? m.typeAnnotation;
|
|
682
|
+
}
|
|
683
|
+
return undefined;
|
|
684
|
+
}
|
|
651
685
|
/**
|
|
652
686
|
* If `node` is a call like `ARRAY.map(param => ...)` where ARRAY is a known
|
|
653
687
|
* string-array constant, returns the callback's first parameter name and the
|
|
@@ -674,8 +674,9 @@ class CallExpressionHandler {
|
|
|
674
674
|
extractKeysFromSelector(node) {
|
|
675
675
|
let body = node.body;
|
|
676
676
|
// Handle block bodies, e.g., $ => { return $.key; }
|
|
677
|
-
|
|
678
|
-
|
|
677
|
+
// swc >=1.16 types function bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
678
|
+
if (body.type === 'BlockStatement' || body.type === 'FunctionBody') {
|
|
679
|
+
const returnStmt = body.stmts.find((s) => s.type === 'ReturnStatement');
|
|
679
680
|
if (returnStmt?.type === 'ReturnStatement' && returnStmt.argument) {
|
|
680
681
|
body = returnStmt.argument;
|
|
681
682
|
}
|
|
@@ -28,6 +28,8 @@ class ExpressionResolver {
|
|
|
28
28
|
// type aliases. Maps typeName -> { memberName: possible string values }.
|
|
29
29
|
// e.g. `interface IProps { size: ChangeType }` -> { IProps: { size: ['all','next'] } }
|
|
30
30
|
objectTypeTable = new Map();
|
|
31
|
+
// Raw TS member nodes of local interfaces / object type aliases, keyed by type name.
|
|
32
|
+
objectTypeMembersRaw = new Map();
|
|
31
33
|
// Temporary per-scope bindings for identifiers holding an object-shaped type,
|
|
32
34
|
// e.g. `function f(props: IProps)` -> { props: { size: ['all','next'] } }.
|
|
33
35
|
temporaryObjectVariables = new Map();
|
|
@@ -234,6 +236,7 @@ class ExpressionResolver {
|
|
|
234
236
|
return;
|
|
235
237
|
// `type IProps = { size: ChangeType }` — object shape, not a string union.
|
|
236
238
|
if (tsType.type === 'TsTypeLiteral') {
|
|
239
|
+
this.objectTypeMembersRaw.set(name, tsType.members);
|
|
237
240
|
const members = this.collectObjectTypeMembers(tsType.members);
|
|
238
241
|
if (members)
|
|
239
242
|
this.objectTypeTable.set(name, members);
|
|
@@ -262,6 +265,8 @@ class ExpressionResolver {
|
|
|
262
265
|
const name = node?.id?.type === 'Identifier' ? node.id.value : undefined;
|
|
263
266
|
if (!name)
|
|
264
267
|
return;
|
|
268
|
+
if (Array.isArray(node?.body?.body))
|
|
269
|
+
this.objectTypeMembersRaw.set(name, node.body.body);
|
|
265
270
|
const members = this.collectObjectTypeMembers(node?.body?.body);
|
|
266
271
|
if (members)
|
|
267
272
|
this.objectTypeTable.set(name, members);
|
|
@@ -298,6 +303,9 @@ class ExpressionResolver {
|
|
|
298
303
|
* Resolve a type annotation that refers to an object shape (interface, object
|
|
299
304
|
* type alias, or inline type literal) to its member → string values map.
|
|
300
305
|
*/
|
|
306
|
+
getObjectTypeMembersRaw(name) {
|
|
307
|
+
return this.objectTypeMembersRaw.get(name);
|
|
308
|
+
}
|
|
301
309
|
resolveTypeMembers(tsType) {
|
|
302
310
|
try {
|
|
303
311
|
if (!tsType)
|
|
@@ -445,9 +453,10 @@ class ExpressionResolver {
|
|
|
445
453
|
}
|
|
446
454
|
}
|
|
447
455
|
};
|
|
448
|
-
// Arrow functions with an expression body (no
|
|
449
|
-
// have their return expression directly as `body`.
|
|
450
|
-
|
|
456
|
+
// Arrow functions with an expression body (no block) — `() => expr` —
|
|
457
|
+
// have their return expression directly as `body`. swc >=1.16 types function
|
|
458
|
+
// bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
459
|
+
if (body.type !== 'BlockStatement' && body.type !== 'FunctionBody') {
|
|
451
460
|
const vals = this.resolvePossibleStringValuesFromExpression(body);
|
|
452
461
|
if (vals.length > 0)
|
|
453
462
|
return Array.from(new Set(vals));
|
|
@@ -609,7 +618,7 @@ class ExpressionResolver {
|
|
|
609
618
|
try {
|
|
610
619
|
let body = expression.body;
|
|
611
620
|
// Handle block body with return statement
|
|
612
|
-
if (body.type === 'BlockStatement') {
|
|
621
|
+
if (body.type === 'BlockStatement' || body.type === 'FunctionBody') {
|
|
613
622
|
const returnStmt = body.stmts.find((s) => s.type === 'ReturnStatement');
|
|
614
623
|
if (returnStmt?.type === 'ReturnStatement' && returnStmt.argument) {
|
|
615
624
|
body = returnStmt.argument;
|
|
@@ -548,6 +548,12 @@ class ScopeManager {
|
|
|
548
548
|
return { defaultNs: this.resolveSimpleStringIdentifier(nsNode.value) };
|
|
549
549
|
if (nsNode.type === 'MemberExpression')
|
|
550
550
|
return { defaultNs: this.resolveSimpleMemberExpression(nsNode) };
|
|
551
|
+
// `useTranslation(ns ?? 'fallback')` / `useTranslation(ns || 'fallback')`:
|
|
552
|
+
// prefer a statically resolvable left side, otherwise use the fallback.
|
|
553
|
+
if (nsNode.type === 'BinaryExpression' && (nsNode.operator === '??' || nsNode.operator === '||')) {
|
|
554
|
+
const left = this.resolveNsArg(nsNode.left);
|
|
555
|
+
return left.defaultNs !== undefined ? left : this.resolveNsArg(nsNode.right);
|
|
556
|
+
}
|
|
551
557
|
if (nsNode.type === 'ArrayExpression') {
|
|
552
558
|
const namespaces = [];
|
|
553
559
|
for (const el of nsNode.elements) {
|
|
@@ -400,7 +400,7 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
400
400
|
// FunctionDeclaration with uppercase name
|
|
401
401
|
if (node.type === 'FunctionDeclaration' && node.identifier?.value && /^[A-Z]/.test(node.identifier.value)) {
|
|
402
402
|
const body = node.body;
|
|
403
|
-
if (body
|
|
403
|
+
if (isBlockBody(body) && body.span) {
|
|
404
404
|
components.push({
|
|
405
405
|
name: node.identifier.value,
|
|
406
406
|
bodyStart: body.span.start,
|
|
@@ -416,7 +416,7 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
416
416
|
// VariableDeclarator path (e.g. `const Foo = function Foo() {}`).
|
|
417
417
|
if (node.type === 'FunctionExpression' && node.identifier?.value && /^[A-Z]/.test(node.identifier.value)) {
|
|
418
418
|
const body = node.body;
|
|
419
|
-
if (body
|
|
419
|
+
if (isBlockBody(body) && body.span) {
|
|
420
420
|
const alreadyRegistered = components.some(c => c.bodyStart === body.span.start && c.bodyEnd === body.span.end);
|
|
421
421
|
if (!alreadyRegistered) {
|
|
422
422
|
components.push({
|
|
@@ -468,9 +468,15 @@ function detectComponentBoundaries(node, content, components) {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* swc >=1.16 types function bodies as 'FunctionBody'; older versions used 'BlockStatement'.
|
|
473
|
+
*/
|
|
474
|
+
function isBlockBody(body) {
|
|
475
|
+
return body?.type === 'BlockStatement' || body?.type === 'FunctionBody';
|
|
476
|
+
}
|
|
471
477
|
/**
|
|
472
478
|
* Helper: extracts a ComponentBoundary from an ArrowFunctionExpression or FunctionExpression
|
|
473
|
-
* that has a
|
|
479
|
+
* that has a block body.
|
|
474
480
|
*/
|
|
475
481
|
function addComponentFromFunctionNode(name, fnNode, content, components) {
|
|
476
482
|
const body = fnNode.body;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,38 +55,38 @@
|
|
|
55
55
|
"@rollup/plugin-replace": "^6.0.3",
|
|
56
56
|
"@rollup/plugin-terser": "^1.0.0",
|
|
57
57
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
58
|
-
"@types/inquirer": "^9.0.
|
|
59
|
-
"@types/node": "^
|
|
60
|
-
"@types/react": "^19.2.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@vitest/coverage-v8": "^4.1.
|
|
58
|
+
"@types/inquirer": "^9.0.10",
|
|
59
|
+
"@types/node": "^26.2.0",
|
|
60
|
+
"@types/react": "^19.2.18",
|
|
61
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
62
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
63
63
|
"eslint": "^9.39.4",
|
|
64
64
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
65
65
|
"eslint-plugin-import": "^2.32.0",
|
|
66
|
-
"memfs": "^4.
|
|
66
|
+
"memfs": "^4.68.1",
|
|
67
67
|
"neostandard": "^0.13.0",
|
|
68
|
-
"rollup": "^4.
|
|
68
|
+
"rollup": "^4.62.4",
|
|
69
69
|
"typescript": "^6.0.3",
|
|
70
|
-
"unplugin-swc": "^1.5.
|
|
71
|
-
"vitest": "^4.1.
|
|
70
|
+
"unplugin-swc": "^1.5.11",
|
|
71
|
+
"vitest": "^4.1.10"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@croct/json5-parser": "^0.2.2",
|
|
75
|
-
"@swc/core": "^1.
|
|
75
|
+
"@swc/core": "^1.16.0",
|
|
76
76
|
"chokidar": "^5.0.0",
|
|
77
|
-
"commander": "^
|
|
78
|
-
"execa": "^
|
|
77
|
+
"commander": "^15.0.0",
|
|
78
|
+
"execa": "^10.0.1",
|
|
79
79
|
"glob": "^13.0.6",
|
|
80
|
-
"i18next": "^26.3.
|
|
80
|
+
"i18next": "^26.3.6",
|
|
81
81
|
"i18next-resources-for-ts": "^2.1.0",
|
|
82
82
|
"inquirer": "^14.0.2",
|
|
83
83
|
"jiti": "^2.7.0",
|
|
84
84
|
"jsonc-parser": "^3.3.1",
|
|
85
|
-
"magic-string": "^
|
|
86
|
-
"minimatch": "^10.2.
|
|
87
|
-
"ora": "^9.4.
|
|
88
|
-
"react": "^19.2.
|
|
89
|
-
"react-i18next": "^17.0.
|
|
85
|
+
"magic-string": "^1.2.0",
|
|
86
|
+
"minimatch": "^10.2.6",
|
|
87
|
+
"ora": "^9.4.1",
|
|
88
|
+
"react": "^19.2.8",
|
|
89
|
+
"react-i18next": "^17.0.11",
|
|
90
90
|
"yaml": "^2.9.0"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -85,6 +85,17 @@ export declare class ASTVisitors {
|
|
|
85
85
|
* @private
|
|
86
86
|
*/
|
|
87
87
|
private walk;
|
|
88
|
+
/**
|
|
89
|
+
* If `typeAnn` is a `TFunction<Ns, KPrefix>` type reference, register
|
|
90
|
+
* `paramKey` in the current scope with that namespace / keyPrefix.
|
|
91
|
+
*/
|
|
92
|
+
private bindTFunctionParam;
|
|
93
|
+
/**
|
|
94
|
+
* Find the raw type node of a named member on an object-shaped type
|
|
95
|
+
* annotation (inline `{ t: TFunction<'ns'> }` or a local interface / type
|
|
96
|
+
* alias name).
|
|
97
|
+
*/
|
|
98
|
+
private getMemberTypeNode;
|
|
88
99
|
/**
|
|
89
100
|
* If `node` is a call like `ARRAY.map(param => ...)` where ARRAY is a known
|
|
90
101
|
* string-array constant, returns the callback's first parameter name and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-visitors.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/ast-visitors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAItE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,W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c,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxD;;;;;;OAMG;IACI,cAAc,IAAK,MAAM;IAIhC;;OAEG;IACI,cAAc,IAAK,MAAM;CAGjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-expression-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/call-expression-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,WAAW,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAc7D,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,kBAAkB,CAAoB;IACvC,UAAU,cAAoB;IACrC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,iBAAiB,CAAsC;gBAG7D,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,MAAM,MAAM,EAC5B,cAAc,EAAE,MAAM,MAAM,EAC5B,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAA2B;IAW3E;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI;IA8ZxG;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAsDpC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,sBAAsB;IA2B9B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,uBAAuB;
|
|
1
|
+
{"version":3,"file":"call-expression-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/call-expression-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,WAAW,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAc7D,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,kBAAkB,CAAoB;IACvC,UAAU,cAAoB;IACrC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,iBAAiB,CAAsC;gBAG7D,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,MAAM,MAAM,EAC5B,cAAc,EAAE,MAAM,MAAM,EAC5B,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAA2B;IAW3E;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI;IA8ZxG;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAsDpC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,sBAAsB;IA2B9B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;;;;;;;OAQG;IACH,OAAO,CAAC,iCAAiC;IAwFzC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB;IAyMxB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|
|
@@ -10,6 +10,7 @@ export declare class ExpressionResolver {
|
|
|
10
10
|
private sharedFunctionReturnTable;
|
|
11
11
|
private temporaryVariables;
|
|
12
12
|
private objectTypeTable;
|
|
13
|
+
private objectTypeMembersRaw;
|
|
13
14
|
private temporaryObjectVariables;
|
|
14
15
|
private arrayElementMembers;
|
|
15
16
|
constructor(hooks: ASTVisitorHooks);
|
|
@@ -55,6 +56,7 @@ export declare class ExpressionResolver {
|
|
|
55
56
|
* Resolve a type annotation that refers to an object shape (interface, object
|
|
56
57
|
* type alias, or inline type literal) to its member → string values map.
|
|
57
58
|
*/
|
|
59
|
+
getObjectTypeMembersRaw(name: string): any[] | undefined;
|
|
58
60
|
resolveTypeMembers(tsType: any): Record<string, string[]> | undefined;
|
|
59
61
|
/**
|
|
60
62
|
* Resolve a type annotation for an array of an object shape (`IProps[]`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-resolver.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/expression-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkD,MAAM,WAAW,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAiB;IAK9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;IACH,OAAO,CAAC,8BAA8B;IA0EtC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB;IAiBjC;;;;;;OAMG;IACH;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,gBAAgB;IAexB;;;;;;;;;OASG;IACH,OAAO,CAAC,qCAAqC;IAqB7C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAgBnC;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAyBrC;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAwBlF;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;CA+DrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/instrumenter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAA6B,sBAAsB,EAAiE,MAAM,gBAAgB,CAAA;AAU1N;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CA+NjC;
|
|
1
|
+
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/instrumenter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAA6B,sBAAsB,EAAiE,MAAM,gBAAgB,CAAA;AAU1N;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,GAAE,MAA4B,GACnC,OAAO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