lingo.dev 0.117.20 → 0.117.22
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/{chunk-HTMTB46P.cjs → chunk-EHIR4A2G.cjs} +2 -2
- package/build/{chunk-HTMTB46P.cjs.map → chunk-EHIR4A2G.cjs.map} +1 -1
- package/build/cli.cjs +213 -158
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +71 -16
- package/build/cli.mjs.map +1 -1
- package/build/compiler.cjs +1 -1
- package/build/locale-codes.cjs +1 -1
- package/build/react/client.cjs +1 -1
- package/build/react/react-router.cjs +1 -1
- package/build/react/rsc.cjs +1 -1
- package/build/react.cjs +1 -1
- package/build/sdk.cjs +1 -1
- package/build/spec.cjs +1 -1
- package/package.json +4 -4
package/build/cli.mjs
CHANGED
|
@@ -1596,8 +1596,10 @@ function createLoader(lDefinition) {
|
|
|
1596
1596
|
const state = {
|
|
1597
1597
|
defaultLocale: void 0,
|
|
1598
1598
|
originalInput: void 0,
|
|
1599
|
-
pullInput
|
|
1600
|
-
|
|
1599
|
+
// Store pullInput and pullOutput per-locale to avoid race conditions
|
|
1600
|
+
// when multiple locales are processed concurrently
|
|
1601
|
+
pullInputByLocale: /* @__PURE__ */ new Map(),
|
|
1602
|
+
pullOutputByLocale: /* @__PURE__ */ new Map(),
|
|
1601
1603
|
initCtx: void 0
|
|
1602
1604
|
};
|
|
1603
1605
|
return {
|
|
@@ -1628,7 +1630,7 @@ function createLoader(lDefinition) {
|
|
|
1628
1630
|
if (locale === state.defaultLocale) {
|
|
1629
1631
|
state.originalInput = input2 || null;
|
|
1630
1632
|
}
|
|
1631
|
-
state.
|
|
1633
|
+
state.pullInputByLocale.set(locale, input2 || null);
|
|
1632
1634
|
const result = await lDefinition.pull(
|
|
1633
1635
|
locale,
|
|
1634
1636
|
input2,
|
|
@@ -1636,7 +1638,7 @@ function createLoader(lDefinition) {
|
|
|
1636
1638
|
state.defaultLocale,
|
|
1637
1639
|
state.originalInput
|
|
1638
1640
|
);
|
|
1639
|
-
state.
|
|
1641
|
+
state.pullOutputByLocale.set(locale, result);
|
|
1640
1642
|
return result;
|
|
1641
1643
|
},
|
|
1642
1644
|
async push(locale, data) {
|
|
@@ -1646,13 +1648,15 @@ function createLoader(lDefinition) {
|
|
|
1646
1648
|
if (state.originalInput === void 0) {
|
|
1647
1649
|
throw new Error("Cannot push data without pulling first");
|
|
1648
1650
|
}
|
|
1651
|
+
const pullInput = state.pullInputByLocale.get(locale) ?? state.pullInputByLocale.get(state.defaultLocale) ?? null;
|
|
1652
|
+
const pullOutput = state.pullOutputByLocale.get(locale) ?? state.pullOutputByLocale.get(state.defaultLocale) ?? null;
|
|
1649
1653
|
const pushResult = await lDefinition.push(
|
|
1650
1654
|
locale,
|
|
1651
1655
|
data,
|
|
1652
1656
|
state.originalInput,
|
|
1653
1657
|
state.defaultLocale,
|
|
1654
|
-
|
|
1655
|
-
|
|
1658
|
+
pullInput,
|
|
1659
|
+
pullOutput
|
|
1656
1660
|
);
|
|
1657
1661
|
return pushResult;
|
|
1658
1662
|
}
|
|
@@ -1710,6 +1714,7 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1710
1714
|
return {};
|
|
1711
1715
|
}
|
|
1712
1716
|
const contextStack = [];
|
|
1717
|
+
let arrayObjectCount = {};
|
|
1713
1718
|
for (let i = 0; i < lines.length; i++) {
|
|
1714
1719
|
const line = lines[i];
|
|
1715
1720
|
const trimmedLine = line.trim();
|
|
@@ -1721,11 +1726,11 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1721
1726
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1722
1727
|
if (keyMatch) {
|
|
1723
1728
|
const key = keyMatch[1];
|
|
1724
|
-
const path19 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1729
|
+
const path19 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1725
1730
|
keyInfo = { key, path: path19 };
|
|
1726
1731
|
}
|
|
1727
1732
|
} else {
|
|
1728
|
-
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack);
|
|
1733
|
+
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack, arrayObjectCount);
|
|
1729
1734
|
}
|
|
1730
1735
|
if (keyInfo && keyInfo.key) {
|
|
1731
1736
|
setCommentAtPath(comments, keyInfo.path, keyInfo.key, commentData.hint);
|
|
@@ -1733,7 +1738,7 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1733
1738
|
i = commentData.endIndex;
|
|
1734
1739
|
continue;
|
|
1735
1740
|
}
|
|
1736
|
-
updateContext(contextStack, line, result);
|
|
1741
|
+
updateContext(contextStack, line, result, arrayObjectCount);
|
|
1737
1742
|
}
|
|
1738
1743
|
return comments;
|
|
1739
1744
|
}
|
|
@@ -1797,34 +1802,84 @@ function extractBlockComment(lines, startIndex) {
|
|
|
1797
1802
|
endIndex
|
|
1798
1803
|
};
|
|
1799
1804
|
}
|
|
1800
|
-
function findAssociatedKey(lines, commentLineIndex, contextStack) {
|
|
1805
|
+
function findAssociatedKey(lines, commentLineIndex, contextStack, arrayObjectCount) {
|
|
1801
1806
|
for (let i = commentLineIndex + 1; i < lines.length; i++) {
|
|
1802
1807
|
const line = lines[i].trim();
|
|
1803
|
-
if (!line || line.startsWith("//") || line.startsWith("/*")
|
|
1808
|
+
if (!line || line.startsWith("//") || line.startsWith("/*")) {
|
|
1809
|
+
continue;
|
|
1810
|
+
}
|
|
1811
|
+
if (line === "{" && contextStack.length > 0) {
|
|
1812
|
+
const parent = contextStack[contextStack.length - 1];
|
|
1813
|
+
if (parent.isArray) {
|
|
1814
|
+
const depth = contextStack.length - 1;
|
|
1815
|
+
const arrayIndex = arrayObjectCount[depth] || 0;
|
|
1816
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
1817
|
+
const innerLine = lines[j].trim();
|
|
1818
|
+
if (!innerLine || innerLine.startsWith("//") || innerLine.startsWith("/*")) continue;
|
|
1819
|
+
const keyMatch2 = innerLine.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1820
|
+
if (keyMatch2) {
|
|
1821
|
+
const key = keyMatch2[1];
|
|
1822
|
+
const path19 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1823
|
+
path19.push(String(arrayIndex));
|
|
1824
|
+
return { key, path: path19 };
|
|
1825
|
+
}
|
|
1826
|
+
if (innerLine === "}") break;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
if (line === "{" || line === "}") {
|
|
1804
1831
|
continue;
|
|
1805
1832
|
}
|
|
1806
1833
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1807
1834
|
if (keyMatch) {
|
|
1808
1835
|
const key = keyMatch[1];
|
|
1809
|
-
const path19 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1836
|
+
const path19 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1810
1837
|
return { key, path: path19 };
|
|
1811
1838
|
}
|
|
1812
1839
|
}
|
|
1813
1840
|
return { key: null, path: [] };
|
|
1814
1841
|
}
|
|
1815
|
-
function updateContext(contextStack, line, parsedJson) {
|
|
1842
|
+
function updateContext(contextStack, line, parsedJson, arrayObjectCount) {
|
|
1843
|
+
const trimmed = line.trim();
|
|
1844
|
+
const arrayMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:\s*\[/);
|
|
1845
|
+
if (arrayMatch) {
|
|
1846
|
+
const depth = contextStack.length;
|
|
1847
|
+
arrayObjectCount[depth] = 0;
|
|
1848
|
+
contextStack.push({ key: arrayMatch[1], isArray: true });
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1816
1851
|
const openBraces = (line.match(/\{/g) || []).length;
|
|
1817
1852
|
const closeBraces = (line.match(/\}/g) || []).length;
|
|
1818
1853
|
if (openBraces > closeBraces) {
|
|
1819
1854
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:\s*\{/);
|
|
1820
1855
|
if (keyMatch) {
|
|
1821
1856
|
contextStack.push({ key: keyMatch[1], isArray: false });
|
|
1857
|
+
} else if (trimmed === "{" && contextStack.length > 0) {
|
|
1858
|
+
const parent = contextStack[contextStack.length - 1];
|
|
1859
|
+
if (parent.isArray) {
|
|
1860
|
+
const depth = contextStack.length - 1;
|
|
1861
|
+
const arrayIndex = arrayObjectCount[depth] || 0;
|
|
1862
|
+
contextStack.push({ key: "", isArray: false, arrayIndex });
|
|
1863
|
+
arrayObjectCount[depth]++;
|
|
1864
|
+
}
|
|
1822
1865
|
}
|
|
1823
|
-
}
|
|
1866
|
+
}
|
|
1867
|
+
const openBrackets = (line.match(/\[/g) || []).length;
|
|
1868
|
+
const closeBrackets = (line.match(/\]/g) || []).length;
|
|
1869
|
+
if (closeBraces > openBraces) {
|
|
1824
1870
|
for (let i = 0; i < closeBraces - openBraces; i++) {
|
|
1825
1871
|
contextStack.pop();
|
|
1826
1872
|
}
|
|
1827
1873
|
}
|
|
1874
|
+
if (closeBrackets > openBrackets) {
|
|
1875
|
+
for (let i = 0; i < closeBrackets - openBrackets; i++) {
|
|
1876
|
+
const popped = contextStack.pop();
|
|
1877
|
+
if (popped?.isArray) {
|
|
1878
|
+
const depth = contextStack.length;
|
|
1879
|
+
delete arrayObjectCount[depth];
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1828
1883
|
}
|
|
1829
1884
|
function setCommentAtPath(comments, path19, key, hint) {
|
|
1830
1885
|
let current = comments;
|
|
@@ -8207,7 +8262,7 @@ var path13 = {
|
|
|
8207
8262
|
};
|
|
8208
8263
|
var sep = defaultPlatform === "win32" ? path13.win32.sep : path13.posix.sep;
|
|
8209
8264
|
minimatch.sep = sep;
|
|
8210
|
-
var GLOBSTAR = Symbol("globstar **");
|
|
8265
|
+
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
8211
8266
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
8212
8267
|
var qmark2 = "[^/]";
|
|
8213
8268
|
var star2 = qmark2 + "*?";
|
|
@@ -14714,7 +14769,7 @@ async function renderHero2() {
|
|
|
14714
14769
|
// package.json
|
|
14715
14770
|
var package_default = {
|
|
14716
14771
|
name: "lingo.dev",
|
|
14717
|
-
version: "0.117.
|
|
14772
|
+
version: "0.117.22",
|
|
14718
14773
|
description: "Lingo.dev CLI",
|
|
14719
14774
|
private: false,
|
|
14720
14775
|
repository: {
|