tempest-react-sdk 0.52.0 → 0.54.0
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 +58 -7
- package/dist/access/Can.cjs +1 -1
- package/dist/access/Can.cjs.map +1 -1
- package/dist/access/Can.js +3 -3
- package/dist/access/Can.js.map +1 -1
- package/dist/audio/audio-bus.cjs +2 -0
- package/dist/audio/audio-bus.cjs.map +1 -0
- package/dist/audio/audio-bus.js +116 -0
- package/dist/audio/audio-bus.js.map +1 -0
- package/dist/audio/level-meter.cjs +1 -1
- package/dist/audio/level-meter.cjs.map +1 -1
- package/dist/audio/level-meter.js +15 -15
- package/dist/audio/level-meter.js.map +1 -1
- package/dist/audio/noise-floor.cjs +2 -0
- package/dist/audio/noise-floor.cjs.map +1 -0
- package/dist/audio/noise-floor.js +27 -0
- package/dist/audio/noise-floor.js.map +1 -0
- package/dist/audio/use-audio-bus.cjs +2 -0
- package/dist/audio/use-audio-bus.cjs.map +1 -0
- package/dist/audio/use-audio-bus.js +11 -0
- package/dist/audio/use-audio-bus.js.map +1 -0
- package/dist/audio/voice-activity.cjs +2 -0
- package/dist/audio/voice-activity.cjs.map +1 -0
- package/dist/audio/voice-activity.js +26 -0
- package/dist/audio/voice-activity.js.map +1 -0
- package/dist/audio/voice-chain-stages.cjs +2 -0
- package/dist/audio/voice-chain-stages.cjs.map +1 -0
- package/dist/audio/voice-chain-stages.js +82 -0
- package/dist/audio/voice-chain-stages.js.map +1 -0
- package/dist/audio/voice-chain.cjs +2 -0
- package/dist/audio/voice-chain.cjs.map +1 -0
- package/dist/audio/voice-chain.js +74 -0
- package/dist/audio/voice-chain.js.map +1 -0
- package/dist/auth/lazy-with-retry.cjs.map +1 -1
- package/dist/auth/lazy-with-retry.js.map +1 -1
- package/dist/auth/passkey.cjs.map +1 -1
- package/dist/auth/passkey.js.map +1 -1
- package/dist/br/BrazilStateCitySelect.cjs +1 -1
- package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
- package/dist/br/BrazilStateCitySelect.js +36 -28
- package/dist/br/BrazilStateCitySelect.js.map +1 -1
- package/dist/br/data/br-centroids.cjs +1 -1
- package/dist/br/data/br-centroids.cjs.map +1 -1
- package/dist/br/data/br-centroids.js +11105 -11045
- package/dist/br/data/br-centroids.js.map +1 -1
- package/dist/br/data/br-locations.cjs +1 -1
- package/dist/br/data/br-locations.cjs.map +1 -1
- package/dist/br/data/br-locations.js +5803 -137
- package/dist/br/data/br-locations.js.map +1 -1
- package/dist/br/data/br-uf-geo.cjs +1 -1
- package/dist/br/data/br-uf-geo.cjs.map +1 -1
- package/dist/br/data/br-uf-geo.js +5721 -6777
- package/dist/br/data/br-uf-geo.js.map +1 -1
- package/dist/br/data/mun/AC.cjs +1 -1
- package/dist/br/data/mun/AC.cjs.map +1 -1
- package/dist/br/data/mun/AC.js +681 -689
- package/dist/br/data/mun/AC.js.map +1 -1
- package/dist/br/data/mun/AL.cjs +1 -1
- package/dist/br/data/mun/AL.cjs.map +1 -1
- package/dist/br/data/mun/AL.js +949 -844
- package/dist/br/data/mun/AL.js.map +1 -1
- package/dist/br/data/mun/AM.cjs +1 -1
- package/dist/br/data/mun/AM.cjs.map +1 -1
- package/dist/br/data/mun/AM.js +4337 -4218
- package/dist/br/data/mun/AM.js.map +1 -1
- package/dist/br/data/mun/AP.cjs +1 -1
- package/dist/br/data/mun/AP.cjs.map +1 -1
- package/dist/br/data/mun/AP.js +786 -780
- package/dist/br/data/mun/AP.js.map +1 -1
- package/dist/br/data/mun/BA.cjs +1 -1
- package/dist/br/data/mun/BA.cjs.map +1 -1
- package/dist/br/data/mun/BA.js +6329 -5633
- package/dist/br/data/mun/BA.js.map +1 -1
- package/dist/br/data/mun/CE.cjs +1 -1
- package/dist/br/data/mun/CE.cjs.map +1 -1
- package/dist/br/data/mun/CE.js +2544 -2487
- package/dist/br/data/mun/CE.js.map +1 -1
- package/dist/br/data/mun/DF.cjs +1 -1
- package/dist/br/data/mun/DF.cjs.map +1 -1
- package/dist/br/data/mun/DF.js +17 -16
- package/dist/br/data/mun/DF.js.map +1 -1
- package/dist/br/data/mun/ES.cjs +1 -1
- package/dist/br/data/mun/ES.cjs.map +1 -1
- package/dist/br/data/mun/ES.js +1101 -1070
- package/dist/br/data/mun/ES.js.map +1 -1
- package/dist/br/data/mun/GO.cjs +1 -1
- package/dist/br/data/mun/GO.cjs.map +1 -1
- package/dist/br/data/mun/GO.js +4632 -4636
- package/dist/br/data/mun/GO.js.map +1 -1
- package/dist/br/data/mun/MA.cjs +1 -1
- package/dist/br/data/mun/MA.cjs.map +1 -1
- package/dist/br/data/mun/MA.js +3603 -3457
- package/dist/br/data/mun/MA.js.map +1 -1
- package/dist/br/data/mun/MG.cjs +1 -1
- package/dist/br/data/mun/MG.cjs.map +1 -1
- package/dist/br/data/mun/MG.js +12716 -11739
- package/dist/br/data/mun/MG.js.map +1 -1
- package/dist/br/data/mun/MS.cjs +1 -1
- package/dist/br/data/mun/MS.cjs.map +1 -1
- package/dist/br/data/mun/MS.js +2182 -2335
- package/dist/br/data/mun/MS.js.map +1 -1
- package/dist/br/data/mun/MT.cjs +1 -1
- package/dist/br/data/mun/MT.cjs.map +1 -1
- package/dist/br/data/mun/MT.js +4808 -4896
- package/dist/br/data/mun/MT.js.map +1 -1
- package/dist/br/data/mun/PA.cjs +1 -1
- package/dist/br/data/mun/PA.cjs.map +1 -1
- package/dist/br/data/mun/PA.js +4981 -4901
- package/dist/br/data/mun/PA.js.map +1 -1
- package/dist/br/data/mun/PB.cjs +1 -1
- package/dist/br/data/mun/PB.cjs.map +1 -1
- package/dist/br/data/mun/PB.js +2418 -1956
- package/dist/br/data/mun/PB.js.map +1 -1
- package/dist/br/data/mun/PE.cjs +1 -1
- package/dist/br/data/mun/PE.cjs.map +1 -1
- package/dist/br/data/mun/PE.js +2164 -1987
- package/dist/br/data/mun/PE.js.map +1 -1
- package/dist/br/data/mun/PI.cjs +1 -1
- package/dist/br/data/mun/PI.cjs.map +1 -1
- package/dist/br/data/mun/PI.js +2982 -2844
- package/dist/br/data/mun/PI.js.map +1 -1
- package/dist/br/data/mun/PR.cjs +1 -1
- package/dist/br/data/mun/PR.cjs.map +1 -1
- package/dist/br/data/mun/PR.js +5425 -5240
- package/dist/br/data/mun/PR.js.map +1 -1
- package/dist/br/data/mun/RJ.cjs +1 -1
- package/dist/br/data/mun/RJ.cjs.map +1 -1
- package/dist/br/data/mun/RJ.js +1395 -1178
- package/dist/br/data/mun/RJ.js.map +1 -1
- package/dist/br/data/mun/RN.cjs +1 -1
- package/dist/br/data/mun/RN.cjs.map +1 -1
- package/dist/br/data/mun/RN.js +1608 -1382
- package/dist/br/data/mun/RN.js.map +1 -1
- package/dist/br/data/mun/RO.cjs +1 -1
- package/dist/br/data/mun/RO.cjs.map +1 -1
- package/dist/br/data/mun/RO.js +1392 -1470
- package/dist/br/data/mun/RO.js.map +1 -1
- package/dist/br/data/mun/RR.cjs +1 -1
- package/dist/br/data/mun/RR.cjs.map +1 -1
- package/dist/br/data/mun/RR.js +795 -778
- package/dist/br/data/mun/RR.js.map +1 -1
- package/dist/br/data/mun/RS.cjs +1 -1
- package/dist/br/data/mun/RS.cjs.map +1 -1
- package/dist/br/data/mun/RS.js +7579 -6424
- package/dist/br/data/mun/RS.js.map +1 -1
- package/dist/br/data/mun/SC.cjs +1 -1
- package/dist/br/data/mun/SC.cjs.map +1 -1
- package/dist/br/data/mun/SC.js +3979 -3357
- package/dist/br/data/mun/SC.js.map +1 -1
- package/dist/br/data/mun/SE.cjs +1 -1
- package/dist/br/data/mun/SE.cjs.map +1 -1
- package/dist/br/data/mun/SE.js +812 -625
- package/dist/br/data/mun/SE.js.map +1 -1
- package/dist/br/data/mun/SP.cjs +1 -1
- package/dist/br/data/mun/SP.cjs.map +1 -1
- package/dist/br/data/mun/SP.js +7866 -6803
- package/dist/br/data/mun/SP.js.map +1 -1
- package/dist/br/data/mun/TO.cjs +1 -1
- package/dist/br/data/mun/TO.cjs.map +1 -1
- package/dist/br/data/mun/TO.js +2763 -2817
- package/dist/br/data/mun/TO.js.map +1 -1
- package/dist/br/locations.cjs +1 -1
- package/dist/br/locations.cjs.map +1 -1
- package/dist/br/locations.js +97 -24
- package/dist/br/locations.js.map +1 -1
- package/dist/br/scales.cjs +1 -1
- package/dist/br/scales.cjs.map +1 -1
- package/dist/br/scales.js +8 -4
- package/dist/br/scales.js.map +1 -1
- package/dist/br/whatsapp.cjs +2 -0
- package/dist/br/whatsapp.cjs.map +1 -0
- package/dist/br/whatsapp.js +21 -0
- package/dist/br/whatsapp.js.map +1 -0
- package/dist/br.cjs +1 -1
- package/dist/br.cjs.map +1 -1
- package/dist/br.d.ts +188 -10
- package/dist/br.js +18 -17
- package/dist/br.js.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +30 -27
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/components/Command/Command.cjs +1 -1
- package/dist/components/Command/Command.cjs.map +1 -1
- package/dist/components/Command/Command.js +78 -75
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.js +42 -39
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +111 -67
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js +45 -42
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Money/Money.cjs +1 -1
- package/dist/components/Money/Money.cjs.map +1 -1
- package/dist/components/Money/Money.js +10 -9
- package/dist/components/Money/Money.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs +1 -1
- package/dist/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.js +38 -31
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/Pagination/Pagination.module.cjs +1 -1
- package/dist/components/Pagination/Pagination.module.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.module.js +4 -4
- package/dist/components/Pagination/Pagination.module.js.map +1 -1
- package/dist/components/Portal/Portal.cjs +1 -1
- package/dist/components/Portal/Portal.cjs.map +1 -1
- package/dist/components/Portal/Portal.js +9 -6
- package/dist/components/Portal/Portal.js.map +1 -1
- package/dist/components/Portal/portal-host.cjs +2 -0
- package/dist/components/Portal/portal-host.cjs.map +1 -0
- package/dist/components/Portal/portal-host.js +11 -0
- package/dist/components/Portal/portal-host.js.map +1 -0
- package/dist/components/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.js +23 -23
- package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.cjs +1 -1
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.js +83 -82
- package/dist/components/Scheduler/Scheduler.js.map +1 -1
- package/dist/components/Slider/Slider.cjs +1 -1
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.js +9 -9
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js +55 -53
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js +41 -31
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.js +78 -68
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
- package/dist/forms/FormField.cjs +1 -1
- package/dist/forms/FormField.cjs.map +1 -1
- package/dist/forms/FormField.js +23 -21
- package/dist/forms/FormField.js.map +1 -1
- package/dist/forms/masked-inputs.cjs +1 -1
- package/dist/forms/masked-inputs.cjs.map +1 -1
- package/dist/forms/masked-inputs.js +20 -19
- package/dist/forms/masked-inputs.js.map +1 -1
- package/dist/hooks/use-fullscreen-element.cjs +2 -0
- package/dist/hooks/use-fullscreen-element.cjs.map +1 -0
- package/dist/hooks/use-fullscreen-element.js +20 -0
- package/dist/hooks/use-fullscreen-element.js.map +1 -0
- package/dist/hooks/use-fullscreen.cjs +2 -0
- package/dist/hooks/use-fullscreen.cjs.map +1 -0
- package/dist/hooks/use-fullscreen.js +66 -0
- package/dist/hooks/use-fullscreen.js.map +1 -0
- package/dist/hooks/use-push-to-talk.cjs +2 -0
- package/dist/hooks/use-push-to-talk.cjs.map +1 -0
- package/dist/hooks/use-push-to-talk.js +61 -0
- package/dist/hooks/use-push-to-talk.js.map +1 -0
- package/dist/http/describe-api-error.cjs.map +1 -1
- package/dist/http/describe-api-error.js.map +1 -1
- package/dist/http/errors.cjs +1 -1
- package/dist/http/errors.cjs.map +1 -1
- package/dist/http/errors.js +34 -16
- package/dist/http/errors.js.map +1 -1
- package/dist/http/parse-response.cjs +2 -2
- package/dist/http/parse-response.cjs.map +1 -1
- package/dist/http/parse-response.js +9 -8
- package/dist/http/parse-response.js.map +1 -1
- package/dist/i18n/create-i18n.cjs +1 -1
- package/dist/i18n/create-i18n.cjs.map +1 -1
- package/dist/i18n/create-i18n.js +28 -27
- package/dist/i18n/create-i18n.js.map +1 -1
- package/dist/query/QueryProvider.cjs +1 -1
- package/dist/query/QueryProvider.cjs.map +1 -1
- package/dist/query/QueryProvider.js +13 -11
- package/dist/query/QueryProvider.js.map +1 -1
- package/dist/query/foreign-client-warning.cjs +2 -0
- package/dist/query/foreign-client-warning.cjs.map +1 -0
- package/dist/query/foreign-client-warning.js +12 -0
- package/dist/query/foreign-client-warning.js.map +1 -0
- package/dist/router/AppRouter.cjs +1 -1
- package/dist/router/AppRouter.cjs.map +1 -1
- package/dist/router/AppRouter.js +28 -21
- package/dist/router/AppRouter.js.map +1 -1
- package/dist/router/RouteGuard.cjs +1 -1
- package/dist/router/RouteGuard.cjs.map +1 -1
- package/dist/router/RouteGuard.js +4 -4
- package/dist/router/RouteGuard.js.map +1 -1
- package/dist/sse/create-event-stream.cjs +1 -1
- package/dist/sse/create-event-stream.cjs.map +1 -1
- package/dist/sse/create-event-stream.js +34 -38
- package/dist/sse/create-event-stream.js.map +1 -1
- package/dist/styles/AIChat.css +79 -0
- package/dist/styles/Accordion.css +12 -0
- package/dist/styles/Alert.css +32 -0
- package/dist/styles/AppBar.css +17 -0
- package/dist/styles/AppShell.css +8 -0
- package/dist/styles/AspectRatio.css +3 -0
- package/dist/styles/AudioPlayer.css +13 -0
- package/dist/styles/AudioRecorder.css +20 -0
- package/dist/styles/Avatar.css +13 -0
- package/dist/styles/AvatarGroup.css +18 -0
- package/dist/styles/Badge.css +25 -0
- package/dist/styles/Banner.css +13 -0
- package/dist/styles/BarList.css +10 -0
- package/dist/styles/BarcodeScanner.css +21 -0
- package/dist/styles/BottomNavigation.css +10 -0
- package/dist/styles/BottomSheet.css +11 -0
- package/dist/styles/BrazilMap.css +20 -0
- package/dist/styles/Breadcrumbs.css +8 -0
- package/dist/styles/Button.css +42 -0
- package/dist/styles/Calendar.css +16 -0
- package/dist/styles/Card.css +15 -0
- package/dist/styles/Carousel.css +17 -0
- package/dist/styles/Center.css +5 -0
- package/dist/styles/Chat.css +35 -0
- package/dist/styles/Checkbox.css +11 -0
- package/dist/styles/ChipInput.css +13 -0
- package/dist/styles/CodeBlock.css +25 -0
- package/dist/styles/Collapsible.css +6 -0
- package/dist/styles/Combobox.css +18 -0
- package/dist/styles/Command.css +20 -0
- package/dist/styles/ContextMenu.css +11 -0
- package/dist/styles/CopyButton.css +4 -0
- package/dist/styles/DataList.css +3 -0
- package/dist/styles/DataTable.css +19 -0
- package/dist/styles/DateRangePicker.css +22 -0
- package/dist/styles/DescriptionList.css +4 -0
- package/dist/styles/Divider.css +11 -0
- package/dist/styles/Drawer.css +22 -0
- package/dist/styles/DropdownMenu.css +16 -0
- package/dist/styles/Dropzone.css +7 -0
- package/dist/styles/EmptyState.css +6 -0
- package/dist/styles/ErrorState.css +6 -0
- package/dist/styles/ErrorText.css +2 -0
- package/dist/styles/FileUpload.css +17 -0
- package/dist/styles/FilterBar.css +19 -0
- package/dist/styles/FloatingActionButton.css +23 -0
- package/dist/styles/Form.css +21 -0
- package/dist/styles/HoverCard.css +11 -0
- package/dist/styles/IconPicker.css +6 -0
- package/dist/styles/Image.css +2 -0
- package/dist/styles/ImageCropper.css +16 -0
- package/dist/styles/Input.css +24 -0
- package/dist/styles/InstallBanner.css +8 -0
- package/dist/styles/Kanban.css +15 -0
- package/dist/styles/Kbd.css +5 -0
- package/dist/styles/Label.css +3 -0
- package/dist/styles/Layout.css +22 -0
- package/dist/styles/Lightbox.css +21 -0
- package/dist/styles/ListTile.css +14 -0
- package/dist/styles/MapLegend.css +9 -0
- package/dist/styles/Markdown.css +24 -0
- package/dist/styles/Masonry.css +4 -0
- package/dist/styles/Menubar.css +17 -0
- package/dist/styles/Modal.css +21 -0
- package/dist/styles/ModalsManager.css +2 -0
- package/dist/styles/MultiSelect.css +21 -0
- package/dist/styles/MunicipalitySearch.css +6 -0
- package/dist/styles/NProgress.css +2 -0
- package/dist/styles/Navbar.css +10 -0
- package/dist/styles/NavigationMenu.css +12 -0
- package/dist/styles/NavigationRail.css +14 -0
- package/dist/styles/NotificationCenter.css +21 -0
- package/dist/styles/OfflineIndicator.css +7 -0
- package/dist/styles/Page.css +13 -0
- package/dist/styles/Pagination.css +12 -0
- package/dist/styles/PasswordInput.css +21 -0
- package/dist/styles/PinInput.css +13 -0
- package/dist/styles/PixQRCode.css +9 -0
- package/dist/styles/Popover.css +10 -0
- package/dist/styles/Progress.css +11 -0
- package/dist/styles/QRCode.css +3 -0
- package/dist/styles/Radio.css +14 -0
- package/dist/styles/RangeSlider.css +15 -0
- package/dist/styles/RatingStars.css +11 -0
- package/dist/styles/RefreshIndicator.css +5 -0
- package/dist/styles/Resizable.css +13 -0
- package/dist/styles/RichTextEditor.css +19 -0
- package/dist/styles/SafeArea.css +7 -0
- package/dist/styles/Scheduler.css +24 -0
- package/dist/styles/ScrollArea.css +7 -0
- package/dist/styles/SearchBar.css +11 -0
- package/dist/styles/SegmentedControl.css +12 -0
- package/dist/styles/Select.css +14 -0
- package/dist/styles/Sidebar.css +19 -0
- package/dist/styles/SignaturePad.css +6 -0
- package/dist/styles/Skeleton.css +7 -0
- package/dist/styles/Slider.css +15 -0
- package/dist/styles/Spacer.css +4 -0
- package/dist/styles/Sparkline.css +4 -0
- package/dist/styles/Spinner.css +12 -0
- package/dist/styles/Stat.css +12 -0
- package/dist/styles/Stepper.css +17 -0
- package/dist/styles/StepperInput.css +15 -0
- package/dist/styles/Switch.css +11 -0
- package/dist/styles/SyncStatusBadge.css +13 -0
- package/dist/styles/Table.css +16 -0
- package/dist/styles/Tabs.css +14 -0
- package/dist/styles/Tag.css +14 -0
- package/dist/styles/Textarea.css +13 -0
- package/dist/styles/TimePicker.css +14 -0
- package/dist/styles/Timeline.css +17 -0
- package/dist/styles/Toast.css +21 -0
- package/dist/styles/Toggle.css +12 -0
- package/dist/styles/ToggleGroup.css +9 -0
- package/dist/styles/Tooltip.css +10 -0
- package/dist/styles/Tour.css +20 -0
- package/dist/styles/TrajectoryMap.css +16 -0
- package/dist/styles/Transfer.css +21 -0
- package/dist/styles/TreeView.css +17 -0
- package/dist/styles/TruncateText.css +2 -0
- package/dist/styles/UpdatePrompt.css +10 -0
- package/dist/styles/VirtualList.css +5 -0
- package/dist/styles/VirtualTable.css +17 -0
- package/dist/styles/VisuallyHidden.css +2 -0
- package/dist/styles/Wizard.css +4 -0
- package/dist/styles/actions.css +104 -0
- package/dist/styles/advanced.css +66 -0
- package/dist/styles/br.css +41 -0
- package/dist/styles/chat.css +113 -0
- package/dist/styles/core.css +40 -0
- package/dist/styles/data.css +222 -0
- package/dist/styles/editor.css +19 -0
- package/dist/styles/feedback.css +201 -0
- package/dist/styles/forms.css +321 -0
- package/dist/styles/geo.css +16 -0
- package/dist/styles/icons.css +6 -0
- package/dist/styles/identity.css +48 -0
- package/dist/styles/layout.css +122 -0
- package/dist/styles/media.css +52 -0
- package/dist/styles/navigation.css +167 -0
- package/dist/styles/overlay.css +73 -0
- package/dist/styles/utility.css +39 -0
- package/dist/styles.css +1 -1
- package/dist/sw/register-service-worker.cjs +1 -1
- package/dist/sw/register-service-worker.cjs.map +1 -1
- package/dist/sw/register-service-worker.js +21 -17
- package/dist/sw/register-service-worker.js.map +1 -1
- package/dist/sw.d.ts +17 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +1382 -76
- package/dist/tempest-react-sdk.js +293 -281
- package/dist/utils/dev-mode.cjs.map +1 -1
- package/dist/utils/dev-mode.js.map +1 -1
- package/dist/utils/duplicate-instance.cjs +2 -0
- package/dist/utils/duplicate-instance.cjs.map +1 -0
- package/dist/utils/duplicate-instance.js +6 -0
- package/dist/utils/duplicate-instance.js.map +1 -0
- package/dist/utils/format.cjs +1 -1
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.js +22 -14
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/intl-cache.cjs +2 -0
- package/dist/utils/intl-cache.cjs.map +1 -0
- package/dist/utils/intl-cache.js +23 -0
- package/dist/utils/intl-cache.js.map +1 -0
- package/dist/utils/json-frame.cjs +2 -0
- package/dist/utils/json-frame.cjs.map +1 -0
- package/dist/utils/json-frame.js +30 -0
- package/dist/utils/json-frame.js.map +1 -0
- package/dist/utils/numbers.cjs +1 -1
- package/dist/utils/numbers.cjs.map +1 -1
- package/dist/utils/numbers.js +8 -7
- package/dist/utils/numbers.js.map +1 -1
- package/dist/vision/results.cjs +1 -1
- package/dist/vision/results.cjs.map +1 -1
- package/dist/vision/results.js +26 -17
- package/dist/vision/results.js.map +1 -1
- package/dist/vision.d.ts +29 -0
- package/dist/vite/tempest-icons.cjs +1 -1
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-icons.js +1 -1
- package/dist/vite/tempest-icons.js.map +1 -1
- package/dist/webrtc/link-stats.cjs +2 -0
- package/dist/webrtc/link-stats.cjs.map +1 -0
- package/dist/webrtc/link-stats.js +74 -0
- package/dist/webrtc/link-stats.js.map +1 -0
- package/dist/webrtc/opus-sdp.cjs +3 -0
- package/dist/webrtc/opus-sdp.cjs.map +1 -0
- package/dist/webrtc/opus-sdp.js +94 -0
- package/dist/webrtc/opus-sdp.js.map +1 -0
- package/dist/webrtc/sender-bitrate.cjs +2 -0
- package/dist/webrtc/sender-bitrate.cjs.map +1 -0
- package/dist/webrtc/sender-bitrate.js +15 -0
- package/dist/webrtc/sender-bitrate.js.map +1 -0
- package/dist/webrtc/use-link-stats.cjs +2 -0
- package/dist/webrtc/use-link-stats.cjs.map +1 -0
- package/dist/webrtc/use-link-stats.js +22 -0
- package/dist/webrtc/use-link-stats.js.map +1 -0
- package/dist/ws/create-web-socket.cjs +1 -1
- package/dist/ws/create-web-socket.cjs.map +1 -1
- package/dist/ws/create-web-socket.js +130 -58
- package/dist/ws/create-web-socket.js.map +1 -1
- package/dist/ws/resilience.cjs +2 -0
- package/dist/ws/resilience.cjs.map +1 -0
- package/dist/ws/resilience.js +21 -0
- package/dist/ws/resilience.js.map +1 -0
- package/dist/ws/use-web-socket.cjs +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js +47 -39
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +5 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
`);throw Error(`[parseResponse] Contract drift on ${
|
|
1
|
+
const e=require("../utils/dev-mode.cjs");function t(t,n,r){let i=t.safeParse(n);if(i.success)return i.data;if(e.isDevBuild()){let e=i.error.issues.map(e=>` - ${e.path.join(`.`)||`<root>`}: ${e.message}`).join(`
|
|
2
|
+
`);throw Error(`[parseResponse] Contract drift on ${r}:\n${e}\n\nRaw payload: ${JSON.stringify(n,null,2)}`)}throw Error(`Resposta inválida do servidor (${r}).`)}exports.parseResponse=t;
|
|
3
3
|
//# sourceMappingURL=parse-response.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-response.cjs","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n *
|
|
1
|
+
{"version":3,"file":"parse-response.cjs","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * A development build throws a detailed error naming every divergent field path\n * and embedding the raw payload; every other build throws a generic sentence, so\n * server internals never reach a user's screen or an error tracker.\n *\n * Which one you get comes from `isDevBuild()`, the SDK's single answer to that\n * question, rather than from a check written here. This function used to ask\n * `typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\"`,\n * and a browser has no `process` identifier at all — so the guard short-circuited\n * and the detailed branch was dead in exactly the build it was written for, no\n * matter what the bundler substituted behind it.\n *\n * The rule `isDevBuild()` applies is `NODE_ENV !== \"production\"`, which is wider\n * than the old `\"development\" || \"test\"`: a staging build that never sets\n * `NODE_ENV=production` gets the drift report, raw payload included.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n * @throws Error When the payload does not match the schema: `[parseResponse]\n * Contract drift on <context>` with the field paths and the raw payload in a\n * development build, `Resposta inválida do servidor (<context>).` otherwise.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n if (isDevBuild()) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":"yCA8BA,SAAgB,EACZ,EACA,EACA,EACgB,CAChB,IAAM,EAAS,EAAO,UAAU,CAAG,EACnC,GAAI,EAAO,QACP,OAAO,EAAO,KAGlB,GAAI,EAAA,WAAW,EAAG,CACd,IAAM,EAAS,EAAO,MAAM,OACvB,IAAK,GAAM,OAAO,EAAE,KAAK,KAAK,GAAG,GAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK;CAAI,EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,EAAK,KAAM,CAAC,GAC3G,CACJ,CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG,CACjE"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { isDevBuild as e } from "../utils/dev-mode.js";
|
|
1
2
|
//#region src/http/parse-response.ts
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
if (
|
|
5
|
-
if (
|
|
6
|
-
let e =
|
|
7
|
-
throw Error(`[parseResponse] Contract drift on ${
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
let i = t.safeParse(n);
|
|
5
|
+
if (i.success) return i.data;
|
|
6
|
+
if (e()) {
|
|
7
|
+
let e = i.error.issues.map((e) => ` - ${e.path.join(".") || "<root>"}: ${e.message}`).join("\n");
|
|
8
|
+
throw Error(`[parseResponse] Contract drift on ${r}:\n${e}\n\nRaw payload: ${JSON.stringify(n, null, 2)}`);
|
|
8
9
|
}
|
|
9
|
-
throw Error(`Resposta inválida do servidor (${
|
|
10
|
+
throw Error(`Resposta inválida do servidor (${r}).`);
|
|
10
11
|
}
|
|
11
12
|
//#endregion
|
|
12
|
-
export {
|
|
13
|
+
export { t as parseResponse };
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=parse-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-response.js","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n *
|
|
1
|
+
{"version":3,"file":"parse-response.js","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * A development build throws a detailed error naming every divergent field path\n * and embedding the raw payload; every other build throws a generic sentence, so\n * server internals never reach a user's screen or an error tracker.\n *\n * Which one you get comes from `isDevBuild()`, the SDK's single answer to that\n * question, rather than from a check written here. This function used to ask\n * `typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\"`,\n * and a browser has no `process` identifier at all — so the guard short-circuited\n * and the detailed branch was dead in exactly the build it was written for, no\n * matter what the bundler substituted behind it.\n *\n * The rule `isDevBuild()` applies is `NODE_ENV !== \"production\"`, which is wider\n * than the old `\"development\" || \"test\"`: a staging build that never sets\n * `NODE_ENV=production` gets the drift report, raw payload included.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n * @throws Error When the payload does not match the schema: `[parseResponse]\n * Contract drift on <context>` with the field paths and the raw payload in a\n * development build, `Resposta inválida do servidor (<context>).` otherwise.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n if (isDevBuild()) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":";;AA8BA,SAAgB,EACZ,GACA,GACA,GACgB;CAChB,IAAM,IAAS,EAAO,UAAU,CAAG;CACnC,IAAI,EAAO,SACP,OAAO,EAAO;CAGlB,IAAI,EAAW,GAAG;EACd,IAAM,IAAS,EAAO,MAAM,OACvB,KAAK,MAAM,OAAO,EAAE,KAAK,KAAK,GAAG,KAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK,IAAI;EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,GAAK,MAAM,CAAC,GAC3G;CACJ;CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG;AACjE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../utils/intl-cache.cjs");function t(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?`{${n}}`:String(r)}):e}function n(e,t,n,r){let i=e[t]?.[r];if(i!==void 0)return i;if(n){let t=e[n]?.[r];if(t!==void 0)return t}return null}function r(i){let{locale:a,fallbackLocale:o=null,messages:s}=i;function c(e,r,i){let c=n(s,a,o,e)??i?.default;return c===void 0?e:t(c,r)}function l(e,r,i,c){let l=n(s,a,o,`${e}${r===1?`_one`:`_other`}`)??n(s,a,o,e)??c?.default;return l===void 0?e:t(l,{count:r,...i??{}})}function u(t,n){return e.numberFormat(a,n).format(t)}function d(t,n){let r=typeof t==`string`?new Date(t):t;return Number.isNaN(r.getTime())?``:e.dateTimeFormat(a,n).format(r)}return{locale:a,fallbackLocale:o,t:c,plural:l,formatNumber:u,formatDate:d,withLocale:e=>r({locale:e,fallbackLocale:o??void 0,messages:s})}}exports.createI18n=r;
|
|
2
2
|
//# sourceMappingURL=create-i18n.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-i18n.cjs","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"create-i18n.cjs","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["import { dateTimeFormat, numberFormat } from \"@/utils/intl-cache\";\nexport type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return numberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return dateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":"2CA6DA,SAAS,EAAY,EAAkB,EAAsC,CAEzE,OADK,EACE,EAAS,QAAQ,cAAe,EAAQ,IAAiB,CAC5D,IAAM,EAAQ,EAAO,GACrB,OAAO,IAAU,IAAA,GAAY,IAAI,EAAK,GAAK,OAAO,CAAK,CAC3D,CAAC,EAJmB,CAKxB,CAEA,SAAS,EACL,EACA,EACA,EACA,EACa,CACb,IAAM,EAAS,EAAQ,EAAO,GAAG,GACjC,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,GAAI,EAAU,CACV,IAAM,EAAgB,EAAQ,EAAS,GAAG,GAC1C,GAAI,IAAkB,IAAA,GAAW,OAAO,CAC5C,CACA,OAAO,IACX,CA6BA,SAAgB,EAAW,EAAkC,CACzD,GAAM,CAAE,SAAQ,iBAAiB,KAAM,YAAa,EAEpD,SAAS,EAAE,EAAa,EAA8B,EAAoC,CACtF,IAAM,EAAW,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAAK,GAAS,QAE3E,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAM,CACvC,CAEA,SAAS,EACL,EACA,EACA,EACA,EACM,CAEN,IAAM,EACF,EAAO,EAAU,EAAQ,EAAgB,GAAG,IAFjC,IAAU,EAAI,OAAS,UAEwB,GAC1D,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAC5C,GAAS,QAEb,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAE,QAAO,GAAI,GAAU,CAAC,CAAG,CAAC,CAC7D,CAEA,SAAS,EAAa,EAAe,EAAyC,CAC1E,OAAO,EAAA,aAAa,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAK,CAClD,CAEA,SAAS,EAAW,EAAsB,EAA2C,CACjF,IAAM,EAAO,OAAO,GAAU,SAAW,IAAI,KAAK,CAAK,EAAI,EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,EAAU,GAClC,EAAA,eAAe,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAI,CACnD,CAEA,MAAO,CACH,SACA,iBACA,IACA,SACA,eACA,aACA,WAAa,GACT,EAAW,CACP,OAAQ,EACR,eAAgB,GAAkB,IAAA,GAClC,UACJ,CAAC,CACT,CACJ"}
|
package/dist/i18n/create-i18n.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { dateTimeFormat as e, numberFormat as t } from "../utils/intl-cache.js";
|
|
1
2
|
//#region src/i18n/create-i18n.ts
|
|
2
|
-
function
|
|
3
|
+
function n(e, t) {
|
|
3
4
|
return t ? e.replace(/\{(\w+)\}/g, (e, n) => {
|
|
4
5
|
let r = t[n];
|
|
5
6
|
return r === void 0 ? `{${n}}` : String(r);
|
|
6
7
|
}) : e;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function r(e, t, n, r) {
|
|
9
10
|
let i = e[t]?.[r];
|
|
10
11
|
if (i !== void 0) return i;
|
|
11
12
|
if (n) {
|
|
@@ -14,41 +15,41 @@ function t(e, t, n, r) {
|
|
|
14
15
|
}
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
let { locale:
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
return
|
|
18
|
+
function i(a) {
|
|
19
|
+
let { locale: o, fallbackLocale: s = null, messages: c } = a;
|
|
20
|
+
function l(e, t, i) {
|
|
21
|
+
let a = r(c, o, s, e) ?? i?.default;
|
|
22
|
+
return a === void 0 ? e : n(a, t);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
let l =
|
|
25
|
-
return l === void 0 ?
|
|
26
|
-
count:
|
|
27
|
-
...
|
|
24
|
+
function u(e, t, i, a) {
|
|
25
|
+
let l = r(c, o, s, `${e}${t === 1 ? "_one" : "_other"}`) ?? r(c, o, s, e) ?? a?.default;
|
|
26
|
+
return l === void 0 ? e : n(l, {
|
|
27
|
+
count: t,
|
|
28
|
+
...i ?? {}
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
31
|
+
function d(e, n) {
|
|
32
|
+
return t(o, n).format(e);
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
return Number.isNaN(
|
|
34
|
+
function f(t, n) {
|
|
35
|
+
let r = typeof t == "string" ? new Date(t) : t;
|
|
36
|
+
return Number.isNaN(r.getTime()) ? "" : e(o, n).format(r);
|
|
36
37
|
}
|
|
37
38
|
return {
|
|
38
|
-
locale:
|
|
39
|
-
fallbackLocale:
|
|
40
|
-
t:
|
|
41
|
-
plural:
|
|
42
|
-
formatNumber:
|
|
43
|
-
formatDate:
|
|
44
|
-
withLocale: (e) =>
|
|
39
|
+
locale: o,
|
|
40
|
+
fallbackLocale: s,
|
|
41
|
+
t: l,
|
|
42
|
+
plural: u,
|
|
43
|
+
formatNumber: d,
|
|
44
|
+
formatDate: f,
|
|
45
|
+
withLocale: (e) => i({
|
|
45
46
|
locale: e,
|
|
46
|
-
fallbackLocale:
|
|
47
|
-
messages:
|
|
47
|
+
fallbackLocale: s ?? void 0,
|
|
48
|
+
messages: c
|
|
48
49
|
})
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
//#endregion
|
|
52
|
-
export {
|
|
53
|
+
export { i as createI18n };
|
|
53
54
|
|
|
54
55
|
//# sourceMappingURL=create-i18n.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-i18n.js","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"create-i18n.js","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["import { dateTimeFormat, numberFormat } from \"@/utils/intl-cache\";\nexport type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return numberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return dateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":";;AA6DA,SAAS,EAAY,GAAkB,GAAsC;CAEzE,OADK,IACE,EAAS,QAAQ,eAAe,GAAQ,MAAiB;EAC5D,IAAM,IAAQ,EAAO;EACrB,OAAO,MAAU,KAAA,IAAY,IAAI,EAAK,KAAK,OAAO,CAAK;CAC3D,CAAC,IAJmB;AAKxB;AAEA,SAAS,EACL,GACA,GACA,GACA,GACa;CACb,IAAM,IAAS,EAAQ,EAAO,GAAG;CACjC,IAAI,MAAW,KAAA,GAAW,OAAO;CACjC,IAAI,GAAU;EACV,IAAM,IAAgB,EAAQ,EAAS,GAAG;EAC1C,IAAI,MAAkB,KAAA,GAAW,OAAO;CAC5C;CACA,OAAO;AACX;AA6BA,SAAgB,EAAW,GAAkC;CACzD,IAAM,EAAE,WAAQ,oBAAiB,MAAM,gBAAa;CAEpD,SAAS,EAAE,GAAa,GAA8B,GAAoC;EACtF,IAAM,IAAW,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAAK,GAAS;EAE3E,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU,CAAM;CACvC;CAEA,SAAS,EACL,GACA,GACA,GACA,GACM;EAEN,IAAM,IACF,EAAO,GAAU,GAAQ,GAAgB,GAAG,IAFjC,MAAU,IAAI,SAAS,UAEwB,KAC1D,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAC5C,GAAS;EAEb,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU;GAAE;GAAO,GAAI,KAAU,CAAC;EAAG,CAAC;CAC7D;CAEA,SAAS,EAAa,GAAe,GAAyC;EAC1E,OAAO,EAAa,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAK;CAClD;CAEA,SAAS,EAAW,GAAsB,GAA2C;EACjF,IAAM,IAAO,OAAO,KAAU,WAAW,IAAI,KAAK,CAAK,IAAI;EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAU,KAClC,EAAe,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAI;CACnD;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,MACT,EAAW;GACP,QAAQ;GACR,gBAAgB,KAAkB,KAAA;GAClC;EACJ,CAAC;CACT;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants.cjs"),t=require("./retry-policy.cjs");let
|
|
1
|
+
const e=require("./constants.cjs"),t=require("./retry-policy.cjs"),n=require("./foreign-client-warning.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("@tanstack/react-query");function o({children:o,client:s,defaultOptions:c}){n.warnOnForeignClient(s);let[l]=(0,r.useState)(()=>s??new a.QueryClient({defaultOptions:{queries:{staleTime:e.STALE_TIME.DEFAULT,gcTime:e.CACHE_TIME.DEFAULT,retry:t.shouldRetryQuery,refetchOnWindowFocus:!1,...c?.queries??{}},mutations:{retry:0,...c?.mutations??{}}}}));return(0,i.jsx)(a.QueryClientProvider,{client:l,children:o})}exports.QueryProvider=o;
|
|
2
2
|
//# sourceMappingURL=QueryProvider.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\nimport { warnOnForeignClient } from \"./foreign-client-warning\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n warnOnForeignClient(client);\n\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"sMAyBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,EAAA,oBAAoB,CAAM,EAE1B,GAAM,CAAC,IAAA,EAAkB,EAAA,SAAA,KAEjB,GACA,IAAI,EAAA,YAAY,CACZ,eAAgB,CACZ,QAAS,CACL,UAAW,EAAA,WAAW,QACtB,OAAQ,EAAA,WAAW,QACnB,MAAO,EAAA,iBACP,qBAAsB,GACtB,GAAI,GAAgB,SAAW,CAAC,CACpC,EACA,UAAW,CACP,MAAO,EACP,GAAI,GAAgB,WAAa,CAAC,CACtC,CACJ,CACJ,CAAC,CACT,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,OAAQ,EAAiB,UAA8B,CAAA,CACvF"}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { CACHE_TIME as e, STALE_TIME as t } from "./constants.js";
|
|
2
2
|
import { shouldRetryQuery as n } from "./retry-policy.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { warnOnForeignClient as r } from "./foreign-client-warning.js";
|
|
4
|
+
import { useState as i } from "react";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
+
import { QueryClient as o, QueryClientProvider as s } from "@tanstack/react-query";
|
|
6
7
|
//#region src/query/QueryProvider.tsx
|
|
7
|
-
function
|
|
8
|
-
|
|
8
|
+
function c({ children: c, client: l, defaultOptions: u }) {
|
|
9
|
+
r(l);
|
|
10
|
+
let [d] = i(() => l ?? new o({ defaultOptions: {
|
|
9
11
|
queries: {
|
|
10
12
|
staleTime: t.DEFAULT,
|
|
11
13
|
gcTime: e.DEFAULT,
|
|
12
14
|
retry: n,
|
|
13
15
|
refetchOnWindowFocus: !1,
|
|
14
|
-
...
|
|
16
|
+
...u?.queries ?? {}
|
|
15
17
|
},
|
|
16
18
|
mutations: {
|
|
17
19
|
retry: 0,
|
|
18
|
-
...
|
|
20
|
+
...u?.mutations ?? {}
|
|
19
21
|
}
|
|
20
22
|
} }));
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
client:
|
|
23
|
-
children:
|
|
23
|
+
return /* @__PURE__ */ a(s, {
|
|
24
|
+
client: d,
|
|
25
|
+
children: c
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
//#endregion
|
|
27
|
-
export {
|
|
29
|
+
export { c as QueryProvider };
|
|
28
30
|
|
|
29
31
|
//# sourceMappingURL=QueryProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\nimport { warnOnForeignClient } from \"./foreign-client-warning\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n warnOnForeignClient(client);\n\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,EAAc,EAAE,aAAU,WAAQ,qBAAsC;CACpF,EAAoB,CAAM;CAE1B,IAAM,CAAC,KAAkB,QAEjB,KACA,IAAI,EAAY,EACZ,gBAAgB;EACZ,SAAS;GACL,WAAW,EAAW;GACtB,QAAQ,EAAW;GACnB,OAAO;GACP,sBAAsB;GACtB,GAAI,GAAgB,WAAW,CAAC;EACpC;EACA,WAAW;GACP,OAAO;GACP,GAAI,GAAgB,aAAa,CAAC;EACtC;CACJ,EACJ,CAAC,CACT;CAEA,OAAO,kBAAC,GAAD;EAAqB,QAAQ;EAAiB;CAA8B,CAAA;AACvF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../utils/dev-mode.cjs"),t=require("../utils/duplicate-instance.cjs");let n=require("@tanstack/react-query");var r=!1;function i(i){r||i===void 0||!e.isDevBuild()||i instanceof n.QueryClient||typeof i.getQueryCache==`function`&&typeof i.mount==`function`&&(r=!0,console.warn(`[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient built by a different copy of @tanstack/react-query. The SDK publishes it on its own copy's context, so the app's \`useQuery\` calls will throw "No QueryClient set" even though this provider is mounted. `+t.DUPLICATE_COPY_REMEDY))}exports.warnOnForeignClient=i;
|
|
2
|
+
//# sourceMappingURL=foreign-client-warning.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreign-client-warning.cjs","names":[],"sources":["../../src/query/foreign-client-warning.ts"],"sourcesContent":["/**\n * Internal, in its own file for the reason the AppBar warning is: a module that\n * exports a component may export nothing else without breaking Fast Refresh\n * (`react-refresh/only-export-components`), and the warn-once latch needs a\n * reset for tests to assert the warning more than once.\n */\nimport { QueryClient } from \"@tanstack/react-query\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\nimport { DUPLICATE_COPY_REMEDY } from \"../utils/duplicate-instance\";\n\n/** Set once the warning has printed, so a re-render does not bury the console. */\nlet warnedForeignClient = false;\n\n/**\n * Reset the warn-once latch. Test-only: the latch is module state, so a suite\n * asserting the warning more than once would otherwise see it only the first time.\n */\nexport function resetForeignClientWarning(): void {\n warnedForeignClient = false;\n}\n\n/**\n * Warn when the `client` handed in was built by a different copy of\n * `@tanstack/react-query`.\n *\n * This prop is the one place the app's copy and the SDK's copy touch: the app\n * constructs a `QueryClient` and passes it in, and `QueryClientProvider` —\n * resolved from the SDK's copy — publishes it on *that* copy's context. Every\n * `useQuery` in the app then reads the app copy's context, finds nothing, and\n * throws `No QueryClient set, use QueryClientProvider to set one` while a\n * provider is plainly mounted three lines up. Nothing in that message points at\n * the duplicate, which is why it costs an afternoon.\n *\n * `instanceof` is the discriminator, and it is exactly the right one: two copies\n * define two distinct `QueryClient` classes, so a client from the other copy\n * duck-types perfectly and fails the identity check. The duck-type guard runs\n * first so the warning fires only on the shape that is actually a client —\n * without it, every hand-rolled test double would trip it.\n *\n * @param client - The client the caller passed, if any.\n */\nexport function warnOnForeignClient(client: QueryClient | undefined): void {\n if (warnedForeignClient || client === undefined || !isDevBuild()) return;\n if (client instanceof QueryClient) return;\n const looksLikeClient =\n typeof (client as Partial<QueryClient>).getQueryCache === \"function\" &&\n typeof (client as Partial<QueryClient>).mount === \"function\";\n if (!looksLikeClient) return;\n warnedForeignClient = true;\n console.warn(\n \"[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient \" +\n \"built by a different copy of @tanstack/react-query. The SDK publishes it on \" +\n \"its own copy's context, so the app's `useQuery` calls will throw \" +\n '\"No QueryClient set\" even though this provider is mounted. ' +\n DUPLICATE_COPY_REMEDY,\n );\n}\n"],"mappings":"6HAYA,IAAI,EAAsB,GA8B1B,SAAgB,EAAoB,EAAuC,CACnE,GAAuB,IAAW,IAAA,IAAa,CAAC,EAAA,WAAW,GAC3D,aAAkB,EAAA,aAElB,OAAQ,EAAgC,eAAkB,YAC1D,OAAQ,EAAgC,OAAU,aAEtD,EAAsB,GACtB,QAAQ,KACJ,uRAII,EAAA,qBACR,EACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isDevBuild as e } from "../utils/dev-mode.js";
|
|
2
|
+
import { DUPLICATE_COPY_REMEDY as t } from "../utils/duplicate-instance.js";
|
|
3
|
+
import { QueryClient as n } from "@tanstack/react-query";
|
|
4
|
+
//#region src/query/foreign-client-warning.ts
|
|
5
|
+
var r = !1;
|
|
6
|
+
function i(i) {
|
|
7
|
+
r || i === void 0 || !e() || i instanceof n || typeof i.getQueryCache == "function" && typeof i.mount == "function" && (r = !0, console.warn("[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient built by a different copy of @tanstack/react-query. The SDK publishes it on its own copy's context, so the app's `useQuery` calls will throw \"No QueryClient set\" even though this provider is mounted. " + t));
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { i as warnOnForeignClient };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=foreign-client-warning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreign-client-warning.js","names":[],"sources":["../../src/query/foreign-client-warning.ts"],"sourcesContent":["/**\n * Internal, in its own file for the reason the AppBar warning is: a module that\n * exports a component may export nothing else without breaking Fast Refresh\n * (`react-refresh/only-export-components`), and the warn-once latch needs a\n * reset for tests to assert the warning more than once.\n */\nimport { QueryClient } from \"@tanstack/react-query\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\nimport { DUPLICATE_COPY_REMEDY } from \"../utils/duplicate-instance\";\n\n/** Set once the warning has printed, so a re-render does not bury the console. */\nlet warnedForeignClient = false;\n\n/**\n * Reset the warn-once latch. Test-only: the latch is module state, so a suite\n * asserting the warning more than once would otherwise see it only the first time.\n */\nexport function resetForeignClientWarning(): void {\n warnedForeignClient = false;\n}\n\n/**\n * Warn when the `client` handed in was built by a different copy of\n * `@tanstack/react-query`.\n *\n * This prop is the one place the app's copy and the SDK's copy touch: the app\n * constructs a `QueryClient` and passes it in, and `QueryClientProvider` —\n * resolved from the SDK's copy — publishes it on *that* copy's context. Every\n * `useQuery` in the app then reads the app copy's context, finds nothing, and\n * throws `No QueryClient set, use QueryClientProvider to set one` while a\n * provider is plainly mounted three lines up. Nothing in that message points at\n * the duplicate, which is why it costs an afternoon.\n *\n * `instanceof` is the discriminator, and it is exactly the right one: two copies\n * define two distinct `QueryClient` classes, so a client from the other copy\n * duck-types perfectly and fails the identity check. The duck-type guard runs\n * first so the warning fires only on the shape that is actually a client —\n * without it, every hand-rolled test double would trip it.\n *\n * @param client - The client the caller passed, if any.\n */\nexport function warnOnForeignClient(client: QueryClient | undefined): void {\n if (warnedForeignClient || client === undefined || !isDevBuild()) return;\n if (client instanceof QueryClient) return;\n const looksLikeClient =\n typeof (client as Partial<QueryClient>).getQueryCache === \"function\" &&\n typeof (client as Partial<QueryClient>).mount === \"function\";\n if (!looksLikeClient) return;\n warnedForeignClient = true;\n console.warn(\n \"[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient \" +\n \"built by a different copy of @tanstack/react-query. The SDK publishes it on \" +\n \"its own copy's context, so the app's `useQuery` calls will throw \" +\n '\"No QueryClient set\" even though this provider is mounted. ' +\n DUPLICATE_COPY_REMEDY,\n );\n}\n"],"mappings":";;;;AAYA,IAAI,IAAsB;AA8B1B,SAAgB,EAAoB,GAAuC;CACnE,KAAuB,MAAW,KAAA,KAAa,CAAC,EAAW,KAC3D,aAAkB,KAElB,OAAQ,EAAgC,iBAAkB,cAC1D,OAAQ,EAAgC,SAAU,eAEtD,IAAsB,IACtB,QAAQ,KACJ,yRAII,CACR;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../auth/lazy-with-retry.cjs"),t=require("./RouteGuard.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("react-router");function a(e){return e}var o=new WeakMap;function s(t){let n=o.get(t);return n||(n=e.lazyWithRetry(t.lazy),o.set(t,n)),n}function c({guard:e,
|
|
1
|
+
const e=require("../auth/lazy-with-retry.cjs"),t=require("./RouteGuard.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("react-router");function a(e){return e}var o=new WeakMap;function s(t){let n=o.get(t);return n||(n=e.lazyWithRetry(t.lazy),o.set(t,n)),n}function c({guard:e,guardFallback:n,redirectTo:i,children:a}){let o=typeof e==`function`?e():e;return(0,r.jsx)(t.RouteGuard,{when:o,fallback:n,redirectTo:i,children:a})}var l=new WeakMap,u=0;function d(e){let t=l.get(e);return t||(t=`guard-${++u}`,l.set(e,t)),t}function f(e,t){return e.map((e,n)=>{let a=e.element;if(e.lazy){let t=s(e);a=(0,r.jsx)(t,{})}return e.guard!==void 0&&(a=(0,r.jsx)(c,{guard:e.guard,guardFallback:e.guardFallback??t,redirectTo:e.redirectTo,children:a},d(e))),e.index?(0,r.jsx)(i.Route,{index:!0,element:a},`index-${n}`):(0,r.jsx)(i.Route,{path:e.path,element:a,caseSensitive:e.caseSensitive,children:e.children?f(e.children,t):null},e.path??`route-${n}`)})}var p={browser:i.BrowserRouter,hash:i.HashRouter,memory:i.MemoryRouter};function m({routes:e,router:t=`browser`,basename:a,initialEntries:o,fallback:s=null}){let c=(0,n.useMemo)(()=>f(e,s),[e,s]),l=p[t];return(0,r.jsx)(l,{...t===`memory`?{basename:a,initialEntries:o}:{basename:a},children:(0,r.jsx)(n.Suspense,{fallback:s,children:(0,r.jsx)(i.Routes,{children:c})})})}exports.AppRouter=m,exports.defineRoutes=a;
|
|
2
2
|
//# sourceMappingURL=AppRouter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouter.cjs","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\nfunction GuardedElement({\n guard,\n redirectTo,\n children,\n}: {\n guard: boolean | (() =>
|
|
1
|
+
{"version":3,"file":"AppRouter.cjs","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouteGuardResult, RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\n/**\n * Runs one route's `guard` and renders the outcome.\n *\n * The guard is called during this component's render, which is what lets it\n * call hooks — `useCan` returning `{ allowed, isLoading }` maps straight onto\n * the three outcomes. See {@link guardKey} for why each guarded route gets its\n * own instance.\n */\nfunction GuardedElement({\n guard,\n guardFallback,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => RouteGuardResult);\n guardFallback?: ReactNode;\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} fallback={guardFallback} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nconst guardKeys = new WeakMap<TempestRouteObject, string>();\nlet guardKeySeq = 0;\n\n/**\n * A key unique to each route object, so React remounts `GuardedElement` when\n * the matched route changes instead of reusing the instance.\n *\n * Load-bearing once guards may call hooks. React Router renders the matched\n * route's element at the same position in the tree, so without a differing key\n * React reconciles two different routes onto the same `GuardedElement`\n * instance and the previous route's guard state survives into the next one's —\n * a guard reading `useState(\"from-a\")` still reads `\"from-a\"` after navigating\n * to a route whose guard initialises it to `\"from-b\"`. Path is not enough on\n * its own: two routes in different branches can share one.\n */\nfunction guardKey(route: TempestRouteObject): string {\n let key = guardKeys.get(route);\n if (!key) {\n key = `guard-${++guardKeySeq}`;\n guardKeys.set(route, key);\n }\n return key;\n}\n\nfunction toRouteElements(routes: TempestRouteObject[], fallback: ReactNode): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement\n key={guardKey(route)}\n guard={route.guard}\n guardFallback={route.guardFallback ?? fallback}\n redirectTo={route.redirectTo}\n >\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children, fallback) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /**\n * Suspense fallback shown while a `lazy` route chunk loads, and the default\n * for a route whose `guard` answers `\"pending\"` — one spinner covers both\n * kinds of \"not ready yet\". A route overrides it with its own\n * `guardFallback`.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes, fallback), [routes, fallback]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":"6JAoBA,SAAgB,EAAa,EAAoD,CAC7E,OAAO,CACX,CAEA,IAAM,EAAY,IAAI,QAEtB,SAAS,EAAY,EAAmD,CACpE,IAAI,EAAO,EAAU,IAAI,CAAK,EAK9B,OAJK,IACD,EAAO,EAAA,cAAc,EAAM,IAAK,EAChC,EAAU,IAAI,EAAO,CAAI,GAEtB,CACX,CAUA,SAAS,EAAe,CACpB,QACA,gBACA,aACA,YAMD,CACC,IAAM,EAAU,OAAO,GAAU,WAAa,EAAM,EAAI,EACxD,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,WAAD,CAAY,KAAM,EAAS,SAAU,EAA2B,aAC3D,UACO,CAAA,CAEpB,CAEA,IAAM,EAAY,IAAI,QAClB,EAAc,EAclB,SAAS,EAAS,EAAmC,CACjD,IAAI,EAAM,EAAU,IAAI,CAAK,EAK7B,OAJK,IACD,EAAM,SAAS,EAAE,IACjB,EAAU,IAAI,EAAO,CAAG,GAErB,CACX,CAEA,SAAS,EAAgB,EAA8B,EAAgC,CACnF,OAAO,EAAO,KAAK,EAAO,IAAM,CAC5B,IAAI,EAAqB,EAAM,QAC/B,GAAI,EAAM,KAAM,CACZ,IAAM,EAAgB,EAAY,CAAK,EACvC,GAAU,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,CAAA,CAC9B,CAkBA,OAjBI,EAAM,QAAU,IAAA,KAChB,GACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAEI,MAAO,EAAM,MACb,cAAe,EAAM,eAAiB,EACtC,WAAY,EAAM,WAEjB,SAAA,CACW,EANP,EAAS,CAAK,CAMP,GAIpB,EAAM,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAA0B,MAAA,GAAe,SAAU,EAAvC,SAAS,GAA8B,GAI1D,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAEI,KAAM,EAAM,KACH,UACT,cAAe,EAAM,cAEpB,SAAA,EAAM,SAAW,EAAgB,EAAM,SAAU,CAAQ,EAAI,IAC3D,EANE,EAAM,MAAQ,SAAS,GAMzB,CAEf,CAAC,CACL,CAEA,IAAM,EAAoD,CACtD,QAAS,EAAA,cACT,KAAM,EAAA,WACN,OAAQ,EAAA,YACZ,EA8BA,SAAgB,EAAU,CACtB,SACA,SAAS,UACT,WACA,iBACA,WAAW,MACI,CACf,IAAM,GAAA,EAAO,EAAA,QAAA,KAAc,EAAgB,EAAQ,CAAQ,EAAG,CAAC,EAAQ,CAAQ,CAAC,EAC1E,EAAS,EAAQ,GAGvB,OACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAAQ,GAHQ,IAAW,SAAW,CAAE,WAAU,gBAAe,EAAI,CAAE,UAAS,EAI5E,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAoB,WAChB,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAA,SAAS,CAAa,CAAA,CAChB,CAAA,CACN,CAAA,CAEhB"}
|
package/dist/router/AppRouter.js
CHANGED
|
@@ -12,43 +12,50 @@ function f(t) {
|
|
|
12
12
|
let n = d.get(t);
|
|
13
13
|
return n || (n = e(t.lazy), d.set(t, n)), n;
|
|
14
14
|
}
|
|
15
|
-
function p({ guard: e,
|
|
16
|
-
let
|
|
15
|
+
function p({ guard: e, guardFallback: n, redirectTo: r, children: a }) {
|
|
16
|
+
let o = typeof e == "function" ? e() : e;
|
|
17
17
|
return /* @__PURE__ */ i(t, {
|
|
18
|
-
when:
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
when: o,
|
|
19
|
+
fallback: n,
|
|
20
|
+
redirectTo: r,
|
|
21
|
+
children: a
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var m = /* @__PURE__ */ new WeakMap(), h = 0;
|
|
25
|
+
function g(e) {
|
|
26
|
+
let t = m.get(e);
|
|
27
|
+
return t || (t = `guard-${++h}`, m.set(e, t)), t;
|
|
28
|
+
}
|
|
29
|
+
function _(e, t) {
|
|
30
|
+
return e.map((e, n) => {
|
|
31
|
+
let r = e.element;
|
|
26
32
|
if (e.lazy) {
|
|
27
33
|
let t = f(e);
|
|
28
|
-
|
|
34
|
+
r = /* @__PURE__ */ i(t, {});
|
|
29
35
|
}
|
|
30
|
-
return e.guard !== void 0 && (
|
|
36
|
+
return e.guard !== void 0 && (r = /* @__PURE__ */ i(p, {
|
|
31
37
|
guard: e.guard,
|
|
38
|
+
guardFallback: e.guardFallback ?? t,
|
|
32
39
|
redirectTo: e.redirectTo,
|
|
33
|
-
children:
|
|
34
|
-
})), e.index ? /* @__PURE__ */ i(c, {
|
|
40
|
+
children: r
|
|
41
|
+
}, g(e))), e.index ? /* @__PURE__ */ i(c, {
|
|
35
42
|
index: !0,
|
|
36
|
-
element:
|
|
37
|
-
}, `index-${
|
|
43
|
+
element: r
|
|
44
|
+
}, `index-${n}`) : /* @__PURE__ */ i(c, {
|
|
38
45
|
path: e.path,
|
|
39
|
-
element:
|
|
46
|
+
element: r,
|
|
40
47
|
caseSensitive: e.caseSensitive,
|
|
41
|
-
children: e.children ?
|
|
42
|
-
}, e.path ?? `route-${
|
|
48
|
+
children: e.children ? _(e.children, t) : null
|
|
49
|
+
}, e.path ?? `route-${n}`);
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
|
-
var
|
|
52
|
+
var v = {
|
|
46
53
|
browser: a,
|
|
47
54
|
hash: o,
|
|
48
55
|
memory: s
|
|
49
56
|
};
|
|
50
|
-
function
|
|
51
|
-
let c = r(() =>
|
|
57
|
+
function y({ routes: e, router: t = "browser", basename: a, initialEntries: o, fallback: s = null }) {
|
|
58
|
+
let c = r(() => _(e, s), [e, s]), u = v[t];
|
|
52
59
|
return /* @__PURE__ */ i(u, {
|
|
53
60
|
...t === "memory" ? {
|
|
54
61
|
basename: a,
|
|
@@ -61,6 +68,6 @@ function g({ routes: e, router: t = "browser", basename: a, initialEntries: o, f
|
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
70
|
//#endregion
|
|
64
|
-
export {
|
|
71
|
+
export { y as AppRouter, u as defineRoutes };
|
|
65
72
|
|
|
66
73
|
//# sourceMappingURL=AppRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouter.js","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\nfunction GuardedElement({\n guard,\n redirectTo,\n children,\n}: {\n guard: boolean | (() =>
|
|
1
|
+
{"version":3,"file":"AppRouter.js","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouteGuardResult, RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\n/**\n * Runs one route's `guard` and renders the outcome.\n *\n * The guard is called during this component's render, which is what lets it\n * call hooks — `useCan` returning `{ allowed, isLoading }` maps straight onto\n * the three outcomes. See {@link guardKey} for why each guarded route gets its\n * own instance.\n */\nfunction GuardedElement({\n guard,\n guardFallback,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => RouteGuardResult);\n guardFallback?: ReactNode;\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} fallback={guardFallback} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nconst guardKeys = new WeakMap<TempestRouteObject, string>();\nlet guardKeySeq = 0;\n\n/**\n * A key unique to each route object, so React remounts `GuardedElement` when\n * the matched route changes instead of reusing the instance.\n *\n * Load-bearing once guards may call hooks. React Router renders the matched\n * route's element at the same position in the tree, so without a differing key\n * React reconciles two different routes onto the same `GuardedElement`\n * instance and the previous route's guard state survives into the next one's —\n * a guard reading `useState(\"from-a\")` still reads `\"from-a\"` after navigating\n * to a route whose guard initialises it to `\"from-b\"`. Path is not enough on\n * its own: two routes in different branches can share one.\n */\nfunction guardKey(route: TempestRouteObject): string {\n let key = guardKeys.get(route);\n if (!key) {\n key = `guard-${++guardKeySeq}`;\n guardKeys.set(route, key);\n }\n return key;\n}\n\nfunction toRouteElements(routes: TempestRouteObject[], fallback: ReactNode): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement\n key={guardKey(route)}\n guard={route.guard}\n guardFallback={route.guardFallback ?? fallback}\n redirectTo={route.redirectTo}\n >\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children, fallback) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /**\n * Suspense fallback shown while a `lazy` route chunk loads, and the default\n * for a route whose `guard` answers `\"pending\"` — one spinner covers both\n * kinds of \"not ready yet\". A route overrides it with its own\n * `guardFallback`.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes, fallback), [routes, fallback]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,EAAa,GAAoD;CAC7E,OAAO;AACX;AAEA,IAAM,oBAAY,IAAI,QAAoD;AAE1E,SAAS,EAAY,GAAmD;CACpE,IAAI,IAAO,EAAU,IAAI,CAAK;CAK9B,OAJK,MACD,IAAO,EAAc,EAAM,IAAK,GAChC,EAAU,IAAI,GAAO,CAAI,IAEtB;AACX;AAUA,SAAS,EAAe,EACpB,UACA,kBACA,eACA,eAMD;CACC,IAAM,IAAU,OAAO,KAAU,aAAa,EAAM,IAAI;CACxD,OACI,kBAAC,GAAD;EAAY,MAAM;EAAS,UAAU;EAA2B;EAC3D;CACO,CAAA;AAEpB;AAEA,IAAM,oBAAY,IAAI,QAAoC,GACtD,IAAc;AAclB,SAAS,EAAS,GAAmC;CACjD,IAAI,IAAM,EAAU,IAAI,CAAK;CAK7B,OAJK,MACD,IAAM,SAAS,EAAE,KACjB,EAAU,IAAI,GAAO,CAAG,IAErB;AACX;AAEA,SAAS,EAAgB,GAA8B,GAAgC;CACnF,OAAO,EAAO,KAAK,GAAO,MAAM;EAC5B,IAAI,IAAqB,EAAM;EAC/B,IAAI,EAAM,MAAM;GACZ,IAAM,IAAgB,EAAY,CAAK;GACvC,IAAU,kBAAC,GAAD,CAAgB,CAAA;EAC9B;EAkBA,OAjBI,EAAM,UAAU,KAAA,MAChB,IACI,kBAAC,GAAD;GAEI,OAAO,EAAM;GACb,eAAe,EAAM,iBAAiB;GACtC,YAAY,EAAM;GAEjB,UAAA;EACW,GANP,EAAS,CAAK,CAMP,IAIpB,EAAM,QACC,kBAAC,GAAD;GAA0B,OAAA;GAAe;EAAU,GAAvC,SAAS,GAA8B,IAI1D,kBAAC,GAAD;GAEI,MAAM,EAAM;GACH;GACT,eAAe,EAAM;GAEpB,UAAA,EAAM,WAAW,EAAgB,EAAM,UAAU,CAAQ,IAAI;EAC3D,GANE,EAAM,QAAQ,SAAS,GAMzB;CAEf,CAAC;AACL;AAEA,IAAM,IAAoD;CACtD,SAAS;CACT,MAAM;CACN,QAAQ;AACZ;AA8BA,SAAgB,EAAU,EACtB,WACA,YAAS,WACT,aACA,mBACA,cAAW,QACI;CACf,IAAM,IAAO,QAAc,EAAgB,GAAQ,CAAQ,GAAG,CAAC,GAAQ,CAAQ,CAAC,GAC1E,IAAS,EAAQ;CAGvB,OACI,kBAAC,GAAD;EAAQ,GAHQ,MAAW,WAAW;GAAE;GAAU;EAAe,IAAI,EAAE,YAAS;EAI5E,UAAA,kBAAC,GAAD;GAAoB;GAChB,UAAA,kBAAC,GAAD,EAAA,UAAS,EAAa,CAAA;EAChB,CAAA;CACN,CAAA;AAEhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react/jsx-runtime"),t=require("react-router");function n({when:n,redirectTo:
|
|
1
|
+
let e=require("react/jsx-runtime"),t=require("react-router");function n({when:n,fallback:r=null,redirectTo:i=`/`,replace:a=!0,children:o}){return n===`pending`?(0,e.jsx)(e.Fragment,{children:r}):(0,e.jsx)(e.Fragment,{children:n?o:(0,e.jsx)(t.Navigate,{to:i,replace:a})})}exports.RouteGuard=n;
|
|
2
2
|
//# sourceMappingURL=RouteGuard.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteGuard.cjs","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed
|
|
1
|
+
{"version":3,"file":"RouteGuard.cjs","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\nimport type { RouteGuardResult } from \"./types\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed — typically\n * `useAuthStore((s) => s.isAuthenticated)`.\n *\n * `\"pending\"` is the third answer, for a permission that has not resolved\n * yet: it holds the decision and renders {@link fallback} instead of\n * choosing between two wrong moves — redirecting someone who does have\n * access, or showing the screen to someone who does not.\n */\n when: RouteGuardResult;\n /**\n * Rendered while `when` is `\"pending\"`. Defaults to nothing, which is a\n * blank screen — pass the same spinner the rest of the app uses.\n */\n fallback?: ReactNode;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is `true`, redirects when it is `false`, and holds on\n * `\"pending\"`. Pairs naturally with `createAuthStore` for protected areas, and\n * with `useCan` for permissions that resolve over the network.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n *\n * @example\n * const { allowed, isLoading } = useCan({ action: \"read\", resource: \"finance\" });\n *\n * <RouteGuard when={isLoading ? \"pending\" : allowed} fallback={<Spinner />}>\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({\n when,\n fallback = null,\n redirectTo = \"/\",\n replace = true,\n children,\n}: RouteGuardProps) {\n if (when === \"pending\") return <>{fallback}</>;\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":"6DA8CA,SAAgB,EAAW,CACvB,OACA,WAAW,KACX,aAAa,IACb,UAAU,GACV,YACgB,CAEhB,OADI,IAAS,WAAkB,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,CAAW,CAAA,GACtC,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,EAAO,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAU,GAAI,EAAqB,SAAU,CAAA,CAAI,CAAA,CACjF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fragment as e, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { Navigate as n } from "react-router";
|
|
3
3
|
//#region src/router/RouteGuard.tsx
|
|
4
|
-
function r({ when: r,
|
|
5
|
-
return /* @__PURE__ */ t(e, { children: r ?
|
|
6
|
-
to:
|
|
7
|
-
replace:
|
|
4
|
+
function r({ when: r, fallback: i = null, redirectTo: a = "/", replace: o = !0, children: s }) {
|
|
5
|
+
return r === "pending" ? /* @__PURE__ */ t(e, { children: i }) : /* @__PURE__ */ t(e, { children: r ? s : /* @__PURE__ */ t(n, {
|
|
6
|
+
to: a,
|
|
7
|
+
replace: o
|
|
8
8
|
}) });
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteGuard.js","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed
|
|
1
|
+
{"version":3,"file":"RouteGuard.js","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\nimport type { RouteGuardResult } from \"./types\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed — typically\n * `useAuthStore((s) => s.isAuthenticated)`.\n *\n * `\"pending\"` is the third answer, for a permission that has not resolved\n * yet: it holds the decision and renders {@link fallback} instead of\n * choosing between two wrong moves — redirecting someone who does have\n * access, or showing the screen to someone who does not.\n */\n when: RouteGuardResult;\n /**\n * Rendered while `when` is `\"pending\"`. Defaults to nothing, which is a\n * blank screen — pass the same spinner the rest of the app uses.\n */\n fallback?: ReactNode;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is `true`, redirects when it is `false`, and holds on\n * `\"pending\"`. Pairs naturally with `createAuthStore` for protected areas, and\n * with `useCan` for permissions that resolve over the network.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n *\n * @example\n * const { allowed, isLoading } = useCan({ action: \"read\", resource: \"finance\" });\n *\n * <RouteGuard when={isLoading ? \"pending\" : allowed} fallback={<Spinner />}>\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({\n when,\n fallback = null,\n redirectTo = \"/\",\n replace = true,\n children,\n}: RouteGuardProps) {\n if (when === \"pending\") return <>{fallback}</>;\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":";;;AA8CA,SAAgB,EAAW,EACvB,SACA,cAAW,MACX,gBAAa,KACb,aAAU,IACV,eACgB;CAEhB,OADI,MAAS,YAAkB,kBAAA,GAAA,EAAA,UAAG,EAAW,CAAA,IACtC,kBAAA,GAAA,EAAA,UAAG,IAAO,IAAW,kBAAC,GAAD;EAAU,IAAI;EAAqB;CAAU,CAAA,EAAI,CAAA;AACjF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../utils/json-frame.cjs");function t(t,n={}){let{withCredentials:r=!1,namedEvents:i=[],heartbeatEvents:a=[`ping`],maxRetries:o=10,initialBackoff:s=1e3,maxBackoff:c=3e4,parser:l,onOpen:u,onMessage:d,onError:f,onParseError:p,onStatusChange:m}=n,h=null,g=null,_=0,v=`idle`,y=!1;function b(e){v!==e&&(v=e,m?.(e))}function x(t,n){if(a.includes(t))return;let r=e.decodeFrame(typeof n.data==`string`?n.data:``,l,p,`createEventStream`);r.delivered&&d?.({event:t,data:r.data,id:n.lastEventId||void 0,raw:n})}function S(){if(y)return;if(_>=o){b(`error`);return}let e=Math.min(s*2**_,c);_+=1,g=setTimeout(C,e)}function C(){if(y)return;h&&h.close(),b(`connecting`);let e=new EventSource(t,{withCredentials:r});h=e,e.onopen=()=>{_=0,b(`open`),u?.()},e.onmessage=e=>x(`message`,e);for(let t of i)e.addEventListener(t,e=>x(t,e));for(let t of a)e.addEventListener(t,()=>{});e.onerror=t=>{f?.(t),e.close(),h=null,b(`closed`),S()}}function w(){y=!0,g&&=(clearTimeout(g),null),_=0,h&&=(h.close(),null),b(`closed`)}function T(){g&&=(clearTimeout(g),null),_=0,y=!1,C()}return C(),{close:w,reconnect:T,get status(){return v}}}exports.createEventStream=t;
|
|
2
2
|
//# sourceMappingURL=create-event-stream.cjs.map
|