@mcp-use/client 2.3.2-canary.0 → 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.
@@ -128,7 +128,7 @@ var Logger = class {
128
128
  var logger = Logger.get();
129
129
 
130
130
  // src/utils/version.ts
131
- var VERSION = "2.3.2-canary.0";
131
+ var VERSION = "2.3.3-canary.0";
132
132
  function getPackageVersion() {
133
133
  return VERSION;
134
134
  }
package/dist/index.js CHANGED
@@ -1559,7 +1559,7 @@ init_connector_telemetry();
1559
1559
  init_logging();
1560
1560
 
1561
1561
  // src/utils/version.ts
1562
- var VERSION = "2.3.2-canary.0";
1562
+ var VERSION = "2.3.3-canary.0";
1563
1563
  function getPackageVersion() {
1564
1564
  return VERSION;
1565
1565
  }
@@ -1880,7 +1880,7 @@ var HttpConnector = class extends BaseConnector {
1880
1880
  };
1881
1881
 
1882
1882
  // src/utils/version.ts
1883
- var VERSION = "2.3.2-canary.0";
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 useRef4,
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
- if (typeof document === "undefined") return;
8542
+ const id = widgetIdRef.current;
8511
8543
  if (displayMode === "pip" || displayMode === "fullscreen") {
8512
- document.documentElement.setAttribute(
8513
- WIDGET_DISPLAY_MODE_ATTR,
8514
- displayMode
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
- document.documentElement.removeAttribute(WIDGET_DISPLAY_MODE_ATTR);
8534
- document.documentElement.removeAttribute(WIDGET_FULLSCREEN_DOCUMENT_ATTR);
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 = useRef4(null);
8738
- const bridgeRef = useRef4(null);
8739
- const containerRef = useRef4(null);
8740
- const pendingBlobRevocationsRef = useRef4(
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 = useRef4(
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 = useRef4(effectiveHostContext);
8809
+ const hostContextRef = useRef5(effectiveHostContext);
8792
8810
  hostContextRef.current = effectiveHostContext;
8793
- const onMessageRef = useRef4(onMessage);
8811
+ const onMessageRef = useRef5(onMessage);
8794
8812
  onMessageRef.current = onMessage;
8795
- const onSamplingRequestRef = useRef4(onSamplingRequest);
8813
+ const onSamplingRequestRef = useRef5(onSamplingRequest);
8796
8814
  onSamplingRequestRef.current = onSamplingRequest;
8797
- const onDownloadFileRef = useRef4(onDownloadFile);
8815
+ const onDownloadFileRef = useRef5(onDownloadFile);
8798
8816
  onDownloadFileRef.current = onDownloadFile;
8799
- const onAppToolsChangedRef = useRef4(onAppToolsChanged);
8817
+ const onAppToolsChangedRef = useRef5(onAppToolsChanged);
8800
8818
  onAppToolsChangedRef.current = onAppToolsChanged;
8801
- const toolInputRef = useRef4(toolInput);
8819
+ const toolInputRef = useRef5(toolInput);
8802
8820
  toolInputRef.current = toolInput;
8803
- const partialToolInputRef = useRef4(partialToolInput);
8821
+ const partialToolInputRef = useRef5(partialToolInput);
8804
8822
  partialToolInputRef.current = partialToolInput;
8805
- const toolOutputRef = useRef4(toolOutput);
8823
+ const toolOutputRef = useRef5(toolOutput);
8806
8824
  toolOutputRef.current = toolOutput;
8807
- const customPropsRef = useRef4(customProps);
8825
+ const customPropsRef = useRef5(customProps);
8808
8826
  customPropsRef.current = customProps;
8809
- const onResourceResolvedRef = useRef4(onResourceResolved);
8827
+ const onResourceResolvedRef = useRef5(onResourceResolved);
8810
8828
  onResourceResolvedRef.current = onResourceResolved;
8811
- const onModelContextUpdateRef = useRef4(onModelContextUpdate);
8829
+ const onModelContextUpdateRef = useRef5(onModelContextUpdate);
8812
8830
  onModelContextUpdateRef.current = onModelContextUpdate;
8813
- const onLogRef = useRef4(onLog);
8831
+ const onLogRef = useRef5(onLog);
8814
8832
  onLogRef.current = onLog;
8815
- const onErrorRef = useRef4(onError);
8833
+ const onErrorRef = useRef5(onError);
8816
8834
  onErrorRef.current = onError;
8817
- const onCspViolationRef = useRef4(onCspViolation);
8835
+ const onCspViolationRef = useRef5(onCspViolation);
8818
8836
  onCspViolationRef.current = onCspViolation;
8819
- const onReadyRef = useRef4(onReady);
8837
+ const onReadyRef = useRef5(onReady);
8820
8838
  onReadyRef.current = onReady;
8821
- const onLifecycleChangeRef = useRef4(onLifecycleChange);
8839
+ const onLifecycleChangeRef = useRef5(onLifecycleChange);
8822
8840
  onLifecycleChangeRef.current = onLifecycleChange;
8823
- const onInlineHeightChangeRef = useRef4(onInlineHeightChange);
8841
+ const onInlineHeightChangeRef = useRef5(onInlineHeightChange);
8824
8842
  onInlineHeightChangeRef.current = onInlineHeightChange;
8825
- const sandboxUrlRef = useRef4(sandboxUrl);
8843
+ const sandboxUrlRef = useRef5(sandboxUrl);
8826
8844
  sandboxUrlRef.current = sandboxUrl;
8827
- const cspModeRef = useRef4(cspMode);
8845
+ const cspModeRef = useRef5(cspMode);
8828
8846
  cspModeRef.current = cspMode;
8829
- const mockOpenAiFileApisRef = useRef4(mockOpenAiFileApis);
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 = useRef4(handleDisplayModeChange);
8878
+ const handleDisplayModeChangeRef = useRef5(handleDisplayModeChange);
8861
8879
  handleDisplayModeChangeRef.current = handleDisplayModeChange;
8862
- const displayModeRef = useRef4(displayMode);
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 = useRef4(false);
9332
+ const readyFiredRef = useRef5(false);
9315
9333
  useEffect5(() => {
9316
9334
  if (readyFiredRef.current || initCount === 0) return;
9317
9335
  readyFiredRef.current = true;