@leanmcp/ui 0.3.1 → 0.3.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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __name } from './chunk-KX75VCMM.mjs';
2
2
  export { GPTApp, UIApp, getGPTAppMetadata, getGPTAppUri, getUIAppMetadata, getUIAppUri } from './chunk-KX75VCMM.mjs';
3
3
  import * as React26 from 'react';
4
- import React26__default, { forwardRef, Component, useState, useRef, useCallback, useEffect, createContext, useContext, useMemo } from 'react';
4
+ import React26__default, { forwardRef, Component, useState, useRef, useCallback, useEffect, createContext, useContext, useMemo, useSyncExternalStore } from 'react';
5
5
  import { applyDocumentTheme, applyHostStyleVariables, applyHostFonts, PostMessageTransport, App } from '@modelcontextprotocol/ext-apps';
6
6
  export { App, PostMessageTransport, RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, applyDocumentTheme, applyHostFonts, applyHostStyleVariables, getDocumentTheme } from '@modelcontextprotocol/ext-apps';
7
7
  import { XIcon, ChevronDownIcon, CheckIcon, ChevronUpIcon, Loader2, SearchIcon, Search, X, AlertCircle, RefreshCw, ChevronLeft, ChevronRight, WifiOff, CircleIcon, ChevronRightIcon, Check, ArrowUpDown, ArrowUp, ArrowDown, Loader2Icon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon } from 'lucide-react';
@@ -2634,6 +2634,59 @@ function useToolSubscription(toolName, options = {}) {
2634
2634
  };
2635
2635
  }
2636
2636
  __name(useToolSubscription, "useToolSubscription");
2637
+ var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
2638
+ function useOpenAiGlobal(key) {
2639
+ return useSyncExternalStore((onChange) => {
2640
+ const handleSetGlobal = /* @__PURE__ */ __name((event) => {
2641
+ const customEvent = event;
2642
+ const value = customEvent.detail?.globals?.[key];
2643
+ if (value !== void 0) {
2644
+ onChange();
2645
+ }
2646
+ }, "handleSetGlobal");
2647
+ window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
2648
+ passive: true
2649
+ });
2650
+ return () => {
2651
+ window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
2652
+ };
2653
+ }, () => window.openai?.[key]);
2654
+ }
2655
+ __name(useOpenAiGlobal, "useOpenAiGlobal");
2656
+
2657
+ // src/mcp/useToolData.ts
2658
+ function useToolOutput() {
2659
+ return useOpenAiGlobal("toolOutput");
2660
+ }
2661
+ __name(useToolOutput, "useToolOutput");
2662
+ function useToolResponseMetadata() {
2663
+ return useOpenAiGlobal("toolResponseMetadata");
2664
+ }
2665
+ __name(useToolResponseMetadata, "useToolResponseMetadata");
2666
+ function useToolInput2() {
2667
+ return useOpenAiGlobal("toolInput");
2668
+ }
2669
+ __name(useToolInput2, "useToolInput");
2670
+ function useWidgetState(initialState) {
2671
+ const rawState = useOpenAiGlobal("widgetState");
2672
+ const resolvedInitial = rawState ?? (typeof initialState === "function" ? initialState() : initialState);
2673
+ const setWidgetState = useCallback((newStateOrUpdater) => {
2674
+ if (!window.openai?.setWidgetState) {
2675
+ console.warn("window.openai.setWidgetState is not available");
2676
+ return;
2677
+ }
2678
+ const current = window.openai.widgetState ?? resolvedInitial;
2679
+ const next = typeof newStateOrUpdater === "function" ? newStateOrUpdater(current) : newStateOrUpdater;
2680
+ window.openai.setWidgetState(next);
2681
+ }, [
2682
+ resolvedInitial
2683
+ ]);
2684
+ return [
2685
+ resolvedInitial,
2686
+ setWidgetState
2687
+ ];
2688
+ }
2689
+ __name(useWidgetState, "useWidgetState");
2637
2690
 
2638
2691
  // src/types/mcp-types.ts
2639
2692
  function normalizeToolBinding(tool) {
@@ -3388,6 +3441,6 @@ var Input2 = /* @__PURE__ */ forwardRef(({ className, label, helperText, error,
3388
3441
  });
3389
3442
  Input2.displayName = "Input";
3390
3443
 
3391
- export { ActionButton, Alert, AlertDescription, AlertTitle, AppProvider, AppShell, Badge, Button2 as Button, Card2 as Card, CardContent2 as CardContent, CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle, Chart, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_RESULT_CONFIG, DataGrid, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, INITIAL_TOOL_STATE, Input2 as Input, Label2 as Label, Modal, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, ResourceView, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Skeleton, Slider, StreamingContent, Switch, TabContent, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs2 as Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, ToolButton, ToolDataGrid, ToolErrorBoundary, ToolForm, ToolInput, ToolProvider, ToolSelect, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useResource, useTool, useToolContext, useToolInput, useToolInputPartial, useToolResult, useToolStream, useToolSubscription };
3444
+ export { ActionButton, Alert, AlertDescription, AlertTitle, AppProvider, AppShell, Badge, Button2 as Button, Card2 as Card, CardContent2 as CardContent, CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle, Chart, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_RESULT_CONFIG, DataGrid, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, INITIAL_TOOL_STATE, Input2 as Input, Label2 as Label, Modal, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, ResourceView, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Skeleton, Slider, StreamingContent, Switch, TabContent, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs2 as Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, ToolButton, ToolDataGrid, ToolErrorBoundary, ToolForm, ToolInput, ToolProvider, ToolSelect, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useOpenAiGlobal, useResource, useTool, useToolContext, useToolInput, useToolInputPartial, useToolInput2 as useToolInputSpec, useToolOutput, useToolResponseMetadata, useToolResult, useToolStream, useToolSubscription, useWidgetState };
3392
3445
  //# sourceMappingURL=index.mjs.map
3393
3446
  //# sourceMappingURL=index.mjs.map