strapi-plugin-faqchatbot 1.0.2 → 1.0.4

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.
@@ -9336,7 +9336,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
9336
9336
  var ys = arrObjKeys(obj, inspect2);
9337
9337
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
9338
9338
  var protoTag = obj instanceof Object ? "" : "null prototype";
9339
- var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
9339
+ var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
9340
9340
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
9341
9341
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
9342
9342
  if (ys.length === 0) {
@@ -9361,25 +9361,25 @@ function canTrustToString(obj) {
9361
9361
  return !toStringTag$1 || !(typeof obj === "object" && (toStringTag$1 in obj || typeof obj[toStringTag$1] !== "undefined"));
9362
9362
  }
9363
9363
  function isArray$4(obj) {
9364
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
9364
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
9365
9365
  }
9366
9366
  function isDate$2(obj) {
9367
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
9367
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
9368
9368
  }
9369
9369
  function isRegExp$2(obj) {
9370
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
9370
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
9371
9371
  }
9372
9372
  function isError(obj) {
9373
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
9373
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
9374
9374
  }
9375
9375
  function isString$1(obj) {
9376
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
9376
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
9377
9377
  }
9378
9378
  function isNumber$1(obj) {
9379
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
9379
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
9380
9380
  }
9381
9381
  function isBoolean$1(obj) {
9382
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
9382
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
9383
9383
  }
9384
9384
  function isSymbol(obj) {
9385
9385
  if (hasShammedSymbols) {
@@ -9415,7 +9415,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
9415
9415
  function has$5(obj, key) {
9416
9416
  return hasOwn$1.call(obj, key);
9417
9417
  }
9418
- function toStr$1(obj) {
9418
+ function toStr(obj) {
9419
9419
  return objectToString.call(obj);
9420
9420
  }
9421
9421
  function nameOf(f2) {
@@ -9724,7 +9724,7 @@ var syntax = SyntaxError;
9724
9724
  var uri = URIError;
9725
9725
  var abs$1 = Math.abs;
9726
9726
  var floor$1 = Math.floor;
9727
- var max$2 = Math.max;
9727
+ var max$1 = Math.max;
9728
9728
  var min$1 = Math.min;
9729
9729
  var pow$1 = Math.pow;
9730
9730
  var round$1 = Math.round;
@@ -9853,78 +9853,99 @@ function requireObject_getPrototypeOf() {
9853
9853
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
9854
9854
  return Object_getPrototypeOf;
9855
9855
  }
9856
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
9857
- var toStr = Object.prototype.toString;
9858
- var max$1 = Math.max;
9859
- var funcType = "[object Function]";
9860
- var concatty = function concatty2(a2, b2) {
9861
- var arr = [];
9862
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
9863
- arr[i2] = a2[i2];
9864
- }
9865
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
9866
- arr[j2 + a2.length] = b2[j2];
9867
- }
9868
- return arr;
9869
- };
9870
- var slicy = function slicy2(arrLike, offset) {
9871
- var arr = [];
9872
- for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
9873
- arr[j2] = arrLike[i2];
9874
- }
9875
- return arr;
9876
- };
9877
- var joiny = function(arr, joiner) {
9878
- var str = "";
9879
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
9880
- str += arr[i2];
9881
- if (i2 + 1 < arr.length) {
9882
- str += joiner;
9856
+ var implementation;
9857
+ var hasRequiredImplementation;
9858
+ function requireImplementation() {
9859
+ if (hasRequiredImplementation) return implementation;
9860
+ hasRequiredImplementation = 1;
9861
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
9862
+ var toStr2 = Object.prototype.toString;
9863
+ var max2 = Math.max;
9864
+ var funcType = "[object Function]";
9865
+ var concatty = function concatty2(a2, b2) {
9866
+ var arr = [];
9867
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
9868
+ arr[i2] = a2[i2];
9883
9869
  }
9884
- }
9885
- return str;
9886
- };
9887
- var implementation$1 = function bind(that) {
9888
- var target = this;
9889
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
9890
- throw new TypeError(ERROR_MESSAGE + target);
9891
- }
9892
- var args = slicy(arguments, 1);
9893
- var bound;
9894
- var binder = function() {
9895
- if (this instanceof bound) {
9896
- var result = target.apply(
9897
- this,
9898
- concatty(args, arguments)
9899
- );
9900
- if (Object(result) === result) {
9901
- return result;
9870
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
9871
+ arr[j2 + a2.length] = b2[j2];
9872
+ }
9873
+ return arr;
9874
+ };
9875
+ var slicy = function slicy2(arrLike, offset) {
9876
+ var arr = [];
9877
+ for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
9878
+ arr[j2] = arrLike[i2];
9879
+ }
9880
+ return arr;
9881
+ };
9882
+ var joiny = function(arr, joiner) {
9883
+ var str = "";
9884
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
9885
+ str += arr[i2];
9886
+ if (i2 + 1 < arr.length) {
9887
+ str += joiner;
9902
9888
  }
9903
- return this;
9904
9889
  }
9905
- return target.apply(
9906
- that,
9907
- concatty(args, arguments)
9908
- );
9890
+ return str;
9909
9891
  };
9910
- var boundLength = max$1(0, target.length - args.length);
9911
- var boundArgs = [];
9912
- for (var i2 = 0; i2 < boundLength; i2++) {
9913
- boundArgs[i2] = "$" + i2;
9914
- }
9915
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
9916
- if (target.prototype) {
9917
- var Empty = function Empty2() {
9892
+ implementation = function bind2(that) {
9893
+ var target = this;
9894
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
9895
+ throw new TypeError(ERROR_MESSAGE + target);
9896
+ }
9897
+ var args = slicy(arguments, 1);
9898
+ var bound;
9899
+ var binder = function() {
9900
+ if (this instanceof bound) {
9901
+ var result = target.apply(
9902
+ this,
9903
+ concatty(args, arguments)
9904
+ );
9905
+ if (Object(result) === result) {
9906
+ return result;
9907
+ }
9908
+ return this;
9909
+ }
9910
+ return target.apply(
9911
+ that,
9912
+ concatty(args, arguments)
9913
+ );
9918
9914
  };
9919
- Empty.prototype = target.prototype;
9920
- bound.prototype = new Empty();
9921
- Empty.prototype = null;
9922
- }
9923
- return bound;
9924
- };
9925
- var implementation = implementation$1;
9926
- var functionBind = Function.prototype.bind || implementation;
9927
- var functionCall = Function.prototype.call;
9915
+ var boundLength = max2(0, target.length - args.length);
9916
+ var boundArgs = [];
9917
+ for (var i2 = 0; i2 < boundLength; i2++) {
9918
+ boundArgs[i2] = "$" + i2;
9919
+ }
9920
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
9921
+ if (target.prototype) {
9922
+ var Empty = function Empty2() {
9923
+ };
9924
+ Empty.prototype = target.prototype;
9925
+ bound.prototype = new Empty();
9926
+ Empty.prototype = null;
9927
+ }
9928
+ return bound;
9929
+ };
9930
+ return implementation;
9931
+ }
9932
+ var functionBind;
9933
+ var hasRequiredFunctionBind;
9934
+ function requireFunctionBind() {
9935
+ if (hasRequiredFunctionBind) return functionBind;
9936
+ hasRequiredFunctionBind = 1;
9937
+ var implementation2 = requireImplementation();
9938
+ functionBind = Function.prototype.bind || implementation2;
9939
+ return functionBind;
9940
+ }
9941
+ var functionCall;
9942
+ var hasRequiredFunctionCall;
9943
+ function requireFunctionCall() {
9944
+ if (hasRequiredFunctionCall) return functionCall;
9945
+ hasRequiredFunctionCall = 1;
9946
+ functionCall = Function.prototype.call;
9947
+ return functionCall;
9948
+ }
9928
9949
  var functionApply;
