lingo.dev 0.85.7 → 0.87.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/build/cli.cjs CHANGED
@@ -26,9 +26,9 @@ function getSettings(explicitApiKey) {
26
26
  _envVarsInfo();
27
27
  return {
28
28
  auth: {
29
- apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _26 => _26.auth, 'optionalAccess', _27 => _27.apiKey]) || defaults.auth.apiKey,
30
- apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _28 => _28.auth, 'optionalAccess', _29 => _29.apiUrl]) || defaults.auth.apiUrl,
31
- webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _30 => _30.auth, 'optionalAccess', _31 => _31.webUrl]) || defaults.auth.webUrl
29
+ apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _25 => _25.auth, 'optionalAccess', _26 => _26.apiKey]) || defaults.auth.apiKey,
30
+ apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _27 => _27.auth, 'optionalAccess', _28 => _28.apiUrl]) || defaults.auth.apiUrl,
31
+ webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _29 => _29.auth, 'optionalAccess', _30 => _30.webUrl]) || defaults.auth.webUrl
32
32
  }
33
33
  };
34
34
  }
@@ -99,7 +99,7 @@ Please use LINGODOTDEV_API_KEY instead.
99
99
  function _envVarsInfo() {
100
100
  const env = _loadEnv();
101
101
  const systemFile = _loadSystemFile();
102
- if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _32 => _32.auth, 'optionalAccess', _33 => _33.apiKey])) {
102
+ if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _31 => _31.auth, 'optionalAccess', _32 => _32.apiKey])) {
103
103
  console.info(
104
104
  "\x1B[36m%s\x1B[0m",
105
105
  `\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
@@ -154,7 +154,7 @@ function createAuthenticator(params) {
154
154
  });
155
155
  if (res.ok) {
156
156
  const payload = await res.json();
157
- if (!_optionalChain([payload, 'optionalAccess', _34 => _34.email])) {
157
+ if (!_optionalChain([payload, 'optionalAccess', _33 => _33.email])) {
158
158
  return null;
159
159
  }
160
160
  return {
@@ -774,7 +774,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
774
774
  });
775
775
  const auth2 = await newAuthenticator.whoami();
776
776
  if (auth2) {
777
- _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _35 => _35.email])}`);
777
+ _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _34 => _34.email])}`);
778
778
  } else {
779
779
  _ora2.default.call(void 0, ).fail("Authentication failed.");
780
780
  }
@@ -854,7 +854,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
854
854
  function getBuckets(i18nConfig) {
855
855
  const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
856
856
  const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
857
- const excludeItems = _optionalChain([bucketEntry, 'access', _36 => _36.exclude, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((item) => resolveBucketItem(item))]);
857
+ const excludeItems = _optionalChain([bucketEntry, 'access', _35 => _35.exclude, 'optionalAccess', _36 => _36.map, 'call', _37 => _37((item) => resolveBucketItem(item))]);
858
858
  const config = {
859
859
  type: bucketType,
860
860
  paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
@@ -878,7 +878,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
878
878
  })
879
879
  )
880
880
  );
881
- const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _39 => _39.flatMap, 'call', _40 => _40(
881
+ const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _38 => _38.flatMap, 'call', _39 => _39(
882
882
  (pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
883
883
  (pathPattern) => ({
884
884
  pathPattern,
@@ -998,17 +998,21 @@ var show_default = new (0, _interactivecommander.Command)().command("show").desc
998
998
 
999
999
 
1000
1000
 
1001
+
1002
+
1003
+
1004
+
1001
1005
  // src/cli/loaders/_utils.ts
1002
1006
  function composeLoaders(...loaders) {
1003
1007
  return {
1004
1008
  init: async () => {
1005
1009
  for (const loader of loaders) {
1006
- await _optionalChain([loader, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
1010
+ await _optionalChain([loader, 'access', _40 => _40.init, 'optionalCall', _41 => _41()]);
1007
1011
  }
1008
1012
  },
1009
1013
  setDefaultLocale(locale) {
1010
1014
  for (const loader of loaders) {
1011
- _optionalChain([loader, 'access', _43 => _43.setDefaultLocale, 'optionalCall', _44 => _44(locale)]);
1015
+ _optionalChain([loader, 'access', _42 => _42.setDefaultLocale, 'optionalCall', _43 => _43(locale)]);
1012
1016
  }
1013
1017
  return this;
1014
1018
  },
@@ -1041,7 +1045,7 @@ function createLoader(lDefinition) {
1041
1045
  if (state.initCtx) {
1042
1046
  return state.initCtx;
1043
1047
  }
1044
- state.initCtx = await _optionalChain([lDefinition, 'access', _45 => _45.init, 'optionalCall', _46 => _46()]);
1048
+ state.initCtx = await _optionalChain([lDefinition, 'access', _44 => _44.init, 'optionalCall', _45 => _45()]);
1045
1049
  return state.initCtx;
1046
1050
  },
1047
1051
  setDefaultLocale(locale) {
@@ -1140,7 +1144,7 @@ function createNormalizeLoader() {
1140
1144
  return normalized;
1141
1145
  },
1142
1146
  push: async (locale, data, originalInput) => {
1143
- const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _47 => _47.keysMap]), () => ( {}));
1147
+ const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _46 => _46.keysMap]), () => ( {}));
1144
1148
  const input2 = mapDenormalizedKeys(data, keysMap);
1145
1149
  const denormalized = _flat.unflatten.call(void 0, input2, {
1146
1150
  delimiter: "/",
@@ -1214,7 +1218,7 @@ function createTextFileLoader(pathPattern) {
1214
1218
  const trimmedResult = result.trim();
1215
1219
  return trimmedResult;
1216
1220
  },
1217
- async push(locale, data, _25, originalLocale) {
1221
+ async push(locale, data, _24, originalLocale) {
1218
1222
  const draftPath = pathPattern.replaceAll("[locale]", locale);
1219
1223
  const finalPath = path15.default.resolve(draftPath);
1220
1224
  const dirPath = path15.default.dirname(finalPath);
@@ -1243,8 +1247,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
1243
1247
  if (!templateData) {
1244
1248
  templateData = await readFileForLocale(pathPattern, originalLocale);
1245
1249
  }
1246
- if (_optionalChain([templateData, 'optionalAccess', _48 => _48.match, 'call', _49 => _49(/[\r\n]$/)])) {
1247
- const ending = _optionalChain([templateData, 'optionalAccess', _50 => _50.includes, 'call', _51 => _51("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _52 => _52.includes, 'call', _53 => _53("\r")]) ? "\r" : "\n";
1250
+ if (_optionalChain([templateData, 'optionalAccess', _47 => _47.match, 'call', _48 => _48(/[\r\n]$/)])) {
1251
+ const ending = _optionalChain([templateData, 'optionalAccess', _49 => _49.includes, 'call', _50 => _50("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _51 => _51.includes, 'call', _52 => _52("\r")]) ? "\r" : "\n";
1248
1252
  return ending;
1249
1253
  }
1250
1254
  return "";
@@ -1285,7 +1289,6 @@ function getStringType(yamlString) {
1285
1289
  const trimmedLine = line.trim();
1286
1290
  return (trimmedLine.startsWith('"') || trimmedLine.match(/:\s*"/)) && (trimmedLine.endsWith('"') || trimmedLine.endsWith('",'));
1287
1291
  });
1288
- console.log("hasDoubleQuotes", hasDoubleQuotes);
1289
1292
  if (hasDoubleQuotes) {
1290
1293
  return "QUOTE_DOUBLE";
1291
1294
  }
@@ -1499,7 +1502,7 @@ function createHtmlLoader() {
1499
1502
  break;
1500
1503
  }
1501
1504
  const siblings = Array.from(parent.childNodes).filter(
1502
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _54 => _54.textContent, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])
1505
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _53 => _53.textContent, 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()])
1503
1506
  );
1504
1507
  const index = siblings.indexOf(current);
1505
1508
  if (index !== -1) {
@@ -1534,11 +1537,11 @@ function createHtmlLoader() {
1534
1537
  result[getPath(element, attr)] = value;
1535
1538
  }
1536
1539
  });
1537
- Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _57 => _57.textContent, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()])).forEach(processNode);
1540
+ Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _56 => _56.textContent, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58()])).forEach(processNode);
1538
1541
  }
1539
1542
  };
1540
- Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _60 => _60.textContent, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])).forEach(processNode);
1541
- Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _63 => _63.textContent, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()])).forEach(processNode);
1543
+ Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])).forEach(processNode);
1544
+ Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])).forEach(processNode);
1542
1545
  return result;
1543
1546
  },
1544
1547
  async push(locale, data, originalInput) {
@@ -1560,7 +1563,7 @@ function createHtmlLoader() {
1560
1563
  for (let i = 0; i < indices.length; i++) {
1561
1564
  const index = parseInt(indices[i]);
1562
1565
  const siblings = Array.from(parent.childNodes).filter(
1563
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _66 => _66.textContent, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()])
1566
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()])
1564
1567
  );
1565
1568
  if (index >= siblings.length) {
1566
1569
  if (i === indices.length - 1) {
@@ -1611,7 +1614,7 @@ function createMarkdownLoader() {
1611
1614
  yaml: yamlEngine
1612
1615
  }
1613
1616
  });
1614
- const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]), () => ( ""))).filter(Boolean);
1617
+ const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _68 => _68.trim, 'call', _69 => _69()]), () => ( ""))).filter(Boolean);
1615
1618
  return {
1616
1619
  ...Object.fromEntries(
1617
1620
  sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
@@ -1623,7 +1626,7 @@ function createMarkdownLoader() {
1623
1626
  const frontmatter = Object.fromEntries(
1624
1627
  Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
1625
1628
  );
1626
- let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()]), () => ( ""))).filter(Boolean).join("\n\n");
1629
+ let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _70 => _70.trim, 'call', _71 => _71()]), () => ( ""))).filter(Boolean).join("\n\n");
1627
1630
  if (Object.keys(frontmatter).length > 0) {
1628
1631
  content = `
1629
1632
  ${content}`;
@@ -1637,58 +1640,6 @@ ${content}`;
1637
1640
  });
1638
1641
  }
1639
1642
 
