@ibealec/create-zed-bridge 1.0.2 → 1.0.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 +214 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/@zed-controller/react-bridge/dist/index.cjs +24 -11
- package/templates/@zed-controller/react-bridge/dist/index.cjs.map +1 -1
- package/templates/@zed-controller/react-bridge/dist/index.js +24 -11
- package/templates/@zed-controller/react-bridge/dist/index.js.map +1 -1
- package/templates/@zed-controller/react-bridge/package.json +16 -0
- package/templates/@zed-controller/shared/package.json +10 -1
|
@@ -1709,26 +1709,39 @@ function TaskStatusToast({
|
|
|
1709
1709
|
return new Promise((resolve) => {
|
|
1710
1710
|
const wsUrl = serverUrl.replace(/^http/, "ws").replace(/\/$/, "");
|
|
1711
1711
|
const ws = new WebSocket(`${wsUrl}/ws/bridge?token=${encodeURIComponent(token)}`);
|
|
1712
|
+
let resolved = false;
|
|
1713
|
+
const cleanup = () => {
|
|
1714
|
+
if (!resolved) {
|
|
1715
|
+
resolved = true;
|
|
1716
|
+
ws.close();
|
|
1717
|
+
resolve();
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1712
1720
|
ws.onopen = () => {
|
|
1713
1721
|
ws.send(JSON.stringify({
|
|
1714
1722
|
type: "kill_session",
|
|
1715
1723
|
sessionId
|
|
1716
1724
|
}));
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1725
|
+
};
|
|
1726
|
+
ws.onmessage = (event) => {
|
|
1727
|
+
try {
|
|
1728
|
+
const message = JSON.parse(event.data);
|
|
1729
|
+
if (message.type === "session_killed" || message.type === "error") {
|
|
1730
|
+
cleanup();
|
|
1731
|
+
}
|
|
1732
|
+
} catch {
|
|
1733
|
+
}
|
|
1721
1734
|
};
|
|
1722
1735
|
ws.onerror = () => {
|
|
1723
|
-
|
|
1724
|
-
resolve();
|
|
1736
|
+
cleanup();
|
|
1725
1737
|
};
|
|
1726
|
-
|
|
1727
|
-
if (
|
|
1728
|
-
|
|
1738
|
+
ws.onclose = () => {
|
|
1739
|
+
if (!resolved) {
|
|
1740
|
+
resolved = true;
|
|
1741
|
+
resolve();
|
|
1729
1742
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1743
|
+
};
|
|
1744
|
+
setTimeout(cleanup, 3e3);
|
|
1732
1745
|
});
|
|
1733
1746
|
}, [serverUrl, token]);
|
|
1734
1747
|
const handleDismiss = useCallback3(async () => {
|