@oddo/lang 0.0.13 → 0.0.14

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/dist/index.mjs CHANGED
@@ -3467,7 +3467,6 @@ function decodeHTMLEntities(text) {
3467
3467
  });
3468
3468
  }
3469
3469
  function convertJSXChildren(childrenCST) {
3470
- var _a;
3471
3470
  if (!childrenCST || childrenCST.length === 0) return [];
3472
3471
  const childrenWithOffsets = childrenCST.map((child) => {
3473
3472
  const firstOffset = getFirstTokenOffset(child);
@@ -3478,14 +3477,32 @@ function convertJSXChildren(childrenCST) {
3478
3477
  const result = [];
3479
3478
  for (let i = 0; i < childrenWithOffsets.length; i++) {
3480
3479
  const current = childrenWithOffsets[i];
3481
- const prevEnd = i > 0 ? childrenWithOffsets[i - 1].lastOffset + 1 : void 0;
3482
- const nextStart = (_a = childrenWithOffsets[i + 1]) == null ? void 0 : _a.firstOffset;
3483
- const converted = convertJSXChild(current.cst, prevEnd, nextStart);
3480
+ if (i > 0 && sourceText) {
3481
+ const prev = childrenWithOffsets[i - 1];
3482
+ const gapStart = prev.lastOffset + 1;
3483
+ const gapEnd = current.firstOffset;
3484
+ if (gapEnd > gapStart) {
3485
+ const gap = sourceText.slice(gapStart, gapEnd);
3486
+ if (gap.length > 0 && gap.trim() === "" && !gap.includes("\n")) {
3487
+ result.push({ type: "jsxText", value: " " });
3488
+ }
3489
+ }
3490
+ }
3491
+ const converted = convertJSXChild(current.cst);
3484
3492
  if (converted !== null) {
3485
3493
  result.push(converted);
3486
3494
  }
3487
3495
  }
3488
- return result;
3496
+ const merged = [];
3497
+ for (const child of result) {
3498
+ const prev = merged[merged.length - 1];
3499
+ if (child.type === "jsxText" && (prev == null ? void 0 : prev.type) === "jsxText") {
3500
+ prev.value += child.value;
3501
+ } else {
3502
+ merged.push(child);
3503
+ }
3504
+ }
3505
+ return merged;
3489
3506
  }
3490
3507
  function getLastTokenOffset(node) {
3491
3508
  if (!node) return void 0;
@@ -3513,7 +3530,7 @@ function getLastTokenOffset(node) {
3513
3530
  }
3514
3531
  return lastOffset;
3515
3532
  }
3516
- function convertJSXChild(cst, startBoundary, endBoundary) {
3533
+ function convertJSXChild(cst) {
3517
3534
  if (cst.children.jsxElement) {
3518
3535
  return convertJSXElement(getFirstChild(cst, "jsxElement"));
3519
3536
  }
@@ -3549,16 +3566,10 @@ function convertJSXChild(cst, startBoundary, endBoundary) {
3549
3566
  const firstToken = allTokens2[0];
3550
3567
  const lastToken = allTokens2[allTokens2.length - 1];
3551
3568
  const lastTokenEnd = lastToken.token.endOffset !== void 0 ? lastToken.token.endOffset : lastToken.token.startOffset + lastToken.token.image.length - 1;
3552
- if (sourceText && (startBoundary !== void 0 || endBoundary !== void 0)) {
3553
- const textStart = startBoundary ?? firstToken.offset;
3554
- const textEnd = endBoundary ?? lastTokenEnd + 1;
3555
- const textValue2 = sourceText.slice(textStart, textEnd);
3569
+ if (sourceText) {
3570
+ const textValue2 = sourceText.slice(firstToken.offset, lastTokenEnd + 1);
3556
3571
  if (textValue2) {
3557
- const decodedValue2 = decodeHTMLEntities(textValue2);
3558
- return {
3559
- type: "jsxText",
3560
- value: decodedValue2
3561
- };
3572
+ return { type: "jsxText", value: decodeHTMLEntities(textValue2) };
3562
3573
  }
3563
3574
  return null;
3564
3575
  }