@mcp-use/client 2.3.0 → 2.3.1-canary.0
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-browser.js
CHANGED
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -1905,7 +1905,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1905
1905
|
};
|
|
1906
1906
|
|
|
1907
1907
|
// src/utils/version.ts
|
|
1908
|
-
var VERSION = "2.3.0";
|
|
1908
|
+
var VERSION = "2.3.1-canary.0";
|
|
1909
1909
|
function getPackageVersion() {
|
|
1910
1910
|
return VERSION;
|
|
1911
1911
|
}
|
|
@@ -8635,14 +8635,27 @@ function CloseIcon() {
|
|
|
8635
8635
|
/* @__PURE__ */ React2.createElement("path", { d: "m6 6 12 12" })
|
|
8636
8636
|
);
|
|
8637
8637
|
}
|
|
8638
|
-
function waitForSandboxProxyReady(iframe) {
|
|
8639
|
-
return new Promise((resolve) => {
|
|
8638
|
+
function waitForSandboxProxyReady(iframe, options) {
|
|
8639
|
+
return new Promise((resolve, reject) => {
|
|
8640
|
+
const cleanup = () => {
|
|
8641
|
+
window.removeEventListener("message", listener);
|
|
8642
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
8643
|
+
};
|
|
8640
8644
|
const listener = (event) => {
|
|
8641
8645
|
if (event.source === iframe.contentWindow && event.data?.method === SANDBOX_PROXY_READY) {
|
|
8642
|
-
|
|
8646
|
+
cleanup();
|
|
8643
8647
|
resolve();
|
|
8644
8648
|
}
|
|
8645
8649
|
};
|
|
8650
|
+
const onAbort = () => {
|
|
8651
|
+
cleanup();
|
|
8652
|
+
reject(new Error("View sandbox initialization was aborted"));
|
|
8653
|
+
};
|
|
8654
|
+
if (options?.signal?.aborted) {
|
|
8655
|
+
onAbort();
|
|
8656
|
+
return;
|
|
8657
|
+
}
|
|
8658
|
+
options?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
8646
8659
|
window.addEventListener("message", listener);
|
|
8647
8660
|
});
|
|
8648
8661
|
}
|
|
@@ -8958,6 +8971,7 @@ function ViewRendererBase({
|
|
|
8958
8971
|
if (!iframe) return;
|
|
8959
8972
|
let disposed = false;
|
|
8960
8973
|
let bridge = null;
|
|
8974
|
+
const abortController = new AbortController();
|
|
8961
8975
|
const run = async () => {
|
|
8962
8976
|
try {
|
|
8963
8977
|
onLifecycleChangeRef.current?.({ status: "connecting" });
|
|
@@ -8969,17 +8983,23 @@ function ViewRendererBase({
|
|
|
8969
8983
|
if (allowAttribute) {
|
|
8970
8984
|
iframe.setAttribute("allow", allowAttribute);
|
|
8971
8985
|
}
|
|
8972
|
-
const readyPromise = waitForSandboxProxyReady(iframe);
|
|
8973
8986
|
if (activeSandboxUrl.protocol === "blob:") {
|
|
8974
8987
|
const response = await fetch(activeSandboxUrl.href);
|
|
8975
8988
|
const sandboxHtml = await response.text();
|
|
8976
|
-
if (disposed) return;
|
|
8989
|
+
if (disposed || abortController.signal.aborted) return;
|
|
8990
|
+
const readyPromise = waitForSandboxProxyReady(iframe, {
|
|
8991
|
+
signal: abortController.signal
|
|
8992
|
+
});
|
|
8977
8993
|
iframe.srcdoc = sandboxHtml;
|
|
8994
|
+
await readyPromise;
|
|
8978
8995
|
} else {
|
|
8996
|
+
const readyPromise = waitForSandboxProxyReady(iframe, {
|
|
8997
|
+
signal: abortController.signal
|
|
8998
|
+
});
|
|
8979
8999
|
iframe.src = activeSandboxUrl.href;
|
|
9000
|
+
await readyPromise;
|
|
8980
9001
|
}
|
|
8981
|
-
|
|
8982
|
-
if (disposed) return;
|
|
9002
|
+
if (disposed || abortController.signal.aborted) return;
|
|
8983
9003
|
const capabilities = {
|
|
8984
9004
|
...effectiveHostCapabilities,
|
|
8985
9005
|
sandbox: {
|
|
@@ -9190,7 +9210,7 @@ function ViewRendererBase({
|
|
|
9190
9210
|
await publishAppTools();
|
|
9191
9211
|
onLifecycleChangeRef.current?.({ status: "ready" });
|
|
9192
9212
|
} catch (err) {
|
|
9193
|
-
if (!disposed) {
|
|
9213
|
+
if (!disposed && !abortController.signal.aborted) {
|
|
9194
9214
|
const message = err instanceof Error ? err.message : "Failed to connect view";
|
|
9195
9215
|
setLoadError(message);
|
|
9196
9216
|
onErrorRef.current?.(message);
|
|
@@ -9201,6 +9221,7 @@ function ViewRendererBase({
|
|
|
9201
9221
|
void run();
|
|
9202
9222
|
return () => {
|
|
9203
9223
|
disposed = true;
|
|
9224
|
+
abortController.abort();
|
|
9204
9225
|
const toClose = bridge;
|
|
9205
9226
|
bridgeRef.current = null;
|
|
9206
9227
|
onAppToolsChangedRef.current?.(null);
|