1640
- // src/cli/loaders/mdx.ts
1641
-
1642
- var _unified = require('unified');
1643
- var _remarkparse = require('remark-parse'); var _remarkparse2 = _interopRequireDefault(_remarkparse);
1644
- var _remarkmdx = require('remark-mdx'); var _remarkmdx2 = _interopRequireDefault(_remarkmdx);
1645
- var _remarkfrontmatter = require('remark-frontmatter'); var _remarkfrontmatter2 = _interopRequireDefault(_remarkfrontmatter);
1646
- var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
1647
- var _remarkstringify = require('remark-stringify'); var _remarkstringify2 = _interopRequireDefault(_remarkstringify);
1648
- var _remarkmdxfrontmatter = require('remark-mdx-frontmatter'); var _remarkmdxfrontmatter2 = _interopRequireDefault(_remarkmdxfrontmatter);
1649
- var _vfile = require('vfile');
1650
- var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
1651
- var serializer = _unified.unified.call(void 0, ).use(_remarkstringify2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
1652
- function createMdxFormatLoader() {
1653
- return createLoader({
1654
- async pull(locale, input2) {
1655
- const file = new (0, _vfile.VFile)(input2);
1656
- const ast = parser.parse(file);
1657
- return JSON.parse(JSON.stringify(ast));
1658
- },
1659
- async push(locale, data) {
1660
- const ast = data;
1661
- const content = String(serializer.stringify(ast));
1662
- return content;
1663
- }
1664
- });
1665
- }
1666
- function createDoubleSerializationLoader() {
1667
- return createLoader({
1668
- async pull(locale, input2) {
1669
- return input2;
1670
- },
1671
- async push(locale, data) {
1672
- const file = new (0, _vfile.VFile)(data);
1673
- const ast = parser.parse(file);
1674
- const finalContent = String(serializer.stringify(ast));
1675
- return finalContent;
1676
- }
1677
- });
1678
- }
1679
- function createMdxStructureLoader() {
1680
- return createLoader({
1681
- async pull(locale, input2) {
1682
- const result = _lodash2.default.chain(input2).pickBy((value, key) => key.endsWith("/value")).value();
1683
- return result;
1684
- },
1685
- async push(locale, data, originalInput) {
1686
- const result = _lodash2.default.merge({}, originalInput, data);
1687
- return result;
1688
- }
1689
- });
1690
- }
1691
-
1692
1643
  // src/cli/loaders/properties.ts
1693
1644
  function createPropertiesLoader() {
1694
1645
  return createLoader({
@@ -1708,7 +1659,7 @@ function createPropertiesLoader() {
1708
1659
  return result;
1709
1660
  },
1710
1661
  async push(locale, payload) {
1711
- const result = Object.entries(payload).filter(([_25, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1662
+ const result = Object.entries(payload).filter(([_24, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1712
1663
  return result;
1713
1664
  }
1714
1665
  });
@@ -1719,7 +1670,7 @@ function isSkippableLine(line) {
1719
1670
  function parsePropertyLine(line) {
1720
1671
  const [key, ...valueParts] = line.split("=");
1721
1672
  return {
1722
- key: _optionalChain([key, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]) || "",
1673
+ key: _optionalChain([key, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()]) || "",
1723
1674
  value: valueParts.join("=").trim()
1724
1675
  };
1725
1676
  }
@@ -1805,7 +1756,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1805
1756
  if (rootTranslationEntity.shouldTranslate === false) {
1806
1757
  continue;
1807
1758
  }
1808
- const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _75 => _75.localizations, 'optionalAccess', _76 => _76[locale]]);
1759
+ const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _74 => _74.localizations, 'optionalAccess', _75 => _75[locale]]);
1809
1760
  if (langTranslationEntity) {
1810
1761
  if ("stringUnit" in langTranslationEntity) {
1811
1762
  resultData[translationKey] = langTranslationEntity.stringUnit.value;
@@ -1814,7 +1765,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1814
1765
  resultData[translationKey] = {};
1815
1766
  const pluralForms = langTranslationEntity.variations.plural;
1816
1767
  for (const form in pluralForms) {
1817
- if (_optionalChain([pluralForms, 'access', _77 => _77[form], 'optionalAccess', _78 => _78.stringUnit, 'optionalAccess', _79 => _79.value])) {
1768
+ if (_optionalChain([pluralForms, 'access', _76 => _76[form], 'optionalAccess', _77 => _77.stringUnit, 'optionalAccess', _78 => _78.value])) {
1818
1769
  resultData[translationKey][form] = pluralForms[form].stringUnit.value;
1819
1770
  }
1820
1771
  }
@@ -1824,7 +1775,6 @@ function createXcodeXcstringsLoader(defaultLocale) {
1824
1775
  resultData[translationKey] = translationKey;
1825
1776
  }
1826
1777
  }
1827
- console.log(resultData);
1828
1778
  return resultData;
1829
1779
  },
1830
1780
  async push(locale, payload, originalInput) {
@@ -1838,7 +1788,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1838
1788
  const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
1839
1789
  if (typeof value === "string") {
1840
1790
  langDataToMerge.strings[key] = {
1841
- extractionState: _optionalChain([originalInput, 'optionalAccess', _80 => _80.strings, 'optionalAccess', _81 => _81[key], 'optionalAccess', _82 => _82.extractionState]),
1791
+ extractionState: _optionalChain([originalInput, 'optionalAccess', _79 => _79.strings, 'optionalAccess', _80 => _80[key], 'optionalAccess', _81 => _81.extractionState]),
1842
1792
  localizations: {
1843
1793
  [locale]: {
1844
1794
  stringUnit: {
@@ -1888,41 +1838,20 @@ var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_pr
1888
1838
  function createPrettierLoader(options) {
1889
1839
  return createLoader({
1890
1840
  async pull(locale, data) {
1891
- return data;
1841
+ const draftPath = options.bucketPathPattern.replaceAll(
1842
+ "[locale]",
1843
+ locale
1844
+ );
1845
+ const finalPath = path15.default.resolve(draftPath);
1846
+ return await formatDataWithPrettier(data, finalPath, options);
1892
1847
  },
1893
1848
  async push(locale, data) {
1894
- const draftPath = options.bucketPathPattern.replaceAll("[locale]", locale);
1849
+ const draftPath = options.bucketPathPattern.replaceAll(
1850
+ "[locale]",
1851
+ locale
1852
+ );
1895
1853
  const finalPath = path15.default.resolve(draftPath);
1896
- const prettierConfig = await loadPrettierConfig(finalPath);
1897
- if (!prettierConfig) {
1898
- return data;
1899
- }
1900
- const config = {
1901
- ...prettierConfig || { printWidth: 2500, bracketSameLine: false },
1902
- parser: options.parser,
1903
- // For HTML parser, preserve comments and quotes
1904
- ...options.parser === "html" ? {
1905
- htmlWhitespaceSensitivity: "ignore",
1906
- singleQuote: false,
1907
- embeddedLanguageFormatting: "off"
1908
- } : {}
1909
- };
1910
- try {
1911
- const result = await _prettier2.default.format(data, config);
1912
- return result;
1913
- } catch (error) {
1914
- if (error instanceof Error && error.message.startsWith("Cannot find package")) {
1915
- console.log();
1916
- console.log("\u26A0\uFE0F Prettier plugins are not installed. Formatting without plugins.");
1917
- console.log("\u26A0\uFE0F To use prettier plugins install project dependencies before running Lingo.dev.");
1918
- config.plugins = [];
1919
- await _prettier2.default.clearConfigCache();
1920
- const result = await _prettier2.default.format(data, config);
1921
- return result;
1922
- } else {
1923
- throw error;
1924
- }
1925
- }
1854
+ return await formatDataWithPrettier(data, finalPath, options);
1926
1855
  }
1927
1856
  });
1928
1857
  }
@@ -1934,6 +1863,39 @@ async function loadPrettierConfig(filePath) {
1934
1863
  return {};
1935
1864
  }
1936
1865
  }
1866
+ async function formatDataWithPrettier(data, filePath, options) {
1867
+ const prettierConfig = await loadPrettierConfig(filePath);
1868
+ if (!prettierConfig && !options.alwaysFormat) {
1869
+ return data;
1870
+ }
1871
+ const config = {
1872
+ ...prettierConfig || { printWidth: 2500, bracketSameLine: false },
1873
+ parser: options.parser,
1874
+ // For HTML parser, preserve comments and quotes
1875
+ ...options.parser === "html" ? {
1876
+ htmlWhitespaceSensitivity: "ignore",
1877
+ singleQuote: false,
1878
+ embeddedLanguageFormatting: "off"
1879
+ } : {}
1880
+ };
1881
+ try {
1882
+ return await _prettier2.default.format(data, config);
1883
+ } catch (error) {
1884
+ if (error instanceof Error && error.message.startsWith("Cannot find package")) {
1885
+ console.log();
1886
+ console.log(
1887
+ "\u26A0\uFE0F Prettier plugins are not installed. Formatting without plugins."
1888
+ );
1889
+ console.log(
1890
+ "\u26A0\uFE0F To use prettier plugins install project dependencies before running Lingo.dev."
1891
+ );
1892
+ config.plugins = [];
1893
+ await _prettier2.default.clearConfigCache();
1894
+ return await _prettier2.default.format(data, config);
1895
+ }
1896
+ throw error;
1897
+ }
1898
+ }
1937
1899
 
1938
1900
  // src/cli/loaders/unlocalizable.ts
1939
1901
 
@@ -1957,10 +1919,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
1957
1919
  }
1958
1920
  }
1959
1921
  return false;
1960
- }).map(([key, _25]) => key);
1961
- const result = _lodash2.default.omitBy(input2, (_25, key) => passthroughKeys.includes(key));
1922
+ }).map(([key, _24]) => key);
1923
+ const result = _lodash2.default.omitBy(input2, (_24, key) => passthroughKeys.includes(key));
1962
1924
  if (returnUnlocalizedKeys) {
1963
- result.unlocalizable = _lodash2.default.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
1925
+ result.unlocalizable = _lodash2.default.omitBy(input2, (_24, key) => !passthroughKeys.includes(key));
1964
1926
  }
1965
1927
  return result;
1966
1928
  },
@@ -1999,7 +1961,7 @@ function createPoDataLoader(params) {
1999
1961
  Object.entries(entries).forEach(([msgid, entry]) => {
2000
1962
  if (msgid && entry.msgid) {
2001
1963
  const context = entry.msgctxt || "";
2002
- const fullEntry = _optionalChain([parsedPo, 'access', _83 => _83.translations, 'access', _84 => _84[context], 'optionalAccess', _85 => _85[msgid]]);
1964
+ const fullEntry = _optionalChain([parsedPo, 'access', _82 => _82.translations, 'access', _83 => _83[context], 'optionalAccess', _84 => _84[msgid]]);
2003
1965
  if (fullEntry) {
2004
1966
  result[msgid] = fullEntry;
2005
1967
  }
@@ -2009,8 +1971,8 @@ function createPoDataLoader(params) {
2009
1971
  return result;
2010
1972
  },
2011
1973
  async push(locale, data, originalInput, originalLocale, pullInput) {
2012
- const currentSections = _optionalChain([pullInput, 'optionalAccess', _86 => _86.split, 'call', _87 => _87("\n\n"), 'access', _88 => _88.filter, 'call', _89 => _89(Boolean)]) || [];
2013
- const originalSections = _optionalChain([originalInput, 'optionalAccess', _90 => _90.split, 'call', _91 => _91("\n\n"), 'access', _92 => _92.filter, 'call', _93 => _93(Boolean)]) || [];
1974
+ const currentSections = _optionalChain([pullInput, 'optionalAccess', _85 => _85.split, 'call', _86 => _86("\n\n"), 'access', _87 => _87.filter, 'call', _88 => _88(Boolean)]) || [];
1975
+ const originalSections = _optionalChain([originalInput, 'optionalAccess', _89 => _89.split, 'call', _90 => _90("\n\n"), 'access', _91 => _91.filter, 'call', _92 => _92(Boolean)]) || [];
2014
1976
  const result = originalSections.map((section) => {
2015
1977
  const sectionPo = _gettextparser2.default.po.parse(section);
2016
1978
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
@@ -2064,7 +2026,7 @@ function createPoContentLoader() {
2064
2026
  entry.msgid,
2065
2027
  {
2066
2028
  ...entry,
2067
- msgstr: [_optionalChain([data, 'access', _94 => _94[entry.msgid], 'optionalAccess', _95 => _95.singular]), _optionalChain([data, 'access', _96 => _96[entry.msgid], 'optionalAccess', _97 => _97.plural]) || null].filter(Boolean)
2029
+ msgstr: [_optionalChain([data, 'access', _93 => _93[entry.msgid], 'optionalAccess', _94 => _94.singular]), _optionalChain([data, 'access', _95 => _95[entry.msgid], 'optionalAccess', _96 => _96.plural]) || null].filter(Boolean)
2068
2030
  }
2069
2031
  ]).fromPairs().value();
2070
2032
  return result;
@@ -2310,7 +2272,7 @@ function createDatoClient(params) {
2310
2272
  only_valid: "true",
2311
2273
  ids: !records.length ? void 0 : records.join(",")
2312
2274
  }
2313
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _98 => _98.response, 'optionalAccess', _99 => _99.body, 'optionalAccess', _100 => _100.data, 'optionalAccess', _101 => _101[0]]) || error));
2275
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _97 => _97.response, 'optionalAccess', _98 => _98.body, 'optionalAccess', _99 => _99.data, 'optionalAccess', _100 => _100[0]]) || error));
2314
2276
  },
2315
2277
  findRecordsForModel: async (modelId, records) => {
2316
2278
  try {
@@ -2320,9 +2282,9 @@ function createDatoClient(params) {
2320
2282
  filter: {
2321
2283
  type: modelId,
2322
2284
  only_valid: "true",
2323
- ids: !_optionalChain([records, 'optionalAccess', _102 => _102.length]) ? void 0 : records.join(",")
2285
+ ids: !_optionalChain([records, 'optionalAccess', _101 => _101.length]) ? void 0 : records.join(",")
2324
2286
  }
2325
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _103 => _103.response, 'optionalAccess', _104 => _104.body, 'optionalAccess', _105 => _105.data, 'optionalAccess', _106 => _106[0]]) || error));
2287
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _102 => _102.response, 'optionalAccess', _103 => _103.body, 'optionalAccess', _104 => _104.data, 'optionalAccess', _105 => _105[0]]) || error));
2326
2288
  return result;
