@open-dy/vibecoding-sdk-taro 0.0.1-beta.4 → 0.0.1-beta.6
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/adapters/interest-card/eslint/eslint-plugin-custom-navigation.mjs +2 -290
- package/dist/adapters/interest-card/eslint/taro.mjs +8 -42
- package/dist/build/plugins/vite-tt-components-entry.d.ts +10 -0
- package/dist/build/plugins/vite-tt-components-entry.js +32 -0
- package/dist/build/plugins/vite-tt-components-entry.js.map +1 -0
- package/dist/build/taro.js +3 -1
- package/dist/build/taro.js.map +1 -1
- package/dist/components/miniapp-open-card.d.ts +46 -1
- package/dist/components/miniapp-open-card.js +14 -1
- package/dist/components/miniapp-open-card.js.map +1 -1
- package/dist/eslint/eslint-plugin-custom-navigation.mjs +290 -0
- package/dist/eslint/taro.mjs +11 -0
- package/dist/reference/llms.txt +76 -34
- package/dist/reference/sdk-api/build/taro/BuildContext.md +7 -2
- package/dist/reference/sdk-api/build/taro/CreateMicroappTaroConfigOptions.md +1 -2
- package/dist/reference/sdk-api/build/taro/createMicroappTaroConfig.md +1 -2
- package/dist/reference/sdk-api/components/miniapp-open-card/MiniappOpenCard.md +109 -0
- package/dist/reference/sdk-api/components/miniapp-open-card/MiniappOpenCardEnvVersion.md +38 -0
- package/dist/reference/sdk-api/components/miniapp-open-card/MiniappOpenCardErrorDetail.md +52 -0
- package/dist/reference/sdk-api/components/miniapp-open-card/MiniappOpenCardProps.md +76 -0
- package/dist/reference/sdk-api/components/miniapp-open-card/index.md +12 -0
- package/dist/reference/sdk-api/libraries/lucide-taro.md +151 -0
- package/dist/reference/sdk-api/runtime/CreateMicroappClientOptions.md +7 -2
- package/dist/reference/sdk-api/runtime/createMicroappClient.md +8 -3
- package/dist/reference/sdk-api/ui/accordion/Accordion.md +114 -0
- package/dist/reference/sdk-api/ui/accordion/AccordionContent.md +100 -0
- package/dist/reference/sdk-api/ui/accordion/AccordionItem.md +107 -0
- package/dist/reference/sdk-api/ui/accordion/AccordionTrigger.md +100 -0
- package/dist/reference/sdk-api/ui/accordion/index.md +12 -0
- package/dist/reference/sdk-api/ui/alert/Alert.md +106 -0
- package/dist/reference/sdk-api/ui/alert/AlertAction.md +100 -0
- package/dist/reference/sdk-api/ui/alert/AlertDescription.md +100 -0
- package/dist/reference/sdk-api/ui/alert/AlertTitle.md +100 -0
- package/dist/reference/sdk-api/ui/alert/index.md +12 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialog.md +58 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogAction.md +107 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogCancel.md +107 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogContent.md +106 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogDescription.md +100 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogFooter.md +100 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogHeader.md +100 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogOverlay.md +100 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogPortal.md +55 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogTitle.md +100 -0
- package/dist/reference/sdk-api/ui/alert-dialog/AlertDialogTrigger.md +118 -0
- package/dist/reference/sdk-api/ui/alert-dialog/index.md +19 -0
- package/dist/reference/sdk-api/ui/aspect-ratio/AspectRatio.md +106 -0
- package/dist/reference/sdk-api/ui/aspect-ratio/index.md +9 -0
- package/dist/reference/sdk-api/ui/avatar/Avatar.md +106 -0
- package/dist/reference/sdk-api/ui/avatar/AvatarBadge.md +100 -0
- package/dist/reference/sdk-api/ui/avatar/AvatarFallback.md +100 -0
- package/dist/reference/sdk-api/ui/avatar/AvatarGroup.md +100 -0
- package/dist/reference/sdk-api/ui/avatar/AvatarGroupCount.md +100 -0
- package/dist/reference/sdk-api/ui/avatar/AvatarImage.md +108 -0
- package/dist/reference/sdk-api/ui/avatar/index.md +14 -0
- package/dist/reference/sdk-api/ui/badge/Badge.md +114 -0
- package/dist/reference/sdk-api/ui/badge/badgeVariants.md +70 -0
- package/dist/reference/sdk-api/ui/badge/index.md +10 -0
- package/dist/reference/sdk-api/ui/button/Button.md +210 -0
- package/dist/reference/sdk-api/ui/button/ButtonProps.md +188 -0
- package/dist/reference/sdk-api/ui/button/buttonVariants.md +84 -0
- package/dist/reference/sdk-api/ui/button/index.md +11 -0
- package/dist/reference/sdk-api/ui/button-group/ButtonGroup.md +106 -0
- package/dist/reference/sdk-api/ui/button-group/ButtonGroupSeparator.md +106 -0
- package/dist/reference/sdk-api/ui/button-group/ButtonGroupText.md +106 -0
- package/dist/reference/sdk-api/ui/button-group/buttonGroupVariants.md +70 -0
- package/dist/reference/sdk-api/ui/button-group/index.md +12 -0
- package/dist/reference/sdk-api/ui/calendar/Calendar.md +144 -0
- package/dist/reference/sdk-api/ui/calendar/CalendarProps.md +118 -0
- package/dist/reference/sdk-api/ui/calendar/index.md +10 -0
- package/dist/reference/sdk-api/ui/card/Card.md +106 -0
- package/dist/reference/sdk-api/ui/card/CardAction.md +100 -0
- package/dist/reference/sdk-api/ui/card/CardContent.md +100 -0
- package/dist/reference/sdk-api/ui/card/CardDescription.md +100 -0
- package/dist/reference/sdk-api/ui/card/CardFooter.md +100 -0
- package/dist/reference/sdk-api/ui/card/CardHeader.md +100 -0
- package/dist/reference/sdk-api/ui/card/CardTitle.md +100 -0
- package/dist/reference/sdk-api/ui/card/index.md +15 -0
- package/dist/reference/sdk-api/ui/carousel/Carousel.md +108 -0
- package/dist/reference/sdk-api/ui/carousel/CarouselContent.md +100 -0
- package/dist/reference/sdk-api/ui/carousel/CarouselItem.md +100 -0
- package/dist/reference/sdk-api/ui/carousel/CarouselNext.md +219 -0
- package/dist/reference/sdk-api/ui/carousel/CarouselPrevious.md +219 -0
- package/dist/reference/sdk-api/ui/carousel/index.md +14 -0
- package/dist/reference/sdk-api/ui/carousel/useCarousel.md +46 -0
- package/dist/reference/sdk-api/ui/checkbox/Checkbox.md +109 -0
- package/dist/reference/sdk-api/ui/checkbox/index.md +9 -0
- package/dist/reference/sdk-api/ui/collapsible/Collapsible.md +108 -0
- package/dist/reference/sdk-api/ui/collapsible/CollapsibleContent.md +100 -0
- package/dist/reference/sdk-api/ui/collapsible/CollapsibleTrigger.md +119 -0
- package/dist/reference/sdk-api/ui/collapsible/index.md +11 -0
- package/dist/reference/sdk-api/ui/combobox/Combobox.md +124 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxChip.md +107 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxChips.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxChipsInput.md +107 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxCollection.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxContent.md +106 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxEmpty.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxGroup.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxInput.md +113 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxItem.md +106 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxLabel.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxList.md +105 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxSeparator.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxTrigger.md +100 -0
- package/dist/reference/sdk-api/ui/combobox/ComboboxValue.md +105 -0
- package/dist/reference/sdk-api/ui/combobox/index.md +24 -0
- package/dist/reference/sdk-api/ui/combobox/useComboboxAnchor.md +43 -0
- package/dist/reference/sdk-api/ui/dialog/Dialog.md +58 -0
- package/dist/reference/sdk-api/ui/dialog/DialogClose.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogContent.md +107 -0
- package/dist/reference/sdk-api/ui/dialog/DialogDescription.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogFooter.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogHeader.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogOverlay.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogPortal.md +55 -0
- package/dist/reference/sdk-api/ui/dialog/DialogTitle.md +100 -0
- package/dist/reference/sdk-api/ui/dialog/DialogTrigger.md +106 -0
- package/dist/reference/sdk-api/ui/dialog/index.md +18 -0
- package/dist/reference/sdk-api/ui/drawer/Drawer.md +59 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerClose.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerContent.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerDescription.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerFooter.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerHeader.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerOverlay.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerPortal.md +55 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerTitle.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/DrawerTrigger.md +100 -0
- package/dist/reference/sdk-api/ui/drawer/index.md +18 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenu.md +58 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuCheckboxItem.md +107 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuContent.md +106 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuGroup.md +100 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuItem.md +107 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuLabel.md +106 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuPortal.md +55 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuRadioGroup.md +100 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuRadioItem.md +106 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuSeparator.md +100 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuShortcut.md +100 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuSub.md +58 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuSubContent.md +100 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuSubTrigger.md +106 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/DropdownMenuTrigger.md +119 -0
- package/dist/reference/sdk-api/ui/dropdown-menu/index.md +23 -0
- package/dist/reference/sdk-api/ui/empty/Empty.md +100 -0
- package/dist/reference/sdk-api/ui/empty/EmptyContent.md +100 -0
- package/dist/reference/sdk-api/ui/empty/EmptyDescription.md +100 -0
- package/dist/reference/sdk-api/ui/empty/EmptyHeader.md +100 -0
- package/dist/reference/sdk-api/ui/empty/EmptyMedia.md +106 -0
- package/dist/reference/sdk-api/ui/empty/EmptyTitle.md +100 -0
- package/dist/reference/sdk-api/ui/empty/index.md +14 -0
- package/dist/reference/sdk-api/ui/field/Field.md +106 -0
- package/dist/reference/sdk-api/ui/field/FieldContent.md +100 -0
- package/dist/reference/sdk-api/ui/field/FieldDescription.md +100 -0
- package/dist/reference/sdk-api/ui/field/FieldError.md +112 -0
- package/dist/reference/sdk-api/ui/field/FieldGroup.md +100 -0
- package/dist/reference/sdk-api/ui/field/FieldLabel.md +85 -0
- package/dist/reference/sdk-api/ui/field/FieldLegend.md +106 -0
- package/dist/reference/sdk-api/ui/field/FieldSeparator.md +105 -0
- package/dist/reference/sdk-api/ui/field/FieldSet.md +100 -0
- package/dist/reference/sdk-api/ui/field/FieldTitle.md +100 -0
- package/dist/reference/sdk-api/ui/field/index.md +18 -0
- package/dist/reference/sdk-api/ui/helpers/collectDataIconState.md +66 -0
- package/dist/reference/sdk-api/ui/helpers/index.md +9 -0
- package/dist/reference/sdk-api/ui/index.md +57 -0
- package/dist/reference/sdk-api/ui/input/Input.md +141 -0
- package/dist/reference/sdk-api/ui/input/index.md +9 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroup.md +100 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroupAddon.md +109 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroupButton.md +220 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroupInput.md +135 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroupText.md +100 -0
- package/dist/reference/sdk-api/ui/input-group/InputGroupTextarea.md +126 -0
- package/dist/reference/sdk-api/ui/input-group/index.md +14 -0
- package/dist/reference/sdk-api/ui/input-otp/InputOTP.md +111 -0
- package/dist/reference/sdk-api/ui/input-otp/InputOTPGroup.md +100 -0
- package/dist/reference/sdk-api/ui/input-otp/InputOTPSeparator.md +100 -0
- package/dist/reference/sdk-api/ui/input-otp/InputOTPSlot.md +107 -0
- package/dist/reference/sdk-api/ui/input-otp/index.md +12 -0
- package/dist/reference/sdk-api/ui/item/Item.md +115 -0
- package/dist/reference/sdk-api/ui/item/ItemActions.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemContent.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemDescription.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemFooter.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemGroup.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemHeader.md +100 -0
- package/dist/reference/sdk-api/ui/item/ItemMedia.md +106 -0
- package/dist/reference/sdk-api/ui/item/ItemSeparator.md +106 -0
- package/dist/reference/sdk-api/ui/item/ItemTitle.md +100 -0
- package/dist/reference/sdk-api/ui/item/index.md +18 -0
- package/dist/reference/sdk-api/ui/label/Label.md +85 -0
- package/dist/reference/sdk-api/ui/label/index.md +9 -0
- package/dist/reference/sdk-api/ui/menubar/Menubar.md +100 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarCheckboxItem.md +111 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarContent.md +108 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarGroup.md +100 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarItem.md +109 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarLabel.md +106 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarMenu.md +55 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarPortal.md +55 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarRadioGroup.md +108 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarRadioItem.md +110 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarSeparator.md +100 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarShortcut.md +100 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarSub.md +58 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarSubContent.md +108 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarSubTrigger.md +107 -0
- package/dist/reference/sdk-api/ui/menubar/MenubarTrigger.md +100 -0
- package/dist/reference/sdk-api/ui/menubar/index.md +24 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenu.md +100 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuContent.md +106 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuIndicator.md +100 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuItem.md +106 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuLink.md +106 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuList.md +100 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuPositioner.md +100 -0
- package/dist/reference/sdk-api/ui/navigation-menu/NavigationMenuTrigger.md +120 -0
- package/dist/reference/sdk-api/ui/navigation-menu/index.md +17 -0
- package/dist/reference/sdk-api/ui/navigation-menu/navigationMenuTriggerStyle.md +64 -0
- package/dist/reference/sdk-api/ui/pagination/Pagination.md +100 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationContent.md +100 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationEllipsis.md +100 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationItem.md +100 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationLink.md +107 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationNext.md +121 -0
- package/dist/reference/sdk-api/ui/pagination/PaginationPrevious.md +121 -0
- package/dist/reference/sdk-api/ui/pagination/index.md +15 -0
- package/dist/reference/sdk-api/ui/popover/Popover.md +58 -0
- package/dist/reference/sdk-api/ui/popover/PopoverAnchor.md +100 -0
- package/dist/reference/sdk-api/ui/popover/PopoverContent.md +108 -0
- package/dist/reference/sdk-api/ui/popover/PopoverDescription.md +100 -0
- package/dist/reference/sdk-api/ui/popover/PopoverHeader.md +100 -0
- package/dist/reference/sdk-api/ui/popover/PopoverTitle.md +100 -0
- package/dist/reference/sdk-api/ui/popover/PopoverTrigger.md +119 -0
- package/dist/reference/sdk-api/ui/popover/index.md +15 -0
- package/dist/reference/sdk-api/ui/portal/Portal.md +55 -0
- package/dist/reference/sdk-api/ui/portal/index.md +9 -0
- package/dist/reference/sdk-api/ui/progress/Progress.md +109 -0
- package/dist/reference/sdk-api/ui/progress/ProgressIndicator.md +107 -0
- package/dist/reference/sdk-api/ui/progress/ProgressLabel.md +100 -0
- package/dist/reference/sdk-api/ui/progress/ProgressTrack.md +100 -0
- package/dist/reference/sdk-api/ui/progress/ProgressValue.md +105 -0
- package/dist/reference/sdk-api/ui/progress/index.md +13 -0
- package/dist/reference/sdk-api/ui/radio-group/RadioGroup.md +108 -0
- package/dist/reference/sdk-api/ui/radio-group/RadioGroupItem.md +107 -0
- package/dist/reference/sdk-api/ui/radio-group/index.md +10 -0
- package/dist/reference/sdk-api/ui/resizable/ResizableHandle.md +107 -0
- package/dist/reference/sdk-api/ui/resizable/ResizablePanel.md +108 -0
- package/dist/reference/sdk-api/ui/resizable/ResizablePanelGroup.md +107 -0
- package/dist/reference/sdk-api/ui/resizable/index.md +11 -0
- package/dist/reference/sdk-api/ui/scroll-area/ScrollArea.md +159 -0
- package/dist/reference/sdk-api/ui/scroll-area/ScrollBar.md +106 -0
- package/dist/reference/sdk-api/ui/scroll-area/index.md +10 -0
- package/dist/reference/sdk-api/ui/select/Select.md +80 -0
- package/dist/reference/sdk-api/ui/select/SelectContent.md +106 -0
- package/dist/reference/sdk-api/ui/select/SelectGroup.md +100 -0
- package/dist/reference/sdk-api/ui/select/SelectItem.md +106 -0
- package/dist/reference/sdk-api/ui/select/SelectLabel.md +100 -0
- package/dist/reference/sdk-api/ui/select/SelectScrollDownButton.md +100 -0
- package/dist/reference/sdk-api/ui/select/SelectScrollUpButton.md +100 -0
- package/dist/reference/sdk-api/ui/select/SelectSeparator.md +100 -0
- package/dist/reference/sdk-api/ui/select/SelectTrigger.md +106 -0
- package/dist/reference/sdk-api/ui/select/SelectValue.md +106 -0
- package/dist/reference/sdk-api/ui/select/index.md +18 -0
- package/dist/reference/sdk-api/ui/separator/Separator.md +106 -0
- package/dist/reference/sdk-api/ui/separator/index.md +9 -0
- package/dist/reference/sdk-api/ui/sheet/Sheet.md +58 -0
- package/dist/reference/sdk-api/ui/sheet/SheetClose.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetContent.md +113 -0
- package/dist/reference/sdk-api/ui/sheet/SheetDescription.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetFooter.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetHeader.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetOverlay.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetPortal.md +55 -0
- package/dist/reference/sdk-api/ui/sheet/SheetTitle.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/SheetTrigger.md +100 -0
- package/dist/reference/sdk-api/ui/sheet/index.md +18 -0
- package/dist/reference/sdk-api/ui/skeleton/Skeleton.md +100 -0
- package/dist/reference/sdk-api/ui/skeleton/index.md +9 -0
- package/dist/reference/sdk-api/ui/slider/Slider.md +116 -0
- package/dist/reference/sdk-api/ui/slider/index.md +9 -0
- package/dist/reference/sdk-api/ui/sonner/Toaster.md +43 -0
- package/dist/reference/sdk-api/ui/sonner/index.md +10 -0
- package/dist/reference/sdk-api/ui/sonner/toast.md +58 -0
- package/dist/reference/sdk-api/ui/spinner/Spinner.md +100 -0
- package/dist/reference/sdk-api/ui/spinner/index.md +9 -0
- package/dist/reference/sdk-api/ui/switch/Switch.md +110 -0
- package/dist/reference/sdk-api/ui/switch/index.md +9 -0
- package/dist/reference/sdk-api/ui/table/Table.md +100 -0
- package/dist/reference/sdk-api/ui/table/TableBody.md +100 -0
- package/dist/reference/sdk-api/ui/table/TableCaption.md +100 -0
- package/dist/reference/sdk-api/ui/table/TableCell.md +106 -0
- package/dist/reference/sdk-api/ui/table/TableFooter.md +100 -0
- package/dist/reference/sdk-api/ui/table/TableHead.md +106 -0
- package/dist/reference/sdk-api/ui/table/TableHeader.md +100 -0
- package/dist/reference/sdk-api/ui/table/TableRow.md +100 -0
- package/dist/reference/sdk-api/ui/table/index.md +16 -0
- package/dist/reference/sdk-api/ui/tabs/Tabs.md +109 -0
- package/dist/reference/sdk-api/ui/tabs/TabsContent.md +106 -0
- package/dist/reference/sdk-api/ui/tabs/TabsList.md +106 -0
- package/dist/reference/sdk-api/ui/tabs/TabsTrigger.md +107 -0
- package/dist/reference/sdk-api/ui/tabs/index.md +13 -0
- package/dist/reference/sdk-api/ui/tabs/tabsListVariants.md +70 -0
- package/dist/reference/sdk-api/ui/textarea/Textarea.md +126 -0
- package/dist/reference/sdk-api/ui/textarea/index.md +9 -0
- package/dist/reference/sdk-api/ui/toggle/Toggle.md +118 -0
- package/dist/reference/sdk-api/ui/toggle/index.md +10 -0
- package/dist/reference/sdk-api/ui/toggle/toggleVariants.md +71 -0
- package/dist/reference/sdk-api/ui/toggle-group/ToggleGroup.md +122 -0
- package/dist/reference/sdk-api/ui/toggle-group/ToggleGroupItem.md +116 -0
- package/dist/reference/sdk-api/ui/toggle-group/index.md +10 -0
- package/dist/reference/sdk-api.json +74470 -146
- package/dist/reference/sdk-api.md +62 -3
- package/dist/ui/accordion.d.ts +48 -0
- package/dist/ui/accordion.js +40 -0
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/alert-dialog.d.ts +123 -0
- package/dist/ui/alert-dialog.js +114 -0
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/alert.d.ts +41 -0
- package/dist/ui/alert.js +41 -0
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/aspect-ratio.d.ts +11 -0
- package/dist/ui/aspect-ratio.js +10 -0
- package/dist/ui/aspect-ratio.js.map +1 -1
- package/dist/ui/avatar.d.ts +65 -0
- package/dist/ui/avatar.js +63 -0
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge.d.ts +22 -0
- package/dist/ui/badge.js +22 -0
- package/dist/ui/badge.js.map +1 -1
- package/dist/ui/button-group.d.ts +45 -0
- package/dist/ui/button-group.js +43 -0
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button.d.ts +52 -0
- package/dist/ui/button.js +30 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/calendar.d.ts +44 -0
- package/dist/ui/calendar.js +19 -0
- package/dist/ui/calendar.js.map +1 -1
- package/dist/ui/card.d.ts +71 -0
- package/dist/ui/card.js +70 -0
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/carousel.d.ts +71 -0
- package/dist/ui/carousel.js +66 -0
- package/dist/ui/carousel.js.map +1 -1
- package/dist/ui/checkbox.d.ts +14 -0
- package/dist/ui/checkbox.js +10 -0
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/collapsible.d.ts +37 -0
- package/dist/ui/collapsible.js +30 -0
- package/dist/ui/collapsible.js.map +1 -1
- package/dist/ui/combobox.d.ts +190 -0
- package/dist/ui/combobox.js +167 -0
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/dialog.d.ts +109 -0
- package/dist/ui/dialog.js +100 -0
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/drawer.d.ts +106 -0
- package/dist/ui/drawer.js +100 -0
- package/dist/ui/drawer.js.map +1 -1
- package/dist/ui/dropdown-menu.d.ts +171 -0
- package/dist/ui/dropdown-menu.js +150 -0
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/empty.d.ts +61 -0
- package/dist/ui/empty.js +61 -0
- package/dist/ui/empty.js.map +1 -1
- package/dist/ui/field.d.ts +105 -0
- package/dist/ui/field.js +101 -0
- package/dist/ui/field.js.map +1 -1
- package/dist/ui/helpers.d.ts +11 -0
- package/dist/ui/helpers.js +11 -0
- package/dist/ui/helpers.js.map +1 -1
- package/dist/ui/input-group.d.ts +65 -0
- package/dist/ui/input-group.js +65 -0
- package/dist/ui/input-group.js.map +1 -1
- package/dist/ui/input-otp.d.ts +48 -0
- package/dist/ui/input-otp.js +40 -0
- package/dist/ui/input-otp.js.map +1 -1
- package/dist/ui/input.d.ts +24 -2
- package/dist/ui/input.js +20 -0
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/item.d.ts +103 -0
- package/dist/ui/item.js +103 -0
- package/dist/ui/item.js.map +1 -1
- package/dist/ui/label.d.ts +10 -0
- package/dist/ui/label.js +10 -0
- package/dist/ui/label.js.map +1 -1
- package/dist/ui/menubar.d.ts +193 -0
- package/dist/ui/menubar.js +160 -0
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/navigation-menu.d.ts +98 -0
- package/dist/ui/navigation-menu.js +90 -0
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/pagination.d.ts +76 -0
- package/dist/ui/pagination.js +73 -0
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/popover.d.ts +81 -0
- package/dist/ui/popover.js +70 -0
- package/dist/ui/popover.js.map +1 -1
- package/dist/ui/portal.d.ts +11 -0
- package/dist/ui/portal.js +10 -0
- package/dist/ui/portal.js.map +1 -1
- package/dist/ui/progress.d.ts +53 -26
- package/dist/ui/progress.js +50 -26
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio-group.d.ts +25 -0
- package/dist/ui/radio-group.js +20 -0
- package/dist/ui/radio-group.js.map +1 -1
- package/dist/ui/resizable.d.ts +37 -0
- package/dist/ui/resizable.js +30 -0
- package/dist/ui/resizable.js.map +1 -1
- package/dist/ui/scroll-area.d.ts +22 -0
- package/dist/ui/scroll-area.js +21 -0
- package/dist/ui/scroll-area.js.map +1 -1
- package/dist/ui/select.d.ts +122 -0
- package/dist/ui/select.js +108 -0
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/separator.d.ts +11 -0
- package/dist/ui/separator.js +10 -0
- package/dist/ui/separator.js.map +1 -1
- package/dist/ui/sheet.d.ts +107 -0
- package/dist/ui/sheet.js +101 -0
- package/dist/ui/sheet.js.map +1 -1
- package/dist/ui/skeleton.d.ts +10 -0
- package/dist/ui/skeleton.js +10 -0
- package/dist/ui/skeleton.js.map +1 -1
- package/dist/ui/slider.d.ts +21 -0
- package/dist/ui/slider.js +14 -0
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/sonner.d.ts +23 -0
- package/dist/ui/sonner.js +21 -0
- package/dist/ui/sonner.js.map +1 -1
- package/dist/ui/spinner.d.ts +10 -0
- package/dist/ui/spinner.js +10 -0
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/switch.d.ts +15 -0
- package/dist/ui/switch.js +10 -0
- package/dist/ui/switch.js.map +1 -1
- package/dist/ui/table.d.ts +81 -0
- package/dist/ui/table.js +80 -0
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tabs.d.ts +59 -0
- package/dist/ui/tabs.js +51 -0
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/textarea.d.ts +13 -0
- package/dist/ui/textarea.js +13 -0
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toggle-group.d.ts +34 -0
- package/dist/ui/toggle-group.js +24 -0
- package/dist/ui/toggle-group.js.map +1 -1
- package/dist/ui/toggle.d.ts +28 -0
- package/dist/ui/toggle.js +24 -0
- package/dist/ui/toggle.js.map +1 -1
- package/package.json +4 -2
- package/release-provenance.json +15 -0
- package/src/adapters/interest-card/eslint/eslint-plugin-custom-navigation.mjs +2 -0
- package/src/adapters/interest-card/eslint/taro.mjs +21 -0
- package/src/adapters/interest-card/runtime/microapp.ts +11 -0
- package/src/adapters/interest-card/types/taro.d.ts +28 -0
- package/src/build/config-overrides.ts +39 -0
- package/src/build/index.ts +5 -0
- package/src/build/plugins/app-config.ts +47 -0
- package/src/build/plugins/depend-card/analyze.ts +122 -0
- package/src/build/plugins/depend-card/source.ts +97 -0
- package/src/build/plugins/vite-depend-card.ts +168 -0
- package/src/build/plugins/vite-image-asset-import.ts +178 -0
- package/src/build/plugins/vite-inline-json.ts +149 -0
- package/src/build/plugins/vite-taro-source-location.ts +224 -0
- package/src/build/plugins/vite-tt-components-entry.ts +33 -0
- package/src/build/taro.ts +830 -0
- package/src/components/miniapp-open-card.ts +94 -0
- package/src/components/native-miniapp-open-card.ts +7 -0
- package/src/eslint/eslint-plugin-custom-navigation.mjs +290 -0
- package/src/eslint/eslint-plugin-microapp-pages.mjs +659 -0
- package/src/eslint/server.mjs +69 -0
- package/src/eslint/taro.mjs +564 -0
- package/src/index.ts +2 -0
- package/src/internal/runtime/douyin-open-button.d.ts +29 -0
- package/src/internal/runtime/iframe-auth/identity.ts +236 -0
- package/src/internal/runtime/iframe-auth/index.ts +2 -0
- package/src/internal/runtime/iframe-auth/sync.ts +37 -0
- package/src/internal/vendor-modules.d.ts +8 -0
- package/src/lib/measure.ts +115 -0
- package/src/lib/platform.ts +11 -0
- package/src/lib/utils.ts +6 -0
- package/src/runtime/client.ts +246 -0
- package/src/runtime/default-client.ts +26 -0
- package/src/runtime/default-iframe-auth.ts +13 -0
- package/src/runtime/douyin-container-request.ts +367 -0
- package/src/runtime/douyin-login-request.ts +514 -0
- package/src/runtime/globals.d.ts +342 -0
- package/src/runtime/index.ts +4 -0
- package/src/runtime/network-url.ts +63 -0
- package/src/ui/accordion.tsx +226 -0
- package/src/ui/alert-dialog.tsx +407 -0
- package/src/ui/alert.tsx +149 -0
- package/src/ui/aspect-ratio.tsx +37 -0
- package/src/ui/avatar.tsx +238 -0
- package/src/ui/badge.tsx +77 -0
- package/src/ui/button-group.tsx +173 -0
- package/src/ui/button.tsx +215 -0
- package/src/ui/calendar.tsx +353 -0
- package/src/ui/card.tsx +217 -0
- package/src/ui/carousel.tsx +259 -0
- package/src/ui/checkbox.tsx +62 -0
- package/src/ui/collapsible.tsx +148 -0
- package/src/ui/combobox.tsx +650 -0
- package/src/ui/dialog.tsx +290 -0
- package/src/ui/drawer.tsx +272 -0
- package/src/ui/dropdown-menu.tsx +547 -0
- package/src/ui/empty.tsx +166 -0
- package/src/ui/field.tsx +427 -0
- package/src/ui/helpers.tsx +39 -0
- package/src/ui/index.ts +47 -0
- package/src/ui/input-group.tsx +320 -0
- package/src/ui/input-otp.tsx +189 -0
- package/src/ui/input.tsx +60 -0
- package/src/ui/item.tsx +338 -0
- package/src/ui/label.tsx +31 -0
- package/src/ui/menubar.tsx +835 -0
- package/src/ui/navigation-menu.tsx +341 -0
- package/src/ui/pagination.tsx +195 -0
- package/src/ui/popover.tsx +363 -0
- package/src/ui/portal.tsx +31 -0
- package/src/ui/progress.tsx +182 -0
- package/src/ui/radio-group.tsx +111 -0
- package/src/ui/resizable.tsx +410 -0
- package/src/ui/scroll-area.tsx +102 -0
- package/src/ui/select.tsx +471 -0
- package/src/ui/separator.tsx +37 -0
- package/src/ui/sheet.tsx +289 -0
- package/src/ui/skeleton.tsx +25 -0
- package/src/ui/slider.tsx +176 -0
- package/src/ui/sonner.tsx +40 -0
- package/src/ui/spinner.tsx +23 -0
- package/src/ui/switch.tsx +94 -0
- package/src/ui/table.tsx +240 -0
- package/src/ui/tabs.tsx +233 -0
- package/src/ui/tailwind.css +2 -0
- package/src/ui/textarea.tsx +49 -0
- package/src/ui/theme.css +234 -0
- package/src/ui/toggle-group.tsx +215 -0
- package/src/ui/toggle.tsx +113 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export type IframeTaroRuntime = {
|
|
2
|
+
getEnv?: () => unknown
|
|
3
|
+
ENV_TYPE?: {
|
|
4
|
+
WEB?: unknown
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type IframeIdentity = {
|
|
9
|
+
accessToken: string
|
|
10
|
+
expiresAt: number
|
|
11
|
+
openId: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type IframeIdentityMessage = {
|
|
15
|
+
from?: unknown
|
|
16
|
+
type?: unknown
|
|
17
|
+
data?: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const IFRAME_IDENTITY_STORAGE_KEY = '__iframe_douyin_identity__'
|
|
21
|
+
const IFRAME_IDENTITY_MESSAGE_FROM = 'agiPreview'
|
|
22
|
+
const IFRAME_IDENTITY_MESSAGE_TYPE = 'douyinAuth'
|
|
23
|
+
const IFRAME_LOGOUT_MESSAGE_TYPE = 'douyinLogout'
|
|
24
|
+
|
|
25
|
+
let cachedIdentity: IframeIdentity | null = null
|
|
26
|
+
|
|
27
|
+
const isWebIframeRuntime = (taro?: IframeTaroRuntime | null) => {
|
|
28
|
+
return (
|
|
29
|
+
typeof taro?.getEnv === 'function' &&
|
|
30
|
+
taro.ENV_TYPE?.WEB != null &&
|
|
31
|
+
taro.getEnv() === taro.ENV_TYPE.WEB &&
|
|
32
|
+
typeof window !== 'undefined' &&
|
|
33
|
+
window.parent !== window
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => {
|
|
38
|
+
return typeof value === 'object' && value !== null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const isExpiredIdentity = (identity: IframeIdentity): boolean => {
|
|
42
|
+
return identity.expiresAt <= Date.now()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const normalizeIdentity = (value: unknown): IframeIdentity | null => {
|
|
46
|
+
if (!isRecord(value)) {
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const accessToken = typeof value.accessToken === 'string' ? value.accessToken.trim() : ''
|
|
51
|
+
const expiresAt =
|
|
52
|
+
typeof value.expiresAt === 'number' && Number.isFinite(value.expiresAt)
|
|
53
|
+
? value.expiresAt
|
|
54
|
+
: 0
|
|
55
|
+
const openId = typeof value.openId === 'string' ? value.openId.trim() : ''
|
|
56
|
+
|
|
57
|
+
if (!accessToken || !openId || expiresAt <= 0) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
accessToken,
|
|
63
|
+
expiresAt,
|
|
64
|
+
openId,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const getParentOrigin = () => {
|
|
69
|
+
if (typeof document === 'undefined' || !document.referrer) {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return new URL(document.referrer).origin
|
|
75
|
+
} catch {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const readStoredIdentity = (
|
|
81
|
+
taro?: IframeTaroRuntime | null,
|
|
82
|
+
): IframeIdentity | null => {
|
|
83
|
+
if (!isWebIframeRuntime(taro) || typeof sessionStorage === 'undefined') {
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
const storedValue = sessionStorage.getItem(IFRAME_IDENTITY_STORAGE_KEY)
|
|
89
|
+
if (!storedValue) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return normalizeIdentity(JSON.parse(storedValue))
|
|
94
|
+
} catch {
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const getIframeIdentity = (
|
|
100
|
+
taro?: IframeTaroRuntime | null,
|
|
101
|
+
): IframeIdentity | null => {
|
|
102
|
+
if (cachedIdentity) {
|
|
103
|
+
if (isExpiredIdentity(cachedIdentity)) {
|
|
104
|
+
clearIframeIdentity(taro)
|
|
105
|
+
return null
|
|
106
|
+
}
|
|
107
|
+
return cachedIdentity
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
cachedIdentity = readStoredIdentity(taro)
|
|
111
|
+
if (cachedIdentity && isExpiredIdentity(cachedIdentity)) {
|
|
112
|
+
clearIframeIdentity(taro)
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
return cachedIdentity
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const persistIframeIdentity = (
|
|
119
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
120
|
+
identity: IframeIdentity,
|
|
121
|
+
) => {
|
|
122
|
+
if (isExpiredIdentity(identity)) {
|
|
123
|
+
clearIframeIdentity(taro)
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
cachedIdentity = identity
|
|
128
|
+
|
|
129
|
+
if (!isWebIframeRuntime(taro) || typeof sessionStorage === 'undefined') {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
sessionStorage.setItem(
|
|
135
|
+
IFRAME_IDENTITY_STORAGE_KEY,
|
|
136
|
+
JSON.stringify(identity),
|
|
137
|
+
)
|
|
138
|
+
} catch {
|
|
139
|
+
// Ignore storage failures and keep the in-memory copy.
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const clearIframeIdentity = (
|
|
144
|
+
taro?: IframeTaroRuntime | null,
|
|
145
|
+
) => {
|
|
146
|
+
cachedIdentity = null
|
|
147
|
+
|
|
148
|
+
if (!isWebIframeRuntime(taro) || typeof sessionStorage === 'undefined') {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
sessionStorage.removeItem(IFRAME_IDENTITY_STORAGE_KEY)
|
|
154
|
+
} catch {
|
|
155
|
+
// Ignore storage failures and rely on the in-memory reset.
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const getIframeIdentityHeaders = (
|
|
160
|
+
taro?: IframeTaroRuntime | null,
|
|
161
|
+
): Record<string, string> => {
|
|
162
|
+
const identity = getIframeIdentity(taro)
|
|
163
|
+
if (!identity) {
|
|
164
|
+
return {}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
OpenId: identity.openId,
|
|
169
|
+
Authorization: `Bearer ${identity.accessToken}`,
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const mergeIframeIdentityHeaders = (
|
|
174
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
175
|
+
header?: Record<string, unknown>,
|
|
176
|
+
): Record<string, unknown> | undefined => {
|
|
177
|
+
const identityHeaders = getIframeIdentityHeaders(taro)
|
|
178
|
+
if (Object.keys(identityHeaders).length === 0) {
|
|
179
|
+
return header
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
...header,
|
|
184
|
+
...identityHeaders,
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const parseIframeIdentityMessage = (
|
|
189
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
190
|
+
event: MessageEvent<unknown>,
|
|
191
|
+
): IframeIdentity | null => {
|
|
192
|
+
if (!isWebIframeRuntime(taro) || event.source !== window.parent) {
|
|
193
|
+
return null
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const parentOrigin = getParentOrigin()
|
|
197
|
+
if (parentOrigin && event.origin !== parentOrigin) {
|
|
198
|
+
return null
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const message = event.data as IframeIdentityMessage
|
|
202
|
+
if (
|
|
203
|
+
!message ||
|
|
204
|
+
message.from !== IFRAME_IDENTITY_MESSAGE_FROM ||
|
|
205
|
+
message.type !== IFRAME_IDENTITY_MESSAGE_TYPE
|
|
206
|
+
) {
|
|
207
|
+
return null
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return normalizeIdentity(message.data)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export const isIframeLogoutMessage = (
|
|
214
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
215
|
+
event: MessageEvent<unknown>,
|
|
216
|
+
): boolean => {
|
|
217
|
+
if (!isWebIframeRuntime(taro) || event.source !== window.parent) {
|
|
218
|
+
return false
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const parentOrigin = getParentOrigin()
|
|
222
|
+
if (parentOrigin && event.origin !== parentOrigin) {
|
|
223
|
+
return false
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const message = event.data as IframeIdentityMessage
|
|
227
|
+
return Boolean(
|
|
228
|
+
message &&
|
|
229
|
+
message.from === IFRAME_IDENTITY_MESSAGE_FROM &&
|
|
230
|
+
message.type === IFRAME_LOGOUT_MESSAGE_TYPE,
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export const shouldListenIframeIdentityMessage = (
|
|
235
|
+
taro?: IframeTaroRuntime | null,
|
|
236
|
+
) => isWebIframeRuntime(taro)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearIframeIdentity,
|
|
3
|
+
type IframeTaroRuntime,
|
|
4
|
+
isIframeLogoutMessage,
|
|
5
|
+
parseIframeIdentityMessage,
|
|
6
|
+
persistIframeIdentity,
|
|
7
|
+
shouldListenIframeIdentityMessage,
|
|
8
|
+
} from './identity'
|
|
9
|
+
|
|
10
|
+
export const subscribeIframeAuth = (
|
|
11
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
12
|
+
clearLoginAuth: () => void,
|
|
13
|
+
) => {
|
|
14
|
+
if (!shouldListenIframeIdentityMessage(taro)) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const handleMessage = (event: MessageEvent<unknown>) => {
|
|
19
|
+
if (isIframeLogoutMessage(taro, event)) {
|
|
20
|
+
clearIframeIdentity(taro)
|
|
21
|
+
clearLoginAuth()
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const identity = parseIframeIdentityMessage(taro, event)
|
|
26
|
+
if (!identity) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
persistIframeIdentity(taro, identity)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
window.addEventListener('message', handleMessage)
|
|
34
|
+
return () => {
|
|
35
|
+
window.removeEventListener('message', handleMessage)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
+
import { canUseDOM, isH5 } from './platform'
|
|
3
|
+
|
|
4
|
+
export type Rect = { left: number; top: number; width: number; height: number }
|
|
5
|
+
|
|
6
|
+
const toNumber = (v: unknown) => {
|
|
7
|
+
if (typeof v === 'number') return v
|
|
8
|
+
if (typeof v === 'string') {
|
|
9
|
+
const n = parseFloat(v)
|
|
10
|
+
return Number.isFinite(n) ? n : 0
|
|
11
|
+
}
|
|
12
|
+
return 0
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const normalizeRect = (r: any): Rect | null => {
|
|
16
|
+
if (!r) return null
|
|
17
|
+
return {
|
|
18
|
+
left: toNumber(r.left),
|
|
19
|
+
top: toNumber(r.top),
|
|
20
|
+
width: toNumber(r.width),
|
|
21
|
+
height: toNumber(r.height),
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const getViewport = () => {
|
|
26
|
+
if (isH5() && canUseDOM()) {
|
|
27
|
+
return { width: window.innerWidth, height: window.innerHeight }
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const info = Taro.getSystemInfoSync()
|
|
31
|
+
return {
|
|
32
|
+
width: toNumber(info.windowWidth),
|
|
33
|
+
height: toNumber(info.windowHeight),
|
|
34
|
+
}
|
|
35
|
+
} catch {
|
|
36
|
+
return { width: 375, height: 667 }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const getRectH5 = (id: string): Rect | null => {
|
|
41
|
+
if (!isH5() || !canUseDOM()) return null
|
|
42
|
+
const el = document.getElementById(id)
|
|
43
|
+
if (!el) return null
|
|
44
|
+
const r = el.getBoundingClientRect()
|
|
45
|
+
return normalizeRect(r)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getRectById = (id: string): Promise<Rect | null> => {
|
|
49
|
+
const h5Rect = getRectH5(id)
|
|
50
|
+
if (h5Rect) return Promise.resolve(h5Rect)
|
|
51
|
+
return new Promise(resolve => {
|
|
52
|
+
const query = Taro.createSelectorQuery()
|
|
53
|
+
query
|
|
54
|
+
.select(`#${id}`)
|
|
55
|
+
.boundingClientRect(res => {
|
|
56
|
+
const rect = Array.isArray(res) ? res[0] : res
|
|
57
|
+
resolve(normalizeRect(rect))
|
|
58
|
+
})
|
|
59
|
+
.exec()
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const computePosition = (params: {
|
|
64
|
+
triggerRect: Rect
|
|
65
|
+
contentRect: Rect
|
|
66
|
+
align: 'start' | 'center' | 'end'
|
|
67
|
+
side: 'top' | 'bottom' | 'left' | 'right'
|
|
68
|
+
sideOffset: number
|
|
69
|
+
}) => {
|
|
70
|
+
const { triggerRect, contentRect, align, side, sideOffset } = params
|
|
71
|
+
const { width: vw, height: vh } = getViewport()
|
|
72
|
+
const margin = 8
|
|
73
|
+
|
|
74
|
+
const crossStart =
|
|
75
|
+
side === 'left' || side === 'right' ? triggerRect.top : triggerRect.left
|
|
76
|
+
const crossSize =
|
|
77
|
+
side === 'left' || side === 'right'
|
|
78
|
+
? triggerRect.height
|
|
79
|
+
: triggerRect.width
|
|
80
|
+
const contentCrossSize =
|
|
81
|
+
side === 'left' || side === 'right'
|
|
82
|
+
? contentRect.height
|
|
83
|
+
: contentRect.width
|
|
84
|
+
|
|
85
|
+
const cross = (() => {
|
|
86
|
+
if (align === 'start') return crossStart
|
|
87
|
+
if (align === 'end') return crossStart + crossSize - contentCrossSize
|
|
88
|
+
return crossStart + crossSize / 2 - contentCrossSize / 2
|
|
89
|
+
})()
|
|
90
|
+
|
|
91
|
+
let left = 0
|
|
92
|
+
let top = 0
|
|
93
|
+
|
|
94
|
+
if (side === 'bottom' || side === 'top') {
|
|
95
|
+
left = cross
|
|
96
|
+
top =
|
|
97
|
+
side === 'bottom'
|
|
98
|
+
? triggerRect.top + triggerRect.height + sideOffset
|
|
99
|
+
: triggerRect.top - contentRect.height - sideOffset
|
|
100
|
+
} else {
|
|
101
|
+
top = cross
|
|
102
|
+
left =
|
|
103
|
+
side === 'right'
|
|
104
|
+
? triggerRect.left + triggerRect.width + sideOffset
|
|
105
|
+
: triggerRect.left - contentRect.width - sideOffset
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const maxLeft = Math.max(margin, vw - contentRect.width - margin)
|
|
109
|
+
const maxTop = Math.max(margin, vh - contentRect.height - margin)
|
|
110
|
+
|
|
111
|
+
left = Math.min(Math.max(left, margin), maxLeft)
|
|
112
|
+
top = Math.min(Math.max(top, margin), maxTop)
|
|
113
|
+
|
|
114
|
+
return { left, top }
|
|
115
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Taro from "@tarojs/taro"
|
|
2
|
+
|
|
3
|
+
export const canUseDOM = () => typeof window !== "undefined" && typeof document !== "undefined"
|
|
4
|
+
|
|
5
|
+
export const isH5 = () => {
|
|
6
|
+
try {
|
|
7
|
+
return Taro.getEnv() === Taro.ENV_TYPE.WEB
|
|
8
|
+
} catch {
|
|
9
|
+
return canUseDOM()
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canUseDouyinContainer,
|
|
3
|
+
downloadByDouyinContainer,
|
|
4
|
+
isDouyinMiniProgram,
|
|
5
|
+
isDouyinPreviewEnv,
|
|
6
|
+
isWebPreviewEnv,
|
|
7
|
+
requestByDouyinContainer,
|
|
8
|
+
requestSSEByDouyinContainer,
|
|
9
|
+
uploadByDouyinContainer,
|
|
10
|
+
} from './douyin-container-request'
|
|
11
|
+
import {
|
|
12
|
+
mergeCachedDouyinLoginHeaders,
|
|
13
|
+
requestByDouyinLogin,
|
|
14
|
+
requestSSEByDouyinLogin,
|
|
15
|
+
requestSSEByFetch,
|
|
16
|
+
setDouyinLoginPlatformChannel,
|
|
17
|
+
uploadByDouyinLogin,
|
|
18
|
+
downloadByDouyinLogin,
|
|
19
|
+
} from './douyin-login-request'
|
|
20
|
+
import { mergeIframeIdentityHeaders } from '../internal/runtime/iframe-auth/index'
|
|
21
|
+
import { appendGetQuery, createUrl } from './network-url'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @desc 配置普通小程序 Network 的平台渠道。
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const options = { platformChannel: 'ext' as const }
|
|
28
|
+
* ```
|
|
29
|
+
* @ai-intent 配置普通小程序 Network 的平台渠道。
|
|
30
|
+
* @ai-when 需要让普通小程序请求携带内场或外场渠道标识时。
|
|
31
|
+
* @ai-avoid 不要在业务页面直接拼接渠道请求头。
|
|
32
|
+
* @ai-example { platformChannel: 'ext' }
|
|
33
|
+
*/
|
|
34
|
+
export interface CreateMicroappClientOptions {
|
|
35
|
+
/** @desc 平台渠道:空字符串为内场,ext 为外场;默认空字符串。 */
|
|
36
|
+
platformChannel?: '' | 'ext'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 网络请求模块
|
|
41
|
+
* 封装 Taro.request、Taro.uploadFile、Taro.downloadFile,自动添加项目域名前缀
|
|
42
|
+
* 如果请求的 url 以 http:// 或 https:// 开头,则不会添加域名前缀
|
|
43
|
+
*
|
|
44
|
+
* IMPORTANT: 项目已经全局注入 PROJECT_DOMAIN
|
|
45
|
+
* IMPORTANT: 除非你需要添加全局参数,如给所有请求加上 header,否则不能修改此文件
|
|
46
|
+
*/
|
|
47
|
+
export function createMicroappClient(
|
|
48
|
+
taro: Taro.TaroStatic,
|
|
49
|
+
options: CreateMicroappClientOptions = {},
|
|
50
|
+
) {
|
|
51
|
+
setDouyinLoginPlatformChannel(options.platformChannel ?? '')
|
|
52
|
+
const mergeExternalPlatformChannelHeader = (
|
|
53
|
+
header?: Record<string, unknown>,
|
|
54
|
+
): Record<string, unknown> | undefined => {
|
|
55
|
+
if (options.platformChannel !== 'ext') return header
|
|
56
|
+
return {
|
|
57
|
+
...header,
|
|
58
|
+
'ai-platform-channel': 'ext',
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 保留原模板的登录态复用;非 Web 预览的可信 iframe 身份可以覆盖它。
|
|
63
|
+
const mergeRequestIdentityHeaders = (
|
|
64
|
+
header?: Record<string, unknown>,
|
|
65
|
+
): Record<string, unknown> | undefined => {
|
|
66
|
+
const loginHeaders = mergeCachedDouyinLoginHeaders(header)
|
|
67
|
+
return isWebPreviewEnv()
|
|
68
|
+
? loginHeaders
|
|
69
|
+
: mergeIframeIdentityHeaders(taro, loginHeaders)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const request = (option => {
|
|
73
|
+
const method = option.method ?? 'GET'
|
|
74
|
+
if (/^http(s)?:\/\//.test(option.url)) {
|
|
75
|
+
return taro.request(option)
|
|
76
|
+
}
|
|
77
|
+
const externalPlatformHeader = mergeExternalPlatformChannelHeader(option.header)
|
|
78
|
+
const fallbackHeader = mergeRequestIdentityHeaders(externalPlatformHeader)
|
|
79
|
+
|
|
80
|
+
const logResponse = (url: string, res: Taro.request.SuccessCallbackResult<any>) => {
|
|
81
|
+
console.log(`[Network] ${method} ${url} ${res.statusCode}`, res.data)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (
|
|
85
|
+
isDouyinMiniProgram() &&
|
|
86
|
+
!isWebPreviewEnv() &&
|
|
87
|
+
!isDouyinPreviewEnv() &&
|
|
88
|
+
canUseDouyinContainer()
|
|
89
|
+
) {
|
|
90
|
+
const header = mergeRequestIdentityHeaders(externalPlatformHeader)
|
|
91
|
+
const promise = requestByDouyinContainer({
|
|
92
|
+
...option,
|
|
93
|
+
method,
|
|
94
|
+
header,
|
|
95
|
+
})
|
|
96
|
+
promise.then(res => logResponse(option.url, res)).catch(() => { })
|
|
97
|
+
return promise
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const promise = requestByDouyinLogin({
|
|
101
|
+
...option,
|
|
102
|
+
method,
|
|
103
|
+
header: fallbackHeader,
|
|
104
|
+
}).catch(() => {
|
|
105
|
+
const { url, data, ...rest } = option
|
|
106
|
+
const finalUrl = appendGetQuery(
|
|
107
|
+
createUrl(url),
|
|
108
|
+
data as Record<string, any> | undefined,
|
|
109
|
+
method,
|
|
110
|
+
)
|
|
111
|
+
return taro.request({
|
|
112
|
+
...rest,
|
|
113
|
+
url: finalUrl,
|
|
114
|
+
method,
|
|
115
|
+
header: fallbackHeader,
|
|
116
|
+
...(method.toUpperCase() === 'GET' ? {} : { data }),
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
promise.then(res => logResponse(option.url, res)).catch(() => { })
|
|
120
|
+
return promise
|
|
121
|
+
}) as typeof Taro.request
|
|
122
|
+
|
|
123
|
+
const uploadFile = ((option: Taro.uploadFile.Option) => {
|
|
124
|
+
if (!option.url) {
|
|
125
|
+
option.url = '';
|
|
126
|
+
}
|
|
127
|
+
if (/^http(s)?:\/\//.test(option.url)) {
|
|
128
|
+
return taro.uploadFile(option)
|
|
129
|
+
}
|
|
130
|
+
option.header = mergeExternalPlatformChannelHeader(option.header)
|
|
131
|
+
if (!option.name) {
|
|
132
|
+
option.name = 'file';
|
|
133
|
+
}
|
|
134
|
+
if (
|
|
135
|
+
isDouyinMiniProgram() &&
|
|
136
|
+
!isWebPreviewEnv() &&
|
|
137
|
+
!isDouyinPreviewEnv() &&
|
|
138
|
+
canUseDouyinContainer() &&
|
|
139
|
+
!/^http(s)?:\/\//.test(option.url)
|
|
140
|
+
) {
|
|
141
|
+
return uploadByDouyinContainer(option)
|
|
142
|
+
}
|
|
143
|
+
return uploadByDouyinLogin(option)
|
|
144
|
+
}) as (
|
|
145
|
+
option: Omit<Taro.uploadFile.Option, 'url' | 'name'> & { url?: string, name?: string },
|
|
146
|
+
) => ReturnType<typeof Taro.uploadFile>
|
|
147
|
+
|
|
148
|
+
const downloadFile = ((option: Taro.downloadFile.Option) => {
|
|
149
|
+
if (!option.url) {
|
|
150
|
+
option.url = '';
|
|
151
|
+
}
|
|
152
|
+
if (/^http(s)?:\/\//.test(option.url)) {
|
|
153
|
+
return taro.downloadFile(option)
|
|
154
|
+
}
|
|
155
|
+
option.header = mergeExternalPlatformChannelHeader(option.header)
|
|
156
|
+
if (
|
|
157
|
+
isDouyinMiniProgram() &&
|
|
158
|
+
!isWebPreviewEnv() &&
|
|
159
|
+
!isDouyinPreviewEnv() &&
|
|
160
|
+
canUseDouyinContainer() &&
|
|
161
|
+
!/^http(s)?:\/\//.test(option.url)
|
|
162
|
+
) {
|
|
163
|
+
return downloadByDouyinContainer(option)
|
|
164
|
+
}
|
|
165
|
+
return downloadByDouyinLogin(option)
|
|
166
|
+
}) as (
|
|
167
|
+
option: Omit<Taro.downloadFile.Option, 'url'> & { url?: string },
|
|
168
|
+
) => ReturnType<typeof Taro.downloadFile>
|
|
169
|
+
|
|
170
|
+
const streamSse = async (option: {
|
|
171
|
+
url: string;
|
|
172
|
+
method?: string;
|
|
173
|
+
data?: unknown;
|
|
174
|
+
header?: Record<string, unknown>;
|
|
175
|
+
onMessage(frame: string): void;
|
|
176
|
+
onError?(error: Error): void;
|
|
177
|
+
onComplete?(): void;
|
|
178
|
+
}) => {
|
|
179
|
+
const method = (option.method ?? "POST") as Taro.request.Option<
|
|
180
|
+
any,
|
|
181
|
+
any
|
|
182
|
+
>["method"];
|
|
183
|
+
const externalPlatformHeader = /^http(s)?:\/\//.test(option.url)
|
|
184
|
+
? option.header
|
|
185
|
+
: mergeExternalPlatformChannelHeader(option.header);
|
|
186
|
+
const fallbackHeader = mergeRequestIdentityHeaders(externalPlatformHeader);
|
|
187
|
+
|
|
188
|
+
let eventSourceTask: EventSourceTask;
|
|
189
|
+
if (
|
|
190
|
+
isDouyinMiniProgram() &&
|
|
191
|
+
!isWebPreviewEnv() &&
|
|
192
|
+
!isDouyinPreviewEnv() &&
|
|
193
|
+
canUseDouyinContainer() &&
|
|
194
|
+
!/^http(s)?:\/\//.test(option.url)
|
|
195
|
+
) {
|
|
196
|
+
const header = mergeRequestIdentityHeaders(externalPlatformHeader);
|
|
197
|
+
eventSourceTask = await requestSSEByDouyinContainer({
|
|
198
|
+
...option,
|
|
199
|
+
method,
|
|
200
|
+
header,
|
|
201
|
+
});
|
|
202
|
+
} else {
|
|
203
|
+
try {
|
|
204
|
+
eventSourceTask = await requestSSEByDouyinLogin({
|
|
205
|
+
...option,
|
|
206
|
+
method,
|
|
207
|
+
header: fallbackHeader,
|
|
208
|
+
});
|
|
209
|
+
} catch {
|
|
210
|
+
const { url, data, ...rest } = option;
|
|
211
|
+
const finalUrl = appendGetQuery(
|
|
212
|
+
createUrl(url),
|
|
213
|
+
data as Record<string, any> | undefined,
|
|
214
|
+
method,
|
|
215
|
+
);
|
|
216
|
+
eventSourceTask = await requestSSEByFetch({
|
|
217
|
+
...rest,
|
|
218
|
+
url: finalUrl,
|
|
219
|
+
method,
|
|
220
|
+
header: fallbackHeader,
|
|
221
|
+
...(method?.toUpperCase() === "GET" ? {} : { data }),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
eventSourceTask.onMessage((chunk) => {
|
|
227
|
+
option.onMessage(chunk.data);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
eventSourceTask.onClose(() => {
|
|
231
|
+
option.onComplete?.();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
close: eventSourceTask.close,
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
request,
|
|
242
|
+
uploadFile,
|
|
243
|
+
downloadFile,
|
|
244
|
+
streamSse,
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
+
import {
|
|
3
|
+
createMicroappClient as createMicroappClientWithTaro,
|
|
4
|
+
type CreateMicroappClientOptions,
|
|
5
|
+
} from './client'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @desc 创建普通小程序的网络入口;SDK 自动绑定项目 Taro 运行时。
|
|
9
|
+
* @params {CreateMicroappClientOptions} [options] 平台渠道配置;默认使用内场渠道。
|
|
10
|
+
* @return {ReturnType<typeof createMicroappClient>} 仅提供普通小程序的 request、uploadFile、downloadFile 和 streamSse。
|
|
11
|
+
* @remarks 业务优先从模板的 @/network 导入 Network;HTTP(S) 绝对地址直接交给 Taro。宿主需要封闭域功能时通过 MiniappOpenCard 承载,请求与数据处理仅在卡内完成。
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const Network = createMicroappClient({ platformChannel: 'ext' })
|
|
15
|
+
* const response = await Network.request({ url: '/api/products', method: 'GET' })
|
|
16
|
+
* ```
|
|
17
|
+
* @ai-intent 创建绑定默认 Taro 实例的普通小程序 Network。
|
|
18
|
+
* @ai-when 业务代码需要统一调用普通小程序的 request、uploadFile、downloadFile 或 streamSse 时。
|
|
19
|
+
* @ai-avoid 不要在页面中直接调用 Taro.request,也不要传入 OpenCard 的 taro 实例。
|
|
20
|
+
* @ai-example const Network = createMicroappClient({ platformChannel: 'ext' })
|
|
21
|
+
*/
|
|
22
|
+
export function createMicroappClient(
|
|
23
|
+
options: CreateMicroappClientOptions = {},
|
|
24
|
+
) {
|
|
25
|
+
return createMicroappClientWithTaro(Taro, options)
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { clearDouyinLoginAuth } from './douyin-login-request'
|
|
2
|
+
import type { IframeTaroRuntime } from '../internal/runtime/iframe-auth/index'
|
|
3
|
+
import { subscribeIframeAuth } from '../internal/runtime/iframe-auth/index'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @desc 同步普通小程序 iframe 身份并返回监听清理函数。
|
|
7
|
+
* @params {IframeTaroRuntime | null | undefined} taro 当前 Taro 运行时实例。
|
|
8
|
+
* @return {() => void} 清理身份消息监听的函数。
|
|
9
|
+
* @example const cleanup = syncIframeAuth(Taro)
|
|
10
|
+
*/
|
|
11
|
+
export const syncIframeAuth = (
|
|
12
|
+
taro: IframeTaroRuntime | null | undefined,
|
|
13
|
+
) => subscribeIframeAuth(taro, clearDouyinLoginAuth)
|