@superinterface/react 2.16.0 → 2.16.2

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
@@ -10,6 +10,47 @@ function _array_with_holes(arr) {
10
10
  function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
+ function _async_iterator(iterable) {
14
+ var method, async, sync, retry = 2;
15
+ for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
16
+ if (async && null != (method = iterable[async])) return method.call(iterable);
17
+ if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
18
+ async = "@@asyncIterator", sync = "@@iterator";
19
+ }
20
+ throw new TypeError("Object is not async iterable");
21
+ }
22
+ function AsyncFromSyncIterator(s) {
23
+ function AsyncFromSyncIteratorContinuation(r) {
24
+ if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
25
+ var done = r.done;
26
+ return Promise.resolve(r.value).then(function(value) {
27
+ return {
28
+ value: value,
29
+ done: done
30
+ };
31
+ });
32
+ }
33
+ return AsyncFromSyncIterator = function(s) {
34
+ this.s = s, this.n = s.next;
35
+ }, AsyncFromSyncIterator.prototype = {
36
+ s: null,
37
+ n: null,
38
+ next: function() {
39
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
40
+ },
41
+ return: function(value) {
42
+ var ret = this.s.return;
43
+ return void 0 === ret ? Promise.resolve({
44
+ value: value,
45
+ done: !0
46
+ }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
47
+ },
48
+ throw: function(value) {
49
+ var thr = this.s.return;
50
+ return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
51
+ }
52
+ }, new AsyncFromSyncIterator(s);
53
+ }
13
54
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
55
  try {
15
56
  var info = gen[key](arg);
@@ -267,6 +308,20 @@ function _ts_generator(thisArg, body) {
267
308
  };
268
309
  }
269
310
  }
311
+ function _ts_values(o) {
312
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
313
+ if (m) return m.call(o);
314
+ if (o && typeof o.length === "number") return {
315
+ next: function() {
316
+ if (o && i >= o.length) o = void 0;
317
+ return {
318
+ value: o && o[i++],
319
+ done: !o
320
+ };
321
+ }
322
+ };
323
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
324
+ }
270
325
  var _import_lodash2_default;
271
326
  var _this;
272
327
  var __create = Object.create;
@@ -1392,10 +1447,7 @@ var components = {
1392
1447
  };
1393
1448
  // src/contexts/markdown/MarkdownContext/index.ts
1394
1449
  var MarkdownContext = (0, import_react22.createContext)({
1395
- remarkPlugins: [],
1396
- rehypeReactOptions: {
1397
- components: components
1398
- }
1450
+ components: components
1399
1451
  });
1400
1452
  // src/hooks/markdown/useMarkdownContext/index.ts