2327
2289
  } catch (_error) {
2328
2290
  throw new Error(
@@ -2336,9 +2298,9 @@ function createDatoClient(params) {
2336
2298
  },
2337
2299
  updateRecord: async (id, payload) => {
2338
2300
  try {
2339
- await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _107 => _107.response, 'optionalAccess', _108 => _108.body, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110[0]]) || error));
2301
+ await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _106 => _106.response, 'optionalAccess', _107 => _107.body, 'optionalAccess', _108 => _108.data, 'optionalAccess', _109 => _109[0]]) || error));
2340
2302
  } catch (_error) {
2341
- if (_optionalChain([_error, 'optionalAccess', _111 => _111.attributes, 'optionalAccess', _112 => _112.details, 'optionalAccess', _113 => _113.message])) {
2303
+ if (_optionalChain([_error, 'optionalAccess', _110 => _110.attributes, 'optionalAccess', _111 => _111.details, 'optionalAccess', _112 => _112.message])) {
2342
2304
  throw new Error(
2343
2305
  [
2344
2306
  `${_error.attributes.details.message}`,
@@ -2359,9 +2321,9 @@ function createDatoClient(params) {
2359
2321
  },
2360
2322
  enableFieldLocalization: async (args) => {
2361
2323
  try {
2362
- await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _114 => _114.response, 'optionalAccess', _115 => _115.body, 'optionalAccess', _116 => _116.data, 'optionalAccess', _117 => _117[0]]) || error));
2324
+ await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _113 => _113.response, 'optionalAccess', _114 => _114.body, 'optionalAccess', _115 => _115.data, 'optionalAccess', _116 => _116[0]]) || error));
2363
2325
  } catch (_error) {
2364
- if (_optionalChain([_error, 'optionalAccess', _118 => _118.attributes, 'optionalAccess', _119 => _119.code]) === "NOT_FOUND") {
2326
+ if (_optionalChain([_error, 'optionalAccess', _117 => _117.attributes, 'optionalAccess', _118 => _118.code]) === "NOT_FOUND") {
2365
2327
  throw new Error(
2366
2328
  [
2367
2329
  `Field "${args.fieldId}" not found in model "${args.modelId}".`,
@@ -2369,7 +2331,7 @@ function createDatoClient(params) {
2369
2331
  ].join("\n\n")
2370
2332
  );
2371
2333
  }
2372
- if (_optionalChain([_error, 'optionalAccess', _120 => _120.attributes, 'optionalAccess', _121 => _121.details, 'optionalAccess', _122 => _122.message])) {
2334
+ if (_optionalChain([_error, 'optionalAccess', _119 => _119.attributes, 'optionalAccess', _120 => _120.details, 'optionalAccess', _121 => _121.message])) {
2373
2335
  throw new Error(
2374
2336
  [`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
2375
2337
  );
@@ -2435,7 +2397,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
2435
2397
  }
2436
2398
  }
2437
2399
  const records = await dato.findRecordsForModel(modelId);
2438
- const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _123 => _123.models, 'access', _124 => _124[modelId], 'optionalAccess', _125 => _125.records]) || [], project);
2400
+ const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _122 => _122.models, 'access', _123 => _123[modelId], 'optionalAccess', _124 => _124.records]) || [], project);
2439
2401
  const selectedRecords = await promptRecordSelection(modelName, recordChoices);
2440
2402
  result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
2441
2403
  updatedConfig.models[modelId].records = selectedRecords;
@@ -2447,14 +2409,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
2447
2409
  },
2448
2410
  async pull(locale, input2, initCtx) {
2449
2411
  const result = {};
2450
- for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _126 => _126.models]) || {})) {
2451
- let records = _optionalChain([initCtx, 'optionalAccess', _127 => _127.models, 'access', _128 => _128[modelId], 'access', _129 => _129.records]) || [];
2412
+ for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _125 => _125.models]) || {})) {
2413
+ let records = _optionalChain([initCtx, 'optionalAccess', _126 => _126.models, 'access', _127 => _127[modelId], 'access', _128 => _128.records]) || [];
2452
2414
  const recordIds = records.map((record) => record.id);
2453
2415
  records = await dato.findRecords(recordIds);
2454
2416
  console.log(`Fetched ${records.length} records for model ${modelId}`);
2455
2417
  if (records.length > 0) {
2456
2418
  result[modelId] = {
2457
- fields: _optionalChain([initCtx, 'optionalAccess', _130 => _130.models, 'optionalAccess', _131 => _131[modelId], 'optionalAccess', _132 => _132.fields]) || [],
2419
+ fields: _optionalChain([initCtx, 'optionalAccess', _129 => _129.models, 'optionalAccess', _130 => _130[modelId], 'optionalAccess', _131 => _131.fields]) || [],
2458
2420
  records
2459
2421
  };
2460
2422
  }
@@ -2513,7 +2475,7 @@ function createRecordChoices(records, selectedIds = [], project) {
2513
2475
  return records.map((record) => ({
2514
2476
  name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
2515
2477
  value: record.id,
2516
- checked: _optionalChain([selectedIds, 'optionalAccess', _133 => _133.includes, 'call', _134 => _134(record.id)])
2478
+ checked: _optionalChain([selectedIds, 'optionalAccess', _132 => _132.includes, 'call', _133 => _133(record.id)])
2517
2479
  }));
2518
2480
  }
2519
2481
  async function promptRecordSelection(modelName, choices) {
@@ -2780,7 +2742,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
2780
2742
  function createVttLoader() {
2781
2743
  return createLoader({
2782
2744
  async pull(locale, input2) {
2783
- const vtt = _optionalChain([_nodewebvtt2.default, 'access', _135 => _135.parse, 'call', _136 => _136(input2), 'optionalAccess', _137 => _137.cues]);
2745
+ const vtt = _optionalChain([_nodewebvtt2.default, 'access', _134 => _134.parse, 'call', _135 => _135(input2), 'optionalAccess', _136 => _136.cues]);
2784
2746
  if (Object.keys(vtt).length === 0) {
2785
2747
  return {};
2786
2748
  } else {
@@ -2833,7 +2795,7 @@ function variableExtractLoader(params) {
2833
2795
  for (let i = 0; i < matches.length; i++) {
2834
2796
  const match = matches[i];
2835
2797
  const currentValue = result[key].value;
2836
- const newValue = _optionalChain([currentValue, 'optionalAccess', _138 => _138.replace, 'call', _139 => _139(match, `{variable:${i}}`)]);
2798
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _137 => _137.replace, 'call', _138 => _138(match, `{variable:${i}}`)]);
2837
2799
  result[key].value = newValue;
2838
2800
  result[key].variables[i] = match;
2839
2801
  }
@@ -2847,7 +2809,7 @@ function variableExtractLoader(params) {
2847
2809
  for (let i = 0; i < valueObj.variables.length; i++) {
2848
2810
  const variable = valueObj.variables[i];
2849
2811
  const currentValue = result[key];
2850
- const newValue = _optionalChain([currentValue, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(`{variable:${i}}`, variable)]);
2812
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _139 => _139.replace, 'call', _140 => _140(`{variable:${i}}`, variable)]);
2851
2813
  result[key] = newValue;
2852
2814
  }
2853
2815
  }
@@ -3028,7 +2990,7 @@ function createVueJsonLoader() {
3028
2990
  return createLoader({
3029
2991
  pull: async (locale, input2, ctx) => {
3030
2992
  const parsed = parseVueFile(input2);
3031
- return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _142 => _142.i18n, 'optionalAccess', _143 => _143[locale]]), () => ( {}));
2993
+ return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _141 => _141.i18n, 'optionalAccess', _142 => _142[locale]]), () => ( {}));
3032
2994
  },
3033
2995
  push: async (locale, data, originalInput) => {
3034
2996
  const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
@@ -3102,6 +3064,423 @@ function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
3102
3064
  });
3103
3065
  }
3104
3066
 
3067
+ // src/cli/loaders/mdx2/frontmatter-split.ts
3068
+
3069
+ function createMdxFrontmatterSplitLoader() {
3070
+ return createLoader({
3071
+ async pull(locale, input2) {
3072
+ const source = input2 || "";
3073
+ const { data: frontmatter, content } = _graymatter2.default.call(void 0, source);
3074
+ return {
3075
+ frontmatter,
3076
+ content
3077
+ };
3078
+ },
3079
+ async push(locale, data) {
3080
+ const { frontmatter = {}, content = "" } = data || {};
3081
+ const result = _graymatter2.default.stringify(content, frontmatter).trim();
3082
+ return result;
3083
+ }
3084
+ });
3085
+ }
3086
+
3087
+ // src/cli/loaders/mdx2/_utils.ts
3088
+ function traverseMdast(ast, visitor) {
3089
+ visitor(ast);
3090
+ if ("children" in ast && Array.isArray(ast.children)) {
3091
+ for (const child of ast.children) {
3092
+ traverseMdast(child, visitor);
3093
+ }
3094
+ }
3095
+ }
3096
+
3097
+ // src/cli/utils/md5.ts
3098
+ var _objecthash = require('object-hash');
3099
+ function md5(input2) {
3100
+ return _objecthash.MD5.call(void 0, input2);
3101
+ }
3102
+
3103
+ // src/cli/loaders/mdx2/code-placeholder.ts
3104
+ var _unified = require('unified');
3105
+ var _remarkparse = require('remark-parse'); var _remarkparse2 = _interopRequireDefault(_remarkparse);
3106
+ var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
3107
+ var _vfile = require('vfile');
3108
+ var _remarkmdx = require('remark-mdx'); var _remarkmdx2 = _interopRequireDefault(_remarkmdx);
3109
+ function parseMdast(content) {
3110
+ const file = new (0, _vfile.VFile)(content);
3111
+ const parser2 = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkgfm2.default).use(_remarkmdx2.default);
3112
+ const result = parser2.parse(file);
3113
+ return result;
3114
+ }
3115
+ function extractCodePlaceholders(content) {
3116
+ const ast = parseMdast(content);
3117
+ const placeholderableElements = [
3118
+ "code",
3119
+ "inlineCode"
3120
+ ];
3121
+ let finalContent = content;
3122
+ const codePlaceholders = {};
3123
+ traverseMdast(ast, (_node) => {
3124
+ if (!placeholderableElements.includes(_node.type)) {
3125
+ return;
3126
+ }
3127
+ const node = _node;
3128
+ const nodeContent = node.value;
3129
+ const nodeContentHash = md5(nodeContent);
3130
+ const placeholderId = `__PLACEHOLDER_${nodeContentHash}__`;
3131
+ const nodeContentStart = _optionalChain([node, 'access', _143 => _143.position, 'optionalAccess', _144 => _144.start, 'access', _145 => _145.offset]);
3132
+ const nodeContentEnd = _optionalChain([node, 'access', _146 => _146.position, 'optionalAccess', _147 => _147.end, 'access', _148 => _148.offset]);
3133
+ if (!nodeContentStart || !nodeContentEnd) {
3134
+ return;
3135
+ }
3136
+ codePlaceholders[placeholderId] = nodeContent;
3137
+ finalContent = finalContent.split(nodeContent).join(placeholderId);
3138
+ });
3139
+ return {
3140
+ content: finalContent,
3141
+ codePlaceholders
3142
+ };
3143
+ }
3144
+ function createMdxCodePlaceholderLoader() {
3145
+ return createLoader({
3146
+ async pull(locale, input2) {
3147
+ const { frontmatter = {}, content = "" } = input2 || {
3148
+ frontmatter: {},
3149
+ content: ""
3150
+ };
3151
+ const { content: resultContent, codePlaceholders } = extractCodePlaceholders(content);
3152
+ return {
3153
+ frontmatter,
3154
+ content: resultContent,
3155
+ codePlaceholders
3156
+ };
3157
+ },
3158
+ async push(locale, data, originalInput) {
3159
+ const { codePlaceholders } = extractCodePlaceholders(
3160
+ _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _149 => _149.content]), () => ( ""))
3161
+ );
3162
+ let finalContent = data.content;
3163
+ for (const [placeholder, original] of Object.entries(codePlaceholders)) {
3164
+ finalContent = finalContent.replaceAll(placeholder, () => original);
3165
+ }
3166
+ const result = {
3167
+ frontmatter: data.frontmatter,
3168
+ content: finalContent
3169
+ };
3170
+ return result;
3171
+ }
3172
+ });
3173
+ }
3174
+
3175
+ // src/cli/loaders/mdx2/section-split.ts
3176
+
3177
+
3178
+
3179
+
3180
+
3181
+ var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkgfm2.default).use(_remarkmdx2.default);
3182
+ var SPACING_MATRIX = [
3183
+ // HEADING as previous type
3184
+ ["\n\n", "\n\n", "\n\n", "\n\n", "\n\n", "\n\n"],
3185
+ // JSX_OPENING_TAG as previous type
3186
+ ["\n\n", "\n", "\n", "\n", "\n", "\n\n"],
3187
+ // JSX_CLOSING_TAG as previous type
3188
+ ["\n\n", "\n", "\n", "\n", "\n\n", "\n\n"],
3189
+ // JSX_SELF_CLOSING_TAG as previous type
3190
+ ["\n\n", "\n", "\n", "\n", "\n", "\n\n"],
3191
+ // CONTENT as previous type
3192
+ ["\n\n", "\n\n", "\n", "\n\n", "\n\n", "\n\n"],
3193
+ // UNKNOWN as previous type
3194
+ ["\n\n", "\n\n", "\n\n", "\n\n", "\n\n", "\n\n"]
3195
+ ];
3196
+ function createMdxSectionSplitLoader() {
3197
+ return createLoader({
3198
+ async pull(_locale, input2) {
3199
+ const {
3200
+ frontmatter = {},
3201
+ content = "",
3202
+ codePlaceholders = {}
3203
+ } = input2 || {
3204
+ frontmatter: {},
3205
+ content: "",
3206
+ codePlaceholders: {}
3207
+ };
3208
+ if (!content.trim()) {
3209
+ return {
3210
+ frontmatter,
3211
+ sections: {}
3212
+ };
3213
+ }
3214
+ const file = new (0, _vfile.VFile)(content);
3215
+ const ast = parser.parse(file);
3216
+ const boundaries = findSectionBoundaries(ast, content);
3217
+ const sections = createSectionsFromBoundaries(boundaries, content);
3218
+ return {
3219
+ frontmatter,
3220
+ sections
3221
+ };
3222
+ },
3223
+ async push(_locale, data, originalInput, _originalLocale) {
3224
+ const sectionsArray = Object.values(data.sections);
3225
+ if (sectionsArray.length === 0) {
3226
+ return {
3227
+ frontmatter: data.frontmatter,
3228
+ content: "",
3229
+ codePlaceholders: _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _150 => _150.codePlaceholders]), () => ( {}))
3230
+ };
3231
+ }
3232
+ const resultParts = new Array(sectionsArray.length * 2 - 1);
3233
+ const sectionTypes = new Array(sectionsArray.length);
3234
+ for (let i = 0; i < sectionsArray.length; i++) {
3235
+ sectionTypes[i] = determineJsxSectionType(sectionsArray[i]);
3236
+ }
3237
+ resultParts[0] = sectionsArray[0];
3238
+ for (let i = 1, j = 1; i < sectionsArray.length; i++, j += 2) {
3239
+ const prevType = sectionTypes[i - 1];
3240
+ const currentType = sectionTypes[i];
3241
+ resultParts[j] = SPACING_MATRIX[prevType][currentType];
3242
+ resultParts[j + 1] = sectionsArray[i];
3243
+ }
3244
+ const content = resultParts.join("");
3245
+ return {
3246
+ frontmatter: data.frontmatter,
3247
+ content,
3248
+ codePlaceholders: _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _151 => _151.codePlaceholders]), () => ( {}))
3249
+ };
3250
+ }
3251
+ });
3252
+ }
3253
+ function determineJsxSectionType(section) {
3254
+ section = section.trim();
3255
+ if (!section) return 5 /* UNKNOWN */;
3256
+ const firstChar = section.charAt(0);
3257
+ const lastChar = section.charAt(section.length - 1);
3258
+ if (firstChar === "#") {
3259
+ if (/^#{1,6}\s/.test(section)) {
3260
+ return 0 /* HEADING */;
3261
+ }
3262
+ }
3263
+ if (firstChar === "<") {
3264
+ if (section.endsWith("/>")) {
3265
+ return 3 /* JSX_SELF_CLOSING_TAG */;
3266
+ }
3267
+ if (section.startsWith("</")) {
3268
+ return 2 /* JSX_CLOSING_TAG */;
3269
+ }
3270
+ if (lastChar === ">") {
3271
+ return 1 /* JSX_OPENING_TAG */;
3272
+ }
3273
+ }
3274
+ return 4 /* CONTENT */;
3275
+ }
3276
+ function isJsxOrHtml(node) {
3277
+ return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement" || node.type === "html";
3278
+ }
3279
+ function findOpeningTagEnd(text) {
3280
+ let depth = 0;
3281
+ let inQuotes = false;
3282
+ let quoteChar = "";
3283
+ for (let i = 0; i < text.length; i++) {
3284
+ const char = text[i];
3285
+ if ((char === '"' || char === "'") && (i === 0 || text[i - 1] !== "\\")) {
3286
+ if (!inQuotes) {
3287
+ inQuotes = true;
3288
+ quoteChar = char;
3289
+ } else if (char === quoteChar) {
3290
+ inQuotes = false;
3291
+ }
3292
+ }
3293
+ if (!inQuotes) {
3294
+ if (char === "<") depth++;
3295
+ if (char === ">") {
3296
+ depth--;
3297
+ if (depth === 0) return i + 1;
3298
+ }
3299
+ }
3300
+ }
3301
+ return -1;
3302
+ }
3303
+ function findClosingTagStart(text) {
3304
+ const openTagMatch = /<([^\s/>]+)/.exec(text);
3305
+ if (!openTagMatch) return -1;
3306
+ const tagName = openTagMatch[1];
3307
+ const closingTagRegex = new RegExp(`</${tagName}\\s*>`, "g");
3308
+ let lastMatch = null;
3309
+ let match;
3310
+ while ((match = closingTagRegex.exec(text)) !== null) {
3311
+ lastMatch = match;
3312
+ }
3313
+ return lastMatch ? lastMatch.index : -1;
3314
+ }
3315
+ function processJsxNode(node, content, boundaries) {
3316
+ if (!node.position || typeof node.position.start.offset !== "number" || typeof node.position.end.offset !== "number") {
3317
+ return;
3318
+ }
3319
+ const nodeStart = node.position.start.offset;
3320
+ const nodeEnd = node.position.end.offset;
3321
+ const nodeContent = content.slice(nodeStart, nodeEnd);
3322
+ if (node.type === "html") {
3323
+ extractHtmlTags(nodeStart, nodeContent, boundaries);
3324
+ return;
3325
+ }
3326
+ if (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") {
3327
+ const isSelfClosing = node.selfClosing === true;
3328
+ if (isSelfClosing) {
3329
+ boundaries.push({
3330
+ start: nodeStart,
3331
+ end: nodeEnd,
3332
+ isolateSelf: true
3333
+ });
3334
+ } else {
3335
+ extractJsxTags(node, nodeContent, boundaries);
3336
+ if (node.children) {
3337
+ for (const child of node.children) {
3338
+ if (isJsxOrHtml(child)) {
3339
+ processJsxNode(child, content, boundaries);
3340
+ }
3341
+ }
3342
+ }
3343
+ }
3344
+ }
3345
+ }
3346
+ function extractHtmlTags(nodeStart, nodeContent, boundaries) {
3347
+ const tagRegex = /<\/?[a-zA-Z][a-zA-Z0-9:._-]*(?:\s+[a-zA-Z:_][a-zA-Z0-9:._-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s]+))?)*\s*\/?>/g;
3348
+ let match;
3349
+ while ((match = tagRegex.exec(nodeContent)) !== null) {
3350
+ const tagStart = nodeStart + match.index;
3351
+ const tagEnd = tagStart + match[0].length;
3352
+ boundaries.push({
3353
+ start: tagStart,
3354
+ end: tagEnd,
3355
+ isolateSelf: true
3356
+ });
3357
+ }
3358
+ }
3359
+ function extractJsxTags(node, nodeContent, boundaries) {
3360
+ const nodeStart = node.position.start.offset;
3361
+ const nodeEnd = node.position.end.offset;
3362
+ if (!nodeStart || !nodeEnd) {
3363
+ return;
3364
+ }
3365
+ const openingTagEnd = findOpeningTagEnd(nodeContent);
3366
+ if (openingTagEnd > 0) {
3367
+ boundaries.push({
3368
+ start: nodeStart,
3369
+ end: nodeStart + openingTagEnd,
3370
+ isolateSelf: true
3371
+ });
3372
+ }
3373
+ const closingTagStart = findClosingTagStart(nodeContent);
3374
+ if (closingTagStart > 0 && closingTagStart < nodeContent.length) {
3375
+ boundaries.push({
3376
+ start: nodeStart + closingTagStart,
3377
+ end: nodeEnd,
3378
+ isolateSelf: true
3379
+ });
3380
+ }
3381
+ }
3382
+ function findSectionBoundaries(ast, content) {
3383
+ const boundaries = [];
3384
+ const nodePositions = /* @__PURE__ */ new Map();
3385
+ traverseMdast(ast, (node) => {
3386
+ if (node.position && typeof node.position.start.offset === "number" && typeof node.position.end.offset === "number") {
3387
+ nodePositions.set(node, {
3388
+ start: node.position.start.offset,
3389
+ end: node.position.end.offset
3390
+ });
3391
+ }
3392
+ });
3393
+ for (const child of ast.children) {
3394
+ const position = nodePositions.get(child);
3395
+ if (!position) continue;
3396
+ if (child.type === "heading") {
3397
+ boundaries.push({
3398
+ start: position.start,
3399
+ end: position.end,
3400
+ isolateSelf: false
3401
+ });
3402
+ } else if (isJsxOrHtml(child)) {
3403
+ processJsxNode(child, content, boundaries);
3404
+ }
3405
+ }
3406
+ return boundaries.sort((a, b) => a.start - b.start);
3407
+ }
3408
+ function createSectionsFromBoundaries(boundaries, content) {
3409
+ const sections = {};
3410
+ if (!content.trim() || boundaries.length === 0) {
3411
+ const trimmed = content.trim();
3412
+ if (trimmed) {
3413
+ sections["0"] = trimmed;
3414
+ }
3415
+ return sections;
3416
+ }
3417
+ let idx = 0;
3418
+ let lastEnd = 0;
3419
+ const sectionsArray = [];
3420
+ for (let i = 0; i < boundaries.length; i++) {
3421
+ const { start, end, isolateSelf } = boundaries[i];
3422
+ if (start > lastEnd) {
3423
+ const segment = content.slice(lastEnd, start).trim();
3424
+ if (segment) {
3425
+ sectionsArray.push(segment);
3426
+ }
3427
+ }
3428
+ if (isolateSelf) {
3429
+ const segment = content.slice(start, end).trim();
3430
+ if (segment) {
3431
+ sectionsArray.push(segment);
3432
+ }
3433
+ lastEnd = end;
3434
+ } else {
3435
+ const nextStart = i + 1 < boundaries.length ? boundaries[i + 1].start : content.length;
3436
+ const segment = content.slice(start, nextStart).trim();
3437
+ if (segment) {
3438
+ sectionsArray.push(segment);
3439
+ }
3440
+ lastEnd = nextStart;
3441
+ }
3442
+ }
3443
+ if (lastEnd < content.length) {
3444
+ const segment = content.slice(lastEnd).trim();
3445
+ if (segment) {
3446
+ sectionsArray.push(segment);
3447
+ }
3448
+ }
3449
+ sectionsArray.forEach((section, index) => {
3450
+ sections[index.toString()] = section;
3451
+ });
3452
+ return sections;
3453
+ }
3454
+
3455
+ // src/cli/loaders/mdx2/localizable-document.ts
3456
+ function createLocalizableMdxDocumentLoader() {
3457
+ return createLoader({
3458
+ async pull(_locale, input2) {
3459
+ return {
3460
+ meta: input2.frontmatter,
3461
+ content: input2.sections
3462
+ };
3463
+ },
3464
+ async push(_locale, data, originalInput, _originalLocale, pullInput) {
3465
+ const result = {
3466
+ frontmatter: data.meta || {},
3467
+ sections: data.content || {}
3468
+ };
3469
+ return result;
3470
+ }
3471
+ });
3472
+ }
3473
+
3474
+ // src/cli/loaders/mdx2/index.ts
3475
+ function createMdxLoader() {
3476
+ return composeLoaders(
3477
+ createMdxFrontmatterSplitLoader(),
3478
+ createMdxCodePlaceholderLoader(),
3479
+ createMdxSectionSplitLoader(),
3480
+ createLocalizableMdxDocumentLoader()
3481
+ );
3482
+ }
3483
+
3105
3484
  // src/cli/loaders/index.ts
3106
3485
  function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys) {
3107
3486
  switch (bucketType) {
@@ -3113,7 +3492,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3113
3492
  createAndroidLoader(),
3114
3493
  createFlatLoader(),
3115
3494
  createSyncLoader(),
3116
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3495
+ createUnlocalizableLoader(
3496
+ options.isCacheRestore,
3497
+ options.returnUnlocalizedKeys
3498
+ )
3117
3499
  );
3118
3500
  case "csv":
3119
3501
  return composeLoaders(
@@ -3121,7 +3503,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3121
3503
  createCsvLoader(),
3122
3504
  createFlatLoader(),
3123
3505
  createSyncLoader(),
3124
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3506
+ createUnlocalizableLoader(
3507
+ options.isCacheRestore,
3508
+ options.returnUnlocalizedKeys
3509
+ )
3125
3510
  );
3126
3511
  case "html":
3127
3512
  return composeLoaders(
@@ -3129,7 +3514,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3129
3514
  createPrettierLoader({ parser: "html", bucketPathPattern }),
3130
3515
  createHtmlLoader(),
3131
3516
  createSyncLoader(),
3132
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3517
+ createUnlocalizableLoader(
3518
+ options.isCacheRestore,
3519
+ options.returnUnlocalizedKeys
3520
+ )
3133
3521
  );
3134
3522
  case "json":
3135
3523
  return composeLoaders(
@@ -3140,7 +3528,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3140
3528
  createFlatLoader(),
3141
3529
  createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3142
3530
  createSyncLoader(),
3143
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3531
+ createUnlocalizableLoader(
3532
+ options.isCacheRestore,
3533
+ options.returnUnlocalizedKeys
3534
+ )
3144
3535
  );
3145
3536
  case "markdown":
3146
3537
  return composeLoaders(
@@ -3148,18 +3539,22 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3148
3539
  createPrettierLoader({ parser: "markdown", bucketPathPattern }),
3149
3540
  createMarkdownLoader(),
3150
3541
  createSyncLoader(),
3151
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3542
+ createUnlocalizableLoader(
3543
+ options.isCacheRestore,
3544
+ options.returnUnlocalizedKeys
3545
+ )
3152
3546
  );
3153
3547
  case "mdx":
3154
3548
  return composeLoaders(
3155
3549
  createTextFileLoader(bucketPathPattern),
3156
- createDoubleSerializationLoader(),
3157
3550
  createPrettierLoader({ parser: "mdx", bucketPathPattern }),
3158
- createMdxFormatLoader(),
3551
+ createMdxLoader(),
3159
3552
  createFlatLoader(),
3160
- createMdxStructureLoader(),
3161
3553
  createSyncLoader(),
3162
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3554
+ createUnlocalizableLoader(
3555
+ options.isCacheRestore,
3556
+ options.returnUnlocalizedKeys
3557
+ )
3163
3558
  );
3164
3559
  case "po":
3165
3560
  return composeLoaders(
@@ -3168,21 +3563,30 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3168
3563
  createFlatLoader(),
3169
3564
  createSyncLoader(),
3170
3565
  createVariableLoader({ type: "python" }),
3171
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3566
+ createUnlocalizableLoader(
3567
+ options.isCacheRestore,
3568
+ options.returnUnlocalizedKeys
3569
+ )
3172
3570
  );
3173
3571
  case "properties":
3174
3572
  return composeLoaders(
3175
3573
  createTextFileLoader(bucketPathPattern),
3176
3574
  createPropertiesLoader(),
3177
3575
  createSyncLoader(),
3178
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3576
+ createUnlocalizableLoader(
3577
+ options.isCacheRestore,
3578
+ options.returnUnlocalizedKeys
3579
+ )
3179
3580
  );
3180
3581
  case "xcode-strings":
3181
3582
  return composeLoaders(
3182
3583
  createTextFileLoader(bucketPathPattern),
3183
3584
  createXcodeStringsLoader(),
3184
3585
  createSyncLoader(),
3185
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3586
+ createUnlocalizableLoader(
3587
+ options.isCacheRestore,
3588
+ options.returnUnlocalizedKeys
3589
+ )
3186
3590
  );
3187
3591
  case "xcode-stringsdict":
3188
3592
  return composeLoaders(
@@ -3190,7 +3594,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3190
3594
  createXcodeStringsdictLoader(),
3191
3595
  createFlatLoader(),
3192
3596
  createSyncLoader(),
3193
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3597
+ createUnlocalizableLoader(
3598
+ options.isCacheRestore,
3599
+ options.returnUnlocalizedKeys
3600
+ )
3194
3601
  );
3195
3602
  case "xcode-xcstrings":
3196
3603
  return composeLoaders(
@@ -3201,7 +3608,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3201
3608
  createFlatLoader(),
3202
3609
  createSyncLoader(),
3203
3610
  createVariableLoader({ type: "ieee" }),
3204
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3611
+ createUnlocalizableLoader(
3612
+ options.isCacheRestore,
3613
+ options.returnUnlocalizedKeys
3614
+ )
3205
3615
  );
3206
3616
  case "yaml":
3207
3617
  return composeLoaders(
@@ -3211,7 +3621,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3211
3621
  createFlatLoader(),
3212
3622
  createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3213
3623
  createSyncLoader(),
3214
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3624
+ createUnlocalizableLoader(
3625
+ options.isCacheRestore,
3626
+ options.returnUnlocalizedKeys
3627
+ )
3215
3628
  );
3216
3629
  case "yaml-root-key":
3217
3630
  return composeLoaders(
@@ -3221,7 +3634,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3221
3634
  createRootKeyLoader(true),
3222
3635
  createFlatLoader(),
3223
3636
  createSyncLoader(),
3224
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3637
+ createUnlocalizableLoader(
3638
+ options.isCacheRestore,
3639
+ options.returnUnlocalizedKeys
3640
+ )
3225
3641
  );
3226
3642
  case "flutter":
3227
3643
  return composeLoaders(
@@ -3231,7 +3647,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3231
3647
  createFlutterLoader(),
3232
3648
  createFlatLoader(),
3233
3649
  createSyncLoader(),
3234
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3650
+ createUnlocalizableLoader(
3651
+ options.isCacheRestore,
3652
+ options.returnUnlocalizedKeys
3653
+ )
3235
3654
  );
3236
3655
  case "xliff":
3237
3656
  return composeLoaders(
@@ -3239,7 +3658,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3239
3658
  createXliffLoader(),
3240
3659
  createFlatLoader(),
3241
3660
  createSyncLoader(),
3242
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3661
+ createUnlocalizableLoader(
3662
+ options.isCacheRestore,
3663
+ options.returnUnlocalizedKeys
3664
+ )
3243
3665
  );
3244
3666
  case "xml":
3245
3667
  return composeLoaders(
@@ -3247,28 +3669,40 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3247
3669
  createXmlLoader(),
3248
3670
  createFlatLoader(),
3249
3671
  createSyncLoader(),
3250
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3672
+ createUnlocalizableLoader(
3673
+ options.isCacheRestore,
3674
+ options.returnUnlocalizedKeys
3675
+ )
3251
3676
  );
3252
3677
  case "srt":
3253
3678
  return composeLoaders(
3254
3679
  createTextFileLoader(bucketPathPattern),
3255
3680
  createSrtLoader(),
3256
3681
  createSyncLoader(),
3257
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3682
+ createUnlocalizableLoader(
3683
+ options.isCacheRestore,
3684
+ options.returnUnlocalizedKeys
3685
+ )
3258
3686
  );
3259
3687
  case "dato":
3260
3688
  return composeLoaders(
3261
3689
  createDatoLoader(bucketPathPattern),
3262
3690
  createSyncLoader(),
3263
3691
  createFlatLoader(),
3264
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3692
+ createUnlocalizableLoader(
3693
+ options.isCacheRestore,
3694
+ options.returnUnlocalizedKeys
3695
+ )
3265
3696
  );
3266
3697
  case "vtt":
3267
3698
  return composeLoaders(
3268
3699
  createTextFileLoader(bucketPathPattern),
3269
3700
  createVttLoader(),
3270
3701
  createSyncLoader(),
3271
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3702
+ createUnlocalizableLoader(
3703
+ options.isCacheRestore,
3704
+ options.returnUnlocalizedKeys
3705
+ )
3272
3706
  );
3273
3707
  case "php":
3274
3708
  return composeLoaders(
@@ -3276,7 +3710,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3276
3710
  createPhpLoader(),
3277
3711
  createSyncLoader(),
3278
3712
  createFlatLoader(),
3279
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3713
+ createUnlocalizableLoader(
3714
+ options.isCacheRestore,
3715
+ options.returnUnlocalizedKeys
3716
+ )
3280
3717
  );
3281
3718
  case "vue-json":
3282
3719
  return composeLoaders(
@@ -3284,7 +3721,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3284
3721
  createVueJsonLoader(),
3285
3722
  createSyncLoader(),
3286
3723
  createFlatLoader(),
3287
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3724
+ createUnlocalizableLoader(
3725
+ options.isCacheRestore,
3726
+ options.returnUnlocalizedKeys
3727
+ )
3288
3728
  );
3289
3729
  }
3290
3730
  }
@@ -3307,23 +3747,6 @@ var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
3307
3747
  }));
3308
3748
  _appendToCache(rows);
3309
3749
  };
3310
- function getNormalizedCache() {
3311
- const rows = _loadCache();
3312
- if (!rows.length) {
3313
- return null;
3314
- }
3315
- const normalized = {};
3316
- for (const row of rows) {
3317
- if (!normalized[row.targetLocale]) {
3318
- normalized[row.targetLocale] = {};
3319
- }
3320
- normalized[row.targetLocale][row.key] = {
3321
- source: row.source,
3322
- result: row.processed
3323
- };
3324
- }
3325
- return normalized;
3326
- }
3327
3750
  function deleteCache() {
3328
3751
  const cacheFilePath = _getCacheFilePath();
3329
3752
  try {
@@ -3331,15 +3754,6 @@ function deleteCache() {
3331
3754
  } catch (e) {
3332
3755
  }
3333
3756
  }
3334
- function _loadCache() {
3335
- const cacheFilePath = _getCacheFilePath();
3336
- if (!fs11.default.existsSync(cacheFilePath)) {
3337
- return [];
3338
- }
3339
- const content = fs11.default.readFileSync(cacheFilePath, "utf-8");
3340
- const result = _parseJSONLines(content);
3341
- return result;
3342
- }
3343
3757
  function _appendToCache(rows) {
3344
3758
  const cacheFilePath = _getCacheFilePath();
3345
3759
  const lines = _buildJSONLines(rows);
@@ -3351,16 +3765,6 @@ function _getCacheFilePath() {
3351
3765
  function _buildJSONLines(rows) {
3352
3766
  return rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
3353
3767
  }
3354
- function _parseJSONLines(lines) {
3355
- return lines.split("\n").map(_tryParseJSON).filter((line) => line !== null);
3356
- }
3357
- function _tryParseJSON(line) {
3358
- try {
3359
- return JSON.parse(line);
3360
- } catch (e) {
3361
- return null;
3362
- }
3363
- }
3364
3768
 
3365
3769
  // src/cli/processor/lingo.ts
3366
3770
  var __sdk = require('@lingo.dev/_sdk');
@@ -3440,7 +3844,7 @@ function createBasicTranslator(model, systemPrompt) {
3440
3844
  ]
3441
3845
  });
3442
3846
  const result = JSON.parse(response.text);
3443
- return _optionalChain([result, 'optionalAccess', _144 => _144.data]) || {};
3847
+ return _optionalChain([result, 'optionalAccess', _152 => _152.data]) || {};
3444
3848
  };
3445
3849
  }
3446
3850
 
@@ -3458,7 +3862,7 @@ function createProcessor(provider, params) {
3458
3862
  }
3459
3863
  }
3460
3864
  function getPureModelProvider(provider) {
3461
- switch (_optionalChain([provider, 'optionalAccess', _145 => _145.id])) {
3865
+ switch (_optionalChain([provider, 'optionalAccess', _153 => _153.id])) {
3462
3866
  case "openai":
3463
3867
  if (!process.env.OPENAI_API_KEY) {
3464
3868
  throw new Error("OPENAI_API_KEY is not set.");
@@ -3475,7 +3879,7 @@ function getPureModelProvider(provider) {
3475
3879
  apiKey: process.env.ANTHROPIC_API_KEY
3476
3880
  })(provider.model);
3477
3881
  default:
3478
- throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _146 => _146.id])}`);
3882
+ throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _154 => _154.id])}`);
3479
3883
  }
3480
3884
  }
3481
3885
 
@@ -3529,7 +3933,6 @@ async function trackEvent(distinctId, event, properties) {
3529
3933
  // src/cli/utils/delta.ts
3530
3934
 
3531
3935
 
3532
- var _objecthash = require('object-hash');
3533
3936
 
3534
3937
  // src/cli/utils/fs.ts
3535
3938
 
@@ -3580,11 +3983,11 @@ function createDeltaProcessor(fileKey) {
3580
3983
  let added = _lodash2.default.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
3581
3984
  let removed = _lodash2.default.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
3582
3985
  const updated = _lodash2.default.filter(Object.keys(params.sourceData), (key) => {
3583
- return _objecthash.MD5.call(void 0, params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
3986
+ return md5(params.sourceData[key]) !== params.checksums[key] && params.checksums[key];
3584
3987
  });
3585
3988
  const renamed = [];
3586
3989
  for (const addedKey of added) {
3587
- const addedHash = _objecthash.MD5.call(void 0, params.sourceData[addedKey]);
3990
+ const addedHash = md5(params.sourceData[addedKey]);
3588
3991
  for (const removedKey of removed) {
3589
3992
  if (params.checksums[removedKey] === addedHash) {
3590
3993
  renamed.push([removedKey, addedKey]);
@@ -3617,18 +4020,18 @@ function createDeltaProcessor(fileKey) {
3617
4020
  writeFile(lockfilePath, lockfileYaml);
3618
4021
  },
3619
4022
  async loadChecksums() {
3620
- const id = _objecthash.MD5.call(void 0, fileKey);
4023
+ const id = md5(fileKey);
3621
4024
  const lockfileData = await this.loadLock();
3622
4025
  return lockfileData.checksums[id] || {};
3623
4026
  },
3624
4027
  async saveChecksums(checksums) {
3625
- const id = _objecthash.MD5.call(void 0, fileKey);
4028
+ const id = md5(fileKey);
3626
4029
  const lockfileData = await this.loadLock();
3627
4030
  lockfileData.checksums[id] = checksums;
3628
4031
  await this.saveLock(lockfileData);
3629
4032
  },
3630
4033
  async createChecksums(sourceData) {
3631
- const checksums = _lodash2.default.mapValues(sourceData, (value) => _objecthash.MD5.call(void 0, value));
4034
+ const checksums = _lodash2.default.mapValues(sourceData, (value) => md5(value));
3632
4035
  return checksums;
3633
4036
  }
3634
4037
  };
@@ -3636,7 +4039,15 @@ function createDeltaProcessor(fileKey) {
3636
4039
 
3637
4040
  // src/cli/cmd/i18n.ts
3638
4041
 
3639
- var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option(
4042
+ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option(
4043
+ "--locale <locale>",
4044
+ "Locale to process",
4045
+ (val, prev) => prev ? [...prev, val] : [val]
4046
+ ).option(
4047
+ "--bucket <bucket>",
4048
+ "Bucket to process",
4049
+ (val, prev) => prev ? [...prev, val] : [val]
4050
+ ).option(
3640
4051
  "--key <key>",
3641
4052
  "Key to process. Process only a specific translation key, useful for debugging or updating a single entry"
3642
4053
  ).option(
@@ -3645,7 +4056,25 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3645
4056
  ).option(
3646
4057
  "--frozen",
3647
4058
  `Run in read-only mode - fails if any translations need updating, useful for CI/CD pipelines to detect missing translations`
3648
- ).option("--force", "Ignore lockfile and process all keys, useful for full re-translation").option("--verbose", "Show detailed output including intermediate processing data and API communication details").option("--interactive", "Enable interactive mode for reviewing and editing translations before they are applied").option("--api-key <api-key>", "Explicitly set the API key to use, override the default API key from settings").option("--debug", "Pause execution at start for debugging purposes, waits for user confirmation before proceeding").option("--strict", "Stop processing on first error instead of continuing with other locales/buckets").action(async function(options) {
4059
+ ).option(
4060
+ "--force",
4061
+ "Ignore lockfile and process all keys, useful for full re-translation"
4062
+ ).option(
4063
+ "--verbose",
4064
+ "Show detailed output including intermediate processing data and API communication details"
4065
+ ).option(
4066
+ "--interactive",
4067
+ "Enable interactive mode for reviewing and editing translations before they are applied"
4068
+ ).option(
4069
+ "--api-key <api-key>",
4070
+ "Explicitly set the API key to use, override the default API key from settings"
4071
+ ).option(
4072
+ "--debug",
4073
+ "Pause execution at start for debugging purposes, waits for user confirmation before proceeding"
4074
+ ).option(
4075
+ "--strict",
4076
+ "Stop processing on first error instead of continuing with other locales/buckets"
4077
+ ).action(async function(options) {
3649
4078
  updateGitignore();
3650
4079
  const ora = _ora2.default.call(void 0, );
3651
4080
  const flags = parseFlags(options);
@@ -3677,19 +4106,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3677
4106
  flags
3678
4107
  });
3679
4108
  let buckets = getBuckets(i18nConfig);
3680
- if (_optionalChain([flags, 'access', _147 => _147.bucket, 'optionalAccess', _148 => _148.length])) {
3681
- buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
4109
+ if (_optionalChain([flags, 'access', _155 => _155.bucket, 'optionalAccess', _156 => _156.length])) {
4110
+ buckets = buckets.filter(
4111
+ (bucket) => flags.bucket.includes(bucket.type)
4112
+ );
3682
4113
  }
3683
4114
  ora.succeed("Buckets retrieved");
3684
- if (_optionalChain([flags, 'access', _149 => _149.file, 'optionalAccess', _150 => _150.length])) {
4115
+ if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
3685
4116
  buckets = buckets.map((bucket) => {
3686
4117
  const paths = bucket.paths.filter(
3687
- (path18) => flags.file.find((file) => _optionalChain([path18, 'access', _151 => _151.pathPattern, 'optionalAccess', _152 => _152.includes, 'call', _153 => _153(file)]))
4118
+ (path18) => flags.file.find((file) => _optionalChain([path18, 'access', _159 => _159.pathPattern, 'optionalAccess', _160 => _160.includes, 'call', _161 => _161(file)]))
3688
4119
  );
3689
4120
  return { ...bucket, paths };
3690
4121
  }).filter((bucket) => bucket.paths.length > 0);
3691
4122
  if (buckets.length === 0) {
3692
- ora.fail("No buckets found. All buckets were filtered out by --file option.");
4123
+ ora.fail(
4124
+ "No buckets found. All buckets were filtered out by --file option."
4125
+ );
3693
4126
  process.exit(1);
3694
4127
  } else {
3695
4128
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
@@ -3701,7 +4134,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3701
4134
  });
3702
4135
  }
3703
4136
  }
3704
- const targetLocales = _optionalChain([flags, 'access', _154 => _154.locale, 'optionalAccess', _155 => _155.length]) ? flags.locale : i18nConfig.locale.targets;
4137
+ const targetLocales = _optionalChain([flags, 'access', _162 => _162.locale, 'optionalAccess', _163 => _163.length]) ? flags.locale : i18nConfig.locale.targets;
3705
4138
  ora.start("Setting up localization cache...");
3706
4139
  const checkLockfileProcessor = createDeltaProcessor("");
3707
4140
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -3709,7 +4142,10 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3709
4142
  ora.start("Creating i18n.lock...");
3710
4143
  for (const bucket of buckets) {
3711
4144
  for (const bucketPath of bucket.paths) {
3712
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
4145
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
4146
+ i18nConfig.locale.source,
4147
+ bucketPath.delimiter
4148
+ );
3713
4149
  const bucketLoader = createBucketLoader(
3714
4150
  bucket.type,
3715
4151
  bucketPath.pathPattern,
@@ -3722,7 +4158,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3722
4158
  );
3723
4159
  bucketLoader.setDefaultLocale(sourceLocale);
3724
4160
  await bucketLoader.init();
3725
- const sourceData = await bucketLoader.pull(i18nConfig.locale.source);
4161
+ const sourceData = await bucketLoader.pull(
4162
+ i18nConfig.locale.source
4163
+ );
3726
4164
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3727
4165
  const checksums = await deltaProcessor.createChecksums(sourceData);
3728
4166
  await deltaProcessor.saveChecksums(checksums);
@@ -3738,9 +4176,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3738
4176
  }
3739
4177
  ora.start("Validating localization state...");
3740
4178
  for (const bucketPath of bucket.paths) {
3741
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
4179
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
4180
+ i18nConfig.locale.source,
4181
+ bucketPath.delimiter
4182
+ );
3742
4183
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3743
- const sourcePath = path15.join(process.cwd(), bucketPath.pathPattern.replace("[locale]", sourceLocale));
4184
+ const sourcePath = path15.join(
4185
+ process.cwd(),
4186
+ bucketPath.pathPattern.replace("[locale]", sourceLocale)
4187
+ );
3744
4188
  const sourceContent = tryReadFile(sourcePath, null);
3745
4189
  const sourceData = JSON.parse(sourceContent || "{}");
3746
4190
  const sourceFlattenedData = _flat.flatten.call(void 0, sourceData, {
@@ -3750,8 +4194,14 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3750
4194
  }
3751
4195
  });
3752
4196
  for (const _targetLocale of targetLocales) {
3753
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
3754
- const targetPath = path15.join(process.cwd(), bucketPath.pathPattern.replace("[locale]", targetLocale));
4197
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
4198
+ _targetLocale,
4199
+ bucketPath.delimiter
4200
+ );
4201
+ const targetPath = path15.join(
4202
+ process.cwd(),
4203
+ bucketPath.pathPattern.replace("[locale]", targetLocale)
4204
+ );
3755
4205
  const targetContent = tryReadFile(targetPath, null);
3756
4206
  const targetData = JSON.parse(targetContent || "{}");
3757
4207
  const targetFlattenedData = _flat.flatten.call(void 0, targetData, {
@@ -3779,68 +4229,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3779
4229
  return decodeURIComponent(key);
3780
4230
  }
3781
4231
  });
3782
- await writeFile(targetPath, JSON.stringify(updatedTargetData, null, 2));
3783
- }
3784
- }
3785
- ora.succeed("Localization state check completed");
3786
- }
3787
- const cache = getNormalizedCache();
3788
- if (cache) {
3789
- console.log();
3790
- ora.succeed(`Cache loaded. Attempting recovery...`);
3791
- const cacheOra = _ora2.default.call(void 0, { indent: 2 });
3792
- for (const bucket of buckets) {
3793
- cacheOra.info(`Processing bucket: ${bucket.type}`);
3794
- for (const bucketPath of bucket.paths) {
3795
- const bucketOra = _ora2.default.call(void 0, { indent: 4 });
3796
- bucketOra.info(`Processing path: ${bucketPath.pathPattern}`);
3797
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
3798
- const bucketLoader = createBucketLoader(
3799
- bucket.type,
3800
- bucketPath.pathPattern,
3801
- {
3802
- isCacheRestore: true,
3803
- defaultLocale: sourceLocale,
3804
- injectLocale: bucket.injectLocale
3805
- },
3806
- bucket.lockedKeys
4232
+ await writeFile(
4233
+ targetPath,
4234
+ JSON.stringify(updatedTargetData, null, 2)
3807
4235
  );
3808
- bucketLoader.setDefaultLocale(sourceLocale);
3809
- await bucketLoader.init();
3810
- const sourceData = await bucketLoader.pull(sourceLocale);
3811
- const cachedSourceData = {};
3812
- for (const targetLocale in cache) {
3813
- const targetData = await bucketLoader.pull(targetLocale);
3814
- for (const key in cache[targetLocale]) {
3815
- const { source, result } = cache[targetLocale][key];
3816
- if (sourceData[key] === source && targetData[key] !== result) {
3817
- targetData[key] = result;
3818
- cachedSourceData[key] = source;
3819
- }
3820
- }
3821
- await bucketLoader.push(targetLocale, targetData);
3822
- const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3823
- const checksums = await deltaProcessor.createChecksums(cachedSourceData);
3824
- await deltaProcessor.saveChecksums(checksums);
3825
- bucketOra.succeed(
3826
- `[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
3827
- );
3828
- }
3829
4236
  }
3830
4237
  }
