@superinterface/react 2.17.5 → 2.19.0

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
@@ -1771,7 +1771,6 @@ var useInfiniteScroll = function(param) {
1771
1771
  if (isFetchingNextPage) return;
1772
1772
  if (!inView) return;
1773
1773
  if (!hasNextPage) return;
1774
- console.log("Fetching next page");
1775
1774
  fetchNextPage();
1776
1775
  }, 500, [
1777
1776
  inView,
@@ -3248,6 +3247,104 @@ import { useContext as useContext12 } from "react";
3248
3247
  var useMessageContext = function() {
3249
3248
  return useContext12(MessageContext);
3250
3249
  };
3250
+ // src/hooks/assistants/useAssistant/index.ts
3251
+ import { useMemo as useMemo10 } from "react";
3252
+ import { useQuery } from "@tanstack/react-query";
3253
+ // src/hooks/assistants/useAssistant/lib/queryOptions/index.ts
3254
+ import { queryOptions as tanstackQueryOptions } from "@tanstack/react-query";
3255
+ // src/hooks/assistants/useAssistant/lib/queryOptions/queryFn.ts
3256
+ var queryFn = function(param) {
3257
+ var superinterfaceContext = param.superinterfaceContext;
3258
+ return function() {
3259
+ var _ref = _async_to_generator(function(param) {
3260
+ var queryKey, _queryKey, _key, assistantId, params;
3261
+ return _ts_generator(this, function(_state) {
3262
+ queryKey = param.queryKey;
3263
+ _queryKey = _sliced_to_array(queryKey, 2), _key = _queryKey[0], assistantId = _queryKey[1].assistantId;
3264
+ params = new URLSearchParams({
3265
+ publicApiKey: superinterfaceContext.variables.publicApiKey
3266
+ });
3267
+ return [
3268
+ 2,
3269
+ fetch("".concat(superinterfaceContext.baseUrl, "/assistants/").concat(assistantId, "?").concat(params)).then(function() {
3270
+ var _ref = _async_to_generator(function(response) {
3271
+ var errorResponse, error;
3272
+ return _ts_generator(this, function(_state) {
3273
+ switch(_state.label){
3274
+ case 0:
3275
+ if (!(response.status !== 200)) return [
3276
+ 3,
3277
+ 4
3278
+ ];
3279
+ _state.label = 1;
3280
+ case 1:
3281
+ _state.trys.push([
3282
+ 1,
3283
+ 3,
3284
+ ,
3285
+ 4
3286
+ ]);
3287
+ return [
3288
+ 4,
3289
+ response.json()
3290
+ ];
3291
+ case 2:
3292
+ errorResponse = _state.sent();
3293
+ throw new Error(errorResponse.error);
3294
+ case 3:
3295
+ error = _state.sent();
3296
+ throw new Error("Failed to fetch");
3297
+ case 4:
3298
+ return [
3299
+ 2,
3300
+ response.json()
3301
+ ];
3302
+ }
3303
+ });
3304
+ });
3305
+ return function(response) {
3306
+ return _ref.apply(this, arguments);
3307
+ };
3308
+ }())
3309
+ ];
3310
+ });
3311
+ });
3312
+ return function(_) {
3313
+ return _ref.apply(this, arguments);
3314
+ };
3315
+ }();
3316
+ };
3317
+ // src/hooks/assistants/useAssistant/lib/queryOptions/index.ts
3318
+ var queryOptions2 = function(param) {
3319
+ var assistantId = param.assistantId, superinterfaceContext = param.superinterfaceContext;
3320
+ return tanstackQueryOptions({
3321
+ queryKey: [
3322
+ "assistants",
3323
+ {
3324
+ assistantId: assistantId
3325
+ }
3326
+ ],
3327
+ queryFn: queryFn({
3328
+ superinterfaceContext: superinterfaceContext
3329
+ })
3330
+ });
3331
+ };
3332
+ // src/hooks/assistants/useAssistant/index.ts
3333
+ var useAssistant = function(param) {
3334
+ var assistantId = param.assistantId;
3335
+ var superinterfaceContext = useSuperinterfaceContext();
3336
+ var props = useQuery(queryOptions2({
3337
+ assistantId: assistantId,
3338
+ superinterfaceContext: superinterfaceContext
3339
+ }));
3340
+ return useMemo10(function() {
3341
+ return _object_spread_props(_object_spread({}, props), {
3342
+ assistant: props.data ? props.data.assistant : null
3343
+ });
3344
+ }, [
3345
+ props
3346
+ ]);
3347
+ };
3251
3348
  // src/components/threads/ThreadDialog/Provider/index.tsx
3252
3349
  import { useState as useState2 } from "react";
3253
3350
  // src/contexts/threads/ThreadDialogContext/index.ts
@@ -3682,11 +3779,11 @@ var blobToData = function(blob) {
3682
3779
  });
