@superinterface/react 2.13.0 → 2.13.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 +75 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2917,7 +2917,7 @@ var useRecorder = function(param) {
|
|
|
2917
2917
|
var silenceAnalyser = useMemo11(function() {
|
|
2918
2918
|
if (!audioEngine) return null;
|
|
2919
2919
|
var result = audioEngine.audioContext.createAnalyser();
|
|
2920
|
-
result.minDecibels = -
|
|
2920
|
+
result.minDecibels = -60;
|
|
2921
2921
|
audioEngine.source.connect(result);
|
|
2922
2922
|
return result;
|
|
2923
2923
|
}, [
|
|
@@ -2960,9 +2960,9 @@ var useRecorder = function(param) {
|
|
|
2960
2960
|
if (status !== "recording") return;
|
|
2961
2961
|
if (!silenceStart) return;
|
|
2962
2962
|
if (!noiseStart) return;
|
|
2963
|
-
if (!silenceStart.isBefore(dayjs2().subtract(1, "second"))) return;
|
|
2963
|
+
if (!silenceStart.isBefore(dayjs2().subtract(1.5, "second"))) return;
|
|
2964
2964
|
audioCaptureProps.stop();
|
|
2965
|
-
},
|
|
2965
|
+
}, 300);
|
|
2966
2966
|
return _object_spread_props(_object_spread({}, audioCaptureProps), {
|
|
2967
2967
|
status: status,
|
|
2968
2968
|
visualizationAnalyser: visualizationAnalyser
|
|
@@ -3232,7 +3232,8 @@ var Root8 = function(param) {
|
|
|
3232
3232
|
});
|
|
3233
3233
|
};
|
|
3234
3234
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
3235
|
-
import { useContext as useContext13 } from "react";
|
|
3235
|
+
import { useContext as useContext13, useState as useState6, useCallback as useCallback5, useEffect as useEffect7 } from "react";
|
|
3236
|
+
import _9 from "lodash";
|
|
3236
3237
|
import { Flex as Flex22 } from "@radix-ui/themes";
|
|
3237
3238
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
3238
3239
|
import { useContext as useContext12 } from "react";
|
|
@@ -3308,6 +3309,30 @@ import { jsx as jsx57, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
|
3308
3309
|
var Visualization = function() {
|
|
3309
3310
|
var audioThreadContext = useAudioThreadContext();
|
|
3310
3311
|
var assistantNameContext = useContext13(AssistantNameContext);
|
|
3312
|
+
var _useState6 = _sliced_to_array(useState6(0), 2), scale = _useState6[0], setScale = _useState6[1];
|
|
3313
|
+
var draw = useCallback5(function(param) {
|
|
3314
|
+
var visualizationAnalyser = param.visualizationAnalyser;
|
|
3315
|
+
if (!visualizationAnalyser) {
|
|
3316
|
+
setScale(1);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
var frequencyData = new Uint8Array(visualizationAnalyser.frequencyBinCount / 15);
|
|
3320
|
+
visualizationAnalyser.getByteFrequencyData(frequencyData);
|
|
3321
|
+
setScale(1 + _9.mean(frequencyData) / 255 / 10);
|
|
3322
|
+
requestAnimationFrame(function() {
|
|
3323
|
+
return draw({
|
|
3324
|
+
visualizationAnalyser: visualizationAnalyser
|
|
3325
|
+
});
|
|
3326
|
+
});
|
|
3327
|
+
}, []);
|
|
3328
|
+
useEffect7(function() {
|
|
3329
|
+
draw({
|
|
3330
|
+
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser
|
|
3331
|
+
});
|
|
3332
|
+
}, [
|
|
3333
|
+
draw,
|
|
3334
|
+
audioThreadContext
|
|
3335
|
+
]);
|
|
3311
3336
|
return /* @__PURE__ */ jsxs18(Flex22, {
|
|
3312
3337
|
direction: "column",
|
|
3313
3338
|
align: "center",
|
|
@@ -3322,7 +3347,8 @@ var Visualization = function() {
|
|
|
3322
3347
|
width: "200px",
|
|
3323
3348
|
style: {
|
|
3324
3349
|
backgroundColor: audioThreadContext.status === "playing" ? "var(--accent-4)" : "var(--gray-4)",
|
|
3325
|
-
borderRadius: "9999px"
|
|
3350
|
+
borderRadius: "9999px",
|
|
3351
|
+
scale: scale
|
|
3326
3352
|
},
|
|
3327
3353
|
children: /* @__PURE__ */ jsx57(BarsVisualizer, {
|
|
3328
3354
|
visualizationAnalyser: audioThreadContext.messageAudioProps.visualizationAnalyser,
|
|
@@ -3345,20 +3371,35 @@ var Visualization = function() {
|
|
|
3345
3371
|
]
|
|
3346
3372
|
});
|
|
3347
3373
|
};
|
|
3348
|
-
// src/components/threads/AudioThread/Status/
|
|
3374
|
+
// src/components/threads/AudioThread/Status/StatusMessages.tsx
|
|
3349
3375
|
import { Flex as Flex23, Text as Text7 } from "@radix-ui/themes";
|
|
3350
|
-
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
3351
|
-
var
|
|
3352
|
-
var
|
|
3353
|
-
return
|
|
3376
|
+
import { jsx as jsx58, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3377
|
+
var html = function(param) {
|
|
3378
|
+
var texts = param.texts;
|
|
3379
|
+
return "\n .status-messages-texts:after {\n content: '".concat(texts[0], "';\n animation: texts ").concat(texts.length * 5, "s linear infinite;\n }\n\n @keyframes texts {\n ").concat(texts.map(function(_10, i) {
|
|
3380
|
+
return "\n ".concat(i * 100 / texts.length, '% {\n content: "').concat(texts[i], '";\n }\n ');
|
|
3381
|
+
}).join(""), "\n }");
|
|
3382
|
+
};
|
|
3383
|
+
var StatusMessages = function(param) {
|
|
3384
|
+
var texts = param.texts;
|
|
3385
|
+
return /* @__PURE__ */ jsxs19(Flex23, {
|
|
3354
3386
|
justify: "center",
|
|
3355
|
-
pb: "
|
|
3356
|
-
children:
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3387
|
+
pb: "5",
|
|
3388
|
+
children: [
|
|
3389
|
+
/* @__PURE__ */ jsx58(Text7, {
|
|
3390
|
+
size: "2",
|
|
3391
|
+
weight: "regular",
|
|
3392
|
+
color: "gray",
|
|
3393
|
+
className: "status-messages-texts"
|
|
3394
|
+
}),
|
|
3395
|
+
/* @__PURE__ */ jsx58("style", {
|
|
3396
|
+
dangerouslySetInnerHTML: {
|
|
3397
|
+
__html: html({
|
|
3398
|
+
texts: texts
|
|
3399
|
+
})
|
|
3400
|
+
}
|
|
3401
|
+
})
|
|
3402
|
+
]
|
|
3362
3403
|
});
|
|
3363
3404
|
};
|
|
3364
3405
|
// src/components/threads/AudioThread/Status/index.tsx
|
|
@@ -3366,8 +3407,13 @@ import { jsx as jsx59 } from "react/jsx-runtime";
|
|
|
3366
3407
|
var Status = function() {
|
|
3367
3408
|
var audioThreadContext = useAudioThreadContext();
|
|
3368
3409
|
if (audioThreadContext.status === "recording") {
|
|
3369
|
-
return /* @__PURE__ */ jsx59(
|
|
3370
|
-
|
|
3410
|
+
return /* @__PURE__ */ jsx59(StatusMessages, {
|
|
3411
|
+
texts: [
|
|
3412
|
+
"Start speaking",
|
|
3413
|
+
"Listening",
|
|
3414
|
+
"Finish speaking to send",
|
|
3415
|
+
"Click the button below to send manually"
|
|
3416
|
+
]
|
|
3371
3417
|
});
|
|
3372
3418
|
}
|
|
3373
3419
|
if ([
|
|
@@ -3375,17 +3421,23 @@ var Status = function() {
|
|
|
3375
3421
|
"idle",
|
|
3376
3422
|
"playerPaused"
|
|
3377
3423
|
].includes(audioThreadContext.status)) {
|
|
3378
|
-
return /* @__PURE__ */ jsx59(
|
|
3379
|
-
|
|
3424
|
+
return /* @__PURE__ */ jsx59(StatusMessages, {
|
|
3425
|
+
texts: [
|
|
3426
|
+
"Click the button below to activate"
|
|
3427
|
+
]
|
|
3380
3428
|
});
|
|
3381
3429
|
}
|
|
3382
3430
|
if (audioThreadContext.status === "playing") {
|
|
3383
|
-
return /* @__PURE__ */ jsx59(
|
|
3384
|
-
|
|
3431
|
+
return /* @__PURE__ */ jsx59(StatusMessages, {
|
|
3432
|
+
texts: [
|
|
3433
|
+
"Click the button below to interrupt"
|
|
3434
|
+
]
|
|
3385
3435
|
});
|
|
3386
3436
|
}
|
|
3387
|
-
return /* @__PURE__ */ jsx59(
|
|
3388
|
-
|
|
3437
|
+
return /* @__PURE__ */ jsx59(StatusMessages, {
|
|
3438
|
+
texts: [
|
|
3439
|
+
"Thinking"
|
|
3440
|
+
]
|
|
3389
3441
|
});
|
|
3390
3442
|
};
|
|
3391
3443
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
@@ -3411,12 +3463,12 @@ var MicIcon = function(props) {
|
|
|
3411
3463
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
3412
3464
|
import { Flex as Flex24, IconButton as IconButton4 } from "@radix-ui/themes";
|
|
3413
3465
|
import { StopIcon as StopIcon2, PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
3414
|
-
import { jsx as jsx61, jsxs as
|
|
3466
|
+
import { jsx as jsx61, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3415
3467
|
var ActionButton = function() {
|
|
3416
3468
|
var audioThreadContext = useAudioThreadContext();
|
|
3417
3469
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
3418
3470
|
if (audioThreadContext.status === "recording") {
|
|
3419
|
-
return /* @__PURE__ */
|
|
3471
|
+
return /* @__PURE__ */ jsxs20(Flex24, {
|
|
3420
3472
|
align: "center",
|
|
3421
3473
|
children: [
|
|
3422
3474
|
/* @__PURE__ */ jsx61(Flex24, {
|
|
@@ -3487,14 +3539,14 @@ var ActionButton = function() {
|
|
|
3487
3539
|
});
|
|
3488
3540
|
};
|
|
3489
3541
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
3490
|
-
import { jsx as jsx62, jsxs as
|
|
3542
|
+
import { jsx as jsx62, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3491
3543
|
var Form = function() {
|
|
3492
3544
|
var audioThreadContext = useAudioThreadContext();
|
|
3493
|
-
return /* @__PURE__ */
|
|
3545
|
+
return /* @__PURE__ */ jsxs21(Flex25, {
|
|
3494
3546
|
direction: "column",
|
|
3495
3547
|
align: "center",
|
|
3496
3548
|
children: [
|
|
3497
|
-
/* @__PURE__ */
|
|
3549
|
+
/* @__PURE__ */ jsxs21(Flex25, {
|
|
3498
3550
|
pb: "3",
|
|
3499
3551
|
align: "center",
|
|
3500
3552
|
children: [
|
|
@@ -3529,9 +3581,9 @@ var Form = function() {
|
|
|
3529
3581
|
});
|
|
3530
3582
|
};
|
|
3531
3583
|
// src/components/threads/AudioThread/index.tsx
|
|
3532
|
-
import { jsx as jsx63, jsxs as
|
|
3584
|
+
import { jsx as jsx63, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3533
3585
|
var AudioThread = function(props) {
|
|
3534
|
-
return /* @__PURE__ */
|
|
3586
|
+
return /* @__PURE__ */ jsxs22(Root8, _object_spread_props(_object_spread({}, props), {
|
|
3535
3587
|
children: [
|
|
3536
3588
|
/* @__PURE__ */ jsx63(Visualization, {}),
|
|
3537
3589
|
/* @__PURE__ */ jsx63(Status, {}),
|
|
@@ -3543,9 +3595,9 @@ AudioThread.Root = Root8;
|
|
|
3543
3595
|
AudioThread.Visualization = Visualization;
|
|
3544
3596
|
AudioThread.Form = Form;
|
|
3545
3597
|
// src/components/threads/AudioThreadDialog/index.tsx
|
|
3546
|
-
import { jsx as jsx64, jsxs as
|
|
3598
|
+
import { jsx as jsx64, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3547
3599
|
var AudioThreadDialog = function() {
|
|
3548
|
-
return /* @__PURE__ */
|
|
3600
|
+
return /* @__PURE__ */ jsxs23(Root6, {
|
|
3549
3601
|
children: [
|
|
3550
3602
|
/* @__PURE__ */ jsx64(Content4.Root, {
|
|
3551
3603
|
children: /* @__PURE__ */ jsx64(AudioThread, {})
|
|
@@ -3570,7 +3622,7 @@ import { Flex as Flex26 } from "@radix-ui/themes";
|
|
|
3570
3622
|
// src/components/suggestions/Suggestions/Item.tsx
|
|
3571
3623
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3572
3624
|
import { Text as Text8, Button as Button3, Spinner } from "@radix-ui/themes";
|
|
3573
|
-
import { jsx as jsx65, jsxs as
|
|
3625
|
+
import { jsx as jsx65, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3574
3626
|
var Item = function(param) {
|
|
3575
3627
|
var suggestion = param.suggestion, isDisabled = param.isDisabled;
|
|
3576
3628
|
var _useCreateMessage = useCreateMessage(), createMessage = _useCreateMessage.createMessage, isPending = _useCreateMessage.isPending;
|
|
@@ -3588,7 +3640,7 @@ var Item = function(param) {
|
|
|
3588
3640
|
};
|
|
3589
3641
|
var Content5 = function(param) {
|
|
3590
3642
|
var onClick = param.onClick, isDisabled = param.isDisabled, isPending = param.isPending, children = param.children;
|
|
3591
|
-
return /* @__PURE__ */
|
|
3643
|
+
return /* @__PURE__ */ jsxs24(Button3, {
|
|
3592
3644
|
variant: "soft",
|
|
3593
3645
|
onClick: onClick,
|
|
3594
3646
|
disabled: isDisabled,
|