lingo.dev 0.86.0 → 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,96 +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 _remarkfrontmatter = require('remark-frontmatter'); var _remarkfrontmatter2 = _interopRequireDefault(_remarkfrontmatter);
1645
- var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
1646
- var _remarkstringify = require('remark-stringify'); var _remarkstringify2 = _interopRequireDefault(_remarkstringify);
1647
- var _vfile = require('vfile');
1648
- var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkgfm2.default);
1649
- var serializer = _unified.unified.call(void 0, ).use(_remarkstringify2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkgfm2.default);
1650
- function createMdxFormatLoader() {
1651
- const skippedTypes = ["code", "inlineCode"];
1652
- return createLoader({
1653
- async pull(locale, input2) {
1654
- const file = new (0, _vfile.VFile)(input2);
1655
- const ast = parser.parse(file);
1656
- const result = _lodash2.default.cloneDeep(ast);
1657
- traverseMdast(result, (node) => {
1658
- if (skippedTypes.includes(node.type)) {
1659
- if ("value" in node) {
1660
- node.value = "";
1661
- }
1662
- }
1663
- });
1664
- return result;
1665
- },
1666
- async push(locale, data, originalInput, originalLocale, pullInput, pullOutput) {
1667
- const file = new (0, _vfile.VFile)(originalInput);
1668
- const ast = parser.parse(file);
1669
- const result = _lodash2.default.cloneDeep(ast);
1670
- traverseMdast(result, (node, indexPath) => {
1671
- if ("value" in node) {
1672
- const incomingValue = findNodeByIndexPath(data, indexPath);
1673
- if (incomingValue && "value" in incomingValue && !_lodash2.default.isEmpty(incomingValue.value)) {
1674
- node.value = incomingValue.value;
1675
- }
1676
- }
1677
- });
1678
- return String(serializer.stringify(result));
1679
- }
1680
- });
1681
- }
1682
- function createDoubleSerializationLoader() {
1683
- return createLoader({
1684
- async pull(locale, input2) {
1685
- return input2;
1686
- },
1687
- async push(locale, data) {
1688
- const file = new (0, _vfile.VFile)(data);
1689
- const ast = parser.parse(file);
1690
- const finalContent = String(serializer.stringify(ast));
1691
- return finalContent;
1692
- }
1693
- });
1694
- }
1695
- function createMdxStructureLoader() {
1696
- return createLoader({
1697
- async pull(locale, input2) {
1698
- const result = _lodash2.default.chain(input2).pickBy((value, key) => key.endsWith("/value")).value();
1699
- return result;
1700
- },
1701
- async push(locale, data, originalInput) {
1702
- const result = _lodash2.default.merge({}, originalInput, data);
1703
- return result;
1704
- }
1705
- });
1706
- }
1707
- function traverseMdast(ast, visitor, indexPath = []) {
1708
- visitor(ast, indexPath);
1709
- if ("children" in ast && Array.isArray(ast.children)) {
1710
- for (let i = 0; i < ast.children.length; i++) {
1711
- traverseMdast(ast.children[i], visitor, [...indexPath, i]);
1712
- }
1713
- }
1714
- }
1715
- function findNodeByIndexPath(ast, indexPath) {
1716
- let result = null;
1717
- const stringifiedIndexPath = indexPath.join(".");
1718
- traverseMdast(ast, (node, path18) => {
1719
- if (result) {
1720
- return;
1721
- }
1722
- const currentStringifiedPath = path18.join(".");
1723
- if (currentStringifiedPath === stringifiedIndexPath) {
1724
- result = node;
1725
- }
1726
- });
1727
- return result;
1728
- }
1729
-
1730
1643
  // src/cli/loaders/properties.ts
1731
1644
  function createPropertiesLoader() {
1732
1645
  return createLoader({
@@ -1746,7 +1659,7 @@ function createPropertiesLoader() {
1746
1659
  return result;
1747
1660
  },
1748
1661
  async push(locale, payload) {
1749
- 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");
1750
1663
  return result;
1751
1664
  }
1752
1665
  });
@@ -1757,7 +1670,7 @@ function isSkippableLine(line) {
1757
1670
  function parsePropertyLine(line) {
1758
1671
  const [key, ...valueParts] = line.split("=");
1759
1672
  return {
1760
- key: _optionalChain([key, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]) || "",
1673
+ key: _optionalChain([key, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()]) || "",
1761
1674
  value: valueParts.join("=").trim()
1762
1675
  };
1763
1676
  }
@@ -1843,7 +1756,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1843
1756
  if (rootTranslationEntity.shouldTranslate === false) {
1844
1757
  continue;
1845
1758
  }
1846
- 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]]);
1847
1760
  if (langTranslationEntity) {
1848
1761
  if ("stringUnit" in langTranslationEntity) {
1849
1762
  resultData[translationKey] = langTranslationEntity.stringUnit.value;
@@ -1852,7 +1765,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1852
1765
  resultData[translationKey] = {};
1853
1766
  const pluralForms = langTranslationEntity.variations.plural;
1854
1767
  for (const form in pluralForms) {
1855
- 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])) {
1856
1769
  resultData[translationKey][form] = pluralForms[form].stringUnit.value;
1857
1770
  }
1858
1771
  }
@@ -1862,7 +1775,6 @@ function createXcodeXcstringsLoader(defaultLocale) {
1862
1775
  resultData[translationKey] = translationKey;
1863
1776
  }
1864
1777
  }
1865
- console.log(resultData);
1866
1778
  return resultData;
1867
1779
  },
