@superinterface/react 2.1.0 → 2.1.2
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 +54 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1321,19 +1321,6 @@ var useLatestRun = function() {
|
|
|
1321
1321
|
props
|
|
1322
1322
|
]);
|
|
1323
1323
|
};
|
|
1324
|
-
// src/lib/runs/isRunEditingMessage/index.ts
|
|
1325
|
-
import _4 from "lodash";
|
|
1326
|
-
var isRunEditingMessage = function(param) {
|
|
1327
|
-
var message = param.message;
|
|
1328
|
-
if (!message) return false;
|
|
1329
|
-
if (message.role === "user") return false;
|
|
1330
|
-
if (!message.run_id) return false;
|
|
1331
|
-
var hasContent = _4.some(message.content, function(content) {
|
|
1332
|
-
var _content_text;
|
|
1333
|
-
return content.type !== "text" || content.type === "text" && ((_content_text = content.text) === null || _content_text === void 0 ? void 0 : _content_text.value) !== "";
|
|
1334
|
-
});
|
|
1335
|
-
return !hasContent;
|
|
1336
|
-
};
|
|
1337
1324
|
// src/hooks/runs/usePollingContext/index.ts
|
|
1338
1325
|
import { useContext as useContext8 } from "react";
|
|
1339
1326
|
// src/contexts/runs/PollingContext/index.tsx
|
|
@@ -1367,9 +1354,7 @@ var isRunActive = function(param) {
|
|
|
1367
1354
|
if (!latestRunProps.latestRun) return false;
|
|
1368
1355
|
if (progressStatuses.includes(latestRunProps.latestRun.status)) return true;
|
|
1369
1356
|
if (stoppedStatuses.includes(latestRunProps.latestRun.status)) return false;
|
|
1370
|
-
return
|
|
1371
|
-
message: latestMessageProps.latestMessage
|
|
1372
|
-
});
|
|
1357
|
+
return false;
|
|
1373
1358
|
};
|
|
1374
1359
|
var useIsRunActive = function() {
|
|
1375
1360
|
var latestRunProps = useLatestRun();
|
|
@@ -1437,12 +1422,12 @@ import { Flex as Flex11 } from "@radix-ui/themes";
|
|
|
1437
1422
|
import { useRef as useRef2 } from "react";
|
|
1438
1423
|
import { useInView } from "react-intersection-observer";
|
|
1439
1424
|
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
1440
|
-
import
|
|
1425
|
+
import _4 from "lodash";
|
|
1441
1426
|
import { useRef, useEffect as useEffect2, useCallback } from "react";
|
|
1442
1427
|
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
1443
1428
|
var _cbRef;
|
|
1444
1429
|
var cbRef = useRef(cb);
|
|
1445
|
-
var throttledCb = useCallback(
|
|
1430
|
+
var throttledCb = useCallback(_4.throttle(function() {
|
|
1446
1431
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1447
1432
|
args[_key] = arguments[_key];
|
|
1448
1433
|
}
|
|
@@ -1769,10 +1754,10 @@ var useCreateRun = function() {
|
|
|
1769
1754
|
});
|
|
1770
1755
|
};
|
|
1771
1756
|
// src/lib/optimistic/isOptimistic.ts
|
|
1772
|
-
import
|
|
1757
|
+
import _5 from "lodash";
|
|
1773
1758
|
var isOptimistic = function(param) {
|
|
1774
1759
|
var id = param.id;
|
|
1775
|
-
return
|
|
1760
|
+
return _5.startsWith(id, "-");
|
|
1776
1761
|
};
|
|
1777
1762
|
// src/hooks/runs/useManageRuns/index.tsx
|
|
1778
1763
|
var useManageRuns = function() {
|
|
@@ -1851,7 +1836,7 @@ var refetch = function() {
|
|
|
1851
1836
|
queryClient = param.queryClient, threadContext = param.threadContext;
|
|
1852
1837
|
return [
|
|
1853
1838
|
4,
|
|
1854
|
-
queryClient.
|
|
1839
|
+
queryClient.refetchQueries({
|
|
1855
1840
|
queryKey: (_threadContext_defaultOptions_queries_queryKey = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey !== void 0 ? _threadContext_defaultOptions_queries_queryKey : [
|
|
1856
1841
|
"messages",
|
|
1857
1842
|
threadContext.variables
|
|
@@ -1862,7 +1847,7 @@ var refetch = function() {
|
|
|
1862
1847
|
_state.sent();
|
|
1863
1848
|
return [
|
|
1864
1849
|
4,
|
|
1865
|
-
queryClient.
|
|
1850
|
+
queryClient.refetchQueries({
|
|
1866
1851
|
queryKey: (_threadContext_defaultOptions_queries_queryKey1 = threadContext.defaultOptions.queries.queryKey) !== null && _threadContext_defaultOptions_queries_queryKey1 !== void 0 ? _threadContext_defaultOptions_queries_queryKey1 : [
|
|
1867
1852
|
"runs",
|
|
1868
1853
|
threadContext.variables
|
|
@@ -1885,12 +1870,15 @@ var refetch = function() {
|
|
|
1885
1870
|
var usePolling = function() {
|
|
1886
1871
|
var threadContext = useSuperinterfaceContext();
|
|
1887
1872
|
var queryClient = useQueryClient6();
|
|
1888
|
-
var
|
|
1873
|
+
var _usePollingContext = usePollingContext(), isPollRefetching = _usePollingContext.isPollRefetching, setIsPollRefetching = _usePollingContext.setIsPollRefetching;
|
|
1889
1874
|
var isRunActiveProps = useIsRunActive();
|
|
1890
1875
|
useInterval(/*#__PURE__*/ _async_to_generator(function() {
|
|
1891
1876
|
return _ts_generator(this, function(_state) {
|
|
1892
1877
|
switch(_state.label){
|
|
1893
1878
|
case 0:
|
|
1879
|
+
if (isPollRefetching) return [
|
|
1880
|
+
2
|
|
1881
|
+
];
|
|
1894
1882
|
setIsPollRefetching(true);
|
|
1895
1883
|
return [
|
|
1896
1884
|
4,
|
|
@@ -1926,8 +1914,7 @@ var usePolling = function() {
|
|
|
1926
1914
|
return null;
|
|
1927
1915
|
};
|
|
1928
1916
|
// src/hooks/actions/useManageActions/index.tsx
|
|
1929
|
-
import {
|
|
1930
|
-
import { useEffect as useEffect5 } from "react";
|
|
1917
|
+
import { useEffect as useEffect5, useState as useState2 } from "react";
|
|
1931
1918
|
// src/hooks/actions/useHandleAction/index.tsx
|
|
1932
1919
|
import { partob as partob2 } from "radash";
|
|
1933
1920
|
import { useMutation as useMutation2, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
@@ -1991,34 +1978,34 @@ var useHandleAction = function() {
|
|
|
1991
1978
|
superinterfaceContext: superinterfaceContext
|
|
1992
1979
|
})));
|
|
1993
1980
|
return _object_spread_props(_object_spread({}, props), {
|
|
1994
|
-
handleAction: partob2(props.
|
|
1981
|
+
handleAction: partob2(props.mutateAsync, threadContext.variables)
|
|
1995
1982
|
});
|
|
1996
1983
|
};
|
|
1997
1984
|
// src/hooks/actions/useManageActions/index.tsx
|
|
1998
1985
|
var useManageActions = function() {
|
|
1999
|
-
var queryClient = useQueryClient8();
|
|
2000
|
-
var threadContext = useSuperinterfaceContext();
|
|
2001
1986
|
var latestRunProps = useLatestRun();
|
|
2002
1987
|
var handleActionProps = useHandleAction();
|
|
1988
|
+
var _useState2 = _sliced_to_array(useState2([]), 2), handledRunIds = _useState2[0], setHandledRunIds = _useState2[1];
|
|
2003
1989
|
useEffect5(function() {
|
|
2004
1990
|
if (handleActionProps.isPending) return;
|
|
2005
1991
|
if (latestRunProps.isFetching) return;
|
|
2006
1992
|
if (!latestRunProps.latestRun) return;
|
|
2007
1993
|
if (latestRunProps.latestRun.status !== "requires_action") return;
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
]
|
|
1994
|
+
if (handledRunIds.includes(latestRunProps.latestRun.id)) return;
|
|
1995
|
+
setHandledRunIds(function(prev) {
|
|
1996
|
+
return _to_consumable_array(prev).concat([
|
|
1997
|
+
latestRunProps.latestRun.id
|
|
1998
|
+
]);
|
|
2013
1999
|
});
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2000
|
+
console.log("Requires action", {
|
|
2001
|
+
latestRunProps: latestRunProps,
|
|
2002
|
+
handleActionProps: handleActionProps
|
|
2017
2003
|
});
|
|
2018
2004
|
handleActionProps.handleAction({
|
|
2019
2005
|
latestRun: latestRunProps.latestRun
|
|
2020
2006
|
});
|
|
2021
2007
|
}, [
|
|
2008
|
+
handledRunIds,
|
|
2022
2009
|
handleActionProps,
|
|
2023
2010
|
latestRunProps
|
|
2024
2011
|
]);
|
|
@@ -2099,7 +2086,7 @@ Messages.NextPageSkeleton = NextPageSkeleton;
|
|
|
2099
2086
|
import { Flex as Flex14, Text as Text5 } from "@radix-ui/themes";
|
|
2100
2087
|
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
2101
2088
|
import { ArrowUpIcon } from "@radix-ui/react-icons";
|
|
2102
|
-
import {
|
|
2089
|
+
import { IconButton, Spinner } from "@radix-ui/themes";
|
|
2103
2090
|
// src/hooks/messages/useMessageFormContext/index.ts
|
|
2104
2091
|
import { useContext as useContext9 } from "react";
|
|
2105
2092
|
// src/contexts/messages/MessageFormContext/index.ts
|
|
@@ -2116,9 +2103,8 @@ var useMessageFormContext = function() {
|
|
|
2116
2103
|
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2117
2104
|
var Submit = function() {
|
|
2118
2105
|
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
2119
|
-
return /* @__PURE__ */ jsx39(
|
|
2106
|
+
return /* @__PURE__ */ jsx39(IconButton, {
|
|
2120
2107
|
type: "submit",
|
|
2121
|
-
radius: "large",
|
|
2122
2108
|
disabled: isDisabled || isLoading,
|
|
2123
2109
|
children: /* @__PURE__ */ jsx39(Spinner, {
|
|
2124
2110
|
loading: isLoading,
|
|
@@ -2131,7 +2117,7 @@ import { useMemo as useMemo9 } from "react";
|
|
|
2131
2117
|
import { useForm, FormProvider } from "react-hook-form";
|
|
2132
2118
|
// src/hooks/messages/useCreateMessage/index.ts
|
|
2133
2119
|
import { partob as partob3 } from "radash";
|
|
2134
|
-
import { useMutation as useMutation3, useQueryClient as
|
|
2120
|
+
import { useMutation as useMutation3, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
2135
2121
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/index.ts
|
|
2136
2122
|
import { omit } from "radash";
|
|
2137
2123
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/onMutate/data.ts
|
|
@@ -2278,7 +2264,7 @@ var useCreateMessage = function() {
|
|
|
2278
2264
|
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
2279
2265
|
onError: function() {}
|
|
2280
2266
|
}, _ref_onError = _ref.onError, onError = _ref_onError === void 0 ? function() {} : _ref_onError;
|
|
2281
|
-
var queryClient =
|
|
2267
|
+
var queryClient = useQueryClient8();
|
|
2282
2268
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2283
2269
|
var threadContext = useSuperinterfaceContext();
|
|
2284
2270
|
var props = useMutation3(_object_spread({
|
|
@@ -2526,11 +2512,11 @@ MessageForm.Submit = Submit;
|
|
|
2526
2512
|
// src/components/threads/Thread/Root/index.tsx
|
|
2527
2513
|
import { Flex as Flex15 } from "@radix-ui/themes";
|
|
2528
2514
|
// src/components/runs/PollingProvider/index.tsx
|
|
2529
|
-
import { useState as
|
|
2515
|
+
import { useState as useState3 } from "react";
|
|
2530
2516
|
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
2531
2517
|
var PollingProvider = function(param) {
|
|
2532
2518
|
var children = param.children;
|
|
2533
|
-
var
|
|
2519
|
+
var _useState3 = _sliced_to_array(useState3(false), 2), isPollRefetching = _useState3[0], setIsPollRefetching = _useState3[1];
|
|
2534
2520
|
return /* @__PURE__ */ jsx44(PollingContext.Provider, {
|
|
2535
2521
|
value: {
|
|
2536
2522
|
isPollRefetching: isPollRefetching,
|
|
@@ -2579,7 +2565,7 @@ var useMessageContext = function() {
|
|
|
2579
2565
|
return useContext11(MessageContext);
|
|
2580
2566
|
};
|
|
2581
2567
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
2582
|
-
import { useState as
|
|
2568
|
+
import { useState as useState4 } from "react";
|
|
2583
2569
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
2584
2570
|
import { createContext as createContext10 } from "react";
|
|
2585
2571
|
var ThreadDialogContext = createContext10({
|
|
@@ -2596,7 +2582,7 @@ import { jsx as jsx48 } from "react/jsx-runtime";
|
|
|
2596
2582
|
var Provider3 = function(param) {
|
|
2597
2583
|
var children = param.children;
|
|
2598
2584
|
var threadDialogContext = useThreadDialogContext();
|
|
2599
|
-
var
|
|
2585
|
+
var _useState4 = _sliced_to_array(useState4(threadDialogContext.isOpen), 2), isOpen = _useState4[0], setIsOpen = _useState4[1];
|
|
2600
2586
|
return /* @__PURE__ */ jsx48(ThreadDialogContext.Provider, {
|
|
2601
2587
|
value: {
|
|
2602
2588
|
isOpen: isOpen,
|
|
@@ -2606,7 +2592,7 @@ var Provider3 = function(param) {
|
|
|
2606
2592
|
});
|
|
2607
2593
|
};
|
|
2608
2594
|
// src/components/toasts/ToastsProvider/index.tsx
|
|
2609
|
-
import { useState as
|
|
2595
|
+
import { useState as useState5, useCallback as useCallback2 } from "react";
|
|
2610
2596
|
import * as Toast2 from "@radix-ui/react-toast";
|
|
2611
2597
|
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
2612
2598
|
import * as Toast from "@radix-ui/react-toast";
|
|
@@ -2645,7 +2631,7 @@ var CustomToast = function(param) {
|
|
|
2645
2631
|
import { jsx as jsx50, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2646
2632
|
var ToastsProvider = function(param) {
|
|
2647
2633
|
var children = param.children;
|
|
2648
|
-
var
|
|
2634
|
+
var _useState5 = _sliced_to_array(useState5([]), 2), toasts = _useState5[0], setToasts = _useState5[1];
|
|
2649
2635
|
var addToast = useCallback2(function(toast) {
|
|
2650
2636
|
return setToasts(function(prevToasts) {
|
|
2651
2637
|
return _to_consumable_array(prevToasts).concat([
|
|
@@ -2727,11 +2713,11 @@ var Trigger = function(param) {
|
|
|
2727
2713
|
});
|
|
2728
2714
|
};
|
|
2729
2715
|
// src/components/threads/ThreadDialog/Button/index.tsx
|
|
2730
|
-
import { IconButton } from "@radix-ui/themes";
|
|
2716
|
+
import { IconButton as IconButton2 } from "@radix-ui/themes";
|
|
2731
2717
|
import { ChatBubbleIcon } from "@radix-ui/react-icons";
|
|
2732
2718
|
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
2733
|
-
var
|
|
2734
|
-
return /* @__PURE__ */ jsx53(
|
|
2719
|
+
var Button2 = function() {
|
|
2720
|
+
return /* @__PURE__ */ jsx53(IconButton2, {
|
|
2735
2721
|
size: "4",
|
|
2736
2722
|
radius: "full",
|
|
2737
2723
|
children: /* @__PURE__ */ jsx53(ChatBubbleIcon, {})
|
|
@@ -2741,7 +2727,7 @@ var Button3 = function() {
|
|
|
2741
2727
|
import { Card as Card2, Inset, Flex as Flex19 } from "@radix-ui/themes";
|
|
2742
2728
|
// src/components/threads/ThreadDialog/Close/index.tsx
|
|
2743
2729
|
import { Cross1Icon } from "@radix-ui/react-icons";
|
|
2744
|
-
import { IconButton as
|
|
2730
|
+
import { IconButton as IconButton3, Flex as Flex18 } from "@radix-ui/themes";
|
|
2745
2731
|
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
2746
2732
|
var Close = function() {
|
|
2747
2733
|
var _useThreadDialogContext = useThreadDialogContext(), setIsOpen = _useThreadDialogContext.setIsOpen, isOpen = _useThreadDialogContext.isOpen;
|
|
@@ -2765,9 +2751,8 @@ var Close = function() {
|
|
|
2765
2751
|
style: {
|
|
2766
2752
|
zIndex: 9999999999
|
|
2767
2753
|
},
|
|
2768
|
-
children: /* @__PURE__ */ jsx54(
|
|
2754
|
+
children: /* @__PURE__ */ jsx54(IconButton3, {
|
|
2769
2755
|
size: "2",
|
|
2770
|
-
radius: "full",
|
|
2771
2756
|
variant: "soft",
|
|
2772
2757
|
children: /* @__PURE__ */ jsx54(Cross1Icon, {})
|
|
2773
2758
|
})
|
|
@@ -2866,14 +2851,14 @@ var ThreadDialog = function() {
|
|
|
2866
2851
|
children: [
|
|
2867
2852
|
/* @__PURE__ */ jsx56(Content4, {}),
|
|
2868
2853
|
/* @__PURE__ */ jsx56(Trigger, {
|
|
2869
|
-
children: /* @__PURE__ */ jsx56(
|
|
2854
|
+
children: /* @__PURE__ */ jsx56(Button2, {})
|
|
2870
2855
|
})
|
|
2871
2856
|
]
|
|
2872
2857
|
});
|
|
2873
2858
|
};
|
|
2874
2859
|
ThreadDialog.Root = Root6;
|
|
2875
2860
|
ThreadDialog.Trigger = Trigger;
|
|
2876
|
-
ThreadDialog.Button =
|
|
2861
|
+
ThreadDialog.Button = Button2;
|
|
2877
2862
|
ThreadDialog.Content = Content4;
|
|
2878
2863
|
// src/components/threads/AudioThread/Root/index.tsx
|
|
2879
2864
|
import "regenerator-runtime/runtime";
|
|
@@ -2975,18 +2960,18 @@ var useStatus = function(param) {
|
|
|
2975
2960
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
2976
2961
|
import dayjs from "dayjs";
|
|
2977
2962
|
import { useAudioCapture } from "use-audio-capture";
|
|
2978
|
-
import { useMemo as useMemo12, useRef as useRef4, useState as
|
|
2963
|
+
import { useMemo as useMemo12, useRef as useRef4, useState as useState6, useCallback as useCallback3, useEffect as useEffect7 } from "react";
|
|
2979
2964
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
2980
2965
|
import { useInterval as useInterval2 } from "react-use";
|
|
2981
2966
|
var useRecorder = function(param) {
|
|
2982
2967
|
var isStopOnSilence = param.isStopOnSilence, onStart = param.onStart, onStop = param.onStop;
|
|
2983
|
-
var
|
|
2984
|
-
var
|
|
2985
|
-
var
|
|
2986
|
-
var
|
|
2968
|
+
var _useState6 = _sliced_to_array(useState6(null), 2), silenceStart = _useState6[0], setSilenceStart = _useState6[1];
|
|
2969
|
+
var _useState61 = _sliced_to_array(useState6(null), 2), noiseStart = _useState61[0], setNoiseStart = _useState61[1];
|
|
2970
|
+
var _useState62 = _sliced_to_array(useState6(null), 2), mediaStream = _useState62[0], setMediaStream = _useState62[1];
|
|
2971
|
+
var _useState63 = _sliced_to_array(useState6("idle"), 2), status = _useState63[0], setStatus = _useState63[1];
|
|
2987
2972
|
var startAudioPlayer = useAudioPlayer();
|
|
2988
2973
|
var endAudioPlayer = useAudioPlayer();
|
|
2989
|
-
var
|
|
2974
|
+
var _useState64 = _sliced_to_array(useState6(false), 2), isLoaded = _useState64[0], setIsLoaded = _useState64[1];
|
|
2990
2975
|
useEffect7(function() {
|
|
2991
2976
|
if (isLoaded) return;
|
|
2992
2977
|
setIsLoaded(true);
|
|
@@ -3045,7 +3030,7 @@ var useRecorder = function(param) {
|
|
|
3045
3030
|
setNoiseStart(null);
|
|
3046
3031
|
}
|
|
3047
3032
|
});
|
|
3048
|
-
var
|
|
3033
|
+
var _useState65 = _sliced_to_array(useState6(null), 2), audioEngine = _useState65[0], setAudioEngine = _useState65[1];
|
|
3049
3034
|
var isInited = useRef4(false);
|
|
3050
3035
|
useEffect7(function() {
|
|
3051
3036
|
if (!mediaStream) return;
|
|
@@ -3123,7 +3108,7 @@ var useRecorder = function(param) {
|
|
|
3123
3108
|
});
|
|
3124
3109
|
};
|
|
3125
3110
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
3126
|
-
import { useMemo as useMemo13, useRef as useRef5, useState as
|
|
3111
|
+
import { useMemo as useMemo13, useRef as useRef5, useState as useState7, useEffect as useEffect8 } from "react";
|
|
3127
3112
|
import { Howler } from "howler";
|
|
3128
3113
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
3129
3114
|
// src/hooks/audioThreads/useMessageAudio/lib/input.ts
|
|
@@ -3149,7 +3134,7 @@ var isHtmlAudioSupported = !unsupportedNames.includes(((_detect = detect()) ===
|
|
|
3149
3134
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
3150
3135
|
var useMessageAudio = function(param) {
|
|
3151
3136
|
var onEnd = param.onEnd;
|
|
3152
|
-
var
|
|
3137
|
+
var _useState7 = _sliced_to_array(useState7([]), 2), playedMessages = _useState7[0], setPlayedMessages = _useState7[1];
|
|
3153
3138
|
var audioPlayer = useAudioPlayer2();
|
|
3154
3139
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
3155
3140
|
var latestMessageProps = useLatestMessage();
|
|
@@ -3193,7 +3178,7 @@ var useMessageAudio = function(param) {
|
|
|
3193
3178
|
onEnd
|
|
3194
3179
|
]);
|
|
3195
3180
|
var isInited = useRef5(false);
|
|
3196
|
-
var
|
|
3181
|
+
var _useState71 = _sliced_to_array(useState7(null), 2), audioEngine = _useState71[0], setAudioEngine = _useState71[1];
|
|
3197
3182
|
useEffect8(function() {
|
|
3198
3183
|
if (!audioPlayer.playing) return;
|
|
3199
3184
|
if (isInited.current) return;
|
|
@@ -3250,7 +3235,6 @@ var Root8 = function(param) {
|
|
|
3250
3235
|
return _ts_generator(this, function(_state) {
|
|
3251
3236
|
switch(_state.label){
|
|
3252
3237
|
case 0:
|
|
3253
|
-
console.log("creaing", chunks);
|
|
3254
3238
|
blob = new Blob(chunks, {
|
|
3255
3239
|
type: chunks[0].type
|
|
3256
3240
|
});
|
|
@@ -3312,25 +3296,30 @@ var useAudioThreadContext = function() {
|
|
|
3312
3296
|
return useContext13(AudioThreadContext);
|
|
3313
3297
|
};
|
|
3314
3298
|
// src/components/threads/AudioThread/BarsVisualizer/index.tsx
|
|
3315
|
-
import
|
|
3299
|
+
import _6 from "lodash";
|
|
3316
3300
|
import { Flex as Flex21, Grid } from "@radix-ui/themes";
|
|
3317
|
-
import { useState as
|
|
3301
|
+
import { useState as useState8, useEffect as useEffect9, useCallback as useCallback4 } from "react";
|
|
3318
3302
|
import { cluster } from "radash";
|
|
3319
3303
|
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
3320
3304
|
var barCount = 4;
|
|
3321
3305
|
var BarsVisualizer = function(param) {
|
|
3322
3306
|
var visualizationAnalyser = param.visualizationAnalyser, color = param.color, height = param.height, barWidth = param.barWidth;
|
|
3323
|
-
var
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3307
|
+
var _useState8 = _sliced_to_array(useState8(null), 2), cachedEmptyVisualizer = _useState8[0], setCachedEmptyVisualizer = _useState8[1];
|
|
3308
|
+
var getEmptyVisualizer = useCallback4(function() {
|
|
3309
|
+
var result = new AudioContext().createAnalyser();
|
|
3310
|
+
setCachedEmptyVisualizer(result);
|
|
3311
|
+
return result;
|
|
3312
|
+
}, [
|
|
3313
|
+
cachedEmptyVisualizer
|
|
3314
|
+
]);
|
|
3315
|
+
var _useState81 = _sliced_to_array(useState8([]), 2), barHeights = _useState81[0], setBarHeights = _useState81[1];
|
|
3327
3316
|
var draw = useCallback4(function(param) {
|
|
3328
3317
|
var visualizationAnalyser2 = param.visualizationAnalyser;
|
|
3329
3318
|
var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
|
|
3330
3319
|
visualizationAnalyser2.getByteFrequencyData(frequencyData);
|
|
3331
3320
|
var clusteredFrequencyData = cluster(frequencyData, frequencyData.length / barCount);
|
|
3332
3321
|
setBarHeights(clusteredFrequencyData.map(function(frequencyDataCluster) {
|
|
3333
|
-
return
|
|
3322
|
+
return _6.mean(frequencyDataCluster) / 255 * 100;
|
|
3334
3323
|
}));
|
|
3335
3324
|
requestAnimationFrame(function() {
|
|
3336
3325
|
return draw({
|
|
@@ -3340,12 +3329,13 @@ var BarsVisualizer = function(param) {
|
|
|
3340
3329
|
}, []);
|
|
3341
3330
|
useEffect9(function() {
|
|
3342
3331
|
draw({
|
|
3343
|
-
visualizationAnalyser: visualizationAnalyser ||
|
|
3332
|
+
visualizationAnalyser: visualizationAnalyser || cachedEmptyVisualizer || getEmptyVisualizer()
|
|
3344
3333
|
});
|
|
3345
3334
|
}, [
|
|
3346
3335
|
draw,
|
|
3347
3336
|
visualizationAnalyser,
|
|
3348
|
-
|
|
3337
|
+
cachedEmptyVisualizer,
|
|
3338
|
+
getEmptyVisualizer
|
|
3349
3339
|
]);
|
|
3350
3340
|
return /* @__PURE__ */ jsx58(Grid, {
|
|
3351
3341
|
columns: "".concat(barCount),
|
|
@@ -3407,7 +3397,7 @@ var Visualization = function() {
|
|
|
3407
3397
|
import { SpeakerModerateIcon } from "@radix-ui/react-icons";
|
|
3408
3398
|
import { Flex as Flex24 } from "@radix-ui/themes";
|
|
3409
3399
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
3410
|
-
import { Flex as Flex23, IconButton as
|
|
3400
|
+
import { Flex as Flex23, IconButton as IconButton4 } from "@radix-ui/themes";
|
|
3411
3401
|
import { PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
3412
3402
|
import { jsx as jsx60, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3413
3403
|
var ActionButton = function() {
|
|
@@ -3419,7 +3409,7 @@ var ActionButton = function() {
|
|
|
3419
3409
|
/* @__PURE__ */ jsx60(Flex23, {
|
|
3420
3410
|
mr: "3",
|
|
3421
3411
|
ml: "-7",
|
|
3422
|
-
children: /* @__PURE__ */ jsx60(
|
|
3412
|
+
children: /* @__PURE__ */ jsx60(IconButton4, {
|
|
3423
3413
|
onClick: audioThreadContext.recorderProps.pause,
|
|
3424
3414
|
color: "gray",
|
|
3425
3415
|
radius: "full",
|
|
@@ -3427,27 +3417,22 @@ var ActionButton = function() {
|
|
|
3427
3417
|
children: /* @__PURE__ */ jsx60(PauseIcon, {})
|
|
3428
3418
|
})
|
|
3429
3419
|
}),
|
|
3430
|
-
/* @__PURE__ */ jsx60(
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
style: {
|
|
3441
|
-
border: "2px solid var(--gray-8)"
|
|
3442
|
-
},
|
|
3443
|
-
children: /* @__PURE__ */ jsx60(ArrowUpIcon2, {})
|
|
3444
|
-
})
|
|
3420
|
+
/* @__PURE__ */ jsx60(IconButton4, {
|
|
3421
|
+
onClick: audioThreadContext.recorderProps.stop,
|
|
3422
|
+
color: "gray",
|
|
3423
|
+
highContrast: true,
|
|
3424
|
+
radius: "full",
|
|
3425
|
+
size: "4",
|
|
3426
|
+
style: {
|
|
3427
|
+
border: "2px solid var(--gray-8)"
|
|
3428
|
+
},
|
|
3429
|
+
children: /* @__PURE__ */ jsx60(ArrowUpIcon2, {})
|
|
3445
3430
|
})
|
|
3446
3431
|
]
|
|
3447
3432
|
});
|
|
3448
3433
|
}
|
|
3449
3434
|
if (audioThreadContext.status === "recorderPaused") {
|
|
3450
|
-
return /* @__PURE__ */ jsx60(
|
|
3435
|
+
return /* @__PURE__ */ jsx60(IconButton4, {
|
|
3451
3436
|
onClick: audioThreadContext.recorderProps.resume,
|
|
3452
3437
|
color: "red",
|
|
3453
3438
|
radius: "full",
|
|
@@ -3459,7 +3444,7 @@ var ActionButton = function() {
|
|
|
3459
3444
|
});
|
|
3460
3445
|
}
|
|
3461
3446
|
if (audioThreadContext.status === "idle") {
|
|
3462
|
-
return /* @__PURE__ */ jsx60(
|
|
3447
|
+
return /* @__PURE__ */ jsx60(IconButton4, {
|
|
3463
3448
|
onClick: function() {
|
|
3464
3449
|
return audioThreadContext.recorderProps.start();
|
|
3465
3450
|
},
|
|
@@ -3472,7 +3457,7 @@ var ActionButton = function() {
|
|
|
3472
3457
|
});
|
|
3473
3458
|
}
|
|
3474
3459
|
if (audioThreadContext.status === "playing") {
|
|
3475
|
-
return /* @__PURE__ */ jsx60(
|
|
3460
|
+
return /* @__PURE__ */ jsx60(IconButton4, {
|
|
3476
3461
|
onClick: function() {
|
|
3477
3462
|
return audioThreadContext.messageAudioProps.pause();
|
|
3478
3463
|
},
|
|
@@ -3486,7 +3471,7 @@ var ActionButton = function() {
|
|
|
3486
3471
|
});
|
|
3487
3472
|
}
|
|
3488
3473
|
if (audioThreadContext.status === "playerPaused") {
|
|
3489
|
-
return /* @__PURE__ */ jsx60(
|
|
3474
|
+
return /* @__PURE__ */ jsx60(IconButton4, {
|
|
3490
3475
|
onClick: function() {
|
|
3491
3476
|
return audioThreadContext.messageAudioProps.play();
|
|
3492
3477
|
},
|
|
@@ -3499,7 +3484,7 @@ var ActionButton = function() {
|
|
|
3499
3484
|
children: /* @__PURE__ */ jsx60(ResumeIcon, {})
|
|
3500
3485
|
});
|
|
3501
3486
|
}
|
|
3502
|
-
return /* @__PURE__ */ jsx60(
|
|
3487
|
+
return /* @__PURE__ */ jsx60(IconButton4, {
|
|
3503
3488
|
size: "4",
|
|
3504
3489
|
color: "red",
|
|
3505
3490
|
radius: "full",
|
|
@@ -3573,25 +3558,25 @@ var AudioThreadDialog = function() {
|
|
|
3573
3558
|
children: /* @__PURE__ */ jsx63(AudioThread, {})
|
|
3574
3559
|
}),
|
|
3575
3560
|
/* @__PURE__ */ jsx63(Trigger, {
|
|
3576
|
-
children: /* @__PURE__ */ jsx63(
|
|
3561
|
+
children: /* @__PURE__ */ jsx63(Button2, {})
|
|
3577
3562
|
})
|
|
3578
3563
|
]
|
|
3579
3564
|
});
|
|
3580
3565
|
};
|
|
3581
3566
|
AudioThreadDialog.Root = Root6;
|
|
3582
3567
|
AudioThreadDialog.Trigger = Trigger;
|
|
3583
|
-
AudioThreadDialog.Button =
|
|
3568
|
+
AudioThreadDialog.Button = Button2;
|
|
3584
3569
|
AudioThreadDialog.Content = Content4;
|
|
3585
3570
|
// src/components/suggestions/Suggestions/index.tsx
|
|
3586
|
-
import { useMemo as
|
|
3571
|
+
import { useMemo as useMemo16 } from "react";
|
|
3587
3572
|
// src/components/suggestions/Suggestions/Content.tsx
|
|
3588
|
-
import { useMemo as
|
|
3573
|
+
import { useMemo as useMemo15 } from "react";
|
|
3589
3574
|
import { isEmpty as isEmpty2 } from "radash";
|
|
3590
3575
|
import { onlyText } from "react-children-utilities";
|
|
3591
3576
|
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3592
3577
|
// src/components/suggestions/Suggestions/Item.tsx
|
|
3593
3578
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3594
|
-
import { Text as Text7, Button as
|
|
3579
|
+
import { Text as Text7, Button as Button3, Spinner as Spinner2 } from "@radix-ui/themes";
|
|
3595
3580
|
import { jsx as jsx64, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3596
3581
|
var Item = function(param) {
|
|
3597
3582
|
var suggestion = param.suggestion, isDisabled = param.isDisabled;
|
|
@@ -3610,7 +3595,7 @@ var Item = function(param) {
|
|
|
3610
3595
|
};
|
|
3611
3596
|
var Content5 = function(param) {
|
|
3612
3597
|
var onClick = param.onClick, isDisabled = param.isDisabled, isPending = param.isPending, children = param.children;
|
|
3613
|
-
return /* @__PURE__ */ jsxs23(
|
|
3598
|
+
return /* @__PURE__ */ jsxs23(Button3, {
|
|
3614
3599
|
variant: "soft",
|
|
3615
3600
|
onClick: onClick,
|
|
3616
3601
|
disabled: isDisabled,
|
|
@@ -3642,7 +3627,7 @@ import { jsx as jsx65 } from "react/jsx-runtime";
|
|
|
3642
3627
|
var Content6 = function(param) {
|
|
3643
3628
|
var children = param.children;
|
|
3644
3629
|
var isRunActiveProps = useIsRunActive();
|
|
3645
|
-
var suggestions =
|
|
3630
|
+
var suggestions = useMemo15(function() {
|
|
3646
3631
|
return onlyText(children).split(/\r?\n/).filter(function(c) {
|
|
3647
3632
|
return !isEmpty2(c);
|
|
3648
3633
|
}).map(function(c) {
|
|
@@ -3651,7 +3636,7 @@ var Content6 = function(param) {
|
|
|
3651
3636
|
}, [
|
|
3652
3637
|
children
|
|
3653
3638
|
]);
|
|
3654
|
-
var isDisabled =
|
|
3639
|
+
var isDisabled = useMemo15(function() {
|
|
3655
3640
|
return isRunActiveProps.isRunActive;
|
|
3656
3641
|
}, [
|
|
3657
3642
|
isRunActiveProps
|
|
@@ -3674,7 +3659,7 @@ import { jsx as jsx66 } from "react/jsx-runtime";
|
|
|
3674
3659
|
var Suggestions = function(param) {
|
|
3675
3660
|
var children = param.children;
|
|
3676
3661
|
var latestMessageProps = useLatestMessage();
|
|
3677
|
-
var isDisabled =
|
|
3662
|
+
var isDisabled = useMemo16(function() {
|
|
3678
3663
|
var // @ts-ignore-next-line
|
|
3679
3664
|
_latestMessageProps_latestMessage_metadata, _latestMessageProps_latestMessage;
|
|
3680
3665
|
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;
|
|
@@ -3689,14 +3674,14 @@ var Suggestions = function(param) {
|
|
|
3689
3674
|
};
|
|
3690
3675
|
Suggestions.Item = Item;
|
|
3691
3676
|
// src/components/markdown/MarkdownProvider/index.tsx
|
|
3692
|
-
import { useMemo as
|
|
3677
|
+
import { useMemo as useMemo17 } from "react";
|
|
3693
3678
|
import { jsx as jsx67 } from "react/jsx-runtime";
|
|
3694
3679
|
var MarkdownProvider = function(_param) {
|
|
3695
3680
|
var children = _param.children, rest = _object_without_properties(_param, [
|
|
3696
3681
|
"children"
|
|
3697
3682
|
]);
|
|
3698
3683
|
var prevMarkdownContext = useMarkdownContext();
|
|
3699
|
-
var value =
|
|
3684
|
+
var value = useMemo17(function() {
|
|
3700
3685
|
return merge(prevMarkdownContext, rest);
|
|
3701
3686
|
}, [
|
|
3702
3687
|
rest,
|