@superinterface/react 2.17.0 → 2.17.1

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
@@ -936,7 +936,7 @@ var UserAvatar = function() {
936
936
  var import_themes28 = require("@radix-ui/themes");
937
937
  // src/components/threads/Thread/Message/index.tsx
938
938
  var import_react24 = require("react");
939
- var import_radash3 = require("radash");
939
+ var import_radash4 = require("radash");
940
940
  var import_themes27 = require("@radix-ui/themes");
941
941
  // src/components/skeletons/StartingContentSkeleton/index.tsx
942
942
  var import_themes8 = require("@radix-ui/themes");
@@ -1499,87 +1499,114 @@ var components = {
1499
1499
  annotation: Annotation
1500
1500
  };
1501
1501
  // src/lib/remark/remarkAnnotation.ts
1502
- var import_unist_util_visit = require("unist-util-visit");
1502
+ var import_radash3 = require("radash");
1503
+ var import_unist_util_flatmap = __toESM(require("unist-util-flatmap"), 1);
1503
1504
  var remarkAnnotation = function(param) {
1504
1505
  var content = param.content;
1505
1506
  return function() {
1506
1507
  return function(tree) {
1507
- (0, import_unist_util_visit.visit)(tree, "text", function(node, index, parent) {
1508
- if (content.text.annotations.length > 0) {
1509
- content.text.annotations.forEach(function(annotation) {
1510
- var _parent_children;
1511
- var _node_position_start, _node_position, _node_position_end, _node_position1;
1512
- if (!((_node_position = node.position) === null || _node_position === void 0 ? void 0 : (_node_position_start = _node_position.start) === null || _node_position_start === void 0 ? void 0 : _node_position_start.offset)) return;
1513
- if (!((_node_position1 = node.position) === null || _node_position1 === void 0 ? void 0 : (_node_position_end = _node_position1.end) === null || _node_position_end === void 0 ? void 0 : _node_position_end.offset)) return;
1514
- if (node.position.start.offset > annotation.start_index) {
1515
- return;
1516
- }
1517
- if (node.position.end.offset < annotation.end_index) {
1518
- return;
1519
- }
1520
- var beforeStart = node.position.start.offset;
1521
- var beforeEnd = annotation.start_index;
1522
- var annotationStart = annotation.start_index;
1523
- var annotationEnd = annotation.end_index;
1524
- var afterStart = annotation.end_index;
1525
- var afterEnd = node.position.end.offset;
1526
- var before = node.value.slice(0, annotation.start_index - node.position.start.offset);
1527
- var annotatedText = node.value.slice(annotation.start_index - node.position.start.offset, annotation.end_index - node.position.start.offset);
1528
- var after = node.value.slice(annotation.end_index - node.position.start.offset);
1529
- var newNodes = [];
1530
- if (before) {
1531
- newNodes.push({
1532
- type: "text",
1533
- value: before,
1534
- position: {
1535
- start: {
1536
- offset: beforeStart
1537
- },
1538
- end: {
1539
- offset: beforeEnd
1540
- }
1541
- }
1542
- });
1543
- }
1508
+ (0, import_unist_util_flatmap.default)(tree, function(node) {
1509
+ if (node.type !== "text") {
1510
+ return [
1511
+ node
1512
+ ];
1513
+ }
1514
+ if (!content.text.annotations.length) {
1515
+ return [
1516
+ node
1517
+ ];
1518
+ }
1519
+ if (!node.position) {
1520
+ return [
1521
+ node
1522
+ ];
1523
+ }
1524
+ var nodeStart = node.position.start.offset;
1525
+ if (!(0, import_radash3.isNumber)(nodeStart)) {
1526
+ return [
1527
+ node
1528
+ ];
1529
+ }
1530
+ var nodeEnd = node.position.end.offset;
1531
+ if (!(0, import_radash3.isNumber)(nodeEnd)) {
1532
+ return [
1533
+ node
1534
+ ];
1535
+ }
1536
+ var newNodes = [];
1537
+ var sortedAnnotations = content.text.annotations.sort(function(a, b) {
1538
+ return a.start_index - b.start_index;
1539
+ });
1540
+ var lastProcessedIndex = nodeStart;
1541
+ sortedAnnotations.forEach(function(annotation) {
1542
+ var annotationStart = annotation.start_index;
1543
+ var annotationEnd = annotation.end_index;
1544
+ if (nodeEnd < annotationStart || nodeStart > annotationEnd) {
1545
+ return;
1546
+ }
1547
+ var startIndex = Math.max(nodeStart, annotationStart);
1548
+ var endIndex = Math.min(nodeEnd, annotationEnd);
1549
+ if (lastProcessedIndex < startIndex) {
1544
1550
  newNodes.push({
1545
- value: annotatedText,
1546
- data: {
1547
- hName: "annotation",
1548
- hProperties: {
1549
- annotation: annotation
1550
- }
1551
- },
1551
+ type: "text",
1552
+ value: node.value.slice(lastProcessedIndex - nodeStart, startIndex - nodeStart),
1552
1553
  position: {
1553
1554
  start: {
1554
- offset: annotationStart
1555
+ line: node.position.start.line,
1556
+ column: node.position.start.column,
1557
+ offset: lastProcessedIndex
1555
1558
  },
1556
1559
  end: {
1557
- offset: annotationEnd
1560
+ line: node.position.end.line,
1561
+ column: node.position.end.column,
1562
+ offset: startIndex
1558
1563
  }
1559
1564
  }
1560
1565
  });
1561
- if (after) {
1562
- newNodes.push({
1563
- type: "text",
1564
- value: after,
1565
- position: {
1566
- start: {
1567
- offset: afterStart
1568
- },
1569
- end: {
1570
- offset: afterEnd
1571
- }
1572
- }
1573
- });
1566
+ }
1567
+ newNodes.push({
1568
+ type: "annotation",
1569
+ value: node.value.slice(startIndex - nodeStart, endIndex - nodeStart),
1570
+ position: {
1571
+ start: {
1572
+ line: node.position.start.line,
1573
+ column: node.position.start.column,
1574
+ offset: startIndex
1575
+ },
1576
+ end: {
1577
+ line: node.position.end.line,
1578
+ column: node.position.end.column,
1579
+ offset: endIndex
1580
+ }
1581
+ },
1582
+ data: {
1583
+ hName: "annotation",
1584
+ hProperties: {
1585
+ annotation: annotation
1586
+ }
1587
+ }
1588
+ });
1589
+ lastProcessedIndex = endIndex;
1590
+ });
1591
+ if (lastProcessedIndex < nodeEnd) {
1592
+ newNodes.push({
1593
+ type: "text",
1594
+ value: node.value.slice(lastProcessedIndex - nodeStart, nodeEnd - nodeStart),
1595
+ position: {
1596
+ start: {
1597
+ line: node.position.start.line,
1598
+ column: node.position.start.column,
1599
+ offset: lastProcessedIndex
1600
+ },
1601
+ end: {
1602
+ line: node.position.end.line,
1603
+ column: node.position.end.column,
1604
+ offset: nodeEnd
1605
+ }
1574
1606
  }
1575
- (_parent_children = parent.children).splice.apply(_parent_children, [
1576
- index,
1577
- 1
1578
- ].concat(_to_consumable_array(newNodes)));
1579
1607
  });
1580
- return import_unist_util_visit.SKIP;
1581
1608
  }
1582
- return;
1609
+ return newNodes;
1583
1610
  });
1584
1611
  };
1585
1612
  };
@@ -1706,13 +1733,13 @@ var Message = function(param) {
1706
1733
  })
1707
1734
  }, index);
1708
1735
  }),
1709
- isInProgress && (0, import_radash3.isEmpty)(laterRunSteps) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StartingContentSkeleton, {})
1736
+ isInProgress && (0, import_radash4.isEmpty)(laterRunSteps) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StartingContentSkeleton, {})
1710
1737
  ]
