@intlayer/babel 8.1.10 → 8.2.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/dist/cjs/babel-plugin-intlayer-extract.cjs +1 -1
- package/dist/cjs/babel-plugin-intlayer-extract.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs +1 -1
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
- package/dist/cjs/extractContent/babelProcessor.cjs +2 -0
- package/dist/cjs/extractContent/babelProcessor.cjs.map +1 -0
- package/dist/cjs/extractContent/contentWriter.cjs +2 -0
- package/dist/cjs/extractContent/contentWriter.cjs.map +1 -0
- package/dist/cjs/extractContent/extractContent.cjs +2 -0
- package/dist/cjs/extractContent/extractContent.cjs.map +1 -0
- package/dist/cjs/extractContent/index.cjs +1 -0
- package/dist/cjs/extractContent/processTsxFile.cjs +6 -0
- package/dist/cjs/extractContent/processTsxFile.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/constants.cjs +2 -0
- package/dist/cjs/extractContent/utils/constants.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/detectPackageName.cjs +2 -0
- package/dist/cjs/extractContent/utils/detectPackageName.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs +2 -0
- package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/generateKey.cjs +2 -0
- package/dist/cjs/extractContent/utils/generateKey.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/getComponentName.cjs +2 -0
- package/dist/cjs/extractContent/utils/getComponentName.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/getExistingIntlayerInfo.cjs +2 -0
- package/dist/cjs/extractContent/utils/getExistingIntlayerInfo.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/getOrGenerateKey.cjs +2 -0
- package/dist/cjs/extractContent/utils/getOrGenerateKey.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/index.cjs +1 -0
- package/dist/cjs/extractContent/utils/resolveDictionaryKey.cjs +2 -0
- package/dist/cjs/extractContent/utils/resolveDictionaryKey.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/shouldExtract.cjs +2 -0
- package/dist/cjs/extractContent/utils/shouldExtract.cjs.map +1 -0
- package/dist/cjs/getExtractPluginOptions.cjs +1 -1
- package/dist/cjs/getOptimizePluginOptions.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/babel-plugin-intlayer-extract.mjs +1 -1
- package/dist/esm/babel-plugin-intlayer-extract.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-optimize.mjs +1 -1
- package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
- package/dist/esm/extractContent/babelProcessor.mjs +2 -0
- package/dist/esm/extractContent/babelProcessor.mjs.map +1 -0
- package/dist/esm/extractContent/contentWriter.mjs +2 -0
- package/dist/esm/extractContent/contentWriter.mjs.map +1 -0
- package/dist/esm/extractContent/extractContent.mjs +2 -0
- package/dist/esm/extractContent/extractContent.mjs.map +1 -0
- package/dist/esm/extractContent/index.mjs +1 -0
- package/dist/esm/extractContent/processTsxFile.mjs +6 -0
- package/dist/esm/extractContent/processTsxFile.mjs.map +1 -0
- package/dist/esm/extractContent/utils/constants.mjs +2 -0
- package/dist/esm/extractContent/utils/constants.mjs.map +1 -0
- package/dist/esm/extractContent/utils/detectPackageName.mjs +2 -0
- package/dist/esm/extractContent/utils/detectPackageName.mjs.map +1 -0
- package/dist/esm/extractContent/utils/extractDictionaryKey.mjs +2 -0
- package/dist/esm/extractContent/utils/extractDictionaryKey.mjs.map +1 -0
- package/dist/esm/extractContent/utils/generateKey.mjs +2 -0
- package/dist/esm/extractContent/utils/generateKey.mjs.map +1 -0
- package/dist/esm/extractContent/utils/getComponentName.mjs +2 -0
- package/dist/esm/extractContent/utils/getComponentName.mjs.map +1 -0
- package/dist/esm/extractContent/utils/getExistingIntlayerInfo.mjs +2 -0
- package/dist/esm/extractContent/utils/getExistingIntlayerInfo.mjs.map +1 -0
- package/dist/esm/extractContent/utils/getOrGenerateKey.mjs +2 -0
- package/dist/esm/extractContent/utils/getOrGenerateKey.mjs.map +1 -0
- package/dist/esm/extractContent/utils/index.mjs +1 -0
- package/dist/esm/extractContent/utils/resolveDictionaryKey.mjs +2 -0
- package/dist/esm/extractContent/utils/resolveDictionaryKey.mjs.map +1 -0
- package/dist/esm/extractContent/utils/shouldExtract.mjs +2 -0
- package/dist/esm/extractContent/utils/shouldExtract.mjs.map +1 -0
- package/dist/esm/getExtractPluginOptions.mjs +1 -1
- package/dist/esm/getOptimizePluginOptions.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/types/babel-plugin-intlayer-extract.d.ts +28 -58
- package/dist/types/babel-plugin-intlayer-extract.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-optimize.d.ts +2 -2
- package/dist/types/babel-plugin-intlayer-optimize.d.ts.map +1 -1
- package/dist/types/extractContent/babelProcessor.d.ts +41 -0
- package/dist/types/extractContent/babelProcessor.d.ts.map +1 -0
- package/dist/types/extractContent/contentWriter.d.ts +27 -0
- package/dist/types/extractContent/contentWriter.d.ts.map +1 -0
- package/dist/types/extractContent/extractContent.d.ts +52 -0
- package/dist/types/extractContent/extractContent.d.ts.map +1 -0
- package/dist/types/extractContent/index.d.ts +4 -0
- package/dist/types/extractContent/processTsxFile.d.ts +18 -0
- package/dist/types/extractContent/processTsxFile.d.ts.map +1 -0
- package/dist/types/extractContent/utils/constants.d.ts +16 -0
- package/dist/types/extractContent/utils/constants.d.ts.map +1 -0
- package/dist/types/extractContent/utils/detectPackageName.d.ts +8 -0
- package/dist/types/extractContent/utils/detectPackageName.d.ts.map +1 -0
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts +11 -0
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts.map +1 -0
- package/dist/types/extractContent/utils/generateKey.d.ts +5 -0
- package/dist/types/extractContent/utils/generateKey.d.ts.map +1 -0
- package/dist/types/extractContent/utils/getComponentName.d.ts +10 -0
- package/dist/types/extractContent/utils/getComponentName.d.ts.map +1 -0
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts +13 -0
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts.map +1 -0
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts +8 -0
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts.map +1 -0
- package/dist/types/extractContent/utils/index.d.ts +10 -0
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts +12 -0
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts.map +1 -0
- package/dist/types/extractContent/utils/shouldExtract.d.ts +14 -0
- package/dist/types/extractContent/utils/shouldExtract.d.ts.map +1 -0
- package/dist/types/getOptimizePluginOptions.d.ts +1 -1
- package/dist/types/index.d.ts +4 -1
- package/package.json +18 -13
- package/dist/cjs/test-babel-error.cjs +0 -7
- package/dist/cjs/test-babel-error.cjs.map +0 -1
- package/dist/cjs/test-merge.cjs +0 -2
- package/dist/cjs/test-merge.cjs.map +0 -1
- package/dist/cjs/test-preserve.cjs +0 -2
- package/dist/cjs/test-preserve.cjs.map +0 -1
- package/dist/esm/test-babel-error.mjs +0 -7
- package/dist/esm/test-babel-error.mjs.map +0 -1
- package/dist/esm/test-merge.mjs +0 -2
- package/dist/esm/test-merge.mjs.map +0 -1
- package/dist/esm/test-preserve.mjs +0 -2
- package/dist/esm/test-preserve.mjs.map +0 -1
- package/dist/types/test-babel-error.d.ts +0 -1
- package/dist/types/test-merge.d.ts +0 -1
- package/dist/types/test-preserve.d.ts +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{packageList as e}from"./constants.mjs";import{dirname as t,join as n}from"node:path";import{existsSync as r,readFileSync as i}from"node:fs";const a=a=>{let o=a;for(;o!==t(o);){let a=n(o,`package.json`);if(r(a))try{let t=JSON.parse(i(a,`utf-8`)),n={...t.dependencies,...t.devDependencies,...t.peerDependencies};for(let t of e)if(n[t])return t}catch{}o=t(o)}};export{a as detectPackageName};
|
|
2
|
+
//# sourceMappingURL=detectPackageName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectPackageName.mjs","names":[],"sources":["../../../../src/extractContent/utils/detectPackageName.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { packageList } from './constants';\n\n/**\n * Detects which intlayer package is used in the project by reading package.json.\n */\nexport const detectPackageName = (searchDir: string): string | undefined => {\n let currentDir = searchDir;\n\n while (currentDir !== dirname(currentDir)) {\n const pkgPath = join(currentDir, 'package.json');\n\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n const allDeps = {\n ...pkg.dependencies,\n ...pkg.devDependencies,\n ...pkg.peerDependencies,\n };\n for (const pkgName of packageList) {\n if (allDeps[pkgName]) return pkgName;\n }\n } catch {\n // Ignore JSON errors\n }\n }\n currentDir = dirname(currentDir);\n }\n\n return undefined;\n};\n"],"mappings":"mJAOA,MAAa,EAAqB,GAA0C,CAC1E,IAAI,EAAa,EAEjB,KAAO,IAAe,EAAQ,EAAW,EAAE,CACzC,IAAM,EAAU,EAAK,EAAY,eAAe,CAEhD,GAAI,EAAW,EAAQ,CACrB,GAAI,CACF,IAAM,EAAM,KAAK,MAAM,EAAa,EAAS,QAAQ,CAAC,CAChD,EAAU,CACd,GAAG,EAAI,aACP,GAAG,EAAI,gBACP,GAAG,EAAI,iBACR,CACD,IAAK,IAAM,KAAW,EACpB,GAAI,EAAQ,GAAU,OAAO,OAEzB,EAIV,EAAa,EAAQ,EAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{detectExportedComponentName as e}from"@intlayer/chokidar/cli";import{camelCaseToKebabCase as t}from"@intlayer/config/utils";const n=(e,t=`comp-`)=>{let n=e.split(/[\\/]/),r=n.pop()||``,i=r.lastIndexOf(`.`),a=i===-1?r:r.slice(0,i);return a.toLowerCase()===`index`&&(a=n.pop()||a),`${t}${a.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[\s_]+/g,`-`).toLowerCase()}`},r=(r,i)=>{let a=e(i);return a?t(a):n(r,``)};export{r as extractDictionaryKey,n as extractDictionaryKeyFromPath};
|
|
2
|
+
//# sourceMappingURL=extractDictionaryKey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"sourcesContent":["import { detectExportedComponentName } from '@intlayer/chokidar/cli';\nimport { camelCaseToKebabCase } from '@intlayer/config/utils';\n\n/**\n * Extracts a dictionary key from a file path.\n *\n * Example: \"src/components/MyComponent/index.tsx\" -> \"comp-my-component\"\n */\nexport const extractDictionaryKeyFromPath = (\n filePath: string,\n prefix = 'comp-'\n): string => {\n const pathParts = filePath.split(/[\\\\/]/);\n const fileNameWithExt = pathParts.pop() || '';\n const lastDotIndex = fileNameWithExt.lastIndexOf('.');\n let baseName =\n lastDotIndex !== -1\n ? fileNameWithExt.slice(0, lastDotIndex)\n : fileNameWithExt;\n\n if (baseName.toLowerCase() === 'index') {\n baseName = pathParts.pop() || baseName;\n }\n\n return `${prefix}${baseName\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase()}`;\n};\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string\n): string => {\n const componentName = detectExportedComponentName(fileText);\n\n if (componentName) {\n return camelCaseToKebabCase(componentName);\n }\n\n return extractDictionaryKeyFromPath(filePath, '');\n};\n"],"mappings":"mIAQA,MAAa,GACX,EACA,EAAS,UACE,CACX,IAAM,EAAY,EAAS,MAAM,QAAQ,CACnC,EAAkB,EAAU,KAAK,EAAI,GACrC,EAAe,EAAgB,YAAY,IAAI,CACjD,EACF,IAAiB,GAEb,EADA,EAAgB,MAAM,EAAG,EAAa,CAO5C,OAJI,EAAS,aAAa,GAAK,UAC7B,EAAW,EAAU,KAAK,EAAI,GAGzB,GAAG,IAAS,EAChB,QAAQ,kBAAmB,QAAQ,CACnC,QAAQ,UAAW,IAAI,CACvB,aAAa,IAGL,GACX,EACA,IACW,CACX,IAAM,EAAgB,EAA4B,EAAS,CAM3D,OAJI,EACK,EAAqB,EAAc,CAGrC,EAA6B,EAAU,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(e,t)=>{let n=e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[\s_-]+/g,` `).replace(/[^\p{L}\p{N} ]/gu,``).trim().split(` `).filter(Boolean).slice(0,5).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);if(n||=`content`,t.has(n)){let e=1;for(;t.has(`${n}${e}`);)e++;n=`${n}${e}`}return n};export{e as generateKey};
|
|
2
|
+
//# sourceMappingURL=generateKey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/generateKey.ts"],"sourcesContent":["export const generateKey = (\n text: string,\n existingKeys: Set<string>\n): string => {\n const maxWords = 5;\n let key = text\n .normalize('NFD') // Normalize to decomposes combined characters (e.g., é -> e + ´)\n .replace(/[\\u0300-\\u036f]/g, '') // Remove the accent characters\n .replace(/[\\s_-]+/g, ' ')\n .replace(/[^\\p{L}\\p{N} ]/gu, '')\n .trim()\n .split(' ')\n .filter(Boolean)\n .slice(0, maxWords)\n .map((word, index) =>\n index === 0\n ? word.toLowerCase()\n : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n\n if (!key) key = 'content';\n if (existingKeys.has(key)) {\n let i = 1;\n while (existingKeys.has(`${key}${i}`)) i++;\n key = `${key}${i}`;\n }\n return key;\n};\n"],"mappings":"AAAA,MAAa,GACX,EACA,IACW,CAEX,IAAI,EAAM,EACP,UAAU,MAAM,CAChB,QAAQ,mBAAoB,GAAG,CAC/B,QAAQ,WAAY,IAAI,CACxB,QAAQ,mBAAoB,GAAG,CAC/B,MAAM,CACN,MAAM,IAAI,CACV,OAAO,QAAQ,CACf,MAAM,EATQ,EASI,CAClB,KAAK,EAAM,IACV,IAAU,EACN,EAAK,aAAa,CAClB,EAAK,OAAO,EAAE,CAAC,aAAa,CAAG,EAAK,MAAM,EAAE,CAAC,aAAa,CAC/D,CACA,KAAK,GAAG,CAGX,GADA,AAAU,IAAM,UACZ,EAAa,IAAI,EAAI,CAAE,CACzB,IAAI,EAAI,EACR,KAAO,EAAa,IAAI,GAAG,IAAM,IAAI,EAAE,IACvC,EAAM,GAAG,IAAM,IAEjB,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"@babel/types";const t=t=>{if(t.isFunctionDeclaration())return t.node.id?.name;if((t.isArrowFunctionExpression()||t.isFunctionExpression())&&t.parentPath.isVariableDeclarator()&&e.isIdentifier(t.parentPath.node.id))return t.parentPath.node.id.name};export{t as getComponentName};
|
|
2
|
+
//# sourceMappingURL=getComponentName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getComponentName.mjs","names":[],"sources":["../../../../src/extractContent/utils/getComponentName.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\n\n/**\n * Resolves the name of the component from various function declaration types.\n */\nexport const getComponentName = (path: NodePath): string | undefined => {\n if (path.isFunctionDeclaration()) {\n return path.node.id?.name;\n }\n\n if (path.isArrowFunctionExpression() || path.isFunctionExpression()) {\n if (\n path.parentPath.isVariableDeclarator() &&\n t.isIdentifier(path.parentPath.node.id)\n ) {\n return path.parentPath.node.id.name;\n }\n }\n\n return undefined;\n};\n"],"mappings":"+BAMA,MAAa,EAAoB,GAAuC,CACtE,GAAI,EAAK,uBAAuB,CAC9B,OAAO,EAAK,KAAK,IAAI,KAGvB,IAAI,EAAK,2BAA2B,EAAI,EAAK,sBAAsB,GAE/D,EAAK,WAAW,sBAAsB,EACtC,EAAE,aAAa,EAAK,WAAW,KAAK,GAAG,CAEvC,OAAO,EAAK,WAAW,KAAK,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"@babel/types";const t=t=>{let n;return t.traverse({CallExpression(t){let r=t.node.callee;if(e.isIdentifier(r)&&(r.name===`useIntlayer`||r.name===`getIntlayer`)){let i=t.node.arguments[0];e.isStringLiteral(i)&&(n={key:i.value,hook:r.name},t.stop())}},Function(e){e.skip()}}),n};export{t as getExistingIntlayerInfo};
|
|
2
|
+
//# sourceMappingURL=getExistingIntlayerInfo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExistingIntlayerInfo.mjs","names":[],"sources":["../../../../src/extractContent/utils/getExistingIntlayerInfo.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\n\n/**\n * Searches for an existing useIntlayer or getIntlayer call in the function body.\n */\nexport const getExistingIntlayerInfo = (\n path: NodePath\n): { key: string; hook: 'useIntlayer' | 'getIntlayer' } | undefined => {\n let result: { key: string; hook: 'useIntlayer' | 'getIntlayer' } | undefined;\n\n // We only check the direct body of the function, not nested functions\n path.traverse({\n CallExpression(childPath) {\n const callee = childPath.node.callee;\n if (\n t.isIdentifier(callee) &&\n (callee.name === 'useIntlayer' || callee.name === 'getIntlayer')\n ) {\n const arg = childPath.node.arguments[0];\n if (t.isStringLiteral(arg)) {\n result = {\n key: arg.value,\n hook: callee.name as 'useIntlayer' | 'getIntlayer',\n };\n childPath.stop();\n }\n }\n },\n Function(childPath) {\n childPath.skip(); // Don't look inside nested functions\n },\n });\n\n return result;\n};\n"],"mappings":"+BAMA,MAAa,EACX,GACqE,CACrE,IAAI,EAyBJ,OAtBA,EAAK,SAAS,CACZ,eAAe,EAAW,CACxB,IAAM,EAAS,EAAU,KAAK,OAC9B,GACE,EAAE,aAAa,EAAO,GACrB,EAAO,OAAS,eAAiB,EAAO,OAAS,eAClD,CACA,IAAM,EAAM,EAAU,KAAK,UAAU,GACjC,EAAE,gBAAgB,EAAI,GACxB,EAAS,CACP,IAAK,EAAI,MACT,KAAM,EAAO,KACd,CACD,EAAU,MAAM,IAItB,SAAS,EAAW,CAClB,EAAU,MAAM,EAEnB,CAAC,CAEK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrGenerateKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/getOrGenerateKey.ts"],"sourcesContent":["import { generateKey } from './generateKey';\n\n/**\n * Gets an existing key for a given text or generates a new one.\n */\nexport const getOrGenerateKey = (\n text: string,\n componentKey: string,\n existingKeys: Set<string>,\n extractedContent: Record<string, Record<string, string>>\n): string => {\n if (!extractedContent[componentKey]) {\n extractedContent[componentKey] = {};\n }\n const existingEntry = Object.entries(extractedContent[componentKey]).find(\n ([_, value]) => value === text\n );\n\n if (existingEntry) {\n return existingEntry[0];\n }\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[componentKey][key] = text;\n return key;\n};\n"],"mappings":"gDAKA,MAAa,GACX,EACA,EACA,EACA,IACW,CACN,EAAiB,KACpB,EAAiB,GAAgB,EAAE,EAErC,IAAM,EAAgB,OAAO,QAAQ,EAAiB,GAAc,CAAC,MAClE,CAAC,EAAG,KAAW,IAAU,EAC3B,CAED,GAAI,EACF,OAAO,EAAc,GAEvB,IAAM,EAAM,EAAY,EAAM,EAAa,CAG3C,OAFA,EAAa,IAAI,EAAI,CACrB,EAAiB,GAAc,GAAO,EAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ATTRIBUTES_TO_EXTRACT as e,packageList as t}from"./constants.mjs";import{detectPackageName as n}from"./detectPackageName.mjs";import{extractDictionaryKey as r,extractDictionaryKeyFromPath as i}from"./extractDictionaryKey.mjs";import{generateKey as a}from"./generateKey.mjs";import{getComponentName as o}from"./getComponentName.mjs";import{getExistingIntlayerInfo as s}from"./getExistingIntlayerInfo.mjs";import{getOrGenerateKey as c}from"./getOrGenerateKey.mjs";import{resolveDictionaryKey as l}from"./resolveDictionaryKey.mjs";import{shouldExtract as u}from"./shouldExtract.mjs";export{e as ATTRIBUTES_TO_EXTRACT,n as detectPackageName,r as extractDictionaryKey,i as extractDictionaryKeyFromPath,a as generateKey,o as getComponentName,s as getExistingIntlayerInfo,c as getOrGenerateKey,t as packageList,l as resolveDictionaryKey,u as shouldExtract};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dirname as e,join as t}from"node:path";import{existsSync as n}from"node:fs";import{getUnmergedDictionaries as r}from"@intlayer/unmerged-dictionaries-entry";const i=(i,a,o,s,c=new Set)=>{let l=s??r(o)??{},{fileExtensions:u}=o.content,d=e(a),f=u[0],p=f.startsWith(`.`)?f:`.${f}`,m=0;for(;m<100;){let e=m===0?i:`${i}${m}`,r=l[e],a=t(d,`${e}${p}`),o=c.has(e),s=r&&r.length>0,u=n(a);if(!o&&!s&&!u)return e;m++}return i};export{i as resolveDictionaryKey};
|
|
2
|
+
//# sourceMappingURL=resolveDictionaryKey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDictionaryKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/resolveDictionaryKey.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\n/**\n * Resolves a unique dictionary key, checking for existing dictionaries and files.\n * Note: this chokidar-specific variant fetches unmergedDictionaries internally\n * from the configuration (unlike the `@intlayer/babel` version which takes it as a parameter).\n */\nexport const resolveDictionaryKey = (\n initialKey: string,\n filePath: string,\n configuration: IntlayerConfig,\n unmergedDictionaries?: Record<string, unknown>,\n usedKeys: Set<string> = new Set()\n): string => {\n const dicts =\n unmergedDictionaries ?? getUnmergedDictionaries(configuration) ?? {};\n\n const { fileExtensions } = configuration.content;\n\n const dirName = dirname(filePath);\n const firstExtension = fileExtensions[0];\n const extension = firstExtension.startsWith('.')\n ? firstExtension\n : `.${firstExtension}`;\n\n let index = 0;\n\n while (index < 100) {\n const keyToTest = index === 0 ? initialKey : `${initialKey}${index}`;\n const dictionaries = dicts[keyToTest] as Dictionary[] | undefined;\n const contentFilePath = join(dirName, `${keyToTest}${extension}`);\n const isKeyUsed = usedKeys.has(keyToTest);\n const hasDictionaries = dictionaries && dictionaries.length > 0;\n const fileExists = existsSync(contentFilePath);\n\n if (!isKeyUsed && !hasDictionaries && !fileExists) {\n return keyToTest;\n }\n index++;\n }\n\n return initialKey;\n};\n"],"mappings":"mKAUA,MAAa,GACX,EACA,EACA,EACA,EACA,EAAwB,IAAI,MACjB,CACX,IAAM,EACJ,GAAwB,EAAwB,EAAc,EAAI,EAAE,CAEhE,CAAE,kBAAmB,EAAc,QAEnC,EAAU,EAAQ,EAAS,CAC3B,EAAiB,EAAe,GAChC,EAAY,EAAe,WAAW,IAAI,CAC5C,EACA,IAAI,IAEJ,EAAQ,EAEZ,KAAO,EAAQ,KAAK,CAClB,IAAM,EAAY,IAAU,EAAI,EAAa,GAAG,IAAa,IACvD,EAAe,EAAM,GACrB,EAAkB,EAAK,EAAS,GAAG,IAAY,IAAY,CAC3D,EAAY,EAAS,IAAI,EAAU,CACnC,EAAkB,GAAgB,EAAa,OAAS,EACxD,EAAa,EAAW,EAAgB,CAE9C,GAAI,CAAC,GAAa,CAAC,GAAmB,CAAC,EACrC,OAAO,EAET,IAGF,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldExtract.mjs","names":[],"sources":["../../../../src/extractContent/utils/shouldExtract.ts"],"sourcesContent":["/**\n * Checks whether the given text should be extracted as a translatable string.\n *\n * Filters out:\n * - Empty strings\n * - Single words (typically icons or technical terms)\n * - Strings not starting with an uppercase letter (likely technical values)\n * - Dynamic content patterns like Vue bindings (`v-`) or object patterns (`{`)\n */\nexport const shouldExtract = (text: string): boolean => {\n const trimmed = text.trim();\n\n if (!trimmed) return false;\n\n // We usually want to extract full sentences or labels, not single technical words\n if (!trimmed.includes(' ')) return false;\n\n // We assume content to extract starts with an uppercase letter\n if (!/^[A-Z]/.test(trimmed)) return false;\n\n // Ignore dynamic content patterns\n if (trimmed.startsWith('{') || trimmed.startsWith('v-')) return false;\n\n return true;\n};\n"],"mappings":"AASA,MAAa,EAAiB,GAA0B,CACtD,IAAM,EAAU,EAAK,MAAM,CAa3B,MAFA,EATI,CAAC,GAGD,CAAC,EAAQ,SAAS,IAAI,EAGtB,CAAC,SAAS,KAAK,EAAQ,EAGvB,EAAQ,WAAW,IAAI,EAAI,EAAQ,WAAW,KAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__require as e}from"./_virtual/_rolldown/runtime.mjs";import{
|
|
1
|
+
import{__require as e}from"./_virtual/_rolldown/runtime.mjs";import{join as t,relative as n}from"node:path";import{ANSIColors as r,colorize as i,getAppLogger as a}from"@intlayer/config/client";import{getConfiguration as o}from"@intlayer/config/node";import{existsSync as s}from"node:fs";import{readFile as c}from"node:fs/promises";import{buildDictionary as l,writeContentDeclaration as u}from"@intlayer/chokidar/build";const d=(d=process.env.INTLAYER_IS_DEV_COMMAND)=>{let f=o(),{baseDir:p}=f.content,m=t(p,f.compiler?.outputDir??`compiler`),h=async e=>{try{if(!s(e))return null;let t=await c(e,`utf-8`);if(!t||t.trim()===``)return null;let n=JSON.parse(t);return Array.isArray(n)?n[0]??null:n}catch(t){return s(e)&&(await c(e,`utf-8`)).trim()!==``&&console.warn(`[intlayer] Warning: Failed to read existing dictionary at ${e}. It might be corrupt. Translations may be lost. Error:`,t),null}},g=(e,t,n)=>{let r={},i=t?.content,a=Object.keys(e).sort();for(let t of a){let a=e[t],o=i?.[t];o&&o.nodeType===`translation`&&o.translation?r[t]={...o,nodeType:`translation`,translation:{...o.translation,[n]:o.translation[n]??a}}:r[t]={nodeType:`translation`,translation:{[n]:a}}}return r},_=async r=>{let{dictionaryKey:i,content:a,locale:o}=r;try{let e=await h(t(m,`${i}.content.json`)),r=g(a,e,o),s={...e,key:i,content:r,filePath:t(n(p,m),`${i}.content.json`)},c=await u(s,f,{newDictionariesPath:n(p,m)});await l([{...s,filePath:n(p,c.path)}],f)}catch(t){if(console.error(`[intlayer] Failed to process extracted content for ${i}:`,t),t instanceof SyntaxError&&t.message.includes(`Unexpected end of JSON input`)){let n=t.message.match(/^(.*\.json):\s*Unexpected end of JSON input/);if(n){let t=n[1];try{let n=e(`fs`).readFileSync(t,`utf-8`);console.error(`[intlayer] Content of the corrupted file (${t}):\n"${n}"`)}catch(e){console.error(`[intlayer] Could not read corrupted file ${t}`,e)}}}}},v=String(d)===`true`,y=f.compiler?.enabled===`build-only`?!v:f.compiler?.enabled??!0,b=a(f);return f.compiler?.enabled===`build-only`&&v&&b(`${i(`Compiler:`,r.GREY_DARK)} i18n function is not inserted in the code in dev mode to optimize build time. (to test i18n in dev mode set compiler.enabled to true)`),{enabled:y,defaultLocale:f.internationalization.defaultLocale,prefix:f.compiler?.dictionaryKeyPrefix,saveComponents:f.compiler?.saveComponents,onExtract:_}};export{d as getExtractPluginOptions};
|
|
2
2
|
//# sourceMappingURL=getExtractPluginOptions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getComponentTransformPatternSync } from '@intlayer/chokidar/utils';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport type { OptimizePluginOptions } from './babel-plugin-intlayer-optimize';\n\ntype GetOptimizePluginOptionsParams = {\n /**\n * Configuration options for loading intlayer config\n */\n configOptions?: GetConfigurationOptions;\n /**\n * Pre-loaded dictionaries (optional - will be loaded if not provided)\n */\n dictionaries?: Dictionary[];\n /**\n * Override specific options\n */\n overrides?: Partial<OptimizePluginOptions>;\n};\n\n/**\n * Load dictionaries from the dictionaries-entry package\n */\nconst loadDictionaries = (config: IntlayerConfig): Dictionary[] => {\n try {\n // Dynamic require to avoid build-time dependency issues\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { getDictionaries } = require('@intlayer/dictionaries-entry');\n const dictionariesRecord = getDictionaries(config) as Record<\n string,\n Dictionary\n >;\n return Object.values(dictionariesRecord);\n } catch {\n // If dictionaries-entry is not available, return empty array\n return [];\n }\n};\n\n/**\n * Get the options for the Intlayer Babel optimization plugin\n * This function loads the Intlayer configuration and returns the paths\n * needed for dictionary optimization and import rewriting.\n */\nexport const getOptimizePluginOptions = (\n params?: GetOptimizePluginOptionsParams\n): OptimizePluginOptions => {\n const {\n configOptions,\n dictionaries: providedDictionaries,\n overrides,\n } = params ?? {};\n\n const config = getConfiguration(configOptions);\n const {\n mainDir,\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n } = config.system;\n const { importMode, optimize } = config.build;\n\n // Build files list from traverse pattern\n const filesListPattern = getComponentTransformPatternSync(config);\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n ];\n\n // Load dictionaries if not provided\n const dictionaries = providedDictionaries ?? loadDictionaries(config);\n\n const dictionaryModeMap: Record
|
|
1
|
+
{"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getComponentTransformPatternSync } from '@intlayer/chokidar/utils';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport type { OptimizePluginOptions } from './babel-plugin-intlayer-optimize';\n\ntype GetOptimizePluginOptionsParams = {\n /**\n * Configuration options for loading intlayer config\n */\n configOptions?: GetConfigurationOptions;\n /**\n * Pre-loaded dictionaries (optional - will be loaded if not provided)\n */\n dictionaries?: Dictionary[];\n /**\n * Override specific options\n */\n overrides?: Partial<OptimizePluginOptions>;\n};\n\n/**\n * Load dictionaries from the dictionaries-entry package\n */\nconst loadDictionaries = (config: IntlayerConfig): Dictionary[] => {\n try {\n // Dynamic require to avoid build-time dependency issues\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { getDictionaries } = require('@intlayer/dictionaries-entry');\n const dictionariesRecord = getDictionaries(config) as Record<\n string,\n Dictionary\n >;\n return Object.values(dictionariesRecord);\n } catch {\n // If dictionaries-entry is not available, return empty array\n return [];\n }\n};\n\n/**\n * Get the options for the Intlayer Babel optimization plugin\n * This function loads the Intlayer configuration and returns the paths\n * needed for dictionary optimization and import rewriting.\n */\nexport const getOptimizePluginOptions = (\n params?: GetOptimizePluginOptionsParams\n): OptimizePluginOptions => {\n const {\n configOptions,\n dictionaries: providedDictionaries,\n overrides,\n } = params ?? {};\n\n const config = getConfiguration(configOptions);\n const {\n mainDir,\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n } = config.system;\n const { importMode, optimize } = config.build;\n\n // Build files list from traverse pattern\n const filesListPattern = getComponentTransformPatternSync(config);\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n ];\n\n // Load dictionaries if not provided\n const dictionaries = providedDictionaries ?? loadDictionaries(config);\n\n const dictionaryModeMap: Record<\n string,\n 'static' | 'dynamic' | 'fetch' | undefined\n > = {};\n\n dictionaries.forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] = dictionary.importMode ?? importMode;\n });\n\n return {\n optimize,\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesDir,\n unmergedDictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n replaceDictionaryEntry: true,\n importMode,\n dictionaryModeMap,\n filesList,\n ...overrides,\n };\n};\n"],"mappings":"mOA2BA,MAAM,EAAoB,GAAyC,CACjE,GAAI,CAGF,GAAM,CAAE,mBAAA,EAA4B,+BAA+B,CAC7D,EAAqB,EAAgB,EAAO,CAIlD,OAAO,OAAO,OAAO,EAAmB,MAClC,CAEN,MAAO,EAAE,GASA,EACX,GAC0B,CAC1B,GAAM,CACJ,gBACA,aAAc,EACd,aACE,GAAU,EAAE,CAEV,EAAS,EAAiB,EAAc,CACxC,CACJ,UACA,kBACA,0BACA,yBACA,wBACE,EAAO,OACL,CAAE,aAAY,YAAa,EAAO,MAGlC,EAAmB,EAAiC,EAAO,CAE3D,EAAwB,EAAK,EAAS,mBAAmB,CACzD,EAAgC,EACpC,EACA,4BACD,CACK,EAA+B,EACnC,EACA,2BACD,CACK,EAA6B,EAAK,EAAS,yBAAyB,CAEpE,EAAY,CAChB,GAAG,EACH,EACA,EACD,CAGK,EAAe,GAAwB,EAAiB,EAAO,CAE/D,EAGF,EAAE,CAMN,OAJA,EAAa,QAAS,GAAe,CACnC,EAAkB,EAAW,KAAO,EAAW,YAAc,GAC7D,CAEK,CACL,WACA,kBACA,wBACA,0BACA,gCACA,yBACA,+BACA,uBACA,6BACA,uBAAwB,GACxB,aACA,oBACA,YACA,GAAG,EACJ"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ATTRIBUTES_TO_EXTRACT as e,packageList as t}from"./extractContent/utils/constants.mjs";import{detectPackageName as n}from"./extractContent/utils/detectPackageName.mjs";import{intlayerExtractBabelPlugin as r}from"./babel-plugin-intlayer-extract.mjs";import{intlayerOptimizeBabelPlugin as i}from"./babel-plugin-intlayer-optimize.mjs";import{getExtractPluginOptions as a}from"./getExtractPluginOptions.mjs";import{getOptimizePluginOptions as o}from"./getOptimizePluginOptions.mjs";import{extractContent as s}from"./extractContent/extractContent.mjs";export{e as ATTRIBUTES_TO_EXTRACT,n as detectPackageName,s as extractContent,a as getExtractPluginOptions,o as getOptimizePluginOptions,r as intlayerExtractBabelPlugin,i as intlayerOptimizeBabelPlugin,t as packageList};
|
|
@@ -1,79 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginObj, PluginPass } from "@babel/core";
|
|
2
2
|
import * as BabelTypes from "@babel/types";
|
|
3
3
|
|
|
4
4
|
//#region src/babel-plugin-intlayer-extract.d.ts
|
|
5
|
-
type ExtractedContent = Record<string, string>;
|
|
6
|
-
/**
|
|
7
|
-
* Extracted content result from a file transformation
|
|
8
|
-
*/
|
|
9
5
|
type ExtractResult = {
|
|
10
|
-
|
|
11
|
-
filePath: string;
|
|
12
|
-
content:
|
|
6
|
+
dictionaryKey: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
content: Record<string, string>;
|
|
13
9
|
locale: string;
|
|
14
10
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Options for the extraction Babel plugin
|
|
17
|
-
*/
|
|
18
11
|
type ExtractPluginOptions = {
|
|
19
|
-
/**
|
|
20
|
-
* The default locale for the extracted content
|
|
21
|
-
*/
|
|
22
12
|
defaultLocale?: string;
|
|
23
|
-
/**
|
|
24
|
-
* The package to import useIntlayer from
|
|
25
|
-
* @default 'react-intlayer'
|
|
26
|
-
*/
|
|
27
13
|
packageName?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Files list to traverse. If provided, only files in this list will be processed.
|
|
30
|
-
*/
|
|
31
14
|
filesList?: string[];
|
|
32
|
-
/**
|
|
33
|
-
* Custom function to determine if a string should be extracted
|
|
34
|
-
*/
|
|
35
15
|
shouldExtract?: (text: string) => boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Callback function called when content is extracted from a file.
|
|
38
|
-
* This allows the compiler to capture the extracted content and write it to files.
|
|
39
|
-
* The dictionary will be updated: new keys added, unused keys removed.
|
|
40
|
-
*/
|
|
41
|
-
onExtract?: (result: ExtractResult) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the extraction compiler is enabled.
|
|
44
|
-
* If false, the plugin will not process the file.
|
|
45
|
-
*/
|
|
46
16
|
enabled?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Prefix for the extracted dictionary keys.
|
|
49
|
-
*/
|
|
50
17
|
prefix?: string;
|
|
18
|
+
saveComponents?: boolean;
|
|
19
|
+
formatCommand?: string;
|
|
51
20
|
/**
|
|
52
|
-
*
|
|
21
|
+
* Callback invoked for each extracted dictionary key/content pair.
|
|
22
|
+
* Used by `getExtractPluginOptions` to write dictionaries to disk.
|
|
23
|
+
* May be async — the plugin will fire-and-forget (Babel transforms are sync).
|
|
53
24
|
*/
|
|
54
|
-
|
|
25
|
+
onExtract?: (result: ExtractResult) => void | Promise<void>;
|
|
55
26
|
};
|
|
56
27
|
type State = PluginPass & {
|
|
57
|
-
opts: ExtractPluginOptions;
|
|
58
|
-
_extractedContent?: ExtractedContent; /** Set of existing keys to avoid duplicates */
|
|
59
|
-
_existingKeys?: Set<string>; /** The dictionary key for this file */
|
|
60
|
-
_dictionaryKey?: string; /** whether the current file is included in the filesList */
|
|
61
|
-
_isIncluded?: boolean; /** Whether this file has JSX (React component) */
|
|
62
|
-
_hasJSX?: boolean; /** Whether we already have useIntlayer imported */
|
|
63
|
-
_hasUseIntlayerImport?: boolean; /** The local name for useIntlayer (in case it's aliased) */
|
|
64
|
-
_useIntlayerLocalName?: string; /** Whether we already have getIntlayer imported */
|
|
65
|
-
_hasGetIntlayerImport?: boolean; /** The local name for getIntlayer (in case it's aliased) */
|
|
66
|
-
_getIntlayerLocalName?: string; /** The variable name to use for content (content or _compContent if content is already used) */
|
|
67
|
-
_contentVarName?: string; /** Whether the file has 'use client' directive */
|
|
68
|
-
_isClient?: boolean; /** Whether there is extracted content at the top level (not in a function) */
|
|
69
|
-
_hasTopLevelContent?: boolean; /** Targets to extract and modify */
|
|
70
|
-
_extractionTargets?: {
|
|
71
|
-
path: NodePath<any>;
|
|
72
|
-
key: string;
|
|
73
|
-
isAttribute: boolean;
|
|
74
|
-
}[]; /** Functions to inject the hook/core logic into */
|
|
75
|
-
_functionsToInject?: Set<NodePath<BabelTypes.Function>>;
|
|
28
|
+
opts: ExtractPluginOptions;
|
|
76
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Babel plugin that extracts translatable content from source files and
|
|
32
|
+
* injects Intlayer hooks (`useIntlayer` / `getIntlayer`) automatically.
|
|
33
|
+
*
|
|
34
|
+
* Designed for use with Babel-based build tools such as Next.js and Webpack.
|
|
35
|
+
*
|
|
36
|
+
* @example babel.config.js
|
|
37
|
+
* ```js
|
|
38
|
+
* const { intlayerExtractBabelPlugin, getExtractPluginOptions } = require('@intlayer/babel');
|
|
39
|
+
* module.exports = {
|
|
40
|
+
* presets: ['next/babel'],
|
|
41
|
+
* plugins: [
|
|
42
|
+
* [intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
43
|
+
* ],
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
77
47
|
declare const intlayerExtractBabelPlugin: (babel: {
|
|
78
48
|
types: typeof BabelTypes;
|
|
79
49
|
}) => PluginObj<State>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;KAmBY,aAAA;EACV,aAAA;EACA,QAAA;EACA,OAAA,EAAS,MAAA;EACT,MAAA;AAAA;AAAA,KAGU,oBAAA;EACV,aAAA;EACA,WAAA;EACA,SAAA;EACA,aAAA,IAAiB,IAAA;EACjB,OAAA;EACA,MAAA;EACA,cAAA;EACA,aAAA;;;;;;EAMA,SAAA,IAAa,MAAA,EAAQ,aAAA,YAAyB,OAAA;AAAA;AAAA,KAG3C,KAAA,GAAQ,UAAA;EAAe,IAAA,EAAM,oBAAA;AAAA;;;;;;;;AAFhC;;;;;;;;;AAqBF;cAAa,0BAAA,GAA8B,KAAA;EACzC,KAAA,SAAc,UAAA;AAAA,MACZ,SAAA,CAAU,KAAA"}
|
|
@@ -50,11 +50,11 @@ type OptimizePluginOptions = {
|
|
|
50
50
|
/**
|
|
51
51
|
* If true, the plugin will activate the dynamic import of the dictionaries. It will rely on Suspense to load the dictionaries.
|
|
52
52
|
*/
|
|
53
|
-
importMode: 'static' | 'dynamic' | 'fetch';
|
|
53
|
+
importMode: 'static' | 'dynamic' | 'fetch' | undefined;
|
|
54
54
|
/**
|
|
55
55
|
* Map of dictionary keys to their specific import mode.
|
|
56
56
|
*/
|
|
57
|
-
dictionaryModeMap?: Record<string, 'static' | 'dynamic' | 'fetch'>;
|
|
57
|
+
dictionaryModeMap?: Record<string, 'static' | 'dynamic' | 'fetch' | undefined>;
|
|
58
58
|
/**
|
|
59
59
|
* Files list to traverse.
|
|
60
60
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":";;;;cAsBM,WAAA;;AApB0C;;KAmDpC,qBAAA;EA/B+C;;AA+B3D;EAIE,QAAA;;;;EAIA,eAAA;EAIA;;;EAAA,qBAAA;EAgBA;;;EAZA,6BAAA;EA4BA;;;EAxBA,uBAAA;
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":";;;;cAsBM,WAAA;;AApB0C;;KAmDpC,qBAAA;EA/B+C;;AA+B3D;EAIE,QAAA;;;;EAIA,eAAA;EAIA;;;EAAA,qBAAA;EAgBA;;;EAZA,6BAAA;EA4BA;;;EAxBA,uBAAA;EAmCS;;AACT;EAhCA,sBAAA;;;;EAIA,4BAAA;EAiCoB;;;EA7BpB,oBAAA;EAmCa;;;EA/Bb,0BAAA;EAuBA;;;EAnBA,sBAAA;EAqBgC;;;EAjBhC,UAAA;EAmBiC;;;EAfjC,iBAAA,GAAoB,MAAA;EAmBP;;;EAZb,SAAA;AAAA;AAAA,KAGG,KAAA,GAAQ,UAAA;EACX,IAAA,EAAM,qBAAA,EA+IK;EA7IX,iBAAA,GAAoB,GAAA,SAAY,UAAA,CAAW,UAAA;EAE3C,kBAAA,GAAqB,GAAA,SAAY,UAAA,CAAW,UAAA,GA6IhC;EA3IZ,eAAA,YA2IW;EAzIX,UAAA,GAAa,GAAA,iBAAoB,WAAA,YAwIjC;EAtIA,YAAA,YAqI0C;EAnI1C,kBAAA,YAqIY;EAnIZ,WAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiIW,2BAAA,GAA+B,KAAA;EAC1C,KAAA,SAAc,UAAA;AAAA,MACZ,SAAA,CAAU,KAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { NodePath } from "@babel/traverse";
|
|
3
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
4
|
+
|
|
5
|
+
//#region src/extractContent/babelProcessor.d.ts
|
|
6
|
+
type BabelReplacement = {
|
|
7
|
+
path: NodePath;
|
|
8
|
+
key: string;
|
|
9
|
+
type: 'jsx-text' | 'jsx-attribute' | 'string-literal' | 'jsx-insertion' | 'jsx-text-combined';
|
|
10
|
+
componentKey: string;
|
|
11
|
+
childrenToReplace?: t.Node[];
|
|
12
|
+
variables?: string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Handles JSX insertions (elements with multiple children, including expressions).
|
|
16
|
+
* Replaces complex JSX structures with variable-based translations.
|
|
17
|
+
*/
|
|
18
|
+
declare const handleJsxInsertionBabel: (path: NodePath<t.JSXElement | t.JSXFragment>, fileCode: string, existingKeys: Set<string>, getComponentKeyForPath: (path: NodePath) => string, extractedContent: Record<string, Record<string, string>>, replacements: BabelReplacement[], handledNodes: Set<t.Node>) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Traverses the AST to identify components and extract content.
|
|
21
|
+
* Returns extraction results and metadata about which components need Intlayer hooks.
|
|
22
|
+
*/
|
|
23
|
+
declare const extractBabelContentForComponents: (ast: t.File, fileCode: string, existingKeys: Set<string>, defaultKey: string, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
24
|
+
extractedContent: Record<string, Record<string, string>>;
|
|
25
|
+
replacements: BabelReplacement[];
|
|
26
|
+
componentsNeedingHooks: Set<NodePath>;
|
|
27
|
+
componentKeyMap: Map<t.Node, string>;
|
|
28
|
+
componentPaths: NodePath[];
|
|
29
|
+
hookMap: Map<t.Node, "useIntlayer" | "getIntlayer">;
|
|
30
|
+
isSolid: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* High-level function to extract content from TS/JS/JSX/TSX AST.
|
|
34
|
+
*/
|
|
35
|
+
declare const extractTsContent: (ast: t.File, fileCode: string, existingKeys: Set<string>, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
36
|
+
extractedContent: Record<string, string>;
|
|
37
|
+
replacements: BabelReplacement[];
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { BabelReplacement, extractBabelContentForComponents, extractTsContent, handleJsxInsertionBabel };
|
|
41
|
+
//# sourceMappingURL=babelProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babelProcessor.d.ts","names":[],"sources":["../../../src/extractContent/babelProcessor.ts"],"mappings":";;;;;KAYY,gBAAA;EACV,IAAA,EAAM,QAAA;EACN,GAAA;EACA,IAAA;EAMA,YAAA;EACA,iBAAA,GAAoB,CAAA,CAAE,IAAA;EACtB,SAAA;AAAA;;;;;cAYW,uBAAA,GACX,IAAA,EAAM,QAAA,CAAS,CAAA,CAAE,UAAA,GAAa,CAAA,CAAE,WAAA,GAChC,QAAA,UACA,YAAA,EAAc,GAAA,UACd,sBAAA,GAAyB,IAAA,EAAM,QAAA,aAC/B,gBAAA,EAAkB,MAAA,SAAe,MAAA,mBACjC,YAAA,EAAc,gBAAA,IACd,YAAA,EAAc,GAAA,CAAI,CAAA,CAAE,IAAA;;;;;cA6GT,gCAAA,GACX,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,QAAA,UACA,YAAA,EAAc,GAAA,UACd,UAAA,UACA,aAAA,EAAe,cAAA,EACf,QAAA,UACA,oBAAA,GAAsB,MAAA;EAEtB,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA,EAAc,gBAAA;EACd,sBAAA,EAAwB,GAAA,CAAI,QAAA;EAC5B,eAAA,EAAiB,GAAA,CAAI,CAAA,CAAE,IAAA;EACvB,cAAA,EAAgB,QAAA;EAChB,OAAA,EAAS,GAAA,CAAI,CAAA,CAAE,IAAA;EACf,OAAA;AAAA;;;;cAgPW,gBAAA,GACX,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,QAAA,UACA,YAAA,EAAc,GAAA,UACd,aAAA,EAAe,cAAA,EACf,QAAA,UACA,oBAAA,GAAsB,MAAA;EAEtB,gBAAA,EAAkB,MAAA;EAClB,YAAA,EAAc,gBAAA;AAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dictionary, IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/extractContent/contentWriter.d.ts
|
|
4
|
+
type TranslationNode = {
|
|
5
|
+
nodeType: 'translation';
|
|
6
|
+
translation: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the path for the content file associated with a component.
|
|
10
|
+
* Checks for existing dictionaries first.
|
|
11
|
+
*/
|
|
12
|
+
declare const resolveContentFilePath: (filePath: string, componentKey: string, configuration: IntlayerConfig, outputDir?: string) => {
|
|
13
|
+
contentFilePath: string;
|
|
14
|
+
relativeContentFilePath: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a dictionary object from extracted content.
|
|
18
|
+
* Handles both single-locale and multi-locale formats based on configuration.
|
|
19
|
+
*/
|
|
20
|
+
declare const createDictionary: (extractedContent: Record<string, string>, componentKey: string, relativeContentFilePath: string, configuration: IntlayerConfig) => Dictionary;
|
|
21
|
+
/**
|
|
22
|
+
* Helper to write extracted content to a dictionary file.
|
|
23
|
+
*/
|
|
24
|
+
declare const writeContentHelper: (extractedContent: Record<string, string>, componentKey: string, filePath: string, configuration: IntlayerConfig, outputDir?: string) => Promise<string>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { TranslationNode, createDictionary, resolveContentFilePath, writeContentHelper };
|
|
27
|
+
//# sourceMappingURL=contentWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;KASY,eAAA;EACV,QAAA;EACA,WAAA,EAAa,MAAA;AAAA;;;;;cAOF,sBAAA,GACX,QAAA,UACA,YAAA,UACA,aAAA,EAAe,cAAA,EACf,SAAA;EACG,eAAA;EAAyB,uBAAA;AAAA;;;;;cAgCjB,gBAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,YAAA,UACA,uBAAA,UACA,aAAA,EAAe,cAAA,KACd,UAAA;;;;cAkCU,kBAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,YAAA,UACA,QAAA,UACA,aAAA,EAAe,cAAA,EACf,SAAA,cACC,OAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PackageName } from "./utils/constants.js";
|
|
2
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
3
|
+
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
4
|
+
|
|
5
|
+
//#region src/extractContent/extractContent.d.ts
|
|
6
|
+
type ExtractIntlayerOptions = {
|
|
7
|
+
configOptions?: GetConfigurationOptions;
|
|
8
|
+
outputDir?: string;
|
|
9
|
+
/**
|
|
10
|
+
* If true, only transform the source file — skip writing content declarations.
|
|
11
|
+
*/
|
|
12
|
+
codeOnly?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If true, only write content declarations — skip transforming the source file.
|
|
15
|
+
* When set, `transformedCode` will still be returned (computed but not written to disk).
|
|
16
|
+
*/
|
|
17
|
+
declarationOnly?: boolean;
|
|
18
|
+
unmergedDictionaries?: Record<string, unknown>;
|
|
19
|
+
configuration?: IntlayerConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Raw source code to process instead of reading from disk.
|
|
22
|
+
* Useful for Vite/webpack transform hooks where the code may already
|
|
23
|
+
* have been modified by a previous plugin.
|
|
24
|
+
*/
|
|
25
|
+
code?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked for each extracted dictionary key/content pair.
|
|
28
|
+
* When provided, the caller is responsible for writing content declarations
|
|
29
|
+
* (the built-in `writeContentHelper` is skipped unless `writeContent` is also true).
|
|
30
|
+
* Used by Vite/webpack plugins that manage their own dictionary write pipeline.
|
|
31
|
+
*/
|
|
32
|
+
onExtract?: (result: {
|
|
33
|
+
key: string;
|
|
34
|
+
content: Record<string, string>;
|
|
35
|
+
filePath: string;
|
|
36
|
+
}) => void | Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Extracts Intlayer content from a single source file and optionally transforms it.
|
|
40
|
+
*
|
|
41
|
+
* - For `.vue` / `.svelte` files the matching optional compiler package is used.
|
|
42
|
+
* - For `.tsx` / `.jsx` / `.ts` / `.js` files the Babel-based `processTsxFile` is used.
|
|
43
|
+
*
|
|
44
|
+
* Returns `{ transformedCode }` so callers (e.g. the Vite plugin) can pass the
|
|
45
|
+
* modified source back to the bundler without writing the file to disk.
|
|
46
|
+
*/
|
|
47
|
+
declare const extractContent: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => Promise<{
|
|
48
|
+
transformedCode: string | null;
|
|
49
|
+
} | undefined>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ExtractIntlayerOptions, extractContent };
|
|
52
|
+
//# sourceMappingURL=extractContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractContent.d.ts","names":[],"sources":["../../../src/extractContent/extractContent.ts"],"mappings":";;;;;KA2BY,sBAAA;EACV,aAAA,GAAgB,uBAAA;EAChB,SAAA;EAFU;;;EAMV,QAAA;EAMuB;;;;EADvB,eAAA;EACA,oBAAA,GAAuB,MAAA;EACvB,aAAA,GAAgB,cAAA;EAZA;;;;;EAkBhB,IAAA;EANA;;;;;;EAaA,SAAA,IAAa,MAAA;IACX,GAAA;IACA,OAAA,EAAS,MAAA;IACT,QAAA;EAAA,aACW,OAAA;AAAA;AAgBf;;;;;;;;;AAAA,cAAa,cAAA,GACX,QAAA,UACA,WAAA,EAAa,WAAA,EACb,OAAA,GAAU,sBAAA,KACT,OAAA;EAAU,eAAA;AAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ATTRIBUTES_TO_EXTRACT, PackageName, packageList } from "./utils/constants.js";
|
|
2
|
+
import { detectPackageName } from "./utils/detectPackageName.js";
|
|
3
|
+
import { ExtractIntlayerOptions, extractContent } from "./extractContent.js";
|
|
4
|
+
export { ATTRIBUTES_TO_EXTRACT, ExtractIntlayerOptions, PackageName, detectPackageName, extractContent, packageList };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/extractContent/processTsxFile.d.ts
|
|
4
|
+
type TextEdit = {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
replacement: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Processes a TSX/JSX/TS/JS file to extract content and inject Intlayer hooks/calls.
|
|
11
|
+
*/
|
|
12
|
+
declare const processTsxFile: (filePath: string, componentKey: string, packageName: string, configuration: IntlayerConfig, save?: boolean, unmergedDictionaries?: Record<string, unknown>, providedFileCode?: string) => {
|
|
13
|
+
extractedContent: Record<string, Record<string, string>>;
|
|
14
|
+
modifiedCode: string;
|
|
15
|
+
} | null;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { TextEdit, processTsxFile };
|
|
18
|
+
//# sourceMappingURL=processTsxFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;KAUY,QAAA;EACV,KAAA;EACA,GAAA;EACA,WAAA;AAAA;;;;cAUW,cAAA,GACX,QAAA,UACA,YAAA,UACA,WAAA,UACA,aAAA,EAAe,cAAA,EACf,IAAA,YACA,oBAAA,GAAsB,MAAA,mBACtB,gBAAA;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/extractContent/utils/constants.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Attributes that should be extracted as translatable strings from JSX/HTML elements.
|
|
4
|
+
* This is the single source of truth shared across all Intlayer compiler packages
|
|
5
|
+
* (@intlayer/babel, @intlayer/vue-compiler, @intlayer/svelte-compiler, @intlayer/chokidar).
|
|
6
|
+
*/
|
|
7
|
+
declare const ATTRIBUTES_TO_EXTRACT: readonly ["title", "placeholder", "alt", "aria-label", "label"];
|
|
8
|
+
/**
|
|
9
|
+
* The list of supported Intlayer integration packages.
|
|
10
|
+
* This is the single source of truth for package name validation.
|
|
11
|
+
*/
|
|
12
|
+
declare const packageList: readonly ["next-intlayer", "react-intlayer", "vue-intlayer", "svelte-intlayer", "preact-intlayer", "solid-intlayer", "angular-intlayer", "express-intlayer", "hono-intlayer", "fastify-intlayer", "adonis-intlayer"];
|
|
13
|
+
type PackageName = (typeof packageList)[number];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ATTRIBUTES_TO_EXTRACT, PackageName, packageList };
|
|
16
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../../../src/extractContent/utils/constants.ts"],"mappings":";;AAKA;;;;cAAa,qBAAA;AAYb;;;;AAAA,cAAa,WAAA;AAAA,KAcD,WAAA,WAAsB,WAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/extractContent/utils/detectPackageName.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Detects which intlayer package is used in the project by reading package.json.
|
|
4
|
+
*/
|
|
5
|
+
declare const detectPackageName: (searchDir: string) => string | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { detectPackageName };
|
|
8
|
+
//# sourceMappingURL=detectPackageName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectPackageName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/detectPackageName.ts"],"mappings":";;AAOA;;cAAa,iBAAA,GAAqB,SAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/extractContent/utils/extractDictionaryKey.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extracts a dictionary key from a file path.
|
|
4
|
+
*
|
|
5
|
+
* Example: "src/components/MyComponent/index.tsx" -> "comp-my-component"
|
|
6
|
+
*/
|
|
7
|
+
declare const extractDictionaryKeyFromPath: (filePath: string, prefix?: string) => string;
|
|
8
|
+
declare const extractDictionaryKey: (filePath: string, fileText: string) => string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { extractDictionaryKey, extractDictionaryKeyFromPath };
|
|
11
|
+
//# sourceMappingURL=extractDictionaryKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"mappings":";;AAQA;;;;cAAa,4BAAA,GACX,QAAA,UACA,MAAA;AAAA,cAoBW,oBAAA,GACX,QAAA,UACA,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/generateKey.ts"],"mappings":";cAAa,WAAA,GACX,IAAA,UACA,YAAA,EAAc,GAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NodePath } from "@babel/traverse";
|
|
2
|
+
|
|
3
|
+
//#region src/extractContent/utils/getComponentName.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the name of the component from various function declaration types.
|
|
6
|
+
*/
|
|
7
|
+
declare const getComponentName: (path: NodePath) => string | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getComponentName };
|
|
10
|
+
//# sourceMappingURL=getComponentName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getComponentName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getComponentName.ts"],"mappings":";;;;;AAMA;cAAa,gBAAA,GAAoB,IAAA,EAAM,QAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NodePath } from "@babel/traverse";
|
|
2
|
+
|
|
3
|
+
//#region src/extractContent/utils/getExistingIntlayerInfo.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Searches for an existing useIntlayer or getIntlayer call in the function body.
|
|
6
|
+
*/
|
|
7
|
+
declare const getExistingIntlayerInfo: (path: NodePath) => {
|
|
8
|
+
key: string;
|
|
9
|
+
hook: "useIntlayer" | "getIntlayer";
|
|
10
|
+
} | undefined;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getExistingIntlayerInfo };
|
|
13
|
+
//# sourceMappingURL=getExistingIntlayerInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExistingIntlayerInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getExistingIntlayerInfo.ts"],"mappings":";;;;;AAMA;cAAa,uBAAA,GACX,IAAA,EAAM,QAAA;EACH,GAAA;EAAa,IAAA;AAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/extractContent/utils/getOrGenerateKey.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets an existing key for a given text or generates a new one.
|
|
4
|
+
*/
|
|
5
|
+
declare const getOrGenerateKey: (text: string, componentKey: string, existingKeys: Set<string>, extractedContent: Record<string, Record<string, string>>) => string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getOrGenerateKey };
|
|
8
|
+
//# sourceMappingURL=getOrGenerateKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrGenerateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getOrGenerateKey.ts"],"mappings":";;AAKA;;cAAa,gBAAA,GACX,IAAA,UACA,YAAA,UACA,YAAA,EAAc,GAAA,UACd,gBAAA,EAAkB,MAAA,SAAe,MAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ATTRIBUTES_TO_EXTRACT, PackageName, packageList } from "./constants.js";
|
|
2
|
+
import { detectPackageName } from "./detectPackageName.js";
|
|
3
|
+
import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractDictionaryKey.js";
|
|
4
|
+
import { generateKey } from "./generateKey.js";
|
|
5
|
+
import { getComponentName } from "./getComponentName.js";
|
|
6
|
+
import { getExistingIntlayerInfo } from "./getExistingIntlayerInfo.js";
|
|
7
|
+
import { getOrGenerateKey } from "./getOrGenerateKey.js";
|
|
8
|
+
import { resolveDictionaryKey } from "./resolveDictionaryKey.js";
|
|
9
|
+
import { shouldExtract } from "./shouldExtract.js";
|
|
10
|
+
export { ATTRIBUTES_TO_EXTRACT, PackageName, detectPackageName, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getExistingIntlayerInfo, getOrGenerateKey, packageList, resolveDictionaryKey, shouldExtract };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/extractContent/utils/resolveDictionaryKey.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a unique dictionary key, checking for existing dictionaries and files.
|
|
6
|
+
* Note: this chokidar-specific variant fetches unmergedDictionaries internally
|
|
7
|
+
* from the configuration (unlike the `@intlayer/babel` version which takes it as a parameter).
|
|
8
|
+
*/
|
|
9
|
+
declare const resolveDictionaryKey: (initialKey: string, filePath: string, configuration: IntlayerConfig, unmergedDictionaries?: Record<string, unknown>, usedKeys?: Set<string>) => string;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { resolveDictionaryKey };
|
|
12
|
+
//# sourceMappingURL=resolveDictionaryKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/resolveDictionaryKey.ts"],"mappings":";;;;;AAUA;;;cAAa,oBAAA,GACX,UAAA,UACA,QAAA,UACA,aAAA,EAAe,cAAA,EACf,oBAAA,GAAuB,MAAA,mBACvB,QAAA,GAAU,GAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/extractContent/utils/shouldExtract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the given text should be extracted as a translatable string.
|
|
4
|
+
*
|
|
5
|
+
* Filters out:
|
|
6
|
+
* - Empty strings
|
|
7
|
+
* - Single words (typically icons or technical terms)
|
|
8
|
+
* - Strings not starting with an uppercase letter (likely technical values)
|
|
9
|
+
* - Dynamic content patterns like Vue bindings (`v-`) or object patterns (`{`)
|
|
10
|
+
*/
|
|
11
|
+
declare const shouldExtract: (text: string) => boolean;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { shouldExtract };
|
|
14
|
+
//# sourceMappingURL=shouldExtract.d.ts.map
|