i18next-cli 1.48.0 → 1.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/parsers/scope-manager.js +9 -2
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/parsers/scope-manager.js +9 -2
- package/package.json +1 -1
- package/types/extractor/parsers/scope-manager.d.ts +2 -0
- package/types/extractor/parsers/scope-manager.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const program = new commander.Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name('i18next-cli')
|
|
33
33
|
.description('A unified, high-performance i18next CLI.')
|
|
34
|
-
.version('1.48.
|
|
34
|
+
.version('1.48.1'); // 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
|
|
@@ -10,6 +10,10 @@ class ScopeManager {
|
|
|
10
10
|
simpleConstants = new Map();
|
|
11
11
|
// Track simple local constant objects with string literal property values
|
|
12
12
|
simpleConstantObjects = new Map();
|
|
13
|
+
// Shared (cross-file) tables so that exported constants from one file can be
|
|
14
|
+
// resolved when imported in another. These are NOT cleared by reset().
|
|
15
|
+
sharedConstants = new Map();
|
|
16
|
+
sharedConstantObjects = new Map();
|
|
13
17
|
constructor(config) {
|
|
14
18
|
this.config = config;
|
|
15
19
|
}
|
|
@@ -135,7 +139,7 @@ class ScopeManager {
|
|
|
135
139
|
* Resolve simple identifier declared in-file to its string literal value, if known.
|
|
136
140
|
*/
|
|
137
141
|
resolveSimpleStringIdentifier(name) {
|
|
138
|
-
return this.simpleConstants.get(name);
|
|
142
|
+
return this.simpleConstants.get(name) ?? this.sharedConstants.get(name);
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
141
145
|
* Resolve a MemberExpression node (e.g., `ns.custom`) to its string value
|
|
@@ -145,7 +149,7 @@ class ScopeManager {
|
|
|
145
149
|
if (node.object.type !== 'Identifier') {
|
|
146
150
|
return undefined;
|
|
147
151
|
}
|
|
148
|
-
const map = this.simpleConstantObjects.get(node.object.value);
|
|
152
|
+
const map = this.simpleConstantObjects.get(node.object.value) ?? this.sharedConstantObjects.get(node.object.value);
|
|
149
153
|
if (!map) {
|
|
150
154
|
return undefined;
|
|
151
155
|
}
|
|
@@ -180,6 +184,7 @@ class ScopeManager {
|
|
|
180
184
|
const unwrapped = ScopeManager.unwrapTsExpression(init);
|
|
181
185
|
if (unwrapped?.type === 'StringLiteral') {
|
|
182
186
|
this.simpleConstants.set(node.id.value, unwrapped.value);
|
|
187
|
+
this.sharedConstants.set(node.id.value, unwrapped.value);
|
|
183
188
|
}
|
|
184
189
|
else if (unwrapped?.type === 'ObjectExpression' && Array.isArray(unwrapped.properties)) {
|
|
185
190
|
const map = {};
|
|
@@ -202,12 +207,14 @@ class ScopeManager {
|
|
|
202
207
|
}
|
|
203
208
|
if (Object.keys(map).length > 0) {
|
|
204
209
|
this.simpleConstantObjects.set(node.id.value, map);
|
|
210
|
+
this.sharedConstantObjects.set(node.id.value, map);
|
|
205
211
|
}
|
|
206
212
|
}
|
|
207
213
|
else {
|
|
208
214
|
const fromType = ScopeManager.extractStringFromTypeAnnotation(node);
|
|
209
215
|
if (fromType !== undefined) {
|
|
210
216
|
this.simpleConstants.set(node.id.value, fromType);
|
|
217
|
+
this.sharedConstants.set(node.id.value, fromType);
|
|
211
218
|
}
|
|
212
219
|
}
|
|
213
220
|
// continue processing; still may be a useTranslation/getFixedT call below
|
package/dist/esm/cli.js
CHANGED
|
@@ -29,7 +29,7 @@ const program = new Command();
|
|
|
29
29
|
program
|
|
30
30
|
.name('i18next-cli')
|
|
31
31
|
.description('A unified, high-performance i18next CLI.')
|
|
32
|
-
.version('1.48.
|
|
32
|
+
.version('1.48.1'); // This string is replaced with the actual version at build time by rollup
|
|
33
33
|
// new: global config override option
|
|
34
34
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
35
35
|
program
|
|
@@ -8,6 +8,10 @@ class ScopeManager {
|
|
|
8
8
|
simpleConstants = new Map();
|
|
9
9
|
// Track simple local constant objects with string literal property values
|
|
10
10
|
simpleConstantObjects = new Map();
|
|
11
|
+
// Shared (cross-file) tables so that exported constants from one file can be
|
|
12
|
+
// resolved when imported in another. These are NOT cleared by reset().
|
|
13
|
+
sharedConstants = new Map();
|
|
14
|
+
sharedConstantObjects = new Map();
|
|
11
15
|
constructor(config) {
|
|
12
16
|
this.config = config;
|
|
13
17
|
}
|
|
@@ -133,7 +137,7 @@ class ScopeManager {
|
|
|
133
137
|
* Resolve simple identifier declared in-file to its string literal value, if known.
|
|
134
138
|
*/
|
|
135
139
|
resolveSimpleStringIdentifier(name) {
|
|
136
|
-
return this.simpleConstants.get(name);
|
|
140
|
+
return this.simpleConstants.get(name) ?? this.sharedConstants.get(name);
|
|
137
141
|
}
|
|
138
142
|
/**
|
|
139
143
|
* Resolve a MemberExpression node (e.g., `ns.custom`) to its string value
|
|
@@ -143,7 +147,7 @@ class ScopeManager {
|
|
|
143
147
|
if (node.object.type !== 'Identifier') {
|
|
144
148
|
return undefined;
|
|
145
149
|
}
|
|
146
|
-
const map = this.simpleConstantObjects.get(node.object.value);
|
|
150
|
+
const map = this.simpleConstantObjects.get(node.object.value) ?? this.sharedConstantObjects.get(node.object.value);
|
|
147
151
|
if (!map) {
|
|
148
152
|
return undefined;
|
|
149
153
|
}
|
|
@@ -178,6 +182,7 @@ class ScopeManager {
|
|
|
178
182
|
const unwrapped = ScopeManager.unwrapTsExpression(init);
|
|
179
183
|
if (unwrapped?.type === 'StringLiteral') {
|
|
180
184
|
this.simpleConstants.set(node.id.value, unwrapped.value);
|
|
185
|
+
this.sharedConstants.set(node.id.value, unwrapped.value);
|
|
181
186
|
}
|
|
182
187
|
else if (unwrapped?.type === 'ObjectExpression' && Array.isArray(unwrapped.properties)) {
|
|
183
188
|
const map = {};
|
|
@@ -200,12 +205,14 @@ class ScopeManager {
|
|
|
200
205
|
}
|
|
201
206
|
if (Object.keys(map).length > 0) {
|
|
202
207
|
this.simpleConstantObjects.set(node.id.value, map);
|
|
208
|
+
this.sharedConstantObjects.set(node.id.value, map);
|
|
203
209
|
}
|
|
204
210
|
}
|
|
205
211
|
else {
|
|
206
212
|
const fromType = ScopeManager.extractStringFromTypeAnnotation(node);
|
|
207
213
|
if (fromType !== undefined) {
|
|
208
214
|
this.simpleConstants.set(node.id.value, fromType);
|
|
215
|
+
this.sharedConstants.set(node.id.value, fromType);
|
|
209
216
|
}
|
|
210
217
|
}
|
|
211
218
|
// continue processing; still may be a useTranslation/getFixedT call below
|
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@ export declare class ScopeManager {
|
|
|
6
6
|
private scope;
|
|
7
7
|
private simpleConstants;
|
|
8
8
|
private simpleConstantObjects;
|
|
9
|
+
private sharedConstants;
|
|
10
|
+
private sharedConstantObjects;
|
|
9
11
|
constructor(config: Omit<I18nextToolkitConfig, 'plugins'>);
|
|
10
12
|
/**
|
|
11
13
|
* Recursively unwraps TypeScript type assertion wrappers to reach the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/scope-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,kBAAkB,EAMnB,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,SAAS,EAA4B,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG5F,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,KAAK,CAAqE;IAGlF,OAAO,CAAC,eAAe,CAAiC;IAGxD,OAAO,CAAC,qBAAqB,CAAiD;gBAEjE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IAI1D;;;OAGG;IACH,OAAO,CAAC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