lingo.dev 0.85.7 → 0.86.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
@@ -1641,25 +1641,41 @@ ${content}`;
1641
1641
 
1642
1642
  var _unified = require('unified');
1643
1643
  var _remarkparse = require('remark-parse'); var _remarkparse2 = _interopRequireDefault(_remarkparse);
1644
- var _remarkmdx = require('remark-mdx'); var _remarkmdx2 = _interopRequireDefault(_remarkmdx);
1645
1644
  var _remarkfrontmatter = require('remark-frontmatter'); var _remarkfrontmatter2 = _interopRequireDefault(_remarkfrontmatter);
1646
1645
  var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
1647
1646
  var _remarkstringify = require('remark-stringify'); var _remarkstringify2 = _interopRequireDefault(_remarkstringify);
1648
- var _remarkmdxfrontmatter = require('remark-mdx-frontmatter'); var _remarkmdxfrontmatter2 = _interopRequireDefault(_remarkmdxfrontmatter);
1649
1647
  var _vfile = require('vfile');
1650
- var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
1651
- var serializer = _unified.unified.call(void 0, ).use(_remarkstringify2.default).use(_remarkmdx2.default).use(_remarkfrontmatter2.default, ["yaml"]).use(_remarkmdxfrontmatter2.default).use(_remarkgfm2.default);
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);
1652
1650
  function createMdxFormatLoader() {
1651
+ const skippedTypes = ["code", "inlineCode"];
1653
1652
  return createLoader({
1654
1653
  async pull(locale, input2) {
1655
1654
  const file = new (0, _vfile.VFile)(input2);
1656
1655
  const ast = parser.parse(file);
1657
- return JSON.parse(JSON.stringify(ast));
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;
1658
1665
  },
1659
- async push(locale, data) {
1660
- const ast = data;
1661
- const content = String(serializer.stringify(ast));
1662
- return content;
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));
1663
1679
  }
1664
1680
  });
1665
1681
  }
@@ -1688,6 +1704,28 @@ function createMdxStructureLoader() {
1688
1704
  }
1689
1705
  });
1690
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
+ }
1691
1729
 
1692
1730
  // src/cli/loaders/properties.ts
1693
1731
  function createPropertiesLoader() {
@@ -5485,7 +5523,7 @@ function validateParams2(i18nConfig, flags) {
5485
5523
  // package.json
5486
5524
  var package_default = {
5487
5525
  name: "lingo.dev",
5488
- version: "0.85.7",
5526
+ version: "0.86.0",
5489
5527
  description: "Lingo.dev CLI",
5490
5528
  private: false,
5491
5529
  publishConfig: {