@superinterface/react 5.3.0-beta.15 → 5.3.0-beta.17
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 +122 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +122 -74
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47419,6 +47419,18 @@ var useMessageAudio = function(_ref) {
|
|
|
47419
47419
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
47420
47420
|
var _useState91 = _sliced_to_array(useState9(false), 2), isPlaying = _useState91[0], setIsPlaying = _useState91[1];
|
|
47421
47421
|
var _useState92 = _sliced_to_array(useState9([]), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
|
|
47422
|
+
var commitAudioQueue = useCallback7(function(next) {
|
|
47423
|
+
if (typeof next === "function") {
|
|
47424
|
+
setAudioQueue(function(prev) {
|
|
47425
|
+
var computed = next(prev);
|
|
47426
|
+
audioQueueRef.current = computed;
|
|
47427
|
+
return computed;
|
|
47428
|
+
});
|
|
47429
|
+
} else {
|
|
47430
|
+
audioQueueRef.current = next;
|
|
47431
|
+
setAudioQueue(next);
|
|
47432
|
+
}
|
|
47433
|
+
}, []);
|
|
47422
47434
|
var audioQueueRef = useRef8([]);
|
|
47423
47435
|
useEffect10(function() {
|
|
47424
47436
|
audioQueueRef.current = audioQueue;
|
|
@@ -47443,7 +47455,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47443
47455
|
var checkForCompletion = useCallback7(function() {
|
|
47444
47456
|
if (activeSegmentsRef.current > 0) return;
|
|
47445
47457
|
var hasPending = audioQueueRef.current.some(function(m) {
|
|
47446
|
-
return !m.stopped &&
|
|
47458
|
+
return !m.stopped && m.nextIndex < m.segments.length;
|
|
47447
47459
|
});
|
|
47448
47460
|
if (hasPending) {
|
|
47449
47461
|
onEndPendingRef.current = true;
|
|
@@ -47595,16 +47607,16 @@ var useMessageAudio = function(_ref) {
|
|
|
47595
47607
|
];
|
|
47596
47608
|
case 6:
|
|
47597
47609
|
unfinished = nextQueue.filter(function(m_7) {
|
|
47598
|
-
return !m_7.stopped &&
|
|
47610
|
+
return !m_7.stopped && m_7.nextIndex < m_7.segments.length;
|
|
47599
47611
|
});
|
|
47600
47612
|
finished = nextQueue.filter(function(m_8) {
|
|
47601
|
-
return !(!m_8.stopped &&
|
|
47613
|
+
return !(!m_8.stopped && m_8.nextIndex < m_8.segments.length);
|
|
47602
47614
|
});
|
|
47603
47615
|
prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
|
|
47604
47616
|
combined = _to_consumable_array(unfinished).concat(_to_consumable_array(prunedFinished));
|
|
47605
47617
|
if (combined.some(function(m_9) {
|
|
47606
|
-
return !m_9.stopped &&
|
|
47607
|
-
})) {
|
|
47618
|
+
return !m_9.stopped && m_9.nextIndex < m_9.segments.length;
|
|
47619
|
+
}) || activeSegmentsRef.current > 0) {
|
|
47608
47620
|
onEndPendingRef.current = true;
|
|
47609
47621
|
}
|
|
47610
47622
|
if (!changed) {
|
|
@@ -47662,7 +47674,7 @@ var useMessageAudio = function(_ref) {
|
|
|
47662
47674
|
}
|
|
47663
47675
|
}
|
|
47664
47676
|
}
|
|
47665
|
-
if (changed)
|
|
47677
|
+
if (changed) commitAudioQueue(combined);
|
|
47666
47678
|
if (segCache.size > MAX_SEG_CACHE) {
|
|
47667
47679
|
entries = Array.from(segCache.entries());
|
|
47668
47680
|
entries.sort(function(a, b) {
|
|
@@ -47941,8 +47953,8 @@ var useMessageAudio = function(_ref) {
|
|
|
47941
47953
|
defaultPlaySegments
|
|
47942
47954
|
]);
|
|
47943
47955
|
var handleStop = useCallback7(function(messageId) {
|
|
47944
|
-
|
|
47945
|
-
return
|
|
47956
|
+
commitAudioQueue(function(prev_0) {
|
|
47957
|
+
return prev_0.map(function(m_13) {
|
|
47946
47958
|
return m_13.id === messageId ? _objectSpread47(_objectSpread47({}, m_13), {}, {
|
|
47947
47959
|
stopped: true
|
|
47948
47960
|
}) : m_13;
|
|
@@ -47961,7 +47973,6 @@ var useMessageAudio = function(_ref) {
|
|
|
47961
47973
|
if (activeSegmentsRef.current === 0) {
|
|
47962
47974
|
setIsPlaying(false);
|
|
47963
47975
|
currentSegmentRef.current = null;
|
|
47964
|
-
pickLockRef.current = false;
|
|
47965
47976
|
checkForCompletion();
|
|
47966
47977
|
}
|
|
47967
47978
|
}, [
|
|
@@ -47969,10 +47980,9 @@ var useMessageAudio = function(_ref) {
|
|
|
47969
47980
|
]);
|
|
47970
47981
|
useEffect10(function() {
|
|
47971
47982
|
var allowParallel = Boolean(providedPlaySegments);
|
|
47972
|
-
if (!allowParallel && isPlaying) return;
|
|
47983
|
+
if (!allowParallel && (isPlaying || audioPlayer.playing)) return;
|
|
47973
47984
|
if (pickLockRef.current) return;
|
|
47974
47985
|
if (audioQueue.length === 0) return;
|
|
47975
|
-
if (!allowParallel && audioPlayer.playing) return;
|
|
47976
47986
|
var candidate = null;
|
|
47977
47987
|
for(var i_3 = 0; i_3 < audioQueue.length; i_3++){
|
|
47978
47988
|
var msg = audioQueue[i_3];
|
|
@@ -47991,73 +48001,111 @@ var useMessageAudio = function(_ref) {
|
|
|
47991
48001
|
}
|
|
47992
48002
|
if (!candidate || candidate.segments.length === 0) return;
|
|
47993
48003
|
pickLockRef.current = true;
|
|
47994
|
-
setIsPlaying(true);
|
|
47995
|
-
|
|
47996
|
-
|
|
47997
|
-
|
|
47998
|
-
|
|
48004
|
+
if (!allowParallel) setIsPlaying(true);
|
|
48005
|
+
var selected = candidate;
|
|
48006
|
+
commitAudioQueue(function(prev_1) {
|
|
48007
|
+
return prev_1.map(function(m_14) {
|
|
48008
|
+
return m_14.id === selected.messageId ? _objectSpread47(_objectSpread47({}, m_14), {}, {
|
|
48009
|
+
nextIndex: selected.startIndex
|
|
47999
48010
|
}) : m_14;
|
|
48000
48011
|
});
|
|
48001
48012
|
});
|
|
48002
|
-
var runPlayback = function() {
|
|
48003
|
-
var
|
|
48004
|
-
|
|
48005
|
-
return
|
|
48006
|
-
|
|
48007
|
-
|
|
48008
|
-
|
|
48009
|
-
|
|
48010
|
-
|
|
48011
|
-
|
|
48012
|
-
|
|
48013
|
-
|
|
48014
|
-
|
|
48015
|
-
|
|
48016
|
-
|
|
48017
|
-
|
|
48018
|
-
|
|
48019
|
-
|
|
48020
|
-
|
|
48021
|
-
|
|
48022
|
-
|
|
48023
|
-
|
|
48024
|
-
|
|
48025
|
-
|
|
48026
|
-
|
|
48027
|
-
|
|
48028
|
-
|
|
48013
|
+
var runPlayback = /* @__PURE__ */ function() {
|
|
48014
|
+
var _ref0 = _asyncToGenerator11(function() {
|
|
48015
|
+
var launchedCount;
|
|
48016
|
+
return _ts_generator(this, function(_state) {
|
|
48017
|
+
switch(_state.label){
|
|
48018
|
+
case 0:
|
|
48019
|
+
launchedCount = 0;
|
|
48020
|
+
return [
|
|
48021
|
+
4,
|
|
48022
|
+
playSegmentsImpl({
|
|
48023
|
+
segments: selected.segments,
|
|
48024
|
+
startIndex: selected.startIndex,
|
|
48025
|
+
message: selected.message,
|
|
48026
|
+
play: function() {
|
|
48027
|
+
var _play = _asyncToGenerator11(function(segment_0) {
|
|
48028
|
+
var advanceTo;
|
|
48029
|
+
return _ts_generator(this, function(_state) {
|
|
48030
|
+
switch(_state.label){
|
|
48031
|
+
case 0:
|
|
48032
|
+
activeSegmentsRef.current += 1;
|
|
48033
|
+
launchedCount += 1;
|
|
48034
|
+
advanceTo = selected.startIndex + launchedCount;
|
|
48035
|
+
onEndPendingRef.current = true;
|
|
48036
|
+
commitAudioQueue(function(prev_2) {
|
|
48037
|
+
return prev_2.map(function(m_15) {
|
|
48038
|
+
return m_15.id === selected.messageId ? _objectSpread47(_objectSpread47({}, m_15), {}, {
|
|
48039
|
+
nextIndex: m_15.nextIndex >= advanceTo ? m_15.nextIndex : advanceTo
|
|
48040
|
+
}) : m_15;
|
|
48041
|
+
});
|
|
48042
|
+
});
|
|
48043
|
+
currentSegmentRef.current = {
|
|
48044
|
+
messageId: selected.messageId,
|
|
48045
|
+
nextIndex: advanceTo
|
|
48046
|
+
};
|
|
48047
|
+
return [
|
|
48048
|
+
4,
|
|
48049
|
+
playInternal(segment_0, {
|
|
48050
|
+
onPlay: function() {},
|
|
48051
|
+
onStop: function() {
|
|
48052
|
+
return handleStop(selected.messageId);
|
|
48053
|
+
},
|
|
48054
|
+
onEnd: function() {
|
|
48055
|
+
commitAudioQueue(function(prev_3) {
|
|
48056
|
+
return prev_3.map(function(m_16) {
|
|
48057
|
+
return m_16.id === selected.messageId ? _objectSpread47(_objectSpread47({}, m_16), {}, {
|
|
48058
|
+
nextIndex: m_16.nextIndex >= advanceTo ? m_16.nextIndex : advanceTo
|
|
48059
|
+
}) : m_16;
|
|
48060
|
+
});
|
|
48061
|
+
});
|
|
48062
|
+
handleSegmentEnd();
|
|
48063
|
+
}
|
|
48064
|
+
})
|
|
48065
|
+
];
|
|
48066
|
+
case 1:
|
|
48067
|
+
_state.sent();
|
|
48068
|
+
return [
|
|
48069
|
+
2
|
|
48070
|
+
];
|
|
48029
48071
|
}
|
|
48030
|
-
})
|
|
48031
|
-
|
|
48032
|
-
|
|
48033
|
-
|
|
48034
|
-
|
|
48035
|
-
|
|
48036
|
-
|
|
48037
|
-
}
|
|
48038
|
-
|
|
48039
|
-
|
|
48040
|
-
|
|
48041
|
-
return
|
|
48042
|
-
|
|
48043
|
-
|
|
48044
|
-
}
|
|
48072
|
+
});
|
|
48073
|
+
});
|
|
48074
|
+
function play(_x6) {
|
|
48075
|
+
return _play.apply(this, arguments);
|
|
48076
|
+
}
|
|
48077
|
+
return play;
|
|
48078
|
+
}()
|
|
48079
|
+
})
|
|
48080
|
+
];
|
|
48081
|
+
case 1:
|
|
48082
|
+
_state.sent();
|
|
48083
|
+
return [
|
|
48084
|
+
2
|
|
48085
|
+
];
|
|
48086
|
+
}
|
|
48045
48087
|
});
|
|
48088
|
+
});
|
|
48089
|
+
return function runPlayback2() {
|
|
48090
|
+
return _ref0.apply(this, arguments);
|
|
48046
48091
|
};
|
|
48047
|
-
|
|
48048
|
-
|
|
48049
|
-
|
|
48050
|
-
|
|
48051
|
-
|
|
48052
|
-
|
|
48053
|
-
|
|
48054
|
-
|
|
48055
|
-
|
|
48056
|
-
|
|
48057
|
-
|
|
48058
|
-
|
|
48059
|
-
|
|
48060
|
-
|
|
48092
|
+
}();
|
|
48093
|
+
Promise.resolve(runPlayback()).catch(function(error) {
|
|
48094
|
+
handleStop(selected.messageId);
|
|
48095
|
+
console.error(error);
|
|
48096
|
+
}).finally(function() {
|
|
48097
|
+
var finalNextIndex = selected.startIndex + selected.segments.length;
|
|
48098
|
+
commitAudioQueue(audioQueueRef.current.map(function(m_17) {
|
|
48099
|
+
return m_17.id === selected.messageId ? _objectSpread47(_objectSpread47({}, m_17), {}, {
|
|
48100
|
+
nextIndex: m_17.nextIndex >= finalNextIndex ? m_17.nextIndex : finalNextIndex
|
|
48101
|
+
}) : m_17;
|
|
48102
|
+
}));
|
|
48103
|
+
pickLockRef.current = false;
|
|
48104
|
+
checkForCompletion();
|
|
48105
|
+
});
|
|
48106
|
+
if (allowParallel) {
|
|
48107
|
+
pickLockRef.current = false;
|
|
48108
|
+
}
|
|
48061
48109
|
}, [
|
|
48062
48110
|
audioQueue,
|
|
48063
48111
|
isPlaying,
|
|
@@ -48115,8 +48163,8 @@ var useMessageAudio = function(_ref) {
|
|
|
48115
48163
|
audioEngine
|
|
48116
48164
|
]);
|
|
48117
48165
|
var isPending = useMemo17(function() {
|
|
48118
|
-
return isPlaying || audioQueue.some(function(
|
|
48119
|
-
return !
|
|
48166
|
+
return isPlaying || audioQueue.some(function(m_18) {
|
|
48167
|
+
return !m_18.stopped && (m_18.nextIndex < m_18.segments.length || m_18.status === "in_progress");
|
|
48120
48168
|
});
|
|
48121
48169
|
}, [
|
|
48122
48170
|
isPlaying,
|