@superinterface/react 3.7.2 → 3.8.0

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
@@ -9303,8 +9303,8 @@ var getMessageSentences = function(_ref) {
9303
9303
  });
9304
9304
  };
9305
9305
  var useMessageAudio = function(t0) {
9306
- var $ = (0, import_react_compiler_runtime50.c)(44);
9307
- var onEnd = t0.onEnd;
9306
+ var $ = (0, import_react_compiler_runtime50.c)(50);
9307
+ var _onEnd = t0.onEnd, passedPlay = t0.play;
9308
9308
  var _ref = _sliced_to_array((0, import_react63.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
9309
9309
  var t1;
9310
9310
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -9407,8 +9407,56 @@ var useMessageAudio = function(t0) {
9407
9407
  }
9408
9408
  var unplayedMessageSentences = t3;
9409
9409
  var t4;
9410
- if ($[12] !== audioPlayer || $[13] !== isAudioPlayed || $[14] !== isPlaying || $[15] !== latestMessageProps.latestMessage || $[16] !== nextAudioPlayer || $[17] !== onEnd || $[18] !== superinterfaceContext || $[19] !== unplayedMessageSentences) {
9411
- t4 = function() {
9410
+ if ($[12] !== audioPlayer || $[13] !== isAudioPlayed || $[14] !== nextAudioPlayer || $[15] !== superinterfaceContext.baseUrl || $[16] !== superinterfaceContext.variables || $[17] !== unplayedMessageSentences) {
9411
+ t4 = function(t52) {
9412
+ var input_0 = t52.input, onPlay = t52.onPlay, onStop = t52.onStop, onEnd_0 = t52.onEnd;
9413
+ var searchParams = new URLSearchParams(_objectSpread45({
9414
+ input: input_0
9415
+ }, superinterfaceContext.variables));
9416
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
9417
+ format: "mp3",
9418
+ autoplay: isAudioPlayed,
9419
+ html5: isHtmlAudioSupported,
9420
+ onplay: onPlay,
9421
+ onstop: onStop,
9422
+ onload: function() {
9423
+ var nextUnplayedMessageSentence = unplayedMessageSentences[1];
9424
+ if (!nextUnplayedMessageSentence) {
9425
+ return;
9426
+ }
9427
+ var isNextFullSentence = FULL_SENTENCE_REGEX.test(nextUnplayedMessageSentence.sentence);
9428
+ if (!isNextFullSentence) {
9429
+ return;
9430
+ }
9431
+ var nextSearchParams = new URLSearchParams(_objectSpread45({
9432
+ input: nextUnplayedMessageSentence.sentence
9433
+ }, superinterfaceContext.variables));
9434
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(nextSearchParams), {
9435
+ format: "mp3",
9436
+ autoplay: false,
9437
+ html5: isHtmlAudioSupported
9438
+ });
9439
+ },
9440
+ onend: onEnd_0
9441
+ });
9442
+ };
9443
+ $[12] = audioPlayer;
9444
+ $[13] = isAudioPlayed;
9445
+ $[14] = nextAudioPlayer;
9446
+ $[15] = superinterfaceContext.baseUrl;
9447
+ $[16] = superinterfaceContext.variables;
9448
+ $[17] = unplayedMessageSentences;
9449
+ $[18] = t4;
9450
+ } else {
9451
+ t4 = $[18];
9452
+ }
9453
+ var defaultPlay = t4;
9454
+ var t5;
9455
+ t5 = passedPlay || defaultPlay;
9456
+ var play = t5;
9457
+ var t6;
9458
+ if ($[19] !== audioPlayer.playing || $[20] !== isPlaying || $[21] !== latestMessageProps.latestMessage || $[22] !== _onEnd || $[23] !== play || $[24] !== unplayedMessageSentences) {
9459
+ t6 = function() {
9412
9460
  if (isPlaying) {
9413
9461
  return;
9414
9462
  }
@@ -9437,17 +9485,13 @@ var useMessageAudio = function(t0) {
9437
9485
  firstUnplayedMessageSentence
9438
9486
  ]);
9439
9487
  });
9440
- var searchParams = new URLSearchParams(_objectSpread45({
9441
- input: firstUnplayedMessageSentence.sentence
9442
- }, superinterfaceContext.variables));
9443
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
9444
- format: "mp3",
9445
- autoplay: isAudioPlayed,
9446
- html5: isHtmlAudioSupported,
9447
- onplay: function() {
9488
+ var input_1 = firstUnplayedMessageSentence.sentence;
9489
+ play({
9490
+ input: input_1,
9491
+ onPlay: function() {
9448
9492
  setIsAudioPlayed(true);
9449
9493
  },
9450
- onstop: function() {
9494
+ onStop: function() {
9451
9495
  setStoppedMessageIds(function(prev_0) {
9452
9496
  return _to_consumable_array(prev_0).concat([
9453
9497
  firstUnplayedMessageSentence.messageId
@@ -9455,47 +9499,27 @@ var useMessageAudio = function(t0) {
9455
9499
  });
9456
9500
  setIsPlaying(false);
9457
9501
  },
9458
- onload: function() {
9459
- var nextUnplayedMessageSentence = unplayedMessageSentences[1];
9460
- if (!nextUnplayedMessageSentence) {
9461
- return;
9462
- }
9463
- var isNextFullSentence = FULL_SENTENCE_REGEX.test(nextUnplayedMessageSentence.sentence);
9464
- if (!isNextFullSentence) {
9465
- return;
9466
- }
9467
- var nextSearchParams = new URLSearchParams(_objectSpread45({
9468
- input: nextUnplayedMessageSentence.sentence
9469
- }, superinterfaceContext.variables));
9470
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(nextSearchParams), {
9471
- format: "mp3",
9472
- autoplay: false,
9473
- html5: isHtmlAudioSupported
9474
- });
9475
- },
9476
- onend: function() {
9502
+ onEnd: function() {
9477
9503
  setIsPlaying(false);
9478
9504
  if (unplayedMessageSentences.length === 1 && latestMessageProps.latestMessage.status !== "in_progress") {
9479
- onEnd();
9505
+ _onEnd();
9480
9506
  }
9481
9507
  }
9482
9508
  });
9483
9509
  };
9484
- $[12] = audioPlayer;
9485
- $[13] = isAudioPlayed;
9486
- $[14] = isPlaying;
9487
- $[15] = latestMessageProps.latestMessage;
9488
- $[16] = nextAudioPlayer;
9489
- $[17] = onEnd;
9490
- $[18] = superinterfaceContext;
9491
- $[19] = unplayedMessageSentences;
9492
- $[20] = t4;
9510
+ $[19] = audioPlayer.playing;
9511
+ $[20] = isPlaying;
9512
+ $[21] = latestMessageProps.latestMessage;
9513
+ $[22] = _onEnd;
9514
+ $[23] = play;
9515
+ $[24] = unplayedMessageSentences;
9516
+ $[25] = t6;
9493
9517
  } else {
9494
- t4 = $[20];
9518
+ t6 = $[25];
9495
9519
  }
9496
- var t5;
9497
- if ($[21] !== audioPlayer || $[22] !== isPlaying || $[23] !== latestMessageProps || $[24] !== nextAudioPlayer || $[25] !== onEnd || $[26] !== playedMessageSentences || $[27] !== superinterfaceContext || $[28] !== unplayedMessageSentences) {
9498
- t5 = [
9520
+ var t7;
9521
+ if ($[26] !== audioPlayer || $[27] !== isPlaying || $[28] !== latestMessageProps || $[29] !== nextAudioPlayer || $[30] !== _onEnd || $[31] !== play || $[32] !== playedMessageSentences || $[33] !== superinterfaceContext || $[34] !== unplayedMessageSentences) {
9522
+ t7 = [
9499
9523
  unplayedMessageSentences,
9500
9524
  isPlaying,
9501
9525
  superinterfaceContext,
@@ -9503,37 +9527,39 @@ var useMessageAudio = function(t0) {
9503
9527
  audioPlayer,
9504
9528
  nextAudioPlayer,
9505
9529
  playedMessageSentences,
9506
- onEnd
9530
+ _onEnd,
9531
+ play
9507
9532
  ];
9508
- $[21] = audioPlayer;
9509
- $[22] = isPlaying;
9510
- $[23] = latestMessageProps;
9511
- $[24] = nextAudioPlayer;
9512
- $[25] = onEnd;
9513
- $[26] = playedMessageSentences;
9514
- $[27] = superinterfaceContext;
9515
- $[28] = unplayedMessageSentences;
9516
- $[29] = t5;
9517
- } else {
9518
- t5 = $[29];
9519
- }
9520
- (0, import_react63.useEffect)(t4, t5);
9521
- var t6;
9522
- if ($[30] !== audioPlayer) {
9523
- t6 = [
9533
+ $[26] = audioPlayer;
9534
+ $[27] = isPlaying;
9535
+ $[28] = latestMessageProps;
9536
+ $[29] = nextAudioPlayer;
9537
+ $[30] = _onEnd;
9538
+ $[31] = play;
9539
+ $[32] = playedMessageSentences;
9540
+ $[33] = superinterfaceContext;
9541
+ $[34] = unplayedMessageSentences;
9542
+ $[35] = t7;
9543
+ } else {
9544
+ t7 = $[35];
9545
+ }
9546
+ (0, import_react63.useEffect)(t6, t7);
9547
+ var t8;
9548
+ if ($[36] !== audioPlayer) {
9549
+ t8 = [
9524
9550
  audioPlayer
9525
9551
  ];
9526
- $[30] = audioPlayer;
9527
- $[31] = t6;
9552
+ $[36] = audioPlayer;
9553
+ $[37] = t8;
9528
9554
  } else {
9529
- t6 = $[31];
9555
+ t8 = $[37];
9530
9556
  }
9531
- (0, import_react63.useEffect)(_temp11, t6);
9557
+ (0, import_react63.useEffect)(_temp11, t8);
9532
9558
  var _ref4 = _sliced_to_array((0, import_react63.useState)(null), 2), audioEngine = _ref4[0], setAudioEngine = _ref4[1];
9533
9559
  var isAudioEngineInited = (0, import_react63.useRef)(false);
9534
- var t7;
9535
- if ($[32] !== audioPlayer.playing) {
9536
- t7 = function() {
9560
+ var t9;
9561
+ if ($[38] !== audioPlayer.playing) {
9562
+ t9 = function() {
9537
9563
  if (!audioPlayer.playing) {
9538
9564
  return;
9539
9565
  }
@@ -9554,63 +9580,63 @@ var useMessageAudio = function(t0) {
9554
9580
  });
9555
9581
  }
9556
9582
  };
9557
- $[32] = audioPlayer.playing;
9558
- $[33] = t7;
9583
+ $[38] = audioPlayer.playing;
9584
+ $[39] = t9;
9559
9585
  } else {
9560
- t7 = $[33];
9586
+ t9 = $[39];
9561
9587
  }
9562
- var t8;
9563
- if ($[34] !== audioPlayer) {
9564
- t8 = [
9588
+ var t10;
9589
+ if ($[40] !== audioPlayer) {
9590
+ t10 = [
9565
9591
  audioPlayer,
9566
9592
  isAudioEngineInited
9567
9593
  ];
9568
- $[34] = audioPlayer;
9569
- $[35] = t8;
9594
+ $[40] = audioPlayer;
9595
+ $[41] = t10;
9570
9596
  } else {
9571
- t8 = $[35];
9597
+ t10 = $[41];
9572
9598
  }
9573
- (0, import_react63.useEffect)(t7, t8);
9574
- var t9;
9599
+ (0, import_react63.useEffect)(t9, t10);
9600
+ var t11;
9575
9601
  bb1: {
9576
9602
  if (!audioEngine) {
9577
- t9 = null;
9603
+ t11 = null;
9578
9604
  break bb1;
9579
9605
  }
9580
9606
  var result;
9581
- if ($[36] !== audioEngine.audioContext || $[37] !== audioEngine.source) {
9607
+ if ($[42] !== audioEngine.audioContext || $[43] !== audioEngine.source) {
9582
9608
  result = audioEngine.audioContext.createAnalyser();
9583
9609
  audioEngine.source.connect(audioEngine.audioContext.destination);
9584
9610
  audioEngine.source.connect(result);
9585
- $[36] = audioEngine.audioContext;
9586
- $[37] = audioEngine.source;
9587
- $[38] = result;
9611
+ $[42] = audioEngine.audioContext;
9612
+ $[43] = audioEngine.source;
9613
+ $[44] = result;
9588
9614
  } else {
9589
- result = $[38];
9615
+ result = $[44];
9590
9616
  }
9591
- t9 = result;
9617
+ t11 = result;
9592
9618
  }
9593
- var visualizationAnalyser = t9;
9594
- var t10;
9595
- t10 = isPlaying || unplayedMessageSentences.length > 0;
9596
- var isPending = t10;
9597
- var t11;
9598
- if ($[39] !== audioPlayer || $[40] !== isAudioPlayed || $[41] !== isPending || $[42] !== visualizationAnalyser) {
9599
- t11 = _objectSpread45(_objectSpread45({
9619
+ var visualizationAnalyser = t11;
9620
+ var t12;
9621
+ t12 = isPlaying || unplayedMessageSentences.length > 0;
9622
+ var isPending = t12;
9623
+ var t13;
9624
+ if ($[45] !== audioPlayer || $[46] !== isAudioPlayed || $[47] !== isPending || $[48] !== visualizationAnalyser) {
9625
+ t13 = _objectSpread45(_objectSpread45({
9600
9626
  isPending: isPending,
9601
9627
  isAudioPlayed: isAudioPlayed
9602
9628
  }, audioPlayer), {}, {
9603
9629
  visualizationAnalyser: visualizationAnalyser
9604
9630
  });
9605
- $[39] = audioPlayer;
9606
- $[40] = isAudioPlayed;
9607
- $[41] = isPending;
9608
- $[42] = visualizationAnalyser;
9609
- $[43] = t11;
9631
+ $[45] = audioPlayer;
9632
+ $[46] = isAudioPlayed;
9633
+ $[47] = isPending;
9634
+ $[48] = visualizationAnalyser;
9635
+ $[49] = t13;
9610
9636
  } else {
9611
- t11 = $[43];
9637
+ t13 = $[49];
9612
9638
  }
9613
- return t11;
9639
+ return t13;
9614
9640
  };
9615
9641
  function _temp11() {
9616
9642
  if (isHtmlAudioSupported) {
@@ -9712,8 +9738,8 @@ function _asyncToGenerator12(n) {
9712
9738
  };
9713
9739
  }
9714
9740
  var Content8 = function(t0) {
9715
- var $ = (0, import_react_compiler_runtime51.c)(21);
9716
- var children = t0.children, className = t0.className, style = t0.style;
9741
+ var $ = (0, import_react_compiler_runtime51.c)(24);
9742
+ var children = t0.children, className = t0.className, style = t0.style, play = t0.play;
9717
9743
  var addToast = useToasts().addToast;
9718
9744
  var queryClient = (0, import_react_query10.useQueryClient)();
9719
9745
  var threadContext = useSuperinterfaceContext();
@@ -9780,11 +9806,9 @@ var Content8 = function(t0) {
9780
9806
  var microphonePermission = usePermission(t2);
9781
9807
  var t3;
9782
9808
  if ($[3] !== microphonePermission || $[4] !== recorderProps) {
9783
- t3 = {
9784
- onEnd: function() {
9785
- if (microphonePermission === "granted") {
9786
- recorderProps.start();
9787
- }
9809
+ t3 = function() {
9810
+ if (microphonePermission === "granted") {
9811
+ recorderProps.start();
9788
9812
  }
9789
9813
  };
9790
9814
  $[3] = microphonePermission;
@@ -9793,41 +9817,53 @@ var Content8 = function(t0) {
9793
9817
  } else {
9794
9818
  t3 = $[5];
9795
9819
  }
9796
- var messageAudioProps = useMessageAudio(t3);
9797
- var t4 = recorderProps;
9798
- var t5;
9799
- if ($[6] !== createMessageProps || $[7] !== messageAudioProps || $[8] !== t4) {
9800
- t5 = {
9801
- recorderProps: t4,
9802
- createMessageProps: createMessageProps,
9803
- messageAudioProps: messageAudioProps
9820
+ var t4;
9821
+ if ($[6] !== play || $[7] !== t3) {
9822
+ t4 = {
9823
+ play: play,
9824
+ onEnd: t3
9804
9825
  };
9805
- $[6] = createMessageProps;
9806
- $[7] = messageAudioProps;
9826
+ $[6] = play;
9827
+ $[7] = t3;
9807
9828
  $[8] = t4;
9808
- $[9] = t5;
9809
9829
  } else {
9810
- t5 = $[9];
9830
+ t4 = $[8];
9811
9831
  }
9812
- var status = useStatus(t5).status;
9813
- var t6 = recorderProps;
9814
- var t7;
9815
- if ($[10] !== messageAudioProps || $[11] !== status || $[12] !== t6) {
9816
- t7 = {
9817
- status: status,
9818
- recorderProps: t6,
9832
+ var messageAudioProps = useMessageAudio(t4);
9833
+ var t5 = recorderProps;
9834
+ var t6;
9835
+ if ($[9] !== createMessageProps || $[10] !== messageAudioProps || $[11] !== t5) {
9836
+ t6 = {
9837
+ recorderProps: t5,
9838
+ createMessageProps: createMessageProps,
9819
9839
  messageAudioProps: messageAudioProps
9820
9840
  };
9841
+ $[9] = createMessageProps;
9821
9842
  $[10] = messageAudioProps;
9822
- $[11] = status;
9843
+ $[11] = t5;
9823
9844
  $[12] = t6;
9824
- $[13] = t7;
9825
9845
  } else {
9826
- t7 = $[13];
9846
+ t6 = $[12];
9827
9847
  }
9848
+ var status = useStatus(t6).status;
9849
+ var t7 = recorderProps;
9828
9850
  var t8;
9829
- if ($[14] !== children || $[15] !== className || $[16] !== style) {
9830
- t8 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_themes58.Flex, {
9851
+ if ($[13] !== messageAudioProps || $[14] !== status || $[15] !== t7) {
9852
+ t8 = {
9853
+ status: status,
9854
+ recorderProps: t7,
9855
+ messageAudioProps: messageAudioProps
9856
+ };
9857
+ $[13] = messageAudioProps;
9858
+ $[14] = status;
9859
+ $[15] = t7;
9860
+ $[16] = t8;
9861
+ } else {
9862
+ t8 = $[16];
9863
+ }
9864
+ var t9;
9865
+ if ($[17] !== children || $[18] !== className || $[19] !== style) {
9866
+ t9 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_themes58.Flex, {
9831
9867
  direction: "column",
9832
9868
  flexGrow: "1",
9833
9869
  p: "9",
@@ -9835,26 +9871,26 @@ var Content8 = function(t0) {
9835
9871
  style: style,
9836
9872
  children: children
9837
9873
  });
9838
- $[14] = children;
9839
- $[15] = className;
9840
- $[16] = style;
9841
- $[17] = t8;
9874
+ $[17] = children;
9875
+ $[18] = className;
9876
+ $[19] = style;
9877
+ $[20] = t9;
9842
9878
  } else {
9843
- t8 = $[17];
9879
+ t9 = $[20];
9844
9880
  }
9845
- var t9;
9846
- if ($[18] !== t7 || $[19] !== t8) {
9847
- t9 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioThreadContext.Provider, {
9848
- value: t7,
9849
- children: t8
9881
+ var t10;
9882
+ if ($[21] !== t8 || $[22] !== t9) {
9883
+ t10 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioThreadContext.Provider, {
9884
+ value: t8,
9885
+ children: t9
9850
9886
  });
9851
- $[18] = t7;
9852
- $[19] = t8;
9853
- $[20] = t9;
9887
+ $[21] = t8;
9888
+ $[22] = t9;
9889
+ $[23] = t10;
9854
9890
  } else {
9855
- t9 = $[20];
9891
+ t10 = $[23];
9856
9892
  }
9857
- return t9;
9893
+ return t10;
9858
9894
  };
9859
9895
  var Root12 = function(_ref) {
9860
9896
  var children = _ref.children, rest = _objectWithoutProperties4(_ref, _excluded4);