@luma-ai/react 2.0.2 → 2.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.
- package/CHANGELOG.md +18 -0
- package/dist/chunks/{src-BuzOHEps.js → src-BHvPjJWi.js} +54 -28
- package/dist/chunks/src-BHvPjJWi.js.map +1 -0
- package/dist/chunks/{support-cursor-CzNzBpxv.js → support-cursor-nmjmyLvL.js} +2 -2
- package/dist/chunks/{support-cursor-CzNzBpxv.js.map → support-cursor-nmjmyLvL.js.map} +1 -1
- package/dist/chunks/{visitor-call-DY8tUjuJ.js → visitor-call-DkVfVNOy.js} +3 -3
- package/dist/chunks/{visitor-call-DY8tUjuJ.js.map → visitor-call-DkVfVNOy.js.map} +1 -1
- package/dist/chunks/{visitor-cobrowse-ctLeCxdW.js → visitor-cobrowse-DgEub0or.js} +3 -3
- package/dist/chunks/{visitor-cobrowse-ctLeCxdW.js.map → visitor-cobrowse-DgEub0or.js.map} +1 -1
- package/dist/{config-BAC3xPNG.d.ts → config-Dz3dV4OK.d.ts} +5 -5
- package/dist/{index-ByvZMuLw.d.ts → index-CChX7dMN.d.ts} +10 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/next.d.ts +2 -2
- package/dist/next.js +1 -1
- package/dist/react-router.d.ts +2 -2
- package/dist/react-router.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -7
- package/dist/server.js.map +1 -1
- package/dist/tanstack.d.ts +2 -2
- package/dist/tanstack.js +1 -1
- package/docs/options.md +5 -7
- package/docs/troubleshooting.md +3 -3
- package/package.json +1 -1
- package/dist/chunks/src-BuzOHEps.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# تغییرات @luma-ai/react
|
|
2
2
|
|
|
3
|
+
## 2.0.4
|
|
4
|
+
|
|
5
|
+
### تغییرها
|
|
6
|
+
|
|
7
|
+
- **یک نشانی برای API لوما**: ویجت و `createLumaSessionHandler` همیشه از `https://dash.lumai.ir/api` استفاده میکنند. این نشانی حالا پشت CDN داخل ایران است و از شبکههای ایران و خارج در دسترس است، پس سرور واسط `ir.lumai.ir` که گزینهٔ `server: "internal"` (پیشفرض قبلی) انتخاب میکرد کنار گذاشته شد. گزینهٔ `server` هنوز پذیرفته میشود تا کد موجود بیتغییر کامپایل شود، ولی دیگر اثری ندارد؛ برای نشانی دیگر (مثلاً توسعه محلی) از `apiBaseUrl` استفاده کنید.
|
|
8
|
+
- **افزونه وردپرس**: تنظیم «سرور دستیار» (داخلی/مستقیم) حذف شد و انتخاب ذخیرهشده نادیده گرفته میشود.
|
|
9
|
+
|
|
10
|
+
## 2.0.3
|
|
11
|
+
|
|
12
|
+
### تازهها
|
|
13
|
+
|
|
14
|
+
- **آیکون جایگزین لوگو**: وقتی دستیار لوگو ندارد یا لوگو هنوز بارگذاری نشده (یا بارگذاری نمیشود)، ویجت بهجای حرف اول نام دستیار آیکونی نشان میدهد که در تنظیمات ظاهر داشبورد انتخاب میشود: پشتیبانی (پیشفرض)، ربات، حباب گفتگو، ستاره یا آدمک.
|
|
15
|
+
|
|
16
|
+
### رفع اشکال
|
|
17
|
+
|
|
18
|
+
- **خطای CORS در کنسول سایت**: ویجت نشانی لوگو روی میزبان فایلها را دیگر با `fetch` نمیخواند (آن میزبان سرآیند CORS نمیفرستد و مرورگر خطا ثبت میکرد)؛ فقط نشانی لوگو روی سرور لوما خوانده میشود و نشانی میزبان فایلها، اگر لازم شود، مثل یک تصویر ساده بارگذاری میشود.
|
|
19
|
+
- **افزونه وردپرس**: پاسخ نشست افزونه حالا `avatarPath` را هم میفرستد، مثل `createLumaSessionHandler`، تا لوگو از سرور لوما بیاید حتی وقتی تنظیمات ظاهر بارگذاری نشده باشد.
|
|
20
|
+
|
|
3
21
|
## 2.0.2
|
|
4
22
|
|
|
5
23
|
### رفع اشکال
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Fragment, createContext, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { AlertCircle, ArrowDownIcon, Bot, Check, CheckCircle2, ClipboardList, CornerDownLeft, ExternalLink, Eye, Loader2, LoaderCircle, LoaderCircleIcon, LoaderIcon, LoaderPinwheelIcon, MessageCircle, Mic, Minus, MousePointer2, MousePointerClick, Package, Phone, RefreshCw, Sparkles, Square, SquarePen, Star, UserRound, Volume2, WifiOff, X, Zap } from "lucide-react";
|
|
5
|
+
import { AlertCircle, ArrowDownIcon, Bot, Check, CheckCircle2, ClipboardList, CornerDownLeft, ExternalLink, Eye, Headset, Loader2, LoaderCircle, LoaderCircleIcon, LoaderIcon, LoaderPinwheelIcon, MessageCircle, Mic, Minus, MousePointer2, MousePointerClick, Package, Phone, RefreshCw, Sparkles, Square, SquarePen, Star, UserRound, Volume2, WifiOff, X, Zap } from "lucide-react";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
import { Slot } from "@radix-ui/react-slot";
|
|
8
8
|
import { cva } from "class-variance-authority";
|
|
@@ -148,11 +148,6 @@ function actionContract(definition) {
|
|
|
148
148
|
confirm: definition.confirm
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
// src/core/config.ts
|
|
152
|
-
var API_BASE_URLS = {
|
|
153
|
-
internal: "https://ir.lumai.ir/api",
|
|
154
|
-
direct: "https://dash.lumai.ir/api"
|
|
155
|
-
};
|
|
156
151
|
function parseSession(value) {
|
|
157
152
|
const raw = value && typeof value === "object" && "data" in value && !("sessionId" in value) ? value.data : value;
|
|
158
153
|
if (!raw || typeof raw !== "object" || !("sessionId" in raw) || typeof raw.sessionId !== "string" || !raw.sessionId.trim()) throw new Error("Invalid session response");
|
|
@@ -899,6 +894,17 @@ var WIDGET_LAUNCHER_ICONS = [
|
|
|
899
894
|
"chat",
|
|
900
895
|
"sparkles"
|
|
901
896
|
];
|
|
897
|
+
/**
|
|
898
|
+
* The icon a widget shows in the logo's place: for an assistant without a
|
|
899
|
+
* logo, and while its logo loads or cannot load.
|
|
900
|
+
*/
|
|
901
|
+
var WIDGET_AVATAR_FALLBACKS = [
|
|
902
|
+
"support",
|
|
903
|
+
"bot",
|
|
904
|
+
"chat",
|
|
905
|
+
"sparkles",
|
|
906
|
+
"user"
|
|
907
|
+
];
|
|
902
908
|
var WIDGET_LAUNCHER_SIZES = [
|
|
903
909
|
"sm",
|
|
904
910
|
"md",
|
|
@@ -962,6 +968,7 @@ var widgetThemeSchema = z.object({
|
|
|
962
968
|
position: z.enum(WIDGET_POSITIONS).optional(),
|
|
963
969
|
size: z.enum(WIDGET_SIZES).optional(),
|
|
964
970
|
launcherIcon: z.enum(WIDGET_LAUNCHER_ICONS).optional(),
|
|
971
|
+
avatarFallback: z.enum(WIDGET_AVATAR_FALLBACKS).optional(),
|
|
965
972
|
launcherLabel: plainText(WIDGET_TEXT_LIMITS.launcherLabel).optional(),
|
|
966
973
|
launcherSize: z.enum(WIDGET_LAUNCHER_SIZES).optional(),
|
|
967
974
|
offsetBottom: offset("desktop").optional(),
|
|
@@ -988,6 +995,7 @@ var WIDGET_THEME_DEFAULTS = {
|
|
|
988
995
|
position: "bottom-right",
|
|
989
996
|
size: "md",
|
|
990
997
|
launcherIcon: "avatar",
|
|
998
|
+
avatarFallback: "support",
|
|
991
999
|
launcherLabel: "",
|
|
992
1000
|
launcherSize: "md",
|
|
993
1001
|
offsetBottom: 20,
|
|
@@ -4735,7 +4743,7 @@ function callNoteText(note, lang) {
|
|
|
4735
4743
|
* (an alias in apps/assistant-widget/vite.config.ts): their call module is
|
|
4736
4744
|
* a script beside the build (`call.js`, `/build/call-<hash>.js`).
|
|
4737
4745
|
*/
|
|
4738
|
-
var importCallModule = () => import("./visitor-call-
|
|
4746
|
+
var importCallModule = () => import("./visitor-call-DkVfVNOy.js").then((module) => ({
|
|
4739
4747
|
api: 1,
|
|
4740
4748
|
mountVisitorCall: module.mountVisitorCall
|
|
4741
4749
|
}));
|
|
@@ -4975,7 +4983,7 @@ function placeInViewport(point, viewport, margin = 16) {
|
|
|
4975
4983
|
* (an alias in apps/assistant-widget/vite.config.ts): their module is a
|
|
4976
4984
|
* script beside the build (`cobrowse.js`, `/build/cobrowse-<hash>.js`).
|
|
4977
4985
|
*/
|
|
4978
|
-
var importCobrowseModule = () => import("./visitor-cobrowse-
|
|
4986
|
+
var importCobrowseModule = () => import("./visitor-cobrowse-DgEub0or.js").then((module) => ({
|
|
4979
4987
|
api: 1,
|
|
4980
4988
|
startCobrowse: module.startCobrowse
|
|
4981
4989
|
}));
|
|
@@ -5810,11 +5818,18 @@ function Cobrowse({ session, visitorKey, tabId, chatId, takenOver, supportKnown,
|
|
|
5810
5818
|
] });
|
|
5811
5819
|
}
|
|
5812
5820
|
// src/ui/assistant-logo.tsx
|
|
5821
|
+
var FALLBACK_ICONS = {
|
|
5822
|
+
support: Headset,
|
|
5823
|
+
bot: Bot,
|
|
5824
|
+
chat: MessageCircle,
|
|
5825
|
+
sparkles: Sparkles,
|
|
5826
|
+
user: UserRound
|
|
5827
|
+
};
|
|
5813
5828
|
/**
|
|
5814
|
-
* The logo, or
|
|
5815
|
-
*
|
|
5829
|
+
* The logo, or the icon the owner chose in its place (support by default):
|
|
5830
|
+
* for an assistant with no logo, and while its logo loads or fails.
|
|
5816
5831
|
*/
|
|
5817
|
-
function AssistantLogo({ view,
|
|
5832
|
+
function AssistantLogo({ view, fallback, onBroken, className, iconClassName }) {
|
|
5818
5833
|
if (view.state === "ready") return /* @__PURE__ */ jsx("img", {
|
|
5819
5834
|
alt: "",
|
|
5820
5835
|
src: view.src,
|
|
@@ -5822,15 +5837,13 @@ function AssistantLogo({ view, name, onBroken, className, iconClassName }) {
|
|
|
5822
5837
|
"data-luma-logo": "ready",
|
|
5823
5838
|
onError: onBroken
|
|
5824
5839
|
});
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
});
|
|
5829
|
-
return /* @__PURE__ */ jsx("span", {
|
|
5840
|
+
const icon = fallback && fallback in FALLBACK_ICONS ? fallback : "support";
|
|
5841
|
+
const Icon = FALLBACK_ICONS[icon];
|
|
5842
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
5830
5843
|
"aria-hidden": "true",
|
|
5831
|
-
className:
|
|
5832
|
-
"data-luma-logo":
|
|
5833
|
-
|
|
5844
|
+
className: iconClassName,
|
|
5845
|
+
"data-luma-logo": view.state,
|
|
5846
|
+
"data-luma-logo-icon": icon
|
|
5834
5847
|
});
|
|
5835
5848
|
}
|
|
5836
5849
|
// src/ui/chat-widget.tsx
|
|
@@ -6642,9 +6655,9 @@ function ChatWidget({ initialState, onNewChat, autoFocus = false, storageKey: ke
|
|
|
6642
6655
|
mobileIconSize,
|
|
6643
6656
|
icon: theme.launcherIcon !== "avatar" ? LAUNCHER_ICONS[theme.launcherIcon] : /* @__PURE__ */ jsx(AssistantLogo, {
|
|
6644
6657
|
view: logo,
|
|
6645
|
-
|
|
6658
|
+
fallback: theme.avatarFallback,
|
|
6646
6659
|
onBroken: onLogoBroken,
|
|
6647
|
-
className: "size-full rounded-full object-cover
|
|
6660
|
+
className: "size-full rounded-full object-cover",
|
|
6648
6661
|
iconClassName: "h-6 w-6"
|
|
6649
6662
|
}),
|
|
6650
6663
|
children: [
|
|
@@ -6654,7 +6667,7 @@ function ChatWidget({ initialState, onNewChat, autoFocus = false, storageKey: ke
|
|
|
6654
6667
|
className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-primary text-primary-foreground",
|
|
6655
6668
|
children: /* @__PURE__ */ jsx(AssistantLogo, {
|
|
6656
6669
|
view: logo,
|
|
6657
|
-
|
|
6670
|
+
fallback: theme.avatarFallback,
|
|
6658
6671
|
onBroken: onLogoBroken,
|
|
6659
6672
|
className: "size-full object-cover",
|
|
6660
6673
|
iconClassName: "size-5"
|
|
@@ -7117,13 +7130,26 @@ function asDataUrl(blob) {
|
|
|
7117
7130
|
});
|
|
7118
7131
|
}
|
|
7119
7132
|
/**
|
|
7120
|
-
*
|
|
7121
|
-
*
|
|
7122
|
-
* storage host
|
|
7133
|
+
* Whether an address is the logo on the Luma API
|
|
7134
|
+
* (`…/assistant/<id>/avatar/<name>`), which answers any site's `fetch`. The
|
|
7135
|
+
* storage host (`…/assistant/avatars/<id>/<name>`) sends no CORS headers.
|
|
7136
|
+
*/
|
|
7137
|
+
function isApiLogo(url) {
|
|
7138
|
+
try {
|
|
7139
|
+
return /\/assistant\/[^/]+\/avatar\/[^/]+$/.test(new URL(url, "http://local").pathname);
|
|
7140
|
+
} catch {
|
|
7141
|
+
return false;
|
|
7142
|
+
}
|
|
7143
|
+
}
|
|
7144
|
+
/**
|
|
7145
|
+
* Loads a logo in the browser. The API's address is fetched, and kept as a
|
|
7146
|
+
* data URL when small; any other address (the storage host, which sends no
|
|
7147
|
+
* CORS headers) is loaded as a plain image only, since fetching it is
|
|
7148
|
+
* refused and logs a CORS error in the site's console.
|
|
7123
7149
|
*/
|
|
7124
7150
|
var browserLogoLoader = async (url, signal) => {
|
|
7125
7151
|
let fetched = null;
|
|
7126
|
-
try {
|
|
7152
|
+
if (isApiLogo(url)) try {
|
|
7127
7153
|
const response = await fetch(url, {
|
|
7128
7154
|
credentials: "omit",
|
|
7129
7155
|
signal: AbortSignal.any([signal, AbortSignal.timeout(15e3)])
|
|
@@ -7466,7 +7492,7 @@ function LumaProvider(props) {
|
|
|
7466
7492
|
}
|
|
7467
7493
|
function LumaWidgetHost({ controller, ...props }) {
|
|
7468
7494
|
const host = props.host;
|
|
7469
|
-
const apiBaseUrl = (props.apiBaseUrl ??
|
|
7495
|
+
const apiBaseUrl = (props.apiBaseUrl ?? "https://dash.lumai.ir/api").replace(/\/+$/, "");
|
|
7470
7496
|
const mode = props.sessionEndpoint ? "server" : "public";
|
|
7471
7497
|
const siteContextKey = JSON.stringify(host?.siteContext ?? null);
|
|
7472
7498
|
const connection = useMemo(() => ({
|
|
@@ -7645,4 +7671,4 @@ var lumaLabel = (label) => ({ "data-luma-label": label });
|
|
|
7645
7671
|
var lumaPrivate = () => ({ "data-luma-private": "" });
|
|
7646
7672
|
export { useLumaAction as a, COBROWSE_LIMITS as c, CALL_FAILURE_TEXT as d, CALL_TIMING as f, defineAction as h, useLuma as i, placeInViewport as l, routerPath as m, lumaPrivate as n, useLumaContext as o, callDuration as p, LumaPrivate as r, LumaProvider as s, lumaLabel as t, pointOf as u };
|
|
7647
7673
|
|
|
7648
|
-
//# sourceMappingURL=src-
|
|
7674
|
+
//# sourceMappingURL=src-BHvPjJWi.js.map
|