@tmls-ai/support 0.1.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +14 -0
  2. 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, {
@@ -135,11 +142,16 @@ function SupportWidget(props) {
135
142
  scale: 0.75,
136
143
  width: root.clientWidth || window.innerWidth,
137
144
  height: root.clientHeight || window.innerHeight,
145
+ // Keep scrolled containers (chat log, lists) at their on-screen scroll
146
+ // position instead of snapping back to the top in the clone.
147
+ features: { restoreScrollPosition: true },
138
148
  filter: (node) => !(node instanceof HTMLElement && node.dataset.tmlsSupportRoot === "true")
139
149
  });
140
150
  setShotPreview(URL.createObjectURL(blob));
141
151
  captureShot._blob = blob;
142
152
  } catch {
153
+ } finally {
154
+ setCapturing(false);
143
155
  }
144
156
  }, []);
145
157
  const submit = useCallback(async () => {
@@ -147,6 +159,7 @@ function SupportWidget(props) {
147
159
  setSending(true);
148
160
  try {
149
161
  let attachmentKeys = [];
162
+ if (withShot && !captureShot._blob) await captureShot();
150
163
  const blob = withShot ? captureShot._blob : void 0;
151
164
  if (blob) {
152
165
  try {
@@ -256,6 +269,7 @@ function SupportWidget(props) {
256
269
  } }),
257
270
  "Attach a screenshot"
258
271
  ] }),
272
+ withShot && capturing && !shotPreview && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#8a8a92", padding: "10px 0", textAlign: "center" }, children: "Capturing screenshot\u2026" }),
259
273
  shotPreview && /* @__PURE__ */ jsx("img", { src: shotPreview, alt: "", style: { width: "100%", borderRadius: 8, border: "0.5px solid #3a3a42" } }),
260
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" })
261
275
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmls-ai/support",
3
- "version": "0.1.2",
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",