@superinterface/react 5.3.0-beta.11 → 5.3.0-beta.13
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 +58 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +58 -67
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +11 -11
- package/dist/types/index.d.ts +11 -11
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { MessagesPage, ThreadStorageOptions, StyleProps, SerializedMessage, UseCreateMessageVariables, DefaultAudioSegment,
|
|
2
|
+
import { MessagesPage, ThreadStorageOptions, StyleProps, SerializedMessage, UseCreateMessageVariables, DefaultAudioSegment, PlayArgs, MessageAudioOverrides, AudioRuntime, Avatar as Avatar$1, SerializedRunStep, ToolCall, MessageGroup as MessageGroup$1 } from './types/index.cjs';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
5
5
|
import * as react_hook_form from 'react-hook-form';
|
|
@@ -581,7 +581,7 @@ declare const AudioThreadDialog: {
|
|
|
581
581
|
|
|
582
582
|
type Args$6<TSegment = DefaultAudioSegment> = {
|
|
583
583
|
children: React.ReactNode;
|
|
584
|
-
play?: (args:
|
|
584
|
+
play?: (args: PlayArgs<TSegment>) => Promise<void> | void;
|
|
585
585
|
playSegments?: MessageAudioOverrides<TSegment>['playSegments'];
|
|
586
586
|
getSegments?: MessageAudioOverrides<TSegment>['getSegments'];
|
|
587
587
|
onEnd?: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { MessagesPage, ThreadStorageOptions, StyleProps, SerializedMessage, UseCreateMessageVariables, DefaultAudioSegment,
|
|
2
|
+
import { MessagesPage, ThreadStorageOptions, StyleProps, SerializedMessage, UseCreateMessageVariables, DefaultAudioSegment, PlayArgs, MessageAudioOverrides, AudioRuntime, Avatar as Avatar$1, SerializedRunStep, ToolCall, MessageGroup as MessageGroup$1 } from './types/index.js';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
5
5
|
import * as react_hook_form from 'react-hook-form';
|
|
@@ -581,7 +581,7 @@ declare const AudioThreadDialog: {
|
|
|
581
581
|
|
|
582
582
|
type Args$6<TSegment = DefaultAudioSegment> = {
|
|
583
583
|
children: React.ReactNode;
|
|
584
|
-
play?: (args:
|
|
584
|
+
play?: (args: PlayArgs<TSegment>) => Promise<void> | void;
|
|
585
585
|
playSegments?: MessageAudioOverrides<TSegment>['playSegments'];
|
|
586
586
|
getSegments?: MessageAudioOverrides<TSegment>['getSegments'];
|
|
587
587
|
onEnd?: () => void;
|
package/dist/index.js
CHANGED
|
@@ -47381,6 +47381,27 @@ var getIncrementalSegments = function(prev, nextInput, now) {
|
|
|
47381
47381
|
touched: now
|
|
47382
47382
|
};
|
|
47383
47383
|
};
|
|
47384
|
+
var getDefaultSegments = function(prev, input2, message, nowTs) {
|
|
47385
|
+
var base = getIncrementalSegments(prev, input2, nowTs);
|
|
47386
|
+
var fullSegments = base.segments;
|
|
47387
|
+
var readyCount = fullSegments.length;
|
|
47388
|
+
if (readyCount > 0 && !isOptimistic({
|
|
47389
|
+
id: message.id
|
|
47390
|
+
}) && message.status === "in_progress") {
|
|
47391
|
+
var last3 = fullSegments[fullSegments.length - 1];
|
|
47392
|
+
if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
|
|
47393
|
+
}
|
|
47394
|
+
var readySegments = fullSegments.slice(0, Math.max(0, readyCount));
|
|
47395
|
+
var playable = readyCount === fullSegments.length ? fullSegments : readySegments;
|
|
47396
|
+
return {
|
|
47397
|
+
entry: {
|
|
47398
|
+
input: base.input,
|
|
47399
|
+
segments: base.segments,
|
|
47400
|
+
touched: nowTs
|
|
47401
|
+
},
|
|
47402
|
+
playable: playable
|
|
47403
|
+
};
|
|
47404
|
+
};
|
|
47384
47405
|
var segmentsEqual = function(a, b) {
|
|
47385
47406
|
if (a === b) return true;
|
|
47386
47407
|
if (a.length !== b.length) return false;
|
|
@@ -47419,16 +47440,6 @@ var useMessageAudio = function(_ref) {
|
|
|
47419
47440
|
setIsAudioPlayed(true);
|
|
47420
47441
|
}
|
|
47421
47442
|
}, []);
|
|
47422
|
-
var segmentToText = useCallback7(function(segment) {
|
|
47423
|
-
if (typeof segment === "string") return segment;
|
|
47424
|
-
if (segment && (typeof segment === "undefined" ? "undefined" : _type_of(segment)) === "object" && "text" in segment) {
|
|
47425
|
-
var value = segment.text;
|
|
47426
|
-
if (typeof value === "string") return value;
|
|
47427
|
-
}
|
|
47428
|
-
if (segment == null) return void 0;
|
|
47429
|
-
var stringified = String(segment);
|
|
47430
|
-
return stringified.length > 0 ? stringified : void 0;
|
|
47431
|
-
}, []);
|
|
47432
47443
|
var checkForCompletion = useCallback7(function() {
|
|
47433
47444
|
if (activeSegmentsRef.current > 0) return;
|
|
47434
47445
|
var hasPending = audioQueueRef.current.some(function(m) {
|
|
@@ -47451,7 +47462,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47451
47462
|
}
|
|
47452
47463
|
var run = /* @__PURE__ */ function() {
|
|
47453
47464
|
var _ref2 = _asyncToGenerator11(function() {
|
|
47454
|
-
var assistantsDesc, assistantsAsc, nowTs, lastNIds, prevQueue, prevById, prevUnfinishedIds, streamingIds, includeIds, segCache, nextQueue, changed, touch, i, _existing$nextIndex, _existing$stopped, m_6,
|
|
47465
|
+
var assistantsDesc, assistantsAsc, nowTs, lastNIds, prevQueue, prevById, prevUnfinishedIds, streamingIds, includeIds, segCache, nextQueue, changed, touch, i, _existing$nextIndex, _existing$stopped, m_6, input2, prevEntry, nextEntry, playableSegments, customSegments, safeSegments, _getDefaultSegments, entry_0, playable, existing, nextIndex, stopped, reuse, unfinished, finished, prunedFinished, combined, i_0, idsInQueue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, id_3, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, id_4, entries, toRemove, i_1;
|
|
47455
47466
|
return _ts_generator(this, function(_state) {
|
|
47456
47467
|
switch(_state.label){
|
|
47457
47468
|
case 0:
|
|
@@ -47512,10 +47523,10 @@ var useMessageAudio = function(_ref) {
|
|
|
47512
47523
|
3,
|
|
47513
47524
|
5
|
|
47514
47525
|
];
|
|
47515
|
-
|
|
47526
|
+
input2 = input({
|
|
47516
47527
|
message: m_6
|
|
47517
47528
|
});
|
|
47518
|
-
if (
|
|
47529
|
+
if (input2 == null) {
|
|
47519
47530
|
segCache.delete(m_6.id);
|
|
47520
47531
|
messagesByIdRef.current.delete(m_6.id);
|
|
47521
47532
|
return [
|
|
@@ -47535,14 +47546,14 @@ var useMessageAudio = function(_ref) {
|
|
|
47535
47546
|
4,
|
|
47536
47547
|
Promise.resolve(providedGetSegments({
|
|
47537
47548
|
message: m_6,
|
|
47538
|
-
|
|
47549
|
+
input: input2
|
|
47539
47550
|
}))
|
|
47540
47551
|
];
|
|
47541
47552
|
case 2:
|
|
47542
47553
|
customSegments = _state.sent();
|
|
47543
47554
|
safeSegments = Array.isArray(customSegments) ? customSegments : [];
|
|
47544
47555
|
nextEntry = {
|
|
47545
|
-
input:
|
|
47556
|
+
input: input2,
|
|
47546
47557
|
segments: safeSegments,
|
|
47547
47558
|
touched: nowTs
|
|
47548
47559
|
};
|
|
@@ -47552,29 +47563,16 @@ var useMessageAudio = function(_ref) {
|
|
|
47552
47563
|
4
|
|
47553
47564
|
];
|
|
47554
47565
|
case 3:
|
|
47555
|
-
|
|
47556
|
-
nextEntry =
|
|
47557
|
-
|
|
47558
|
-
segments: base.segments,
|
|
47559
|
-
touched: nowTs
|
|
47560
|
-
};
|
|
47561
|
-
fullSegments = base.segments;
|
|
47562
|
-
readyCount = fullSegments.length;
|
|
47563
|
-
if (readyCount > 0 && !isOptimistic({
|
|
47564
|
-
id: m_6.id
|
|
47565
|
-
}) && m_6.status === "in_progress") {
|
|
47566
|
-
last3 = fullSegments[fullSegments.length - 1];
|
|
47567
|
-
if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
|
|
47568
|
-
}
|
|
47569
|
-
readySegments = fullSegments.slice(0, Math.max(0, readyCount));
|
|
47570
|
-
playableSegments = readyCount === fullSegments.length ? fullSegments : readySegments;
|
|
47566
|
+
_getDefaultSegments = getDefaultSegments(prevEntry, input2, m_6, nowTs), entry_0 = _getDefaultSegments.entry, playable = _getDefaultSegments.playable;
|
|
47567
|
+
nextEntry = entry_0;
|
|
47568
|
+
playableSegments = playable;
|
|
47571
47569
|
_state.label = 4;
|
|
47572
47570
|
case 4:
|
|
47573
47571
|
touch(m_6.id, nextEntry);
|
|
47574
47572
|
existing = prevById.get(m_6.id);
|
|
47575
47573
|
nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, playableSegments.length);
|
|
47576
47574
|
stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
|
|
47577
|
-
reuse = !!existing && existing.status === m_6.status && existing.
|
|
47575
|
+
reuse = !!existing && existing.status === m_6.status && existing.messageInput === input2 && existing.nextIndex === nextIndex && existing.stopped === stopped && segmentsEqual(existing.segments, playableSegments);
|
|
47578
47576
|
if (reuse) {
|
|
47579
47577
|
nextQueue.push(existing);
|
|
47580
47578
|
} else {
|
|
@@ -47584,7 +47582,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47584
47582
|
segments: playableSegments,
|
|
47585
47583
|
nextIndex: nextIndex,
|
|
47586
47584
|
stopped: stopped,
|
|
47587
|
-
|
|
47585
|
+
messageInput: input2
|
|
47588
47586
|
});
|
|
47589
47587
|
changed = true;
|
|
47590
47588
|
}
|
|
@@ -47737,13 +47735,13 @@ var useMessageAudio = function(_ref) {
|
|
|
47737
47735
|
]);
|
|
47738
47736
|
var defaultPlay = useCallback7(/* @__PURE__ */ function() {
|
|
47739
47737
|
var _ref5 = _asyncToGenerator11(function(_ref4) {
|
|
47740
|
-
var
|
|
47738
|
+
var input_0, onPlay, onStop, onEnd_0, searchParams;
|
|
47741
47739
|
return _ts_generator(this, function(_state) {
|
|
47742
47740
|
switch(_state.label){
|
|
47743
47741
|
case 0:
|
|
47744
|
-
|
|
47742
|
+
input_0 = _ref4.input, onPlay = _ref4.onPlay, onStop = _ref4.onStop, onEnd_0 = _ref4.onEnd;
|
|
47745
47743
|
searchParams = new URLSearchParams(_objectSpread47({
|
|
47746
|
-
input:
|
|
47744
|
+
input: input_0
|
|
47747
47745
|
}, superinterfaceContext.variables));
|
|
47748
47746
|
return [
|
|
47749
47747
|
4,
|
|
@@ -47778,10 +47776,8 @@ var useMessageAudio = function(_ref) {
|
|
|
47778
47776
|
if (!owner) return;
|
|
47779
47777
|
var nextSegment = owner.segments[current.nextIndex];
|
|
47780
47778
|
if (!nextSegment) return;
|
|
47781
|
-
var nextText = segmentToText(nextSegment);
|
|
47782
|
-
if (!nextText) return;
|
|
47783
47779
|
var nextSearchParams = new URLSearchParams(_objectSpread47({
|
|
47784
|
-
input:
|
|
47780
|
+
input: nextSegment
|
|
47785
47781
|
}, superinterfaceContext.variables));
|
|
47786
47782
|
nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
|
|
47787
47783
|
format: "mp3",
|
|
@@ -47807,37 +47803,28 @@ var useMessageAudio = function(_ref) {
|
|
|
47807
47803
|
audioPlayer,
|
|
47808
47804
|
nextAudioPlayer,
|
|
47809
47805
|
superinterfaceContext,
|
|
47810
|
-
|
|
47806
|
+
markAudioPlayed
|
|
47811
47807
|
]);
|
|
47812
47808
|
var playInternal = useCallback7(/* @__PURE__ */ function() {
|
|
47813
|
-
var _ref6 = _asyncToGenerator11(function(
|
|
47814
|
-
var text, args;
|
|
47809
|
+
var _ref6 = _asyncToGenerator11(function(segment, handlers2) {
|
|
47815
47810
|
return _ts_generator(this, function(_state) {
|
|
47816
47811
|
switch(_state.label){
|
|
47817
47812
|
case 0:
|
|
47818
|
-
text = segmentToText(segment_0);
|
|
47819
|
-
if (!text) {
|
|
47820
|
-
handlers2.onEnd();
|
|
47821
|
-
return [
|
|
47822
|
-
2
|
|
47823
|
-
];
|
|
47824
|
-
}
|
|
47825
|
-
args = {
|
|
47826
|
-
input: text,
|
|
47827
|
-
onPlay: function() {
|
|
47828
|
-
markAudioPlayed();
|
|
47829
|
-
handlers2.onPlay();
|
|
47830
|
-
},
|
|
47831
|
-
onStop: handlers2.onStop,
|
|
47832
|
-
onEnd: handlers2.onEnd
|
|
47833
|
-
};
|
|
47834
47813
|
if (!providedPlay) return [
|
|
47835
47814
|
3,
|
|
47836
47815
|
2
|
|
47837
47816
|
];
|
|
47838
47817
|
return [
|
|
47839
47818
|
4,
|
|
47840
|
-
Promise.resolve(providedPlay(
|
|
47819
|
+
Promise.resolve(providedPlay({
|
|
47820
|
+
input: segment,
|
|
47821
|
+
onPlay: function() {
|
|
47822
|
+
markAudioPlayed();
|
|
47823
|
+
handlers2.onPlay();
|
|
47824
|
+
},
|
|
47825
|
+
onStop: handlers2.onStop,
|
|
47826
|
+
onEnd: handlers2.onEnd
|
|
47827
|
+
}))
|
|
47841
47828
|
];
|
|
47842
47829
|
case 1:
|
|
47843
47830
|
_state.sent();
|
|
@@ -47847,7 +47834,12 @@ var useMessageAudio = function(_ref) {
|
|
|
47847
47834
|
case 2:
|
|
47848
47835
|
return [
|
|
47849
47836
|
4,
|
|
47850
|
-
defaultPlay(
|
|
47837
|
+
defaultPlay({
|
|
47838
|
+
input: segment,
|
|
47839
|
+
onPlay: handlers2.onPlay,
|
|
47840
|
+
onStop: handlers2.onStop,
|
|
47841
|
+
onEnd: handlers2.onEnd
|
|
47842
|
+
})
|
|
47851
47843
|
];
|
|
47852
47844
|
case 3:
|
|
47853
47845
|
_state.sent();
|
|
@@ -47861,7 +47853,6 @@ var useMessageAudio = function(_ref) {
|
|
|
47861
47853
|
return _ref6.apply(this, arguments);
|
|
47862
47854
|
};
|
|
47863
47855
|
}(), [
|
|
47864
|
-
segmentToText,
|
|
47865
47856
|
providedPlay,
|
|
47866
47857
|
defaultPlay,
|
|
47867
47858
|
markAudioPlayed
|
|
@@ -47912,7 +47903,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47912
47903
|
};
|
|
47913
47904
|
}(), []);
|
|
47914
47905
|
var playSegmentsImpl = useCallback7(/* @__PURE__ */ function() {
|
|
47915
|
-
var _ref9 = _asyncToGenerator11(function(
|
|
47906
|
+
var _ref9 = _asyncToGenerator11(function(args) {
|
|
47916
47907
|
return _ts_generator(this, function(_state) {
|
|
47917
47908
|
switch(_state.label){
|
|
47918
47909
|
case 0:
|
|
@@ -47922,7 +47913,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47922
47913
|
];
|
|
47923
47914
|
return [
|
|
47924
47915
|
4,
|
|
47925
|
-
Promise.resolve(providedPlaySegments(
|
|
47916
|
+
Promise.resolve(providedPlaySegments(args))
|
|
47926
47917
|
];
|
|
47927
47918
|
case 1:
|
|
47928
47919
|
_state.sent();
|
|
@@ -47932,7 +47923,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47932
47923
|
case 2:
|
|
47933
47924
|
return [
|
|
47934
47925
|
4,
|
|
47935
|
-
defaultPlaySegments(
|
|
47926
|
+
defaultPlaySegments(args)
|
|
47936
47927
|
];
|
|
47937
47928
|
case 3:
|
|
47938
47929
|
_state.sent();
|
|
@@ -47990,7 +47981,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47990
47981
|
candidate = {
|
|
47991
47982
|
messageId: msg.id,
|
|
47992
47983
|
message: message_0,
|
|
47993
|
-
|
|
47984
|
+
messageInput: msg.messageInput,
|
|
47994
47985
|
startIndex: msg.nextIndex,
|
|
47995
47986
|
segments: msg.segments.slice(msg.nextIndex)
|
|
47996
47987
|
};
|
|
@@ -48028,7 +48019,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48028
48019
|
startIndex: candidate.startIndex,
|
|
48029
48020
|
message: candidate.message,
|
|
48030
48021
|
play: function() {
|
|
48031
|
-
var _play = _asyncToGenerator11(function(
|
|
48022
|
+
var _play = _asyncToGenerator11(function(segment_0) {
|
|
48032
48023
|
return _ts_generator(this, function(_state) {
|
|
48033
48024
|
switch(_state.label){
|
|
48034
48025
|
case 0:
|
|
@@ -48040,7 +48031,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48040
48031
|
};
|
|
48041
48032
|
return [
|
|
48042
48033
|
4,
|
|
48043
|
-
playInternal(
|
|
48034
|
+
playInternal(segment_0, {
|
|
48044
48035
|
onPlay: function() {},
|
|
48045
48036
|
onStop: function() {
|
|
48046
48037
|
return handleStop(candidate.messageId);
|