9929
9950
  var hasRequiredFunctionApply;
9930
9951
  function requireFunctionApply() {
@@ -9934,14 +9955,14 @@ function requireFunctionApply() {
9934
9955
  return functionApply;
9935
9956
  }
9936
9957
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
9937
- var bind$3 = functionBind;
9958
+ var bind$3 = requireFunctionBind();
9938
9959
  var $apply$1 = requireFunctionApply();
9939
- var $call$2 = functionCall;
9960
+ var $call$2 = requireFunctionCall();
9940
9961
  var $reflectApply = reflectApply;
9941
9962
  var actualApply = $reflectApply || bind$3.call($call$2, $apply$1);
9942
- var bind$2 = functionBind;
9963
+ var bind$2 = requireFunctionBind();
9943
9964
  var $TypeError$4 = type;
9944
- var $call$1 = functionCall;
9965
+ var $call$1 = requireFunctionCall();
9945
9966
  var $actualApply = actualApply;
9946
9967
  var callBindApplyHelpers = function callBindBasic(args) {
9947
9968
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -10007,8 +10028,8 @@ function requireHasown() {
10007
10028
  hasRequiredHasown = 1;
10008
10029
  var call = Function.prototype.call;
10009
10030
  var $hasOwn = Object.prototype.hasOwnProperty;
10010
- var bind3 = functionBind;
10011
- hasown = bind3.call(call, $hasOwn);
10031
+ var bind2 = requireFunctionBind();
10032
+ hasown = bind2.call(call, $hasOwn);
10012
10033
  return hasown;
10013
10034
  }
10014
10035
  var undefined$1;
@@ -10022,7 +10043,7 @@ var $TypeError$3 = type;
10022
10043
  var $URIError = uri;
10023
10044
  var abs = abs$1;
10024
10045
  var floor = floor$1;
10025
- var max = max$2;
10046
+ var max = max$1;
10026
10047
  var min = min$1;
10027
10048
  var pow = pow$1;
10028
10049
  var round = round$1;
@@ -10056,7 +10077,7 @@ var getProto = requireGetProto();
10056
10077
  var $ObjectGPO = requireObject_getPrototypeOf();
10057
10078
  var $ReflectGPO = requireReflect_getPrototypeOf();
10058
10079
  var $apply = requireFunctionApply();
10059
- var $call = functionCall;
10080
+ var $call = requireFunctionCall();
10060
10081
  var needsEval = {};
10061
10082
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
10062
10083
  var INTRINSICS = {
@@ -10227,7 +10248,7 @@ var LEGACY_ALIASES = {
10227
10248
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
10228
10249
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
10229
10250
  };
10230
- var bind$1 = functionBind;
10251
+ var bind$1 = requireFunctionBind();
10231
10252
  var hasOwn = requireHasown();
10232
10253
  var $concat = bind$1.call($call, Array.prototype.concat);
10233
10254
  var $spliceApply = bind$1.call($apply, Array.prototype.splice);
@@ -14558,7 +14579,7 @@ const admin = adminApi.enhanceEndpoints({
14558
14579
  overrideExisting: false
14559
14580
  });
14560
14581
  const { useInitQuery, useTelemetryPropertiesQuery, useInformationQuery, useProjectSettingsQuery, useUpdateProjectSettingsMutation, useGetPluginsQuery, useGetLicenseLimitsQuery, useGetLicenseTrialTimeLeftQuery, useGetGuidedTourMetaQuery } = admin;
14561
- function bind2(fn2, thisArg) {
14582
+ function bind(fn2, thisArg) {
14562
14583
  return function wrap() {
14563
14584
  return fn2.apply(thisArg, arguments);
14564
14585
  };
@@ -14695,7 +14716,7 @@ function merge2() {
14695
14716
  const extend = (a2, b2, thisArg, { allOwnKeys } = {}) => {
14696
14717
  forEach$1(b2, (val, key) => {
14697
14718
  if (thisArg && isFunction$1(val)) {
14698
- a2[key] = bind2(val, thisArg);
14719
+ a2[key] = bind(val, thisArg);
14699
14720
  } else {
14700
14721
  a2[key] = val;
14701
14722
  }
@@ -16975,7 +16996,7 @@ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
16975
16996
  });
16976
16997
  function createInstance(defaultConfig) {
16977
16998
  const context = new Axios$1(defaultConfig);
16978
- const instance = bind2(Axios$1.prototype.request, context);
16999
+ const instance = bind(Axios$1.prototype.request, context);
16979
17000
  utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
16980
17001
  utils$1.extend(instance, context, null, { allOwnKeys: true });
16981
17002
  instance.create = function create2(instanceConfig) {
@@ -24975,7 +24996,7 @@ const ChatWindowWrapper = styled__default.default(designSystem.Box)`
24975
24996
  height: 500px;
24976
24997
  z-index: 1000;
24977
24998
  overflow: hidden;
24978
- box-shadow: 0 10px 40px rgba(0,0,0,0.2);
24999
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
24979
25000
  border: 1px solid ${({ theme }) => theme.colors.neutral150};
24980
25001
  transform-origin: bottom right;
24981
25002
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
@@ -25031,27 +25052,29 @@ const ChatbotPreview = () => {
25031
25052
  if (!res.ok) throw new Error("Request failed");
25032
25053
  const reader = res.body?.getReader();
25033
25054
  if (!reader) throw new Error("No stream");
25055
+ const decoder = new TextDecoder();
25034
25056
  let botMessage = "";
25035
- let doneStream = false;
25036
25057
  setMessages((prev) => [...prev, { text: "", isUser: false }]);
25037
- while (!doneStream) {
25058
+ while (true) {
25038
25059
  const { done, value } = await reader.read();
25039
25060
  if (done) break;
25040
- const chunk = new TextDecoder().decode(value);
25061
+ const chunk = decoder.decode(value, { stream: true });
25041
25062
  const lines = chunk.split("\n");
25042
- for (const line of lines) {
25043
- if (!line.startsWith("data: ")) continue;
25044
- const text = line.replace("data: ", "").trim();
25045
- if (text === "[DONE]") {
25046
- doneStream = true;
25047
- break;
25063
+ for (let rawLine of lines) {
25064
+ const line = rawLine.replace(/\r/g, "");
25065
+ if (line.includes("[DONE]")) return;
25066
+ if (line.startsWith("data: ")) {
25067
+ const token = line.replace("data: ", "");
25068
+ botMessage += token;
25069
+ setMessages((prev) => {
25070
+ const updated = [...prev];
25071
+ updated[updated.length - 1] = {
25072
+ text: botMessage,
25073
+ isUser: false
25074
+ };
25075
+ return updated;
25076
+ });
25048
25077
  }
25049
- botMessage += text;
25050
- setMessages((prev) => {
25051
- const updated = [...prev];
25052
- updated[updated.length - 1] = { text: botMessage, isUser: false };
25053
- return updated;
25054
- });
25055
25078
  }
25056
25079
  }
25057
25080
  } catch (err) {
@@ -25068,14 +25091,74 @@ const ChatbotPreview = () => {
25068
25091
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
25069
25092
  /* @__PURE__ */ jsxRuntime.jsx(icons.Message, { color: "neutral0", width: 18 }),
25070
25093
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral0", children: "Chatbot Preview" }),
25071
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { as: "button", onClick: handleClearHistory, style: { background: "none", border: "none", cursor: "pointer", display: "flex" }, title: "Clear History", children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, { color: "neutral0", width: 14 }) })
25094
+ /* @__PURE__ */ jsxRuntime.jsx(
25095
+ designSystem.Box,
25096
+ {
25097
+ as: "button",
25098
+ onClick: handleClearHistory,
25099
+ style: { background: "none", border: "none", cursor: "pointer", display: "flex" },
25100
+ title: "Clear History",
25101
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, { color: "neutral0", width: 14 })
25102
+ }
25103
+ )
25072
25104
  ] }),
25073
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { as: "button", onClick: () => setIsOpen(false), style: { background: "none", border: "none", cursor: "pointer", display: "flex" }, title: "Close Chat", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, { color: "neutral0", width: 14 }) })
25105
+ /* @__PURE__ */ jsxRuntime.jsx(
25106
+ designSystem.Box,
25107
+ {
25108
+ as: "button",
25109
+ onClick: () => setIsOpen(false),
25110
+ style: { background: "none", border: "none", cursor: "pointer", display: "flex" },
25111
+ title: "Close Chat",
25112
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, { color: "neutral0", width: 14 })
25113
+ }
25114
+ )
25074
25115
  ] }) }),
25075
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ref: scrollRef, padding: 4, background: "neutral100", style: { flex: 1, overflowY: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: messages.map((msg, idx) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, hasRadius: true, background: msg.isUser ? "primary600" : "neutral0", shadow: "filterShadow", style: { alignSelf: msg.isUser ? "flex-end" : "flex-start", maxWidth: "85%" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: msg.isUser ? "neutral0" : "neutral800", children: msg.text }) }, idx)) }) }),
25116
+ /* @__PURE__ */ jsxRuntime.jsx(
25117
+ designSystem.Box,
25118
+ {
25119
+ ref: scrollRef,
25120
+ padding: 4,
25121
+ background: "neutral100",
25122
+ style: { flex: 1, overflowY: "auto" },
25123
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: messages.map((msg, idx) => /* @__PURE__ */ jsxRuntime.jsx(
25124
+ designSystem.Box,
25125
+ {
25126
+ padding: 3,
25127
+ hasRadius: true,
25128
+ background: msg.isUser ? "primary600" : "neutral0",
25129
+ shadow: "filterShadow",
25130
+ style: {
25131
+ alignSelf: msg.isUser ? "flex-end" : "flex-start",
25132
+ maxWidth: "85%",
25133
+ wordBreak: "break-word",
25134
+ overflowWrap: "anywhere",
25135
+ whiteSpace: "pre-wrap"
25136
+ },
25137
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: msg.isUser ? "neutral0" : "neutral800", children: msg.text })
25138
+ },
25139
+ idx
25140
+ )) })
25141
+ }
25142
+ ),
25076
25143
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, background: "neutral0", style: { borderTop: "1px solid #f0f0f5" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
25077
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flexGrow: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.TextInput, { placeholder: "Type a message...", value: chatInput, onChange: (e2) => setChatInput(e2.target.value), onKeyDown: (e2) => e2.key === "Enter" && handleSendMessage() }) }),
25078
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleSendMessage, style: { height: "40px" }, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.PaperPlane, {}), children: "Send" })
25144
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flexGrow: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
25145
+ designSystem.TextInput,
25146
+ {
25147
+ placeholder: "Type a message...",
25148
+ value: chatInput,
25149
+ onChange: (e2) => setChatInput(e2.target.value),
25150
+ onKeyDown: (e2) => e2.key === "Enter" && handleSendMessage()
25151
+ }
25152
+ ) }),
25153
+ /* @__PURE__ */ jsxRuntime.jsx(
25154
+ designSystem.Button,
25155
+ {
25156
+ onClick: handleSendMessage,
25157
+ style: { height: "40px" },
25158
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.PaperPlane, {}),
25159
+ children: "Send"
25160
+ }
25161
+ )
25079
25162
  ] }) })
25080
25163
  ] }) })
25081
25164
  ] });
@@ -24974,7 +24974,7 @@ const ChatWindowWrapper = styled$1(Box)`
24974
24974
  height: 500px;
24975
24975
  z-index: 1000;
24976
24976
  overflow: hidden;
24977
- box-shadow: 0 10px 40px rgba(0,0,0,0.2);
24977
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
24978
24978
  border: 1px solid ${({ theme }) => theme.colors.neutral150};
24979
24979
  transform-origin: bottom right;
24980
24980
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
@@ -25030,27 +25030,29 @@ const ChatbotPreview = () => {
25030
25030
  if (!res.ok) throw new Error("Request failed");
25031
25031
  const reader = res.body?.getReader();
25032
25032
  if (!reader) throw new Error("No stream");
25033
+ const decoder = new TextDecoder();
25033
25034
  let botMessage = "";
25034
- let doneStream = false;
25035
25035
  setMessages((prev) => [...prev, { text: "", isUser: false }]);
25036
- while (!doneStream) {
25036
+ while (true) {
25037
25037
  const { done, value } = await reader.read();
25038
25038
  if (done) break;
25039
- const chunk = new TextDecoder().decode(value);
25039
+ const chunk = decoder.decode(value, { stream: true });
25040
25040
  const lines = chunk.split("\n");
25041
- for (const line of lines) {
25042
- if (!line.startsWith("data: ")) continue;
25043
- const text = line.replace("data: ", "").trim();
25044
- if (text === "[DONE]") {
25045
- doneStream = true;
25046
- break;
25041
+ for (let rawLine of lines) {
25042
+ const line = rawLine.replace(/\r/g, "");
25043
+ if (line.includes("[DONE]")) return;
25044
+ if (line.startsWith("data: ")) {
25045
+ const token = line.replace("data: ", "");
25046
+ botMessage += token;
25047
+ setMessages((prev) => {
25048
+ const updated = [...prev];
25049
+ updated[updated.length - 1] = {
25050
+ text: botMessage,
25051
+ isUser: false
25052
+ };
25053
+ return updated;
25054
+ });
25047
25055
  }
25048
- botMessage += text;
25049
- setMessages((prev) => {
25050
- const updated = [...prev];
25051
- updated[updated.length - 1] = { text: botMessage, isUser: false };
25052
- return updated;
25053
- });
25054
25056
  }
25055
25057
  }
25056
25058
  } catch (err) {
@@ -25067,14 +25069,74 @@ const ChatbotPreview = () => {
25067
25069
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
25068
25070
  /* @__PURE__ */ jsx(Message, { color: "neutral0", width: 18 }),
25069
25071
  /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral0", children: "Chatbot Preview" }),
25070
- /* @__PURE__ */ jsx(Box, { as: "button", onClick: handleClearHistory, style: { background: "none", border: "none", cursor: "pointer", display: "flex" }, title: "Clear History", children: /* @__PURE__ */ jsx(ArrowClockwise, { color: "neutral0", width: 14 }) })
25072
+ /* @__PURE__ */ jsx(
25073
+ Box,
25074
+ {
25075
+ as: "button",
25076
+ onClick: handleClearHistory,
25077
+ style: { background: "none", border: "none", cursor: "pointer", display: "flex" },
25078
+ title: "Clear History",
25079
+ children: /* @__PURE__ */ jsx(ArrowClockwise, { color: "neutral0", width: 14 })
25080
+ }
25081
+ )
25071
25082
  ] }),
25072
- /* @__PURE__ */ jsx(Box, { as: "button", onClick: () => setIsOpen(false), style: { background: "none", border: "none", cursor: "pointer", display: "flex" }, title: "Close Chat", children: /* @__PURE__ */ jsx(Cross, { color: "neutral0", width: 14 }) })
25083
+ /* @__PURE__ */ jsx(
25084
+ Box,
25085
+ {
25086
+ as: "button",
25087
+ onClick: () => setIsOpen(false),
25088
+ style: { background: "none", border: "none", cursor: "pointer", display: "flex" },
25089
+ title: "Close Chat",
25090
+ children: /* @__PURE__ */ jsx(Cross, { color: "neutral0", width: 14 })
25091
+ }
25092
+ )
25073
25093
  ] }) }),
25074
- /* @__PURE__ */ jsx(Box, { ref: scrollRef, padding: 4, background: "neutral100", style: { flex: 1, overflowY: "auto" }, children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: messages.map((msg, idx) => /* @__PURE__ */ jsx(Box, { padding: 3, hasRadius: true, background: msg.isUser ? "primary600" : "neutral0", shadow: "filterShadow", style: { alignSelf: msg.isUser ? "flex-end" : "flex-start", maxWidth: "85%" }, children: /* @__PURE__ */ jsx(Typography, { textColor: msg.isUser ? "neutral0" : "neutral800", children: msg.text }) }, idx)) }) }),
25094
+ /* @__PURE__ */ jsx(
25095
+ Box,
25096
+ {
25097
+ ref: scrollRef,
25098
+ padding: 4,
25099
+ background: "neutral100",
25100
+ style: { flex: 1, overflowY: "auto" },
25101
+ children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: messages.map((msg, idx) => /* @__PURE__ */ jsx(
25102
+ Box,
25103
+ {
25104
+ padding: 3,
25105
+ hasRadius: true,
25106
+ background: msg.isUser ? "primary600" : "neutral0",
25107
+ shadow: "filterShadow",
25108
+ style: {
25109
+ alignSelf: msg.isUser ? "flex-end" : "flex-start",
25110
+ maxWidth: "85%",
25111
+ wordBreak: "break-word",
25112
+ overflowWrap: "anywhere",
25113
+ whiteSpace: "pre-wrap"
25114
+ },
25115
+ children: /* @__PURE__ */ jsx(Typography, { textColor: msg.isUser ? "neutral0" : "neutral800", children: msg.text })
25116
+ },
25117
+ idx
25118
+ )) })
25119
+ }
25120
+ ),
25075
25121
  /* @__PURE__ */ jsx(Box, { padding: 3, background: "neutral0", style: { borderTop: "1px solid #f0f0f5" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
25076
- /* @__PURE__ */ jsx(Box, { style: { flexGrow: 1 }, children: /* @__PURE__ */ jsx(TextInput, { placeholder: "Type a message...", value: chatInput, onChange: (e2) => setChatInput(e2.target.value), onKeyDown: (e2) => e2.key === "Enter" && handleSendMessage() }) }),
25077
- /* @__PURE__ */ jsx(Button, { onClick: handleSendMessage, style: { height: "40px" }, startIcon: /* @__PURE__ */ jsx(PaperPlane, {}), children: "Send" })
25122
+ /* @__PURE__ */ jsx(Box, { style: { flexGrow: 1 }, children: /* @__PURE__ */ jsx(
25123
+ TextInput,
25124
+ {
25125
+ placeholder: "Type a message...",
25126
+ value: chatInput,
25127
+ onChange: (e2) => setChatInput(e2.target.value),
25128
+ onKeyDown: (e2) => e2.key === "Enter" && handleSendMessage()
25129
+ }
25130
+ ) }),
25131
+ /* @__PURE__ */ jsx(
25132
+ Button,
25133
+ {
25134
+ onClick: handleSendMessage,
25135
+ style: { height: "40px" },
25136
+ startIcon: /* @__PURE__ */ jsx(PaperPlane, {}),
25137
+ children: "Send"
25138
+ }
25139
+ )
25078
25140
  ] }) })
