@superinterface/react 2.17.1 → 2.17.3
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 +164 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +119 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.d.cts
CHANGED
|
@@ -14,11 +14,11 @@ import * as openai_resources_beta_threads_runs_steps from 'openai/resources/beta
|
|
|
14
14
|
declare const options: {
|
|
15
15
|
get: ({ assistantId, }: {
|
|
16
16
|
assistantId: string;
|
|
17
|
-
}) =>
|
|
17
|
+
}) => any;
|
|
18
18
|
set: ({ assistantId, threadId, }: {
|
|
19
19
|
assistantId: string;
|
|
20
20
|
threadId: string;
|
|
21
|
-
}) =>
|
|
21
|
+
}) => any;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
type Args$7 = {
|
|
@@ -329,6 +329,7 @@ declare const useCreateMessage: ({ onError, }?: {
|
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
declare const useMessageFormContext: () => {
|
|
332
|
+
content: string;
|
|
332
333
|
isDisabled: boolean;
|
|
333
334
|
isLoading: boolean;
|
|
334
335
|
files: openai_resources.FileObject[];
|
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ import * as openai_resources_beta_threads_runs_steps from 'openai/resources/beta
|
|
|
14
14
|
declare const options: {
|
|
15
15
|
get: ({ assistantId, }: {
|
|
16
16
|
assistantId: string;
|
|
17
|
-
}) =>
|
|
17
|
+
}) => any;
|
|
18
18
|
set: ({ assistantId, threadId, }: {
|
|
19
19
|
assistantId: string;
|
|
20
20
|
threadId: string;
|
|
21
|
-
}) =>
|
|
21
|
+
}) => any;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
type Args$7 = {
|
|
@@ -329,6 +329,7 @@ declare const useCreateMessage: ({ onError, }?: {
|
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
declare const useMessageFormContext: () => {
|
|
332
|
+
content: string;
|
|
332
333
|
isDisabled: boolean;
|
|
333
334
|
isLoading: boolean;
|
|
334
335
|
files: openai_resources.FileObject[];
|
package/dist/index.js
CHANGED
|
@@ -1856,6 +1856,7 @@ import { useContext as useContext10 } from "react";
|
|
|
1856
1856
|
// src/contexts/messages/MessageFormContext/index.ts
|
|
1857
1857
|
import { createContext as createContext10 } from "react";
|
|
1858
1858
|
var MessageFormContext = createContext10({
|
|
1859
|
+
content: "",
|
|
1859
1860
|
isDisabled: false,
|
|
1860
1861
|
isLoading: false,
|
|
1861
1862
|
files: [],
|
|
@@ -2534,7 +2535,7 @@ var Root4 = function(param) {
|
|
|
2534
2535
|
var children = param.children, onSubmitArg = param.onSubmit;
|
|
2535
2536
|
var _useState = _sliced_to_array(useState([]), 2), files = _useState[0], setFiles = _useState[1];
|
|
2536
2537
|
var formProps = useForm(formOptions);
|
|
2537
|
-
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset;
|
|
2538
|
+
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset, watch = formProps.watch;
|
|
2538
2539
|
var addToast = useToasts().addToast;
|
|
2539
2540
|
var queryClient = useQueryClient4();
|
|
2540
2541
|
var threadContext = useSuperinterfaceContext();
|
|
@@ -2638,13 +2639,15 @@ var Root4 = function(param) {
|
|
|
2638
2639
|
return _ref.apply(this, arguments);
|
|
2639
2640
|
};
|
|
2640
2641
|
}();
|
|
2642
|
+
var content = watch("content");
|
|
2641
2643
|
return /* @__PURE__ */ jsx48(MessageFormContext.Provider, {
|
|
2642
2644
|
value: {
|
|
2643
2645
|
isDisabled: isDisabled,
|
|
2644
2646
|
isLoading: isLoading,
|
|
2645
2647
|
files: files,
|
|
2646
2648
|
setFiles: setFiles,
|
|
2647
|
-
isFileLoading: isFileLoading
|
|
2649
|
+
isFileLoading: isFileLoading,
|
|
2650
|
+
content: content
|
|
2648
2651
|
},
|
|
2649
2652
|
children: /* @__PURE__ */ jsx48(FormProvider, _object_spread_props(_object_spread({}, formProps), {
|
|
2650
2653
|
children: /* @__PURE__ */ jsx48(Box12, {
|
|
@@ -2664,8 +2667,17 @@ import { Container as RadixContainer, Flex as Flex19 } from "@radix-ui/themes";
|
|
|
2664
2667
|
// src/components/threads/Thread/MessageForm/Field/Control.tsx
|
|
2665
2668
|
import { Flex as Flex16 } from "@radix-ui/themes";
|
|
2666
2669
|
import { useFormContext } from "react-hook-form";
|
|
2667
|
-
|
|
2668
|
-
import {
|
|
2670
|
+
// src/hooks/misc/usePrevious.ts
|
|
2671
|
+
import { useEffect as useEffect3, useRef as useRef4 } from "react";
|
|
2672
|
+
var usePrevious = function(state) {
|
|
2673
|
+
var ref = useRef4();
|
|
2674
|
+
useEffect3(function() {
|
|
2675
|
+
ref.current = state;
|
|
2676
|
+
});
|
|
2677
|
+
return ref.current;
|
|
2678
|
+
};
|
|
2679
|
+
// src/components/threads/Thread/MessageForm/Field/Control.tsx
|
|
2680
|
+
import { useContext as useContext11, useMemo as useMemo9, useRef as useRef5, useEffect as useEffect4 } from "react";
|
|
2669
2681
|
// src/components/textareas/TextareaBase/index.tsx
|
|
2670
2682
|
import { forwardRef as forwardRef3 } from "react";
|
|
2671
2683
|
import TextareaAutosize from "react-textarea-autosize";
|
|
@@ -2713,9 +2725,9 @@ var Input = function() {
|
|
|
2713
2725
|
isLoading
|
|
2714
2726
|
]);
|
|
2715
2727
|
var isDisabledPrevious = usePrevious(isDisabled);
|
|
2716
|
-
var textareaRef =
|
|
2728
|
+
var textareaRef = useRef5(null);
|
|
2717
2729
|
var textareaProps = register("content");
|
|
2718
|
-
|
|
2730
|
+
useEffect4(function() {
|
|
2719
2731
|
if (isDisabled) return;
|
|
2720
2732
|
if (!isDisabledPrevious) return;
|
|
2721
2733
|
if (!textareaRef.current) return;
|
|
@@ -3549,7 +3561,6 @@ ThreadDialog.Root = Root9;
|
|
|
3549
3561
|
ThreadDialog.Trigger = Trigger;
|
|
3550
3562
|
ThreadDialog.Content = Content4;
|
|
3551
3563
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
3552
|
-
import "regenerator-runtime/runtime";
|
|
3553
3564
|
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3554
3565
|
// src/contexts/threads/AudioThreadContext/index.ts
|
|
3555
3566
|
import { createContext as createContext12 } from "react";
|
|
@@ -3608,8 +3619,58 @@ var AudioThreadContext = createContext12({
|
|
|
3608
3619
|
})
|
|
3609
3620
|
}
|
|
3610
3621
|
});
|
|
3611
|
-
// src/
|
|
3612
|
-
import {
|
|
3622
|
+
// src/hooks/misc/usePermission/index.ts
|
|
3623
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
3624
|
+
// src/hooks/misc/usePermission/util.ts
|
|
3625
|
+
var noop = function() {};
|
|
3626
|
+
function on(obj) {
|
|
3627
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
3628
|
+
args[_key - 1] = arguments[_key];
|
|
3629
|
+
}
|
|
3630
|
+
if (obj && obj.addEventListener) {
|
|
3631
|
+
var _obj;
|
|
3632
|
+
(_obj = obj).addEventListener.apply(_obj, _to_consumable_array(args));
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
function off(obj) {
|
|
3636
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
3637
|
+
args[_key - 1] = arguments[_key];
|
|
3638
|
+
}
|
|
3639
|
+
if (obj && obj.removeEventListener) {
|
|
3640
|
+
var _obj;
|
|
3641
|
+
(_obj = obj).removeEventListener.apply(_obj, _to_consumable_array(args));
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
// src/hooks/misc/usePermission/index.ts
|
|
3645
|
+
var usePermission = function(permissionDesc) {
|
|
3646
|
+
var _useState4 = _sliced_to_array(useState4(""), 2), state = _useState4[0], setState = _useState4[1];
|
|
3647
|
+
useEffect5(function() {
|
|
3648
|
+
var mounted = true;
|
|
3649
|
+
var permissionStatus = null;
|
|
3650
|
+
var onChange = function() {
|
|
3651
|
+
if (!mounted) {
|
|
3652
|
+
return;
|
|
3653
|
+
}
|
|
3654
|
+
setState(function() {
|
|
3655
|
+
var _permissionStatus_state;
|
|
3656
|
+
return (_permissionStatus_state = permissionStatus === null || permissionStatus === void 0 ? void 0 : permissionStatus.state) !== null && _permissionStatus_state !== void 0 ? _permissionStatus_state : "";
|
|
3657
|
+
});
|
|
3658
|
+
};
|
|
3659
|
+
navigator.permissions.query(permissionDesc).then(function(status) {
|
|
3660
|
+
permissionStatus = status;
|
|
3661
|
+
on(permissionStatus, "change", onChange);
|
|
3662
|
+
onChange();
|
|
3663
|
+
}).catch(noop);
|
|
3664
|
+
return function() {
|
|
3665
|
+
permissionStatus && off(permissionStatus, "change", onChange);
|
|
3666
|
+
mounted = false;
|
|
3667
|
+
permissionStatus = null;
|
|
3668
|
+
};
|
|
3669
|
+
}, [
|
|
3670
|
+
permissionDesc
|
|
3671
|
+
]);
|
|
3672
|
+
return state;
|
|
3673
|
+
};
|
|
3613
3674
|
// src/components/threads/AudioThread/Root/lib/blobToData.ts
|
|
3614
3675
|
var blobToData = function(blob) {
|
|
3615
3676
|
return new Promise(function(resolve) {
|
|
@@ -3649,19 +3710,40 @@ var useStatus = function(param) {
|
|
|
3649
3710
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
3650
3711
|
import dayjs3 from "dayjs";
|
|
3651
3712
|
import { useAudioCapture } from "use-audio-capture";
|
|
3652
|
-
import { useMemo as useMemo11, useRef as
|
|
3713
|
+
import { useMemo as useMemo11, useRef as useRef7, useState as useState5, useCallback as useCallback4, useEffect as useEffect7 } from "react";
|
|
3653
3714
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
3654
|
-
|
|
3715
|
+
// src/hooks/misc/useInterval.ts
|
|
3716
|
+
import { useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
3717
|
+
var useInterval = function(callback, delay) {
|
|
3718
|
+
var savedCallback = useRef6(function() {});
|
|
3719
|
+
useEffect6(function() {
|
|
3720
|
+
savedCallback.current = callback;
|
|
3721
|
+
});
|
|
3722
|
+
useEffect6(function() {
|
|
3723
|
+
if (delay !== null) {
|
|
3724
|
+
var interval = setInterval(function() {
|
|
3725
|
+
return savedCallback.current();
|
|
3726
|
+
}, delay || 0);
|
|
3727
|
+
return function() {
|
|
3728
|
+
return clearInterval(interval);
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
return void 0;
|
|
3732
|
+
}, [
|
|
3733
|
+
delay
|
|
3734
|
+
]);
|
|
3735
|
+
};
|
|
3736
|
+
// src/hooks/audioThreads/useRecorder/index.ts
|
|
3655
3737
|
var useRecorder = function(param) {
|
|
3656
3738
|
var isStopOnSilence = param.isStopOnSilence, onStart = param.onStart, onStop = param.onStop;
|
|
3657
|
-
var
|
|
3658
|
-
var
|
|
3659
|
-
var
|
|
3660
|
-
var
|
|
3739
|
+
var _useState5 = _sliced_to_array(useState5(null), 2), silenceStart = _useState5[0], setSilenceStart = _useState5[1];
|
|
3740
|
+
var _useState51 = _sliced_to_array(useState5(null), 2), noiseStart = _useState51[0], setNoiseStart = _useState51[1];
|
|
3741
|
+
var _useState52 = _sliced_to_array(useState5(null), 2), mediaStream = _useState52[0], setMediaStream = _useState52[1];
|
|
3742
|
+
var _useState53 = _sliced_to_array(useState5("idle"), 2), status = _useState53[0], setStatus = _useState53[1];
|
|
3661
3743
|
var startAudioPlayer = useAudioPlayer();
|
|
3662
3744
|
var endAudioPlayer = useAudioPlayer();
|
|
3663
|
-
var
|
|
3664
|
-
|
|
3745
|
+
var _useState54 = _sliced_to_array(useState5(false), 2), isLoaded = _useState54[0], setIsLoaded = _useState54[1];
|
|
3746
|
+
useEffect7(function() {
|
|
3665
3747
|
if (isLoaded) return;
|
|
3666
3748
|
setIsLoaded(true);
|
|
3667
3749
|
}, [
|
|
@@ -3719,9 +3801,9 @@ var useRecorder = function(param) {
|
|
|
3719
3801
|
setNoiseStart(null);
|
|
3720
3802
|
}
|
|
3721
3803
|
});
|
|
3722
|
-
var
|
|
3723
|
-
var isInited =
|
|
3724
|
-
|
|
3804
|
+
var _useState55 = _sliced_to_array(useState5(null), 2), audioEngine = _useState55[0], setAudioEngine = _useState55[1];
|
|
3805
|
+
var isInited = useRef7(false);
|
|
3806
|
+
useEffect7(function() {
|
|
3725
3807
|
if (!mediaStream) return;
|
|
3726
3808
|
if (isInited.current) return;
|
|
3727
3809
|
isInited.current = true;
|
|
@@ -3774,7 +3856,7 @@ var useRecorder = function(param) {
|
|
|
3774
3856
|
setNoiseStart,
|
|
3775
3857
|
setSilenceStart
|
|
3776
3858
|
]);
|
|
3777
|
-
|
|
3859
|
+
useEffect7(function() {
|
|
3778
3860
|
if (!isStopOnSilence) return;
|
|
3779
3861
|
requestAnimationFrame(function() {
|
|
3780
3862
|
return handleSilence();
|
|
@@ -3797,7 +3879,7 @@ var useRecorder = function(param) {
|
|
|
3797
3879
|
});
|
|
3798
3880
|
};
|
|
3799
3881
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
3800
|
-
import { useMemo as useMemo12, useRef as
|
|
3882
|
+
import { useMemo as useMemo12, useRef as useRef8, useState as useState6, useEffect as useEffect8 } from "react";
|
|
3801
3883
|
import nlp from "compromise";
|
|
3802
3884
|
import { Howler } from "howler";
|
|
3803
3885
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
@@ -3835,13 +3917,13 @@ var getMessageSentences = function(param) {
|
|
|
3835
3917
|
};
|
|
3836
3918
|
var useMessageAudio = function(param) {
|
|
3837
3919
|
var onEnd = param.onEnd;
|
|
3838
|
-
var
|
|
3839
|
-
var
|
|
3840
|
-
var
|
|
3920
|
+
var _useState6 = _sliced_to_array(useState6(false), 2), isAudioPlayed = _useState6[0], setIsAudioPlayed = _useState6[1];
|
|
3921
|
+
var _useState61 = _sliced_to_array(useState6([]), 2), stoppedMessageIds = _useState61[0], setStoppedMessageIds = _useState61[1];
|
|
3922
|
+
var _useState62 = _sliced_to_array(useState6([]), 2), playedMessageSentences = _useState62[0], setPlayedMessageSentences = _useState62[1];
|
|
3841
3923
|
var audioPlayer = useAudioPlayer2();
|
|
3842
3924
|
var nextAudioPlayer = useAudioPlayer2();
|
|
3843
3925
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
3844
|
-
var
|
|
3926
|
+
var _useState63 = _sliced_to_array(useState6(false), 2), isPlaying = _useState63[0], setIsPlaying = _useState63[1];
|
|
3845
3927
|
var latestMessageProps = useLatestMessage();
|
|
3846
3928
|
var unplayedMessageSentences = useMemo12(function() {
|
|
3847
3929
|
if (!latestMessageProps.latestMessage) return [];
|
|
@@ -3864,7 +3946,7 @@ var useMessageAudio = function(param) {
|
|
|
3864
3946
|
latestMessageProps,
|
|
3865
3947
|
playedMessageSentences
|
|
3866
3948
|
]);
|
|
3867
|
-
|
|
3949
|
+
useEffect8(function() {
|
|
3868
3950
|
if (isPlaying) return;
|
|
3869
3951
|
if (audioPlayer.playing) return;
|
|
3870
3952
|
if (!latestMessageProps.latestMessage) return;
|
|
@@ -3932,7 +4014,7 @@ var useMessageAudio = function(param) {
|
|
|
3932
4014
|
playedMessageSentences,
|
|
3933
4015
|
onEnd
|
|
3934
4016
|
]);
|
|
3935
|
-
|
|
4017
|
+
useEffect8(function() {
|
|
3936
4018
|
if (isHtmlAudioSupported) {
|
|
3937
4019
|
var _Howler__howls___sounds_, _Howler__howls_;
|
|
3938
4020
|
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;
|
|
@@ -3941,9 +4023,9 @@ var useMessageAudio = function(param) {
|
|
|
3941
4023
|
}, [
|
|
3942
4024
|
audioPlayer
|
|
3943
4025
|
]);
|
|
3944
|
-
var
|
|
3945
|
-
var isAudioEngineInited =
|
|
3946
|
-
|
|
4026
|
+
var _useState64 = _sliced_to_array(useState6(null), 2), audioEngine = _useState64[0], setAudioEngine = _useState64[1];
|
|
4027
|
+
var isAudioEngineInited = useRef8(false);
|
|
4028
|
+
useEffect8(function() {
|
|
3947
4029
|
if (!audioPlayer.playing) return;
|
|
3948
4030
|
if (isAudioEngineInited.current) return;
|
|
3949
4031
|
isAudioEngineInited.current = true;
|
|
@@ -4060,7 +4142,7 @@ var Root12 = function(param) {
|
|
|
4060
4142
|
});
|
|
4061
4143
|
};
|
|
4062
4144
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
4063
|
-
import { useContext as useContext15, useState as
|
|
4145
|
+
import { useContext as useContext15, useState as useState8, useCallback as useCallback6, useEffect as useEffect10 } from "react";
|
|
4064
4146
|
import _9 from "lodash";
|
|
4065
4147
|
import { Flex as Flex27 } from "@radix-ui/themes";
|
|
4066
4148
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
@@ -4071,13 +4153,13 @@ var useAudioThreadContext = function() {
|
|
|
4071
4153
|
// src/components/threads/AudioThread/BarsVisualizer/index.tsx
|
|
4072
4154
|
import _8 from "lodash";
|
|
4073
4155
|
import { Flex as Flex26, Grid } from "@radix-ui/themes";
|
|
4074
|
-
import { useState as
|
|
4156
|
+
import { useState as useState7, useEffect as useEffect9, useCallback as useCallback5 } from "react";
|
|
4075
4157
|
import { cluster } from "radash";
|
|
4076
4158
|
import { jsx as jsx67 } from "react/jsx-runtime";
|
|
4077
4159
|
var barCount = 4;
|
|
4078
4160
|
var BarsVisualizer = function(param) {
|
|
4079
4161
|
var visualizationAnalyser = param.visualizationAnalyser, backgroundColor = param.backgroundColor, height = param.height, barWidth = param.barWidth;
|
|
4080
|
-
var
|
|
4162
|
+
var _useState7 = _sliced_to_array(useState7([]), 2), barHeights = _useState7[0], setBarHeights = _useState7[1];
|
|
4081
4163
|
var draw = useCallback5(function(param) {
|
|
4082
4164
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
4083
4165
|
if (!visualizationAnalyser2) {
|
|
@@ -4096,7 +4178,7 @@ var BarsVisualizer = function(param) {
|
|
|
4096
4178
|
});
|
|
4097
4179
|
});
|
|
4098
4180
|
}, []);
|
|
4099
|
-
|
|
4181
|
+
useEffect9(function() {
|
|
4100
4182
|
draw({
|
|
4101
4183
|
visualizationAnalyser: visualizationAnalyser
|
|
4102
4184
|
});
|
|
@@ -4137,7 +4219,7 @@ import { jsx as jsx68, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
|
4137
4219
|
var Visualization = function() {
|
|
4138
4220
|
var audioThreadContext = useAudioThreadContext();
|
|
4139
4221
|
var assistantNameContext = useContext15(AssistantNameContext);
|
|
4140
|
-
var
|
|
4222
|
+
var _useState8 = _sliced_to_array(useState8(0), 2), scale = _useState8[0], setScale = _useState8[1];
|
|
4141
4223
|
var draw = useCallback6(function(param) {
|
|
4142
4224
|
var visualizationAnalyser = param.visualizationAnalyser;
|
|
4143
4225
|
if (!visualizationAnalyser) {
|
|
@@ -4153,7 +4235,7 @@ var Visualization = function() {
|
|
|
4153
4235
|
});
|
|
4154
4236
|
});
|
|
4155
4237
|
}, []);
|
|
4156
|
-
|
|
4238
|
+
useEffect10(function() {
|
|
4157
4239
|
draw({
|
|
4158
4240
|
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser
|
|
4159
4241
|
});
|