funda-ui 4.6.151 → 4.6.222
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/Chatbox/index.css +70 -13
- package/Chatbox/index.d.ts +1 -0
- package/Chatbox/index.js +351 -268
- package/lib/cjs/Chatbox/index.d.ts +1 -0
- package/lib/cjs/Chatbox/index.js +351 -268
- package/lib/css/Chatbox/index.css +70 -13
- package/lib/esm/Chatbox/PureLoader.tsx +4 -2
- package/lib/esm/Chatbox/TypingEffect.tsx +12 -41
- package/lib/esm/Chatbox/index.scss +92 -23
- package/lib/esm/Chatbox/index.tsx +66 -29
- package/lib/esm/Chatbox/utils/func.ts +52 -1
- package/lib/esm/Textarea/index.tsx +0 -2
- package/package.json +1 -1
package/Chatbox/index.js
CHANGED
|
@@ -3565,124 +3565,22 @@ var sanitize = __webpack_require__(959);
|
|
|
3565
3565
|
;// CONCATENATED MODULE: ./src/PureLoader.tsx
|
|
3566
3566
|
|
|
3567
3567
|
var PureLoader = function PureLoader(props) {
|
|
3568
|
-
var
|
|
3568
|
+
var _props$prefix = props.prefix,
|
|
3569
|
+
prefix = _props$prefix === void 0 ? 'custom-' : _props$prefix,
|
|
3570
|
+
txt = props.txt,
|
|
3569
3571
|
center = props.center,
|
|
3570
3572
|
customClassName = props.customClassName;
|
|
3571
3573
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
3572
|
-
className: "
|
|
3574
|
+
className: "".concat(prefix, "chatbox-loader-container ").concat(customClassName || '')
|
|
3573
3575
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
3574
3576
|
className: "row g-0 align-items-center"
|
|
3575
3577
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
3576
3578
|
className: center ? 'text-center' : ''
|
|
3577
3579
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("small", null, txt || txt === '' ? txt : 'Loading...')), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
3578
|
-
className: "
|
|
3580
|
+
className: "${prefix}chatbox-loader"
|
|
3579
3581
|
})))));
|
|
3580
3582
|
};
|
|
3581
3583
|
/* harmony default export */ const src_PureLoader = (PureLoader);
|
|
3582
|
-
;// CONCATENATED MODULE: ./src/TypingEffect.tsx
|
|
3583
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3584
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3585
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3586
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
3587
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
3588
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3589
|
-
|
|
3590
|
-
var TypingEffect = function TypingEffect(_ref) {
|
|
3591
|
-
var content = _ref.content,
|
|
3592
|
-
speed = _ref.speed,
|
|
3593
|
-
onComplete = _ref.onComplete,
|
|
3594
|
-
onUpdate = _ref.onUpdate;
|
|
3595
|
-
var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
|
|
3596
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3597
|
-
displayedContent = _useState2[0],
|
|
3598
|
-
setDisplayedContent = _useState2[1];
|
|
3599
|
-
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
|
|
3600
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
3601
|
-
index = _useState4[0],
|
|
3602
|
-
setIndex = _useState4[1];
|
|
3603
|
-
var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
|
|
3604
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
3605
|
-
imagePlaceholders = _useState6[0],
|
|
3606
|
-
setImagePlaceholders = _useState6[1];
|
|
3607
|
-
var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
|
|
3608
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
3609
|
-
processedContent = _useState8[0],
|
|
3610
|
-
setProcessedContent = _useState8[1];
|
|
3611
|
-
|
|
3612
|
-
// Extract and replace image tags
|
|
3613
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
3614
|
-
var extractImages = function extractImages(html) {
|
|
3615
|
-
var placeholders = [];
|
|
3616
|
-
var processedHtml = html;
|
|
3617
|
-
|
|
3618
|
-
// <img>
|
|
3619
|
-
processedHtml = processedHtml.replace(/<img[^>]*>/g, function (match) {
|
|
3620
|
-
var placeholder = "[IMG_".concat(placeholders.length, "]");
|
|
3621
|
-
placeholders.push({
|
|
3622
|
-
original: match,
|
|
3623
|
-
placeholder: placeholder,
|
|
3624
|
-
type: 'img'
|
|
3625
|
-
});
|
|
3626
|
-
return placeholder;
|
|
3627
|
-
});
|
|
3628
|
-
|
|
3629
|
-
// <svg>
|
|
3630
|
-
processedHtml = processedHtml.replace(/<svg[^>]*>[\s\S]*?<\/svg>/g, function (match) {
|
|
3631
|
-
var placeholder = "[SVG_".concat(placeholders.length, "]");
|
|
3632
|
-
placeholders.push({
|
|
3633
|
-
original: match,
|
|
3634
|
-
placeholder: placeholder,
|
|
3635
|
-
type: 'svg'
|
|
3636
|
-
});
|
|
3637
|
-
return placeholder;
|
|
3638
|
-
});
|
|
3639
|
-
return {
|
|
3640
|
-
processedHtml: processedHtml,
|
|
3641
|
-
placeholders: placeholders
|
|
3642
|
-
};
|
|
3643
|
-
};
|
|
3644
|
-
var _extractImages = extractImages(content),
|
|
3645
|
-
processedHtml = _extractImages.processedHtml,
|
|
3646
|
-
placeholders = _extractImages.placeholders;
|
|
3647
|
-
setProcessedContent(processedHtml);
|
|
3648
|
-
setImagePlaceholders(placeholders);
|
|
3649
|
-
}, [content]);
|
|
3650
|
-
|
|
3651
|
-
// Handle typing effects
|
|
3652
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
3653
|
-
var timer = setInterval(function () {
|
|
3654
|
-
if (index < processedContent.length) {
|
|
3655
|
-
var newContent = processedContent.substring(0, index + 1);
|
|
3656
|
-
|
|
3657
|
-
// Replace the completed placeholder
|
|
3658
|
-
imagePlaceholders.forEach(function (_ref2) {
|
|
3659
|
-
var original = _ref2.original,
|
|
3660
|
-
placeholder = _ref2.placeholder;
|
|
3661
|
-
if (newContent.includes(placeholder)) {
|
|
3662
|
-
newContent = newContent.replace(placeholder, original);
|
|
3663
|
-
}
|
|
3664
|
-
});
|
|
3665
|
-
setDisplayedContent(newContent);
|
|
3666
|
-
setIndex(function (prev) {
|
|
3667
|
-
return prev + 1;
|
|
3668
|
-
});
|
|
3669
|
-
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate();
|
|
3670
|
-
} else {
|
|
3671
|
-
clearInterval(timer);
|
|
3672
|
-
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
3673
|
-
}
|
|
3674
|
-
}, speed);
|
|
3675
|
-
return function () {
|
|
3676
|
-
return clearInterval(timer);
|
|
3677
|
-
};
|
|
3678
|
-
}, [processedContent, index, speed, onComplete, onUpdate, imagePlaceholders]);
|
|
3679
|
-
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
3680
|
-
dangerouslySetInnerHTML: {
|
|
3681
|
-
__html: displayedContent
|
|
3682
|
-
}
|
|
3683
|
-
});
|
|
3684
|
-
};
|
|
3685
|
-
/* harmony default export */ const src_TypingEffect = (TypingEffect);
|
|
3686
3584
|
;// CONCATENATED MODULE: ./src/utils/func.ts
|
|
3687
3585
|
// app.ts
|
|
3688
3586
|
|
|
@@ -3711,6 +3609,11 @@ function formatLatestDisplayContent(str) {
|
|
|
3711
3609
|
return match; // If not empty, return the original matched content
|
|
3712
3610
|
});
|
|
3713
3611
|
|
|
3612
|
+
// Then handle tables without is-init class
|
|
3613
|
+
output = output.replace(/<table(?![^>]*\bis-init\b)([^>]*)>([\s\S]*?)<\/table>/g, function (match, attributes, content) {
|
|
3614
|
+
// Add is-init class to table and wrap it in container div
|
|
3615
|
+
return "<div class=\"table-container\"><table class=\"is-init\"".concat(attributes, ">").concat(content, "</table></div>");
|
|
3616
|
+
});
|
|
3714
3617
|
return output;
|
|
3715
3618
|
}
|
|
3716
3619
|
function formatName(str, isAnswer, props) {
|
|
@@ -3787,6 +3690,125 @@ function isStreamResponse(response) {
|
|
|
3787
3690
|
return response.body instanceof ReadableStream;
|
|
3788
3691
|
}
|
|
3789
3692
|
;
|
|
3693
|
+
function extractHtmlTags(html) {
|
|
3694
|
+
var placeholders = [];
|
|
3695
|
+
var processedHtml = html;
|
|
3696
|
+
|
|
3697
|
+
// <table>
|
|
3698
|
+
processedHtml = processedHtml.replace(/<table[^>]*>[\s\S]*?<\/table>/g, function (match) {
|
|
3699
|
+
var placeholder = "[TABLE_".concat(placeholders.length, "]");
|
|
3700
|
+
placeholders.push({
|
|
3701
|
+
original: "<div class=\"table-container\">".concat(match === null || match === void 0 ? void 0 : match.replace('<table', '<table class="is-init"'), "</div>"),
|
|
3702
|
+
placeholder: placeholder,
|
|
3703
|
+
type: 'table'
|
|
3704
|
+
});
|
|
3705
|
+
return placeholder;
|
|
3706
|
+
});
|
|
3707
|
+
|
|
3708
|
+
// <img>
|
|
3709
|
+
processedHtml = processedHtml.replace(/<img[^>]*>/g, function (match) {
|
|
3710
|
+
var placeholder = "[IMG_".concat(placeholders.length, "]");
|
|
3711
|
+
placeholders.push({
|
|
3712
|
+
original: match,
|
|
3713
|
+
placeholder: placeholder,
|
|
3714
|
+
type: 'img'
|
|
3715
|
+
});
|
|
3716
|
+
return placeholder;
|
|
3717
|
+
});
|
|
3718
|
+
|
|
3719
|
+
// <svg>
|
|
3720
|
+
processedHtml = processedHtml.replace(/<svg[^>]*>[\s\S]*?<\/svg>/g, function (match) {
|
|
3721
|
+
var placeholder = "[SVG_".concat(placeholders.length, "]");
|
|
3722
|
+
placeholders.push({
|
|
3723
|
+
original: match,
|
|
3724
|
+
placeholder: placeholder,
|
|
3725
|
+
type: 'svg'
|
|
3726
|
+
});
|
|
3727
|
+
return placeholder;
|
|
3728
|
+
});
|
|
3729
|
+
return {
|
|
3730
|
+
processedHtml: processedHtml,
|
|
3731
|
+
placeholders: placeholders
|
|
3732
|
+
};
|
|
3733
|
+
}
|
|
3734
|
+
;
|
|
3735
|
+
;// CONCATENATED MODULE: ./src/TypingEffect.tsx
|
|
3736
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3737
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3738
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3739
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
3740
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
3741
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
// extract
|
|
3745
|
+
|
|
3746
|
+
var TypingEffect = function TypingEffect(_ref) {
|
|
3747
|
+
var content = _ref.content,
|
|
3748
|
+
speed = _ref.speed,
|
|
3749
|
+
onComplete = _ref.onComplete,
|
|
3750
|
+
onUpdate = _ref.onUpdate;
|
|
3751
|
+
var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
|
|
3752
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3753
|
+
displayedContent = _useState2[0],
|
|
3754
|
+
setDisplayedContent = _useState2[1];
|
|
3755
|
+
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
|
|
3756
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3757
|
+
index = _useState4[0],
|
|
3758
|
+
setIndex = _useState4[1];
|
|
3759
|
+
var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
|
|
3760
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3761
|
+
htmlTagPlaceholder = _useState6[0],
|
|
3762
|
+
setHtmlTagPlaceholders = _useState6[1];
|
|
3763
|
+
var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
|
|
3764
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3765
|
+
processedContent = _useState8[0],
|
|
3766
|
+
setProcessedContent = _useState8[1];
|
|
3767
|
+
|
|
3768
|
+
// Extract and replace image tags
|
|
3769
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
3770
|
+
var _extractHtmlTags = extractHtmlTags(content),
|
|
3771
|
+
processedHtml = _extractHtmlTags.processedHtml,
|
|
3772
|
+
placeholders = _extractHtmlTags.placeholders;
|
|
3773
|
+
setProcessedContent(processedHtml);
|
|
3774
|
+
setHtmlTagPlaceholders(placeholders);
|
|
3775
|
+
}, [content]);
|
|
3776
|
+
|
|
3777
|
+
// Handle typing effects
|
|
3778
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
3779
|
+
var timer = setInterval(function () {
|
|
3780
|
+
if (index < processedContent.length) {
|
|
3781
|
+
var newContent = processedContent.substring(0, index + 1);
|
|
3782
|
+
|
|
3783
|
+
// Replace the completed placeholder
|
|
3784
|
+
htmlTagPlaceholder.forEach(function (_ref2) {
|
|
3785
|
+
var original = _ref2.original,
|
|
3786
|
+
placeholder = _ref2.placeholder;
|
|
3787
|
+
if (newContent.includes(placeholder)) {
|
|
3788
|
+
newContent = newContent.replace(placeholder, original);
|
|
3789
|
+
}
|
|
3790
|
+
});
|
|
3791
|
+
setDisplayedContent(newContent);
|
|
3792
|
+
setIndex(function (prev) {
|
|
3793
|
+
return prev + 1;
|
|
3794
|
+
});
|
|
3795
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate();
|
|
3796
|
+
} else {
|
|
3797
|
+
clearInterval(timer);
|
|
3798
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
3799
|
+
}
|
|
3800
|
+
}, speed);
|
|
3801
|
+
return function () {
|
|
3802
|
+
return clearInterval(timer);
|
|
3803
|
+
};
|
|
3804
|
+
}, [processedContent, index, speed, onComplete, onUpdate, htmlTagPlaceholder]);
|
|
3805
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
3806
|
+
dangerouslySetInnerHTML: {
|
|
3807
|
+
__html: displayedContent
|
|
3808
|
+
}
|
|
3809
|
+
});
|
|
3810
|
+
};
|
|
3811
|
+
/* harmony default export */ const src_TypingEffect = (TypingEffect);
|
|
3790
3812
|
;// CONCATENATED MODULE: ./src/useStreamController.tsx
|
|
3791
3813
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3792
3814
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
@@ -4179,12 +4201,8 @@ var useStreamController = function useStreamController() {
|
|
|
4179
4201
|
/* harmony default export */ const src_useStreamController = (useStreamController);
|
|
4180
4202
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
4181
4203
|
function src_typeof(obj) { "@babel/helpers - typeof"; return src_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, src_typeof(obj); }
|
|
4182
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || src_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4183
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4184
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4185
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return src_arrayLikeToArray(arr); }
|
|
4186
|
-
function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4187
4204
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = src_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
4205
|
+
function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4188
4206
|
function src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4189
4207
|
function src_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4190
4208
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -4192,6 +4210,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4192
4210
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4193
4211
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return src_typeof(key) === "symbol" ? key : String(key); }
|
|
4194
4212
|
function _toPrimitive(input, hint) { if (src_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (src_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4213
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || src_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4214
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4215
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4216
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return src_arrayLikeToArray(arr); }
|
|
4195
4217
|
function src_slicedToArray(arr, i) { return src_arrayWithHoles(arr) || src_iterableToArrayLimit(arr, i) || src_unsupportedIterableToArray(arr, i) || src_nonIterableRest(); }
|
|
4196
4218
|
function src_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4197
4219
|
function src_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return src_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return src_arrayLikeToArray(o, minLen); }
|
|
@@ -4298,8 +4320,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
4298
4320
|
setShow(false);
|
|
4299
4321
|
},
|
|
4300
4322
|
clearData: function clearData() {
|
|
4301
|
-
|
|
4323
|
+
// Update both the conversation history and displayed messages
|
|
4302
4324
|
conversationHistory.current = [];
|
|
4325
|
+
setMsgList([]);
|
|
4303
4326
|
},
|
|
4304
4327
|
sendMsg: function sendMsg() {
|
|
4305
4328
|
handleClickSafe();
|
|
@@ -4313,6 +4336,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
4313
4336
|
conversationHistory.current = conversationHistory.current.slice(-maxLength);
|
|
4314
4337
|
}
|
|
4315
4338
|
},
|
|
4339
|
+
setHistory: function setHistory(messages) {
|
|
4340
|
+
// Update both the conversation history and displayed messages
|
|
4341
|
+
conversationHistory.current = _toConsumableArray(messages);
|
|
4342
|
+
setMsgList(_toConsumableArray(messages));
|
|
4343
|
+
},
|
|
4316
4344
|
setVal: function setVal(v) {
|
|
4317
4345
|
if (inputContentRef.current) inputContentRef.current.set(v);
|
|
4318
4346
|
},
|
|
@@ -4519,34 +4547,83 @@ var Chatbox = function Chatbox(props) {
|
|
|
4519
4547
|
return newState;
|
|
4520
4548
|
});
|
|
4521
4549
|
};
|
|
4522
|
-
var executeButtonAction = function
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4550
|
+
var executeButtonAction = /*#__PURE__*/function () {
|
|
4551
|
+
var _ref = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(actionStr, buttonId, buttonElement) {
|
|
4552
|
+
var actionFn, result, options, newState;
|
|
4553
|
+
return src_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4554
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4555
|
+
case 0:
|
|
4556
|
+
_context.prev = 0;
|
|
4557
|
+
actionFn = new Function('method', 'isActive', 'button', actionStr); // !!!REQUIRED "await"
|
|
4558
|
+
// "customMethods" may be asynchronous
|
|
4559
|
+
_context.next = 4;
|
|
4560
|
+
return actionFn(exposedMethods(), !activeButtons[buttonId], buttonElement);
|
|
4561
|
+
case 4:
|
|
4562
|
+
result = _context.sent;
|
|
4563
|
+
// If the returned result is an array, it is a dynamic option
|
|
4564
|
+
if (Array.isArray(result) && Object.keys(dynamicOptions).length === 0) {
|
|
4565
|
+
options = result.map(function (item) {
|
|
4566
|
+
var _Object$entries$ = src_slicedToArray(Object.entries(item)[0], 2),
|
|
4567
|
+
key = _Object$entries$[0],
|
|
4568
|
+
value = _Object$entries$[1];
|
|
4569
|
+
var _split$map = value.split('{#}').map(function (s) {
|
|
4570
|
+
return s.trim();
|
|
4571
|
+
}),
|
|
4572
|
+
_split$map2 = src_slicedToArray(_split$map, 3),
|
|
4573
|
+
label = _split$map2[0],
|
|
4574
|
+
val = _split$map2[1],
|
|
4575
|
+
onClick = _split$map2[2];
|
|
4576
|
+
return {
|
|
4577
|
+
label: label,
|
|
4578
|
+
value: val,
|
|
4579
|
+
onClick: onClick
|
|
4580
|
+
};
|
|
4581
|
+
}); // Update dynamic options
|
|
4582
|
+
setDynamicOptions(function (prev) {
|
|
4583
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, options));
|
|
4584
|
+
});
|
|
4585
|
+
}
|
|
4532
4586
|
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4587
|
+
// Update the button status
|
|
4588
|
+
newState = !activeButtons[buttonId];
|
|
4589
|
+
setActiveButtons(function (prev) {
|
|
4590
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, newState));
|
|
4591
|
+
});
|
|
4592
|
+
return _context.abrupt("return", result);
|
|
4593
|
+
case 11:
|
|
4594
|
+
_context.prev = 11;
|
|
4595
|
+
_context.t0 = _context["catch"](0);
|
|
4596
|
+
console.error('Error executing button action:', _context.t0);
|
|
4597
|
+
case 14:
|
|
4598
|
+
case "end":
|
|
4599
|
+
return _context.stop();
|
|
4600
|
+
}
|
|
4601
|
+
}, _callee, null, [[0, 11]]);
|
|
4602
|
+
}));
|
|
4603
|
+
return function executeButtonAction(_x2, _x3, _x4) {
|
|
4604
|
+
return _ref.apply(this, arguments);
|
|
4605
|
+
};
|
|
4606
|
+
}();
|
|
4543
4607
|
|
|
4544
4608
|
// options
|
|
4545
4609
|
var _useState21 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4546
4610
|
_useState22 = src_slicedToArray(_useState21, 2),
|
|
4547
4611
|
selectedOpt = _useState22[0],
|
|
4548
4612
|
setSelectedOpt = _useState22[1];
|
|
4549
|
-
|
|
4613
|
+
// Store dynamic options
|
|
4614
|
+
var _useState23 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4615
|
+
_useState24 = src_slicedToArray(_useState23, 2),
|
|
4616
|
+
dynamicOptions = _useState24[0],
|
|
4617
|
+
setDynamicOptions = _useState24[1];
|
|
4618
|
+
var getButtonOptions = function getButtonOptions(btn, buttonId) {
|
|
4619
|
+
// If you are using the dynamic option and already have a cache, return the option for caching
|
|
4620
|
+
//---------
|
|
4621
|
+
if (btn.dynamicOptions && dynamicOptions[buttonId]) {
|
|
4622
|
+
return dynamicOptions[buttonId];
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4625
|
+
// Use the static option from "props"
|
|
4626
|
+
//---------
|
|
4550
4627
|
var options = [];
|
|
4551
4628
|
var index = 1;
|
|
4552
4629
|
while (true) {
|
|
@@ -4580,8 +4657,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
4580
4657
|
});
|
|
4581
4658
|
} else {
|
|
4582
4659
|
setSelectedOpt(function (prev) {
|
|
4583
|
-
var
|
|
4584
|
-
return _objectSpread(_objectSpread({}, prev), {}, (
|
|
4660
|
+
var _objectSpread4;
|
|
4661
|
+
return _objectSpread(_objectSpread({}, prev), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, buttonId, option.label), _defineProperty(_objectSpread4, "curIndex", index), _defineProperty(_objectSpread4, "curValue", value), _objectSpread4));
|
|
4585
4662
|
});
|
|
4586
4663
|
}
|
|
4587
4664
|
executeButtonAction(option.onClick, buttonId, document.getElementById(buttonId));
|
|
@@ -4644,25 +4721,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
4644
4721
|
|
|
4645
4722
|
// parse chunk data
|
|
4646
4723
|
var parseChunkData = /*#__PURE__*/function () {
|
|
4647
|
-
var
|
|
4724
|
+
var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(chunk, index, complete) {
|
|
4648
4725
|
var lastContent, _args$responseExtract, extractPath, lines, _iterator, _step, line, _content, result, _iterator2, _step2, path, content, parsedContent, latestRes;
|
|
4649
|
-
return src_regeneratorRuntime().wrap(function
|
|
4650
|
-
while (1) switch (
|
|
4726
|
+
return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4727
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4651
4728
|
case 0:
|
|
4652
4729
|
// Store the final content and bind it to loading
|
|
4653
4730
|
lastContent = '';
|
|
4654
|
-
|
|
4731
|
+
_context2.prev = 1;
|
|
4655
4732
|
// Extract response using the path
|
|
4656
4733
|
extractPath = (_args$responseExtract = args().responseExtractPath) === null || _args$responseExtract === void 0 ? void 0 : _args$responseExtract.slice(1); // Streaming data is JSON split by rows
|
|
4657
4734
|
lines = chunk.split("\n").filter(function (line) {
|
|
4658
4735
|
return line.trim() !== "";
|
|
4659
4736
|
});
|
|
4660
4737
|
_iterator = _createForOfIteratorHelper(lines);
|
|
4661
|
-
|
|
4738
|
+
_context2.prev = 5;
|
|
4662
4739
|
_iterator.s();
|
|
4663
4740
|
case 7:
|
|
4664
4741
|
if ((_step = _iterator.n()).done) {
|
|
4665
|
-
|
|
4742
|
+
_context2.next = 45;
|
|
4666
4743
|
break;
|
|
4667
4744
|
}
|
|
4668
4745
|
line = _step.value;
|
|
@@ -4673,7 +4750,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
4673
4750
|
|
|
4674
4751
|
// Send the streamed data to the front end
|
|
4675
4752
|
if (!(line.indexOf('[DONE]') < 0)) {
|
|
4676
|
-
|
|
4753
|
+
_context2.next = 40;
|
|
4677
4754
|
break;
|
|
4678
4755
|
}
|
|
4679
4756
|
// STEP 1:
|
|
@@ -4681,14 +4758,14 @@ var Chatbox = function Chatbox(props) {
|
|
|
4681
4758
|
// Create a JSON string
|
|
4682
4759
|
_content = "".concat(line.replace(/^data:\s*/, '')); // Determine whether it is in JSON format
|
|
4683
4760
|
if (isValidJSON(_content)) {
|
|
4684
|
-
|
|
4761
|
+
_context2.next = 16;
|
|
4685
4762
|
break;
|
|
4686
4763
|
}
|
|
4687
4764
|
console.log('--> [ERROR] Wrong JSON format');
|
|
4688
4765
|
|
|
4689
4766
|
//reset SSE
|
|
4690
4767
|
closeSSE();
|
|
4691
|
-
return
|
|
4768
|
+
return _context2.abrupt("break", 45);
|
|
4692
4769
|
case 16:
|
|
4693
4770
|
// STEP 2:
|
|
4694
4771
|
// ------
|
|
@@ -4697,18 +4774,18 @@ var Chatbox = function Chatbox(props) {
|
|
|
4697
4774
|
// for Ollama API (STREAM END)
|
|
4698
4775
|
//*******
|
|
4699
4776
|
if (!(typeof result.done !== 'undefined')) {
|
|
4700
|
-
|
|
4777
|
+
_context2.next = 22;
|
|
4701
4778
|
break;
|
|
4702
4779
|
}
|
|
4703
4780
|
if (!(result.done === true)) {
|
|
4704
|
-
|
|
4781
|
+
_context2.next = 22;
|
|
4705
4782
|
break;
|
|
4706
4783
|
}
|
|
4707
4784
|
console.log('--> [DONE]');
|
|
4708
4785
|
|
|
4709
4786
|
//reset SSE
|
|
4710
4787
|
closeSSE();
|
|
4711
|
-
return
|
|
4788
|
+
return _context2.abrupt("break", 45);
|
|
4712
4789
|
case 22:
|
|
4713
4790
|
//*******
|
|
4714
4791
|
// for OpenAI API
|
|
@@ -4730,10 +4807,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
4730
4807
|
// ------
|
|
4731
4808
|
// 🚀 !! IMPORTANT: Skip the error content
|
|
4732
4809
|
if (!(typeof content === 'undefined')) {
|
|
4733
|
-
|
|
4810
|
+
_context2.next = 26;
|
|
4734
4811
|
break;
|
|
4735
4812
|
}
|
|
4736
|
-
return
|
|
4813
|
+
return _context2.abrupt("continue", 43);
|
|
4737
4814
|
case 26:
|
|
4738
4815
|
// STEP 4:
|
|
4739
4816
|
// ------
|
|
@@ -4760,13 +4837,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4760
4837
|
// ------
|
|
4761
4838
|
parsedContent = tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4762
4839
|
if (!(typeof args().renderParser === 'function')) {
|
|
4763
|
-
|
|
4840
|
+
_context2.next = 36;
|
|
4764
4841
|
break;
|
|
4765
4842
|
}
|
|
4766
|
-
|
|
4843
|
+
_context2.next = 35;
|
|
4767
4844
|
return args().renderParser(parsedContent);
|
|
4768
4845
|
case 35:
|
|
4769
|
-
parsedContent =
|
|
4846
|
+
parsedContent = _context2.sent;
|
|
4770
4847
|
case 36:
|
|
4771
4848
|
// STEP 8:
|
|
4772
4849
|
// ------
|
|
@@ -4783,55 +4860,55 @@ var Chatbox = function Chatbox(props) {
|
|
|
4783
4860
|
// ------
|
|
4784
4861
|
// Scroll to the bottom
|
|
4785
4862
|
scrollToBottom();
|
|
4786
|
-
|
|
4863
|
+
_context2.next = 43;
|
|
4787
4864
|
break;
|
|
4788
4865
|
case 40:
|
|
4789
4866
|
console.log('--> [DONE]');
|
|
4790
4867
|
|
|
4791
4868
|
//reset SSE
|
|
4792
4869
|
closeSSE();
|
|
4793
|
-
return
|
|
4870
|
+
return _context2.abrupt("break", 45);
|
|
4794
4871
|
case 43:
|
|
4795
|
-
|
|
4872
|
+
_context2.next = 7;
|
|
4796
4873
|
break;
|
|
4797
4874
|
case 45:
|
|
4798
|
-
|
|
4875
|
+
_context2.next = 50;
|
|
4799
4876
|
break;
|
|
4800
4877
|
case 47:
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
_iterator.e(
|
|
4878
|
+
_context2.prev = 47;
|
|
4879
|
+
_context2.t0 = _context2["catch"](5);
|
|
4880
|
+
_iterator.e(_context2.t0);
|
|
4804
4881
|
case 50:
|
|
4805
|
-
|
|
4882
|
+
_context2.prev = 50;
|
|
4806
4883
|
_iterator.f();
|
|
4807
|
-
return
|
|
4884
|
+
return _context2.finish(50);
|
|
4808
4885
|
case 53:
|
|
4809
|
-
|
|
4886
|
+
_context2.next = 58;
|
|
4810
4887
|
break;
|
|
4811
4888
|
case 55:
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
console.error('--> Error processing chunk:',
|
|
4889
|
+
_context2.prev = 55;
|
|
4890
|
+
_context2.t1 = _context2["catch"](1);
|
|
4891
|
+
console.error('--> Error processing chunk:', _context2.t1);
|
|
4815
4892
|
case 58:
|
|
4816
4893
|
latestRes = complete ? lastContent : tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4817
4894
|
if (!(typeof args().renderParser === 'function')) {
|
|
4818
|
-
|
|
4895
|
+
_context2.next = 63;
|
|
4819
4896
|
break;
|
|
4820
4897
|
}
|
|
4821
|
-
|
|
4898
|
+
_context2.next = 62;
|
|
4822
4899
|
return args().renderParser(latestRes);
|
|
4823
4900
|
case 62:
|
|
4824
|
-
latestRes =
|
|
4901
|
+
latestRes = _context2.sent;
|
|
4825
4902
|
case 63:
|
|
4826
|
-
return
|
|
4903
|
+
return _context2.abrupt("return", formatLatestDisplayContent(latestRes));
|
|
4827
4904
|
case 64:
|
|
4828
4905
|
case "end":
|
|
4829
|
-
return
|
|
4906
|
+
return _context2.stop();
|
|
4830
4907
|
}
|
|
4831
|
-
},
|
|
4908
|
+
}, _callee2, null, [[1, 55], [5, 47, 50, 53]]);
|
|
4832
4909
|
}));
|
|
4833
|
-
return function parseChunkData(
|
|
4834
|
-
return
|
|
4910
|
+
return function parseChunkData(_x5, _x6, _x7) {
|
|
4911
|
+
return _ref2.apply(this, arguments);
|
|
4835
4912
|
};
|
|
4836
4913
|
}();
|
|
4837
4914
|
|
|
@@ -4839,11 +4916,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
4839
4916
|
var tempLastContent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('');
|
|
4840
4917
|
var streamController = src_useStreamController({
|
|
4841
4918
|
onChunk: function () {
|
|
4842
|
-
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
4843
|
-
var _args$onChunk,
|
|
4919
|
+
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3(chunk, index) {
|
|
4920
|
+
var _args$onChunk, _args4;
|
|
4844
4921
|
var res;
|
|
4845
|
-
return src_regeneratorRuntime().wrap(function
|
|
4846
|
-
while (1) switch (
|
|
4922
|
+
return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4923
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4847
4924
|
case 0:
|
|
4848
4925
|
// start (Execute it only once)
|
|
4849
4926
|
if (index === 0) {
|
|
@@ -4852,50 +4929,50 @@ var Chatbox = function Chatbox(props) {
|
|
|
4852
4929
|
}
|
|
4853
4930
|
|
|
4854
4931
|
//
|
|
4855
|
-
|
|
4932
|
+
_context3.next = 3;
|
|
4856
4933
|
return parseChunkData(chunk, index, false);
|
|
4857
4934
|
case 3:
|
|
4858
|
-
res =
|
|
4935
|
+
res = _context3.sent;
|
|
4859
4936
|
//
|
|
4860
|
-
(_args$onChunk = (
|
|
4937
|
+
(_args$onChunk = (_args4 = args()).onChunk) === null || _args$onChunk === void 0 ? void 0 : _args$onChunk.call(_args4, inputContentRef.current, res, conversationHistory.current);
|
|
4861
4938
|
case 5:
|
|
4862
4939
|
case "end":
|
|
4863
|
-
return
|
|
4940
|
+
return _context3.stop();
|
|
4864
4941
|
}
|
|
4865
|
-
},
|
|
4942
|
+
}, _callee3);
|
|
4866
4943
|
}));
|
|
4867
|
-
function onChunk(
|
|
4944
|
+
function onChunk(_x8, _x9) {
|
|
4868
4945
|
return _onChunk.apply(this, arguments);
|
|
4869
4946
|
}
|
|
4870
4947
|
return onChunk;
|
|
4871
4948
|
}(),
|
|
4872
4949
|
onComplete: function () {
|
|
4873
|
-
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
4874
|
-
var _args$onComplete,
|
|
4950
|
+
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4(lastContent) {
|
|
4951
|
+
var _args$onComplete, _args6;
|
|
4875
4952
|
var res;
|
|
4876
|
-
return src_regeneratorRuntime().wrap(function
|
|
4877
|
-
while (1) switch (
|
|
4953
|
+
return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4954
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4878
4955
|
case 0:
|
|
4879
4956
|
console.log('--> Stream complete');
|
|
4880
|
-
|
|
4957
|
+
_context4.next = 3;
|
|
4881
4958
|
return parseChunkData(lastContent, 0, true);
|
|
4882
4959
|
case 3:
|
|
4883
|
-
res =
|
|
4960
|
+
res = _context4.sent;
|
|
4884
4961
|
// Display AI reply
|
|
4885
4962
|
displayMessage(args().answerNameRes, res);
|
|
4886
4963
|
|
|
4887
4964
|
//
|
|
4888
|
-
(_args$onComplete = (
|
|
4965
|
+
(_args$onComplete = (_args6 = args()).onComplete) === null || _args$onComplete === void 0 ? void 0 : _args$onComplete.call(_args6, inputContentRef.current, res, conversationHistory.current);
|
|
4889
4966
|
|
|
4890
4967
|
//
|
|
4891
4968
|
closeSSE();
|
|
4892
4969
|
case 7:
|
|
4893
4970
|
case "end":
|
|
4894
|
-
return
|
|
4971
|
+
return _context4.stop();
|
|
4895
4972
|
}
|
|
4896
|
-
},
|
|
4973
|
+
}, _callee4);
|
|
4897
4974
|
}));
|
|
4898
|
-
function onComplete(
|
|
4975
|
+
function onComplete(_x10) {
|
|
4899
4976
|
return _onComplete.apply(this, arguments);
|
|
4900
4977
|
}
|
|
4901
4978
|
return onComplete;
|
|
@@ -4944,34 +5021,34 @@ var Chatbox = function Chatbox(props) {
|
|
|
4944
5021
|
});
|
|
4945
5022
|
};
|
|
4946
5023
|
var sendMessage = /*#__PURE__*/function () {
|
|
4947
|
-
var
|
|
4948
|
-
var messageInput, message, inputMsg, res, _args$onChunk2,
|
|
4949
|
-
return src_regeneratorRuntime().wrap(function
|
|
4950
|
-
while (1) switch (
|
|
5024
|
+
var _ref3 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5() {
|
|
5025
|
+
var messageInput, message, inputMsg, res, _args$onChunk2, _args8, _args$onComplete2, _args9, reply, replyRes;
|
|
5026
|
+
return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5027
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
4951
5028
|
case 0:
|
|
4952
5029
|
if (!(rootRef.current === null || msgContainerRef.current === null || msInput.current === null)) {
|
|
4953
|
-
|
|
5030
|
+
_context5.next = 2;
|
|
4954
5031
|
break;
|
|
4955
5032
|
}
|
|
4956
|
-
return
|
|
5033
|
+
return _context5.abrupt("return");
|
|
4957
5034
|
case 2:
|
|
4958
5035
|
messageInput = msInput.current;
|
|
4959
5036
|
message = (0,sanitize.htmlEncode)(messageInput.value); // It fires in real time as the user enters
|
|
4960
5037
|
// Sanitizing input is the process of securing/cleaning/filtering input data.
|
|
4961
5038
|
if (!(typeof args().onInputCallback === 'function')) {
|
|
4962
|
-
|
|
5039
|
+
_context5.next = 8;
|
|
4963
5040
|
break;
|
|
4964
5041
|
}
|
|
4965
|
-
|
|
5042
|
+
_context5.next = 7;
|
|
4966
5043
|
return args().onInputCallback(message);
|
|
4967
5044
|
case 7:
|
|
4968
|
-
message =
|
|
5045
|
+
message = _context5.sent;
|
|
4969
5046
|
case 8:
|
|
4970
5047
|
if (!(message.trim() === '')) {
|
|
4971
|
-
|
|
5048
|
+
_context5.next = 10;
|
|
4972
5049
|
break;
|
|
4973
5050
|
}
|
|
4974
|
-
return
|
|
5051
|
+
return _context5.abrupt("return");
|
|
4975
5052
|
case 10:
|
|
4976
5053
|
// Start the timer
|
|
4977
5054
|
setElapsedTime(0); // Reset elapsed time
|
|
@@ -4984,13 +5061,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4984
5061
|
// user message
|
|
4985
5062
|
inputMsg = "".concat(message); // If a render parser exists, it is used to process the string
|
|
4986
5063
|
if (!(typeof args().renderParser === 'function')) {
|
|
4987
|
-
|
|
5064
|
+
_context5.next = 17;
|
|
4988
5065
|
break;
|
|
4989
5066
|
}
|
|
4990
|
-
|
|
5067
|
+
_context5.next = 16;
|
|
4991
5068
|
return args().renderParser(inputMsg);
|
|
4992
5069
|
case 16:
|
|
4993
|
-
inputMsg =
|
|
5070
|
+
inputMsg = _context5.sent;
|
|
4994
5071
|
case 17:
|
|
4995
5072
|
displayMessage(args().questionNameRes, inputMsg); // Display user message
|
|
4996
5073
|
|
|
@@ -5002,48 +5079,48 @@ var Chatbox = function Chatbox(props) {
|
|
|
5002
5079
|
|
|
5003
5080
|
// clear
|
|
5004
5081
|
if (inputContentRef.current) inputContentRef.current.clear();
|
|
5005
|
-
|
|
5006
|
-
|
|
5082
|
+
_context5.prev = 21;
|
|
5083
|
+
_context5.next = 24;
|
|
5007
5084
|
return mainRequest(message);
|
|
5008
5085
|
case 24:
|
|
5009
|
-
res =
|
|
5086
|
+
res = _context5.sent;
|
|
5010
5087
|
if (res.useStreamRender) {
|
|
5011
|
-
|
|
5088
|
+
_context5.next = 36;
|
|
5012
5089
|
break;
|
|
5013
5090
|
}
|
|
5014
5091
|
reply = res.reply;
|
|
5015
5092
|
replyRes = "".concat(reply); // If a render parser exists, it is used to process the string
|
|
5016
5093
|
if (!(typeof args().renderParser === 'function')) {
|
|
5017
|
-
|
|
5094
|
+
_context5.next = 32;
|
|
5018
5095
|
break;
|
|
5019
5096
|
}
|
|
5020
|
-
|
|
5097
|
+
_context5.next = 31;
|
|
5021
5098
|
return args().renderParser(replyRes);
|
|
5022
5099
|
case 31:
|
|
5023
|
-
replyRes =
|
|
5100
|
+
replyRes = _context5.sent;
|
|
5024
5101
|
case 32:
|
|
5025
5102
|
displayMessage(args().answerNameRes, replyRes); // Display AI reply
|
|
5026
5103
|
|
|
5027
5104
|
//
|
|
5028
|
-
(_args$onChunk2 = (
|
|
5029
|
-
(_args$onComplete2 = (
|
|
5105
|
+
(_args$onChunk2 = (_args8 = args()).onChunk) === null || _args$onChunk2 === void 0 ? void 0 : _args$onChunk2.call(_args8, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5106
|
+
(_args$onComplete2 = (_args9 = args()).onComplete) === null || _args$onComplete2 === void 0 ? void 0 : _args$onComplete2.call(_args9, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5030
5107
|
|
|
5031
5108
|
//reset SSE
|
|
5032
5109
|
closeSSE();
|
|
5033
5110
|
case 36:
|
|
5034
|
-
|
|
5111
|
+
_context5.next = 45;
|
|
5035
5112
|
break;
|
|
5036
5113
|
case 38:
|
|
5037
|
-
|
|
5038
|
-
|
|
5114
|
+
_context5.prev = 38;
|
|
5115
|
+
_context5.t0 = _context5["catch"](21);
|
|
5039
5116
|
// loading
|
|
5040
5117
|
setLoading(false);
|
|
5041
5118
|
|
|
5042
5119
|
// Stop the timer
|
|
5043
5120
|
clearInterval(timer.current);
|
|
5044
5121
|
timer.current = null;
|
|
5045
|
-
console.error('--> Error sending message:',
|
|
5046
|
-
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(
|
|
5122
|
+
console.error('--> Error sending message:', _context5.t0);
|
|
5123
|
+
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(_context5.t0))); // Display AI reply
|
|
5047
5124
|
case 45:
|
|
5048
5125
|
// clear
|
|
5049
5126
|
messageInput.value = '';
|
|
@@ -5055,12 +5132,12 @@ var Chatbox = function Chatbox(props) {
|
|
|
5055
5132
|
scrollToBottom();
|
|
5056
5133
|
case 48:
|
|
5057
5134
|
case "end":
|
|
5058
|
-
return
|
|
5135
|
+
return _context5.stop();
|
|
5059
5136
|
}
|
|
5060
|
-
},
|
|
5137
|
+
}, _callee5, null, [[21, 38]]);
|
|
5061
5138
|
}));
|
|
5062
5139
|
return function sendMessage() {
|
|
5063
|
-
return
|
|
5140
|
+
return _ref3.apply(this, arguments);
|
|
5064
5141
|
};
|
|
5065
5142
|
}();
|
|
5066
5143
|
var handleClickSafe = useDebounce_default()(function () {
|
|
@@ -5072,25 +5149,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
5072
5149
|
setShow(false);
|
|
5073
5150
|
};
|
|
5074
5151
|
var mainRequest = /*#__PURE__*/function () {
|
|
5075
|
-
var
|
|
5152
|
+
var _ref4 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee6(msg) {
|
|
5076
5153
|
var currentStreamMode, requestBodyRes, customResponse, content, isStream, contentRes, response, _errInfo, _args$responseExtract2, extractPath, _response, _errInfo2, jsonResponse, result, _iterator3, _step3, path, _content2, _err;
|
|
5077
|
-
return src_regeneratorRuntime().wrap(function
|
|
5078
|
-
while (1) switch (
|
|
5154
|
+
return src_regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
5155
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
5079
5156
|
case 0:
|
|
5080
5157
|
currentStreamMode = args().isStream; // Update stream mode
|
|
5081
5158
|
setEnableStreamMode(currentStreamMode);
|
|
5082
|
-
|
|
5159
|
+
_context6.prev = 2;
|
|
5083
5160
|
// Parse and interpolate request body template
|
|
5084
5161
|
requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
|
|
5085
5162
|
// If a formatter function exists, it is used to process the request body
|
|
5086
5163
|
if (!(typeof args().requestBodyFormatter === 'function')) {
|
|
5087
|
-
|
|
5164
|
+
_context6.next = 8;
|
|
5088
5165
|
break;
|
|
5089
5166
|
}
|
|
5090
|
-
|
|
5167
|
+
_context6.next = 7;
|
|
5091
5168
|
return args().requestBodyFormatter(requestBodyRes, args().latestContextData, conversationHistory.current);
|
|
5092
5169
|
case 7:
|
|
5093
|
-
requestBodyRes =
|
|
5170
|
+
requestBodyRes = _context6.sent;
|
|
5094
5171
|
case 8:
|
|
5095
5172
|
// Scroll to the bottom
|
|
5096
5173
|
setTimeout(function () {
|
|
@@ -5098,19 +5175,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5098
5175
|
scrollToBottom();
|
|
5099
5176
|
}, 500);
|
|
5100
5177
|
if (!(typeof args().customRequest === 'function')) {
|
|
5101
|
-
|
|
5178
|
+
_context6.next = 25;
|
|
5102
5179
|
break;
|
|
5103
5180
|
}
|
|
5104
5181
|
// Update stream mode
|
|
5105
5182
|
setEnableStreamMode(false);
|
|
5106
|
-
|
|
5183
|
+
_context6.next = 13;
|
|
5107
5184
|
return args().customRequest(msg, {
|
|
5108
5185
|
requestBody: requestBodyRes,
|
|
5109
5186
|
apiUrl: args().requestApiUrl || '',
|
|
5110
5187
|
headers: args().headerConfigRes
|
|
5111
5188
|
});
|
|
5112
5189
|
case 13:
|
|
5113
|
-
customResponse =
|
|
5190
|
+
customResponse = _context6.sent;
|
|
5114
5191
|
content = customResponse.content, isStream = customResponse.isStream;
|
|
5115
5192
|
contentRes = content; // Update stream mode
|
|
5116
5193
|
setEnableStreamMode(isStream);
|
|
@@ -5118,24 +5195,24 @@ var Chatbox = function Chatbox(props) {
|
|
|
5118
5195
|
// NORMAL
|
|
5119
5196
|
//++++++++++++++++++++++++++++++++++++++++++++++++
|
|
5120
5197
|
if (!(!isStream && typeof contentRes === 'string' && contentRes.trim() !== '')) {
|
|
5121
|
-
|
|
5198
|
+
_context6.next = 20;
|
|
5122
5199
|
break;
|
|
5123
5200
|
}
|
|
5124
5201
|
// Replace with a valid label
|
|
5125
5202
|
contentRes = fixHtmlTags(contentRes, args().withReasoning, args().reasoningSwitchLabel);
|
|
5126
|
-
return
|
|
5203
|
+
return _context6.abrupt("return", {
|
|
5127
5204
|
reply: formatLatestDisplayContent(contentRes),
|
|
5128
5205
|
useStreamRender: false
|
|
5129
5206
|
});
|
|
5130
5207
|
case 20:
|
|
5131
5208
|
if (!(isStream && isStreamResponse(contentRes))) {
|
|
5132
|
-
|
|
5209
|
+
_context6.next = 24;
|
|
5133
5210
|
break;
|
|
5134
5211
|
}
|
|
5135
|
-
|
|
5212
|
+
_context6.next = 23;
|
|
5136
5213
|
return streamController.start(contentRes);
|
|
5137
5214
|
case 23:
|
|
5138
|
-
return
|
|
5215
|
+
return _context6.abrupt("return", {
|
|
5139
5216
|
reply: tempAnimText,
|
|
5140
5217
|
// The final content will be in tempAnimText
|
|
5141
5218
|
useStreamRender: true
|
|
@@ -5149,19 +5226,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5149
5226
|
}
|
|
5150
5227
|
case 25:
|
|
5151
5228
|
if (!currentStreamMode) {
|
|
5152
|
-
|
|
5229
|
+
_context6.next = 39;
|
|
5153
5230
|
break;
|
|
5154
5231
|
}
|
|
5155
|
-
|
|
5232
|
+
_context6.next = 28;
|
|
5156
5233
|
return fetch(args().requestApiUrl || '', {
|
|
5157
5234
|
method: "POST",
|
|
5158
5235
|
body: JSON.stringify(requestBodyRes),
|
|
5159
5236
|
headers: args().headerConfigRes
|
|
5160
5237
|
});
|
|
5161
5238
|
case 28:
|
|
5162
|
-
response =
|
|
5239
|
+
response = _context6.sent;
|
|
5163
5240
|
if (response.ok) {
|
|
5164
|
-
|
|
5241
|
+
_context6.next = 34;
|
|
5165
5242
|
break;
|
|
5166
5243
|
}
|
|
5167
5244
|
_errInfo = "[ERROR] HTTP Error ".concat(response.status, ": ").concat(response.statusText);
|
|
@@ -5169,15 +5246,15 @@ var Chatbox = function Chatbox(props) {
|
|
|
5169
5246
|
|
|
5170
5247
|
// hide loader
|
|
5171
5248
|
setLoaderDisplay(false);
|
|
5172
|
-
return
|
|
5249
|
+
return _context6.abrupt("return", {
|
|
5173
5250
|
reply: _errInfo,
|
|
5174
5251
|
useStreamRender: false
|
|
5175
5252
|
});
|
|
5176
5253
|
case 34:
|
|
5177
|
-
|
|
5254
|
+
_context6.next = 36;
|
|
5178
5255
|
return streamController.start(response);
|
|
5179
5256
|
case 36:
|
|
5180
|
-
return
|
|
5257
|
+
return _context6.abrupt("return", {
|
|
5181
5258
|
reply: tempAnimText,
|
|
5182
5259
|
// The final content will be in tempAnimText
|
|
5183
5260
|
useStreamRender: true
|
|
@@ -5185,7 +5262,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5185
5262
|
case 39:
|
|
5186
5263
|
// Extract response using the path
|
|
5187
5264
|
extractPath = (_args$responseExtract2 = args().responseExtractPath) === null || _args$responseExtract2 === void 0 ? void 0 : _args$responseExtract2.slice(1);
|
|
5188
|
-
|
|
5265
|
+
_context6.next = 42;
|
|
5189
5266
|
return fetch(args().requestApiUrl || '', {
|
|
5190
5267
|
method: "POST",
|
|
5191
5268
|
headers: args().headerConfigRes,
|
|
@@ -5193,22 +5270,22 @@ var Chatbox = function Chatbox(props) {
|
|
|
5193
5270
|
signal: abortController.current.signal
|
|
5194
5271
|
});
|
|
5195
5272
|
case 42:
|
|
5196
|
-
_response =
|
|
5273
|
+
_response = _context6.sent;
|
|
5197
5274
|
if (_response.ok) {
|
|
5198
|
-
|
|
5275
|
+
_context6.next = 47;
|
|
5199
5276
|
break;
|
|
5200
5277
|
}
|
|
5201
5278
|
_errInfo2 = "[ERROR] HTTP Error ".concat(_response.status, ": ").concat(_response.statusText); // hide loader
|
|
5202
5279
|
setLoaderDisplay(false);
|
|
5203
|
-
return
|
|
5280
|
+
return _context6.abrupt("return", {
|
|
5204
5281
|
reply: _errInfo2,
|
|
5205
5282
|
useStreamRender: false
|
|
5206
5283
|
});
|
|
5207
5284
|
case 47:
|
|
5208
|
-
|
|
5285
|
+
_context6.next = 49;
|
|
5209
5286
|
return _response.json();
|
|
5210
5287
|
case 49:
|
|
5211
|
-
jsonResponse =
|
|
5288
|
+
jsonResponse = _context6.sent;
|
|
5212
5289
|
// hide loader
|
|
5213
5290
|
setLoaderDisplay(false);
|
|
5214
5291
|
result = jsonResponse;
|
|
@@ -5227,33 +5304,33 @@ var Chatbox = function Chatbox(props) {
|
|
|
5227
5304
|
}
|
|
5228
5305
|
_content2 = result; // Replace with a valid label
|
|
5229
5306
|
_content2 = fixHtmlTags(_content2, args().withReasoning, args().reasoningSwitchLabel);
|
|
5230
|
-
return
|
|
5307
|
+
return _context6.abrupt("return", {
|
|
5231
5308
|
reply: formatLatestDisplayContent(_content2),
|
|
5232
5309
|
useStreamRender: false
|
|
5233
5310
|
});
|
|
5234
5311
|
case 56:
|
|
5235
|
-
|
|
5312
|
+
_context6.next = 64;
|
|
5236
5313
|
break;
|
|
5237
5314
|
case 58:
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
_err = "--> Error in mainRequest: ".concat(
|
|
5315
|
+
_context6.prev = 58;
|
|
5316
|
+
_context6.t0 = _context6["catch"](2);
|
|
5317
|
+
_err = "--> Error in mainRequest: ".concat(_context6.t0);
|
|
5241
5318
|
console.error(_err);
|
|
5242
5319
|
|
|
5243
5320
|
//reset SSE
|
|
5244
5321
|
closeSSE();
|
|
5245
|
-
return
|
|
5322
|
+
return _context6.abrupt("return", {
|
|
5246
5323
|
reply: _err,
|
|
5247
5324
|
useStreamRender: false
|
|
5248
5325
|
});
|
|
5249
5326
|
case 64:
|
|
5250
5327
|
case "end":
|
|
5251
|
-
return
|
|
5328
|
+
return _context6.stop();
|
|
5252
5329
|
}
|
|
5253
|
-
},
|
|
5330
|
+
}, _callee6, null, [[2, 58]]);
|
|
5254
5331
|
}));
|
|
5255
|
-
return function mainRequest(
|
|
5256
|
-
return
|
|
5332
|
+
return function mainRequest(_x11) {
|
|
5333
|
+
return _ref4.apply(this, arguments);
|
|
5257
5334
|
};
|
|
5258
5335
|
}();
|
|
5259
5336
|
|
|
@@ -5508,8 +5585,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
5508
5585
|
}
|
|
5509
5586
|
},
|
|
5510
5587
|
onChange: function onChange(e) {
|
|
5511
|
-
var _args$onInputChange,
|
|
5512
|
-
(_args$onInputChange = (
|
|
5588
|
+
var _args$onInputChange, _args12;
|
|
5589
|
+
(_args$onInputChange = (_args12 = args()).onInputChange) === null || _args$onInputChange === void 0 ? void 0 : _args$onInputChange.call(_args12, inputContentRef.current, e.target.value);
|
|
5513
5590
|
},
|
|
5514
5591
|
rows: args().defaultRows || 3,
|
|
5515
5592
|
autoSize: true,
|
|
@@ -5556,6 +5633,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5556
5633
|
display: loading ? 'block' : 'none'
|
|
5557
5634
|
}
|
|
5558
5635
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_PureLoader, {
|
|
5636
|
+
prefix: args().prefix,
|
|
5559
5637
|
customClassName: "w-100",
|
|
5560
5638
|
txt: ""
|
|
5561
5639
|
}))) : null, args().toolkitButtons && args().toolkitButtons.length > 0 && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
@@ -5565,7 +5643,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5565
5643
|
var _id = "".concat(args().prefix || 'custom-', "chatbox-btn-tools-").concat(chatId).concat(index);
|
|
5566
5644
|
var isActive = activeButtons[_id];
|
|
5567
5645
|
if (btn.isSelect) {
|
|
5568
|
-
var options = getButtonOptions(btn);
|
|
5646
|
+
var options = getButtonOptions(btn, _id);
|
|
5569
5647
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5570
5648
|
key: index,
|
|
5571
5649
|
className: "toolkit-select-wrapper"
|
|
@@ -5577,6 +5655,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
5577
5655
|
setActiveButtons(function (prev) {
|
|
5578
5656
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, _id, !prev[_id]));
|
|
5579
5657
|
});
|
|
5658
|
+
|
|
5659
|
+
//
|
|
5660
|
+
executeButtonAction(btn.onClick, _id, e.currentTarget);
|
|
5580
5661
|
}
|
|
5581
5662
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5582
5663
|
dangerouslySetInnerHTML: {
|
|
@@ -5602,7 +5683,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5602
5683
|
d: "M144,6525.39 L142.594,6524 L133.987,6532.261 L133.069,6531.38 L133.074,6531.385 L125.427,6524.045 L124,6525.414 C126.113,6527.443 132.014,6533.107 133.987,6535 C135.453,6533.594 134.024,6534.965 144,6525.39"
|
|
5603
5684
|
}))))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5604
5685
|
className: "toolkit-select-options ".concat(isActive ? 'active' : '')
|
|
5605
|
-
}, options.map(function (option, optIndex) {
|
|
5686
|
+
}, options.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, options.map(function (option, optIndex) {
|
|
5606
5687
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5607
5688
|
key: optIndex,
|
|
5608
5689
|
className: "toolkit-select-option ".concat(option.value || '', " ").concat(selectedOpt.curIndex === optIndex ? 'selected' : ''),
|
|
@@ -5614,7 +5695,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
5614
5695
|
__html: option.label
|
|
5615
5696
|
}
|
|
5616
5697
|
}));
|
|
5617
|
-
})))
|
|
5698
|
+
})) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5699
|
+
className: "".concat(args().prefix || 'custom-', "chatbox-mini-loader")
|
|
5700
|
+
}))));
|
|
5618
5701
|
}
|
|
5619
5702
|
|
|
5620
5703
|
// The rendering of the normal button
|