25079
25141
  ] }) })
25080
25142
  ] });
@@ -26,7 +26,7 @@ const Initializer = ({ setPlugin }) => {
26
26
  }, []);
27
27
  return null;
28
28
  };
29
- const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.PuzzlePiece, {});
29
+ const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Discuss, {});
30
30
  const index = {
31
31
  register(app) {
32
32
  app.addMenuLink({
@@ -37,7 +37,7 @@ const index = {
37
37
  defaultMessage: PLUGIN_ID
38
38
  },
39
39
  Component: async () => {
40
- const { App } = await Promise.resolve().then(() => require("../_chunks/App-BegikOzF.js"));
40
+ const { App } = await Promise.resolve().then(() => require("../_chunks/App-B9KjKqVf.js"));
41
41
  return App;
42
42
  }
43
43
  });
@@ -1,6 +1,6 @@
1
1
  import { useRef, useEffect } from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { PuzzlePiece } from "@strapi/icons";
3
+ import { Discuss } from "@strapi/icons";
4
4
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
5
5
  const v = glob[path];
6
6
  if (v) {
@@ -25,7 +25,7 @@ const Initializer = ({ setPlugin }) => {
25
25
  }, []);
26
26
  return null;
27
27
  };
28
- const PluginIcon = () => /* @__PURE__ */ jsx(PuzzlePiece, {});
28
+ const PluginIcon = () => /* @__PURE__ */ jsx(Discuss, {});
29
29
  const index = {
30
30
  register(app) {
31
31
  app.addMenuLink({
@@ -36,7 +36,7 @@ const index = {
36
36
  defaultMessage: PLUGIN_ID
37
37
  },
38
38
  Component: async () => {
39
- const { App } = await import("../_chunks/App-_ybXHESK.mjs");
39
+ const { App } = await import("../_chunks/App-BLjeG5zk.mjs");
40
40
  return App;
41
41
  }
42
42
  });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.2",
2
+ "version": "1.0.4",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "main": "dist/server/index.js",