@superinterface/react 2.17.5 → 2.18.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 +170 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -8
- package/dist/index.d.ts +143 -8
- package/dist/index.js +116 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -433,6 +433,9 @@ __export(src_exports, {
|
|
|
433
433
|
UserAvatarContext: function() {
|
|
434
434
|
return UserAvatarContext;
|
|
435
435
|
},
|
|
436
|
+
useAssistant: function() {
|
|
437
|
+
return useAssistant;
|
|
438
|
+
},
|
|
436
439
|
useComponents: function() {
|
|
437
440
|
return useComponents;
|
|
438
441
|
},
|
|
@@ -3394,25 +3397,123 @@ var import_react39 = require("react");
|
|
|
3394
3397
|
var useMessageContext = function() {
|
|
3395
3398
|
return (0, import_react39.useContext)(MessageContext);
|
|
3396
3399
|
};
|
|
3400
|
+
// src/hooks/assistants/useAssistant/index.ts
|
|
3401
|
+
var import_react40 = require("react");
|
|
3402
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
3403
|
+
// src/hooks/assistants/useAssistant/lib/queryOptions/index.ts
|
|
3404
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
3405
|
+
// src/hooks/assistants/useAssistant/lib/queryOptions/queryFn.ts
|
|
3406
|
+
var queryFn = function(param) {
|
|
3407
|
+
var superinterfaceContext = param.superinterfaceContext;
|
|
3408
|
+
return function() {
|
|
3409
|
+
var _ref = _async_to_generator(function(param) {
|
|
3410
|
+
var queryKey, _queryKey, _key, assistantId, params;
|
|
3411
|
+
return _ts_generator(this, function(_state) {
|
|
3412
|
+
queryKey = param.queryKey;
|
|
3413
|
+
_queryKey = _sliced_to_array(queryKey, 2), _key = _queryKey[0], assistantId = _queryKey[1].assistantId;
|
|
3414
|
+
params = new URLSearchParams({
|
|
3415
|
+
publicApiKey: superinterfaceContext.variables.publicApiKey
|
|
3416
|
+
});
|
|
3417
|
+
return [
|
|
3418
|
+
2,
|
|
3419
|
+
fetch("".concat(superinterfaceContext.baseUrl, "/assistants/").concat(assistantId, "?").concat(params)).then(function() {
|
|
3420
|
+
var _ref = _async_to_generator(function(response) {
|
|
3421
|
+
var errorResponse, error;
|
|
3422
|
+
return _ts_generator(this, function(_state) {
|
|
3423
|
+
switch(_state.label){
|
|
3424
|
+
case 0:
|
|
3425
|
+
if (!(response.status !== 200)) return [
|
|
3426
|
+
3,
|
|
3427
|
+
4
|
|
3428
|
+
];
|
|
3429
|
+
_state.label = 1;
|
|
3430
|
+
case 1:
|
|
3431
|
+
_state.trys.push([
|
|
3432
|
+
1,
|
|
3433
|
+
3,
|
|
3434
|
+
,
|
|
3435
|
+
4
|
|
3436
|
+
]);
|
|
3437
|
+
return [
|
|
3438
|
+
4,
|
|
3439
|
+
response.json()
|
|
3440
|
+
];
|
|
3441
|
+
case 2:
|
|
3442
|
+
errorResponse = _state.sent();
|
|
3443
|
+
throw new Error(errorResponse.error);
|
|
3444
|
+
case 3:
|
|
3445
|
+
error = _state.sent();
|
|
3446
|
+
throw new Error("Failed to fetch");
|
|
3447
|
+
case 4:
|
|
3448
|
+
return [
|
|
3449
|
+
2,
|
|
3450
|
+
response.json()
|
|
3451
|
+
];
|
|
3452
|
+
}
|
|
3453
|
+
});
|
|
3454
|
+
});
|
|
3455
|
+
return function(response) {
|
|
3456
|
+
return _ref.apply(this, arguments);
|
|
3457
|
+
};
|
|
3458
|
+
}())
|
|
3459
|
+
];
|
|
3460
|
+
});
|
|
3461
|
+
});
|
|
3462
|
+
return function(_) {
|
|
3463
|
+
return _ref.apply(this, arguments);
|
|
3464
|
+
};
|
|
3465
|
+
}();
|
|
3466
|
+
};
|
|
3467
|
+
// src/hooks/assistants/useAssistant/lib/queryOptions/index.ts
|
|
3468
|
+
var queryOptions2 = function(param) {
|
|
3469
|
+
var assistantId = param.assistantId, superinterfaceContext = param.superinterfaceContext;
|
|
3470
|
+
return (0, import_react_query7.queryOptions)({
|
|
3471
|
+
queryKey: [
|
|
3472
|
+
"assistants",
|
|
3473
|
+
{
|
|
3474
|
+
assistantId: assistantId
|
|
3475
|
+
}
|
|
3476
|
+
],
|
|
3477
|
+
queryFn: queryFn({
|
|
3478
|
+
superinterfaceContext: superinterfaceContext
|
|
3479
|
+
})
|
|
3480
|
+
});
|
|
3481
|
+
};
|
|
3482
|
+
// src/hooks/assistants/useAssistant/index.ts
|
|
3483
|
+
var useAssistant = function(param) {
|
|
3484
|
+
var assistantId = param.assistantId;
|
|
3485
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
3486
|
+
var props = (0, import_react_query8.useQuery)(queryOptions2({
|
|
3487
|
+
assistantId: assistantId,
|
|
3488
|
+
superinterfaceContext: superinterfaceContext
|
|
3489
|
+
}));
|
|
3490
|
+
return (0, import_react40.useMemo)(function() {
|
|
3491
|
+
return _object_spread_props(_object_spread({}, props), {
|
|
3492
|
+
assistant: props.data ? props.data.assistant : null
|
|
3493
|
+
});
|
|
3494
|
+
}, [
|
|
3495
|
+
props
|
|
3496
|
+
]);
|
|
3497
|
+
};
|
|
3397
3498
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
3398
|
-
var
|
|
3499
|
+
var import_react43 = require("react");
|
|
3399
3500
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
3400
|
-
var
|
|
3401
|
-
var ThreadDialogContext = (0,
|
|
3501
|
+
var import_react41 = require("react");
|
|
3502
|
+
var ThreadDialogContext = (0, import_react41.createContext)({
|
|
3402
3503
|
isOpen: false,
|
|
3403
3504
|
setIsOpen: function() {}
|
|
3404
3505
|
});
|
|
3405
3506
|
// src/hooks/threads/useThreadDialogContext/index.ts
|
|
3406
|
-
var
|
|
3507
|
+
var import_react42 = require("react");
|
|
3407
3508
|
var useThreadDialogContext = function() {
|
|
3408
|
-
return (0,
|
|
3509
|
+
return (0, import_react42.useContext)(ThreadDialogContext);
|
|
3409
3510
|
};
|
|
3410
3511
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
3411
3512
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
3412
3513
|
var Provider3 = function(param) {
|
|
3413
3514
|
var children = param.children;
|
|
3414
3515
|
var threadDialogContext = useThreadDialogContext();
|
|
3415
|
-
var _ref = _sliced_to_array((0,
|
|
3516
|
+
var _ref = _sliced_to_array((0, import_react43.useState)(threadDialogContext.isOpen), 2), isOpen = _ref[0], setIsOpen = _ref[1];
|
|
3416
3517
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ThreadDialogContext.Provider, {
|
|
3417
3518
|
value: {
|
|
3418
3519
|
isOpen: isOpen,
|
|
@@ -3422,7 +3523,7 @@ var Provider3 = function(param) {
|
|
|
3422
3523
|
});
|
|
3423
3524
|
};
|
|
3424
3525
|
// src/components/toasts/ToastsProvider/index.tsx
|
|
3425
|
-
var
|
|
3526
|
+
var import_react44 = require("react");
|
|
3426
3527
|
var Toast2 = __toESM(require("@radix-ui/react-toast"), 1);
|
|
3427
3528
|
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
3428
3529
|
var Toast = __toESM(require("@radix-ui/react-toast"), 1);
|
|
@@ -3461,8 +3562,8 @@ var CustomToast = function(param) {
|
|
|
3461
3562
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
3462
3563
|
var ToastsProvider = function(param) {
|
|
3463
3564
|
var children = param.children;
|
|
3464
|
-
var _ref = _sliced_to_array((0,
|
|
3465
|
-
var addToast = (0,
|
|
3565
|
+
var _ref = _sliced_to_array((0, import_react44.useState)([]), 2), toasts = _ref[0], setToasts = _ref[1];
|
|
3566
|
+
var addToast = (0, import_react44.useCallback)(function(toast) {
|
|
3466
3567
|
return setToasts(function(prevToasts) {
|
|
3467
3568
|
return _to_consumable_array(prevToasts).concat([
|
|
3468
3569
|
toast
|
|
@@ -3709,8 +3810,8 @@ ThreadDialog.Content = Content4;
|
|
|
3709
3810
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
3710
3811
|
var import_themes45 = require("@radix-ui/themes");
|
|
3711
3812
|
// src/contexts/threads/AudioThreadContext/index.ts
|
|
3712
|
-
var
|
|
3713
|
-
var AudioThreadContext = (0,
|
|
3813
|
+
var import_react45 = require("react");
|
|
3814
|
+
var AudioThreadContext = (0, import_react45.createContext)({
|
|
3714
3815
|
status: "idle",
|
|
3715
3816
|
recorderProps: {
|
|
3716
3817
|
status: "idle",
|
|
@@ -3766,7 +3867,7 @@ var AudioThreadContext = (0, import_react44.createContext)({
|
|
|
3766
3867
|
}
|
|
3767
3868
|
});
|
|
3768
3869
|
// src/hooks/misc/usePermission/index.ts
|
|
3769
|
-
var
|
|
3870
|
+
var import_react46 = require("react");
|
|
3770
3871
|
// src/hooks/misc/usePermission/util.ts
|
|
3771
3872
|
var noop = function() {};
|
|
3772
3873
|
function on(obj) {
|
|
@@ -3789,8 +3890,8 @@ function off(obj) {
|
|
|
3789
3890
|
}
|
|
3790
3891
|
// src/hooks/misc/usePermission/index.ts
|
|
3791
3892
|
var usePermission = function(permissionDesc) {
|
|
3792
|
-
var _ref = _sliced_to_array((0,
|
|
3793
|
-
(0,
|
|
3893
|
+
var _ref = _sliced_to_array((0, import_react46.useState)(""), 2), state = _ref[0], setState = _ref[1];
|
|
3894
|
+
(0, import_react46.useEffect)(function() {
|
|
3794
3895
|
var mounted = true;
|
|
3795
3896
|
var permissionStatus = null;
|
|
3796
3897
|
var onChange = function() {
|
|
@@ -3828,11 +3929,11 @@ var blobToData = function(blob) {
|
|
|
3828
3929
|
});
|
|
3829
3930
|
};
|
|
3830
3931
|
// src/hooks/audioThreads/useStatus/index.ts
|
|
3831
|
-
var
|
|
3932
|
+
var import_react47 = require("react");
|
|
3832
3933
|
var useStatus = function(param) {
|
|
3833
3934
|
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
|
|
3834
3935
|
var latestMessageProps = useLatestMessage();
|
|
3835
|
-
var status = (0,
|
|
3936
|
+
var status = (0, import_react47.useMemo)(function() {
|
|
3836
3937
|
var _latestMessageProps_latestMessage;
|
|
3837
3938
|
if (recorderProps.status === "recording") return "recording";
|
|
3838
3939
|
if (createMessageProps.isPending) return "creatingMessage";
|
|
@@ -3856,16 +3957,16 @@ var useStatus = function(param) {
|
|
|
3856
3957
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
3857
3958
|
var import_dayjs3 = __toESM(require("dayjs"), 1);
|
|
3858
3959
|
var import_use_audio_capture = require("use-audio-capture");
|
|
3859
|
-
var
|
|
3960
|
+
var import_react49 = require("react");
|
|
3860
3961
|
var import_react_use_audio_player = require("react-use-audio-player");
|
|
3861
3962
|
// src/hooks/misc/useInterval.ts
|
|
3862
|
-
var
|
|
3963
|
+
var import_react48 = require("react");
|
|
3863
3964
|
var useInterval = function(callback, delay) {
|
|
3864
|
-
var savedCallback = (0,
|
|
3865
|
-
(0,
|
|
3965
|
+
var savedCallback = (0, import_react48.useRef)(function() {});
|
|
3966
|
+
(0, import_react48.useEffect)(function() {
|
|
3866
3967
|
savedCallback.current = callback;
|
|
3867
3968
|
});
|
|
3868
|
-
(0,
|
|
3969
|
+
(0, import_react48.useEffect)(function() {
|
|
3869
3970
|
if (delay !== null) {
|
|
3870
3971
|
var interval = setInterval(function() {
|
|
3871
3972
|
return savedCallback.current();
|
|
@@ -3882,14 +3983,14 @@ var useInterval = function(callback, delay) {
|
|
|
3882
3983
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
3883
3984
|
var useRecorder = function(param) {
|
|
3884
3985
|
var isStopOnSilence = param.isStopOnSilence, onStart = param.onStart, onStop = param.onStop;
|
|
3885
|
-
var _ref = _sliced_to_array((0,
|
|
3886
|
-
var _ref1 = _sliced_to_array((0,
|
|
3887
|
-
var _ref2 = _sliced_to_array((0,
|
|
3888
|
-
var _ref3 = _sliced_to_array((0,
|
|
3986
|
+
var _ref = _sliced_to_array((0, import_react49.useState)(null), 2), silenceStart = _ref[0], setSilenceStart = _ref[1];
|
|
3987
|
+
var _ref1 = _sliced_to_array((0, import_react49.useState)(null), 2), noiseStart = _ref1[0], setNoiseStart = _ref1[1];
|
|
3988
|
+
var _ref2 = _sliced_to_array((0, import_react49.useState)(null), 2), mediaStream = _ref2[0], setMediaStream = _ref2[1];
|
|
3989
|
+
var _ref3 = _sliced_to_array((0, import_react49.useState)("idle"), 2), status = _ref3[0], setStatus = _ref3[1];
|
|
3889
3990
|
var startAudioPlayer = (0, import_react_use_audio_player.useAudioPlayer)();
|
|
3890
3991
|
var endAudioPlayer = (0, import_react_use_audio_player.useAudioPlayer)();
|
|
3891
|
-
var _ref4 = _sliced_to_array((0,
|
|
3892
|
-
(0,
|
|
3992
|
+
var _ref4 = _sliced_to_array((0, import_react49.useState)(false), 2), isLoaded = _ref4[0], setIsLoaded = _ref4[1];
|
|
3993
|
+
(0, import_react49.useEffect)(function() {
|
|
3893
3994
|
if (isLoaded) return;
|
|
3894
3995
|
setIsLoaded(true);
|
|
3895
3996
|
}, [
|
|
@@ -3947,9 +4048,9 @@ var useRecorder = function(param) {
|
|
|
3947
4048
|
setNoiseStart(null);
|
|
3948
4049
|
}
|
|
3949
4050
|
});
|
|
3950
|
-
var _ref5 = _sliced_to_array((0,
|
|
3951
|
-
var isInited = (0,
|
|
3952
|
-
(0,
|
|
4051
|
+
var _ref5 = _sliced_to_array((0, import_react49.useState)(null), 2), audioEngine = _ref5[0], setAudioEngine = _ref5[1];
|
|
4052
|
+
var isInited = (0, import_react49.useRef)(false);
|
|
4053
|
+
(0, import_react49.useEffect)(function() {
|
|
3953
4054
|
if (!mediaStream) return;
|
|
3954
4055
|
if (isInited.current) return;
|
|
3955
4056
|
isInited.current = true;
|
|
@@ -3962,7 +4063,7 @@ var useRecorder = function(param) {
|
|
|
3962
4063
|
isInited,
|
|
3963
4064
|
mediaStream
|
|
3964
4065
|
]);
|
|
3965
|
-
var visualizationAnalyser = (0,
|
|
4066
|
+
var visualizationAnalyser = (0, import_react49.useMemo)(function() {
|
|
3966
4067
|
if (!audioEngine) return null;
|
|
3967
4068
|
var result = audioEngine.audioContext.createAnalyser();
|
|
3968
4069
|
audioEngine.source.connect(result);
|
|
@@ -3970,7 +4071,7 @@ var useRecorder = function(param) {
|
|
|
3970
4071
|
}, [
|
|
3971
4072
|
audioEngine
|
|
3972
4073
|
]);
|
|
3973
|
-
var silenceAnalyser = (0,
|
|
4074
|
+
var silenceAnalyser = (0, import_react49.useMemo)(function() {
|
|
3974
4075
|
if (!audioEngine) return null;
|
|
3975
4076
|
var result = audioEngine.audioContext.createAnalyser();
|
|
3976
4077
|
result.minDecibels = -60;
|
|
@@ -3979,7 +4080,7 @@ var useRecorder = function(param) {
|
|
|
3979
4080
|
}, [
|
|
3980
4081
|
audioEngine
|
|
3981
4082
|
]);
|
|
3982
|
-
var handleSilence = (0,
|
|
4083
|
+
var handleSilence = (0, import_react49.useCallback)(function() {
|
|
3983
4084
|
if (!silenceAnalyser) return;
|
|
3984
4085
|
var frequencyData = new Uint8Array(silenceAnalyser.frequencyBinCount);
|
|
3985
4086
|
silenceAnalyser.getByteFrequencyData(frequencyData);
|
|
@@ -4002,7 +4103,7 @@ var useRecorder = function(param) {
|
|
|
4002
4103
|
setNoiseStart,
|
|
4003
4104
|
setSilenceStart
|
|
4004
4105
|
]);
|
|
4005
|
-
(0,
|
|
4106
|
+
(0, import_react49.useEffect)(function() {
|
|
4006
4107
|
if (!isStopOnSilence) return;
|
|
4007
4108
|
requestAnimationFrame(function() {
|
|
4008
4109
|
return handleSilence();
|
|
@@ -4025,7 +4126,7 @@ var useRecorder = function(param) {
|
|
|
4025
4126
|
});
|
|
4026
4127
|
};
|
|
4027
4128
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
4028
|
-
var
|
|
4129
|
+
var import_react50 = require("react");
|
|
4029
4130
|
var import_compromise = __toESM(require("compromise"), 1);
|
|
4030
4131
|
var import_howler = require("howler");
|
|
4031
4132
|
var import_react_use_audio_player2 = require("react-use-audio-player");
|
|
@@ -4063,15 +4164,15 @@ var getMessageSentences = function(param) {
|
|
|
4063
4164
|
};
|
|
4064
4165
|
var useMessageAudio = function(param) {
|
|
4065
4166
|
var onEnd = param.onEnd;
|
|
4066
|
-
var _ref = _sliced_to_array((0,
|
|
4067
|
-
var _ref1 = _sliced_to_array((0,
|
|
4068
|
-
var _ref2 = _sliced_to_array((0,
|
|
4167
|
+
var _ref = _sliced_to_array((0, import_react50.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
|
|
4168
|
+
var _ref1 = _sliced_to_array((0, import_react50.useState)([]), 2), stoppedMessageIds = _ref1[0], setStoppedMessageIds = _ref1[1];
|
|
4169
|
+
var _ref2 = _sliced_to_array((0, import_react50.useState)([]), 2), playedMessageSentences = _ref2[0], setPlayedMessageSentences = _ref2[1];
|
|
4069
4170
|
var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
|
|
4070
4171
|
var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
|
|
4071
4172
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
4072
|
-
var _ref3 = _sliced_to_array((0,
|
|
4173
|
+
var _ref3 = _sliced_to_array((0, import_react50.useState)(false), 2), isPlaying = _ref3[0], setIsPlaying = _ref3[1];
|
|
4073
4174
|
var latestMessageProps = useLatestMessage();
|
|
4074
|
-
var unplayedMessageSentences = (0,
|
|
4175
|
+
var unplayedMessageSentences = (0, import_react50.useMemo)(function() {
|
|
4075
4176
|
if (!latestMessageProps.latestMessage) return [];
|
|
4076
4177
|
if (latestMessageProps.latestMessage.role !== "assistant") return [];
|
|
4077
4178
|
if (stoppedMessageIds.includes(latestMessageProps.latestMessage.id)) return [];
|
|
@@ -4092,7 +4193,7 @@ var useMessageAudio = function(param) {
|
|
|
4092
4193
|
latestMessageProps,
|
|
4093
4194
|
playedMessageSentences
|
|
4094
4195
|
]);
|
|
4095
|
-
(0,
|
|
4196
|
+
(0, import_react50.useEffect)(function() {
|
|
4096
4197
|
if (isPlaying) return;
|
|
4097
4198
|
if (audioPlayer.playing) return;
|
|
4098
4199
|
if (!latestMessageProps.latestMessage) return;
|
|
@@ -4160,7 +4261,7 @@ var useMessageAudio = function(param) {
|
|
|
4160
4261
|
playedMessageSentences,
|
|
4161
4262
|
onEnd
|
|
4162
4263
|
]);
|
|
4163
|
-
(0,
|
|
4264
|
+
(0, import_react50.useEffect)(function() {
|
|
4164
4265
|
if (isHtmlAudioSupported) {
|
|
4165
4266
|
var _import_howler_Howler__howls___sounds_, _import_howler_Howler__howls_, _import_howler_Howler;
|
|
4166
4267
|
if (!((_import_howler_Howler = import_howler.Howler) === null || _import_howler_Howler === void 0 ? void 0 : (_import_howler_Howler__howls_ = _import_howler_Howler._howls[0]) === null || _import_howler_Howler__howls_ === void 0 ? void 0 : (_import_howler_Howler__howls___sounds_ = _import_howler_Howler__howls_._sounds[0]) === null || _import_howler_Howler__howls___sounds_ === void 0 ? void 0 : _import_howler_Howler__howls___sounds_._node)) return;
|
|
@@ -4169,9 +4270,9 @@ var useMessageAudio = function(param) {
|
|
|
4169
4270
|
}, [
|
|
4170
4271
|
audioPlayer
|
|
4171
4272
|
]);
|
|
4172
|
-
var _ref4 = _sliced_to_array((0,
|
|
4173
|
-
var isAudioEngineInited = (0,
|
|
4174
|
-
(0,
|
|
4273
|
+
var _ref4 = _sliced_to_array((0, import_react50.useState)(null), 2), audioEngine = _ref4[0], setAudioEngine = _ref4[1];
|
|
4274
|
+
var isAudioEngineInited = (0, import_react50.useRef)(false);
|
|
4275
|
+
(0, import_react50.useEffect)(function() {
|
|
4175
4276
|
if (!audioPlayer.playing) return;
|
|
4176
4277
|
if (isAudioEngineInited.current) return;
|
|
4177
4278
|
isAudioEngineInited.current = true;
|
|
@@ -4192,7 +4293,7 @@ var useMessageAudio = function(param) {
|
|
|
4192
4293
|
audioPlayer,
|
|
4193
4294
|
isAudioEngineInited
|
|
4194
4295
|
]);
|
|
4195
|
-
var visualizationAnalyser = (0,
|
|
4296
|
+
var visualizationAnalyser = (0, import_react50.useMemo)(function() {
|
|
4196
4297
|
if (!audioEngine) return null;
|
|
4197
4298
|
var result = audioEngine.audioContext.createAnalyser();
|
|
4198
4299
|
audioEngine.source.connect(audioEngine.audioContext.destination);
|
|
@@ -4201,7 +4302,7 @@ var useMessageAudio = function(param) {
|
|
|
4201
4302
|
}, [
|
|
4202
4303
|
audioEngine
|
|
4203
4304
|
]);
|
|
4204
|
-
var isPending = (0,
|
|
4305
|
+
var isPending = (0, import_react50.useMemo)(function() {
|
|
4205
4306
|
return isPlaying || unplayedMessageSentences.length > 0;
|
|
4206
4307
|
}, [
|
|
4207
4308
|
isPlaying,
|
|
@@ -4288,25 +4389,25 @@ var Root12 = function(param) {
|
|
|
4288
4389
|
});
|
|
4289
4390
|
};
|
|
4290
4391
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
4291
|
-
var
|
|
4392
|
+
var import_react53 = require("react");
|
|
4292
4393
|
var import_lodash9 = __toESM(require("lodash"), 1);
|
|
4293
4394
|
var import_themes47 = require("@radix-ui/themes");
|
|
4294
4395
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
4295
|
-
var
|
|
4396
|
+
var import_react51 = require("react");
|
|
4296
4397
|
var useAudioThreadContext = function() {
|
|
4297
|
-
return (0,
|
|
4398
|
+
return (0, import_react51.useContext)(AudioThreadContext);
|
|
4298
4399
|
};
|
|
4299
4400
|
// src/components/threads/AudioThread/BarsVisualizer/index.tsx
|
|
4300
4401
|
var import_lodash8 = __toESM(require("lodash"), 1);
|
|
4301
4402
|
var import_themes46 = require("@radix-ui/themes");
|
|
4302
|
-
var
|
|
4403
|
+
var import_react52 = require("react");
|
|
4303
4404
|
var import_radash16 = require("radash");
|
|
4304
4405
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
4305
4406
|
var barCount = 4;
|
|
4306
4407
|
var BarsVisualizer = function(param) {
|
|
4307
4408
|
var visualizationAnalyser = param.visualizationAnalyser, backgroundColor = param.backgroundColor, height = param.height, barWidth = param.barWidth;
|
|
4308
|
-
var _ref = _sliced_to_array((0,
|
|
4309
|
-
var draw = (0,
|
|
4409
|
+
var _ref = _sliced_to_array((0, import_react52.useState)([]), 2), barHeights = _ref[0], setBarHeights = _ref[1];
|
|
4410
|
+
var draw = (0, import_react52.useCallback)(function(param) {
|
|
4310
4411
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
4311
4412
|
if (!visualizationAnalyser2) {
|
|
4312
4413
|
setBarHeights(Array(barCount).fill(0));
|
|
@@ -4324,7 +4425,7 @@ var BarsVisualizer = function(param) {
|
|
|
4324
4425
|
});
|
|
4325
4426
|
});
|
|
4326
4427
|
}, []);
|
|
4327
|
-
(0,
|
|
4428
|
+
(0, import_react52.useEffect)(function() {
|
|
4328
4429
|
draw({
|
|
4329
4430
|
visualizationAnalyser: visualizationAnalyser
|
|
4330
4431
|
});
|
|
@@ -4364,9 +4465,9 @@ var BarsVisualizer = function(param) {
|
|
|
4364
4465
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
4365
4466
|
var Visualization = function() {
|
|
4366
4467
|
var audioThreadContext = useAudioThreadContext();
|
|
4367
|
-
var assistantNameContext = (0,
|
|
4368
|
-
var _ref = _sliced_to_array((0,
|
|
4369
|
-
var draw = (0,
|
|
4468
|
+
var assistantNameContext = (0, import_react53.useContext)(AssistantNameContext);
|
|
4469
|
+
var _ref = _sliced_to_array((0, import_react53.useState)(0), 2), scale = _ref[0], setScale = _ref[1];
|
|
4470
|
+
var draw = (0, import_react53.useCallback)(function(param) {
|
|
4370
4471
|
var visualizationAnalyser = param.visualizationAnalyser;
|
|
4371
4472
|
if (!visualizationAnalyser) {
|
|
4372
4473
|
setScale(1);
|
|
@@ -4381,7 +4482,7 @@ var Visualization = function() {
|
|
|
4381
4482
|
});
|
|
4382
4483
|
});
|
|
4383
4484
|
}, []);
|
|
4384
|
-
(0,
|
|
4485
|
+
(0, import_react53.useEffect)(function() {
|
|
4385
4486
|
draw({
|
|
4386
4487
|
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser
|
|
4387
4488
|
});
|
|
@@ -4666,9 +4767,9 @@ AudioThreadDialog.Root = Root9;
|
|
|
4666
4767
|
AudioThreadDialog.Trigger = Trigger;
|
|
4667
4768
|
AudioThreadDialog.Content = Content4;
|
|
4668
4769
|
// src/components/suggestions/Suggestions/index.tsx
|
|
4669
|
-
var
|
|
4770
|
+
var import_react55 = require("react");
|
|
4670
4771
|
// src/components/suggestions/Suggestions/Content.tsx
|
|
4671
|
-
var
|
|
4772
|
+
var import_react54 = require("react");
|
|
4672
4773
|
var import_radash17 = require("radash");
|
|
4673
4774
|
var import_react_children_utilities = require("react-children-utilities");
|
|
4674
4775
|
var import_themes52 = require("@radix-ui/themes");
|
|
@@ -4725,7 +4826,7 @@ var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
|
4725
4826
|
var Content6 = function(param) {
|
|
4726
4827
|
var children = param.children;
|
|
4727
4828
|
var isMutatingMessage = useIsMutatingMessage();
|
|
4728
|
-
var suggestions = (0,
|
|
4829
|
+
var suggestions = (0, import_react54.useMemo)(function() {
|
|
4729
4830
|
return (0, import_react_children_utilities.onlyText)(children).split(/\r?\n/).filter(function(c) {
|
|
4730
4831
|
return !(0, import_radash17.isEmpty)(c);
|
|
4731
4832
|
}).map(function(c) {
|
|
@@ -4752,7 +4853,7 @@ var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
|
4752
4853
|
var Suggestions = function(param) {
|
|
4753
4854
|
var children = param.children;
|
|
4754
4855
|
var latestMessageProps = useLatestMessage();
|
|
4755
|
-
var isDisabled = (0,
|
|
4856
|
+
var isDisabled = (0, import_react55.useMemo)(function() {
|
|
4756
4857
|
var // @ts-ignore-next-line
|
|
4757
4858
|
_latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
4758
4859
|
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;
|
|
@@ -4767,14 +4868,14 @@ var Suggestions = function(param) {
|
|
|
4767
4868
|
};
|
|
4768
4869
|
Suggestions.Item = Item;
|
|
4769
4870
|
// src/components/markdown/MarkdownProvider/index.tsx
|
|
4770
|
-
var
|
|
4871
|
+
var import_react56 = require("react");
|
|
4771
4872
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
4772
4873
|
var MarkdownProvider = function(_param) {
|
|
4773
4874
|
var children = _param.children, rest = _object_without_properties(_param, [
|
|
4774
4875
|
"children"
|
|
4775
4876
|
]);
|
|
4776
4877
|
var prevMarkdownContext = useMarkdownContext();
|
|
4777
|
-
var value = (0,
|
|
4878
|
+
var value = (0, import_react56.useMemo)(function() {
|
|
4778
4879
|
return merge(prevMarkdownContext, rest);
|
|
4779
4880
|
}, [
|
|
4780
4881
|
rest,
|
|
@@ -4786,11 +4887,11 @@ var MarkdownProvider = function(_param) {
|
|
|
4786
4887
|
});
|
|
4787
4888
|
};
|
|
4788
4889
|
// src/components/components/ComponentsProvider.tsx
|
|
4789
|
-
var
|
|
4890
|
+
var import_react58 = require("react");
|
|
4790
4891
|
// src/hooks/components/useComponents.ts
|
|
4791
|
-
var
|
|
4892
|
+
var import_react57 = require("react");
|
|
4792
4893
|
var useComponents = function() {
|
|
4793
|
-
return (0,
|
|
4894
|
+
return (0, import_react57.useContext)(ComponentsContext);
|
|
4794
4895
|
};
|
|
4795
4896
|
// src/components/components/ComponentsProvider.tsx
|
|
4796
4897
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
@@ -4799,7 +4900,7 @@ var ComponentsProvider = function(_param) {
|
|
|
4799
4900
|
"children"
|
|
4800
4901
|
]);
|
|
4801
4902
|
var prevComponents = useComponents();
|
|
4802
|
-
var value = (0,
|
|
4903
|
+
var value = (0, import_react58.useMemo)(function() {
|
|
4803
4904
|
return merge(prevComponents, rest);
|
|
4804
4905
|
}, [
|
|
4805
4906
|
rest,
|
|
@@ -4828,6 +4929,7 @@ var ComponentsProvider = function(_param) {
|
|
|
4828
4929
|
ThreadDialog: ThreadDialog,
|
|
4829
4930
|
ThreadDialogContext: ThreadDialogContext,
|
|
4830
4931
|
UserAvatarContext: UserAvatarContext,
|
|
4932
|
+
useAssistant: useAssistant,
|
|
4831
4933
|
useComponents: useComponents,
|
|
4832
4934
|
useCreateMessage: useCreateMessage,
|
|
4833
4935
|
useLatestMessage: useLatestMessage,
|