@levo-so/site-runtime 0.2.2 → 0.3.0

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.
@@ -0,0 +1,9 @@
1
+ import { i as e, r as t } from "./inlineCollectionTheme-D2w17LHX.js";
2
+ import { n } from "./theme.cssm-2YTdd8Yh.js";
3
+ //#region ../../libraries/levocn/dist/styles/inlineBaseTheme.js
4
+ var r = n(e), i = (e) => e ? e.radius && !e.radiusScale ? r({
5
+ ...e,
6
+ radiusScale: t(e.radius)
7
+ }) : r(e) : {};
8
+ //#endregion
9
+ export { i as t };
@@ -0,0 +1,86 @@
1
+ import { n as e } from "./theme.cssm-2YTdd8Yh.js";
2
+ //#region ../../libraries/levocn/dist/styles/theme/themeVars.cssm.js
3
+ var t = {
4
+ colors: {
5
+ background: "var(--_1i5egzy0)",
6
+ foreground: "var(--_1i5egzy1)",
7
+ text: "var(--_1i5egzy2)",
8
+ heading: "var(--_1i5egzy3)",
9
+ card: "var(--_1i5egzy4)",
10
+ cardForeground: "var(--_1i5egzy5)",
11
+ popover: "var(--_1i5egzy6)",
12
+ popoverForeground: "var(--_1i5egzy7)",
13
+ primary: "var(--_1i5egzy8)",
14
+ primaryForeground: "var(--_1i5egzy9)",
15
+ secondary: "var(--_1i5egzya)",
16
+ secondaryForeground: "var(--_1i5egzyb)",
17
+ muted: "var(--_1i5egzyc)",
18
+ mutedForeground: "var(--_1i5egzyd)",
19
+ accent: "var(--_1i5egzye)",
20
+ accentForeground: "var(--_1i5egzyf)",
21
+ destructive: "var(--_1i5egzyg)",
22
+ border: "var(--_1i5egzyh)",
23
+ input: "var(--_1i5egzyi)",
24
+ inputForeground: "var(--_1i5egzyj)",
25
+ ring: "var(--_1i5egzyk)"
26
+ },
27
+ radius: "var(--_1i5egzyl)",
28
+ radiusScale: {
29
+ sm: "var(--_1i5egzym)",
30
+ base: "var(--_1i5egzyn)",
31
+ md: "var(--_1i5egzyo)",
32
+ lg: "var(--_1i5egzyp)",
33
+ xl: "var(--_1i5egzyq)",
34
+ "2xl": "var(--_1i5egzyr)",
35
+ "3xl": "var(--_1i5egzys)",
36
+ "4xl": "var(--_1i5egzyt)",
37
+ "5xl": "var(--_1i5egzyu)",
38
+ "6xl": "var(--_1i5egzyv)",
39
+ "7xl": "var(--_1i5egzyw)",
40
+ "8xl": "var(--_1i5egzyx)",
41
+ full: "var(--_1i5egzyy)"
42
+ },
43
+ baseFontSize: "var(--_1i5egzyz)",
44
+ fonts: {
45
+ body: "var(--_1i5egzy10)",
46
+ heading: "var(--_1i5egzy11)"
47
+ },
48
+ shadow: {
49
+ xs: "var(--_1i5egzy12)",
50
+ sm: "var(--_1i5egzy13)",
51
+ md: "var(--_1i5egzy14)",
52
+ lg: "var(--_1i5egzy15)",
53
+ xl: "var(--_1i5egzy16)",
54
+ inner: "var(--_1i5egzy17)"
55
+ }
56
+ }, n = (e) => ({
57
+ sm: `calc(${e} * 0.5)`,
58
+ base: e,
59
+ md: `calc(${e} * 1.5)`,
60
+ lg: `calc(${e} * 2)`,
61
+ xl: `calc(${e} * 3)`,
62
+ "2xl": `calc(${e} * 4)`,
63
+ "3xl": `calc(${e} * 6)`,
64
+ "4xl": `calc(${e} * 8)`,
65
+ "5xl": `calc(${e} * 12)`,
66
+ "6xl": `calc(${e} * 16)`,
67
+ "7xl": `calc(${e} * 20)`,
68
+ "8xl": `calc(${e} * 24)`,
69
+ full: "100%"
70
+ }), r = {
71
+ form: {
72
+ maxWidth: "var(--_1092q7b0)",
73
+ gap: "var(--_1092q7b1)",
74
+ borderRadius: "var(--_1092q7b2)",
75
+ labelFontSize: "var(--_1092q7b3)",
76
+ helpFontSize: "var(--_1092q7b4)"
77
+ },
78
+ input: {
79
+ fontSize: "var(--_1092q7b5)",
80
+ height: "var(--_1092q7b6)",
81
+ borderRadius: "var(--_1092q7b7)"
82
+ },
83
+ checkbox: { labelFontSize: "var(--_1092q7b8)" }
84
+ }, i = e(r);
85
+ //#endregion
86
+ export { t as i, r as n, n as r, i as t };
@@ -0,0 +1,168 @@
1
+ "use client";
2
+ import { a as e, c as t, f as n, h as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u, u as d, v as f } from "./pillChrome-AhXOWXIb.js";
3
+ import { useEffect as p, useRef as m, useState as h } from "react";
4
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
5
+ import { ArrowUp as v, Sparkles as y } from "lucide-react";
6
+ //#region ../../libraries/ai-chat/src/useActiveAgent.ts
7
+ var b = (e) => f("active_agent", e), x = (e) => {
8
+ let t = b(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
+ }, S = (e, t) => {
19
+ let n = b(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
+ }, C = ({ url: e, workspaceId: t, headers: n }) => {
24
+ let [r, i] = h({ status: "loading" });
25
+ p(() => {
26
+ let e = x(t);
27
+ i(e ? {
28
+ status: "ready",
29
+ agent: e
30
+ } : (e) => e.status === "ready" ? { status: "loading" } : e);
31
+ }, [t]);
32
+ let a = m(n);
33
+ return a.current = n, p(() => {
34
+ if (!t || !e) return;
35
+ let n = new AbortController();
36
+ return (async () => {
37
+ try {
38
+ let r = await fetch(e, {
39
+ method: "GET",
40
+ credentials: "include",
41
+ headers: a.current,
42
+ signal: n.signal
43
+ });
44
+ if (!r.ok) {
45
+ S(t, null), i({ status: "missing" });
46
+ return;
47
+ }
48
+ let o = (await r.json())?.content?.data;
49
+ if (!o || typeof o.id != "string" || o.id.length === 0) {
50
+ S(t, null), i({ status: "missing" });
51
+ return;
52
+ }
53
+ S(t, o), i({
54
+ status: "ready",
55
+ agent: o
56
+ });
57
+ } catch (e) {
58
+ if (e?.name === "AbortError") return;
59
+ console.warn("[levo-kb-chat] active-agent boot failed:", e), i({ status: "error" });
60
+ }
61
+ })(), () => n.abort();
62
+ }, [t, e]), r;
63
+ }, w = (...e) => e.filter(Boolean).join(" "), T = () => import("./KBChatWidget-D7F9LRwI.js"), E = (e) => {
64
+ let [t, n] = h(null), [r, i] = h(!1), [a, o] = h("");
65
+ return t ? /* @__PURE__ */ g(t, {
66
+ initialOpen: !0,
67
+ initialDraft: a,
68
+ ...e
69
+ }) : /* @__PURE__ */ g(O, {
70
+ siteName: e.siteName,
71
+ draft: a,
72
+ loading: r,
73
+ onDraftChange: o,
74
+ onActivate: () => {
75
+ r || t || (i(!0), T().then((e) => n(() => e.KBChatWidget)).catch((e) => {
76
+ i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
77
+ }));
78
+ },
79
+ onPrefetch: () => {
80
+ T().catch(() => {});
81
+ }
82
+ });
83
+ }, D = () => /* @__PURE__ */ g("span", {
84
+ "aria-hidden": !0,
85
+ className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent"
86
+ }), O = ({ siteName: f, draft: p, loading: b, onDraftChange: x, onActivate: S, onPrefetch: C }) => {
87
+ let T = m(null), E = m(null), O = r(f), [k, A] = h(!1);
88
+ return /* @__PURE__ */ g("div", {
89
+ onPointerEnter: C,
90
+ className: w("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] -translate-x-1/2", c),
91
+ children: /* @__PURE__ */ g("div", {
92
+ className: w(o, t, "ai-chat-intro-morph"),
93
+ children: /* @__PURE__ */ _("div", {
94
+ ref: E,
95
+ className: w(d, k && "ai-chat-pill-surface--stacked"),
96
+ children: [
97
+ /* @__PURE__ */ g("button", {
98
+ type: "button",
99
+ onClick: S,
100
+ onFocus: C,
101
+ "aria-label": "Open AI chat",
102
+ className: i,
103
+ children: b ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(y, { className: "h-5 w-5" })
104
+ }),
105
+ /* @__PURE__ */ _("div", {
106
+ className: l,
107
+ children: [/* @__PURE__ */ g("textarea", {
108
+ ref: T,
109
+ rows: 1,
110
+ autoComplete: "off",
111
+ autoCorrect: "off",
112
+ autoCapitalize: "none",
113
+ inputMode: "text",
114
+ value: p,
115
+ "aria-label": O,
116
+ onFocus: S,
117
+ onChange: (e) => {
118
+ let t = e.currentTarget;
119
+ x(t.value), E.current && A(a(E.current, t));
120
+ },
121
+ className: n
122
+ }), !p && /* @__PURE__ */ g("span", {
123
+ className: w("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"),
124
+ "aria-hidden": !0,
125
+ children: O
126
+ })]
127
+ }),
128
+ /* @__PURE__ */ g("div", {
129
+ className: u,
130
+ children: /* @__PURE__ */ g("button", {
131
+ type: "button",
132
+ onClick: S,
133
+ "aria-label": "Open AI chat",
134
+ className: e,
135
+ style: s,
136
+ children: b ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(v, { className: "h-5 w-5 stroke-[2.5px]" })
137
+ })
138
+ })
139
+ ]
140
+ })
141
+ })
142
+ });
143
+ }, k = "/.levo/public/api/v1/agents/kb-chat/public", A = (e) => e.replace(/\/v1\/agents\/kb-chat\/public\/?$/, ""), j = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, apiBaseUrl: i = k, authHeaders: a, showBranding: o, siteSlug: s }) => {
144
+ let c = C({
145
+ url: `${A(i)}/v1/intelligence/site-agent/get-active`,
146
+ workspaceId: e,
147
+ headers: e ? {
148
+ ...a,
149
+ "Levo-Workspace": e
150
+ } : a
151
+ });
152
+ return c.status === "ready" ? /* @__PURE__ */ g("div", {
153
+ "data-ai-chat-root": !0,
154
+ children: /* @__PURE__ */ g(E, {
155
+ workspaceId: e,
156
+ siteName: t,
157
+ siteLogo: n,
158
+ siteIcon: r,
159
+ agentId: c.agent.id,
160
+ apiBaseUrl: i,
161
+ authHeaders: a,
162
+ showBranding: o,
163
+ siteSlug: s
164
+ })
165
+ }) : null;
166
+ };
167
+ //#endregion
168
+ export { j as default };
@@ -0,0 +1,166 @@
1
+ import { n as e } from "./theme.cssm-2YTdd8Yh.js";
2
+ import { Extension as t, findParentNodeClosestToPos as n } from "@tiptap/core";
3
+ import { NodeSelection as r } from "@tiptap/pm/state";
4
+ import { CellSelection as i, cellAround as a } from "@tiptap/pm/tables";
5
+ //#region ../../libraries/editor-core/dist/styles/content.cssm.js
6
+ var o = "_12oclrg0", s = "u2k86a0", c = e({
7
+ baseSpacing: "var(--_1q6hy0o0)",
8
+ highlight: "var(--_1q6hy0o1)",
9
+ highlightForeground: "var(--_1q6hy0o2)"
10
+ });
11
+ //#endregion
12
+ //#region ../../libraries/editor-core/dist/utils/getSelectedNodeOfType.js
13
+ function l(e, t) {
14
+ let o = [], s = new Set(t);
15
+ if (e instanceof i) return e.forEachCell((e, t) => {
16
+ s.has(e.type.name) && o.push({
17
+ node: e,
18
+ pos: t
19
+ });
20
+ }), o;
21
+ if (e instanceof r) {
22
+ let { node: t, from: n } = e;
23
+ return t && s.has(t.type.name) && o.push({
24
+ node: t,
25
+ pos: n
26
+ }), o;
27
+ }
28
+ let { $anchor: c } = e, l = a(c);
29
+ if (l) {
30
+ let t = e.$anchor.doc.nodeAt(l.pos);
31
+ if (t && s.has(t.type.name)) return o.push({
32
+ node: t,
33
+ pos: l.pos
34
+ }), o;
35
+ }
36
+ let u = n(c, (e) => s.has(e.type.name));
37
+ return u && o.push({
38
+ node: u.node,
39
+ pos: u.pos
40
+ }), o;
41
+ }
42
+ //#endregion
43
+ //#region ../../libraries/editor-core/dist/utils/updateNodesAttr.js
44
+ function u(e, t, n, r) {
45
+ if (!t.length) return !1;
46
+ let i = !1;
47
+ for (let { pos: a } of t) {
48
+ let t = e.doc.nodeAt(a);
49
+ if (!t) continue;
50
+ let o = t.attrs[n], s = typeof r == "function" ? r(o) : r;
51
+ if (o === s) continue;
52
+ let c = { ...t.attrs };
53
+ s === void 0 ? delete c[n] : c[n] = s, e.setNodeMarkup(a, void 0, c), i = !0;
54
+ }
55
+ return i;
56
+ }
57
+ //#endregion
58
+ //#region ../../libraries/editor-core/dist/extensions/nodeStyling/nodeAlignment.js
59
+ function d(e, t, n) {
60
+ if (e.length === 0) return null;
61
+ for (let r of e) if ((r.node.attrs?.[t] ?? null) !== n) return n;
62
+ return null;
63
+ }
64
+ var f = t.create({
65
+ name: "textAlign",
66
+ addOptions() {
67
+ return {
68
+ types: [
69
+ "paragraph",
70
+ "heading",
71
+ "quote",
72
+ "blockquoteFigure",
73
+ "tableCell",
74
+ "tableHeader"
75
+ ],
76
+ useStyle: !0,
77
+ textAlignValues: [
78
+ "left",
79
+ "center",
80
+ "right",
81
+ "justify"
82
+ ],
83
+ verticalAlignValues: [
84
+ "top",
85
+ "middle",
86
+ "bottom"
87
+ ]
88
+ };
89
+ },
90
+ addGlobalAttributes() {
91
+ return [{
92
+ types: this.options.types,
93
+ attributes: {
94
+ textAlign: {
95
+ default: null,
96
+ parseHTML: (e) => {
97
+ let t = e.style?.textAlign;
98
+ if (t && this.options.textAlignValues.includes(t)) return t;
99
+ let n = e.getAttribute("data-text-align");
100
+ return n && this.options.textAlignValues.includes(n) ? n : null;
101
+ },
102
+ renderHTML: (e) => {
103
+ let t = e.textAlign;
104
+ return !t || !this.options.textAlignValues.includes(t) ? {} : this.options.useStyle ? { style: `text-align: ${t}` } : { "data-text-align": t };
105
+ }
106
+ },
107
+ nodeVerticalAlign: {
108
+ default: null,
109
+ parseHTML: (e) => {
110
+ let t = e.style?.verticalAlign;
111
+ if (t && this.options.verticalAlignValues.includes(t)) return t;
112
+ let n = e.getAttribute("data-vertical-align");
113
+ return n && this.options.verticalAlignValues.includes(n) ? n : null;
114
+ },
115
+ renderHTML: (e) => {
116
+ let t = e.nodeVerticalAlign;
117
+ return !t || !this.options.verticalAlignValues.includes(t) ? {} : this.options.useStyle ? { style: `vertical-align: ${t}` } : { "data-vertical-align": t };
118
+ }
119
+ }
120
+ }
121
+ }];
122
+ },
123
+ addCommands() {
124
+ let e = (e, t) => (n) => ({ state: r, tr: i }) => {
125
+ let a = l(r.selection, this.options.types);
126
+ return a.length === 0 ? !1 : u(i, a, e, t(a, n));
127
+ };
128
+ return {
129
+ setNodeTextAlign: e("textAlign", (e, t) => !t || !this.options.textAlignValues.includes(t) ? null : t),
130
+ unsetNodeTextAlign: e("textAlign", () => null),
131
+ toggleNodeTextAlign: e("textAlign", (e, t) => !t || !this.options.textAlignValues.includes(t) ? null : d(e, "textAlign", t)),
132
+ setNodeVAlign: e("nodeVerticalAlign", (e, t) => !t || !this.options.verticalAlignValues.includes(t) ? null : t),
133
+ unsetNodeVAlign: e("nodeVerticalAlign", () => null),
134
+ toggleNodeVAlign: e("nodeVerticalAlign", (e, t) => !t || !this.options.verticalAlignValues.includes(t) ? null : d(e, "nodeVerticalAlign", t)),
135
+ setNodeAlignment: (e, t) => ({ state: n, tr: r }) => {
136
+ let i = l(n.selection, this.options.types);
137
+ if (i.length === 0) return !1;
138
+ let a = !1;
139
+ for (let { node: n, pos: o } of i) {
140
+ let i = { ...n.attrs };
141
+ e && this.options.textAlignValues.includes(e) && (i.textAlign = e, a = !0), t && this.options.verticalAlignValues.includes(t) && (i.nodeVerticalAlign = t, a = !0), a && r.setNodeMarkup(o, void 0, i);
142
+ }
143
+ return a;
144
+ },
145
+ unsetNodeAlignment: () => ({ state: e, tr: t }) => {
146
+ let n = l(e.selection, this.options.types);
147
+ if (n.length === 0) return !1;
148
+ let r = !1;
149
+ for (let { node: e, pos: i } of n) {
150
+ let n = e.attrs?.textAlign ?? null, a = e.attrs?.nodeVerticalAlign ?? null;
151
+ if (n || a) {
152
+ let n = {
153
+ ...e.attrs,
154
+ textAlign: null,
155
+ nodeVerticalAlign: null
156
+ };
157
+ t.setNodeMarkup(i, void 0, n), r = !0;
158
+ }
159
+ }
160
+ return r;
161
+ }
162
+ };
163
+ }
164
+ });
165
+ //#endregion
166
+ export { o as i, c as n, s as r, f as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/site-runtime",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
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": [
@@ -17,6 +17,10 @@
17
17
  "types": "./index.d.ts",
18
18
  "default": "./index.js"
19
19
  },
