@leanmcp/ui 0.3.2 → 0.3.3
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/README.md +1 -1
- package/dist/index.d.mts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2634,6 +2634,81 @@ function useToolSubscription(toolName, options = {}) {
|
|
|
2634
2634
|
};
|
|
2635
2635
|
}
|
|
2636
2636
|
__name(useToolSubscription, "useToolSubscription");
|
|
2637
|
+
function useAuth() {
|
|
2638
|
+
const { callTool, isConnected } = useGptApp();
|
|
2639
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
2640
|
+
const [user, setUser] = useState(null);
|
|
2641
|
+
const [loading, setLoading] = useState(false);
|
|
2642
|
+
const [error, setError] = useState(null);
|
|
2643
|
+
const checkAuthStatus = useCallback(async () => {
|
|
2644
|
+
if (!isConnected) return;
|
|
2645
|
+
try {
|
|
2646
|
+
const result = await callTool("getAuthStatus", {});
|
|
2647
|
+
if (result && result.user) {
|
|
2648
|
+
setIsAuthenticated(true);
|
|
2649
|
+
setUser(result.user);
|
|
2650
|
+
} else {
|
|
2651
|
+
setIsAuthenticated(false);
|
|
2652
|
+
setUser(null);
|
|
2653
|
+
}
|
|
2654
|
+
} catch (err) {
|
|
2655
|
+
setIsAuthenticated(false);
|
|
2656
|
+
setUser(null);
|
|
2657
|
+
}
|
|
2658
|
+
}, [
|
|
2659
|
+
callTool,
|
|
2660
|
+
isConnected
|
|
2661
|
+
]);
|
|
2662
|
+
const triggerAuth = useCallback(async () => {
|
|
2663
|
+
if (!isConnected) {
|
|
2664
|
+
setError(new Error("Not connected to ChatGPT"));
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
setLoading(true);
|
|
2668
|
+
setError(null);
|
|
2669
|
+
try {
|
|
2670
|
+
const result = await callTool("checkAuth", {});
|
|
2671
|
+
if (result && result.user) {
|
|
2672
|
+
setIsAuthenticated(true);
|
|
2673
|
+
setUser(result.user);
|
|
2674
|
+
} else if (result && result.success) {
|
|
2675
|
+
setIsAuthenticated(true);
|
|
2676
|
+
await checkAuthStatus();
|
|
2677
|
+
}
|
|
2678
|
+
} catch (err) {
|
|
2679
|
+
setError(err);
|
|
2680
|
+
} finally {
|
|
2681
|
+
setLoading(false);
|
|
2682
|
+
}
|
|
2683
|
+
}, [
|
|
2684
|
+
callTool,
|
|
2685
|
+
isConnected,
|
|
2686
|
+
checkAuthStatus
|
|
2687
|
+
]);
|
|
2688
|
+
const clearAuth = useCallback(() => {
|
|
2689
|
+
setIsAuthenticated(false);
|
|
2690
|
+
setUser(null);
|
|
2691
|
+
setError(null);
|
|
2692
|
+
}, []);
|
|
2693
|
+
useEffect(() => {
|
|
2694
|
+
if (isConnected) {
|
|
2695
|
+
checkAuthStatus().catch(() => {
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
}, [
|
|
2699
|
+
isConnected,
|
|
2700
|
+
checkAuthStatus
|
|
2701
|
+
]);
|
|
2702
|
+
return {
|
|
2703
|
+
isAuthenticated,
|
|
2704
|
+
user,
|
|
2705
|
+
loading,
|
|
2706
|
+
error,
|
|
2707
|
+
triggerAuth,
|
|
2708
|
+
clearAuth
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
__name(useAuth, "useAuth");
|
|
2637
2712
|
var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
2638
2713
|
function useOpenAiGlobal(key) {
|
|
2639
2714
|
return useSyncExternalStore((onChange) => {
|
|
@@ -3441,6 +3516,6 @@ var Input2 = /* @__PURE__ */ forwardRef(({ className, label, helperText, error,
|
|
|
3441
3516
|
});
|
|
3442
3517
|
Input2.displayName = "Input";
|
|
3443
3518
|
|
|
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 };
|
|
3519
|
+
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, useAuth, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useOpenAiGlobal, useResource, useTool, useToolContext, useToolInput, useToolInputPartial, useToolInput2 as useToolInputSpec, useToolOutput, useToolResponseMetadata, useToolResult, useToolStream, useToolSubscription, useWidgetState };
|
|
3445
3520
|
//# sourceMappingURL=index.mjs.map
|
|
3446
3521
|
//# sourceMappingURL=index.mjs.map
|