lingo.dev 0.117.7 → 0.117.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cli.cjs CHANGED
@@ -3407,8 +3407,8 @@ function serializeElement(node) {
3407
3407
  const attrString = Object.entries(attributes).map(([key, value]) => ` ${key}="${escapeAttributeValue(String(value))}"`).join("");
3408
3408
  const children = Array.isArray(node.$$) ? node.$$ : [];
3409
3409
  if (children.length === 0) {
3410
- const textContent2 = _nullishCoalesce(node._, () => ( ""));
3411
- return `<${name}${attrString}>${textContent2}</${name}>`;
3410
+ const textContent3 = _nullishCoalesce(node._, () => ( ""));
3411
+ return `<${name}${attrString}>${textContent3}</${name}>`;
3412
3412
  }
3413
3413
  const childContent = children.map(serializeElement).join("");
3414
3414
  return `<${name}${attrString}>${childContent}</${name}>`;
@@ -3497,10 +3497,10 @@ function createPullOutputCleaner() {
3497
3497
  }
3498
3498
 
3499
3499
  // src/cli/loaders/html.ts
3500
- var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2); var htmlparser22 = _interopRequireWildcard(_htmlparser2);
3500
+ var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2); var htmlparser22 = _interopRequireWildcard(_htmlparser2); var htmlparser23 = _interopRequireWildcard(_htmlparser2);
3501
3501
  var _domhandler = require('domhandler');
