mcp-use 1.5.0-canary.0 → 1.5.0-canary.2
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/{chunk-RE7EYFDV.js → chunk-GPAOZN2F.js} +459 -967
- package/dist/{chunk-GRLCLVAK.js → chunk-UT7O4SIJ.js} +14 -4
- package/dist/index.cjs +500 -998
- package/dist/index.js +12 -6
- package/dist/src/browser.cjs +14 -4
- package/dist/src/browser.js +1 -1
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +5 -0
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/react/ErrorBoundary.d.ts +24 -0
- package/dist/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/src/react/Image.d.ts +11 -0
- package/dist/src/react/Image.d.ts.map +1 -0
- package/dist/src/react/McpUseProvider.d.ts +46 -0
- package/dist/src/react/McpUseProvider.d.ts.map +1 -0
- package/dist/src/react/ThemeProvider.d.ts +14 -0
- package/dist/src/react/ThemeProvider.d.ts.map +1 -0
- package/dist/src/react/WidgetControls.d.ts +44 -0
- package/dist/src/react/WidgetControls.d.ts.map +1 -0
- package/dist/src/react/index.cjs +500 -998
- package/dist/src/react/index.d.ts +9 -6
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +12 -6
- package/dist/src/react/types.d.ts +2 -0
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/react/useWidget.d.ts.map +1 -1
- package/dist/src/react/widget-types.d.ts +6 -0
- package/dist/src/react/widget-types.d.ts.map +1 -1
- package/dist/src/server/connect-adapter.d.ts.map +1 -1
- package/dist/src/server/index.cjs +232 -21
- package/dist/src/server/index.js +232 -21
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/src/react/WidgetDebugger.d.ts +0 -31
- package/dist/src/react/WidgetDebugger.d.ts.map +0 -1
- package/dist/src/react/WidgetFullscreenWrapper.d.ts +0 -32
- package/dist/src/react/WidgetFullscreenWrapper.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient,
|
|
3
3
|
BrowserOAuthClientProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UT7O4SIJ.js";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -42,8 +42,9 @@ function useMcp(options) {
|
|
|
42
42
|
onPopupWindow,
|
|
43
43
|
timeout = 3e4,
|
|
44
44
|
// 30 seconds default for connection timeout
|
|
45
|
-
sseReadTimeout = 3e5
|
|
45
|
+
sseReadTimeout = 3e5,
|
|
46
46
|
// 5 minutes default for SSE read timeout
|
|
47
|
+
wrapTransport
|
|
47
48
|
} = options;
|
|
48
49
|
const [state, setState] = useState("discovering");
|
|
49
50
|
const [tools, setTools] = useState([]);
|
|
@@ -194,8 +195,17 @@ function useMcp(options) {
|
|
|
194
195
|
}
|
|
195
196
|
clientRef.current.addServer(serverName, {
|
|
196
197
|
...serverConfig,
|
|
197
|
-
authProvider: authProviderRef.current
|
|
198
|
+
authProvider: authProviderRef.current,
|
|
198
199
|
// ← SDK handles OAuth automatically!
|
|
200
|
+
wrapTransport: wrapTransport ? (transport) => {
|
|
201
|
+
console.log(
|
|
202
|
+
"[useMcp] Applying transport wrapper for server:",
|
|
203
|
+
serverName,
|
|
204
|
+
"url:",
|
|
205
|
+
url
|
|
206
|
+
);
|
|
207
|
+
return wrapTransport(transport, url);
|
|
208
|
+
} : void 0
|
|
199
209
|
});
|
|
200
210
|
const session = await clientRef.current.createSession(serverName);
|
|
201
211
|
await session.initialize();
|
|
@@ -609,6 +619,52 @@ function useMcp(options) {
|
|
|
609
619
|
}
|
|
610
620
|
__name(useMcp, "useMcp");
|
|
611
621
|
|
|
622
|
+
// src/react/ErrorBoundary.tsx
|
|
623
|
+
import React from "react";
|
|
624
|
+
var ErrorBoundary = class extends React.Component {
|
|
625
|
+
static {
|
|
626
|
+
__name(this, "ErrorBoundary");
|
|
627
|
+
}
|
|
628
|
+
constructor(props) {
|
|
629
|
+
super(props);
|
|
630
|
+
this.state = { hasError: false, error: null };
|
|
631
|
+
}
|
|
632
|
+
static getDerivedStateFromError(error) {
|
|
633
|
+
return { hasError: true, error };
|
|
634
|
+
}
|
|
635
|
+
componentDidCatch(error, errorInfo) {
|
|
636
|
+
console.error("Widget Error:", error, errorInfo);
|
|
637
|
+
}
|
|
638
|
+
render() {
|
|
639
|
+
if (this.state.hasError) {
|
|
640
|
+
return /* @__PURE__ */ React.createElement("div", { className: "p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100" }, /* @__PURE__ */ React.createElement("h3", { className: "font-bold mb-2" }, "Widget Error"), /* @__PURE__ */ React.createElement("pre", { className: "text-sm whitespace-pre-wrap" }, this.state.error?.message));
|
|
641
|
+
}
|
|
642
|
+
return this.props.children;
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/react/Image.tsx
|
|
647
|
+
import React2 from "react";
|
|
648
|
+
var Image = /* @__PURE__ */ __name(({ src, ...props }) => {
|
|
649
|
+
const publicUrl = typeof window !== "undefined" && window.__mcpPublicUrl ? window.__mcpPublicUrl : "";
|
|
650
|
+
const getFinalSrc = /* @__PURE__ */ __name((source) => {
|
|
651
|
+
if (!source) return source;
|
|
652
|
+
if (source.startsWith("http://") || source.startsWith("https://") || source.startsWith("data:")) {
|
|
653
|
+
return source;
|
|
654
|
+
}
|
|
655
|
+
if (!publicUrl) {
|
|
656
|
+
return source;
|
|
657
|
+
}
|
|
658
|
+
const cleanSrc = source.startsWith("/") ? source.slice(1) : source;
|
|
659
|
+
return `${publicUrl}/${cleanSrc}`;
|
|
660
|
+
}, "getFinalSrc");
|
|
661
|
+
const finalSrc = getFinalSrc(src);
|
|
662
|
+
return /* @__PURE__ */ React2.createElement("img", { src: finalSrc, ...props });
|
|
663
|
+
}, "Image");
|
|
664
|
+
|
|
665
|
+
// src/react/ThemeProvider.tsx
|
|
666
|
+
import React3, { useEffect as useEffect3, useLayoutEffect, useState as useState3 } from "react";
|
|
667
|
+
|
|
612
668
|
// src/react/useWidget.ts
|
|
613
669
|
import {
|
|
614
670
|
useCallback as useCallback2,
|
|
@@ -687,8 +743,9 @@ function useWidget(defaultProps) {
|
|
|
687
743
|
const provider = useMemo(() => {
|
|
688
744
|
return isOpenAiAvailable ? "openai" : "mcp-ui";
|
|
689
745
|
}, [isOpenAiAvailable]);
|
|
746
|
+
const searchString = typeof window !== "undefined" ? window.location.search : "";
|
|
690
747
|
const urlParams = useMemo(() => {
|
|
691
|
-
const urlParams2 = new URLSearchParams(
|
|
748
|
+
const urlParams2 = new URLSearchParams(searchString);
|
|
692
749
|
if (urlParams2.has("mcpUseParams")) {
|
|
693
750
|
return JSON.parse(urlParams2.get("mcpUseParams"));
|
|
694
751
|
}
|
|
@@ -697,7 +754,7 @@ function useWidget(defaultProps) {
|
|
|
697
754
|
toolOutput: {},
|
|
698
755
|
toolId: ""
|
|
699
756
|
};
|
|
700
|
-
}, [
|
|
757
|
+
}, [searchString]);
|
|
701
758
|
const toolInput = provider === "openai" ? useOpenAiGlobal("toolInput") : urlParams.toolInput;
|
|
702
759
|
const toolOutput = provider === "openai" ? useOpenAiGlobal("toolOutput") : urlParams.toolOutput;
|
|
703
760
|
const toolResponseMetadata = useOpenAiGlobal("toolResponseMetadata");
|
|
@@ -708,6 +765,12 @@ function useWidget(defaultProps) {
|
|
|
708
765
|
const maxHeight = useOpenAiGlobal("maxHeight");
|
|
709
766
|
const userAgent = useOpenAiGlobal("userAgent");
|
|
710
767
|
const locale = useOpenAiGlobal("locale");
|
|
768
|
+
const mcp_url = useMemo(() => {
|
|
769
|
+
if (typeof window !== "undefined" && window.__mcpPublicUrl) {
|
|
770
|
+
return window.__mcpPublicUrl.replace(/\/mcp-use\/public$/, "");
|
|
771
|
+
}
|
|
772
|
+
return "";
|
|
773
|
+
}, []);
|
|
711
774
|
const [localWidgetState, setLocalWidgetState] = useState2(null);
|
|
712
775
|
useEffect2(() => {
|
|
713
776
|
if (widgetState !== void 0) {
|
|
@@ -749,14 +812,15 @@ function useWidget(defaultProps) {
|
|
|
749
812
|
);
|
|
750
813
|
const setState = useCallback2(
|
|
751
814
|
async (state) => {
|
|
752
|
-
const newState = typeof state === "function" ? state(localWidgetState) : state;
|
|
753
815
|
if (!window.openai?.setWidgetState) {
|
|
754
816
|
throw new Error("window.openai.setWidgetState is not available");
|
|
755
817
|
}
|
|
818
|
+
const currentState = widgetState !== void 0 ? widgetState : localWidgetState;
|
|
819
|
+
const newState = typeof state === "function" ? state(currentState) : state;
|
|
756
820
|
setLocalWidgetState(newState);
|
|
757
821
|
return window.openai.setWidgetState(newState);
|
|
758
822
|
},
|
|
759
|
-
[localWidgetState]
|
|
823
|
+
[widgetState, localWidgetState]
|
|
760
824
|
);
|
|
761
825
|
return {
|
|
762
826
|
// Props and state (with defaults)
|
|
@@ -775,6 +839,7 @@ function useWidget(defaultProps) {
|
|
|
775
839
|
capabilities: { hover: true, touch: false }
|
|
776
840
|
},
|
|
777
841
|
locale: locale || "en",
|
|
842
|
+
mcp_url,
|
|
778
843
|
// Actions
|
|
779
844
|
callTool,
|
|
780
845
|
sendFollowUpMessage,
|
|
@@ -806,283 +871,49 @@ function useWidgetState(defaultState) {
|
|
|
806
871
|
}
|
|
807
872
|
__name(useWidgetState, "useWidgetState");
|
|
808
873
|
|
|
809
|
-
// src/react/
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const [isHovered, setIsHovered] = useState3(false);
|
|
820
|
-
const containerRef = useRef2(null);
|
|
821
|
-
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
822
|
-
const isPip = displayMode === "pip" && isAvailable;
|
|
823
|
-
const isDark = theme === "dark";
|
|
824
|
-
const buttonBg = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.7)";
|
|
825
|
-
const buttonBgHover = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.9)";
|
|
826
|
-
const buttonColor = "white";
|
|
827
|
-
const getPositionStyles = /* @__PURE__ */ __name(() => {
|
|
828
|
-
const baseOffset = 16;
|
|
829
|
-
const topOffset = safeArea?.insets?.top ? `${Math.max(baseOffset, safeArea.insets.top + 8)}px` : `${baseOffset}px`;
|
|
830
|
-
const rightOffset = safeArea?.insets?.right ? `${Math.max(baseOffset, safeArea.insets.right + 8)}px` : `${baseOffset}px`;
|
|
831
|
-
const bottomOffset = safeArea?.insets?.bottom ? `${Math.max(baseOffset, safeArea.insets.bottom + 8)}px` : `${baseOffset}px`;
|
|
832
|
-
const leftOffset = safeArea?.insets?.left ? `${Math.max(baseOffset, safeArea.insets.left + 8)}px` : `${baseOffset}px`;
|
|
833
|
-
const styles = {
|
|
834
|
-
position: "absolute",
|
|
835
|
-
zIndex: 1e3,
|
|
836
|
-
display: "flex",
|
|
837
|
-
gap: "8px",
|
|
838
|
-
opacity: isHovered ? 1 : 0,
|
|
839
|
-
transition: "opacity 0.2s ease-in-out",
|
|
840
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
841
|
-
};
|
|
842
|
-
switch (position) {
|
|
843
|
-
case "top-left":
|
|
844
|
-
styles.top = topOffset;
|
|
845
|
-
styles.left = leftOffset;
|
|
846
|
-
break;
|
|
847
|
-
case "top-center":
|
|
848
|
-
styles.top = topOffset;
|
|
849
|
-
styles.left = "50%";
|
|
850
|
-
styles.transform = "translateX(-50%)";
|
|
851
|
-
break;
|
|
852
|
-
case "top-right":
|
|
853
|
-
styles.top = topOffset;
|
|
854
|
-
styles.right = rightOffset;
|
|
855
|
-
break;
|
|
856
|
-
case "center-left":
|
|
857
|
-
styles.top = "50%";
|
|
858
|
-
styles.left = leftOffset;
|
|
859
|
-
styles.transform = "translateY(-50%)";
|
|
860
|
-
break;
|
|
861
|
-
case "center-right":
|
|
862
|
-
styles.top = "50%";
|
|
863
|
-
styles.right = rightOffset;
|
|
864
|
-
styles.transform = "translateY(-50%)";
|
|
865
|
-
break;
|
|
866
|
-
case "bottom-left":
|
|
867
|
-
styles.bottom = bottomOffset;
|
|
868
|
-
styles.left = leftOffset;
|
|
869
|
-
break;
|
|
870
|
-
case "bottom-center":
|
|
871
|
-
styles.bottom = bottomOffset;
|
|
872
|
-
styles.left = "50%";
|
|
873
|
-
styles.transform = "translateX(-50%)";
|
|
874
|
-
break;
|
|
875
|
-
case "bottom-right":
|
|
876
|
-
styles.bottom = bottomOffset;
|
|
877
|
-
styles.right = rightOffset;
|
|
878
|
-
break;
|
|
879
|
-
default:
|
|
880
|
-
styles.top = topOffset;
|
|
881
|
-
styles.right = rightOffset;
|
|
882
|
-
break;
|
|
874
|
+
// src/react/ThemeProvider.tsx
|
|
875
|
+
var ThemeProvider = /* @__PURE__ */ __name(({
|
|
876
|
+
children
|
|
877
|
+
}) => {
|
|
878
|
+
const { theme, isAvailable } = useWidget();
|
|
879
|
+
console.log("theme", theme);
|
|
880
|
+
const [systemPreference, setSystemPreference] = useState3(
|
|
881
|
+
() => {
|
|
882
|
+
if (typeof window === "undefined") return "light";
|
|
883
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
883
884
|
}
|
|
884
|
-
|
|
885
|
-
}, "getPositionStyles");
|
|
885
|
+
);
|
|
886
886
|
useEffect3(() => {
|
|
887
|
-
if (
|
|
888
|
-
const
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
}, "handleFullscreen");
|
|
904
|
-
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
905
|
-
try {
|
|
906
|
-
await requestDisplayMode("pip");
|
|
907
|
-
} catch (error) {
|
|
908
|
-
console.error("Failed to go pip:", error);
|
|
909
|
-
}
|
|
910
|
-
}, "handlePip");
|
|
911
|
-
const getTooltipStyles = /* @__PURE__ */ __name(() => {
|
|
912
|
-
const baseStyles = {
|
|
913
|
-
position: "absolute",
|
|
914
|
-
padding: "4px 8px",
|
|
915
|
-
backgroundColor: isDark ? "rgba(0, 0, 0, 0.9)" : "rgba(0, 0, 0, 0.9)",
|
|
916
|
-
color: "white",
|
|
917
|
-
borderRadius: "4px",
|
|
918
|
-
fontSize: "12px",
|
|
919
|
-
whiteSpace: "nowrap",
|
|
920
|
-
pointerEvents: "none",
|
|
921
|
-
transition: "opacity 0.2s ease-in-out"
|
|
922
|
-
};
|
|
923
|
-
switch (position) {
|
|
924
|
-
case "top-right":
|
|
925
|
-
return {
|
|
926
|
-
...baseStyles,
|
|
927
|
-
top: "100%",
|
|
928
|
-
right: "0",
|
|
929
|
-
marginTop: "8px"
|
|
930
|
-
};
|
|
931
|
-
case "top-left":
|
|
932
|
-
return {
|
|
933
|
-
...baseStyles,
|
|
934
|
-
top: "100%",
|
|
935
|
-
left: "0",
|
|
936
|
-
marginTop: "8px"
|
|
937
|
-
};
|
|
938
|
-
case "top-center":
|
|
939
|
-
return {
|
|
940
|
-
...baseStyles,
|
|
941
|
-
top: "100%",
|
|
942
|
-
left: "50%",
|
|
943
|
-
transform: "translateX(-50%)",
|
|
944
|
-
marginTop: "8px"
|
|
945
|
-
};
|
|
946
|
-
case "bottom-right":
|
|
947
|
-
return {
|
|
948
|
-
...baseStyles,
|
|
949
|
-
bottom: "100%",
|
|
950
|
-
right: "0",
|
|
951
|
-
marginBottom: "8px"
|
|
952
|
-
};
|
|
953
|
-
case "bottom-left":
|
|
954
|
-
return {
|
|
955
|
-
...baseStyles,
|
|
956
|
-
bottom: "100%",
|
|
957
|
-
left: "0",
|
|
958
|
-
marginBottom: "8px"
|
|
959
|
-
};
|
|
960
|
-
case "bottom-center":
|
|
961
|
-
return {
|
|
962
|
-
...baseStyles,
|
|
963
|
-
bottom: "100%",
|
|
964
|
-
left: "50%",
|
|
965
|
-
transform: "translateX(-50%)",
|
|
966
|
-
marginBottom: "8px"
|
|
967
|
-
};
|
|
968
|
-
case "center-left":
|
|
969
|
-
return {
|
|
970
|
-
...baseStyles,
|
|
971
|
-
left: "100%",
|
|
972
|
-
top: "50%",
|
|
973
|
-
transform: "translateY(-50%)",
|
|
974
|
-
marginLeft: "8px"
|
|
975
|
-
};
|
|
976
|
-
case "center-right":
|
|
977
|
-
return {
|
|
978
|
-
...baseStyles,
|
|
979
|
-
right: "100%",
|
|
980
|
-
top: "50%",
|
|
981
|
-
transform: "translateY(-50%)",
|
|
982
|
-
marginRight: "8px"
|
|
983
|
-
};
|
|
984
|
-
default:
|
|
985
|
-
return {
|
|
986
|
-
...baseStyles,
|
|
987
|
-
top: "100%",
|
|
988
|
-
right: "0",
|
|
989
|
-
marginTop: "8px"
|
|
990
|
-
};
|
|
887
|
+
if (typeof window === "undefined") return;
|
|
888
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
889
|
+
const handleChange = /* @__PURE__ */ __name((e) => {
|
|
890
|
+
setSystemPreference(e.matches ? "dark" : "light");
|
|
891
|
+
}, "handleChange");
|
|
892
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
893
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
894
|
+
}, []);
|
|
895
|
+
const effectiveTheme = isAvailable ? theme : systemPreference;
|
|
896
|
+
useLayoutEffect(() => {
|
|
897
|
+
if (typeof document === "undefined") return;
|
|
898
|
+
if (effectiveTheme === "dark") {
|
|
899
|
+
document.documentElement.classList.add("dark");
|
|
900
|
+
} else {
|
|
901
|
+
document.documentElement.classList.remove("dark");
|
|
991
902
|
}
|
|
992
|
-
},
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
label,
|
|
996
|
-
children: icon
|
|
997
|
-
}) => {
|
|
998
|
-
const [isButtonHovered, setIsButtonHovered] = useState3(false);
|
|
999
|
-
const tooltipStyles = getTooltipStyles();
|
|
1000
|
-
return /* @__PURE__ */ React.createElement(
|
|
1001
|
-
"button",
|
|
1002
|
-
{
|
|
1003
|
-
style: {
|
|
1004
|
-
padding: "8px",
|
|
1005
|
-
backgroundColor: buttonBg,
|
|
1006
|
-
color: buttonColor,
|
|
1007
|
-
border: "none",
|
|
1008
|
-
borderRadius: "8px",
|
|
1009
|
-
cursor: "pointer",
|
|
1010
|
-
display: "flex",
|
|
1011
|
-
alignItems: "center",
|
|
1012
|
-
justifyContent: "center",
|
|
1013
|
-
width: "32px",
|
|
1014
|
-
height: "32px",
|
|
1015
|
-
transition: "background-color 0.2s",
|
|
1016
|
-
backdropFilter: "blur(8px)",
|
|
1017
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
1018
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
1019
|
-
position: "relative"
|
|
1020
|
-
},
|
|
1021
|
-
onMouseEnter: (e) => {
|
|
1022
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
1023
|
-
setIsButtonHovered(true);
|
|
1024
|
-
},
|
|
1025
|
-
onMouseLeave: (e) => {
|
|
1026
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
1027
|
-
setIsButtonHovered(false);
|
|
1028
|
-
},
|
|
1029
|
-
onClick,
|
|
1030
|
-
"aria-label": label
|
|
1031
|
-
},
|
|
1032
|
-
/* @__PURE__ */ React.createElement(
|
|
1033
|
-
"svg",
|
|
1034
|
-
{
|
|
1035
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1036
|
-
width: "16",
|
|
1037
|
-
height: "16",
|
|
1038
|
-
viewBox: "0 0 24 24",
|
|
1039
|
-
fill: "none",
|
|
1040
|
-
stroke: "currentColor",
|
|
1041
|
-
strokeWidth: "2",
|
|
1042
|
-
strokeLinecap: "round",
|
|
1043
|
-
strokeLinejoin: "round",
|
|
1044
|
-
style: { display: "block" }
|
|
1045
|
-
},
|
|
1046
|
-
icon
|
|
1047
|
-
),
|
|
1048
|
-
showLabels && /* @__PURE__ */ React.createElement(
|
|
1049
|
-
"span",
|
|
1050
|
-
{
|
|
1051
|
-
style: {
|
|
1052
|
-
...tooltipStyles,
|
|
1053
|
-
opacity: isButtonHovered ? 1 : 0
|
|
1054
|
-
}
|
|
1055
|
-
},
|
|
1056
|
-
label
|
|
1057
|
-
)
|
|
1058
|
-
);
|
|
1059
|
-
}, "IconButton");
|
|
1060
|
-
return /* @__PURE__ */ React.createElement(
|
|
1061
|
-
"div",
|
|
1062
|
-
{
|
|
1063
|
-
ref: containerRef,
|
|
1064
|
-
className,
|
|
1065
|
-
style: {
|
|
1066
|
-
position: "relative",
|
|
1067
|
-
height: "fit-content"
|
|
1068
|
-
},
|
|
1069
|
-
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
1070
|
-
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
1071
|
-
},
|
|
1072
|
-
!isFullscreen && !isPip && /* @__PURE__ */ React.createElement("div", { style: getPositionStyles() }, /* @__PURE__ */ React.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ React.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ React.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ React.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ React.createElement("path", { d: "M9 21H3v-6" })), /* @__PURE__ */ React.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ React.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ React.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))),
|
|
1073
|
-
children
|
|
1074
|
-
);
|
|
1075
|
-
}
|
|
1076
|
-
__name(WidgetFullscreenWrapper, "WidgetFullscreenWrapper");
|
|
903
|
+
}, [effectiveTheme]);
|
|
904
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
905
|
+
}, "ThemeProvider");
|
|
1077
906
|
|
|
1078
|
-
// src/react/
|
|
1079
|
-
import
|
|
1080
|
-
function
|
|
907
|
+
// src/react/WidgetControls.tsx
|
|
908
|
+
import React4, { useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
|
|
909
|
+
function WidgetControls({
|
|
1081
910
|
children,
|
|
1082
911
|
className = "",
|
|
1083
912
|
position = "top-right",
|
|
1084
913
|
attachTo,
|
|
1085
|
-
showLabels = true
|
|
914
|
+
showLabels = true,
|
|
915
|
+
debugger: enableDebugger = false,
|
|
916
|
+
viewControls = false
|
|
1086
917
|
}) {
|
|
1087
918
|
const {
|
|
1088
919
|
props,
|
|
@@ -1104,8 +935,8 @@ function WidgetDebugger({
|
|
|
1104
935
|
} = useWidget();
|
|
1105
936
|
const [isHovered, setIsHovered] = useState4(false);
|
|
1106
937
|
const [isOverlayOpen, setIsOverlayOpen] = useState4(false);
|
|
1107
|
-
const containerRef =
|
|
1108
|
-
const overlayRef =
|
|
938
|
+
const containerRef = useRef2(null);
|
|
939
|
+
const overlayRef = useRef2(null);
|
|
1109
940
|
const [windowOpenAiKeys, setWindowOpenAiKeys] = useState4([]);
|
|
1110
941
|
const [actionResult, setActionResult] = useState4("");
|
|
1111
942
|
const [toolName, setToolName] = useState4("get-my-city");
|
|
@@ -1118,6 +949,7 @@ function WidgetDebugger({
|
|
|
1118
949
|
);
|
|
1119
950
|
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
1120
951
|
const isPip = displayMode === "pip" && isAvailable;
|
|
952
|
+
const isDevMode = typeof window !== "undefined" && window.location.pathname.includes("/inspector/api/dev-widget/");
|
|
1121
953
|
useEffect4(() => {
|
|
1122
954
|
const timeoutId = setTimeout(() => {
|
|
1123
955
|
if (typeof window !== "undefined" && window.openai) {
|
|
@@ -1131,74 +963,87 @@ function WidgetDebugger({
|
|
|
1131
963
|
setWindowOpenAiKeys([]);
|
|
1132
964
|
}
|
|
1133
965
|
}, 100);
|
|
1134
|
-
return () =>
|
|
966
|
+
return () => {
|
|
967
|
+
clearTimeout(timeoutId);
|
|
968
|
+
};
|
|
1135
969
|
}, []);
|
|
1136
970
|
const isDark = theme === "dark";
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
971
|
+
const getPositionClasses = /* @__PURE__ */ __name(() => {
|
|
972
|
+
const baseClasses = [
|
|
973
|
+
"absolute",
|
|
974
|
+
"z-[1000]",
|
|
975
|
+
"flex",
|
|
976
|
+
"gap-2",
|
|
977
|
+
"transition-opacity",
|
|
978
|
+
"duration-200",
|
|
979
|
+
"ease-in-out",
|
|
980
|
+
isHovered ? "opacity-100" : "opacity-0",
|
|
981
|
+
isHovered ? "pointer-events-auto" : "pointer-events-none"
|
|
982
|
+
];
|
|
983
|
+
switch (position) {
|
|
984
|
+
case "top-left":
|
|
985
|
+
return [...baseClasses, "top-4", "left-4"];
|
|
986
|
+
case "top-center":
|
|
987
|
+
return [...baseClasses, "top-4", "left-1/2", "-translate-x-1/2"];
|
|
988
|
+
case "top-right":
|
|
989
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
990
|
+
case "center-left":
|
|
991
|
+
return [...baseClasses, "top-1/2", "left-4", "-translate-y-1/2"];
|
|
992
|
+
case "center-right":
|
|
993
|
+
return [...baseClasses, "top-1/2", "right-4", "-translate-y-1/2"];
|
|
994
|
+
case "bottom-left":
|
|
995
|
+
return [...baseClasses, "bottom-4", "left-4"];
|
|
996
|
+
case "bottom-center":
|
|
997
|
+
return [...baseClasses, "bottom-4", "left-1/2", "-translate-x-1/2"];
|
|
998
|
+
case "bottom-right":
|
|
999
|
+
return [...baseClasses, "bottom-4", "right-4"];
|
|
1000
|
+
default:
|
|
1001
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
1002
|
+
}
|
|
1003
|
+
}, "getPositionClasses");
|
|
1004
|
+
const getPositionOffsetStyles = /* @__PURE__ */ __name(() => {
|
|
1141
1005
|
const baseOffset = 16;
|
|
1142
|
-
const topOffset = safeArea?.insets?.top ?
|
|
1143
|
-
const rightOffset = safeArea?.insets?.right ?
|
|
1144
|
-
const bottomOffset = safeArea?.insets?.bottom ?
|
|
1145
|
-
const leftOffset = safeArea?.insets?.left ?
|
|
1146
|
-
const styles = {
|
|
1147
|
-
position: "absolute",
|
|
1148
|
-
zIndex: 1e3,
|
|
1149
|
-
display: "flex",
|
|
1150
|
-
gap: "8px",
|
|
1151
|
-
opacity: isHovered ? 1 : 0,
|
|
1152
|
-
transition: "opacity 0.2s ease-in-out",
|
|
1153
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
1154
|
-
};
|
|
1006
|
+
const topOffset = safeArea?.insets?.top ? Math.max(baseOffset, safeArea.insets.top + 8) : baseOffset;
|
|
1007
|
+
const rightOffset = safeArea?.insets?.right ? Math.max(baseOffset, safeArea.insets.right + 8) : baseOffset;
|
|
1008
|
+
const bottomOffset = safeArea?.insets?.bottom ? Math.max(baseOffset, safeArea.insets.bottom + 8) : baseOffset;
|
|
1009
|
+
const leftOffset = safeArea?.insets?.left ? Math.max(baseOffset, safeArea.insets.left + 8) : baseOffset;
|
|
1010
|
+
const styles = {};
|
|
1155
1011
|
switch (position) {
|
|
1156
1012
|
case "top-left":
|
|
1157
|
-
styles.top = topOffset
|
|
1158
|
-
styles.left = leftOffset
|
|
1013
|
+
styles.top = `${topOffset}px`;
|
|
1014
|
+
styles.left = `${leftOffset}px`;
|
|
1159
1015
|
break;
|
|
1160
1016
|
case "top-center":
|
|
1161
|
-
styles.top = topOffset
|
|
1162
|
-
styles.left = "50%";
|
|
1163
|
-
styles.transform = "translateX(-50%)";
|
|
1017
|
+
styles.top = `${topOffset}px`;
|
|
1164
1018
|
break;
|
|
1165
1019
|
case "top-right":
|
|
1166
|
-
styles.top = topOffset
|
|
1167
|
-
styles.right = rightOffset
|
|
1168
|
-
if (!isFullscreen && !isPip) {
|
|
1169
|
-
styles.right = `calc(${rightOffset} + 80px)`;
|
|
1170
|
-
}
|
|
1020
|
+
styles.top = `${topOffset}px`;
|
|
1021
|
+
styles.right = `${rightOffset}px`;
|
|
1171
1022
|
break;
|
|
1172
1023
|
case "center-left":
|
|
1173
|
-
styles.
|
|
1174
|
-
styles.left = leftOffset;
|
|
1175
|
-
styles.transform = "translateY(-50%)";
|
|
1024
|
+
styles.left = `${leftOffset}px`;
|
|
1176
1025
|
break;
|
|
1177
1026
|
case "center-right":
|
|
1178
|
-
styles.
|
|
1179
|
-
styles.right = rightOffset;
|
|
1180
|
-
styles.transform = "translateY(-50%)";
|
|
1027
|
+
styles.right = `${rightOffset}px`;
|
|
1181
1028
|
break;
|
|
1182
1029
|
case "bottom-left":
|
|
1183
|
-
styles.bottom = bottomOffset
|
|
1184
|
-
styles.left = leftOffset
|
|
1030
|
+
styles.bottom = `${bottomOffset}px`;
|
|
1031
|
+
styles.left = `${leftOffset}px`;
|
|
1185
1032
|
break;
|
|
1186
1033
|
case "bottom-center":
|
|
1187
|
-
styles.bottom = bottomOffset
|
|
1188
|
-
styles.left = "50%";
|
|
1189
|
-
styles.transform = "translateX(-50%)";
|
|
1034
|
+
styles.bottom = `${bottomOffset}px`;
|
|
1190
1035
|
break;
|
|
1191
1036
|
case "bottom-right":
|
|
1192
|
-
styles.bottom = bottomOffset
|
|
1193
|
-
styles.right = rightOffset
|
|
1037
|
+
styles.bottom = `${bottomOffset}px`;
|
|
1038
|
+
styles.right = `${rightOffset}px`;
|
|
1194
1039
|
break;
|
|
1195
1040
|
default:
|
|
1196
|
-
styles.top = topOffset
|
|
1197
|
-
styles.right = rightOffset
|
|
1041
|
+
styles.top = `${topOffset}px`;
|
|
1042
|
+
styles.right = `${rightOffset}px`;
|
|
1198
1043
|
break;
|
|
1199
1044
|
}
|
|
1200
1045
|
return styles;
|
|
1201
|
-
}, "
|
|
1046
|
+
}, "getPositionOffsetStyles");
|
|
1202
1047
|
useEffect4(() => {
|
|
1203
1048
|
if (!attachTo) return;
|
|
1204
1049
|
const handleMouseEnter = /* @__PURE__ */ __name(() => setIsHovered(true), "handleMouseEnter");
|
|
@@ -1281,128 +1126,97 @@ function WidgetDebugger({
|
|
|
1281
1126
|
setActionResult(`Error: ${error.message}`);
|
|
1282
1127
|
}
|
|
1283
1128
|
}, "handleSetState");
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1129
|
+
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
1130
|
+
try {
|
|
1131
|
+
await requestDisplayMode("fullscreen");
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
console.error("Failed to go fullscreen:", error);
|
|
1134
|
+
}
|
|
1135
|
+
}, "handleFullscreen");
|
|
1136
|
+
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
1137
|
+
try {
|
|
1138
|
+
await requestDisplayMode("pip");
|
|
1139
|
+
} catch (error) {
|
|
1140
|
+
console.error("Failed to go pip:", error);
|
|
1141
|
+
}
|
|
1142
|
+
}, "handlePip");
|
|
1143
|
+
const getTooltipClasses = /* @__PURE__ */ __name(() => {
|
|
1144
|
+
const baseClasses = [
|
|
1145
|
+
"absolute",
|
|
1146
|
+
"px-2",
|
|
1147
|
+
"py-1",
|
|
1148
|
+
"bg-black/90",
|
|
1149
|
+
"text-white",
|
|
1150
|
+
"rounded",
|
|
1151
|
+
"text-xs",
|
|
1152
|
+
"whitespace-nowrap",
|
|
1153
|
+
"pointer-events-none",
|
|
1154
|
+
"transition-opacity",
|
|
1155
|
+
"duration-200",
|
|
1156
|
+
"ease-in-out"
|
|
1157
|
+
];
|
|
1296
1158
|
switch (position) {
|
|
1297
1159
|
case "top-right":
|
|
1298
|
-
return
|
|
1299
|
-
...baseStyles,
|
|
1300
|
-
top: "100%",
|
|
1301
|
-
right: "0",
|
|
1302
|
-
marginTop: "8px"
|
|
1303
|
-
};
|
|
1160
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
1304
1161
|
case "top-left":
|
|
1305
|
-
return
|
|
1306
|
-
...baseStyles,
|
|
1307
|
-
top: "100%",
|
|
1308
|
-
left: "0",
|
|
1309
|
-
marginTop: "8px"
|
|
1310
|
-
};
|
|
1162
|
+
return [...baseClasses, "top-full", "left-0", "mt-2"];
|
|
1311
1163
|
case "top-center":
|
|
1312
|
-
return
|
|
1313
|
-
...
|
|
1314
|
-
top
|
|
1315
|
-
left
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1164
|
+
return [
|
|
1165
|
+
...baseClasses,
|
|
1166
|
+
"top-full",
|
|
1167
|
+
"left-1/2",
|
|
1168
|
+
"-translate-x-1/2",
|
|
1169
|
+
"mt-2"
|
|
1170
|
+
];
|
|
1319
1171
|
case "bottom-right":
|
|
1320
|
-
return
|
|
1321
|
-
...baseStyles,
|
|
1322
|
-
bottom: "100%",
|
|
1323
|
-
right: "0",
|
|
1324
|
-
marginBottom: "8px"
|
|
1325
|
-
};
|
|
1172
|
+
return [...baseClasses, "bottom-full", "right-0", "mb-2"];
|
|
1326
1173
|
case "bottom-left":
|
|
1327
|
-
return
|
|
1328
|
-
...baseStyles,
|
|
1329
|
-
bottom: "100%",
|
|
1330
|
-
left: "0",
|
|
1331
|
-
marginBottom: "8px"
|
|
1332
|
-
};
|
|
1174
|
+
return [...baseClasses, "bottom-full", "left-0", "mb-2"];
|
|
1333
1175
|
case "bottom-center":
|
|
1334
|
-
return
|
|
1335
|
-
...
|
|
1336
|
-
bottom
|
|
1337
|
-
left
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1176
|
+
return [
|
|
1177
|
+
...baseClasses,
|
|
1178
|
+
"bottom-full",
|
|
1179
|
+
"left-1/2",
|
|
1180
|
+
"-translate-x-1/2",
|
|
1181
|
+
"mb-2"
|
|
1182
|
+
];
|
|
1341
1183
|
case "center-left":
|
|
1342
|
-
return
|
|
1343
|
-
...
|
|
1344
|
-
left
|
|
1345
|
-
top
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1184
|
+
return [
|
|
1185
|
+
...baseClasses,
|
|
1186
|
+
"left-full",
|
|
1187
|
+
"top-1/2",
|
|
1188
|
+
"-translate-y-1/2",
|
|
1189
|
+
"ml-2"
|
|
1190
|
+
];
|
|
1349
1191
|
case "center-right":
|
|
1350
|
-
return
|
|
1351
|
-
...
|
|
1352
|
-
right
|
|
1353
|
-
top
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1192
|
+
return [
|
|
1193
|
+
...baseClasses,
|
|
1194
|
+
"right-full",
|
|
1195
|
+
"top-1/2",
|
|
1196
|
+
"-translate-y-1/2",
|
|
1197
|
+
"mr-2"
|
|
1198
|
+
];
|
|
1357
1199
|
default:
|
|
1358
|
-
return
|
|
1359
|
-
...baseStyles,
|
|
1360
|
-
top: "100%",
|
|
1361
|
-
right: "0",
|
|
1362
|
-
marginTop: "8px"
|
|
1363
|
-
};
|
|
1200
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
1364
1201
|
}
|
|
1365
|
-
}, "
|
|
1202
|
+
}, "getTooltipClasses");
|
|
1366
1203
|
const IconButton = /* @__PURE__ */ __name(({
|
|
1367
1204
|
onClick,
|
|
1368
1205
|
label,
|
|
1369
1206
|
children: icon
|
|
1370
1207
|
}) => {
|
|
1371
1208
|
const [isButtonHovered, setIsButtonHovered] = useState4(false);
|
|
1372
|
-
const
|
|
1373
|
-
return /* @__PURE__ */
|
|
1209
|
+
const tooltipClasses = getTooltipClasses();
|
|
1210
|
+
return /* @__PURE__ */ React4.createElement(
|
|
1374
1211
|
"button",
|
|
1375
1212
|
{
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
color: buttonColor,
|
|
1380
|
-
border: "none",
|
|
1381
|
-
borderRadius: "8px",
|
|
1382
|
-
cursor: "pointer",
|
|
1383
|
-
display: "flex",
|
|
1384
|
-
alignItems: "center",
|
|
1385
|
-
justifyContent: "center",
|
|
1386
|
-
width: "32px",
|
|
1387
|
-
height: "32px",
|
|
1388
|
-
transition: "background-color 0.2s",
|
|
1389
|
-
backdropFilter: "blur(8px)",
|
|
1390
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
1391
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
1392
|
-
position: "relative"
|
|
1393
|
-
},
|
|
1394
|
-
onMouseEnter: (e) => {
|
|
1395
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
1396
|
-
setIsButtonHovered(true);
|
|
1397
|
-
},
|
|
1398
|
-
onMouseLeave: (e) => {
|
|
1399
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
1400
|
-
setIsButtonHovered(false);
|
|
1401
|
-
},
|
|
1213
|
+
className: `p-2 ${isDark ? "bg-white/10 hover:bg-white/20" : "bg-black/70 hover:bg-black/90"} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${isDark ? "shadow-[0_2px_8px_rgba(0,0,0,0.3)]" : "shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,
|
|
1214
|
+
onMouseEnter: () => setIsButtonHovered(true),
|
|
1215
|
+
onMouseLeave: () => setIsButtonHovered(false),
|
|
1402
1216
|
onClick,
|
|
1403
1217
|
"aria-label": label
|
|
1404
1218
|
},
|
|
1405
|
-
/* @__PURE__ */
|
|
1219
|
+
/* @__PURE__ */ React4.createElement(
|
|
1406
1220
|
"svg",
|
|
1407
1221
|
{
|
|
1408
1222
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1414,17 +1228,14 @@ function WidgetDebugger({
|
|
|
1414
1228
|
strokeWidth: "2",
|
|
1415
1229
|
strokeLinecap: "round",
|
|
1416
1230
|
strokeLinejoin: "round",
|
|
1417
|
-
|
|
1231
|
+
className: "block"
|
|
1418
1232
|
},
|
|
1419
1233
|
icon
|
|
1420
1234
|
),
|
|
1421
|
-
showLabels && /* @__PURE__ */
|
|
1235
|
+
showLabels && /* @__PURE__ */ React4.createElement(
|
|
1422
1236
|
"span",
|
|
1423
1237
|
{
|
|
1424
|
-
|
|
1425
|
-
...tooltipStyles,
|
|
1426
|
-
opacity: isButtonHovered ? 1 : 0
|
|
1427
|
-
}
|
|
1238
|
+
className: `${tooltipClasses.join(" ")} ${isButtonHovered ? "opacity-100" : "opacity-0"}`
|
|
1428
1239
|
},
|
|
1429
1240
|
label
|
|
1430
1241
|
)
|
|
@@ -1451,577 +1262,258 @@ function WidgetDebugger({
|
|
|
1451
1262
|
const { top, bottom, left, right } = sa.insets;
|
|
1452
1263
|
return `T:${top} B:${bottom} L:${left} R:${right}`;
|
|
1453
1264
|
}, "formatSafeArea");
|
|
1454
|
-
return /* @__PURE__ */
|
|
1265
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
|
|
1455
1266
|
"div",
|
|
1456
1267
|
{
|
|
1457
1268
|
ref: containerRef,
|
|
1458
|
-
className
|
|
1459
|
-
style: {
|
|
1460
|
-
position: "relative",
|
|
1461
|
-
height: "fit-content"
|
|
1462
|
-
},
|
|
1269
|
+
className: `${className} relative h-fit`,
|
|
1463
1270
|
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
1464
1271
|
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
1465
1272
|
},
|
|
1466
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ React4.createElement(
|
|
1274
|
+
"div",
|
|
1275
|
+
{
|
|
1276
|
+
className: getPositionClasses().join(" "),
|
|
1277
|
+
style: getPositionOffsetStyles()
|
|
1278
|
+
},
|
|
1279
|
+
!isDevMode && /* @__PURE__ */ React4.createElement(React4.Fragment, null, !isFullscreen && !isPip && /* @__PURE__ */ React4.createElement(React4.Fragment, null, (viewControls === true || viewControls === "fullscreen") && /* @__PURE__ */ React4.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ React4.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ React4.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ React4.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ React4.createElement("path", { d: "M9 21H3v-6" })), (viewControls === true || viewControls === "pip") && /* @__PURE__ */ React4.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ React4.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ React4.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))), enableDebugger && /* @__PURE__ */ React4.createElement(IconButton, { onClick: handleToggleOverlay, label: "Debug Info" }, /* @__PURE__ */ React4.createElement("path", { d: "M12 20v-9" }), /* @__PURE__ */ React4.createElement("path", { d: "M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z" }), /* @__PURE__ */ React4.createElement("path", { d: "M14.12 3.88 16 2" }), /* @__PURE__ */ React4.createElement("path", { d: "M21 21a4 4 0 0 0-3.81-4" }), /* @__PURE__ */ React4.createElement("path", { d: "M21 5a4 4 0 0 1-3.55 3.97" }), /* @__PURE__ */ React4.createElement("path", { d: "M22 13h-4" }), /* @__PURE__ */ React4.createElement("path", { d: "M3 21a4 4 0 0 1 3.81-4" }), /* @__PURE__ */ React4.createElement("path", { d: "M3 5a4 4 0 0 0 3.55 3.97" }), /* @__PURE__ */ React4.createElement("path", { d: "M6 13H2" }), /* @__PURE__ */ React4.createElement("path", { d: "m8 2 1.88 1.88" }), /* @__PURE__ */ React4.createElement("path", { d: "M9 7.13V6a3 3 0 1 1 6 0v1.13" })))
|
|
1280
|
+
),
|
|
1467
1281
|
children
|
|
1468
|
-
), isOverlayOpen && /* @__PURE__ */
|
|
1282
|
+
), isOverlayOpen && enableDebugger && /* @__PURE__ */ React4.createElement(
|
|
1469
1283
|
"div",
|
|
1470
1284
|
{
|
|
1471
1285
|
ref: overlayRef,
|
|
1472
|
-
|
|
1473
|
-
position: "fixed",
|
|
1474
|
-
top: 0,
|
|
1475
|
-
left: 0,
|
|
1476
|
-
right: 0,
|
|
1477
|
-
bottom: 0,
|
|
1478
|
-
backgroundColor: "#000000",
|
|
1479
|
-
color: "#ffffff",
|
|
1480
|
-
fontFamily: "monospace",
|
|
1481
|
-
fontSize: "12px",
|
|
1482
|
-
zIndex: 1e4,
|
|
1483
|
-
overflow: "auto",
|
|
1484
|
-
padding: "16px"
|
|
1485
|
-
},
|
|
1286
|
+
className: "fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",
|
|
1486
1287
|
onClick: (e) => {
|
|
1487
1288
|
if (e.target === overlayRef.current) {
|
|
1488
1289
|
setIsOverlayOpen(false);
|
|
1489
1290
|
}
|
|
1490
1291
|
}
|
|
1491
1292
|
},
|
|
1492
|
-
/* @__PURE__ */
|
|
1293
|
+
/* @__PURE__ */ React4.createElement(
|
|
1493
1294
|
"button",
|
|
1494
1295
|
{
|
|
1495
1296
|
onClick: () => setIsOverlayOpen(false),
|
|
1496
|
-
|
|
1497
|
-
position: "absolute",
|
|
1498
|
-
top: "16px",
|
|
1499
|
-
right: "16px",
|
|
1500
|
-
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
1501
|
-
color: "#ffffff",
|
|
1502
|
-
border: "none",
|
|
1503
|
-
borderRadius: "4px",
|
|
1504
|
-
width: "32px",
|
|
1505
|
-
height: "32px",
|
|
1506
|
-
cursor: "pointer",
|
|
1507
|
-
display: "flex",
|
|
1508
|
-
alignItems: "center",
|
|
1509
|
-
justifyContent: "center",
|
|
1510
|
-
fontSize: "18px",
|
|
1511
|
-
lineHeight: 1
|
|
1512
|
-
},
|
|
1297
|
+
className: "absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none",
|
|
1513
1298
|
"aria-label": "Close"
|
|
1514
1299
|
},
|
|
1515
1300
|
"\xD7"
|
|
1516
1301
|
),
|
|
1517
|
-
/* @__PURE__ */
|
|
1518
|
-
"
|
|
1302
|
+
/* @__PURE__ */ React4.createElement("div", { className: "max-w-[1200px] mx-auto pt-10" }, /* @__PURE__ */ React4.createElement("h1", { className: "text-lg font-bold mb-4 border-b border-gray-700 pb-2" }, "Debug Info"), /* @__PURE__ */ React4.createElement("table", { className: "w-full border-collapse border-spacing-0" }, /* @__PURE__ */ React4.createElement("tbody", null, /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Props"), /* @__PURE__ */ React4.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(props))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Output"), /* @__PURE__ */ React4.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(output))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Metadata"), /* @__PURE__ */ React4.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(metadata))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "State"), /* @__PURE__ */ React4.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(state))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Theme"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, theme)), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Display Mode"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, displayMode)), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Locale"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, locale)), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Max Height"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, maxHeight, "px")), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "User Agent"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, formatUserAgent(userAgent))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Safe Area"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, formatSafeArea(safeArea))), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "API Available"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ React4.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ React4.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "window.openai Keys"), /* @__PURE__ */ React4.createElement("td", { className: "p-2" }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))), /* @__PURE__ */ React4.createElement("h2", { className: "text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2" }, "Actions"), /* @__PURE__ */ React4.createElement("div", { className: "flex flex-col gap-3" }, /* @__PURE__ */ React4.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ React4.createElement(
|
|
1303
|
+
"input",
|
|
1304
|
+
{
|
|
1305
|
+
type: "text",
|
|
1306
|
+
value: toolName,
|
|
1307
|
+
onChange: (e) => setToolName(e.target.value),
|
|
1308
|
+
placeholder: "Tool name",
|
|
1309
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"
|
|
1310
|
+
}
|
|
1311
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1312
|
+
"input",
|
|
1519
1313
|
{
|
|
1520
|
-
|
|
1314
|
+
type: "text",
|
|
1315
|
+
value: toolArgs,
|
|
1316
|
+
onChange: (e) => setToolArgs(e.target.value),
|
|
1317
|
+
placeholder: '{"key": "value"}',
|
|
1318
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
1319
|
+
}
|
|
1320
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1321
|
+
"button",
|
|
1322
|
+
{
|
|
1323
|
+
onClick: handleCallTool,
|
|
1324
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
1521
1325
|
},
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
"
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
)
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
)
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
fontWeight: "bold",
|
|
1592
|
-
width: "200px",
|
|
1593
|
-
verticalAlign: "top"
|
|
1594
|
-
}
|
|
1595
|
-
},
|
|
1596
|
-
"Metadata"
|
|
1597
|
-
), /* @__PURE__ */ React2.createElement(
|
|
1598
|
-
"td",
|
|
1599
|
-
{
|
|
1600
|
-
style: {
|
|
1601
|
-
padding: "8px",
|
|
1602
|
-
whiteSpace: "pre-wrap",
|
|
1603
|
-
wordBreak: "break-all"
|
|
1604
|
-
}
|
|
1605
|
-
},
|
|
1606
|
-
formatValue(metadata)
|
|
1607
|
-
)), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1608
|
-
"td",
|
|
1609
|
-
{
|
|
1610
|
-
style: {
|
|
1611
|
-
padding: "8px",
|
|
1612
|
-
fontWeight: "bold",
|
|
1613
|
-
width: "200px",
|
|
1614
|
-
verticalAlign: "top"
|
|
1615
|
-
}
|
|
1616
|
-
},
|
|
1617
|
-
"State"
|
|
1618
|
-
), /* @__PURE__ */ React2.createElement(
|
|
1619
|
-
"td",
|
|
1620
|
-
{
|
|
1621
|
-
style: {
|
|
1622
|
-
padding: "8px",
|
|
1623
|
-
whiteSpace: "pre-wrap",
|
|
1624
|
-
wordBreak: "break-all"
|
|
1625
|
-
}
|
|
1626
|
-
},
|
|
1627
|
-
formatValue(state)
|
|
1628
|
-
)), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1629
|
-
"td",
|
|
1630
|
-
{
|
|
1631
|
-
style: {
|
|
1632
|
-
padding: "8px",
|
|
1633
|
-
fontWeight: "bold",
|
|
1634
|
-
width: "200px",
|
|
1635
|
-
verticalAlign: "top"
|
|
1636
|
-
}
|
|
1637
|
-
},
|
|
1638
|
-
"Theme"
|
|
1639
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, theme)), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1640
|
-
"td",
|
|
1641
|
-
{
|
|
1642
|
-
style: {
|
|
1643
|
-
padding: "8px",
|
|
1644
|
-
fontWeight: "bold",
|
|
1645
|
-
width: "200px",
|
|
1646
|
-
verticalAlign: "top"
|
|
1647
|
-
}
|
|
1648
|
-
},
|
|
1649
|
-
"Display Mode"
|
|
1650
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, displayMode)), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1651
|
-
"td",
|
|
1652
|
-
{
|
|
1653
|
-
style: {
|
|
1654
|
-
padding: "8px",
|
|
1655
|
-
fontWeight: "bold",
|
|
1656
|
-
width: "200px",
|
|
1657
|
-
verticalAlign: "top"
|
|
1658
|
-
}
|
|
1659
|
-
},
|
|
1660
|
-
"Locale"
|
|
1661
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, locale)), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1662
|
-
"td",
|
|
1663
|
-
{
|
|
1664
|
-
style: {
|
|
1665
|
-
padding: "8px",
|
|
1666
|
-
fontWeight: "bold",
|
|
1667
|
-
width: "200px",
|
|
1668
|
-
verticalAlign: "top"
|
|
1669
|
-
}
|
|
1670
|
-
},
|
|
1671
|
-
"Max Height"
|
|
1672
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, maxHeight, "px")), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1673
|
-
"td",
|
|
1674
|
-
{
|
|
1675
|
-
style: {
|
|
1676
|
-
padding: "8px",
|
|
1677
|
-
fontWeight: "bold",
|
|
1678
|
-
width: "200px",
|
|
1679
|
-
verticalAlign: "top"
|
|
1680
|
-
}
|
|
1681
|
-
},
|
|
1682
|
-
"User Agent"
|
|
1683
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, formatUserAgent(userAgent))), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1684
|
-
"td",
|
|
1685
|
-
{
|
|
1686
|
-
style: {
|
|
1687
|
-
padding: "8px",
|
|
1688
|
-
fontWeight: "bold",
|
|
1689
|
-
width: "200px",
|
|
1690
|
-
verticalAlign: "top"
|
|
1691
|
-
}
|
|
1692
|
-
},
|
|
1693
|
-
"Safe Area"
|
|
1694
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, formatSafeArea(safeArea))), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1695
|
-
"td",
|
|
1696
|
-
{
|
|
1697
|
-
style: {
|
|
1698
|
-
padding: "8px",
|
|
1699
|
-
fontWeight: "bold",
|
|
1700
|
-
width: "200px",
|
|
1701
|
-
verticalAlign: "top"
|
|
1702
|
-
}
|
|
1703
|
-
},
|
|
1704
|
-
"API Available"
|
|
1705
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ React2.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ React2.createElement(
|
|
1706
|
-
"td",
|
|
1707
|
-
{
|
|
1708
|
-
style: {
|
|
1709
|
-
padding: "8px",
|
|
1710
|
-
fontWeight: "bold",
|
|
1711
|
-
width: "200px",
|
|
1712
|
-
verticalAlign: "top"
|
|
1713
|
-
}
|
|
1714
|
-
},
|
|
1715
|
-
"window.openai Keys"
|
|
1716
|
-
), /* @__PURE__ */ React2.createElement("td", { style: { padding: "8px" } }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))
|
|
1717
|
-
),
|
|
1718
|
-
/* @__PURE__ */ React2.createElement(
|
|
1719
|
-
"h2",
|
|
1720
|
-
{
|
|
1721
|
-
style: {
|
|
1722
|
-
fontSize: "16px",
|
|
1723
|
-
fontWeight: "bold",
|
|
1724
|
-
marginTop: "32px",
|
|
1725
|
-
marginBottom: "16px",
|
|
1726
|
-
borderBottom: "1px solid #333",
|
|
1727
|
-
paddingBottom: "8px"
|
|
1728
|
-
}
|
|
1729
|
-
},
|
|
1730
|
-
"Actions"
|
|
1731
|
-
),
|
|
1732
|
-
/* @__PURE__ */ React2.createElement(
|
|
1733
|
-
"div",
|
|
1734
|
-
{
|
|
1735
|
-
style: { display: "flex", flexDirection: "column", gap: "12px" }
|
|
1736
|
-
},
|
|
1737
|
-
/* @__PURE__ */ React2.createElement(
|
|
1738
|
-
"div",
|
|
1739
|
-
{
|
|
1740
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
1741
|
-
},
|
|
1742
|
-
/* @__PURE__ */ React2.createElement(
|
|
1743
|
-
"input",
|
|
1744
|
-
{
|
|
1745
|
-
type: "text",
|
|
1746
|
-
value: toolName,
|
|
1747
|
-
onChange: (e) => setToolName(e.target.value),
|
|
1748
|
-
placeholder: "Tool name",
|
|
1749
|
-
style: {
|
|
1750
|
-
padding: "6px 8px",
|
|
1751
|
-
backgroundColor: "#1a1a1a",
|
|
1752
|
-
color: "#ffffff",
|
|
1753
|
-
border: "1px solid #333",
|
|
1754
|
-
borderRadius: "4px",
|
|
1755
|
-
fontFamily: "monospace",
|
|
1756
|
-
fontSize: "12px",
|
|
1757
|
-
width: "150px"
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
),
|
|
1761
|
-
/* @__PURE__ */ React2.createElement(
|
|
1762
|
-
"input",
|
|
1763
|
-
{
|
|
1764
|
-
type: "text",
|
|
1765
|
-
value: toolArgs,
|
|
1766
|
-
onChange: (e) => setToolArgs(e.target.value),
|
|
1767
|
-
placeholder: '{"key": "value"}',
|
|
1768
|
-
style: {
|
|
1769
|
-
padding: "6px 8px",
|
|
1770
|
-
backgroundColor: "#1a1a1a",
|
|
1771
|
-
color: "#ffffff",
|
|
1772
|
-
border: "1px solid #333",
|
|
1773
|
-
borderRadius: "4px",
|
|
1774
|
-
fontFamily: "monospace",
|
|
1775
|
-
fontSize: "12px",
|
|
1776
|
-
flex: 1
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
),
|
|
1780
|
-
/* @__PURE__ */ React2.createElement(
|
|
1781
|
-
"button",
|
|
1782
|
-
{
|
|
1783
|
-
onClick: handleCallTool,
|
|
1784
|
-
style: {
|
|
1785
|
-
padding: "6px 12px",
|
|
1786
|
-
backgroundColor: "#333",
|
|
1787
|
-
color: "#ffffff",
|
|
1788
|
-
border: "1px solid #555",
|
|
1789
|
-
borderRadius: "4px",
|
|
1790
|
-
cursor: "pointer",
|
|
1791
|
-
fontFamily: "monospace",
|
|
1792
|
-
fontSize: "12px"
|
|
1793
|
-
}
|
|
1794
|
-
},
|
|
1795
|
-
"Call Tool"
|
|
1796
|
-
)
|
|
1797
|
-
),
|
|
1798
|
-
/* @__PURE__ */ React2.createElement(
|
|
1799
|
-
"div",
|
|
1800
|
-
{
|
|
1801
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
1802
|
-
},
|
|
1803
|
-
/* @__PURE__ */ React2.createElement(
|
|
1804
|
-
"input",
|
|
1805
|
-
{
|
|
1806
|
-
type: "text",
|
|
1807
|
-
value: followUpMessage,
|
|
1808
|
-
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
1809
|
-
placeholder: "Follow-up message",
|
|
1810
|
-
style: {
|
|
1811
|
-
padding: "6px 8px",
|
|
1812
|
-
backgroundColor: "#1a1a1a",
|
|
1813
|
-
color: "#ffffff",
|
|
1814
|
-
border: "1px solid #333",
|
|
1815
|
-
borderRadius: "4px",
|
|
1816
|
-
fontFamily: "monospace",
|
|
1817
|
-
fontSize: "12px",
|
|
1818
|
-
flex: 1
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
),
|
|
1822
|
-
/* @__PURE__ */ React2.createElement(
|
|
1823
|
-
"button",
|
|
1824
|
-
{
|
|
1825
|
-
onClick: handleSendFollowUpMessage,
|
|
1826
|
-
style: {
|
|
1827
|
-
padding: "6px 12px",
|
|
1828
|
-
backgroundColor: "#333",
|
|
1829
|
-
color: "#ffffff",
|
|
1830
|
-
border: "1px solid #555",
|
|
1831
|
-
borderRadius: "4px",
|
|
1832
|
-
cursor: "pointer",
|
|
1833
|
-
fontFamily: "monospace",
|
|
1834
|
-
fontSize: "12px"
|
|
1835
|
-
}
|
|
1836
|
-
},
|
|
1837
|
-
"Send Follow-Up"
|
|
1838
|
-
)
|
|
1839
|
-
),
|
|
1840
|
-
/* @__PURE__ */ React2.createElement(
|
|
1841
|
-
"div",
|
|
1842
|
-
{
|
|
1843
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
1844
|
-
},
|
|
1845
|
-
/* @__PURE__ */ React2.createElement(
|
|
1846
|
-
"input",
|
|
1847
|
-
{
|
|
1848
|
-
type: "text",
|
|
1849
|
-
value: externalUrl,
|
|
1850
|
-
onChange: (e) => setExternalUrl(e.target.value),
|
|
1851
|
-
placeholder: "External URL",
|
|
1852
|
-
style: {
|
|
1853
|
-
padding: "6px 8px",
|
|
1854
|
-
backgroundColor: "#1a1a1a",
|
|
1855
|
-
color: "#ffffff",
|
|
1856
|
-
border: "1px solid #333",
|
|
1857
|
-
borderRadius: "4px",
|
|
1858
|
-
fontFamily: "monospace",
|
|
1859
|
-
fontSize: "12px",
|
|
1860
|
-
flex: 1
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
),
|
|
1864
|
-
/* @__PURE__ */ React2.createElement(
|
|
1865
|
-
"button",
|
|
1866
|
-
{
|
|
1867
|
-
onClick: handleOpenExternal,
|
|
1868
|
-
style: {
|
|
1869
|
-
padding: "6px 12px",
|
|
1870
|
-
backgroundColor: "#333",
|
|
1871
|
-
color: "#ffffff",
|
|
1872
|
-
border: "1px solid #555",
|
|
1873
|
-
borderRadius: "4px",
|
|
1874
|
-
cursor: "pointer",
|
|
1875
|
-
fontFamily: "monospace",
|
|
1876
|
-
fontSize: "12px"
|
|
1877
|
-
}
|
|
1878
|
-
},
|
|
1879
|
-
"Open Link"
|
|
1880
|
-
)
|
|
1881
|
-
),
|
|
1882
|
-
/* @__PURE__ */ React2.createElement(
|
|
1883
|
-
"div",
|
|
1884
|
-
{
|
|
1885
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
1886
|
-
},
|
|
1887
|
-
/* @__PURE__ */ React2.createElement("span", { style: { width: "150px", fontSize: "12px" } }, "Display Mode:"),
|
|
1888
|
-
/* @__PURE__ */ React2.createElement(
|
|
1889
|
-
"button",
|
|
1890
|
-
{
|
|
1891
|
-
onClick: () => handleRequestDisplayMode("inline"),
|
|
1892
|
-
style: {
|
|
1893
|
-
padding: "6px 12px",
|
|
1894
|
-
backgroundColor: "#333",
|
|
1895
|
-
color: "#ffffff",
|
|
1896
|
-
border: "1px solid #555",
|
|
1897
|
-
borderRadius: "4px",
|
|
1898
|
-
cursor: "pointer",
|
|
1899
|
-
fontFamily: "monospace",
|
|
1900
|
-
fontSize: "12px",
|
|
1901
|
-
flex: 1
|
|
1902
|
-
}
|
|
1903
|
-
},
|
|
1904
|
-
"Inline"
|
|
1905
|
-
),
|
|
1906
|
-
/* @__PURE__ */ React2.createElement(
|
|
1907
|
-
"button",
|
|
1908
|
-
{
|
|
1909
|
-
onClick: () => handleRequestDisplayMode("pip"),
|
|
1910
|
-
style: {
|
|
1911
|
-
padding: "6px 12px",
|
|
1912
|
-
backgroundColor: "#333",
|
|
1913
|
-
color: "#ffffff",
|
|
1914
|
-
border: "1px solid #555",
|
|
1915
|
-
borderRadius: "4px",
|
|
1916
|
-
cursor: "pointer",
|
|
1917
|
-
fontFamily: "monospace",
|
|
1918
|
-
fontSize: "12px",
|
|
1919
|
-
flex: 1
|
|
1920
|
-
}
|
|
1921
|
-
},
|
|
1922
|
-
"PiP"
|
|
1923
|
-
),
|
|
1924
|
-
/* @__PURE__ */ React2.createElement(
|
|
1925
|
-
"button",
|
|
1926
|
-
{
|
|
1927
|
-
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
1928
|
-
style: {
|
|
1929
|
-
padding: "6px 12px",
|
|
1930
|
-
backgroundColor: "#333",
|
|
1931
|
-
color: "#ffffff",
|
|
1932
|
-
border: "1px solid #555",
|
|
1933
|
-
borderRadius: "4px",
|
|
1934
|
-
cursor: "pointer",
|
|
1935
|
-
fontFamily: "monospace",
|
|
1936
|
-
fontSize: "12px",
|
|
1937
|
-
flex: 1
|
|
1938
|
-
}
|
|
1939
|
-
},
|
|
1940
|
-
"Fullscreen"
|
|
1941
|
-
)
|
|
1942
|
-
),
|
|
1943
|
-
/* @__PURE__ */ React2.createElement(
|
|
1944
|
-
"div",
|
|
1945
|
-
{
|
|
1946
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
1947
|
-
},
|
|
1948
|
-
/* @__PURE__ */ React2.createElement(
|
|
1949
|
-
"button",
|
|
1950
|
-
{
|
|
1951
|
-
onClick: handleSetState,
|
|
1952
|
-
style: {
|
|
1953
|
-
padding: "6px 12px",
|
|
1954
|
-
backgroundColor: "#333",
|
|
1955
|
-
color: "#ffffff",
|
|
1956
|
-
border: "1px solid #555",
|
|
1957
|
-
borderRadius: "4px",
|
|
1958
|
-
cursor: "pointer",
|
|
1959
|
-
fontFamily: "monospace",
|
|
1960
|
-
fontSize: "12px"
|
|
1961
|
-
}
|
|
1962
|
-
},
|
|
1963
|
-
"Set State (Add Timestamp)"
|
|
1964
|
-
)
|
|
1965
|
-
),
|
|
1966
|
-
actionResult && /* @__PURE__ */ React2.createElement(
|
|
1967
|
-
"div",
|
|
1968
|
-
{
|
|
1969
|
-
style: {
|
|
1970
|
-
marginTop: "8px",
|
|
1971
|
-
padding: "8px",
|
|
1972
|
-
backgroundColor: "#1a1a1a",
|
|
1973
|
-
border: "1px solid #333",
|
|
1974
|
-
borderRadius: "4px",
|
|
1975
|
-
whiteSpace: "pre-wrap",
|
|
1976
|
-
wordBreak: "break-all",
|
|
1977
|
-
fontSize: "11px",
|
|
1978
|
-
maxHeight: "200px",
|
|
1979
|
-
overflow: "auto"
|
|
1980
|
-
}
|
|
1981
|
-
},
|
|
1982
|
-
/* @__PURE__ */ React2.createElement(
|
|
1983
|
-
"div",
|
|
1984
|
-
{
|
|
1985
|
-
style: {
|
|
1986
|
-
fontWeight: "bold",
|
|
1987
|
-
marginBottom: "4px",
|
|
1988
|
-
color: "#aaa"
|
|
1989
|
-
}
|
|
1990
|
-
},
|
|
1991
|
-
"Result:"
|
|
1992
|
-
),
|
|
1993
|
-
actionResult,
|
|
1994
|
-
/* @__PURE__ */ React2.createElement(
|
|
1995
|
-
"button",
|
|
1996
|
-
{
|
|
1997
|
-
onClick: () => setActionResult(""),
|
|
1998
|
-
style: {
|
|
1999
|
-
marginTop: "8px",
|
|
2000
|
-
padding: "4px 8px",
|
|
2001
|
-
backgroundColor: "#333",
|
|
2002
|
-
color: "#ffffff",
|
|
2003
|
-
border: "1px solid #555",
|
|
2004
|
-
borderRadius: "4px",
|
|
2005
|
-
cursor: "pointer",
|
|
2006
|
-
fontFamily: "monospace",
|
|
2007
|
-
fontSize: "11px"
|
|
2008
|
-
}
|
|
2009
|
-
},
|
|
2010
|
-
"Clear"
|
|
2011
|
-
)
|
|
2012
|
-
)
|
|
2013
|
-
)
|
|
2014
|
-
)
|
|
1326
|
+
"Call Tool"
|
|
1327
|
+
)), /* @__PURE__ */ React4.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ React4.createElement(
|
|
1328
|
+
"input",
|
|
1329
|
+
{
|
|
1330
|
+
type: "text",
|
|
1331
|
+
value: followUpMessage,
|
|
1332
|
+
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
1333
|
+
placeholder: "Follow-up message",
|
|
1334
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
1335
|
+
}
|
|
1336
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1337
|
+
"button",
|
|
1338
|
+
{
|
|
1339
|
+
onClick: handleSendFollowUpMessage,
|
|
1340
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
1341
|
+
},
|
|
1342
|
+
"Send Follow-Up"
|
|
1343
|
+
)), /* @__PURE__ */ React4.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ React4.createElement(
|
|
1344
|
+
"input",
|
|
1345
|
+
{
|
|
1346
|
+
type: "text",
|
|
1347
|
+
value: externalUrl,
|
|
1348
|
+
onChange: (e) => setExternalUrl(e.target.value),
|
|
1349
|
+
placeholder: "External URL",
|
|
1350
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
1351
|
+
}
|
|
1352
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1353
|
+
"button",
|
|
1354
|
+
{
|
|
1355
|
+
onClick: handleOpenExternal,
|
|
1356
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
1357
|
+
},
|
|
1358
|
+
"Open Link"
|
|
1359
|
+
)), /* @__PURE__ */ React4.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ React4.createElement("span", { className: "w-[150px] text-xs" }, "Display Mode:"), /* @__PURE__ */ React4.createElement(
|
|
1360
|
+
"button",
|
|
1361
|
+
{
|
|
1362
|
+
onClick: () => handleRequestDisplayMode("inline"),
|
|
1363
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
1364
|
+
},
|
|
1365
|
+
"Inline"
|
|
1366
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1367
|
+
"button",
|
|
1368
|
+
{
|
|
1369
|
+
onClick: () => handleRequestDisplayMode("pip"),
|
|
1370
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
1371
|
+
},
|
|
1372
|
+
"PiP"
|
|
1373
|
+
), /* @__PURE__ */ React4.createElement(
|
|
1374
|
+
"button",
|
|
1375
|
+
{
|
|
1376
|
+
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
1377
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
1378
|
+
},
|
|
1379
|
+
"Fullscreen"
|
|
1380
|
+
)), /* @__PURE__ */ React4.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ React4.createElement(
|
|
1381
|
+
"button",
|
|
1382
|
+
{
|
|
1383
|
+
onClick: handleSetState,
|
|
1384
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
1385
|
+
},
|
|
1386
|
+
"Set State (Add Timestamp)"
|
|
1387
|
+
)), actionResult && /* @__PURE__ */ React4.createElement("div", { className: "mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto" }, /* @__PURE__ */ React4.createElement("div", { className: "font-bold mb-1 text-gray-400" }, "Result:"), actionResult, /* @__PURE__ */ React4.createElement(
|
|
1388
|
+
"button",
|
|
1389
|
+
{
|
|
1390
|
+
onClick: () => setActionResult(""),
|
|
1391
|
+
className: "mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"
|
|
1392
|
+
},
|
|
1393
|
+
"Clear"
|
|
1394
|
+
))))
|
|
2015
1395
|
));
|
|
2016
1396
|
}
|
|
2017
|
-
__name(
|
|
1397
|
+
__name(WidgetControls, "WidgetControls");
|
|
1398
|
+
|
|
1399
|
+
// src/react/McpUseProvider.tsx
|
|
1400
|
+
import React5, { StrictMode, useCallback as useCallback3, useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
1401
|
+
import { BrowserRouter } from "react-router-dom";
|
|
1402
|
+
function getBasename() {
|
|
1403
|
+
if (typeof window === "undefined") return "/";
|
|
1404
|
+
const path = window.location.pathname;
|
|
1405
|
+
const match = path.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
1406
|
+
if (match) {
|
|
1407
|
+
return match[1];
|
|
1408
|
+
}
|
|
1409
|
+
return "/";
|
|
1410
|
+
}
|
|
1411
|
+
__name(getBasename, "getBasename");
|
|
1412
|
+
var HEIGHT_DEBOUNCE_MS = 150;
|
|
1413
|
+
var MIN_HEIGHT_CHANGE_PX = 5;
|
|
1414
|
+
function McpUseProvider({
|
|
1415
|
+
children,
|
|
1416
|
+
debugger: enableDebugger = false,
|
|
1417
|
+
viewControls = false,
|
|
1418
|
+
autoSize = false
|
|
1419
|
+
}) {
|
|
1420
|
+
const basename = getBasename();
|
|
1421
|
+
const containerRef = useRef3(null);
|
|
1422
|
+
const lastHeightRef = useRef3(0);
|
|
1423
|
+
const debounceTimeoutRef = useRef3(null);
|
|
1424
|
+
const notificationInProgressRef = useRef3(false);
|
|
1425
|
+
const notifyHeight = useCallback3((height) => {
|
|
1426
|
+
if (typeof window !== "undefined" && window.openai?.notifyIntrinsicHeight) {
|
|
1427
|
+
notificationInProgressRef.current = true;
|
|
1428
|
+
window.openai.notifyIntrinsicHeight(height).then(() => {
|
|
1429
|
+
notificationInProgressRef.current = false;
|
|
1430
|
+
}).catch((error) => {
|
|
1431
|
+
notificationInProgressRef.current = false;
|
|
1432
|
+
console.error(
|
|
1433
|
+
"[McpUseProvider] Failed to notify intrinsic height:",
|
|
1434
|
+
error
|
|
1435
|
+
);
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
}, []);
|
|
1439
|
+
const debouncedNotifyHeight = useCallback3(
|
|
1440
|
+
(height) => {
|
|
1441
|
+
if (debounceTimeoutRef.current) {
|
|
1442
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
1443
|
+
}
|
|
1444
|
+
debounceTimeoutRef.current = setTimeout(() => {
|
|
1445
|
+
const heightDiff = Math.abs(height - lastHeightRef.current);
|
|
1446
|
+
if (heightDiff >= MIN_HEIGHT_CHANGE_PX && height > 0) {
|
|
1447
|
+
lastHeightRef.current = height;
|
|
1448
|
+
notifyHeight(height);
|
|
1449
|
+
}
|
|
1450
|
+
}, HEIGHT_DEBOUNCE_MS);
|
|
1451
|
+
},
|
|
1452
|
+
[notifyHeight]
|
|
1453
|
+
);
|
|
1454
|
+
useEffect5(() => {
|
|
1455
|
+
if (!autoSize) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const container = containerRef.current;
|
|
1459
|
+
if (!container || typeof ResizeObserver === "undefined") {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const observer = new ResizeObserver((entries) => {
|
|
1463
|
+
if (notificationInProgressRef.current) {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
for (const entry of entries) {
|
|
1467
|
+
const height = entry.contentRect.height;
|
|
1468
|
+
const scrollHeight = entry.target.scrollHeight;
|
|
1469
|
+
const intrinsicHeight = Math.max(height, scrollHeight);
|
|
1470
|
+
debouncedNotifyHeight(intrinsicHeight);
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
observer.observe(container);
|
|
1474
|
+
const initialHeight = Math.max(
|
|
1475
|
+
container.offsetHeight,
|
|
1476
|
+
container.scrollHeight
|
|
1477
|
+
);
|
|
1478
|
+
if (initialHeight > 0) {
|
|
1479
|
+
debouncedNotifyHeight(initialHeight);
|
|
1480
|
+
}
|
|
1481
|
+
return () => {
|
|
1482
|
+
observer.disconnect();
|
|
1483
|
+
if (debounceTimeoutRef.current) {
|
|
1484
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
1485
|
+
debounceTimeoutRef.current = null;
|
|
1486
|
+
}
|
|
1487
|
+
notificationInProgressRef.current = false;
|
|
1488
|
+
};
|
|
1489
|
+
}, [autoSize, debouncedNotifyHeight]);
|
|
1490
|
+
let content = children;
|
|
1491
|
+
content = /* @__PURE__ */ React5.createElement(ErrorBoundary, null, content);
|
|
1492
|
+
if (enableDebugger || viewControls) {
|
|
1493
|
+
content = /* @__PURE__ */ React5.createElement(WidgetControls, { debugger: enableDebugger, viewControls }, content);
|
|
1494
|
+
}
|
|
1495
|
+
content = /* @__PURE__ */ React5.createElement(BrowserRouter, { basename }, content);
|
|
1496
|
+
content = /* @__PURE__ */ React5.createElement(ThemeProvider, null, content);
|
|
1497
|
+
if (autoSize) {
|
|
1498
|
+
const containerStyle = {
|
|
1499
|
+
width: "100%",
|
|
1500
|
+
minHeight: 0
|
|
1501
|
+
};
|
|
1502
|
+
content = /* @__PURE__ */ React5.createElement("div", { ref: containerRef, style: containerStyle }, content);
|
|
1503
|
+
}
|
|
1504
|
+
return /* @__PURE__ */ React5.createElement(StrictMode, null, content);
|
|
1505
|
+
}
|
|
1506
|
+
__name(McpUseProvider, "McpUseProvider");
|
|
2018
1507
|
|
|
2019
1508
|
export {
|
|
2020
1509
|
useMcp,
|
|
1510
|
+
ErrorBoundary,
|
|
1511
|
+
Image,
|
|
2021
1512
|
useWidget,
|
|
2022
1513
|
useWidgetProps,
|
|
2023
1514
|
useWidgetTheme,
|
|
2024
1515
|
useWidgetState,
|
|
2025
|
-
|
|
2026
|
-
|
|
1516
|
+
ThemeProvider,
|
|
1517
|
+
WidgetControls,
|
|
1518
|
+
McpUseProvider
|
|
2027
1519
|
};
|