3831
- deleteCache();
3832
- if (flags.verbose) {
3833
- cacheOra.info("Cache file deleted.");
3834
- }
3835
- } else if (flags.verbose) {
3836
- ora.info("Cache file not found. Skipping recovery.");
4238
+ ora.succeed("Localization state check completed");
3837
4239
  }
3838
4240
  if (flags.frozen) {
3839
4241
  ora.start("Checking for lockfile updates...");
3840
4242
  let requiresUpdate = null;
3841
4243
  bucketLoop: for (const bucket of buckets) {
3842
4244
  for (const bucketPath of bucket.paths) {
3843
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
4245
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
4246
+ i18nConfig.locale.source,
4247
+ bucketPath.delimiter
4248
+ );
3844
4249
  const bucketLoader = createBucketLoader(
3845
4250
  bucket.type,
3846
4251
  bucketPath.pathPattern,
@@ -3854,9 +4259,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3854
4259
  );
3855
4260
  bucketLoader.setDefaultLocale(sourceLocale);
3856
4261
  await bucketLoader.init();
3857
- const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(
3858
- i18nConfig.locale.source
3859
- );
4262
+ const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(i18nConfig.locale.source);
3860
4263
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3861
4264
  const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
3862
4265
  const savedChecksums = await deltaProcessor.loadChecksums();
@@ -3869,11 +4272,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3869
4272
  break bucketLoop;
3870
4273
  }
3871
4274
  for (const _targetLocale of targetLocales) {
3872
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
4275
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
4276
+ _targetLocale,
4277
+ bucketPath.delimiter
4278
+ );
3873
4279
  const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
3874
- const missingKeys = _lodash2.default.difference(Object.keys(sourceData), Object.keys(targetData));
3875
- const extraKeys = _lodash2.default.difference(Object.keys(targetData), Object.keys(sourceData));
3876
- const unlocalizableDataDiff = !_lodash2.default.isEqual(sourceUnlocalizable, targetUnlocalizable);
4280
+ const missingKeys = _lodash2.default.difference(
4281
+ Object.keys(sourceData),
4282
+ Object.keys(targetData)
4283
+ );
4284
+ const extraKeys = _lodash2.default.difference(
4285
+ Object.keys(targetData),
4286
+ Object.keys(sourceData)
4287
+ );
4288
+ const unlocalizableDataDiff = !_lodash2.default.isEqual(
4289
+ sourceUnlocalizable,
4290
+ targetUnlocalizable
4291
+ );
3877
4292
  if (missingKeys.length > 0) {
3878
4293
  requiresUpdate = "missing";
3879
4294
  break bucketLoop;
@@ -3896,7 +4311,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3896
4311
  extra: "Target file has extra translations not present in the source file.",
3897
4312
  unlocalizable: "Unlocalizable data (such as booleans, dates, URLs, etc.) do not match."
3898
4313
  }[requiresUpdate];
3899
- ora.fail(`Localization data has changed; please update i18n.lock or run without --frozen.`);
4314
+ ora.fail(
4315
+ `Localization data has changed; please update i18n.lock or run without --frozen.`
4316
+ );
3900
4317
  ora.fail(` Details: ${message}`);
3901
4318
  process.exit(1);
3902
4319
  } else {
@@ -3908,8 +4325,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3908
4325
  console.log();
3909
4326
  ora.info(`Processing bucket: ${bucket.type}`);
3910
4327
  for (const bucketPath of bucket.paths) {
3911
- const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketPath.pathPattern}`);
3912
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
4328
+ const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(
4329
+ `Processing path: ${bucketPath.pathPattern}`
4330
+ );
4331
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
4332
+ i18nConfig.locale.source,
4333
+ bucketPath.delimiter
4334
+ );
3913
4335
  const bucketLoader = createBucketLoader(
3914
4336
  bucket.type,
3915
4337
  bucketPath.pathPattern,
@@ -3924,21 +4346,33 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3924
4346
  await bucketLoader.init();
3925
4347
  let sourceData = await bucketLoader.pull(sourceLocale);
3926
4348
  for (const _targetLocale of targetLocales) {
3927
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
4349
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
4350
+ _targetLocale,
4351
+ bucketPath.delimiter
4352
+ );
3928
4353
  try {
3929
- bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
4354
+ bucketOra.start(
4355
+ `[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`
4356
+ );
3930
4357
  sourceData = await bucketLoader.pull(sourceLocale);
3931
4358
  const targetData = await bucketLoader.pull(targetLocale);
3932
- const deltaProcessor2 = createDeltaProcessor(bucketPath.pathPattern);
4359
+ const deltaProcessor2 = createDeltaProcessor(
4360
+ bucketPath.pathPattern
4361
+ );
3933
4362
  const checksums2 = await deltaProcessor2.loadChecksums();
3934
4363
  const delta = await deltaProcessor2.calculateDelta({
3935
4364
  sourceData,
3936
4365
  targetData,
3937
4366
  checksums: checksums2
3938
4367
  });
3939
- let processableData = _lodash2.default.chain(sourceData).entries().filter(([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force).fromPairs().value();
4368
+ let processableData = _lodash2.default.chain(sourceData).entries().filter(
4369
+ ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!flags.force
4370
+ ).fromPairs().value();
3940
4371
  if (flags.key) {
3941
- processableData = _lodash2.default.pickBy(processableData, (_25, key) => key === flags.key);
4372
+ processableData = _lodash2.default.pickBy(
4373
+ processableData,
4374
+ (_24, key) => key === flags.key
4375
+ );
3942
4376
  }
3943
4377
  if (flags.verbose) {
3944
4378
  bucketOra.info(JSON.stringify(processableData, null, 2));
@@ -3950,7 +4384,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3950
4384
  apiKey: settings.auth.apiKey,
3951
4385
  apiUrl: settings.auth.apiUrl
3952
4386
  });
3953
- processPayload = withExponentialBackoff(processPayload, 3, 1e3);
4387
+ processPayload = withExponentialBackoff(
4388
+ processPayload,
4389
+ 3,
4390
+ 1e3
4391
+ );
3954
4392
  const processedTargetData = await processPayload(
3955
4393
  {
3956
4394
  sourceLocale,
@@ -3975,7 +4413,12 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3975
4413
  if (flags.verbose) {
3976
4414
  bucketOra.info(JSON.stringify(processedTargetData, null, 2));
3977
4415
  }
3978
- let finalTargetData = _lodash2.default.merge({}, sourceData, targetData, processedTargetData);
4416
+ let finalTargetData = _lodash2.default.merge(
4417
+ {},
4418
+ sourceData,
4419
+ targetData,
4420
+ processedTargetData
4421
+ );
3979
4422
  if (flags.interactive) {
3980
4423
  bucketOra.stop();
3981
4424
  const reviewedData = await reviewChanges({
@@ -3987,17 +4430,25 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3987
4430
  force: flags.force
3988
4431
  });
3989
4432
  finalTargetData = reviewedData;
3990
- bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
4433
+ bucketOra.start(
4434
+ `Applying changes to ${bucketPath} (${targetLocale})`
4435
+ );
3991
4436
  }
3992
4437
  const finalDiffSize = _lodash2.default.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
3993
4438
  await bucketLoader.push(targetLocale, finalTargetData);
3994
4439
  if (finalDiffSize > 0 || flags.force) {
3995
- bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed`);
4440
+ bucketOra.succeed(
4441
+ `[${sourceLocale} -> ${targetLocale}] Localization completed`
4442
+ );
3996
4443
  } else {
3997
- bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed (no changes).`);
4444
+ bucketOra.succeed(
4445
+ `[${sourceLocale} -> ${targetLocale}] Localization completed (no changes).`
4446
+ );
3998
4447
  }
3999
4448
  } catch (_error) {
4000
- const error = new Error(`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`);
4449
+ const error = new Error(
4450
+ `[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`
4451
+ );
4001
4452
  if (flags.strict) {
4002
4453
  throw error;
4003
4454
  } else {
@@ -4011,7 +4462,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4011
4462
  await deltaProcessor.saveChecksums(checksums);
4012
4463
  }
4013
4464
  } catch (_error) {
4014
- const error = new Error(`Failed to process bucket ${bucket.type}: ${_error.message}`);
4465
+ const error = new Error(
4466
+ `Failed to process bucket ${bucket.type}: ${_error.message}`
4467
+ );
4015
4468
  if (flags.strict) {
4016
4469
  throw error;
4017
4470
  } else {
@@ -4089,12 +4542,14 @@ function validateParams(i18nConfig, flags) {
4089
4542
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
4090
4543
  docUrl: "bucketNotFound"
4091
4544
  });
4092
- } else if (_optionalChain([flags, 'access', _156 => _156.locale, 'optionalAccess', _157 => _157.some, 'call', _158 => _158((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4545
+ } else if (_optionalChain([flags, 'access', _164 => _164.locale, 'optionalAccess', _165 => _165.some, 'call', _166 => _166((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4093
4546
  throw new CLIError({
4094
4547
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
4095
4548
  docUrl: "localeTargetNotFound"
4096
4549
  });
4097
- } else if (_optionalChain([flags, 'access', _159 => _159.bucket, 'optionalAccess', _160 => _160.some, 'call', _161 => _161((bucket) => !i18nConfig.buckets[bucket])])) {
4550
+ } else if (_optionalChain([flags, 'access', _167 => _167.bucket, 'optionalAccess', _168 => _168.some, 'call', _169 => _169(
4551
+ (bucket) => !i18nConfig.buckets[bucket]
4552
+ )])) {
4098
4553
  throw new CLIError({
4099
4554
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
4100
4555
  docUrl: "bucketNotFound"
@@ -4126,8 +4581,10 @@ ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.default.yellow(args.targetL
4126
4581
  if (line.startsWith("@")) return _chalk2.default.cyan(line);
4127
4582
  return line;
4128
4583
  }).join("\n");
4129
- console.log(`
4130
- Reviewing changes for ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.default.yellow(args.targetLocale)}):`);
4584
+ console.log(
4585
+ `
4586
+ Reviewing changes for ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.default.yellow(args.targetLocale)}):`
4587
+ );
4131
4588
  console.log(coloredDiff);
4132
4589
  const { action } = await _inquirer2.default.prompt([
4133
4590
  {
@@ -4163,9 +4620,19 @@ Reviewing changes for ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.defau
4163
4620
  console.log(`