1868
1780
  async push(locale, payload, originalInput) {
@@ -1876,7 +1788,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1876
1788
  const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
1877
1789
  if (typeof value === "string") {
1878
1790
  langDataToMerge.strings[key] = {
1879
- 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]),
1880
1792
  localizations: {
1881
1793
  [locale]: {
1882
1794
  stringUnit: {
@@ -1926,41 +1838,20 @@ var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_pr
1926
1838
  function createPrettierLoader(options) {
1927
1839
  return createLoader({
1928
1840
  async pull(locale, data) {
1929
- 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);
1930
1847
  },
1931
1848
  async push(locale, data) {
1932
- const draftPath = options.bucketPathPattern.replaceAll("[locale]", locale);
1849
+ const draftPath = options.bucketPathPattern.replaceAll(
1850
+ "[locale]",
1851
+ locale
1852
+ );
1933
1853
  const finalPath = path15.default.resolve(draftPath);
1934
- const prettierConfig = await loadPrettierConfig(finalPath);
1935
- if (!prettierConfig) {
1936
- return data;
1937
- }
1938
- const config = {
1939
- ...prettierConfig || { printWidth: 2500, bracketSameLine: false },
1940
- parser: options.parser,
1941
- // For HTML parser, preserve comments and quotes
1942
- ...options.parser === "html" ? {
1943
- htmlWhitespaceSensitivity: "ignore",
1944
- singleQuote: false,
1945
- embeddedLanguageFormatting: "off"
1946
- } : {}
1947
- };
1948
- try {
1949
- const result = await _prettier2.default.format(data, config);
1950
- return result;
1951
- } catch (error) {
1952
- if (error instanceof Error && error.message.startsWith("Cannot find package")) {
1953
- console.log();
1954
- console.log("\u26A0\uFE0F Prettier plugins are not installed. Formatting without plugins.");
1955
- console.log("\u26A0\uFE0F To use prettier plugins install project dependencies before running Lingo.dev.");
1956
- config.plugins = [];
1957
- await _prettier2.default.clearConfigCache();
1958
- const result = await _prettier2.default.format(data, config);
1959
- return result;
1960
- } else {
1961
- throw error;
1962
- }
1963
- }
1854
+ return await formatDataWithPrettier(data, finalPath, options);
1964
1855
  }
1965
1856
  });
1966
1857
  }
@@ -1972,6 +1863,39 @@ async function loadPrettierConfig(filePath) {
1972
1863
  return {};
1973
1864
  }
1974
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
+ }
1975
1899
 
1976
1900
  // src/cli/loaders/unlocalizable.ts
1977
1901
 
@@ -1995,10 +1919,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
1995
1919
  }
1996
1920
  }
1997
1921
  return false;
1998
- }).map(([key, _25]) => key);
1999
- 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));
2000
1924
  if (returnUnlocalizedKeys) {
2001
- result.unlocalizable = _lodash2.default.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
1925
+ result.unlocalizable = _lodash2.default.omitBy(input2, (_24, key) => !passthroughKeys.includes(key));
2002
1926
  }
2003
1927
  return result;
2004
1928
  },
@@ -2037,7 +1961,7 @@ function createPoDataLoader(params) {
2037
1961
  Object.entries(entries).forEach(([msgid, entry]) => {
2038
1962
  if (msgid && entry.msgid) {
2039
1963
  const context = entry.msgctxt || "";
2040
- 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]]);
2041
1965
  if (fullEntry) {
2042
1966
  result[msgid] = fullEntry;
2043
1967
  }
@@ -2047,8 +1971,8 @@ function createPoDataLoader(params) {
2047
1971
  return result;
2048
1972
  },
2049
1973
  async push(locale, data, originalInput, originalLocale, pullInput) {
2050
- const currentSections = _optionalChain([pullInput, 'optionalAccess', _86 => _86.split, 'call', _87 => _87("\n\n"), 'access', _88 => _88.filter, 'call', _89 => _89(Boolean)]) || [];
2051
- 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)]) || [];
2052
1976
  const result = originalSections.map((section) => {
2053
1977
  const sectionPo = _gettextparser2.default.po.parse(section);
2054
1978
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
@@ -2102,7 +2026,7 @@ function createPoContentLoader() {
2102
2026
  entry.msgid,
2103
2027
  {
2104
2028
  ...entry,
2105
- 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)
2106
2030
  }
2107
2031
  ]).fromPairs().value();
2108
2032
  return result;
@@ -2348,7 +2272,7 @@ function createDatoClient(params) {
2348
2272
  only_valid: "true",
2349
2273
  ids: !records.length ? void 0 : records.join(",")
2350
2274
  }
2351
- }).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));
2352
2276
  },
2353
2277
  findRecordsForModel: async (modelId, records) => {
2354
2278
  try {
@@ -2358,9 +2282,9 @@ function createDatoClient(params) {
2358
2282
  filter: {
2359
2283
  type: modelId,
2360
2284
  only_valid: "true",
2361
- ids: !_optionalChain([records, 'optionalAccess', _102 => _102.length]) ? void 0 : records.join(",")
2285
+ ids: !_optionalChain([records, 'optionalAccess', _101 => _101.length]) ? void 0 : records.join(",")
2362
2286
  }
2363
- }).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));
2364
2288
  return result;
2365
2289
  } catch (_error) {
2366
2290
  throw new Error(
@@ -2374,9 +2298,9 @@ function createDatoClient(params) {
2374
2298
  },
2375
2299
  updateRecord: async (id, payload) => {
2376
2300
  try {
2377
- 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));
2378
2302
  } catch (_error) {
2379
- 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])) {
2380
2304
  throw new Error(
2381
2305
  [
2382
2306
  `${_error.attributes.details.message}`,
@@ -2397,9 +2321,9 @@ function createDatoClient(params) {
2397
2321
  },
2398
2322
  enableFieldLocalization: async (args) => {
2399
2323
  try {
2400
- 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));
2401
2325
  } catch (_error) {
2402
- 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") {
2403
2327
  throw new Error(
2404
2328
  [
2405
2329
  `Field "${args.fieldId}" not found in model "${args.modelId}".`,
@@ -2407,7 +2331,7 @@ function createDatoClient(params) {
2407
2331
  ].join("\n\n")
2408
2332
  );
2409
2333
  }
2410
- 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])) {
2411
2335
  throw new Error(
2412
2336
  [`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
2413
2337
  );
@@ -2473,7 +2397,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
2473
2397
  }
2474
2398
  }
2475
2399
  const records = await dato.findRecordsForModel(modelId);
2476
- 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);
2477
2401
  const selectedRecords = await promptRecordSelection(modelName, recordChoices);
2478
2402
  result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
2479
2403
  updatedConfig.models[modelId].records = selectedRecords;
@@ -2485,14 +2409,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
2485
2409
  },
2486
2410
  async pull(locale, input2, initCtx) {
2487
2411
  const result = {};
2488
- for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _126 => _126.models]) || {})) {
2489
- 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]) || [];
2490
2414
  const recordIds = records.map((record) => record.id);
2491
2415
  records = await dato.findRecords(recordIds);
2492
2416
  console.log(`Fetched ${records.length} records for model ${modelId}`);
2493
2417
  if (records.length > 0) {
2494
2418
  result[modelId] = {
2495
- 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]) || [],
2496
2420
  records
2497
2421
  };
2498
2422
  }
@@ -2551,7 +2475,7 @@ function createRecordChoices(records, selectedIds = [], project) {
2551
2475
  return records.map((record) => ({
2552
2476
  name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
2553
2477
  value: record.id,
2554
- 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)])
2555
2479
  }));
2556
2480
  }
2557
2481
  async function promptRecordSelection(modelName, choices) {
@@ -2818,7 +2742,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
2818
2742
  function createVttLoader() {
2819
2743
  return createLoader({
2820
2744
  async pull(locale, input2) {
2821
- 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]);
2822
2746
  if (Object.keys(vtt).length === 0) {
2823
2747
  return {};
2824
2748
  } else {
@@ -2871,7 +2795,7 @@ function variableExtractLoader(params) {
2871
2795
  for (let i = 0; i < matches.length; i++) {
2872
2796
  const match = matches[i];
2873
2797
  const currentValue = result[key].value;
2874
- 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}}`)]);
2875
2799
  result[key].value = newValue;
