i18next-cli 1.19.3 → 1.20.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/CHANGELOG.md +4 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/ast-visitors.js +1 -1
- package/dist/cjs/extractor/core/key-finder.js +1 -1
- package/dist/cjs/extractor/parsers/expression-resolver.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/ast-visitors.js +1 -1
- package/dist/esm/extractor/core/key-finder.js +1 -1
- package/dist/esm/extractor/parsers/expression-resolver.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/extractor/core/ast-visitors.ts +15 -3
- package/src/extractor/core/key-finder.ts +4 -1
- package/src/extractor/parsers/expression-resolver.ts +31 -1
- package/types/extractor/core/ast-visitors.d.ts +2 -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 +5 -0
- package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.20.0](https://github.com/i18next/i18next-cli/compare/v1.19.3...v1.20.0) - 2025-11-03
|
|
9
|
+
|
|
10
|
+
- feat(extractor): statically extract keys referenced via TypeScript enums (e.g. `t(ERROR_CODE.UNKNOWN_ERROR)` → `'UNKNOWN_ERROR'`). Resolves only string-initialized enum members; conservative, non-breaking. [#87](https://github.com/i18next/i18next-cli/issues/87)
|
|
11
|
+
|
|
8
12
|
## [1.19.3](https://github.com/i18next/i18next-cli/compare/v1.19.2...v1.19.3) - 2025-11-02
|
|
9
13
|
|
|
10
14
|
- fix(extractor): improving preserve flat JSON output when extract.defaultNS is false during re-extraction. [#73](https://github.com/i18next/i18next-cli/issues/73)
|
package/dist/cjs/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("commander"),t=require("chokidar"),o=require("glob"),n=require("minimatch"),i=require("chalk"),a=require("./config.js"),r=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),g=require("./init.js"),d=require("./linter.js"),p=require("./status.js"),f=require("./locize.js");const m=new e.Command;m.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.
|
|
2
|
+
"use strict";var e=require("commander"),t=require("chokidar"),o=require("glob"),n=require("minimatch"),i=require("chalk"),a=require("./config.js"),r=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),g=require("./init.js"),d=require("./linter.js"),p=require("./status.js"),f=require("./locize.js");const m=new e.Command;m.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.20.0"),m.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),m.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async e=>{try{const o=m.opts().config,i=await a.ensureConfig(o),r=async()=>{const t=await c.runExtractor(i,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:!!e.syncPrimary});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await r(),e.watch){console.log("\nWatching for changes...");const e=await w(i.extract.input),o=y(i.extract.ignore),a=h(i.extract.output),c=[...o,...a].filter(Boolean),s=e.filter(e=>!c.some(t=>n.minimatch(e,t,{dot:!0})));t.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),r()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),m.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,t)=>{const o=m.opts().config;let n=await a.loadConfig(o);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await r.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await p.runStatus(n,{detail:e,namespace:t.namespace})}),m.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const o=m.opts().config,i=await a.ensureConfig(o),r=()=>s.runTypesGenerator(i);if(await r(),e.watch){console.log("\nWatching for changes...");const e=await w(i.types?.input||[]),o=[...y(i.extract?.ignore)].filter(Boolean),a=e.filter(e=>!o.some(t=>n.minimatch(e,t,{dot:!0})));t.watch(a,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),r()})}}),m.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=m.opts().config,t=await a.ensureConfig(e);await l.runSyncer(t)}),m.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),m.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(g.runInit),m.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const o=m.opts().config,c=async()=>{let e=await a.loadConfig(o);if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const t=await r.detectConfig();t||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=t}await d.runLinterCli(e)};if(await c(),e.watch){console.log("\nWatching for changes...");const e=await a.loadConfig(o);if(e?.extract?.input){const o=await w(e.extract.input),i=[...y(e.extract.ignore),...h(e.extract.output)].filter(Boolean),a=o.filter(e=>!i.some(t=>n.minimatch(e,t,{dot:!0})));t.watch(a,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),c()})}}}),m.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const t=m.opts().config,o=await a.ensureConfig(t);await f.runLocizeSync(o,e)}),m.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const t=m.opts().config,o=await a.ensureConfig(t);await f.runLocizeDownload(o,e)}),m.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const t=m.opts().config,o=await a.ensureConfig(t);await f.runLocizeMigrate(o,e)}),m.parse(process.argv);const y=e=>Array.isArray(e)?e:e?[e]:[],h=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],w=async(e=[])=>{const t=y(e),n=await Promise.all(t.map(e=>o.glob(e||"",{nodir:!0})));return Array.from(new Set(n.flat()))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../parsers/scope-manager.js"),s=require("../parsers/expression-resolver.js"),r=require("../parsers/call-expression-handler.js"),
|
|
1
|
+
"use strict";var e=require("../parsers/scope-manager.js"),s=require("../parsers/expression-resolver.js"),r=require("../parsers/call-expression-handler.js"),a=require("../parsers/jsx-handler.js");exports.ASTVisitors=class{pluginContext;config;logger;hooks;get objectKeys(){return this.callExpressionHandler.objectKeys}scopeManager;expressionResolver;callExpressionHandler;jsxHandler;constructor(o,t,i,n,l){this.pluginContext=t,this.config=o,this.logger=i,this.hooks={onBeforeVisitNode:n?.onBeforeVisitNode,onAfterVisitNode:n?.onAfterVisitNode,resolvePossibleKeyStringValues:n?.resolvePossibleKeyStringValues,resolvePossibleContextStringValues:n?.resolvePossibleContextStringValues},this.scopeManager=new e.ScopeManager(o),this.expressionResolver=l??new s.ExpressionResolver(this.hooks),this.callExpressionHandler=new r.CallExpressionHandler(o,t,i,this.expressionResolver),this.jsxHandler=new a.JSXHandler(o,t,this.expressionResolver)}visit(e){this.scopeManager.reset(),this.scopeManager.enterScope(),this.walk(e),this.scopeManager.exitScope()}walk(e){if(!e)return;let s=!1;switch("Function"!==e.type&&"ArrowFunctionExpression"!==e.type&&"FunctionExpression"!==e.type||(this.scopeManager.enterScope(),s=!0),this.hooks.onBeforeVisitNode?.(e),e.type){case"VariableDeclarator":this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);break;case"TSEnumDeclaration":case"TsEnumDeclaration":case"TsEnumDecl":this.expressionResolver.captureEnumDeclaration(e);break;case"CallExpression":this.callExpressionHandler.handleCallExpression(e,this.scopeManager.getVarFromScope.bind(this.scopeManager));break;case"JSXElement":this.jsxHandler.handleJSXElement(e,this.scopeManager.getVarFromScope.bind(this.scopeManager))}this.hooks.onAfterVisitNode?.(e);for(const s in e){if("span"===s)continue;const r=e[s];if(Array.isArray(r)){for(const e of r)if(e&&"object"==typeof e)if("VariableDeclarator"!==e.type){if(e&&e.id&&Array.isArray(e.members)&&this.expressionResolver.captureEnumDeclaration(e),"VariableDeclaration"===e.type&&Array.isArray(e.declarations))for(const s of e.declarations)s&&"object"==typeof s&&"VariableDeclarator"===s.type&&(this.scopeManager.handleVariableDeclarator(s),this.expressionResolver.captureVariableDeclarator(s))}else this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);for(const e of r)e&&"object"==typeof e&&this.walk(e)}else r&&"object"==typeof r&&this.walk(r)}s&&this.scopeManager.exitScope()}getVarFromScope(e){return this.scopeManager.getVarFromScope(e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("glob"),r=require("./extractor.js"),t=require("../../utils/logger.js"),
|
|
1
|
+
"use strict";var e=require("glob"),r=require("./extractor.js"),t=require("../../utils/logger.js"),o=require("../plugin-manager.js"),n=require("./ast-visitors.js"),s=require("../parsers/expression-resolver.js");exports.findKeys=async function(i,a=new t.ConsoleLogger){const{plugins:l,...c}=i,u=l||[],g=await async function(r){const t=["node_modules/**"],o=Array.isArray(r.extract.ignore)?r.extract.ignore:r.extract.ignore?[r.extract.ignore]:[];return await e.glob(r.extract.input,{ignore:[...t,...o],cwd:process.cwd()})}(i),x=new Map,p=o.createPluginContext(x,u,c,a),d={onBeforeVisitNode:e=>{for(const r of u)try{r.onVisitNode?.(e,p)}catch(e){a.warn(`Plugin ${r.name} onVisitNode failed:`,e)}},resolvePossibleKeyStringValues:e=>u.flatMap(r=>{try{return r.extractKeysFromExpression?.(e,i,a)??[]}catch(e){return a.warn(`Plugin ${r.name} extractKeysFromExpression failed:`,e),[]}}),resolvePossibleContextStringValues:e=>u.flatMap(r=>{try{return r.extractContextFromExpression?.(e,i,a)??[]}catch(e){return a.warn(`Plugin ${r.name} extractContextFromExpression failed:`,e),[]}})},f=new s.ExpressionResolver(d),w=new n.ASTVisitors(c,p,a,d,f);p.getVarFromScope=w.getVarFromScope.bind(w),await o.initializePlugins(u);for(const e of g)await r.processFile(e,u,w,p,c,a);for(const e of u)await(e.onEnd?.(x));const y=c.extract?.pluralSeparator??"_",m=["zero","one","two","few","many","other"];for(const e of x.values()){const r=String(e.key).split(y),t=r[r.length-1],o=r.length>=3&&"ordinal"===r[r.length-2];(m.includes(t)||o&&m.includes(t))&&(e.isExpandedPlural=!0)}return{allKeys:x,objectKeys:w.objectKeys}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.ExpressionResolver=class{hooks;symbolTable=new Map;constructor(e){this.hooks=e}captureVariableDeclarator(e){try{if(!e||!e.id||!e.init)return;if("Identifier"!==e.id.type)return;const
|
|
1
|
+
"use strict";exports.ExpressionResolver=class{hooks;symbolTable=new Map;constructor(e){this.hooks=e}captureVariableDeclarator(e){try{if(!e||!e.id||!e.init)return;if("Identifier"!==e.id.type)return;const t=e.id.value,r=e.init;if("ObjectExpression"===r.type&&Array.isArray(r.properties)){const e={};for(const t of r.properties){if(!t||"KeyValueProperty"!==t.type)continue;const r=t.key,s="Identifier"===r?.type||"StringLiteral"===r?.type?r.value:void 0;if(!s)continue;const i=t.value,o=this.resolvePossibleStringValuesFromExpression(i);1===o.length&&(e[s]=o[0])}if(Object.keys(e).length>0)return void this.symbolTable.set(t,e)}const s=this.resolvePossibleStringValuesFromExpression(r);s.length>0&&this.symbolTable.set(t,s)}catch{}}captureEnumDeclaration(e){try{if(!e||!e.id||!Array.isArray(e.members))return;const t="Identifier"===e.id.type?e.id.value:void 0;if(!t)return;const r={};for(const t of e.members){if(!t||!t.id)continue;const e=t.id,s="Identifier"===e.type||"StringLiteral"===e.type?e.value:void 0;if(!s)continue;const i=t.init??t.initializer;i&&"StringLiteral"===i.type&&(r[s]=i.value)}Object.keys(r).length>0&&this.symbolTable.set(t,r)}catch{}}resolvePossibleContextStringValues(e){return[...this.hooks.resolvePossibleContextStringValues?.(e)??[],...this.resolvePossibleStringValuesFromExpression(e)]}resolvePossibleKeyStringValues(e){return[...this.hooks.resolvePossibleKeyStringValues?.(e)??[],...this.resolvePossibleStringValuesFromExpression(e)]}resolvePossibleStringValuesFromExpression(e,t=!1){if("StringLiteral"===e.type)return e.value||t?[e.value]:[];if("ConditionalExpression"===e.type){return[...this.resolvePossibleStringValuesFromExpression(e.consequent,t),...this.resolvePossibleStringValuesFromExpression(e.alternate,t)]}if("Identifier"===e.type&&"undefined"===e.value)return[];if("TemplateLiteral"===e.type)return this.resolvePossibleStringValuesFromTemplateString(e);if("MemberExpression"===e.type)try{const t=e.object,r=e.property;if("Identifier"===t.type){const e=this.symbolTable.get(t.value);if(e&&"string"!=typeof e&&!Array.isArray(e)){let t;if("Identifier"===r.type?t=r.value:"Computed"===r.type&&"StringLiteral"===r.expression?.type&&(t=r.expression.value),t&&void 0!==e[t])return[e[t]]}}}catch{}if(e.left&&e.right)try{const r=this.resolvePossibleStringValuesFromExpression(e.left,t),s=this.resolvePossibleStringValuesFromExpression(e.right,t);if(r.length>0&&s.length>0){const e=[];for(const t of r)for(const r of s)e.push(`${t}${r}`);return e}}catch{}if("NumericLiteral"===e.type||"BooleanLiteral"===e.type)return[`${e.value}`];if("TsSatisfiesExpression"===e.type||"TsAsExpression"===e.type){const r=e.typeAnnotation;return this.resolvePossibleStringValuesFromType(r,t)}if("Identifier"===e.type){const t=this.symbolTable.get(e.value);return t&&Array.isArray(t)?t:[]}return[]}resolvePossibleStringValuesFromType(e,t=!1){if("TsUnionType"===e.type)return e.types.flatMap(e=>this.resolvePossibleStringValuesFromType(e,t));if("TsLiteralType"===e.type){if("StringLiteral"===e.literal.type)return e.literal.value||t?[e.literal.value]:[];if("TemplateLiteral"===e.literal.type)return this.resolvePossibleStringValuesFromTemplateLiteralType(e.literal);if("NumericLiteral"===e.literal.type||"BooleanLiteral"===e.literal.type)return[`${e.literal.value}`]}return[]}resolvePossibleStringValuesFromTemplateString(e){if(1===e.quasis.length&&0===e.expressions.length)return[e.quasis[0].cooked||""];const[t,...r]=e.quasis;return e.expressions.reduce((e,t,s)=>e.flatMap(e=>{const i=r[s]?.cooked??"";return this.resolvePossibleStringValuesFromExpression(t,!0).map(t=>`${e}${t}${i}`)}),[t.cooked??""])}resolvePossibleStringValuesFromTemplateLiteralType(e){if(1===e.quasis.length&&0===e.types.length)return[e.quasis[0].cooked||""];const[t,...r]=e.quasis;return e.types.reduce((e,t,s)=>e.flatMap(e=>{const i=r[s]?.cooked??"";return this.resolvePossibleStringValuesFromType(t,!0).map(t=>`${e}${t}${i}`)}),[t.cooked??""])}};
|
package/dist/esm/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as t}from"commander";import o from"chokidar";import{glob as e}from"glob";import{minimatch as i}from"minimatch";import n from"chalk";import{ensureConfig as a,loadConfig as r}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as m}from"./migrator.js";import{runInit as f}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";const w=new t;w.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.
|
|
2
|
+
import{Command as t}from"commander";import o from"chokidar";import{glob as e}from"glob";import{minimatch as i}from"minimatch";import n from"chalk";import{ensureConfig as a,loadConfig as r}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as m}from"./migrator.js";import{runInit as f}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";const w=new t;w.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.20.0"),w.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),w.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").action(async t=>{try{const e=w.opts().config,n=await a(e),r=async()=>{const o=await s(n,{isWatchMode:!!t.watch,isDryRun:!!t.dryRun,syncPrimaryWithDefaults:!!t.syncPrimary});return t.ci&&!o?(console.log("✅ No files were updated."),process.exit(0)):t.ci&&o&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),o};if(await r(),t.watch){console.log("\nWatching for changes...");const t=await z(n.extract.input),e=x(n.extract.ignore),a=j(n.extract.output),c=[...e,...a].filter(Boolean),s=t.filter(t=>!c.some(o=>i(t,o,{dot:!0})));o.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),r()})}}catch(t){console.error("Error running extractor:",t),process.exit(1)}}),w.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(t,o)=>{const e=w.opts().config;let i=await r(e);if(!i){console.log(n.blue("No config file found. Attempting to detect project structure..."));const t=await c();t||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),i=t}await g(i,{detail:t,namespace:o.namespace})}),w.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async t=>{const e=w.opts().config,n=await a(e),r=()=>l(n);if(await r(),t.watch){console.log("\nWatching for changes...");const t=await z(n.types?.input||[]),e=[...x(n.extract?.ignore)].filter(Boolean),a=t.filter(t=>!e.some(o=>i(t,o,{dot:!0})));o.watch(a,{persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),r()})}}),w.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const t=w.opts().config,o=await a(t);await p(o)}),w.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async t=>{await m(t)}),w.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(f),w.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async t=>{const e=w.opts().config,a=async()=>{let t=await r(e);if(!t){console.log(n.blue("No config file found. Attempting to detect project structure..."));const o=await c();o||(console.error(n.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${n.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(n.green("Project structure detected successfully!")),t=o}await d(t)};if(await a(),t.watch){console.log("\nWatching for changes...");const t=await r(e);if(t?.extract?.input){const e=await z(t.extract.input),n=[...x(t.extract.ignore),...j(t.extract.output)].filter(Boolean),r=e.filter(t=>!n.some(o=>i(t,o,{dot:!0})));o.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",t=>{console.log(`\nFile changed: ${t}`),a()})}}}),w.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async t=>{const o=w.opts().config,e=await a(o);await u(e,t)}),w.command("locize-download").description("Download all translations from your locize project.").action(async t=>{const o=w.opts().config,e=await a(o);await y(e,t)}),w.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async t=>{const o=w.opts().config,e=await a(o);await h(e,t)}),w.parse(process.argv);const x=t=>Array.isArray(t)?t:t?[t]:[],j=t=>t&&"string"==typeof t?[t.replace(/\{\{[^}]+\}\}/g,"*")]:[],z=async(t=[])=>{const o=x(t),i=await Promise.all(o.map(t=>e(t||"",{nodir:!0})));return Array.from(new Set(i.flat()))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ScopeManager as e}from"../parsers/scope-manager.js";import{ExpressionResolver as s}from"../parsers/expression-resolver.js";import{CallExpressionHandler as r}from"../parsers/call-expression-handler.js";import{JSXHandler as o}from"../parsers/jsx-handler.js";class a{pluginContext;config;logger;hooks;get objectKeys(){return this.callExpressionHandler.objectKeys}scopeManager;expressionResolver;callExpressionHandler;jsxHandler;constructor(a,t,i,n){this.pluginContext=t,this.config=a,this.logger=i,this.hooks={onBeforeVisitNode:n?.onBeforeVisitNode,onAfterVisitNode:n?.onAfterVisitNode,resolvePossibleKeyStringValues:n?.resolvePossibleKeyStringValues,resolvePossibleContextStringValues:n?.resolvePossibleContextStringValues},this.scopeManager=new e(a),this.expressionResolver=new s(this.hooks),this.callExpressionHandler=new r(a,t,i,this.expressionResolver),this.jsxHandler=new o(a,t,this.expressionResolver)}visit(e){this.scopeManager.reset(),this.scopeManager.enterScope(),this.walk(e),this.scopeManager.exitScope()}walk(e){if(!e)return;let s=!1;switch("Function"!==e.type&&"ArrowFunctionExpression"!==e.type&&"FunctionExpression"!==e.type||(this.scopeManager.enterScope(),s=!0),this.hooks.onBeforeVisitNode?.(e),e.type){case"VariableDeclarator":this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);break;case"CallExpression":this.callExpressionHandler.handleCallExpression(e,this.scopeManager.getVarFromScope.bind(this.scopeManager));break;case"JSXElement":this.jsxHandler.handleJSXElement(e,this.scopeManager.getVarFromScope.bind(this.scopeManager))}this.hooks.onAfterVisitNode?.(e);for(const s in e){if("span"===s)continue;const r=e[s];if(Array.isArray(r)){for(const e of r)if(e&&"object"==typeof e)if("VariableDeclarator"!==e.type){if("VariableDeclaration"===e.type&&Array.isArray(e.declarations))for(const s of e.declarations)s&&"object"==typeof s&&"VariableDeclarator"===s.type&&(this.scopeManager.handleVariableDeclarator(s),this.expressionResolver.captureVariableDeclarator(s))}else this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);for(const e of r)e&&"object"==typeof e&&this.walk(e)}else r&&"object"==typeof r&&this.walk(r)}s&&this.scopeManager.exitScope()}getVarFromScope(e){return this.scopeManager.getVarFromScope(e)}}export{a as ASTVisitors};
|
|
1
|
+
import{ScopeManager as e}from"../parsers/scope-manager.js";import{ExpressionResolver as s}from"../parsers/expression-resolver.js";import{CallExpressionHandler as r}from"../parsers/call-expression-handler.js";import{JSXHandler as o}from"../parsers/jsx-handler.js";class a{pluginContext;config;logger;hooks;get objectKeys(){return this.callExpressionHandler.objectKeys}scopeManager;expressionResolver;callExpressionHandler;jsxHandler;constructor(a,t,i,n,l){this.pluginContext=t,this.config=a,this.logger=i,this.hooks={onBeforeVisitNode:n?.onBeforeVisitNode,onAfterVisitNode:n?.onAfterVisitNode,resolvePossibleKeyStringValues:n?.resolvePossibleKeyStringValues,resolvePossibleContextStringValues:n?.resolvePossibleContextStringValues},this.scopeManager=new e(a),this.expressionResolver=l??new s(this.hooks),this.callExpressionHandler=new r(a,t,i,this.expressionResolver),this.jsxHandler=new o(a,t,this.expressionResolver)}visit(e){this.scopeManager.reset(),this.scopeManager.enterScope(),this.walk(e),this.scopeManager.exitScope()}walk(e){if(!e)return;let s=!1;switch("Function"!==e.type&&"ArrowFunctionExpression"!==e.type&&"FunctionExpression"!==e.type||(this.scopeManager.enterScope(),s=!0),this.hooks.onBeforeVisitNode?.(e),e.type){case"VariableDeclarator":this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);break;case"TSEnumDeclaration":case"TsEnumDeclaration":case"TsEnumDecl":this.expressionResolver.captureEnumDeclaration(e);break;case"CallExpression":this.callExpressionHandler.handleCallExpression(e,this.scopeManager.getVarFromScope.bind(this.scopeManager));break;case"JSXElement":this.jsxHandler.handleJSXElement(e,this.scopeManager.getVarFromScope.bind(this.scopeManager))}this.hooks.onAfterVisitNode?.(e);for(const s in e){if("span"===s)continue;const r=e[s];if(Array.isArray(r)){for(const e of r)if(e&&"object"==typeof e)if("VariableDeclarator"!==e.type){if(e&&e.id&&Array.isArray(e.members)&&this.expressionResolver.captureEnumDeclaration(e),"VariableDeclaration"===e.type&&Array.isArray(e.declarations))for(const s of e.declarations)s&&"object"==typeof s&&"VariableDeclarator"===s.type&&(this.scopeManager.handleVariableDeclarator(s),this.expressionResolver.captureVariableDeclarator(s))}else this.scopeManager.handleVariableDeclarator(e),this.expressionResolver.captureVariableDeclarator(e);for(const e of r)e&&"object"==typeof e&&this.walk(e)}else r&&"object"==typeof r&&this.walk(r)}s&&this.scopeManager.exitScope()}getVarFromScope(e){return this.scopeManager.getVarFromScope(e)}}export{a as ASTVisitors};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{glob as
|
|
1
|
+
import{glob as r}from"glob";import{processFile as e}from"./extractor.js";import{ConsoleLogger as t}from"../../utils/logger.js";import{createPluginContext as o,initializePlugins as n}from"../plugin-manager.js";import{ASTVisitors as a}from"./ast-visitors.js";import{ExpressionResolver as s}from"../parsers/expression-resolver.js";async function i(i,c=new t){const{plugins:l,...p}=i,m=l||[],f=await async function(e){const t=["node_modules/**"],o=Array.isArray(e.extract.ignore)?e.extract.ignore:e.extract.ignore?[e.extract.ignore]:[];return await r(e.extract.input,{ignore:[...t,...o],cwd:process.cwd()})}(i),u=new Map,g=o(u,m,p,c),x={onBeforeVisitNode:r=>{for(const e of m)try{e.onVisitNode?.(r,g)}catch(r){c.warn(`Plugin ${e.name} onVisitNode failed:`,r)}},resolvePossibleKeyStringValues:r=>m.flatMap(e=>{try{return e.extractKeysFromExpression?.(r,i,c)??[]}catch(r){return c.warn(`Plugin ${e.name} extractKeysFromExpression failed:`,r),[]}}),resolvePossibleContextStringValues:r=>m.flatMap(e=>{try{return e.extractContextFromExpression?.(r,i,c)??[]}catch(r){return c.warn(`Plugin ${e.name} extractContextFromExpression failed:`,r),[]}})},d=new s(x),w=new a(p,g,c,x,d);g.getVarFromScope=w.getVarFromScope.bind(w),await n(m);for(const r of f)await e(r,m,w,g,p,c);for(const r of m)await(r.onEnd?.(u));const y=p.extract?.pluralSeparator??"_",h=["zero","one","two","few","many","other"];for(const r of u.values()){const e=String(r.key).split(y),t=e[e.length-1],o=e.length>=3&&"ordinal"===e[e.length-2];(h.includes(t)||o&&h.includes(t))&&(r.isExpandedPlural=!0)}return{allKeys:u,objectKeys:w.objectKeys}}export{i as findKeys};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class e{hooks;symbolTable=new Map;constructor(e){this.hooks=e}captureVariableDeclarator(e){try{if(!e||!e.id||!e.init)return;if("Identifier"!==e.id.type)return;const
|
|
1
|
+
class e{hooks;symbolTable=new Map;constructor(e){this.hooks=e}captureVariableDeclarator(e){try{if(!e||!e.id||!e.init)return;if("Identifier"!==e.id.type)return;const t=e.id.value,r=e.init;if("ObjectExpression"===r.type&&Array.isArray(r.properties)){const e={};for(const t of r.properties){if(!t||"KeyValueProperty"!==t.type)continue;const r=t.key,s="Identifier"===r?.type||"StringLiteral"===r?.type?r.value:void 0;if(!s)continue;const i=t.value,o=this.resolvePossibleStringValuesFromExpression(i);1===o.length&&(e[s]=o[0])}if(Object.keys(e).length>0)return void this.symbolTable.set(t,e)}const s=this.resolvePossibleStringValuesFromExpression(r);s.length>0&&this.symbolTable.set(t,s)}catch{}}captureEnumDeclaration(e){try{if(!e||!e.id||!Array.isArray(e.members))return;const t="Identifier"===e.id.type?e.id.value:void 0;if(!t)return;const r={};for(const t of e.members){if(!t||!t.id)continue;const e=t.id,s="Identifier"===e.type||"StringLiteral"===e.type?e.value:void 0;if(!s)continue;const i=t.init??t.initializer;i&&"StringLiteral"===i.type&&(r[s]=i.value)}Object.keys(r).length>0&&this.symbolTable.set(t,r)}catch{}}resolvePossibleContextStringValues(e){return[...this.hooks.resolvePossibleContextStringValues?.(e)??[],...this.resolvePossibleStringValuesFromExpression(e)]}resolvePossibleKeyStringValues(e){return[...this.hooks.resolvePossibleKeyStringValues?.(e)??[],...this.resolvePossibleStringValuesFromExpression(e)]}resolvePossibleStringValuesFromExpression(e,t=!1){if("StringLiteral"===e.type)return e.value||t?[e.value]:[];if("ConditionalExpression"===e.type){return[...this.resolvePossibleStringValuesFromExpression(e.consequent,t),...this.resolvePossibleStringValuesFromExpression(e.alternate,t)]}if("Identifier"===e.type&&"undefined"===e.value)return[];if("TemplateLiteral"===e.type)return this.resolvePossibleStringValuesFromTemplateString(e);if("MemberExpression"===e.type)try{const t=e.object,r=e.property;if("Identifier"===t.type){const e=this.symbolTable.get(t.value);if(e&&"string"!=typeof e&&!Array.isArray(e)){let t;if("Identifier"===r.type?t=r.value:"Computed"===r.type&&"StringLiteral"===r.expression?.type&&(t=r.expression.value),t&&void 0!==e[t])return[e[t]]}}}catch{}if(e.left&&e.right)try{const r=this.resolvePossibleStringValuesFromExpression(e.left,t),s=this.resolvePossibleStringValuesFromExpression(e.right,t);if(r.length>0&&s.length>0){const e=[];for(const t of r)for(const r of s)e.push(`${t}${r}`);return e}}catch{}if("NumericLiteral"===e.type||"BooleanLiteral"===e.type)return[`${e.value}`];if("TsSatisfiesExpression"===e.type||"TsAsExpression"===e.type){const r=e.typeAnnotation;return this.resolvePossibleStringValuesFromType(r,t)}if("Identifier"===e.type){const t=this.symbolTable.get(e.value);return t&&Array.isArray(t)?t:[]}return[]}resolvePossibleStringValuesFromType(e,t=!1){if("TsUnionType"===e.type)return e.types.flatMap(e=>this.resolvePossibleStringValuesFromType(e,t));if("TsLiteralType"===e.type){if("StringLiteral"===e.literal.type)return e.literal.value||t?[e.literal.value]:[];if("TemplateLiteral"===e.literal.type)return this.resolvePossibleStringValuesFromTemplateLiteralType(e.literal);if("NumericLiteral"===e.literal.type||"BooleanLiteral"===e.literal.type)return[`${e.literal.value}`]}return[]}resolvePossibleStringValuesFromTemplateString(e){if(1===e.quasis.length&&0===e.expressions.length)return[e.quasis[0].cooked||""];const[t,...r]=e.quasis;return e.expressions.reduce((e,t,s)=>e.flatMap(e=>{const i=r[s]?.cooked??"";return this.resolvePossibleStringValuesFromExpression(t,!0).map(t=>`${e}${t}${i}`)}),[t.cooked??""])}resolvePossibleStringValuesFromTemplateLiteralType(e){if(1===e.quasis.length&&0===e.types.length)return[e.quasis[0].cooked||""];const[t,...r]=e.quasis;return e.types.reduce((e,t,s)=>e.flatMap(e=>{const i=r[s]?.cooked??"";return this.resolvePossibleStringValuesFromType(t,!0).map(t=>`${e}${t}${i}`)}),[t.cooked??""])}}export{e as ExpressionResolver};
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -22,7 +22,7 @@ const program = new Command()
|
|
|
22
22
|
program
|
|
23
23
|
.name('i18next-cli')
|
|
24
24
|
.description('A unified, high-performance i18next CLI.')
|
|
25
|
-
.version('1.
|
|
25
|
+
.version('1.20.0')
|
|
26
26
|
|
|
27
27
|
// new: global config override option
|
|
28
28
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)')
|
|
@@ -53,7 +53,8 @@ export class ASTVisitors {
|
|
|
53
53
|
config: Omit<I18nextToolkitConfig, 'plugins'>,
|
|
54
54
|
pluginContext: PluginContext,
|
|
55
55
|
logger: Logger,
|
|
56
|
-
hooks?: ASTVisitorHooks
|
|
56
|
+
hooks?: ASTVisitorHooks,
|
|
57
|
+
expressionResolver?: ExpressionResolver
|
|
57
58
|
) {
|
|
58
59
|
this.pluginContext = pluginContext
|
|
59
60
|
this.config = config
|
|
@@ -66,7 +67,8 @@ export class ASTVisitors {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
this.scopeManager = new ScopeManager(config)
|
|
69
|
-
|
|
70
|
+
// use shared resolver when provided so captured enums/objects are visible across files
|
|
71
|
+
this.expressionResolver = expressionResolver ?? new ExpressionResolver(this.hooks)
|
|
70
72
|
this.callExpressionHandler = new CallExpressionHandler(config, pluginContext, logger, this.expressionResolver)
|
|
71
73
|
this.jsxHandler = new JSXHandler(config, pluginContext, this.expressionResolver)
|
|
72
74
|
}
|
|
@@ -119,6 +121,12 @@ export class ASTVisitors {
|
|
|
119
121
|
// resolve identifiers / member expressions that reference them.
|
|
120
122
|
this.expressionResolver.captureVariableDeclarator(node)
|
|
121
123
|
break
|
|
124
|
+
case 'TSEnumDeclaration':
|
|
125
|
+
case 'TsEnumDeclaration':
|
|
126
|
+
case 'TsEnumDecl':
|
|
127
|
+
// capture enums into resolver symbol table
|
|
128
|
+
this.expressionResolver.captureEnumDeclaration(node)
|
|
129
|
+
break
|
|
122
130
|
case 'CallExpression':
|
|
123
131
|
this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager))
|
|
124
132
|
break
|
|
@@ -152,7 +160,11 @@ export class ASTVisitors {
|
|
|
152
160
|
this.expressionResolver.captureVariableDeclarator(item)
|
|
153
161
|
continue
|
|
154
162
|
}
|
|
155
|
-
|
|
163
|
+
// enum declarations can appear as ExportDeclaration.declaration earlier; be permissive
|
|
164
|
+
if (item && item.id && Array.isArray(item.members)) {
|
|
165
|
+
this.expressionResolver.captureEnumDeclaration(item)
|
|
166
|
+
// continue to allow further traversal
|
|
167
|
+
}
|
|
156
168
|
// Common case: VariableDeclaration which contains .declarations (VariableDeclarator[])
|
|
157
169
|
if (item.type === 'VariableDeclaration' && Array.isArray(item.declarations)) {
|
|
158
170
|
for (const decl of item.declarations) {
|
|
@@ -5,6 +5,7 @@ import { processFile } from './extractor'
|
|
|
5
5
|
import { ConsoleLogger } from '../../utils/logger'
|
|
6
6
|
import { initializePlugins, createPluginContext } from '../plugin-manager'
|
|
7
7
|
import { ASTVisitors } from './ast-visitors'
|
|
8
|
+
import { ExpressionResolver } from '../parsers/expression-resolver'
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Main function for finding translation keys across all source files in a project.
|
|
@@ -81,7 +82,9 @@ export async function findKeys (
|
|
|
81
82
|
} satisfies ASTVisitorHooks
|
|
82
83
|
|
|
83
84
|
// 3. Create the visitor instance, passing it the context.
|
|
84
|
-
|
|
85
|
+
// Use a shared ExpressionResolver so captured enums/objects in one file are available when resolving MemberExpressions
|
|
86
|
+
const sharedExpressionResolver = new ExpressionResolver(hooks)
|
|
87
|
+
const astVisitors = new ASTVisitors(otherConfig, pluginContext, logger, hooks, sharedExpressionResolver)
|
|
85
88
|
|
|
86
89
|
// 4. "Wire up" the visitor's scope method to the context.
|
|
87
90
|
// This avoids a circular dependency while giving plugins access to the scope.
|
|
@@ -63,6 +63,34 @@ export class ExpressionResolver {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Capture a TypeScript enum declaration so members can be resolved later.
|
|
68
|
+
* Accepts SWC node shapes like `TsEnumDeclaration` / `TSEnumDeclaration`.
|
|
69
|
+
*/
|
|
70
|
+
captureEnumDeclaration (node: any): void {
|
|
71
|
+
try {
|
|
72
|
+
if (!node || !node.id || !Array.isArray(node.members)) return
|
|
73
|
+
const name = node.id.type === 'Identifier' ? node.id.value : undefined
|
|
74
|
+
if (!name) return
|
|
75
|
+
const map: Record<string, string> = {}
|
|
76
|
+
for (const m of node.members) {
|
|
77
|
+
if (!m || !m.id) continue
|
|
78
|
+
const keyNode = m.id
|
|
79
|
+
const memberName = keyNode.type === 'Identifier' ? keyNode.value : keyNode.type === 'StringLiteral' ? keyNode.value : undefined
|
|
80
|
+
if (!memberName) continue
|
|
81
|
+
const init = (m as any).init ?? (m as any).initializer
|
|
82
|
+
if (init && init.type === 'StringLiteral') {
|
|
83
|
+
map[memberName] = init.value
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (Object.keys(map).length > 0) {
|
|
87
|
+
this.symbolTable.set(name, map)
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
// noop
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
66
94
|
/**
|
|
67
95
|
* Resolves an expression to one or more possible context string values that can be
|
|
68
96
|
* determined statically from the AST. This is a wrapper around the plugin hook
|
|
@@ -140,7 +168,9 @@ export class ExpressionResolver {
|
|
|
140
168
|
let propName: string | undefined
|
|
141
169
|
if (prop.type === 'Identifier') propName = prop.value
|
|
142
170
|
else if (prop.type === 'Computed' && prop.expression?.type === 'StringLiteral') propName = prop.expression.value
|
|
143
|
-
if (propName && base[propName] !== undefined)
|
|
171
|
+
if (propName && base[propName] !== undefined) {
|
|
172
|
+
return [base[propName]]
|
|
173
|
+
}
|
|
144
174
|
}
|
|
145
175
|
}
|
|
146
176
|
} catch {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Module } from '@swc/core';
|
|
2
2
|
import type { PluginContext, I18nextToolkitConfig, Logger, ASTVisitorHooks, ScopeInfo } from '../../types';
|
|
3
|
+
import { ExpressionResolver } from '../parsers/expression-resolver';
|
|
3
4
|
/**
|
|
4
5
|
* AST visitor class that traverses JavaScript/TypeScript syntax trees to extract translation keys.
|
|
5
6
|
*
|
|
@@ -39,7 +40,7 @@ export declare class ASTVisitors {
|
|
|
39
40
|
* @param pluginContext - Context for adding discovered translation keys
|
|
40
41
|
* @param logger - Logger for warnings and debug information
|
|
41
42
|
*/
|
|
42
|
-
constructor(config: Omit<I18nextToolkitConfig, 'plugins'>, pluginContext: PluginContext, logger: Logger, hooks?: ASTVisitorHooks);
|
|
43
|
+
constructor(config: Omit<I18nextToolkitConfig, 'plugins'>, pluginContext: PluginContext, logger: Logger, hooks?: ASTVisitorHooks, expressionResolver?: ExpressionResolver);
|
|
43
44
|
/**
|
|
44
45
|
* Main entry point for AST traversal.
|
|
45
46
|
* Creates a root scope and begins the recursive walk through the syntax tree.
|
|
@@ -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,aAAa,CAAA;
|
|
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,aAAa,CAAA;AAE1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAInE;;;;;;;;;;;;;;;;;;;;;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;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IAEvC;;;;;;OAMG;gBAED,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,kBAAkB;IAmBzC;;;;;OAKG;IACI,KAAK,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI;IAiGZ;;;;;;;;OAQG;IACI,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAG7D"}
|
|
@@ -1 +1 @@
|
|
|
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,aAAa,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,aAAa,CAAA;AAO9F;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CA6E1E"}
|
|
@@ -15,6 +15,11 @@ export declare class ExpressionResolver {
|
|
|
15
15
|
* @param node - VariableDeclarator-like node (has .id and .init)
|
|
16
16
|
*/
|
|
17
17
|
captureVariableDeclarator(node: any): void;
|
|
18
|
+
/**
|
|
19
|
+
* Capture a TypeScript enum declaration so members can be resolved later.
|
|
20
|
+
* Accepts SWC node shapes like `TsEnumDeclaration` / `TSEnumDeclaration`.
|
|
21
|
+
*/
|
|
22
|
+
captureEnumDeclaration(node: any): void;
|
|
18
23
|
/**
|
|
19
24
|
* Resolves an expression to one or more possible context string values that can be
|
|
20
25
|
* determined statically from the AST. This is a wrapper around the plugin hook
|
|
@@ -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,aAAa,CAAA;AAElD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAiB;IAK9B,OAAO,CAAC,WAAW,CAA4D;gBAElE,KAAK,EAAE,eAAe;IAInC;;;;;;;;;OASG;IACH,yBAAyB,CAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAwC3C;;;;;;;OAOG;IACH,kCAAkC,CAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE;IAKrE;;;;;;;OAOG;IACH,8BAA8B,CAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE;IAKjE;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,yCAAyC;
|
|
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,aAAa,CAAA;AAElD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAiB;IAK9B,OAAO,CAAC,WAAW,CAA4D;gBAElE,KAAK,EAAE,eAAe;IAInC;;;;;;;;;OASG;IACH,yBAAyB,CAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAwC3C;;;OAGG;IACH,sBAAsB,CAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAwBxC;;;;;;;OAOG;IACH,kCAAkC,CAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE;IAKrE;;;;;;;OAOG;IACH,8BAA8B,CAAE,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE;IAKjE;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,yCAAyC;IAkFjD,OAAO,CAAC,mCAAmC;IAwB3C;;;;;;OAMG;IACH,OAAO,CAAC,6CAA6C;IAyBrD;;;;;;OAMG;IACH,OAAO,CAAC,kDAAkD;CAwB3D"}
|