4164
4621
  Editing value for: ${_chalk2.default.cyan(key)}`);
4165
4622
  console.log(_chalk2.default.gray("Source text:"), _chalk2.default.blue(args.sourceData[key]));
4166
- console.log(_chalk2.default.gray("Current value:"), _chalk2.default.red(args.currentData[key] || "(empty)"));
4167
- console.log(_chalk2.default.gray("Suggested value:"), _chalk2.default.green(args.proposedData[key]));
4168
- console.log(_chalk2.default.gray("\nYour editor will open. Edit the text and save to continue."));
4623
+ console.log(
4624
+ _chalk2.default.gray("Current value:"),
4625
+ _chalk2.default.red(args.currentData[key] || "(empty)")
4626
+ );
4627
+ console.log(
4628
+ _chalk2.default.gray("Suggested value:"),
4629
+ _chalk2.default.green(args.proposedData[key])
4630
+ );
4631
+ console.log(
4632
+ _chalk2.default.gray(
4633
+ "\nYour editor will open. Edit the text and save to continue."
4634
+ )
4635
+ );
4169
4636
  console.log(_chalk2.default.gray("------------"));
4170
4637
  try {
4171
4638
  const editorContent = [
@@ -4186,11 +4653,15 @@ Editing value for: ${_chalk2.default.cyan(key)}`);
4186
4653
  if (customValue) {
4187
4654
  customData[key] = customValue;
4188
4655
  } else {
4189
- console.log(_chalk2.default.yellow("Empty value provided, keeping the current value."));
4656
+ console.log(
4657
+ _chalk2.default.yellow("Empty value provided, keeping the current value.")
4658
+ );
4190
4659
  customData[key] = args.currentData[key] || args.proposedData[key];
4191
4660
  }
