i18next-cli 1.75.0 → 1.75.2
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 +2 -2
- package/dist/cjs/extractor/core/ast-visitors.js +7 -4
- package/dist/cjs/extractor/core/key-finder.js +8 -6
- package/dist/cjs/extractor/parsers/expression-resolver.js +202 -36
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/localize/localize.js +1 -1
- package/dist/esm/cli.js +2 -2
- package/dist/esm/extractor/core/ast-visitors.js +7 -4
- package/dist/esm/extractor/core/key-finder.js +2 -0
- package/dist/esm/extractor/parsers/expression-resolver.js +202 -36
- package/dist/esm/index.js +1 -1
- package/dist/esm/localize/localize.js +1 -1
- package/package.json +1 -1
- package/types/extractor/core/ast-visitors.d.ts.map +1 -1
- package/types/extractor/core/key-finder.d.ts.map +1 -1
- package/types/extractor/parsers/expression-resolver.d.ts +25 -0
- package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -9,8 +9,8 @@ var node_util = require('node:util');
|
|
|
9
9
|
var config = require('./config.js');
|
|
10
10
|
var heuristicConfig = require('./heuristic-config.js');
|
|
11
11
|
var extractor = require('./extractor/core/extractor.js');
|
|
12
|
-
require('node:module');
|
|
13
12
|
require('node:path');
|
|
13
|
+
require('node:module');
|
|
14
14
|
var nestedObject = require('./utils/nested-object.js');
|
|
15
15
|
require('node:fs/promises');
|
|
16
16
|
require('jiti');
|
|
@@ -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.75.
|
|
40
|
+
.version('1.75.2') // This string is replaced with the actual version at build time by rollup
|
|
41
41
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
42
42
|
// new: global config override option
|
|
43
43
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -172,8 +172,10 @@ class ASTVisitors {
|
|
|
172
172
|
this.expressionResolver.captureFunctionDeclaration(node);
|
|
173
173
|
break;
|
|
174
174
|
case 'ImportDeclaration':
|
|
175
|
+
case 'ExportNamedDeclaration':
|
|
175
176
|
// `import { X as Y }` → ExpressionResolver.sharedImportAliases, resolved
|
|
176
|
-
// once the pre-scan has seen every file
|
|
177
|
+
// once the pre-scan has seen every file; `import * as Types` / `export * as Types`
|
|
178
|
+
// → namespace names.
|
|
177
179
|
this.expressionResolver.captureImportDeclaration(node);
|
|
178
180
|
break;
|
|
179
181
|
}
|
|
@@ -824,8 +826,8 @@ class ASTVisitors {
|
|
|
824
826
|
let members;
|
|
825
827
|
if (tsType.type === 'TsTypeLiteral')
|
|
826
828
|
members = tsType.members;
|
|
827
|
-
else if (tsType.type === 'TsTypeReference' && tsType
|
|
828
|
-
members = this.expressionResolver.getObjectTypeMembersRaw(
|
|
829
|
+
else if (tsType.type === 'TsTypeReference' && this.expressionResolver.typeRefName(tsType)) {
|
|
830
|
+
members = this.expressionResolver.getObjectTypeMembersRaw(this.expressionResolver.typeRefName(tsType));
|
|
829
831
|
}
|
|
830
832
|
if (!Array.isArray(members))
|
|
831
833
|
return [];
|
|
@@ -877,7 +879,7 @@ class ASTVisitors {
|
|
|
877
879
|
(innerCallee.property.value === 'keys' || innerCallee.property.value === 'values')) {
|
|
878
880
|
const isKeys = innerCallee.property.value === 'keys';
|
|
879
881
|
// The single argument to Object.keys/values must be a known identifier
|
|
880
|
-
const mapArg = obj.arguments?.[0]?.expression;
|
|
882
|
+
const mapArg = this.expressionResolver.unwrapNamespace(obj.arguments?.[0]?.expression);
|
|
881
883
|
if (mapArg?.type === 'Identifier') {
|
|
882
884
|
const mapEntry = this.expressionResolver.getObjectMap(mapArg.value);
|
|
883
885
|
if (mapEntry) {
|
|
@@ -1051,6 +1053,7 @@ class ASTVisitors {
|
|
|
1051
1053
|
setCurrentFile(file, code) {
|
|
1052
1054
|
this.currentFile = file;
|
|
1053
1055
|
this.currentCode = code;
|
|
1056
|
+
this.expressionResolver.setCurrentFile(file);
|
|
1054
1057
|
}
|
|
1055
1058
|
/**
|
|
1056
1059
|
* Returns the currently set file path.
|
|
@@ -6,6 +6,7 @@ var logger = require('../../utils/logger.js');
|
|
|
6
6
|
var pluginManager = require('../plugin-manager.js');
|
|
7
7
|
var astVisitors = require('./ast-visitors.js');
|
|
8
8
|
var expressionResolver = require('../parsers/expression-resolver.js');
|
|
9
|
+
var config = require('../../config.js');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Main function for finding translation keys across all source files in a project.
|
|
@@ -35,10 +36,10 @@ var expressionResolver = require('../parsers/expression-resolver.js');
|
|
|
35
36
|
* console.log(`Found ${keys.size} unique translation keys`)
|
|
36
37
|
* ```
|
|
37
38
|
*/
|
|
38
|
-
async function findKeys(config, logger$1 = new logger.ConsoleLogger(), fileErrors) {
|
|
39
|
-
const { plugins: pluginsOrUndefined, ...otherConfig } = config;
|
|
39
|
+
async function findKeys(config$1, logger$1 = new logger.ConsoleLogger(), fileErrors) {
|
|
40
|
+
const { plugins: pluginsOrUndefined, ...otherConfig } = config$1;
|
|
40
41
|
const plugins = pluginsOrUndefined || [];
|
|
41
|
-
const sourceFiles = await processSourceFiles(config);
|
|
42
|
+
const sourceFiles = await processSourceFiles(config$1);
|
|
42
43
|
const allKeys = new Map();
|
|
43
44
|
// 1. Create the base context with config and logger.
|
|
44
45
|
const pluginContext = pluginManager.createPluginContext(allKeys, plugins, otherConfig, logger$1);
|
|
@@ -57,7 +58,7 @@ async function findKeys(config, logger$1 = new logger.ConsoleLogger(), fileError
|
|
|
57
58
|
resolvePossibleKeyStringValues: (expression) => {
|
|
58
59
|
return plugins.flatMap(plugin => {
|
|
59
60
|
try {
|
|
60
|
-
return plugin.extractKeysFromExpression?.(expression, config, logger$1) ?? [];
|
|
61
|
+
return plugin.extractKeysFromExpression?.(expression, config$1, logger$1) ?? [];
|
|
61
62
|
}
|
|
62
63
|
catch (err) {
|
|
63
64
|
logger$1.warn(`Plugin ${plugin.name} extractKeysFromExpression failed:`, err);
|
|
@@ -68,7 +69,7 @@ async function findKeys(config, logger$1 = new logger.ConsoleLogger(), fileError
|
|
|
68
69
|
resolvePossibleContextStringValues: (expression) => {
|
|
69
70
|
return plugins.flatMap(plugin => {
|
|
70
71
|
try {
|
|
71
|
-
return plugin.extractContextFromExpression?.(expression, config, logger$1) ?? [];
|
|
72
|
+
return plugin.extractContextFromExpression?.(expression, config$1, logger$1) ?? [];
|
|
72
73
|
}
|
|
73
74
|
catch (err) {
|
|
74
75
|
logger$1.warn(`Plugin ${plugin.name} extractContextFromExpression failed:`, err);
|
|
@@ -80,7 +81,8 @@ async function findKeys(config, logger$1 = new logger.ConsoleLogger(), fileError
|
|
|
80
81
|
// 3. Create the visitor instance, passing it the context.
|
|
81
82
|
// Use a shared ExpressionResolver so captured enums/objects in one file are available when resolving MemberExpressions
|
|
82
83
|
const sharedExpressionResolver = new expressionResolver.ExpressionResolver(hooks);
|
|
83
|
-
sharedExpressionResolver.maxMemberDepth = config.extract.maxTypeDepth ?? 5;
|
|
84
|
+
sharedExpressionResolver.maxMemberDepth = config$1.extract.maxTypeDepth ?? 5;
|
|
85
|
+
sharedExpressionResolver.pathAliases = await config.getTsConfigAliases();
|
|
84
86
|
const astVisitors$1 = new astVisitors.ASTVisitors(otherConfig, pluginContext, logger$1, hooks, sharedExpressionResolver);
|
|
85
87
|
// 4. "Wire up" the visitor's scope method to the context.
|
|
86
88
|
// This avoids a circular dependency while giving plugins access to the scope.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var node_path = require('node:path');
|
|
3
4
|
var astUtils = require('./ast-utils.js');
|
|
4
5
|
|
|
5
6
|
// Whether `next` holds everything `prev` does: every value of a list, every
|
|
@@ -61,6 +62,45 @@ const memberByKey = (members, key) => {
|
|
|
61
62
|
}
|
|
62
63
|
return index.get(key);
|
|
63
64
|
};
|
|
65
|
+
// `/src/api/github-api.ts`, `.d.ts`, or an import of `./github-api.js` -> `/src/api/github-api`
|
|
66
|
+
const moduleKey = (path) => path.replace(/(\.d)?\.[cm]?[jt]sx?$/, '');
|
|
67
|
+
/**
|
|
68
|
+
* A cross-file table keyed by declared name. Every entry is also kept under the module that
|
|
69
|
+
* declares it (`/src/api/github-api#components`), and a lookup made while a file is being read
|
|
70
|
+
* first tries where that file gets the name from: the module it imported it from, then its own
|
|
71
|
+
* declaration. The bare name, held by whichever file declared it last, is the fallback, so two
|
|
72
|
+
* generated clients that both declare `components` no longer overwrite each other (#306).
|
|
73
|
+
*/
|
|
74
|
+
class ModuleTable extends Map {
|
|
75
|
+
scope;
|
|
76
|
+
constructor(scope) {
|
|
77
|
+
super();
|
|
78
|
+
this.scope = scope;
|
|
79
|
+
}
|
|
80
|
+
get(name) {
|
|
81
|
+
for (const key of this.scope.keysOf(name)) {
|
|
82
|
+
const value = super.get(key);
|
|
83
|
+
if (value !== undefined)
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
return super.get(name);
|
|
87
|
+
}
|
|
88
|
+
has(name) {
|
|
89
|
+
return this.scope.keysOf(name).some(key => super.has(key)) || super.has(name);
|
|
90
|
+
}
|
|
91
|
+
set(name, value) {
|
|
92
|
+
const key = this.scope.declaringKey(name);
|
|
93
|
+
if (key)
|
|
94
|
+
super.set(key, value);
|
|
95
|
+
return super.set(name, value);
|
|
96
|
+
}
|
|
97
|
+
delete(name) {
|
|
98
|
+
const key = this.scope.declaringKey(name);
|
|
99
|
+
if (key)
|
|
100
|
+
super.delete(key);
|
|
101
|
+
return super.delete(name);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
64
104
|
// `T['a']` / `T[200]` -> 'a' / '200'
|
|
65
105
|
const indexedKey = (type) => type?.indexType?.type === 'TsLiteralType' ? literalKey(type.indexType.literal) : undefined;
|
|
66
106
|
// Whether replacing `prev` by `next` only adds to it.
|
|
@@ -93,30 +133,33 @@ class ExpressionResolver {
|
|
|
93
133
|
// - Record<string, string> (object of static string properties)
|
|
94
134
|
variableTable = new Map();
|
|
95
135
|
// Shared (cross-file) table for enums / exported object maps that should persist
|
|
96
|
-
sharedEnumTable = new
|
|
136
|
+
sharedEnumTable = new ModuleTable(this);
|
|
97
137
|
// Per-file table for type aliases: Maps typeName -> string[]
|
|
98
138
|
// e.g. `type ChangeType = 'all' | 'next' | 'this'` -> { ChangeType: ['all', 'next', 'this'] }
|
|
99
139
|
typeAliasTable = new Map();
|
|
100
140
|
// Shared (cross-file) table for string-array constants (e.g. `as const` arrays).
|
|
101
141
|
// Persists across resetFileSymbols() so exported arrays are visible to importers.
|
|
102
|
-
sharedVariableTable = new
|
|
142
|
+
sharedVariableTable = new ModuleTable(this);
|
|
143
|
+
// Shared (cross-file) table for as-const object maps, `export const LABELS = { … } as const`,
|
|
144
|
+
// so `LABELS.save` and `Object.keys(LABELS)` resolve in importing files.
|
|
145
|
+
sharedObjectMapTable = new ModuleTable(this);
|
|
103
146
|
// Shared (cross-file) table for type aliases — populated alongside typeAliasTable.
|
|
104
147
|
// Persists across resetFileSymbols() so exported type aliases are visible to importers.
|
|
105
|
-
sharedTypeAliasTable = new
|
|
148
|
+
sharedTypeAliasTable = new ModuleTable(this);
|
|
106
149
|
// Shared (cross-file) table for function return-value sets. Populated from
|
|
107
150
|
// both explicit return-type annotations and body-inferred return values so
|
|
108
151
|
// that `t(fn())` / `const x = fn(); t(\`...${x}...\`)` work across files.
|
|
109
152
|
// Persists across resetFileSymbols() just like the other shared tables.
|
|
110
|
-
sharedFunctionReturnTable = new
|
|
153
|
+
sharedFunctionReturnTable = new ModuleTable(this);
|
|
111
154
|
// Temporary per-scope variable overrides, used to inject .map() / .forEach()
|
|
112
155
|
// callback parameters while the callback body is being walked.
|
|
113
156
|
temporaryVariables = new Map();
|
|
114
157
|
// Shared (cross-file) table for object-shaped types: interfaces and object
|
|
115
158
|
// type aliases. Maps typeName -> { memberName: possible string values }.
|
|
116
159
|
// e.g. `interface IProps { size: ChangeType }` -> { IProps: { size: ['all','next'] } }
|
|
117
|
-
objectTypeTable = new
|
|
160
|
+
objectTypeTable = new ModuleTable(this);
|
|
118
161
|
// Raw TS member nodes of local interfaces / object type aliases, keyed by type name.
|
|
119
|
-
objectTypeMembersRaw = new
|
|
162
|
+
objectTypeMembersRaw = new ModuleTable(this);
|
|
120
163
|
// Temporary per-scope bindings for identifiers holding an object-shaped type,
|
|
121
164
|
// e.g. `function f(props: IProps)` -> { props: { size: ['all','next'] } }.
|
|
122
165
|
temporaryObjectVariables = new Map();
|
|
@@ -129,13 +172,16 @@ class ExpressionResolver {
|
|
|
129
172
|
// Every other table is keyed by the *declared* name, so without this a type
|
|
130
173
|
// referenced through an alias resolves to nothing.
|
|
131
174
|
sharedImportAliases = new Map();
|
|
175
|
+
// Shared (cross-file) namespace names: `import * as Types`, `export * as Types`. Their
|
|
176
|
+
// members are declared under their own names, so `Types.COLORS` resolves as `COLORS`.
|
|
177
|
+
sharedNamespaceNames = new Set();
|
|
132
178
|
// Type parameters of generic object types, e.g. `type Base<T> = { type: T }`.
|
|
133
|
-
objectTypeParams = new
|
|
179
|
+
objectTypeParams = new ModuleTable(this);
|
|
134
180
|
// Values bound to type parameters while a generic type is being resolved.
|
|
135
181
|
typeParamBindings = new Map();
|
|
136
182
|
// Shared (cross-file) member maps of functions returning an object type,
|
|
137
183
|
// e.g. `const getAnimal = (): Animal => …` -> { getAnimal: { type: ['DUCK', 'DOG'] } }
|
|
138
|
-
sharedFunctionReturnMembers = new
|
|
184
|
+
sharedFunctionReturnMembers = new ModuleTable(this);
|
|
139
185
|
// Per-file identifiers holding an object type, from their annotation or from the
|
|
140
186
|
// function they were initialised by: `const animal = getAnimal()` -> { animal: { type: [...] } }
|
|
141
187
|
objectVariables = new Map();
|
|
@@ -150,9 +196,88 @@ class ExpressionResolver {
|
|
|
150
196
|
// this many levels below a declared or indexed type, so recursive types stay small
|
|
151
197
|
// (`extract.maxTypeDepth`).
|
|
152
198
|
maxMemberDepth = 5;
|
|
199
|
+
// The module being read (its path without extension), and where each module gets its
|
|
200
|
+
// names from (see ModuleTable)
|
|
201
|
+
currentModule;
|
|
202
|
+
knownModules = new Set();
|
|
203
|
+
// module -> local name -> { from: the import's resolved path, name: the declared name }
|
|
204
|
+
fileImports = new Map();
|
|
205
|
+
// module -> namespace import's local name -> the import's resolved path
|
|
206
|
+
fileNamespaces = new Map();
|
|
207
|
+
// tsconfig `paths`, `@api` -> `/abs/src/api`
|
|
208
|
+
pathAliases = {};
|
|
153
209
|
constructor(hooks) {
|
|
154
210
|
this.hooks = hooks;
|
|
155
211
|
}
|
|
212
|
+
setCurrentFile(file) {
|
|
213
|
+
this.currentModule = moduleKey(node_path.resolve(file));
|
|
214
|
+
this.knownModules.add(this.currentModule);
|
|
215
|
+
}
|
|
216
|
+
// `./api/github-api` / `@api/github-api` imported in the current file -> its path, or undefined
|
|
217
|
+
// for a package or anything else that isn't a file of this project
|
|
218
|
+
importPath(source) {
|
|
219
|
+
if (!this.currentModule)
|
|
220
|
+
return undefined;
|
|
221
|
+
if (source.startsWith('.'))
|
|
222
|
+
return moduleKey(node_path.resolve(node_path.dirname(this.currentModule), source));
|
|
223
|
+
for (const [alias, path] of Object.entries(this.pathAliases)) {
|
|
224
|
+
if (source === alias || source.startsWith(`${alias}/`))
|
|
225
|
+
return moduleKey(node_path.resolve(path, `.${source.slice(alias.length)}`));
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
// The scanned module an import path points to: the file itself or its `index`
|
|
230
|
+
moduleOf(path) {
|
|
231
|
+
return [path, `${path}/index`].find(m => this.knownModules.has(m));
|
|
232
|
+
}
|
|
233
|
+
// ModuleTable: the keys `name` read in the current file may be stored under, most specific first
|
|
234
|
+
keysOf(name) {
|
|
235
|
+
if (name.includes('#'))
|
|
236
|
+
return [name];
|
|
237
|
+
if (!this.currentModule)
|
|
238
|
+
return [];
|
|
239
|
+
const keys = [];
|
|
240
|
+
const imported = this.fileImports.get(this.currentModule)?.get(name);
|
|
241
|
+
const module = imported && this.moduleOf(imported.from);
|
|
242
|
+
if (module)
|
|
243
|
+
keys.push(`${module}#${imported.name}`);
|
|
244
|
+
keys.push(`${this.currentModule}#${name}`);
|
|
245
|
+
return keys;
|
|
246
|
+
}
|
|
247
|
+
// ModuleTable: the key a declaration made in the current file is also stored under
|
|
248
|
+
declaringKey(name) {
|
|
249
|
+
return this.currentModule && !name.includes('#') ? `${this.currentModule}#${name}` : undefined;
|
|
250
|
+
}
|
|
251
|
+
// Replays run after every file was read: run each in the file it was recorded in
|
|
252
|
+
inCurrentFile(fn) {
|
|
253
|
+
const module = this.currentModule;
|
|
254
|
+
return () => {
|
|
255
|
+
const saved = this.currentModule;
|
|
256
|
+
this.currentModule = module;
|
|
257
|
+
try {
|
|
258
|
+
fn();
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
this.currentModule = saved;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* `Color` / `Types.Color` / `NS.Inner.Color` -> 'Color'. Declarations are looked up by their
|
|
267
|
+
* own name, so a qualified name resolves by its last part, whatever namespace holds it, and
|
|
268
|
+
* through a namespace import of a module (`GH.components`) by that module's declaration.
|
|
269
|
+
*/
|
|
270
|
+
typeRefName(type) {
|
|
271
|
+
const typeName = type?.typeName;
|
|
272
|
+
if (typeName?.type === 'Identifier')
|
|
273
|
+
return typeName.value;
|
|
274
|
+
if (typeName?.type !== 'TsQualifiedName')
|
|
275
|
+
return undefined;
|
|
276
|
+
const name = typeName.right?.value;
|
|
277
|
+
const from = typeName.left?.type === 'Identifier' && this.currentModule ? this.fileNamespaces.get(this.currentModule)?.get(typeName.left.value) : undefined;
|
|
278
|
+
const module = from && this.moduleOf(from);
|
|
279
|
+
return module && name ? `${module}#${name}` : name;
|
|
280
|
+
}
|
|
156
281
|
/**
|
|
157
282
|
* Clear per-file captured variables. Enums / shared maps are kept.
|
|
158
283
|
*/
|
|
@@ -172,6 +297,8 @@ class ExpressionResolver {
|
|
|
172
297
|
*/
|
|
173
298
|
finishPreScan() {
|
|
174
299
|
this.resetFileSymbols();
|
|
300
|
+
// Mirroring onto import aliases writes bare names only; each replay restores its own file
|
|
301
|
+
this.currentModule = undefined;
|
|
175
302
|
// ponytail: each round fixes one more link of a chain declared against file order; 10 is plenty
|
|
176
303
|
for (let round = 0; round < 10; round++) {
|
|
177
304
|
this.applyImportAliases();
|
|
@@ -327,6 +454,7 @@ class ExpressionResolver {
|
|
|
327
454
|
// If at least one property was resolvable, record the partial map.
|
|
328
455
|
if (Object.keys(map).length > 0) {
|
|
329
456
|
this.variableTable.set(name, map);
|
|
457
|
+
this.sharedObjectMapTable.set(name, map);
|
|
330
458
|
return;
|
|
331
459
|
}
|
|
332
460
|
}
|
|
@@ -394,7 +522,7 @@ class ExpressionResolver {
|
|
|
394
522
|
if (!tsType)
|
|
395
523
|
return;
|
|
396
524
|
if (this.recording)
|
|
397
|
-
this.replays.push(() => this.captureTypeAliasDeclaration(node));
|
|
525
|
+
this.replays.push(this.inCurrentFile(() => this.captureTypeAliasDeclaration(node)));
|
|
398
526
|
const params = node.typeParams?.parameters;
|
|
399
527
|
// `type IProps = { size: ChangeType }` — object shape, not a string union.
|
|
400
528
|
if (tsType.type === 'TsTypeLiteral') {
|
|
@@ -431,19 +559,59 @@ class ExpressionResolver {
|
|
|
431
559
|
*/
|
|
432
560
|
captureImportDeclaration(node) {
|
|
433
561
|
try {
|
|
562
|
+
const from = node?.type === 'ImportDeclaration' && typeof node.source?.value === 'string' ? this.importPath(node.source.value) : undefined;
|
|
563
|
+
const imports = from && this.currentModule ? (this.fileImports.get(this.currentModule) ?? new Map()) : undefined;
|
|
564
|
+
if (imports)
|
|
565
|
+
this.fileImports.set(this.currentModule, imports);
|
|
434
566
|
for (const spec of node?.specifiers ?? []) {
|
|
567
|
+
// `import * as Types from …` / `export * as Types from …`
|
|
568
|
+
if (spec?.type === 'ImportNamespaceSpecifier' && spec.local?.value) {
|
|
569
|
+
this.sharedNamespaceNames.add(spec.local.value);
|
|
570
|
+
if (from) {
|
|
571
|
+
if (!this.fileNamespaces.has(this.currentModule))
|
|
572
|
+
this.fileNamespaces.set(this.currentModule, new Map());
|
|
573
|
+
this.fileNamespaces.get(this.currentModule).set(spec.local.value, from);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (spec?.type === 'ExportNamespaceSpecifier' && spec.name?.value)
|
|
577
|
+
this.sharedNamespaceNames.add(spec.name.value);
|
|
435
578
|
if (spec?.type !== 'ImportSpecifier')
|
|
436
579
|
continue;
|
|
437
580
|
const local = spec.local?.value;
|
|
438
|
-
const imported = spec.imported?.value;
|
|
581
|
+
const imported = spec.imported?.value ?? local;
|
|
439
582
|
if (local && imported && local !== imported)
|
|
440
583
|
this.sharedImportAliases.set(local, imported);
|
|
584
|
+
// `import { components as githubComponents } from './github-api'` → that module's `components`
|
|
585
|
+
if (local && imported && imports)
|
|
586
|
+
imports.set(local, { from: from, name: imported });
|
|
441
587
|
}
|
|
442
588
|
}
|
|
443
589
|
catch {
|
|
444
590
|
// noop
|
|
445
591
|
}
|
|
446
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* `Types.COLORS` → `COLORS` when `Types` is a namespace import (also one renamed by
|
|
595
|
+
* `import { Types as T }` from a barrel); any other expression is returned as is.
|
|
596
|
+
*/
|
|
597
|
+
unwrapNamespace(expr) {
|
|
598
|
+
if (expr?.type !== 'MemberExpression' || expr.object?.type !== 'Identifier' || expr.property?.type !== 'Identifier')
|
|
599
|
+
return expr;
|
|
600
|
+
const ns = expr.object.value;
|
|
601
|
+
if (!this.sharedNamespaceNames.has(this.sharedImportAliases.get(ns) ?? ns))
|
|
602
|
+
return expr;
|
|
603
|
+
// `GH.components` with `import * as GH from './github-api'` → that module's `components`
|
|
604
|
+
const from = this.currentModule ? this.fileNamespaces.get(this.currentModule)?.get(ns) : undefined;
|
|
605
|
+
const module = from && this.moduleOf(from);
|
|
606
|
+
return { type: 'Identifier', value: module ? `${module}#${expr.property.value}` : expr.property.value, span: expr.span };
|
|
607
|
+
}
|
|
608
|
+
// The variable a `typeof` names: `typeof LABELS`, or `typeof Types.LABELS` through a namespace import
|
|
609
|
+
typeQueryName(exprName) {
|
|
610
|
+
if (exprName?.type === 'TsQualifiedName') {
|
|
611
|
+
return this.unwrapNamespace({ type: 'MemberExpression', object: exprName.left, property: exprName.right })?.value;
|
|
612
|
+
}
|
|
613
|
+
return exprName?.value ?? exprName?.name;
|
|
614
|
+
}
|
|
447
615
|
/**
|
|
448
616
|
* Mirror every declaration captured under its declared name onto the local
|
|
449
617
|
* names it was imported as. Must run after the pre-scan pass has seen all
|
|
@@ -457,6 +625,7 @@ class ExpressionResolver {
|
|
|
457
625
|
this.sharedTypeAliasTable,
|
|
458
626
|
this.sharedEnumTable,
|
|
459
627
|
this.sharedVariableTable,
|
|
628
|
+
this.sharedObjectMapTable,
|
|
460
629
|
this.sharedFunctionReturnTable,
|
|
461
630
|
this.sharedFunctionReturnMembers,
|
|
462
631
|
this.objectTypeTable,
|
|
@@ -484,7 +653,7 @@ class ExpressionResolver {
|
|
|
484
653
|
if (!name)
|
|
485
654
|
return;
|
|
486
655
|
if (this.recording)
|
|
487
|
-
this.replays.push(() => this.captureInterfaceDeclaration(node));
|
|
656
|
+
this.replays.push(this.inCurrentFile(() => this.captureInterfaceDeclaration(node)));
|
|
488
657
|
const params = node.typeParams?.parameters;
|
|
489
658
|
if (!this.replaying && Array.isArray(node?.body?.body))
|
|
490
659
|
this.setObjectTypeRaw(name, node.body.body, params);
|
|
@@ -532,13 +701,14 @@ class ExpressionResolver {
|
|
|
532
701
|
* function returning one (`getAnimal()`).
|
|
533
702
|
*/
|
|
534
703
|
objectMembersOf(expr) {
|
|
535
|
-
expr = astUtils.unwrapParens(expr);
|
|
704
|
+
expr = this.unwrapNamespace(astUtils.unwrapParens(expr));
|
|
536
705
|
if (expr?.type === 'OptionalChainingExpression')
|
|
537
706
|
return this.objectMembersOf(expr.base);
|
|
538
707
|
if (expr?.type === 'Identifier')
|
|
539
708
|
return this.temporaryObjectVariables.get(expr.value) ?? this.objectVariables.get(expr.value);
|
|
540
|
-
|
|
541
|
-
|
|
709
|
+
const callee = this.unwrapNamespace(expr?.callee);
|
|
710
|
+
if (expr?.type === 'CallExpression' && callee?.type === 'Identifier')
|
|
711
|
+
return this.sharedFunctionReturnMembers.get(callee.value);
|
|
542
712
|
// `deepObject.Foo.Bar` → the members nested under `Foo.Bar`
|
|
543
713
|
if (expr?.type === 'MemberExpression') {
|
|
544
714
|
const prop = expr.property;
|
|
@@ -622,8 +792,8 @@ class ExpressionResolver {
|
|
|
622
792
|
}
|
|
623
793
|
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
624
794
|
}
|
|
625
|
-
|
|
626
|
-
|
|
795
|
+
const name = tsType.type === 'TsTypeReference' ? this.typeRefName(tsType) : undefined;
|
|
796
|
+
if (name) {
|
|
627
797
|
// `Base<'DUCK'>` → instantiate the generic type's members with the argument
|
|
628
798
|
const args = tsType.typeParams?.params;
|
|
629
799
|
const params = this.objectTypeParams.get(name);
|
|
@@ -677,7 +847,7 @@ class ExpressionResolver {
|
|
|
677
847
|
obj = obj.typeAnnotation;
|
|
678
848
|
if (obj?.type === 'TsIndexedAccessType')
|
|
679
849
|
obj = this.indexedAccessTarget(obj);
|
|
680
|
-
const name = obj?.type === 'TsTypeReference' && !obj.typeParams
|
|
850
|
+
const name = obj?.type === 'TsTypeReference' && !obj.typeParams ? this.typeRefName(obj) : undefined;
|
|
681
851
|
const members = obj?.type === 'TsTypeLiteral'
|
|
682
852
|
? obj.members
|
|
683
853
|
: name && !this.objectTypeParams.has(name) ? this.objectTypeMembersRaw.get(name) : undefined;
|
|
@@ -724,7 +894,7 @@ class ExpressionResolver {
|
|
|
724
894
|
* inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
|
|
725
895
|
*/
|
|
726
896
|
arrayValuesOf(expr) {
|
|
727
|
-
expr = unwrapExpr(expr);
|
|
897
|
+
expr = this.unwrapNamespace(unwrapExpr(expr));
|
|
728
898
|
if (expr?.type === 'Identifier')
|
|
729
899
|
return this.getVariableValues(expr.value);
|
|
730
900
|
if (expr?.type === 'ArrayExpression')
|
|
@@ -742,7 +912,7 @@ class ExpressionResolver {
|
|
|
742
912
|
* typed member (`props.items`).
|
|
743
913
|
*/
|
|
744
914
|
arrayMembersOf(expr) {
|
|
745
|
-
expr = unwrapExpr(expr);
|
|
915
|
+
expr = this.unwrapNamespace(unwrapExpr(expr));
|
|
746
916
|
if (expr?.type === 'Identifier')
|
|
747
917
|
return this.arrayElementMembers.get(expr.value);
|
|
748
918
|
if (expr?.type === 'ArrayExpression')
|
|
@@ -835,7 +1005,7 @@ class ExpressionResolver {
|
|
|
835
1005
|
};
|
|
836
1006
|
store();
|
|
837
1007
|
if (this.recording && (returnType || refs.length > 0))
|
|
838
|
-
this.replays.push(store);
|
|
1008
|
+
this.replays.push(this.inCurrentFile(store));
|
|
839
1009
|
}
|
|
840
1010
|
/**
|
|
841
1011
|
* Collect a function's return expressions (the expression body of an arrow
|
|
@@ -944,10 +1114,7 @@ class ExpressionResolver {
|
|
|
944
1114
|
const v = this.variableTable.get(name);
|
|
945
1115
|
if (v && !Array.isArray(v) && typeof v === 'object')
|
|
946
1116
|
return v;
|
|
947
|
-
|
|
948
|
-
if (ev)
|
|
949
|
-
return ev;
|
|
950
|
-
return undefined;
|
|
1117
|
+
return this.sharedObjectMapTable.get(name) ?? this.sharedEnumTable.get(name);
|
|
951
1118
|
}
|
|
952
1119
|
/**
|
|
953
1120
|
* Capture a TypeScript enum declaration so members can be resolved later.
|
|
@@ -1028,7 +1195,8 @@ class ExpressionResolver {
|
|
|
1028
1195
|
*/
|
|
1029
1196
|
resolvePossibleStringValuesFromExpression(expression, returnEmptyStrings = false) {
|
|
1030
1197
|
// `t(('key'))` / `t(cond ? 'a' : ('b'))`: parens are just a wrapper node (#295).
|
|
1031
|
-
|
|
1198
|
+
// `Types.COLORS` with `import * as Types` → `COLORS`
|
|
1199
|
+
expression = this.unwrapNamespace(astUtils.unwrapParens(expression));
|
|
1032
1200
|
// `pet.category?.kind` → `pet.category.kind`
|
|
1033
1201
|
if (expression.type === 'OptionalChainingExpression') {
|
|
1034
1202
|
return this.resolvePossibleStringValuesFromExpression(expression.base, returnEmptyStrings);
|
|
@@ -1113,7 +1281,7 @@ class ExpressionResolver {
|
|
|
1113
1281
|
// MemberExpression: try to resolve object identifier to an object map in the symbol table
|
|
1114
1282
|
if (expression.type === 'MemberExpression') {
|
|
1115
1283
|
try {
|
|
1116
|
-
const obj = expression.object;
|
|
1284
|
+
const obj = this.unwrapNamespace(expression.object);
|
|
1117
1285
|
const prop = expression.property;
|
|
1118
1286
|
const propName = prop.type === 'Identifier'
|
|
1119
1287
|
? prop.value
|
|
@@ -1128,7 +1296,7 @@ class ExpressionResolver {
|
|
|
1128
1296
|
// only handle simple identifier base + simple property (Identifier or computed StringLiteral)
|
|
1129
1297
|
if (obj.type === 'Identifier') {
|
|
1130
1298
|
const baseVar = this.variableTable.get(obj.value);
|
|
1131
|
-
const baseShared = this.sharedEnumTable.get(obj.value);
|
|
1299
|
+
const baseShared = this.sharedObjectMapTable.get(obj.value) ?? this.sharedEnumTable.get(obj.value);
|
|
1132
1300
|
const base = baseVar ?? baseShared;
|
|
1133
1301
|
if (base && typeof base !== 'string' && !Array.isArray(base)) {
|
|
1134
1302
|
if (propName && base[propName] !== undefined) {
|
|
@@ -1165,7 +1333,7 @@ class ExpressionResolver {
|
|
|
1165
1333
|
// the shared cross-file table populated during pre-scan.
|
|
1166
1334
|
if (expression.type === 'CallExpression') {
|
|
1167
1335
|
try {
|
|
1168
|
-
const callee = expression.callee;
|
|
1336
|
+
const callee = this.unwrapNamespace(expression.callee);
|
|
1169
1337
|
if (callee?.type === 'Identifier') {
|
|
1170
1338
|
const v = this.variableTable.get(callee.value);
|
|
1171
1339
|
if (Array.isArray(v) && v.length > 0)
|
|
@@ -1298,9 +1466,7 @@ class ExpressionResolver {
|
|
|
1298
1466
|
// where `type ChangeType = 'all' | 'next' | 'this'` was captured earlier.
|
|
1299
1467
|
// Also handles `declare const d: SomeEnum` where SomeEnum is a TS enum with string values.
|
|
1300
1468
|
if (type.type === 'TsTypeReference') {
|
|
1301
|
-
const typeName =
|
|
1302
|
-
? type.typeName.value
|
|
1303
|
-
: undefined;
|
|
1469
|
+
const typeName = this.typeRefName(type);
|
|
1304
1470
|
if (typeName) {
|
|
1305
1471
|
// Inside a generic type: the parameter's argument, default or constraint
|
|
1306
1472
|
const bound = this.typeParamBindings.get(typeName);
|
|
@@ -1338,7 +1504,7 @@ class ExpressionResolver {
|
|
|
1338
1504
|
// SWC: TsTypeQuery.exprName is TsEntityName (Identifier | TsQualifiedName)
|
|
1339
1505
|
const exprName = objType.exprName ?? objType.expr ?? objType.entityName;
|
|
1340
1506
|
// access .value (Identifier) or fall back to .name for alternate SWC builds
|
|
1341
|
-
const varName = exprName
|
|
1507
|
+
const varName = this.typeQueryName(exprName);
|
|
1342
1508
|
if (varName) {
|
|
1343
1509
|
const vals = this.getVariableValues(varName);
|
|
1344
1510
|
if (vals && vals.length > 0)
|
|
@@ -1373,17 +1539,17 @@ class ExpressionResolver {
|
|
|
1373
1539
|
// Object.keys(MAP).forEach(k => t(MAP[k]))
|
|
1374
1540
|
if (type.type === 'TsTypeOperator') {
|
|
1375
1541
|
try {
|
|
1376
|
-
const op = type.
|
|
1542
|
+
const op = type.op;
|
|
1377
1543
|
if (op === 'keyof') {
|
|
1378
1544
|
let inner = type.typeAnnotation;
|
|
1379
1545
|
while (inner?.type === 'TsParenthesizedType')
|
|
1380
1546
|
inner = inner.typeAnnotation;
|
|
1381
1547
|
if (inner?.type === 'TsTypeQuery' || inner?.type === 'TSTypeQuery') {
|
|
1382
1548
|
const exprName = inner.exprName ?? inner.expr ?? inner.entityName;
|
|
1383
|
-
const varName = exprName
|
|
1549
|
+
const varName = this.typeQueryName(exprName);
|
|
1384
1550
|
if (varName) {
|
|
1385
|
-
// Look up in variableTable (local) or
|
|
1386
|
-
const v = this.variableTable.get(varName) ?? this.
|
|
1551
|
+
// Look up in variableTable (local) or sharedObjectMapTable (cross-file) for object maps
|
|
1552
|
+
const v = this.variableTable.get(varName) ?? this.sharedObjectMapTable.get(varName);
|
|
1387
1553
|
if (v && !Array.isArray(v) && typeof v === 'object') {
|
|
1388
1554
|
return Object.keys(v);
|
|
1389
1555
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var config = require('./config.js');
|
|
|
4
4
|
var extractor = require('./extractor/core/extractor.js');
|
|
5
5
|
var keyFinder = require('./extractor/core/key-finder.js');
|
|
6
6
|
var translationManager = require('./extractor/core/translation-manager.js');
|
|
7
|
+
require('node:path');
|
|
7
8
|
require('node:module');
|
|
8
9
|
var linter = require('./linter.js');
|
|
9
10
|
var syncer = require('./syncer.js');
|
|
@@ -15,7 +16,6 @@ require('./utils/jsx-attributes.js');
|
|
|
15
16
|
require('magic-string');
|
|
16
17
|
var localize = require('./localize/localize.js');
|
|
17
18
|
require('node:fs/promises');
|
|
18
|
-
require('node:path');
|
|
19
19
|
var agentPrompt = require('./localize/agent-prompt.js');
|
|
20
20
|
|
|
21
21
|
|
|
@@ -8,8 +8,8 @@ var glob = require('glob');
|
|
|
8
8
|
var config = require('../config.js');
|
|
9
9
|
var heuristicConfig = require('../heuristic-config.js');
|
|
10
10
|
var extractor = require('../extractor/core/extractor.js');
|
|
11
|
-
require('node:module');
|
|
12
11
|
require('node:path');
|
|
12
|
+
require('node:module');
|
|
13
13
|
var nestedObject = require('../utils/nested-object.js');
|
|
14
14
|
require('jiti');
|
|
15
15
|
require('@croct/json5-parser');
|
package/dist/esm/cli.js
CHANGED
|
@@ -7,8 +7,8 @@ import { styleText } from 'node:util';
|
|
|
7
7
|
import { ensureConfig, loadConfig } from './config.js';
|
|
8
8
|
import { detectConfig } from './heuristic-config.js';
|
|
9
9
|
import { runExtractor } from './extractor/core/extractor.js';
|
|
10
|
-
import 'node:module';
|
|
11
10
|
import 'node:path';
|
|
11
|
+
import 'node:module';
|
|
12
12
|
import { getNestedKeys, getNestedValue } from './utils/nested-object.js';
|
|
13
13
|
import 'node:fs/promises';
|
|
14
14
|
import 'jiti';
|
|
@@ -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.75.
|
|
34
|
+
.version('1.75.2') // This string is replaced with the actual version at build time by rollup
|
|
35
35
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
36
36
|
// new: global config override option
|
|
37
37
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -170,8 +170,10 @@ class ASTVisitors {
|
|
|
170
170
|
this.expressionResolver.captureFunctionDeclaration(node);
|
|
171
171
|
break;
|
|
172
172
|
case 'ImportDeclaration':
|
|
173
|
+
case 'ExportNamedDeclaration':
|
|
173
174
|
// `import { X as Y }` → ExpressionResolver.sharedImportAliases, resolved
|
|
174
|
-
// once the pre-scan has seen every file
|
|
175
|
+
// once the pre-scan has seen every file; `import * as Types` / `export * as Types`
|
|
176
|
+
// → namespace names.
|
|
175
177
|
this.expressionResolver.captureImportDeclaration(node);
|
|
176
178
|
break;
|
|
177
179
|
}
|
|
@@ -822,8 +824,8 @@ class ASTVisitors {
|
|
|
822
824
|
let members;
|
|
823
825
|
if (tsType.type === 'TsTypeLiteral')
|
|
824
826
|
members = tsType.members;
|
|
825
|
-
else if (tsType.type === 'TsTypeReference' && tsType
|
|
826
|
-
members = this.expressionResolver.getObjectTypeMembersRaw(
|
|
827
|
+
else if (tsType.type === 'TsTypeReference' && this.expressionResolver.typeRefName(tsType)) {
|
|
828
|
+
members = this.expressionResolver.getObjectTypeMembersRaw(this.expressionResolver.typeRefName(tsType));
|
|
827
829
|
}
|
|
828
830
|
if (!Array.isArray(members))
|
|
829
831
|
return [];
|
|
@@ -875,7 +877,7 @@ class ASTVisitors {
|
|
|
875
877
|
(innerCallee.property.value === 'keys' || innerCallee.property.value === 'values')) {
|
|
876
878
|
const isKeys = innerCallee.property.value === 'keys';
|
|
877
879
|
// The single argument to Object.keys/values must be a known identifier
|
|
878
|
-
const mapArg = obj.arguments?.[0]?.expression;
|
|
880
|
+
const mapArg = this.expressionResolver.unwrapNamespace(obj.arguments?.[0]?.expression);
|
|
879
881
|
if (mapArg?.type === 'Identifier') {
|
|
880
882
|
const mapEntry = this.expressionResolver.getObjectMap(mapArg.value);
|
|
881
883
|
if (mapEntry) {
|
|
@@ -1049,6 +1051,7 @@ class ASTVisitors {
|
|
|
1049
1051
|
setCurrentFile(file, code) {
|
|
1050
1052
|
this.currentFile = file;
|
|
1051
1053
|
this.currentCode = code;
|
|
1054
|
+
this.expressionResolver.setCurrentFile(file);
|
|
1052
1055
|
}
|
|
1053
1056
|
/**
|
|
1054
1057
|
* Returns the currently set file path.
|
|
@@ -4,6 +4,7 @@ import { ConsoleLogger } from '../../utils/logger.js';
|
|
|
4
4
|
import { createPluginContext, initializePlugins } from '../plugin-manager.js';
|
|
5
5
|
import { ASTVisitors } from './ast-visitors.js';
|
|
6
6
|
import { ExpressionResolver } from '../parsers/expression-resolver.js';
|
|
7
|
+
import { getTsConfigAliases } from '../../config.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Main function for finding translation keys across all source files in a project.
|
|
@@ -79,6 +80,7 @@ async function findKeys(config, logger = new ConsoleLogger(), fileErrors) {
|
|
|
79
80
|
// Use a shared ExpressionResolver so captured enums/objects in one file are available when resolving MemberExpressions
|
|
80
81
|
const sharedExpressionResolver = new ExpressionResolver(hooks);
|
|
81
82
|
sharedExpressionResolver.maxMemberDepth = config.extract.maxTypeDepth ?? 5;
|
|
83
|
+
sharedExpressionResolver.pathAliases = await getTsConfigAliases();
|
|
82
84
|
const astVisitors = new ASTVisitors(otherConfig, pluginContext, logger, hooks, sharedExpressionResolver);
|
|
83
85
|
// 4. "Wire up" the visitor's scope method to the context.
|
|
84
86
|
// This avoids a circular dependency while giving plugins access to the scope.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolve, dirname } from 'node:path';
|
|
1
2
|
import { unwrapParens } from './ast-utils.js';
|
|
2
3
|
|
|
3
4
|
// Whether `next` holds everything `prev` does: every value of a list, every
|
|
@@ -59,6 +60,45 @@ const memberByKey = (members, key) => {
|
|
|
59
60
|
}
|
|
60
61
|
return index.get(key);
|
|
61
62
|
};
|
|
63
|
+
// `/src/api/github-api.ts`, `.d.ts`, or an import of `./github-api.js` -> `/src/api/github-api`
|
|
64
|
+
const moduleKey = (path) => path.replace(/(\.d)?\.[cm]?[jt]sx?$/, '');
|
|
65
|
+
/**
|
|
66
|
+
* A cross-file table keyed by declared name. Every entry is also kept under the module that
|
|
67
|
+
* declares it (`/src/api/github-api#components`), and a lookup made while a file is being read
|
|
68
|
+
* first tries where that file gets the name from: the module it imported it from, then its own
|
|
69
|
+
* declaration. The bare name, held by whichever file declared it last, is the fallback, so two
|
|
70
|
+
* generated clients that both declare `components` no longer overwrite each other (#306).
|
|
71
|
+
*/
|
|
72
|
+
class ModuleTable extends Map {
|
|
73
|
+
scope;
|
|
74
|
+
constructor(scope) {
|
|
75
|
+
super();
|
|
76
|
+
this.scope = scope;
|
|
77
|
+
}
|
|
78
|
+
get(name) {
|
|
79
|
+
for (const key of this.scope.keysOf(name)) {
|
|
80
|
+
const value = super.get(key);
|
|
81
|
+
if (value !== undefined)
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
return super.get(name);
|
|
85
|
+
}
|
|
86
|
+
has(name) {
|
|
87
|
+
return this.scope.keysOf(name).some(key => super.has(key)) || super.has(name);
|
|
88
|
+
}
|
|
89
|
+
set(name, value) {
|
|
90
|
+
const key = this.scope.declaringKey(name);
|
|
91
|
+
if (key)
|
|
92
|
+
super.set(key, value);
|
|
93
|
+
return super.set(name, value);
|
|
94
|
+
}
|
|
95
|
+
delete(name) {
|
|
96
|
+
const key = this.scope.declaringKey(name);
|
|
97
|
+
if (key)
|
|
98
|
+
super.delete(key);
|
|
99
|
+
return super.delete(name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
62
102
|
// `T['a']` / `T[200]` -> 'a' / '200'
|
|
63
103
|
const indexedKey = (type) => type?.indexType?.type === 'TsLiteralType' ? literalKey(type.indexType.literal) : undefined;
|
|
64
104
|
// Whether replacing `prev` by `next` only adds to it.
|
|
@@ -91,30 +131,33 @@ class ExpressionResolver {
|
|
|
91
131
|
// - Record<string, string> (object of static string properties)
|
|
92
132
|
variableTable = new Map();
|
|
93
133
|
// Shared (cross-file) table for enums / exported object maps that should persist
|
|
94
|
-
sharedEnumTable = new
|
|
134
|
+
sharedEnumTable = new ModuleTable(this);
|
|
95
135
|
// Per-file table for type aliases: Maps typeName -> string[]
|
|
96
136
|
// e.g. `type ChangeType = 'all' | 'next' | 'this'` -> { ChangeType: ['all', 'next', 'this'] }
|
|
97
137
|
typeAliasTable = new Map();
|
|
98
138
|
// Shared (cross-file) table for string-array constants (e.g. `as const` arrays).
|
|
99
139
|
// Persists across resetFileSymbols() so exported arrays are visible to importers.
|
|
100
|
-
sharedVariableTable = new
|
|
140
|
+
sharedVariableTable = new ModuleTable(this);
|
|
141
|
+
// Shared (cross-file) table for as-const object maps, `export const LABELS = { … } as const`,
|
|
142
|
+
// so `LABELS.save` and `Object.keys(LABELS)` resolve in importing files.
|
|
143
|
+
sharedObjectMapTable = new ModuleTable(this);
|
|
101
144
|
// Shared (cross-file) table for type aliases — populated alongside typeAliasTable.
|
|
102
145
|
// Persists across resetFileSymbols() so exported type aliases are visible to importers.
|
|
103
|
-
sharedTypeAliasTable = new
|
|
146
|
+
sharedTypeAliasTable = new ModuleTable(this);
|
|
104
147
|
// Shared (cross-file) table for function return-value sets. Populated from
|
|
105
148
|
// both explicit return-type annotations and body-inferred return values so
|
|
106
149
|
// that `t(fn())` / `const x = fn(); t(\`...${x}...\`)` work across files.
|
|
107
150
|
// Persists across resetFileSymbols() just like the other shared tables.
|
|
108
|
-
sharedFunctionReturnTable = new
|
|
151
|
+
sharedFunctionReturnTable = new ModuleTable(this);
|
|
109
152
|
// Temporary per-scope variable overrides, used to inject .map() / .forEach()
|
|
110
153
|
// callback parameters while the callback body is being walked.
|
|
111
154
|
temporaryVariables = new Map();
|
|
112
155
|
// Shared (cross-file) table for object-shaped types: interfaces and object
|
|
113
156
|
// type aliases. Maps typeName -> { memberName: possible string values }.
|
|
114
157
|
// e.g. `interface IProps { size: ChangeType }` -> { IProps: { size: ['all','next'] } }
|
|
115
|
-
objectTypeTable = new
|
|
158
|
+
objectTypeTable = new ModuleTable(this);
|
|
116
159
|
// Raw TS member nodes of local interfaces / object type aliases, keyed by type name.
|
|
117
|
-
objectTypeMembersRaw = new
|
|
160
|
+
objectTypeMembersRaw = new ModuleTable(this);
|
|
118
161
|
// Temporary per-scope bindings for identifiers holding an object-shaped type,
|
|
119
162
|
// e.g. `function f(props: IProps)` -> { props: { size: ['all','next'] } }.
|
|
120
163
|
temporaryObjectVariables = new Map();
|
|
@@ -127,13 +170,16 @@ class ExpressionResolver {
|
|
|
127
170
|
// Every other table is keyed by the *declared* name, so without this a type
|
|
128
171
|
// referenced through an alias resolves to nothing.
|
|
129
172
|
sharedImportAliases = new Map();
|
|
173
|
+
// Shared (cross-file) namespace names: `import * as Types`, `export * as Types`. Their
|
|
174
|
+
// members are declared under their own names, so `Types.COLORS` resolves as `COLORS`.
|
|
175
|
+
sharedNamespaceNames = new Set();
|
|
130
176
|
// Type parameters of generic object types, e.g. `type Base<T> = { type: T }`.
|
|
131
|
-
objectTypeParams = new
|
|
177
|
+
objectTypeParams = new ModuleTable(this);
|
|
132
178
|
// Values bound to type parameters while a generic type is being resolved.
|
|
133
179
|
typeParamBindings = new Map();
|
|
134
180
|
// Shared (cross-file) member maps of functions returning an object type,
|
|
135
181
|
// e.g. `const getAnimal = (): Animal => …` -> { getAnimal: { type: ['DUCK', 'DOG'] } }
|
|
136
|
-
sharedFunctionReturnMembers = new
|
|
182
|
+
sharedFunctionReturnMembers = new ModuleTable(this);
|
|
137
183
|
// Per-file identifiers holding an object type, from their annotation or from the
|
|
138
184
|
// function they were initialised by: `const animal = getAnimal()` -> { animal: { type: [...] } }
|
|
139
185
|
objectVariables = new Map();
|
|
@@ -148,9 +194,88 @@ class ExpressionResolver {
|
|
|
148
194
|
// this many levels below a declared or indexed type, so recursive types stay small
|
|
149
195
|
// (`extract.maxTypeDepth`).
|
|
150
196
|
maxMemberDepth = 5;
|
|
197
|
+
// The module being read (its path without extension), and where each module gets its
|
|
198
|
+
// names from (see ModuleTable)
|
|
199
|
+
currentModule;
|
|
200
|
+
knownModules = new Set();
|
|
201
|
+
// module -> local name -> { from: the import's resolved path, name: the declared name }
|
|
202
|
+
fileImports = new Map();
|
|
203
|
+
// module -> namespace import's local name -> the import's resolved path
|
|
204
|
+
fileNamespaces = new Map();
|
|
205
|
+
// tsconfig `paths`, `@api` -> `/abs/src/api`
|
|
206
|
+
pathAliases = {};
|
|
151
207
|
constructor(hooks) {
|
|
152
208
|
this.hooks = hooks;
|
|
153
209
|
}
|
|
210
|
+
setCurrentFile(file) {
|
|
211
|
+
this.currentModule = moduleKey(resolve(file));
|
|
212
|
+
this.knownModules.add(this.currentModule);
|
|
213
|
+
}
|
|
214
|
+
// `./api/github-api` / `@api/github-api` imported in the current file -> its path, or undefined
|
|
215
|
+
// for a package or anything else that isn't a file of this project
|
|
216
|
+
importPath(source) {
|
|
217
|
+
if (!this.currentModule)
|
|
218
|
+
return undefined;
|
|
219
|
+
if (source.startsWith('.'))
|
|
220
|
+
return moduleKey(resolve(dirname(this.currentModule), source));
|
|
221
|
+
for (const [alias, path] of Object.entries(this.pathAliases)) {
|
|
222
|
+
if (source === alias || source.startsWith(`${alias}/`))
|
|
223
|
+
return moduleKey(resolve(path, `.${source.slice(alias.length)}`));
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
// The scanned module an import path points to: the file itself or its `index`
|
|
228
|
+
moduleOf(path) {
|
|
229
|
+
return [path, `${path}/index`].find(m => this.knownModules.has(m));
|
|
230
|
+
}
|
|
231
|
+
// ModuleTable: the keys `name` read in the current file may be stored under, most specific first
|
|
232
|
+
keysOf(name) {
|
|
233
|
+
if (name.includes('#'))
|
|
234
|
+
return [name];
|
|
235
|
+
if (!this.currentModule)
|
|
236
|
+
return [];
|
|
237
|
+
const keys = [];
|
|
238
|
+
const imported = this.fileImports.get(this.currentModule)?.get(name);
|
|
239
|
+
const module = imported && this.moduleOf(imported.from);
|
|
240
|
+
if (module)
|
|
241
|
+
keys.push(`${module}#${imported.name}`);
|
|
242
|
+
keys.push(`${this.currentModule}#${name}`);
|
|
243
|
+
return keys;
|
|
244
|
+
}
|
|
245
|
+
// ModuleTable: the key a declaration made in the current file is also stored under
|
|
246
|
+
declaringKey(name) {
|
|
247
|
+
return this.currentModule && !name.includes('#') ? `${this.currentModule}#${name}` : undefined;
|
|
248
|
+
}
|
|
249
|
+
// Replays run after every file was read: run each in the file it was recorded in
|
|
250
|
+
inCurrentFile(fn) {
|
|
251
|
+
const module = this.currentModule;
|
|
252
|
+
return () => {
|
|
253
|
+
const saved = this.currentModule;
|
|
254
|
+
this.currentModule = module;
|
|
255
|
+
try {
|
|
256
|
+
fn();
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
this.currentModule = saved;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* `Color` / `Types.Color` / `NS.Inner.Color` -> 'Color'. Declarations are looked up by their
|
|
265
|
+
* own name, so a qualified name resolves by its last part, whatever namespace holds it, and
|
|
266
|
+
* through a namespace import of a module (`GH.components`) by that module's declaration.
|
|
267
|
+
*/
|
|
268
|
+
typeRefName(type) {
|
|
269
|
+
const typeName = type?.typeName;
|
|
270
|
+
if (typeName?.type === 'Identifier')
|
|
271
|
+
return typeName.value;
|
|
272
|
+
if (typeName?.type !== 'TsQualifiedName')
|
|
273
|
+
return undefined;
|
|
274
|
+
const name = typeName.right?.value;
|
|
275
|
+
const from = typeName.left?.type === 'Identifier' && this.currentModule ? this.fileNamespaces.get(this.currentModule)?.get(typeName.left.value) : undefined;
|
|
276
|
+
const module = from && this.moduleOf(from);
|
|
277
|
+
return module && name ? `${module}#${name}` : name;
|
|
278
|
+
}
|
|
154
279
|
/**
|
|
155
280
|
* Clear per-file captured variables. Enums / shared maps are kept.
|
|
156
281
|
*/
|
|
@@ -170,6 +295,8 @@ class ExpressionResolver {
|
|
|
170
295
|
*/
|
|
171
296
|
finishPreScan() {
|
|
172
297
|
this.resetFileSymbols();
|
|
298
|
+
// Mirroring onto import aliases writes bare names only; each replay restores its own file
|
|
299
|
+
this.currentModule = undefined;
|
|
173
300
|
// ponytail: each round fixes one more link of a chain declared against file order; 10 is plenty
|
|
174
301
|
for (let round = 0; round < 10; round++) {
|
|
175
302
|
this.applyImportAliases();
|
|
@@ -325,6 +452,7 @@ class ExpressionResolver {
|
|
|
325
452
|
// If at least one property was resolvable, record the partial map.
|
|
326
453
|
if (Object.keys(map).length > 0) {
|
|
327
454
|
this.variableTable.set(name, map);
|
|
455
|
+
this.sharedObjectMapTable.set(name, map);
|
|
328
456
|
return;
|
|
329
457
|
}
|
|
330
458
|
}
|
|
@@ -392,7 +520,7 @@ class ExpressionResolver {
|
|
|
392
520
|
if (!tsType)
|
|
393
521
|
return;
|
|
394
522
|
if (this.recording)
|
|
395
|
-
this.replays.push(() => this.captureTypeAliasDeclaration(node));
|
|
523
|
+
this.replays.push(this.inCurrentFile(() => this.captureTypeAliasDeclaration(node)));
|
|
396
524
|
const params = node.typeParams?.parameters;
|
|
397
525
|
// `type IProps = { size: ChangeType }` — object shape, not a string union.
|
|
398
526
|
if (tsType.type === 'TsTypeLiteral') {
|
|
@@ -429,19 +557,59 @@ class ExpressionResolver {
|
|
|
429
557
|
*/
|
|
430
558
|
captureImportDeclaration(node) {
|
|
431
559
|
try {
|
|
560
|
+
const from = node?.type === 'ImportDeclaration' && typeof node.source?.value === 'string' ? this.importPath(node.source.value) : undefined;
|
|
561
|
+
const imports = from && this.currentModule ? (this.fileImports.get(this.currentModule) ?? new Map()) : undefined;
|
|
562
|
+
if (imports)
|
|
563
|
+
this.fileImports.set(this.currentModule, imports);
|
|
432
564
|
for (const spec of node?.specifiers ?? []) {
|
|
565
|
+
// `import * as Types from …` / `export * as Types from …`
|
|
566
|
+
if (spec?.type === 'ImportNamespaceSpecifier' && spec.local?.value) {
|
|
567
|
+
this.sharedNamespaceNames.add(spec.local.value);
|
|
568
|
+
if (from) {
|
|
569
|
+
if (!this.fileNamespaces.has(this.currentModule))
|
|
570
|
+
this.fileNamespaces.set(this.currentModule, new Map());
|
|
571
|
+
this.fileNamespaces.get(this.currentModule).set(spec.local.value, from);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (spec?.type === 'ExportNamespaceSpecifier' && spec.name?.value)
|
|
575
|
+
this.sharedNamespaceNames.add(spec.name.value);
|
|
433
576
|
if (spec?.type !== 'ImportSpecifier')
|
|
434
577
|
continue;
|
|
435
578
|
const local = spec.local?.value;
|
|
436
|
-
const imported = spec.imported?.value;
|
|
579
|
+
const imported = spec.imported?.value ?? local;
|
|
437
580
|
if (local && imported && local !== imported)
|
|
438
581
|
this.sharedImportAliases.set(local, imported);
|
|
582
|
+
// `import { components as githubComponents } from './github-api'` → that module's `components`
|
|
583
|
+
if (local && imported && imports)
|
|
584
|
+
imports.set(local, { from: from, name: imported });
|
|
439
585
|
}
|
|
440
586
|
}
|
|
441
587
|
catch {
|
|
442
588
|
// noop
|
|
443
589
|
}
|
|
444
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* `Types.COLORS` → `COLORS` when `Types` is a namespace import (also one renamed by
|
|
593
|
+
* `import { Types as T }` from a barrel); any other expression is returned as is.
|
|
594
|
+
*/
|
|
595
|
+
unwrapNamespace(expr) {
|
|
596
|
+
if (expr?.type !== 'MemberExpression' || expr.object?.type !== 'Identifier' || expr.property?.type !== 'Identifier')
|
|
597
|
+
return expr;
|
|
598
|
+
const ns = expr.object.value;
|
|
599
|
+
if (!this.sharedNamespaceNames.has(this.sharedImportAliases.get(ns) ?? ns))
|
|
600
|
+
return expr;
|
|
601
|
+
// `GH.components` with `import * as GH from './github-api'` → that module's `components`
|
|
602
|
+
const from = this.currentModule ? this.fileNamespaces.get(this.currentModule)?.get(ns) : undefined;
|
|
603
|
+
const module = from && this.moduleOf(from);
|
|
604
|
+
return { type: 'Identifier', value: module ? `${module}#${expr.property.value}` : expr.property.value, span: expr.span };
|
|
605
|
+
}
|
|
606
|
+
// The variable a `typeof` names: `typeof LABELS`, or `typeof Types.LABELS` through a namespace import
|
|
607
|
+
typeQueryName(exprName) {
|
|
608
|
+
if (exprName?.type === 'TsQualifiedName') {
|
|
609
|
+
return this.unwrapNamespace({ type: 'MemberExpression', object: exprName.left, property: exprName.right })?.value;
|
|
610
|
+
}
|
|
611
|
+
return exprName?.value ?? exprName?.name;
|
|
612
|
+
}
|
|
445
613
|
/**
|
|
446
614
|
* Mirror every declaration captured under its declared name onto the local
|
|
447
615
|
* names it was imported as. Must run after the pre-scan pass has seen all
|
|
@@ -455,6 +623,7 @@ class ExpressionResolver {
|
|
|
455
623
|
this.sharedTypeAliasTable,
|
|
456
624
|
this.sharedEnumTable,
|
|
457
625
|
this.sharedVariableTable,
|
|
626
|
+
this.sharedObjectMapTable,
|
|
458
627
|
this.sharedFunctionReturnTable,
|
|
459
628
|
this.sharedFunctionReturnMembers,
|
|
460
629
|
this.objectTypeTable,
|
|
@@ -482,7 +651,7 @@ class ExpressionResolver {
|
|
|
482
651
|
if (!name)
|
|
483
652
|
return;
|
|
484
653
|
if (this.recording)
|
|
485
|
-
this.replays.push(() => this.captureInterfaceDeclaration(node));
|
|
654
|
+
this.replays.push(this.inCurrentFile(() => this.captureInterfaceDeclaration(node)));
|
|
486
655
|
const params = node.typeParams?.parameters;
|
|
487
656
|
if (!this.replaying && Array.isArray(node?.body?.body))
|
|
488
657
|
this.setObjectTypeRaw(name, node.body.body, params);
|
|
@@ -530,13 +699,14 @@ class ExpressionResolver {
|
|
|
530
699
|
* function returning one (`getAnimal()`).
|
|
531
700
|
*/
|
|
532
701
|
objectMembersOf(expr) {
|
|
533
|
-
expr = unwrapParens(expr);
|
|
702
|
+
expr = this.unwrapNamespace(unwrapParens(expr));
|
|
534
703
|
if (expr?.type === 'OptionalChainingExpression')
|
|
535
704
|
return this.objectMembersOf(expr.base);
|
|
536
705
|
if (expr?.type === 'Identifier')
|
|
537
706
|
return this.temporaryObjectVariables.get(expr.value) ?? this.objectVariables.get(expr.value);
|
|
538
|
-
|
|
539
|
-
|
|
707
|
+
const callee = this.unwrapNamespace(expr?.callee);
|
|
708
|
+
if (expr?.type === 'CallExpression' && callee?.type === 'Identifier')
|
|
709
|
+
return this.sharedFunctionReturnMembers.get(callee.value);
|
|
540
710
|
// `deepObject.Foo.Bar` → the members nested under `Foo.Bar`
|
|
541
711
|
if (expr?.type === 'MemberExpression') {
|
|
542
712
|
const prop = expr.property;
|
|
@@ -620,8 +790,8 @@ class ExpressionResolver {
|
|
|
620
790
|
}
|
|
621
791
|
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
622
792
|
}
|
|
623
|
-
|
|
624
|
-
|
|
793
|
+
const name = tsType.type === 'TsTypeReference' ? this.typeRefName(tsType) : undefined;
|
|
794
|
+
if (name) {
|
|
625
795
|
// `Base<'DUCK'>` → instantiate the generic type's members with the argument
|
|
626
796
|
const args = tsType.typeParams?.params;
|
|
627
797
|
const params = this.objectTypeParams.get(name);
|
|
@@ -675,7 +845,7 @@ class ExpressionResolver {
|
|
|
675
845
|
obj = obj.typeAnnotation;
|
|
676
846
|
if (obj?.type === 'TsIndexedAccessType')
|
|
677
847
|
obj = this.indexedAccessTarget(obj);
|
|
678
|
-
const name = obj?.type === 'TsTypeReference' && !obj.typeParams
|
|
848
|
+
const name = obj?.type === 'TsTypeReference' && !obj.typeParams ? this.typeRefName(obj) : undefined;
|
|
679
849
|
const members = obj?.type === 'TsTypeLiteral'
|
|
680
850
|
? obj.members
|
|
681
851
|
: name && !this.objectTypeParams.has(name) ? this.objectTypeMembersRaw.get(name) : undefined;
|
|
@@ -722,7 +892,7 @@ class ExpressionResolver {
|
|
|
722
892
|
* inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
|
|
723
893
|
*/
|
|
724
894
|
arrayValuesOf(expr) {
|
|
725
|
-
expr = unwrapExpr(expr);
|
|
895
|
+
expr = this.unwrapNamespace(unwrapExpr(expr));
|
|
726
896
|
if (expr?.type === 'Identifier')
|
|
727
897
|
return this.getVariableValues(expr.value);
|
|
728
898
|
if (expr?.type === 'ArrayExpression')
|
|
@@ -740,7 +910,7 @@ class ExpressionResolver {
|
|
|
740
910
|
* typed member (`props.items`).
|
|
741
911
|
*/
|
|
742
912
|
arrayMembersOf(expr) {
|
|
743
|
-
expr = unwrapExpr(expr);
|
|
913
|
+
expr = this.unwrapNamespace(unwrapExpr(expr));
|
|
744
914
|
if (expr?.type === 'Identifier')
|
|
745
915
|
return this.arrayElementMembers.get(expr.value);
|
|
746
916
|
if (expr?.type === 'ArrayExpression')
|
|
@@ -833,7 +1003,7 @@ class ExpressionResolver {
|
|
|
833
1003
|
};
|
|
834
1004
|
store();
|
|
835
1005
|
if (this.recording && (returnType || refs.length > 0))
|
|
836
|
-
this.replays.push(store);
|
|
1006
|
+
this.replays.push(this.inCurrentFile(store));
|
|
837
1007
|
}
|
|
838
1008
|
/**
|
|
839
1009
|
* Collect a function's return expressions (the expression body of an arrow
|
|
@@ -942,10 +1112,7 @@ class ExpressionResolver {
|
|
|
942
1112
|
const v = this.variableTable.get(name);
|
|
943
1113
|
if (v && !Array.isArray(v) && typeof v === 'object')
|
|
944
1114
|
return v;
|
|
945
|
-
|
|
946
|
-
if (ev)
|
|
947
|
-
return ev;
|
|
948
|
-
return undefined;
|
|
1115
|
+
return this.sharedObjectMapTable.get(name) ?? this.sharedEnumTable.get(name);
|
|
949
1116
|
}
|
|
950
1117
|
/**
|
|
951
1118
|
* Capture a TypeScript enum declaration so members can be resolved later.
|
|
@@ -1026,7 +1193,8 @@ class ExpressionResolver {
|
|
|
1026
1193
|
*/
|
|
1027
1194
|
resolvePossibleStringValuesFromExpression(expression, returnEmptyStrings = false) {
|
|
1028
1195
|
// `t(('key'))` / `t(cond ? 'a' : ('b'))`: parens are just a wrapper node (#295).
|
|
1029
|
-
|
|
1196
|
+
// `Types.COLORS` with `import * as Types` → `COLORS`
|
|
1197
|
+
expression = this.unwrapNamespace(unwrapParens(expression));
|
|
1030
1198
|
// `pet.category?.kind` → `pet.category.kind`
|
|
1031
1199
|
if (expression.type === 'OptionalChainingExpression') {
|
|
1032
1200
|
return this.resolvePossibleStringValuesFromExpression(expression.base, returnEmptyStrings);
|
|
@@ -1111,7 +1279,7 @@ class ExpressionResolver {
|
|
|
1111
1279
|
// MemberExpression: try to resolve object identifier to an object map in the symbol table
|
|
1112
1280
|
if (expression.type === 'MemberExpression') {
|
|
1113
1281
|
try {
|
|
1114
|
-
const obj = expression.object;
|
|
1282
|
+
const obj = this.unwrapNamespace(expression.object);
|
|
1115
1283
|
const prop = expression.property;
|
|
1116
1284
|
const propName = prop.type === 'Identifier'
|
|
1117
1285
|
? prop.value
|
|
@@ -1126,7 +1294,7 @@ class ExpressionResolver {
|
|
|
1126
1294
|
// only handle simple identifier base + simple property (Identifier or computed StringLiteral)
|
|
1127
1295
|
if (obj.type === 'Identifier') {
|
|
1128
1296
|
const baseVar = this.variableTable.get(obj.value);
|
|
1129
|
-
const baseShared = this.sharedEnumTable.get(obj.value);
|
|
1297
|
+
const baseShared = this.sharedObjectMapTable.get(obj.value) ?? this.sharedEnumTable.get(obj.value);
|
|
1130
1298
|
const base = baseVar ?? baseShared;
|
|
1131
1299
|
if (base && typeof base !== 'string' && !Array.isArray(base)) {
|
|
1132
1300
|
if (propName && base[propName] !== undefined) {
|
|
@@ -1163,7 +1331,7 @@ class ExpressionResolver {
|
|
|
1163
1331
|
// the shared cross-file table populated during pre-scan.
|
|
1164
1332
|
if (expression.type === 'CallExpression') {
|
|
1165
1333
|
try {
|
|
1166
|
-
const callee = expression.callee;
|
|
1334
|
+
const callee = this.unwrapNamespace(expression.callee);
|
|
1167
1335
|
if (callee?.type === 'Identifier') {
|
|
1168
1336
|
const v = this.variableTable.get(callee.value);
|
|
1169
1337
|
if (Array.isArray(v) && v.length > 0)
|
|
@@ -1296,9 +1464,7 @@ class ExpressionResolver {
|
|
|
1296
1464
|
// where `type ChangeType = 'all' | 'next' | 'this'` was captured earlier.
|
|
1297
1465
|
// Also handles `declare const d: SomeEnum` where SomeEnum is a TS enum with string values.
|
|
1298
1466
|
if (type.type === 'TsTypeReference') {
|
|
1299
|
-
const typeName =
|
|
1300
|
-
? type.typeName.value
|
|
1301
|
-
: undefined;
|
|
1467
|
+
const typeName = this.typeRefName(type);
|
|
1302
1468
|
if (typeName) {
|
|
1303
1469
|
// Inside a generic type: the parameter's argument, default or constraint
|
|
1304
1470
|
const bound = this.typeParamBindings.get(typeName);
|
|
@@ -1336,7 +1502,7 @@ class ExpressionResolver {
|
|
|
1336
1502
|
// SWC: TsTypeQuery.exprName is TsEntityName (Identifier | TsQualifiedName)
|
|
1337
1503
|
const exprName = objType.exprName ?? objType.expr ?? objType.entityName;
|
|
1338
1504
|
// access .value (Identifier) or fall back to .name for alternate SWC builds
|
|
1339
|
-
const varName = exprName
|
|
1505
|
+
const varName = this.typeQueryName(exprName);
|
|
1340
1506
|
if (varName) {
|
|
1341
1507
|
const vals = this.getVariableValues(varName);
|
|
1342
1508
|
if (vals && vals.length > 0)
|
|
@@ -1371,17 +1537,17 @@ class ExpressionResolver {
|
|
|
1371
1537
|
// Object.keys(MAP).forEach(k => t(MAP[k]))
|
|
1372
1538
|
if (type.type === 'TsTypeOperator') {
|
|
1373
1539
|
try {
|
|
1374
|
-
const op = type.
|
|
1540
|
+
const op = type.op;
|
|
1375
1541
|
if (op === 'keyof') {
|
|
1376
1542
|
let inner = type.typeAnnotation;
|
|
1377
1543
|
while (inner?.type === 'TsParenthesizedType')
|
|
1378
1544
|
inner = inner.typeAnnotation;
|
|
1379
1545
|
if (inner?.type === 'TsTypeQuery' || inner?.type === 'TSTypeQuery') {
|
|
1380
1546
|
const exprName = inner.exprName ?? inner.expr ?? inner.entityName;
|
|
1381
|
-
const varName = exprName
|
|
1547
|
+
const varName = this.typeQueryName(exprName);
|
|
1382
1548
|
if (varName) {
|
|
1383
|
-
// Look up in variableTable (local) or
|
|
1384
|
-
const v = this.variableTable.get(varName) ?? this.
|
|
1549
|
+
// Look up in variableTable (local) or sharedObjectMapTable (cross-file) for object maps
|
|
1550
|
+
const v = this.variableTable.get(varName) ?? this.sharedObjectMapTable.get(varName);
|
|
1385
1551
|
if (v && !Array.isArray(v) && typeof v === 'object') {
|
|
1386
1552
|
return Object.keys(v);
|
|
1387
1553
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { defineConfig } from './config.js';
|
|
|
2
2
|
export { extract, runExtractor } from './extractor/core/extractor.js';
|
|
3
3
|
export { findKeys } from './extractor/core/key-finder.js';
|
|
4
4
|
export { getTranslations } from './extractor/core/translation-manager.js';
|
|
5
|
+
import 'node:path';
|
|
5
6
|
import 'node:module';
|
|
6
7
|
export { recommendedAcceptedAttributes, recommendedAcceptedTags, runLinter } from './linter.js';
|
|
7
8
|
export { runSyncer } from './syncer.js';
|
|
@@ -13,5 +14,4 @@ import './utils/jsx-attributes.js';
|
|
|
13
14
|
import 'magic-string';
|
|
14
15
|
export { runLocalize } from './localize/localize.js';
|
|
15
16
|
import 'node:fs/promises';
|
|
16
|
-
import 'node:path';
|
|
17
17
|
export { AGENT_PROMPT } from './localize/agent-prompt.js';
|
|
@@ -6,8 +6,8 @@ import { glob } from 'glob';
|
|
|
6
6
|
import { loadConfig, ensureConfig } from '../config.js';
|
|
7
7
|
import { detectConfig } from '../heuristic-config.js';
|
|
8
8
|
import { runExtractor } from '../extractor/core/extractor.js';
|
|
9
|
-
import 'node:module';
|
|
10
9
|
import 'node:path';
|
|
10
|
+
import 'node:module';
|
|
11
11
|
import { getNestedKeys, getNestedValue } from '../utils/nested-object.js';
|
|
12
12
|
import 'jiti';
|
|
13
13
|
import '@croct/json5-parser';
|
package/package.json
CHANGED
|
@@ -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,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3H,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAiB,MAAM,mCAAmC,CAAA;AAuCrF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,KAAK,CAAiB;IAE9B,IAAW,UAAU,gBAEpB;IAGD,SAAgB,YAAY,EAAE,YAAY,EAAE,CAAK;IAEjD,SAAgB,YAAY,EAAE,YAAY,CAAA;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO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],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAmB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"key-finder.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/key-finder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAmB,MAAM,gBAAgB,CAAA;AAQjG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CA8FxG"}
|
|
@@ -7,6 +7,7 @@ export declare class ExpressionResolver {
|
|
|
7
7
|
private sharedEnumTable;
|
|
8
8
|
private typeAliasTable;
|
|
9
9
|
private sharedVariableTable;
|
|
10
|
+
private sharedObjectMapTable;
|
|
10
11
|
private sharedTypeAliasTable;
|
|
11
12
|
private sharedFunctionReturnTable;
|
|
12
13
|
private temporaryVariables;
|
|
@@ -15,6 +16,7 @@ export declare class ExpressionResolver {
|
|
|
15
16
|
private temporaryObjectVariables;
|
|
16
17
|
private arrayElementMembers;
|
|
17
18
|
private sharedImportAliases;
|
|
19
|
+
private sharedNamespaceNames;
|
|
18
20
|
private objectTypeParams;
|
|
19
21
|
private typeParamBindings;
|
|
20
22
|
private sharedFunctionReturnMembers;
|
|
@@ -25,7 +27,24 @@ export declare class ExpressionResolver {
|
|
|
25
27
|
private grew;
|
|
26
28
|
private memberDepth;
|
|
27
29
|
maxMemberDepth: number;
|
|
30
|
+
private currentModule;
|
|
31
|
+
private knownModules;
|
|
32
|
+
private fileImports;
|
|
33
|
+
private fileNamespaces;
|
|
34
|
+
pathAliases: Record<string, string>;
|
|
28
35
|
constructor(hooks: ASTVisitorHooks);
|
|
36
|
+
setCurrentFile(file: string): void;
|
|
37
|
+
private importPath;
|
|
38
|
+
private moduleOf;
|
|
39
|
+
keysOf(name: string): string[];
|
|
40
|
+
declaringKey(name: string): string | undefined;
|
|
41
|
+
private inCurrentFile;
|
|
42
|
+
/**
|
|
43
|
+
* `Color` / `Types.Color` / `NS.Inner.Color` -> 'Color'. Declarations are looked up by their
|
|
44
|
+
* own name, so a qualified name resolves by its last part, whatever namespace holds it, and
|
|
45
|
+
* through a namespace import of a module (`GH.components`) by that module's declaration.
|
|
46
|
+
*/
|
|
47
|
+
typeRefName(type: any): string | undefined;
|
|
29
48
|
/**
|
|
30
49
|
* Clear per-file captured variables. Enums / shared maps are kept.
|
|
31
50
|
*/
|
|
@@ -73,6 +92,12 @@ export declare class ExpressionResolver {
|
|
|
73
92
|
* where `imported` is null for a non-renaming import (nothing to record then).
|
|
74
93
|
*/
|
|
75
94
|
captureImportDeclaration(node: any): void;
|
|
95
|
+
/**
|
|
96
|
+
* `Types.COLORS` → `COLORS` when `Types` is a namespace import (also one renamed by
|
|
97
|
+
* `import { Types as T }` from a barrel); any other expression is returned as is.
|
|
98
|
+
*/
|
|
99
|
+
unwrapNamespace(expr: any): any;
|
|
100
|
+
private typeQueryName;
|
|
76
101
|
/**
|
|
77
102
|
* Mirror every declaration captured under its declared name onto the local
|
|
78
103
|
* names it was imported as. Must run after the pre-scan pass has seen all
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"expression-resolver.d.ts","s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