@superinterface/react 2.22.2 → 2.22.4

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.cjs CHANGED
@@ -1618,136 +1618,152 @@ var remarkAnnotation = function(param) {
1618
1618
  return function() {
1619
1619
  return function(tree) {
1620
1620
  (0, import_unist_util_flatmap.default)(tree, function(node) {
1621
- var _content_text_annotations, _content_text;
1622
- if (![
1623
- "text",
1624
- "link"
1625
- ].includes(node.type)) {
1626
- return [
1627
- node
1628
- ];
1629
- }
1630
- if (!((_content_text = content.text) === null || _content_text === void 0 ? void 0 : (_content_text_annotations = _content_text.annotations) === null || _content_text_annotations === void 0 ? void 0 : _content_text_annotations.length)) {
1631
- return [
1632
- node
1633
- ];
1634
- }
1635
- if (!node.position) {
1636
- return [
1637
- node
1638
- ];
1639
- }
1640
- var nodeStart = node.position.start.offset;
1641
- if (!(0, import_radash3.isNumber)(nodeStart)) {
1642
- return [
1643
- node
1644
- ];
1645
- }
1646
- var nodeEnd = node.position.end.offset;
1647
- if (!(0, import_radash3.isNumber)(nodeEnd)) {
1621
+ if (node.type === "text" || node.type === "link") {
1622
+ return processNodeWithAnnotations({
1623
+ node: node,
1624
+ content: content
1625
+ });
1626
+ } else {
1648
1627
  return [
1649
1628
  node
1650
1629
  ];
1651
1630
  }
1652
- var newNodes = [];
1653
- var lastProcessedIndex = nodeStart;
1654
- sortedAnnotations({
1655
- content: content
1656
- }).forEach(function(annotation) {
1657
- var annotationStart = annotation.start_index;
1658
- var annotationEnd = annotation.end_index;
1659
- if (nodeEnd < annotationStart || nodeStart > annotationEnd) {
1660
- return;
1661
- }
1662
- if (node.type === "link") {
1663
- if (annotation.type === "file_path") {
1664
- console.log({
1665
- annotation: annotation,
1666
- node: node
1667
- });
1668
- newNodes.push(_object_spread_props(_object_spread({}, node), {
1669
- type: "annotation",
1670
- // @ts-ignore-next-line
1671
- url: annotation.file_path.file_id,
1672
- data: {
1673
- hName: "annotation",
1674
- hProperties: {
1675
- annotation: annotation
1676
- }
1677
- }
1678
- }));
1679
- }
1680
- return;
1681
- }
1682
- var startIndex = Math.max(nodeStart, annotationStart);
1683
- var endIndex = Math.min(nodeEnd, annotationEnd);
1684
- if (lastProcessedIndex < startIndex) {
1685
- newNodes.push({
1686
- type: "text",
1687
- value: node.value.slice(lastProcessedIndex - nodeStart, startIndex - nodeStart),
1688
- position: {
1689
- start: {
1690
- line: node.position.start.line,
1691
- column: node.position.start.column,
1692
- offset: lastProcessedIndex
1693
- },
1694
- end: {
1695
- line: node.position.end.line,
1696
- column: node.position.end.column,
1697
- offset: startIndex
1698
- }
1699
- }
1700
- });
1701
- }
1702
- newNodes.push({
1703
- type: "annotation",
1704
- value: node.value.slice(startIndex - nodeStart, endIndex - nodeStart),
1705
- position: {
1706
- start: {
1707
- line: node.position.start.line,
1708
- column: node.position.start.column,
1709
- offset: startIndex
1710
- },
1711
- end: {
1712
- line: node.position.end.line,
1713
- column: node.position.end.column,
1714
- offset: endIndex
1715
- }
1716
- },
1717
- data: {
1718
- hName: "annotation",
1719
- hProperties: {
1720
- annotation: annotation
1721
- }
1722
- }
1723
- });
1724
- lastProcessedIndex = endIndex;
1725
- });
1726
- if (node.type === "text") {
1727
- if (lastProcessedIndex < nodeEnd) {
1728
- newNodes.push({
1729
- type: "text",
1730
- value: node.value.slice(lastProcessedIndex - nodeStart, nodeEnd - nodeStart),
1731
- position: {
1732
- start: {
1733
- line: node.position.start.line,
1734
- column: node.position.start.column,
1735
- offset: lastProcessedIndex
1736
- },
1737
- end: {
1738
- line: node.position.end.line,
1739
- column: node.position.end.column,
1740
- offset: nodeEnd
1741
- }
1742
- }
1743
- });
1744
- }
1745
- }
1746
- return newNodes;
1747
1631
  });
1748
1632
  };
1749
1633
  };
1750
1634
  };
1635
+ var processNodeWithAnnotations = function(param) {
1636
+ var node = param.node, content = param.content;
1637
+ var _content_text_annotations, _content_text;
1638
+ if (!((_content_text = content.text) === null || _content_text === void 0 ? void 0 : (_content_text_annotations = _content_text.annotations) === null || _content_text_annotations === void 0 ? void 0 : _content_text_annotations.length)) {
1639
+ return [
1640
+ node
1641
+ ];
1642
+ }
1643
+ if (!node.position) {
1644
+ return [
1645
+ node
1646
+ ];
1647
+ }
1648
+ var annotations = sortedAnnotations({
1649
+ content: content
1650
+ });
1651
+ if (node.type === "text") {
1652
+ return processTextNode({
1653
+ node: node,
1654
+ annotations: annotations
1655
+ });
1656
+ } else if (node.type === "link") {
1657
+ var linkNode = node;
1658
+ linkNode.children = (0, import_unist_util_flatmap.default)(linkNode.children, function(childNode) {
1659
+ if (childNode.type === "text") {
1660
+ return processTextNode({
1661
+ node: childNode,
1662
+ annotations: annotations
1663
+ });
1664
+ } else {
1665
+ return [
1666
+ childNode
1667
+ ];
1668
+ }
1669
+ });
1670
+ return [
1671
+ linkNode
1672
+ ];
1673
+ } else {
1674
+ return [
1675
+ node
1676
+ ];
1677
+ }
1678
+ };
1679
+ var processTextNode = function(param) {
1680
+ var node = param.node, annotations = param.annotations;
1681
+ if (!node.position || !node.value) {
1682
+ return [
1683
+ node
1684
+ ];
1685
+ }
1686
+ var nodeStart = node.position.start.offset;
1687
+ var nodeEnd = node.position.end.offset;
1688
+ if (!(0, import_radash3.isNumber)(nodeStart) || !(0, import_radash3.isNumber)(nodeEnd)) {
1689
+ return [
1690
+ node
1691
+ ];
1692
+ }
1693
+ var newNodes = [];
1694
+ var lastIndex = nodeStart;
1695
+ annotations.forEach(function(annotation) {
1696
+ var annotationStart = annotation.start_index;
1697
+ var annotationEnd = annotation.end_index;
1698
+ if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) {
1699
+ return;
1700
+ }
1701
+ var start = Math.max(nodeStart, annotationStart);
1702
+ var end = Math.min(nodeEnd, annotationEnd);
1703
+ if (lastIndex < start) {
1704
+ newNodes.push(createTextNode({
1705
+ node: node,
1706
+ startOffset: lastIndex,
1707
+ endOffset: start
1708
+ }));
1709
+ }
1710
+ newNodes.push(createAnnotationNode({
1711
+ node: node,
1712
+ startOffset: start,
1713
+ endOffset: end,
1714
+ annotation: annotation
1715
+ }));
1716
+ lastIndex = end;
1717
+ });
1718
+ if (lastIndex < nodeEnd) {
1719
+ newNodes.push(createTextNode({
1720
+ node: node,
1721
+ startOffset: lastIndex,
1722
+ endOffset: nodeEnd
1723
+ }));
1724
+ }
1725
+ return newNodes;
1726
+ };
1727
+ var createTextNode = function(param) {
1728
+ var node = param.node, startOffset = param.startOffset, endOffset = param.endOffset;
1729
+ var valueStart = startOffset - node.position.start.offset;
1730
+ var valueEnd = endOffset - node.position.start.offset;
1731
+ return {
1732
+ type: "text",
1733
+ value: node.value.slice(valueStart, valueEnd),
1734
+ position: {
1735
+ start: _object_spread_props(_object_spread({}, node.position.start), {
1736
+ offset: startOffset
1737
+ }),
1738
+ end: _object_spread_props(_object_spread({}, node.position.end), {
1739
+ offset: endOffset
1740
+ })
1741
+ }
1742
+ };
1743
+ };
1744
+ var createAnnotationNode = function(param) {
1745
+ var node = param.node, startOffset = param.startOffset, endOffset = param.endOffset, annotation = param.annotation;
1746
+ var valueStart = startOffset - node.position.start.offset;
1747
+ var valueEnd = endOffset - node.position.start.offset;
1748
+ return {
1749
+ type: "annotation",
1750
+ value: node.value.slice(valueStart, valueEnd),
1751
+ position: {
1752
+ start: _object_spread_props(_object_spread({}, node.position.start), {
1753
+ offset: startOffset
1754
+ }),
1755
+ end: _object_spread_props(_object_spread({}, node.position.end), {
1756
+ offset: endOffset
1757
+ })
1758
+ },
1759
+ data: {
1760
+ hName: "annotation",
1761
+ hProperties: {
1762
+ annotation: annotation
1763
+ }
1764
+ }
1765
+ };
1766
+ };
1751
1767
  // src/contexts/markdown/MarkdownContext/lib/getRemarkPlugins.ts
1752
1768
  var getRemarkPlugins = function(param) {
1753
1769
  var content = param.content;
@@ -2509,7 +2525,7 @@ var threadRunCreated = function(param) {
2509
2525
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunFailed.ts
2510
2526
  var threadRunFailed = function(param) {
2511
2527
  var value = param.value, queryClient = param.queryClient, messagesQueryKey = param.messagesQueryKey;
2512
- throw new Error("There was a problem sending your message. Please try again.");
2528
+ throw new Error("Failed to send your message, try again. If you are the owner, check the logs.");
2513
2529
  };
2514
2530
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepCreated.ts
2515
2531
  var threadRunStepCreated = function(param) {
@@ -2826,7 +2842,7 @@ var mutationFn = function(param) {
2826
2842
  throw new Error(errorResponse.error);
2827
2843
  case 4:
2828
2844
  error = _state.sent();
2829
- throw new Error("There was a problem sending your message. Please try again.");
2845
+ throw new Error("Failed to send your message, try again. If you are the owner, check the logs.");
2830
2846
  case 5:
2831
2847
  if (response.body == null) {
2832
2848
  throw new Error("The response body is empty.");