4192
4661
  } catch (error) {
4193
- console.log(_chalk2.default.red("Error while editing, keeping the suggested value."));
4662
+ console.log(
4663
+ _chalk2.default.red("Error while editing, keeping the suggested value.")
4664
+ );
4194
4665
  customData[key] = args.proposedData[key];
4195
4666
  }
4196
4667
  }
@@ -4404,7 +4875,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
4404
4875
  var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
4405
4876
 
4406
4877
 
4407
- var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_25, program) => {
4878
+ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_24, program) => {
4408
4879
  const apiKey = program.args[0];
4409
4880
  const settings = getSettings(apiKey);
4410
4881
  if (!settings.auth.apiKey) {
@@ -4527,7 +4998,7 @@ var InBranchFlow = class extends IntegrationFlow {
4527
4998
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
4528
4999
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
4529
5000
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
4530
- _optionalChain([this, 'access', _162 => _162.platformKit, 'optionalAccess', _163 => _163.gitConfig, 'call', _164 => _164()]);
5001
+ _optionalChain([this, 'access', _170 => _170.platformKit, 'optionalAccess', _171 => _171.gitConfig, 'call', _172 => _172()]);
4531
5002
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
4532
5003
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
4533
5004
  if (!processOwnCommits) {
@@ -4552,7 +5023,7 @@ var InBranchFlow = class extends IntegrationFlow {
4552
5023
  // ../../action/src/flows/pull-request.ts
4553
5024
  var PullRequestFlow = class extends InBranchFlow {
4554
5025
  async preRun() {
4555
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _165 => _165()]);
5026
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _173 => _173()]);
4556
5027
  if (!canContinue) {
4557
5028
  return false;
4558
5029
  }
@@ -4770,10 +5241,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
4770
5241
  repo_slug: this.platformConfig.repositoryName,
4771
5242
  state: "OPEN"
4772
5243
  }).then(({ data: { values } }) => {
4773
- return _optionalChain([values, 'optionalAccess', _166 => _166.find, 'call', _167 => _167(
4774
- ({ source, destination }) => _optionalChain([source, 'optionalAccess', _168 => _168.branch, 'optionalAccess', _169 => _169.name]) === branch && _optionalChain([destination, 'optionalAccess', _170 => _170.branch, 'optionalAccess', _171 => _171.name]) === this.platformConfig.baseBranchName
5244
+ return _optionalChain([values, 'optionalAccess', _174 => _174.find, 'call', _175 => _175(
5245
+ ({ source, destination }) => _optionalChain([source, 'optionalAccess', _176 => _176.branch, 'optionalAccess', _177 => _177.name]) === branch && _optionalChain([destination, 'optionalAccess', _178 => _178.branch, 'optionalAccess', _179 => _179.name]) === this.platformConfig.baseBranchName
4775
5246
  )]);
4776
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _172 => _172.id]));
5247
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _180 => _180.id]));
4777
5248
  }
