@tmls-ai/support 0.1.3 → 0.1.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/dist/index.js +11 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,6 +116,7 @@ function SupportWidget(props) {
|
|
|
116
116
|
const [message, setMessage] = useState("");
|
|
117
117
|
const [withShot, setWithShot] = useState(true);
|
|
118
118
|
const [shotPreview, setShotPreview] = useState(null);
|
|
119
|
+
const [capturing, setCapturing] = useState(false);
|
|
119
120
|
const [sending, setSending] = useState(false);
|
|
120
121
|
const [lastTicket, setLastTicket] = useState(null);
|
|
121
122
|
const [threads, setThreads] = useState([]);
|
|
@@ -128,6 +129,12 @@ function SupportWidget(props) {
|
|
|
128
129
|
installErrorCapture();
|
|
129
130
|
}, []);
|
|
130
131
|
const captureShot = useCallback(async () => {
|
|
132
|
+
setCapturing(true);
|
|
133
|
+
await new Promise((resolve) => {
|
|
134
|
+
const ric = window.requestIdleCallback;
|
|
135
|
+
if (ric) ric(() => resolve(), { timeout: 600 });
|
|
136
|
+
else setTimeout(resolve, 150);
|
|
137
|
+
});
|
|
131
138
|
try {
|
|
132
139
|
const root = document.documentElement;
|
|
133
140
|
const blob = await domToBlob(root, {
|
|
@@ -143,6 +150,8 @@ function SupportWidget(props) {
|
|
|
143
150
|
setShotPreview(URL.createObjectURL(blob));
|
|
144
151
|
captureShot._blob = blob;
|
|
145
152
|
} catch {
|
|
153
|
+
} finally {
|
|
154
|
+
setCapturing(false);
|
|
146
155
|
}
|
|
147
156
|
}, []);
|
|
148
157
|
const submit = useCallback(async () => {
|
|
@@ -150,6 +159,7 @@ function SupportWidget(props) {
|
|
|
150
159
|
setSending(true);
|
|
151
160
|
try {
|
|
152
161
|
let attachmentKeys = [];
|
|
162
|
+
if (withShot && !captureShot._blob) await captureShot();
|
|
153
163
|
const blob = withShot ? captureShot._blob : void 0;
|
|
154
164
|
if (blob) {
|
|
155
165
|
try {
|
|
@@ -259,6 +269,7 @@ function SupportWidget(props) {
|
|
|
259
269
|
} }),
|
|
260
270
|
"Attach a screenshot"
|
|
261
271
|
] }),
|
|
272
|
+
withShot && capturing && !shotPreview && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#8a8a92", padding: "10px 0", textAlign: "center" }, children: "Capturing screenshot\u2026" }),
|
|
262
273
|
shotPreview && /* @__PURE__ */ jsx("img", { src: shotPreview, alt: "", style: { width: "100%", borderRadius: 8, border: "0.5px solid #3a3a42" } }),
|
|
263
274
|
/* @__PURE__ */ jsx("button", { onClick: submit, disabled: !message.trim() || sending, style: { ...primary(accent), opacity: !message.trim() || sending ? 0.5 : 1 }, children: sending ? "Sending\u2026" : "Send report" })
|
|
264
275
|
] }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmls-ai/support",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|