@superinterface/react 2.10.1 → 2.12.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 +220 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -196
- package/dist/index.d.ts +2 -196
- package/dist/index.js +124 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/components/core/SuperinterfaceProvider/index.tsx
|
|
2
2
|
function _array_like_to_array(arr, len) {
|
|
3
3
|
if (len == null || len > arr.length) len = arr.length;
|
|
4
4
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -265,6 +265,8 @@ function _ts_generator(thisArg, body) {
|
|
|
265
265
|
}
|
|
266
266
|
var _2;
|
|
267
267
|
var _detect;
|
|
268
|
+
import { useRef } from "react";
|
|
269
|
+
// src/lib/misc/merge/index.ts
|
|
268
270
|
import _21 from "lodash";
|
|
269
271
|
// src/lib/misc/merge/customizer.ts
|
|
270
272
|
import _ from "lodash";
|
|
@@ -324,7 +326,10 @@ var SuperinterfaceContext = createContext({
|
|
|
324
326
|
queries: {},
|
|
325
327
|
mutations: {}
|
|
326
328
|
},
|
|
327
|
-
threadIdCookieOptions: options
|
|
329
|
+
threadIdCookieOptions: options,
|
|
330
|
+
createMessageAbortControllerRef: {
|
|
331
|
+
current: null
|
|
332
|
+
}
|
|
328
333
|
});
|
|
329
334
|
// src/hooks/core/useSuperinterfaceContext/index.ts
|
|
330
335
|
import { useContext } from "react";
|
|
@@ -336,7 +341,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
336
341
|
var SuperinterfaceProvider = function(param) {
|
|
337
342
|
var children = param.children, baseUrl2 = param.baseUrl, variables = param.variables, defaultOptions = param.defaultOptions, threadIdCookieOptions = param.threadIdCookieOptions;
|
|
338
343
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
339
|
-
var
|
|
344
|
+
var createMessageAbortControllerRef = useRef(null);
|
|
345
|
+
var value = merge(superinterfaceContext, _object_spread_props(_object_spread({}, baseUrl2 ? {
|
|
340
346
|
baseUrl: baseUrl2
|
|
341
347
|
} : {}, variables ? {
|
|
342
348
|
variables: variables
|
|
@@ -344,7 +350,9 @@ var SuperinterfaceProvider = function(param) {
|
|
|
344
350
|
defaultOptions: defaultOptions
|
|
345
351
|
} : {}, threadIdCookieOptions ? {
|
|
346
352
|
threadIdCookieOptions: threadIdCookieOptions
|
|
347
|
-
} : {})
|
|
353
|
+
} : {}), {
|
|
354
|
+
createMessageAbortControllerRef: createMessageAbortControllerRef
|
|
355
|
+
}));
|
|
348
356
|
return /* @__PURE__ */ jsx(SuperinterfaceContext.Provider, {
|
|
349
357
|
value: value,
|
|
350
358
|
children: children
|
|
@@ -700,7 +708,7 @@ var AssistantNameContext = createContext4("Assistant");
|
|
|
700
708
|
// src/components/threads/Thread/Messages/Content/MessageGroup/Content/index.tsx
|
|
701
709
|
import { Flex as Flex10 } from "@radix-ui/themes";
|
|
702
710
|
// src/components/threads/Thread/Message/index.tsx
|
|
703
|
-
import { useMemo as
|
|
711
|
+
import { useMemo as useMemo5, Fragment } from "react";
|
|
704
712
|
import { Box as Box9 } from "@radix-ui/themes";
|
|
705
713
|
// src/components/skeletons/StartingContentSkeleton/index.tsx
|
|
706
714
|
import { Skeleton as Skeleton2 } from "@radix-ui/themes";
|
|
@@ -985,6 +993,24 @@ var RunSteps = function(param) {
|
|
|
985
993
|
})
|
|
986
994
|
});
|
|
987
995
|
};
|
|
996
|
+
// src/hooks/messages/useIsMutatingMessage/index.ts
|
|
997
|
+
import { useMemo as useMemo4 } from "react";
|
|
998
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
999
|
+
var useIsMutatingMessage = function() {
|
|
1000
|
+
var threadContext = useSuperinterfaceContext();
|
|
1001
|
+
var mutatingMessagesCount = useIsMutating({
|
|
1002
|
+
mutationKey: [
|
|
1003
|
+
"createMessage",
|
|
1004
|
+
threadContext.variables
|
|
1005
|
+
]
|
|
1006
|
+
});
|
|
1007
|
+
var isMutatingMessage = useMemo4(function() {
|
|
1008
|
+
return mutatingMessagesCount > 0;
|
|
1009
|
+
}, [
|
|
1010
|
+
mutatingMessagesCount
|
|
1011
|
+
]);
|
|
1012
|
+
return isMutatingMessage;
|
|
1013
|
+
};
|
|
988
1014
|
// src/contexts/messages/MessageContext/index.ts
|
|
989
1015
|
import { createContext as createContext6 } from "react";
|
|
990
1016
|
var MessageContext = createContext6({
|
|
@@ -1147,7 +1173,7 @@ var TextContent = function(param) {
|
|
|
1147
1173
|
import { jsx as jsx30, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1148
1174
|
var Message = function(param) {
|
|
1149
1175
|
var message = param.message;
|
|
1150
|
-
var
|
|
1176
|
+
var _useMemo5 = _sliced_to_array(useMemo5(function() {
|
|
1151
1177
|
if (!message.runSteps.length) return [
|
|
1152
1178
|
[],
|
|
1153
1179
|
[]
|
|
@@ -1178,8 +1204,10 @@ var Message = function(param) {
|
|
|
1178
1204
|
];
|
|
1179
1205
|
}, [
|
|
1180
1206
|
message
|
|
1181
|
-
]), 2), olderRunSteps =
|
|
1182
|
-
var
|
|
1207
|
+
]), 2), olderRunSteps = _useMemo5[0], laterRunSteps = _useMemo5[1];
|
|
1208
|
+
var isMutatingMessage = useIsMutatingMessage();
|
|
1209
|
+
var isInProgress = useMemo5(function() {
|
|
1210
|
+
if (!isMutatingMessage) return false;
|
|
1183
1211
|
if (message.status === "in_progress") return true;
|
|
1184
1212
|
return message.runSteps.some(function(rs) {
|
|
1185
1213
|
return rs.status === "in_progress";
|
|
@@ -1308,10 +1336,10 @@ var StartingSkeleton = function(param) {
|
|
|
1308
1336
|
});
|
|
1309
1337
|
};
|
|
1310
1338
|
// src/hooks/messages/useLatestMessage/index.ts
|
|
1311
|
-
import { useMemo as
|
|
1339
|
+
import { useMemo as useMemo6 } from "react";
|
|
1312
1340
|
var useLatestMessage = function() {
|
|
1313
1341
|
var props = useMessages();
|
|
1314
|
-
return
|
|
1342
|
+
return useMemo6(function() {
|
|
1315
1343
|
return _object_spread_props(_object_spread({}, props), {
|
|
1316
1344
|
latestMessage: props.messages[0] || null
|
|
1317
1345
|
});
|
|
@@ -1325,24 +1353,6 @@ var isOptimistic = function(param) {
|
|
|
1325
1353
|
var id = param.id;
|
|
1326
1354
|
return _4.startsWith(id, "-");
|
|
1327
1355
|
};
|
|
1328
|
-
// src/hooks/messages/useIsMutatingMessage/index.ts
|
|
1329
|
-
import { useMemo as useMemo6 } from "react";
|
|
1330
|
-
import { useIsMutating } from "@tanstack/react-query";
|
|
1331
|
-
var useIsMutatingMessage = function() {
|
|
1332
|
-
var threadContext = useSuperinterfaceContext();
|
|
1333
|
-
var mutatingMessagesCount = useIsMutating({
|
|
1334
|
-
mutationKey: [
|
|
1335
|
-
"createMessage",
|
|
1336
|
-
threadContext.variables
|
|
1337
|
-
]
|
|
1338
|
-
});
|
|
1339
|
-
var isMutatingMessage = useMemo6(function() {
|
|
1340
|
-
return mutatingMessagesCount > 0;
|
|
1341
|
-
}, [
|
|
1342
|
-
mutatingMessagesCount
|
|
1343
|
-
]);
|
|
1344
|
-
return isMutatingMessage;
|
|
1345
|
-
};
|
|
1346
1356
|
// src/components/threads/Thread/Messages/Progress/index.tsx
|
|
1347
1357
|
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
1348
1358
|
var Progress = function() {
|
|
@@ -1367,14 +1377,14 @@ var Progress = function() {
|
|
|
1367
1377
|
// src/components/threads/Thread/Messages/Root/index.tsx
|
|
1368
1378
|
import { Flex as Flex11 } from "@radix-ui/themes";
|
|
1369
1379
|
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
1370
|
-
import { useRef as
|
|
1380
|
+
import { useRef as useRef3 } from "react";
|
|
1371
1381
|
import { useInView } from "react-intersection-observer";
|
|
1372
1382
|
// src/hooks/misc/useThrottledEffect/index.tsx
|
|
1373
1383
|
import _5 from "lodash";
|
|
1374
|
-
import { useRef, useEffect as useEffect2, useCallback } from "react";
|
|
1384
|
+
import { useRef as useRef2, useEffect as useEffect2, useCallback } from "react";
|
|
1375
1385
|
var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
1376
1386
|
var _cbRef;
|
|
1377
|
-
var cbRef =
|
|
1387
|
+
var cbRef = useRef2(cb);
|
|
1378
1388
|
var throttledCb = useCallback(_5.throttle(function() {
|
|
1379
1389
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1380
1390
|
args[_key] = arguments[_key];
|
|
@@ -1396,7 +1406,7 @@ var useThrottledEffect = function(cb, delay, additionalDeps) {
|
|
|
1396
1406
|
// src/hooks/misc/useInfiniteScroll/index.tsx
|
|
1397
1407
|
var useInfiniteScroll = function(param) {
|
|
1398
1408
|
var isFetchingNextPage = param.isFetchingNextPage, hasNextPage = param.hasNextPage, fetchNextPage = param.fetchNextPage;
|
|
1399
|
-
var containerRef =
|
|
1409
|
+
var containerRef = useRef3(null);
|
|
1400
1410
|
var _useInView = useInView({
|
|
1401
1411
|
root: containerRef.current,
|
|
1402
1412
|
rootMargin: "0px",
|
|
@@ -1486,8 +1496,8 @@ Messages.NextPageSkeleton = NextPageSkeleton;
|
|
|
1486
1496
|
// src/components/threads/Thread/MessageForm/index.tsx
|
|
1487
1497
|
import { Flex as Flex14, Text as Text5 } from "@radix-ui/themes";
|
|
1488
1498
|
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1489
|
-
import { ArrowUpIcon } from "@radix-ui/react-icons";
|
|
1490
|
-
import { IconButton
|
|
1499
|
+
import { ArrowUpIcon, StopIcon } from "@radix-ui/react-icons";
|
|
1500
|
+
import { IconButton } from "@radix-ui/themes";
|
|
1491
1501
|
// src/hooks/messages/useMessageFormContext/index.ts
|
|
1492
1502
|
import { useContext as useContext8 } from "react";
|
|
1493
1503
|
// src/contexts/messages/MessageFormContext/index.ts
|
|
@@ -1503,17 +1513,26 @@ var useMessageFormContext = function() {
|
|
|
1503
1513
|
// src/components/threads/Thread/MessageForm/Submit/index.tsx
|
|
1504
1514
|
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
1505
1515
|
var Submit = function() {
|
|
1516
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
1506
1517
|
var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading;
|
|
1518
|
+
if (isLoading) {
|
|
1519
|
+
return /* @__PURE__ */ jsx39(IconButton, {
|
|
1520
|
+
type: "button",
|
|
1521
|
+
onClick: function() {
|
|
1522
|
+
var _superinterfaceContext_createMessageAbortControllerRef_current;
|
|
1523
|
+
return (_superinterfaceContext_createMessageAbortControllerRef_current = superinterfaceContext.createMessageAbortControllerRef.current) === null || _superinterfaceContext_createMessageAbortControllerRef_current === void 0 ? void 0 : _superinterfaceContext_createMessageAbortControllerRef_current.abort();
|
|
1524
|
+
},
|
|
1525
|
+
children: /* @__PURE__ */ jsx39(StopIcon, {})
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1507
1528
|
return /* @__PURE__ */ jsx39(IconButton, {
|
|
1508
1529
|
type: "submit",
|
|
1509
|
-
disabled: isDisabled
|
|
1510
|
-
children: /* @__PURE__ */ jsx39(
|
|
1511
|
-
loading: isLoading,
|
|
1512
|
-
children: /* @__PURE__ */ jsx39(ArrowUpIcon, {})
|
|
1513
|
-
})
|
|
1530
|
+
disabled: isDisabled,
|
|
1531
|
+
children: /* @__PURE__ */ jsx39(ArrowUpIcon, {})
|
|
1514
1532
|
});
|
|
1515
1533
|
};
|
|
1516
1534
|
// src/components/threads/Thread/MessageForm/Root/index.tsx
|
|
1535
|
+
import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
1517
1536
|
import { useMemo as useMemo8 } from "react";
|
|
1518
1537
|
import { useForm, FormProvider } from "react-hook-form";
|
|
1519
1538
|
import { Box as Box12 } from "@radix-ui/themes";
|
|
@@ -2015,10 +2034,12 @@ var mutationFn = function(param) {
|
|
|
2015
2034
|
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
2016
2035
|
return function() {
|
|
2017
2036
|
var _ref = _async_to_generator(function(variables) {
|
|
2018
|
-
var response, parser, reader, messagesQueryKey, _ref, done, value;
|
|
2037
|
+
var abortController, response, parser, reader, messagesQueryKey, _ref, done, value;
|
|
2019
2038
|
return _ts_generator(this, function(_state) {
|
|
2020
2039
|
switch(_state.label){
|
|
2021
2040
|
case 0:
|
|
2041
|
+
abortController = new AbortController();
|
|
2042
|
+
superinterfaceContext.createMessageAbortControllerRef.current = abortController;
|
|
2022
2043
|
return [
|
|
2023
2044
|
4,
|
|
2024
2045
|
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), {
|
|
@@ -2026,7 +2047,8 @@ var mutationFn = function(param) {
|
|
|
2026
2047
|
body: JSON.stringify(body({
|
|
2027
2048
|
variables: variables,
|
|
2028
2049
|
superinterfaceContext: superinterfaceContext
|
|
2029
|
-
}))
|
|
2050
|
+
})),
|
|
2051
|
+
signal: abortController.signal
|
|
2030
2052
|
})
|
|
2031
2053
|
];
|
|
2032
2054
|
case 1:
|
|
@@ -2066,7 +2088,6 @@ var mutationFn = function(param) {
|
|
|
2066
2088
|
value: value,
|
|
2067
2089
|
messagesQueryKey: messagesQueryKey,
|
|
2068
2090
|
queryClient: queryClient,
|
|
2069
|
-
variables: variables,
|
|
2070
2091
|
superinterfaceContext: superinterfaceContext
|
|
2071
2092
|
});
|
|
2072
2093
|
return [
|
|
@@ -2140,9 +2161,26 @@ var Root2 = function(param) {
|
|
|
2140
2161
|
var formProps = useForm(formOptions);
|
|
2141
2162
|
var handleSubmit = formProps.handleSubmit, isSubmitting = formProps.formState.isSubmitting, reset = formProps.reset;
|
|
2142
2163
|
var addToast = useToasts().addToast;
|
|
2164
|
+
var queryClient = useQueryClient4();
|
|
2165
|
+
var threadContext = useSuperinterfaceContext();
|
|
2143
2166
|
var createMessage = useCreateMessage({
|
|
2144
2167
|
onError: function(error) {
|
|
2145
|
-
|
|
2168
|
+
if (error.name === "AbortError") {
|
|
2169
|
+
queryClient.invalidateQueries({
|
|
2170
|
+
queryKey: [
|
|
2171
|
+
"messages",
|
|
2172
|
+
threadContext.variables
|
|
2173
|
+
]
|
|
2174
|
+
});
|
|
2175
|
+
queryClient.invalidateQueries({
|
|
2176
|
+
queryKey: [
|
|
2177
|
+
"runs",
|
|
2178
|
+
threadContext.variables
|
|
2179
|
+
]
|
|
2180
|
+
});
|
|
2181
|
+
return;
|
|
2182
|
+
}
|
|
2183
|
+
addToast({
|
|
2146
2184
|
type: "error",
|
|
2147
2185
|
message: error.message
|
|
2148
2186
|
});
|
|
@@ -2164,6 +2202,7 @@ var Root2 = function(param) {
|
|
|
2164
2202
|
return [
|
|
2165
2203
|
4,
|
|
2166
2204
|
createMessage({
|
|
2205
|
+
// @ts-ignore-next-line
|
|
2167
2206
|
content: data2.content
|
|
2168
2207
|
})
|
|
2169
2208
|
];
|
|
@@ -2207,7 +2246,7 @@ var Root2 = function(param) {
|
|
|
2207
2246
|
};
|
|
2208
2247
|
// src/components/threads/Thread/MessageForm/Field/index.tsx
|
|
2209
2248
|
import { usePrevious } from "react-use";
|
|
2210
|
-
import { useContext as useContext9, useMemo as useMemo9, useRef as
|
|
2249
|
+
import { useContext as useContext9, useMemo as useMemo9, useRef as useRef4, useEffect as useEffect3 } from "react";
|
|
2211
2250
|
// src/components/textareas/TextareaBase/index.tsx
|
|
2212
2251
|
import { forwardRef as forwardRef3 } from "react";
|
|
2213
2252
|
import TextareaAutosize from "react-textarea-autosize";
|
|
@@ -2285,7 +2324,7 @@ var Control = function() {
|
|
|
2285
2324
|
isLoading
|
|
2286
2325
|
]);
|
|
2287
2326
|
var isDisabledPrevious = usePrevious(isDisabled);
|
|
2288
|
-
var textareaRef =
|
|
2327
|
+
var textareaRef = useRef4(null);
|
|
2289
2328
|
var textareaProps = register("content");
|
|
2290
2329
|
useEffect3(function() {
|
|
2291
2330
|
if (isDisabled) return;
|
|
@@ -2782,7 +2821,7 @@ var useStatus = function(param) {
|
|
|
2782
2821
|
// src/hooks/audioThreads/useRecorder/index.ts
|
|
2783
2822
|
import dayjs2 from "dayjs";
|
|
2784
2823
|
import { useAudioCapture } from "use-audio-capture";
|
|
2785
|
-
import { useMemo as useMemo11, useRef as
|
|
2824
|
+
import { useMemo as useMemo11, useRef as useRef5, useState as useState3, useCallback as useCallback3, useEffect as useEffect4 } from "react";
|
|
2786
2825
|
import { useAudioPlayer } from "react-use-audio-player";
|
|
2787
2826
|
import { useInterval } from "react-use";
|
|
2788
2827
|
var useRecorder = function(param) {
|
|
@@ -2853,7 +2892,7 @@ var useRecorder = function(param) {
|
|
|
2853
2892
|
}
|
|
2854
2893
|
});
|
|
2855
2894
|
var _useState35 = _sliced_to_array(useState3(null), 2), audioEngine = _useState35[0], setAudioEngine = _useState35[1];
|
|
2856
|
-
var isInited =
|
|
2895
|
+
var isInited = useRef5(false);
|
|
2857
2896
|
useEffect4(function() {
|
|
2858
2897
|
if (!mediaStream) return;
|
|
2859
2898
|
if (isInited.current) return;
|
|
@@ -2930,7 +2969,7 @@ var useRecorder = function(param) {
|
|
|
2930
2969
|
});
|
|
2931
2970
|
};
|
|
2932
2971
|
// src/hooks/audioThreads/useMessageAudio/index.ts
|
|
2933
|
-
import { useMemo as useMemo12, useRef as
|
|
2972
|
+
import { useMemo as useMemo12, useRef as useRef6, useState as useState4, useEffect as useEffect5 } from "react";
|
|
2934
2973
|
import nlp from "compromise";
|
|
2935
2974
|
import { Howler } from "howler";
|
|
2936
2975
|
import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
|
|
@@ -2969,15 +3008,17 @@ var getMessageSentences = function(param) {
|
|
|
2969
3008
|
var useMessageAudio = function(param) {
|
|
2970
3009
|
var onEnd = param.onEnd;
|
|
2971
3010
|
var _useState4 = _sliced_to_array(useState4(false), 2), isAudioPlayed = _useState4[0], setIsAudioPlayed = _useState4[1];
|
|
2972
|
-
var _useState41 = _sliced_to_array(useState4([]), 2),
|
|
3011
|
+
var _useState41 = _sliced_to_array(useState4([]), 2), stoppedMessageIds = _useState41[0], setStoppedMessageIds = _useState41[1];
|
|
3012
|
+
var _useState42 = _sliced_to_array(useState4([]), 2), playedMessageSentences = _useState42[0], setPlayedMessageSentences = _useState42[1];
|
|
2973
3013
|
var audioPlayer = useAudioPlayer2();
|
|
2974
3014
|
var nextAudioPlayer = useAudioPlayer2();
|
|
2975
3015
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
2976
|
-
var
|
|
3016
|
+
var _useState43 = _sliced_to_array(useState4(false), 2), isPlaying = _useState43[0], setIsPlaying = _useState43[1];
|
|
2977
3017
|
var latestMessageProps = useLatestMessage();
|
|
2978
3018
|
var unplayedMessageSentences = useMemo12(function() {
|
|
2979
3019
|
if (!latestMessageProps.latestMessage) return [];
|
|
2980
3020
|
if (latestMessageProps.latestMessage.role !== "assistant") return [];
|
|
3021
|
+
if (stoppedMessageIds.includes(latestMessageProps.latestMessage.id)) return [];
|
|
2981
3022
|
var input2 = input({
|
|
2982
3023
|
message: latestMessageProps.latestMessage
|
|
2983
3024
|
});
|
|
@@ -3024,6 +3065,14 @@ var useMessageAudio = function(param) {
|
|
|
3024
3065
|
onplay: function() {
|
|
3025
3066
|
setIsAudioPlayed(true);
|
|
3026
3067
|
},
|
|
3068
|
+
onstop: function() {
|
|
3069
|
+
setStoppedMessageIds(function(prev) {
|
|
3070
|
+
return _to_consumable_array(prev).concat([
|
|
3071
|
+
firstUnplayedMessageSentence.messageId
|
|
3072
|
+
]);
|
|
3073
|
+
});
|
|
3074
|
+
setIsPlaying(false);
|
|
3075
|
+
},
|
|
3027
3076
|
onload: function() {
|
|
3028
3077
|
var nextUnplayedMessageSentence = unplayedMessageSentences[1];
|
|
3029
3078
|
if (!nextUnplayedMessageSentence) return;
|
|
@@ -3064,8 +3113,8 @@ var useMessageAudio = function(param) {
|
|
|
3064
3113
|
}, [
|
|
3065
3114
|
audioPlayer
|
|
3066
3115
|
]);
|
|
3067
|
-
var
|
|
3068
|
-
var isAudioEngineInited =
|
|
3116
|
+
var _useState44 = _sliced_to_array(useState4(null), 2), audioEngine = _useState44[0], setAudioEngine = _useState44[1];
|
|
3117
|
+
var isAudioEngineInited = useRef6(false);
|
|
3069
3118
|
useEffect5(function() {
|
|
3070
3119
|
if (!audioPlayer.playing) return;
|
|
3071
3120
|
if (isAudioEngineInited.current) return;
|
|
@@ -3282,14 +3331,14 @@ var Visualization = function() {
|
|
|
3282
3331
|
});
|
|
3283
3332
|
};
|
|
3284
3333
|
// src/components/threads/AudioThread/Form/index.tsx
|
|
3285
|
-
import { SpeakerModerateIcon } from "@radix-ui/react-icons";
|
|
3286
3334
|
import { Flex as Flex24 } from "@radix-ui/themes";
|
|
3287
3335
|
// src/components/threads/AudioThread/Form/ActionButton/index.tsx
|
|
3288
3336
|
import { Flex as Flex23, IconButton as IconButton4 } from "@radix-ui/themes";
|
|
3289
|
-
import { PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
3337
|
+
import { StopIcon as StopIcon2, PauseIcon, ArrowUpIcon as ArrowUpIcon2, ResumeIcon } from "@radix-ui/react-icons";
|
|
3290
3338
|
import { jsx as jsx58, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3291
3339
|
var ActionButton = function() {
|
|
3292
3340
|
var audioThreadContext = useAudioThreadContext();
|
|
3341
|
+
var superinterfaceContext = useSuperinterfaceContext();
|
|
3293
3342
|
if (audioThreadContext.status === "recording") {
|
|
3294
3343
|
return /* @__PURE__ */ jsxs18(Flex23, {
|
|
3295
3344
|
align: "center",
|
|
@@ -3348,7 +3397,10 @@ var ActionButton = function() {
|
|
|
3348
3397
|
if (audioThreadContext.status === "playing") {
|
|
3349
3398
|
return /* @__PURE__ */ jsx58(IconButton4, {
|
|
3350
3399
|
onClick: function() {
|
|
3351
|
-
|
|
3400
|
+
var _superinterfaceContext_createMessageAbortControllerRef_current;
|
|
3401
|
+
audioThreadContext.messageAudioProps.stop();
|
|
3402
|
+
(_superinterfaceContext_createMessageAbortControllerRef_current = superinterfaceContext.createMessageAbortControllerRef.current) === null || _superinterfaceContext_createMessageAbortControllerRef_current === void 0 ? void 0 : _superinterfaceContext_createMessageAbortControllerRef_current.abort();
|
|
3403
|
+
audioThreadContext.recorderProps.start();
|
|
3352
3404
|
},
|
|
3353
3405
|
size: "4",
|
|
3354
3406
|
color: "gray",
|
|
@@ -3357,7 +3409,7 @@ var ActionButton = function() {
|
|
|
3357
3409
|
style: {
|
|
3358
3410
|
border: "2px solid var(--gray-8)"
|
|
3359
3411
|
},
|
|
3360
|
-
children: /* @__PURE__ */ jsx58(
|
|
3412
|
+
children: /* @__PURE__ */ jsx58(StopIcon2, {})
|
|
3361
3413
|
});
|
|
3362
3414
|
}
|
|
3363
3415
|
if (audioThreadContext.status === "playerPaused") {
|
|
@@ -3391,35 +3443,23 @@ var Form = function() {
|
|
|
3391
3443
|
direction: "column",
|
|
3392
3444
|
align: "center",
|
|
3393
3445
|
children: [
|
|
3394
|
-
/* @__PURE__ */
|
|
3446
|
+
/* @__PURE__ */ jsx59(Flex24, {
|
|
3395
3447
|
pb: "3",
|
|
3396
3448
|
align: "center",
|
|
3397
|
-
children:
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
px: "2",
|
|
3410
|
-
py: "1",
|
|
3411
|
-
style: {
|
|
3412
|
-
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-4)" : "var(--gray-4)",
|
|
3413
|
-
borderRadius: "var(--radius-6)"
|
|
3414
|
-
},
|
|
3415
|
-
children: /* @__PURE__ */ jsx59(BarsVisualizer, {
|
|
3416
|
-
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser,
|
|
3417
|
-
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-11)" : "var(--gray-11)",
|
|
3418
|
-
height: "20px",
|
|
3419
|
-
barWidth: "12px"
|
|
3420
|
-
})
|
|
3449
|
+
children: /* @__PURE__ */ jsx59(Flex24, {
|
|
3450
|
+
px: "2",
|
|
3451
|
+
py: "1",
|
|
3452
|
+
style: {
|
|
3453
|
+
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-4)" : "var(--gray-4)",
|
|
3454
|
+
borderRadius: "var(--radius-6)"
|
|
3455
|
+
},
|
|
3456
|
+
children: /* @__PURE__ */ jsx59(BarsVisualizer, {
|
|
3457
|
+
visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser,
|
|
3458
|
+
backgroundColor: audioThreadContext.status === "recording" ? "var(--accent-11)" : "var(--gray-11)",
|
|
3459
|
+
height: "20px",
|
|
3460
|
+
barWidth: "12px"
|
|
3421
3461
|
})
|
|
3422
|
-
|
|
3462
|
+
})
|
|
3423
3463
|
}),
|
|
3424
3464
|
/* @__PURE__ */ jsx59(ActionButton, {})
|
|
3425
3465
|
]
|
|
@@ -3465,7 +3505,7 @@ import { onlyText } from "react-children-utilities";
|
|
|
3465
3505
|
import { Flex as Flex25 } from "@radix-ui/themes";
|
|
3466
3506
|
// src/components/suggestions/Suggestions/Item.tsx
|
|
3467
3507
|
import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
|
|
3468
|
-
import { Text as Text7, Button as Button3, Spinner
|
|
3508
|
+
import { Text as Text7, Button as Button3, Spinner } from "@radix-ui/themes";
|
|
3469
3509
|
import { jsx as jsx62, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3470
3510
|
var Item = function(param) {
|
|
3471
3511
|
var suggestion = param.suggestion, isDisabled = param.isDisabled;
|
|
@@ -3499,7 +3539,7 @@ var Content5 = function(param) {
|
|
|
3499
3539
|
weight: "regular",
|
|
3500
3540
|
children: children
|
|
3501
3541
|
}),
|
|
3502
|
-
/* @__PURE__ */ jsx62(
|
|
3542
|
+
/* @__PURE__ */ jsx62(Spinner, {
|
|
3503
3543
|
loading: isPending,
|
|
3504
3544
|
children: /* @__PURE__ */ jsx62(ArrowUpIcon3, {
|
|
3505
3545
|
style: {
|