4778
5249
  async closePullRequest({ pullRequestNumber }) {
4779
5250
  await this.bb.repositories.declinePullRequest({
@@ -4859,7 +5330,7 @@ var GitHubPlatformKit = class extends PlatformKit {
4859
5330
  repo: this.platformConfig.repositoryName,
4860
5331
  base: this.platformConfig.baseBranchName,
4861
5332
  state: "open"
4862
- }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _173 => _173.number]));
5333
+ }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _181 => _181.number]));
4863
5334
  }
4864
5335
  async closePullRequest({ pullRequestNumber }) {
4865
5336
  await this.octokit.rest.pulls.update({
@@ -4972,7 +5443,7 @@ var GitlabPlatformKit = class extends PlatformKit {
4972
5443
  sourceBranch: branch,
4973
5444
  state: "opened"
4974
5445
  });
4975
- return _optionalChain([mergeRequests, 'access', _174 => _174[0], 'optionalAccess', _175 => _175.iid]);
5446
+ return _optionalChain([mergeRequests, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.iid]);
4976
5447
  }
4977
5448
  async closePullRequest({ pullRequestNumber }) {
4978
5449
  await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
@@ -5025,7 +5496,7 @@ async function main() {
5025
5496
  const { isPullRequestMode } = platformKit.config;
5026
5497
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
5027
5498
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
5028
- const canRun = await _optionalChain([flow, 'access', _176 => _176.preRun, 'optionalCall', _177 => _177()]);
5499
+ const canRun = await _optionalChain([flow, 'access', _184 => _184.preRun, 'optionalCall', _185 => _185()]);
5029
5500
  if (canRun === false) {
5030
5501
  return;
5031
5502
  }
@@ -5033,7 +5504,7 @@ async function main() {
5033
5504
  if (!hasChanges) {
5034
5505
  return;
5035
5506
  }
5036
- await _optionalChain([flow, 'access', _178 => _178.postRun, 'optionalCall', _179 => _179()]);
5507
+ await _optionalChain([flow, 'access', _186 => _186.postRun, 'optionalCall', _187 => _187()]);
5037
5508
  }
5038
5509
 
5039
5510
  // src/cli/cmd/ci.ts
@@ -5055,7 +5526,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5055
5526
  }
5056
5527
  const env = {
5057
5528
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
5058
- LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _180 => _180.pullRequest, 'optionalAccess', _181 => _181.toString, 'call', _182 => _182()]) || "false",
5529
+ LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _188 => _188.pullRequest, 'optionalAccess', _189 => _189.toString, 'call', _190 => _190()]) || "false",
5059
5530
  ...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