20
+ "./popups": {
21
+ "types": "./popups.d.ts",
22
+ "default": "./popups.js"
23
+ },
20
24
  "./setup.css": "./styles.css"
21
25
  },
22
26
  "files": [
@@ -63,15 +67,23 @@
63
67
  "lowlight": "3.1.0",
64
68
  "@vanilla-extract/dynamic": "2.1.5",
65
69
  "sonner": "2.0.7",
70
+ "@assistant-ui/react": "0.12.14",
71
+ "@assistant-ui/react-ai-sdk": "1.3.10",
72
+ "@assistant-ui/react-markdown": "0.12.5",
73
+ "@assistant-ui/core": "0.1.5",
74
+ "@assistant-ui/store": "0.2.2",
75
+ "@assistant-ui/tap": "0.5.2",
76
+ "remark-gfm": "4.0.1",
66
77
  "@stripe/react-stripe-js": "^3.1.1",
67
78
  "@stripe/stripe-js": "^5.5.0",
68
79
  "react-razorpay": "^3.0.1",
69
- "@levo-so/insights": "0.2.1",
70
- "@levo-so/core": "0.2.1"
80
+ "@levo-so/core": "0.2.1",
81
+ "@levo-so/insights": "0.2.1"
71
82
  },
72
83
  "peerDependencies": {
73
84
  "@base-ui/react": "^1.5.0",
74
85
  "@tanstack/react-query": ">=5",
86
+ "@tanstack/react-router": ">=1.170.0",
75
87
  "lucide-react": ">=0.4",
76
88
  "react": ">=19",
77
89
  "react-dom": ">=19"
@@ -0,0 +1,20 @@
1
+ //#region ../../libraries/ai-chat/src/helpers.ts
2
+ var e = (e, t = {
3
+ hour: "numeric",
4
+ minute: "2-digit"
5
+ }) => {
6
+ if (!e) return "";
7
+ let n = e instanceof Date ? e : new Date(e);
8
+ return Number.isNaN(n.getTime()) ? "" : n.toLocaleTimeString([], t);
9
+ }, t = (e, t) => t ? `levo.site_chat.${e}.${t}` : null, n = (e, t) => {
10
+ e.style.height = "auto", e.style.height = t === void 0 ? `${e.scrollHeight}px` : `${Math.min(e.scrollHeight, t)}px`;
11
+ }, r = "w-72", i = "ai-chat-pill-gradient relative rounded-[30px] p-[2px] transition-shadow duration-300", a = "shadow-lg shadow-zinc-950/10", o = "shadow-md", s = "ai-chat-pill-surface min-h-14 w-full rounded-[28px] bg-white p-1.5", c = "ai-chat-pill-surface--stacked", l = "ai-chat-pill-input relative min-w-0", u = "ai-chat-pill-actions flex items-center gap-1.5", d = "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", f = "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", p = "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", m = 24, h = (e, t) => {
12
+ e.classList.remove(c), t.style.height = "auto";
13
+ let r = t.scrollHeight > m + 4;
14
+ return e.classList.toggle(c, r), n(t, 120), r;
15
+ }, g = "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", _ = {
16
+ backgroundColor: "var(--color-brand, #0a0a0a)",
17
+ color: "var(--color-brand-foreground, #fff)"
18
+ }, v = (e) => e ? `Ask ${e}` : "Ask AI";
19
+ //#endregion
20
+ export { e as _, f as a, a as c, c as d, p as f, n as g, v as h, g as i, d as l, h as m, i as n, _ as o, r as p, l as r, o as s, u as t, s as u, t as v };
package/popups.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `usePopup` — imperative open/close for the site's popups.
3
+ *
4
+ * This is its OWN package entry (`@levo-so/site-runtime/popups`), deliberately not part of
5
+ * the main barrel. Upstream, the popup store is emitted into the same chunk as the tiptap
6
+ * content renderer, so any static import of this hook drags ~100 kB of renderer with it
7
+ * (see levo-turbo#4545). Exporting it from the barrel would put that on the eager graph of
8
+ * EVERY page of EVERY site — including sites with no popups — and on every SSR render.
9
+ * From a separate entry, only a page that actually imports it pays.
10
+ *
11
+ * Static (not lazy) by necessity: a hook must be callable during render, and it has to read
12
+ * the SAME nanostores store the mounted `<LevoPopups>` writes to — a lazily-loaded second
13
+ * copy would never see the loaded popups.
14
+ *
15
+ * When #4545 lands a store-only entry upstream, re-point the import at it; consumers keep
16
+ * this import path and just get lighter.
17
+ */
18
+ /** The slice of a loaded popup a site can act on. Matching by `id` is the contract. */
19
+ export declare interface ILevoPopup {
20
+ /** Stable popup id (`PU…`) — what `openPopup` takes. */
21
+ id: string;
22
+ /** The name the popup was given in the dashboard. */
23
+ title: string;
24
+ description?: string;
25
+ }
26
+
27
+ export declare interface ILevoPopupControls {
28
+ /** Active popups loaded for this site. Empty until the fetch resolves. */
29
+ popups: ILevoPopup[];
30
+ isLoading: boolean;
31
+ /**
32
+ * Open a popup by id. Force-opens — bypasses cooldown and display-frequency caps,
33
+ * because a click is an explicit request. No-op if that popup isn't loaded.
34
+ */
35
+ openPopup: (id: string) => void;
36
+ /** Close whatever popup is currently open. No-op if none is. */
37
+ closePopup: () => void;
38
+ }
39
+
40
+ /**
41
+ * Explicit return type on purpose: it keeps the rolled-up `.d.ts` self-contained. A bare
42
+ * `export { usePopup } from "@levo.libraries/popups"` emits a re-export of a PRIVATE
43
+ * package that a generated site can't resolve.
44
+ */
45
+ export declare const usePopup: () => ILevoPopupControls;
46
+
47
+ export { }
package/popups.js ADDED
@@ -0,0 +1,5 @@
1
+ import { t as e } from "./dist-CJknSbJK.js";
2
+ //#region src/popups/usePopup.ts
3
+ var t = () => e();
4
+ //#endregion
5
+ export { t as usePopup };
@@ -0,0 +1,11 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = (t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ };
10
+ //#endregion
11
+ export { t };