@tmls-ai/support 0.1.4 → 0.1.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 +29 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -106,6 +106,16 @@ var SEVERITIES = [
|
|
|
106
106
|
{ id: "annoying", label: "Annoying" },
|
|
107
107
|
{ id: "minor", label: "Minor" }
|
|
108
108
|
];
|
|
109
|
+
var deeplinkTicket = (() => {
|
|
110
|
+
if (typeof window === "undefined") return null;
|
|
111
|
+
const params = new URLSearchParams(window.location.search);
|
|
112
|
+
const tn = params.get("support");
|
|
113
|
+
if (!tn) return null;
|
|
114
|
+
params.delete("support");
|
|
115
|
+
const qs = params.toString();
|
|
116
|
+
window.history.replaceState({}, "", window.location.pathname + (qs ? `?${qs}` : "") + window.location.hash);
|
|
117
|
+
return tn;
|
|
118
|
+
})();
|
|
109
119
|
function SupportWidget(props) {
|
|
110
120
|
const { productId, apiUrl, getToken, accent = "#0a84ff", getContext, appVersion } = props;
|
|
111
121
|
const api = useMemo(() => new SupportApi(apiUrl, getToken), [apiUrl, getToken]);
|
|
@@ -137,7 +147,7 @@ function SupportWidget(props) {
|
|
|
137
147
|
});
|
|
138
148
|
try {
|
|
139
149
|
const root = document.documentElement;
|
|
140
|
-
const
|
|
150
|
+
const shoot = () => domToBlob(root, {
|
|
141
151
|
quality: 0.8,
|
|
142
152
|
scale: 0.75,
|
|
143
153
|
width: root.clientWidth || window.innerWidth,
|
|
@@ -147,6 +157,11 @@ function SupportWidget(props) {
|
|
|
147
157
|
features: { restoreScrollPosition: true },
|
|
148
158
|
filter: (node) => !(node instanceof HTMLElement && node.dataset.tmlsSupportRoot === "true")
|
|
149
159
|
});
|
|
160
|
+
let blob = await shoot();
|
|
161
|
+
if (blob.size < 1024) {
|
|
162
|
+
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
|
|
163
|
+
blob = await shoot();
|
|
164
|
+
}
|
|
150
165
|
setShotPreview(URL.createObjectURL(blob));
|
|
151
166
|
captureShot._blob = blob;
|
|
152
167
|
} catch {
|
|
@@ -214,6 +229,18 @@ function SupportWidget(props) {
|
|
|
214
229
|
setMessages(detail.messages);
|
|
215
230
|
}
|
|
216
231
|
}, [api, reply, activeId]);
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (!deeplinkTicket) return;
|
|
234
|
+
const tn = deeplinkTicket;
|
|
235
|
+
(async () => {
|
|
236
|
+
setOpen(true);
|
|
237
|
+
const convos = await api.listConversations();
|
|
238
|
+
setThreads(convos);
|
|
239
|
+
const match = convos.find((c) => String(c.ticket_number) === tn);
|
|
240
|
+
if (match) await openThread(match.id);
|
|
241
|
+
else setView("threads");
|
|
242
|
+
})();
|
|
243
|
+
}, [api, openThread]);
|
|
217
244
|
const chip = (active) => ({
|
|
218
245
|
padding: "6px 12px",
|
|
219
246
|
borderRadius: 999,
|
|
@@ -339,6 +366,7 @@ function SupportWidget(props) {
|
|
|
339
366
|
"button",
|
|
340
367
|
{
|
|
341
368
|
onClick: () => {
|
|
369
|
+
if (open) deeplinkTicket = null;
|
|
342
370
|
setOpen((o) => !o);
|
|
343
371
|
if (!open && withShot) captureShot();
|
|
344
372
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmls-ai/support",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Embeddable Timeless support widget — bottom-right report overlay (type / severity / screenshot) + ticket thread. Auto-captures context, talks to tmls-support-api.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|