@superinterface/react 5.3.0-beta.12 → 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 +48 -57
- 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 +48 -57
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +10 -10
- package/dist/types/index.d.ts +10 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47530,6 +47530,27 @@ var getIncrementalSegments = function(prev, nextInput, now) {
|
|
|
47530
47530
|
touched: now
|
|
47531
47531
|
};
|
|
47532
47532
|
};
|
|
47533
|
+
var getDefaultSegments = function(prev, input2, message, nowTs) {
|
|
47534
|
+
var base = getIncrementalSegments(prev, input2, nowTs);
|
|
47535
|
+
var fullSegments = base.segments;
|
|
47536
|
+
var readyCount = fullSegments.length;
|
|
47537
|
+
if (readyCount > 0 && !isOptimistic({
|
|
47538
|
+
id: message.id
|
|
47539
|
+
}) && message.status === "in_progress") {
|
|
47540
|
+
var last3 = fullSegments[fullSegments.length - 1];
|
|
47541
|
+
if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
|
|
47542
|
+
}
|
|
47543
|
+
var readySegments = fullSegments.slice(0, Math.max(0, readyCount));
|
|
47544
|
+
var playable = readyCount === fullSegments.length ? fullSegments : readySegments;
|
|
47545
|
+
return {
|
|
47546
|
+
entry: {
|
|
47547
|
+
input: base.input,
|
|
47548
|
+
segments: base.segments,
|
|
47549
|
+
touched: nowTs
|
|
47550
|
+
},
|
|
47551
|
+
playable: playable
|
|
47552
|
+
};
|
|
47553
|
+
};
|
|
47533
47554
|
var segmentsEqual = function(a, b) {
|
|
47534
47555
|
if (a === b) return true;
|
|
47535
47556
|
if (a.length !== b.length) return false;
|
|
@@ -47568,16 +47589,6 @@ var useMessageAudio = function(_ref) {
|
|
|
47568
47589
|
setIsAudioPlayed(true);
|
|
47569
47590
|
}
|
|
47570
47591
|
}, []);
|
|
47571
|
-
var segmentToText = (0, import_react67.useCallback)(function(segment) {
|
|
47572
|
-
if (typeof segment === "string") return segment;
|
|
47573
|
-
if (segment && (typeof segment === "undefined" ? "undefined" : _type_of(segment)) === "object" && "text" in segment) {
|
|
47574
|
-
var value = segment.text;
|
|
47575
|
-
if (typeof value === "string") return value;
|
|
47576
|
-
}
|
|
47577
|
-
if (segment == null) return void 0;
|
|
47578
|
-
var stringified = String(segment);
|
|
47579
|
-
return stringified.length > 0 ? stringified : void 0;
|
|
47580
|
-
}, []);
|
|
47581
47592
|
var checkForCompletion = (0, import_react67.useCallback)(function() {
|
|
47582
47593
|
if (activeSegmentsRef.current > 0) return;
|
|
47583
47594
|
var hasPending = audioQueueRef.current.some(function(m) {
|
|
@@ -47600,7 +47611,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47600
47611
|
}
|
|
47601
47612
|
var run = /* @__PURE__ */ function() {
|
|
47602
47613
|
var _ref2 = _asyncToGenerator11(function() {
|
|
47603
|
-
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,
|
|
47614
|
+
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;
|
|
47604
47615
|
return _ts_generator(this, function(_state) {
|
|
47605
47616
|
switch(_state.label){
|
|
47606
47617
|
case 0:
|
|
@@ -47701,22 +47712,9 @@ var useMessageAudio = function(_ref) {
|
|
|
47701
47712
|
4
|
|
47702
47713
|
];
|
|
47703
47714
|
case 3:
|
|
47704
|
-
|
|
47705
|
-
nextEntry =
|
|
47706
|
-
|
|
47707
|
-
segments: base.segments,
|
|
47708
|
-
touched: nowTs
|
|
47709
|
-
};
|
|
47710
|
-
fullSegments = base.segments;
|
|
47711
|
-
readyCount = fullSegments.length;
|
|
47712
|
-
if (readyCount > 0 && !isOptimistic({
|
|
47713
|
-
id: m_6.id
|
|
47714
|
-
}) && m_6.status === "in_progress") {
|
|
47715
|
-
last3 = fullSegments[fullSegments.length - 1];
|
|
47716
|
-
if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
|
|
47717
|
-
}
|
|
47718
|
-
readySegments = fullSegments.slice(0, Math.max(0, readyCount));
|
|
47719
|
-
playableSegments = readyCount === fullSegments.length ? fullSegments : readySegments;
|
|
47715
|
+
_getDefaultSegments = getDefaultSegments(prevEntry, input2, m_6, nowTs), entry_0 = _getDefaultSegments.entry, playable = _getDefaultSegments.playable;
|
|
47716
|
+
nextEntry = entry_0;
|
|
47717
|
+
playableSegments = playable;
|
|
47720
47718
|
_state.label = 4;
|
|
47721
47719
|
case 4:
|
|
47722
47720
|
touch(m_6.id, nextEntry);
|
|
@@ -47927,10 +47925,8 @@ var useMessageAudio = function(_ref) {
|
|
|
47927
47925
|
if (!owner) return;
|
|
47928
47926
|
var nextSegment = owner.segments[current.nextIndex];
|
|
47929
47927
|
if (!nextSegment) return;
|
|
47930
|
-
var nextText = segmentToText(nextSegment);
|
|
47931
|
-
if (!nextText) return;
|
|
47932
47928
|
var nextSearchParams = new URLSearchParams(_objectSpread47({
|
|
47933
|
-
input:
|
|
47929
|
+
input: nextSegment
|
|
47934
47930
|
}, superinterfaceContext.variables));
|
|
47935
47931
|
nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
|
|
47936
47932
|
format: "mp3",
|
|
@@ -47956,37 +47952,28 @@ var useMessageAudio = function(_ref) {
|
|
|
47956
47952
|
audioPlayer,
|
|
47957
47953
|
nextAudioPlayer,
|
|
47958
47954
|
superinterfaceContext,
|
|
47959
|
-
|
|
47955
|
+
markAudioPlayed
|
|
47960
47956
|
]);
|
|
47961
47957
|
var playInternal = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
|
|
47962
|
-
var _ref6 = _asyncToGenerator11(function(
|
|
47963
|
-
var text, args;
|
|
47958
|
+
var _ref6 = _asyncToGenerator11(function(segment, handlers2) {
|
|
47964
47959
|
return _ts_generator(this, function(_state) {
|
|
47965
47960
|
switch(_state.label){
|
|
47966
47961
|
case 0:
|
|
47967
|
-
text = segmentToText(segment_0);
|
|
47968
|
-
if (!text) {
|
|
47969
|
-
handlers2.onEnd();
|
|
47970
|
-
return [
|
|
47971
|
-
2
|
|
47972
|
-
];
|
|
47973
|
-
}
|
|
47974
|
-
args = {
|
|
47975
|
-
input: text,
|
|
47976
|
-
onPlay: function() {
|
|
47977
|
-
markAudioPlayed();
|
|
47978
|
-
handlers2.onPlay();
|
|
47979
|
-
},
|
|
47980
|
-
onStop: handlers2.onStop,
|
|
47981
|
-
onEnd: handlers2.onEnd
|
|
47982
|
-
};
|
|
47983
47962
|
if (!providedPlay) return [
|
|
47984
47963
|
3,
|
|
47985
47964
|
2
|
|
47986
47965
|
];
|
|
47987
47966
|
return [
|
|
47988
47967
|
4,
|
|
47989
|
-
Promise.resolve(providedPlay(
|
|
47968
|
+
Promise.resolve(providedPlay({
|
|
47969
|
+
input: segment,
|
|
47970
|
+
onPlay: function() {
|
|
47971
|
+
markAudioPlayed();
|
|
47972
|
+
handlers2.onPlay();
|
|
47973
|
+
},
|
|
47974
|
+
onStop: handlers2.onStop,
|
|
47975
|
+
onEnd: handlers2.onEnd
|
|
47976
|
+
}))
|
|
47990
47977
|
];
|
|
47991
47978
|
case 1:
|
|
47992
47979
|
_state.sent();
|
|
@@ -47996,7 +47983,12 @@ var useMessageAudio = function(_ref) {
|
|
|
47996
47983
|
case 2:
|
|
47997
47984
|
return [
|
|
47998
47985
|
4,
|
|
47999
|
-
defaultPlay(
|
|
47986
|
+
defaultPlay({
|
|
47987
|
+
input: segment,
|
|
47988
|
+
onPlay: handlers2.onPlay,
|
|
47989
|
+
onStop: handlers2.onStop,
|
|
47990
|
+
onEnd: handlers2.onEnd
|
|
47991
|
+
})
|
|
48000
47992
|
];
|
|
48001
47993
|
case 3:
|
|
48002
47994
|
_state.sent();
|
|
@@ -48010,7 +48002,6 @@ var useMessageAudio = function(_ref) {
|
|
|
48010
48002
|
return _ref6.apply(this, arguments);
|
|
48011
48003
|
};
|
|
48012
48004
|
}(), [
|
|
48013
|
-
segmentToText,
|
|
48014
48005
|
providedPlay,
|
|
48015
48006
|
defaultPlay,
|
|
48016
48007
|
markAudioPlayed
|
|
@@ -48061,7 +48052,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48061
48052
|
};
|
|
48062
48053
|
}(), []);
|
|
48063
48054
|
var playSegmentsImpl = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
|
|
48064
|
-
var _ref9 = _asyncToGenerator11(function(
|
|
48055
|
+
var _ref9 = _asyncToGenerator11(function(args) {
|
|
48065
48056
|
return _ts_generator(this, function(_state) {
|
|
48066
48057
|
switch(_state.label){
|
|
48067
48058
|
case 0:
|
|
@@ -48071,7 +48062,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48071
48062
|
];
|
|
48072
48063
|
return [
|
|
48073
48064
|
4,
|
|
48074
|
-
Promise.resolve(providedPlaySegments(
|
|
48065
|
+
Promise.resolve(providedPlaySegments(args))
|
|
48075
48066
|
];
|
|
48076
48067
|
case 1:
|
|
48077
48068
|
_state.sent();
|
|
@@ -48081,7 +48072,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48081
48072
|
case 2:
|
|
48082
48073
|
return [
|
|
48083
48074
|
4,
|
|
48084
|
-
defaultPlaySegments(
|
|
48075
|
+
defaultPlaySegments(args)
|
|
48085
48076
|
];
|
|
48086
48077
|
case 3:
|
|
48087
48078
|
_state.sent();
|
|
@@ -48177,7 +48168,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48177
48168
|
startIndex: candidate.startIndex,
|
|
48178
48169
|
message: candidate.message,
|
|
48179
48170
|
play: function() {
|
|
48180
|
-
var _play = _asyncToGenerator11(function(
|
|
48171
|
+
var _play = _asyncToGenerator11(function(segment_0) {
|
|
48181
48172
|
return _ts_generator(this, function(_state) {
|
|
48182
48173
|
switch(_state.label){
|
|
48183
48174
|
case 0:
|
|
@@ -48189,7 +48180,7 @@ var useMessageAudio = function(_ref) {
|
|
|
48189
48180
|
};
|
|
48190
48181
|
return [
|
|
48191
48182
|
4,
|
|
48192
|
-
playInternal(
|
|
48183
|
+
playInternal(segment_0, {
|
|
48193
48184
|
onPlay: function() {},
|
|
48194
48185
|
onStop: function() {
|
|
48195
48186
|
return handleStop(candidate.messageId);
|