2876
2800
  result[key].variables[i] = match;
2877
2801
  }
@@ -2885,7 +2809,7 @@ function variableExtractLoader(params) {
2885
2809
  for (let i = 0; i < valueObj.variables.length; i++) {
2886
2810
  const variable = valueObj.variables[i];
2887
2811
  const currentValue = result[key];
2888
- 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)]);
2889
2813
  result[key] = newValue;
2890
2814
  }
2891
2815
  }
@@ -3066,7 +2990,7 @@ function createVueJsonLoader() {
3066
2990
  return createLoader({
3067
2991
  pull: async (locale, input2, ctx) => {
3068
2992
  const parsed = parseVueFile(input2);
3069
- 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]]), () => ( {}));
3070
2994
  },
3071
2995
  push: async (locale, data, originalInput) => {
3072
2996
  const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
@@ -3140,6 +3064,423 @@ function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
3140
3064
  });
3141
3065
  }
3142
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
+
3143
3484
  // src/cli/loaders/index.ts
3144
3485
  function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys) {
3145
3486
  switch (bucketType) {
@@ -3151,7 +3492,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3151
3492
  createAndroidLoader(),
3152
3493
  createFlatLoader(),
3153
3494
  createSyncLoader(),
3154
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3495
+ createUnlocalizableLoader(
3496
+ options.isCacheRestore,
3497
+ options.returnUnlocalizedKeys
3498
+ )
3155
3499
  );
3156
3500
  case "csv":
3157
3501
  return composeLoaders(
@@ -3159,7 +3503,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3159
3503
  createCsvLoader(),
3160
3504
  createFlatLoader(),
3161
3505
  createSyncLoader(),
3162
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3506
+ createUnlocalizableLoader(
3507
+ options.isCacheRestore,
3508
+ options.returnUnlocalizedKeys
3509
+ )
3163
3510
  );
3164
3511
  case "html":
3165
3512
  return composeLoaders(
@@ -3167,7 +3514,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3167
3514
  createPrettierLoader({ parser: "html", bucketPathPattern }),
3168
3515
  createHtmlLoader(),
3169
3516
  createSyncLoader(),
3170
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3517
+ createUnlocalizableLoader(
3518
+ options.isCacheRestore,
3519
+ options.returnUnlocalizedKeys
3520
+ )
3171
3521
  );
3172
3522
  case "json":
3173
3523
  return composeLoaders(
@@ -3178,7 +3528,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3178
3528
  createFlatLoader(),
3179
3529
  createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3180
3530
  createSyncLoader(),
3181
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3531
+ createUnlocalizableLoader(
3532
+ options.isCacheRestore,
3533
+ options.returnUnlocalizedKeys
3534
+ )
3182
3535
  );
3183
3536
  case "markdown":
3184
3537
  return composeLoaders(
@@ -3186,18 +3539,22 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3186
3539
  createPrettierLoader({ parser: "markdown", bucketPathPattern }),
3187
3540
  createMarkdownLoader(),
3188
3541
  createSyncLoader(),
3189
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3542
+ createUnlocalizableLoader(
3543
+ options.isCacheRestore,
3544
+ options.returnUnlocalizedKeys
3545
+ )
3190
3546
  );
3191
3547
  case "mdx":
3192
3548
  return composeLoaders(
3193
3549
  createTextFileLoader(bucketPathPattern),
3194
- createDoubleSerializationLoader(),
3195
3550
  createPrettierLoader({ parser: "mdx", bucketPathPattern }),
3196
- createMdxFormatLoader(),
3551
+ createMdxLoader(),
3197
3552
  createFlatLoader(),
3198
- createMdxStructureLoader(),
3199
3553
  createSyncLoader(),
3200
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3554
+ createUnlocalizableLoader(
3555
+ options.isCacheRestore,
3556
+ options.returnUnlocalizedKeys
3557
+ )
3201
3558
  );
3202
3559
  case "po":
3203
3560
  return composeLoaders(
@@ -3206,21 +3563,30 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3206
3563
  createFlatLoader(),
3207
3564
  createSyncLoader(),
3208
3565
  createVariableLoader({ type: "python" }),
3209
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3566
+ createUnlocalizableLoader(
3567
+ options.isCacheRestore,
3568
+ options.returnUnlocalizedKeys
3569
+ )
3210
3570
  );
3211
3571
  case "properties":
3212
3572
  return composeLoaders(
3213
3573
  createTextFileLoader(bucketPathPattern),
3214
3574
  createPropertiesLoader(),
3215
3575
  createSyncLoader(),
3216
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3576
+ createUnlocalizableLoader(
3577
+ options.isCacheRestore,
3578
+ options.returnUnlocalizedKeys
3579
+ )
3217
3580
  );
3218
3581
  case "xcode-strings":
3219
3582
  return composeLoaders(
3220
3583
  createTextFileLoader(bucketPathPattern),
3221
3584
  createXcodeStringsLoader(),
3222
3585
  createSyncLoader(),
3223
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3586
+ createUnlocalizableLoader(
3587
+ options.isCacheRestore,
3588
+ options.returnUnlocalizedKeys
3589
+ )
3224
3590
  );
3225
3591
  case "xcode-stringsdict":
3226
3592
  return composeLoaders(
@@ -3228,7 +3594,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3228
3594
  createXcodeStringsdictLoader(),
3229
3595
  createFlatLoader(),
3230
3596
  createSyncLoader(),
3231
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3597
+ createUnlocalizableLoader(
3598
+ options.isCacheRestore,
3599
+ options.returnUnlocalizedKeys
3600
+ )
3232
3601
  );
3233
3602
  case "xcode-xcstrings":
3234
3603
  return composeLoaders(
@@ -3239,7 +3608,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3239
3608
  createFlatLoader(),
3240
3609
  createSyncLoader(),
3241
3610
  createVariableLoader({ type: "ieee" }),
3242
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3611
+ createUnlocalizableLoader(
3612
+ options.isCacheRestore,
3613
+ options.returnUnlocalizedKeys
3614
+ )
3243
3615
  );
3244
3616
  case "yaml":
3245
3617
  return composeLoaders(
@@ -3249,7 +3621,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3249
3621
  createFlatLoader(),
3250
3622
  createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3251
3623
  createSyncLoader(),
3252
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3624
+ createUnlocalizableLoader(
3625
+ options.isCacheRestore,
3626
+ options.returnUnlocalizedKeys
3627
+ )
3253
3628
  );
3254
3629
  case "yaml-root-key":
3255
3630
  return composeLoaders(
@@ -3259,7 +3634,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3259
3634
  createRootKeyLoader(true),
3260
3635
  createFlatLoader(),
3261
3636
  createSyncLoader(),
3262
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3637
+ createUnlocalizableLoader(
3638
+ options.isCacheRestore,
3639
+ options.returnUnlocalizedKeys
3640
+ )
3263
3641
  );
3264
3642
  case "flutter":
3265
3643
  return composeLoaders(
@@ -3269,7 +3647,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3269
3647
  createFlutterLoader(),
3270
3648
  createFlatLoader(),
3271
3649
  createSyncLoader(),
3272
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3650
+ createUnlocalizableLoader(
3651
+ options.isCacheRestore,
3652
+ options.returnUnlocalizedKeys
3653
+ )
3273
3654
  );
3274
3655
  case "xliff":
3275
3656
  return composeLoaders(
@@ -3277,7 +3658,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3277
3658
  createXliffLoader(),
3278
3659
  createFlatLoader(),
3279
3660
  createSyncLoader(),
3280
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3661
+ createUnlocalizableLoader(
3662
+ options.isCacheRestore,
3663
+ options.returnUnlocalizedKeys
3664
+ )
3281
3665
  );
3282
3666
  case "xml":
3283
3667
  return composeLoaders(
@@ -3285,28 +3669,40 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3285
3669
  createXmlLoader(),
3286
3670
  createFlatLoader(),
3287
3671
  createSyncLoader(),
3288
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3672
+ createUnlocalizableLoader(
3673
+ options.isCacheRestore,
3674
+ options.returnUnlocalizedKeys
3675
+ )
3289
3676
  );
3290
3677
  case "srt":
3291
3678
  return composeLoaders(
3292
3679
  createTextFileLoader(bucketPathPattern),
3293
3680
  createSrtLoader(),
3294
3681
  createSyncLoader(),
3295
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3682
+ createUnlocalizableLoader(
3683
+ options.isCacheRestore,
3684
+ options.returnUnlocalizedKeys
3685
+ )
3296
3686
  );
3297
3687
  case "dato":
3298
3688
  return composeLoaders(
3299
3689
  createDatoLoader(bucketPathPattern),
3300
3690
  createSyncLoader(),
3301
3691
  createFlatLoader(),
3302
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3692
+ createUnlocalizableLoader(
3693
+ options.isCacheRestore,
3694
+ options.returnUnlocalizedKeys
3695
+ )
3303
3696
  );
3304
3697
  case "vtt":
3305
3698
  return composeLoaders(
3306
3699
  createTextFileLoader(bucketPathPattern),
3307
3700
  createVttLoader(),
3308
3701
  createSyncLoader(),
3309
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3702
+ createUnlocalizableLoader(
3703
+ options.isCacheRestore,
3704
+ options.returnUnlocalizedKeys
3705
+ )
3310
3706
  );
3311
3707
  case "php":
3312
3708
  return composeLoaders(
@@ -3314,7 +3710,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3314
3710
  createPhpLoader(),
3315
3711
  createSyncLoader(),
3316
3712
  createFlatLoader(),
3317
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3713
+ createUnlocalizableLoader(
3714
+ options.isCacheRestore,
3715
+ options.returnUnlocalizedKeys
3716
+ )
3318
3717
  );
3319
3718
  case "vue-json":
3320
3719
  return composeLoaders(
@@ -3322,7 +3721,10 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3322
3721
  createVueJsonLoader(),
3323
3722
  createSyncLoader(),
3324
3723
  createFlatLoader(),
3325
- createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
3724
+ createUnlocalizableLoader(
3725
+ options.isCacheRestore,
3726
+ options.returnUnlocalizedKeys
3727
+ )
3326
3728
  );
3327
3729
  }
