@luma-ai/react 0.1.0 → 2.0.1
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 +51 -0
- package/README.md +18 -12
- package/dist/chunks/src-C48p0wsr.js +7647 -0
- package/dist/chunks/src-C48p0wsr.js.map +1 -0
- package/dist/chunks/support-cursor-BU9gztRA.js +131 -0
- package/dist/chunks/support-cursor-BU9gztRA.js.map +1 -0
- package/dist/chunks/visitor-call-CoKCjk8c.js +1129 -0
- package/dist/chunks/visitor-call-CoKCjk8c.js.map +1 -0
- package/dist/chunks/visitor-cobrowse-Ba7H1VtS.js +1415 -0
- package/dist/chunks/visitor-cobrowse-Ba7H1VtS.js.map +1 -0
- package/dist/{config-CCT7m9eE.d.ts → config-BAC3xPNG.d.ts} +1 -6
- package/dist/index-ByvZMuLw.d.ts +415 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -2
- package/dist/next.d.ts +3 -5
- package/dist/next.js +2 -3
- package/dist/next.js.map +1 -1
- package/dist/react-router.d.ts +3 -5
- package/dist/react-router.js +2 -3
- package/dist/react-router.js.map +1 -1
- package/dist/server.d.ts +1 -3
- package/dist/server.js +11 -12
- package/dist/server.js.map +1 -1
- package/dist/tanstack.d.ts +3 -5
- package/dist/tanstack.js +2 -3
- package/dist/tanstack.js.map +1 -1
- package/docs/ai-agents.md +5 -5
- package/docs/appearance.md +92 -0
- package/docs/data-sources.md +18 -18
- package/docs/features.md +62 -0
- package/docs/hooks.md +22 -8
- package/docs/index.md +17 -7
- package/docs/options.md +58 -51
- package/docs/privacy.md +29 -6
- package/docs/server.md +11 -7
- package/docs/troubleshooting.md +16 -8
- package/package.json +28 -21
- package/skills/luma-ai-react/SKILL.md +32 -13
- package/dist/chunks/src-dnp1waFV.js +0 -3100
- package/dist/chunks/src-dnp1waFV.js.map +0 -1
- package/dist/index-BdkoFDyP.d.ts +0 -189
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as COBROWSE_LIMITS, l as placeInViewport } from "./src-C48p0wsr.js";
|
|
3
|
+
// src/cobrowse/support-cursor.ts
|
|
4
|
+
/**
|
|
5
|
+
* Support's cursor on the visitor's page (phase 14): an arrow with a small
|
|
6
|
+
* «پشتیبانی» label, moved smoothly to where support points; an edge marker
|
|
7
|
+
* toward a point outside the window; a short ripple for "look here". Plain
|
|
8
|
+
* DOM, drawn in the widget's own layer with `pointer-events: none`: it never
|
|
9
|
+
* clicks, types, focuses, scrolls or navigates, and the page stays usable
|
|
10
|
+
* underneath. Shared by the co-browsing module and the call module.
|
|
11
|
+
*/
|
|
12
|
+
var STYLE_ID = "luma-support-cursor-style";
|
|
13
|
+
var STYLE = `
|
|
14
|
+
.luma-sc{position:fixed;top:0;left:0;z-index:2147483646;pointer-events:none;will-change:transform;transition:transform 90ms linear;display:none}
|
|
15
|
+
.luma-sc[data-shown]{display:block}
|
|
16
|
+
.luma-sc[data-jump]{transition:none}
|
|
17
|
+
.luma-sc svg{display:block;width:22px;height:22px;filter:drop-shadow(0 1px 2px #0007)}
|
|
18
|
+
.luma-sc span,.luma-sc-edge span{position:absolute;top:18px;left:14px;padding:1px 7px;border-radius:999px;background:#2563eb;color:#fff;font:600 11px/18px system-ui,Tahoma,sans-serif;white-space:nowrap;box-shadow:0 1px 3px #0005}
|
|
19
|
+
.luma-sc-edge{position:fixed;top:0;left:0;z-index:2147483646;pointer-events:none;display:none}
|
|
20
|
+
.luma-sc-edge[data-shown]{display:block}
|
|
21
|
+
.luma-sc-edge i{position:relative;display:flex;align-items:center;justify-content:center;width:30px;height:30px;margin:-15px 0 0 -15px;border-radius:50%;background:#2563eb;box-shadow:0 1px 4px #0006}
|
|
22
|
+
.luma-sc-edge span{top:16px;left:-20px}
|
|
23
|
+
.luma-sc-ripple{position:fixed;z-index:2147483646;width:44px;height:44px;margin:-22px 0 0 -22px;border-radius:50%;box-shadow:inset 0 0 0 3px #2563eb;background:#2563eb2e;pointer-events:none;animation:luma-sc-ripple .8s ease-out forwards}
|
|
24
|
+
@keyframes luma-sc-ripple{from{transform:scale(.3);opacity:1}to{transform:scale(1.6);opacity:0}}
|
|
25
|
+
@media (prefers-reduced-motion:reduce){.luma-sc{transition:none}.luma-sc-ripple{animation-duration:1.2s;animation-timing-function:steps(2)}}
|
|
26
|
+
`;
|
|
27
|
+
var ARROW = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M3 2l17 9.5-7.5 1.7L9 21z\" fill=\"#2563eb\" stroke=\"#fff\" stroke-width=\"1.6\" stroke-linejoin=\"round\"/></svg>";
|
|
28
|
+
function createSupportCursor(layer, lang) {
|
|
29
|
+
const root = layer.getRootNode();
|
|
30
|
+
const host = root instanceof Document ? root.head : root;
|
|
31
|
+
if (!host.querySelector?.(`#${STYLE_ID}`)) {
|
|
32
|
+
const style = document.createElement("style");
|
|
33
|
+
style.id = STYLE_ID;
|
|
34
|
+
style.textContent = STYLE;
|
|
35
|
+
host.append(style);
|
|
36
|
+
}
|
|
37
|
+
const label = lang === "fa" ? "پشتیبانی" : "Support";
|
|
38
|
+
const cursor = document.createElement("div");
|
|
39
|
+
cursor.className = "luma-sc";
|
|
40
|
+
cursor.setAttribute("aria-hidden", "true");
|
|
41
|
+
cursor.setAttribute("data-luma-support-cursor", "");
|
|
42
|
+
cursor.innerHTML = ARROW;
|
|
43
|
+
const tag = document.createElement("span");
|
|
44
|
+
tag.textContent = label;
|
|
45
|
+
cursor.append(tag);
|
|
46
|
+
const edge = document.createElement("div");
|
|
47
|
+
edge.className = "luma-sc-edge";
|
|
48
|
+
edge.setAttribute("aria-hidden", "true");
|
|
49
|
+
edge.setAttribute("data-luma-support-edge", "");
|
|
50
|
+
const dot = document.createElement("i");
|
|
51
|
+
dot.innerHTML = "<svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M5 3l7 5-7 5z\" fill=\"#fff\"/></svg>";
|
|
52
|
+
const edgeTag = document.createElement("span");
|
|
53
|
+
edgeTag.textContent = label;
|
|
54
|
+
edge.append(dot, edgeTag);
|
|
55
|
+
layer.append(cursor, edge);
|
|
56
|
+
let target = null;
|
|
57
|
+
let movedAt = 0;
|
|
58
|
+
let frame = 0;
|
|
59
|
+
let shown = false;
|
|
60
|
+
const hide = () => {
|
|
61
|
+
cursor.removeAttribute("data-shown");
|
|
62
|
+
edge.removeAttribute("data-shown");
|
|
63
|
+
shown = false;
|
|
64
|
+
};
|
|
65
|
+
const tick = () => {
|
|
66
|
+
frame = 0;
|
|
67
|
+
if (!target || Date.now() - movedAt > COBROWSE_LIMITS.cursorIdleMs) {
|
|
68
|
+
target = null;
|
|
69
|
+
hide();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const point = target();
|
|
73
|
+
if (!point) hide();
|
|
74
|
+
else {
|
|
75
|
+
const place = placeInViewport(point, {
|
|
76
|
+
w: window.innerWidth,
|
|
77
|
+
h: window.innerHeight
|
|
78
|
+
});
|
|
79
|
+
if (place.inside) {
|
|
80
|
+
if (!shown) cursor.setAttribute("data-jump", "");
|
|
81
|
+
cursor.style.transform = `translate(${place.x}px,${place.y}px)`;
|
|
82
|
+
cursor.setAttribute("data-shown", "");
|
|
83
|
+
edge.removeAttribute("data-shown");
|
|
84
|
+
if (!shown) requestAnimationFrame(() => cursor.removeAttribute("data-jump"));
|
|
85
|
+
shown = true;
|
|
86
|
+
} else {
|
|
87
|
+
cursor.removeAttribute("data-shown");
|
|
88
|
+
shown = false;
|
|
89
|
+
edge.style.transform = `translate(${place.x}px,${place.y}px)`;
|
|
90
|
+
dot.style.transform = `rotate(${place.angle}deg)`;
|
|
91
|
+
edge.setAttribute("data-shown", "");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
frame = requestAnimationFrame(tick);
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
move(next) {
|
|
98
|
+
target = next;
|
|
99
|
+
movedAt = Date.now();
|
|
100
|
+
if (!next) {
|
|
101
|
+
hide();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!frame) frame = requestAnimationFrame(tick);
|
|
105
|
+
},
|
|
106
|
+
ripple(at) {
|
|
107
|
+
const point = at();
|
|
108
|
+
if (!point) return;
|
|
109
|
+
const place = placeInViewport(point, {
|
|
110
|
+
w: window.innerWidth,
|
|
111
|
+
h: window.innerHeight
|
|
112
|
+
});
|
|
113
|
+
const ring = document.createElement("div");
|
|
114
|
+
ring.className = "luma-sc-ripple";
|
|
115
|
+
ring.setAttribute("data-luma-support-ripple", "");
|
|
116
|
+
ring.style.left = `${place.x}px`;
|
|
117
|
+
ring.style.top = `${place.y}px`;
|
|
118
|
+
layer.append(ring);
|
|
119
|
+
setTimeout(() => ring.remove(), 1300);
|
|
120
|
+
},
|
|
121
|
+
destroy() {
|
|
122
|
+
if (frame) cancelAnimationFrame(frame);
|
|
123
|
+
target = null;
|
|
124
|
+
cursor.remove();
|
|
125
|
+
edge.remove();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export { createSupportCursor as t };
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=support-cursor-BU9gztRA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support-cursor-BU9gztRA.js","names":[],"sources":["../../src/cobrowse/support-cursor.ts"],"sourcesContent":["import {\n COBROWSE_LIMITS,\n placeInViewport,\n} from \"@luma/assistant-contract/cobrowse-basics\";\n\n/**\n * Support's cursor on the visitor's page (phase 14): an arrow with a small\n * «پشتیبانی» label, moved smoothly to where support points; an edge marker\n * toward a point outside the window; a short ripple for \"look here\". Plain\n * DOM, drawn in the widget's own layer with `pointer-events: none`: it never\n * clicks, types, focuses, scrolls or navigates, and the page stays usable\n * underneath. Shared by the co-browsing module and the call module.\n */\n\nconst STYLE_ID = \"luma-support-cursor-style\";\nconst STYLE = `\n.luma-sc{position:fixed;top:0;left:0;z-index:2147483646;pointer-events:none;will-change:transform;transition:transform 90ms linear;display:none}\n.luma-sc[data-shown]{display:block}\n.luma-sc[data-jump]{transition:none}\n.luma-sc svg{display:block;width:22px;height:22px;filter:drop-shadow(0 1px 2px #0007)}\n.luma-sc span,.luma-sc-edge span{position:absolute;top:18px;left:14px;padding:1px 7px;border-radius:999px;background:#2563eb;color:#fff;font:600 11px/18px system-ui,Tahoma,sans-serif;white-space:nowrap;box-shadow:0 1px 3px #0005}\n.luma-sc-edge{position:fixed;top:0;left:0;z-index:2147483646;pointer-events:none;display:none}\n.luma-sc-edge[data-shown]{display:block}\n.luma-sc-edge i{position:relative;display:flex;align-items:center;justify-content:center;width:30px;height:30px;margin:-15px 0 0 -15px;border-radius:50%;background:#2563eb;box-shadow:0 1px 4px #0006}\n.luma-sc-edge span{top:16px;left:-20px}\n.luma-sc-ripple{position:fixed;z-index:2147483646;width:44px;height:44px;margin:-22px 0 0 -22px;border-radius:50%;box-shadow:inset 0 0 0 3px #2563eb;background:#2563eb2e;pointer-events:none;animation:luma-sc-ripple .8s ease-out forwards}\n@keyframes luma-sc-ripple{from{transform:scale(.3);opacity:1}to{transform:scale(1.6);opacity:0}}\n@media (prefers-reduced-motion:reduce){.luma-sc{transition:none}.luma-sc-ripple{animation-duration:1.2s;animation-timing-function:steps(2)}}\n`;\nconst ARROW =\n '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M3 2l17 9.5-7.5 1.7L9 21z\" fill=\"#2563eb\" stroke=\"#fff\" stroke-width=\"1.6\" stroke-linejoin=\"round\"/></svg>';\n\nexport type CursorPoint = { x: number; y: number };\n/** Where the cursor is now (read every frame, so it follows the page). */\nexport type CursorTarget = () => CursorPoint | null;\n\nexport type SupportCursor = {\n /** Moves the cursor (null: support's mouse left the page). */\n move: (target: CursorTarget | null) => void;\n ripple: (target: CursorTarget) => void;\n destroy: () => void;\n};\n\nexport function createSupportCursor(\n layer: HTMLElement,\n lang: \"fa\" | \"en\",\n): SupportCursor {\n const root = layer.getRootNode() as Document | ShadowRoot;\n const host = root instanceof Document ? root.head : root;\n if (!host.querySelector?.(`#${STYLE_ID}`)) {\n const style = document.createElement(\"style\");\n style.id = STYLE_ID;\n style.textContent = STYLE;\n host.append(style);\n }\n const label = lang === \"fa\" ? \"پشتیبانی\" : \"Support\";\n const cursor = document.createElement(\"div\");\n cursor.className = \"luma-sc\";\n cursor.setAttribute(\"aria-hidden\", \"true\");\n cursor.setAttribute(\"data-luma-support-cursor\", \"\");\n cursor.innerHTML = ARROW;\n const tag = document.createElement(\"span\");\n tag.textContent = label;\n cursor.append(tag);\n const edge = document.createElement(\"div\");\n edge.className = \"luma-sc-edge\";\n edge.setAttribute(\"aria-hidden\", \"true\");\n edge.setAttribute(\"data-luma-support-edge\", \"\");\n const dot = document.createElement(\"i\");\n // An arrowhead pointing right; the circle turns toward the target.\n dot.innerHTML =\n '<svg viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M5 3l7 5-7 5z\" fill=\"#fff\"/></svg>';\n const edgeTag = document.createElement(\"span\");\n edgeTag.textContent = label;\n edge.append(dot, edgeTag);\n layer.append(cursor, edge);\n\n let target: CursorTarget | null = null;\n let movedAt = 0;\n let frame = 0;\n let shown = false;\n\n const hide = () => {\n cursor.removeAttribute(\"data-shown\");\n edge.removeAttribute(\"data-shown\");\n shown = false;\n };\n const tick = () => {\n frame = 0;\n if (!target || Date.now() - movedAt > COBROWSE_LIMITS.cursorIdleMs) {\n target = null;\n hide();\n return;\n }\n const point = target();\n if (!point) hide();\n else {\n const place = placeInViewport(point, {\n w: window.innerWidth,\n h: window.innerHeight,\n });\n if (place.inside) {\n if (!shown) cursor.setAttribute(\"data-jump\", \"\");\n cursor.style.transform = `translate(${place.x}px,${place.y}px)`;\n cursor.setAttribute(\"data-shown\", \"\");\n edge.removeAttribute(\"data-shown\");\n if (!shown)\n requestAnimationFrame(() => cursor.removeAttribute(\"data-jump\"));\n shown = true;\n } else {\n cursor.removeAttribute(\"data-shown\");\n shown = false;\n edge.style.transform = `translate(${place.x}px,${place.y}px)`;\n dot.style.transform = `rotate(${place.angle}deg)`;\n edge.setAttribute(\"data-shown\", \"\");\n }\n }\n frame = requestAnimationFrame(tick);\n };\n\n return {\n move(next) {\n target = next;\n movedAt = Date.now();\n if (!next) {\n hide();\n return;\n }\n if (!frame) frame = requestAnimationFrame(tick);\n },\n ripple(at) {\n const point = at();\n if (!point) return;\n const place = placeInViewport(point, {\n w: window.innerWidth,\n h: window.innerHeight,\n });\n const ring = document.createElement(\"div\");\n ring.className = \"luma-sc-ripple\";\n ring.setAttribute(\"data-luma-support-ripple\", \"\");\n ring.style.left = `${place.x}px`;\n ring.style.top = `${place.y}px`;\n layer.append(ring);\n setTimeout(() => ring.remove(), 1300);\n },\n destroy() {\n if (frame) cancelAnimationFrame(frame);\n target = null;\n cursor.remove();\n edge.remove();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAM,WAAW;AACjB,IAAM,QAAQ;;;;;;;;;;;;;;AAcd,IAAM,QACJ;AAaF,SAAgB,oBACd,OACA,MACe;CACf,MAAM,OAAO,MAAM,YAAY;CAC/B,MAAM,OAAO,gBAAgB,WAAW,KAAK,OAAO;CACpD,IAAI,CAAC,KAAK,gBAAgB,IAAI,UAAU,GAAG;EACzC,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,KAAK;EACX,MAAM,cAAc;EACpB,KAAK,OAAO,KAAK;CACnB;CACA,MAAM,QAAQ,SAAS,OAAO,aAAa;CAC3C,MAAM,SAAS,SAAS,cAAc,KAAK;CAC3C,OAAO,YAAY;CACnB,OAAO,aAAa,eAAe,MAAM;CACzC,OAAO,aAAa,4BAA4B,EAAE;CAClD,OAAO,YAAY;CACnB,MAAM,MAAM,SAAS,cAAc,MAAM;CACzC,IAAI,cAAc;CAClB,OAAO,OAAO,GAAG;CACjB,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,YAAY;CACjB,KAAK,aAAa,eAAe,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