@intlayer/babel 8.4.4 → 8.4.5

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.
Files changed (139) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/babel-plugin-intlayer-extract.cjs +75 -1
  3. package/dist/cjs/babel-plugin-intlayer-extract.cjs.map +1 -1
  4. package/dist/cjs/babel-plugin-intlayer-optimize.cjs +306 -1
  5. package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
  6. package/dist/cjs/extractContent/babelProcessor.cjs +261 -1
  7. package/dist/cjs/extractContent/babelProcessor.cjs.map +1 -1
  8. package/dist/cjs/extractContent/contentWriter.cjs +134 -1
  9. package/dist/cjs/extractContent/contentWriter.cjs.map +1 -1
  10. package/dist/cjs/extractContent/extractContent.cjs +184 -1
  11. package/dist/cjs/extractContent/extractContent.cjs.map +1 -1
  12. package/dist/cjs/extractContent/index.cjs +26 -1
  13. package/dist/cjs/extractContent/processTsxFile.cjs +263 -5
  14. package/dist/cjs/extractContent/processTsxFile.cjs.map +1 -1
  15. package/dist/cjs/extractContent/utils/constants.cjs +42 -1
  16. package/dist/cjs/extractContent/utils/constants.cjs.map +1 -1
  17. package/dist/cjs/extractContent/utils/detectPackageName.cjs +26 -1
  18. package/dist/cjs/extractContent/utils/detectPackageName.cjs.map +1 -1
  19. package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs +77 -1
  20. package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs.map +1 -1
  21. package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs +29 -1
  22. package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs.map +1 -1
  23. package/dist/cjs/extractContent/utils/generateKey.cjs +16 -1
  24. package/dist/cjs/extractContent/utils/generateKey.cjs.map +1 -1
  25. package/dist/cjs/extractContent/utils/getComponentName.cjs +18 -1
  26. package/dist/cjs/extractContent/utils/getComponentName.cjs.map +1 -1
  27. package/dist/cjs/extractContent/utils/getExistingIntlayerInfo.cjs +50 -1
  28. package/dist/cjs/extractContent/utils/getExistingIntlayerInfo.cjs.map +1 -1
  29. package/dist/cjs/extractContent/utils/getOrGenerateKey.cjs +19 -1
  30. package/dist/cjs/extractContent/utils/getOrGenerateKey.cjs.map +1 -1
  31. package/dist/cjs/extractContent/utils/index.cjs +27 -1
  32. package/dist/cjs/extractContent/utils/resolveDictionaryKey.cjs +34 -1
  33. package/dist/cjs/extractContent/utils/resolveDictionaryKey.cjs.map +1 -1
  34. package/dist/cjs/extractContent/utils/shouldExtract.cjs +23 -1
  35. package/dist/cjs/extractContent/utils/shouldExtract.cjs.map +1 -1
  36. package/dist/cjs/getExtractPluginOptions.cjs +41 -1
  37. package/dist/cjs/getExtractPluginOptions.cjs.map +1 -1
  38. package/dist/cjs/getOptimizePluginOptions.cjs +63 -1
  39. package/dist/cjs/getOptimizePluginOptions.cjs.map +1 -1
  40. package/dist/cjs/index.cjs +34 -1
  41. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  42. package/dist/esm/babel-plugin-intlayer-extract.mjs +72 -1
  43. package/dist/esm/babel-plugin-intlayer-extract.mjs.map +1 -1
  44. package/dist/esm/babel-plugin-intlayer-optimize.mjs +304 -1
  45. package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
  46. package/dist/esm/extractContent/babelProcessor.mjs +255 -1
  47. package/dist/esm/extractContent/babelProcessor.mjs.map +1 -1
  48. package/dist/esm/extractContent/contentWriter.mjs +129 -1
  49. package/dist/esm/extractContent/contentWriter.mjs.map +1 -1
  50. package/dist/esm/extractContent/extractContent.mjs +180 -1
  51. package/dist/esm/extractContent/extractContent.mjs.map +1 -1
  52. package/dist/esm/extractContent/index.mjs +10 -1
  53. package/dist/esm/extractContent/processTsxFile.mjs +259 -5
  54. package/dist/esm/extractContent/processTsxFile.mjs.map +1 -1
  55. package/dist/esm/extractContent/utils/constants.mjs +38 -1
  56. package/dist/esm/extractContent/utils/constants.mjs.map +1 -1
  57. package/dist/esm/extractContent/utils/detectPackageName.mjs +24 -1
  58. package/dist/esm/extractContent/utils/detectPackageName.mjs.map +1 -1
  59. package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs +72 -1
  60. package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs.map +1 -1
  61. package/dist/esm/extractContent/utils/extractDictionaryKey.mjs +26 -1
  62. package/dist/esm/extractContent/utils/extractDictionaryKey.mjs.map +1 -1
  63. package/dist/esm/extractContent/utils/generateKey.mjs +14 -1
  64. package/dist/esm/extractContent/utils/generateKey.mjs.map +1 -1
  65. package/dist/esm/extractContent/utils/getComponentName.mjs +15 -1
  66. package/dist/esm/extractContent/utils/getComponentName.mjs.map +1 -1
  67. package/dist/esm/extractContent/utils/getExistingIntlayerInfo.mjs +47 -1
  68. package/dist/esm/extractContent/utils/getExistingIntlayerInfo.mjs.map +1 -1
  69. package/dist/esm/extractContent/utils/getOrGenerateKey.mjs +18 -1
  70. package/dist/esm/extractContent/utils/getOrGenerateKey.mjs.map +1 -1
  71. package/dist/esm/extractContent/utils/index.mjs +12 -1
  72. package/dist/esm/extractContent/utils/resolveDictionaryKey.mjs +32 -1
  73. package/dist/esm/extractContent/utils/resolveDictionaryKey.mjs.map +1 -1
  74. package/dist/esm/extractContent/utils/shouldExtract.mjs +21 -1
  75. package/dist/esm/extractContent/utils/shouldExtract.mjs.map +1 -1
  76. package/dist/esm/getExtractPluginOptions.mjs +38 -1
  77. package/dist/esm/getExtractPluginOptions.mjs.map +1 -1
  78. package/dist/esm/getOptimizePluginOptions.mjs +63 -1
  79. package/dist/esm/getOptimizePluginOptions.mjs.map +1 -0
  80. package/dist/esm/index.mjs +14 -1
  81. package/dist/types/babel-plugin-intlayer-extract.d.ts +1 -1
  82. package/dist/types/extractContent/contentWriter.d.ts +36 -2
  83. package/dist/types/extractContent/contentWriter.d.ts.map +1 -0
  84. package/dist/types/extractContent/extractContent.d.ts +37 -2
  85. package/dist/types/extractContent/extractContent.d.ts.map +1 -0
  86. package/dist/types/extractContent/index.d.ts +8 -8
  87. package/dist/types/extractContent/processTsxFile.d.ts +1 -1
  88. package/dist/types/extractContent/processTsxFile.d.ts.map +1 -1
  89. package/dist/types/extractContent/utils/constants.d.ts +20 -2
  90. package/dist/types/extractContent/utils/constants.d.ts.map +1 -0
  91. package/dist/types/extractContent/utils/detectPackageName.d.ts +10 -2
  92. package/dist/types/extractContent/utils/detectPackageName.d.ts.map +1 -0
  93. package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts +28 -2
  94. package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts.map +1 -0
  95. package/dist/types/extractContent/utils/extractDictionaryKey.d.ts +11 -2
  96. package/dist/types/extractContent/utils/extractDictionaryKey.d.ts.map +1 -0
  97. package/dist/types/extractContent/utils/generateKey.d.ts +5 -2
  98. package/dist/types/extractContent/utils/generateKey.d.ts.map +1 -0
  99. package/dist/types/extractContent/utils/getComponentName.d.ts +10 -2
  100. package/dist/types/extractContent/utils/getComponentName.d.ts.map +1 -0
  101. package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts +19 -2
  102. package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts.map +1 -0
  103. package/dist/types/extractContent/utils/getOrGenerateKey.d.ts +8 -2
  104. package/dist/types/extractContent/utils/getOrGenerateKey.d.ts.map +1 -0
  105. package/dist/types/extractContent/utils/index.d.ts +10 -10
  106. package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts +12 -2
  107. package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts.map +1 -0
  108. package/dist/types/extractContent/utils/shouldExtract.d.ts +14 -2
  109. package/dist/types/extractContent/utils/shouldExtract.d.ts.map +1 -0
  110. package/dist/types/index.d.ts +8 -8
  111. package/package.json +9 -9
  112. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  113. package/dist/esm/getOptimizePluginOptions-BAFPfVq5.mjs +0 -2
  114. package/dist/esm/getOptimizePluginOptions-BAFPfVq5.mjs.map +0 -1
  115. package/dist/types/constants-BLArAqsA.d.ts +0 -20
  116. package/dist/types/constants-BLArAqsA.d.ts.map +0 -1
  117. package/dist/types/contentWriter-I2Ch5yQY.d.ts +0 -36
  118. package/dist/types/contentWriter-I2Ch5yQY.d.ts.map +0 -1
  119. package/dist/types/detectPackageName-C0TfbHa3.d.ts +0 -10
  120. package/dist/types/detectPackageName-C0TfbHa3.d.ts.map +0 -1
  121. package/dist/types/extractContent-AFk68B7L.d.ts +0 -37
  122. package/dist/types/extractContent-AFk68B7L.d.ts.map +0 -1
  123. package/dist/types/extractDictionaryInfo-5GLZsA_I.d.ts +0 -28
  124. package/dist/types/extractDictionaryInfo-5GLZsA_I.d.ts.map +0 -1
  125. package/dist/types/extractDictionaryKey-CHgfwRo6.d.ts +0 -11
  126. package/dist/types/extractDictionaryKey-CHgfwRo6.d.ts.map +0 -1
  127. package/dist/types/generateKey-Cgdh6seq.d.ts +0 -5
  128. package/dist/types/generateKey-Cgdh6seq.d.ts.map +0 -1
  129. package/dist/types/getComponentName-DGlmJa-F.d.ts +0 -10
  130. package/dist/types/getComponentName-DGlmJa-F.d.ts.map +0 -1
  131. package/dist/types/getExistingIntlayerInfo-Cy6Vpcfb.d.ts +0 -19
  132. package/dist/types/getExistingIntlayerInfo-Cy6Vpcfb.d.ts.map +0 -1
  133. package/dist/types/getOrGenerateKey-DtIR0WeU.d.ts +0 -8
  134. package/dist/types/getOrGenerateKey-DtIR0WeU.d.ts.map +0 -1
  135. package/dist/types/index-DK_kKFOF.d.ts +0 -1
  136. package/dist/types/resolveDictionaryKey-CcbieIfX.d.ts +0 -12
  137. package/dist/types/resolveDictionaryKey-CcbieIfX.d.ts.map +0 -1
  138. package/dist/types/shouldExtract-BRaeB9eg.d.ts +0 -14
  139. package/dist/types/shouldExtract-BRaeB9eg.d.ts.map +0 -1