3328
3730
  }
@@ -3345,23 +3747,6 @@ var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
3345
3747
  }));
3346
3748
  _appendToCache(rows);
3347
3749
  };
3348
- function getNormalizedCache() {
3349
- const rows = _loadCache();
3350
- if (!rows.length) {
3351
- return null;
3352
- }
3353
- const normalized = {};
3354
- for (const row of rows) {
3355
- if (!normalized[row.targetLocale]) {
3356
- normalized[row.targetLocale] = {};
3357
- }
3358
- normalized[row.targetLocale][row.key] = {
3359
- source: row.source,
3360
- result: row.processed
3361
- };
3362
- }
3363
- return normalized;
3364
- }
3365
3750
  function deleteCache() {
3366
3751
  const cacheFilePath = _getCacheFilePath();
3367
3752
  try {
@@ -3369,15 +3754,6 @@ function deleteCache() {
3369
3754
  } catch (e) {
3370
3755
  }
3371
3756
  }
3372
- function _loadCache() {
3373
- const cacheFilePath = _getCacheFilePath();
3374
- if (!fs11.default.existsSync(cacheFilePath)) {
3375
- return [];
3376
- }
3377
- const content = fs11.default.readFileSync(cacheFilePath, "utf-8");
3378
- const result = _parseJSONLines(content);
3379
- return result;
3380
- }
3381
3757
  function _appendToCache(rows) {
3382
3758
  const cacheFilePath = _getCacheFilePath();
3383
3759
  const lines = _buildJSONLines(rows);
@@ -3389,16 +3765,6 @@ function _getCacheFilePath() {
3389
3765
  function _buildJSONLines(rows) {
3390
3766
  return rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
3391
3767
  }
3392
- function _parseJSONLines(lines) {
3393
- return lines.split("\n").map(_tryParseJSON).filter((line) => line !== null);
3394
- }
3395
- function _tryParseJSON(line) {
3396
- try {
3397
- return JSON.parse(line);
3398
- } catch (e) {
3399
- return null;
3400
- }
3401
- }
3402
3768
 
3403
3769
  // src/cli/processor/lingo.ts
3404
3770
  var __sdk = require('@lingo.dev/_sdk');
@@ -3478,7 +3844,7 @@ function createBasicTranslator(model, systemPrompt) {
3478
3844
  ]
3479
3845
  });
3480
3846
  const result = JSON.parse(response.text);
3481
- return _optionalChain([result, 'optionalAccess', _144 => _144.data]) || {};
3847
+ return _optionalChain([result, 'optionalAccess', _152 => _152.data]) || {};
3482
3848
  };
3483
3849
  }
3484
3850
 
@@ -3496,7 +3862,7 @@ function createProcessor(provider, params) {
3496
3862
  }
