@levo-so/site-runtime 0.3.9 → 0.3.11
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/{DateTimeWidget-LfaosVVW.js → DateTimeWidget-U3lD0q1q.js} +1 -1
- package/{KBChatWidget-CuAtGhHT.js → KBChatWidget-CXIsQEgj.js} +426 -421
- package/PopupBody-BI-MJqmd-DW3qWKam.js +159 -0
- package/{PopupRenderer-D66Gx63H-C6RnOnl2.js → PopupRenderer-D66Gx63H-BnOmWsyj.js} +24 -24
- package/RichTextWidget-DfakML79.js +749 -0
- package/RteThemeProvider-BQmfSXSl.js +20 -0
- package/{nodeAlignment-COvc-rIj.js → content.cssm-XdMsTGIB.js} +24 -32
- package/{dist-orLT2eNz.js → dist-BdNHqoWi.js} +2 -2
- package/{dist-Rjs__H25.js → dist-Cl_sKk9y.js} +1 -1
- package/index.d.ts +28 -9
- package/index.js +346 -288
- package/inlineRteTheme-CRPtkNXy.js +10 -0
- package/kbChat-jqrzqmaT.js +173 -0
- package/package.json +7 -3
- package/pillChrome-CEpWGNZB.js +50 -0
- package/popups.js +1 -1
- package/{PopupBody-BI-MJqmd-C0qNyN7V.js → react-Cj_U6VZQ.js} +814 -965
- package/rich-text.d.ts +25 -0
- package/rich-text.js +1644 -0
- package/styles.css +1 -1
- package/RichTextWidget-BFWVevY7.js +0 -759
- package/kbChat-L55effMi.js +0 -173
- package/pillChrome-uieiq_SK.js +0 -30
- /package/{PhoneWidget-D-CcDuie.js → PhoneWidget-DQQa4bL6.js} +0 -0
- /package/{Popover-BTdlOQP_.js → Popover-C29yJ7rz.js} +0 -0
- /package/{es-Bj3CsMJz.js → es-ByBbirnH.js} +0 -0
- /package/{rteTheme.cssm-CaRzrwtu.js → rteTheme.cssm-W4gTOijw.js} +0 -0
- /package/{usePopupRedirect-CAAdcpaW-D9XoiVhG.js → usePopupRedirect-CAAdcpaW-Ddjyf4KK.js} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as e } from "./createThemeExtension-4AUn51iJ.js";
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region ../../libraries/editor-core/dist/theme/inlineRteTheme.js
|
|
4
|
+
var t = e({
|
|
5
|
+
baseSpacing: "var(--_1q6hy0o0)",
|
|
6
|
+
highlight: "var(--_1q6hy0o1)",
|
|
7
|
+
highlightForeground: "var(--_1q6hy0o2)"
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { C as e, a as t, c as n, f as r, g as i, h as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, u as p } from "./pillChrome-CEpWGNZB.js";
|
|
3
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
4
|
+
import { useEffect as g, useRef as _, useState as v } from "react";
|
|
5
|
+
import { ArrowUp as y, Sparkles as b } from "lucide-react";
|
|
6
|
+
//#region ../../libraries/ai-chat/src/useActiveAgent.ts
|
|
7
|
+
var x = (t) => e("active_agent", t), S = (e) => {
|
|
8
|
+
let t = x(e);
|
|
9
|
+
if (!t || typeof window > "u") return null;
|
|
10
|
+
try {
|
|
11
|
+
let e = window.sessionStorage.getItem(t);
|
|
12
|
+
if (!e) return null;
|
|
13
|
+
let n = JSON.parse(e);
|
|
14
|
+
return typeof n?.id != "string" || n.id.length === 0 ? null : n;
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}, C = (e, t) => {
|
|
19
|
+
let n = x(e);
|
|
20
|
+
if (!(!n || typeof window > "u")) try {
|
|
21
|
+
t === null ? window.sessionStorage.removeItem(n) : window.sessionStorage.setItem(n, JSON.stringify(t));
|
|
22
|
+
} catch {}
|
|
23
|
+
}, w = ({ url: e, workspaceId: t, headers: n, path: r }) => {
|
|
24
|
+
let [i, a] = v({ status: "loading" });
|
|
25
|
+
g(() => {
|
|
26
|
+
let e = S(t);
|
|
27
|
+
a(e ? {
|
|
28
|
+
status: "ready",
|
|
29
|
+
agent: e
|
|
30
|
+
} : (e) => e.status === "ready" ? { status: "loading" } : e);
|
|
31
|
+
}, [t]);
|
|
32
|
+
let o = _(n);
|
|
33
|
+
return o.current = n, g(() => {
|
|
34
|
+
if (!t || !e) return;
|
|
35
|
+
let n = r ? `${e}${e.includes("?") ? "&" : "?"}path=${encodeURIComponent(r)}` : e, i = new AbortController();
|
|
36
|
+
return (async () => {
|
|
37
|
+
try {
|
|
38
|
+
let e = await fetch(n, {
|
|
39
|
+
method: "GET",
|
|
40
|
+
credentials: "include",
|
|
41
|
+
headers: o.current,
|
|
42
|
+
signal: i.signal
|
|
43
|
+
});
|
|
44
|
+
if (!e.ok) {
|
|
45
|
+
C(t, null), a({ status: "missing" });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let r = (await e.json())?.content?.data;
|
|
49
|
+
if (!r || typeof r.id != "string" || r.id.length === 0) {
|
|
50
|
+
C(t, null), a({ status: "missing" });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
C(t, r), a({
|
|
54
|
+
status: "ready",
|
|
55
|
+
agent: r
|
|
56
|
+
});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (e?.name === "AbortError") return;
|
|
59
|
+
console.warn("[levo-kb-chat] active-agent boot failed:", e), a({ status: "error" });
|
|
60
|
+
}
|
|
61
|
+
})(), () => i.abort();
|
|
62
|
+
}, [
|
|
63
|
+
t,
|
|
64
|
+
e,
|
|
65
|
+
r
|
|
66
|
+
]), i;
|
|
67
|
+
}, T = (...e) => e.filter(Boolean).join(" "), E = () => import("./KBChatWidget-CXIsQEgj.js"), D = (e) => {
|
|
68
|
+
let [t, n] = v(null), [r, i] = v(!1), [a, o] = v("");
|
|
69
|
+
return t ? /* @__PURE__ */ m(t, {
|
|
70
|
+
initialOpen: !0,
|
|
71
|
+
initialDraft: a,
|
|
72
|
+
...e
|
|
73
|
+
}) : /* @__PURE__ */ m(k, {
|
|
74
|
+
siteName: e.siteName,
|
|
75
|
+
draft: a,
|
|
76
|
+
loading: r,
|
|
77
|
+
onDraftChange: o,
|
|
78
|
+
onActivate: () => {
|
|
79
|
+
r || t || (i(!0), E().then((e) => n(() => e.KBChatWidget)).catch((e) => {
|
|
80
|
+
i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
|
|
81
|
+
}));
|
|
82
|
+
},
|
|
83
|
+
onPrefetch: () => {
|
|
84
|
+
E().catch(() => {});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}, O = () => /* @__PURE__ */ m("span", {
|
|
88
|
+
"aria-hidden": !0,
|
|
89
|
+
className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent"
|
|
90
|
+
}), k = ({ siteName: e, draft: i, loading: g, onDraftChange: x, onActivate: S, onPrefetch: C }) => {
|
|
91
|
+
let w = _(null), E = _(null), D = a(e), [k, A] = v(!1);
|
|
92
|
+
return /* @__PURE__ */ m("div", {
|
|
93
|
+
onPointerEnter: C,
|
|
94
|
+
className: T("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] -translate-x-1/2", u),
|
|
95
|
+
children: /* @__PURE__ */ m("div", {
|
|
96
|
+
className: T(c, n, "ai-chat-intro-morph"),
|
|
97
|
+
children: /* @__PURE__ */ h("div", {
|
|
98
|
+
ref: E,
|
|
99
|
+
className: T(p, k && "ai-chat-pill-surface--stacked"),
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ m("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: S,
|
|
104
|
+
onFocus: C,
|
|
105
|
+
"aria-label": "Open AI chat",
|
|
106
|
+
className: o,
|
|
107
|
+
children: g ? /* @__PURE__ */ m(O, {}) : /* @__PURE__ */ m(b, { className: "h-5 w-5" })
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ h("div", {
|
|
110
|
+
className: d,
|
|
111
|
+
children: [/* @__PURE__ */ m("textarea", {
|
|
112
|
+
ref: w,
|
|
113
|
+
rows: 1,
|
|
114
|
+
autoComplete: "off",
|
|
115
|
+
autoCorrect: "off",
|
|
116
|
+
autoCapitalize: "none",
|
|
117
|
+
inputMode: "text",
|
|
118
|
+
value: i,
|
|
119
|
+
"aria-label": D,
|
|
120
|
+
onFocus: S,
|
|
121
|
+
onChange: (e) => {
|
|
122
|
+
let t = e.currentTarget;
|
|
123
|
+
x(t.value), E.current && A(s(E.current, t));
|
|
124
|
+
},
|
|
125
|
+
className: r
|
|
126
|
+
}), !i && /* @__PURE__ */ m("span", {
|
|
127
|
+
className: T("ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", "ai-chat-intro-label"),
|
|
128
|
+
"aria-hidden": !0,
|
|
129
|
+
children: D
|
|
130
|
+
})]
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ m("div", {
|
|
133
|
+
className: f,
|
|
134
|
+
children: /* @__PURE__ */ m("button", {
|
|
135
|
+
type: "button",
|
|
136
|
+
onClick: S,
|
|
137
|
+
"aria-label": "Open AI chat",
|
|
138
|
+
className: t,
|
|
139
|
+
style: l,
|
|
140
|
+
children: g ? /* @__PURE__ */ m(O, {}) : /* @__PURE__ */ m(y, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}, A = "/.levo/public/api/v1/agents/kb-chat/public", j = (e) => e.replace(/\/v1\/agents\/kb-chat\/public\/?$/, ""), M = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, apiBaseUrl: a = A, authHeaders: o, showBranding: s, siteSlug: c, path: l }) => {
|
|
148
|
+
let u = w({
|
|
149
|
+
url: `${j(a)}/v1/intelligence/site-agent/get-active`,
|
|
150
|
+
workspaceId: e,
|
|
151
|
+
headers: e ? {
|
|
152
|
+
...i(o),
|
|
153
|
+
"Levo-Workspace": e
|
|
154
|
+
} : i(o),
|
|
155
|
+
path: l
|
|
156
|
+
});
|
|
157
|
+
return u.status === "ready" ? /* @__PURE__ */ m("div", {
|
|
158
|
+
"data-ai-chat-root": !0,
|
|
159
|
+
children: /* @__PURE__ */ m(D, {
|
|
160
|
+
workspaceId: e,
|
|
161
|
+
siteName: t,
|
|
162
|
+
siteLogo: n,
|
|
163
|
+
siteIcon: r,
|
|
164
|
+
agentId: u.agent.id,
|
|
165
|
+
apiBaseUrl: a,
|
|
166
|
+
authHeaders: o,
|
|
167
|
+
showBranding: s,
|
|
168
|
+
siteSlug: c
|
|
169
|
+
})
|
|
170
|
+
}) : null;
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
export { M as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/site-runtime",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Runtime for Levo Studio v3 sites — the editor preview inspector, page head metadata, and the Levo data client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"types": "./popups.d.ts",
|
|
22
22
|
"default": "./popups.js"
|
|
23
23
|
},
|
|
24
|
+
"./rich-text": {
|
|
25
|
+
"types": "./rich-text.d.ts",
|
|
26
|
+
"default": "./rich-text.js"
|
|
27
|
+
},
|
|
24
28
|
"./start": {
|
|
25
29
|
"types": "./start.d.ts",
|
|
26
30
|
"default": "./start.js"
|
|
@@ -81,8 +85,8 @@
|
|
|
81
85
|
"@stripe/react-stripe-js": "3.1.1",
|
|
82
86
|
"@stripe/stripe-js": "5.5.0",
|
|
83
87
|
"react-razorpay": "3.0.1",
|
|
84
|
-
"@levo-so/core": "0.3.
|
|
85
|
-
"@levo-so/insights": "0.3.
|
|
88
|
+
"@levo-so/core": "0.3.11",
|
|
89
|
+
"@levo-so/insights": "0.3.11"
|
|
86
90
|
},
|
|
87
91
|
"peerDependencies": {
|
|
88
92
|
"@base-ui/react": "^1.5.0",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region ../../libraries/ai-chat/src/helpers.ts
|
|
2
|
+
var e = "disabled:cursor-not-allowed disabled:opacity-40", t = (e) => {
|
|
3
|
+
if (!e) return null;
|
|
4
|
+
let t = e instanceof Date ? e : new Date(e);
|
|
5
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
6
|
+
}, n = (e, n = {
|
|
7
|
+
hour: "numeric",
|
|
8
|
+
minute: "2-digit"
|
|
9
|
+
}) => t(e)?.toLocaleTimeString([], n) ?? "", r = (e, r) => {
|
|
10
|
+
let i = t(e);
|
|
11
|
+
if (!i) return "";
|
|
12
|
+
let a = /* @__PURE__ */ new Date();
|
|
13
|
+
if (i.toDateString() === a.toDateString()) return n(i, r);
|
|
14
|
+
let o = i.toLocaleTimeString([], {
|
|
15
|
+
hour: "numeric",
|
|
16
|
+
minute: "2-digit"
|
|
17
|
+
});
|
|
18
|
+
return `${i.toLocaleDateString([], {
|
|
19
|
+
month: "short",
|
|
20
|
+
day: "numeric",
|
|
21
|
+
...i.getFullYear() !== a.getFullYear() && { year: "numeric" }
|
|
22
|
+
})} · ${o}`;
|
|
23
|
+
}, i = (e) => {
|
|
24
|
+
let n = t(e);
|
|
25
|
+
return n ? `${n.toLocaleDateString([], { dateStyle: "medium" })} · ${n.toLocaleTimeString([], { timeStyle: "short" })}` : "";
|
|
26
|
+
}, a = (e) => {
|
|
27
|
+
let t = e.metadata?.custom?.createdAt;
|
|
28
|
+
return typeof t == "string" || t instanceof Date ? t : e.createdAt;
|
|
29
|
+
}, o = (e, t) => t ? `levo.site_chat.${e}.${t}` : null, s = (e, t) => {
|
|
30
|
+
e.style.height = "auto", e.style.height = t === void 0 ? `${e.scrollHeight}px` : `${Math.min(e.scrollHeight, t)}px`;
|
|
31
|
+
}, c = (e, t) => {
|
|
32
|
+
e.setText(t);
|
|
33
|
+
let n = document.activeElement?.closest("[data-ai-chat-root]") ?? document;
|
|
34
|
+
requestAnimationFrame(() => {
|
|
35
|
+
let e = n.querySelector("textarea[data-ai-chat-composer]");
|
|
36
|
+
if (!e) return;
|
|
37
|
+
e.focus();
|
|
38
|
+
let t = e.value.length;
|
|
39
|
+
e.setSelectionRange(t, t);
|
|
40
|
+
});
|
|
41
|
+
}, l = (e) => typeof e == "function" ? e() : e ?? {}, u = "w-72", d = "ai-chat-pill-gradient relative rounded-[30px] p-[2px] transition-shadow duration-300", f = "shadow-lg shadow-zinc-950/10", p = "shadow-md", m = "ai-chat-pill-surface min-h-14 w-full rounded-[28px] bg-white p-1.5", h = "ai-chat-pill-surface--stacked", g = "ai-chat-pill-input relative min-w-0", _ = "ai-chat-pill-actions flex items-center gap-1.5", v = "ai-chat-pill-spark flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full text-blue-500 transition-[background-color,transform] duration-150 hover:bg-zinc-50 active:scale-95", y = "flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-[transform,box-shadow] duration-150 hover:scale-105 hover:shadow-md active:scale-95", b = "block h-6 max-h-[120px] w-full resize-none overflow-y-auto bg-transparent text-base text-zinc-900 leading-6 placeholder:text-zinc-400 focus:outline-none", x = 24, S = (e, t) => {
|
|
42
|
+
e.classList.remove(h), t.style.height = "auto";
|
|
43
|
+
let n = t.scrollHeight > x + 4;
|
|
44
|
+
return e.classList.toggle(h, n), s(t, 120), n;
|
|
45
|
+
}, C = "ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", w = {
|
|
46
|
+
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
47
|
+
color: "var(--color-brand-foreground, #fff)"
|
|
48
|
+
}, T = (e) => e ? `Ask ${e}` : "Ask AI";
|
|
49
|
+
//#endregion
|
|
50
|
+
export { o as C, a as S, e as _, y as a, i as b, f as c, h as d, b as f, l as g, T as h, C as i, v as l, S as m, d as n, w as o, u as p, g as r, p as s, _ as t, m as u, s as v, r as x, c as y };
|
package/popups.js
CHANGED