@superinterface/react 2.8.1 → 2.9.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.cjs +52 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -50
- package/dist/index.js.map +1 -1
- package/package.json +5 -9
package/dist/index.js
CHANGED
|
@@ -729,16 +729,16 @@ import { useContext as useContext4 } from "react";
|
|
|
729
729
|
import { createContext as createContext5 } from "react";
|
|
730
730
|
var FunctionComponentsContext = createContext5({});
|
|
731
731
|
// src/components/functions/FunctionBase/index.tsx
|
|
732
|
-
import {
|
|
732
|
+
import { Popover as Popover2 } from "@radix-ui/themes";
|
|
733
733
|
// src/components/toolCalls/ToolCallBase/index.tsx
|
|
734
|
-
import { Flex as Flex5, Button,
|
|
734
|
+
import { Flex as Flex5, Button, Popover } from "@radix-ui/themes";
|
|
735
735
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
736
736
|
var ToolCallBase = function(param) {
|
|
737
737
|
var children = param.children;
|
|
738
738
|
return /* @__PURE__ */ jsx8(Flex5, {
|
|
739
739
|
py: "1",
|
|
740
740
|
ml: "-2",
|
|
741
|
-
children: /* @__PURE__ */ jsx8(
|
|
741
|
+
children: /* @__PURE__ */ jsx8(Popover.Trigger, {
|
|
742
742
|
children: /* @__PURE__ */ jsx8(Button, {
|
|
743
743
|
size: "1",
|
|
744
744
|
color: "gold",
|
|
@@ -829,7 +829,7 @@ var Content = function(param) {
|
|
|
829
829
|
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
830
830
|
var FunctionBase = function(param) {
|
|
831
831
|
var fn = param.fn, runStep = param.runStep, title2 = param.title;
|
|
832
|
-
return /* @__PURE__ */ jsxs3(
|
|
832
|
+
return /* @__PURE__ */ jsxs3(Popover2.Root, {
|
|
833
833
|
children: [
|
|
834
834
|
/* @__PURE__ */ jsxs3(ToolCallBase, {
|
|
835
835
|
children: [
|
|
@@ -841,7 +841,7 @@ var FunctionBase = function(param) {
|
|
|
841
841
|
})
|
|
842
842
|
]
|
|
843
843
|
}),
|
|
844
|
-
/* @__PURE__ */ jsx12(
|
|
844
|
+
/* @__PURE__ */ jsx12(Popover2.Content, {
|
|
845
845
|
style: {
|
|
846
846
|
maxHeight: "200px"
|
|
847
847
|
},
|
|
@@ -918,11 +918,11 @@ var ToolCall = function(param) {
|
|
|
918
918
|
});
|
|
919
919
|
};
|
|
920
920
|
// src/components/runSteps/RunStep/ToolCalls/Starting/index.tsx
|
|
921
|
-
import {
|
|
921
|
+
import { Popover as Popover3, Text as Text3 } from "@radix-ui/themes";
|
|
922
922
|
import { CircleIcon as CircleIcon2 } from "@radix-ui/react-icons";
|
|
923
923
|
import { jsx as jsx17, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
924
924
|
var Starting = function() {
|
|
925
|
-
return /* @__PURE__ */ jsxs4(
|
|
925
|
+
return /* @__PURE__ */ jsxs4(Popover3.Root, {
|
|
926
926
|
children: [
|
|
927
927
|
/* @__PURE__ */ jsxs4(ToolCallBase, {
|
|
928
928
|
children: [
|
|
@@ -932,7 +932,7 @@ var Starting = function() {
|
|
|
932
932
|
})
|
|
933
933
|
]
|
|
934
934
|
}),
|
|
935
|
-
/* @__PURE__ */ jsx17(
|
|
935
|
+
/* @__PURE__ */ jsx17(Popover3.Content, {
|
|
936
936
|
style: {
|
|
937
937
|
maxHeight: "500px"
|
|
938
938
|
},
|
|
@@ -2432,7 +2432,7 @@ var CustomToast = function(param) {
|
|
|
2432
2432
|
height: "14px",
|
|
2433
2433
|
align: "center",
|
|
2434
2434
|
children: toast.type === "success" ? /* @__PURE__ */ jsx47(CheckCircledIcon2, {
|
|
2435
|
-
color: "var(--
|
|
2435
|
+
color: "var(--accent-9)"
|
|
2436
2436
|
}) : /* @__PURE__ */ jsx47(CrossCircledIcon, {
|
|
2437
2437
|
color: "var(--red-9)"
|
|
2438
2438
|
})
|
|
@@ -2762,8 +2762,8 @@ var useStatus = function(param) {
|
|
|
2762
2762
|
var _latestMessageProps_latestMessage;
|
|
2763
2763
|
if (recorderProps.status === "recording") return "recording";
|
|
2764
2764
|
if (createMessageProps.isPending) return "creatingMessage";
|
|
2765
|
+
if (messageAudioProps.paused || !messageAudioProps.isAudioPlayed) return "playerPaused";
|
|
2765
2766
|
if (messageAudioProps.playing || messageAudioProps.isPending) return "playing";
|
|
2766
|
-
if (messageAudioProps.paused) return "playerPaused";
|
|
2767
2767
|
if (!messageAudioProps.isReady) return "loading";
|
|
2768
2768
|
if (((_latestMessageProps_latestMessage = latestMessageProps.latestMessage) === null || _latestMessageProps_latestMessage === void 0 ? void 0 : _latestMessageProps_latestMessage.status) === "in_progress") return "creatingMessage";
|
|
2769
2769
|
if (recorderProps.status === "idle") return "idle";
|
|
@@ -2968,10 +2968,12 @@ var getMessageSentences = function(param) {
|
|
|
2968
2968
|
};
|
|
2969
2969
|
var useMessageAudio = function(param) {
|
|
2970
2970
|
var onEnd = param.onEnd;
|
|
2971
|
-
var _useState4 = _sliced_to_array(useState4(
|
|
2971
|
+
var _useState4 = _sliced_to_array(useState4(false), 2), isAudioPlayed = _useState4[0], setIsAudioPlayed = _useState4[1];
|
|
2972
|
+
var _useState41 = _sliced_to_array(useState4([]), 2), playedMessageSentences = _useState41[0], setPlayedMessageSentences = _useState41[1];
|
|
2972
2973
|
var audioPlayer = useAudioPlayer2();
|
|
2974
|
+
var nextAudioPlayer = useAudioPlayer2();
|
|
2973
2975
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2974
|
-
var
|
|
2976
|
+
var _useState42 = _sliced_to_array(useState4(false), 2), isPlaying = _useState42[0], setIsPlaying = _useState42[1];
|
|
2975
2977
|
var latestMessageProps = useLatestMessage();
|
|
2976
2978
|
var unplayedMessageSentences = useMemo12(function() {
|
|
2977
2979
|
if (!latestMessageProps.latestMessage) return [];
|
|
@@ -3015,8 +3017,25 @@ var useMessageAudio = function(param) {
|
|
|
3015
3017
|
}, superinterfaceContext.variables));
|
|
3016
3018
|
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
|
|
3017
3019
|
format: "mp3",
|
|
3018
|
-
autoplay:
|
|
3020
|
+
autoplay: isAudioPlayed,
|
|
3019
3021
|
html5: isHtmlAudioSupported,
|
|
3022
|
+
onplay: function() {
|
|
3023
|
+
setIsAudioPlayed(true);
|
|
3024
|
+
},
|
|
3025
|
+
onload: function() {
|
|
3026
|
+
var nextUnplayedMessageSentence = unplayedMessageSentences[1];
|
|
3027
|
+
if (!nextUnplayedMessageSentence) return;
|
|
3028
|
+
var isNextFullSentence = FULL_SENTENCE_REGEX.test(nextUnplayedMessageSentence.sentence);
|
|
3029
|
+
if (!isNextFullSentence) return;
|
|
3030
|
+
var nextSearchParams = new URLSearchParams(_object_spread({
|
|
3031
|
+
input: nextUnplayedMessageSentence.sentence
|
|
3032
|
+
}, superinterfaceContext.variables));
|
|
3033
|
+
nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(nextSearchParams), {
|
|
3034
|
+
format: "mp3",
|
|
3035
|
+
autoplay: false,
|
|
3036
|
+
html5: isHtmlAudioSupported
|
|
3037
|
+
});
|
|
3038
|
+
},
|
|
3020
3039
|
onend: function() {
|
|
3021
3040
|
setIsPlaying(false);
|
|
3022
3041
|
if (unplayedMessageSentences.length === 1 && latestMessageProps.latestMessage.status !== "in_progress") {
|
|
@@ -3030,24 +3049,16 @@ var useMessageAudio = function(param) {
|
|
|
3030
3049
|
superinterfaceContext,
|
|
3031
3050
|
latestMessageProps,
|
|
3032
3051
|
audioPlayer,
|
|
3052
|
+
nextAudioPlayer,
|
|
3033
3053
|
playedMessageSentences,
|
|
3034
3054
|
onEnd
|
|
3035
3055
|
]);
|
|
3036
|
-
var
|
|
3037
|
-
var
|
|
3038
|
-
useEffect5(function() {
|
|
3039
|
-
if (isHtmlAudioSupported) {
|
|
3040
|
-
var _Howler__howls___sounds_, _Howler__howls_;
|
|
3041
|
-
if (!(Howler === null || Howler === void 0 ? void 0 : (_Howler__howls_ = Howler._howls[0]) === null || _Howler__howls_ === void 0 ? void 0 : (_Howler__howls___sounds_ = _Howler__howls_._sounds[0]) === null || _Howler__howls___sounds_ === void 0 ? void 0 : _Howler__howls___sounds_._node)) return;
|
|
3042
|
-
Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
|
|
3043
|
-
}
|
|
3044
|
-
}, [
|
|
3045
|
-
audioPlayer
|
|
3046
|
-
]);
|
|
3056
|
+
var _useState43 = _sliced_to_array(useState4(null), 2), audioEngine = _useState43[0], setAudioEngine = _useState43[1];
|
|
3057
|
+
var isAudioEngineInited = useRef5(false);
|
|
3047
3058
|
useEffect5(function() {
|
|
3048
3059
|
if (!audioPlayer.playing) return;
|
|
3049
|
-
if (
|
|
3050
|
-
|
|
3060
|
+
if (isAudioEngineInited.current) return;
|
|
3061
|
+
isAudioEngineInited.current = true;
|
|
3051
3062
|
if (isHtmlAudioSupported) {
|
|
3052
3063
|
var audioContext = new AudioContext();
|
|
3053
3064
|
setAudioEngine({
|
|
@@ -3063,7 +3074,7 @@ var useMessageAudio = function(param) {
|
|
|
3063
3074
|
}
|
|
3064
3075
|
}, [
|
|
3065
3076
|
audioPlayer,
|
|
3066
|
-
|
|
3077
|
+
isAudioEngineInited
|
|
3067
3078
|
]);
|
|
3068
3079
|
var visualizationAnalyser = useMemo12(function() {
|
|
3069
3080
|
if (!audioEngine) return null;
|
|
@@ -3081,7 +3092,8 @@ var useMessageAudio = function(param) {
|
|
|
3081
3092
|
unplayedMessageSentences
|
|
3082
3093
|
]);
|
|
3083
3094
|
return _object_spread_props(_object_spread({
|
|
3084
|
-
isPending: isPending
|
|
3095
|
+
isPending: isPending,
|
|
3096
|
+
isAudioPlayed: isAudioPlayed
|
|
3085
3097
|
}, audioPlayer), {
|
|
3086
3098
|
visualizationAnalyser: visualizationAnalyser
|
|
3087
3099
|
});
|
|
@@ -3095,7 +3107,6 @@ var Root8 = function(param) {
|
|
|
3095
3107
|
isStopOnSilence: true,
|
|
3096
3108
|
onStart: /*#__PURE__*/ _async_to_generator(function() {
|
|
3097
3109
|
return _ts_generator(this, function(_state) {
|
|
3098
|
-
console.log("start");
|
|
3099
3110
|
return [
|
|
3100
3111
|
2
|
|
3101
3112
|
];
|
|
@@ -3175,18 +3186,14 @@ import { cluster } from "radash";
|
|
|
3175
3186
|
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
3176
3187
|
var barCount = 4;
|
|
3177
3188
|
var BarsVisualizer = function(param) {
|
|
3178
|
-
var visualizationAnalyser = param.visualizationAnalyser,
|
|
3179
|
-
var _useState5 = _sliced_to_array(useState5(
|
|
3180
|
-
var getEmptyVisualizer = useCallback4(function() {
|
|
3181
|
-
var result = new AudioContext().createAnalyser();
|
|
3182
|
-
setCachedEmptyVisualizer(result);
|
|
3183
|
-
return result;
|
|
3184
|
-
}, [
|
|
3185
|
-
cachedEmptyVisualizer
|
|
3186
|
-
]);
|
|
3187
|
-
var _useState51 = _sliced_to_array(useState5([]), 2), barHeights = _useState51[0], setBarHeights = _useState51[1];
|
|
3189
|
+
var visualizationAnalyser = param.visualizationAnalyser, backgroundColor = param.backgroundColor, height = param.height, barWidth = param.barWidth;
|
|
3190
|
+
var _useState5 = _sliced_to_array(useState5([]), 2), barHeights = _useState5[0], setBarHeights = _useState5[1];
|
|
3188
3191
|
var draw = useCallback4(function(param) {
|
|
3189
3192
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
3193
|
+
if (!visualizationAnalyser2) {
|
|
3194
|
+
setBarHeights(Array(barCount).fill(0));
|
|
3195
|
+
return;
|
|
3196
|
+
}
|
|
3190
3197
|
var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
|
|
3191
3198
|
visualizationAnalyser2.getByteFrequencyData(frequencyData);
|
|
3192
3199
|
var clusteredFrequencyData = cluster(frequencyData, frequencyData.length / barCount);
|
|
@@ -3201,13 +3208,11 @@ var BarsVisualizer = function(param) {
|
|
|
3201
3208
|
}, []);
|
|
3202
3209
|
useEffect6(function() {
|
|
3203
3210
|
draw({
|
|
3204
|
-
visualizationAnalyser: visualizationAnalyser
|
|
3211
|
+
visualizationAnalyser: visualizationAnalyser
|
|
3205
3212
|
});
|
|
3206
3213
|
}, [
|
|
3207
3214
|
draw,
|
|
3208
|
-
visualizationAnalyser
|
|
3209
|
-
cachedEmptyVisualizer,
|
|
3210
|
-
getEmptyVisualizer
|
|
3215
|
+
visualizationAnalyser
|
|
3211
3216
|
]);
|
|
3212
3217
|
return /* @__PURE__ */ jsx56(Grid, {
|
|
3213
3218
|
columns: "".concat(barCount),
|
|
@@ -3229,7 +3234,7 @@ var BarsVisualizer = function(param) {
|
|
|
3229
3234
|
height: "".concat(barHeight + 20, "%"),
|
|
3230
3235
|
width: barWidth,
|
|
3231
3236
|
style: {
|
|
3232
|
-
backgroundColor:
|
|
3237
|
+
backgroundColor: backgroundColor,
|
|
3233
3238
|
borderRadius: "var(--radius-6)"
|
|
3234
3239
|
}
|
|
3235
3240
|
})
|
|
@@ -3253,12 +3258,12 @@ var Visualization = function() {
|
|
|
3253
3258
|
height: "200px",
|
|
3254
3259
|
width: "200px",
|
|
3255
3260
|
style: {
|
|
3256
|
-
backgroundColor:
|
|
3261
|
+
backgroundColor: audioThreadContext.status === "playing" ? "var(--accent-4)" : "var(--gray-4)",
|
|
3257
3262
|
borderRadius: "9999px"
|
|
3258
3263
|
},
|
|
3259
3264
|
children: /* @__PURE__ */ jsx57(BarsVisualizer, {
|
|
3260
3265
|
visualizationAnalyser: audioThreadContext.messageAudioProps.visualizationAnalyser,
|
|
3261
|
-
|
|
3266
|
+
backgroundColor: audioThreadContext.status === "playing" ? "var(--accent-11)" : "var(--gray-11)",
|
|
3262
3267
|
height: "40px",
|
|
3263
3268
|
barWidth: "24px"
|
|
3264
3269
|
})
|
|
@@ -3348,9 +3353,9 @@ var ActionButton = function() {
|
|
|
3348
3353
|
return audioThreadContext.messageAudioProps.play();
|
|
3349
3354
|
},
|
|
3350
3355
|
size: "4",
|
|
3351
|
-
color: "gray",
|
|
3352
3356
|
radius: "full",
|
|
3353
3357
|
style: {
|
|
3358
|
+
backgroundColor: "var(--accent-11)",
|
|
3354
3359
|
border: "2px solid var(--gray-8)"
|
|
3355
3360
|
},
|
|
3356
3361
|
children: /* @__PURE__ */ jsx58(ResumeIcon, {})
|
|
@@ -3384,7 +3389,7 @@ var Form = function() {
|
|
|
3384
3389
|
align: "center",
|
|
3385
3390
|
children: /* @__PURE__ */ jsx59(SpeakerModerateIcon, {
|
|
3386
3391
|
style: {
|
|
3387
|
-
color:
|
|
3392
|
+
color: audioThreadContext.status === "recording" ? "var(--accent-12)" : "var(--gray-12)"
|
|
3388
3393
|
}
|
|
3389
3394
|
})
|
|
3390
3395
|
}),
|
|
@@ -3392,12 +3397,12 @@ var Form = function() {
|
|
|
3392
3397
|
px: "2",
|
|
3393
3398
|
py: "1",
|
|
3394
3399
|
style: {
|
|
3395
|
-
backgroundColor:
|
|
3400
|
+
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-4)" : "var(--gray-4)",
|
|
3396
3401
|
borderRadius: "var(--radius-6)"
|
|
3397
3402
|
},
|
|
3398
3403
|
children: /* @__PURE__ */ jsx59(BarsVisualizer, {
|
|
3399
3404
|
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser,
|
|
3400
|
-
|
|
3405
|
+
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-11)" : "var(--gray-11)",
|
|
3401
3406
|
height: "20px",
|
|
3402
3407
|
barWidth: "12px"
|
|
3403
3408
|
})
|