@superinterface/react 3.4.1 → 3.5.1
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 +251 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -68
- package/dist/index.d.ts +15 -68
- package/dist/index.js +198 -90
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -456,7 +456,7 @@ var SuperinterfaceProvider = function(param) {
|
|
|
456
456
|
// src/components/threads/Thread/Messages/index.tsx
|
|
457
457
|
import { Flex as Flex18 } from "@radix-ui/themes";
|
|
458
458
|
// src/components/threads/Thread/Message/index.tsx
|
|
459
|
-
import { useMemo as
|
|
459
|
+
import { useMemo as useMemo9 } from "react";
|
|
460
460
|
import { isEmpty as isEmpty2 } from "radash";
|
|
461
461
|
import { Box as Box9 } from "@radix-ui/themes";
|
|
462
462
|
// src/components/skeletons/StartingContentSkeleton/index.tsx
|
|
@@ -908,7 +908,11 @@ var Attachments = function(param) {
|
|
|
908
908
|
});
|
|
909
909
|
};
|
|
910
910
|
// src/components/threads/Thread/Message/ContentPart/TextContent.tsx
|
|
911
|
-
import
|
|
911
|
+
import { useState as useState2, useEffect as useEffect2, useMemo as useMemo8 } from "react";
|
|
912
|
+
import { compile } from "@mdx-js/mdx";
|
|
913
|
+
import { MDXProvider, useMDXComponents } from "@mdx-js/react";
|
|
914
|
+
import * as runtime from "react/jsx-runtime";
|
|
915
|
+
import recmaMdxEscapeMissingComponents from "recma-mdx-escape-missing-components";
|
|
912
916
|
// src/hooks/markdown/useMarkdownContext/index.ts
|
|
913
917
|
import { useContext as useContext5 } from "react";
|
|
914
918
|
// src/contexts/markdown/MarkdownContext/index.ts
|
|
@@ -2532,11 +2536,26 @@ var components = {
|
|
|
2532
2536
|
]
|
|
2533
2537
|
});
|
|
2534
2538
|
},
|
|
2535
|
-
thead:
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2539
|
+
thead: function(props) {
|
|
2540
|
+
return /* @__PURE__ */ jsx43(Table.Header, _object_spread({}, props));
|
|
2541
|
+
},
|
|
2542
|
+
tbody: function(props) {
|
|
2543
|
+
return /* @__PURE__ */ jsx43(Table.Body, _object_spread({}, props));
|
|
2544
|
+
},
|
|
2545
|
+
tr: function(props) {
|
|
2546
|
+
return /* @__PURE__ */ jsx43(Table.Row, _object_spread({}, props));
|
|
2547
|
+
},
|
|
2548
|
+
td: function(_param) {
|
|
2549
|
+
var width2 = _param.width, rest = _object_without_properties(_param, [
|
|
2550
|
+
"width"
|
|
2551
|
+
]);
|
|
2552
|
+
return /* @__PURE__ */ jsx43(Table.Cell, _object_spread_props(_object_spread({}, rest), {
|
|
2553
|
+
width: width2
|
|
2554
|
+
}));
|
|
2555
|
+
},
|
|
2556
|
+
th: function(props) {
|
|
2557
|
+
return /* @__PURE__ */ jsx43(Table.ColumnHeaderCell, _object_spread({}, props));
|
|
2558
|
+
}
|
|
2540
2559
|
};
|
|
2541
2560
|
// src/contexts/markdown/MarkdownContext/lib/getRemarkPlugins.ts
|
|
2542
2561
|
import remarkGfm from "remark-gfm";
|
|
@@ -2721,18 +2740,106 @@ var useMarkdownContext = function() {
|
|
|
2721
2740
|
};
|
|
2722
2741
|
// src/components/threads/Thread/Message/ContentPart/TextContent.tsx
|
|
2723
2742
|
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2743
|
+
var evaluate = /*#__PURE__*/ function() {
|
|
2744
|
+
var _ref = _async_to_generator(function(param) {
|
|
2745
|
+
var code, fn;
|
|
2746
|
+
return _ts_generator(this, function(_state) {
|
|
2747
|
+
code = param.code;
|
|
2748
|
+
fn = new Function("runtime", "useMDXComponents", code);
|
|
2749
|
+
return [
|
|
2750
|
+
2,
|
|
2751
|
+
fn(_object_spread_props(_object_spread({}, runtime), {
|
|
2752
|
+
useMDXComponents: useMDXComponents
|
|
2753
|
+
}))
|
|
2754
|
+
];
|
|
2755
|
+
});
|
|
2756
|
+
});
|
|
2757
|
+
return function evaluate(_) {
|
|
2758
|
+
return _ref.apply(this, arguments);
|
|
2759
|
+
};
|
|
2760
|
+
}();
|
|
2724
2761
|
var TextContent = function(param) {
|
|
2725
2762
|
var content = param.content;
|
|
2726
|
-
var _useMarkdownContext = useMarkdownContext(), getRemarkPlugins2 = _useMarkdownContext.getRemarkPlugins,
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
return(// @ts-ignore-next-line
|
|
2730
|
-
/* @__PURE__ */ jsx44(Markdown, _object_spread_props(_object_spread({}, rest), {
|
|
2731
|
-
remarkPlugins: getRemarkPlugins2({
|
|
2763
|
+
var _useMarkdownContext = useMarkdownContext(), getRemarkPlugins2 = _useMarkdownContext.getRemarkPlugins, components2 = _useMarkdownContext.components;
|
|
2764
|
+
var remarkPlugins = useMemo8(function() {
|
|
2765
|
+
return getRemarkPlugins2({
|
|
2732
2766
|
content: content
|
|
2733
|
-
})
|
|
2734
|
-
|
|
2735
|
-
|
|
2767
|
+
});
|
|
2768
|
+
}, [
|
|
2769
|
+
content,
|
|
2770
|
+
getRemarkPlugins2
|
|
2771
|
+
]);
|
|
2772
|
+
var _useState2 = _sliced_to_array(useState2(null), 2), MDXComponent = _useState2[0], setMDXComponent = _useState2[1];
|
|
2773
|
+
useEffect2(function() {
|
|
2774
|
+
var compileMDX = /*#__PURE__*/ function() {
|
|
2775
|
+
var _ref = _async_to_generator(function() {
|
|
2776
|
+
var compiled, code, module, MDXContent, error;
|
|
2777
|
+
return _ts_generator(this, function(_state) {
|
|
2778
|
+
switch(_state.label){
|
|
2779
|
+
case 0:
|
|
2780
|
+
_state.trys.push([
|
|
2781
|
+
0,
|
|
2782
|
+
3,
|
|
2783
|
+
,
|
|
2784
|
+
4
|
|
2785
|
+
]);
|
|
2786
|
+
return [
|
|
2787
|
+
4,
|
|
2788
|
+
compile(content.text.value, {
|
|
2789
|
+
outputFormat: "function-body",
|
|
2790
|
+
remarkPlugins: remarkPlugins,
|
|
2791
|
+
recmaPlugins: [
|
|
2792
|
+
recmaMdxEscapeMissingComponents
|
|
2793
|
+
],
|
|
2794
|
+
providerImportSource: "@mdx-js/react"
|
|
2795
|
+
})
|
|
2796
|
+
];
|
|
2797
|
+
case 1:
|
|
2798
|
+
compiled = _state.sent();
|
|
2799
|
+
code = String(compiled);
|
|
2800
|
+
return [
|
|
2801
|
+
4,
|
|
2802
|
+
evaluate({
|
|
2803
|
+
code: code
|
|
2804
|
+
})
|
|
2805
|
+
];
|
|
2806
|
+
case 2:
|
|
2807
|
+
module = _state.sent();
|
|
2808
|
+
MDXContent = module.default;
|
|
2809
|
+
setMDXComponent(function() {
|
|
2810
|
+
return MDXContent;
|
|
2811
|
+
});
|
|
2812
|
+
return [
|
|
2813
|
+
3,
|
|
2814
|
+
4
|
|
2815
|
+
];
|
|
2816
|
+
case 3:
|
|
2817
|
+
error = _state.sent();
|
|
2818
|
+
return [
|
|
2819
|
+
3,
|
|
2820
|
+
4
|
|
2821
|
+
];
|
|
2822
|
+
case 4:
|
|
2823
|
+
return [
|
|
2824
|
+
2
|
|
2825
|
+
];
|
|
2826
|
+
}
|
|
2827
|
+
});
|
|
2828
|
+
});
|
|
2829
|
+
return function compileMDX() {
|
|
2830
|
+
return _ref.apply(this, arguments);
|
|
2831
|
+
};
|
|
2832
|
+
}();
|
|
2833
|
+
compileMDX();
|
|
2834
|
+
}, [
|
|
2835
|
+
content,
|
|
2836
|
+
remarkPlugins
|
|
2837
|
+
]);
|
|
2838
|
+
if (!MDXComponent) return content.text.value;
|
|
2839
|
+
return /* @__PURE__ */ jsx44(MDXProvider, {
|
|
2840
|
+
components: components2,
|
|
2841
|
+
children: /* @__PURE__ */ jsx44(MDXComponent, {})
|
|
2842
|
+
});
|
|
2736
2843
|
};
|
|
2737
2844
|
// src/components/threads/Thread/Message/ContentPart/ImageFileContent.tsx
|
|
2738
2845
|
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
@@ -2765,7 +2872,7 @@ var ContentPart = function(param) {
|
|
|
2765
2872
|
import { jsx as jsx47, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2766
2873
|
var Message = function(param) {
|
|
2767
2874
|
var message = param.message, className = param.className, style = param.style;
|
|
2768
|
-
var
|
|
2875
|
+
var _useMemo9 = _sliced_to_array(useMemo9(function() {
|
|
2769
2876
|
if (!message.runSteps.length) return [
|
|
2770
2877
|
[],
|
|
2771
2878
|
[]
|
|
@@ -2796,9 +2903,9 @@ var Message = function(param) {
|
|
|
2796
2903
|
];
|
|
2797
2904
|
}, [
|
|
2798
2905
|
message
|
|
2799
|
-
]), 2), olderRunSteps =
|
|
2906
|
+
]), 2), olderRunSteps = _useMemo9[0], laterRunSteps = _useMemo9[1];
|
|
2800
2907
|
var isMutatingMessage = useIsMutatingMessage();
|
|
2801
|
-
var isInProgress =
|
|
2908
|
+
var isInProgress = useMemo9(function() {
|
|
2802
2909
|
if (!isMutatingMessage) return false;
|
|
2803
2910
|
if (message.status === "in_progress") return true;
|
|
2804
2911
|
return message.runSteps.some(function(rs) {
|
|
@@ -2842,9 +2949,9 @@ var Message = function(param) {
|
|
|
2842
2949
|
});
|
|
2843
2950
|
};
|
|
2844
2951
|
// src/components/threads/Thread/Messages/Content/index.tsx
|
|
2845
|
-
import { useEffect as
|
|
2952
|
+
import { useEffect as useEffect3 } from "react";
|
|
2846
2953
|
// src/hooks/messageGroups/useMessageGroups/index.ts
|
|
2847
|
-
import { useMemo as
|
|
2954
|
+
import { useMemo as useMemo10 } from "react";
|
|
2848
2955
|
// src/hooks/messageGroups/useMessageGroups/lib/messageGroups/index.ts
|
|
2849
2956
|
import _6 from "lodash";
|
|
2850
2957
|
import { last as last2 } from "radash";
|
|
@@ -2906,7 +3013,7 @@ var messageGroups = function(param) {
|
|
|
2906
3013
|
// src/hooks/messageGroups/useMessageGroups/index.ts
|
|
2907
3014
|
var useMessageGroups = function(param) {
|
|
2908
3015
|
var messages2 = param.messages;
|
|
2909
|
-
return
|
|
3016
|
+
return useMemo10(function() {
|
|
2910
3017
|
return {
|
|
2911
3018
|
messageGroups: messageGroups({
|
|
2912
3019
|
messages: messages2
|
|
@@ -3104,7 +3211,7 @@ var Content6 = function() {
|
|
|
3104
3211
|
var _useMessageGroups = useMessageGroups({
|
|
3105
3212
|
messages: messages2
|
|
3106
3213
|
}), messageGroups2 = _useMessageGroups.messageGroups;
|
|
3107
|
-
|
|
3214
|
+
useEffect3(function() {
|
|
3108
3215
|
if (isLoadingError) {
|
|
3109
3216
|
addToast({
|
|
3110
3217
|
type: "error",
|
|
@@ -3127,7 +3234,7 @@ var Content6 = function() {
|
|
|
3127
3234
|
});
|
|
3128
3235
|
};
|
|
3129
3236
|
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
3130
|
-
import { useMemo as
|
|
3237
|
+
import { useMemo as useMemo11 } from "react";
|
|
3131
3238
|
// src/components/skeletons/StartingSkeleton/index.tsx
|
|
3132
3239
|
import { useContext as useContext9 } from "react";
|
|
3133
3240
|
import { Box as Box12 } from "@radix-ui/themes";
|
|
@@ -3155,7 +3262,7 @@ import { jsx as jsx59 } from "react/jsx-runtime";
|
|
|
3155
3262
|
var Progress = function() {
|
|
3156
3263
|
var latestMessage = useLatestMessage().latestMessage;
|
|
3157
3264
|
var isMutatingMessage = useIsMutatingMessage();
|
|
3158
|
-
var isVisible =
|
|
3265
|
+
var isVisible = useMemo11(function() {
|
|
3159
3266
|
if (!latestMessage) return false;
|
|
3160
3267
|
if (latestMessage.role !== "user") return false;
|
|
3161
3268
|
if (latestMessage.status === "in_progress") return false;
|
|
@@ -3178,7 +3285,7 @@ import { useRef as useRef3 } from "react";
|
|
|
3178
3285
|
import { useInView } from "react-intersection-observer";
|
|
3179
3286
|
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
3180
3287
|
import _7 from "lodash";
|
|
3181
|
-
import { useRef as useRef2, useEffect as
|
|
3288
|
+
import { useRef as useRef2, useEffect as useEffect4, useCallback } from "react";
|
|
3182
3289
|
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
3183
3290
|
var _cbRef;
|
|
3184
3291
|
var cbRef = useRef2(cb);
|
|
@@ -3193,10 +3300,10 @@ var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
|
3193
3300
|
}), [
|
|
3194
3301
|
delay
|
|
3195
3302
|
]);
|
|
3196
|
-
|
|
3303
|
+
useEffect4(function() {
|
|
3197
3304
|
cbRef.current = cb;
|
|
3198
3305
|
});
|
|
3199
|
-
|
|
3306
|
+
useEffect4(throttledCb, [
|
|
3200
3307
|
throttledCb
|
|
3201
3308
|
].concat(_to_consumable_array(additionalDeps)));
|
|
3202
3309
|
};
|
|
@@ -3353,7 +3460,7 @@ Submit.Root = Root3;
|
|
|
3353
3460
|
Submit.Button = Button3;
|
|
3354
3461
|
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
3355
3462
|
import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
3356
|
-
import { useMemo as
|
|
3463
|
+
import { useMemo as useMemo12, useState as useState3 } from "react";
|
|
3357
3464
|
import { useForm, FormProvider } from "react-hook-form";
|
|
3358
3465
|
import { Box as Box13 } from "@radix-ui/themes";
|
|
3359
3466
|
// src/components/threads/Thread/MessageForm/Root/lib/formOptions.ts
|
|
@@ -3370,7 +3477,7 @@ import { partob as partob2 } from "radash";
|
|
|
3370
3477
|
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
3371
3478
|
var Root4 = function(param) {
|
|
3372
3479
|
var children = param.children, onSubmitArg = param.onSubmit, isDisabledArg = param.isDisabled, style = param.style, className = param.className;
|
|
3373
|
-
var
|
|
3480
|
+
var _useState3 = _sliced_to_array(useState3([]), 2), files = _useState3[0], setFiles = _useState3[1];
|
|
3374
3481
|
var formProps = useForm(formOptions);
|
|
3375
3482
|
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset, watch = formProps.watch;
|
|
3376
3483
|
var addToast = useToasts().addToast;
|
|
@@ -3384,7 +3491,7 @@ var Root4 = function(param) {
|
|
|
3384
3491
|
})
|
|
3385
3492
|
}).createMessage;
|
|
3386
3493
|
var isMutatingMessage = useIsMutatingMessage();
|
|
3387
|
-
var isFileLoading =
|
|
3494
|
+
var isFileLoading = useMemo12(function() {
|
|
3388
3495
|
return files.some(function(file) {
|
|
3389
3496
|
return isOptimistic({
|
|
3390
3497
|
id: file.id
|
|
@@ -3393,14 +3500,14 @@ var Root4 = function(param) {
|
|
|
3393
3500
|
}, [
|
|
3394
3501
|
files
|
|
3395
3502
|
]);
|
|
3396
|
-
var isLoading =
|
|
3503
|
+
var isLoading = useMemo12(function() {
|
|
3397
3504
|
return isMutatingMessage || isSubmitting;
|
|
3398
3505
|
}, [
|
|
3399
3506
|
isMutatingMessage,
|
|
3400
3507
|
isSubmitting
|
|
3401
3508
|
]);
|
|
3402
3509
|
var latestMessage = useLatestMessage().latestMessage;
|
|
3403
|
-
var isDisabled =
|
|
3510
|
+
var isDisabled = useMemo12(function() {
|
|
3404
3511
|
var // @ts-ignore-next-line
|
|
3405
3512
|
_latestMessage_metadata;
|
|
3406
3513
|
return (latestMessage === null || latestMessage === void 0 ? void 0 : (_latestMessage_metadata = latestMessage.metadata) === null || _latestMessage_metadata === void 0 ? void 0 : _latestMessage_metadata.isBlocking) || isDisabledArg;
|
|
@@ -3490,16 +3597,16 @@ import { Container as RadixContainer, Flex as Flex23 } from "@radix-ui/themes";
|
|
|
3490
3597
|
import { Flex as Flex20 } from "@radix-ui/themes";
|
|
3491
3598
|
import { useFormContext } from "react-hook-form";
|
|
3492
3599
|
// src/hooks/misc/usePrevious.ts
|
|
3493
|
-
import { useEffect as
|
|
3600
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
3494
3601
|
var usePrevious = function(state) {
|
|
3495
3602
|
var ref = useRef4();
|
|
3496
|
-
|
|
3603
|
+
useEffect5(function() {
|
|
3497
3604
|
ref.current = state;
|
|
3498
3605
|
});
|
|
3499
3606
|
return ref.current;
|
|
3500
3607
|
};
|
|
3501
3608
|
// src/components/threads/Thread/MessageForm/Field/Control.tsx
|
|
3502
|
-
import { useContext as useContext11, useMemo as
|
|
3609
|
+
import { useContext as useContext11, useMemo as useMemo13, useRef as useRef5, useEffect as useEffect6 } from "react";
|
|
3503
3610
|
// src/components/textareas/TextareaBase/index.tsx
|
|
3504
3611
|
import { forwardRef as forwardRef3 } from "react";
|
|
3505
3612
|
import TextareaAutosize from "react-textarea-autosize";
|
|
@@ -3546,7 +3653,7 @@ var Input = function(props) {
|
|
|
3546
3653
|
var assistantNameContext = useContext11(AssistantNameContext);
|
|
3547
3654
|
var register = useFormContext().register;
|
|
3548
3655
|
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
3549
|
-
var isSubmitDisabled =
|
|
3656
|
+
var isSubmitDisabled = useMemo13(function() {
|
|
3550
3657
|
return isDisabled || isLoading;
|
|
3551
3658
|
}, [
|
|
3552
3659
|
isDisabled,
|
|
@@ -3555,7 +3662,7 @@ var Input = function(props) {
|
|
|
3555
3662
|
var isDisabledPrevious = usePrevious(isDisabled);
|
|
3556
3663
|
var textareaRef = useRef5(null);
|
|
3557
3664
|
var textareaProps = register("content");
|
|
3558
|
-
|
|
3665
|
+
useEffect6(function() {
|
|
3559
3666
|
if (isDisabled) return;
|
|
3560
3667
|
if (!isDisabledPrevious) return;
|
|
3561
3668
|
if (!textareaRef.current) return;
|
|
@@ -4050,7 +4157,7 @@ import { Flex as Flex25 } from "@radix-ui/themes";
|
|
|
4050
4157
|
// src/components/threads/Thread/Provider/index.tsx
|
|
4051
4158
|
var Provider2 = SuperinterfaceProvider;
|
|
4052
4159
|
// src/components/toasts/ToastsProvider/index.tsx
|
|
4053
|
-
import { useState as
|
|
4160
|
+
import { useState as useState4, useCallback as useCallback3 } from "react";
|
|
4054
4161
|
import * as Toast2 from "@radix-ui/react-toast";
|
|
4055
4162
|
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
4056
4163
|
import * as Toast from "@radix-ui/react-toast";
|
|
@@ -4089,7 +4196,7 @@ var CustomToast = function(param) {
|
|
|
4089
4196
|
import { jsx as jsx72, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
4090
4197
|
var ToastsProvider = function(param) {
|
|
4091
4198
|
var children = param.children, _param_bottom = param.bottom, bottom = _param_bottom === void 0 ? 0 : _param_bottom;
|
|
4092
|
-
var
|
|
4199
|
+
var _useState4 = _sliced_to_array(useState4([]), 2), toasts = _useState4[0], setToasts = _useState4[1];
|
|
4093
4200
|
var addToast = useCallback3(function(toast) {
|
|
4094
4201
|
return setToasts(function(prevToasts) {
|
|
4095
4202
|
return _to_consumable_array(prevToasts).concat([
|
|
@@ -4171,7 +4278,7 @@ var useMessageContext = function() {
|
|
|
4171
4278
|
return useContext12(MessageContext);
|
|
4172
4279
|
};
|
|
4173
4280
|
// src/hooks/assistants/useAssistant/index.ts
|
|
4174
|
-
import { useMemo as
|
|
4281
|
+
import { useMemo as useMemo14 } from "react";
|
|
4175
4282
|
import { useQuery } from "@tanstack/react-query";
|
|
4176
4283
|
// src/hooks/assistants/useAssistant/lib/queryOptions/index.ts
|
|
4177
4284
|
import { queryOptions as tanstackQueryOptions } from "@tanstack/react-query";
|
|
@@ -4260,7 +4367,7 @@ var useAssistant = function(param) {
|
|
|
4260
4367
|
assistantId: assistantId,
|
|
4261
4368
|
superinterfaceContext: superinterfaceContext
|
|
4262
4369
|
}));
|
|
4263
|
-
return
|
|
4370
|
+
return useMemo14(function() {
|
|
4264
4371
|
return _object_spread_props(_object_spread({}, props), {
|
|
4265
4372
|
assistant: props.data ? props.data.assistant : null
|
|
4266
4373
|
});
|
|
@@ -4269,7 +4376,7 @@ var useAssistant = function(param) {
|
|
|
4269
4376
|
]);
|
|
4270
4377
|
};
|
|
4271
4378
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
4272
|
-
import { useState as
|
|
4379
|
+
import { useState as useState5 } from "react";
|
|
4273
4380
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
4274
4381
|
import { createContext as createContext11 } from "react";
|
|
4275
4382
|
var ThreadDialogContext = createContext11({
|
|
@@ -4286,7 +4393,7 @@ import { jsx as jsx75 } from "react/jsx-runtime";
|
|
|
4286
4393
|
var Provider4 = function(param) {
|
|
4287
4394
|
var children = param.children;
|
|
4288
4395
|
var threadDialogContext = useThreadDialogContext();
|
|
4289
|
-
var
|
|
4396
|
+
var _useState5 = _sliced_to_array(useState5(threadDialogContext.isOpen), 2), isOpen = _useState5[0], setIsOpen = _useState5[1];
|
|
4290
4397
|
return /* @__PURE__ */ jsx75(ThreadDialogContext.Provider, {
|
|
4291
4398
|
value: {
|
|
4292
4399
|
isOpen: isOpen,
|
|
@@ -4562,7 +4669,7 @@ var AudioThreadContext = createContext12({
|
|
|
4562
4669
|
}
|
|
4563
4670
|
});
|
|
4564
4671
|
// src/hooks/misc/usePermission/index.ts
|
|
4565
|
-
import { useEffect as
|
|
4672
|
+
import { useEffect as useEffect7, useState as useState6 } from "react";
|
|
4566
4673
|
// src/hooks/misc/usePermission/util.ts
|
|
4567
4674
|
var noop = function() {};
|
|
4568
4675
|
function on(obj) {
|
|
@@ -4585,8 +4692,8 @@ function off(obj) {
|
|
|
4585
4692
|
}
|
|
4586
4693
|
// src/hooks/misc/usePermission/index.ts
|
|
4587
4694
|
var usePermission = function(permissionDesc) {
|
|
4588
|
-
var
|
|
4589
|
-
|
|
4695
|
+
var _useState6 = _sliced_to_array(useState6(""), 2), state = _useState6[0], setState = _useState6[1];
|
|
4696
|
+
useEffect7(function() {
|
|
4590
4697
|
var mounted = true;
|
|
4591
4698
|
var permissionStatus = null;
|
|
4592
4699
|
var onChange = function() {
|
|
@@ -4624,11 +4731,11 @@ var blobToData = function(blob) {
|
|
|
4624
4731
|
});
|
|
4625
4732
|
};
|
|
4626
4733
|
// src/hooks/audioThreads/useStatus/index.ts
|
|
4627
|
-
import { useMemo as
|
|
4734
|
+
import { useMemo as useMemo15 } from "react";
|
|
4628
4735
|
var useStatus = function(param) {
|
|
4629
4736
|
var messageAudioProps = param.messageAudioProps, recorderProps = param.recorderProps, createMessageProps = param.createMessageProps;
|
|
4630
4737
|
var latestMessageProps = useLatestMessage();
|
|
4631
|
-
var status =
|
|
4738
|
+
var status = useMemo15(function() {
|
|
4632
4739
|
var _latestMessageProps_latestMessage;
|
|
4633
4740
|
if (recorderProps.status === "recording") return "recording";
|
|
4634
4741
|
if (createMessageProps.isPending) return "creatingMessage";
|
|
@@ -4652,16 +4759,16 @@ var useStatus = function(param) {
|
|
|
4652
4759
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
4653
4760
|
import dayjs3 from "dayjs";
|
|
4654
4761
|
import { useAudioCapture } from "use-audio-capture";
|
|
4655
|
-
import { useMemo as
|
|
4762
|
+
import { useMemo as useMemo16, useRef as useRef7, useState as useState7, useCallback as useCallback4, useEffect as useEffect9 } from "react";
|
|
4656
4763
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
4657
4764
|
// src/hooks/misc/useInterval.ts
|
|
4658
|
-
import { useEffect as
|
|
4765
|
+
import { useEffect as useEffect8, useRef as useRef6 } from "react";
|
|
4659
4766
|
var useInterval = function(callback, delay) {
|
|
4660
4767
|
var savedCallback = useRef6(function() {});
|
|
4661
|
-
|
|
4768
|
+
useEffect8(function() {
|
|
4662
4769
|
savedCallback.current = callback;
|
|
4663
4770
|
});
|
|
4664
|
-
|
|
4771
|
+
useEffect8(function() {
|
|
4665
4772
|
if (delay !== null) {
|
|
4666
4773
|
var interval = setInterval(function() {
|
|
4667
4774
|
return savedCallback.current();
|
|
@@ -4678,14 +4785,14 @@ var useInterval = function(callback, delay) {
|
|
|
4678
4785
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
4679
4786
|
var useRecorder = function(param) {
|
|
4680
4787
|
var isStopOnSilence = param.isStopOnSilence, onStart = param.onStart, onStop = param.onStop;
|
|
4681
|
-
var
|
|
4682
|
-
var
|
|
4683
|
-
var
|
|
4684
|
-
var
|
|
4788
|
+
var _useState7 = _sliced_to_array(useState7(null), 2), silenceStart = _useState7[0], setSilenceStart = _useState7[1];
|
|
4789
|
+
var _useState71 = _sliced_to_array(useState7(null), 2), noiseStart = _useState71[0], setNoiseStart = _useState71[1];
|
|
4790
|
+
var _useState72 = _sliced_to_array(useState7(null), 2), mediaStream = _useState72[0], setMediaStream = _useState72[1];
|
|
4791
|
+
var _useState73 = _sliced_to_array(useState7("idle"), 2), status = _useState73[0], setStatus = _useState73[1];
|
|
4685
4792
|
var startAudioPlayer = useAudioPlayer();
|
|
4686
4793
|
var endAudioPlayer = useAudioPlayer();
|
|
4687
|
-
var
|
|
4688
|
-
|
|
4794
|
+
var _useState74 = _sliced_to_array(useState7(false), 2), isLoaded = _useState74[0], setIsLoaded = _useState74[1];
|
|
4795
|
+
useEffect9(function() {
|
|
4689
4796
|
if (isLoaded) return;
|
|
4690
4797
|
setIsLoaded(true);
|
|
4691
4798
|
}, [
|
|
@@ -4743,9 +4850,9 @@ var useRecorder = function(param) {
|
|
|
4743
4850
|
setNoiseStart(null);
|
|
4744
4851
|
}
|
|
4745
4852
|
});
|
|
4746
|
-
var
|
|
4853
|
+
var _useState75 = _sliced_to_array(useState7(null), 2), audioEngine = _useState75[0], setAudioEngine = _useState75[1];
|
|
4747
4854
|
var isInited = useRef7(false);
|
|
4748
|
-
|
|
4855
|
+
useEffect9(function() {
|
|
4749
4856
|
if (!mediaStream) return;
|
|
4750
4857
|
if (isInited.current) return;
|
|
4751
4858
|
isInited.current = true;
|
|
@@ -4758,7 +4865,7 @@ var useRecorder = function(param) {
|
|
|
4758
4865
|
isInited,
|
|
4759
4866
|
mediaStream
|
|
4760
4867
|
]);
|
|
4761
|
-
var visualizationAnalyser =
|
|
4868
|
+
var visualizationAnalyser = useMemo16(function() {
|
|
4762
4869
|
if (!audioEngine) return null;
|
|
4763
4870
|
var result = audioEngine.audioContext.createAnalyser();
|
|
4764
4871
|
audioEngine.source.connect(result);
|
|
@@ -4766,7 +4873,7 @@ var useRecorder = function(param) {
|
|
|
4766
4873
|
}, [
|
|
4767
4874
|
audioEngine
|
|
4768
4875
|
]);
|
|
4769
|
-
var silenceAnalyser =
|
|
4876
|
+
var silenceAnalyser = useMemo16(function() {
|
|
4770
4877
|
if (!audioEngine) return null;
|
|
4771
4878
|
var result = audioEngine.audioContext.createAnalyser();
|
|
4772
4879
|
result.minDecibels = -60;
|
|
@@ -4798,7 +4905,7 @@ var useRecorder = function(param) {
|
|
|
4798
4905
|
setNoiseStart,
|
|
4799
4906
|
setSilenceStart
|
|
4800
4907
|
]);
|
|
4801
|
-
|
|
4908
|
+
useEffect9(function() {
|
|
4802
4909
|
if (!isStopOnSilence) return;
|
|
4803
4910
|
requestAnimationFrame(function() {
|
|
4804
4911
|
return handleSilence();
|
|
@@ -4821,7 +4928,7 @@ var useRecorder = function(param) {
|
|
|
4821
4928
|
});
|
|
4822
4929
|
};
|
|
4823
4930
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
4824
|
-
import { useMemo as
|
|
4931
|
+
import { useMemo as useMemo17, useRef as useRef8, useState as useState8, useEffect as useEffect10 } from "react";
|
|
4825
4932
|
import nlp from "compromise";
|
|
4826
4933
|
import { Howler } from "howler";
|
|
4827
4934
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
@@ -4859,15 +4966,15 @@ var getMessageSentences = function(param) {
|
|
|
4859
4966
|
};
|
|
4860
4967
|
var useMessageAudio = function(param) {
|
|
4861
4968
|
var onEnd = param.onEnd;
|
|
4862
|
-
var
|
|
4863
|
-
var
|
|
4864
|
-
var
|
|
4969
|
+
var _useState8 = _sliced_to_array(useState8(false), 2), isAudioPlayed = _useState8[0], setIsAudioPlayed = _useState8[1];
|
|
4970
|
+
var _useState81 = _sliced_to_array(useState8([]), 2), stoppedMessageIds = _useState81[0], setStoppedMessageIds = _useState81[1];
|
|
4971
|
+
var _useState82 = _sliced_to_array(useState8([]), 2), playedMessageSentences = _useState82[0], setPlayedMessageSentences = _useState82[1];
|
|
4865
4972
|
var audioPlayer = useAudioPlayer2();
|
|
4866
4973
|
var nextAudioPlayer = useAudioPlayer2();
|
|
4867
4974
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
4868
|
-
var
|
|
4975
|
+
var _useState83 = _sliced_to_array(useState8(false), 2), isPlaying = _useState83[0], setIsPlaying = _useState83[1];
|
|
4869
4976
|
var latestMessageProps = useLatestMessage();
|
|
4870
|
-
var unplayedMessageSentences =
|
|
4977
|
+
var unplayedMessageSentences = useMemo17(function() {
|
|
4871
4978
|
if (!latestMessageProps.latestMessage) return [];
|
|
4872
4979
|
if (latestMessageProps.latestMessage.role !== "assistant") return [];
|
|
4873
4980
|
if (stoppedMessageIds.includes(latestMessageProps.latestMessage.id)) return [];
|
|
@@ -4888,7 +4995,7 @@ var useMessageAudio = function(param) {
|
|
|
4888
4995
|
latestMessageProps,
|
|
4889
4996
|
playedMessageSentences
|
|
4890
4997
|
]);
|
|
4891
|
-
|
|
4998
|
+
useEffect10(function() {
|
|
4892
4999
|
if (isPlaying) return;
|
|
4893
5000
|
if (audioPlayer.playing) return;
|
|
4894
5001
|
if (!latestMessageProps.latestMessage) return;
|
|
@@ -4956,7 +5063,7 @@ var useMessageAudio = function(param) {
|
|
|
4956
5063
|
playedMessageSentences,
|
|
4957
5064
|
onEnd
|
|
4958
5065
|
]);
|
|
4959
|
-
|
|
5066
|
+
useEffect10(function() {
|
|
4960
5067
|
if (isHtmlAudioSupported) {
|
|
4961
5068
|
var _Howler__howls___sounds_, _Howler__howls_;
|
|
4962
5069
|
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;
|
|
@@ -4965,9 +5072,9 @@ var useMessageAudio = function(param) {
|
|
|
4965
5072
|
}, [
|
|
4966
5073
|
audioPlayer
|
|
4967
5074
|
]);
|
|
4968
|
-
var
|
|
5075
|
+
var _useState84 = _sliced_to_array(useState8(null), 2), audioEngine = _useState84[0], setAudioEngine = _useState84[1];
|
|
4969
5076
|
var isAudioEngineInited = useRef8(false);
|
|
4970
|
-
|
|
5077
|
+
useEffect10(function() {
|
|
4971
5078
|
if (!audioPlayer.playing) return;
|
|
4972
5079
|
if (isAudioEngineInited.current) return;
|
|
4973
5080
|
isAudioEngineInited.current = true;
|
|
@@ -4988,7 +5095,7 @@ var useMessageAudio = function(param) {
|
|
|
4988
5095
|
audioPlayer,
|
|
4989
5096
|
isAudioEngineInited
|
|
4990
5097
|
]);
|
|
4991
|
-
var visualizationAnalyser =
|
|
5098
|
+
var visualizationAnalyser = useMemo17(function() {
|
|
4992
5099
|
if (!audioEngine) return null;
|
|
4993
5100
|
var result = audioEngine.audioContext.createAnalyser();
|
|
4994
5101
|
audioEngine.source.connect(audioEngine.audioContext.destination);
|
|
@@ -4997,7 +5104,7 @@ var useMessageAudio = function(param) {
|
|
|
4997
5104
|
}, [
|
|
4998
5105
|
audioEngine
|
|
4999
5106
|
]);
|
|
5000
|
-
var isPending =
|
|
5107
|
+
var isPending = useMemo17(function() {
|
|
5001
5108
|
return isPlaying || unplayedMessageSentences.length > 0;
|
|
5002
5109
|
}, [
|
|
5003
5110
|
isPlaying,
|
|
@@ -5109,7 +5216,7 @@ var Root12 = function(_param) {
|
|
|
5109
5216
|
});
|
|
5110
5217
|
};
|
|
5111
5218
|
// src/components/threads/AudioThread/Visualization/index.tsx
|
|
5112
|
-
import { useContext as useContext15, useState as
|
|
5219
|
+
import { useContext as useContext15, useState as useState10, useCallback as useCallback6, useEffect as useEffect12 } from "react";
|
|
5113
5220
|
import _9 from "lodash";
|
|
5114
5221
|
import { Flex as Flex31 } from "@radix-ui/themes";
|
|
5115
5222
|
// src/hooks/threads/useAudioThreadContext/index.ts
|
|
@@ -5120,13 +5227,13 @@ var useAudioThreadContext = function() {
|
|
|
5120
5227
|
// src/components/threads/AudioThread/BarsVisualizer/index.tsx
|
|
5121
5228
|
import _8 from "lodash";
|
|
5122
5229
|
import { Flex as Flex30, Grid } from "@radix-ui/themes";
|
|
5123
|
-
import { useState as
|
|
5230
|
+
import { useState as useState9, useEffect as useEffect11, useCallback as useCallback5 } from "react";
|
|
5124
5231
|
import { cluster } from "radash";
|
|
5125
5232
|
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
5126
5233
|
var barCount = 4;
|
|
5127
5234
|
var BarsVisualizer = function(param) {
|
|
5128
5235
|
var visualizationAnalyser = param.visualizationAnalyser, backgroundColor = param.backgroundColor, height = param.height, barWidth = param.barWidth;
|
|
5129
|
-
var
|
|
5236
|
+
var _useState9 = _sliced_to_array(useState9([]), 2), barHeights = _useState9[0], setBarHeights = _useState9[1];
|
|
5130
5237
|
var draw = useCallback5(function(param) {
|
|
5131
5238
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
5132
5239
|
if (!visualizationAnalyser2) {
|
|
@@ -5145,7 +5252,7 @@ var BarsVisualizer = function(param) {
|
|
|
5145
5252
|
});
|
|
5146
5253
|
});
|
|
5147
5254
|
}, []);
|
|
5148
|
-
|
|
5255
|
+
useEffect11(function() {
|
|
5149
5256
|
draw({
|
|
5150
5257
|
visualizationAnalyser: visualizationAnalyser
|
|
5151
5258
|
});
|
|
@@ -5186,7 +5293,7 @@ import { jsx as jsx84, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
|
5186
5293
|
var Visualization = function(props) {
|
|
5187
5294
|
var audioThreadContext = useAudioThreadContext();
|
|
5188
5295
|
var assistantNameContext = useContext15(AssistantNameContext);
|
|
5189
|
-
var
|
|
5296
|
+
var _useState10 = _sliced_to_array(useState10(0), 2), scale = _useState10[0], setScale = _useState10[1];
|
|
5190
5297
|
var draw = useCallback6(function(param) {
|
|
5191
5298
|
var visualizationAnalyser = param.visualizationAnalyser;
|
|
5192
5299
|
if (!visualizationAnalyser) {
|
|
@@ -5202,7 +5309,7 @@ var Visualization = function(props) {
|
|
|
5202
5309
|
});
|
|
5203
5310
|
});
|
|
5204
5311
|
}, []);
|
|
5205
|
-
|
|
5312
|
+
useEffect12(function() {
|
|
5206
5313
|
draw({
|
|
5207
5314
|
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser
|
|
5208
5315
|
});
|
|
@@ -5492,14 +5599,15 @@ AudioThreadDialog.Root = Root9;
|
|
|
5492
5599
|
AudioThreadDialog.Trigger = Trigger;
|
|
5493
5600
|
AudioThreadDialog.Content = Content7;
|
|
5494
5601
|
// src/components/markdown/MarkdownProvider/index.tsx
|
|
5495
|
-
import { useMemo as
|
|
5602
|
+
import { useMemo as useMemo18 } from "react";
|
|
5496
5603
|
import { jsx as jsx92 } from "react/jsx-runtime";
|
|
5497
5604
|
var MarkdownProvider = function(_param) {
|
|
5498
|
-
var children = _param.children, rest = _object_without_properties(_param, [
|
|
5499
|
-
"children"
|
|
5605
|
+
var children = _param.children, components2 = _param.components, rest = _object_without_properties(_param, [
|
|
5606
|
+
"children",
|
|
5607
|
+
"components"
|
|
5500
5608
|
]);
|
|
5501
5609
|
var prevMarkdownContext = useMarkdownContext();
|
|
5502
|
-
var value =
|
|
5610
|
+
var value = useMemo18(function() {
|
|
5503
5611
|
return merge(prevMarkdownContext, rest);
|
|
5504
5612
|
}, [
|
|
5505
5613
|
rest,
|
|
@@ -5581,7 +5689,7 @@ var ImageAvatar = function(param) {
|
|
|
5581
5689
|
});
|
|
5582
5690
|
};
|
|
5583
5691
|
// src/components/iconAvatars/IconAvatar.tsx
|
|
5584
|
-
import { useMemo as
|
|
5692
|
+
import { useMemo as useMemo19 } from "react";
|
|
5585
5693
|
import { Avatar as Avatar5 } from "@radix-ui/themes";
|
|
5586
5694
|
// src/lib/iconAvatars/iconAvatarComponents.ts
|
|
5587
5695
|
import { BackpackIcon, RocketIcon, MagicWandIcon, CubeIcon, TargetIcon, DiscIcon, GlobeIcon, StarIcon, LightningBoltIcon as LightningBoltIcon2, FaceIcon, PersonIcon as PersonIcon2, HeartIcon } from "@radix-ui/react-icons";
|
|
@@ -5591,7 +5699,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, "BACKPACK" /* BACK
|
|
|
5591
5699
|
import { jsx as jsx94 } from "react/jsx-runtime";
|
|
5592
5700
|
var IconAvatar = function(param) {
|
|
5593
5701
|
var iconAvatar = param.iconAvatar, size = param.size, className = param.className, style = param.style;
|
|
5594
|
-
var Component =
|
|
5702
|
+
var Component = useMemo19(function() {
|
|
5595
5703
|
return iconAvatarComponents[iconAvatar.name];
|
|
5596
5704
|
}, [
|
|
5597
5705
|
iconAvatar
|
|
@@ -5633,7 +5741,7 @@ var Avatar6 = function(param) {
|
|
|
5633
5741
|
});
|
|
5634
5742
|
};
|
|
5635
5743
|
// src/components/components/ComponentsProvider.tsx
|
|
5636
|
-
import { useMemo as
|
|
5744
|
+
import { useMemo as useMemo20 } from "react";
|
|
5637
5745
|
// src/hooks/components/useComponents.ts
|
|
5638
5746
|
import { useContext as useContext16 } from "react";
|
|
5639
5747
|
var useComponents = function() {
|
|
@@ -5646,7 +5754,7 @@ var ComponentsProvider = function(_param) {
|
|
|
5646
5754
|
"children"
|
|
5647
5755
|
]);
|
|
5648
5756
|
var prevComponents = useComponents();
|
|
5649
|
-
var value =
|
|
5757
|
+
var value = useMemo20(function() {
|
|
5650
5758
|
return merge(prevComponents, rest);
|
|
5651
5759
|
}, [
|
|
5652
5760
|
rest,
|