3497
3863
  }
3498
3864
  function getPureModelProvider(provider) {
3499
- switch (_optionalChain([provider, 'optionalAccess', _145 => _145.id])) {
3865
+ switch (_optionalChain([provider, 'optionalAccess', _153 => _153.id])) {
3500
3866
  case "openai":
3501
3867
  if (!process.env.OPENAI_API_KEY) {
3502
3868
  throw new Error("OPENAI_API_KEY is not set.");
@@ -3513,7 +3879,7 @@ function getPureModelProvider(provider) {
3513
3879
  apiKey: process.env.ANTHROPIC_API_KEY
3514
3880
  })(provider.model);
3515
3881
  default:
3516
- throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _146 => _146.id])}`);
3882
+ throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _154 => _154.id])}`);
3517
3883
  }
3518
3884
  }
3519
3885
 
@@ -3567,7 +3933,6 @@ async function trackEvent(distinctId, event, properties) {
3567
3933
  // src/cli/utils/delta.ts
3568
3934
 
3569
3935
 
3570
- var _objecthash = require('object-hash');
3571
3936
 
3572
3937
  // src/cli/utils/fs.ts
3573
3938
 
@@ -3618,11 +3983,11 @@ function createDeltaProcessor(fileKey) {
3618
3983
  let added = _lodash2.default.difference(Object.keys(params.sourceData), Object.keys(params.targetData));
3619
3984
  let removed = _lodash2.default.difference(Object.keys(params.targetData), Object.keys(params.sourceData));
3620
3985
  const updated = _lodash2.default.filter(Object.keys(params.sourceData), (key) => {
3621
- 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];
3622
3987
  });
3623
3988
  const renamed = [];
3624
3989
  for (const addedKey of added) {
3625
- const addedHash = _objecthash.MD5.call(void 0, params.sourceData[addedKey]);
3990
+ const addedHash = md5(params.sourceData[addedKey]);
3626
3991
  for (const removedKey of removed) {
3627
3992
  if (params.checksums[removedKey] === addedHash) {
3628
3993
  renamed.push([removedKey, addedKey]);
@@ -3655,18 +4020,18 @@ function createDeltaProcessor(fileKey) {
3655
4020
  writeFile(lockfilePath, lockfileYaml);
3656
4021
  },
3657
4022
  async loadChecksums() {
3658
- const id = _objecthash.MD5.call(void 0, fileKey);
4023
+ const id = md5(fileKey);
3659
4024
  const lockfileData = await this.loadLock();
3660
4025
  return lockfileData.checksums[id] || {};
3661
4026
  },
3662
4027
  async saveChecksums(checksums) {
3663
- const id = _objecthash.MD5.call(void 0, fileKey);
4028
+ const id = md5(fileKey);
3664
4029
  const lockfileData = await this.loadLock();
3665
4030
  lockfileData.checksums[id] = checksums;
3666
4031
  await this.saveLock(lockfileData);
3667
4032
  },
3668
4033
  async createChecksums(sourceData) {
3669
- const checksums = _lodash2.default.mapValues(sourceData, (value) => _objecthash.MD5.call(void 0, value));
4034
+ const checksums = _lodash2.default.mapValues(sourceData, (value) => md5(value));
3670
4035
  return checksums;
3671
4036
  }
3672
4037
  };
@@ -3674,7 +4039,15 @@ function createDeltaProcessor(fileKey) {
3674
4039
 
3675
4040
  // src/cli/cmd/i18n.ts
3676
4041
 
3677
- 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(
3678
4051
  "--key <key>",
3679
4052
  "Key to process. Process only a specific translation key, useful for debugging or updating a single entry"
3680
4053
  ).option(
@@ -3683,7 +4056,25 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3683
4056
  ).option(
3684
4057
  "--frozen",
3685
4058
  `Run in read-only mode - fails if any translations need updating, useful for CI/CD pipelines to detect missing translations`
3686
- ).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) {
3687
4078
  updateGitignore();
3688
4079
  const ora = _ora2.default.call(void 0, );
3689
4080
  const flags = parseFlags(options);
@@ -3715,19 +4106,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3715
4106
  flags
3716
4107
  });
3717
4108
  let buckets = getBuckets(i18nConfig);
3718
- if (_optionalChain([flags, 'access', _147 => _147.bucket, 'optionalAccess', _148 => _148.length])) {
3719
- 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
+ );
3720
4113
  }
3721
4114
  ora.succeed("Buckets retrieved");
3722
- if (_optionalChain([flags, 'access', _149 => _149.file, 'optionalAccess', _150 => _150.length])) {
4115
+ if (_optionalChain([flags, 'access', _157 => _157.file, 'optionalAccess', _158 => _158.length])) {
3723
4116
  buckets = buckets.map((bucket) => {
3724
4117
  const paths = bucket.paths.filter(
3725
- (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)]))
3726
4119
  );
3727
4120
  return { ...bucket, paths };
3728
4121
  }).filter((bucket) => bucket.paths.length > 0);
3729
4122
  if (buckets.length === 0) {
3730
- 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
+ );
3731
4126
  process.exit(1);
3732
4127
  } else {
3733
4128
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
@@ -3739,7 +4134,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3739
4134
  });
3740
4135
  }
3741
4136
  }
3742
- 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;
3743
4138
  ora.start("Setting up localization cache...");
3744
4139
  const checkLockfileProcessor = createDeltaProcessor("");
3745
4140
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -3747,7 +4142,10 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3747
4142
  ora.start("Creating i18n.lock...");
3748
4143
  for (const bucket of buckets) {
3749
4144
  for (const bucketPath of bucket.paths) {
3750
- 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
+ );
3751
4149
  const bucketLoader = createBucketLoader(
3752
4150
  bucket.type,
3753
4151
  bucketPath.pathPattern,
@@ -3760,7 +4158,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3760
4158
  );
3761
4159
  bucketLoader.setDefaultLocale(sourceLocale);
3762
4160
  await bucketLoader.init();
3763
- const sourceData = await bucketLoader.pull(i18nConfig.locale.source);
4161
+ const sourceData = await bucketLoader.pull(
4162
+ i18nConfig.locale.source
4163
+ );
3764
4164
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3765
4165
  const checksums = await deltaProcessor.createChecksums(sourceData);
3766
4166
  await deltaProcessor.saveChecksums(checksums);
@@ -3776,9 +4176,15 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3776
4176
  }
3777
4177
  ora.start("Validating localization state...");
3778
4178
  for (const bucketPath of bucket.paths) {
3779
- 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
+ );
3780
4183
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3781
- 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
+ );
3782
4188
  const sourceContent = tryReadFile(sourcePath, null);
3783
4189
  const sourceData = JSON.parse(sourceContent || "{}");