3502
- var _domutils = require('domutils'); var domutils = _interopRequireWildcard(_domutils);
3503
- var _domserializer = require('dom-serializer'); var DomSerializer = _interopRequireWildcard(_domserializer);
3502
+ var _domutils = require('domutils'); var domutils = _interopRequireWildcard(_domutils); var domutils2 = _interopRequireWildcard(_domutils);
3503
+ var _domserializer = require('dom-serializer'); var DomSerializer = _interopRequireWildcard(_domserializer); var DomSerializer2 = _interopRequireWildcard(_domserializer);
3504
3504
  function createHtmlLoader() {
3505
3505
  const PHRASING_ELEMENTS = /* @__PURE__ */ new Set([
3506
3506
  // Text-level semantics
@@ -4194,9 +4194,9 @@ function serializeXmlNode(node) {
4194
4194
  const attrString = Object.entries(attrs).map(([key, value]) => ` ${key}="${escapeAttributeValue2(String(value))}"`).join("");
4195
4195
  const children = node.$$ || [];
4196
4196
  if (children.length === 0) {
4197
- const textContent2 = node._ || "";
4198
- if (textContent2) {
4199
- return `<${name}${attrString}>${textContent2}</${name}>`;
4197
+ const textContent3 = node._ || "";
4198
+ if (textContent3) {
4199
+ return `<${name}${attrString}>${textContent3}</${name}>`;
4200
4200
  }
4201
4201
  return `<${name}${attrString} />`;
4202
4202
  }
@@ -4253,9 +4253,9 @@ function serializeElement2(node, indent2 = "") {
4253
4253
  const attrString = Object.entries(attributes).map(([key, value]) => ` ${key}="${escapeAttributeValue2(String(value))}"`).join("");
4254
4254
  const children = Array.isArray(node.$$) ? node.$$ : [];
4255
4255
  if (children.length === 0) {
4256
- const textContent2 = _nullishCoalesce(node._, () => ( ""));
4257
- if (textContent2) {
4258
- return `${indent2}<${name}${attrString}>${textContent2}</${name}>`;
4256
+ const textContent3 = _nullishCoalesce(node._, () => ( ""));
4257
+ if (textContent3) {
4258
+ return `${indent2}<${name}${attrString}>${textContent3}</${name}>`;
4259
4259
  }
4260
4260
  return `${indent2}<${name}${attrString} />`;
4261
4261
  }
@@ -5814,10 +5814,10 @@ function formatXml(xml) {
5814
5814
  if (cdataNode) {
5815
5815
  return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
5816
5816
  }
5817
- const textContent2 = _optionalChain([element, 'access', _258 => _258.textContent, 'optionalAccess', _259 => _259.trim, 'call', _260 => _260()]) || "";
5817
+ const textContent3 = _optionalChain([element, 'access', _258 => _258.textContent, 'optionalAccess', _259 => _259.trim, 'call', _260 => _260()]) || "";
5818
5818
  const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
5819
- if (hasOnlyText && textContent2) {
5820
- return `${indent2}${openTag}${textContent2}</${tagName}>`;
5819
+ if (hasOnlyText && textContent3) {
5820
+ return `${indent2}${openTag}${textContent3}</${tagName}>`;
5821
5821
  }
5822
5822
  const children = Array.from(element.children);
5823
5823
  if (children.length === 0) {
@@ -9137,14 +9137,14 @@ function parseEjsForTranslation(input2) {
9137
9137
  if (part.type === "ejs") {
9138
9138
  template += part.content;
9139
9139
  } else {
9140
- const textContent2 = part.content;
9140
+ const textContent3 = part.content;
9141
9141
  const htmlTagRegex = /<[^>]+>/g;
9142
9142
  const textParts = [];
9143
9143
  let lastTextIndex = 0;
9144
9144
  let htmlMatch;
9145
- while ((htmlMatch = htmlTagRegex.exec(textContent2)) !== null) {
9145
+ while ((htmlMatch = htmlTagRegex.exec(textContent3)) !== null) {
9146
9146
  if (htmlMatch.index > lastTextIndex) {
9147
- const textBefore = textContent2.slice(lastTextIndex, htmlMatch.index);
9147
+ const textBefore = textContent3.slice(lastTextIndex, htmlMatch.index);
9148
9148
  if (textBefore.trim()) {
9149
9149
  textParts.push({ type: "text", content: textBefore });
9150
9150
  } else {
@@ -9154,8 +9154,8 @@ function parseEjsForTranslation(input2) {
9154
9154
  textParts.push({ type: "html", content: htmlMatch[0] });
9155
9155
  lastTextIndex = htmlMatch.index + htmlMatch[0].length;
9156
9156
  }
9157
- if (lastTextIndex < textContent2.length) {
9158
- const remainingText = textContent2.slice(lastTextIndex);
9157
+ if (lastTextIndex < textContent3.length) {
9158
+ const remainingText = textContent3.slice(lastTextIndex);
9159
9159
  if (remainingText.trim()) {
9160
9160
  textParts.push({ type: "text", content: remainingText });
9161
9161
  } else {
@@ -9163,11 +9163,11 @@ function parseEjsForTranslation(input2) {
9163
9163
  }
9164
9164
  }
9165
9165
  if (textParts.length === 0) {
9166
- const trimmedContent = textContent2.trim();
9166
+ const trimmedContent = textContent3.trim();
9167
9167
  if (trimmedContent) {
9168
- textParts.push({ type: "text", content: textContent2 });
9168
+ textParts.push({ type: "text", content: textContent3 });
9169
9169
  } else {
9170
- textParts.push({ type: "html", content: textContent2 });
9170
+ textParts.push({ type: "html", content: textContent3 });
9171
9171
  }
9172
9172
  }
9173
9173
  for (const textPart of textParts) {
@@ -9236,6 +9236,368 @@ function createEjsLoader() {
9236
9236
  });
9237
9237
  }
9238
9238
 
9239
+ // src/cli/loaders/twig.ts
9240
+
9241
+
9242
+
9243
+
9244
+ function createTwigLoader() {
9245
+ const PHRASING_ELEMENTS = /* @__PURE__ */ new Set([
9246
+ // Text-level semantics
9247
+ "a",
9248
+ "abbr",
9249
+ "b",
9250
+ "bdi",
9251
+ "bdo",
9252
+ "br",
9253
+ "cite",
9254
+ "code",
9255
+ "data",
9256
+ "dfn",
9257
+ "em",
9258
+ "i",
9259
+ "kbd",
9260
+ "mark",
9261
+ "q",
9262
+ "ruby",
9263
+ "s",
9264
+ "samp",
9265
+ "small",
9266
+ "span",
9267
+ "strong",
9268
+ "sub",
9269
+ "sup",
9270
+ "time",
9271
+ "u",
9272
+ "var",
9273
+ "wbr",
9274
+ // Media
9275
+ "audio",
9276
+ "img",
9277
+ "video",
9278
+ "picture",
9279
+ // Interactive
9280
+ "button",
9281
+ "input",
9282
+ "label",
9283
+ "select",
9284
+ "textarea",
9285
+ // Embedded
9286
+ "canvas",
9287
+ "iframe",
9288
+ "object",
9289
+ "svg",
9290
+ "math",
9291
+ // Other
9292
+ "del",
9293
+ "ins",
9294
+ "map",
9295
+ "area"
9296
+ ]);
9297
+ const BLOCK_ELEMENTS = /* @__PURE__ */ new Set([
9298
+ "div",
9299
+ "p",
9300
+ "h1",
9301
+ "h2",
9302
+ "h3",
9303
+ "h4",
9304
+ "h5",
9305
+ "h6",
9306
+ "ul",
9307
+ "ol",
9308
+ "li",
9309
+ "dl",
9310
+ "dt",
9311
+ "dd",
9312
+ "blockquote",
9313
+ "pre",
9314
+ "article",
9315
+ "aside",
9316
+ "nav",
9317
+ "section",
9318
+ "header",
9319
+ "footer",
9320
+ "main",
9321
+ "figure",
9322
+ "figcaption",
9323
+ "table",
9324
+ "thead",
9325
+ "tbody",
9326
+ "tfoot",
9327
+ "tr",
9328
+ "td",
9329
+ "th",
9330
+ "caption",
9331
+ "form",
9332
+ "fieldset",
9333
+ "legend",
9334
+ "details",
9335
+ "summary",
9336
+ "address",
9337
+ "hr",
9338
+ "search",
9339
+ "dialog",
9340
+ "noscript",
9341
+ "title"
9342
+ ]);
9343
+ const UNLOCALIZABLE_TAGS = /* @__PURE__ */ new Set(["script", "style"]);
9344
+ const LOCALIZABLE_ATTRIBUTES2 = {
9345
+ meta: ["content"],
9346
+ img: ["alt", "title"],
9347
+ input: ["placeholder", "title", "aria-label"],
9348
+ textarea: ["placeholder", "title", "aria-label"],
9349
+ button: ["title", "aria-label"],
9350
+ a: ["title", "aria-label"],
9351
+ abbr: ["title"],
9352
+ link: ["title"]
9353
+ };
9354
+ function preprocessTwig(input2) {
9355
+ const twigBlocks = [];
9356
+ let counter = 0;
9357
+ const processed = input2.replace(/\{%[\s\S]*?%\}/g, (match2) => {
9358
+ twigBlocks.push(match2);
9359
+ return `__TWIG_BLOCK_${counter++}__`;
9360
+ });
9361
+ return {
9362
+ processed: processed.replace(/\{#[\s\S]*?#\}/g, (match2) => {
9363
+ twigBlocks.push(match2);
9364
+ return `__TWIG_BLOCK_${counter++}__`;
9365
+ }),
9366
+ twigBlocks
9367
+ };
9368
+ }
9369
+ function postprocessTwig(text, twigBlocks) {
9370
+ return text.replace(/__TWIG_BLOCK_(\d+)__/g, (_37, index) => {
9371
+ return twigBlocks[parseInt(index, 10)] || "";
9372
+ });
9373
+ }
9374
+ return createLoader({
9375
+ async pull(locale, input2) {
9376
+ const result = {};
9377
+ const { processed, twigBlocks } = preprocessTwig(input2);
9378
+ const handler = new (0, _domhandler.DomHandler)();
9379
+ const parser = new htmlparser23.Parser(handler, {
9380
+ lowerCaseTags: false,
9381
+ lowerCaseAttributeNames: false
9382
+ });
9383
+ parser.write(processed);
9384
+ parser.end();
9385
+ const dom = handler.dom;
9386
+ function isInsideUnlocalizableTag(element) {
9387
+ let current = element.parent;
9388
+ while (current && current.type === "tag") {
9389
+ if (UNLOCALIZABLE_TAGS.has(current.name.toLowerCase())) {
9390
+ return true;
9391
+ }
9392
+ current = current.parent;
9393
+ }
9394
+ return false;
9395
+ }
9396
+ function hasTranslatableContent(element) {
9397
+ const text = domutils2.textContent(element);
9398
+ return text.trim().length > 0;
9399
+ }
9400
+ function isLeafBlock(element) {
9401
+ const childElements = element.children.filter(
9402
+ (child) => child.type === "tag"
9403
+ );
9404
+ for (const child of childElements) {
9405
+ if (BLOCK_ELEMENTS.has(child.name.toLowerCase())) {
9406
+ return false;
9407
+ }
9408
+ }
9409
+ return hasTranslatableContent(element);
9410
+ }
9411
+ function getInnerHTML2(element) {
9412
+ const html2 = element.children.map((child) => DomSerializer2.default(child, { encodeEntities: false })).join("");
9413
+ return postprocessTwig(html2, twigBlocks);
9414
+ }
9415
+ function extractAttributes(element, path19) {
9416
+ const tagName = element.name.toLowerCase();
9417
+ const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
9418
+ if (!attrs) return;
9419
+ for (const attr of attrs) {
9420
+ const value = _optionalChain([element, 'access', _325 => _325.attribs, 'optionalAccess', _326 => _326[attr]]);
9421
+ if (value && value.trim()) {
9422
+ const restoredValue = postprocessTwig(value.trim(), twigBlocks);
9423
+ result[`${path19}#${attr}`] = restoredValue;
9424
+ }
9425
+ }
9426
+ }
9427
+ function extractFromElement(element, pathParts) {
9428
+ const path19 = pathParts.join("/");
9429
+ if (isInsideUnlocalizableTag(element)) {
9430
+ return;
9431
+ }
9432
+ extractAttributes(element, path19);
9433
+ const tagName = element.name.toLowerCase();
9434
+ if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
9435
+ const content = getInnerHTML2(element).trim();
9436
+ if (content) {
9437
+ result[path19] = content;
9438
+ }
9439
+ return;
9440
+ }
9441
+ if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
9442
+ const content = getInnerHTML2(element).trim();
9443
+ if (content) {
9444
+ result[path19] = content;
9445
+ }
9446
+ return;
9447
+ }
9448
+ let childIndex = 0;
9449
+ const childElements = element.children.filter(
9450
+ (child) => child.type === "tag"
9451
+ );
9452
+ for (const child of childElements) {
9453
+ extractFromElement(child, [...pathParts, childIndex++]);
9454
+ }
9455
+ }
9456
+ const html = domutils2.findOne(
9457
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "html",
9458
+ dom,
9459
+ true
9460
+ );
9461
+ if (html) {
9462
+ const head = domutils2.findOne(
9463
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "head",
9464
+ html.children,
9465
+ true
9466
+ );
9467
+ const body = domutils2.findOne(
9468
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "body",
9469
+ html.children,
9470
+ true
9471
+ );
9472
+ if (head) {
9473
+ let headIndex = 0;
9474
+ const headChildren = head.children.filter(
9475
+ (child) => child.type === "tag"
9476
+ );
9477
+ for (const child of headChildren) {
9478
+ extractFromElement(child, ["head", headIndex++]);
9479
+ }
9480
+ }
9481
+ if (body) {
9482
+ let bodyIndex = 0;
9483
+ const bodyChildren = body.children.filter(
9484
+ (child) => child.type === "tag"
9485
+ );
9486
+ for (const child of bodyChildren) {
9487
+ extractFromElement(child, ["body", bodyIndex++]);
9488
+ }
9489
+ }
9490
+ } else {
9491
+ let rootIndex = 0;
9492
+ const rootElements = dom.filter(
9493
+ (child) => child.type === "tag"
9494
+ );
9495
+ for (const child of rootElements) {
9496
+ extractFromElement(child, [rootIndex++]);
9497
+ }
9498
+ }
9499
+ return result;
9500
+ },
9501
+ async push(locale, data, originalInput) {
9502
+ const { processed, twigBlocks } = preprocessTwig(originalInput || "");
9503
+ const handler = new (0, _domhandler.DomHandler)();
9504
+ const parser = new htmlparser23.Parser(handler, {
9505
+ lowerCaseTags: false,
9506
+ lowerCaseAttributeNames: false
9507
+ });
9508
+ parser.write(processed || "<!DOCTYPE html><html><head></head><body></body></html>");
9509
+ parser.end();
9510
+ const dom = handler.dom;
9511
+ const html = domutils2.findOne(
9512
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "html",
9513
+ dom,
9514
+ true
9515
+ );
9516
+ if (html) {
9517
+ html.attribs = html.attribs || {};
9518
+ html.attribs.lang = locale;
9519
+ }
9520
+ function traverseByIndices(element, indices) {
9521
+ let current = element;
9522
+ for (const indexStr of indices) {
9523
+ if (!current) return null;
9524
+ const index = parseInt(indexStr, 10);
9525
+ const children = current.children.filter(
9526
+ (child) => child.type === "tag"
9527
+ );
9528
+ if (index >= children.length) {
9529
+ return null;
9530
+ }
9531
+ current = children[index];
9532
+ }
9533
+ return current;
9534
+ }
9535
+ function resolvePathToElement(path19) {
9536
+ const parts = path19.split("/");
9537
+ const [rootTag, ...indices] = parts;
9538
+ let current = null;
9539
+ if (html) {
9540
+ if (rootTag === "head") {
9541
+ current = domutils2.findOne(
9542
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "head",
9543
+ html.children,
9544
+ true
9545
+ );
9546
+ } else if (rootTag === "body") {
9547
+ current = domutils2.findOne(
9548
+ (elem) => elem.type === "tag" && elem.name.toLowerCase() === "body",
9549
+ html.children,
9550
+ true
9551
+ );
9552
+ }
9553
+ if (!current) return null;
9554
+ return traverseByIndices(current, indices);
9555
+ } else {
9556
+ const rootElements = dom.filter(
9557
+ (child) => child.type === "tag"
9558
+ );
9559
+ const rootIndex = parseInt(rootTag, 10);
9560
+ if (rootIndex >= rootElements.length) {
9561
+ return null;
9562
+ }
9563
+ current = rootElements[rootIndex];
9564
+ return traverseByIndices(current, indices);
9565
+ }
9566
+ }
9567
+ for (const [path19, value] of Object.entries(data)) {
9568
+ const [nodePath, attribute] = path19.split("#");
9569
+ const element = resolvePathToElement(nodePath);
9570
+ if (!element) {
9571
+ console.warn(`Path not found in original template: ${nodePath}`);
9572
+ continue;
9573
+ }
9574
+ if (attribute) {
9575
+ element.attribs = element.attribs || {};
9576
+ element.attribs[attribute] = value;
9577
+ } else {
9578
+ if (value) {
9579
+ const { processed: processedValue, twigBlocks: valueTwigBlocks } = preprocessTwig(value);
9580
+ const valueHandler = new (0, _domhandler.DomHandler)();
9581
+ const valueParser = new htmlparser23.Parser(valueHandler);
9582
+ valueParser.write(processedValue);
9583
+ valueParser.end();
9584
+ element.children = valueHandler.dom;
9585
+ element.children.forEach((child) => {
9586
+ if (child.type === "text" && child.data) {
9587
+ child.data = postprocessTwig(child.data, valueTwigBlocks);
9588
+ }
9589
+ });
9590
+ } else {
9591
+ element.children = [];
9592
+ }
9593
+ }
9594
+ }
9595
+ const serialized = DomSerializer2.default(dom, { encodeEntities: false });
9596
+ return postprocessTwig(serialized, twigBlocks);
9597
+ }
9598
+ });
9599
+ }
9600
+
9239
9601
  // src/cli/loaders/ensure-key-order.ts
9240
9602
 
9241
9603
  function createEnsureKeyOrderLoader() {
@@ -9734,6 +10096,16 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
9734
10096
  createIgnoredKeysLoader(ignoredKeys || []),
9735
10097
  createUnlocalizableLoader(options.returnUnlocalizedKeys)
9736
10098
  );
10099
+ case "twig":
10100
+ return composeLoaders(
10101
+ createTextFileLoader(bucketPathPattern),
10102
+ createLockedPatternsLoader(lockedPatterns),
10103
+ createTwigLoader(),
10104
+ createLockedKeysLoader(lockedKeys || []),
10105
+ createIgnoredKeysLoader(ignoredKeys || []),
10106
+ createSyncLoader(),
10107
+ createUnlocalizableLoader(options.returnUnlocalizedKeys)
10108
+ );
9737
10109
  case "txt":
9738
10110
  return composeLoaders(
9739
10111
  createTextFileLoader(bucketPathPattern),
@@ -10133,7 +10505,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
10133
10505
  ]
10134
10506
  });
10135
10507
  const result = JSON.parse(response.text);
10136
- return _optionalChain([result, 'optionalAccess', _325 => _325.data]) || {};
10508
+ return _optionalChain([result, 'optionalAccess', _327 => _327.data]) || {};
10137
10509
  }
10138
10510
  }
10139
10511
  function extractPayloadChunks(payload) {
@@ -10216,7 +10588,7 @@ function getPureModelProvider(provider) {
10216
10588
 
10217
10589
  ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
10218
10590
  `;
10219
- switch (_optionalChain([provider, 'optionalAccess', _326 => _326.id])) {
10591
+ switch (_optionalChain([provider, 'optionalAccess', _328 => _328.id])) {
10220
10592
  case "openai": {
10221
10593
  if (!process.env.OPENAI_API_KEY) {
10222
10594
  throw new Error(
@@ -10274,7 +10646,7 @@ function getPureModelProvider(provider) {
10274
10646
  })(provider.model);
10275
10647
  }
10276
10648
  default: {
10277
- throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _327 => _327.id])));
10649
+ throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _329 => _329.id])));
10278
10650
  }
10279
10651
  }
10280
10652
  }
@@ -10560,7 +10932,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
10560
10932
  validateParams(i18nConfig, flags);
10561
10933
  ora.succeed("Localization configuration is valid");
10562
10934
  ora.start("Connecting to Lingo.dev Localization Engine...");
10563
- const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _328 => _328.provider]);
10935
+ const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _330 => _330.provider]);
10564
10936
  if (isByokMode) {
10565
10937
  authId = null;
10566
10938
  ora.succeed("Using external provider (BYOK mode)");
@@ -10574,16 +10946,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
10574
10946
  flags
10575
10947
  });
10576
10948
  let buckets = getBuckets(i18nConfig);
10577
- if (_optionalChain([flags, 'access', _329 => _329.bucket, 'optionalAccess', _330 => _330.length])) {
10949
+ if (_optionalChain([flags, 'access', _331 => _331.bucket, 'optionalAccess', _332 => _332.length])) {
10578
10950
  buckets = buckets.filter(
10579
10951
  (bucket) => flags.bucket.includes(bucket.type)
10580
10952
  );
10581
10953
  }
10582
10954
  ora.succeed("Buckets retrieved");
10583
- if (_optionalChain([flags, 'access', _331 => _331.file, 'optionalAccess', _332 => _332.length])) {
10955
+ if (_optionalChain([flags, 'access', _333 => _333.file, 'optionalAccess', _334 => _334.length])) {
10584
10956
  buckets = buckets.map((bucket) => {
10585
10957
  const paths = bucket.paths.filter(
10586
- (path19) => flags.file.find((file) => _optionalChain([path19, 'access', _333 => _333.pathPattern, 'optionalAccess', _334 => _334.includes, 'call', _335 => _335(file)]))
10958
+ (path19) => flags.file.find((file) => _optionalChain([path19, 'access', _335 => _335.pathPattern, 'optionalAccess', _336 => _336.includes, 'call', _337 => _337(file)]))
10587
10959
  );
10588
10960
  return { ...bucket, paths };
10589
10961
  }).filter((bucket) => bucket.paths.length > 0);
@@ -10604,7 +10976,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
10604
10976
  });
10605
10977
  }
10606
10978
  }
10607
- const targetLocales = _optionalChain([flags, 'access', _336 => _336.locale, 'optionalAccess', _337 => _337.length]) ? flags.locale : i18nConfig.locale.targets;
10979
+ const targetLocales = _optionalChain([flags, 'access', _338 => _338.locale, 'optionalAccess', _339 => _339.length]) ? flags.locale : i18nConfig.locale.targets;
10608
10980
  ora.start("Setting up localization cache...");
10609
10981
  const checkLockfileProcessor = createDeltaProcessor("");
10610
10982
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -10889,7 +11261,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
10889
11261
  }
10890
11262
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
10891
11263
  const checksums = await deltaProcessor.createChecksums(sourceData);
10892
- if (!_optionalChain([flags, 'access', _338 => _338.locale, 'optionalAccess', _339 => _339.length])) {
11264
+ if (!_optionalChain([flags, 'access', _340 => _340.locale, 'optionalAccess', _341 => _341.length])) {
10893
11265
  await deltaProcessor.saveChecksums(checksums);
10894
11266
  }
10895
11267
  }
@@ -11013,12 +11385,12 @@ function validateParams(i18nConfig, flags) {
11013
11385
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
11014
11386
  docUrl: "bucketNotFound"
11015
11387
  });
11016
- } else if (_optionalChain([flags, 'access', _340 => _340.locale, 'optionalAccess', _341 => _341.some, 'call', _342 => _342((locale) => !i18nConfig.locale.targets.includes(locale))])) {
11388
+ } else if (_optionalChain([flags, 'access', _342 => _342.locale, 'optionalAccess', _343 => _343.some, 'call', _344 => _344((locale) => !i18nConfig.locale.targets.includes(locale))])) {
11017
11389
  throw new ValidationError({
11018
11390
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
11019
11391
  docUrl: "localeTargetNotFound"
11020
11392
  });
11021
- } else if (_optionalChain([flags, 'access', _343 => _343.bucket, 'optionalAccess', _344 => _344.some, 'call', _345 => _345(
11393
+ } else if (_optionalChain([flags, 'access', _345 => _345.bucket, 'optionalAccess', _346 => _346.some, 'call', _347 => _347(
11022
11394
  (bucket) => !i18nConfig.buckets[bucket]
11023
11395
  )])) {
11024
11396
  throw new ValidationError({
@@ -11552,7 +11924,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
11552
11924
  const response = await engine.whoami();
11553
11925
  return {
11554
11926
  authenticated: !!response,
11555
- username: _optionalChain([response, 'optionalAccess', _346 => _346.email])
11927
+ username: _optionalChain([response, 'optionalAccess', _348 => _348.email])
11556
11928
  };
11557
11929
  } catch (error) {
11558
11930
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -11668,7 +12040,7 @@ function createExplicitLocalizer(provider) {
11668
12040
  }
11669
12041
  function createAiSdkLocalizer(params) {
11670
12042
  const skipAuth = params.skipAuth === true;
11671
- const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _347 => _347.apiKeyName]), () => ( ""))];
12043
+ const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _349 => _349.apiKeyName]), () => ( ""))];
11672
12044
  if (!skipAuth && !apiKey || !params.apiKeyName) {
11673
12045
  throw new Error(
11674
12046
  _dedent2.default`
@@ -11802,8 +12174,8 @@ async function setup(input2) {
11802
12174
  throw new Error(
11803
12175
  "No buckets found in i18n.json. Please add at least one bucket containing i18n content."
11804
12176
  );
11805
- } else if (_optionalChain([ctx, 'access', _348 => _348.flags, 'access', _349 => _349.bucket, 'optionalAccess', _350 => _350.some, 'call', _351 => _351(
11806
- (bucket) => !_optionalChain([ctx, 'access', _352 => _352.config, 'optionalAccess', _353 => _353.buckets, 'access', _354 => _354[bucket]])
12177
+ } else if (_optionalChain([ctx, 'access', _350 => _350.flags, 'access', _351 => _351.bucket, 'optionalAccess', _352 => _352.some, 'call', _353 => _353(
12178
+ (bucket) => !_optionalChain([ctx, 'access', _354 => _354.config, 'optionalAccess', _355 => _355.buckets, 'access', _356 => _356[bucket]])
11807
12179
  )])) {
11808
12180
  throw new Error(
11809
12181
  `One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
@@ -11816,7 +12188,7 @@ async function setup(input2) {
11816
12188
  title: "Selecting localization provider",
11817
12189
  task: async (ctx, task) => {
11818
12190
  ctx.localizer = createLocalizer(
11819
- _optionalChain([ctx, 'access', _355 => _355.config, 'optionalAccess', _356 => _356.provider]),
12191
+ _optionalChain([ctx, 'access', _357 => _357.config, 'optionalAccess', _358 => _358.provider]),
11820
12192
  ctx.flags.apiKey
11821
12193
  );
11822
12194
  if (!ctx.localizer) {
@@ -11829,7 +12201,7 @@ async function setup(input2) {
11829
12201
  },
11830
12202
  {
11831
12203
  title: "Checking authentication",
11832
- enabled: (ctx) => _optionalChain([ctx, 'access', _357 => _357.localizer, 'optionalAccess', _358 => _358.id]) === "Lingo.dev",
12204
+ enabled: (ctx) => _optionalChain([ctx, 'access', _359 => _359.localizer, 'optionalAccess', _360 => _360.id]) === "Lingo.dev",
11833
12205
  task: async (ctx, task) => {
11834
12206
  const authStatus = await ctx.localizer.checkAuth();
11835
12207
  if (!authStatus.authenticated) {
@@ -11842,7 +12214,7 @@ async function setup(input2) {
11842
12214
  },
11843
12215
  {
11844
12216
  title: "Validating configuration",
11845
- enabled: (ctx) => _optionalChain([ctx, 'access', _359 => _359.localizer, 'optionalAccess', _360 => _360.id]) !== "Lingo.dev",
12217
+ enabled: (ctx) => _optionalChain([ctx, 'access', _361 => _361.localizer, 'optionalAccess', _362 => _362.id]) !== "Lingo.dev",
11846
12218
  task: async (ctx, task) => {
11847
12219
  const validationStatus = await ctx.localizer.validateSettings();
11848
12220
  if (!validationStatus.valid) {
@@ -12173,7 +12545,7 @@ function createWorkerTask(args) {
12173
12545
  const processableData = _lodash2.default.chain(sourceData).entries().filter(
12174
12546
  ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
12175
12547
  ).filter(
12176
- ([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _361 => _361.onlyKeys, 'optionalAccess', _362 => _362.some, 'call', _363 => _363(
12548
+ ([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _363 => _363.onlyKeys, 'optionalAccess', _364 => _364.some, 'call', _365 => _365(
12177
12549
  (pattern) => minimatch(key, pattern)
12178
12550
  )])
12179
12551
  ).fromPairs().value();
@@ -12241,7 +12613,7 @@ function createWorkerTask(args) {
12241
12613
  finalRenamedTargetData
12242
12614
  );
12243
12615
  const checksums = await deltaProcessor.createChecksums(sourceData);
12244
- if (!_optionalChain([args, 'access', _364 => _364.ctx, 'access', _365 => _365.flags, 'access', _366 => _366.targetLocale, 'optionalAccess', _367 => _367.length])) {
12616
+ if (!_optionalChain([args, 'access', _366 => _366.ctx, 'access', _367 => _367.flags, 'access', _368 => _368.targetLocale, 'optionalAccess', _369 => _369.length])) {
12245
12617
  await deltaProcessor.saveChecksums(checksums);
12246
12618
  }
12247
12619
  });
@@ -12446,10 +12818,10 @@ var flagsSchema2 = _zod.z.object({
12446
12818
  async function frozen(input2) {
12447
12819
  console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
12448
12820
  let buckets = getBuckets(input2.config);
12449
- if (_optionalChain([input2, 'access', _368 => _368.flags, 'access', _369 => _369.bucket, 'optionalAccess', _370 => _370.length])) {
12821
+ if (_optionalChain([input2, 'access', _370 => _370.flags, 'access', _371 => _371.bucket, 'optionalAccess', _372 => _372.length])) {
12450
12822
  buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
12451
12823
  }
12452
- if (_optionalChain([input2, 'access', _371 => _371.flags, 'access', _372 => _372.file, 'optionalAccess', _373 => _373.length])) {
12824
+ if (_optionalChain([input2, 'access', _373 => _373.flags, 'access', _374 => _374.file, 'optionalAccess', _375 => _375.length])) {
12453
12825
  buckets = buckets.map((bucket) => {
12454
12826
  const paths = bucket.paths.filter(
12455
12827
  (p) => input2.flags.file.some(
@@ -12586,13 +12958,13 @@ async function frozen(input2) {
12586
12958
 
12587
12959
  // src/cli/cmd/run/_utils.ts
12588
12960
  async function determineAuthId(ctx) {
12589
- const isByokMode = !!_optionalChain([ctx, 'access', _374 => _374.config, 'optionalAccess', _375 => _375.provider]);
12961
+ const isByokMode = !!_optionalChain([ctx, 'access', _376 => _376.config, 'optionalAccess', _377 => _377.provider]);
12590
12962
  if (isByokMode) {
12591
12963
  return null;
12592
12964
  } else {
12593
12965
  try {
12594
- const authStatus = await _optionalChain([ctx, 'access', _376 => _376.localizer, 'optionalAccess', _377 => _377.checkAuth, 'call', _378 => _378()]);
12595
- return _optionalChain([authStatus, 'optionalAccess', _379 => _379.username]) || null;
12966
+ const authStatus = await _optionalChain([ctx, 'access', _378 => _378.localizer, 'optionalAccess', _379 => _379.checkAuth, 'call', _380 => _380()]);
12967
+ return _optionalChain([authStatus, 'optionalAccess', _381 => _381.username]) || null;
12596
12968
  } catch (e3) {
12597
12969
  return null;
12598
12970
  }
@@ -12790,7 +13162,7 @@ var InBranchFlow = class extends IntegrationFlow {
12790
13162
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
12791
13163
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
12792
13164
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
12793
- _optionalChain([this, 'access', _380 => _380.platformKit, 'optionalAccess', _381 => _381.gitConfig, 'call', _382 => _382()]);
13165
+ _optionalChain([this, 'access', _382 => _382.platformKit, 'optionalAccess', _383 => _383.gitConfig, 'call', _384 => _384()]);
12794
13166
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
12795
13167
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
12796
13168
  if (!processOwnCommits) {
@@ -12822,7 +13194,7 @@ var InBranchFlow = class extends IntegrationFlow {
12822
13194
  // src/cli/cmd/ci/flows/pull-request.ts
12823
13195
  var PullRequestFlow = class extends InBranchFlow {
12824
13196
  async preRun() {
12825
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _383 => _383()]);
13197
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _385 => _385()]);
12826
13198
  if (!canContinue) {
12827
13199
  return false;
12828
13200
  }
@@ -13089,10 +13461,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
13089
13461
  repo_slug: this.platformConfig.repositoryName,
13090
13462
  state: "OPEN"
13091
13463
  }).then(({ data: { values } }) => {
13092
- return _optionalChain([values, 'optionalAccess', _384 => _384.find, 'call', _385 => _385(
13093
- ({ source, destination }) => _optionalChain([source, 'optionalAccess', _386 => _386.branch, 'optionalAccess', _387 => _387.name]) === branch && _optionalChain([destination, 'optionalAccess', _388 => _388.branch, 'optionalAccess', _389 => _389.name]) === this.platformConfig.baseBranchName
13464
+ return _optionalChain([values, 'optionalAccess', _386 => _386.find, 'call', _387 => _387(
13465
+ ({ source, destination }) => _optionalChain([source, 'optionalAccess', _388 => _388.branch, 'optionalAccess', _389 => _389.name]) === branch && _optionalChain([destination, 'optionalAccess', _390 => _390.branch, 'optionalAccess', _391 => _391.name]) === this.platformConfig.baseBranchName
13094
13466
  )]);
13095
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _390 => _390.id]));
13467
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _392 => _392.id]));
13096
13468
  }
13097
13469
  async closePullRequest({ pullRequestNumber }) {
13098
13470
  await this.bb.repositories.declinePullRequest({
@@ -13188,7 +13560,7 @@ var GitHubPlatformKit = class extends PlatformKit {
13188
13560
  repo: this.platformConfig.repositoryName,
13189
13561
  base: this.platformConfig.baseBranchName,
13190
13562
  state: "open"
13191
- }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _391 => _391.number]));
13563
+ }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _393 => _393.number]));
13192
13564
  }
13193
13565
  async closePullRequest({ pullRequestNumber }) {
13194
13566
  await this.octokit.rest.pulls.update({
@@ -13315,7 +13687,7 @@ var GitlabPlatformKit = class extends PlatformKit {
13315
13687
  sourceBranch: branch,
13316
13688
  state: "opened"
13317
13689
  });
13318
- return _optionalChain([mergeRequests, 'access', _392 => _392[0], 'optionalAccess', _393 => _393.iid]);
13690
+ return _optionalChain([mergeRequests, 'access', _394 => _394[0], 'optionalAccess', _395 => _395.iid]);
13319
13691
  }
13320
13692
  async closePullRequest({
13321
13693
  pullRequestNumber
@@ -13427,7 +13799,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
13427
13799
  }
13428
13800
  const env = {
13429
13801
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
13430
- LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _394 => _394.pullRequest, 'optionalAccess', _395 => _395.toString, 'call', _396 => _396()]) || "false",
13802
+ LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _396 => _396.pullRequest, 'optionalAccess', _397 => _397.toString, 'call', _398 => _398()]) || "false",
13431
13803
  ...options.commitMessage && {
13432
13804
  LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
13433
13805
  },
@@ -13453,7 +13825,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
13453
13825
  const { isPullRequestMode } = platformKit.config;
13454
13826
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
13455
13827
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
13456
- const canRun = await _optionalChain([flow, 'access', _397 => _397.preRun, 'optionalCall', _398 => _398()]);
13828
+ const canRun = await _optionalChain([flow, 'access', _399 => _399.preRun, 'optionalCall', _400 => _400()]);
13457
13829
  if (canRun === false) {
13458
13830
  return;
13459
13831
  }
@@ -13463,7 +13835,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
13463
13835
  if (!hasChanges) {
13464
13836
  return;
13465
13837
  }
13466
- await _optionalChain([flow, 'access', _399 => _399.postRun, 'optionalCall', _400 => _400()]);
13838
+ await _optionalChain([flow, 'access', _401 => _401.postRun, 'optionalCall', _402 => _402()]);
13467
13839
  });
13468
13840
  function parseBooleanArg(val) {
13469
13841
  if (val === true) return true;
@@ -13500,8 +13872,8 @@ function exitGracefully(elapsedMs = 0) {
13500
13872
  }
13501
13873
  }
13502
13874
  function checkForPendingOperations() {
13503
- const activeHandles = _optionalChain([process, 'access', _401 => _401._getActiveHandles, 'optionalCall', _402 => _402()]) || [];
13504
- const activeRequests = _optionalChain([process, 'access', _403 => _403._getActiveRequests, 'optionalCall', _404 => _404()]) || [];
13875
+ const activeHandles = _optionalChain([process, 'access', _403 => _403._getActiveHandles, 'optionalCall', _404 => _404()]) || [];
13876
+ const activeRequests = _optionalChain([process, 'access', _405 => _405._getActiveRequests, 'optionalCall', _406 => _406()]) || [];
13505
13877
  const nonStandardHandles = activeHandles.filter((handle) => {
13506
13878
  if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
13507
13879
  return false;
@@ -13570,17 +13942,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
13570
13942
  flags
13571
13943
  });
13572
13944
  let buckets = getBuckets(i18nConfig);
13573
- if (_optionalChain([flags, 'access', _405 => _405.bucket, 'optionalAccess', _406 => _406.length])) {
13945
+ if (_optionalChain([flags, 'access', _407 => _407.bucket, 'optionalAccess', _408 => _408.length])) {
13574
13946
  buckets = buckets.filter(
13575
13947
  (bucket) => flags.bucket.includes(bucket.type)
13576
13948
  );
13577
13949
  }
13578
13950
  ora.succeed("Buckets retrieved");
13579
- if (_optionalChain([flags, 'access', _407 => _407.file, 'optionalAccess', _408 => _408.length])) {
13951
+ if (_optionalChain([flags, 'access', _409 => _409.file, 'optionalAccess', _410 => _410.length])) {
13580
13952
  buckets = buckets.map((bucket) => {
13581
13953
  const paths = bucket.paths.filter(
13582
13954
  (path19) => flags.file.find(
13583
- (file) => _optionalChain([path19, 'access', _409 => _409.pathPattern, 'optionalAccess', _410 => _410.includes, 'call', _411 => _411(file)]) || _optionalChain([path19, 'access', _412 => _412.pathPattern, 'optionalAccess', _413 => _413.match, 'call', _414 => _414(file)]) || minimatch(path19.pathPattern, file)
13955
+ (file) => _optionalChain([path19, 'access', _411 => _411.pathPattern, 'optionalAccess', _412 => _412.includes, 'call', _413 => _413(file)]) || _optionalChain([path19, 'access', _414 => _414.pathPattern, 'optionalAccess', _415 => _415.match, 'call', _416 => _416(file)]) || minimatch(path19.pathPattern, file)
13584
13956
  )
13585
13957
  );
13586
13958
  return { ...bucket, paths };
@@ -13600,7 +13972,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
13600
13972
  });
13601
13973
  }
13602
13974
  }
13603
- const targetLocales = _optionalChain([flags, 'access', _415 => _415.locale, 'optionalAccess', _416 => _416.length]) ? flags.locale : i18nConfig.locale.targets;
13975
+ const targetLocales = _optionalChain([flags, 'access', _417 => _417.locale, 'optionalAccess', _418 => _418.length]) ? flags.locale : i18nConfig.locale.targets;
13604
13976
  let totalSourceKeyCount = 0;
13605
13977
  let uniqueKeysToTranslate = 0;
13606
13978
  let totalExistingTranslations = 0;
@@ -14008,12 +14380,12 @@ function validateParams2(i18nConfig, flags) {
14008
14380
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
14009
14381
  docUrl: "bucketNotFound"
14010
14382
  });
14011
- } else if (_optionalChain([flags, 'access', _417 => _417.locale, 'optionalAccess', _418 => _418.some, 'call', _419 => _419((locale) => !i18nConfig.locale.targets.includes(locale))])) {
14383
+ } else if (_optionalChain([flags, 'access', _419 => _419.locale, 'optionalAccess', _420 => _420.some, 'call', _421 => _421((locale) => !i18nConfig.locale.targets.includes(locale))])) {
14012
14384
  throw new CLIError({
14013
14385
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
14014
14386
  docUrl: "localeTargetNotFound"
14015
14387
  });
14016
- } else if (_optionalChain([flags, 'access', _420 => _420.bucket, 'optionalAccess', _421 => _421.some, 'call', _422 => _422(
14388
+ } else if (_optionalChain([flags, 'access', _422 => _422.bucket, 'optionalAccess', _423 => _423.some, 'call', _424 => _424(
14017
14389
  (bucket) => !i18nConfig.buckets[bucket]
14018
14390
  )])) {
14019
14391
  throw new CLIError({
@@ -14105,7 +14477,7 @@ async function renderHero2() {
14105
14477
  // package.json
14106
14478
  var package_default = {
14107
14479
  name: "lingo.dev",
14108
- version: "0.117.7",
14480
+ version: "0.117.8",
14109
14481
  description: "Lingo.dev CLI",
14110
14482
  private: false,
14111
14483
  publishConfig: {
@@ -14401,7 +14773,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
14401
14773
  if (options.file && options.file.length) {
14402
14774
  buckets = buckets.map((bucket) => {
14403
14775
  const paths = bucket.paths.filter(
14404
- (bucketPath) => _optionalChain([options, 'access', _423 => _423.file, 'optionalAccess', _424 => _424.some, 'call', _425 => _425((f) => bucketPath.pathPattern.includes(f))])
14776
+ (bucketPath) => _optionalChain([options, 'access', _425 => _425.file, 'optionalAccess', _426 => _426.some, 'call', _427 => _427((f) => bucketPath.pathPattern.includes(f))])
14405
14777
  );
14406
14778
  return { ...bucket, paths };
14407
14779
  }).filter((bucket) => bucket.paths.length > 0);