@superinterface/react 5.3.0-beta.12 → 5.3.0-beta.14
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 +101 -141
- 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 +101 -141
- 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();
|
|
@@ -48155,95 +48146,64 @@ var useMessageAudio = function(_ref) {
|
|
|
48155
48146
|
}) : m_14;
|
|
48156
48147
|
});
|
|
48157
48148
|
});
|
|
48158
|
-
var runPlayback =
|
|
48159
|
-
var
|
|
48160
|
-
|
|
48161
|
-
return
|
|
48162
|
-
|
|
48163
|
-
|
|
48164
|
-
|
|
48165
|
-
|
|
48166
|
-
|
|
48167
|
-
_state
|
|
48168
|
-
|
|
48169
|
-
|
|
48170
|
-
|
|
48171
|
-
|
|
48172
|
-
|
|
48173
|
-
|
|
48174
|
-
|
|
48175
|
-
|
|
48176
|
-
|
|
48177
|
-
|
|
48178
|
-
|
|
48179
|
-
|
|
48180
|
-
|
|
48181
|
-
|
|
48182
|
-
|
|
48183
|
-
|
|
48184
|
-
|
|
48185
|
-
nextIndex_0 += 1;
|
|
48186
|
-
currentSegmentRef.current = {
|
|
48187
|
-
messageId: candidate.messageId,
|
|
48188
|
-
nextIndex: nextIndex_0
|
|
48189
|
-
};
|
|
48190
|
-
return [
|
|
48191
|
-
4,
|
|
48192
|
-
playInternal(segment_1, {
|
|
48193
|
-
onPlay: function() {},
|
|
48194
|
-
onStop: function() {
|
|
48195
|
-
return handleStop(candidate.messageId);
|
|
48196
|
-
},
|
|
48197
|
-
onEnd: function() {
|
|
48198
|
-
return handleSegmentEnd();
|
|
48199
|
-
}
|
|
48200
|
-
})
|
|
48201
|
-
];
|
|
48202
|
-
case 1:
|
|
48203
|
-
_state.sent();
|
|
48204
|
-
return [
|
|
48205
|
-
2
|
|
48206
|
-
];
|
|
48149
|
+
var runPlayback = function() {
|
|
48150
|
+
var nextIndex_0 = candidate.startIndex;
|
|
48151
|
+
var launch = function() {
|
|
48152
|
+
return playSegmentsImpl({
|
|
48153
|
+
segments: candidate.segments,
|
|
48154
|
+
startIndex: candidate.startIndex,
|
|
48155
|
+
message: candidate.message,
|
|
48156
|
+
play: function() {
|
|
48157
|
+
var _play = _asyncToGenerator11(function(segment_0) {
|
|
48158
|
+
return _ts_generator(this, function(_state) {
|
|
48159
|
+
switch(_state.label){
|
|
48160
|
+
case 0:
|
|
48161
|
+
activeSegmentsRef.current += 1;
|
|
48162
|
+
nextIndex_0 += 1;
|
|
48163
|
+
currentSegmentRef.current = {
|
|
48164
|
+
messageId: candidate.messageId,
|
|
48165
|
+
nextIndex: nextIndex_0
|
|
48166
|
+
};
|
|
48167
|
+
return [
|
|
48168
|
+
4,
|
|
48169
|
+
playInternal(segment_0, {
|
|
48170
|
+
onPlay: function() {},
|
|
48171
|
+
onStop: function() {
|
|
48172
|
+
return handleStop(candidate.messageId);
|
|
48173
|
+
},
|
|
48174
|
+
onEnd: function() {
|
|
48175
|
+
return handleSegmentEnd();
|
|
48207
48176
|
}
|
|
48208
|
-
})
|
|
48209
|
-
|
|
48210
|
-
|
|
48211
|
-
|
|
48212
|
-
|
|
48213
|
-
|
|
48214
|
-
|
|
48215
|
-
}
|
|
48216
|
-
|
|
48217
|
-
|
|
48218
|
-
|
|
48219
|
-
return
|
|
48220
|
-
|
|
48221
|
-
|
|
48222
|
-
|
|
48223
|
-
case 3:
|
|
48224
|
-
error = _state.sent();
|
|
48225
|
-
handleStop(candidate.messageId);
|
|
48226
|
-
console.error(error);
|
|
48227
|
-
return [
|
|
48228
|
-
3,
|
|
48229
|
-
5
|
|
48230
|
-
];
|
|
48231
|
-
case 4:
|
|
48232
|
-
checkForCompletion();
|
|
48233
|
-
return [
|
|
48234
|
-
7
|
|
48235
|
-
];
|
|
48236
|
-
case 5:
|
|
48237
|
-
return [
|
|
48238
|
-
2
|
|
48239
|
-
];
|
|
48240
|
-
}
|
|
48177
|
+
})
|
|
48178
|
+
];
|
|
48179
|
+
case 1:
|
|
48180
|
+
_state.sent();
|
|
48181
|
+
return [
|
|
48182
|
+
2
|
|
48183
|
+
];
|
|
48184
|
+
}
|
|
48185
|
+
});
|
|
48186
|
+
});
|
|
48187
|
+
function play(_x6) {
|
|
48188
|
+
return _play.apply(this, arguments);
|
|
48189
|
+
}
|
|
48190
|
+
return play;
|
|
48191
|
+
}()
|
|
48241
48192
|
});
|
|
48242
|
-
});
|
|
48243
|
-
return function runPlayback2() {
|
|
48244
|
-
return _ref0.apply(this, arguments);
|
|
48245
48193
|
};
|
|
48246
|
-
|
|
48194
|
+
try {
|
|
48195
|
+
Promise.resolve(launch()).catch(function(error_0) {
|
|
48196
|
+
handleStop(candidate.messageId);
|
|
48197
|
+
console.error(error_0);
|
|
48198
|
+
}).finally(function() {
|
|
48199
|
+
checkForCompletion();
|
|
48200
|
+
});
|
|
48201
|
+
} catch (error) {
|
|
48202
|
+
handleStop(candidate.messageId);
|
|
48203
|
+
console.error(error);
|
|
48204
|
+
checkForCompletion();
|
|
48205
|
+
}
|
|
48206
|
+
};
|
|
48247
48207
|
runPlayback();
|
|
48248
48208
|
}, [
|
|
48249
48209
|
audioQueue,
|