3784
4190
  const sourceFlattenedData = _flat.flatten.call(void 0, sourceData, {
@@ -3788,8 +4194,14 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3788
4194
  }
3789
4195
  });
3790
4196
  for (const _targetLocale of targetLocales) {
3791
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
3792
- 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
+ );
3793
4205
  const targetContent = tryReadFile(targetPath, null);
3794
4206
  const targetData = JSON.parse(targetContent || "{}");
3795
4207
  const targetFlattenedData = _flat.flatten.call(void 0, targetData, {
@@ -3817,68 +4229,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3817
4229
  return decodeURIComponent(key);
3818
4230
  }
3819
4231
  });
3820
- await writeFile(targetPath, JSON.stringify(updatedTargetData, null, 2));
3821
- }
3822
- }
3823
- ora.succeed("Localization state check completed");
3824
- }
3825
- const cache = getNormalizedCache();
3826
- if (cache) {
3827
- console.log();
3828
- ora.succeed(`Cache loaded. Attempting recovery...`);
3829
- const cacheOra = _ora2.default.call(void 0, { indent: 2 });
3830
- for (const bucket of buckets) {
3831
- cacheOra.info(`Processing bucket: ${bucket.type}`);
3832
- for (const bucketPath of bucket.paths) {
3833
- const bucketOra = _ora2.default.call(void 0, { indent: 4 });
3834
- bucketOra.info(`Processing path: ${bucketPath.pathPattern}`);
3835
- const sourceLocale = __spec.resolveOverriddenLocale.call(void 0, i18nConfig.locale.source, bucketPath.delimiter);
3836
- const bucketLoader = createBucketLoader(
3837
- bucket.type,
3838
- bucketPath.pathPattern,
3839
- {
3840
- isCacheRestore: true,
3841
- defaultLocale: sourceLocale,
3842
- injectLocale: bucket.injectLocale
3843
- },
3844
- bucket.lockedKeys
4232
+ await writeFile(
4233
+ targetPath,
4234
+ JSON.stringify(updatedTargetData, null, 2)
3845
4235
  );
3846
- bucketLoader.setDefaultLocale(sourceLocale);
3847
- await bucketLoader.init();
3848
- const sourceData = await bucketLoader.pull(sourceLocale);
3849
- const cachedSourceData = {};
3850
- for (const targetLocale in cache) {
3851
- const targetData = await bucketLoader.pull(targetLocale);
3852
- for (const key in cache[targetLocale]) {
3853
- const { source, result } = cache[targetLocale][key];
3854
- if (sourceData[key] === source && targetData[key] !== result) {
3855
- targetData[key] = result;
3856
- cachedSourceData[key] = source;
3857
- }
3858
- }
3859
- await bucketLoader.push(targetLocale, targetData);
3860
- const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3861
- const checksums = await deltaProcessor.createChecksums(cachedSourceData);
3862
- await deltaProcessor.saveChecksums(checksums);
3863
- bucketOra.succeed(
3864
- `[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
3865
- );
3866
- }
3867
4236
  }
3868
4237
  }
3869
- deleteCache();
3870
- if (flags.verbose) {
3871
- cacheOra.info("Cache file deleted.");
3872
- }
3873
- } else if (flags.verbose) {
3874
- ora.info("Cache file not found. Skipping recovery.");
4238
+ ora.succeed("Localization state check completed");
3875
4239
  }
3876
4240
  if (flags.frozen) {
3877
4241
  ora.start("Checking for lockfile updates...");
3878
4242
  let requiresUpdate = null;
3879
4243
  bucketLoop: for (const bucket of buckets) {
3880
4244
  for (const bucketPath of bucket.paths) {
3881
- 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
+ );
3882
4249
  const bucketLoader = createBucketLoader(
3883
4250
  bucket.type,
3884
4251
  bucketPath.pathPattern,
@@ -3892,9 +4259,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3892
4259
  );
3893
4260
  bucketLoader.setDefaultLocale(sourceLocale);
3894
4261
  await bucketLoader.init();
3895
- const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(
3896
- i18nConfig.locale.source
3897
- );
4262
+ const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(i18nConfig.locale.source);
3898
4263
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
3899
4264
  const sourceChecksums = await deltaProcessor.createChecksums(sourceData);
3900
4265
  const savedChecksums = await deltaProcessor.loadChecksums();
@@ -3907,11 +4272,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3907
4272
  break bucketLoop;
3908
4273
  }
3909
4274
  for (const _targetLocale of targetLocales) {
3910
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
4275
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
4276
+ _targetLocale,
4277
+ bucketPath.delimiter
4278
+ );
3911
4279
  const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
3912
- const missingKeys = _lodash2.default.difference(Object.keys(sourceData), Object.keys(targetData));
3913
- const extraKeys = _lodash2.default.difference(Object.keys(targetData), Object.keys(sourceData));
3914
- 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
+ );
3915
4292
  if (missingKeys.length > 0) {
3916
4293
  requiresUpdate = "missing";
3917
4294
  break bucketLoop;
@@ -3934,7 +4311,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3934
4311
  extra: "Target file has extra translations not present in the source file.",
3935
4312
  unlocalizable: "Unlocalizable data (such as booleans, dates, URLs, etc.) do not match."
3936
4313
  }[requiresUpdate];
3937
- 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
+ );
3938
4317
  ora.fail(` Details: ${message}`);
3939
4318
  process.exit(1);
3940
4319
  } else {
@@ -3946,8 +4325,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3946
4325
  console.log();
3947
4326
  ora.info(`Processing bucket: ${bucket.type}`);
3948
4327
  for (const bucketPath of bucket.paths) {
3949
- const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketPath.pathPattern}`);
3950
- 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
+ );
3951
4335
  const bucketLoader = createBucketLoader(
3952
4336
  bucket.type,
3953
4337
  bucketPath.pathPattern,
@@ -3962,21 +4346,33 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3962
4346
  await bucketLoader.init();
3963
4347
  let sourceData = await bucketLoader.pull(sourceLocale);
3964
4348
  for (const _targetLocale of targetLocales) {
3965
- const targetLocale = __spec.resolveOverriddenLocale.call(void 0, _targetLocale, bucketPath.delimiter);
4349
+ const targetLocale = __spec.resolveOverriddenLocale.call(void 0,
4350
+ _targetLocale,
4351
+ bucketPath.delimiter
4352
+ );
3966
4353
  try {
3967
- bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
4354
+ bucketOra.start(
4355
+ `[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`
4356
+ );
3968
4357
  sourceData = await bucketLoader.pull(sourceLocale);
3969
4358
  const targetData = await bucketLoader.pull(targetLocale);
3970
- const deltaProcessor2 = createDeltaProcessor(bucketPath.pathPattern);
4359
+ const deltaProcessor2 = createDeltaProcessor(
4360
+ bucketPath.pathPattern
4361
+ );
3971
4362
  const checksums2 = await deltaProcessor2.loadChecksums();
3972
4363
  const delta = await deltaProcessor2.calculateDelta({
3973
4364
  sourceData,
3974
4365
  targetData,
3975
4366
  checksums: checksums2
3976
4367
  });
3977
- 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();
3978
4371
  if (flags.key) {
3979
- processableData = _lodash2.default.pickBy(processableData, (_25, key) => key === flags.key);
4372
+ processableData = _lodash2.default.pickBy(
4373
+ processableData,
4374
+ (_24, key) => key === flags.key
4375
+ );
3980
4376
  }
3981
4377
  if (flags.verbose) {
3982
4378
  bucketOra.info(JSON.stringify(processableData, null, 2));
@@ -3988,7 +4384,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3988
4384
  apiKey: settings.auth.apiKey,
3989
4385
  apiUrl: settings.auth.apiUrl
3990
4386
  });
3991
- processPayload = withExponentialBackoff(processPayload, 3, 1e3);
4387
+ processPayload = withExponentialBackoff(
4388
+ processPayload,
4389
+ 3,
4390
+ 1e3
4391
+ );
3992
4392
  const processedTargetData = await processPayload(
3993
4393
  {
3994
4394
  sourceLocale,
@@ -4013,7 +4413,12 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4013
4413
  if (flags.verbose) {
4014
4414
  bucketOra.info(JSON.stringify(processedTargetData, null, 2));
4015
4415
  }
4016
- let finalTargetData = _lodash2.default.merge({}, sourceData, targetData, processedTargetData);
4416
+ let finalTargetData = _lodash2.default.merge(
4417
+ {},
4418
+ sourceData,
4419
+ targetData,
4420
+ processedTargetData
4421
+ );
4017
4422
  if (flags.interactive) {
4018
4423
  bucketOra.stop();
4019
4424
  const reviewedData = await reviewChanges({
@@ -4025,17 +4430,25 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4025
4430
  force: flags.force
4026
4431
  });
4027
4432
  finalTargetData = reviewedData;
4028
- bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
4433
+ bucketOra.start(
4434
+ `Applying changes to ${bucketPath} (${targetLocale})`
4435
+ );
4029
4436
  }
4030
4437
  const finalDiffSize = _lodash2.default.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
4031
4438
  await bucketLoader.push(targetLocale, finalTargetData);
4032
4439
  if (finalDiffSize > 0 || flags.force) {
4033
- bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed`);
4440
+ bucketOra.succeed(
4441
+ `[${sourceLocale} -> ${targetLocale}] Localization completed`
4442
+ );
4034
4443
  } else {
4035
- bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed (no changes).`);
4444
+ bucketOra.succeed(
4445
+ `[${sourceLocale} -> ${targetLocale}] Localization completed (no changes).`
4446
+ );
4036
4447
  }
4037
4448
  } catch (_error) {
4038
- const error = new Error(`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`);
4449
+ const error = new Error(
4450
+ `[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`
4451
+ );
4039
4452
  if (flags.strict) {
4040
4453
  throw error;
4041
4454
  } else {
@@ -4049,7 +4462,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4049
4462
  await deltaProcessor.saveChecksums(checksums);
4050
4463
  }
4051
4464
  } catch (_error) {
4052
- 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
+ );
4053
4468
  if (flags.strict) {
4054
4469
  throw error;
4055
4470
  } else {
@@ -4127,12 +4542,14 @@ function validateParams(i18nConfig, flags) {
4127
4542
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
4128
4543
  docUrl: "bucketNotFound"
4129
4544
  });
4130
- } 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))])) {
4131
4546
  throw new CLIError({
4132
4547
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
4133
4548
  docUrl: "localeTargetNotFound"
4134
4549
  });
4135
- } 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
+ )])) {
4136
4553
  throw new CLIError({
4137
4554
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
4138
4555
  docUrl: "bucketNotFound"
@@ -4164,8 +4581,10 @@ ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.default.yellow(args.targetL
4164
4581
  if (line.startsWith("@")) return _chalk2.default.cyan(line);
4165
4582
  return line;
4166
4583
  }).join("\n");
4167
- console.log(`
4168
- 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
+ );
4169
4588
  console.log(coloredDiff);
4170
4589
  const { action } = await _inquirer2.default.prompt([
4171
4590
  {
@@ -4201,9 +4620,19 @@ Reviewing changes for ${_chalk2.default.blue(args.pathPattern)} (${_chalk2.defau
4201
4620
  console.log(`
4202
4621
  Editing value for: ${_chalk2.default.cyan(key)}`);
4203
4622
  console.log(_chalk2.default.gray("Source text:"), _chalk2.default.blue(args.sourceData[key]));
4204
- console.log(_chalk2.default.gray("Current value:"), _chalk2.default.red(args.currentData[key] || "(empty)"));
4205
- console.log(_chalk2.default.gray("Suggested value:"), _chalk2.default.green(args.proposedData[key]));
4206
- 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
+ );
4207
4636
  console.log(_chalk2.default.gray("------------"));
4208
4637
  try {
4209
4638
  const editorContent = [
@@ -4224,11 +4653,15 @@ Editing value for: ${_chalk2.default.cyan(key)}`);
4224
4653
  if (customValue) {
4225
4654
  customData[key] = customValue;
4226
4655
  } else {
4227
- 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
+ );
4228
4659
  customData[key] = args.currentData[key] || args.proposedData[key];
4229
4660
  }
4230
4661
  } catch (error) {
4231
- 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
+ );
4232
4665
  customData[key] = args.proposedData[key];
