@spteck/react-controls-v2 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/aiAssistant/AIAssistant.d.ts.map +1 -1
- package/dist/components/aiAssistant/IAIAssistantProps.d.ts +11 -2
- package/dist/components/aiAssistant/IAIAssistantProps.d.ts.map +1 -1
- package/dist/components/aiAssistant/useStreamRequest.d.ts.map +1 -1
- package/dist/components/appDashboard/IAppDashboardProps.d.ts.map +1 -1
- package/dist/components/typographyControl/ITypographyControlProps.d.ts +3 -0
- package/dist/components/typographyControl/ITypographyControlProps.d.ts.map +1 -1
- package/dist/components/typographyControl/TypographyControl.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/components/appDashboard/ExampleAppDashboardUsage.d.ts +0 -9
- package/dist/components/appDashboard/ExampleAppDashboardUsage.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -5378,7 +5378,10 @@ const TypographyControl = (props) => {
|
|
|
5378
5378
|
children,
|
|
5379
5379
|
style,
|
|
5380
5380
|
className,
|
|
5381
|
-
color
|
|
5381
|
+
color,
|
|
5382
|
+
block,
|
|
5383
|
+
truncate: truncate2,
|
|
5384
|
+
wrap
|
|
5382
5385
|
} = props;
|
|
5383
5386
|
const typographyStyle = css$1({
|
|
5384
5387
|
color,
|
|
@@ -5400,7 +5403,7 @@ const TypographyControl = (props) => {
|
|
|
5400
5403
|
marginRight: marginRight && spacingMap[marginRight] ? spacingMap[marginRight] : marginRight,
|
|
5401
5404
|
...style
|
|
5402
5405
|
});
|
|
5403
|
-
return /* @__PURE__ */ jsx$2(Text, { as, className: mergeClasses(className, typographyStyle), children });
|
|
5406
|
+
return /* @__PURE__ */ jsx$2(Text, { as, className: mergeClasses(className, typographyStyle), block, truncate: truncate2, wrap, children });
|
|
5404
5407
|
};
|
|
5405
5408
|
const ButtonMenu = (props) => {
|
|
5406
5409
|
var _a3, _b2;
|
|
@@ -25434,11 +25437,45 @@ function useStreamRequest() {
|
|
|
25434
25437
|
const decoder = new TextDecoder("utf-8");
|
|
25435
25438
|
let done = false;
|
|
25436
25439
|
let accumulatedData = "";
|
|
25440
|
+
let buffer = "";
|
|
25437
25441
|
while (!done) {
|
|
25438
25442
|
const { value, done: doneReading } = await reader.read();
|
|
25439
25443
|
done = doneReading;
|
|
25440
25444
|
if (value) {
|
|
25441
25445
|
const chunk = decoder.decode(value, { stream: true });
|
|
25446
|
+
buffer += chunk;
|
|
25447
|
+
const lines = buffer.split("\n");
|
|
25448
|
+
buffer = lines.pop() || "";
|
|
25449
|
+
let currentEvent = "";
|
|
25450
|
+
let currentData = "";
|
|
25451
|
+
for (const line2 of lines) {
|
|
25452
|
+
if (line2.startsWith("event:")) {
|
|
25453
|
+
currentEvent = line2.substring(6).trim();
|
|
25454
|
+
} else if (line2.startsWith("data:")) {
|
|
25455
|
+
currentData = line2.substring(5).trim();
|
|
25456
|
+
} else if (line2 === "") {
|
|
25457
|
+
if (currentEvent === "error") {
|
|
25458
|
+
try {
|
|
25459
|
+
const errorData = JSON.parse(currentData);
|
|
25460
|
+
const errorMessage = errorData.message || "An error occurred";
|
|
25461
|
+
if (errorMessage.includes("429") || errorMessage.toLowerCase().includes("rate limit")) {
|
|
25462
|
+
throw new Error("Rate limit exceeded. Please wait a moment and try again.");
|
|
25463
|
+
} else if (errorMessage.includes("quota")) {
|
|
25464
|
+
throw new Error("API quota exceeded. Please try again later.");
|
|
25465
|
+
} else {
|
|
25466
|
+
throw new Error(errorMessage);
|
|
25467
|
+
}
|
|
25468
|
+
} catch (parseError) {
|
|
25469
|
+
if (parseError instanceof Error && parseError.message.includes("Rate limit")) {
|
|
25470
|
+
throw parseError;
|
|
25471
|
+
}
|
|
25472
|
+
throw new Error(currentData || "An error occurred during streaming");
|
|
25473
|
+
}
|
|
25474
|
+
}
|
|
25475
|
+
currentEvent = "";
|
|
25476
|
+
currentData = "";
|
|
25477
|
+
}
|
|
25478
|
+
}
|
|
25442
25479
|
accumulatedData += chunk;
|
|
25443
25480
|
setData(accumulatedData);
|
|
25444
25481
|
if (onChunk) {
|
|
@@ -25549,7 +25586,8 @@ const AIAssistant = (props) => {
|
|
|
25549
25586
|
input: currentInput,
|
|
25550
25587
|
timezone,
|
|
25551
25588
|
locale: locale2,
|
|
25552
|
-
history: chatHistory.current
|
|
25589
|
+
history: chatHistory.current,
|
|
25590
|
+
mcpServers: openAIConfig == null ? void 0 : openAIConfig.mcpServers
|
|
25553
25591
|
};
|
|
25554
25592
|
try {
|
|
25555
25593
|
await sendRequest(endpoint, payload, void 0, (chunk) => {
|
|
@@ -25571,11 +25609,23 @@ const AIAssistant = (props) => {
|
|
|
25571
25609
|
});
|
|
25572
25610
|
} catch (err) {
|
|
25573
25611
|
console.error("Error during streaming:", err);
|
|
25612
|
+
let errorMessage = "Error occurred while processing your request.";
|
|
25613
|
+
if (err instanceof Error) {
|
|
25614
|
+
if (err.message.includes("Rate limit") || err.message.includes("429")) {
|
|
25615
|
+
errorMessage = "⚠️ Rate limit exceeded. Please wait a moment before sending another message.";
|
|
25616
|
+
} else if (err.message.includes("quota")) {
|
|
25617
|
+
errorMessage = "⚠️ API quota exceeded. Please try again later.";
|
|
25618
|
+
} else if (err.message.includes("abort")) {
|
|
25619
|
+
errorMessage = "Request was cancelled.";
|
|
25620
|
+
} else {
|
|
25621
|
+
errorMessage = err.message;
|
|
25622
|
+
}
|
|
25623
|
+
}
|
|
25574
25624
|
dispatch({
|
|
25575
25625
|
type: "UPDATE_LAST_ASSISTANT_MESSAGE",
|
|
25576
25626
|
message: {
|
|
25577
25627
|
...assistantMessage,
|
|
25578
|
-
message:
|
|
25628
|
+
message: errorMessage,
|
|
25579
25629
|
status: "failed"
|
|
25580
25630
|
}
|
|
25581
25631
|
});
|