@mcp-use/client 2.3.2 → 2.3.3-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/.tsbuildinfo +1 -1
- package/dist/index-browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +72 -54
- package/dist/react/index.js.map +1 -1
- package/dist/react/view/use-display-mode.d.ts +2 -0
- package/dist/react/view/use-display-mode.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index-browser.js
CHANGED
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -1880,7 +1880,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1880
1880
|
};
|
|
1881
1881
|
|
|
1882
1882
|
// src/utils/version.ts
|
|
1883
|
-
var VERSION = "2.3.
|
|
1883
|
+
var VERSION = "2.3.3-canary.0";
|
|
1884
1884
|
function getPackageVersion() {
|
|
1885
1885
|
return VERSION;
|
|
1886
1886
|
}
|
|
@@ -7843,7 +7843,7 @@ import React2, {
|
|
|
7843
7843
|
useCallback as useCallback6,
|
|
7844
7844
|
useEffect as useEffect5,
|
|
7845
7845
|
useMemo as useMemo3,
|
|
7846
|
-
useRef as
|
|
7846
|
+
useRef as useRef5,
|
|
7847
7847
|
useState as useState4
|
|
7848
7848
|
} from "react";
|
|
7849
7849
|
|
|
@@ -8493,7 +8493,7 @@ function buildSandboxProxyBlobHtml(search) {
|
|
|
8493
8493
|
}
|
|
8494
8494
|
|
|
8495
8495
|
// src/react/view/use-display-mode.ts
|
|
8496
|
-
import { useCallback as useCallback5, useEffect as useEffect4 } from "react";
|
|
8496
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
8497
8497
|
var SHELL_BASE = "w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background";
|
|
8498
8498
|
var WIDGET_FULLSCREEN_OVERLAY_CLASSES = `fixed inset-0 z-[200] ${SHELL_BASE}`;
|
|
8499
8499
|
var WIDGET_PIP_SHELL_CLASSES = [
|
|
@@ -8505,33 +8505,51 @@ var WIDGET_PIP_SHELL_CLASSES = [
|
|
|
8505
8505
|
].join(" ");
|
|
8506
8506
|
var WIDGET_FULLSCREEN_DOCUMENT_ATTR = "data-mcp-widget-fullscreen";
|
|
8507
8507
|
var WIDGET_DISPLAY_MODE_ATTR = "data-mcp-widget-display-mode";
|
|
8508
|
+
var activeWidgetDisplayModes = /* @__PURE__ */ new Map();
|
|
8509
|
+
function syncDocumentDisplayModeAttributes() {
|
|
8510
|
+
if (typeof document === "undefined") return;
|
|
8511
|
+
let hasFullscreen = false;
|
|
8512
|
+
let hasPip = false;
|
|
8513
|
+
for (const mode of activeWidgetDisplayModes.values()) {
|
|
8514
|
+
if (mode === "fullscreen") {
|
|
8515
|
+
hasFullscreen = true;
|
|
8516
|
+
break;
|
|
8517
|
+
}
|
|
8518
|
+
if (mode === "pip") {
|
|
8519
|
+
hasPip = true;
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8522
|
+
if (hasFullscreen) {
|
|
8523
|
+
document.documentElement.setAttribute(
|
|
8524
|
+
WIDGET_DISPLAY_MODE_ATTR,
|
|
8525
|
+
"fullscreen"
|
|
8526
|
+
);
|
|
8527
|
+
document.documentElement.setAttribute(WIDGET_FULLSCREEN_DOCUMENT_ATTR, "");
|
|
8528
|
+
} else if (hasPip) {
|
|
8529
|
+
document.documentElement.setAttribute(WIDGET_DISPLAY_MODE_ATTR, "pip");
|
|
8530
|
+
document.documentElement.removeAttribute(WIDGET_FULLSCREEN_DOCUMENT_ATTR);
|
|
8531
|
+
} else {
|
|
8532
|
+
document.documentElement.removeAttribute(WIDGET_DISPLAY_MODE_ATTR);
|
|
8533
|
+
document.documentElement.removeAttribute(WIDGET_FULLSCREEN_DOCUMENT_ATTR);
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8508
8536
|
function useWidgetDisplayModeDocumentChrome(displayMode) {
|
|
8537
|
+
const widgetIdRef = useRef4(null);
|
|
8538
|
+
if (widgetIdRef.current === null) {
|
|
8539
|
+
widgetIdRef.current = /* @__PURE__ */ Symbol("mcp-widget-display-mode");
|
|
8540
|
+
}
|
|
8509
8541
|
useEffect4(() => {
|
|
8510
|
-
|
|
8542
|
+
const id = widgetIdRef.current;
|
|
8511
8543
|
if (displayMode === "pip" || displayMode === "fullscreen") {
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
);
|
|
8516
|
-
if (displayMode === "fullscreen") {
|
|
8517
|
-
document.documentElement.setAttribute(
|
|
8518
|
-
WIDGET_FULLSCREEN_DOCUMENT_ATTR,
|
|
8519
|
-
""
|
|
8520
|
-
);
|
|
8521
|
-
} else {
|
|
8522
|
-
document.documentElement.removeAttribute(
|
|
8523
|
-
WIDGET_FULLSCREEN_DOCUMENT_ATTR
|
|
8524
|
-
);
|
|
8525
|
-
}
|
|
8526
|
-
return () => {
|
|
8527
|
-
document.documentElement.removeAttribute(WIDGET_DISPLAY_MODE_ATTR);
|
|
8528
|
-
document.documentElement.removeAttribute(
|
|
8529
|
-
WIDGET_FULLSCREEN_DOCUMENT_ATTR
|
|
8530
|
-
);
|
|
8531
|
-
};
|
|
8544
|
+
activeWidgetDisplayModes.set(id, displayMode);
|
|
8545
|
+
} else {
|
|
8546
|
+
activeWidgetDisplayModes.delete(id);
|
|
8532
8547
|
}
|
|
8533
|
-
|
|
8534
|
-
|
|
8548
|
+
syncDocumentDisplayModeAttributes();
|
|
8549
|
+
return () => {
|
|
8550
|
+
activeWidgetDisplayModes.delete(id);
|
|
8551
|
+
syncDocumentDisplayModeAttributes();
|
|
8552
|
+
};
|
|
8535
8553
|
}, [displayMode]);
|
|
8536
8554
|
}
|
|
8537
8555
|
function useViewDisplayModeControls({
|
|
@@ -8734,13 +8752,13 @@ function ViewRendererBase({
|
|
|
8734
8752
|
invoking,
|
|
8735
8753
|
invoked
|
|
8736
8754
|
}) {
|
|
8737
|
-
const iframeRef =
|
|
8738
|
-
const bridgeRef =
|
|
8739
|
-
const containerRef =
|
|
8740
|
-
const pendingBlobRevocationsRef =
|
|
8755
|
+
const iframeRef = useRef5(null);
|
|
8756
|
+
const bridgeRef = useRef5(null);
|
|
8757
|
+
const containerRef = useRef5(null);
|
|
8758
|
+
const pendingBlobRevocationsRef = useRef5(
|
|
8741
8759
|
/* @__PURE__ */ new Map()
|
|
8742
8760
|
);
|
|
8743
|
-
const connectionRef =
|
|
8761
|
+
const connectionRef = useRef5(
|
|
8744
8762
|
source.kind === "live" ? source.connection : null
|
|
8745
8763
|
);
|
|
8746
8764
|
const [resolved, setResolved] = useState4(null);
|
|
@@ -8788,45 +8806,45 @@ function ViewRendererBase({
|
|
|
8788
8806
|
if (hostContext.displayMode === displayMode) return hostContext;
|
|
8789
8807
|
return { ...hostContext, displayMode };
|
|
8790
8808
|
}, [hostContext, displayMode]);
|
|
8791
|
-
const hostContextRef =
|
|
8809
|
+
const hostContextRef = useRef5(effectiveHostContext);
|
|
8792
8810
|
hostContextRef.current = effectiveHostContext;
|
|
8793
|
-
const onMessageRef =
|
|
8811
|
+
const onMessageRef = useRef5(onMessage);
|
|
8794
8812
|
onMessageRef.current = onMessage;
|
|
8795
|
-
const onSamplingRequestRef =
|
|
8813
|
+
const onSamplingRequestRef = useRef5(onSamplingRequest);
|
|
8796
8814
|
onSamplingRequestRef.current = onSamplingRequest;
|
|
8797
|
-
const onDownloadFileRef =
|
|
8815
|
+
const onDownloadFileRef = useRef5(onDownloadFile);
|
|
8798
8816
|
onDownloadFileRef.current = onDownloadFile;
|
|
8799
|
-
const onAppToolsChangedRef =
|
|
8817
|
+
const onAppToolsChangedRef = useRef5(onAppToolsChanged);
|
|
8800
8818
|
onAppToolsChangedRef.current = onAppToolsChanged;
|
|
8801
|
-
const toolInputRef =
|
|
8819
|
+
const toolInputRef = useRef5(toolInput);
|
|
8802
8820
|
toolInputRef.current = toolInput;
|
|
8803
|
-
const partialToolInputRef =
|
|
8821
|
+
const partialToolInputRef = useRef5(partialToolInput);
|
|
8804
8822
|
partialToolInputRef.current = partialToolInput;
|
|
8805
|
-
const toolOutputRef =
|
|
8823
|
+
const toolOutputRef = useRef5(toolOutput);
|
|
8806
8824
|
toolOutputRef.current = toolOutput;
|
|
8807
|
-
const customPropsRef =
|
|
8825
|
+
const customPropsRef = useRef5(customProps);
|
|
8808
8826
|
customPropsRef.current = customProps;
|
|
8809
|
-
const onResourceResolvedRef =
|
|
8827
|
+
const onResourceResolvedRef = useRef5(onResourceResolved);
|
|
8810
8828
|
onResourceResolvedRef.current = onResourceResolved;
|
|
8811
|
-
const onModelContextUpdateRef =
|
|
8829
|
+
const onModelContextUpdateRef = useRef5(onModelContextUpdate);
|
|
8812
8830
|
onModelContextUpdateRef.current = onModelContextUpdate;
|
|
8813
|
-
const onLogRef =
|
|
8831
|
+
const onLogRef = useRef5(onLog);
|
|
8814
8832
|
onLogRef.current = onLog;
|
|
8815
|
-
const onErrorRef =
|
|
8833
|
+
const onErrorRef = useRef5(onError);
|
|
8816
8834
|
onErrorRef.current = onError;
|
|
8817
|
-
const onCspViolationRef =
|
|
8835
|
+
const onCspViolationRef = useRef5(onCspViolation);
|
|
8818
8836
|
onCspViolationRef.current = onCspViolation;
|
|
8819
|
-
const onReadyRef =
|
|
8837
|
+
const onReadyRef = useRef5(onReady);
|
|
8820
8838
|
onReadyRef.current = onReady;
|
|
8821
|
-
const onLifecycleChangeRef =
|
|
8839
|
+
const onLifecycleChangeRef = useRef5(onLifecycleChange);
|
|
8822
8840
|
onLifecycleChangeRef.current = onLifecycleChange;
|
|
8823
|
-
const onInlineHeightChangeRef =
|
|
8841
|
+
const onInlineHeightChangeRef = useRef5(onInlineHeightChange);
|
|
8824
8842
|
onInlineHeightChangeRef.current = onInlineHeightChange;
|
|
8825
|
-
const sandboxUrlRef =
|
|
8843
|
+
const sandboxUrlRef = useRef5(sandboxUrl);
|
|
8826
8844
|
sandboxUrlRef.current = sandboxUrl;
|
|
8827
|
-
const cspModeRef =
|
|
8845
|
+
const cspModeRef = useRef5(cspMode);
|
|
8828
8846
|
cspModeRef.current = cspMode;
|
|
8829
|
-
const mockOpenAiFileApisRef =
|
|
8847
|
+
const mockOpenAiFileApisRef = useRef5(mockOpenAiFileApis);
|
|
8830
8848
|
mockOpenAiFileApisRef.current = mockOpenAiFileApis;
|
|
8831
8849
|
const resolveSandboxUrl = useCallback6((next) => {
|
|
8832
8850
|
const custom = sandboxUrlRef.current;
|
|
@@ -8857,9 +8875,9 @@ function ViewRendererBase({
|
|
|
8857
8875
|
displayMode,
|
|
8858
8876
|
setDisplayMode
|
|
8859
8877
|
});
|
|
8860
|
-
const handleDisplayModeChangeRef =
|
|
8878
|
+
const handleDisplayModeChangeRef = useRef5(handleDisplayModeChange);
|
|
8861
8879
|
handleDisplayModeChangeRef.current = handleDisplayModeChange;
|
|
8862
|
-
const displayModeRef =
|
|
8880
|
+
const displayModeRef = useRef5(displayMode);
|
|
8863
8881
|
displayModeRef.current = displayMode;
|
|
8864
8882
|
const liveResourceUri = source.kind === "live" ? source.resourceUri : void 0;
|
|
8865
8883
|
const preloadedHtml = source.kind === "preloaded" ? source.html : void 0;
|
|
@@ -9311,7 +9329,7 @@ function ViewRendererBase({
|
|
|
9311
9329
|
if (!bridge || initCount === 0 || !cancelled) return;
|
|
9312
9330
|
void bridge.sendToolCancelled({ reason: "Cancelled by user" });
|
|
9313
9331
|
}, [cancelled, initCount]);
|
|
9314
|
-
const readyFiredRef =
|
|
9332
|
+
const readyFiredRef = useRef5(false);
|
|
9315
9333
|
useEffect5(() => {
|
|
9316
9334
|
if (readyFiredRef.current || initCount === 0) return;
|
|
9317
9335
|
readyFiredRef.current = true;
|