@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.js CHANGED
@@ -1466,136 +1466,152 @@ var remarkAnnotation = function(param) {
1466
1466
  return function() {
1467
1467
  return function(tree) {
1468
1468
  flatMap(tree, function(node) {
1469
- var _content_text_annotations, _content_text;
1470
- if (![
1471
- "text",
1472
- "link"
1473
- ].includes(node.type)) {
1474
- return [
1475
- node
1476
- ];
1477
- }
1478
- 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)) {
1479
- return [
1480
- node
1481
- ];
1482
- }
1483
- if (!node.position) {
1484
- return [
1485
- node
1486
- ];
1487
- }
1488
- var nodeStart = node.position.start.offset;
1489
- if (!isNumber(nodeStart)) {
1490
- return [
1491
- node
1492
- ];
1493
- }
1494
- var nodeEnd = node.position.end.offset;
1495
- if (!isNumber(nodeEnd)) {
1469
+ if (node.type === "text" || node.type === "link") {
1470
+ return processNodeWithAnnotations({
1471
+ node: node,
1472
+ content: content
1473
+ });
1474
+ } else {
1496
1475
  return [
1497
1476
  node
1498
1477
  ];
1499
1478
  }
1500
- var newNodes = [];
1501
- var lastProcessedIndex = nodeStart;
1502
- sortedAnnotations({
1503
- content: content
1504
- }).forEach(function(annotation) {
1505
- var annotationStart = annotation.start_index;
1506
- var annotationEnd = annotation.end_index;
1507
- if (nodeEnd < annotationStart || nodeStart > annotationEnd) {
1508
- return;
1509
- }
1510
- if (node.type === "link") {
1511
- if (annotation.type === "file_path") {
1512
- console.log({
1513
- annotation: annotation,
1514
- node: node
1515
- });
1516
- newNodes.push(_object_spread_props(_object_spread({}, node), {
1517
- type: "annotation",
1518
- // @ts-ignore-next-line
1519
- url: annotation.file_path.file_id,
1520
- data: {
1521
- hName: "annotation",
1522
- hProperties: {
1523
- annotation: annotation
1524
- }
1525
- }
1526
- }));
1527
- }
1528
- return;
1529
- }
1530
- var startIndex = Math.max(nodeStart, annotationStart);
1531
- var endIndex = Math.min(nodeEnd, annotationEnd);
1532
- if (lastProcessedIndex < startIndex) {
1533
- newNodes.push({
1534
- type: "text",
1535
- value: node.value.slice(lastProcessedIndex - nodeStart, startIndex - nodeStart),
1536
- position: {
1537
- start: {
1538
- line: node.position.start.line,
1539
- column: node.position.start.column,
1540
- offset: lastProcessedIndex
1541
- },
1542
- end: {
1543
- line: node.position.end.line,
1544
- column: node.position.end.column,
1545
- offset: startIndex
1546
- }
1547
- }
1548
- });
1549
- }
1550
- newNodes.push({
1551
- type: "annotation",
1552
- value: node.value.slice(startIndex - nodeStart, endIndex - nodeStart),
1553
- position: {
1554
- start: {
1555
- line: node.position.start.line,
1556
- column: node.position.start.column,
1557
- offset: startIndex
1558
- },
1559
- end: {
1560
- line: node.position.end.line,
1561
- column: node.position.end.column,
1562
- offset: endIndex
1563
- }
1564
- },
1565
- data: {
1566
- hName: "annotation",
1567
- hProperties: {
1568
- annotation: annotation
1569
- }
1570
- }
1571
- });
1572
- lastProcessedIndex = endIndex;
1573
- });
1574
- if (node.type === "text") {
1575
- if (lastProcessedIndex < nodeEnd) {
1576
- newNodes.push({
1577
- type: "text",
1578
- value: node.value.slice(lastProcessedIndex - nodeStart, nodeEnd - nodeStart),
1579
- position: {
1580
- start: {
1581
- line: node.position.start.line,
1582
- column: node.position.start.column,
1583
- offset: lastProcessedIndex
1584
- },
1585
- end: {
1586
- line: node.position.end.line,
1587
- column: node.position.end.column,
1588
- offset: nodeEnd
1589
- }
1590
- }
1591
- });
1592
- }
1593
- }
1594
- return newNodes;
1595
1479
  });
1596
1480
  };
1597
1481
  };
1598
1482
  };