@@ -1,2 +1,22 @@
1
- const e=e=>{let t=e.trim();return!(!t||!t.includes(` `)||!/^[A-Z]/.test(t)||t.startsWith(`{`)||t.startsWith(`v-`))};export{e as shouldExtract};
1
+ //#region src/extractContent/utils/shouldExtract.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
+ const shouldExtract = (text) => {
12
+ const trimmed = text.trim();
13
+ if (!trimmed) return false;
14
+ if (!trimmed.includes(" ")) return false;
15
+ if (!/^[A-Z]/.test(trimmed)) return false;
16
+ if (trimmed.startsWith("{") || trimmed.startsWith("v-")) return false;
17
+ return true;
18
+ };
19
+
20
+ //#endregion
21
+ export { shouldExtract };
2
22
  //# sourceMappingURL=shouldExtract.mjs.map
@@ -1 +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
+ {"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,iBAAiB,SAA0B;CACtD,MAAM,UAAU,KAAK,MAAM;AAE3B,KAAI,CAAC,QAAS,QAAO;AAGrB,KAAI,CAAC,QAAQ,SAAS,IAAI,CAAE,QAAO;AAGnC,KAAI,CAAC,SAAS,KAAK,QAAQ,CAAE,QAAO;AAGpC,KAAI,QAAQ,WAAW,IAAI,IAAI,QAAQ,WAAW,KAAK,CAAE,QAAO;AAEhE,QAAO"}
@@ -1,2 +1,39 @@
1
- import{writeContentHelper as e}from"./extractContent/contentWriter.mjs";import{buildComponentFilesList as t}from"@intlayer/chokidar/utils";import*as n from"@intlayer/config/colors";import{COMPILER_ENABLED as r}from"@intlayer/config/defaultValues";import{colorize as i,colorizeKey as a,getAppLogger as o}from"@intlayer/config/logger";import{getConfiguration as s}from"@intlayer/config/node";const c=(c=s(),l=process.env.INTLAYER_IS_DEV_COMMAND)=>{let u=l===`dev`||l===`serve`||l===`true`,d=u?`dev`:`build`,f=o(c);c.compiler?.enabled===`build-only`&&u&&f(`${i(`Compiler:`,n.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)`);let p=c.compiler?.enabled??r;p===`build-only`&&(p=d?d===`build`:!0);let m=t(c);return{enabled:p,configuration:c,filesList:m,onExtract:async({dictionaryKey:t,content:n,filePath:r})=>{try{await e(n,t,r,c)}catch(e){f([`Failed to process extracted content for ${a(t)}:`,e],{level:`error`})}}}};export{c as getExtractPluginOptions};
1
+ import { writeContentHelper } from "./extractContent/contentWriter.mjs";
2
+ import { buildComponentFilesList } from "@intlayer/chokidar/utils";
3
+ import * as ANSIColors from "@intlayer/config/colors";
4
+ import { COMPILER_ENABLED } from "@intlayer/config/defaultValues";
5
+ import { colorize, colorizeKey, getAppLogger } from "@intlayer/config/logger";
6
+ import { getConfiguration } from "@intlayer/config/node";
7
+
8
+ //#region src/getExtractPluginOptions.ts
9
+ /**
10
+ * Get the options for the Intlayer Babel extraction plugin
11
+ * This function loads the Intlayer configuration and sets up the onExtract callback
12
+ * to write dictionaries to the filesystem.
13
+ */
14
+ const getExtractPluginOptions = (configuration = getConfiguration(), isDev = process.env.INTLAYER_IS_DEV_COMMAND) => {
15
+ const isDevBoolean = isDev === "dev" || isDev === "serve" || isDev === "true";
16
+ const compilerMode = isDevBoolean ? "dev" : "build";
17
+ const logger = getAppLogger(configuration);
18
+ if (configuration.compiler?.enabled === "build-only" && isDevBoolean) logger(`${colorize("Compiler:", ANSIColors.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)`);
19
+ let enabled = configuration.compiler?.enabled ?? COMPILER_ENABLED;
20
+ if (enabled === "build-only") if (compilerMode) enabled = compilerMode === "build";
21
+ else enabled = false;
22
+ const filesList = buildComponentFilesList(configuration);
23
+ return {
24
+ enabled,
25
+ configuration,
26
+ filesList,
27
+ onExtract: async ({ dictionaryKey, content, filePath }) => {
28
+ try {
29
+ await writeContentHelper(content, dictionaryKey, filePath, configuration);
30
+ } catch (error) {
31
+ logger([`Failed to process extracted content for ${colorizeKey(dictionaryKey)}:`, error], { level: "error" });
32
+ }
33
+ }
34
+ };
35
+ };
36
+
37
+ //#endregion
38
+ export { getExtractPluginOptions };
2
39
  //# sourceMappingURL=getExtractPluginOptions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import { buildComponentFilesList } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED } from '@intlayer/config/defaultValues';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { ExtractPluginOptions } from './babel-plugin-intlayer-extract';\nimport { writeContentHelper } from './extractContent/contentWriter';\n\n/**\n * Mode of the compiler\n * - 'dev': Development mode with HMR support\n * - 'build': Production build mode\n */\nexport type CompilerMode = 'dev' | 'build';\n\n/**\n * Get the options for the Intlayer Babel extraction plugin\n * This function loads the Intlayer configuration and sets up the onExtract callback\n * to write dictionaries to the filesystem.\n */\nexport const getExtractPluginOptions = (\n configuration: IntlayerConfig = getConfiguration(),\n isDev: CompilerMode | string | undefined = process.env.INTLAYER_IS_DEV_COMMAND\n): ExtractPluginOptions => {\n // Accept 'dev'/'serve' (Vite), boolean true, or the string 'true' (env var)\n const isDevBoolean = isDev === 'dev' || isDev === 'serve' || isDev === 'true';\n\n const compilerMode: CompilerMode = isDevBoolean ? 'dev' : 'build';\n\n const logger = getAppLogger(configuration);\n\n if (configuration.compiler?.enabled === 'build-only' && isDevBoolean) {\n logger(\n `${colorize('Compiler:', ANSIColors.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)`\n );\n }\n\n let enabled = configuration.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') {\n if (compilerMode) {\n enabled = compilerMode === 'build';\n } else {\n // Fallback if mode isn't explicitly provided (e.g. pure babel plugin context)\n enabled = process.env.NODE_ENV === 'production';\n }\n }\n\n const filesList = buildComponentFilesList(configuration);\n\n return {\n enabled,\n configuration,\n filesList,\n onExtract: async ({ dictionaryKey, content, filePath }) => {\n try {\n await writeContentHelper(\n content,\n dictionaryKey,\n filePath,\n configuration\n );\n } catch (error) {\n logger(\n [\n `Failed to process extracted content for ${colorizeKey(dictionaryKey)}:`,\n error,\n ],\n { level: 'error' }\n );\n }\n },\n };\n};\n"],"mappings":"sYAqBA,MAAa,GACX,EAAgC,GAAkB,CAClD,EAA2C,QAAQ,IAAI,0BAC9B,CAEzB,IAAM,EAAe,IAAU,OAAS,IAAU,SAAW,IAAU,OAEjE,EAA6B,EAAe,MAAQ,QAEpD,EAAS,EAAa,EAAc,CAEtC,EAAc,UAAU,UAAY,cAAgB,GACtD,EACE,GAAG,EAAS,YAAa,EAAW,UAAU,CAAC,wIAChD,CAGH,IAAI,EAAU,EAAc,UAAU,SAAW,EAE7C,IAAY,eACd,AAIE,EAJE,EACQ,IAAiB,QAGjB,IAId,IAAM,EAAY,EAAwB,EAAc,CAExD,MAAO,CACL,UACA,gBACA,YACA,UAAW,MAAO,CAAE,gBAAe,UAAS,cAAe,CACzD,GAAI,CACF,MAAM,EACJ,EACA,EACA,EACA,EACD,OACM,EAAO,CACd,EACE,CACE,2CAA2C,EAAY,EAAc,CAAC,GACtE,EACD,CACD,CAAE,MAAO,QAAS,CACnB,GAGN"}
