@apteva/apteva-kit 0.1.77 → 0.1.78

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
@@ -606,14 +606,6 @@ function findMatchingBracket(text, startIndex) {
606
606
  }
607
607
  return -1;
608
608
  }
609
- function findOpeningBracket(text) {
610
- const squareIndex = text.indexOf("[");
611
- const curlyIndex = text.indexOf("{");
612
- if (squareIndex === -1 && curlyIndex === -1) return null;
613
- if (squareIndex === -1) return { index: curlyIndex, char: "{" };
614
- if (curlyIndex === -1) return { index: squareIndex, char: "[" };
615
- return squareIndex < curlyIndex ? { index: squareIndex, char: "[" } : { index: curlyIndex, char: "{" };
616
- }
617
609
  function parseWidgetsFromText(text) {
618
610
  const segments = [];
619
611
  let hasWidgets = false;
@@ -627,14 +619,13 @@ function parseWidgetsFromText(text) {
627
619
  const typeMatch = afterStart.match(/^@ui:(\w+)/);
628
620
  if (typeMatch) {
629
621
  const widgetType = typeMatch[1];
630
- const afterType = afterStart.slice(typeMatch[0].length);
631
- const bracketInfo = findOpeningBracket(afterType);
632
- if (!bracketInfo) {
622
+ const bracketOpenIndex = afterStart.indexOf("[");
623
+ if (bracketOpenIndex === -1) {
633
624
  processText = text.slice(0, lastWidgetStart);
634
625
  pendingWidgetType = widgetType;
635
626
  hasPendingWidget = true;
636
627
  } else {
637
- const fullBracketStart = lastWidgetStart + typeMatch[0].length + bracketInfo.index;
628
+ const fullBracketStart = lastWidgetStart + bracketOpenIndex;
638
629
  const bracketEnd = findMatchingBracket(text, fullBracketStart);
639
630
  if (bracketEnd === -1) {
640
631
  if (STREAMABLE_WIDGET_TYPES.includes(widgetType)) {
@@ -676,22 +667,16 @@ function parseWidgetsFromText(text) {
676
667
  if (hasPendingWidget) {
677
668
  processText = processText.replace(/[\s:;\-–—\.]+$/g, "");
678
669
  }
679
- const startPattern = /@ui:(\w+)([\[{])/g;
670
+ const startPattern = /@ui:(\w+)\[/g;
680
671
  let match;
681
672
  while ((match = startPattern.exec(processText)) !== null) {
682
673
  const widgetType = match[1];
683
- const openingBracket = match[2];
684
674
  const bracketStart = match.index + match[0].length - 1;
685
675
  const bracketEnd = findMatchingBracket(processText, bracketStart);
686
676
  if (bracketEnd === -1) {
687
677
  continue;
688
678
  }
689
- let jsonContent;
690
- if (openingBracket === "[") {
691
- jsonContent = processText.slice(bracketStart + 1, bracketEnd);
692
- } else {
693
- jsonContent = processText.slice(bracketStart, bracketEnd + 1);
694
- }
679
+ const jsonContent = processText.slice(bracketStart + 1, bracketEnd);
695
680
  if (match.index > currentIndex) {
696
681
  const textContent = processText.slice(currentIndex, match.index).trim();
697
682
  if (textContent) {