4233
4666
  }
4234
4667
  }
@@ -4442,7 +4875,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
4442
4875
  var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
4443
4876
 
4444
4877
 
4445
- 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) => {
4446
4879
  const apiKey = program.args[0];
4447
4880
  const settings = getSettings(apiKey);
4448
4881
  if (!settings.auth.apiKey) {
@@ -4565,7 +4998,7 @@ var InBranchFlow = class extends IntegrationFlow {
4565
4998
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
4566
4999
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
4567
5000
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
4568
- _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()]);
4569
5002
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
4570
5003
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
4571
5004
  if (!processOwnCommits) {
@@ -4590,7 +5023,7 @@ var InBranchFlow = class extends IntegrationFlow {
4590
5023
  // ../../action/src/flows/pull-request.ts
4591
5024
  var PullRequestFlow = class extends InBranchFlow {
4592
5025
  async preRun() {
4593
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _165 => _165()]);
5026
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _173 => _173()]);
4594
5027
  if (!canContinue) {
4595
5028
  return false;
4596
5029
  }
@@ -4808,10 +5241,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
4808
5241
  repo_slug: this.platformConfig.repositoryName,
4809
5242
  state: "OPEN"
4810
5243
  }).then(({ data: { values } }) => {
4811
- return _optionalChain([values, 'optionalAccess', _166 => _166.find, 'call', _167 => _167(
4812
- ({ 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
4813
5246
  )]);
4814
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _172 => _172.id]));
5247
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _180 => _180.id]));
4815
5248
  }
