lingo.dev 0.117.0 → 0.117.2
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 +271 -138
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +139 -6
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.cjs
CHANGED
|
@@ -2088,14 +2088,147 @@ function createYamlLoader() {
|
|
|
2088
2088
|
return _yaml2.default.parse(input2) || {};
|
|
2089
2089
|
},
|
|
2090
2090
|
async push(locale, payload, originalInput) {
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2091
|
+
if (!originalInput || !originalInput.trim()) {
|
|
2092
|
+
return _yaml2.default.stringify(payload, {
|
|
2093
|
+
lineWidth: -1,
|
|
2094
|
+
defaultKeyType: "PLAIN",
|
|
2095
|
+
defaultStringType: "PLAIN"
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
try {
|
|
2099
|
+
const sourceDoc = _yaml2.default.parseDocument(originalInput);
|
|
2100
|
+
const metadata = extractQuotingMetadata(sourceDoc);
|
|
2101
|
+
const outputDoc = _yaml2.default.parseDocument(
|
|
2102
|
+
_yaml2.default.stringify(payload, {
|
|
2103
|
+
lineWidth: -1,
|
|
2104
|
+
defaultKeyType: "PLAIN"
|
|
2105
|
+
})
|
|
2106
|
+
);
|
|
2107
|
+
applyQuotingMetadata(outputDoc, metadata);
|
|
2108
|
+
return outputDoc.toString({ lineWidth: -1 });
|
|
2109
|
+
} catch (error) {
|
|
2110
|
+
console.warn("Failed to preserve YAML formatting:", error);
|
|
2111
|
+
return _yaml2.default.stringify(payload, {
|
|
2112
|
+
lineWidth: -1,
|
|
2113
|
+
defaultKeyType: getKeyType(originalInput),
|
|
2114
|
+
defaultStringType: getStringType(originalInput)
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2096
2117
|
}
|
|
2097
2118
|
});
|
|
2098
2119
|
}
|
|
2120
|
+
function extractQuotingMetadata(doc) {
|
|
2121
|
+
const metadata = {
|
|
2122
|
+
keys: /* @__PURE__ */ new Map(),
|
|
2123
|
+
values: /* @__PURE__ */ new Map()
|
|
2124
|
+
};
|
|
2125
|
+
const root = doc.contents;
|
|
2126
|
+
if (!root) return metadata;
|
|
2127
|
+
walkAndExtract(root, [], metadata);
|
|
2128
|
+
return metadata;
|
|
2129
|
+
}
|
|
2130
|
+
function walkAndExtract(node, path19, metadata) {
|
|
2131
|
+
if (isScalar(node)) {
|
|
2132
|
+
if (node.type && node.type !== "PLAIN") {
|
|
2133
|
+
metadata.values.set(path19.join("."), node.type);
|
|
2134
|
+
}
|
|
2135
|
+
} else if (isYAMLMap(node)) {
|
|
2136
|
+
if (node.items && Array.isArray(node.items)) {
|
|
2137
|
+
for (const pair of node.items) {
|
|
2138
|
+
if (pair && pair.key) {
|
|
2139
|
+
const key = getKeyValue(pair.key);
|
|
2140
|
+
if (key !== null && key !== void 0) {
|
|
2141
|
+
const keyPath = [...path19, String(key)].join(".");
|
|
2142
|
+
if (pair.key.type && pair.key.type !== "PLAIN") {
|
|
2143
|
+
metadata.keys.set(keyPath, pair.key.type);
|
|
2144
|
+
}
|
|
2145
|
+
if (pair.value) {
|
|
2146
|
+
walkAndExtract(pair.value, [...path19, String(key)], metadata);
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
} else if (isYAMLSeq(node)) {
|
|
2153
|
+
if (node.items && Array.isArray(node.items)) {
|
|
2154
|
+
for (let i = 0; i < node.items.length; i++) {
|
|
2155
|
+
if (node.items[i]) {
|
|
2156
|
+
walkAndExtract(node.items[i], [...path19, String(i)], metadata);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
function applyQuotingMetadata(doc, metadata) {
|
|
2163
|
+
const root = doc.contents;
|
|
2164
|
+
if (!root) return;
|
|
2165
|
+
walkAndApply(root, [], metadata);
|
|
2166
|
+
}
|
|
2167
|
+
function walkAndApply(node, path19, metadata) {
|
|
2168
|
+
if (isScalar(node)) {
|
|
2169
|
+
const pathKey = path19.join(".");
|
|
2170
|
+
const quoteType = metadata.values.get(pathKey);
|
|
2171
|
+
if (quoteType) {
|
|
2172
|
+
node.type = quoteType;
|
|
2173
|
+
}
|
|
2174
|
+
} else if (isYAMLMap(node)) {
|
|
2175
|
+
if (node.items && Array.isArray(node.items)) {
|
|
2176
|
+
for (const pair of node.items) {
|
|
2177
|
+
if (pair && pair.key) {
|
|
2178
|
+
const key = getKeyValue(pair.key);
|
|
2179
|
+
if (key !== null && key !== void 0) {
|
|
2180
|
+
const keyPath = [...path19, String(key)].join(".");
|
|
2181
|
+
const keyQuoteType = metadata.keys.get(keyPath);
|
|
2182
|
+
if (keyQuoteType) {
|
|
2183
|
+
pair.key.type = keyQuoteType;
|
|
2184
|
+
}
|
|
2185
|
+
if (pair.value) {
|
|
2186
|
+
walkAndApply(pair.value, [...path19, String(key)], metadata);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
} else if (isYAMLSeq(node)) {
|
|
2193
|
+
if (node.items && Array.isArray(node.items)) {
|
|
2194
|
+
for (let i = 0; i < node.items.length; i++) {
|
|
2195
|
+
if (node.items[i]) {
|
|
2196
|
+
walkAndApply(node.items[i], [...path19, String(i)], metadata);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
function isScalar(node) {
|
|
2203
|
+
if (_optionalChain([node, 'optionalAccess', _112 => _112.constructor, 'optionalAccess', _113 => _113.name]) === "Scalar") {
|
|
2204
|
+
return true;
|
|
2205
|
+
}
|
|
2206
|
+
return node && typeof node === "object" && "value" in node && ("type" in node || "format" in node);
|
|
2207
|
+
}
|
|
2208
|
+
function isYAMLMap(node) {
|
|
2209
|
+
if (_optionalChain([node, 'optionalAccess', _114 => _114.constructor, 'optionalAccess', _115 => _115.name]) === "YAMLMap") {
|
|
2210
|
+
return true;
|
|
2211
|
+
}
|
|
2212
|
+
return node && typeof node === "object" && "items" in node && Array.isArray(node.items) && !("value" in node);
|
|
2213
|
+
}
|
|
2214
|
+
function isYAMLSeq(node) {
|
|
2215
|
+
if (_optionalChain([node, 'optionalAccess', _116 => _116.constructor, 'optionalAccess', _117 => _117.name]) === "YAMLSeq") {
|
|
2216
|
+
return true;
|
|
2217
|
+
}
|
|
2218
|
+
return node && typeof node === "object" && "items" in node && Array.isArray(node.items) && !("type" in node) && !("value" in node);
|
|
2219
|
+
}
|
|
2220
|
+
function getKeyValue(key) {
|
|
2221
|
+
if (key === null || key === void 0) {
|
|
2222
|
+
return null;
|
|
2223
|
+
}
|
|
2224
|
+
if (typeof key === "object" && "value" in key) {
|
|
2225
|
+
return key.value;
|
|
2226
|
+
}
|
|
2227
|
+
if (typeof key === "string" || typeof key === "number") {
|
|
2228
|
+
return key;
|
|
2229
|
+
}
|
|
2230
|
+
return null;
|
|
2231
|
+
}
|
|
2099
2232
|
function getKeyType(yamlString) {
|
|
2100
2233
|
if (yamlString) {
|
|
2101
2234
|
const lines = yamlString.split("\n");
|
|
@@ -2275,7 +2408,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2275
2408
|
const resourceNodes = [];
|
|
2276
2409
|
let metaIndex = 0;
|
|
2277
2410
|
for (const child of resourcesNode.$$) {
|
|
2278
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2411
|
+
const elementName = _optionalChain([child, 'optionalAccess', _118 => _118["#name"]]);
|
|
2279
2412
|
if (!isResourceElementName(elementName)) {
|
|
2280
2413
|
continue;
|
|
2281
2414
|
}
|
|
@@ -2283,11 +2416,11 @@ async function parseAndroidDocument(input2) {
|
|
|
2283
2416
|
if (!meta || meta.type !== elementName) {
|
|
2284
2417
|
continue;
|
|
2285
2418
|
}
|
|
2286
|
-
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2419
|
+
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _119 => _119.$, 'optionalAccess', _120 => _120.name]), () => ( meta.name));
|
|
2287
2420
|
if (!name) {
|
|
2288
2421
|
continue;
|
|
2289
2422
|
}
|
|
2290
|
-
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2423
|
+
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _121 => _121.$, 'optionalAccess', _122 => _122.translatable]), () => ( ""))).toLowerCase() !== "false";
|
|
2291
2424
|
switch (meta.type) {
|
|
2292
2425
|
case "string": {
|
|
2293
2426
|
resourceNodes.push({
|
|
@@ -2300,7 +2433,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2300
2433
|
break;
|
|
2301
2434
|
}
|
|
2302
2435
|
case "string-array": {
|
|
2303
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2436
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _123 => _123.item]), () => ( []));
|
|
2304
2437
|
const items = [];
|
|
2305
2438
|
const templateItems = meta.items;
|
|
2306
2439
|
for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
|
|
@@ -2324,7 +2457,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2324
2457
|
break;
|
|
2325
2458
|
}
|
|
2326
2459
|
case "plurals": {
|
|
2327
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2460
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _124 => _124.item]), () => ( []));
|
|
2328
2461
|
const templateItems = meta.items;
|
|
2329
2462
|
const items = [];
|
|
2330
2463
|
for (const templateItem of templateItems) {
|
|
@@ -2333,7 +2466,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2333
2466
|
continue;
|
|
2334
2467
|
}
|
|
2335
2468
|
const nodeItem = itemNodes.find(
|
|
2336
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2469
|
+
(item) => _optionalChain([item, 'optionalAccess', _125 => _125.$, 'optionalAccess', _126 => _126.quantity]) === quantity
|
|
2337
2470
|
);
|
|
2338
2471
|
if (!nodeItem) {
|
|
2339
2472
|
continue;
|
|
@@ -2614,7 +2747,7 @@ function cloneResourceNode(resource) {
|
|
|
2614
2747
|
const nodeClone = deepClone(resource.node);
|
|
2615
2748
|
const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
|
|
2616
2749
|
const items = itemNodes.map((itemNode, index) => {
|
|
2617
|
-
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access',
|
|
2750
|
+
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access', _127 => _127.items, 'access', _128 => _128[index], 'optionalAccess', _129 => _129.meta]), () => ( _optionalChain([resource, 'access', _130 => _130.items, 'access', _131 => _131[resource.items.length - 1], 'optionalAccess', _132 => _132.meta]))), () => ( makeTextMeta([])));
|
|
2618
2751
|
return {
|
|
2619
2752
|
node: itemNode,
|
|
2620
2753
|
meta: cloneTextMeta(templateMeta)
|
|
@@ -2634,7 +2767,7 @@ function cloneResourceNode(resource) {
|
|
|
2634
2767
|
const items = [];
|
|
2635
2768
|
for (const templateItem of resource.items) {
|
|
2636
2769
|
const cloneNode = itemNodes.find(
|
|
2637
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2770
|
+
(item) => _optionalChain([item, 'optionalAccess', _133 => _133.$, 'optionalAccess', _134 => _134.quantity]) === templateItem.quantity
|
|
2638
2771
|
);
|
|
2639
2772
|
if (!cloneNode) {
|
|
2640
2773
|
continue;
|
|
@@ -2890,8 +3023,8 @@ function cloneDocumentStructure(document) {
|
|
|
2890
3023
|
resourceNodes.map((r) => resourceLookupKey(r.type, r.name))
|
|
2891
3024
|
);
|
|
2892
3025
|
let filtered = resourcesClone.$$.filter((child) => {
|
|
2893
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2894
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3026
|
+
const elementName = _optionalChain([child, 'optionalAccess', _135 => _135["#name"]]);
|
|
3027
|
+
const name = _optionalChain([child, 'optionalAccess', _136 => _136.$, 'optionalAccess', _137 => _137.name]);
|
|
2895
3028
|
if (!isResourceElementName(elementName) || !name) {
|
|
2896
3029
|
return true;
|
|
2897
3030
|
}
|
|
@@ -2900,7 +3033,7 @@ function cloneDocumentStructure(document) {
|
|
|
2900
3033
|
const cleaned = [];
|
|
2901
3034
|
let lastWasWhitespace = false;
|
|
2902
3035
|
for (const child of filtered) {
|
|
2903
|
-
const isWhitespace = _optionalChain([child, 'optionalAccess',
|
|
3036
|
+
const isWhitespace = _optionalChain([child, 'optionalAccess', _138 => _138["#name"]]) === "__text__" && (!child._ || child._.trim() === "");
|
|
2904
3037
|
if (isWhitespace) {
|
|
2905
3038
|
if (!lastWasWhitespace) {
|
|
2906
3039
|
cleaned.push(child);
|
|
@@ -2922,8 +3055,8 @@ function buildResourceLookup(resources) {
|
|
|
2922
3055
|
const lookup = /* @__PURE__ */ new Map();
|
|
2923
3056
|
const children = Array.isArray(resources.$$) ? resources.$$ : [];
|
|
2924
3057
|
for (const child of children) {
|
|
2925
|
-
const type = _optionalChain([child, 'optionalAccess',
|
|
2926
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3058
|
+
const type = _optionalChain([child, 'optionalAccess', _139 => _139["#name"]]);
|
|
3059
|
+
const name = _optionalChain([child, 'optionalAccess', _140 => _140.$, 'optionalAccess', _141 => _141.name]);
|
|
2927
3060
|
if (!type || !name || !isResourceElementName(type)) {
|
|
2928
3061
|
continue;
|
|
2929
3062
|
}
|
|
@@ -2952,7 +3085,7 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
2952
3085
|
}
|
|
2953
3086
|
case "string-array": {
|
|
2954
3087
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
2955
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3088
|
+
(child) => _optionalChain([child, 'optionalAccess', _142 => _142["#name"]]) === "item"
|
|
2956
3089
|
);
|
|
2957
3090
|
node.item = childItems;
|
|
2958
3091
|
if (childItems.length < resource.items.length) {
|
|
@@ -2981,12 +3114,12 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
2981
3114
|
}
|
|
2982
3115
|
case "plurals": {
|
|
2983
3116
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
2984
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3117
|
+
(child) => _optionalChain([child, 'optionalAccess', _143 => _143["#name"]]) === "item"
|
|
2985
3118
|
);
|
|
2986
3119
|
node.item = childItems;
|
|
2987
3120
|
const itemMap = /* @__PURE__ */ new Map();
|
|
2988
3121
|
for (const item of childItems) {
|
|
2989
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
3122
|
+
if (_optionalChain([item, 'optionalAccess', _144 => _144.$, 'optionalAccess', _145 => _145.quantity])) {
|
|
2990
3123
|
itemMap.set(item.$.quantity, item);
|
|
2991
3124
|
}
|
|
2992
3125
|
}
|
|
@@ -3276,7 +3409,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
3276
3409
|
|
|
3277
3410
|
function detectKeyColumnName(csvString) {
|
|
3278
3411
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
3279
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
3412
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _146 => _146[0], 'optionalAccess', _147 => _147.trim, 'call', _148 => _148()]);
|
|
3280
3413
|
return firstColumn || "KEY";
|
|
3281
3414
|
}
|
|
3282
3415
|
function createCsvLoader() {
|
|
@@ -3378,7 +3511,7 @@ function createHtmlLoader() {
|
|
|
3378
3511
|
break;
|
|
3379
3512
|
}
|
|
3380
3513
|
const siblings = Array.from(parent.childNodes).filter(
|
|
3381
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3514
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _149 => _149.textContent, 'optionalAccess', _150 => _150.trim, 'call', _151 => _151()])
|
|
3382
3515
|
);
|
|
3383
3516
|
const index = siblings.indexOf(current);
|
|
3384
3517
|
if (index !== -1) {
|
|
@@ -3414,15 +3547,15 @@ function createHtmlLoader() {
|
|
|
3414
3547
|
}
|
|
3415
3548
|
});
|
|
3416
3549
|
Array.from(element.childNodes).filter(
|
|
3417
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3550
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _152 => _152.textContent, 'optionalAccess', _153 => _153.trim, 'call', _154 => _154()])
|
|
3418
3551
|
).forEach(processNode);
|
|
3419
3552
|
}
|
|
3420
3553
|
};
|
|
3421
3554
|
Array.from(document.head.childNodes).filter(
|
|
3422
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3555
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _155 => _155.textContent, 'optionalAccess', _156 => _156.trim, 'call', _157 => _157()])
|
|
3423
3556
|
).forEach(processNode);
|
|
3424
3557
|
Array.from(document.body.childNodes).filter(
|
|
3425
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3558
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _158 => _158.textContent, 'optionalAccess', _159 => _159.trim, 'call', _160 => _160()])
|
|
3426
3559
|
).forEach(processNode);
|
|
3427
3560
|
return result;
|
|
3428
3561
|
},
|
|
@@ -3447,7 +3580,7 @@ function createHtmlLoader() {
|
|
|
3447
3580
|
for (let i = 0; i < indices.length; i++) {
|
|
3448
3581
|
const index = parseInt(indices[i]);
|
|
3449
3582
|
const siblings = Array.from(parent.childNodes).filter(
|
|
3450
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3583
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _161 => _161.textContent, 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()])
|
|
3451
3584
|
);
|
|
3452
3585
|
if (index >= siblings.length) {
|
|
3453
3586
|
if (i === indices.length - 1) {
|
|
@@ -3498,7 +3631,7 @@ function createMarkdownLoader() {
|
|
|
3498
3631
|
yaml: yamlEngine
|
|
3499
3632
|
}
|
|
3500
3633
|
});
|
|
3501
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
3634
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]), () => ( ""))).filter(Boolean);
|
|
3502
3635
|
return {
|
|
3503
3636
|
...Object.fromEntries(
|
|
3504
3637
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -3517,7 +3650,7 @@ function createMarkdownLoader() {
|
|
|
3517
3650
|
);
|
|
3518
3651
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
3519
3652
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
3520
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
3653
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _166 => _166.trim, 'call', _167 => _167()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
3521
3654
|
if (Object.keys(frontmatter).length > 0) {
|
|
3522
3655
|
content = `
|
|
3523
3656
|
${content}`;
|
|
@@ -3542,7 +3675,7 @@ function createMarkdocLoader() {
|
|
|
3542
3675
|
const result = {};
|
|
3543
3676
|
const counters = {};
|
|
3544
3677
|
traverseAndExtract(ast, "", result, counters);
|
|
3545
|
-
if (_optionalChain([ast, 'access',
|
|
3678
|
+
if (_optionalChain([ast, 'access', _168 => _168.attributes, 'optionalAccess', _169 => _169.frontmatter])) {
|
|
3546
3679
|
const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
|
|
3547
3680
|
Object.entries(frontmatter).forEach(([key, value]) => {
|
|
3548
3681
|
if (typeof value === "string") {
|
|
@@ -3588,7 +3721,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
3588
3721
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3589
3722
|
semanticType = nodeSemanticType;
|
|
3590
3723
|
}
|
|
3591
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3724
|
+
if (node.type === "text" && _optionalChain([node, 'access', _170 => _170.attributes, 'optionalAccess', _171 => _171.content])) {
|
|
3592
3725
|
const content = node.attributes.content;
|
|
3593
3726
|
if (typeof content === "string" && content.trim()) {
|
|
3594
3727
|
if (semanticType) {
|
|
@@ -3615,7 +3748,7 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
3615
3748
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3616
3749
|
semanticType = nodeSemanticType;
|
|
3617
3750
|
}
|
|
3618
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3751
|
+
if (node.type === "text" && _optionalChain([node, 'access', _172 => _172.attributes, 'optionalAccess', _173 => _173.content])) {
|
|
3619
3752
|
const content = node.attributes.content;
|
|
3620
3753
|
if (typeof content === "string" && content.trim()) {
|
|
3621
3754
|
if (semanticType) {
|
|
@@ -3638,7 +3771,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
3638
3771
|
if (!node || typeof node !== "object") {
|
|
3639
3772
|
return;
|
|
3640
3773
|
}
|
|
3641
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3774
|
+
if (node.type === "text" && _optionalChain([node, 'access', _174 => _174.attributes, 'optionalAccess', _175 => _175.content])) {
|
|
3642
3775
|
const content = node.attributes.content;
|
|
3643
3776
|
if (typeof content === "string") {
|
|
3644
3777
|
const contentPath = path19 ? `${path19}/attributes/content` : "attributes/content";
|
|
@@ -3688,7 +3821,7 @@ function isSkippableLine(line) {
|
|
|
3688
3821
|
function parsePropertyLine(line) {
|
|
3689
3822
|
const [key, ...valueParts] = line.split("=");
|
|
3690
3823
|
return {
|
|
3691
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
3824
|
+
key: _optionalChain([key, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]) || "",
|
|
3692
3825
|
value: valueParts.join("=").trim()
|
|
3693
3826
|
};
|
|
3694
3827
|
}
|
|
@@ -3980,7 +4113,7 @@ var Parser = class {
|
|
|
3980
4113
|
}
|
|
3981
4114
|
}
|
|
3982
4115
|
expect(type) {
|
|
3983
|
-
if (_optionalChain([this, 'access',
|
|
4116
|
+
if (_optionalChain([this, 'access', _178 => _178.current, 'call', _179 => _179(), 'optionalAccess', _180 => _180.type]) === type) {
|
|
3984
4117
|
this.advance();
|
|
3985
4118
|
return true;
|
|
3986
4119
|
}
|
|
@@ -4057,7 +4190,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4057
4190
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4058
4191
|
continue;
|
|
4059
4192
|
}
|
|
4060
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4193
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _181 => _181.localizations, 'optionalAccess', _182 => _182[locale]]);
|
|
4061
4194
|
if (langTranslationEntity) {
|
|
4062
4195
|
if ("stringUnit" in langTranslationEntity) {
|
|
4063
4196
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -4071,7 +4204,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4071
4204
|
resultData[translationKey] = {};
|
|
4072
4205
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4073
4206
|
for (const form in pluralForms) {
|
|
4074
|
-
if (_optionalChain([pluralForms, 'access',
|
|
4207
|
+
if (_optionalChain([pluralForms, 'access', _183 => _183[form], 'optionalAccess', _184 => _184.stringUnit, 'optionalAccess', _185 => _185.value])) {
|
|
4075
4208
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
4076
4209
|
}
|
|
4077
4210
|
}
|
|
@@ -4097,7 +4230,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4097
4230
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
4098
4231
|
if (typeof value === "string") {
|
|
4099
4232
|
langDataToMerge.strings[key] = {
|
|
4100
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4233
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _186 => _186.strings, 'optionalAccess', _187 => _187[key], 'optionalAccess', _188 => _188.extractionState]),
|
|
4101
4234
|
localizations: {
|
|
4102
4235
|
[locale]: {
|
|
4103
4236
|
stringUnit: {
|
|
@@ -4112,7 +4245,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4112
4245
|
}
|
|
4113
4246
|
} else if (Array.isArray(value)) {
|
|
4114
4247
|
langDataToMerge.strings[key] = {
|
|
4115
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4248
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _189 => _189.strings, 'optionalAccess', _190 => _190[key], 'optionalAccess', _191 => _191.extractionState]),
|
|
4116
4249
|
localizations: {
|
|
4117
4250
|
[locale]: {
|
|
4118
4251
|
stringSet: {
|
|
@@ -4170,7 +4303,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4170
4303
|
for (const [locale, localization] of Object.entries(
|
|
4171
4304
|
entity.localizations
|
|
4172
4305
|
)) {
|
|
4173
|
-
if (_optionalChain([localization, 'access',
|
|
4306
|
+
if (_optionalChain([localization, 'access', _192 => _192.variations, 'optionalAccess', _193 => _193.plural])) {
|
|
4174
4307
|
const pluralForms = localization.variations.plural;
|
|
4175
4308
|
for (const form in pluralForms) {
|
|
4176
4309
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -4190,7 +4323,7 @@ function _removeLocale(input2, locale) {
|
|
|
4190
4323
|
const { strings } = input2;
|
|
4191
4324
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
4192
4325
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
4193
|
-
if (_optionalChain([value, 'access',
|
|
4326
|
+
if (_optionalChain([value, 'access', _194 => _194.localizations, 'optionalAccess', _195 => _195[locale]])) {
|
|
4194
4327
|
delete value.localizations[locale];
|
|
4195
4328
|
}
|
|
4196
4329
|
}
|
|
@@ -4321,7 +4454,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4321
4454
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4322
4455
|
continue;
|
|
4323
4456
|
}
|
|
4324
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4457
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _196 => _196.localizations, 'optionalAccess', _197 => _197[locale]]);
|
|
4325
4458
|
if (langTranslationEntity) {
|
|
4326
4459
|
if (!resultData[translationKey]) {
|
|
4327
4460
|
resultData[translationKey] = {};
|
|
@@ -4333,7 +4466,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4333
4466
|
for (const [subName, subData] of Object.entries(
|
|
4334
4467
|
langTranslationEntity.substitutions
|
|
4335
4468
|
)) {
|
|
4336
|
-
const pluralForms = _optionalChain([subData, 'access',
|
|
4469
|
+
const pluralForms = _optionalChain([subData, 'access', _198 => _198.variations, 'optionalAccess', _199 => _199.plural]);
|
|
4337
4470
|
if (pluralForms) {
|
|
4338
4471
|
const forms = {};
|
|
4339
4472
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
@@ -4358,7 +4491,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4358
4491
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4359
4492
|
const forms = {};
|
|
4360
4493
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
4361
|
-
if (_optionalChain([formData, 'optionalAccess',
|
|
4494
|
+
if (_optionalChain([formData, 'optionalAccess', _200 => _200.stringUnit, 'optionalAccess', _201 => _201.value])) {
|
|
4362
4495
|
forms[form] = formData.stringUnit.value;
|
|
4363
4496
|
}
|
|
4364
4497
|
}
|
|
@@ -4401,7 +4534,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4401
4534
|
for (const [subName, subData] of Object.entries(
|
|
4402
4535
|
keyData.substitutions
|
|
4403
4536
|
)) {
|
|
4404
|
-
const pluralValue = _optionalChain([subData, 'optionalAccess',
|
|
4537
|
+
const pluralValue = _optionalChain([subData, 'optionalAccess', _202 => _202.variations, 'optionalAccess', _203 => _203.plural]);
|
|
4405
4538
|
if (pluralValue && isIcuPluralString(pluralValue)) {
|
|
4406
4539
|
try {
|
|
4407
4540
|
const pluralForms = parseIcuPluralString(pluralValue, locale);
|
|
@@ -4414,8 +4547,8 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4414
4547
|
}
|
|
4415
4548
|
};
|
|
4416
4549
|
}
|
|
4417
|
-
const sourceLocale = _optionalChain([originalInput, 'optionalAccess',
|
|
4418
|
-
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess',
|
|
4550
|
+
const sourceLocale = _optionalChain([originalInput, 'optionalAccess', _204 => _204.sourceLanguage]) || "en";
|
|
4551
|
+
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess', _205 => _205.strings, 'optionalAccess', _206 => _206[baseKey], 'optionalAccess', _207 => _207.localizations, 'optionalAccess', _208 => _208[sourceLocale], 'optionalAccess', _209 => _209.substitutions, 'optionalAccess', _210 => _210[subName], 'optionalAccess', _211 => _211.formatSpecifier]) || subName;
|
|
4419
4552
|
subs[subName] = {
|
|
4420
4553
|
formatSpecifier: origFormatSpec,
|
|
4421
4554
|
variations: {
|
|
@@ -4440,7 +4573,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
4440
4573
|
values: keyData.stringSet
|
|
4441
4574
|
};
|
|
4442
4575
|
}
|
|
4443
|
-
if ("variations" in keyData && _optionalChain([keyData, 'access',
|
|
4576
|
+
if ("variations" in keyData && _optionalChain([keyData, 'access', _212 => _212.variations, 'optionalAccess', _213 => _213.plural])) {
|
|
4444
4577
|
const pluralValue = keyData.variations.plural;
|
|
4445
4578
|
if (isIcuPluralString(pluralValue)) {
|
|
4446
4579
|
try {
|
|
@@ -4467,7 +4600,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
4467
4600
|
}
|
|
4468
4601
|
if (Object.keys(localizationData).length > 0) {
|
|
4469
4602
|
langDataToMerge.strings[baseKey] = {
|
|
4470
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4603
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _214 => _214.strings, 'optionalAccess', _215 => _215[baseKey], 'optionalAccess', _216 => _216.extractionState]),
|
|
4471
4604
|
localizations: {
|
|
4472
4605
|
[locale]: localizationData
|
|
4473
4606
|
}
|
|
@@ -4690,8 +4823,8 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
4690
4823
|
});
|
|
4691
4824
|
return formatted.content;
|
|
4692
4825
|
} catch (error) {
|
|
4693
|
-
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access',
|
|
4694
|
-
if (_optionalChain([errorMessage, 'optionalAccess',
|
|
4826
|
+
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _217 => _217.stackTrace, 'optionalAccess', _218 => _218.toString, 'call', _219 => _219(), 'access', _220 => _220.split, 'call', _221 => _221("\n"), 'access', _222 => _222[0]]) : "";
|
|
4827
|
+
if (_optionalChain([errorMessage, 'optionalAccess', _223 => _223.includes, 'call', _224 => _224("does not exist in the workspace")])) {
|
|
4695
4828
|
} else {
|
|
4696
4829
|
console.log(`\u26A0\uFE0F Biome skipped ${path14.default.basename(filePath)}`);
|
|
4697
4830
|
if (errorMessage) {
|
|
@@ -4738,7 +4871,7 @@ function createPoDataLoader(params) {
|
|
|
4738
4871
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
4739
4872
|
if (msgid && entry.msgid) {
|
|
4740
4873
|
const context = entry.msgctxt || "";
|
|
4741
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
4874
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _225 => _225.translations, 'access', _226 => _226[context], 'optionalAccess', _227 => _227[msgid]]);
|
|
4742
4875
|
if (fullEntry) {
|
|
4743
4876
|
result[msgid] = fullEntry;
|
|
4744
4877
|
}
|
|
@@ -4748,8 +4881,8 @@ function createPoDataLoader(params) {
|
|
|
4748
4881
|
return result;
|
|
4749
4882
|
},
|
|
4750
4883
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
4751
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
4752
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
4884
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _228 => _228.split, 'call', _229 => _229("\n\n"), 'access', _230 => _230.filter, 'call', _231 => _231(Boolean)]) || [];
|
|
4885
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _232 => _232.split, 'call', _233 => _233("\n\n"), 'access', _234 => _234.filter, 'call', _235 => _235(Boolean)]) || [];
|
|
4753
4886
|
const result = originalSections.map((section) => {
|
|
4754
4887
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
4755
4888
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -4818,8 +4951,8 @@ function createPoContentLoader() {
|
|
|
4818
4951
|
{
|
|
4819
4952
|
...entry,
|
|
4820
4953
|
msgstr: [
|
|
4821
|
-
_optionalChain([data, 'access',
|
|
4822
|
-
_optionalChain([data, 'access',
|
|
4954
|
+
_optionalChain([data, 'access', _236 => _236[entry.msgid], 'optionalAccess', _237 => _237.singular]),
|
|
4955
|
+
_optionalChain([data, 'access', _238 => _238[entry.msgid], 'optionalAccess', _239 => _239.plural]) || null
|
|
4823
4956
|
].filter(Boolean)
|
|
4824
4957
|
}
|
|
4825
4958
|
]).fromPairs().value();
|
|
@@ -4941,7 +5074,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
4941
5074
|
let key = getTransUnitKey(unit);
|
|
4942
5075
|
if (!key) return;
|
|
4943
5076
|
if (seenKeys.has(key)) {
|
|
4944
|
-
const id = _optionalChain([unit, 'access',
|
|
5077
|
+
const id = _optionalChain([unit, 'access', _240 => _240.getAttribute, 'call', _241 => _241("id"), 'optionalAccess', _242 => _242.trim, 'call', _243 => _243()]);
|
|
4945
5078
|
if (id) {
|
|
4946
5079
|
key = `${key}#${id}`;
|
|
4947
5080
|
} else {
|
|
@@ -4989,7 +5122,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
4989
5122
|
let key = getTransUnitKey(unit);
|
|
4990
5123
|
if (!key) return;
|
|
4991
5124
|
if (seenKeys.has(key)) {
|
|
4992
|
-
const id = _optionalChain([unit, 'access',
|
|
5125
|
+
const id = _optionalChain([unit, 'access', _244 => _244.getAttribute, 'call', _245 => _245("id"), 'optionalAccess', _246 => _246.trim, 'call', _247 => _247()]);
|
|
4993
5126
|
if (id) {
|
|
4994
5127
|
key = `${key}#${id}`;
|
|
4995
5128
|
} else {
|
|
@@ -5031,7 +5164,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5031
5164
|
const translationKeys = new Set(Object.keys(translations));
|
|
5032
5165
|
existingUnits.forEach((unit, key) => {
|
|
5033
5166
|
if (!translationKeys.has(key)) {
|
|
5034
|
-
_optionalChain([unit, 'access',
|
|
5167
|
+
_optionalChain([unit, 'access', _248 => _248.parentNode, 'optionalAccess', _249 => _249.removeChild, 'call', _250 => _250(unit)]);
|
|
5035
5168
|
}
|
|
5036
5169
|
});
|
|
5037
5170
|
return serializeWithDeclaration(
|
|
@@ -5074,18 +5207,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
5074
5207
|
Array.from(container.children).forEach((child) => {
|
|
5075
5208
|
const tagName = child.tagName;
|
|
5076
5209
|
if (tagName === "unit") {
|
|
5077
|
-
const unitId = _optionalChain([child, 'access',
|
|
5210
|
+
const unitId = _optionalChain([child, 'access', _251 => _251.getAttribute, 'call', _252 => _252("id"), 'optionalAccess', _253 => _253.trim, 'call', _254 => _254()]);
|
|
5078
5211
|
if (!unitId) return;
|
|
5079
5212
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5080
5213
|
const segment = child.querySelector("segment");
|
|
5081
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
5214
|
+
const source = _optionalChain([segment, 'optionalAccess', _255 => _255.querySelector, 'call', _256 => _256("source")]);
|
|
5082
5215
|
if (source) {
|
|
5083
5216
|
result[key] = extractTextContent(source);
|
|
5084
5217
|
} else {
|
|
5085
5218
|
result[key] = unitId;
|
|
5086
5219
|
}
|
|
5087
5220
|
} else if (tagName === "group") {
|
|
5088
|
-
const groupId = _optionalChain([child, 'access',
|
|
5221
|
+
const groupId = _optionalChain([child, 'access', _257 => _257.getAttribute, 'call', _258 => _258("id"), 'optionalAccess', _259 => _259.trim, 'call', _260 => _260()]);
|
|
5089
5222
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5090
5223
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
5091
5224
|
}
|
|
@@ -5121,12 +5254,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
5121
5254
|
Array.from(container.children).forEach((child) => {
|
|
5122
5255
|
const tagName = child.tagName;
|
|
5123
5256
|
if (tagName === "unit") {
|
|
5124
|
-
const unitId = _optionalChain([child, 'access',
|
|
5257
|
+
const unitId = _optionalChain([child, 'access', _261 => _261.getAttribute, 'call', _262 => _262("id"), 'optionalAccess', _263 => _263.trim, 'call', _264 => _264()]);
|
|
5125
5258
|
if (!unitId) return;
|
|
5126
5259
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5127
5260
|
index.set(key, child);
|
|
5128
5261
|
} else if (tagName === "group") {
|
|
5129
|
-
const groupId = _optionalChain([child, 'access',
|
|
5262
|
+
const groupId = _optionalChain([child, 'access', _265 => _265.getAttribute, 'call', _266 => _266("id"), 'optionalAccess', _267 => _267.trim, 'call', _268 => _268()]);
|
|
5130
5263
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5131
5264
|
indexUnitsV2(child, fileId, newPath, index);
|
|
5132
5265
|
}
|
|
@@ -5147,9 +5280,9 @@ function updateUnitV2(unit, value) {
|
|
|
5147
5280
|
setTextContent(source, value);
|
|
5148
5281
|
}
|
|
5149
5282
|
function getTransUnitKey(transUnit) {
|
|
5150
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
5283
|
+
const resname = _optionalChain([transUnit, 'access', _269 => _269.getAttribute, 'call', _270 => _270("resname"), 'optionalAccess', _271 => _271.trim, 'call', _272 => _272()]);
|
|
5151
5284
|
if (resname) return resname;
|
|
5152
|
-
const id = _optionalChain([transUnit, 'access',
|
|
5285
|
+
const id = _optionalChain([transUnit, 'access', _273 => _273.getAttribute, 'call', _274 => _274("id"), 'optionalAccess', _275 => _275.trim, 'call', _276 => _276()]);
|
|
5153
5286
|
if (id) return id;
|
|
5154
5287
|
const sourceElement = transUnit.querySelector("source");
|
|
5155
5288
|
if (sourceElement) {
|
|
@@ -5206,7 +5339,7 @@ function formatXml(xml) {
|
|
|
5206
5339
|
if (cdataNode) {
|
|
5207
5340
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
5208
5341
|
}
|
|
5209
|
-
const textContent = _optionalChain([element, 'access',
|
|
5342
|
+
const textContent = _optionalChain([element, 'access', _277 => _277.textContent, 'optionalAccess', _278 => _278.trim, 'call', _279 => _279()]) || "";
|
|
5210
5343
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
5211
5344
|
if (hasOnlyText && textContent) {
|
|
5212
5345
|
return `${indent2}${openTag}${textContent}</${tagName}>`;
|
|
@@ -5499,7 +5632,7 @@ function createDatoClient(params) {
|
|
|
5499
5632
|
ids: !records.length ? void 0 : records.join(",")
|
|
5500
5633
|
}
|
|
5501
5634
|
}).catch(
|
|
5502
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5635
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _280 => _280.response, 'optionalAccess', _281 => _281.body, 'optionalAccess', _282 => _282.data, 'optionalAccess', _283 => _283[0]]) || error)
|
|
5503
5636
|
);
|
|
5504
5637
|
},
|
|
5505
5638
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -5510,10 +5643,10 @@ function createDatoClient(params) {
|
|
|
5510
5643
|
filter: {
|
|
5511
5644
|
type: modelId,
|
|
5512
5645
|
only_valid: "true",
|
|
5513
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
5646
|
+
ids: !_optionalChain([records, 'optionalAccess', _284 => _284.length]) ? void 0 : records.join(",")
|
|
5514
5647
|
}
|
|
5515
5648
|
}).catch(
|
|
5516
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5649
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _285 => _285.response, 'optionalAccess', _286 => _286.body, 'optionalAccess', _287 => _287.data, 'optionalAccess', _288 => _288[0]]) || error)
|
|
5517
5650
|
);
|
|
5518
5651
|
return result;
|
|
5519
5652
|
} catch (_error) {
|
|
@@ -5529,10 +5662,10 @@ function createDatoClient(params) {
|
|
|
5529
5662
|
updateRecord: async (id, payload) => {
|
|
5530
5663
|
try {
|
|
5531
5664
|
await dato.items.update(id, payload).catch(
|
|
5532
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5665
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _289 => _289.response, 'optionalAccess', _290 => _290.body, 'optionalAccess', _291 => _291.data, 'optionalAccess', _292 => _292[0]]) || error)
|
|
5533
5666
|
);
|
|
5534
5667
|
} catch (_error) {
|
|
5535
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5668
|
+
if (_optionalChain([_error, 'optionalAccess', _293 => _293.attributes, 'optionalAccess', _294 => _294.details, 'optionalAccess', _295 => _295.message])) {
|
|
5536
5669
|
throw new Error(
|
|
5537
5670
|
[
|
|
5538
5671
|
`${_error.attributes.details.message}`,
|
|
@@ -5554,10 +5687,10 @@ function createDatoClient(params) {
|
|
|
5554
5687
|
enableFieldLocalization: async (args) => {
|
|
5555
5688
|
try {
|
|
5556
5689
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
5557
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5690
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _296 => _296.response, 'optionalAccess', _297 => _297.body, 'optionalAccess', _298 => _298.data, 'optionalAccess', _299 => _299[0]]) || error)
|
|
5558
5691
|
);
|
|
5559
5692
|
} catch (_error) {
|
|
5560
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5693
|
+
if (_optionalChain([_error, 'optionalAccess', _300 => _300.attributes, 'optionalAccess', _301 => _301.code]) === "NOT_FOUND") {
|
|
5561
5694
|
throw new Error(
|
|
5562
5695
|
[
|
|
5563
5696
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -5565,7 +5698,7 @@ function createDatoClient(params) {
|
|
|
5565
5698
|
].join("\n\n")
|
|
5566
5699
|
);
|
|
5567
5700
|
}
|
|
5568
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5701
|
+
if (_optionalChain([_error, 'optionalAccess', _302 => _302.attributes, 'optionalAccess', _303 => _303.details, 'optionalAccess', _304 => _304.message])) {
|
|
5569
5702
|
throw new Error(
|
|
5570
5703
|
[
|
|
5571
5704
|
`${_error.attributes.details.message}`,
|
|
@@ -5643,7 +5776,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
5643
5776
|
const records = await dato.findRecordsForModel(modelId);
|
|
5644
5777
|
const recordChoices = createRecordChoices(
|
|
5645
5778
|
records,
|
|
5646
|
-
_optionalChain([config, 'access',
|
|
5779
|
+
_optionalChain([config, 'access', _305 => _305.models, 'access', _306 => _306[modelId], 'optionalAccess', _307 => _307.records]) || [],
|
|
5647
5780
|
project
|
|
5648
5781
|
);
|
|
5649
5782
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -5662,14 +5795,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
5662
5795
|
},
|
|
5663
5796
|
async pull(locale, input2, initCtx) {
|
|
5664
5797
|
const result = {};
|
|
5665
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
5666
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
5798
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _308 => _308.models]) || {})) {
|
|
5799
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _309 => _309.models, 'access', _310 => _310[modelId], 'access', _311 => _311.records]) || [];
|
|
5667
5800
|
const recordIds = records.map((record) => record.id);
|
|
5668
5801
|
records = await dato.findRecords(recordIds);
|
|
5669
5802
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
5670
5803
|
if (records.length > 0) {
|
|
5671
5804
|
result[modelId] = {
|
|
5672
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
5805
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _312 => _312.models, 'optionalAccess', _313 => _313[modelId], 'optionalAccess', _314 => _314.fields]) || [],
|
|
5673
5806
|
records
|
|
5674
5807
|
};
|
|
5675
5808
|
}
|
|
@@ -5732,7 +5865,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
5732
5865
|
return records.map((record) => ({
|
|
5733
5866
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
5734
5867
|
value: record.id,
|
|
5735
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
5868
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _315 => _315.includes, 'call', _316 => _316(record.id)])
|
|
5736
5869
|
}));
|
|
5737
5870
|
}
|
|
5738
5871
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -6051,7 +6184,7 @@ function createVttLoader() {
|
|
|
6051
6184
|
if (!input2) {
|
|
6052
6185
|
return "";
|
|
6053
6186
|
}
|
|
6054
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
6187
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _317 => _317.parse, 'call', _318 => _318(input2), 'optionalAccess', _319 => _319.cues]);
|
|
6055
6188
|
if (Object.keys(vtt).length === 0) {
|
|
6056
6189
|
return {};
|
|
6057
6190
|
} else {
|
|
@@ -6105,7 +6238,7 @@ function variableExtractLoader(params) {
|
|
|
6105
6238
|
for (let i = 0; i < matches.length; i++) {
|
|
6106
6239
|
const match2 = matches[i];
|
|
6107
6240
|
const currentValue = result[key].value;
|
|
6108
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6241
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _320 => _320.replace, 'call', _321 => _321(match2, `{variable:${i}}`)]);
|
|
6109
6242
|
result[key].value = newValue;
|
|
6110
6243
|
result[key].variables[i] = match2;
|
|
6111
6244
|
}
|
|
@@ -6120,7 +6253,7 @@ function variableExtractLoader(params) {
|
|
|
6120
6253
|
const variable = valueObj.variables[i];
|
|
6121
6254
|
const currentValue = result[key];
|
|
6122
6255
|
if (typeof currentValue === "string") {
|
|
6123
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6256
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _322 => _322.replaceAll, 'call', _323 => _323(
|
|
6124
6257
|
`{variable:${i}}`,
|
|
6125
6258
|
variable
|
|
6126
6259
|
)]);
|
|
@@ -6324,7 +6457,7 @@ function createVueJsonLoader() {
|
|
|
6324
6457
|
return createLoader({
|
|
6325
6458
|
pull: async (locale, input2, ctx) => {
|
|
6326
6459
|
const parsed = parseVueFile(input2);
|
|
6327
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
6460
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _324 => _324.i18n, 'optionalAccess', _325 => _325[locale]]), () => ( {}));
|
|
6328
6461
|
},
|
|
6329
6462
|
push: async (locale, data, originalInput) => {
|
|
6330
6463
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -6509,7 +6642,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
6509
6642
|
objectExpression.properties.forEach((prop) => {
|
|
6510
6643
|
if (!t.isObjectProperty(prop)) return;
|
|
6511
6644
|
const key = getPropertyKey(prop);
|
|
6512
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
6645
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _326 => _326[key]]);
|
|
6513
6646
|
if (incomingVal === void 0) {
|
|
6514
6647
|
return;
|
|
6515
6648
|
}
|
|
@@ -6545,7 +6678,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
6545
6678
|
let modified = false;
|
|
6546
6679
|
arrayExpression.elements.forEach((element, index) => {
|
|
6547
6680
|
if (!element) return;
|
|
6548
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
6681
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _327 => _327[index]]);
|
|
6549
6682
|
if (incomingVal === void 0) return;
|
|
6550
6683
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
6551
6684
|
if (element.value !== incomingVal) {
|
|
@@ -7039,7 +7172,7 @@ var AST = class _AST {
|
|
|
7039
7172
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
7040
7173
|
if (this.isStart() && !this.type)
|
|
7041
7174
|
ret.unshift([]);
|
|
7042
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7175
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _328 => _328.#parent, 'optionalAccess', _329 => _329.type]) === "!")) {
|
|
7043
7176
|
ret.push({});
|
|
7044
7177
|
}
|
|
7045
7178
|
return ret;
|
|
@@ -7047,7 +7180,7 @@ var AST = class _AST {
|
|
|
7047
7180
|
isStart() {
|
|
7048
7181
|
if (this.#root === this)
|
|
7049
7182
|
return true;
|
|
7050
|
-
if (!_optionalChain([this, 'access',
|
|
7183
|
+
if (!_optionalChain([this, 'access', _330 => _330.#parent, 'optionalAccess', _331 => _331.isStart, 'call', _332 => _332()]))
|
|
7051
7184
|
return false;
|
|
7052
7185
|
if (this.#parentIndex === 0)
|
|
7053
7186
|
return true;
|
|
@@ -7063,12 +7196,12 @@ var AST = class _AST {
|
|
|
7063
7196
|
isEnd() {
|
|
7064
7197
|
if (this.#root === this)
|
|
7065
7198
|
return true;
|
|
7066
|
-
if (_optionalChain([this, 'access',
|
|
7199
|
+
if (_optionalChain([this, 'access', _333 => _333.#parent, 'optionalAccess', _334 => _334.type]) === "!")
|
|
7067
7200
|
return true;
|
|
7068
|
-
if (!_optionalChain([this, 'access',
|
|
7201
|
+
if (!_optionalChain([this, 'access', _335 => _335.#parent, 'optionalAccess', _336 => _336.isEnd, 'call', _337 => _337()]))
|
|
7069
7202
|
return false;
|
|
7070
7203
|
if (!this.type)
|
|
7071
|
-
return _optionalChain([this, 'access',
|
|
7204
|
+
return _optionalChain([this, 'access', _338 => _338.#parent, 'optionalAccess', _339 => _339.isEnd, 'call', _340 => _340()]);
|
|
7072
7205
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
7073
7206
|
return this.#parentIndex === pl - 1;
|
|
7074
7207
|
}
|
|
@@ -7313,7 +7446,7 @@ var AST = class _AST {
|
|
|
7313
7446
|
}
|
|
7314
7447
|
}
|
|
7315
7448
|
let end = "";
|
|
7316
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7449
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _341 => _341.#parent, 'optionalAccess', _342 => _342.type]) === "!") {
|
|
7317
7450
|
end = "(?:$|\\/)";
|
|
7318
7451
|
}
|
|
7319
7452
|
const final2 = start2 + src + end;
|
|
@@ -8414,7 +8547,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
8414
8547
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
8415
8548
|
const result = {
|
|
8416
8549
|
frontmatter: data.frontmatter,
|
|
8417
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
8550
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _343 => _343.codePlaceholders]) || {},
|
|
8418
8551
|
content
|
|
8419
8552
|
};
|
|
8420
8553
|
return result;
|
|
@@ -9514,7 +9647,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
9514
9647
|
]
|
|
9515
9648
|
});
|
|
9516
9649
|
const result = JSON.parse(response.text);
|
|
9517
|
-
return _optionalChain([result, 'optionalAccess',
|
|
9650
|
+
return _optionalChain([result, 'optionalAccess', _344 => _344.data]) || {};
|
|
9518
9651
|
}
|
|
9519
9652
|
}
|
|
9520
9653
|
function extractPayloadChunks(payload) {
|
|
@@ -9597,7 +9730,7 @@ function getPureModelProvider(provider) {
|
|
|
9597
9730
|
|
|
9598
9731
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
9599
9732
|
`;
|
|
9600
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
9733
|
+
switch (_optionalChain([provider, 'optionalAccess', _345 => _345.id])) {
|
|
9601
9734
|
case "openai": {
|
|
9602
9735
|
if (!process.env.OPENAI_API_KEY) {
|
|
9603
9736
|
throw new Error(
|
|
@@ -9655,7 +9788,7 @@ function getPureModelProvider(provider) {
|
|
|
9655
9788
|
})(provider.model);
|
|
9656
9789
|
}
|
|
9657
9790
|
default: {
|
|
9658
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
9791
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _346 => _346.id])));
|
|
9659
9792
|
}
|
|
9660
9793
|
}
|
|
9661
9794
|
}
|
|
@@ -9941,7 +10074,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
9941
10074
|
validateParams(i18nConfig, flags);
|
|
9942
10075
|
ora.succeed("Localization configuration is valid");
|
|
9943
10076
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
9944
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
10077
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _347 => _347.provider]);
|
|
9945
10078
|
if (isByokMode) {
|
|
9946
10079
|
authId = null;
|
|
9947
10080
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -9955,16 +10088,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
9955
10088
|
flags
|
|
9956
10089
|
});
|
|
9957
10090
|
let buckets = getBuckets(i18nConfig);
|
|
9958
|
-
if (_optionalChain([flags, 'access',
|
|
10091
|
+
if (_optionalChain([flags, 'access', _348 => _348.bucket, 'optionalAccess', _349 => _349.length])) {
|
|
9959
10092
|
buckets = buckets.filter(
|
|
9960
10093
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
9961
10094
|
);
|
|
9962
10095
|
}
|
|
9963
10096
|
ora.succeed("Buckets retrieved");
|
|
9964
|
-
if (_optionalChain([flags, 'access',
|
|
10097
|
+
if (_optionalChain([flags, 'access', _350 => _350.file, 'optionalAccess', _351 => _351.length])) {
|
|
9965
10098
|
buckets = buckets.map((bucket) => {
|
|
9966
10099
|
const paths = bucket.paths.filter(
|
|
9967
|
-
(path19) => flags.file.find((file) => _optionalChain([path19, 'access',
|
|
10100
|
+
(path19) => flags.file.find((file) => _optionalChain([path19, 'access', _352 => _352.pathPattern, 'optionalAccess', _353 => _353.includes, 'call', _354 => _354(file)]))
|
|
9968
10101
|
);
|
|
9969
10102
|
return { ...bucket, paths };
|
|
9970
10103
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -9985,7 +10118,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
9985
10118
|
});
|
|
9986
10119
|
}
|
|
9987
10120
|
}
|
|
9988
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
10121
|
+
const targetLocales = _optionalChain([flags, 'access', _355 => _355.locale, 'optionalAccess', _356 => _356.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
9989
10122
|
ora.start("Setting up localization cache...");
|
|
9990
10123
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
9991
10124
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -10270,7 +10403,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10270
10403
|
}
|
|
10271
10404
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
10272
10405
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
10273
|
-
if (!_optionalChain([flags, 'access',
|
|
10406
|
+
if (!_optionalChain([flags, 'access', _357 => _357.locale, 'optionalAccess', _358 => _358.length])) {
|
|
10274
10407
|
await deltaProcessor.saveChecksums(checksums);
|
|
10275
10408
|
}
|
|
10276
10409
|
}
|
|
@@ -10394,12 +10527,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
10394
10527
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
10395
10528
|
docUrl: "bucketNotFound"
|
|
10396
10529
|
});
|
|
10397
|
-
} else if (_optionalChain([flags, 'access',
|
|
10530
|
+
} else if (_optionalChain([flags, 'access', _359 => _359.locale, 'optionalAccess', _360 => _360.some, 'call', _361 => _361((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
10398
10531
|
throw new ValidationError({
|
|
10399
10532
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
10400
10533
|
docUrl: "localeTargetNotFound"
|
|
10401
10534
|
});
|
|
10402
|
-
} else if (_optionalChain([flags, 'access',
|
|
10535
|
+
} else if (_optionalChain([flags, 'access', _362 => _362.bucket, 'optionalAccess', _363 => _363.some, 'call', _364 => _364(
|
|
10403
10536
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
10404
10537
|
)])) {
|
|
10405
10538
|
throw new ValidationError({
|
|
@@ -10933,7 +11066,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
10933
11066
|
const response = await engine.whoami();
|
|
10934
11067
|
return {
|
|
10935
11068
|
authenticated: !!response,
|
|
10936
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
11069
|
+
username: _optionalChain([response, 'optionalAccess', _365 => _365.email])
|
|
10937
11070
|
};
|
|
10938
11071
|
} catch (error) {
|
|
10939
11072
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -11049,7 +11182,7 @@ function createExplicitLocalizer(provider) {
|
|
|
11049
11182
|
}
|
|
11050
11183
|
function createAiSdkLocalizer(params) {
|
|
11051
11184
|
const skipAuth = params.skipAuth === true;
|
|
11052
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
11185
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _366 => _366.apiKeyName]), () => ( ""))];
|
|
11053
11186
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
11054
11187
|
throw new Error(
|
|
11055
11188
|
_dedent2.default`
|
|
@@ -11183,8 +11316,8 @@ async function setup(input2) {
|
|
|
11183
11316
|
throw new Error(
|
|
11184
11317
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
11185
11318
|
);
|
|
11186
|
-
} else if (_optionalChain([ctx, 'access',
|
|
11187
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
11319
|
+
} else if (_optionalChain([ctx, 'access', _367 => _367.flags, 'access', _368 => _368.bucket, 'optionalAccess', _369 => _369.some, 'call', _370 => _370(
|
|
11320
|
+
(bucket) => !_optionalChain([ctx, 'access', _371 => _371.config, 'optionalAccess', _372 => _372.buckets, 'access', _373 => _373[bucket]])
|
|
11188
11321
|
)])) {
|
|
11189
11322
|
throw new Error(
|
|
11190
11323
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -11197,7 +11330,7 @@ async function setup(input2) {
|
|
|
11197
11330
|
title: "Selecting localization provider",
|
|
11198
11331
|
task: async (ctx, task) => {
|
|
11199
11332
|
ctx.localizer = createLocalizer(
|
|
11200
|
-
_optionalChain([ctx, 'access',
|
|
11333
|
+
_optionalChain([ctx, 'access', _374 => _374.config, 'optionalAccess', _375 => _375.provider]),
|
|
11201
11334
|
ctx.flags.apiKey
|
|
11202
11335
|
);
|
|
11203
11336
|
if (!ctx.localizer) {
|
|
@@ -11210,7 +11343,7 @@ async function setup(input2) {
|
|
|
11210
11343
|
},
|
|
11211
11344
|
{
|
|
11212
11345
|
title: "Checking authentication",
|
|
11213
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
11346
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _376 => _376.localizer, 'optionalAccess', _377 => _377.id]) === "Lingo.dev",
|
|
11214
11347
|
task: async (ctx, task) => {
|
|
11215
11348
|
const authStatus = await ctx.localizer.checkAuth();
|
|
11216
11349
|
if (!authStatus.authenticated) {
|
|
@@ -11223,7 +11356,7 @@ async function setup(input2) {
|
|
|
11223
11356
|
},
|
|
11224
11357
|
{
|
|
11225
11358
|
title: "Validating configuration",
|
|
11226
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
11359
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _378 => _378.localizer, 'optionalAccess', _379 => _379.id]) !== "Lingo.dev",
|
|
11227
11360
|
task: async (ctx, task) => {
|
|
11228
11361
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
11229
11362
|
if (!validationStatus.valid) {
|
|
@@ -11554,7 +11687,7 @@ function createWorkerTask(args) {
|
|
|
11554
11687
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
11555
11688
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
11556
11689
|
).filter(
|
|
11557
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
11690
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _380 => _380.onlyKeys, 'optionalAccess', _381 => _381.some, 'call', _382 => _382(
|
|
11558
11691
|
(pattern) => minimatch(key, pattern)
|
|
11559
11692
|
)])
|
|
11560
11693
|
).fromPairs().value();
|
|
@@ -11622,7 +11755,7 @@ function createWorkerTask(args) {
|
|
|
11622
11755
|
finalRenamedTargetData
|
|
11623
11756
|
);
|
|
11624
11757
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
11625
|
-
if (!_optionalChain([args, 'access',
|
|
11758
|
+
if (!_optionalChain([args, 'access', _383 => _383.ctx, 'access', _384 => _384.flags, 'access', _385 => _385.targetLocale, 'optionalAccess', _386 => _386.length])) {
|
|
11626
11759
|
await deltaProcessor.saveChecksums(checksums);
|
|
11627
11760
|
}
|
|
11628
11761
|
});
|
|
@@ -11827,10 +11960,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
11827
11960
|
async function frozen(input2) {
|
|
11828
11961
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
11829
11962
|
let buckets = getBuckets(input2.config);
|
|
11830
|
-
if (_optionalChain([input2, 'access',
|
|
11963
|
+
if (_optionalChain([input2, 'access', _387 => _387.flags, 'access', _388 => _388.bucket, 'optionalAccess', _389 => _389.length])) {
|
|
11831
11964
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
11832
11965
|
}
|
|
11833
|
-
if (_optionalChain([input2, 'access',
|
|
11966
|
+
if (_optionalChain([input2, 'access', _390 => _390.flags, 'access', _391 => _391.file, 'optionalAccess', _392 => _392.length])) {
|
|
11834
11967
|
buckets = buckets.map((bucket) => {
|
|
11835
11968
|
const paths = bucket.paths.filter(
|
|
11836
11969
|
(p) => input2.flags.file.some(
|
|
@@ -11967,13 +12100,13 @@ async function frozen(input2) {
|
|
|
11967
12100
|
|
|
11968
12101
|
// src/cli/cmd/run/_utils.ts
|
|
11969
12102
|
async function determineAuthId(ctx) {
|
|
11970
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
12103
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _393 => _393.config, 'optionalAccess', _394 => _394.provider]);
|
|
11971
12104
|
if (isByokMode) {
|
|
11972
12105
|
return null;
|
|
11973
12106
|
} else {
|
|
11974
12107
|
try {
|
|
11975
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
11976
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
12108
|
+
const authStatus = await _optionalChain([ctx, 'access', _395 => _395.localizer, 'optionalAccess', _396 => _396.checkAuth, 'call', _397 => _397()]);
|
|
12109
|
+
return _optionalChain([authStatus, 'optionalAccess', _398 => _398.username]) || null;
|
|
11977
12110
|
} catch (e3) {
|
|
11978
12111
|
return null;
|
|
11979
12112
|
}
|
|
@@ -12171,7 +12304,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12171
12304
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
12172
12305
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
12173
12306
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
12174
|
-
_optionalChain([this, 'access',
|
|
12307
|
+
_optionalChain([this, 'access', _399 => _399.platformKit, 'optionalAccess', _400 => _400.gitConfig, 'call', _401 => _401()]);
|
|
12175
12308
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
12176
12309
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
12177
12310
|
if (!processOwnCommits) {
|
|
@@ -12203,7 +12336,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12203
12336
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
12204
12337
|
var PullRequestFlow = class extends InBranchFlow {
|
|
12205
12338
|
async preRun() {
|
|
12206
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
12339
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _402 => _402()]);
|
|
12207
12340
|
if (!canContinue) {
|
|
12208
12341
|
return false;
|
|
12209
12342
|
}
|
|
@@ -12470,10 +12603,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
12470
12603
|
repo_slug: this.platformConfig.repositoryName,
|
|
12471
12604
|
state: "OPEN"
|
|
12472
12605
|
}).then(({ data: { values } }) => {
|
|
12473
|
-
return _optionalChain([values, 'optionalAccess',
|
|
12474
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
12606
|
+
return _optionalChain([values, 'optionalAccess', _403 => _403.find, 'call', _404 => _404(
|
|
12607
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _405 => _405.branch, 'optionalAccess', _406 => _406.name]) === branch && _optionalChain([destination, 'optionalAccess', _407 => _407.branch, 'optionalAccess', _408 => _408.name]) === this.platformConfig.baseBranchName
|
|
12475
12608
|
)]);
|
|
12476
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
12609
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _409 => _409.id]));
|
|
12477
12610
|
}
|
|
12478
12611
|
async closePullRequest({ pullRequestNumber }) {
|
|
12479
12612
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -12569,7 +12702,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
12569
12702
|
repo: this.platformConfig.repositoryName,
|
|
12570
12703
|
base: this.platformConfig.baseBranchName,
|
|
12571
12704
|
state: "open"
|
|
12572
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
12705
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _410 => _410.number]));
|
|
12573
12706
|
}
|
|
12574
12707
|
async closePullRequest({ pullRequestNumber }) {
|
|
12575
12708
|
await this.octokit.rest.pulls.update({
|
|
@@ -12696,7 +12829,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
12696
12829
|
sourceBranch: branch,
|
|
12697
12830
|
state: "opened"
|
|
12698
12831
|
});
|
|
12699
|
-
return _optionalChain([mergeRequests, 'access',
|
|
12832
|
+
return _optionalChain([mergeRequests, 'access', _411 => _411[0], 'optionalAccess', _412 => _412.iid]);
|
|
12700
12833
|
}
|
|
12701
12834
|
async closePullRequest({
|
|
12702
12835
|
pullRequestNumber
|
|
@@ -12808,7 +12941,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12808
12941
|
}
|
|
12809
12942
|
const env = {
|
|
12810
12943
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
12811
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
12944
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _413 => _413.pullRequest, 'optionalAccess', _414 => _414.toString, 'call', _415 => _415()]) || "false",
|
|
12812
12945
|
...options.commitMessage && {
|
|
12813
12946
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
12814
12947
|
},
|
|
@@ -12834,7 +12967,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12834
12967
|
const { isPullRequestMode } = platformKit.config;
|
|
12835
12968
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
12836
12969
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
12837
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
12970
|
+
const canRun = await _optionalChain([flow, 'access', _416 => _416.preRun, 'optionalCall', _417 => _417()]);
|
|
12838
12971
|
if (canRun === false) {
|
|
12839
12972
|
return;
|
|
12840
12973
|
}
|
|
@@ -12844,7 +12977,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12844
12977
|
if (!hasChanges) {
|
|
12845
12978
|
return;
|
|
12846
12979
|
}
|
|
12847
|
-
await _optionalChain([flow, 'access',
|
|
12980
|
+
await _optionalChain([flow, 'access', _418 => _418.postRun, 'optionalCall', _419 => _419()]);
|
|
12848
12981
|
});
|
|
12849
12982
|
function parseBooleanArg(val) {
|
|
12850
12983
|
if (val === true) return true;
|
|
@@ -12881,8 +13014,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
12881
13014
|
}
|
|
12882
13015
|
}
|
|
12883
13016
|
function checkForPendingOperations() {
|
|
12884
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
12885
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
13017
|
+
const activeHandles = _optionalChain([process, 'access', _420 => _420._getActiveHandles, 'optionalCall', _421 => _421()]) || [];
|
|
13018
|
+
const activeRequests = _optionalChain([process, 'access', _422 => _422._getActiveRequests, 'optionalCall', _423 => _423()]) || [];
|
|
12886
13019
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
12887
13020
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
12888
13021
|
return false;
|
|
@@ -12951,17 +13084,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
12951
13084
|
flags
|
|
12952
13085
|
});
|
|
12953
13086
|
let buckets = getBuckets(i18nConfig);
|
|
12954
|
-
if (_optionalChain([flags, 'access',
|
|
13087
|
+
if (_optionalChain([flags, 'access', _424 => _424.bucket, 'optionalAccess', _425 => _425.length])) {
|
|
12955
13088
|
buckets = buckets.filter(
|
|
12956
13089
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
12957
13090
|
);
|
|
12958
13091
|
}
|
|
12959
13092
|
ora.succeed("Buckets retrieved");
|
|
12960
|
-
if (_optionalChain([flags, 'access',
|
|
13093
|
+
if (_optionalChain([flags, 'access', _426 => _426.file, 'optionalAccess', _427 => _427.length])) {
|
|
12961
13094
|
buckets = buckets.map((bucket) => {
|
|
12962
13095
|
const paths = bucket.paths.filter(
|
|
12963
13096
|
(path19) => flags.file.find(
|
|
12964
|
-
(file) => _optionalChain([path19, 'access',
|
|
13097
|
+
(file) => _optionalChain([path19, 'access', _428 => _428.pathPattern, 'optionalAccess', _429 => _429.includes, 'call', _430 => _430(file)]) || _optionalChain([path19, 'access', _431 => _431.pathPattern, 'optionalAccess', _432 => _432.match, 'call', _433 => _433(file)]) || minimatch(path19.pathPattern, file)
|
|
12965
13098
|
)
|
|
12966
13099
|
);
|
|
12967
13100
|
return { ...bucket, paths };
|
|
@@ -12981,7 +13114,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
12981
13114
|
});
|
|
12982
13115
|
}
|
|
12983
13116
|
}
|
|
12984
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
13117
|
+
const targetLocales = _optionalChain([flags, 'access', _434 => _434.locale, 'optionalAccess', _435 => _435.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
12985
13118
|
let totalSourceKeyCount = 0;
|
|
12986
13119
|
let uniqueKeysToTranslate = 0;
|
|
12987
13120
|
let totalExistingTranslations = 0;
|
|
@@ -13389,12 +13522,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
13389
13522
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
13390
13523
|
docUrl: "bucketNotFound"
|
|
13391
13524
|
});
|
|
13392
|
-
} else if (_optionalChain([flags, 'access',
|
|
13525
|
+
} else if (_optionalChain([flags, 'access', _436 => _436.locale, 'optionalAccess', _437 => _437.some, 'call', _438 => _438((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
13393
13526
|
throw new CLIError({
|
|
13394
13527
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
13395
13528
|
docUrl: "localeTargetNotFound"
|
|
13396
13529
|
});
|
|
13397
|
-
} else if (_optionalChain([flags, 'access',
|
|
13530
|
+
} else if (_optionalChain([flags, 'access', _439 => _439.bucket, 'optionalAccess', _440 => _440.some, 'call', _441 => _441(
|
|
13398
13531
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
13399
13532
|
)])) {
|
|
13400
13533
|
throw new CLIError({
|
|
@@ -13486,7 +13619,7 @@ async function renderHero2() {
|
|
|
13486
13619
|
// package.json
|
|
13487
13620
|
var package_default = {
|
|
13488
13621
|
name: "lingo.dev",
|
|
13489
|
-
version: "0.117.
|
|
13622
|
+
version: "0.117.2",
|
|
13490
13623
|
description: "Lingo.dev CLI",
|
|
13491
13624
|
private: false,
|
|
13492
13625
|
publishConfig: {
|
|
@@ -13778,7 +13911,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
13778
13911
|
if (options.file && options.file.length) {
|
|
13779
13912
|
buckets = buckets.map((bucket) => {
|
|
13780
13913
|
const paths = bucket.paths.filter(
|
|
13781
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
13914
|
+
(bucketPath) => _optionalChain([options, 'access', _442 => _442.file, 'optionalAccess', _443 => _443.some, 'call', _444 => _444((f) => bucketPath.pathPattern.includes(f))])
|
|
13782
13915
|
);
|
|
13783
13916
|
return { ...bucket, paths };
|
|
13784
13917
|
}).filter((bucket) => bucket.paths.length > 0);
|