i18next-cli 1.23.5 → 1.23.7
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 +9 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/extractor.js +1 -1
- package/dist/cjs/extractor/parsers/jsx-parser.js +1 -1
- package/dist/cjs/linter.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/extractor.js +1 -1
- package/dist/esm/extractor/parsers/jsx-parser.js +1 -1
- package/dist/esm/linter.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/extractor/core/extractor.ts +2 -0
- package/src/extractor/parsers/jsx-parser.ts +263 -42
- package/src/linter.ts +2 -0
- package/types/extractor/core/extractor.d.ts.map +1 -1
- package/types/linter.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ 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.23.7](https://github.com/i18next/i18next-cli/compare/v1.23.6...v1.23.7) - 2025-11-12
|
|
9
|
+
|
|
10
|
+
- improved Trans component parsing further [102](https://github.com/i18next/i18next-cli/issues/102)
|
|
11
|
+
|
|
12
|
+
## [1.23.6](https://github.com/i18next/i18next-cli/compare/v1.23.5...v1.23.6) - 2025-11-12
|
|
13
|
+
|
|
14
|
+
- fix jsx extraction [#108](https://github.com/i18next/i18next-cli/issues/108)
|
|
15
|
+
- improved Trans component parsing for spaces [102](https://github.com/i18next/i18next-cli/issues/102)
|
|
16
|
+
|
|
8
17
|
## [1.23.5](https://github.com/i18next/i18next-cli/compare/v1.23.4...v1.23.5) - 2025-11-11
|
|
9
18
|
|
|
10
19
|
- **Extractor:** Fixed custom sort function not being applied to nested keys. When providing a custom `sort` function (e.g., for case-insensitive sorting to match locize's behavior), the sorting logic is now correctly applied throughout the entire object hierarchy, not just at the top level. This ensures consistent key ordering at all nesting levels in translation files. [#106](https://github.com/i18next/i18next-cli/issues/106)
|
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.23.
|
|
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.23.7"),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 t=require("ora"),e=require("chalk"),r=require("@swc/core"),a=require("node:fs/promises"),o=require("node:path"),n=require("./key-finder.js"),s=require("./translation-manager.js"),i=require("../../utils/validation.js"),c=require("../parsers/comment-parser.js"),l=require("../../utils/logger.js"),u=require("../../utils/file-utils.js"),y=require("../../utils/funnel-msg-tracker.js");exports.extract=async function(t,{syncPrimaryWithDefaults:e=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(e=>e!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:r,objectKeys:a}=await n.findKeys(t);return s.getTranslations(r,a,t,{syncPrimaryWithDefaults:e})},exports.processFile=async function(t,e,n,s,u,y=new l.ConsoleLogger){try{let l=await a.readFile(t,"utf-8");for(const r of e)try{const e=await(r.onLoad?.(l,t));void 0!==e&&(l=e)}catch(t){y.warn(`Plugin ${r.name} onLoad failed:`,t)}const d=o.extname(t).toLowerCase(),g=".ts"===d||".tsx"===d||".mts"===d||".cts"===d,m=".tsx"===d;let
|
|
1
|
+
"use strict";var t=require("ora"),e=require("chalk"),r=require("@swc/core"),a=require("node:fs/promises"),o=require("node:path"),n=require("./key-finder.js"),s=require("./translation-manager.js"),i=require("../../utils/validation.js"),c=require("../parsers/comment-parser.js"),l=require("../../utils/logger.js"),u=require("../../utils/file-utils.js"),y=require("../../utils/funnel-msg-tracker.js");exports.extract=async function(t,{syncPrimaryWithDefaults:e=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(e=>e!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:r,objectKeys:a}=await n.findKeys(t);return s.getTranslations(r,a,t,{syncPrimaryWithDefaults:e})},exports.processFile=async function(t,e,n,s,u,y=new l.ConsoleLogger){try{let l=await a.readFile(t,"utf-8");for(const r of e)try{const e=await(r.onLoad?.(l,t));void 0!==e&&(l=e)}catch(t){y.warn(`Plugin ${r.name} onLoad failed:`,t)}const d=o.extname(t).toLowerCase(),g=".ts"===d||".tsx"===d||".mts"===d||".cts"===d,m=".tsx"===d,p=".jsx"===d;let f;try{f=await r.parse(l,{syntax:g?"typescript":"ecmascript",tsx:m,jsx:p,decorators:!0,dynamicImport:!0,comments:!0})}catch(e){if(".ts"!==d||m)throw new i.ExtractorError("Failed to process file",t,e);try{f=await r.parse(l,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),y.info?.(`Parsed ${t} using TSX fallback`)}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}}s.getVarFromScope=n.getVarFromScope.bind(n),n.setCurrentFile(t,l),n.visit(f),c.extractKeysFromComments(l,s,u,n.getVarFromScope.bind(n))}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}},exports.runExtractor=async function(r,{isWatchMode:c=!1,isDryRun:d=!1,syncPrimaryWithDefaults:g=!1}={},m=new l.ConsoleLogger){r.extract.primaryLanguage||=r.locales[0]||"en",r.extract.secondaryLanguages||=r.locales.filter(t=>t!==r?.extract?.primaryLanguage),r.extract.functions||=["t","*.t"],r.extract.transComponents||=["Trans"],i.validateExtractorConfig(r);const p=r.plugins||[],f=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:i}=await n.findKeys(r,m);f.text=`Found ${t.size} unique keys. Updating translation files...`;const c=await s.getTranslations(t,i,r,{syncPrimaryWithDefaults:g});let l=!1;for(const t of c)if(t.updated&&(l=!0,!d)){const n=u.serializeTranslationFile(t.newTranslations,r.extract.outputFormat,r.extract.indentation);await a.mkdir(o.dirname(t.path),{recursive:!0}),await a.writeFile(t.path,n),m.info(e.green(`Updated: ${t.path}`))}if(p.length>0){f.text="Running post-extraction plugins...";for(const t of p)await(t.afterSync?.(c,r))}return f.succeed(e.bold("Extraction complete!")),l&&await async function(){if(!await y.shouldShowFunnel("extract"))return;return console.log(e.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${e.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${e.cyan("https://youtu.be/joPsZghT3wM")}`),y.recordFunnelShown("extract")}(),l}catch(t){throw f.fail(e.red("Extraction failed.")),t}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./ast-utils.js");function t(t){if(t)return"StringLiteral"===t.type?t.value:"TemplateLiteral"===t.type&&e.isSimpleTemplateLiteral(t)?t.quasis[0].cooked:void 0}function n(e){return"StringLiteral"===e.value?.type?e.value.value:"JSXExpressionContainer"===e.value?.type?t(e.value.expression):void 0}exports.extractFromTransComponent=function(i,r){const s=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"i18nKey"===e.name.value),o=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"defaults"===e.name.value),p=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"count"===e.name.value),
|
|
1
|
+
"use strict";var e=require("./ast-utils.js");function t(t){if(t)return"StringLiteral"===t.type?t.value:"TemplateLiteral"===t.type&&e.isSimpleTemplateLiteral(t)?t.quasis[0].cooked:void 0}function n(e){return"StringLiteral"===e.value?.type?e.value.value:"JSXExpressionContainer"===e.value?.type?t(e.value.expression):void 0}exports.extractFromTransComponent=function(i,r){const s=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"i18nKey"===e.name.value),o=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"defaults"===e.name.value),p=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"count"===e.name.value),a=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"values"===e.name.value);let l;p||"JSXAttribute"!==a?.type||"JSXExpressionContainer"!==a.value?.type||"ObjectExpression"!==a.value.expression.type||(l=e.getObjectPropValueExpression(a.value.expression,"count"));const u=!!p||!!l,y=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"tOptions"===e.name.value),f="JSXAttribute"===y?.type&&"JSXExpressionContainer"===y.value?.type&&"ObjectExpression"===y.value.expression.type?y.value.expression:void 0,c=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),g=!!c,d=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"context"===e.name.value);let v="JSXAttribute"===d?.type&&"JSXExpressionContainer"===d.value?.type?d.value.expression:"JSXAttribute"===d?.type&&"StringLiteral"===d.value?.type?d.value:void 0;const S=i.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ns"===e.name.value);let x;x="JSXAttribute"===S?.type?n(S):void 0,f&&(void 0===x&&(x=e.getObjectPropValue(f,"ns")),void 0===v&&(v=e.getObjectPropValueExpression(f,"context")));const J=function(e,n){if(!e||0===e.length)return"";const i=new Set(n.extract.transKeepBasicHtmlNodesFor??["br","strong","i","p"]),r=e=>e&&"JSXText"===e.type&&/^\s*$/.test(e.value)&&e.value.includes("\n");function s(e,n,o=!1,p=!1){if(!e||!e.length)return;const a=p&&e.filter(e=>e&&"JSXElement"===e.type&&"p"===e.opening?.name?.value).length>1;let l=0,u=e.length-1;for(;l<=u&&r(e[l]);)l++;for(;u>=l&&r(e[u]);)u--;const y=l<=u?e.slice(l,u+1):[],f=y.some(e=>e&&("JSXElement"===e.type||"JSXFragment"===e.type));for(let e=0;e<y.length;e++){const p=y[e];if(p)if("JSXText"!==p.type){if("JSXExpressionContainer"===p.type){if(o&&!f&&p.expression){const e=p.expression.type;if("ObjectExpression"===e){const e=p.expression.properties&&p.expression.properties[0];if(e&&"KeyValueProperty"===e.type)continue}const n=t(p.expression);if(void 0!==n){if(!(/^\s*$/.test(n)&&!n.includes("\n")))continue}else if("Identifier"===e||"MemberExpression"===e||"CallExpression"===e)continue}const i=t(p.expression);if(void 0!==i){const t=/^\s*$/.test(i)&&!i.includes("\n"),s=y[e-1],o=y[e+1];if(t){const t=y[e+2];if(o&&"JSXText"===o.type&&r(o)&&t&&("JSXElement"===t.type||"JSXFragment"===t.type)){const t=y[e-1],n=y[e-2];if(!t||"JSXText"!==t.type&&n&&"JSXExpressionContainer"===n.type)continue}if(s&&("JSXElement"===s.type||"JSXFragment"===s.type)&&o&&"JSXText"===o.type&&r(o))continue;const i=!o||"JSXText"===o.type&&!r(o);if(s&&"JSXText"===s.type&&i){const e=n[n.length-1];if(e&&"JSXText"===e.type){e.value=String(e.value)+p.expression.value;continue}}if(s&&("JSXElement"===s.type||"JSXFragment"===s.type)&&o&&"JSXText"===o.type&&r(o))continue}}n.push(p);continue}if("JSXElement"===p.type){const e=p.opening&&p.opening.name&&"Identifier"===p.opening.name.type?p.opening.name.value:void 0;if(e&&i.has(e)){const i=p.opening&&Array.isArray(p.opening.attributes)&&p.opening.attributes.length>0,r=p.children||[],o=1===r.length&&("JSXText"===r[0]?.type||"JSXExpressionContainer"===r[0]?.type&&void 0!==t(r[0].expression)),l=!r.length,u=o;i&&!o?(n.push(p),s(p.children||[],n,!0)):l?n.push(p):u||("p"===e&&a?(n.push(p),s(p.children||[],n,!0,!1)):s(p.children||[],n,!1,!1));continue}n.push(p),s(p.children||[],n,!0);continue}"JSXFragment"!==p.type||s(p.children||[],n,o)}else{if(o&&!f)continue;if(o&&r(p))continue;if(r(p)){const t=y[e-1],i=y[e+1];if(t&&("JSXElement"===t.type||"JSXFragment"===t.type)&&i&&("JSXElement"===i.type||"JSXFragment"===i.type))continue;const r=n[n.length-1],s=y[e-1];if(r){if(s&&"JSXExpressionContainer"===s.type)continue;if("JSXText"===r.type&&s&&"JSXText"===s.type){r.value=String(r.value)+p.value;continue}}}if(o&&f&&0===e)continue;n.push(p)}}}const o=[];s(e,o,!1,!0);const p=e=>String(e).replace(/^\s*\n\s*/g,"").replace(/\s*\n\s*$/g,"");function a(e,n,s=!1){if(!e||0===e.length)return"";let l="",u=0;for(let y=0;y<e.length;y++){const f=e[y];if(f)if("JSXText"!==f.type){if("JSXExpressionContainer"===f.type){const e=f.expression;if(!e)continue;const n=t(e);if(void 0!==n)l+=n;else if("Identifier"===e.type)l+=`{{${e.value}}}`;else if("ObjectExpression"===e.type){const t=e.properties[0];t&&"KeyValueProperty"===t.type&&t.key&&"Identifier"===t.key.type?l+=`{{${t.key.value}}}`:t&&"Identifier"===t.type?l+=`{{${t.value}}}`:l+="{{value}}"}else"MemberExpression"===e.type&&e.property&&"Identifier"===e.property.type?l+=`{{${e.property.value}}}`:"CallExpression"===e.type&&"Identifier"===e.callee?.type?l+=`{{${e.callee.value}}}`:l+="{{value}}";continue}if("JSXElement"===f.type){let c;f.opening&&f.opening.name&&"Identifier"===f.opening.name.type&&(c=f.opening.name.value);const g=s?u:void 0;if(s&&"JSXElement"===f.type&&u++,c&&i.has(c)){const s=f.opening&&Array.isArray(f.opening.attributes)&&f.opening.attributes.length>0,u=f.children||[],d=u.length>0,v=1===u.length&&("JSXText"===u[0]?.type||"JSXExpressionContainer"===u[0]?.type&&void 0!==t(u[0].expression));if(!d||v){const t=v?a(u,void 0):"";if(""!==String(t).trim())l+=`<${c}>${t}</${c}>`;else{const t=e[y-1];t&&"JSXText"===t.type&&/\n\s*$/.test(t.value)&&(l=l.replace(/\s+$/,"")),l+=`<${c} />`}}else if(s&&!v){const e=u;if(e.some(e=>e&&("JSXText"===e.type||"JSXExpressionContainer"===e.type)&&-1!==o.indexOf(e))){const t=o.indexOf(f),n=a(e,void 0);l+=`<${t}>${p(n)}</${t}>`}else{const t=new Map;let r=0;for(const n of e)if(n&&"JSXElement"===n.type){const e=n.opening&&n.opening.name&&"Identifier"===n.opening.name.type?n.opening.name.value:void 0;if(e&&i.has(e)){const e=n.opening&&Array.isArray(n.opening.attributes)&&n.opening.attributes.length>0,i=n.children||[],s=1===i.length&&"JSXText"===i[0]?.type;(e||i.length&&!s)&&t.set(n,r++)}else t.set(n,r++)}const s=n&&n.has(f)?n.get(f):o.indexOf(f),u=a(e,t.size?t:void 0);l+=`<${s}>${p(u)}</${s}>`}}else{const e=o.indexOf(f);if(-1!==e){const n=void 0!==g?g:e;if((()=>{let e=!1;for(const t of u)if(t)if("JSXElement"!==t.type){if("JSXExpressionContainer"===t.type&&-1!==o.indexOf(t))return e;if("JSXText"===t.type&&-1!==o.indexOf(t)){if(r(t))continue;if(!e)return!0;if(u.slice(u.indexOf(t)+1).some(e=>e&&"JSXElement"===e.type))return!0}}else e=!0;return!1})()){const e=a(u,void 0,!1);l+=`<${n}>${p(e)}</${n}>`;continue}const s=new Map;let y=n;for(const e of u)if(e&&"JSXElement"===e.type){const n=e.opening&&e.opening.name&&"Identifier"===e.opening.name.type?e.opening.name.value:void 0;if(n&&i.has(n)){const n=e.opening&&Array.isArray(e.opening.attributes)&&e.opening.attributes.length>0,i=e.children||[],r=1===i.length&&("JSXText"===i[0]?.type||"JSXExpressionContainer"===i[0]?.type&&void 0!==t(i[0].expression));!n&&(!i.length||r)||s.set(e,y++)}else s.set(e,y++)}const f=a(u,s.size>0?s:void 0,!1);l+=`<${n}>${p(f)}</${n}>`}else{const e=a(u,void 0,!1);l+=`<${c}>${p(e)}</${c}>`}}}else{const e=f.children||[];if(e.some(e=>e&&("JSXText"===e.type||"JSXExpressionContainer"===e.type)&&-1!==o.indexOf(e))){const t=o.indexOf(f),n=a(e,void 0);l+=`<${t}>${p(n)}</${t}>`}else{const t=new Map;let r=0;for(const n of e)if(n&&"JSXElement"===n.type){const e=n.opening&&n.opening.name&&"Identifier"===n.opening.name.type?n.opening.name.value:void 0;if(e&&i.has(e)){const e=n.opening&&Array.isArray(n.opening.attributes)&&n.opening.attributes.length>0,i=n.children||[],s=1===i.length&&"JSXText"===i[0]?.type;!e&&(!i.length||s)||t.set(n,r++)}else t.set(n,r++)}const s=n&&n.has(f)?n.get(f):o.indexOf(f),u=a(e,t.size?t:void 0);l+=`<${s}>${p(u)}</${s}>`}}continue}"JSXFragment"!==f.type||(l+=a(f.children||[]))}else{if(r(f))continue;l+=f.value}}return l}const l=a(e,void 0,!0),u=String(l).replace(/<br \/>\s*\n\s*/g,"<br />").replace(/\s+/g," ");return u.replace(/\s+\./g,".").trim()}(i.children,r);let X;const m="JSXAttribute"===o?.type?n(o):void 0;if(void 0!==m)X=m;else{const e=r.extract.defaultValue;X="string"==typeof e?e:""}let h,b;if("JSXAttribute"===s?.type){if("StringLiteral"===s.value?.type){if(h=s.value,b=h.value,!b||""===b.trim())return null;if(x&&"StringLiteral"===h.type){const e=r.extract.nsSeparator??":",t=h.value;if(e&&t.startsWith(`${x}${e}`)){if(b=t.slice(`${x}${e}`.length),!b||""===b.trim())return null;h={...h,value:b}}}}else"JSXExpressionContainer"===s.value?.type&&"JSXEmptyExpression"!==s.value.expression.type&&(h=s.value.expression);if(!h)return null}return o||!b||J.trim()?!o&&J.trim()&&(X=J):X=b,{keyExpression:h,serializedChildren:J,ns:x,defaultValue:X,hasCount:u,isOrdinal:g,contextExpression:v,optionsNode:f,explicitDefault:void 0!==m||(e=>{if(!e||!Array.isArray(e.properties))return!1;for(const t of e.properties)if(t&&"KeyValueProperty"===t.type&&t.key){const e="Identifier"===t.key.type&&t.key.value||"StringLiteral"===t.key.type&&t.key.value;if("string"==typeof e&&e.startsWith("defaultValue"))return!0}return!1})(f)}};
|
package/dist/cjs/linter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("glob"),t=require("node:fs/promises"),r=require("@swc/core"),n=require("node:path"),s=require("node:events"),o=require("chalk"),i=require("ora");class a extends s.EventEmitter{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e.glob(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const l=new Map;for(const e of a){const o=await t.readFile(e,"utf-8"),i=n.extname(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,p=".tsx"===i;let
|
|
1
|
+
"use strict";var e=require("glob"),t=require("node:fs/promises"),r=require("@swc/core"),n=require("node:path"),s=require("node:events"),o=require("chalk"),i=require("ora");class a extends s.EventEmitter{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e.glob(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const l=new Map;for(const e of a){const o=await t.readFile(e,"utf-8"),i=n.extname(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,p=".tsx"===i,f=".jsx"===i;let g;try{g=await r.parse(o,{syntax:a?"typescript":"ecmascript",tsx:p,jsx:f,decorators:!0})}catch(t){if(".ts"!==i||p){const e=this.wrapError(t);this.emit("error",e);continue}try{g=await r.parse(o,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const m=u(g,o,s);m.length>0&&(c+=m.length,l.set(e,m))}const p={success:0===c,message:c>0?`Linter found ${c} potential issues.`:"No issues found.",files:Object.fromEntries(l.entries())};return this.emit("done",p),p}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}const c=e=>/^(https|http|\/\/|^\/)/.test(e);function u(e,t,r){const n=[],s=[],o=e=>t.substring(0,e).split("\n").length,i=r.extract.transComponents||["Trans"],a=r.extract.ignoredTags||[],u=new Set([...i,"script","style","code",...a]),l=r.extract.ignoredAttributes||[],p=new Set(["className","key","id","style","href","i18nKey","defaults","type","target",...l]),f=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?f({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null};return r(t)},g=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=f(r);if(e&&u.has(e))return!0}}return!1},m=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type){if(!g(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!c(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=g(r);if("JSXAttribute"===t?.type&&!p.has(t.name.value)&&!n){const t=e.value.trim();t&&"..."!==t&&!c(t)&&isNaN(Number(t))&&s.push(e)}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>m(e,r)):n&&"object"==typeof n&&m(n,r)}};m(e,[]);let h=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,h);s>-1&&(n.push({text:e.value.trim(),line:o(s)}),h=s+r.length)}return n}exports.Linter=a,exports.runLinter=async function(e){return new a(e).run()},exports.runLinterCli=async function(e){const t=new a(e),r=i().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(o.green.bold(n));else{r.fail(o.red.bold(n));for(const[e,t]of Object.entries(s))console.log(o.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${o.gray(`${t}:`)} ${o.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}};
|
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.23.
|
|
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.23.7"),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 t from"ora";import a from"chalk";import{parse as e}from"@swc/core";import{mkdir as o,writeFile as r,readFile as n}from"node:fs/promises";import{dirname as s,extname as i}from"node:path";import{findKeys as c}from"./key-finder.js";import{getTranslations as l}from"./translation-manager.js";import{validateExtractorConfig as m,ExtractorError as f}from"../../utils/validation.js";import{extractKeysFromComments as p}from"../parsers/comment-parser.js";import{ConsoleLogger as u}from"../../utils/logger.js";import{serializeTranslationFile as y}from"../../utils/file-utils.js";import{shouldShowFunnel as d,recordFunnelShown as g}from"../../utils/funnel-msg-tracker.js";async function w(e,{isWatchMode:n=!1,isDryRun:i=!1,syncPrimaryWithDefaults:f=!1}={},p=new u){e.extract.primaryLanguage||=e.locales[0]||"en",e.extract.secondaryLanguages||=e.locales.filter(t=>t!==e?.extract?.primaryLanguage),e.extract.functions||=["t","*.t"],e.extract.transComponents||=["Trans"],m(e);const w=e.plugins||[],x=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:n}=await c(e,p);x.text=`Found ${t.size} unique keys. Updating translation files...`;const m=await l(t,n,e,{syncPrimaryWithDefaults:f});let u=!1;for(const t of m)if(t.updated&&(u=!0,!i)){const n=y(t.newTranslations,e.extract.outputFormat,e.extract.indentation);await o(s(t.path),{recursive:!0}),await r(t.path,n),p.info(a.green(`Updated: ${t.path}`))}if(w.length>0){x.text="Running post-extraction plugins...";for(const t of w)await(t.afterSync?.(m,e))}return x.succeed(a.bold("Extraction complete!")),u&&await async function(){if(!await d("extract"))return;return console.log(a.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${a.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${a.cyan("https://youtu.be/joPsZghT3wM")}`),g("extract")}(),u}catch(t){throw x.fail(a.red("Extraction failed.")),t}}async function x(t,a,o,r,s,c=new u){try{let l=await n(t,"utf-8");for(const e of a)try{const a=await(e.onLoad?.(l,t));void 0!==a&&(l=a)}catch(t){c.warn(`Plugin ${e.name} onLoad failed:`,t)}const m=i(t).toLowerCase(),u=".ts"===m||".tsx"===m||".mts"===m||".cts"===m,y=".tsx"===m;let
|
|
1
|
+
import t from"ora";import a from"chalk";import{parse as e}from"@swc/core";import{mkdir as o,writeFile as r,readFile as n}from"node:fs/promises";import{dirname as s,extname as i}from"node:path";import{findKeys as c}from"./key-finder.js";import{getTranslations as l}from"./translation-manager.js";import{validateExtractorConfig as m,ExtractorError as f}from"../../utils/validation.js";import{extractKeysFromComments as p}from"../parsers/comment-parser.js";import{ConsoleLogger as u}from"../../utils/logger.js";import{serializeTranslationFile as y}from"../../utils/file-utils.js";import{shouldShowFunnel as d,recordFunnelShown as g}from"../../utils/funnel-msg-tracker.js";async function w(e,{isWatchMode:n=!1,isDryRun:i=!1,syncPrimaryWithDefaults:f=!1}={},p=new u){e.extract.primaryLanguage||=e.locales[0]||"en",e.extract.secondaryLanguages||=e.locales.filter(t=>t!==e?.extract?.primaryLanguage),e.extract.functions||=["t","*.t"],e.extract.transComponents||=["Trans"],m(e);const w=e.plugins||[],x=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:n}=await c(e,p);x.text=`Found ${t.size} unique keys. Updating translation files...`;const m=await l(t,n,e,{syncPrimaryWithDefaults:f});let u=!1;for(const t of m)if(t.updated&&(u=!0,!i)){const n=y(t.newTranslations,e.extract.outputFormat,e.extract.indentation);await o(s(t.path),{recursive:!0}),await r(t.path,n),p.info(a.green(`Updated: ${t.path}`))}if(w.length>0){x.text="Running post-extraction plugins...";for(const t of w)await(t.afterSync?.(m,e))}return x.succeed(a.bold("Extraction complete!")),u&&await async function(){if(!await d("extract"))return;return console.log(a.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${a.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${a.cyan("https://youtu.be/joPsZghT3wM")}`),g("extract")}(),u}catch(t){throw x.fail(a.red("Extraction failed.")),t}}async function x(t,a,o,r,s,c=new u){try{let l=await n(t,"utf-8");for(const e of a)try{const a=await(e.onLoad?.(l,t));void 0!==a&&(l=a)}catch(t){c.warn(`Plugin ${e.name} onLoad failed:`,t)}const m=i(t).toLowerCase(),u=".ts"===m||".tsx"===m||".mts"===m||".cts"===m,y=".tsx"===m,d=".jsx"===m;let g;try{g=await e(l,{syntax:u?"typescript":"ecmascript",tsx:y,jsx:d,decorators:!0,dynamicImport:!0,comments:!0})}catch(a){if(".ts"!==m||y)throw new f("Failed to process file",t,a);try{g=await e(l,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),c.info?.(`Parsed ${t} using TSX fallback`)}catch(a){throw new f("Failed to process file",t,a)}}r.getVarFromScope=o.getVarFromScope.bind(o),o.setCurrentFile(t,l),o.visit(g),p(l,r,s,o.getVarFromScope.bind(o))}catch(a){throw new f("Failed to process file",t,a)}}async function h(t,{syncPrimaryWithDefaults:a=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(a=>a!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:e,objectKeys:o}=await c(t);return l(e,o,t,{syncPrimaryWithDefaults:a})}export{h as extract,x as processFile,w as runExtractor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getObjectPropValueExpression as e,getObjectPropValue as t,isSimpleTemplateLiteral as n}from"./ast-utils.js";function i(e){if(e)return"StringLiteral"===e.type?e.value:"TemplateLiteral"===e.type&&n(e)?e.quasis[0].cooked:void 0}function r(e){return"StringLiteral"===e.value?.type?e.value.value:"JSXExpressionContainer"===e.value?.type?i(e.value.expression):void 0}function
|
|
1
|
+
import{getObjectPropValueExpression as e,getObjectPropValue as t,isSimpleTemplateLiteral as n}from"./ast-utils.js";function i(e){if(e)return"StringLiteral"===e.type?e.value:"TemplateLiteral"===e.type&&n(e)?e.quasis[0].cooked:void 0}function r(e){return"StringLiteral"===e.value?.type?e.value.value:"JSXExpressionContainer"===e.value?.type?i(e.value.expression):void 0}function o(n,o){const s=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"i18nKey"===e.name.value),p=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"defaults"===e.name.value),a=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"count"===e.name.value),l=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"values"===e.name.value);let u;a||"JSXAttribute"!==l?.type||"JSXExpressionContainer"!==l.value?.type||"ObjectExpression"!==l.value.expression.type||(u=e(l.value.expression,"count"));const y=!!a||!!u,f=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"tOptions"===e.name.value),c="JSXAttribute"===f?.type&&"JSXExpressionContainer"===f.value?.type&&"ObjectExpression"===f.value.expression.type?f.value.expression:void 0,g=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),d=!!g,v=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"context"===e.name.value);let S="JSXAttribute"===v?.type&&"JSXExpressionContainer"===v.value?.type?v.value.expression:"JSXAttribute"===v?.type&&"StringLiteral"===v.value?.type?v.value:void 0;const x=n.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ns"===e.name.value);let J;J="JSXAttribute"===x?.type?r(x):void 0,c&&(void 0===J&&(J=t(c,"ns")),void 0===S&&(S=e(c,"context")));const X=function(e,t){if(!e||0===e.length)return"";const n=new Set(t.extract.transKeepBasicHtmlNodesFor??["br","strong","i","p"]),r=e=>e&&"JSXText"===e.type&&/^\s*$/.test(e.value)&&e.value.includes("\n");function o(e,t,s=!1,p=!1){if(!e||!e.length)return;const a=p&&e.filter(e=>e&&"JSXElement"===e.type&&"p"===e.opening?.name?.value).length>1;let l=0,u=e.length-1;for(;l<=u&&r(e[l]);)l++;for(;u>=l&&r(e[u]);)u--;const y=l<=u?e.slice(l,u+1):[],f=y.some(e=>e&&("JSXElement"===e.type||"JSXFragment"===e.type));for(let e=0;e<y.length;e++){const p=y[e];if(p)if("JSXText"!==p.type){if("JSXExpressionContainer"===p.type){if(s&&!f&&p.expression){const e=p.expression.type;if("ObjectExpression"===e){const e=p.expression.properties&&p.expression.properties[0];if(e&&"KeyValueProperty"===e.type)continue}const t=i(p.expression);if(void 0!==t){if(!(/^\s*$/.test(t)&&!t.includes("\n")))continue}else if("Identifier"===e||"MemberExpression"===e||"CallExpression"===e)continue}const n=i(p.expression);if(void 0!==n){const i=/^\s*$/.test(n)&&!n.includes("\n"),o=y[e-1],s=y[e+1];if(i){const n=y[e+2];if(s&&"JSXText"===s.type&&r(s)&&n&&("JSXElement"===n.type||"JSXFragment"===n.type)){const t=y[e-1],n=y[e-2];if(!t||"JSXText"!==t.type&&n&&"JSXExpressionContainer"===n.type)continue}if(o&&("JSXElement"===o.type||"JSXFragment"===o.type)&&s&&"JSXText"===s.type&&r(s))continue;const i=!s||"JSXText"===s.type&&!r(s);if(o&&"JSXText"===o.type&&i){const e=t[t.length-1];if(e&&"JSXText"===e.type){e.value=String(e.value)+p.expression.value;continue}}if(o&&("JSXElement"===o.type||"JSXFragment"===o.type)&&s&&"JSXText"===s.type&&r(s))continue}}t.push(p);continue}if("JSXElement"===p.type){const e=p.opening&&p.opening.name&&"Identifier"===p.opening.name.type?p.opening.name.value:void 0;if(e&&n.has(e)){const n=p.opening&&Array.isArray(p.opening.attributes)&&p.opening.attributes.length>0,r=p.children||[],s=1===r.length&&("JSXText"===r[0]?.type||"JSXExpressionContainer"===r[0]?.type&&void 0!==i(r[0].expression)),l=!r.length,u=s;n&&!s?(t.push(p),o(p.children||[],t,!0)):l?t.push(p):u||("p"===e&&a?(t.push(p),o(p.children||[],t,!0,!1)):o(p.children||[],t,!1,!1));continue}t.push(p),o(p.children||[],t,!0);continue}"JSXFragment"!==p.type||o(p.children||[],t,s)}else{if(s&&!f)continue;if(s&&r(p))continue;if(r(p)){const n=y[e-1],i=y[e+1];if(n&&("JSXElement"===n.type||"JSXFragment"===n.type)&&i&&("JSXElement"===i.type||"JSXFragment"===i.type))continue;const r=t[t.length-1],o=y[e-1];if(r){if(o&&"JSXExpressionContainer"===o.type)continue;if("JSXText"===r.type&&o&&"JSXText"===o.type){r.value=String(r.value)+p.value;continue}}}if(s&&f&&0===e)continue;t.push(p)}}}const s=[];o(e,s,!1,!0);const p=e=>String(e).replace(/^\s*\n\s*/g,"").replace(/\s*\n\s*$/g,"");function a(e,t,o=!1){if(!e||0===e.length)return"";let l="",u=0;for(let y=0;y<e.length;y++){const f=e[y];if(f)if("JSXText"!==f.type){if("JSXExpressionContainer"===f.type){const e=f.expression;if(!e)continue;const t=i(e);if(void 0!==t)l+=t;else if("Identifier"===e.type)l+=`{{${e.value}}}`;else if("ObjectExpression"===e.type){const t=e.properties[0];t&&"KeyValueProperty"===t.type&&t.key&&"Identifier"===t.key.type?l+=`{{${t.key.value}}}`:t&&"Identifier"===t.type?l+=`{{${t.value}}}`:l+="{{value}}"}else"MemberExpression"===e.type&&e.property&&"Identifier"===e.property.type?l+=`{{${e.property.value}}}`:"CallExpression"===e.type&&"Identifier"===e.callee?.type?l+=`{{${e.callee.value}}}`:l+="{{value}}";continue}if("JSXElement"===f.type){let c;f.opening&&f.opening.name&&"Identifier"===f.opening.name.type&&(c=f.opening.name.value);const g=o?u:void 0;if(o&&"JSXElement"===f.type&&u++,c&&n.has(c)){const o=f.opening&&Array.isArray(f.opening.attributes)&&f.opening.attributes.length>0,u=f.children||[],d=u.length>0,v=1===u.length&&("JSXText"===u[0]?.type||"JSXExpressionContainer"===u[0]?.type&&void 0!==i(u[0].expression));if(!d||v){const t=v?a(u,void 0):"";if(""!==String(t).trim())l+=`<${c}>${t}</${c}>`;else{const t=e[y-1];t&&"JSXText"===t.type&&/\n\s*$/.test(t.value)&&(l=l.replace(/\s+$/,"")),l+=`<${c} />`}}else if(o&&!v){const e=u;if(e.some(e=>e&&("JSXText"===e.type||"JSXExpressionContainer"===e.type)&&-1!==s.indexOf(e))){const t=s.indexOf(f),n=a(e,void 0);l+=`<${t}>${p(n)}</${t}>`}else{const i=new Map;let r=0;for(const t of e)if(t&&"JSXElement"===t.type){const e=t.opening&&t.opening.name&&"Identifier"===t.opening.name.type?t.opening.name.value:void 0;if(e&&n.has(e)){const e=t.opening&&Array.isArray(t.opening.attributes)&&t.opening.attributes.length>0,n=t.children||[],o=1===n.length&&"JSXText"===n[0]?.type;(e||n.length&&!o)&&i.set(t,r++)}else i.set(t,r++)}const o=t&&t.has(f)?t.get(f):s.indexOf(f),u=a(e,i.size?i:void 0);l+=`<${o}>${p(u)}</${o}>`}}else{const e=s.indexOf(f);if(-1!==e){const t=void 0!==g?g:e;if((()=>{let e=!1;for(const t of u)if(t)if("JSXElement"!==t.type){if("JSXExpressionContainer"===t.type&&-1!==s.indexOf(t))return e;if("JSXText"===t.type&&-1!==s.indexOf(t)){if(r(t))continue;if(!e)return!0;if(u.slice(u.indexOf(t)+1).some(e=>e&&"JSXElement"===e.type))return!0}}else e=!0;return!1})()){const e=a(u,void 0,!1);l+=`<${t}>${p(e)}</${t}>`;continue}const o=new Map;let y=t;for(const e of u)if(e&&"JSXElement"===e.type){const t=e.opening&&e.opening.name&&"Identifier"===e.opening.name.type?e.opening.name.value:void 0;if(t&&n.has(t)){const t=e.opening&&Array.isArray(e.opening.attributes)&&e.opening.attributes.length>0,n=e.children||[],r=1===n.length&&("JSXText"===n[0]?.type||"JSXExpressionContainer"===n[0]?.type&&void 0!==i(n[0].expression));!t&&(!n.length||r)||o.set(e,y++)}else o.set(e,y++)}const f=a(u,o.size>0?o:void 0,!1);l+=`<${t}>${p(f)}</${t}>`}else{const e=a(u,void 0,!1);l+=`<${c}>${p(e)}</${c}>`}}}else{const e=f.children||[];if(e.some(e=>e&&("JSXText"===e.type||"JSXExpressionContainer"===e.type)&&-1!==s.indexOf(e))){const t=s.indexOf(f),n=a(e,void 0);l+=`<${t}>${p(n)}</${t}>`}else{const i=new Map;let r=0;for(const t of e)if(t&&"JSXElement"===t.type){const e=t.opening&&t.opening.name&&"Identifier"===t.opening.name.type?t.opening.name.value:void 0;if(e&&n.has(e)){const e=t.opening&&Array.isArray(t.opening.attributes)&&t.opening.attributes.length>0,n=t.children||[],o=1===n.length&&"JSXText"===n[0]?.type;!e&&(!n.length||o)||i.set(t,r++)}else i.set(t,r++)}const o=t&&t.has(f)?t.get(f):s.indexOf(f),u=a(e,i.size?i:void 0);l+=`<${o}>${p(u)}</${o}>`}}continue}"JSXFragment"!==f.type||(l+=a(f.children||[]))}else{if(r(f))continue;l+=f.value}}return l}const l=a(e,void 0,!0),u=String(l).replace(/<br \/>\s*\n\s*/g,"<br />").replace(/\s+/g," ");return u.replace(/\s+\./g,".").trim()}(n.children,o);let m;const h="JSXAttribute"===p?.type?r(p):void 0;if(void 0!==h)m=h;else{const e=o.extract.defaultValue;m="string"==typeof e?e:""}let b,E;if("JSXAttribute"===s?.type){if("StringLiteral"===s.value?.type){if(b=s.value,E=b.value,!E||""===E.trim())return null;if(J&&"StringLiteral"===b.type){const e=o.extract.nsSeparator??":",t=b.value;if(e&&t.startsWith(`${J}${e}`)){if(E=t.slice(`${J}${e}`.length),!E||""===E.trim())return null;b={...b,value:E}}}}else"JSXExpressionContainer"===s.value?.type&&"JSXEmptyExpression"!==s.value.expression.type&&(b=s.value.expression);if(!b)return null}p||!E||X.trim()?!p&&X.trim()&&(m=X):m=E;return{keyExpression:b,serializedChildren:X,ns:J,defaultValue:m,hasCount:y,isOrdinal:d,contextExpression:S,optionsNode:c,explicitDefault:void 0!==h||(e=>{if(!e||!Array.isArray(e.properties))return!1;for(const t of e.properties)if(t&&"KeyValueProperty"===t.type&&t.key){const e="Identifier"===t.key.type&&t.key.value||"StringLiteral"===t.key.type&&t.key.value;if("string"==typeof e&&e.startsWith("defaultValue"))return!0}return!1})(c)}}export{o as extractFromTransComponent};
|
package/dist/esm/linter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{glob as e}from"glob";import{readFile as t}from"node:fs/promises";import{parse as r}from"@swc/core";import{extname as n}from"node:path";import{EventEmitter as s}from"node:events";import o from"chalk";import i from"ora";class a extends s{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const l=new Map;for(const e of a){const o=await t(e,"utf-8"),i=n(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,u=".tsx"===i;let
|
|
1
|
+
import{glob as e}from"glob";import{readFile as t}from"node:fs/promises";import{parse as r}from"@swc/core";import{extname as n}from"node:path";import{EventEmitter as s}from"node:events";import o from"chalk";import i from"ora";class a extends s{config;constructor(e){super({captureRejections:!0}),this.config=e}wrapError(e){const t="Linter failed to run: ";if(e instanceof Error){if(e.message.startsWith(t))return e;const r=new Error(`${t}${e.message}`);return r.stack=e.stack,r}return new Error(`${t}${String(e)}`)}async run(){const{config:s}=this;try{this.emit("progress",{message:"Finding source files to analyze..."});const o=["node_modules/**"],i=Array.isArray(s.extract.ignore)?s.extract.ignore:s.extract.ignore?[s.extract.ignore]:[],a=await e(s.extract.input,{ignore:[...o,...i]});this.emit("progress",{message:`Analyzing ${a.length} source files...`});let c=0;const l=new Map;for(const e of a){const o=await t(e,"utf-8"),i=n(e).toLowerCase(),a=".ts"===i||".tsx"===i||".mts"===i||".cts"===i,u=".tsx"===i,p=".jsx"===i;let m;try{m=await r(o,{syntax:a?"typescript":"ecmascript",tsx:u,jsx:p,decorators:!0})}catch(t){if(".ts"!==i||u){const e=this.wrapError(t);this.emit("error",e);continue}try{m=await r(o,{syntax:"typescript",tsx:!0,decorators:!0}),this.emit("progress",{message:`Parsed ${e} using TSX fallback`})}catch(e){const t=this.wrapError(e);this.emit("error",t);continue}}const g=f(m,o,s);g.length>0&&(c+=g.length,l.set(e,g))}const u={success:0===c,message:c>0?`Linter found ${c} potential issues.`:"No issues found.",files:Object.fromEntries(l.entries())};return this.emit("done",u),u}catch(e){const t=this.wrapError(e);throw this.emit("error",t),t}}}async function c(e){return new a(e).run()}async function l(e){const t=new a(e),r=i().start();t.on("progress",e=>{r.text=e.message});try{const{success:e,message:n,files:s}=await t.run();if(e)r.succeed(o.green.bold(n));else{r.fail(o.red.bold(n));for(const[e,t]of Object.entries(s))console.log(o.yellow(`\n${e}`)),t.forEach(({text:e,line:t})=>{console.log(` ${o.gray(`${t}:`)} ${o.red("Error:")} Found hardcoded string: "${e}"`)});process.exit(1)}}catch(e){const n=t.wrapError(e);r.fail(n.message),console.error(n),process.exit(1)}}const u=e=>/^(https|http|\/\/|^\/)/.test(e);function f(e,t,r){const n=[],s=[],o=e=>t.substring(0,e).split("\n").length,i=r.extract.transComponents||["Trans"],a=r.extract.ignoredTags||[],c=new Set([...i,"script","style","code",...a]),l=r.extract.ignoredAttributes||[],f=new Set(["className","key","id","style","href","i18nKey","defaults","type","target",...l]),p=e=>{if(!e)return null;const t=e.name??e.opening?.name??e.opening?.name;if(!t)return e.opening?.name?p({name:e.opening.name}):null;const r=e=>{if(!e)return null;if("JSXIdentifier"===e.type&&(e.name||e.value))return e.name??e.value;if("Identifier"===e.type&&(e.name||e.value))return e.name??e.value;if("JSXMemberExpression"===e.type){const t=r(e.object),n=r(e.property);return t&&n?`${t}.${n}`:n??t}return e.name??e.value??e.property?.name??e.property?.value??null};return r(t)},m=e=>{for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"object"==typeof r&&("JSXElement"===r.type||"JSXOpeningElement"===r.type||"JSXSelfClosingElement"===r.type)){const e=p(r);if(e&&c.has(e))return!0}}return!1},g=(e,t)=>{if(!e||"object"!=typeof e)return;const r=[...t,e];if("JSXText"===e.type){if(!m(r)){const t=e.value.trim();t&&t.length>1&&"..."!==t&&!u(t)&&isNaN(Number(t))&&!t.startsWith("{{")&&s.push(e)}}if("StringLiteral"===e.type){const t=r[r.length-2],n=m(r);if("JSXAttribute"===t?.type&&!f.has(t.name.value)&&!n){const t=e.value.trim();t&&"..."!==t&&!u(t)&&isNaN(Number(t))&&s.push(e)}}for(const t of Object.keys(e)){if("span"===t)continue;const n=e[t];Array.isArray(n)?n.forEach(e=>g(e,r)):n&&"object"==typeof n&&g(n,r)}};g(e,[]);let h=0;for(const e of s){const r=e.raw??e.value,s=t.indexOf(r,h);s>-1&&(n.push({text:e.value.trim(),line:o(s)}),h=s+r.length)}return n}export{a as Linter,c as runLinter,l as runLinterCli};
|
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.23.
|
|
25
|
+
.version('1.23.7')
|
|
26
26
|
|
|
27
27
|
// new: global config override option
|
|
28
28
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)')
|
|
@@ -158,12 +158,14 @@ export async function processFile (
|
|
|
158
158
|
const fileExt = extname(file).toLowerCase()
|
|
159
159
|
const isTypeScriptFile = fileExt === '.ts' || fileExt === '.tsx' || fileExt === '.mts' || fileExt === '.cts'
|
|
160
160
|
const isTSX = fileExt === '.tsx'
|
|
161
|
+
const isJSX = fileExt === '.jsx'
|
|
161
162
|
|
|
162
163
|
let ast: any
|
|
163
164
|
try {
|
|
164
165
|
ast = await parse(code, {
|
|
165
166
|
syntax: isTypeScriptFile ? 'typescript' : 'ecmascript',
|
|
166
167
|
tsx: isTSX,
|
|
168
|
+
jsx: isJSX,
|
|
167
169
|
decorators: true,
|
|
168
170
|
dynamicImport: true,
|
|
169
171
|
comments: true,
|
|
@@ -295,9 +295,14 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
295
295
|
n.value.includes('\n')
|
|
296
296
|
|
|
297
297
|
// Build deterministic global slot list (pre-order)
|
|
298
|
-
function collectSlots (nodes: any[], slots: any[], parentIsNonPreserved = false) {
|
|
298
|
+
function collectSlots (nodes: any[], slots: any[], parentIsNonPreserved = false, isRootLevel = false) {
|
|
299
299
|
if (!nodes || !nodes.length) return
|
|
300
300
|
|
|
301
|
+
// Check if there are multiple <p> elements at root level
|
|
302
|
+
const multiplePAtRoot = isRootLevel && nodes.filter((n: any) =>
|
|
303
|
+
n && n.type === 'JSXElement' && n.opening?.name?.value === 'p'
|
|
304
|
+
).length > 1
|
|
305
|
+
|
|
301
306
|
// First, identify boundary whitespace nodes (start and end of sibling list)
|
|
302
307
|
// We trim ONLY pure-whitespace JSXText nodes from the boundaries
|
|
303
308
|
let startIdx = 0
|
|
@@ -504,16 +509,50 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
504
509
|
? n.opening.name.value
|
|
505
510
|
: undefined
|
|
506
511
|
if (tagName && allowedTags.has(tagName)) {
|
|
507
|
-
//
|
|
508
|
-
//
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
// Check if this preserved tag will actually be preserved as literal HTML
|
|
513
|
+
// or if it will be indexed (has complex children or attributes)
|
|
514
|
+
const hasAttrs =
|
|
515
|
+
n.opening &&
|
|
516
|
+
Array.isArray((n.opening as any).attributes) &&
|
|
517
|
+
(n.opening as any).attributes.length > 0
|
|
518
|
+
const children = n.children || []
|
|
519
|
+
// Check for single PURE text child (JSXText OR simple string expression)
|
|
520
|
+
const isSinglePureTextChild =
|
|
521
|
+
children.length === 1 && (
|
|
522
|
+
children[0]?.type === 'JSXText' ||
|
|
523
|
+
(children[0]?.type === 'JSXExpressionContainer' &&
|
|
524
|
+
getStringLiteralFromExpression(children[0].expression) !== undefined)
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
// Self-closing tags (no children) should be added to slots but rendered as literal HTML
|
|
528
|
+
// Tags with single pure text child should NOT be added to slots and rendered as literal HTML
|
|
529
|
+
const isSelfClosing = !children.length
|
|
530
|
+
const hasTextContent = isSinglePureTextChild
|
|
531
|
+
|
|
532
|
+
if (hasAttrs && !isSinglePureTextChild) {
|
|
533
|
+
// Has attributes AND complex children -> will be indexed, add to slots
|
|
534
|
+
slots.push(n)
|
|
535
|
+
collectSlots(n.children || [], slots, true)
|
|
536
|
+
} else if (isSelfClosing) {
|
|
537
|
+
// Self-closing tag with no attributes: add to slots (affects indexes) but will render as literal
|
|
514
538
|
slots.push(n)
|
|
539
|
+
} else if (!hasTextContent) {
|
|
540
|
+
// Has complex children but no attributes
|
|
541
|
+
// For <p> tags at root level with multiple <p> siblings, index them
|
|
542
|
+
// For other preserved tags, preserve as literal (don't add to slots)
|
|
543
|
+
if (tagName === 'p' && multiplePAtRoot) {
|
|
544
|
+
slots.push(n)
|
|
545
|
+
collectSlots(n.children || [], slots, true, false)
|
|
546
|
+
} else {
|
|
547
|
+
// Other preserved tags: preserve as literal, don't add to slots
|
|
548
|
+
// But DO process children to add them to slots
|
|
549
|
+
collectSlots(n.children || [], slots, false, false)
|
|
550
|
+
}
|
|
551
|
+
} else {
|
|
552
|
+
// Has single pure text child and no attributes: preserve as literal, don't add to slots
|
|
553
|
+
// Don't process children either - they're part of the preserved tag
|
|
515
554
|
}
|
|
516
|
-
|
|
555
|
+
continue
|
|
517
556
|
} else {
|
|
518
557
|
// non-preserved element: the element itself is a single slot.
|
|
519
558
|
// Pre-order: allocate the parent's slot first, then descend into its
|
|
@@ -537,7 +576,7 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
537
576
|
|
|
538
577
|
// prepare the global slot list for the whole subtree
|
|
539
578
|
const globalSlots: any[] = []
|
|
540
|
-
collectSlots(children, globalSlots, false)
|
|
579
|
+
collectSlots(children, globalSlots, false, true)
|
|
541
580
|
|
|
542
581
|
// Trim only newline-only indentation at the edges of serialized inner text.
|
|
543
582
|
// This preserves single leading/trailing spaces which are meaningful between inline placeholders.
|
|
@@ -548,10 +587,12 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
548
587
|
// remove trailing newline-only indentation
|
|
549
588
|
.replace(/\s*\n\s*$/g, '')
|
|
550
589
|
|
|
551
|
-
function visitNodes (nodes: any[], localIndexMap?: Map<any, number
|
|
590
|
+
function visitNodes (nodes: any[], localIndexMap?: Map<any, number>, isRootLevel = false): string {
|
|
552
591
|
if (!nodes || nodes.length === 0) return ''
|
|
553
592
|
let out = ''
|
|
554
|
-
|
|
593
|
+
|
|
594
|
+
// At root level, build index based on element position among siblings
|
|
595
|
+
let rootElementIndex = 0
|
|
555
596
|
|
|
556
597
|
for (let i = 0; i < nodes.length; i++) {
|
|
557
598
|
const node = nodes[i]
|
|
@@ -559,12 +600,7 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
559
600
|
|
|
560
601
|
if (node.type === 'JSXText') {
|
|
561
602
|
if (isFormattingWhitespace(node)) continue
|
|
562
|
-
|
|
563
|
-
out += node.value.replace(/^\s+/, '')
|
|
564
|
-
lastWasSelfClosing = false
|
|
565
|
-
} else {
|
|
566
|
-
out += node.value
|
|
567
|
-
}
|
|
603
|
+
out += node.value
|
|
568
604
|
continue
|
|
569
605
|
}
|
|
570
606
|
|
|
@@ -593,7 +629,6 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
593
629
|
} else {
|
|
594
630
|
out += '{{value}}'
|
|
595
631
|
}
|
|
596
|
-
lastWasSelfClosing = false
|
|
597
632
|
continue
|
|
598
633
|
}
|
|
599
634
|
|
|
@@ -603,25 +638,195 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
603
638
|
tag = node.opening.name.value
|
|
604
639
|
}
|
|
605
640
|
|
|
641
|
+
// Track root element index for root-level elements
|
|
642
|
+
const myRootIndex = isRootLevel ? rootElementIndex : undefined
|
|
643
|
+
if (isRootLevel && node.type === 'JSXElement') {
|
|
644
|
+
rootElementIndex++
|
|
645
|
+
}
|
|
646
|
+
|
|
606
647
|
if (tag && allowedTags.has(tag)) {
|
|
607
|
-
|
|
608
|
-
//
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
648
|
+
// Match react-i18next behavior: only preserve as literal HTML when:
|
|
649
|
+
// 1. No children (!childChildren) AND no attributes (!childPropsCount)
|
|
650
|
+
// 2. OR: Has children but only the children prop (childPropsCount === 1) AND children is a simple string (isString(childChildren))
|
|
651
|
+
|
|
652
|
+
const hasAttrs =
|
|
653
|
+
node.opening &&
|
|
654
|
+
Array.isArray((node.opening as any).attributes) &&
|
|
655
|
+
(node.opening as any).attributes.length > 0
|
|
656
|
+
|
|
657
|
+
const children = node.children || []
|
|
658
|
+
const hasChildren = children.length > 0
|
|
659
|
+
|
|
660
|
+
// Check if children is a single PURE text node (JSXText OR simple string expression)
|
|
661
|
+
const isSinglePureTextChild =
|
|
662
|
+
children.length === 1 && (
|
|
663
|
+
children[0]?.type === 'JSXText' ||
|
|
664
|
+
(children[0]?.type === 'JSXExpressionContainer' &&
|
|
665
|
+
getStringLiteralFromExpression(children[0].expression) !== undefined)
|
|
666
|
+
)
|
|
667
|
+
|
|
668
|
+
// Preserve as literal HTML in two cases:
|
|
669
|
+
// 1. No children and no attributes: <br />
|
|
670
|
+
// 2. Single pure text child (with or without attributes): <strong>text</strong> or <strong title="...">text</strong>
|
|
671
|
+
if ((!hasChildren || isSinglePureTextChild)) {
|
|
672
|
+
const inner = isSinglePureTextChild ? visitNodes(children, undefined) : ''
|
|
673
|
+
const hasMeaningfulChildren = String(inner).trim() !== ''
|
|
674
|
+
|
|
675
|
+
if (!hasMeaningfulChildren) {
|
|
676
|
+
// Self-closing
|
|
677
|
+
const prevOriginal = nodes[i - 1]
|
|
678
|
+
if (prevOriginal && prevOriginal.type === 'JSXText' && /\n\s*$/.test(prevOriginal.value)) {
|
|
679
|
+
out = out.replace(/\s+$/, '')
|
|
680
|
+
}
|
|
681
|
+
out += `<${tag} />`
|
|
682
|
+
} else {
|
|
683
|
+
// Preserve with content: <strong>text</strong>
|
|
684
|
+
out += `<${tag}>${inner}</${tag}>`
|
|
685
|
+
}
|
|
686
|
+
} else if (hasAttrs && !isSinglePureTextChild) {
|
|
687
|
+
// Has attributes -> treat as indexed element with numeric placeholder
|
|
688
|
+
const childrenLocal = children
|
|
689
|
+
const hasNonElementGlobalSlots = childrenLocal.some((ch: any) =>
|
|
690
|
+
ch && (ch.type === 'JSXText' || ch.type === 'JSXExpressionContainer') && globalSlots.indexOf(ch) !== -1
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
if (hasNonElementGlobalSlots) {
|
|
694
|
+
const idx = globalSlots.indexOf(node)
|
|
695
|
+
const inner = visitNodes(childrenLocal, undefined)
|
|
696
|
+
out += `<${idx}>${trimFormattingEdges(inner)}</${idx}>`
|
|
697
|
+
} else {
|
|
698
|
+
const childrenLocalMap = new Map<any, number>()
|
|
699
|
+
let localIdxCounter = 0
|
|
700
|
+
for (const ch of childrenLocal) {
|
|
701
|
+
if (!ch) continue
|
|
702
|
+
if (ch.type === 'JSXElement') {
|
|
703
|
+
const chTag = ch.opening && ch.opening.name && ch.opening.name.type === 'Identifier'
|
|
704
|
+
? ch.opening.name.value
|
|
705
|
+
: undefined
|
|
706
|
+
if (chTag && allowedTags.has(chTag)) {
|
|
707
|
+
const chHasAttrs =
|
|
708
|
+
ch.opening &&
|
|
709
|
+
Array.isArray((ch.opening as any).attributes) &&
|
|
710
|
+
(ch.opening as any).attributes.length > 0
|
|
711
|
+
const chChildren = ch.children || []
|
|
712
|
+
const chIsSingleText = chChildren.length === 1 && chChildren[0]?.type === 'JSXText'
|
|
713
|
+
// Only skip indexing if it would be preserved as literal
|
|
714
|
+
if (!chHasAttrs && (!chChildren.length || chIsSingleText)) {
|
|
715
|
+
// Will be preserved, don't index
|
|
716
|
+
} else {
|
|
717
|
+
childrenLocalMap.set(ch, localIdxCounter++)
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
childrenLocalMap.set(ch, localIdxCounter++)
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const idx = localIndexMap && localIndexMap.has(node) ? localIndexMap.get(node) : globalSlots.indexOf(node)
|
|
726
|
+
const inner = visitNodes(childrenLocal, childrenLocalMap.size ? childrenLocalMap : undefined)
|
|
727
|
+
out += `<${idx}>${trimFormattingEdges(inner)}</${idx}>`
|
|
619
728
|
}
|
|
620
|
-
out += `<${tag} />`
|
|
621
|
-
lastWasSelfClosing = true
|
|
622
729
|
} else {
|
|
623
|
-
|
|
624
|
-
|
|
730
|
+
// Has complex children but no attributes -> preserve tag as literal but index children
|
|
731
|
+
// Check if this tag is in globalSlots - if so, index it
|
|
732
|
+
const idx = globalSlots.indexOf(node)
|
|
733
|
+
if (idx !== -1) {
|
|
734
|
+
// This tag is in globalSlots, so index it
|
|
735
|
+
// At root level, use the element's position among root elements
|
|
736
|
+
const indexToUse = myRootIndex !== undefined ? myRootIndex : idx
|
|
737
|
+
|
|
738
|
+
// Check if children have text/expression nodes in globalSlots
|
|
739
|
+
// that appear BEFORE or BETWEEN element children (not just trailing)
|
|
740
|
+
// Exclude formatting whitespace (newline-only text) from this check
|
|
741
|
+
const hasNonElementGlobalSlots = (() => {
|
|
742
|
+
let foundElement = false
|
|
743
|
+
|
|
744
|
+
for (const ch of children) {
|
|
745
|
+
if (!ch) continue
|
|
746
|
+
|
|
747
|
+
if (ch.type === 'JSXElement') {
|
|
748
|
+
foundElement = true
|
|
749
|
+
continue
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (ch.type === 'JSXExpressionContainer' && globalSlots.indexOf(ch) !== -1) {
|
|
753
|
+
// Only count if before/between elements, not trailing
|
|
754
|
+
return foundElement // false if before first element, true if after
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (ch.type === 'JSXText' && globalSlots.indexOf(ch) !== -1) {
|
|
758
|
+
// Exclude formatting whitespace
|
|
759
|
+
if (isFormattingWhitespace(ch)) continue
|
|
760
|
+
|
|
761
|
+
// Only count text that appears BEFORE the first element
|
|
762
|
+
// Trailing text after all elements should not force global indexing
|
|
763
|
+
if (!foundElement) {
|
|
764
|
+
// Text before first element - counts
|
|
765
|
+
return true
|
|
766
|
+
}
|
|
767
|
+
// Text after an element - check if there are more elements after this text
|
|
768
|
+
const remainingNodes = children.slice(children.indexOf(ch) + 1)
|
|
769
|
+
const hasMoreElements = remainingNodes.some((n: any) => n && n.type === 'JSXElement')
|
|
770
|
+
if (hasMoreElements) {
|
|
771
|
+
// Text between elements - counts
|
|
772
|
+
return true
|
|
773
|
+
}
|
|
774
|
+
// Trailing text after last element - doesn't count
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
return false
|
|
779
|
+
})()
|
|
780
|
+
|
|
781
|
+
// If children have non-element global slots, use global indexes
|
|
782
|
+
// Otherwise use local indexes starting from parent's index + 1
|
|
783
|
+
if (hasNonElementGlobalSlots) {
|
|
784
|
+
const inner = visitNodes(children, undefined, false)
|
|
785
|
+
out += `<${indexToUse}>${trimFormattingEdges(inner)}</${indexToUse}>`
|
|
786
|
+
continue
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Build local index map for children of this indexed element
|
|
790
|
+
const childrenLocalMap = new Map<any, number>()
|
|
791
|
+
let localIdxCounter = indexToUse // Start from parent index (reuse parent's index for first child)
|
|
792
|
+
for (const ch of children) {
|
|
793
|
+
if (!ch) continue
|
|
794
|
+
if (ch.type === 'JSXElement') {
|
|
795
|
+
const chTag = ch.opening && ch.opening.name && ch.opening.name.type === 'Identifier'
|
|
796
|
+
? ch.opening.name.value
|
|
797
|
+
: undefined
|
|
798
|
+
|
|
799
|
+
if (chTag && allowedTags.has(chTag)) {
|
|
800
|
+
// Check if this child will be preserved as literal HTML
|
|
801
|
+
const chHasAttrs =
|
|
802
|
+
ch.opening &&
|
|
803
|
+
Array.isArray((ch.opening as any).attributes) &&
|
|
804
|
+
(ch.opening as any).attributes.length > 0
|
|
805
|
+
const chChildren = ch.children || []
|
|
806
|
+
const chIsSinglePureText =
|
|
807
|
+
chChildren.length === 1 && (
|
|
808
|
+
chChildren[0]?.type === 'JSXText' ||
|
|
809
|
+
(chChildren[0]?.type === 'JSXExpressionContainer' &&
|
|
810
|
+
getStringLiteralFromExpression(chChildren[0].expression) !== undefined)
|
|
811
|
+
)
|
|
812
|
+
const chWillBePreserved = !chHasAttrs && (!chChildren.length || chIsSinglePureText)
|
|
813
|
+
if (!chWillBePreserved) {
|
|
814
|
+
// Will be indexed, add to local map
|
|
815
|
+
childrenLocalMap.set(ch, localIdxCounter++)
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
// Non-preserved tag, always indexed
|
|
819
|
+
childrenLocalMap.set(ch, localIdxCounter++)
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
const inner = visitNodes(children, childrenLocalMap.size > 0 ? childrenLocalMap : undefined, false)
|
|
824
|
+
out += `<${indexToUse}>${trimFormattingEdges(inner)}</${indexToUse}>`
|
|
825
|
+
} else {
|
|
826
|
+
// Not in globalSlots, preserve as literal HTML
|
|
827
|
+
const inner = visitNodes(children, undefined, false)
|
|
828
|
+
out += `<${tag}>${trimFormattingEdges(inner)}</${tag}>`
|
|
829
|
+
}
|
|
625
830
|
}
|
|
626
831
|
} else {
|
|
627
832
|
// Decide whether to use local (restarted) indexes for this element's
|
|
@@ -641,7 +846,6 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
641
846
|
const idx = globalSlots.indexOf(node)
|
|
642
847
|
const inner = visitNodes(children, undefined)
|
|
643
848
|
out += `<${idx}>${trimFormattingEdges(inner)}</${idx}>`
|
|
644
|
-
lastWasSelfClosing = false
|
|
645
849
|
} else {
|
|
646
850
|
const childrenLocalMap = new Map<any, number>()
|
|
647
851
|
let localIdxCounter = 0
|
|
@@ -652,8 +856,16 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
652
856
|
? ch.opening.name.value
|
|
653
857
|
: undefined
|
|
654
858
|
if (chTag && allowedTags.has(chTag)) {
|
|
655
|
-
|
|
656
|
-
|
|
859
|
+
// Check if this child will be preserved as literal HTML
|
|
860
|
+
const chHasAttrs =
|
|
861
|
+
ch.opening &&
|
|
862
|
+
Array.isArray((ch.opening as any).attributes) &&
|
|
863
|
+
(ch.opening as any).attributes.length > 0
|
|
864
|
+
const chChildren = ch.children || []
|
|
865
|
+
const chIsSinglePureText = chChildren.length === 1 && chChildren[0]?.type === 'JSXText'
|
|
866
|
+
const chWillBePreserved = !chHasAttrs && (!chChildren.length || chIsSinglePureText)
|
|
867
|
+
if (!chWillBePreserved) {
|
|
868
|
+
// Will be indexed, add to local map
|
|
657
869
|
childrenLocalMap.set(ch, localIdxCounter++)
|
|
658
870
|
}
|
|
659
871
|
} else {
|
|
@@ -665,7 +877,6 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
665
877
|
const idx = localIndexMap && localIndexMap.has(node) ? localIndexMap.get(node) : globalSlots.indexOf(node)
|
|
666
878
|
const inner = visitNodes(children, childrenLocalMap.size ? childrenLocalMap : undefined)
|
|
667
879
|
out += `<${idx}>${trimFormattingEdges(inner)}</${idx}>`
|
|
668
|
-
lastWasSelfClosing = false
|
|
669
880
|
}
|
|
670
881
|
}
|
|
671
882
|
continue
|
|
@@ -673,7 +884,6 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
673
884
|
|
|
674
885
|
if (node.type === 'JSXFragment') {
|
|
675
886
|
out += visitNodes(node.children || [])
|
|
676
|
-
lastWasSelfClosing = false
|
|
677
887
|
continue
|
|
678
888
|
}
|
|
679
889
|
|
|
@@ -683,6 +893,17 @@ function serializeJSXChildren (children: any[], config: I18nextToolkitConfig): s
|
|
|
683
893
|
return out
|
|
684
894
|
}
|
|
685
895
|
|
|
686
|
-
const result = visitNodes(children)
|
|
687
|
-
|
|
896
|
+
const result = visitNodes(children, undefined, true)
|
|
897
|
+
|
|
898
|
+
// Final cleanup in correct order:
|
|
899
|
+
// 1. First, handle <br /> followed by whitespace+newline (boundary formatting)
|
|
900
|
+
const afterBrCleanup = String(result).replace(/<br \/>\s*\n\s*/g, '<br />')
|
|
901
|
+
|
|
902
|
+
// 2. Then normalize remaining whitespace sequences to single space
|
|
903
|
+
const normalized = afterBrCleanup.replace(/\s+/g, ' ')
|
|
904
|
+
|
|
905
|
+
// 3. Remove space before period at end
|
|
906
|
+
const finalResult = normalized.replace(/\s+\./g, '.')
|
|
907
|
+
|
|
908
|
+
return finalResult.trim()
|
|
688
909
|
}
|
package/src/linter.ts
CHANGED
|
@@ -63,12 +63,14 @@ export class Linter extends EventEmitter<LinterEventMap> {
|
|
|
63
63
|
const fileExt = extname(file).toLowerCase()
|
|
64
64
|
const isTypeScriptFile = fileExt === '.ts' || fileExt === '.tsx' || fileExt === '.mts' || fileExt === '.cts'
|
|
65
65
|
const isTSX = fileExt === '.tsx'
|
|
66
|
+
const isJSX = fileExt === '.jsx'
|
|
66
67
|
|
|
67
68
|
let ast: any
|
|
68
69
|
try {
|
|
69
70
|
ast = await parse(code, {
|
|
70
71
|
syntax: isTypeScriptFile ? 'typescript' : 'ecmascript',
|
|
71
72
|
tsx: isTSX,
|
|
73
|
+
jsx: isJSX,
|
|
72
74
|
decorators: true
|
|
73
75
|
})
|
|
74
76
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKtF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,EACE,WAAmB,EACnB,QAAgB,EAChB,uBAA+B,EAChC,GAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC9B,EACN,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,OAAO,CAAC,CAyDlB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKtF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,EACE,WAAmB,EACnB,QAAgB,EAChB,uBAA+B,EAChC,GAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC9B,EACN,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,OAAO,CAAC,CAyDlB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,IAAI,CAAC,CAsEf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,OAAO,CAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,uBAA+B,EAAE,GAAE;IAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAO,sDAO3I"}
|
package/types/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QAAC;YACT,OAAO,EAAE,MAAM,CAAC;SACjB;KAAC,CAAC;IACH,IAAI,EAAE;QAAC;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;SAC1C;KAAC,CAAC;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB,CAAA;AAED,qBAAa,MAAO,SAAQ,YAAY,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAsB;gBAEvB,MAAM,EAAE,oBAAoB;IAKzC,SAAS,CAAE,KAAK,EAAE,OAAO;IAanB,GAAG;;;;;;;
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QAAC;YACT,OAAO,EAAE,MAAM,CAAC;SACjB;KAAC,CAAC;IACH,IAAI,EAAE;QAAC;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;SAC1C;KAAC,CAAC;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB,CAAA;AAED,qBAAa,MAAO,SAAQ,YAAY,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAsB;gBAEvB,MAAM,EAAE,oBAAoB;IAKzC,SAAS,CAAE,KAAK,EAAE,OAAO;IAanB,GAAG;;;;;;;CA2EV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,SAAS,CAAE,MAAM,EAAE,oBAAoB;;;;;;GAE5D;AAED,wBAAsB,YAAY,CAAE,MAAM,EAAE,oBAAoB,iBA4B/D;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;CACd"}
|