4816
5249
  async closePullRequest({ pullRequestNumber }) {
4817
5250
  await this.bb.repositories.declinePullRequest({
@@ -4897,7 +5330,7 @@ var GitHubPlatformKit = class extends PlatformKit {
4897
5330
  repo: this.platformConfig.repositoryName,
4898
5331
  base: this.platformConfig.baseBranchName,
4899
5332
  state: "open"
4900
- }).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]));
4901
5334
  }
4902
5335
  async closePullRequest({ pullRequestNumber }) {
4903
5336
  await this.octokit.rest.pulls.update({
@@ -5010,7 +5443,7 @@ var GitlabPlatformKit = class extends PlatformKit {
5010
5443
  sourceBranch: branch,
5011
5444
  state: "opened"
5012
5445
  });
5013
- return _optionalChain([mergeRequests, 'access', _174 => _174[0], 'optionalAccess', _175 => _175.iid]);
5446
+ return _optionalChain([mergeRequests, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.iid]);
5014
5447
  }
5015
5448
  async closePullRequest({ pullRequestNumber }) {
5016
5449
  await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
@@ -5063,7 +5496,7 @@ async function main() {
5063
5496
  const { isPullRequestMode } = platformKit.config;
5064
5497
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
5065
5498
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
5066
- 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()]);
5067
5500
  if (canRun === false) {
5068
5501
  return;
5069
5502
  }
@@ -5071,7 +5504,7 @@ async function main() {
5071
5504
  if (!hasChanges) {
5072
5505
  return;
5073
5506
  }
5074
- await _optionalChain([flow, 'access', _178 => _178.postRun, 'optionalCall', _179 => _179()]);
5507
+ await _optionalChain([flow, 'access', _186 => _186.postRun, 'optionalCall', _187 => _187()]);
5075
5508
  }
5076
5509
 
5077
5510
  // src/cli/cmd/ci.ts
@@ -5093,7 +5526,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5093
5526
  }
5094
5527
  const env = {
5095
5528
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
5096
- 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",
5097
5530
  ...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
5098
5531
  ...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
5099
5532
  ...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
@@ -5144,13 +5577,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5144
5577
  flags
5145
5578
  });
5146
5579
  let buckets = getBuckets(i18nConfig);
5147
- if (_optionalChain([flags, 'access', _183 => _183.bucket, 'optionalAccess', _184 => _184.length])) {
5580
+ if (_optionalChain([flags, 'access', _191 => _191.bucket, 'optionalAccess', _192 => _192.length])) {
5148
5581
  buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
5149
5582
  }
5150
5583
  ora.succeed("Buckets retrieved");
5151
- if (_optionalChain([flags, 'access', _185 => _185.file, 'optionalAccess', _186 => _186.length])) {
5584
+ if (_optionalChain([flags, 'access', _193 => _193.file, 'optionalAccess', _194 => _194.length])) {
5152
5585
  buckets = buckets.map((bucket) => {
5153
- 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)])));
5154
5587
  return { ...bucket, paths };
5155
5588
  }).filter((bucket) => bucket.paths.length > 0);
5156
5589
  if (buckets.length === 0) {
@@ -5166,7 +5599,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5166
5599
  });
5167
5600
  }
5168
5601
  }
5169
- 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;
5170
5603
  let totalSourceKeyCount = 0;
5171
5604
  let uniqueKeysToTranslate = 0;
5172
5605
  let totalExistingTranslations = 0;
@@ -5507,12 +5940,12 @@ function validateParams2(i18nConfig, flags) {
5507
5940
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
5508
5941
  docUrl: "bucketNotFound"
5509
5942
  });
5510
- } 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))])) {
5511
5944
  throw new CLIError({
5512
5945
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
5513
5946
  docUrl: "localeTargetNotFound"
5514
5947
  });
5515
- } 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])])) {
5516
5949
  throw new CLIError({
5517
5950
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
5518
5951
  docUrl: "bucketNotFound"
@@ -5523,7 +5956,7 @@ function validateParams2(i18nConfig, flags) {
5523
5956
  // package.json
5524
5957
  var package_default = {
5525
5958
  name: "lingo.dev",
5526
- version: "0.86.0",
5959
+ version: "0.87.0",
5527
5960
  description: "Lingo.dev CLI",
5528
5961
  private: false,
5529
5962
  publishConfig: {
@@ -5597,6 +6030,7 @@ var package_default = {
5597
6030
  "csv-parse": "^5.6.0",
5598
6031
  "csv-stringify": "^6.5.2",
5599
6032
  "date-fns": "^4.1.0",
6033
+ dedent: "^1.5.3",
5600
6034
  diff: "^7.0.0",
5601
6035
  dotenv: "^16.4.7",
5602
6036
  express: "^4.21.2",
@@ -5616,6 +6050,9 @@ var package_default = {
5616
6050
  jsonrepair: "^3.11.2",
5617
6051
  lodash: "^4.17.21",
5618
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",
5619
6056
  "node-webvtt": "^1.9.4",
5620
6057
  "object-hash": "^3.0.0",
5621
6058
  octokit: "^4.0.2",
@@ -5626,14 +6063,18 @@ var package_default = {
5626
6063
  plist: "^3.1.0",
5627
6064
  "posthog-node": "^4.11.2",
5628
6065
  prettier: "^3.4.2",
6066
+ "rehype-stringify": "^10.0.1",
6067
+ "remark-disable-tokenizers": "^1.1.1",
5629
6068
  "remark-frontmatter": "^5.0.0",
5630
6069
  "remark-gfm": "^4.0.1",
5631
6070
  "remark-mdx": "^3.1.0",
5632
6071
  "remark-mdx-frontmatter": "^5.1.0",
5633
6072
  "remark-parse": "^11.0.0",
6073
+ "remark-rehype": "^11.1.2",
5634
6074
  "remark-stringify": "^11.0.0",
5635
6075
  "srt-parser-2": "^1.2.3",
5636
6076
  unified: "^11.0.5",
6077
+ "unist-util-visit": "^5.0.0",
5637
6078
  vfile: "^6.0.3",
5638
6079
  xliff: "^6.2.1",
5639
6080
  xml2js: "^0.6.2",