mcp-use 1.5.0-canary.0 → 1.5.0-canary.1
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-5XVM4A23.js} +446 -964
- package/dist/index.cjs +474 -992
- package/dist/index.js +11 -5
- 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 +474 -992
- 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 +11 -5
- 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
package/dist/src/react/index.cjs
CHANGED
|
@@ -31,8 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/react/index.ts
|
|
32
32
|
var react_exports = {};
|
|
33
33
|
__export(react_exports, {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
35
|
+
Image: () => Image,
|
|
36
|
+
McpUseProvider: () => McpUseProvider,
|
|
37
|
+
ThemeProvider: () => ThemeProvider,
|
|
38
|
+
WidgetControls: () => WidgetControls,
|
|
36
39
|
onMcpAuthorization: () => onMcpAuthorization,
|
|
37
40
|
useMcp: () => useMcp,
|
|
38
41
|
useWidget: () => useWidget,
|
|
@@ -2321,15 +2324,61 @@ async function onMcpAuthorization() {
|
|
|
2321
2324
|
}
|
|
2322
2325
|
__name(onMcpAuthorization, "onMcpAuthorization");
|
|
2323
2326
|
|
|
2327
|
+
// src/react/ErrorBoundary.tsx
|
|
2328
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
2329
|
+
var ErrorBoundary = class extends import_react2.default.Component {
|
|
2330
|
+
static {
|
|
2331
|
+
__name(this, "ErrorBoundary");
|
|
2332
|
+
}
|
|
2333
|
+
constructor(props) {
|
|
2334
|
+
super(props);
|
|
2335
|
+
this.state = { hasError: false, error: null };
|
|
2336
|
+
}
|
|
2337
|
+
static getDerivedStateFromError(error) {
|
|
2338
|
+
return { hasError: true, error };
|
|
2339
|
+
}
|
|
2340
|
+
componentDidCatch(error, errorInfo) {
|
|
2341
|
+
console.error("Widget Error:", error, errorInfo);
|
|
2342
|
+
}
|
|
2343
|
+
render() {
|
|
2344
|
+
if (this.state.hasError) {
|
|
2345
|
+
return /* @__PURE__ */ import_react2.default.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__ */ import_react2.default.createElement("h3", { className: "font-bold mb-2" }, "Widget Error"), /* @__PURE__ */ import_react2.default.createElement("pre", { className: "text-sm whitespace-pre-wrap" }, this.state.error?.message));
|
|
2346
|
+
}
|
|
2347
|
+
return this.props.children;
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
|
|
2351
|
+
// src/react/Image.tsx
|
|
2352
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
2353
|
+
var Image = /* @__PURE__ */ __name(({ src, ...props }) => {
|
|
2354
|
+
const publicUrl = typeof window !== "undefined" && window.__mcpPublicUrl ? window.__mcpPublicUrl : "";
|
|
2355
|
+
const getFinalSrc = /* @__PURE__ */ __name((source) => {
|
|
2356
|
+
if (!source) return source;
|
|
2357
|
+
if (source.startsWith("http://") || source.startsWith("https://") || source.startsWith("data:")) {
|
|
2358
|
+
return source;
|
|
2359
|
+
}
|
|
2360
|
+
if (!publicUrl) {
|
|
2361
|
+
return source;
|
|
2362
|
+
}
|
|
2363
|
+
const cleanSrc = source.startsWith("/") ? source.slice(1) : source;
|
|
2364
|
+
return `${publicUrl}/${cleanSrc}`;
|
|
2365
|
+
}, "getFinalSrc");
|
|
2366
|
+
const finalSrc = getFinalSrc(src);
|
|
2367
|
+
return /* @__PURE__ */ import_react3.default.createElement("img", { src: finalSrc, ...props });
|
|
2368
|
+
}, "Image");
|
|
2369
|
+
|
|
2370
|
+
// src/react/ThemeProvider.tsx
|
|
2371
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
2372
|
+
|
|
2324
2373
|
// src/react/useWidget.ts
|
|
2325
|
-
var
|
|
2374
|
+
var import_react4 = require("react");
|
|
2326
2375
|
|
|
2327
2376
|
// src/react/widget-types.ts
|
|
2328
2377
|
var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
2329
2378
|
|
|
2330
2379
|
// src/react/useWidget.ts
|
|
2331
2380
|
function useOpenAiGlobal(key) {
|
|
2332
|
-
return (0,
|
|
2381
|
+
return (0, import_react4.useSyncExternalStore)(
|
|
2333
2382
|
(onChange) => {
|
|
2334
2383
|
const handleSetGlobal = /* @__PURE__ */ __name((event) => {
|
|
2335
2384
|
const customEvent = event;
|
|
@@ -2353,10 +2402,10 @@ function useOpenAiGlobal(key) {
|
|
|
2353
2402
|
}
|
|
2354
2403
|
__name(useOpenAiGlobal, "useOpenAiGlobal");
|
|
2355
2404
|
function useWidget(defaultProps) {
|
|
2356
|
-
const [isOpenAiAvailable, setIsOpenAiAvailable] = (0,
|
|
2405
|
+
const [isOpenAiAvailable, setIsOpenAiAvailable] = (0, import_react4.useState)(
|
|
2357
2406
|
() => typeof window !== "undefined" && !!window.openai
|
|
2358
2407
|
);
|
|
2359
|
-
(0,
|
|
2408
|
+
(0, import_react4.useEffect)(() => {
|
|
2360
2409
|
if (typeof window !== "undefined" && window.openai) {
|
|
2361
2410
|
setIsOpenAiAvailable(true);
|
|
2362
2411
|
return;
|
|
@@ -2390,11 +2439,12 @@ function useWidget(defaultProps) {
|
|
|
2390
2439
|
}
|
|
2391
2440
|
};
|
|
2392
2441
|
}, []);
|
|
2393
|
-
const provider = (0,
|
|
2442
|
+
const provider = (0, import_react4.useMemo)(() => {
|
|
2394
2443
|
return isOpenAiAvailable ? "openai" : "mcp-ui";
|
|
2395
2444
|
}, [isOpenAiAvailable]);
|
|
2396
|
-
const
|
|
2397
|
-
|
|
2445
|
+
const searchString = typeof window !== "undefined" ? window.location.search : "";
|
|
2446
|
+
const urlParams = (0, import_react4.useMemo)(() => {
|
|
2447
|
+
const urlParams2 = new URLSearchParams(searchString);
|
|
2398
2448
|
if (urlParams2.has("mcpUseParams")) {
|
|
2399
2449
|
return JSON.parse(urlParams2.get("mcpUseParams"));
|
|
2400
2450
|
}
|
|
@@ -2403,7 +2453,7 @@ function useWidget(defaultProps) {
|
|
|
2403
2453
|
toolOutput: {},
|
|
2404
2454
|
toolId: ""
|
|
2405
2455
|
};
|
|
2406
|
-
}, [
|
|
2456
|
+
}, [searchString]);
|
|
2407
2457
|
const toolInput = provider === "openai" ? useOpenAiGlobal("toolInput") : urlParams.toolInput;
|
|
2408
2458
|
const toolOutput = provider === "openai" ? useOpenAiGlobal("toolOutput") : urlParams.toolOutput;
|
|
2409
2459
|
const toolResponseMetadata = useOpenAiGlobal("toolResponseMetadata");
|
|
@@ -2414,13 +2464,19 @@ function useWidget(defaultProps) {
|
|
|
2414
2464
|
const maxHeight = useOpenAiGlobal("maxHeight");
|
|
2415
2465
|
const userAgent = useOpenAiGlobal("userAgent");
|
|
2416
2466
|
const locale = useOpenAiGlobal("locale");
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2467
|
+
const mcp_url = (0, import_react4.useMemo)(() => {
|
|
2468
|
+
if (typeof window !== "undefined" && window.__mcpPublicUrl) {
|
|
2469
|
+
return window.__mcpPublicUrl.replace(/\/mcp-use\/public$/, "");
|
|
2470
|
+
}
|
|
2471
|
+
return "";
|
|
2472
|
+
}, []);
|
|
2473
|
+
const [localWidgetState, setLocalWidgetState] = (0, import_react4.useState)(null);
|
|
2474
|
+
(0, import_react4.useEffect)(() => {
|
|
2419
2475
|
if (widgetState !== void 0) {
|
|
2420
2476
|
setLocalWidgetState(widgetState);
|
|
2421
2477
|
}
|
|
2422
2478
|
}, [widgetState]);
|
|
2423
|
-
const callTool = (0,
|
|
2479
|
+
const callTool = (0, import_react4.useCallback)(
|
|
2424
2480
|
async (name, args) => {
|
|
2425
2481
|
if (!window.openai?.callTool) {
|
|
2426
2482
|
throw new Error("window.openai.callTool is not available");
|
|
@@ -2429,7 +2485,7 @@ function useWidget(defaultProps) {
|
|
|
2429
2485
|
},
|
|
2430
2486
|
[]
|
|
2431
2487
|
);
|
|
2432
|
-
const sendFollowUpMessage = (0,
|
|
2488
|
+
const sendFollowUpMessage = (0, import_react4.useCallback)(
|
|
2433
2489
|
async (prompt) => {
|
|
2434
2490
|
if (!window.openai?.sendFollowUpMessage) {
|
|
2435
2491
|
throw new Error("window.openai.sendFollowUpMessage is not available");
|
|
@@ -2438,13 +2494,13 @@ function useWidget(defaultProps) {
|
|
|
2438
2494
|
},
|
|
2439
2495
|
[]
|
|
2440
2496
|
);
|
|
2441
|
-
const openExternal = (0,
|
|
2497
|
+
const openExternal = (0, import_react4.useCallback)((href) => {
|
|
2442
2498
|
if (!window.openai?.openExternal) {
|
|
2443
2499
|
throw new Error("window.openai.openExternal is not available");
|
|
2444
2500
|
}
|
|
2445
2501
|
window.openai.openExternal({ href });
|
|
2446
2502
|
}, []);
|
|
2447
|
-
const requestDisplayMode = (0,
|
|
2503
|
+
const requestDisplayMode = (0, import_react4.useCallback)(
|
|
2448
2504
|
async (mode) => {
|
|
2449
2505
|
if (!window.openai?.requestDisplayMode) {
|
|
2450
2506
|
throw new Error("window.openai.requestDisplayMode is not available");
|
|
@@ -2453,16 +2509,17 @@ function useWidget(defaultProps) {
|
|
|
2453
2509
|
},
|
|
2454
2510
|
[]
|
|
2455
2511
|
);
|
|
2456
|
-
const setState = (0,
|
|
2512
|
+
const setState = (0, import_react4.useCallback)(
|
|
2457
2513
|
async (state) => {
|
|
2458
|
-
const newState = typeof state === "function" ? state(localWidgetState) : state;
|
|
2459
2514
|
if (!window.openai?.setWidgetState) {
|
|
2460
2515
|
throw new Error("window.openai.setWidgetState is not available");
|
|
2461
2516
|
}
|
|
2517
|
+
const currentState = widgetState !== void 0 ? widgetState : localWidgetState;
|
|
2518
|
+
const newState = typeof state === "function" ? state(currentState) : state;
|
|
2462
2519
|
setLocalWidgetState(newState);
|
|
2463
2520
|
return window.openai.setWidgetState(newState);
|
|
2464
2521
|
},
|
|
2465
|
-
[localWidgetState]
|
|
2522
|
+
[widgetState, localWidgetState]
|
|
2466
2523
|
);
|
|
2467
2524
|
return {
|
|
2468
2525
|
// Props and state (with defaults)
|
|
@@ -2481,6 +2538,7 @@ function useWidget(defaultProps) {
|
|
|
2481
2538
|
capabilities: { hover: true, touch: false }
|
|
2482
2539
|
},
|
|
2483
2540
|
locale: locale || "en",
|
|
2541
|
+
mcp_url,
|
|
2484
2542
|
// Actions
|
|
2485
2543
|
callTool,
|
|
2486
2544
|
sendFollowUpMessage,
|
|
@@ -2503,7 +2561,7 @@ function useWidgetTheme() {
|
|
|
2503
2561
|
__name(useWidgetTheme, "useWidgetTheme");
|
|
2504
2562
|
function useWidgetState(defaultState) {
|
|
2505
2563
|
const { state, setState } = useWidget();
|
|
2506
|
-
(0,
|
|
2564
|
+
(0, import_react4.useEffect)(() => {
|
|
2507
2565
|
if (state === null && defaultState !== void 0 && window.openai?.setWidgetState) {
|
|
2508
2566
|
setState(defaultState);
|
|
2509
2567
|
}
|
|
@@ -2512,283 +2570,49 @@ function useWidgetState(defaultState) {
|
|
|
2512
2570
|
}
|
|
2513
2571
|
__name(useWidgetState, "useWidgetState");
|
|
2514
2572
|
|
|
2515
|
-
// src/react/
|
|
2516
|
-
var
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
const [isHovered, setIsHovered] = (0, import_react3.useState)(false);
|
|
2526
|
-
const containerRef = (0, import_react3.useRef)(null);
|
|
2527
|
-
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
2528
|
-
const isPip = displayMode === "pip" && isAvailable;
|
|
2529
|
-
const isDark = theme === "dark";
|
|
2530
|
-
const buttonBg = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.7)";
|
|
2531
|
-
const buttonBgHover = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.9)";
|
|
2532
|
-
const buttonColor = "white";
|
|
2533
|
-
const getPositionStyles = /* @__PURE__ */ __name(() => {
|
|
2534
|
-
const baseOffset = 16;
|
|
2535
|
-
const topOffset = safeArea?.insets?.top ? `${Math.max(baseOffset, safeArea.insets.top + 8)}px` : `${baseOffset}px`;
|
|
2536
|
-
const rightOffset = safeArea?.insets?.right ? `${Math.max(baseOffset, safeArea.insets.right + 8)}px` : `${baseOffset}px`;
|
|
2537
|
-
const bottomOffset = safeArea?.insets?.bottom ? `${Math.max(baseOffset, safeArea.insets.bottom + 8)}px` : `${baseOffset}px`;
|
|
2538
|
-
const leftOffset = safeArea?.insets?.left ? `${Math.max(baseOffset, safeArea.insets.left + 8)}px` : `${baseOffset}px`;
|
|
2539
|
-
const styles = {
|
|
2540
|
-
position: "absolute",
|
|
2541
|
-
zIndex: 1e3,
|
|
2542
|
-
display: "flex",
|
|
2543
|
-
gap: "8px",
|
|
2544
|
-
opacity: isHovered ? 1 : 0,
|
|
2545
|
-
transition: "opacity 0.2s ease-in-out",
|
|
2546
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
2547
|
-
};
|
|
2548
|
-
switch (position) {
|
|
2549
|
-
case "top-left":
|
|
2550
|
-
styles.top = topOffset;
|
|
2551
|
-
styles.left = leftOffset;
|
|
2552
|
-
break;
|
|
2553
|
-
case "top-center":
|
|
2554
|
-
styles.top = topOffset;
|
|
2555
|
-
styles.left = "50%";
|
|
2556
|
-
styles.transform = "translateX(-50%)";
|
|
2557
|
-
break;
|
|
2558
|
-
case "top-right":
|
|
2559
|
-
styles.top = topOffset;
|
|
2560
|
-
styles.right = rightOffset;
|
|
2561
|
-
break;
|
|
2562
|
-
case "center-left":
|
|
2563
|
-
styles.top = "50%";
|
|
2564
|
-
styles.left = leftOffset;
|
|
2565
|
-
styles.transform = "translateY(-50%)";
|
|
2566
|
-
break;
|
|
2567
|
-
case "center-right":
|
|
2568
|
-
styles.top = "50%";
|
|
2569
|
-
styles.right = rightOffset;
|
|
2570
|
-
styles.transform = "translateY(-50%)";
|
|
2571
|
-
break;
|
|
2572
|
-
case "bottom-left":
|
|
2573
|
-
styles.bottom = bottomOffset;
|
|
2574
|
-
styles.left = leftOffset;
|
|
2575
|
-
break;
|
|
2576
|
-
case "bottom-center":
|
|
2577
|
-
styles.bottom = bottomOffset;
|
|
2578
|
-
styles.left = "50%";
|
|
2579
|
-
styles.transform = "translateX(-50%)";
|
|
2580
|
-
break;
|
|
2581
|
-
case "bottom-right":
|
|
2582
|
-
styles.bottom = bottomOffset;
|
|
2583
|
-
styles.right = rightOffset;
|
|
2584
|
-
break;
|
|
2585
|
-
default:
|
|
2586
|
-
styles.top = topOffset;
|
|
2587
|
-
styles.right = rightOffset;
|
|
2588
|
-
break;
|
|
2589
|
-
}
|
|
2590
|
-
return styles;
|
|
2591
|
-
}, "getPositionStyles");
|
|
2592
|
-
(0, import_react3.useEffect)(() => {
|
|
2593
|
-
if (!attachTo) return;
|
|
2594
|
-
const handleMouseEnter = /* @__PURE__ */ __name(() => setIsHovered(true), "handleMouseEnter");
|
|
2595
|
-
const handleMouseLeave = /* @__PURE__ */ __name(() => setIsHovered(false), "handleMouseLeave");
|
|
2596
|
-
attachTo.addEventListener("mouseenter", handleMouseEnter);
|
|
2597
|
-
attachTo.addEventListener("mouseleave", handleMouseLeave);
|
|
2598
|
-
return () => {
|
|
2599
|
-
attachTo.removeEventListener("mouseenter", handleMouseEnter);
|
|
2600
|
-
attachTo.removeEventListener("mouseleave", handleMouseLeave);
|
|
2601
|
-
};
|
|
2602
|
-
}, [attachTo]);
|
|
2603
|
-
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
2604
|
-
try {
|
|
2605
|
-
await requestDisplayMode("fullscreen");
|
|
2606
|
-
} catch (error) {
|
|
2607
|
-
console.error("Failed to go fullscreen:", error);
|
|
2608
|
-
}
|
|
2609
|
-
}, "handleFullscreen");
|
|
2610
|
-
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
2611
|
-
try {
|
|
2612
|
-
await requestDisplayMode("pip");
|
|
2613
|
-
} catch (error) {
|
|
2614
|
-
console.error("Failed to go pip:", error);
|
|
2615
|
-
}
|
|
2616
|
-
}, "handlePip");
|
|
2617
|
-
const getTooltipStyles = /* @__PURE__ */ __name(() => {
|
|
2618
|
-
const baseStyles = {
|
|
2619
|
-
position: "absolute",
|
|
2620
|
-
padding: "4px 8px",
|
|
2621
|
-
backgroundColor: isDark ? "rgba(0, 0, 0, 0.9)" : "rgba(0, 0, 0, 0.9)",
|
|
2622
|
-
color: "white",
|
|
2623
|
-
borderRadius: "4px",
|
|
2624
|
-
fontSize: "12px",
|
|
2625
|
-
whiteSpace: "nowrap",
|
|
2626
|
-
pointerEvents: "none",
|
|
2627
|
-
transition: "opacity 0.2s ease-in-out"
|
|
2628
|
-
};
|
|
2629
|
-
switch (position) {
|
|
2630
|
-
case "top-right":
|
|
2631
|
-
return {
|
|
2632
|
-
...baseStyles,
|
|
2633
|
-
top: "100%",
|
|
2634
|
-
right: "0",
|
|
2635
|
-
marginTop: "8px"
|
|
2636
|
-
};
|
|
2637
|
-
case "top-left":
|
|
2638
|
-
return {
|
|
2639
|
-
...baseStyles,
|
|
2640
|
-
top: "100%",
|
|
2641
|
-
left: "0",
|
|
2642
|
-
marginTop: "8px"
|
|
2643
|
-
};
|
|
2644
|
-
case "top-center":
|
|
2645
|
-
return {
|
|
2646
|
-
...baseStyles,
|
|
2647
|
-
top: "100%",
|
|
2648
|
-
left: "50%",
|
|
2649
|
-
transform: "translateX(-50%)",
|
|
2650
|
-
marginTop: "8px"
|
|
2651
|
-
};
|
|
2652
|
-
case "bottom-right":
|
|
2653
|
-
return {
|
|
2654
|
-
...baseStyles,
|
|
2655
|
-
bottom: "100%",
|
|
2656
|
-
right: "0",
|
|
2657
|
-
marginBottom: "8px"
|
|
2658
|
-
};
|
|
2659
|
-
case "bottom-left":
|
|
2660
|
-
return {
|
|
2661
|
-
...baseStyles,
|
|
2662
|
-
bottom: "100%",
|
|
2663
|
-
left: "0",
|
|
2664
|
-
marginBottom: "8px"
|
|
2665
|
-
};
|
|
2666
|
-
case "bottom-center":
|
|
2667
|
-
return {
|
|
2668
|
-
...baseStyles,
|
|
2669
|
-
bottom: "100%",
|
|
2670
|
-
left: "50%",
|
|
2671
|
-
transform: "translateX(-50%)",
|
|
2672
|
-
marginBottom: "8px"
|
|
2673
|
-
};
|
|
2674
|
-
case "center-left":
|
|
2675
|
-
return {
|
|
2676
|
-
...baseStyles,
|
|
2677
|
-
left: "100%",
|
|
2678
|
-
top: "50%",
|
|
2679
|
-
transform: "translateY(-50%)",
|
|
2680
|
-
marginLeft: "8px"
|
|
2681
|
-
};
|
|
2682
|
-
case "center-right":
|
|
2683
|
-
return {
|
|
2684
|
-
...baseStyles,
|
|
2685
|
-
right: "100%",
|
|
2686
|
-
top: "50%",
|
|
2687
|
-
transform: "translateY(-50%)",
|
|
2688
|
-
marginRight: "8px"
|
|
2689
|
-
};
|
|
2690
|
-
default:
|
|
2691
|
-
return {
|
|
2692
|
-
...baseStyles,
|
|
2693
|
-
top: "100%",
|
|
2694
|
-
right: "0",
|
|
2695
|
-
marginTop: "8px"
|
|
2696
|
-
};
|
|
2573
|
+
// src/react/ThemeProvider.tsx
|
|
2574
|
+
var ThemeProvider = /* @__PURE__ */ __name(({
|
|
2575
|
+
children
|
|
2576
|
+
}) => {
|
|
2577
|
+
const { theme, isAvailable } = useWidget();
|
|
2578
|
+
console.log("theme", theme);
|
|
2579
|
+
const [systemPreference, setSystemPreference] = (0, import_react5.useState)(
|
|
2580
|
+
() => {
|
|
2581
|
+
if (typeof window === "undefined") return "light";
|
|
2582
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
2697
2583
|
}
|
|
2698
|
-
}, "getTooltipStyles");
|
|
2699
|
-
const IconButton = /* @__PURE__ */ __name(({
|
|
2700
|
-
onClick,
|
|
2701
|
-
label,
|
|
2702
|
-
children: icon
|
|
2703
|
-
}) => {
|
|
2704
|
-
const [isButtonHovered, setIsButtonHovered] = (0, import_react3.useState)(false);
|
|
2705
|
-
const tooltipStyles = getTooltipStyles();
|
|
2706
|
-
return /* @__PURE__ */ import_react3.default.createElement(
|
|
2707
|
-
"button",
|
|
2708
|
-
{
|
|
2709
|
-
style: {
|
|
2710
|
-
padding: "8px",
|
|
2711
|
-
backgroundColor: buttonBg,
|
|
2712
|
-
color: buttonColor,
|
|
2713
|
-
border: "none",
|
|
2714
|
-
borderRadius: "8px",
|
|
2715
|
-
cursor: "pointer",
|
|
2716
|
-
display: "flex",
|
|
2717
|
-
alignItems: "center",
|
|
2718
|
-
justifyContent: "center",
|
|
2719
|
-
width: "32px",
|
|
2720
|
-
height: "32px",
|
|
2721
|
-
transition: "background-color 0.2s",
|
|
2722
|
-
backdropFilter: "blur(8px)",
|
|
2723
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
2724
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
2725
|
-
position: "relative"
|
|
2726
|
-
},
|
|
2727
|
-
onMouseEnter: (e) => {
|
|
2728
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
2729
|
-
setIsButtonHovered(true);
|
|
2730
|
-
},
|
|
2731
|
-
onMouseLeave: (e) => {
|
|
2732
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
2733
|
-
setIsButtonHovered(false);
|
|
2734
|
-
},
|
|
2735
|
-
onClick,
|
|
2736
|
-
"aria-label": label
|
|
2737
|
-
},
|
|
2738
|
-
/* @__PURE__ */ import_react3.default.createElement(
|
|
2739
|
-
"svg",
|
|
2740
|
-
{
|
|
2741
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2742
|
-
width: "16",
|
|
2743
|
-
height: "16",
|
|
2744
|
-
viewBox: "0 0 24 24",
|
|
2745
|
-
fill: "none",
|
|
2746
|
-
stroke: "currentColor",
|
|
2747
|
-
strokeWidth: "2",
|
|
2748
|
-
strokeLinecap: "round",
|
|
2749
|
-
strokeLinejoin: "round",
|
|
2750
|
-
style: { display: "block" }
|
|
2751
|
-
},
|
|
2752
|
-
icon
|
|
2753
|
-
),
|
|
2754
|
-
showLabels && /* @__PURE__ */ import_react3.default.createElement(
|
|
2755
|
-
"span",
|
|
2756
|
-
{
|
|
2757
|
-
style: {
|
|
2758
|
-
...tooltipStyles,
|
|
2759
|
-
opacity: isButtonHovered ? 1 : 0
|
|
2760
|
-
}
|
|
2761
|
-
},
|
|
2762
|
-
label
|
|
2763
|
-
)
|
|
2764
|
-
);
|
|
2765
|
-
}, "IconButton");
|
|
2766
|
-
return /* @__PURE__ */ import_react3.default.createElement(
|
|
2767
|
-
"div",
|
|
2768
|
-
{
|
|
2769
|
-
ref: containerRef,
|
|
2770
|
-
className,
|
|
2771
|
-
style: {
|
|
2772
|
-
position: "relative",
|
|
2773
|
-
height: "fit-content"
|
|
2774
|
-
},
|
|
2775
|
-
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
2776
|
-
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
2777
|
-
},
|
|
2778
|
-
!isFullscreen && !isPip && /* @__PURE__ */ import_react3.default.createElement("div", { style: getPositionStyles() }, /* @__PURE__ */ import_react3.default.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ import_react3.default.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "M9 21H3v-6" })), /* @__PURE__ */ import_react3.default.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ import_react3.default.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ import_react3.default.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))),
|
|
2779
|
-
children
|
|
2780
2584
|
);
|
|
2781
|
-
|
|
2782
|
-
|
|
2585
|
+
(0, import_react5.useEffect)(() => {
|
|
2586
|
+
if (typeof window === "undefined") return;
|
|
2587
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
2588
|
+
const handleChange = /* @__PURE__ */ __name((e) => {
|
|
2589
|
+
setSystemPreference(e.matches ? "dark" : "light");
|
|
2590
|
+
}, "handleChange");
|
|
2591
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
2592
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
2593
|
+
}, []);
|
|
2594
|
+
const effectiveTheme = isAvailable ? theme : systemPreference;
|
|
2595
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
2596
|
+
if (typeof document === "undefined") return;
|
|
2597
|
+
if (effectiveTheme === "dark") {
|
|
2598
|
+
document.documentElement.classList.add("dark");
|
|
2599
|
+
} else {
|
|
2600
|
+
document.documentElement.classList.remove("dark");
|
|
2601
|
+
}
|
|
2602
|
+
}, [effectiveTheme]);
|
|
2603
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, children);
|
|
2604
|
+
}, "ThemeProvider");
|
|
2783
2605
|
|
|
2784
|
-
// src/react/
|
|
2785
|
-
var
|
|
2786
|
-
function
|
|
2606
|
+
// src/react/WidgetControls.tsx
|
|
2607
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
2608
|
+
function WidgetControls({
|
|
2787
2609
|
children,
|
|
2788
2610
|
className = "",
|
|
2789
2611
|
position = "top-right",
|
|
2790
2612
|
attachTo,
|
|
2791
|
-
showLabels = true
|
|
2613
|
+
showLabels = true,
|
|
2614
|
+
debugger: enableDebugger = false,
|
|
2615
|
+
viewControls = false
|
|
2792
2616
|
}) {
|
|
2793
2617
|
const {
|
|
2794
2618
|
props,
|
|
@@ -2808,23 +2632,24 @@ function WidgetDebugger({
|
|
|
2808
2632
|
requestDisplayMode,
|
|
2809
2633
|
setState
|
|
2810
2634
|
} = useWidget();
|
|
2811
|
-
const [isHovered, setIsHovered] = (0,
|
|
2812
|
-
const [isOverlayOpen, setIsOverlayOpen] = (0,
|
|
2813
|
-
const containerRef = (0,
|
|
2814
|
-
const overlayRef = (0,
|
|
2815
|
-
const [windowOpenAiKeys, setWindowOpenAiKeys] = (0,
|
|
2816
|
-
const [actionResult, setActionResult] = (0,
|
|
2817
|
-
const [toolName, setToolName] = (0,
|
|
2818
|
-
const [toolArgs, setToolArgs] = (0,
|
|
2819
|
-
const [followUpMessage, setFollowUpMessage] = (0,
|
|
2635
|
+
const [isHovered, setIsHovered] = (0, import_react6.useState)(false);
|
|
2636
|
+
const [isOverlayOpen, setIsOverlayOpen] = (0, import_react6.useState)(false);
|
|
2637
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
2638
|
+
const overlayRef = (0, import_react6.useRef)(null);
|
|
2639
|
+
const [windowOpenAiKeys, setWindowOpenAiKeys] = (0, import_react6.useState)([]);
|
|
2640
|
+
const [actionResult, setActionResult] = (0, import_react6.useState)("");
|
|
2641
|
+
const [toolName, setToolName] = (0, import_react6.useState)("get-my-city");
|
|
2642
|
+
const [toolArgs, setToolArgs] = (0, import_react6.useState)("{}");
|
|
2643
|
+
const [followUpMessage, setFollowUpMessage] = (0, import_react6.useState)(
|
|
2820
2644
|
"Test follow-up message"
|
|
2821
2645
|
);
|
|
2822
|
-
const [externalUrl, setExternalUrl] = (0,
|
|
2646
|
+
const [externalUrl, setExternalUrl] = (0, import_react6.useState)(
|
|
2823
2647
|
"https://docs.mcp-use.com"
|
|
2824
2648
|
);
|
|
2825
2649
|
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
2826
2650
|
const isPip = displayMode === "pip" && isAvailable;
|
|
2827
|
-
|
|
2651
|
+
const isDevMode = typeof window !== "undefined" && window.location.pathname.includes("/inspector/api/dev-widget/");
|
|
2652
|
+
(0, import_react6.useEffect)(() => {
|
|
2828
2653
|
const timeoutId = setTimeout(() => {
|
|
2829
2654
|
if (typeof window !== "undefined" && window.openai) {
|
|
2830
2655
|
try {
|
|
@@ -2837,75 +2662,88 @@ function WidgetDebugger({
|
|
|
2837
2662
|
setWindowOpenAiKeys([]);
|
|
2838
2663
|
}
|
|
2839
2664
|
}, 100);
|
|
2840
|
-
return () =>
|
|
2665
|
+
return () => {
|
|
2666
|
+
clearTimeout(timeoutId);
|
|
2667
|
+
};
|
|
2841
2668
|
}, []);
|
|
2842
2669
|
const isDark = theme === "dark";
|
|
2843
|
-
const
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2670
|
+
const getPositionClasses = /* @__PURE__ */ __name(() => {
|
|
2671
|
+
const baseClasses = [
|
|
2672
|
+
"absolute",
|
|
2673
|
+
"z-[1000]",
|
|
2674
|
+
"flex",
|
|
2675
|
+
"gap-2",
|
|
2676
|
+
"transition-opacity",
|
|
2677
|
+
"duration-200",
|
|
2678
|
+
"ease-in-out",
|
|
2679
|
+
isHovered ? "opacity-100" : "opacity-0",
|
|
2680
|
+
isHovered ? "pointer-events-auto" : "pointer-events-none"
|
|
2681
|
+
];
|
|
2682
|
+
switch (position) {
|
|
2683
|
+
case "top-left":
|
|
2684
|
+
return [...baseClasses, "top-4", "left-4"];
|
|
2685
|
+
case "top-center":
|
|
2686
|
+
return [...baseClasses, "top-4", "left-1/2", "-translate-x-1/2"];
|
|
2687
|
+
case "top-right":
|
|
2688
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
2689
|
+
case "center-left":
|
|
2690
|
+
return [...baseClasses, "top-1/2", "left-4", "-translate-y-1/2"];
|
|
2691
|
+
case "center-right":
|
|
2692
|
+
return [...baseClasses, "top-1/2", "right-4", "-translate-y-1/2"];
|
|
2693
|
+
case "bottom-left":
|
|
2694
|
+
return [...baseClasses, "bottom-4", "left-4"];
|
|
2695
|
+
case "bottom-center":
|
|
2696
|
+
return [...baseClasses, "bottom-4", "left-1/2", "-translate-x-1/2"];
|
|
2697
|
+
case "bottom-right":
|
|
2698
|
+
return [...baseClasses, "bottom-4", "right-4"];
|
|
2699
|
+
default:
|
|
2700
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
2701
|
+
}
|
|
2702
|
+
}, "getPositionClasses");
|
|
2703
|
+
const getPositionOffsetStyles = /* @__PURE__ */ __name(() => {
|
|
2847
2704
|
const baseOffset = 16;
|
|
2848
|
-
const topOffset = safeArea?.insets?.top ?
|
|
2849
|
-
const rightOffset = safeArea?.insets?.right ?
|
|
2850
|
-
const bottomOffset = safeArea?.insets?.bottom ?
|
|
2851
|
-
const leftOffset = safeArea?.insets?.left ?
|
|
2852
|
-
const styles = {
|
|
2853
|
-
position: "absolute",
|
|
2854
|
-
zIndex: 1e3,
|
|
2855
|
-
display: "flex",
|
|
2856
|
-
gap: "8px",
|
|
2857
|
-
opacity: isHovered ? 1 : 0,
|
|
2858
|
-
transition: "opacity 0.2s ease-in-out",
|
|
2859
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
2860
|
-
};
|
|
2705
|
+
const topOffset = safeArea?.insets?.top ? Math.max(baseOffset, safeArea.insets.top + 8) : baseOffset;
|
|
2706
|
+
const rightOffset = safeArea?.insets?.right ? Math.max(baseOffset, safeArea.insets.right + 8) : baseOffset;
|
|
2707
|
+
const bottomOffset = safeArea?.insets?.bottom ? Math.max(baseOffset, safeArea.insets.bottom + 8) : baseOffset;
|
|
2708
|
+
const leftOffset = safeArea?.insets?.left ? Math.max(baseOffset, safeArea.insets.left + 8) : baseOffset;
|
|
2709
|
+
const styles = {};
|
|
2861
2710
|
switch (position) {
|
|
2862
2711
|
case "top-left":
|
|
2863
|
-
styles.top = topOffset
|
|
2864
|
-
styles.left = leftOffset
|
|
2712
|
+
styles.top = `${topOffset}px`;
|
|
2713
|
+
styles.left = `${leftOffset}px`;
|
|
2865
2714
|
break;
|
|
2866
2715
|
case "top-center":
|
|
2867
|
-
styles.top = topOffset
|
|
2868
|
-
styles.left = "50%";
|
|
2869
|
-
styles.transform = "translateX(-50%)";
|
|
2716
|
+
styles.top = `${topOffset}px`;
|
|
2870
2717
|
break;
|
|
2871
2718
|
case "top-right":
|
|
2872
|
-
styles.top = topOffset
|
|
2873
|
-
styles.right = rightOffset
|
|
2874
|
-
if (!isFullscreen && !isPip) {
|
|
2875
|
-
styles.right = `calc(${rightOffset} + 80px)`;
|
|
2876
|
-
}
|
|
2719
|
+
styles.top = `${topOffset}px`;
|
|
2720
|
+
styles.right = `${rightOffset}px`;
|
|
2877
2721
|
break;
|
|
2878
2722
|
case "center-left":
|
|
2879
|
-
styles.
|
|
2880
|
-
styles.left = leftOffset;
|
|
2881
|
-
styles.transform = "translateY(-50%)";
|
|
2723
|
+
styles.left = `${leftOffset}px`;
|
|
2882
2724
|
break;
|
|
2883
2725
|
case "center-right":
|
|
2884
|
-
styles.
|
|
2885
|
-
styles.right = rightOffset;
|
|
2886
|
-
styles.transform = "translateY(-50%)";
|
|
2726
|
+
styles.right = `${rightOffset}px`;
|
|
2887
2727
|
break;
|
|
2888
2728
|
case "bottom-left":
|
|
2889
|
-
styles.bottom = bottomOffset
|
|
2890
|
-
styles.left = leftOffset
|
|
2729
|
+
styles.bottom = `${bottomOffset}px`;
|
|
2730
|
+
styles.left = `${leftOffset}px`;
|
|
2891
2731
|
break;
|
|
2892
2732
|
case "bottom-center":
|
|
2893
|
-
styles.bottom = bottomOffset
|
|
2894
|
-
styles.left = "50%";
|
|
2895
|
-
styles.transform = "translateX(-50%)";
|
|
2733
|
+
styles.bottom = `${bottomOffset}px`;
|
|
2896
2734
|
break;
|
|
2897
2735
|
case "bottom-right":
|
|
2898
|
-
styles.bottom = bottomOffset
|
|
2899
|
-
styles.right = rightOffset
|
|
2736
|
+
styles.bottom = `${bottomOffset}px`;
|
|
2737
|
+
styles.right = `${rightOffset}px`;
|
|
2900
2738
|
break;
|
|
2901
2739
|
default:
|
|
2902
|
-
styles.top = topOffset
|
|
2903
|
-
styles.right = rightOffset
|
|
2740
|
+
styles.top = `${topOffset}px`;
|
|
2741
|
+
styles.right = `${rightOffset}px`;
|
|
2904
2742
|
break;
|
|
2905
2743
|
}
|
|
2906
2744
|
return styles;
|
|
2907
|
-
}, "
|
|
2908
|
-
(0,
|
|
2745
|
+
}, "getPositionOffsetStyles");
|
|
2746
|
+
(0, import_react6.useEffect)(() => {
|
|
2909
2747
|
if (!attachTo) return;
|
|
2910
2748
|
const handleMouseEnter = /* @__PURE__ */ __name(() => setIsHovered(true), "handleMouseEnter");
|
|
2911
2749
|
const handleMouseLeave = /* @__PURE__ */ __name(() => setIsHovered(false), "handleMouseLeave");
|
|
@@ -2916,7 +2754,7 @@ function WidgetDebugger({
|
|
|
2916
2754
|
attachTo.removeEventListener("mouseleave", handleMouseLeave);
|
|
2917
2755
|
};
|
|
2918
2756
|
}, [attachTo]);
|
|
2919
|
-
(0,
|
|
2757
|
+
(0, import_react6.useEffect)(() => {
|
|
2920
2758
|
if (!isOverlayOpen) return;
|
|
2921
2759
|
const handleClickOutside = /* @__PURE__ */ __name((event) => {
|
|
2922
2760
|
if (overlayRef.current && !overlayRef.current.contains(event.target)) {
|
|
@@ -2928,7 +2766,7 @@ function WidgetDebugger({
|
|
|
2928
2766
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
2929
2767
|
};
|
|
2930
2768
|
}, [isOverlayOpen]);
|
|
2931
|
-
(0,
|
|
2769
|
+
(0, import_react6.useEffect)(() => {
|
|
2932
2770
|
if (isOverlayOpen) {
|
|
2933
2771
|
document.body.style.overflow = "hidden";
|
|
2934
2772
|
} else {
|
|
@@ -2987,128 +2825,97 @@ function WidgetDebugger({
|
|
|
2987
2825
|
setActionResult(`Error: ${error.message}`);
|
|
2988
2826
|
}
|
|
2989
2827
|
}, "handleSetState");
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2828
|
+
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
2829
|
+
try {
|
|
2830
|
+
await requestDisplayMode("fullscreen");
|
|
2831
|
+
} catch (error) {
|
|
2832
|
+
console.error("Failed to go fullscreen:", error);
|
|
2833
|
+
}
|
|
2834
|
+
}, "handleFullscreen");
|
|
2835
|
+
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
2836
|
+
try {
|
|
2837
|
+
await requestDisplayMode("pip");
|
|
2838
|
+
} catch (error) {
|
|
2839
|
+
console.error("Failed to go pip:", error);
|
|
2840
|
+
}
|
|
2841
|
+
}, "handlePip");
|
|
2842
|
+
const getTooltipClasses = /* @__PURE__ */ __name(() => {
|
|
2843
|
+
const baseClasses = [
|
|
2844
|
+
"absolute",
|
|
2845
|
+
"px-2",
|
|
2846
|
+
"py-1",
|
|
2847
|
+
"bg-black/90",
|
|
2848
|
+
"text-white",
|
|
2849
|
+
"rounded",
|
|
2850
|
+
"text-xs",
|
|
2851
|
+
"whitespace-nowrap",
|
|
2852
|
+
"pointer-events-none",
|
|
2853
|
+
"transition-opacity",
|
|
2854
|
+
"duration-200",
|
|
2855
|
+
"ease-in-out"
|
|
2856
|
+
];
|
|
3002
2857
|
switch (position) {
|
|
3003
2858
|
case "top-right":
|
|
3004
|
-
return
|
|
3005
|
-
...baseStyles,
|
|
3006
|
-
top: "100%",
|
|
3007
|
-
right: "0",
|
|
3008
|
-
marginTop: "8px"
|
|
3009
|
-
};
|
|
2859
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
3010
2860
|
case "top-left":
|
|
3011
|
-
return
|
|
3012
|
-
...baseStyles,
|
|
3013
|
-
top: "100%",
|
|
3014
|
-
left: "0",
|
|
3015
|
-
marginTop: "8px"
|
|
3016
|
-
};
|
|
2861
|
+
return [...baseClasses, "top-full", "left-0", "mt-2"];
|
|
3017
2862
|
case "top-center":
|
|
3018
|
-
return
|
|
3019
|
-
...
|
|
3020
|
-
top
|
|
3021
|
-
left
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
2863
|
+
return [
|
|
2864
|
+
...baseClasses,
|
|
2865
|
+
"top-full",
|
|
2866
|
+
"left-1/2",
|
|
2867
|
+
"-translate-x-1/2",
|
|
2868
|
+
"mt-2"
|
|
2869
|
+
];
|
|
3025
2870
|
case "bottom-right":
|
|
3026
|
-
return
|
|
3027
|
-
...baseStyles,
|
|
3028
|
-
bottom: "100%",
|
|
3029
|
-
right: "0",
|
|
3030
|
-
marginBottom: "8px"
|
|
3031
|
-
};
|
|
2871
|
+
return [...baseClasses, "bottom-full", "right-0", "mb-2"];
|
|
3032
2872
|
case "bottom-left":
|
|
3033
|
-
return
|
|
3034
|
-
...baseStyles,
|
|
3035
|
-
bottom: "100%",
|
|
3036
|
-
left: "0",
|
|
3037
|
-
marginBottom: "8px"
|
|
3038
|
-
};
|
|
2873
|
+
return [...baseClasses, "bottom-full", "left-0", "mb-2"];
|
|
3039
2874
|
case "bottom-center":
|
|
3040
|
-
return
|
|
3041
|
-
...
|
|
3042
|
-
bottom
|
|
3043
|
-
left
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
2875
|
+
return [
|
|
2876
|
+
...baseClasses,
|
|
2877
|
+
"bottom-full",
|
|
2878
|
+
"left-1/2",
|
|
2879
|
+
"-translate-x-1/2",
|
|
2880
|
+
"mb-2"
|
|
2881
|
+
];
|
|
3047
2882
|
case "center-left":
|
|
3048
|
-
return
|
|
3049
|
-
...
|
|
3050
|
-
left
|
|
3051
|
-
top
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
2883
|
+
return [
|
|
2884
|
+
...baseClasses,
|
|
2885
|
+
"left-full",
|
|
2886
|
+
"top-1/2",
|
|
2887
|
+
"-translate-y-1/2",
|
|
2888
|
+
"ml-2"
|
|
2889
|
+
];
|
|
3055
2890
|
case "center-right":
|
|
3056
|
-
return
|
|
3057
|
-
...
|
|
3058
|
-
right
|
|
3059
|
-
top
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
2891
|
+
return [
|
|
2892
|
+
...baseClasses,
|
|
2893
|
+
"right-full",
|
|
2894
|
+
"top-1/2",
|
|
2895
|
+
"-translate-y-1/2",
|
|
2896
|
+
"mr-2"
|
|
2897
|
+
];
|
|
3063
2898
|
default:
|
|
3064
|
-
return
|
|
3065
|
-
...baseStyles,
|
|
3066
|
-
top: "100%",
|
|
3067
|
-
right: "0",
|
|
3068
|
-
marginTop: "8px"
|
|
3069
|
-
};
|
|
2899
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
3070
2900
|
}
|
|
3071
|
-
}, "
|
|
2901
|
+
}, "getTooltipClasses");
|
|
3072
2902
|
const IconButton = /* @__PURE__ */ __name(({
|
|
3073
2903
|
onClick,
|
|
3074
2904
|
label,
|
|
3075
2905
|
children: icon
|
|
3076
2906
|
}) => {
|
|
3077
|
-
const [isButtonHovered, setIsButtonHovered] = (0,
|
|
3078
|
-
const
|
|
3079
|
-
return /* @__PURE__ */
|
|
2907
|
+
const [isButtonHovered, setIsButtonHovered] = (0, import_react6.useState)(false);
|
|
2908
|
+
const tooltipClasses = getTooltipClasses();
|
|
2909
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
3080
2910
|
"button",
|
|
3081
2911
|
{
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
color: buttonColor,
|
|
3086
|
-
border: "none",
|
|
3087
|
-
borderRadius: "8px",
|
|
3088
|
-
cursor: "pointer",
|
|
3089
|
-
display: "flex",
|
|
3090
|
-
alignItems: "center",
|
|
3091
|
-
justifyContent: "center",
|
|
3092
|
-
width: "32px",
|
|
3093
|
-
height: "32px",
|
|
3094
|
-
transition: "background-color 0.2s",
|
|
3095
|
-
backdropFilter: "blur(8px)",
|
|
3096
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
3097
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
3098
|
-
position: "relative"
|
|
3099
|
-
},
|
|
3100
|
-
onMouseEnter: (e) => {
|
|
3101
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
3102
|
-
setIsButtonHovered(true);
|
|
3103
|
-
},
|
|
3104
|
-
onMouseLeave: (e) => {
|
|
3105
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
3106
|
-
setIsButtonHovered(false);
|
|
3107
|
-
},
|
|
2912
|
+
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`,
|
|
2913
|
+
onMouseEnter: () => setIsButtonHovered(true),
|
|
2914
|
+
onMouseLeave: () => setIsButtonHovered(false),
|
|
3108
2915
|
onClick,
|
|
3109
2916
|
"aria-label": label
|
|
3110
2917
|
},
|
|
3111
|
-
/* @__PURE__ */
|
|
2918
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
3112
2919
|
"svg",
|
|
3113
2920
|
{
|
|
3114
2921
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3120,17 +2927,14 @@ function WidgetDebugger({
|
|
|
3120
2927
|
strokeWidth: "2",
|
|
3121
2928
|
strokeLinecap: "round",
|
|
3122
2929
|
strokeLinejoin: "round",
|
|
3123
|
-
|
|
2930
|
+
className: "block"
|
|
3124
2931
|
},
|
|
3125
2932
|
icon
|
|
3126
2933
|
),
|
|
3127
|
-
showLabels && /* @__PURE__ */
|
|
2934
|
+
showLabels && /* @__PURE__ */ import_react6.default.createElement(
|
|
3128
2935
|
"span",
|
|
3129
2936
|
{
|
|
3130
|
-
|
|
3131
|
-
...tooltipStyles,
|
|
3132
|
-
opacity: isButtonHovered ? 1 : 0
|
|
3133
|
-
}
|
|
2937
|
+
className: `${tooltipClasses.join(" ")} ${isButtonHovered ? "opacity-100" : "opacity-0"}`
|
|
3134
2938
|
},
|
|
3135
2939
|
label
|
|
3136
2940
|
)
|
|
@@ -3157,567 +2961,245 @@ function WidgetDebugger({
|
|
|
3157
2961
|
const { top, bottom, left, right } = sa.insets;
|
|
3158
2962
|
return `T:${top} B:${bottom} L:${left} R:${right}`;
|
|
3159
2963
|
}, "formatSafeArea");
|
|
3160
|
-
return /* @__PURE__ */
|
|
2964
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(
|
|
3161
2965
|
"div",
|
|
3162
2966
|
{
|
|
3163
2967
|
ref: containerRef,
|
|
3164
|
-
className
|
|
3165
|
-
style: {
|
|
3166
|
-
position: "relative",
|
|
3167
|
-
height: "fit-content"
|
|
3168
|
-
},
|
|
2968
|
+
className: `${className} relative h-fit`,
|
|
3169
2969
|
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
3170
2970
|
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
3171
2971
|
},
|
|
3172
|
-
/* @__PURE__ */
|
|
2972
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
2973
|
+
"div",
|
|
2974
|
+
{
|
|
2975
|
+
className: getPositionClasses().join(" "),
|
|
2976
|
+
style: getPositionOffsetStyles()
|
|
2977
|
+
},
|
|
2978
|
+
!isDevMode && /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, !isFullscreen && !isPip && /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, (viewControls === true || viewControls === "fullscreen") && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M9 21H3v-6" })), (viewControls === true || viewControls === "pip") && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ import_react6.default.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))), enableDebugger && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handleToggleOverlay, label: "Debug Info" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M12 20v-9" }), /* @__PURE__ */ import_react6.default.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__ */ import_react6.default.createElement("path", { d: "M14.12 3.88 16 2" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 21a4 4 0 0 0-3.81-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 5a4 4 0 0 1-3.55 3.97" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M22 13h-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M3 21a4 4 0 0 1 3.81-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M3 5a4 4 0 0 0 3.55 3.97" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M6 13H2" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m8 2 1.88 1.88" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M9 7.13V6a3 3 0 1 1 6 0v1.13" })))
|
|
2979
|
+
),
|
|
3173
2980
|
children
|
|
3174
|
-
), isOverlayOpen && /* @__PURE__ */
|
|
2981
|
+
), isOverlayOpen && enableDebugger && /* @__PURE__ */ import_react6.default.createElement(
|
|
3175
2982
|
"div",
|
|
3176
2983
|
{
|
|
3177
2984
|
ref: overlayRef,
|
|
3178
|
-
|
|
3179
|
-
position: "fixed",
|
|
3180
|
-
top: 0,
|
|
3181
|
-
left: 0,
|
|
3182
|
-
right: 0,
|
|
3183
|
-
bottom: 0,
|
|
3184
|
-
backgroundColor: "#000000",
|
|
3185
|
-
color: "#ffffff",
|
|
3186
|
-
fontFamily: "monospace",
|
|
3187
|
-
fontSize: "12px",
|
|
3188
|
-
zIndex: 1e4,
|
|
3189
|
-
overflow: "auto",
|
|
3190
|
-
padding: "16px"
|
|
3191
|
-
},
|
|
2985
|
+
className: "fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",
|
|
3192
2986
|
onClick: (e) => {
|
|
3193
2987
|
if (e.target === overlayRef.current) {
|
|
3194
2988
|
setIsOverlayOpen(false);
|
|
3195
2989
|
}
|
|
3196
2990
|
}
|
|
3197
2991
|
},
|
|
3198
|
-
/* @__PURE__ */
|
|
2992
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
3199
2993
|
"button",
|
|
3200
2994
|
{
|
|
3201
2995
|
onClick: () => setIsOverlayOpen(false),
|
|
3202
|
-
|
|
3203
|
-
position: "absolute",
|
|
3204
|
-
top: "16px",
|
|
3205
|
-
right: "16px",
|
|
3206
|
-
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
3207
|
-
color: "#ffffff",
|
|
3208
|
-
border: "none",
|
|
3209
|
-
borderRadius: "4px",
|
|
3210
|
-
width: "32px",
|
|
3211
|
-
height: "32px",
|
|
3212
|
-
cursor: "pointer",
|
|
3213
|
-
display: "flex",
|
|
3214
|
-
alignItems: "center",
|
|
3215
|
-
justifyContent: "center",
|
|
3216
|
-
fontSize: "18px",
|
|
3217
|
-
lineHeight: 1
|
|
3218
|
-
},
|
|
2996
|
+
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",
|
|
3219
2997
|
"aria-label": "Close"
|
|
3220
2998
|
},
|
|
3221
2999
|
"\xD7"
|
|
3222
3000
|
),
|
|
3223
|
-
/* @__PURE__ */
|
|
3224
|
-
"
|
|
3001
|
+
/* @__PURE__ */ import_react6.default.createElement("div", { className: "max-w-[1200px] mx-auto pt-10" }, /* @__PURE__ */ import_react6.default.createElement("h1", { className: "text-lg font-bold mb-4 border-b border-gray-700 pb-2" }, "Debug Info"), /* @__PURE__ */ import_react6.default.createElement("table", { className: "w-full border-collapse border-spacing-0" }, /* @__PURE__ */ import_react6.default.createElement("tbody", null, /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Props"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(props))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Output"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(output))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Metadata"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(metadata))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "State"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(state))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Theme"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, theme)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Display Mode"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, displayMode)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Locale"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, locale)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Max Height"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, maxHeight, "px")), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "User Agent"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, formatUserAgent(userAgent))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Safe Area"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, formatSafeArea(safeArea))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "API Available"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "window.openai Keys"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))), /* @__PURE__ */ import_react6.default.createElement("h2", { className: "text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2" }, "Actions"), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-3" }, /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
3002
|
+
"input",
|
|
3225
3003
|
{
|
|
3226
|
-
|
|
3004
|
+
type: "text",
|
|
3005
|
+
value: toolName,
|
|
3006
|
+
onChange: (e) => setToolName(e.target.value),
|
|
3007
|
+
placeholder: "Tool name",
|
|
3008
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"
|
|
3009
|
+
}
|
|
3010
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3011
|
+
"input",
|
|
3012
|
+
{
|
|
3013
|
+
type: "text",
|
|
3014
|
+
value: toolArgs,
|
|
3015
|
+
onChange: (e) => setToolArgs(e.target.value),
|
|
3016
|
+
placeholder: '{"key": "value"}',
|
|
3017
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
3018
|
+
}
|
|
3019
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3020
|
+
"button",
|
|
3021
|
+
{
|
|
3022
|
+
onClick: handleCallTool,
|
|
3023
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
3227
3024
|
},
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
"
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
)
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
)
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
fontWeight: "bold",
|
|
3298
|
-
width: "200px",
|
|
3299
|
-
verticalAlign: "top"
|
|
3300
|
-
}
|
|
3301
|
-
},
|
|
3302
|
-
"Metadata"
|
|
3303
|
-
), /* @__PURE__ */ import_react4.default.createElement(
|
|
3304
|
-
"td",
|
|
3305
|
-
{
|
|
3306
|
-
style: {
|
|
3307
|
-
padding: "8px",
|
|
3308
|
-
whiteSpace: "pre-wrap",
|
|
3309
|
-
wordBreak: "break-all"
|
|
3310
|
-
}
|
|
3311
|
-
},
|
|
3312
|
-
formatValue(metadata)
|
|
3313
|
-
)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3314
|
-
"td",
|
|
3315
|
-
{
|
|
3316
|
-
style: {
|
|
3317
|
-
padding: "8px",
|
|
3318
|
-
fontWeight: "bold",
|
|
3319
|
-
width: "200px",
|
|
3320
|
-
verticalAlign: "top"
|
|
3321
|
-
}
|
|
3322
|
-
},
|
|
3323
|
-
"State"
|
|
3324
|
-
), /* @__PURE__ */ import_react4.default.createElement(
|
|
3325
|
-
"td",
|
|
3326
|
-
{
|
|
3327
|
-
style: {
|
|
3328
|
-
padding: "8px",
|
|
3329
|
-
whiteSpace: "pre-wrap",
|
|
3330
|
-
wordBreak: "break-all"
|
|
3331
|
-
}
|
|
3332
|
-
},
|
|
3333
|
-
formatValue(state)
|
|
3334
|
-
)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3335
|
-
"td",
|
|
3336
|
-
{
|
|
3337
|
-
style: {
|
|
3338
|
-
padding: "8px",
|
|
3339
|
-
fontWeight: "bold",
|
|
3340
|
-
width: "200px",
|
|
3341
|
-
verticalAlign: "top"
|
|
3342
|
-
}
|
|
3343
|
-
},
|
|
3344
|
-
"Theme"
|
|
3345
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, theme)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3346
|
-
"td",
|
|
3347
|
-
{
|
|
3348
|
-
style: {
|
|
3349
|
-
padding: "8px",
|
|
3350
|
-
fontWeight: "bold",
|
|
3351
|
-
width: "200px",
|
|
3352
|
-
verticalAlign: "top"
|
|
3353
|
-
}
|
|
3354
|
-
},
|
|
3355
|
-
"Display Mode"
|
|
3356
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, displayMode)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3357
|
-
"td",
|
|
3358
|
-
{
|
|
3359
|
-
style: {
|
|
3360
|
-
padding: "8px",
|
|
3361
|
-
fontWeight: "bold",
|
|
3362
|
-
width: "200px",
|
|
3363
|
-
verticalAlign: "top"
|
|
3364
|
-
}
|
|
3365
|
-
},
|
|
3366
|
-
"Locale"
|
|
3367
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, locale)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3368
|
-
"td",
|
|
3369
|
-
{
|
|
3370
|
-
style: {
|
|
3371
|
-
padding: "8px",
|
|
3372
|
-
fontWeight: "bold",
|
|
3373
|
-
width: "200px",
|
|
3374
|
-
verticalAlign: "top"
|
|
3375
|
-
}
|
|
3376
|
-
},
|
|
3377
|
-
"Max Height"
|
|
3378
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, maxHeight, "px")), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3379
|
-
"td",
|
|
3380
|
-
{
|
|
3381
|
-
style: {
|
|
3382
|
-
padding: "8px",
|
|
3383
|
-
fontWeight: "bold",
|
|
3384
|
-
width: "200px",
|
|
3385
|
-
verticalAlign: "top"
|
|
3386
|
-
}
|
|
3387
|
-
},
|
|
3388
|
-
"User Agent"
|
|
3389
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, formatUserAgent(userAgent))), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3390
|
-
"td",
|
|
3391
|
-
{
|
|
3392
|
-
style: {
|
|
3393
|
-
padding: "8px",
|
|
3394
|
-
fontWeight: "bold",
|
|
3395
|
-
width: "200px",
|
|
3396
|
-
verticalAlign: "top"
|
|
3397
|
-
}
|
|
3398
|
-
},
|
|
3399
|
-
"Safe Area"
|
|
3400
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, formatSafeArea(safeArea))), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3401
|
-
"td",
|
|
3402
|
-
{
|
|
3403
|
-
style: {
|
|
3404
|
-
padding: "8px",
|
|
3405
|
-
fontWeight: "bold",
|
|
3406
|
-
width: "200px",
|
|
3407
|
-
verticalAlign: "top"
|
|
3408
|
-
}
|
|
3409
|
-
},
|
|
3410
|
-
"API Available"
|
|
3411
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
3412
|
-
"td",
|
|
3413
|
-
{
|
|
3414
|
-
style: {
|
|
3415
|
-
padding: "8px",
|
|
3416
|
-
fontWeight: "bold",
|
|
3417
|
-
width: "200px",
|
|
3418
|
-
verticalAlign: "top"
|
|
3419
|
-
}
|
|
3420
|
-
},
|
|
3421
|
-
"window.openai Keys"
|
|
3422
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))
|
|
3423
|
-
),
|
|
3424
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3425
|
-
"h2",
|
|
3426
|
-
{
|
|
3427
|
-
style: {
|
|
3428
|
-
fontSize: "16px",
|
|
3429
|
-
fontWeight: "bold",
|
|
3430
|
-
marginTop: "32px",
|
|
3431
|
-
marginBottom: "16px",
|
|
3432
|
-
borderBottom: "1px solid #333",
|
|
3433
|
-
paddingBottom: "8px"
|
|
3434
|
-
}
|
|
3435
|
-
},
|
|
3436
|
-
"Actions"
|
|
3437
|
-
),
|
|
3438
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3439
|
-
"div",
|
|
3440
|
-
{
|
|
3441
|
-
style: { display: "flex", flexDirection: "column", gap: "12px" }
|
|
3442
|
-
},
|
|
3443
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3444
|
-
"div",
|
|
3445
|
-
{
|
|
3446
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
3447
|
-
},
|
|
3448
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3449
|
-
"input",
|
|
3450
|
-
{
|
|
3451
|
-
type: "text",
|
|
3452
|
-
value: toolName,
|
|
3453
|
-
onChange: (e) => setToolName(e.target.value),
|
|
3454
|
-
placeholder: "Tool name",
|
|
3455
|
-
style: {
|
|
3456
|
-
padding: "6px 8px",
|
|
3457
|
-
backgroundColor: "#1a1a1a",
|
|
3458
|
-
color: "#ffffff",
|
|
3459
|
-
border: "1px solid #333",
|
|
3460
|
-
borderRadius: "4px",
|
|
3461
|
-
fontFamily: "monospace",
|
|
3462
|
-
fontSize: "12px",
|
|
3463
|
-
width: "150px"
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
),
|
|
3467
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3468
|
-
"input",
|
|
3469
|
-
{
|
|
3470
|
-
type: "text",
|
|
3471
|
-
value: toolArgs,
|
|
3472
|
-
onChange: (e) => setToolArgs(e.target.value),
|
|
3473
|
-
placeholder: '{"key": "value"}',
|
|
3474
|
-
style: {
|
|
3475
|
-
padding: "6px 8px",
|
|
3476
|
-
backgroundColor: "#1a1a1a",
|
|
3477
|
-
color: "#ffffff",
|
|
3478
|
-
border: "1px solid #333",
|
|
3479
|
-
borderRadius: "4px",
|
|
3480
|
-
fontFamily: "monospace",
|
|
3481
|
-
fontSize: "12px",
|
|
3482
|
-
flex: 1
|
|
3483
|
-
}
|
|
3484
|
-
}
|
|
3485
|
-
),
|
|
3486
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3487
|
-
"button",
|
|
3488
|
-
{
|
|
3489
|
-
onClick: handleCallTool,
|
|
3490
|
-
style: {
|
|
3491
|
-
padding: "6px 12px",
|
|
3492
|
-
backgroundColor: "#333",
|
|
3493
|
-
color: "#ffffff",
|
|
3494
|
-
border: "1px solid #555",
|
|
3495
|
-
borderRadius: "4px",
|
|
3496
|
-
cursor: "pointer",
|
|
3497
|
-
fontFamily: "monospace",
|
|
3498
|
-
fontSize: "12px"
|
|
3499
|
-
}
|
|
3500
|
-
},
|
|
3501
|
-
"Call Tool"
|
|
3502
|
-
)
|
|
3503
|
-
),
|
|
3504
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3505
|
-
"div",
|
|
3506
|
-
{
|
|
3507
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
3508
|
-
},
|
|
3509
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3510
|
-
"input",
|
|
3511
|
-
{
|
|
3512
|
-
type: "text",
|
|
3513
|
-
value: followUpMessage,
|
|
3514
|
-
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
3515
|
-
placeholder: "Follow-up message",
|
|
3516
|
-
style: {
|
|
3517
|
-
padding: "6px 8px",
|
|
3518
|
-
backgroundColor: "#1a1a1a",
|
|
3519
|
-
color: "#ffffff",
|
|
3520
|
-
border: "1px solid #333",
|
|
3521
|
-
borderRadius: "4px",
|
|
3522
|
-
fontFamily: "monospace",
|
|
3523
|
-
fontSize: "12px",
|
|
3524
|
-
flex: 1
|
|
3525
|
-
}
|
|
3526
|
-
}
|
|
3527
|
-
),
|
|
3528
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3529
|
-
"button",
|
|
3530
|
-
{
|
|
3531
|
-
onClick: handleSendFollowUpMessage,
|
|
3532
|
-
style: {
|
|
3533
|
-
padding: "6px 12px",
|
|
3534
|
-
backgroundColor: "#333",
|
|
3535
|
-
color: "#ffffff",
|
|
3536
|
-
border: "1px solid #555",
|
|
3537
|
-
borderRadius: "4px",
|
|
3538
|
-
cursor: "pointer",
|
|
3539
|
-
fontFamily: "monospace",
|
|
3540
|
-
fontSize: "12px"
|
|
3541
|
-
}
|
|
3542
|
-
},
|
|
3543
|
-
"Send Follow-Up"
|
|
3544
|
-
)
|
|
3545
|
-
),
|
|
3546
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3547
|
-
"div",
|
|
3548
|
-
{
|
|
3549
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
3550
|
-
},
|
|
3551
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3552
|
-
"input",
|
|
3553
|
-
{
|
|
3554
|
-
type: "text",
|
|
3555
|
-
value: externalUrl,
|
|
3556
|
-
onChange: (e) => setExternalUrl(e.target.value),
|
|
3557
|
-
placeholder: "External URL",
|
|
3558
|
-
style: {
|
|
3559
|
-
padding: "6px 8px",
|
|
3560
|
-
backgroundColor: "#1a1a1a",
|
|
3561
|
-
color: "#ffffff",
|
|
3562
|
-
border: "1px solid #333",
|
|
3563
|
-
borderRadius: "4px",
|
|
3564
|
-
fontFamily: "monospace",
|
|
3565
|
-
fontSize: "12px",
|
|
3566
|
-
flex: 1
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
),
|
|
3570
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3571
|
-
"button",
|
|
3572
|
-
{
|
|
3573
|
-
onClick: handleOpenExternal,
|
|
3574
|
-
style: {
|
|
3575
|
-
padding: "6px 12px",
|
|
3576
|
-
backgroundColor: "#333",
|
|
3577
|
-
color: "#ffffff",
|
|
3578
|
-
border: "1px solid #555",
|
|
3579
|
-
borderRadius: "4px",
|
|
3580
|
-
cursor: "pointer",
|
|
3581
|
-
fontFamily: "monospace",
|
|
3582
|
-
fontSize: "12px"
|
|
3583
|
-
}
|
|
3584
|
-
},
|
|
3585
|
-
"Open Link"
|
|
3586
|
-
)
|
|
3587
|
-
),
|
|
3588
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3589
|
-
"div",
|
|
3590
|
-
{
|
|
3591
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
3592
|
-
},
|
|
3593
|
-
/* @__PURE__ */ import_react4.default.createElement("span", { style: { width: "150px", fontSize: "12px" } }, "Display Mode:"),
|
|
3594
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3595
|
-
"button",
|
|
3596
|
-
{
|
|
3597
|
-
onClick: () => handleRequestDisplayMode("inline"),
|
|
3598
|
-
style: {
|
|
3599
|
-
padding: "6px 12px",
|
|
3600
|
-
backgroundColor: "#333",
|
|
3601
|
-
color: "#ffffff",
|
|
3602
|
-
border: "1px solid #555",
|
|
3603
|
-
borderRadius: "4px",
|
|
3604
|
-
cursor: "pointer",
|
|
3605
|
-
fontFamily: "monospace",
|
|
3606
|
-
fontSize: "12px",
|
|
3607
|
-
flex: 1
|
|
3608
|
-
}
|
|
3609
|
-
},
|
|
3610
|
-
"Inline"
|
|
3611
|
-
),
|
|
3612
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3613
|
-
"button",
|
|
3614
|
-
{
|
|
3615
|
-
onClick: () => handleRequestDisplayMode("pip"),
|
|
3616
|
-
style: {
|
|
3617
|
-
padding: "6px 12px",
|
|
3618
|
-
backgroundColor: "#333",
|
|
3619
|
-
color: "#ffffff",
|
|
3620
|
-
border: "1px solid #555",
|
|
3621
|
-
borderRadius: "4px",
|
|
3622
|
-
cursor: "pointer",
|
|
3623
|
-
fontFamily: "monospace",
|
|
3624
|
-
fontSize: "12px",
|
|
3625
|
-
flex: 1
|
|
3626
|
-
}
|
|
3627
|
-
},
|
|
3628
|
-
"PiP"
|
|
3629
|
-
),
|
|
3630
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3631
|
-
"button",
|
|
3632
|
-
{
|
|
3633
|
-
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
3634
|
-
style: {
|
|
3635
|
-
padding: "6px 12px",
|
|
3636
|
-
backgroundColor: "#333",
|
|
3637
|
-
color: "#ffffff",
|
|
3638
|
-
border: "1px solid #555",
|
|
3639
|
-
borderRadius: "4px",
|
|
3640
|
-
cursor: "pointer",
|
|
3641
|
-
fontFamily: "monospace",
|
|
3642
|
-
fontSize: "12px",
|
|
3643
|
-
flex: 1
|
|
3644
|
-
}
|
|
3645
|
-
},
|
|
3646
|
-
"Fullscreen"
|
|
3647
|
-
)
|
|
3648
|
-
),
|
|
3649
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3650
|
-
"div",
|
|
3651
|
-
{
|
|
3652
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
3653
|
-
},
|
|
3654
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3655
|
-
"button",
|
|
3656
|
-
{
|
|
3657
|
-
onClick: handleSetState,
|
|
3658
|
-
style: {
|
|
3659
|
-
padding: "6px 12px",
|
|
3660
|
-
backgroundColor: "#333",
|
|
3661
|
-
color: "#ffffff",
|
|
3662
|
-
border: "1px solid #555",
|
|
3663
|
-
borderRadius: "4px",
|
|
3664
|
-
cursor: "pointer",
|
|
3665
|
-
fontFamily: "monospace",
|
|
3666
|
-
fontSize: "12px"
|
|
3667
|
-
}
|
|
3668
|
-
},
|
|
3669
|
-
"Set State (Add Timestamp)"
|
|
3670
|
-
)
|
|
3671
|
-
),
|
|
3672
|
-
actionResult && /* @__PURE__ */ import_react4.default.createElement(
|
|
3673
|
-
"div",
|
|
3674
|
-
{
|
|
3675
|
-
style: {
|
|
3676
|
-
marginTop: "8px",
|
|
3677
|
-
padding: "8px",
|
|
3678
|
-
backgroundColor: "#1a1a1a",
|
|
3679
|
-
border: "1px solid #333",
|
|
3680
|
-
borderRadius: "4px",
|
|
3681
|
-
whiteSpace: "pre-wrap",
|
|
3682
|
-
wordBreak: "break-all",
|
|
3683
|
-
fontSize: "11px",
|
|
3684
|
-
maxHeight: "200px",
|
|
3685
|
-
overflow: "auto"
|
|
3686
|
-
}
|
|
3687
|
-
},
|
|
3688
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3689
|
-
"div",
|
|
3690
|
-
{
|
|
3691
|
-
style: {
|
|
3692
|
-
fontWeight: "bold",
|
|
3693
|
-
marginBottom: "4px",
|
|
3694
|
-
color: "#aaa"
|
|
3695
|
-
}
|
|
3696
|
-
},
|
|
3697
|
-
"Result:"
|
|
3698
|
-
),
|
|
3699
|
-
actionResult,
|
|
3700
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
3701
|
-
"button",
|
|
3702
|
-
{
|
|
3703
|
-
onClick: () => setActionResult(""),
|
|
3704
|
-
style: {
|
|
3705
|
-
marginTop: "8px",
|
|
3706
|
-
padding: "4px 8px",
|
|
3707
|
-
backgroundColor: "#333",
|
|
3708
|
-
color: "#ffffff",
|
|
3709
|
-
border: "1px solid #555",
|
|
3710
|
-
borderRadius: "4px",
|
|
3711
|
-
cursor: "pointer",
|
|
3712
|
-
fontFamily: "monospace",
|
|
3713
|
-
fontSize: "11px"
|
|
3714
|
-
}
|
|
3715
|
-
},
|
|
3716
|
-
"Clear"
|
|
3717
|
-
)
|
|
3718
|
-
)
|
|
3719
|
-
)
|
|
3720
|
-
)
|
|
3025
|
+
"Call Tool"
|
|
3026
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
3027
|
+
"input",
|
|
3028
|
+
{
|
|
3029
|
+
type: "text",
|
|
3030
|
+
value: followUpMessage,
|
|
3031
|
+
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
3032
|
+
placeholder: "Follow-up message",
|
|
3033
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
3034
|
+
}
|
|
3035
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3036
|
+
"button",
|
|
3037
|
+
{
|
|
3038
|
+
onClick: handleSendFollowUpMessage,
|
|
3039
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
3040
|
+
},
|
|
3041
|
+
"Send Follow-Up"
|
|
3042
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
3043
|
+
"input",
|
|
3044
|
+
{
|
|
3045
|
+
type: "text",
|
|
3046
|
+
value: externalUrl,
|
|
3047
|
+
onChange: (e) => setExternalUrl(e.target.value),
|
|
3048
|
+
placeholder: "External URL",
|
|
3049
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
3050
|
+
}
|
|
3051
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3052
|
+
"button",
|
|
3053
|
+
{
|
|
3054
|
+
onClick: handleOpenExternal,
|
|
3055
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
3056
|
+
},
|
|
3057
|
+
"Open Link"
|
|
3058
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement("span", { className: "w-[150px] text-xs" }, "Display Mode:"), /* @__PURE__ */ import_react6.default.createElement(
|
|
3059
|
+
"button",
|
|
3060
|
+
{
|
|
3061
|
+
onClick: () => handleRequestDisplayMode("inline"),
|
|
3062
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
3063
|
+
},
|
|
3064
|
+
"Inline"
|
|
3065
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3066
|
+
"button",
|
|
3067
|
+
{
|
|
3068
|
+
onClick: () => handleRequestDisplayMode("pip"),
|
|
3069
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
3070
|
+
},
|
|
3071
|
+
"PiP"
|
|
3072
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
3073
|
+
"button",
|
|
3074
|
+
{
|
|
3075
|
+
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
3076
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
3077
|
+
},
|
|
3078
|
+
"Fullscreen"
|
|
3079
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
3080
|
+
"button",
|
|
3081
|
+
{
|
|
3082
|
+
onClick: handleSetState,
|
|
3083
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
3084
|
+
},
|
|
3085
|
+
"Set State (Add Timestamp)"
|
|
3086
|
+
)), actionResult && /* @__PURE__ */ import_react6.default.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__ */ import_react6.default.createElement("div", { className: "font-bold mb-1 text-gray-400" }, "Result:"), actionResult, /* @__PURE__ */ import_react6.default.createElement(
|
|
3087
|
+
"button",
|
|
3088
|
+
{
|
|
3089
|
+
onClick: () => setActionResult(""),
|
|
3090
|
+
className: "mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"
|
|
3091
|
+
},
|
|
3092
|
+
"Clear"
|
|
3093
|
+
))))
|
|
3721
3094
|
));
|
|
3722
3095
|
}
|
|
3723
|
-
__name(
|
|
3096
|
+
__name(WidgetControls, "WidgetControls");
|
|
3097
|
+
|
|
3098
|
+
// src/react/McpUseProvider.tsx
|
|
3099
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
3100
|
+
var import_react_router_dom = require("react-router-dom");
|
|
3101
|
+
function getBasename() {
|
|
3102
|
+
if (typeof window === "undefined") return "/";
|
|
3103
|
+
const path = window.location.pathname;
|
|
3104
|
+
const match = path.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
3105
|
+
if (match) {
|
|
3106
|
+
return match[1];
|
|
3107
|
+
}
|
|
3108
|
+
return "/";
|
|
3109
|
+
}
|
|
3110
|
+
__name(getBasename, "getBasename");
|
|
3111
|
+
var HEIGHT_DEBOUNCE_MS = 150;
|
|
3112
|
+
var MIN_HEIGHT_CHANGE_PX = 5;
|
|
3113
|
+
function McpUseProvider({
|
|
3114
|
+
children,
|
|
3115
|
+
debugger: enableDebugger = false,
|
|
3116
|
+
viewControls = false,
|
|
3117
|
+
autoSize = false
|
|
3118
|
+
}) {
|
|
3119
|
+
const basename = getBasename();
|
|
3120
|
+
const containerRef = (0, import_react7.useRef)(null);
|
|
3121
|
+
const lastHeightRef = (0, import_react7.useRef)(0);
|
|
3122
|
+
const debounceTimeoutRef = (0, import_react7.useRef)(null);
|
|
3123
|
+
const notificationInProgressRef = (0, import_react7.useRef)(false);
|
|
3124
|
+
const notifyHeight = (0, import_react7.useCallback)((height) => {
|
|
3125
|
+
if (typeof window !== "undefined" && window.openai?.notifyIntrinsicHeight) {
|
|
3126
|
+
notificationInProgressRef.current = true;
|
|
3127
|
+
window.openai.notifyIntrinsicHeight(height).then(() => {
|
|
3128
|
+
notificationInProgressRef.current = false;
|
|
3129
|
+
}).catch((error) => {
|
|
3130
|
+
notificationInProgressRef.current = false;
|
|
3131
|
+
console.error(
|
|
3132
|
+
"[McpUseProvider] Failed to notify intrinsic height:",
|
|
3133
|
+
error
|
|
3134
|
+
);
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
}, []);
|
|
3138
|
+
const debouncedNotifyHeight = (0, import_react7.useCallback)(
|
|
3139
|
+
(height) => {
|
|
3140
|
+
if (debounceTimeoutRef.current) {
|
|
3141
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
3142
|
+
}
|
|
3143
|
+
debounceTimeoutRef.current = setTimeout(() => {
|
|
3144
|
+
const heightDiff = Math.abs(height - lastHeightRef.current);
|
|
3145
|
+
if (heightDiff >= MIN_HEIGHT_CHANGE_PX && height > 0) {
|
|
3146
|
+
lastHeightRef.current = height;
|
|
3147
|
+
notifyHeight(height);
|
|
3148
|
+
}
|
|
3149
|
+
}, HEIGHT_DEBOUNCE_MS);
|
|
3150
|
+
},
|
|
3151
|
+
[notifyHeight]
|
|
3152
|
+
);
|
|
3153
|
+
(0, import_react7.useEffect)(() => {
|
|
3154
|
+
if (!autoSize) {
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
const container = containerRef.current;
|
|
3158
|
+
if (!container || typeof ResizeObserver === "undefined") {
|
|
3159
|
+
return;
|
|
3160
|
+
}
|
|
3161
|
+
const observer = new ResizeObserver((entries) => {
|
|
3162
|
+
if (notificationInProgressRef.current) {
|
|
3163
|
+
return;
|
|
3164
|
+
}
|
|
3165
|
+
for (const entry of entries) {
|
|
3166
|
+
const height = entry.contentRect.height;
|
|
3167
|
+
const scrollHeight = entry.target.scrollHeight;
|
|
3168
|
+
const intrinsicHeight = Math.max(height, scrollHeight);
|
|
3169
|
+
debouncedNotifyHeight(intrinsicHeight);
|
|
3170
|
+
}
|
|
3171
|
+
});
|
|
3172
|
+
observer.observe(container);
|
|
3173
|
+
const initialHeight = Math.max(
|
|
3174
|
+
container.offsetHeight,
|
|
3175
|
+
container.scrollHeight
|
|
3176
|
+
);
|
|
3177
|
+
if (initialHeight > 0) {
|
|
3178
|
+
debouncedNotifyHeight(initialHeight);
|
|
3179
|
+
}
|
|
3180
|
+
return () => {
|
|
3181
|
+
observer.disconnect();
|
|
3182
|
+
if (debounceTimeoutRef.current) {
|
|
3183
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
3184
|
+
debounceTimeoutRef.current = null;
|
|
3185
|
+
}
|
|
3186
|
+
notificationInProgressRef.current = false;
|
|
3187
|
+
};
|
|
3188
|
+
}, [autoSize, debouncedNotifyHeight]);
|
|
3189
|
+
let content = children;
|
|
3190
|
+
content = /* @__PURE__ */ import_react7.default.createElement(ErrorBoundary, null, content);
|
|
3191
|
+
if (enableDebugger || viewControls) {
|
|
3192
|
+
content = /* @__PURE__ */ import_react7.default.createElement(WidgetControls, { debugger: enableDebugger, viewControls }, content);
|
|
3193
|
+
}
|
|
3194
|
+
content = /* @__PURE__ */ import_react7.default.createElement(import_react_router_dom.BrowserRouter, { basename }, content);
|
|
3195
|
+
content = /* @__PURE__ */ import_react7.default.createElement(ThemeProvider, null, content);
|
|
3196
|
+
if (autoSize) {
|
|
3197
|
+
const containerStyle = {
|
|
3198
|
+
width: "100%",
|
|
3199
|
+
minHeight: 0
|
|
3200
|
+
};
|
|
3201
|
+
content = /* @__PURE__ */ import_react7.default.createElement("div", { ref: containerRef, style: containerStyle }, content);
|
|
3202
|
+
}
|
|
3203
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.StrictMode, null, content);
|
|
3204
|
+
}
|
|
3205
|
+
__name(McpUseProvider, "McpUseProvider");
|