5060
5531
  ...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
5061
5532
  ...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
@@ -5106,13 +5577,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5106
5577
  flags
5107
5578
  });
5108
5579
  let buckets = getBuckets(i18nConfig);
5109
- if (_optionalChain([flags, 'access', _183 => _183.bucket, 'optionalAccess', _184 => _184.length])) {
5580
+ if (_optionalChain([flags, 'access', _191 => _191.bucket, 'optionalAccess', _192 => _192.length])) {
5110
5581
  buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
5111
5582
  }
5112
5583
  ora.succeed("Buckets retrieved");
5113
- if (_optionalChain([flags, 'access', _185 => _185.file, 'optionalAccess', _186 => _186.length])) {
5584
+ if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
5114
5585
  buckets = buckets.map((bucket) => {
5115
- const paths = bucket.paths.filter((path18) => flags.file.find((file) => _optionalChain([path18, 'access', _187 => _187.pathPattern, 'optionalAccess', _188 => _188.match, 'call', _189 => _189(file)])));
5586
+ const paths = bucket.paths.filter((path18) => flags.file.find((file) => _optionalChain([path18, 'access', _195 => _195.pathPattern, 'optionalAccess', _196 => _196.match, 'call', _197 => _197(file)])));
5116
5587
  return { ...bucket, paths };
5117
5588
  }).filter((bucket) => bucket.paths.length > 0);
5118
5589
  if (buckets.length === 0) {
@@ -5128,7 +5599,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5128
5599
  });
5129
5600
  }
5130
5601
  }
5131
- const targetLocales = _optionalChain([flags, 'access', _190 => _190.locale, 'optionalAccess', _191 => _191.length]) ? flags.locale : i18nConfig.locale.targets;
5602
+ const targetLocales = _optionalChain([flags, 'access', _198 => _198.locale, 'optionalAccess', _199 => _199.length]) ? flags.locale : i18nConfig.locale.targets;
5132
5603
  let totalSourceKeyCount = 0;
5133
5604
  let uniqueKeysToTranslate = 0;
5134
5605
  let totalExistingTranslations = 0;
@@ -5469,12 +5940,12 @@ function validateParams2(i18nConfig, flags) {
5469
5940
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
5470
5941
  docUrl: "bucketNotFound"
5471
5942
  });
5472
- } else if (_optionalChain([flags, 'access', _192 => _192.locale, 'optionalAccess', _193 => _193.some, 'call', _194 => _194((locale) => !i18nConfig.locale.targets.includes(locale))])) {
5943
+ } else if (_optionalChain([flags, 'access', _200 => _200.locale, 'optionalAccess', _201 => _201.some, 'call', _202 => _202((locale) => !i18nConfig.locale.targets.includes(locale))])) {
5473
5944
  throw new CLIError({
5474
5945
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
5475
5946
  docUrl: "localeTargetNotFound"
5476
5947
  });
5477
- } else if (_optionalChain([flags, 'access', _195 => _195.bucket, 'optionalAccess', _196 => _196.some, 'call', _197 => _197((bucket) => !i18nConfig.buckets[bucket])])) {
5948
+ } else if (_optionalChain([flags, 'access', _203 => _203.bucket, 'optionalAccess', _204 => _204.some, 'call', _205 => _205((bucket) => !i18nConfig.buckets[bucket])])) {
5478
5949
  throw new CLIError({
5479
5950
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
5480
5951
  docUrl: "bucketNotFound"
@@ -5485,7 +5956,7 @@ function validateParams2(i18nConfig, flags) {
5485
5956
  // package.json
5486
5957
  var package_default = {
5487
5958
  name: "lingo.dev",
5488
- version: "0.85.7",
5959
+ version: "0.87.0",
5489
5960
  description: "Lingo.dev CLI",
5490
5961
  private: false,
5491
5962
  publishConfig: {
@@ -5559,6 +6030,7 @@ var package_default = {
5559
6030
  "csv-parse": "^5.6.0",
5560
6031
  "csv-stringify": "^6.5.2",
5561
6032
  "date-fns": "^4.1.0",
6033
+ dedent: "^1.5.3",
5562
6034
  diff: "^7.0.0",
5563
6035
  dotenv: "^16.4.7",
5564
6036
  express: "^4.21.2",
@@ -5578,6 +6050,9 @@ var package_default = {
5578
6050
  jsonrepair: "^3.11.2",
5579
6051
  lodash: "^4.17.21",
5580
6052
  marked: "^15.0.6",
6053
+ "mdast-util-from-markdown": "^2.0.2",
6054
+ "mdast-util-gfm": "^3.1.0",
6055
+ "micromark-extension-gfm": "^3.0.0",
5581
6056
  "node-webvtt": "^1.9.4",
5582
6057
  "object-hash": "^3.0.0",
5583
6058
  octokit: "^4.0.2",
@@ -5588,14 +6063,18 @@ var package_default = {
5588
6063
  plist: "^3.1.0",
5589
6064
  "posthog-node": "^4.11.2",
5590
6065
  prettier: "^3.4.2",
6066
+ "rehype-stringify": "^10.0.1",
6067
+ "remark-disable-tokenizers": "^1.1.1",
5591
6068
  "remark-frontmatter": "^5.0.0",
5592
6069
  "remark-gfm": "^4.0.1",
5593
6070
  "remark-mdx": "^3.1.0",
5594
6071
  "remark-mdx-frontmatter": "^5.1.0",
5595
6072
  "remark-parse": "^11.0.0",
6073
+ "remark-rehype": "^11.1.2",
5596
6074
  "remark-stringify": "^11.0.0",
5597
6075
  "srt-parser-2": "^1.2.3",
5598
6076
  unified: "^11.0.5",
6077
+ "unist-util-visit": "^5.0.0",
5599
6078
  vfile: "^6.0.3",
5600
6079
  xliff: "^6.2.1",
5601
6080
  xml2js: "^0.6.2",