@superinterface/react 5.3.0-beta.13 → 5.3.0-beta.15

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 CHANGED
@@ -48117,9 +48117,11 @@ var useMessageAudio = function(_ref) {
48117
48117
  checkForCompletion
48118
48118
  ]);
48119
48119
  (0, import_react67.useEffect)(function() {
48120
- if (isPlaying) return;
48120
+ var allowParallel = Boolean(providedPlaySegments);
48121
+ if (!allowParallel && isPlaying) return;
48121
48122
  if (pickLockRef.current) return;
48122
48123
  if (audioQueue.length === 0) return;
48124
+ if (!allowParallel && audioPlayer.playing) return;
48123
48125
  var candidate = null;
48124
48126
  for(var i_3 = 0; i_3 < audioQueue.length; i_3++){
48125
48127
  var msg = audioQueue[i_3];
@@ -48146,95 +48148,64 @@ var useMessageAudio = function(_ref) {
48146
48148
  }) : m_14;
48147
48149
  });
48148
48150
  });
48149
- var runPlayback = /* @__PURE__ */ function() {
48150
- var _ref0 = _asyncToGenerator11(function() {
48151
- var nextIndex_0, error;
48152
- return _ts_generator(this, function(_state) {
48153
- switch(_state.label){
48154
- case 0:
48155
- nextIndex_0 = candidate.startIndex;
48156
- _state.label = 1;
48157
- case 1:
48158
- _state.trys.push([
48159
- 1,
48160
- 3,
48161
- 4,
48162
- 5
48163
- ]);
48164
- return [
48165
- 4,
48166
- playSegmentsImpl({
48167
- segments: candidate.segments,
48168
- startIndex: candidate.startIndex,
48169
- message: candidate.message,
48170
- play: function() {
48171
- var _play = _asyncToGenerator11(function(segment_0) {
48172
- return _ts_generator(this, function(_state) {
48173
- switch(_state.label){
48174
- case 0:
48175
- activeSegmentsRef.current += 1;
48176
- nextIndex_0 += 1;
48177
- currentSegmentRef.current = {
48178
- messageId: candidate.messageId,
48179
- nextIndex: nextIndex_0
48180
- };
48181
- return [
48182
- 4,
48183
- playInternal(segment_0, {
48184
- onPlay: function() {},
48185
- onStop: function() {
48186
- return handleStop(candidate.messageId);
48187
- },
48188
- onEnd: function() {
48189
- return handleSegmentEnd();
48190
- }
48191
- })
48192
- ];
48193
- case 1:
48194
- _state.sent();
48195
- return [
48196
- 2
48197
- ];
48151
+ var runPlayback = function() {
48152
+ var nextIndex_0 = candidate.startIndex;
48153
+ var launch = function() {
48154
+ return playSegmentsImpl({
48155
+ segments: candidate.segments,
48156
+ startIndex: candidate.startIndex,
48157
+ message: candidate.message,
48158
+ play: function() {
48159
+ var _play = _asyncToGenerator11(function(segment_0) {
48160
+ return _ts_generator(this, function(_state) {
48161
+ switch(_state.label){
48162
+ case 0:
48163
+ activeSegmentsRef.current += 1;
48164
+ nextIndex_0 += 1;
48165
+ currentSegmentRef.current = {
48166
+ messageId: candidate.messageId,
48167
+ nextIndex: nextIndex_0
48168
+ };
48169
+ return [
48170
+ 4,
48171
+ playInternal(segment_0, {
48172
+ onPlay: function() {},
48173
+ onStop: function() {
48174
+ return handleStop(candidate.messageId);
48175
+ },
48176
+ onEnd: function() {
48177
+ return handleSegmentEnd();
48198
48178
  }
48199
- });
48200
- });
48201
- function play(_x6) {
48202
- return _play.apply(this, arguments);
48203
- }
48204
- return play;
48205
- }()
48206
- })
48207
- ];
48208
- case 2:
48209
- _state.sent();
48210
- return [
48211
- 3,
48212
- 5
48213
- ];
48214
- case 3:
48215
- error = _state.sent();
48216
- handleStop(candidate.messageId);
48217
- console.error(error);
48218
- return [
48219
- 3,
48220
- 5
48221
- ];
48222
- case 4:
48223
- checkForCompletion();
48224
- return [
48225
- 7
48226
- ];
48227
- case 5:
48228
- return [
48229
- 2
48230
- ];
48231
- }
48179
+ })
48180
+ ];
48181
+ case 1:
48182
+ _state.sent();
48183
+ return [
48184
+ 2
48185
+ ];
48186
+ }
48187
+ });
48188
+ });
48189
+ function play(_x6) {
48190
+ return _play.apply(this, arguments);
48191
+ }
48192
+ return play;
48193
+ }()
48232
48194
  });
48233
- });
48234
- return function runPlayback2() {
48235
- return _ref0.apply(this, arguments);
48236
48195
  };
48237
- }();
48196
+ try {
48197
+ Promise.resolve(launch()).catch(function(error_0) {
48198
+ handleStop(candidate.messageId);
48199
+ console.error(error_0);
48200
+ }).finally(function() {
48201
+ checkForCompletion();
48202
+ });
48203
+ } catch (error) {
48204
+ handleStop(candidate.messageId);
48205
+ console.error(error);
48206
+ checkForCompletion();
48207
+ }
48208
+ };
48238
48209
  runPlayback();
48239
48210
  }, [
48240
48211
  audioQueue,
@@ -48243,7 +48214,9 @@ var useMessageAudio = function(_ref) {
48243
48214
  playInternal,
48244
48215
  handleStop,
48245
48216
  handleSegmentEnd,
48246
- checkForCompletion
48217
+ checkForCompletion,
48218
+ providedPlaySegments,
48219
+ audioPlayer.playing
48247
48220
  ]);
48248
48221
  (0, import_react67.useEffect)(function() {
48249
48222
  if (isHtmlAudioSupported) {