1483
+ var processNodeWithAnnotations = function(param) {
1484
+ var node = param.node, content = param.content;
1485
+ var _content_text_annotations, _content_text;
1486
+ 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)) {
1487
+ return [
1488
+ node
1489
+ ];
1490
+ }
1491
+ if (!node.position) {
1492
+ return [
1493
+ node
1494
+ ];
1495
+ }
1496
+ var annotations = sortedAnnotations({
1497
+ content: content
1498
+ });
1499
+ if (node.type === "text") {
1500
+ return processTextNode({
1501
+ node: node,
1502
+ annotations: annotations
1503
+ });
1504
+ } else if (node.type === "link") {
1505
+ var linkNode = node;
1506
+ linkNode.children = flatMap(linkNode.children, function(childNode) {
1507
+ if (childNode.type === "text") {
1508
+ return processTextNode({
1509
+ node: childNode,
1510
+ annotations: annotations
1511
+ });
1512
+ } else {
1513
+ return [
1514
+ childNode
1515
+ ];
1516
+ }
1517
+ });
1518
+ return [
1519
+ linkNode
1520
+ ];
1521
+ } else {
1522
+ return [
1523
+ node
1524
+ ];
1525
+ }
1526
+ };
1527
+ var processTextNode = function(param) {
1528
+ var node = param.node, annotations = param.annotations;
1529
+ if (!node.position || !node.value) {
1530
+ return [
1531
+ node
1532
+ ];
1533
+ }
1534
+ var nodeStart = node.position.start.offset;
1535
+ var nodeEnd = node.position.end.offset;
1536
+ if (!isNumber(nodeStart) || !isNumber(nodeEnd)) {
1537
+ return [
1538
+ node
1539
+ ];
1540
+ }
1541
+ var newNodes = [];
1542
+ var lastIndex = nodeStart;
1543
+ annotations.forEach(function(annotation) {
1544
+ var annotationStart = annotation.start_index;
1545
+ var annotationEnd = annotation.end_index;
1546
+ if (nodeEnd <= annotationStart || nodeStart >= annotationEnd) {
1547
+ return;
1548
+ }
1549
+ var start = Math.max(nodeStart, annotationStart);
1550
+ var end = Math.min(nodeEnd, annotationEnd);
1551
+ if (lastIndex < start) {
1552
+ newNodes.push(createTextNode({
1553
+ node: node,
1554
+ startOffset: lastIndex,
1555
+ endOffset: start
1556
+ }));
1557
+ }
1558
+ newNodes.push(createAnnotationNode({
1559
+ node: node,
1560
+ startOffset: start,
1561
+ endOffset: end,
1562
+ annotation: annotation
1563
+ }));
1564
+ lastIndex = end;
1565
+ });
1566
+ if (lastIndex < nodeEnd) {
1567
+ newNodes.push(createTextNode({
1568
+ node: node,
1569
+ startOffset: lastIndex,
1570
+ endOffset: nodeEnd
1571
+ }));
1572
+ }
1573
+ return newNodes;
1574
+ };
1575
+ var createTextNode = function(param) {
1576
+ var node = param.node, startOffset = param.startOffset, endOffset = param.endOffset;
1577
+ var valueStart = startOffset - node.position.start.offset;
1578
+ var valueEnd = endOffset - node.position.start.offset;
1579
+ return {
1580
+ type: "text",
1581
+ value: node.value.slice(valueStart, valueEnd),
1582
+ position: {
1583
+ start: _object_spread_props(_object_spread({}, node.position.start), {
1584
+ offset: startOffset
1585
+ }),
1586
+ end: _object_spread_props(_object_spread({}, node.position.end), {
1587
+ offset: endOffset
1588
+ })
1589
+ }
1590
+ };
1591
+ };
1592
+ var createAnnotationNode = function(param) {
1593
+ var node = param.node, startOffset = param.startOffset, endOffset = param.endOffset, annotation = param.annotation;
1594
+ var valueStart = startOffset - node.position.start.offset;
1595
+ var valueEnd = endOffset - node.position.start.offset;
1596
+ return {
1597
+ type: "annotation",
1598
+ value: node.value.slice(valueStart, valueEnd),
1599
+ position: {
1600
+ start: _object_spread_props(_object_spread({}, node.position.start), {
1601
+ offset: startOffset
1602
+ }),
1603
+ end: _object_spread_props(_object_spread({}, node.position.end), {
1604
+ offset: endOffset
1605
+ })
1606
+ },
1607
+ data: {
1608
+ hName: "annotation",
1609
+ hProperties: {
1610
+ annotation: annotation
1611
+ }
1612
+ }
1613
+ };
1614
+ };
1599
1615
  // src/contexts/markdown/MarkdownContext/lib/getRemarkPlugins.ts
1600
1616
  var getRemarkPlugins = function(param) {
1601
1617
  var content = param.content;
@@ -2357,7 +2373,7 @@ var threadRunCreated = function(param) {
2357
2373
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunFailed.ts
2358
2374
  var threadRunFailed = function(param) {
2359
2375
  var value = param.value, queryClient = param.queryClient, messagesQueryKey = param.messagesQueryKey;
2360
- throw new Error("There was a problem sending your message. Please try again.");
2376
+ throw new Error("Failed to send your message, try again. If you are the owner, check the logs.");
2361
2377
  };
2362
2378
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepCreated.ts
2363
2379
  var threadRunStepCreated = function(param) {
@@ -2674,7 +2690,7 @@ var mutationFn = function(param) {
2674
2690
  throw new Error(errorResponse.error);
2675
2691
  case 4:
2676
2692
  error = _state.sent();
2677
- throw new Error("There was a problem sending your message. Please try again.");
2693
+ throw new Error("Failed to send your message, try again. If you are the owner, check the logs.");
2678
2694
  case 5:
2679
2695
  if (response.body == null) {
2680
2696
  throw new Error("The response body is empty.");