1401
1453
  var useMarkdownContext = function() {
@@ -2733,6 +2785,7 @@ var Preview = function() {
2733
2785
  };
2734
2786
  // src/components/threads/Thread/MessageForm/Field/Files/Control.tsx
2735
2787
  var import_react37 = require("react");
2788
+ var import_radash13 = require("radash");
2736
2789
  var import_dayjs2 = __toESM(require("dayjs"), 1);
2737
2790
  var import_react_icons8 = require("@radix-ui/react-icons");
2738
2791
  var import_themes36 = require("@radix-ui/themes");
@@ -2852,50 +2905,174 @@ var Control2 = function() {
2852
2905
  var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading, setFiles = _useMessageFormContext.setFiles;
2853
2906
  var createFile = useCreateFile().createFile;
2854
2907
  var addToast = useToasts().addToast;
2855
- var onChange = (0, import_react37.useCallback)(function(event) {
2856
- var files = event.target.files;
2857
- if (!files) return;
2858
- var newFiles = Array.from(files).map(function(file) {
2859
- var id = optimisticId();
2860
- createFile({
2861
- file: file
2862
- }, {
2863
- onSuccess: function(param) {
2864
- var file2 = param.file;
2865
- setFiles(function(prev) {
2866
- return _to_consumable_array(prev.filter(function(prevFile) {
2867
- return prevFile.id !== id;
2868
- })).concat([
2869
- file2
2870
- ]);
2871
- });
2872
- },
2873
- onError: function() {
2874
- addToast({
2875
- type: "error",
2876
- message: "Could not upload file. Please try again."
2877
- });
2878
- setFiles(function(prev) {
2879
- return prev.filter(function(prevFile) {
2880
- return prevFile.id !== id;
2908
+ var onChange = (0, import_react37.useCallback)(function() {
2909
+ var _ref = _async_to_generator(function(event) {
2910
+ var fileObjects, newFiles, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, err;
2911
+ return _ts_generator(this, function(_state) {
2912
+ switch(_state.label){
2913
+ case 0:
2914
+ fileObjects = event.target.files;
2915
+ if (!fileObjects) return [
2916
+ 2
2917
+ ];
2918
+ newFiles = Array.from(fileObjects).map(function(fileObject) {
2919
+ return {
2920
+ id: optimisticId(),
2921
+ filename: fileObject.name,
2922
+ object: "file",
2923
+ purpose: "assistants",
2924
+ created_at: (0, import_dayjs2.default)().unix(),
2925
+ bytes: fileObject.size,
2926
+ status: "processed",
2927
+ fileObject: fileObject
2928
+ };
2881
2929
  });
2882
- });
2930
+ setFiles(function(prev) {
2931
+ return _to_consumable_array(prev).concat(_to_consumable_array(newFiles.map(function(file) {
2932
+ return (0, import_radash13.omit)(file, [
2933
+ "fileObject"
2934
+ ]);
2935
+ })));
2936
+ });
2937
+ _iteratorAbruptCompletion = false, _didIteratorError = false;
2938
+ _state.label = 1;
2939
+ case 1:
2940
+ _state.trys.push([
2941
+ 1,
2942
+ 7,
2943
+ 8,
2944
+ 13
2945
+ ]);
2946
+ _loop = function() {
2947
+ var _value, newFile;
2948
+ return _ts_generator(this, function(_state) {
2949
+ switch(_state.label){
2950
+ case 0:
2951
+ _value = _step.value;
2952
+ newFile = _value;
2953
+ return [
2954
+ 4,
2955
+ createFile({
2956
+ file: newFile.fileObject
2957
+ }, {
2958
+ onSuccess: function(param) {
2959
+ var file = param.file;
2960
+ return setFiles(function(prev) {
2961
+ return _to_consumable_array(prev.filter(function(prevFile) {
2962
+ return prevFile.id !== newFile.id;
2963
+ })).concat([
2964
+ file
2965
+ ]);
2966
+ });
2967
+ },
2968
+ onError: function() {
2969
+ addToast({
2970
+ type: "error",
2971
+ message: "Could not upload file. Please try again."
2972
+ });
2973
+ setFiles(function(prev) {
2974
+ return prev.filter(function(prevFile) {
2975
+ return prevFile.id !== newFile.id;
2976
+ });
2977
+ });
2978
+ }
2979
+ })
2980
+ ];
2981
+ case 1:
2982
+ _state.sent();
2983
+ return [
2984
+ 2
2985
+ ];
2986
+ }
2987
+ });
2988
+ };
2989
+ _iterator = _async_iterator(newFiles);
2990
+ _state.label = 2;
2991
+ case 2:
2992
+ return [
2993
+ 4,
2994
+ _iterator.next()
2995
+ ];
2996
+ case 3:
2997
+ if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
2998
+ 3,
2999
+ 6
3000
+ ];
3001
+ return [
3002
+ 5,
3003
+ _ts_values(_loop())
3004
+ ];
3005
+ case 4:
3006
+ _state.sent();
3007
+ _state.label = 5;
3008
+ case 5:
3009
+ _iteratorAbruptCompletion = false;
3010
+ return [
3011
+ 3,
3012
+ 2
3013
+ ];
3014
+ case 6:
3015
+ return [
3016
+ 3,
3017
+ 13
3018
+ ];
3019
+ case 7:
3020
+ err = _state.sent();
3021
+ _didIteratorError = true;
3022
+ _iteratorError = err;
3023
+ return [
3024
+ 3,
3025
+ 13
3026
+ ];
3027
+ case 8:
3028
+ _state.trys.push([
3029
+ 8,
3030
+ ,
3031
+ 11,
3032
+ 12
3033
+ ]);
3034
+ if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
3035
+ 3,
3036
+ 10
3037
+ ];
3038
+ return [
3039
+ 4,
3040
+ _iterator.return()
3041
+ ];
3042
+ case 9:
3043
+ _state.sent();
3044
+ _state.label = 10;
3045
+ case 10:
3046
+ return [
3047
+ 3,
3048
+ 12
3049
+ ];
3050
+ case 11:
3051
+ if (_didIteratorError) {
3052
+ throw _iteratorError;
3053
+ }
3054
+ return [
3055
+ 7
3056
+ ];
3057
+ case 12:
3058
+ return [
3059
+ 7
3060
+ ];
3061
+ case 13:
3062
+ return [
3063
+ 2
3064
+ ];
2883
3065
  }
2884
3066
  });
2885
- return {
2886
- id: id,
2887
- filename: file.name,
2888
- object: "file",
2889
- purpose: "assistants",
2890
- created_at: (0, import_dayjs2.default)().unix(),
2891
- bytes: file.size,
2892
- status: "processed"
2893
- };
2894
3067
  });
2895
- setFiles(function(prev) {
2896
- return _to_consumable_array(prev).concat(_to_consumable_array(newFiles));
2897
- });
2898
- }, []);
3068
+ return function(event) {
3069
+ return _ref.apply(this, arguments);
3070
+ };
3071
+ }(), [
3072
+ addToast,
3073
+ createFile,
3074
+ setFiles
3075
+ ]);
2899
3076
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_themes36.Flex, {
2900
3077
  pt: "2",
2901
3078
  pr: "2",
@@ -2913,6 +3090,7 @@ var Control2 = function() {
2913
3090
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react_icons8.FilePlusIcon, {}),
2914
3091
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("input", {
2915
3092
  type: "file",
3093
+ multiple: true,
2916
3094
  accept: accept,
2917
3095
  onChange: onChange,
2918
3096
  style: {
@@ -3588,7 +3766,7 @@ var import_compromise = __toESM(require("compromise"), 1);
3588
3766
  var import_howler = require("howler");
3589
3767
  var import_react_use_audio_player2 = require("react-use-audio-player");
3590
3768
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
3591
- var import_radash13 = require("radash");
3769
+ var import_radash14 = require("radash");
3592
3770
  var input = function(param) {
3593
3771
  var message = param.message;
3594
3772
  var textContents = message.content.filter(function(c) {
@@ -3597,7 +3775,7 @@ var input = function(param) {
3597
3775
  var result = textContents.map(function(c) {
3598
3776
  return c.text.value;
3599
3777
  }).join(" ");
3600
- if ((0, import_radash13.isEmpty)(result)) return null;
3778
+ if ((0, import_radash14.isEmpty)(result)) return null;
3601
3779
  return result;
3602
3780
  };
3603
3781
  // src/hooks/audioThreads/useMessageAudio/lib/isHtmlAudioSupported.ts
@@ -3858,7 +4036,7 @@ var useAudioThreadContext = function() {
3858
4036
  var import_lodash8 = __toESM(require("lodash"), 1);
3859
4037
  var import_themes45 = require("@radix-ui/themes");
3860
4038
  var import_react48 = require("react");
3861
- var import_radash14 = require("radash");
4039
+ var import_radash15 = require("radash");
3862
4040
  var import_jsx_runtime65 = require("react/jsx-runtime");
3863
4041
  var barCount = 4;
3864
4042
  var BarsVisualizer = function(param) {
@@ -3872,7 +4050,7 @@ var BarsVisualizer = function(param) {
3872
4050
  }
3873
4051
  var frequencyData = new Uint8Array(visualizationAnalyser2.frequencyBinCount / 15);
3874
4052
  visualizationAnalyser2.getByteFrequencyData(frequencyData);
3875
- var clusteredFrequencyData = (0, import_radash14.cluster)(frequencyData, frequencyData.length / barCount);
4053
+ var clusteredFrequencyData = (0, import_radash15.cluster)(frequencyData, frequencyData.length / barCount);
3876
4054
  setBarHeights(clusteredFrequencyData.map(function(frequencyDataCluster) {
3877
4055
  return import_lodash8.default.mean(frequencyDataCluster) / 255 * 100;
3878
4056
  }));
@@ -4227,7 +4405,7 @@ AudioThreadDialog.Content = Content4;
4227
4405
  var import_react51 = require("react");
4228
4406
  // src/components/suggestions/Suggestions/Content.tsx
4229
4407
  var import_react50 = require("react");
4230
- var import_radash15 = require("radash");
4408
+ var import_radash16 = require("radash");
4231
4409
  var import_react_children_utilities = require("react-children-utilities");
4232
4410
  var import_themes51 = require("@radix-ui/themes");
4233
4411
  // src/components/suggestions/Suggestions/Item.tsx
@@ -4285,14 +4463,14 @@ var Content6 = function(param) {
4285
4463
  var isMutatingMessage = useIsMutatingMessage();
4286
4464
  var suggestions = (0, import_react50.useMemo)(function() {
4287
4465
  return (0, import_react_children_utilities.onlyText)(children).split(/\r?\n/).filter(function(c) {
4288
- return !(0, import_radash15.isEmpty)(c);
4466
+ return !(0, import_radash16.isEmpty)(c);
4289
4467
  }).map(function(c) {
4290
4468
  return c.trim();
4291
4469
  });
4292
4470
  }, [
4293
4471
  children
4294
4472
  ]);
4295
- if ((0, import_radash15.isEmpty)(suggestions)) return null;
4473
+ if ((0, import_radash16.isEmpty)(suggestions)) return null;
4296
4474
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_themes51.Flex, {
4297
4475
  gap: "2",
4298
4476
  py: "2",