1711
1738
  }),
1712
1739
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(RunSteps, {
1713
1740
  runSteps: laterRunSteps
1714
1741
  }),
1715
- isInProgress && !(0, import_radash3.isEmpty)(laterRunSteps) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_themes27.Box, {
1742
+ isInProgress && !(0, import_radash4.isEmpty)(laterRunSteps) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_themes27.Box, {
1716
1743
  children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StartingContentSkeleton, {})
1717
1744
  })
1718
1745
  ]
@@ -1958,7 +1985,8 @@ var Messages = function(param) {
1958
1985
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(NextPageSkeleton, {}),
1959
1986
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_themes32.Flex, {
1960
1987
  flexShrink: "0",
1961
- flexGrow: "1"
1988
+ flexGrow: "1",
1989
+ minHeight: "var(--space-5)"
1962
1990
  })
1963
1991
  ]
1964
1992
  });
@@ -2026,16 +2054,16 @@ var import_react34 = require("react");
2026
2054
  var import_react_hook_form = require("react-hook-form");
2027
2055
  var import_themes34 = require("@radix-ui/themes");
2028
2056
  // src/hooks/messages/useCreateMessage/index.ts
2029
- var import_radash11 = require("radash");
2057
+ var import_radash12 = require("radash");
2030
2058
  var import_react_query4 = require("@tanstack/react-query");
