lingo.dev 0.117.7 → 0.117.9
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 +645 -151
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +522 -28
- package/build/cli.mjs.map +1 -1
- package/package.json +5 -5
package/build/cli.cjs
CHANGED
|
@@ -2325,9 +2325,119 @@ function _isMetadataKey(key) {
|
|
|
2325
2325
|
return key.startsWith("@");
|
|
2326
2326
|
}
|
|
2327
2327
|
|
|
2328
|
+
// src/cli/loaders/ail.ts
|
|
2329
|
+
var _xml2js = require('xml2js');
|
|
2330
|
+
function createAilLoader() {
|
|
2331
|
+
return createLoader({
|
|
2332
|
+
async pull(locale, input2) {
|
|
2333
|
+
const result = {};
|
|
2334
|
+
if (!input2 || !input2.trim()) {
|
|
2335
|
+
return result;
|
|
2336
|
+
}
|
|
2337
|
+
try {
|
|
2338
|
+
const parsed = await _xml2js.parseStringPromise.call(void 0, input2, {
|
|
2339
|
+
explicitArray: true,
|
|
2340
|
+
// Always use arrays for consistency
|
|
2341
|
+
mergeAttrs: false,
|
|
2342
|
+
// Keep attributes separate in $
|
|
2343
|
+
trim: true,
|
|
2344
|
+
explicitRoot: true
|
|
2345
|
+
});
|
|
2346
|
+
const dictionary = parsed.DICTIONARY;
|
|
2347
|
+
if (!dictionary) {
|
|
2348
|
+
return result;
|
|
2349
|
+
}
|
|
2350
|
+
const entries = dictionary.ENTRY || [];
|
|
2351
|
+
for (const entry of entries) {
|
|
2352
|
+
const id = _optionalChain([entry, 'access', _112 => _112.$, 'optionalAccess', _113 => _113.id]);
|
|
2353
|
+
if (!id) {
|
|
2354
|
+
continue;
|
|
2355
|
+
}
|
|
2356
|
+
const strings = entry.STRING || [];
|
|
2357
|
+
const sourceString = strings.find(
|
|
2358
|
+
(s) => _optionalChain([s, 'access', _114 => _114.$, 'optionalAccess', _115 => _115.lang]) === locale
|
|
2359
|
+
);
|
|
2360
|
+
if (_optionalChain([sourceString, 'optionalAccess', _116 => _116.$, 'access', _117 => _117.value])) {
|
|
2361
|
+
result[id] = sourceString.$.value;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
return result;
|
|
2365
|
+
} catch (error) {
|
|
2366
|
+
console.error("Failed to parse AIL file:", error);
|
|
2367
|
+
return result;
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
async push(locale, data, originalInput) {
|
|
2371
|
+
if (!originalInput || !originalInput.trim()) {
|
|
2372
|
+
const dictionary = {
|
|
2373
|
+
$: { type: "multilanguage" },
|
|
2374
|
+
ENTRY: Object.entries(data).map(([id, value]) => ({
|
|
2375
|
+
$: { id },
|
|
2376
|
+
STRING: [
|
|
2377
|
+
{
|
|
2378
|
+
$: { lang: locale, value }
|
|
2379
|
+
}
|
|
2380
|
+
]
|
|
2381
|
+
}))
|
|
2382
|
+
};
|
|
2383
|
+
const builder = new (0, _xml2js.Builder)({
|
|
2384
|
+
xmldec: { version: "1.0", encoding: "UTF-8" },
|
|
2385
|
+
headless: false
|
|
2386
|
+
});
|
|
2387
|
+
return builder.buildObject({ DICTIONARY: dictionary });
|
|
2388
|
+
}
|
|
2389
|
+
try {
|
|
2390
|
+
const parsed = await _xml2js.parseStringPromise.call(void 0, originalInput, {
|
|
2391
|
+
explicitArray: true,
|
|
2392
|
+
mergeAttrs: false,
|
|
2393
|
+
trim: true,
|
|
2394
|
+
explicitRoot: true
|
|
2395
|
+
});
|
|
2396
|
+
const dictionary = parsed.DICTIONARY;
|
|
2397
|
+
if (!dictionary) {
|
|
2398
|
+
throw new Error("No DICTIONARY root element found");
|
|
2399
|
+
}
|
|
2400
|
+
const entries = dictionary.ENTRY || [];
|
|
2401
|
+
for (const [id, value] of Object.entries(data)) {
|
|
2402
|
+
let entry = entries.find((e) => _optionalChain([e, 'access', _118 => _118.$, 'optionalAccess', _119 => _119.id]) === id);
|
|
2403
|
+
if (!entry) {
|
|
2404
|
+
entry = {
|
|
2405
|
+
$: { id },
|
|
2406
|
+
STRING: []
|
|
2407
|
+
};
|
|
2408
|
+
entries.push(entry);
|
|
2409
|
+
}
|
|
2410
|
+
if (!entry.STRING) {
|
|
2411
|
+
entry.STRING = [];
|
|
2412
|
+
}
|
|
2413
|
+
let targetString = entry.STRING.find(
|
|
2414
|
+
(s) => _optionalChain([s, 'access', _120 => _120.$, 'optionalAccess', _121 => _121.lang]) === locale
|
|
2415
|
+
);
|
|
2416
|
+
if (targetString) {
|
|
2417
|
+
targetString.$.value = value;
|
|
2418
|
+
} else {
|
|
2419
|
+
entry.STRING.push({
|
|
2420
|
+
$: { lang: locale, value }
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
dictionary.ENTRY = entries;
|
|
2425
|
+
const builder = new (0, _xml2js.Builder)({
|
|
2426
|
+
xmldec: { version: "1.0", encoding: "UTF-8" },
|
|
2427
|
+
headless: false
|
|
2428
|
+
});
|
|
2429
|
+
return builder.buildObject({ DICTIONARY: dictionary });
|
|
2430
|
+
} catch (error) {
|
|
2431
|
+
console.error("Failed to build AIL file:", error);
|
|
2432
|
+
throw error;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2328
2438
|
// src/cli/loaders/android.ts
|
|
2329
2439
|
var _module = require('module');
|
|
2330
|
-
|
|
2440
|
+
|
|
2331
2441
|
var require2 = _module.createRequire.call(void 0, _chunkHTMTB46Pcjs.importMetaUrl);
|
|
2332
2442
|
var sax = require2("sax");
|
|
2333
2443
|
var defaultAndroidResourcesXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
@@ -2432,7 +2542,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2432
2542
|
const resourceNodes = [];
|
|
2433
2543
|
let metaIndex = 0;
|
|
2434
2544
|
for (const child of resourcesNode.$$) {
|
|
2435
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2545
|
+
const elementName = _optionalChain([child, 'optionalAccess', _122 => _122["#name"]]);
|
|
2436
2546
|
if (!isResourceElementName(elementName)) {
|
|
2437
2547
|
continue;
|
|
2438
2548
|
}
|
|
@@ -2440,11 +2550,11 @@ async function parseAndroidDocument(input2) {
|
|
|
2440
2550
|
if (!meta || meta.type !== elementName) {
|
|
2441
2551
|
continue;
|
|
2442
2552
|
}
|
|
2443
|
-
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2553
|
+
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _123 => _123.$, 'optionalAccess', _124 => _124.name]), () => ( meta.name));
|
|
2444
2554
|
if (!name) {
|
|
2445
2555
|
continue;
|
|
2446
2556
|
}
|
|
2447
|
-
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2557
|
+
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _125 => _125.$, 'optionalAccess', _126 => _126.translatable]), () => ( ""))).toLowerCase() !== "false";
|
|
2448
2558
|
switch (meta.type) {
|
|
2449
2559
|
case "string": {
|
|
2450
2560
|
resourceNodes.push({
|
|
@@ -2457,7 +2567,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2457
2567
|
break;
|
|
2458
2568
|
}
|
|
2459
2569
|
case "string-array": {
|
|
2460
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2570
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _127 => _127.item]), () => ( []));
|
|
2461
2571
|
const items = [];
|
|
2462
2572
|
const templateItems = meta.items;
|
|
2463
2573
|
for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
|
|
@@ -2481,7 +2591,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2481
2591
|
break;
|
|
2482
2592
|
}
|
|
2483
2593
|
case "plurals": {
|
|
2484
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2594
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _128 => _128.item]), () => ( []));
|
|
2485
2595
|
const templateItems = meta.items;
|
|
2486
2596
|
const items = [];
|
|
2487
2597
|
for (const templateItem of templateItems) {
|
|
@@ -2490,7 +2600,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2490
2600
|
continue;
|
|
2491
2601
|
}
|
|
2492
2602
|
const nodeItem = itemNodes.find(
|
|
2493
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2603
|
+
(item) => _optionalChain([item, 'optionalAccess', _129 => _129.$, 'optionalAccess', _130 => _130.quantity]) === quantity
|
|
2494
2604
|
);
|
|
2495
2605
|
if (!nodeItem) {
|
|
2496
2606
|
continue;
|
|
@@ -2764,7 +2874,7 @@ function cloneResourceNode(resource) {
|
|
|
2764
2874
|
const nodeClone = deepClone(resource.node);
|
|
2765
2875
|
const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
|
|
2766
2876
|
const items = itemNodes.map((itemNode, index) => {
|
|
2767
|
-
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access',
|
|
2877
|
+
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access', _131 => _131.items, 'access', _132 => _132[index], 'optionalAccess', _133 => _133.meta]), () => ( _optionalChain([resource, 'access', _134 => _134.items, 'access', _135 => _135[resource.items.length - 1], 'optionalAccess', _136 => _136.meta]))), () => ( makeTextMeta([])));
|
|
2768
2878
|
return {
|
|
2769
2879
|
node: itemNode,
|
|
2770
2880
|
meta: cloneTextMeta(templateMeta)
|
|
@@ -2784,7 +2894,7 @@ function cloneResourceNode(resource) {
|
|
|
2784
2894
|
const items = [];
|
|
2785
2895
|
for (const templateItem of resource.items) {
|
|
2786
2896
|
const cloneNode = itemNodes.find(
|
|
2787
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2897
|
+
(item) => _optionalChain([item, 'optionalAccess', _137 => _137.$, 'optionalAccess', _138 => _138.quantity]) === templateItem.quantity
|
|
2788
2898
|
);
|
|
2789
2899
|
if (!cloneNode) {
|
|
2790
2900
|
continue;
|
|
@@ -3040,8 +3150,8 @@ function cloneDocumentStructure(document) {
|
|
|
3040
3150
|
resourceNodes.map((r) => resourceLookupKey(r.type, r.name))
|
|
3041
3151
|
);
|
|
3042
3152
|
let filtered = resourcesClone.$$.filter((child) => {
|
|
3043
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
3044
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3153
|
+
const elementName = _optionalChain([child, 'optionalAccess', _139 => _139["#name"]]);
|
|
3154
|
+
const name = _optionalChain([child, 'optionalAccess', _140 => _140.$, 'optionalAccess', _141 => _141.name]);
|
|
3045
3155
|
if (!isResourceElementName(elementName) || !name) {
|
|
3046
3156
|
return true;
|
|
3047
3157
|
}
|
|
@@ -3050,7 +3160,7 @@ function cloneDocumentStructure(document) {
|
|
|
3050
3160
|
const cleaned = [];
|
|
3051
3161
|
let lastWasWhitespace = false;
|
|
3052
3162
|
for (const child of filtered) {
|
|
3053
|
-
const isWhitespace = _optionalChain([child, 'optionalAccess',
|
|
3163
|
+
const isWhitespace = _optionalChain([child, 'optionalAccess', _142 => _142["#name"]]) === "__text__" && (!child._ || child._.trim() === "");
|
|
3054
3164
|
if (isWhitespace) {
|
|
3055
3165
|
if (!lastWasWhitespace) {
|
|
3056
3166
|
cleaned.push(child);
|
|
@@ -3072,8 +3182,8 @@ function buildResourceLookup(resources) {
|
|
|
3072
3182
|
const lookup = /* @__PURE__ */ new Map();
|
|
3073
3183
|
const children = Array.isArray(resources.$$) ? resources.$$ : [];
|
|
3074
3184
|
for (const child of children) {
|
|
3075
|
-
const type = _optionalChain([child, 'optionalAccess',
|
|
3076
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3185
|
+
const type = _optionalChain([child, 'optionalAccess', _143 => _143["#name"]]);
|
|
3186
|
+
const name = _optionalChain([child, 'optionalAccess', _144 => _144.$, 'optionalAccess', _145 => _145.name]);
|
|
3077
3187
|
if (!type || !name || !isResourceElementName(type)) {
|
|
3078
3188
|
continue;
|
|
3079
3189
|
}
|
|
@@ -3102,7 +3212,7 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3102
3212
|
}
|
|
3103
3213
|
case "string-array": {
|
|
3104
3214
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3105
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3215
|
+
(child) => _optionalChain([child, 'optionalAccess', _146 => _146["#name"]]) === "item"
|
|
3106
3216
|
);
|
|
3107
3217
|
node.item = childItems;
|
|
3108
3218
|
if (childItems.length < resource.items.length) {
|
|
@@ -3131,12 +3241,12 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3131
3241
|
}
|
|
3132
3242
|
case "plurals": {
|
|
3133
3243
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3134
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3244
|
+
(child) => _optionalChain([child, 'optionalAccess', _147 => _147["#name"]]) === "item"
|
|
3135
3245
|
);
|
|
3136
3246
|
node.item = childItems;
|
|
3137
3247
|
const itemMap = /* @__PURE__ */ new Map();
|
|
3138
3248
|
for (const item of childItems) {
|
|
3139
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
3249
|
+
if (_optionalChain([item, 'optionalAccess', _148 => _148.$, 'optionalAccess', _149 => _149.quantity])) {
|
|
3140
3250
|
itemMap.set(item.$.quantity, item);
|
|
3141
3251
|
}
|
|
3142
3252
|
}
|
|
@@ -3407,8 +3517,8 @@ function serializeElement(node) {
|
|
|
3407
3517
|
const attrString = Object.entries(attributes).map(([key, value]) => ` ${key}="${escapeAttributeValue(String(value))}"`).join("");
|
|
3408
3518
|
const children = Array.isArray(node.$$) ? node.$$ : [];
|
|
3409
3519
|
if (children.length === 0) {
|
|
3410
|
-
const
|
|
3411
|
-
return `<${name}${attrString}>${
|
|
3520
|
+
const textContent3 = _nullishCoalesce(node._, () => ( ""));
|
|
3521
|
+
return `<${name}${attrString}>${textContent3}</${name}>`;
|
|
3412
3522
|
}
|
|
3413
3523
|
const childContent = children.map(serializeElement).join("");
|
|
3414
3524
|
return `<${name}${attrString}>${childContent}</${name}>`;
|
|
@@ -3426,7 +3536,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
3426
3536
|
|
|
3427
3537
|
function detectKeyColumnName(csvString) {
|
|
3428
3538
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
3429
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
3539
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _150 => _150[0], 'optionalAccess', _151 => _151.trim, 'call', _152 => _152()]);
|
|
3430
3540
|
return firstColumn || "KEY";
|
|
3431
3541
|
}
|
|
3432
3542
|
function createCsvLoader() {
|
|
@@ -3497,10 +3607,10 @@ function createPullOutputCleaner() {
|
|
|
3497
3607
|
}
|
|
3498
3608
|
|
|
3499
3609
|
// src/cli/loaders/html.ts
|
|
3500
|
-
var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2); var htmlparser22 = _interopRequireWildcard(_htmlparser2);
|
|
3610
|
+
var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2); var htmlparser22 = _interopRequireWildcard(_htmlparser2); var htmlparser23 = _interopRequireWildcard(_htmlparser2);
|
|
3501
3611
|
var _domhandler = require('domhandler');
|
|
3502
|
-
var _domutils = require('domutils'); var domutils = _interopRequireWildcard(_domutils);
|
|
3503
|
-
var _domserializer = require('dom-serializer'); var DomSerializer = _interopRequireWildcard(_domserializer);
|
|
3612
|
+
var _domutils = require('domutils'); var domutils = _interopRequireWildcard(_domutils); var domutils2 = _interopRequireWildcard(_domutils);
|
|
3613
|
+
var _domserializer = require('dom-serializer'); var DomSerializer = _interopRequireWildcard(_domserializer); var DomSerializer2 = _interopRequireWildcard(_domserializer);
|
|
3504
3614
|
function createHtmlLoader() {
|
|
3505
3615
|
const PHRASING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
3506
3616
|
// Text-level semantics
|
|
@@ -3656,7 +3766,7 @@ function createHtmlLoader() {
|
|
|
3656
3766
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
3657
3767
|
if (!attrs) return;
|
|
3658
3768
|
for (const attr of attrs) {
|
|
3659
|
-
const value = _optionalChain([element, 'access',
|
|
3769
|
+
const value = _optionalChain([element, 'access', _153 => _153.attribs, 'optionalAccess', _154 => _154[attr]]);
|
|
3660
3770
|
if (value && value.trim()) {
|
|
3661
3771
|
result[`${path19}#${attr}`] = value.trim();
|
|
3662
3772
|
}
|
|
@@ -3848,7 +3958,7 @@ function createMarkdownLoader() {
|
|
|
3848
3958
|
yaml: yamlEngine
|
|
3849
3959
|
}
|
|
3850
3960
|
});
|
|
3851
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
3961
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _155 => _155.trim, 'call', _156 => _156()]), () => ( ""))).filter(Boolean);
|
|
3852
3962
|
return {
|
|
3853
3963
|
...Object.fromEntries(
|
|
3854
3964
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -3867,7 +3977,7 @@ function createMarkdownLoader() {
|
|
|
3867
3977
|
);
|
|
3868
3978
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
3869
3979
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
3870
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
3980
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _157 => _157.trim, 'call', _158 => _158()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
3871
3981
|
if (Object.keys(frontmatter).length > 0) {
|
|
3872
3982
|
content = `
|
|
3873
3983
|
${content}`;
|
|
@@ -3892,7 +4002,7 @@ function createMarkdocLoader() {
|
|
|
3892
4002
|
const result = {};
|
|
3893
4003
|
const counters = {};
|
|
3894
4004
|
traverseAndExtract(ast, "", result, counters);
|
|
3895
|
-
if (_optionalChain([ast, 'access',
|
|
4005
|
+
if (_optionalChain([ast, 'access', _159 => _159.attributes, 'optionalAccess', _160 => _160.frontmatter])) {
|
|
3896
4006
|
const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
|
|
3897
4007
|
Object.entries(frontmatter).forEach(([key, value]) => {
|
|
3898
4008
|
if (typeof value === "string") {
|
|
@@ -3938,7 +4048,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
3938
4048
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3939
4049
|
semanticType = nodeSemanticType;
|
|
3940
4050
|
}
|
|
3941
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4051
|
+
if (node.type === "text" && _optionalChain([node, 'access', _161 => _161.attributes, 'optionalAccess', _162 => _162.content])) {
|
|
3942
4052
|
const content = node.attributes.content;
|
|
3943
4053
|
if (typeof content === "string" && content.trim()) {
|
|
3944
4054
|
if (semanticType) {
|
|
@@ -3965,7 +4075,7 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
3965
4075
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3966
4076
|
semanticType = nodeSemanticType;
|
|
3967
4077
|
}
|
|
3968
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4078
|
+
if (node.type === "text" && _optionalChain([node, 'access', _163 => _163.attributes, 'optionalAccess', _164 => _164.content])) {
|
|
3969
4079
|
const content = node.attributes.content;
|
|
3970
4080
|
if (typeof content === "string" && content.trim()) {
|
|
3971
4081
|
if (semanticType) {
|
|
@@ -3988,7 +4098,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
3988
4098
|
if (!node || typeof node !== "object") {
|
|
3989
4099
|
return;
|
|
3990
4100
|
}
|
|
3991
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4101
|
+
if (node.type === "text" && _optionalChain([node, 'access', _165 => _165.attributes, 'optionalAccess', _166 => _166.content])) {
|
|
3992
4102
|
const content = node.attributes.content;
|
|
3993
4103
|
if (typeof content === "string") {
|
|
3994
4104
|
const contentPath = path19 ? `${path19}/attributes/content` : "attributes/content";
|
|
@@ -4194,9 +4304,9 @@ function serializeXmlNode(node) {
|
|
|
4194
4304
|
const attrString = Object.entries(attrs).map(([key, value]) => ` ${key}="${escapeAttributeValue2(String(value))}"`).join("");
|
|
4195
4305
|
const children = node.$$ || [];
|
|
4196
4306
|
if (children.length === 0) {
|
|
4197
|
-
const
|
|
4198
|
-
if (
|
|
4199
|
-
return `<${name}${attrString}>${
|
|
4307
|
+
const textContent3 = node._ || "";
|
|
4308
|
+
if (textContent3) {
|
|
4309
|
+
return `<${name}${attrString}>${textContent3}</${name}>`;
|
|
4200
4310
|
}
|
|
4201
4311
|
return `<${name}${attrString} />`;
|
|
4202
4312
|
}
|
|
@@ -4253,9 +4363,9 @@ function serializeElement2(node, indent2 = "") {
|
|
|
4253
4363
|
const attrString = Object.entries(attributes).map(([key, value]) => ` ${key}="${escapeAttributeValue2(String(value))}"`).join("");
|
|
4254
4364
|
const children = Array.isArray(node.$$) ? node.$$ : [];
|
|
4255
4365
|
if (children.length === 0) {
|
|
4256
|
-
const
|
|
4257
|
-
if (
|
|
4258
|
-
return `${indent2}<${name}${attrString}>${
|
|
4366
|
+
const textContent3 = _nullishCoalesce(node._, () => ( ""));
|
|
4367
|
+
if (textContent3) {
|
|
4368
|
+
return `${indent2}<${name}${attrString}>${textContent3}</${name}>`;
|
|
4259
4369
|
}
|
|
4260
4370
|
return `${indent2}<${name}${attrString} />`;
|
|
4261
4371
|
}
|
|
@@ -4296,7 +4406,7 @@ function isSkippableLine(line) {
|
|
|
4296
4406
|
function parsePropertyLine(line) {
|
|
4297
4407
|
const [key, ...valueParts] = line.split("=");
|
|
4298
4408
|
return {
|
|
4299
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
4409
|
+
key: _optionalChain([key, 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]) || "",
|
|
4300
4410
|
value: valueParts.join("=").trim()
|
|
4301
4411
|
};
|
|
4302
4412
|
}
|
|
@@ -4588,7 +4698,7 @@ var Parser3 = class {
|
|
|
4588
4698
|
}
|
|
4589
4699
|
}
|
|
4590
4700
|
expect(type) {
|
|
4591
|
-
if (_optionalChain([this, 'access',
|
|
4701
|
+
if (_optionalChain([this, 'access', _169 => _169.current, 'call', _170 => _170(), 'optionalAccess', _171 => _171.type]) === type) {
|
|
4592
4702
|
this.advance();
|
|
4593
4703
|
return true;
|
|
4594
4704
|
}
|
|
@@ -4665,7 +4775,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4665
4775
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4666
4776
|
continue;
|
|
4667
4777
|
}
|
|
4668
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4778
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _172 => _172.localizations, 'optionalAccess', _173 => _173[locale]]);
|
|
4669
4779
|
if (langTranslationEntity) {
|
|
4670
4780
|
if ("stringUnit" in langTranslationEntity) {
|
|
4671
4781
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -4679,7 +4789,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4679
4789
|
resultData[translationKey] = {};
|
|
4680
4790
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4681
4791
|
for (const form in pluralForms) {
|
|
4682
|
-
if (_optionalChain([pluralForms, 'access',
|
|
4792
|
+
if (_optionalChain([pluralForms, 'access', _174 => _174[form], 'optionalAccess', _175 => _175.stringUnit, 'optionalAccess', _176 => _176.value])) {
|
|
4683
4793
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
4684
4794
|
}
|
|
4685
4795
|
}
|
|
@@ -4705,7 +4815,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4705
4815
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
4706
4816
|
if (typeof value === "string") {
|
|
4707
4817
|
langDataToMerge.strings[key] = {
|
|
4708
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4818
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _177 => _177.strings, 'optionalAccess', _178 => _178[key], 'optionalAccess', _179 => _179.extractionState]),
|
|
4709
4819
|
localizations: {
|
|
4710
4820
|
[locale]: {
|
|
4711
4821
|
stringUnit: {
|
|
@@ -4720,7 +4830,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4720
4830
|
}
|
|
4721
4831
|
} else if (Array.isArray(value)) {
|
|
4722
4832
|
langDataToMerge.strings[key] = {
|
|
4723
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4833
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _180 => _180.strings, 'optionalAccess', _181 => _181[key], 'optionalAccess', _182 => _182.extractionState]),
|
|
4724
4834
|
localizations: {
|
|
4725
4835
|
[locale]: {
|
|
4726
4836
|
stringSet: {
|
|
@@ -4778,7 +4888,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4778
4888
|
for (const [locale, localization] of Object.entries(
|
|
4779
4889
|
entity.localizations
|
|
4780
4890
|
)) {
|
|
4781
|
-
if (_optionalChain([localization, 'access',
|
|
4891
|
+
if (_optionalChain([localization, 'access', _183 => _183.variations, 'optionalAccess', _184 => _184.plural])) {
|
|
4782
4892
|
const pluralForms = localization.variations.plural;
|
|
4783
4893
|
for (const form in pluralForms) {
|
|
4784
4894
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -4798,7 +4908,7 @@ function _removeLocale(input2, locale) {
|
|
|
4798
4908
|
const { strings } = input2;
|
|
4799
4909
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
4800
4910
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
4801
|
-
if (_optionalChain([value, 'access',
|
|
4911
|
+
if (_optionalChain([value, 'access', _185 => _185.localizations, 'optionalAccess', _186 => _186[locale]])) {
|
|
4802
4912
|
delete value.localizations[locale];
|
|
4803
4913
|
}
|
|
4804
4914
|
}
|
|
@@ -4929,7 +5039,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4929
5039
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4930
5040
|
continue;
|
|
4931
5041
|
}
|
|
4932
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
5042
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _187 => _187.localizations, 'optionalAccess', _188 => _188[locale]]);
|
|
4933
5043
|
if (langTranslationEntity) {
|
|
4934
5044
|
if (!resultData[translationKey]) {
|
|
4935
5045
|
resultData[translationKey] = {};
|
|
@@ -4941,7 +5051,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4941
5051
|
for (const [subName, subData] of Object.entries(
|
|
4942
5052
|
langTranslationEntity.substitutions
|
|
4943
5053
|
)) {
|
|
4944
|
-
const pluralForms = _optionalChain([subData, 'access',
|
|
5054
|
+
const pluralForms = _optionalChain([subData, 'access', _189 => _189.variations, 'optionalAccess', _190 => _190.plural]);
|
|
4945
5055
|
if (pluralForms) {
|
|
4946
5056
|
const forms = {};
|
|
4947
5057
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
@@ -4966,7 +5076,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
4966
5076
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4967
5077
|
const forms = {};
|
|
4968
5078
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
4969
|
-
if (_optionalChain([formData, 'optionalAccess',
|
|
5079
|
+
if (_optionalChain([formData, 'optionalAccess', _191 => _191.stringUnit, 'optionalAccess', _192 => _192.value])) {
|
|
4970
5080
|
forms[form] = formData.stringUnit.value;
|
|
4971
5081
|
}
|
|
4972
5082
|
}
|
|
@@ -5009,7 +5119,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5009
5119
|
for (const [subName, subData] of Object.entries(
|
|
5010
5120
|
keyData.substitutions
|
|
5011
5121
|
)) {
|
|
5012
|
-
const pluralValue = _optionalChain([subData, 'optionalAccess',
|
|
5122
|
+
const pluralValue = _optionalChain([subData, 'optionalAccess', _193 => _193.variations, 'optionalAccess', _194 => _194.plural]);
|
|
5013
5123
|
if (pluralValue && isIcuPluralString(pluralValue)) {
|
|
5014
5124
|
try {
|
|
5015
5125
|
const pluralForms = parseIcuPluralString(pluralValue, locale);
|
|
@@ -5022,8 +5132,8 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5022
5132
|
}
|
|
5023
5133
|
};
|
|
5024
5134
|
}
|
|
5025
|
-
const sourceLocale = _optionalChain([originalInput, 'optionalAccess',
|
|
5026
|
-
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess',
|
|
5135
|
+
const sourceLocale = _optionalChain([originalInput, 'optionalAccess', _195 => _195.sourceLanguage]) || "en";
|
|
5136
|
+
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess', _196 => _196.strings, 'optionalAccess', _197 => _197[baseKey], 'optionalAccess', _198 => _198.localizations, 'optionalAccess', _199 => _199[sourceLocale], 'optionalAccess', _200 => _200.substitutions, 'optionalAccess', _201 => _201[subName], 'optionalAccess', _202 => _202.formatSpecifier]) || subName;
|
|
5027
5137
|
subs[subName] = {
|
|
5028
5138
|
formatSpecifier: origFormatSpec,
|
|
5029
5139
|
variations: {
|
|
@@ -5048,7 +5158,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5048
5158
|
values: keyData.stringSet
|
|
5049
5159
|
};
|
|
5050
5160
|
}
|
|
5051
|
-
if ("variations" in keyData && _optionalChain([keyData, 'access',
|
|
5161
|
+
if ("variations" in keyData && _optionalChain([keyData, 'access', _203 => _203.variations, 'optionalAccess', _204 => _204.plural])) {
|
|
5052
5162
|
const pluralValue = keyData.variations.plural;
|
|
5053
5163
|
if (isIcuPluralString(pluralValue)) {
|
|
5054
5164
|
try {
|
|
@@ -5075,7 +5185,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5075
5185
|
}
|
|
5076
5186
|
if (Object.keys(localizationData).length > 0) {
|
|
5077
5187
|
langDataToMerge.strings[baseKey] = {
|
|
5078
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
5188
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _205 => _205.strings, 'optionalAccess', _206 => _206[baseKey], 'optionalAccess', _207 => _207.extractionState]),
|
|
5079
5189
|
localizations: {
|
|
5080
5190
|
[locale]: localizationData
|
|
5081
5191
|
}
|
|
@@ -5298,8 +5408,8 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5298
5408
|
});
|
|
5299
5409
|
return formatted.content;
|
|
5300
5410
|
} catch (error) {
|
|
5301
|
-
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access',
|
|
5302
|
-
if (_optionalChain([errorMessage, 'optionalAccess',
|
|
5411
|
+
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _208 => _208.stackTrace, 'optionalAccess', _209 => _209.toString, 'call', _210 => _210(), 'access', _211 => _211.split, 'call', _212 => _212("\n"), 'access', _213 => _213[0]]) : "";
|
|
5412
|
+
if (_optionalChain([errorMessage, 'optionalAccess', _214 => _214.includes, 'call', _215 => _215("does not exist in the workspace")])) {
|
|
5303
5413
|
} else {
|
|
5304
5414
|
console.log(`\u26A0\uFE0F Biome skipped ${path14.default.basename(filePath)}`);
|
|
5305
5415
|
if (errorMessage) {
|
|
@@ -5346,7 +5456,7 @@ function createPoDataLoader(params) {
|
|
|
5346
5456
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
5347
5457
|
if (msgid && entry.msgid) {
|
|
5348
5458
|
const context = entry.msgctxt || "";
|
|
5349
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
5459
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _216 => _216.translations, 'access', _217 => _217[context], 'optionalAccess', _218 => _218[msgid]]);
|
|
5350
5460
|
if (fullEntry) {
|
|
5351
5461
|
result[msgid] = fullEntry;
|
|
5352
5462
|
}
|
|
@@ -5356,8 +5466,8 @@ function createPoDataLoader(params) {
|
|
|
5356
5466
|
return result;
|
|
5357
5467
|
},
|
|
5358
5468
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
5359
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
5360
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
5469
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _219 => _219.split, 'call', _220 => _220("\n\n"), 'access', _221 => _221.filter, 'call', _222 => _222(Boolean)]) || [];
|
|
5470
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _223 => _223.split, 'call', _224 => _224("\n\n"), 'access', _225 => _225.filter, 'call', _226 => _226(Boolean)]) || [];
|
|
5361
5471
|
const result = originalSections.map((section) => {
|
|
5362
5472
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
5363
5473
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -5426,8 +5536,8 @@ function createPoContentLoader() {
|
|
|
5426
5536
|
{
|
|
5427
5537
|
...entry,
|
|
5428
5538
|
msgstr: [
|
|
5429
|
-
_optionalChain([data, 'access',
|
|
5430
|
-
_optionalChain([data, 'access',
|
|
5539
|
+
_optionalChain([data, 'access', _227 => _227[entry.msgid], 'optionalAccess', _228 => _228.singular]),
|
|
5540
|
+
_optionalChain([data, 'access', _229 => _229[entry.msgid], 'optionalAccess', _230 => _230.plural]) || null
|
|
5431
5541
|
].filter(Boolean)
|
|
5432
5542
|
}
|
|
5433
5543
|
]).fromPairs().value();
|
|
@@ -5549,7 +5659,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
5549
5659
|
let key = getTransUnitKey(unit);
|
|
5550
5660
|
if (!key) return;
|
|
5551
5661
|
if (seenKeys.has(key)) {
|
|
5552
|
-
const id = _optionalChain([unit, 'access',
|
|
5662
|
+
const id = _optionalChain([unit, 'access', _231 => _231.getAttribute, 'call', _232 => _232("id"), 'optionalAccess', _233 => _233.trim, 'call', _234 => _234()]);
|
|
5553
5663
|
if (id) {
|
|
5554
5664
|
key = `${key}#${id}`;
|
|
5555
5665
|
} else {
|
|
@@ -5597,7 +5707,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5597
5707
|
let key = getTransUnitKey(unit);
|
|
5598
5708
|
if (!key) return;
|
|
5599
5709
|
if (seenKeys.has(key)) {
|
|
5600
|
-
const id = _optionalChain([unit, 'access',
|
|
5710
|
+
const id = _optionalChain([unit, 'access', _235 => _235.getAttribute, 'call', _236 => _236("id"), 'optionalAccess', _237 => _237.trim, 'call', _238 => _238()]);
|
|
5601
5711
|
if (id) {
|
|
5602
5712
|
key = `${key}#${id}`;
|
|
5603
5713
|
} else {
|
|
@@ -5639,7 +5749,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5639
5749
|
const translationKeys = new Set(Object.keys(translations));
|
|
5640
5750
|
existingUnits.forEach((unit, key) => {
|
|
5641
5751
|
if (!translationKeys.has(key)) {
|
|
5642
|
-
_optionalChain([unit, 'access',
|
|
5752
|
+
_optionalChain([unit, 'access', _239 => _239.parentNode, 'optionalAccess', _240 => _240.removeChild, 'call', _241 => _241(unit)]);
|
|
5643
5753
|
}
|
|
5644
5754
|
});
|
|
5645
5755
|
return serializeWithDeclaration(
|
|
@@ -5682,18 +5792,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
5682
5792
|
Array.from(container.children).forEach((child) => {
|
|
5683
5793
|
const tagName = child.tagName;
|
|
5684
5794
|
if (tagName === "unit") {
|
|
5685
|
-
const unitId = _optionalChain([child, 'access',
|
|
5795
|
+
const unitId = _optionalChain([child, 'access', _242 => _242.getAttribute, 'call', _243 => _243("id"), 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]);
|
|
5686
5796
|
if (!unitId) return;
|
|
5687
5797
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5688
5798
|
const segment = child.querySelector("segment");
|
|
5689
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
5799
|
+
const source = _optionalChain([segment, 'optionalAccess', _246 => _246.querySelector, 'call', _247 => _247("source")]);
|
|
5690
5800
|
if (source) {
|
|
5691
5801
|
result[key] = extractTextContent(source);
|
|
5692
5802
|
} else {
|
|
5693
5803
|
result[key] = unitId;
|
|
5694
5804
|
}
|
|
5695
5805
|
} else if (tagName === "group") {
|
|
5696
|
-
const groupId = _optionalChain([child, 'access',
|
|
5806
|
+
const groupId = _optionalChain([child, 'access', _248 => _248.getAttribute, 'call', _249 => _249("id"), 'optionalAccess', _250 => _250.trim, 'call', _251 => _251()]);
|
|
5697
5807
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5698
5808
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
5699
5809
|
}
|
|
@@ -5729,12 +5839,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
5729
5839
|
Array.from(container.children).forEach((child) => {
|
|
5730
5840
|
const tagName = child.tagName;
|
|
5731
5841
|
if (tagName === "unit") {
|
|
5732
|
-
const unitId = _optionalChain([child, 'access',
|
|
5842
|
+
const unitId = _optionalChain([child, 'access', _252 => _252.getAttribute, 'call', _253 => _253("id"), 'optionalAccess', _254 => _254.trim, 'call', _255 => _255()]);
|
|
5733
5843
|
if (!unitId) return;
|
|
5734
5844
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5735
5845
|
index.set(key, child);
|
|
5736
5846
|
} else if (tagName === "group") {
|
|
5737
|
-
const groupId = _optionalChain([child, 'access',
|
|
5847
|
+
const groupId = _optionalChain([child, 'access', _256 => _256.getAttribute, 'call', _257 => _257("id"), 'optionalAccess', _258 => _258.trim, 'call', _259 => _259()]);
|
|
5738
5848
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5739
5849
|
indexUnitsV2(child, fileId, newPath, index);
|
|
5740
5850
|
}
|
|
@@ -5755,9 +5865,9 @@ function updateUnitV2(unit, value) {
|
|
|
5755
5865
|
setTextContent(source, value);
|
|
5756
5866
|
}
|
|
5757
5867
|
function getTransUnitKey(transUnit) {
|
|
5758
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
5868
|
+
const resname = _optionalChain([transUnit, 'access', _260 => _260.getAttribute, 'call', _261 => _261("resname"), 'optionalAccess', _262 => _262.trim, 'call', _263 => _263()]);
|
|
5759
5869
|
if (resname) return resname;
|
|
5760
|
-
const id = _optionalChain([transUnit, 'access',
|
|
5870
|
+
const id = _optionalChain([transUnit, 'access', _264 => _264.getAttribute, 'call', _265 => _265("id"), 'optionalAccess', _266 => _266.trim, 'call', _267 => _267()]);
|
|
5761
5871
|
if (id) return id;
|
|
5762
5872
|
const sourceElement = transUnit.querySelector("source");
|
|
5763
5873
|
if (sourceElement) {
|
|
@@ -5814,10 +5924,10 @@ function formatXml(xml) {
|
|
|
5814
5924
|
if (cdataNode) {
|
|
5815
5925
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
5816
5926
|
}
|
|
5817
|
-
const
|
|
5927
|
+
const textContent3 = _optionalChain([element, 'access', _268 => _268.textContent, 'optionalAccess', _269 => _269.trim, 'call', _270 => _270()]) || "";
|
|
5818
5928
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
5819
|
-
if (hasOnlyText &&
|
|
5820
|
-
return `${indent2}${openTag}${
|
|
5929
|
+
if (hasOnlyText && textContent3) {
|
|
5930
|
+
return `${indent2}${openTag}${textContent3}</${tagName}>`;
|
|
5821
5931
|
}
|
|
5822
5932
|
const children = Array.from(element.children);
|
|
5823
5933
|
if (children.length === 0) {
|
|
@@ -6107,7 +6217,7 @@ function createDatoClient(params) {
|
|
|
6107
6217
|
ids: !records.length ? void 0 : records.join(",")
|
|
6108
6218
|
}
|
|
6109
6219
|
}).catch(
|
|
6110
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6220
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _271 => _271.response, 'optionalAccess', _272 => _272.body, 'optionalAccess', _273 => _273.data, 'optionalAccess', _274 => _274[0]]) || error)
|
|
6111
6221
|
);
|
|
6112
6222
|
},
|
|
6113
6223
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -6118,10 +6228,10 @@ function createDatoClient(params) {
|
|
|
6118
6228
|
filter: {
|
|
6119
6229
|
type: modelId,
|
|
6120
6230
|
only_valid: "true",
|
|
6121
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
6231
|
+
ids: !_optionalChain([records, 'optionalAccess', _275 => _275.length]) ? void 0 : records.join(",")
|
|
6122
6232
|
}
|
|
6123
6233
|
}).catch(
|
|
6124
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6234
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _276 => _276.response, 'optionalAccess', _277 => _277.body, 'optionalAccess', _278 => _278.data, 'optionalAccess', _279 => _279[0]]) || error)
|
|
6125
6235
|
);
|
|
6126
6236
|
return result;
|
|
6127
6237
|
} catch (_error) {
|
|
@@ -6137,10 +6247,10 @@ function createDatoClient(params) {
|
|
|
6137
6247
|
updateRecord: async (id, payload) => {
|
|
6138
6248
|
try {
|
|
6139
6249
|
await dato.items.update(id, payload).catch(
|
|
6140
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6250
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _280 => _280.response, 'optionalAccess', _281 => _281.body, 'optionalAccess', _282 => _282.data, 'optionalAccess', _283 => _283[0]]) || error)
|
|
6141
6251
|
);
|
|
6142
6252
|
} catch (_error) {
|
|
6143
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6253
|
+
if (_optionalChain([_error, 'optionalAccess', _284 => _284.attributes, 'optionalAccess', _285 => _285.details, 'optionalAccess', _286 => _286.message])) {
|
|
6144
6254
|
throw new Error(
|
|
6145
6255
|
[
|
|
6146
6256
|
`${_error.attributes.details.message}`,
|
|
@@ -6162,10 +6272,10 @@ function createDatoClient(params) {
|
|
|
6162
6272
|
enableFieldLocalization: async (args) => {
|
|
6163
6273
|
try {
|
|
6164
6274
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
6165
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6275
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _287 => _287.response, 'optionalAccess', _288 => _288.body, 'optionalAccess', _289 => _289.data, 'optionalAccess', _290 => _290[0]]) || error)
|
|
6166
6276
|
);
|
|
6167
6277
|
} catch (_error) {
|
|
6168
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6278
|
+
if (_optionalChain([_error, 'optionalAccess', _291 => _291.attributes, 'optionalAccess', _292 => _292.code]) === "NOT_FOUND") {
|
|
6169
6279
|
throw new Error(
|
|
6170
6280
|
[
|
|
6171
6281
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -6173,7 +6283,7 @@ function createDatoClient(params) {
|
|
|
6173
6283
|
].join("\n\n")
|
|
6174
6284
|
);
|
|
6175
6285
|
}
|
|
6176
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6286
|
+
if (_optionalChain([_error, 'optionalAccess', _293 => _293.attributes, 'optionalAccess', _294 => _294.details, 'optionalAccess', _295 => _295.message])) {
|
|
6177
6287
|
throw new Error(
|
|
6178
6288
|
[
|
|
6179
6289
|
`${_error.attributes.details.message}`,
|
|
@@ -6251,7 +6361,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6251
6361
|
const records = await dato.findRecordsForModel(modelId);
|
|
6252
6362
|
const recordChoices = createRecordChoices(
|
|
6253
6363
|
records,
|
|
6254
|
-
_optionalChain([config, 'access',
|
|
6364
|
+
_optionalChain([config, 'access', _296 => _296.models, 'access', _297 => _297[modelId], 'optionalAccess', _298 => _298.records]) || [],
|
|
6255
6365
|
project
|
|
6256
6366
|
);
|
|
6257
6367
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -6270,14 +6380,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6270
6380
|
},
|
|
6271
6381
|
async pull(locale, input2, initCtx) {
|
|
6272
6382
|
const result = {};
|
|
6273
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
6274
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
6383
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _299 => _299.models]) || {})) {
|
|
6384
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _300 => _300.models, 'access', _301 => _301[modelId], 'access', _302 => _302.records]) || [];
|
|
6275
6385
|
const recordIds = records.map((record) => record.id);
|
|
6276
6386
|
records = await dato.findRecords(recordIds);
|
|
6277
6387
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
6278
6388
|
if (records.length > 0) {
|
|
6279
6389
|
result[modelId] = {
|
|
6280
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
6390
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _303 => _303.models, 'optionalAccess', _304 => _304[modelId], 'optionalAccess', _305 => _305.fields]) || [],
|
|
6281
6391
|
records
|
|
6282
6392
|
};
|
|
6283
6393
|
}
|
|
@@ -6340,7 +6450,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
6340
6450
|
return records.map((record) => ({
|
|
6341
6451
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
6342
6452
|
value: record.id,
|
|
6343
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
6453
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _306 => _306.includes, 'call', _307 => _307(record.id)])
|
|
6344
6454
|
}));
|
|
6345
6455
|
}
|
|
6346
6456
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -6659,7 +6769,7 @@ function createVttLoader() {
|
|
|
6659
6769
|
if (!input2) {
|
|
6660
6770
|
return "";
|
|
6661
6771
|
}
|
|
6662
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
6772
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _308 => _308.parse, 'call', _309 => _309(input2), 'optionalAccess', _310 => _310.cues]);
|
|
6663
6773
|
if (Object.keys(vtt).length === 0) {
|
|
6664
6774
|
return {};
|
|
6665
6775
|
} else {
|
|
@@ -6713,7 +6823,7 @@ function variableExtractLoader(params) {
|
|
|
6713
6823
|
for (let i = 0; i < matches.length; i++) {
|
|
6714
6824
|
const match2 = matches[i];
|
|
6715
6825
|
const currentValue = result[key].value;
|
|
6716
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6826
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _311 => _311.replace, 'call', _312 => _312(match2, `{variable:${i}}`)]);
|
|
6717
6827
|
result[key].value = newValue;
|
|
6718
6828
|
result[key].variables[i] = match2;
|
|
6719
6829
|
}
|
|
@@ -6728,7 +6838,7 @@ function variableExtractLoader(params) {
|
|
|
6728
6838
|
const variable = valueObj.variables[i];
|
|
6729
6839
|
const currentValue = result[key];
|
|
6730
6840
|
if (typeof currentValue === "string") {
|
|
6731
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6841
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _313 => _313.replaceAll, 'call', _314 => _314(
|
|
6732
6842
|
`{variable:${i}}`,
|
|
6733
6843
|
variable
|
|
6734
6844
|
)]);
|
|
@@ -6932,7 +7042,7 @@ function createVueJsonLoader() {
|
|
|
6932
7042
|
return createLoader({
|
|
6933
7043
|
pull: async (locale, input2, ctx) => {
|
|
6934
7044
|
const parsed = parseVueFile(input2);
|
|
6935
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
7045
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _315 => _315.i18n, 'optionalAccess', _316 => _316[locale]]), () => ( {}));
|
|
6936
7046
|
},
|
|
6937
7047
|
push: async (locale, data, originalInput) => {
|
|
6938
7048
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -7117,7 +7227,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
7117
7227
|
objectExpression.properties.forEach((prop) => {
|
|
7118
7228
|
if (!t.isObjectProperty(prop)) return;
|
|
7119
7229
|
const key = getPropertyKey(prop);
|
|
7120
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
7230
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _317 => _317[key]]);
|
|
7121
7231
|
if (incomingVal === void 0) {
|
|
7122
7232
|
return;
|
|
7123
7233
|
}
|
|
@@ -7153,7 +7263,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
7153
7263
|
let modified = false;
|
|
7154
7264
|
arrayExpression.elements.forEach((element, index) => {
|
|
7155
7265
|
if (!element) return;
|
|
7156
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
7266
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _318 => _318[index]]);
|
|
7157
7267
|
if (incomingVal === void 0) return;
|
|
7158
7268
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
7159
7269
|
if (element.value !== incomingVal) {
|
|
@@ -7647,7 +7757,7 @@ var AST = class _AST {
|
|
|
7647
7757
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
7648
7758
|
if (this.isStart() && !this.type)
|
|
7649
7759
|
ret.unshift([]);
|
|
7650
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7760
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _319 => _319.#parent, 'optionalAccess', _320 => _320.type]) === "!")) {
|
|
7651
7761
|
ret.push({});
|
|
7652
7762
|
}
|
|
7653
7763
|
return ret;
|
|
@@ -7655,7 +7765,7 @@ var AST = class _AST {
|
|
|
7655
7765
|
isStart() {
|
|
7656
7766
|
if (this.#root === this)
|
|
7657
7767
|
return true;
|
|
7658
|
-
if (!_optionalChain([this, 'access',
|
|
7768
|
+
if (!_optionalChain([this, 'access', _321 => _321.#parent, 'optionalAccess', _322 => _322.isStart, 'call', _323 => _323()]))
|
|
7659
7769
|
return false;
|
|
7660
7770
|
if (this.#parentIndex === 0)
|
|
7661
7771
|
return true;
|
|
@@ -7671,12 +7781,12 @@ var AST = class _AST {
|
|
|
7671
7781
|
isEnd() {
|
|
7672
7782
|
if (this.#root === this)
|
|
7673
7783
|
return true;
|
|
7674
|
-
if (_optionalChain([this, 'access',
|
|
7784
|
+
if (_optionalChain([this, 'access', _324 => _324.#parent, 'optionalAccess', _325 => _325.type]) === "!")
|
|
7675
7785
|
return true;
|
|
7676
|
-
if (!_optionalChain([this, 'access',
|
|
7786
|
+
if (!_optionalChain([this, 'access', _326 => _326.#parent, 'optionalAccess', _327 => _327.isEnd, 'call', _328 => _328()]))
|
|
7677
7787
|
return false;
|
|
7678
7788
|
if (!this.type)
|
|
7679
|
-
return _optionalChain([this, 'access',
|
|
7789
|
+
return _optionalChain([this, 'access', _329 => _329.#parent, 'optionalAccess', _330 => _330.isEnd, 'call', _331 => _331()]);
|
|
7680
7790
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
7681
7791
|
return this.#parentIndex === pl - 1;
|
|
7682
7792
|
}
|
|
@@ -7921,7 +8031,7 @@ var AST = class _AST {
|
|
|
7921
8031
|
}
|
|
7922
8032
|
}
|
|
7923
8033
|
let end = "";
|
|
7924
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
8034
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _332 => _332.#parent, 'optionalAccess', _333 => _333.type]) === "!") {
|
|
7925
8035
|
end = "(?:$|\\/)";
|
|
7926
8036
|
}
|
|
7927
8037
|
const final2 = start2 + src + end;
|
|
@@ -9022,7 +9132,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
9022
9132
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
9023
9133
|
const result = {
|
|
9024
9134
|
frontmatter: data.frontmatter,
|
|
9025
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
9135
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _334 => _334.codePlaceholders]) || {},
|
|
9026
9136
|
content
|
|
9027
9137
|
};
|
|
9028
9138
|
return result;
|
|
@@ -9137,14 +9247,14 @@ function parseEjsForTranslation(input2) {
|
|
|
9137
9247
|
if (part.type === "ejs") {
|
|
9138
9248
|
template += part.content;
|
|
9139
9249
|
} else {
|
|
9140
|
-
const
|
|
9250
|
+
const textContent3 = part.content;
|
|
9141
9251
|
const htmlTagRegex = /<[^>]+>/g;
|
|
9142
9252
|
const textParts = [];
|
|
9143
9253
|
let lastTextIndex = 0;
|
|
9144
9254
|
let htmlMatch;
|
|
9145
|
-
while ((htmlMatch = htmlTagRegex.exec(
|
|
9255
|
+
while ((htmlMatch = htmlTagRegex.exec(textContent3)) !== null) {
|
|
9146
9256
|
if (htmlMatch.index > lastTextIndex) {
|
|
9147
|
-
const textBefore =
|
|
9257
|
+
const textBefore = textContent3.slice(lastTextIndex, htmlMatch.index);
|
|
9148
9258
|
if (textBefore.trim()) {
|
|
9149
9259
|
textParts.push({ type: "text", content: textBefore });
|
|
9150
9260
|
} else {
|
|
@@ -9154,8 +9264,8 @@ function parseEjsForTranslation(input2) {
|
|
|
9154
9264
|
textParts.push({ type: "html", content: htmlMatch[0] });
|
|
9155
9265
|
lastTextIndex = htmlMatch.index + htmlMatch[0].length;
|
|
9156
9266
|
}
|
|
9157
|
-
if (lastTextIndex <
|
|
9158
|
-
const remainingText =
|
|
9267
|
+
if (lastTextIndex < textContent3.length) {
|
|
9268
|
+
const remainingText = textContent3.slice(lastTextIndex);
|
|
9159
9269
|
if (remainingText.trim()) {
|
|
9160
9270
|
textParts.push({ type: "text", content: remainingText });
|
|
9161
9271
|
} else {
|
|
@@ -9163,11 +9273,11 @@ function parseEjsForTranslation(input2) {
|
|
|
9163
9273
|
}
|
|
9164
9274
|
}
|
|
9165
9275
|
if (textParts.length === 0) {
|
|
9166
|
-
const trimmedContent =
|
|
9276
|
+
const trimmedContent = textContent3.trim();
|
|
9167
9277
|
if (trimmedContent) {
|
|
9168
|
-
textParts.push({ type: "text", content:
|
|
9278
|
+
textParts.push({ type: "text", content: textContent3 });
|
|
9169
9279
|
} else {
|
|
9170
|
-
textParts.push({ type: "html", content:
|
|
9280
|
+
textParts.push({ type: "html", content: textContent3 });
|
|
9171
9281
|
}
|
|
9172
9282
|
}
|
|
9173
9283
|
for (const textPart of textParts) {
|
|
@@ -9236,6 +9346,368 @@ function createEjsLoader() {
|
|
|
9236
9346
|
});
|
|
9237
9347
|
}
|
|
9238
9348
|
|
|
9349
|
+
// src/cli/loaders/twig.ts
|
|
9350
|
+
|
|
9351
|
+
|
|
9352
|
+
|
|
9353
|
+
|
|
9354
|
+
function createTwigLoader() {
|
|
9355
|
+
const PHRASING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
9356
|
+
// Text-level semantics
|
|
9357
|
+
"a",
|
|
9358
|
+
"abbr",
|
|
9359
|
+
"b",
|
|
9360
|
+
"bdi",
|
|
9361
|
+
"bdo",
|
|
9362
|
+
"br",
|
|
9363
|
+
"cite",
|
|
9364
|
+
"code",
|
|
9365
|
+
"data",
|
|
9366
|
+
"dfn",
|
|
9367
|
+
"em",
|
|
9368
|
+
"i",
|
|
9369
|
+
"kbd",
|
|
9370
|
+
"mark",
|
|
9371
|
+
"q",
|
|
9372
|
+
"ruby",
|
|
9373
|
+
"s",
|
|
9374
|
+
"samp",
|
|
9375
|
+
"small",
|
|
9376
|
+
"span",
|
|
9377
|
+
"strong",
|
|
9378
|
+
"sub",
|
|
9379
|
+
"sup",
|
|
9380
|
+
"time",
|
|
9381
|
+
"u",
|
|
9382
|
+
"var",
|
|
9383
|
+
"wbr",
|
|
9384
|
+
// Media
|
|
9385
|
+
"audio",
|
|
9386
|
+
"img",
|
|
9387
|
+
"video",
|
|
9388
|
+
"picture",
|
|
9389
|
+
// Interactive
|
|
9390
|
+
"button",
|
|
9391
|
+
"input",
|
|
9392
|
+
"label",
|
|
9393
|
+
"select",
|
|
9394
|
+
"textarea",
|
|
9395
|
+
// Embedded
|
|
9396
|
+
"canvas",
|
|
9397
|
+
"iframe",
|
|
9398
|
+
"object",
|
|
9399
|
+
"svg",
|
|
9400
|
+
"math",
|
|
9401
|
+
// Other
|
|
9402
|
+
"del",
|
|
9403
|
+
"ins",
|
|
9404
|
+
"map",
|
|
9405
|
+
"area"
|
|
9406
|
+
]);
|
|
9407
|
+
const BLOCK_ELEMENTS = /* @__PURE__ */ new Set([
|
|
9408
|
+
"div",
|
|
9409
|
+
"p",
|
|
9410
|
+
"h1",
|
|
9411
|
+
"h2",
|
|
9412
|
+
"h3",
|
|
9413
|
+
"h4",
|
|
9414
|
+
"h5",
|
|
9415
|
+
"h6",
|
|
9416
|
+
"ul",
|
|
9417
|
+
"ol",
|
|
9418
|
+
"li",
|
|
9419
|
+
"dl",
|
|
9420
|
+
"dt",
|
|
9421
|
+
"dd",
|
|
9422
|
+
"blockquote",
|
|
9423
|
+
"pre",
|
|
9424
|
+
"article",
|
|
9425
|
+
"aside",
|
|
9426
|
+
"nav",
|
|
9427
|
+
"section",
|
|
9428
|
+
"header",
|
|
9429
|
+
"footer",
|
|
9430
|
+
"main",
|
|
9431
|
+
"figure",
|
|
9432
|
+
"figcaption",
|
|
9433
|
+
"table",
|
|
9434
|
+
"thead",
|
|
9435
|
+
"tbody",
|
|
9436
|
+
"tfoot",
|
|
9437
|
+
"tr",
|
|
9438
|
+
"td",
|
|
9439
|
+
"th",
|
|
9440
|
+
"caption",
|
|
9441
|
+
"form",
|
|
9442
|
+
"fieldset",
|
|
9443
|
+
"legend",
|
|
9444
|
+
"details",
|
|
9445
|
+
"summary",
|
|
9446
|
+
"address",
|
|
9447
|
+
"hr",
|
|
9448
|
+
"search",
|
|
9449
|
+
"dialog",
|
|
9450
|
+
"noscript",
|
|
9451
|
+
"title"
|
|
9452
|
+
]);
|
|
9453
|
+
const UNLOCALIZABLE_TAGS = /* @__PURE__ */ new Set(["script", "style"]);
|
|
9454
|
+
const LOCALIZABLE_ATTRIBUTES2 = {
|
|
9455
|
+
meta: ["content"],
|
|
9456
|
+
img: ["alt", "title"],
|
|
9457
|
+
input: ["placeholder", "title", "aria-label"],
|
|
9458
|
+
textarea: ["placeholder", "title", "aria-label"],
|
|
9459
|
+
button: ["title", "aria-label"],
|
|
9460
|
+
a: ["title", "aria-label"],
|
|
9461
|
+
abbr: ["title"],
|
|
9462
|
+
link: ["title"]
|
|
9463
|
+
};
|
|
9464
|
+
function preprocessTwig(input2) {
|
|
9465
|
+
const twigBlocks = [];
|
|
9466
|
+
let counter = 0;
|
|
9467
|
+
const processed = input2.replace(/\{%[\s\S]*?%\}/g, (match2) => {
|
|
9468
|
+
twigBlocks.push(match2);
|
|
9469
|
+
return `__TWIG_BLOCK_${counter++}__`;
|
|
9470
|
+
});
|
|
9471
|
+
return {
|
|
9472
|
+
processed: processed.replace(/\{#[\s\S]*?#\}/g, (match2) => {
|
|
9473
|
+
twigBlocks.push(match2);
|
|
9474
|
+
return `__TWIG_BLOCK_${counter++}__`;
|
|
9475
|
+
}),
|
|
9476
|
+
twigBlocks
|
|
9477
|
+
};
|
|
9478
|
+
}
|
|
9479
|
+
function postprocessTwig(text, twigBlocks) {
|
|
9480
|
+
return text.replace(/__TWIG_BLOCK_(\d+)__/g, (_37, index) => {
|
|
9481
|
+
return twigBlocks[parseInt(index, 10)] || "";
|
|
9482
|
+
});
|
|
9483
|
+
}
|
|
9484
|
+
return createLoader({
|
|
9485
|
+
async pull(locale, input2) {
|
|
9486
|
+
const result = {};
|
|
9487
|
+
const { processed, twigBlocks } = preprocessTwig(input2);
|
|
9488
|
+
const handler = new (0, _domhandler.DomHandler)();
|
|
9489
|
+
const parser = new htmlparser23.Parser(handler, {
|
|
9490
|
+
lowerCaseTags: false,
|
|
9491
|
+
lowerCaseAttributeNames: false
|
|
9492
|
+
});
|
|
9493
|
+
parser.write(processed);
|
|
9494
|
+
parser.end();
|
|
9495
|
+
const dom = handler.dom;
|
|
9496
|
+
function isInsideUnlocalizableTag(element) {
|
|
9497
|
+
let current = element.parent;
|
|
9498
|
+
while (current && current.type === "tag") {
|
|
9499
|
+
if (UNLOCALIZABLE_TAGS.has(current.name.toLowerCase())) {
|
|
9500
|
+
return true;
|
|
9501
|
+
}
|
|
9502
|
+
current = current.parent;
|
|
9503
|
+
}
|
|
9504
|
+
return false;
|
|
9505
|
+
}
|
|
9506
|
+
function hasTranslatableContent(element) {
|
|
9507
|
+
const text = domutils2.textContent(element);
|
|
9508
|
+
return text.trim().length > 0;
|
|
9509
|
+
}
|
|
9510
|
+
function isLeafBlock(element) {
|
|
9511
|
+
const childElements = element.children.filter(
|
|
9512
|
+
(child) => child.type === "tag"
|
|
9513
|
+
);
|
|
9514
|
+
for (const child of childElements) {
|
|
9515
|
+
if (BLOCK_ELEMENTS.has(child.name.toLowerCase())) {
|
|
9516
|
+
return false;
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9519
|
+
return hasTranslatableContent(element);
|
|
9520
|
+
}
|
|
9521
|
+
function getInnerHTML2(element) {
|
|
9522
|
+
const html2 = element.children.map((child) => DomSerializer2.default(child, { encodeEntities: false })).join("");
|
|
9523
|
+
return postprocessTwig(html2, twigBlocks);
|
|
9524
|
+
}
|
|
9525
|
+
function extractAttributes(element, path19) {
|
|
9526
|
+
const tagName = element.name.toLowerCase();
|
|
9527
|
+
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
9528
|
+
if (!attrs) return;
|
|
9529
|
+
for (const attr of attrs) {
|
|
9530
|
+
const value = _optionalChain([element, 'access', _335 => _335.attribs, 'optionalAccess', _336 => _336[attr]]);
|
|
9531
|
+
if (value && value.trim()) {
|
|
9532
|
+
const restoredValue = postprocessTwig(value.trim(), twigBlocks);
|
|
9533
|
+
result[`${path19}#${attr}`] = restoredValue;
|
|
9534
|
+
}
|
|
9535
|
+
}
|
|
9536
|
+
}
|
|
9537
|
+
function extractFromElement(element, pathParts) {
|
|
9538
|
+
const path19 = pathParts.join("/");
|
|
9539
|
+
if (isInsideUnlocalizableTag(element)) {
|
|
9540
|
+
return;
|
|
9541
|
+
}
|
|
9542
|
+
extractAttributes(element, path19);
|
|
9543
|
+
const tagName = element.name.toLowerCase();
|
|
9544
|
+
if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
|
|
9545
|
+
const content = getInnerHTML2(element).trim();
|
|
9546
|
+
if (content) {
|
|
9547
|
+
result[path19] = content;
|
|
9548
|
+
}
|
|
9549
|
+
return;
|
|
9550
|
+
}
|
|
9551
|
+
if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
|
|
9552
|
+
const content = getInnerHTML2(element).trim();
|
|
9553
|
+
if (content) {
|
|
9554
|
+
result[path19] = content;
|
|
9555
|
+
}
|
|
9556
|
+
return;
|
|
9557
|
+
}
|
|
9558
|
+
let childIndex = 0;
|
|
9559
|
+
const childElements = element.children.filter(
|
|
9560
|
+
(child) => child.type === "tag"
|
|
9561
|
+
);
|
|
9562
|
+
for (const child of childElements) {
|
|
9563
|
+
extractFromElement(child, [...pathParts, childIndex++]);
|
|
9564
|
+
}
|
|
9565
|
+
}
|
|
9566
|
+
const html = domutils2.findOne(
|
|
9567
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "html",
|
|
9568
|
+
dom,
|
|
9569
|
+
true
|
|
9570
|
+
);
|
|
9571
|
+
if (html) {
|
|
9572
|
+
const head = domutils2.findOne(
|
|
9573
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "head",
|
|
9574
|
+
html.children,
|
|
9575
|
+
true
|
|
9576
|
+
);
|
|
9577
|
+
const body = domutils2.findOne(
|
|
9578
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "body",
|
|
9579
|
+
html.children,
|
|
9580
|
+
true
|
|
9581
|
+
);
|
|
9582
|
+
if (head) {
|
|
9583
|
+
let headIndex = 0;
|
|
9584
|
+
const headChildren = head.children.filter(
|
|
9585
|
+
(child) => child.type === "tag"
|
|
9586
|
+
);
|
|
9587
|
+
for (const child of headChildren) {
|
|
9588
|
+
extractFromElement(child, ["head", headIndex++]);
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
if (body) {
|
|
9592
|
+
let bodyIndex = 0;
|
|
9593
|
+
const bodyChildren = body.children.filter(
|
|
9594
|
+
(child) => child.type === "tag"
|
|
9595
|
+
);
|
|
9596
|
+
for (const child of bodyChildren) {
|
|
9597
|
+
extractFromElement(child, ["body", bodyIndex++]);
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9600
|
+
} else {
|
|
9601
|
+
let rootIndex = 0;
|
|
9602
|
+
const rootElements = dom.filter(
|
|
9603
|
+
(child) => child.type === "tag"
|
|
9604
|
+
);
|
|
9605
|
+
for (const child of rootElements) {
|
|
9606
|
+
extractFromElement(child, [rootIndex++]);
|
|
9607
|
+
}
|
|
9608
|
+
}
|
|
9609
|
+
return result;
|
|
9610
|
+
},
|
|
9611
|
+
async push(locale, data, originalInput) {
|
|
9612
|
+
const { processed, twigBlocks } = preprocessTwig(originalInput || "");
|
|
9613
|
+
const handler = new (0, _domhandler.DomHandler)();
|
|
9614
|
+
const parser = new htmlparser23.Parser(handler, {
|
|
9615
|
+
lowerCaseTags: false,
|
|
9616
|
+
lowerCaseAttributeNames: false
|
|
9617
|
+
});
|
|
9618
|
+
parser.write(processed || "<!DOCTYPE html><html><head></head><body></body></html>");
|
|
9619
|
+
parser.end();
|
|
9620
|
+
const dom = handler.dom;
|
|
9621
|
+
const html = domutils2.findOne(
|
|
9622
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "html",
|
|
9623
|
+
dom,
|
|
9624
|
+
true
|
|
9625
|
+
);
|
|
9626
|
+
if (html) {
|
|
9627
|
+
html.attribs = html.attribs || {};
|
|
9628
|
+
html.attribs.lang = locale;
|
|
9629
|
+
}
|
|
9630
|
+
function traverseByIndices(element, indices) {
|
|
9631
|
+
let current = element;
|
|
9632
|
+
for (const indexStr of indices) {
|
|
9633
|
+
if (!current) return null;
|
|
9634
|
+
const index = parseInt(indexStr, 10);
|
|
9635
|
+
const children = current.children.filter(
|
|
9636
|
+
(child) => child.type === "tag"
|
|
9637
|
+
);
|
|
9638
|
+
if (index >= children.length) {
|
|
9639
|
+
return null;
|
|
9640
|
+
}
|
|
9641
|
+
current = children[index];
|
|
9642
|
+
}
|
|
9643
|
+
return current;
|
|
9644
|
+
}
|
|
9645
|
+
function resolvePathToElement(path19) {
|
|
9646
|
+
const parts = path19.split("/");
|
|
9647
|
+
const [rootTag, ...indices] = parts;
|
|
9648
|
+
let current = null;
|
|
9649
|
+
if (html) {
|
|
9650
|
+
if (rootTag === "head") {
|
|
9651
|
+
current = domutils2.findOne(
|
|
9652
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "head",
|
|
9653
|
+
html.children,
|
|
9654
|
+
true
|
|
9655
|
+
);
|
|
9656
|
+
} else if (rootTag === "body") {
|
|
9657
|
+
current = domutils2.findOne(
|
|
9658
|
+
(elem) => elem.type === "tag" && elem.name.toLowerCase() === "body",
|
|
9659
|
+
html.children,
|
|
9660
|
+
true
|
|
9661
|
+
);
|
|
9662
|
+
}
|
|
9663
|
+
if (!current) return null;
|
|
9664
|
+
return traverseByIndices(current, indices);
|
|
9665
|
+
} else {
|
|
9666
|
+
const rootElements = dom.filter(
|
|
9667
|
+
(child) => child.type === "tag"
|
|
9668
|
+
);
|
|
9669
|
+
const rootIndex = parseInt(rootTag, 10);
|
|
9670
|
+
if (rootIndex >= rootElements.length) {
|
|
9671
|
+
return null;
|
|
9672
|
+
}
|
|
9673
|
+
current = rootElements[rootIndex];
|
|
9674
|
+
return traverseByIndices(current, indices);
|
|
9675
|
+
}
|
|
9676
|
+
}
|
|
9677
|
+
for (const [path19, value] of Object.entries(data)) {
|
|
9678
|
+
const [nodePath, attribute] = path19.split("#");
|
|
9679
|
+
const element = resolvePathToElement(nodePath);
|
|
9680
|
+
if (!element) {
|
|
9681
|
+
console.warn(`Path not found in original template: ${nodePath}`);
|
|
9682
|
+
continue;
|
|
9683
|
+
}
|
|
9684
|
+
if (attribute) {
|
|
9685
|
+
element.attribs = element.attribs || {};
|
|
9686
|
+
element.attribs[attribute] = value;
|
|
9687
|
+
} else {
|
|
9688
|
+
if (value) {
|
|
9689
|
+
const { processed: processedValue, twigBlocks: valueTwigBlocks } = preprocessTwig(value);
|
|
9690
|
+
const valueHandler = new (0, _domhandler.DomHandler)();
|
|
9691
|
+
const valueParser = new htmlparser23.Parser(valueHandler);
|
|
9692
|
+
valueParser.write(processedValue);
|
|
9693
|
+
valueParser.end();
|
|
9694
|
+
element.children = valueHandler.dom;
|
|
9695
|
+
element.children.forEach((child) => {
|
|
9696
|
+
if (child.type === "text" && child.data) {
|
|
9697
|
+
child.data = postprocessTwig(child.data, valueTwigBlocks);
|
|
9698
|
+
}
|
|
9699
|
+
});
|
|
9700
|
+
} else {
|
|
9701
|
+
element.children = [];
|
|
9702
|
+
}
|
|
9703
|
+
}
|
|
9704
|
+
}
|
|
9705
|
+
const serialized = DomSerializer2.default(dom, { encodeEntities: false });
|
|
9706
|
+
return postprocessTwig(serialized, twigBlocks);
|
|
9707
|
+
}
|
|
9708
|
+
});
|
|
9709
|
+
}
|
|
9710
|
+
|
|
9239
9711
|
// src/cli/loaders/ensure-key-order.ts
|
|
9240
9712
|
|
|
9241
9713
|
function createEnsureKeyOrderLoader() {
|
|
@@ -9388,6 +9860,18 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
9388
9860
|
switch (bucketType) {
|
|
9389
9861
|
default:
|
|
9390
9862
|
throw new Error(`Unsupported bucket type: ${bucketType}`);
|
|
9863
|
+
case "ail":
|
|
9864
|
+
return composeLoaders(
|
|
9865
|
+
createTextFileLoader(bucketPathPattern),
|
|
9866
|
+
createLockedPatternsLoader(lockedPatterns),
|
|
9867
|
+
createAilLoader(),
|
|
9868
|
+
createEnsureKeyOrderLoader(),
|
|
9869
|
+
createFlatLoader(),
|
|
9870
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
9871
|
+
createIgnoredKeysLoader(ignoredKeys || []),
|
|
9872
|
+
createSyncLoader(),
|
|
9873
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
9874
|
+
);
|
|
9391
9875
|
case "android":
|
|
9392
9876
|
return composeLoaders(
|
|
9393
9877
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -9734,6 +10218,16 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
9734
10218
|
createIgnoredKeysLoader(ignoredKeys || []),
|
|
9735
10219
|
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
9736
10220
|
);
|
|
10221
|
+
case "twig":
|
|
10222
|
+
return composeLoaders(
|
|
10223
|
+
createTextFileLoader(bucketPathPattern),
|
|
10224
|
+
createLockedPatternsLoader(lockedPatterns),
|
|
10225
|
+
createTwigLoader(),
|
|
10226
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
10227
|
+
createIgnoredKeysLoader(ignoredKeys || []),
|
|
10228
|
+
createSyncLoader(),
|
|
10229
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
10230
|
+
);
|
|
9737
10231
|
case "txt":
|
|
9738
10232
|
return composeLoaders(
|
|
9739
10233
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -10133,7 +10627,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
10133
10627
|
]
|
|
10134
10628
|
});
|
|
10135
10629
|
const result = JSON.parse(response.text);
|
|
10136
|
-
return _optionalChain([result, 'optionalAccess',
|
|
10630
|
+
return _optionalChain([result, 'optionalAccess', _337 => _337.data]) || {};
|
|
10137
10631
|
}
|
|
10138
10632
|
}
|
|
10139
10633
|
function extractPayloadChunks(payload) {
|
|
@@ -10216,7 +10710,7 @@ function getPureModelProvider(provider) {
|
|
|
10216
10710
|
|
|
10217
10711
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
10218
10712
|
`;
|
|
10219
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
10713
|
+
switch (_optionalChain([provider, 'optionalAccess', _338 => _338.id])) {
|
|
10220
10714
|
case "openai": {
|
|
10221
10715
|
if (!process.env.OPENAI_API_KEY) {
|
|
10222
10716
|
throw new Error(
|
|
@@ -10274,7 +10768,7 @@ function getPureModelProvider(provider) {
|
|
|
10274
10768
|
})(provider.model);
|
|
10275
10769
|
}
|
|
10276
10770
|
default: {
|
|
10277
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
10771
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _339 => _339.id])));
|
|
10278
10772
|
}
|
|
10279
10773
|
}
|
|
10280
10774
|
}
|
|
@@ -10560,7 +11054,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10560
11054
|
validateParams(i18nConfig, flags);
|
|
10561
11055
|
ora.succeed("Localization configuration is valid");
|
|
10562
11056
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
10563
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
11057
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _340 => _340.provider]);
|
|
10564
11058
|
if (isByokMode) {
|
|
10565
11059
|
authId = null;
|
|
10566
11060
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -10574,16 +11068,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10574
11068
|
flags
|
|
10575
11069
|
});
|
|
10576
11070
|
let buckets = getBuckets(i18nConfig);
|
|
10577
|
-
if (_optionalChain([flags, 'access',
|
|
11071
|
+
if (_optionalChain([flags, 'access', _341 => _341.bucket, 'optionalAccess', _342 => _342.length])) {
|
|
10578
11072
|
buckets = buckets.filter(
|
|
10579
11073
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
10580
11074
|
);
|
|
10581
11075
|
}
|
|
10582
11076
|
ora.succeed("Buckets retrieved");
|
|
10583
|
-
if (_optionalChain([flags, 'access',
|
|
11077
|
+
if (_optionalChain([flags, 'access', _343 => _343.file, 'optionalAccess', _344 => _344.length])) {
|
|
10584
11078
|
buckets = buckets.map((bucket) => {
|
|
10585
11079
|
const paths = bucket.paths.filter(
|
|
10586
|
-
(path19) => flags.file.find((file) => _optionalChain([path19, 'access',
|
|
11080
|
+
(path19) => flags.file.find((file) => _optionalChain([path19, 'access', _345 => _345.pathPattern, 'optionalAccess', _346 => _346.includes, 'call', _347 => _347(file)]))
|
|
10587
11081
|
);
|
|
10588
11082
|
return { ...bucket, paths };
|
|
10589
11083
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -10604,7 +11098,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10604
11098
|
});
|
|
10605
11099
|
}
|
|
10606
11100
|
}
|
|
10607
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
11101
|
+
const targetLocales = _optionalChain([flags, 'access', _348 => _348.locale, 'optionalAccess', _349 => _349.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
10608
11102
|
ora.start("Setting up localization cache...");
|
|
10609
11103
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
10610
11104
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -10889,7 +11383,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10889
11383
|
}
|
|
10890
11384
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
10891
11385
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
10892
|
-
if (!_optionalChain([flags, 'access',
|
|
11386
|
+
if (!_optionalChain([flags, 'access', _350 => _350.locale, 'optionalAccess', _351 => _351.length])) {
|
|
10893
11387
|
await deltaProcessor.saveChecksums(checksums);
|
|
10894
11388
|
}
|
|
10895
11389
|
}
|
|
@@ -11013,12 +11507,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
11013
11507
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
11014
11508
|
docUrl: "bucketNotFound"
|
|
11015
11509
|
});
|
|
11016
|
-
} else if (_optionalChain([flags, 'access',
|
|
11510
|
+
} else if (_optionalChain([flags, 'access', _352 => _352.locale, 'optionalAccess', _353 => _353.some, 'call', _354 => _354((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
11017
11511
|
throw new ValidationError({
|
|
11018
11512
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
11019
11513
|
docUrl: "localeTargetNotFound"
|
|
11020
11514
|
});
|
|
11021
|
-
} else if (_optionalChain([flags, 'access',
|
|
11515
|
+
} else if (_optionalChain([flags, 'access', _355 => _355.bucket, 'optionalAccess', _356 => _356.some, 'call', _357 => _357(
|
|
11022
11516
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
11023
11517
|
)])) {
|
|
11024
11518
|
throw new ValidationError({
|
|
@@ -11552,7 +12046,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
11552
12046
|
const response = await engine.whoami();
|
|
11553
12047
|
return {
|
|
11554
12048
|
authenticated: !!response,
|
|
11555
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
12049
|
+
username: _optionalChain([response, 'optionalAccess', _358 => _358.email])
|
|
11556
12050
|
};
|
|
11557
12051
|
} catch (error) {
|
|
11558
12052
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -11668,7 +12162,7 @@ function createExplicitLocalizer(provider) {
|
|
|
11668
12162
|
}
|
|
11669
12163
|
function createAiSdkLocalizer(params) {
|
|
11670
12164
|
const skipAuth = params.skipAuth === true;
|
|
11671
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
12165
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _359 => _359.apiKeyName]), () => ( ""))];
|
|
11672
12166
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
11673
12167
|
throw new Error(
|
|
11674
12168
|
_dedent2.default`
|
|
@@ -11802,8 +12296,8 @@ async function setup(input2) {
|
|
|
11802
12296
|
throw new Error(
|
|
11803
12297
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
11804
12298
|
);
|
|
11805
|
-
} else if (_optionalChain([ctx, 'access',
|
|
11806
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
12299
|
+
} else if (_optionalChain([ctx, 'access', _360 => _360.flags, 'access', _361 => _361.bucket, 'optionalAccess', _362 => _362.some, 'call', _363 => _363(
|
|
12300
|
+
(bucket) => !_optionalChain([ctx, 'access', _364 => _364.config, 'optionalAccess', _365 => _365.buckets, 'access', _366 => _366[bucket]])
|
|
11807
12301
|
)])) {
|
|
11808
12302
|
throw new Error(
|
|
11809
12303
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -11816,7 +12310,7 @@ async function setup(input2) {
|
|
|
11816
12310
|
title: "Selecting localization provider",
|
|
11817
12311
|
task: async (ctx, task) => {
|
|
11818
12312
|
ctx.localizer = createLocalizer(
|
|
11819
|
-
_optionalChain([ctx, 'access',
|
|
12313
|
+
_optionalChain([ctx, 'access', _367 => _367.config, 'optionalAccess', _368 => _368.provider]),
|
|
11820
12314
|
ctx.flags.apiKey
|
|
11821
12315
|
);
|
|
11822
12316
|
if (!ctx.localizer) {
|
|
@@ -11829,7 +12323,7 @@ async function setup(input2) {
|
|
|
11829
12323
|
},
|
|
11830
12324
|
{
|
|
11831
12325
|
title: "Checking authentication",
|
|
11832
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12326
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _369 => _369.localizer, 'optionalAccess', _370 => _370.id]) === "Lingo.dev",
|
|
11833
12327
|
task: async (ctx, task) => {
|
|
11834
12328
|
const authStatus = await ctx.localizer.checkAuth();
|
|
11835
12329
|
if (!authStatus.authenticated) {
|
|
@@ -11842,7 +12336,7 @@ async function setup(input2) {
|
|
|
11842
12336
|
},
|
|
11843
12337
|
{
|
|
11844
12338
|
title: "Validating configuration",
|
|
11845
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12339
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _371 => _371.localizer, 'optionalAccess', _372 => _372.id]) !== "Lingo.dev",
|
|
11846
12340
|
task: async (ctx, task) => {
|
|
11847
12341
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
11848
12342
|
if (!validationStatus.valid) {
|
|
@@ -12173,7 +12667,7 @@ function createWorkerTask(args) {
|
|
|
12173
12667
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
12174
12668
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
12175
12669
|
).filter(
|
|
12176
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
12670
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _373 => _373.onlyKeys, 'optionalAccess', _374 => _374.some, 'call', _375 => _375(
|
|
12177
12671
|
(pattern) => minimatch(key, pattern)
|
|
12178
12672
|
)])
|
|
12179
12673
|
).fromPairs().value();
|
|
@@ -12241,7 +12735,7 @@ function createWorkerTask(args) {
|
|
|
12241
12735
|
finalRenamedTargetData
|
|
12242
12736
|
);
|
|
12243
12737
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
12244
|
-
if (!_optionalChain([args, 'access',
|
|
12738
|
+
if (!_optionalChain([args, 'access', _376 => _376.ctx, 'access', _377 => _377.flags, 'access', _378 => _378.targetLocale, 'optionalAccess', _379 => _379.length])) {
|
|
12245
12739
|
await deltaProcessor.saveChecksums(checksums);
|
|
12246
12740
|
}
|
|
12247
12741
|
});
|
|
@@ -12446,10 +12940,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
12446
12940
|
async function frozen(input2) {
|
|
12447
12941
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
12448
12942
|
let buckets = getBuckets(input2.config);
|
|
12449
|
-
if (_optionalChain([input2, 'access',
|
|
12943
|
+
if (_optionalChain([input2, 'access', _380 => _380.flags, 'access', _381 => _381.bucket, 'optionalAccess', _382 => _382.length])) {
|
|
12450
12944
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
12451
12945
|
}
|
|
12452
|
-
if (_optionalChain([input2, 'access',
|
|
12946
|
+
if (_optionalChain([input2, 'access', _383 => _383.flags, 'access', _384 => _384.file, 'optionalAccess', _385 => _385.length])) {
|
|
12453
12947
|
buckets = buckets.map((bucket) => {
|
|
12454
12948
|
const paths = bucket.paths.filter(
|
|
12455
12949
|
(p) => input2.flags.file.some(
|
|
@@ -12586,13 +13080,13 @@ async function frozen(input2) {
|
|
|
12586
13080
|
|
|
12587
13081
|
// src/cli/cmd/run/_utils.ts
|
|
12588
13082
|
async function determineAuthId(ctx) {
|
|
12589
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
13083
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _386 => _386.config, 'optionalAccess', _387 => _387.provider]);
|
|
12590
13084
|
if (isByokMode) {
|
|
12591
13085
|
return null;
|
|
12592
13086
|
} else {
|
|
12593
13087
|
try {
|
|
12594
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
12595
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
13088
|
+
const authStatus = await _optionalChain([ctx, 'access', _388 => _388.localizer, 'optionalAccess', _389 => _389.checkAuth, 'call', _390 => _390()]);
|
|
13089
|
+
return _optionalChain([authStatus, 'optionalAccess', _391 => _391.username]) || null;
|
|
12596
13090
|
} catch (e3) {
|
|
12597
13091
|
return null;
|
|
12598
13092
|
}
|
|
@@ -12790,7 +13284,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12790
13284
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
12791
13285
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
12792
13286
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
12793
|
-
_optionalChain([this, 'access',
|
|
13287
|
+
_optionalChain([this, 'access', _392 => _392.platformKit, 'optionalAccess', _393 => _393.gitConfig, 'call', _394 => _394()]);
|
|
12794
13288
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
12795
13289
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
12796
13290
|
if (!processOwnCommits) {
|
|
@@ -12822,7 +13316,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12822
13316
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
12823
13317
|
var PullRequestFlow = class extends InBranchFlow {
|
|
12824
13318
|
async preRun() {
|
|
12825
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
13319
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _395 => _395()]);
|
|
12826
13320
|
if (!canContinue) {
|
|
12827
13321
|
return false;
|
|
12828
13322
|
}
|
|
@@ -13089,10 +13583,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
13089
13583
|
repo_slug: this.platformConfig.repositoryName,
|
|
13090
13584
|
state: "OPEN"
|
|
13091
13585
|
}).then(({ data: { values } }) => {
|
|
13092
|
-
return _optionalChain([values, 'optionalAccess',
|
|
13093
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
13586
|
+
return _optionalChain([values, 'optionalAccess', _396 => _396.find, 'call', _397 => _397(
|
|
13587
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _398 => _398.branch, 'optionalAccess', _399 => _399.name]) === branch && _optionalChain([destination, 'optionalAccess', _400 => _400.branch, 'optionalAccess', _401 => _401.name]) === this.platformConfig.baseBranchName
|
|
13094
13588
|
)]);
|
|
13095
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
13589
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _402 => _402.id]));
|
|
13096
13590
|
}
|
|
13097
13591
|
async closePullRequest({ pullRequestNumber }) {
|
|
13098
13592
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -13188,7 +13682,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
13188
13682
|
repo: this.platformConfig.repositoryName,
|
|
13189
13683
|
base: this.platformConfig.baseBranchName,
|
|
13190
13684
|
state: "open"
|
|
13191
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
13685
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _403 => _403.number]));
|
|
13192
13686
|
}
|
|
13193
13687
|
async closePullRequest({ pullRequestNumber }) {
|
|
13194
13688
|
await this.octokit.rest.pulls.update({
|
|
@@ -13315,7 +13809,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
13315
13809
|
sourceBranch: branch,
|
|
13316
13810
|
state: "opened"
|
|
13317
13811
|
});
|
|
13318
|
-
return _optionalChain([mergeRequests, 'access',
|
|
13812
|
+
return _optionalChain([mergeRequests, 'access', _404 => _404[0], 'optionalAccess', _405 => _405.iid]);
|
|
13319
13813
|
}
|
|
13320
13814
|
async closePullRequest({
|
|
13321
13815
|
pullRequestNumber
|
|
@@ -13427,7 +13921,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
13427
13921
|
}
|
|
13428
13922
|
const env = {
|
|
13429
13923
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
13430
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
13924
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _406 => _406.pullRequest, 'optionalAccess', _407 => _407.toString, 'call', _408 => _408()]) || "false",
|
|
13431
13925
|
...options.commitMessage && {
|
|
13432
13926
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
13433
13927
|
},
|
|
@@ -13453,7 +13947,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
13453
13947
|
const { isPullRequestMode } = platformKit.config;
|
|
13454
13948
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
13455
13949
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
13456
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
13950
|
+
const canRun = await _optionalChain([flow, 'access', _409 => _409.preRun, 'optionalCall', _410 => _410()]);
|
|
13457
13951
|
if (canRun === false) {
|
|
13458
13952
|
return;
|
|
13459
13953
|
}
|
|
@@ -13463,7 +13957,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
13463
13957
|
if (!hasChanges) {
|
|
13464
13958
|
return;
|
|
13465
13959
|
}
|
|
13466
|
-
await _optionalChain([flow, 'access',
|
|
13960
|
+
await _optionalChain([flow, 'access', _411 => _411.postRun, 'optionalCall', _412 => _412()]);
|
|
13467
13961
|
});
|
|
13468
13962
|
function parseBooleanArg(val) {
|
|
13469
13963
|
if (val === true) return true;
|
|
@@ -13500,8 +13994,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
13500
13994
|
}
|
|
13501
13995
|
}
|
|
13502
13996
|
function checkForPendingOperations() {
|
|
13503
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
13504
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
13997
|
+
const activeHandles = _optionalChain([process, 'access', _413 => _413._getActiveHandles, 'optionalCall', _414 => _414()]) || [];
|
|
13998
|
+
const activeRequests = _optionalChain([process, 'access', _415 => _415._getActiveRequests, 'optionalCall', _416 => _416()]) || [];
|
|
13505
13999
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
13506
14000
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
13507
14001
|
return false;
|
|
@@ -13570,17 +14064,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
13570
14064
|
flags
|
|
13571
14065
|
});
|
|
13572
14066
|
let buckets = getBuckets(i18nConfig);
|
|
13573
|
-
if (_optionalChain([flags, 'access',
|
|
14067
|
+
if (_optionalChain([flags, 'access', _417 => _417.bucket, 'optionalAccess', _418 => _418.length])) {
|
|
13574
14068
|
buckets = buckets.filter(
|
|
13575
14069
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
13576
14070
|
);
|
|
13577
14071
|
}
|
|
13578
14072
|
ora.succeed("Buckets retrieved");
|
|
13579
|
-
if (_optionalChain([flags, 'access',
|
|
14073
|
+
if (_optionalChain([flags, 'access', _419 => _419.file, 'optionalAccess', _420 => _420.length])) {
|
|
13580
14074
|
buckets = buckets.map((bucket) => {
|
|
13581
14075
|
const paths = bucket.paths.filter(
|
|
13582
14076
|
(path19) => flags.file.find(
|
|
13583
|
-
(file) => _optionalChain([path19, 'access',
|
|
14077
|
+
(file) => _optionalChain([path19, 'access', _421 => _421.pathPattern, 'optionalAccess', _422 => _422.includes, 'call', _423 => _423(file)]) || _optionalChain([path19, 'access', _424 => _424.pathPattern, 'optionalAccess', _425 => _425.match, 'call', _426 => _426(file)]) || minimatch(path19.pathPattern, file)
|
|
13584
14078
|
)
|
|
13585
14079
|
);
|
|
13586
14080
|
return { ...bucket, paths };
|
|
@@ -13600,7 +14094,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
13600
14094
|
});
|
|
13601
14095
|
}
|
|
13602
14096
|
}
|
|
13603
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
14097
|
+
const targetLocales = _optionalChain([flags, 'access', _427 => _427.locale, 'optionalAccess', _428 => _428.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
13604
14098
|
let totalSourceKeyCount = 0;
|
|
13605
14099
|
let uniqueKeysToTranslate = 0;
|
|
13606
14100
|
let totalExistingTranslations = 0;
|
|
@@ -14008,12 +14502,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
14008
14502
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
14009
14503
|
docUrl: "bucketNotFound"
|
|
14010
14504
|
});
|
|
14011
|
-
} else if (_optionalChain([flags, 'access',
|
|
14505
|
+
} else if (_optionalChain([flags, 'access', _429 => _429.locale, 'optionalAccess', _430 => _430.some, 'call', _431 => _431((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
14012
14506
|
throw new CLIError({
|
|
14013
14507
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
14014
14508
|
docUrl: "localeTargetNotFound"
|
|
14015
14509
|
});
|
|
14016
|
-
} else if (_optionalChain([flags, 'access',
|
|
14510
|
+
} else if (_optionalChain([flags, 'access', _432 => _432.bucket, 'optionalAccess', _433 => _433.some, 'call', _434 => _434(
|
|
14017
14511
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
14018
14512
|
)])) {
|
|
14019
14513
|
throw new CLIError({
|
|
@@ -14105,7 +14599,7 @@ async function renderHero2() {
|
|
|
14105
14599
|
// package.json
|
|
14106
14600
|
var package_default = {
|
|
14107
14601
|
name: "lingo.dev",
|
|
14108
|
-
version: "0.117.
|
|
14602
|
+
version: "0.117.9",
|
|
14109
14603
|
description: "Lingo.dev CLI",
|
|
14110
14604
|
private: false,
|
|
14111
14605
|
publishConfig: {
|
|
@@ -14401,7 +14895,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
14401
14895
|
if (options.file && options.file.length) {
|
|
14402
14896
|
buckets = buckets.map((bucket) => {
|
|
14403
14897
|
const paths = bucket.paths.filter(
|
|
14404
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
14898
|
+
(bucketPath) => _optionalChain([options, 'access', _435 => _435.file, 'optionalAccess', _436 => _436.some, 'call', _437 => _437((f) => bucketPath.pathPattern.includes(f))])
|
|
14405
14899
|
);
|
|
14406
14900
|
return { ...bucket, paths };
|
|
14407
14901
|
}).filter((bucket) => bucket.paths.length > 0);
|