3683
3780
  };
3684
3781
  // src/hooks/audioThreads/useStatus/index.ts
3685
- import { useMemo as useMemo10 } from "react";
3782
+ import { useMemo as useMemo11 } from "react";
3686
3783
  var useStatus = function(param) {
3687
3784
  var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
3688
3785
  var latestMessageProps = useLatestMessage();
3689
- var status = useMemo10(function() {
3786
+ var status = useMemo11(function() {
3690
3787
  var _latestMessageProps_latestMessage;
3691
3788
  if (recorderProps.status === "recording") return "recording";
3692
3789
  if (createMessageProps.isPending) return "creatingMessage";
@@ -3710,7 +3807,7 @@ var useStatus = function(param) {
3710
3807
  // src/hooks/audioThreads/useRecorder/index.ts
3711
3808
  import dayjs3 from "dayjs";
3712
3809
  import { useAudioCapture } from "use-audio-capture";
3713
- import { useMemo as useMemo11, useRef as useRef7, useState as useState5, useCallback as useCallback4, useEffect as useEffect7 } from "react";
3810
+ import { useMemo as useMemo12, useRef as useRef7, useState as useState5, useCallback as useCallback4, useEffect as useEffect7 } from "react";
3714
3811
  import { useAudioPlayer } from "react-use-audio-player";
3715
3812
  // src/hooks/misc/useInterval.ts
3716
3813
  import { useEffect as useEffect6, useRef as useRef6 } from "react";
@@ -3816,7 +3913,7 @@ var useRecorder = function(param) {
3816
3913
  isInited,
3817
3914
  mediaStream
3818
3915
  ]);
3819
- var visualizationAnalyser = useMemo11(function() {
3916
+ var visualizationAnalyser = useMemo12(function() {
3820
3917
  if (!audioEngine) return null;
3821
3918
  var result = audioEngine.audioContext.createAnalyser();
3822
3919
  audioEngine.source.connect(result);
@@ -3824,7 +3921,7 @@ var useRecorder = function(param) {
3824
3921
  }, [
3825
3922
  audioEngine
3826
3923
  ]);
3827
- var silenceAnalyser = useMemo11(function() {
3924
+ var silenceAnalyser = useMemo12(function() {
3828
3925
  if (!audioEngine) return null;
3829
3926
  var result = audioEngine.audioContext.createAnalyser();
3830
3927
  result.minDecibels = -60;
@@ -3879,7 +3976,7 @@ var useRecorder = function(param) {
3879
3976
  });
3880
3977
  };
3881
3978
  // src/hooks/audioThreads/useMessageAudio/index.ts
3882
- import { useMemo as useMemo12, useRef as useRef8, useState as useState6, useEffect as useEffect8 } from "react";
3979
+ import { useMemo as useMemo13, useRef as useRef8, useState as useState6, useEffect as useEffect8 } from "react";
3883
3980
  import nlp from "compromise";
3884
3981
  import { Howler } from "howler";
3885
3982
  import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
@@ -3925,7 +4022,7 @@ var useMessageAudio = function(param) {
3925
4022
  var superinterfaceContext = useSuperinterfaceContext();
3926
4023
  var _useState63 = _sliced_to_array(useState6(false), 2), isPlaying = _useState63[0], setIsPlaying = _useState63[1];
3927
4024
  var latestMessageProps = useLatestMessage();
3928
- var unplayedMessageSentences = useMemo12(function() {
4025
+ var unplayedMessageSentences = useMemo13(function() {
3929
4026
  if (!latestMessageProps.latestMessage) return [];
3930
4027
  if (latestMessageProps.latestMessage.role !== "assistant") return [];
3931
4028
  if (stoppedMessageIds.includes(latestMessageProps.latestMessage.id)) return [];
@@ -4046,7 +4143,7 @@ var useMessageAudio = function(param) {
4046
4143
  audioPlayer,
4047
4144
  isAudioEngineInited
4048
4145
  ]);
4049
- var visualizationAnalyser = useMemo12(function() {
4146
+ var visualizationAnalyser = useMemo13(function() {
4050
4147
  if (!audioEngine) return null;
4051
4148
  var result = audioEngine.audioContext.createAnalyser();
4052
4149
  audioEngine.source.connect(audioEngine.audioContext.destination);
@@ -4055,7 +4152,7 @@ var useMessageAudio = function(param) {
4055
4152
  }, [
4056
4153
  audioEngine
4057
4154
  ]);
4058
- var isPending = useMemo12(function() {
4155
+ var isPending = useMemo13(function() {
4059
4156
  return isPlaying || unplayedMessageSentences.length > 0;
4060
4157
  }, [
4061
4158
  isPlaying,
@@ -4520,9 +4617,9 @@ AudioThreadDialog.Root = Root9;
4520
4617
  AudioThreadDialog.Trigger = Trigger;
4521
4618
  AudioThreadDialog.Content = Content4;
4522
4619
  // src/components/suggestions/Suggestions/index.tsx
4523
- import { useMemo as useMemo14 } from "react";
4620
+ import { useMemo as useMemo15 } from "react";
4524
4621
  // src/components/suggestions/Suggestions/Content.tsx
4525
- import { useMemo as useMemo13 } from "react";
4622
+ import { useMemo as useMemo14 } from "react";
4526
4623
  import { isEmpty as isEmpty3 } from "radash";
4527
4624
  import { onlyText } from "react-children-utilities";
4528
4625
  import { Flex as Flex31 } from "@radix-ui/themes";
@@ -4579,7 +4676,7 @@ import { jsx as jsx77 } from "react/jsx-runtime";
4579
4676
  var Content6 = function(param) {
4580
4677
  var children = param.children;
4581
4678
  var isMutatingMessage = useIsMutatingMessage();
4582
- var suggestions = useMemo13(function() {
4679
+ var suggestions = useMemo14(function() {
4583
4680
  return onlyText(children).split(/\r?\n/).filter(function(c) {
4584
4681
  return !isEmpty3(c);
4585
4682
  }).map(function(c) {
@@ -4606,7 +4703,7 @@ import { jsx as jsx78 } from "react/jsx-runtime";
4606
4703
  var Suggestions = function(param) {
4607
4704
  var children = param.children;
4608
4705
  var latestMessageProps = useLatestMessage();
4609
- var isDisabled = useMemo14(function() {
4706
+ var isDisabled = useMemo15(function() {
4610
4707
  var // @ts-ignore-next-line
4611
4708
  _latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
4612
4709
  return (_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : (_latestMessageProps_latestMessage_metadata = _latestMessageProps_latestMessage.metadata) === null || _latestMessageProps_latestMessage_metadata === void 0 ? void 0 : _latestMessageProps_latestMessage_metadata.isBlocking;
@@ -4621,14 +4718,14 @@ var Suggestions = function(param) {
4621
4718
  };
4622
4719
  Suggestions.Item = Item;
4623
4720
  // src/components/markdown/MarkdownProvider/index.tsx
4624
- import { useMemo as useMemo15 } from "react";
4721
+ import { useMemo as useMemo16 } from "react";
4625
4722
  import { jsx as jsx79 } from "react/jsx-runtime";
4626
4723
  var MarkdownProvider = function(_param) {
4627
4724
  var children = _param.children, rest = _object_without_properties(_param, [
4628
4725
  "children"
4629
4726
  ]);
4630
4727
  var prevMarkdownContext = useMarkdownContext();
4631
- var value = useMemo15(function() {
4728
+ var value = useMemo16(function() {
4632
4729
  return merge(prevMarkdownContext, rest);
4633
4730
  }, [
4634
4731
  rest,
@@ -4639,30 +4736,111 @@ var MarkdownProvider = function(_param) {
4639
4736
  children: children
4640
4737
  });
4641
4738
  };
4739
+ // src/components/avatars/Avatar.tsx
4740
+ import { Avatar as RadixAvatar } from "@radix-ui/themes";
4741
+ // src/components/imageAvatars/ImageAvatar.tsx
4742
+ import { Avatar as Avatar4 } from "@radix-ui/themes";
4743
+ import { jsx as jsx80 } from "react/jsx-runtime";
4744
+ var width = function(param) {
4745
+ var size = param.size;
4746
+ if (size === "1") {
4747
+ return 48;
4748
+ } else if (size === "3") {
4749
+ return 96;
4750
+ }
4751
+ return 96;
4752
+ };
4753
+ var optimizedSrc = function(param) {
4754
+ var imageAvatar = param.imageAvatar, size = param.size, superinterfaceContext = param.superinterfaceContext;
4755
+ if (!imageAvatar.url) return "";
4756
+ if (imageAvatar.url.endsWith(".svg")) return imageAvatar.url;
4757
+ if (!superinterfaceContext.baseUrl) return imageAvatar.url;
4758
+ var baseUrl2 = new URL(superinterfaceContext.baseUrl);
4759
+ return new URL("/_next/image?url=".concat(encodeURIComponent(imageAvatar.url), "&w=").concat(width({
4760
+ size: size
4761
+ }), "&q=95"), "".concat(baseUrl2.origin)).toString();
4762
+ };
4763
+ var ImageAvatar = function(param) {
4764
+ var imageAvatar = param.imageAvatar, size = param.size;
4765
+ var superinterfaceContext = useSuperinterfaceContext();
4766
+ return /* @__PURE__ */ jsx80(Avatar4, {
4767
+ fallback: "",
4768
+ src: optimizedSrc({
4769
+ imageAvatar: imageAvatar,
4770
+ size: size,
4771
+ superinterfaceContext: superinterfaceContext
4772
+ }),
4773
+ size: size
4774
+ });
4775
+ };
4776
+ // src/components/iconAvatars/IconAvatar.tsx
4777
+ import { useMemo as useMemo17 } from "react";
4778
+ import { Avatar as Avatar5 } from "@radix-ui/themes";
4779
+ // src/lib/iconAvatars/iconAvatarComponents.ts
4780
+ import { BackpackIcon, RocketIcon, MagicWandIcon, CubeIcon, TargetIcon, DiscIcon, GlobeIcon, StarIcon, LightningBoltIcon as LightningBoltIcon2, FaceIcon, PersonIcon as PersonIcon2, HeartIcon } from "@radix-ui/react-icons";
4781
+ var _obj;
4782
+ var iconAvatarComponents = (_obj = {}, _define_property(_obj, "BACKPACK" /* BACKPACK */ , BackpackIcon), _define_property(_obj, "ROCKET" /* ROCKET */ , RocketIcon), _define_property(_obj, "MAGIC_WAND" /* MAGIC_WAND */ , MagicWandIcon), _define_property(_obj, "CUBE" /* CUBE */ , CubeIcon), _define_property(_obj, "TARGET" /* TARGET */ , TargetIcon), _define_property(_obj, "DISC" /* DISC */ , DiscIcon), _define_property(_obj, "GLOBE" /* GLOBE */ , GlobeIcon), _define_property(_obj, "STAR" /* STAR */ , StarIcon), _define_property(_obj, "LIGHTNING_BOLT" /* LIGHTNING_BOLT */ , LightningBoltIcon2), _define_property(_obj, "FACE" /* FACE */ , FaceIcon), _define_property(_obj, "PERSON" /* PERSON */ , PersonIcon2), _define_property(_obj, "HEART" /* HEART */ , HeartIcon), _obj);
4783
+ // src/components/iconAvatars/IconAvatar.tsx
4784
+ import { jsx as jsx81 } from "react/jsx-runtime";
4785
+ var IconAvatar = function(param) {
4786
+ var iconAvatar = param.iconAvatar, size = param.size;
4787
+ var Component = useMemo17(function() {
4788
+ return iconAvatarComponents[iconAvatar.name];
4789
+ }, [
4790
+ iconAvatar
4791
+ ]);
4792
+ return /* @__PURE__ */ jsx81(Avatar5, {
4793
+ size: size,
4794
+ fallback: Component ? /* @__PURE__ */ jsx81(Component, {}) : ""
4795
+ });
4796
+ };
4797
+ // src/components/avatars/Avatar.tsx
4798
+ import { jsx as jsx82 } from "react/jsx-runtime";
4799
+ var Avatar6 = function(param) {
4800
+ var avatar = param.avatar, _param_size = param.size, size = _param_size === void 0 ? "1" : _param_size;
4801
+ if (avatar) {
4802
+ if (avatar.type === "IMAGE" /* IMAGE */ && avatar.imageAvatar) {
4803
+ return /* @__PURE__ */ jsx82(ImageAvatar, {
4804
+ imageAvatar: avatar.imageAvatar,
4805
+ size: size
4806
+ });
4807
+ }
4808
+ if (avatar.type === "ICON" /* ICON */ && avatar.iconAvatar) {
4809
+ return /* @__PURE__ */ jsx82(IconAvatar, {
4810
+ iconAvatar: avatar.iconAvatar,
4811
+ size: size
4812
+ });
4813
+ }
4814
+ }
4815
+ return /* @__PURE__ */ jsx82(RadixAvatar, {
4816
+ fallback: "",
4817
+ size: size
4818
+ });
4819
+ };
4642
4820
  // src/components/components/ComponentsProvider.tsx
4643
- import { useMemo as useMemo16 } from "react";
4821
+ import { useMemo as useMemo18 } from "react";
4644
4822
  // src/hooks/components/useComponents.ts
4645
4823
  import { useContext as useContext16 } from "react";
4646
4824
  var useComponents = function() {
4647
4825
  return useContext16(ComponentsContext);
4648
4826
  };
4649
4827
  // src/components/components/ComponentsProvider.tsx
4650
- import { jsx as jsx80 } from "react/jsx-runtime";
4828
+ import { jsx as jsx83 } from "react/jsx-runtime";
4651
4829
  var ComponentsProvider = function(_param) {
4652
4830
  var children = _param.children, rest = _object_without_properties(_param, [
4653
4831
  "children"
4654
4832
  ]);
4655
4833
  var prevComponents = useComponents();
4656
- var value = useMemo16(function() {
4834
+ var value = useMemo18(function() {
4657
4835
  return merge(prevComponents, rest);
4658
4836
  }, [
4659
4837
  rest,
4660
4838
  prevComponents
4661
4839
  ]);
4662
- return /* @__PURE__ */ jsx80(ComponentsContext.Provider, {
4840
+ return /* @__PURE__ */ jsx83(ComponentsContext.Provider, {
4663
4841
  value: value,
4664
4842
  children: children
4665
4843
  });
4666
4844
  };
4667
- export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, ComponentsProvider, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, RunStep, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, UserAvatarContext, useComponents, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessageFormContext, useMessages, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext, useThreadDialogContext };
4845
+ export { AssistantAvatarContext, AssistantNameContext, AudioThread, AudioThreadDialog, Avatar6 as Avatar, ComponentsProvider, FunctionBase, FunctionComponentsContext, MarkdownContext, MarkdownProvider, RunStep, Suggestions, SuperinterfaceProvider, Thread, ThreadDialog, ThreadDialogContext, UserAvatarContext, useAssistant, useComponents, useCreateMessage, useLatestMessage, useMarkdownContext, useMessageContext, useMessageFormContext, useMessages, useSuperinterfaceContext, useSuperinterfaceContext as useThreadContext, useThreadDialogContext };
4668
4846
  //# sourceMappingURL=index.js.map