1
+ {"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import { buildComponentFilesList } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED } from '@intlayer/config/defaultValues';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { ExtractPluginOptions } from './babel-plugin-intlayer-extract';\nimport { writeContentHelper } from './extractContent/contentWriter';\n\n/**\n * Mode of the compiler\n * - 'dev': Development mode with HMR support\n * - 'build': Production build mode\n */\nexport type CompilerMode = 'dev' | 'build';\n\n/**\n * Get the options for the Intlayer Babel extraction plugin\n * This function loads the Intlayer configuration and sets up the onExtract callback\n * to write dictionaries to the filesystem.\n */\nexport const getExtractPluginOptions = (\n configuration: IntlayerConfig = getConfiguration(),\n isDev: CompilerMode | string | undefined = process.env.INTLAYER_IS_DEV_COMMAND\n): ExtractPluginOptions => {\n // Accept 'dev'/'serve' (Vite), boolean true, or the string 'true' (env var)\n const isDevBoolean = isDev === 'dev' || isDev === 'serve' || isDev === 'true';\n\n const compilerMode: CompilerMode = isDevBoolean ? 'dev' : 'build';\n\n const logger = getAppLogger(configuration);\n\n if (configuration.compiler?.enabled === 'build-only' && isDevBoolean) {\n logger(\n `${colorize('Compiler:', ANSIColors.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)`\n );\n }\n\n let enabled = configuration.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') {\n if (compilerMode) {\n enabled = compilerMode === 'build';\n } else {\n // Fallback if mode isn't explicitly provided (e.g. pure babel plugin context)\n enabled = process.env.NODE_ENV === 'production';\n }\n }\n\n const filesList = buildComponentFilesList(configuration);\n\n return {\n enabled,\n configuration,\n filesList,\n onExtract: async ({ dictionaryKey, content, filePath }) => {\n try {\n await writeContentHelper(\n content,\n dictionaryKey,\n filePath,\n configuration\n );\n } catch (error) {\n logger(\n [\n `Failed to process extracted content for ${colorizeKey(dictionaryKey)}:`,\n error,\n ],\n { level: 'error' }\n );\n }\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,2BACX,gBAAgC,kBAAkB,EAClD,QAA2C,QAAQ,IAAI,4BAC9B;CAEzB,MAAM,eAAe,UAAU,SAAS,UAAU,WAAW,UAAU;CAEvE,MAAM,eAA6B,eAAe,QAAQ;CAE1D,MAAM,SAAS,aAAa,cAAc;AAE1C,KAAI,cAAc,UAAU,YAAY,gBAAgB,aACtD,QACE,GAAG,SAAS,aAAa,WAAW,UAAU,CAAC,wIAChD;CAGH,IAAI,UAAU,cAAc,UAAU,WAAW;AAEjD,KAAI,YAAY,aACd,KAAI,aACF,WAAU,iBAAiB;KAG3B,WAAU;CAId,MAAM,YAAY,wBAAwB,cAAc;AAExD,QAAO;EACL;EACA;EACA;EACA,WAAW,OAAO,EAAE,eAAe,SAAS,eAAe;AACzD,OAAI;AACF,UAAM,mBACJ,SACA,eACA,UACA,cACD;YACM,OAAO;AACd,WACE,CACE,2CAA2C,YAAY,cAAc,CAAC,IACtE,MACD,EACD,EAAE,OAAO,SAAS,CACnB;;;EAGN"}
@@ -1 +1,63 @@
1
- import{t as e}from"./getOptimizePluginOptions-BAFPfVq5.mjs";export{e as getOptimizePluginOptions};
1
+ import { __require } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { buildComponentFilesList } from "@intlayer/chokidar/utils";
3
+ import { getConfiguration } from "@intlayer/config/node";
4
+ import { join } from "node:path";
5
+
6
+ //#region src/getOptimizePluginOptions.ts
7
+ /**
8
+ * Load dictionaries from the dictionaries-entry package
9
+ */
10
+ const loadDictionaries = (config) => {
11
+ try {
12
+ const { getDictionaries } = __require("@intlayer/dictionaries-entry");
13
+ const dictionariesRecord = getDictionaries(config);
14
+ return Object.values(dictionariesRecord);
15
+ } catch {
16
+ return [];
17
+ }
18
+ };
19
+ /**
20
+ * Get the options for the Intlayer Babel optimization plugin
21
+ * This function loads the Intlayer configuration and returns the paths
22
+ * needed for dictionary optimization and import rewriting.
23
+ */
24
+ const getOptimizePluginOptions = (params) => {
25
+ const { configOptions, dictionaries: providedDictionaries, overrides } = params ?? {};
26
+ const config = getConfiguration(configOptions);
27
+ const { mainDir, dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, fetchDictionariesDir } = config.system;
28
+ const { importMode, optimize } = config.build;
29
+ const dictionariesEntryPath = join(mainDir, "dictionaries.mjs");
30
+ const unmergedDictionariesEntryPath = join(mainDir, "unmerged_dictionaries.mjs");
31
+ const dynamicDictionariesEntryPath = join(mainDir, "dynamic_dictionaries.mjs");
32
+ const fetchDictionariesEntryPath = join(mainDir, "fetch_dictionaries.mjs");
33
+ const filesList = [
34
+ ...buildComponentFilesList(config),
35
+ dictionariesEntryPath,
36
+ unmergedDictionariesEntryPath
37
+ ];
38
+ const dictionaries = providedDictionaries ?? loadDictionaries(config);
39
+ const dictionaryModeMap = {};
40
+ dictionaries.forEach((dictionary) => {
41
+ dictionaryModeMap[dictionary.key] = dictionary.importMode ?? importMode;
42
+ });
43
+ return {
44
+ optimize,
45
+ dictionariesDir,
46
+ dictionariesEntryPath,
47
+ unmergedDictionariesDir,
48
+ unmergedDictionariesEntryPath,
49
+ dynamicDictionariesDir,
50
+ dynamicDictionariesEntryPath,
51
+ fetchDictionariesDir,
52
+ fetchDictionariesEntryPath,
53
+ replaceDictionaryEntry: true,
54
+ importMode,
55
+ dictionaryModeMap,
56
+ filesList,
57
+ ...overrides
58
+ };
59
+ };
60
+
61
+ //#endregion
62
+ export { getOptimizePluginOptions };
63
+ //# sourceMappingURL=getOptimizePluginOptions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { buildComponentFilesList } from '@intlayer/chokidar/utils';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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);\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 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 filesListPattern = buildComponentFilesList(config);\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":";;;;;;;;;AA4BA,MAAM,oBAAoB,WAAyC;AACjE,KAAI;EAGF,MAAM,EAAE,8BAA4B,+BAA+B;EACnE,MAAM,qBAAqB,gBAAgB,OAAO;AAElD,SAAO,OAAO,OAAO,mBAAmB;SAClC;AAEN,SAAO,EAAE;;;;;;;;AASb,MAAa,4BACX,WAC0B;CAC1B,MAAM,EACJ,eACA,cAAc,sBACd,cACE,UAAU,EAAE;CAEhB,MAAM,SAAS,iBAAiB,cAAc;CAC9C,MAAM,EACJ,SACA,iBACA,yBACA,wBACA,yBACE,OAAO;CACX,MAAM,EAAE,YAAY,aAAa,OAAO;CAExC,MAAM,wBAAwB,KAAK,SAAS,mBAAmB;CAC/D,MAAM,gCAAgC,KACpC,SACA,4BACD;CACD,MAAM,+BAA+B,KACnC,SACA,2BACD;CACD,MAAM,6BAA6B,KAAK,SAAS,yBAAyB;CAI1E,MAAM,YAAY;EAChB,GAHuB,wBAAwB,OAAO;EAItD;EACA;EACD;CAGD,MAAM,eAAe,wBAAwB,iBAAiB,OAAO;CAErE,MAAM,oBAGF,EAAE;AAEN,cAAa,SAAS,eAAe;AACnC,oBAAkB,WAAW,OAAO,WAAW,cAAc;GAC7D;AAEF,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,wBAAwB;EACxB;EACA;EACA;EACA,GAAG;EACJ"}
@@ -1 +1,14 @@
1
- import{t as e}from"./getOptimizePluginOptions-BAFPfVq5.mjs";import{extractDictionaryKey as t,extractDictionaryKeyFromPath as n}from"./extractContent/utils/extractDictionaryKey.mjs";import{extractDictionaryInfo as r,getOutput as i,resolveContentFilePaths as a}from"./extractContent/utils/extractDictionaryInfo.mjs";import{mergeWithExistingMultilingualDictionary as o,mergeWithExistingPerLocaleDictionary as s,writeContentHelper as c}from"./extractContent/contentWriter.mjs";import{getExtractPluginOptions as l}from"./getExtractPluginOptions.mjs";import{ATTRIBUTES_TO_EXTRACT as u,SERVER_CAPABLE_PACKAGES as d,packageList as f}from"./extractContent/utils/constants.mjs";import{detectPackageName as p}from"./extractContent/utils/detectPackageName.mjs";import{generateKey as m}from"./extractContent/utils/generateKey.mjs";import{getComponentName as h}from"./extractContent/utils/getComponentName.mjs";import{extractContent as g,extractContentSync as _}from"./extractContent/extractContent.mjs";import{intlayerExtractBabelPlugin as v}from"./babel-plugin-intlayer-extract.mjs";import{intlayerOptimizeBabelPlugin as y}from"./babel-plugin-intlayer-optimize.mjs";import"./extractContent/index.mjs";export{u as ATTRIBUTES_TO_EXTRACT,d as SERVER_CAPABLE_PACKAGES,p as detectPackageName,g as extractContent,_ as extractContentSync,r as extractDictionaryInfo,t as extractDictionaryKey,n as extractDictionaryKeyFromPath,m as generateKey,h as getComponentName,l as getExtractPluginOptions,e as getOptimizePluginOptions,i as getOutput,v as intlayerExtractBabelPlugin,y as intlayerOptimizeBabelPlugin,o as mergeWithExistingMultilingualDictionary,s as mergeWithExistingPerLocaleDictionary,f as packageList,a as resolveContentFilePaths,c as writeContentHelper};
1
+ import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractContent/utils/extractDictionaryKey.mjs";
2
+ import { extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./extractContent/utils/extractDictionaryInfo.mjs";
3
+ import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./extractContent/contentWriter.mjs";
4
+ import { getExtractPluginOptions } from "./getExtractPluginOptions.mjs";
5
+ import { ATTRIBUTES_TO_EXTRACT, SERVER_CAPABLE_PACKAGES, packageList } from "./extractContent/utils/constants.mjs";
6
+ import { detectPackageName } from "./extractContent/utils/detectPackageName.mjs";
7
+ import { generateKey } from "./extractContent/utils/generateKey.mjs";
8
+ import { getComponentName } from "./extractContent/utils/getComponentName.mjs";
9
+ import { extractContent, extractContentSync } from "./extractContent/extractContent.mjs";
10
+ import { intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.mjs";
11
+ import { getOptimizePluginOptions } from "./getOptimizePluginOptions.mjs";
12
+ import { intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.mjs";
13
+
14
+ export { ATTRIBUTES_TO_EXTRACT, SERVER_CAPABLE_PACKAGES, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getExtractPluginOptions, getOptimizePluginOptions, getOutput, intlayerExtractBabelPlugin, intlayerOptimizeBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, packageList, resolveContentFilePaths, writeContentHelper };
@@ -1,4 +1,4 @@
1
- import { n as PackageName } from "./constants-BLArAqsA.js";
1
+ import { PackageName } from "./extractContent/utils/constants.js";
2
2
  import { PluginObj, PluginPass } from "@babel/core";
3
3
  import * as BabelTypes from "@babel/types";
4
4
  import { Locale } from "@intlayer/types/allLocales";
@@ -1,2 +1,36 @@
1
- import { n as mergeWithExistingPerLocaleDictionary, r as writeContentHelper, t as mergeWithExistingMultilingualDictionary } from "../contentWriter-I2Ch5yQY.js";
2
- export { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper };
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Dictionary, DictionaryKey } from "@intlayer/types/dictionary";
3
+
4
+ //#region src/extractContent/contentWriter.d.ts
5
+ /**
6
+ * Translation node structure used in dictionaries
7
+ */
8
+ type TranslationNode = {
9
+ nodeType: 'translation';
10
+ translation: Record<string, string>;
11
+ };
12
+ /**
13
+ * Dictionary content structure - map of keys to translation nodes
14
+ */
15
+ type DictionaryContentMap = Record<string, TranslationNode>;
16
+ /**
17
+ * Merge extracted content with existing dictionary for multilingual format.
18
+ * - Keys in extracted but not in existing: added with default locale only
19
+ * - Keys in both: preserve existing translations, update default locale value
20
+ * - Keys in existing but not in extracted: removed (no longer in source)
21
+ */
22
+ declare const mergeWithExistingMultilingualDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null, defaultLocale: string) => DictionaryContentMap;
23
+ /**
24
+ * Merge extracted content with existing dictionary for per-locale format.
25
+ * - Keys in extracted but not in existing: added
26
+ * - Keys in both: update value
27
+ * - Keys in existing but not in extracted: removed (no longer in source)
28
+ */
29
+ declare const mergeWithExistingPerLocaleDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null) => Record<string, string>;
30
+ /**
31
+ * Helper to write extracted content to dictionary file(s).
32
+ */
33
+ declare const writeContentHelper: (extractedContent: Record<string, string>, dictionaryKey: DictionaryKey, filePath: string, configuration: IntlayerConfig) => Promise<string>;
34
+ //#endregion
35
+ export { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper };
36
+ //# sourceMappingURL=contentWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;;;;AAY4E;KAyBvE,eAAA;EACH,QAAA;EACA,WAAA,EAAa,MAAA;AAAA;;;;KAMV,oBAAA,GAAuB,MAAA,SAAe,eAAA;AANtB;;;;;AAmBrB;AAnBqB,cAmBR,uCAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,kBAAA,EAAoB,UAAA,SACpB,aAAA,aACC,oBAAA;;;;;;;cA+CU,oCAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,kBAAA,EAAoB,UAAA,YACnB,MAAA;;;;cA2CU,kBAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,aAAA,EAAe,aAAA,EACf,QAAA,UACA,aAAA,EAAe,cAAA,KACd,OAAA"}
@@ -1,2 +1,37 @@
1
- import { n as extractContent, r as extractContentSync, t as ExtractIntlayerOptions } from "../extractContent-AFk68B7L.js";
2
- export { ExtractIntlayerOptions, extractContent, extractContentSync };
1
+ import { PackageName } from "./utils/constants.js";
2
+ import { IntlayerConfig } from "@intlayer/types/config";
3
+ import { GetConfigurationOptions } from "@intlayer/config/node";
4
+
5
+ //#region src/extractContent/extractContent.d.ts
6
+ type ExtractIntlayerOptions = {
7
+ configOptions?: GetConfigurationOptions;
8
+ codeOnly?: boolean;
9
+ declarationOnly?: boolean;
10
+ unmergedDictionaries?: Record<string, unknown>;
11
+ configuration?: IntlayerConfig;
12
+ code?: string;
13
+ onExtract?: (result: {
14
+ key: string;
15
+ content: Record<string, string>;
16
+ filePath: string;
17
+ }) => void | Promise<void>;
18
+ };
19
+ type ExtractResult = {
20
+ transformedCode: string | null;
21
+ extractedContentMap: Record<string, Record<string, string>>;
22
+ };
23
+ declare const extractContent: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => Promise<ExtractResult | undefined>;
24
+ /**
25
+ * Synchronous variant of `extractContent` — used by the Babel plugin which
26
+ * runs in a sync transform context (e.g. Next.js / Webpack).
27
+ *
28
+ * Differences from `extractContent`:
29
+ * - Loads external compilers (Vue, Svelte) via `require()` instead of `import()`
30
+ * - Fires `onExtract` callbacks as fire-and-forget (cannot await in sync context)
31
+ * - Does NOT write dictionary files or run the code formatter; callers that
32
+ * need persistence should supply an `onExtract` callback
33
+ */
34
+ declare const extractContentSync: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => ExtractResult | undefined;
35
+ //#endregion
36
+ export { ExtractIntlayerOptions, extractContent, extractContentSync };
37
+ //# sourceMappingURL=extractContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractContent.d.ts","names":[],"sources":["../../../src/extractContent/extractContent.ts"],"mappings":";;;;;KA0BY,sBAAA;EACV,aAAA,GAAgB,uBAAA;EAChB,QAAA;EACA,eAAA;EACA,oBAAA,GAAuB,MAAA;EACvB,aAAA,GAAgB,cAAA;EAChB,IAAA;EACA,SAAA,IAAa,MAAA;IACX,GAAA;IACA,OAAA,EAAS,MAAA;IACT,QAAA;EAAA,aACW,OAAA;AAAA;AAAA,KAmNV,aAAA;EACH,eAAA;EACA,mBAAA,EAAqB,MAAA,SAAe,MAAA;AAAA;AAAA,cAmCzB,cAAA,GACX,QAAA,UACA,WAAA,EAAa,WAAA,EACb,OAAA,GAAU,sBAAA,KACT,OAAA,CAAQ,aAAA;;;;;;;;;;;cA8EE,kBAAA,GACX,QAAA,UACA,WAAA,EAAa,WAAA,EACb,OAAA,GAAU,sBAAA,KACT,aAAA"}
@@ -1,9 +1,9 @@
1
- import { i as packageList, n as PackageName, r as SERVER_CAPABLE_PACKAGES, t as ATTRIBUTES_TO_EXTRACT } from "../constants-BLArAqsA.js";
2
- import { n as mergeWithExistingPerLocaleDictionary, r as writeContentHelper, t as mergeWithExistingMultilingualDictionary } from "../contentWriter-I2Ch5yQY.js";
3
- import { t as detectPackageName } from "../detectPackageName-C0TfbHa3.js";
4
- import { a as resolveContentFilePaths, i as getOutput, n as ResolveContentFilePaths, r as extractDictionaryInfo, t as ExtractDictionaryInfoOptions } from "../extractDictionaryInfo-5GLZsA_I.js";
5
- import { n as extractDictionaryKeyFromPath, t as extractDictionaryKey } from "../extractDictionaryKey-CHgfwRo6.js";
6
- import { t as generateKey } from "../generateKey-Cgdh6seq.js";
7
- import { t as getComponentName } from "../getComponentName-DGlmJa-F.js";
8
- import { n as extractContent, r as extractContentSync, t as ExtractIntlayerOptions } from "../extractContent-AFk68B7L.js";
1
+ import { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./utils/constants.js";
2
+ import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./contentWriter.js";
3
+ import { detectPackageName } from "./utils/detectPackageName.js";
4
+ import { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./utils/extractDictionaryInfo.js";
5
+ import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./utils/extractDictionaryKey.js";
6
+ import { generateKey } from "./utils/generateKey.js";
7
+ import { getComponentName } from "./utils/getComponentName.js";
8
+ import { ExtractIntlayerOptions, extractContent, extractContentSync } from "./extractContent.js";
9
9
  export { ATTRIBUTES_TO_EXTRACT, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, PackageName, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getOutput, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, packageList, resolveContentFilePaths, writeContentHelper };
@@ -1,4 +1,4 @@
1
- import { n as PackageName } from "../constants-BLArAqsA.js";
1
+ import { PackageName } from "./utils/constants.js";
2
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
3
 
4
4
  //#region src/extractContent/processTsxFile.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;KAeY,QAAA;EACV,KAAA;EACA,GAAA;EACA,WAAA;AAAA;;;AAHF;cAaa,cAAA,GACX,QAAA,UACA,YAAA,UACA,WAAA,EAAa,WAAA,EACb,aAAA,EAAe,cAAA,EACf,IAAA,YACA,oBAAA,GAAsB,MAAA,mBACtB,gBAAA;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA;AAAA"}
1
+ {"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;KAeY,QAAA;EACV,KAAA;EACA,GAAA;EACA,WAAA;AAAA;;;;cAUW,cAAA,GACX,QAAA,UACA,YAAA,UACA,WAAA,EAAa,WAAA,EACb,aAAA,EAAe,cAAA,EACf,IAAA,YACA,oBAAA,GAAsB,MAAA,mBACtB,gBAAA;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA;AAAA"}
@@ -1,2 +1,20 @@
1
- import { i as packageList, n as PackageName, r as SERVER_CAPABLE_PACKAGES, t as ATTRIBUTES_TO_EXTRACT } from "../../constants-BLArAqsA.js";
2
- export { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList };
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
+ * Order matter for resolution
13
+ */
14
+ 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", "intlayer"];
15
+ /** Packages that support a `/server` sub-path for React Server Components. */
16
+ declare const SERVER_CAPABLE_PACKAGES: ReadonlySet<string>;
17
+ type PackageName = (typeof packageList)[number];
18
+ //#endregion
19
+ export { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList };
20
+ //# 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;AAcb;;;;;AAgBA;AAhBA,cAAa,WAAA;;cAgBA,uBAAA,EAAyB,WAAA;AAAA,KAI1B,WAAA,WAAsB,WAAA"}
@@ -1,2 +1,10 @@
1
- import { t as detectPackageName } from "../../detectPackageName-C0TfbHa3.js";
2
- export { detectPackageName };
1
+ import { PackageName } from "./constants.js";
2
+
3
+ //#region src/extractContent/utils/detectPackageName.d.ts
4
+ /**
5
+ * Detects which intlayer package is used in the project by reading package.json.
6
+ */
7
+ declare const detectPackageName: (searchDir: string) => PackageName;
8
+ //#endregion
9
+ export { detectPackageName };
10
+ //# 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,aAAoB,WAAA"}
@@ -1,2 +1,28 @@
1
- import { a as resolveContentFilePaths, i as getOutput, n as ResolveContentFilePaths, r as extractDictionaryInfo, t as ExtractDictionaryInfoOptions } from "../../extractDictionaryInfo-5GLZsA_I.js";
2
- export { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths };
1
+ import { Locale } from "@intlayer/types/allLocales";
2
+ import { IntlayerConfig } from "@intlayer/types/config";
3
+ import { FilePathPatternFunction } from "@intlayer/types/filePathPattern";
4
+
5
+ //#region src/extractContent/utils/extractDictionaryInfo.d.ts
6
+ declare const getOutput: (configuration: IntlayerConfig) => FilePathPatternFunction;
7
+ type ResolveContentFilePaths = {
8
+ absolutePath: string;
9
+ relativePath: string;
10
+ isPerLocale: boolean;
11
+ };
12
+ /**
13
+ * Resolves the paths for the content files associated with a component.
14
+ * Checks for existing dictionaries first.
15
+ */
16
+ declare const resolveContentFilePaths: (filePath: string, componentKey: string, configuration: IntlayerConfig, locale?: Locale) => Promise<ResolveContentFilePaths>;
17
+ type ExtractDictionaryInfoOptions = {
18
+ configuration?: IntlayerConfig;
19
+ };
20
+ /**
21
+ * Extracts the dictionary key and dictionary file path for a given component file.
22
+ */
23
+ declare const extractDictionaryInfo: (filePath: string, fileText: string, configuration: IntlayerConfig) => Promise<{
24
+ dictionaryKey: string;
25
+ } & ResolveContentFilePaths>;
26
+ //#endregion
27
+ export { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths };
28
+ //# sourceMappingURL=extractDictionaryInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractDictionaryInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryInfo.ts"],"mappings":";;;;;cAiBa,SAAA,GACX,aAAA,EAAe,cAAA,KACd,uBAAA;AAAA,KAeS,uBAAA;EACV,YAAA;EACA,YAAA;EACA,WAAA;AAAA;;;;;cAOW,uBAAA,GACX,QAAA,UACA,YAAA,UACA,aAAA,EAAe,cAAA,EACf,MAAA,GAAS,MAAA,KACR,OAAA,CAAQ,uBAAA;AAAA,KAyEC,4BAAA;EACV,aAAA,GAAgB,cAAA;AAAA;;;;cAML,qBAAA,GACX,QAAA,UACA,QAAA,UACA,aAAA,EAAe,cAAA,KACd,OAAA;EAEC,aAAA;AAAA,IACE,uBAAA"}
@@ -1,2 +1,11 @@
1
- import { n as extractDictionaryKeyFromPath, t as extractDictionaryKey } from "../../extractDictionaryKey-CHgfwRo6.js";
2
- export { extractDictionaryKey, extractDictionaryKeyFromPath };
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, prefix?: 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":";;AASA;;;;cAAa,4BAAA,GACX,QAAA,UACA,MAAA;AAAA,cAoBW,oBAAA,GACX,QAAA,UACA,QAAA,UACA,MAAA"}
@@ -1,2 +1,5 @@
1
- import { t as generateKey } from "../../generateKey-Cgdh6seq.js";
2
- export { generateKey };
1
+ //#region src/extractContent/utils/generateKey.d.ts
2
+ declare const generateKey: (text: string, existingKeys: Set<string>) => string;
3
+ //#endregion
4
+ export { generateKey };
5
+ //# sourceMappingURL=generateKey.d.ts.map
@@ -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"}
@@ -1,2 +1,10 @@
1
- import { t as getComponentName } from "../../getComponentName-DGlmJa-F.js";
2
- export { getComponentName };
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"}
@@ -1,2 +1,19 @@
1
- import { n as getExistingIntlayerInfo, t as ExistingIntlayerInfo } from "../../getExistingIntlayerInfo-Cy6Vpcfb.js";
2
- export { ExistingIntlayerInfo, getExistingIntlayerInfo };
1
+ import * as t from "@babel/types";
2
+ import { NodePath } from "@babel/traverse";
3
+
4
+ //#region src/extractContent/utils/getExistingIntlayerInfo.d.ts
5
+ type ExistingIntlayerInfo = {
6
+ key: string;
7
+ hook: 'useIntlayer' | 'getIntlayer'; /** The variable name used to store the call result (e.g. `t` in `const t = useIntlayer(...)`) */
8
+ variableName: string; /** True when the call result is destructured: `const { a, b } = getIntlayer(...)` */
9
+ isDestructured: boolean; /** Keys already present in the destructuring pattern (empty when not destructured) */
10
+ existingDestructuredKeys: string[]; /** The ObjectPattern AST node, present only when `isDestructured` is true */
11
+ objectPatternNode?: t.ObjectPattern;
12
+ };
13
+ /**
14
+ * Searches for an existing useIntlayer or getIntlayer call in the function body.
15
+ */
16
+ declare const getExistingIntlayerInfo: (path: NodePath) => ExistingIntlayerInfo | undefined;
17
+ //#endregion
18
+ export { ExistingIntlayerInfo, getExistingIntlayerInfo };
19
+ //# sourceMappingURL=getExistingIntlayerInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExistingIntlayerInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getExistingIntlayerInfo.ts"],"mappings":";;;;KAGY,oBAAA;EACV,GAAA;EACA,IAAA,iCAF8B;EAI9B,YAAA,UAMmC;EAJnC,cAAA,WAJA;EAMA,wBAAA,YAFA;EAIA,iBAAA,GAAoB,CAAA,CAAE,aAAA;AAAA;;;;cAMX,uBAAA,GACX,IAAA,EAAM,QAAA,KACL,oBAAA"}
@@ -1,2 +1,8 @@
1
- import { t as getOrGenerateKey } from "../../getOrGenerateKey-DtIR0WeU.js";
2
- export { getOrGenerateKey };
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"}
@@ -1,11 +1,11 @@
1
- import { i as packageList, n as PackageName, r as SERVER_CAPABLE_PACKAGES, t as ATTRIBUTES_TO_EXTRACT } from "../../constants-BLArAqsA.js";
2
- import { t as detectPackageName } from "../../detectPackageName-C0TfbHa3.js";
3
- import { a as resolveContentFilePaths, i as getOutput, n as ResolveContentFilePaths, r as extractDictionaryInfo, t as ExtractDictionaryInfoOptions } from "../../extractDictionaryInfo-5GLZsA_I.js";
4
- import { n as extractDictionaryKeyFromPath, t as extractDictionaryKey } from "../../extractDictionaryKey-CHgfwRo6.js";
5
- import { t as generateKey } from "../../generateKey-Cgdh6seq.js";
6
- import { t as getComponentName } from "../../getComponentName-DGlmJa-F.js";
7
- import { n as getExistingIntlayerInfo, t as ExistingIntlayerInfo } from "../../getExistingIntlayerInfo-Cy6Vpcfb.js";
8
- import { t as getOrGenerateKey } from "../../getOrGenerateKey-DtIR0WeU.js";
9
- import { t as resolveDictionaryKey } from "../../resolveDictionaryKey-CcbieIfX.js";
10
- import { t as shouldExtract } from "../../shouldExtract-BRaeB9eg.js";
1
+ import { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./constants.js";
2
+ import { detectPackageName } from "./detectPackageName.js";
3
+ import { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./extractDictionaryInfo.js";
4
+ import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractDictionaryKey.js";
5
+ import { generateKey } from "./generateKey.js";
6
+ import { getComponentName } from "./getComponentName.js";
7
+ import { ExistingIntlayerInfo, getExistingIntlayerInfo } from "./getExistingIntlayerInfo.js";
8
+ import { getOrGenerateKey } from "./getOrGenerateKey.js";
9
+ import { resolveDictionaryKey } from "./resolveDictionaryKey.js";
10
+ import { shouldExtract } from "./shouldExtract.js";
11
11
  export { ATTRIBUTES_TO_EXTRACT, ExistingIntlayerInfo, ExtractDictionaryInfoOptions, PackageName, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, detectPackageName, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getExistingIntlayerInfo, getOrGenerateKey, getOutput, packageList, resolveContentFilePaths, resolveDictionaryKey, shouldExtract };
@@ -1,2 +1,12 @@
1
- import { t as resolveDictionaryKey } from "../../resolveDictionaryKey-CcbieIfX.js";
2
- export { resolveDictionaryKey };
1
+ import { IntlayerConfig } from "@intlayer/types/config";
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":";;;;;AAWA;;;cAAa,oBAAA,GACX,UAAA,UACA,QAAA,UACA,aAAA,EAAe,cAAA,EACf,oBAAA,GAAuB,MAAA,mBACvB,QAAA,GAAU,GAAA"}
@@ -1,2 +1,14 @@
1
- import { t as shouldExtract } from "../../shouldExtract-BRaeB9eg.js";
2
- export { shouldExtract };
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldExtract.d.ts","names":[],"sources":["../../../../src/extractContent/utils/shouldExtract.ts"],"mappings":";;AASA;;;;;;;;cAAa,aAAA,GAAiB,IAAA"}
@@ -1,13 +1,13 @@
1
- import { i as packageList, n as PackageName, r as SERVER_CAPABLE_PACKAGES, t as ATTRIBUTES_TO_EXTRACT } from "./constants-BLArAqsA.js";
1
+ import { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./extractContent/utils/constants.js";
2
2
  import { ExtractPluginOptions, ExtractResult, intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.js";
3
3
  import { OptimizePluginOptions, intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.js";
4
- import { n as mergeWithExistingPerLocaleDictionary, r as writeContentHelper, t as mergeWithExistingMultilingualDictionary } from "./contentWriter-I2Ch5yQY.js";
5
- import { t as detectPackageName } from "./detectPackageName-C0TfbHa3.js";
6
- import { a as resolveContentFilePaths, i as getOutput, n as ResolveContentFilePaths, r as extractDictionaryInfo, t as ExtractDictionaryInfoOptions } from "./extractDictionaryInfo-5GLZsA_I.js";
7
- import { n as extractDictionaryKeyFromPath, t as extractDictionaryKey } from "./extractDictionaryKey-CHgfwRo6.js";
8
- import { t as generateKey } from "./generateKey-Cgdh6seq.js";
9
- import { t as getComponentName } from "./getComponentName-DGlmJa-F.js";
10
- import { n as extractContent, r as extractContentSync, t as ExtractIntlayerOptions } from "./extractContent-AFk68B7L.js";
4
+ import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./extractContent/contentWriter.js";
5
+ import { detectPackageName } from "./extractContent/utils/detectPackageName.js";
6
+ import { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./extractContent/utils/extractDictionaryInfo.js";
7
+ import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractContent/utils/extractDictionaryKey.js";
8
+ import { generateKey } from "./extractContent/utils/generateKey.js";
9
+ import { getComponentName } from "./extractContent/utils/getComponentName.js";
10
+ import { ExtractIntlayerOptions, extractContent, extractContentSync } from "./extractContent/extractContent.js";
11
11
  import { CompilerMode, getExtractPluginOptions } from "./getExtractPluginOptions.js";
12
12
  import { getOptimizePluginOptions } from "./getOptimizePluginOptions.js";
13
13
  export { ATTRIBUTES_TO_EXTRACT, type CompilerMode, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, ExtractPluginOptions, ExtractResult, OptimizePluginOptions, PackageName, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getExtractPluginOptions, getOptimizePluginOptions, getOutput, intlayerExtractBabelPlugin, intlayerOptimizeBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, packageList, resolveContentFilePaths, writeContentHelper };