2031
2059
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
2032
- var import_radash5 = require("radash");
2060
+ var import_radash6 = require("radash");
2033
2061
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
2034
2062
  var import_dayjs = __toESM(require("dayjs"), 1);
2035
2063
  // src/lib/optimistic/optimisticId.ts
2036
- var import_radash4 = require("radash");
2064
+ var import_radash5 = require("radash");
2037
2065
  var optimisticId = function() {
2038
- return "-".concat((0, import_radash4.uid)(24));
2066
+ return "-".concat((0, import_radash5.uid)(24));
2039
2067
  };
2040
2068
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
2041
2069
  var data = function(param) {
@@ -2100,7 +2128,7 @@ var onMutate = function(param) {
2100
2128
  case 0:
2101
2129
  queryKey = [
2102
2130
  "messages",
2103
- (0, import_radash5.omit)(newMessage, [
2131
+ (0, import_radash6.omit)(newMessage, [
2104
2132
  "content",
2105
2133
  "attachments"
2106
2134
  ])
@@ -2149,7 +2177,7 @@ var threadCreated = function(param) {
2149
2177
  });
2150
2178
  };
2151
2179
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/extendMessage.ts
2152
- var import_radash6 = require("radash");
2180
+ var import_radash7 = require("radash");
2153
2181
  var extendMessage = function(param) {
2154
2182
  var message = param.message, messages2 = param.messages;
2155
2183
  var _this, _this1;
@@ -2162,7 +2190,7 @@ var extendMessage = function(param) {
2162
2190
  });
2163
2191
  });
2164
2192
  var _runSteps, _ref;
2165
- var runSteps = (_ref = (_runSteps = (_this = (0, import_radash6.last)(prevOptimitisticRunMessages)) === null || _this === void 0 ? void 0 : _this.runSteps) !== null && _runSteps !== void 0 ? _runSteps : (_this1 = (0, import_radash6.last)(prevRunMessages)) === null || _this1 === void 0 ? void 0 : _this1.runSteps) !== null && _ref !== void 0 ? _ref : [];
2193
+ var runSteps = (_ref = (_runSteps = (_this = (0, import_radash7.last)(prevOptimitisticRunMessages)) === null || _this === void 0 ? void 0 : _this.runSteps) !== null && _runSteps !== void 0 ? _runSteps : (_this1 = (0, import_radash7.last)(prevRunMessages)) === null || _this1 === void 0 ? void 0 : _this1.runSteps) !== null && _ref !== void 0 ? _ref : [];
2166
2194
  return _object_spread_props(_object_spread({}, message), {
2167
2195
  runSteps: runSteps
2168
2196
  });
@@ -2215,11 +2243,11 @@ var threadMessageCreated = function(param) {
2215
2243
  };
2216
2244
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadMessageDelta.ts
2217
2245
  var import_lodash6 = __toESM(require("lodash"), 1);
2218
- var import_radash7 = require("radash");
2246
+ var import_radash8 = require("radash");
2219
2247
  var updatedContentPart = function(param) {
2220
2248
  var prevContentPart = param.prevContentPart, delta = param.delta;
2221
2249
  if (!prevContentPart) {
2222
- return (0, import_radash7.omit)(delta, [
2250
+ return (0, import_radash8.omit)(delta, [
2223
2251
  "index"
2224
2252
  ]);
2225
2253
  }
@@ -2281,7 +2309,7 @@ var threadMessageDelta = function(param) {
2281
2309
  });
2282
2310
  };
2283
2311
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadMessageCompleted.ts
2284
- var import_radash8 = require("radash");
2312
+ var import_radash9 = require("radash");
2285
2313
  var threadMessageCompleted = function(param) {
2286
2314
  var value = param.value, queryClient = param.queryClient, messagesQueryKey = param.messagesQueryKey;
2287
2315
  return queryClient.setQueryData(messagesQueryKey, function(prevData) {
@@ -2301,7 +2329,7 @@ var threadMessageCompleted = function(param) {
2301
2329
  return _object_spread_props(_object_spread({}, prevData), {
2302
2330
  pages: [
2303
2331
  _object_spread_props(_object_spread({}, latestPage), {
2304
- data: (0, import_radash8.replace)(latestPage.data, extendMessage({
2332
+ data: (0, import_radash9.replace)(latestPage.data, extendMessage({
2305
2333
  message: value.data,
2306
2334
  messages: latestPage.data
2307
2335
  }), function(m) {
@@ -2367,11 +2395,11 @@ var threadRunStepCreated = function(param) {
2367
2395
  };
2368
2396
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepDelta.ts
2369
2397
  var import_lodash7 = __toESM(require("lodash"), 1);
2370
- var import_radash9 = require("radash");
2398
+ var import_radash10 = require("radash");
2371
2399
  var updatedToolCall = function(param) {
2372
2400
  var toolCall = param.toolCall, delta = param.delta;
2373
2401
  if (!toolCall) {
2374
- return (0, import_radash9.omit)(delta, [
2402
+ return (0, import_radash10.omit)(delta, [
2375
2403
  "index"
2376
2404
  ]);
2377
2405
  }
@@ -2454,7 +2482,7 @@ var threadRunStepDelta = function(param) {
2454
2482
  });
2455
2483
  };
2456
2484
  // src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/threadRunStepCompleted.ts
2457
- var import_radash10 = require("radash");
2485
+ var import_radash11 = require("radash");
2458
2486
  var threadRunStepCompleted = function(param) {
2459
2487
  var value = param.value, queryClient = param.queryClient, messagesQueryKey = param.messagesQueryKey;
2460
2488
  return queryClient.setQueryData(messagesQueryKey, function(prevData) {
@@ -2466,7 +2494,7 @@ var threadRunStepCompleted = function(param) {
2466
2494
  data: latestPage.data.map(function(m) {
2467
2495
  if (m.run_id === value.data.run_id) {
2468
2496
  return _object_spread_props(_object_spread({}, m), {
2469
- runSteps: (0, import_radash10.replace)(m.runSteps, value.data, function(rs) {
2497
+ runSteps: (0, import_radash11.replace)(m.runSteps, value.data, function(rs) {
2470
2498
  return rs.id === value.data.id;
2471
2499
  })
2472
2500
  });
@@ -2633,7 +2661,7 @@ var useCreateMessage = function() {
2633
2661
  onError: onError
2634
2662
  }));
2635
2663
  return _object_spread_props(_object_spread({}, props), {
2636
- createMessage: (0, import_radash11.partob)(props.mutateAsync, threadContext.variables)
2664
+ createMessage: (0, import_radash12.partob)(props.mutateAsync, threadContext.variables)
2637
2665
  });
2638
2666
  };
2639
2667
  // src/components/threads/Thread/MessageForm/Root/lib/formOptions.ts
@@ -2646,7 +2674,7 @@ var formOptions = {
2646
2674
  resolver: (0, import_zod2.zodResolver)(schema)
2647
2675
  };
2648
2676
  // src/components/threads/Thread/MessageForm/Root/index.tsx
2649
- var import_radash12 = require("radash");
2677
+ var import_radash13 = require("radash");
2650
2678
  var import_jsx_runtime48 = require("react/jsx-runtime");
2651
2679
  var Root4 = function(param) {
2652
2680
  var children = param.children, onSubmitArg = param.onSubmit;
@@ -2705,7 +2733,7 @@ var Root4 = function(param) {
2705
2733
  isLoading,
2706
2734
  files
2707
2735
  ]);
2708
- var onSubmit = onSubmitArg ? (0, import_radash12.partob)(onSubmitArg, {
2736
+ var onSubmit = onSubmitArg ? (0, import_radash13.partob)(onSubmitArg, {
2709
2737
  reset: reset,
2710
2738
  createMessage: createMessage
2711
2739
  }) : function() {
@@ -2939,7 +2967,7 @@ var Preview = function() {
2939
2967
  };
2940
2968
  // src/components/threads/Thread/MessageForm/Field/Files/Control.tsx
2941
2969
  var import_react37 = require("react");
2942
- var import_radash13 = require("radash");
2970
+ var import_radash14 = require("radash");
2943
2971
  var import_dayjs2 = __toESM(require("dayjs"), 1);
2944
2972
  var import_react_icons9 = require("@radix-ui/react-icons");
2945
2973
  var import_themes37 = require("@radix-ui/themes");
@@ -3083,7 +3111,7 @@ var Control2 = function() {
3083
3111
  });
3084
3112
  setFiles(function(prev) {
3085
3113
  return _to_consumable_array(prev).concat(_to_consumable_array(newFiles.map(function(file) {
3086
- return (0, import_radash13.omit)(file, [
3114
+ return (0, import_radash14.omit)(file, [
3087
3115
  "fileObject"
3088
3116
  ]);
3089
3117
  })));
@@ -3920,7 +3948,7 @@ var import_compromise = __toESM(require("compromise"), 1);
3920
3948
  var import_howler = require("howler");
3921
3949
  var import_react_use_audio_player2 = require("react-use-audio-player");
3922
3950
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
3923
- var import_radash14 = require("radash");
3951
+ var import_radash15 = require("radash");
3924
3952
  var input = function(param) {
3925
3953
  var message = param.message;
3926
3954
  var textContents = message.content.filter(function(c) {
@@ -3929,7 +3957,7 @@ var input = function(param) {
3929
3957
  var result = textContents.map(function(c) {
3930
3958
  return c.text.value;
3931
3959
  }).join(" ");
3932
- if ((0, import_radash14.isEmpty)(result)) return null;
3960
+ if ((0, import_radash15.isEmpty)(result)) return null;
3933
3961
  return result;
3934
3962
  };
3935
3963
  // src/hooks/audioThreads/useMessageAudio/lib/isHtmlAudioSupported.ts
@@ -4190,7 +4218,7 @@ var useAudioThreadContext = function() {
4190
4218
  var import_lodash8 = __toESM(require("lodash"), 1);
4191
4219
  var import_themes46 = require("@radix-ui/themes");
4192
4220
  var import_react48 = require("react");
4193
- var import_radash15 = require("radash");
4221
+ var import_radash16 = require("radash");
4194
4222
  var import_jsx_runtime67 = require("react/jsx-runtime");
4195
4223
  var barCount = 4;
4196
4224
  var BarsVisualizer = function(param) {
@@ -4204,7 +4232,7 @@ var BarsVisualizer = function(param) {
4204
4232
  }
4205
4233
  var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
4206
4234
  visualizationAnalyser2.getByteFrequencyData(frequencyData);
4207
- var clusteredFrequencyData = (0, import_radash15.cluster)(frequencyData, frequencyData.length / barCount);
4235
+ var clusteredFrequencyData = (0, import_radash16.cluster)(frequencyData, frequencyData.length / barCount);
4208
4236
  setBarHeights(clusteredFrequencyData.map(function(frequencyDataCluster) {
4209
4237
  return import_lodash8.default.mean(frequencyDataCluster) / 255 * 100;
4210
4238
  }));
@@ -4559,7 +4587,7 @@ AudioThreadDialog.Content = Content4;
4559
4587
  var import_react51 = require("react");
4560
4588
  // src/components/suggestions/Suggestions/Content.tsx
4561
4589
  var import_react50 = require("react");
4562
- var import_radash16 = require("radash");
4590
+ var import_radash17 = require("radash");
4563
4591
  var import_react_children_utilities = require("react-children-utilities");
4564
4592
  var import_themes52 = require("@radix-ui/themes");
4565
4593
  // src/components/suggestions/Suggestions/Item.tsx
@@ -4617,14 +4645,14 @@ var Content6 = function(param) {
4617
4645
  var isMutatingMessage = useIsMutatingMessage();
4618
4646
  var suggestions = (0, import_react50.useMemo)(function() {
4619
4647
  return (0, import_react_children_utilities.onlyText)(children).split(/\r?\n/).filter(function(c) {
4620
- return !(0, import_radash16.isEmpty)(c);
4648
+ return !(0, import_radash17.isEmpty)(c);
4621
4649
  }).map(function(c) {
4622
4650
  return c.trim();
4623
4651
  });
4624
4652
  }, [
4625
4653
  children
4626
4654
  ]);
4627
- if ((0, import_radash16.isEmpty)(suggestions)) return null;
4655
+ if ((0, import_radash17.isEmpty)(suggestions)) return null;
4628
4656
  return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_themes52.Flex, {
4629
4657
  gap: "2",
4630
4658
  py: "2",