@retrivora-ai/rag-engine 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -381,8 +381,9 @@ function resolveImage(data) {
381
381
  }
382
382
  return void 0;
383
383
  }
384
- function ChartBlock({ rawContent, primaryColor, accentColor }) {
384
+ function ChartBlock({ rawContent, primaryColor, accentColor, isStreaming }) {
385
385
  const result = import_react5.default.useMemo(() => {
386
+ if (isStreaming) return { loading: true };
386
387
  if (!rawContent || rawContent === "undefined") return { error: "Empty chart config." };
387
388
  try {
388
389
  const sanitized = sanitizeJson(rawContent);
@@ -393,7 +394,10 @@ function ChartBlock({ rawContent, primaryColor, accentColor }) {
393
394
  console.error("[ChartBlock] Parsing failed.\nError:", err, "\nSanitized:\n", sanitized);
394
395
  return { error: String(err) };
395
396
  }
396
- }, [rawContent]);
397
+ }, [rawContent, isStreaming]);
398
+ if ("loading" in result) {
399
+ return /* @__PURE__ */ import_react5.default.createElement("div", { className: "my-4 p-8 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex flex-col items-center justify-center gap-3 select-none" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "w-6 h-6 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ import_react5.default.createElement("p", { className: "text-xs text-slate-500 font-medium animate-pulse" }, "Preparing data visualization..."));
400
+ }
397
401
  if ("error" in result) {
398
402
  return /* @__PURE__ */ import_react5.default.createElement("div", { className: "p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm border border-red-100 dark:border-red-900/30" }, /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-medium mb-1" }, "Failed to render chart"), /* @__PURE__ */ import_react5.default.createElement("p", { className: "opacity-70 text-xs" }, "The generated configuration is invalid. Check the console for details."));
399
403
  }
@@ -524,14 +528,15 @@ function MessageBubble({
524
528
  {
525
529
  rawContent: String(children != null ? children : "").trim(),
526
530
  primaryColor,
527
- accentColor
531
+ accentColor,
532
+ isStreaming
528
533
  }
529
534
  );
530
535
  }
531
536
  return /* @__PURE__ */ import_react5.default.createElement("code", __spreadValues({ className }, props), typeof children === "string" || typeof children === "number" ? children : JSON.stringify(children));
532
537
  }
533
538
  }),
534
- [primaryColor, accentColor]
539
+ [primaryColor, accentColor, isStreaming]
535
540
  );
536
541
  return /* @__PURE__ */ import_react5.default.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ import_react5.default.createElement(
537
542
  "div",
package/dist/index.mjs CHANGED
@@ -344,8 +344,9 @@ function resolveImage(data) {
344
344
  }
345
345
  return void 0;
346
346
  }
347
- function ChartBlock({ rawContent, primaryColor, accentColor }) {
347
+ function ChartBlock({ rawContent, primaryColor, accentColor, isStreaming }) {
348
348
  const result = React5.useMemo(() => {
349
+ if (isStreaming) return { loading: true };
349
350
  if (!rawContent || rawContent === "undefined") return { error: "Empty chart config." };
350
351
  try {
351
352
  const sanitized = sanitizeJson(rawContent);
@@ -356,7 +357,10 @@ function ChartBlock({ rawContent, primaryColor, accentColor }) {
356
357
  console.error("[ChartBlock] Parsing failed.\nError:", err, "\nSanitized:\n", sanitized);
357
358
  return { error: String(err) };
358
359
  }
359
- }, [rawContent]);
360
+ }, [rawContent, isStreaming]);
361
+ if ("loading" in result) {
362
+ return /* @__PURE__ */ React5.createElement("div", { className: "my-4 p-8 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex flex-col items-center justify-center gap-3 select-none" }, /* @__PURE__ */ React5.createElement("div", { className: "w-6 h-6 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" }), /* @__PURE__ */ React5.createElement("p", { className: "text-xs text-slate-500 font-medium animate-pulse" }, "Preparing data visualization..."));
363
+ }
360
364
  if ("error" in result) {
361
365
  return /* @__PURE__ */ React5.createElement("div", { className: "p-4 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 rounded-lg text-sm border border-red-100 dark:border-red-900/30" }, /* @__PURE__ */ React5.createElement("p", { className: "font-medium mb-1" }, "Failed to render chart"), /* @__PURE__ */ React5.createElement("p", { className: "opacity-70 text-xs" }, "The generated configuration is invalid. Check the console for details."));
362
366
  }
@@ -487,14 +491,15 @@ function MessageBubble({
487
491
  {
488
492
  rawContent: String(children != null ? children : "").trim(),
489
493
  primaryColor,
490
- accentColor
494
+ accentColor,
495
+ isStreaming
491
496
  }
492
497
  );
493
498
  }
494
499
  return /* @__PURE__ */ React5.createElement("code", __spreadValues({ className }, props), typeof children === "string" || typeof children === "number" ? children : JSON.stringify(children));
495
500
  }
496
501
  }),
497
- [primaryColor, accentColor]
502
+ [primaryColor, accentColor, isStreaming]
498
503
  );
499
504
  return /* @__PURE__ */ React5.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ React5.createElement(
500
505
  "div",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "MIT",
@@ -110,10 +110,12 @@ interface ChartBlockProps {
110
110
  rawContent: string;
111
111
  primaryColor: string;
112
112
  accentColor: string;
113
+ isStreaming?: boolean;
113
114
  }
114
115
 
115
- function ChartBlock({ rawContent, primaryColor, accentColor }: ChartBlockProps) {
116
- const result = React.useMemo<{ config: ChartConfig } | { error: string }>(() => {
116
+ function ChartBlock({ rawContent, primaryColor, accentColor, isStreaming }: ChartBlockProps) {
117
+ const result = React.useMemo<{ config: ChartConfig } | { error: string } | { loading: boolean }>(() => {
118
+ if (isStreaming) return { loading: true };
117
119
  if (!rawContent || rawContent === 'undefined') return { error: 'Empty chart config.' };
118
120
  try {
119
121
  const sanitized = sanitizeJson(rawContent);
@@ -124,7 +126,16 @@ function ChartBlock({ rawContent, primaryColor, accentColor }: ChartBlockProps)
124
126
  console.error('[ChartBlock] Parsing failed.\nError:', err, '\nSanitized:\n', sanitized);
125
127
  return { error: String(err) };
126
128
  }
127
- }, [rawContent]);
129
+ }, [rawContent, isStreaming]);
130
+
131
+ if ('loading' in result) {
132
+ return (
133
+ <div className="my-4 p-8 bg-slate-50 dark:bg-white/5 rounded-xl border border-dashed border-slate-300 dark:border-white/10 flex flex-col items-center justify-center gap-3 select-none">
134
+ <div className="w-6 h-6 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin" />
135
+ <p className="text-xs text-slate-500 font-medium animate-pulse">Preparing data visualization...</p>
136
+ </div>
137
+ );
138
+ }
128
139
 
129
140
  if ('error' in result) {
130
141
  return (
@@ -269,6 +280,7 @@ export function MessageBubble({
269
280
  rawContent={String(children ?? '').trim()}
270
281
  primaryColor={primaryColor}
271
282
  accentColor={accentColor}
283
+ isStreaming={isStreaming}
272
284
  />
273
285
  );
274
286
  }
@@ -282,7 +294,7 @@ export function MessageBubble({
282
294
  );
283
295
  },
284
296
  }),
285
- [primaryColor, accentColor],
297
+ [primaryColor, accentColor, isStreaming],
286
298
  );
287
299
 
288
300
  // ── Render ─────────────────────────────────────────────────────────────────