tempest-react-sdk 0.38.3 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/access/access-control-context.cjs.map +1 -1
- package/dist/access/use-can.cjs.map +1 -1
- package/dist/app/AppProviders.cjs.map +1 -1
- package/dist/app/AppProviders.js.map +1 -1
- package/dist/audio/use-audio-recorder.cjs.map +1 -1
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-microphone.cjs.map +1 -1
- package/dist/auth/create-auth-store.cjs.map +1 -1
- package/dist/auth/lazy-with-retry.cjs.map +1 -1
- package/dist/auth/use-passkey.cjs.map +1 -1
- package/dist/br/BrazilMap.cjs +1 -1
- package/dist/br/BrazilMap.cjs.map +1 -1
- package/dist/br/BrazilMap.js +2 -2
- package/dist/br/BrazilMap.js.map +1 -1
- package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
- package/dist/br/BrazilStateCitySelect.js.map +1 -1
- package/dist/br/BrazilStateMap.cjs +1 -1
- package/dist/br/BrazilStateMap.cjs.map +1 -1
- package/dist/br/BrazilStateMap.js +2 -2
- package/dist/br/BrazilStateMap.js.map +1 -1
- package/dist/br/MapLegend.cjs.map +1 -1
- package/dist/br/MapLegend.js.map +1 -1
- package/dist/br/MapMarkers.cjs.map +1 -1
- package/dist/br/MapMarkers.js.map +1 -1
- package/dist/br/MunicipalitySearch.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.js.map +1 -1
- package/dist/br/PixQRCode.cjs.map +1 -1
- package/dist/br/PixQRCode.js.map +1 -1
- package/dist/br/use-map-hover.cjs.map +1 -1
- package/dist/br/use-map-zoom.cjs.map +1 -1
- package/dist/capture/media-recorder.cjs +1 -1
- package/dist/capture/media-recorder.js +2 -2
- package/dist/capture/use-barcode-scanner.cjs +1 -1
- package/dist/capture/use-barcode-scanner.cjs.map +1 -1
- package/dist/capture/use-barcode-scanner.js +2 -2
- package/dist/capture/use-barcode-scanner.js.map +1 -1
- package/dist/capture/use-screen-capture.cjs.map +1 -1
- package/dist/capture/use-speech-recognition.cjs.map +1 -1
- package/dist/capture/use-torch.cjs.map +1 -1
- package/dist/capture/use-video-recorder.cjs.map +1 -1
- package/dist/charts/AreaChart.cjs.map +1 -1
- package/dist/charts/AreaChart.js.map +1 -1
- package/dist/charts/BarChart.cjs.map +1 -1
- package/dist/charts/BarChart.js.map +1 -1
- package/dist/charts/LineChart.cjs.map +1 -1
- package/dist/charts/LineChart.js.map +1 -1
- package/dist/charts/PieChart.cjs.map +1 -1
- package/dist/charts/PieChart.js.map +1 -1
- package/dist/charts/RadarChart.cjs.map +1 -1
- package/dist/charts/RadarChart.js.map +1 -1
- package/dist/charts/use-chart-colors.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Alert/Alert.cjs.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppShell/AppShell.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/Badge/Badge.cjs.map +1 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Banner/Banner.cjs.map +1 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.js +38 -41
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Carousel/Carousel.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- package/dist/components/Chat/Chat.cjs.map +1 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/Chat/ChatComposer.cjs.map +1 -1
- package/dist/components/Chat/ChatComposer.js.map +1 -1
- package/dist/components/Chat/chat-groups.cjs +1 -1
- package/dist/components/Chat/chat-groups.cjs.map +1 -1
- package/dist/components/Chat/chat-groups.js +2 -2
- package/dist/components/Chat/chat-groups.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/ChipInput/ChipInput.cjs.map +1 -1
- package/dist/components/ChipInput/ChipInput.js.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Command/Command.cjs.map +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.cjs.map +1 -1
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DataList/DataList.cjs.map +1 -1
- package/dist/components/DataList/DataList.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs.map +1 -1
- package/dist/components/DataTable/EditableCell.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.cjs.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Divider/Divider.cjs.map +1 -1
- package/dist/components/Divider/Divider.js.map +1 -1
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/Dropzone/Dropzone.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.cjs.map +1 -1
- package/dist/components/ErrorState/ErrorState.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/FileUpload/FileUpload.cjs.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +1 -1
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.js.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.cjs.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.js.map +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/HoverCard/HoverCard.cjs.map +1 -1
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/Image/Image.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.js +1 -1
- package/dist/components/ImageCropper/ImageCropper.js.map +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/Kanban/Kanban.cjs.map +1 -1
- package/dist/components/Kanban/Kanban.js.map +1 -1
- package/dist/components/Label/Label.cjs.map +1 -1
- package/dist/components/Label/Label.js.map +1 -1
- package/dist/components/Lightbox/Lightbox.cjs.map +1 -1
- package/dist/components/Lightbox/Lightbox.js.map +1 -1
- package/dist/components/ListTile/ListTile.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.js.map +1 -1
- package/dist/components/Markdown/Markdown.cjs +1 -1
- package/dist/components/Markdown/Markdown.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.js +2 -2
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Masonry/Masonry.cjs.map +1 -1
- package/dist/components/Masonry/Masonry.js.map +1 -1
- package/dist/components/Menubar/Menubar.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.cjs.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.js.map +1 -1
- package/dist/components/Money/Money.cjs.map +1 -1
- package/dist/components/Money/Money.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NProgress/NProgress.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js.map +1 -1
- package/dist/components/NotificationCenter/use-notification-inbox.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.js.map +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/PinInput/PinInput.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.js.map +1 -1
- package/dist/components/Popover/Popover.cjs.map +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Portal/Portal.cjs.map +1 -1
- package/dist/components/Progress/Progress.cjs.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/QRCode/QRCode.cjs.map +1 -1
- package/dist/components/QRCode/QRCode.js.map +1 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/RatingStars/RatingStars.cjs.map +1 -1
- package/dist/components/RatingStars/RatingStars.js.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.cjs.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/Resizable/Resizable.cjs.map +1 -1
- package/dist/components/Resizable/Resizable.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -1
- package/dist/components/Sparkline/Sparkline.js.map +1 -1
- package/dist/components/Spinner/Spinner.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/Stat/Stat.cjs.map +1 -1
- package/dist/components/Stat/Stat.js.map +1 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/StepperInput/StepperInput.cjs.map +1 -1
- package/dist/components/StepperInput/StepperInput.js.map +1 -1
- package/dist/components/Switch/Switch.cjs.map +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tag/Tag.cjs.map +1 -1
- package/dist/components/Tag/Tag.js.map +1 -1
- package/dist/components/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.cjs.map +1 -1
- package/dist/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/components/Toggle/Toggle.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tour/Tour.cjs.map +1 -1
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/Transfer/Transfer.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.js.map +1 -1
- package/dist/components/TreeView/TreeView.cjs +1 -1
- package/dist/components/TreeView/TreeView.cjs.map +1 -1
- package/dist/components/TreeView/TreeView.js +1 -4
- package/dist/components/TreeView/TreeView.js.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.cjs.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.js.map +1 -1
- package/dist/data/data-provider-context.cjs.map +1 -1
- package/dist/data/use-resource.cjs.map +1 -1
- package/dist/editor/RichTextEditor.cjs.map +1 -1
- package/dist/editor/RichTextEditor.js.map +1 -1
- package/dist/error-boundary/use-error-handler.cjs.map +1 -1
- package/dist/feature-flags/FeatureFlagsProvider.cjs.map +1 -1
- package/dist/forms/FormField.cjs.map +1 -1
- package/dist/forms/masked-inputs.cjs.map +1 -1
- package/dist/forms/use-viacep.cjs.map +1 -1
- package/dist/forms/use-zod-form.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.js.map +1 -1
- package/dist/geo/leaflet-map.cjs.map +1 -1
- package/dist/geo/leaflet-map.js.map +1 -1
- package/dist/geo/use-position-tracker.cjs.map +1 -1
- package/dist/hooks/use-announce.cjs.map +1 -1
- package/dist/hooks/use-async.cjs.map +1 -1
- package/dist/hooks/use-before-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-breakpoint.cjs.map +1 -1
- package/dist/hooks/use-click-outside.cjs.map +1 -1
- package/dist/hooks/use-client-filter.cjs.map +1 -1
- package/dist/hooks/use-clipboard.cjs.map +1 -1
- package/dist/hooks/use-counter.cjs.map +1 -1
- package/dist/hooks/use-debounce.cjs.map +1 -1
- package/dist/hooks/use-deep-memo.cjs.map +1 -1
- package/dist/hooks/use-disclosure.cjs.map +1 -1
- package/dist/hooks/use-document-visibility.cjs.map +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-geolocation.cjs.map +1 -1
- package/dist/hooks/use-hover.cjs.map +1 -1
- package/dist/hooks/use-idle.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.cjs +1 -1
- package/dist/hooks/use-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.js +1 -1
- package/dist/hooks/use-install-prompt.js.map +1 -1
- package/dist/hooks/use-intersection-observer.cjs.map +1 -1
- package/dist/hooks/use-interval.cjs.map +1 -1
- package/dist/hooks/use-is-first-render.cjs.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.cjs +1 -1
- package/dist/hooks/use-keyboard-shortcut.cjs.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.js +1 -1
- package/dist/hooks/use-keyboard-shortcut.js.map +1 -1
- package/dist/hooks/use-list-state.cjs.map +1 -1
- package/dist/hooks/use-local-storage.cjs.map +1 -1
- package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
- package/dist/hooks/use-long-press.cjs.map +1 -1
- package/dist/hooks/use-map.cjs.map +1 -1
- package/dist/hooks/use-media-devices.cjs.map +1 -1
- package/dist/hooks/use-media-permission.cjs.map +1 -1
- package/dist/hooks/use-media-query.cjs.map +1 -1
- package/dist/hooks/use-object-url.cjs.map +1 -1
- package/dist/hooks/use-online.cjs.map +1 -1
- package/dist/hooks/use-pagination.cjs.map +1 -1
- package/dist/hooks/use-previous.cjs.map +1 -1
- package/dist/hooks/use-queue.cjs.map +1 -1
- package/dist/hooks/use-resize-observer.cjs.map +1 -1
- package/dist/hooks/use-scroll-overflow.cjs.map +1 -1
- package/dist/hooks/use-service-worker-update.cjs.map +1 -1
- package/dist/hooks/use-set.cjs.map +1 -1
- package/dist/hooks/use-sortable.cjs +1 -1
- package/dist/hooks/use-sortable.cjs.map +1 -1
- package/dist/hooks/use-sortable.js +0 -2
- package/dist/hooks/use-sortable.js.map +1 -1
- package/dist/hooks/use-stable-callback.cjs.map +1 -1
- package/dist/hooks/use-storage-estimate.cjs.map +1 -1
- package/dist/hooks/use-throttle.cjs.map +1 -1
- package/dist/hooks/use-timeout.cjs.map +1 -1
- package/dist/hooks/use-toggle.cjs.map +1 -1
- package/dist/hooks/use-window-size.cjs.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +7 -5
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +1 -1
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/use-poll.cjs.map +1 -1
- package/dist/i18n/I18nProvider.cjs.map +1 -1
- package/dist/icons/Icon.cjs.map +1 -1
- package/dist/icons/IconProvider.cjs.map +1 -1
- package/dist/icons/icon-context.cjs.map +1 -1
- package/dist/icons/use-icon.cjs.map +1 -1
- package/dist/imaging/use-image-processing.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.js.map +1 -1
- package/dist/oauth/use-oauth-callback.cjs.map +1 -1
- package/dist/offline/use-offline-sync.cjs.map +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/query/QueryProvider.cjs.map +1 -1
- package/dist/query/constants.cjs +1 -1
- package/dist/query/constants.cjs.map +1 -1
- package/dist/query/constants.js +10 -10
- package/dist/query/constants.js.map +1 -1
- package/dist/query/create-query-keys.cjs +1 -1
- package/dist/query/create-query-keys.cjs.map +1 -1
- package/dist/query/create-query-keys.js +1 -1
- package/dist/query/create-query-keys.js.map +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/use-cursor-query.cjs.map +1 -1
- package/dist/query/use-offline-mutation.cjs.map +1 -1
- package/dist/query/use-paginated-query.cjs.map +1 -1
- package/dist/router/AppRouter.cjs +1 -1
- package/dist/router/AppRouter.cjs.map +1 -1
- package/dist/router/AppRouter.js +7 -2
- package/dist/router/AppRouter.js.map +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/store/create-store.cjs.map +1 -1
- package/dist/tabular/use-tabular-predictor.cjs.map +1 -1
- package/dist/telemetry/TelemetryProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/color.cjs +1 -1
- package/dist/theme/color.cjs.map +1 -1
- package/dist/theme/color.js +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/utils/cn.cjs +1 -1
- package/dist/utils/cn.cjs.map +1 -1
- package/dist/utils/cn.js +1 -1
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/objects.cjs +1 -1
- package/dist/utils/objects.cjs.map +1 -1
- package/dist/utils/objects.js +1 -1
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/xlsx.cjs +1 -1
- package/dist/utils/xlsx.cjs.map +1 -1
- package/dist/utils/xlsx.js +3 -3
- package/dist/utils/xlsx.js.map +1 -1
- package/dist/vision/core/canvas.cjs +1 -1
- package/dist/vision/core/canvas.cjs.map +1 -1
- package/dist/vision/core/canvas.js +4 -4
- package/dist/vision/core/canvas.js.map +1 -1
- package/dist/vision/core/exceptions.cjs +1 -1
- package/dist/vision/core/exceptions.cjs.map +1 -1
- package/dist/vision/core/exceptions.js +2 -2
- package/dist/vision/core/exceptions.js.map +1 -1
- package/dist/vision/core/metadata.cjs +2 -2
- package/dist/vision/core/metadata.cjs.map +1 -1
- package/dist/vision/core/metadata.js +11 -8
- package/dist/vision/core/metadata.js.map +1 -1
- package/dist/vision/core/session.cjs +1 -1
- package/dist/vision/core/session.cjs.map +1 -1
- package/dist/vision/core/session.js +8 -5
- package/dist/vision/core/session.js.map +1 -1
- package/dist/vision/fusion.cjs +2 -0
- package/dist/vision/fusion.cjs.map +1 -0
- package/dist/vision/fusion.js +42 -0
- package/dist/vision/fusion.js.map +1 -0
- package/dist/vision/index.cjs +1 -1
- package/dist/vision/index.cjs.map +1 -1
- package/dist/vision/index.js +23 -20
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/io/image.cjs +1 -1
- package/dist/vision/io/image.cjs.map +1 -1
- package/dist/vision/io/image.js +4 -2
- package/dist/vision/io/image.js.map +1 -1
- package/dist/vision/labels.cjs +1 -1
- package/dist/vision/labels.cjs.map +1 -1
- package/dist/vision/labels.js +7 -4
- package/dist/vision/labels.js.map +1 -1
- package/dist/vision/postprocess/detection.cjs +1 -1
- package/dist/vision/postprocess/detection.cjs.map +1 -1
- package/dist/vision/postprocess/detection.js +3 -10
- package/dist/vision/postprocess/detection.js.map +1 -1
- package/dist/vision/postprocess/segmentation.cjs +1 -1
- package/dist/vision/postprocess/segmentation.cjs.map +1 -1
- package/dist/vision/postprocess/segmentation.js +11 -15
- package/dist/vision/postprocess/segmentation.js.map +1 -1
- package/dist/vision/preprocess/image.cjs +1 -1
- package/dist/vision/preprocess/image.cjs.map +1 -1
- package/dist/vision/preprocess/image.js +4 -2
- package/dist/vision/preprocess/image.js.map +1 -1
- package/dist/vision/preprocess/pipeline.cjs +2 -0
- package/dist/vision/preprocess/pipeline.cjs.map +1 -0
- package/dist/vision/preprocess/pipeline.js +61 -0
- package/dist/vision/preprocess/pipeline.js.map +1 -0
- package/dist/vision/results.cjs +1 -1
- package/dist/vision/results.cjs.map +1 -1
- package/dist/vision/results.js +23 -2
- package/dist/vision/results.js.map +1 -1
- package/dist/vision/tasks/base.cjs +1 -1
- package/dist/vision/tasks/base.cjs.map +1 -1
- package/dist/vision/tasks/base.js +11 -2
- package/dist/vision/tasks/base.js.map +1 -1
- package/dist/vision/tasks/classifier.cjs +1 -1
- package/dist/vision/tasks/classifier.cjs.map +1 -1
- package/dist/vision/tasks/classifier.js +2 -2
- package/dist/vision/tasks/classifier.js.map +1 -1
- package/dist/vision/tasks/detectClassify.cjs +2 -0
- package/dist/vision/tasks/detectClassify.cjs.map +1 -0
- package/dist/vision/tasks/detectClassify.js +222 -0
- package/dist/vision/tasks/detectClassify.js.map +1 -0
- package/dist/vision/tasks/detector.cjs +1 -1
- package/dist/vision/tasks/detector.cjs.map +1 -1
- package/dist/vision/tasks/detector.js +54 -29
- package/dist/vision/tasks/detector.js.map +1 -1
- package/dist/vision/tasks/segmenter.cjs +1 -1
- package/dist/vision/tasks/segmenter.cjs.map +1 -1
- package/dist/vision/tasks/segmenter.js +53 -28
- package/dist/vision/tasks/segmenter.js.map +1 -1
- package/dist/vision/types.cjs.map +1 -1
- package/dist/vision/types.js.map +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-live-luminance.cjs.map +1 -1
- package/dist/vision.cjs +1 -1
- package/dist/vision.d.ts +1517 -962
- package/dist/vision.js +25 -22
- package/dist/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +3 -3
- package/dist/vite/create-vite-config.js.map +1 -1
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-icons.cjs.map +1 -1
- 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 +5 -3
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +2 -2
- package/template/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-offline-sync.cjs","names":[],"sources":["../../src/offline/use-offline-sync.ts"],"sourcesContent":["import { useEffect, useRef, useSyncExternalStore } from \"react\";\nimport type {\n OfflineSync,\n OutboxOp,\n SyncRunSummary,\n SyncState,\n SyncTrigger,\n} from \"./create-offline-sync\";\n\n/**\n * Options for {@link useOfflineSync}. All auto-flush triggers are opt-in except\n * `flushOnOnline`, which defaults to `true` so the app catches up the moment\n * connectivity returns.\n */\nexport interface UseOfflineSyncOptions {\n /** Flush once when the component mounts (trigger `\"boot\"`). Default `false`. */\n flushOnMount?: boolean;\n /**\n * Flush when the browser fires the `online` event (trigger\n * `\"online-event\"`). Default `true`.\n */\n flushOnOnline?: boolean;\n /**\n * Flush on this interval in milliseconds (trigger `\"interval\"`). `0`\n * disables the timer. Default `0`.\n */\n intervalMs?: number;\n}\n\n/**\n * Reactive view of an {@link OfflineSync} engine, plus its imperative actions.\n * Extends {@link SyncState} so `phase`, `pending`, `lastSummary`, `lastError`\n * and `lastSyncedAt` are read directly off the result.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n */\nexport interface UseOfflineSyncResult<TPayload> extends SyncState {\n /** `true` while a flush run is in progress (`phase === \"syncing\"`). */\n syncing: boolean;\n /** Queue a mutation. Mirrors {@link OfflineSync.enqueue}. */\n enqueue: (op: OutboxOp, recordId: string, payload?: TPayload) => Promise<string>;\n /** Trigger a flush run. Mirrors {@link OfflineSync.flush}. */\n flush: (trigger?: SyncTrigger) => Promise<SyncRunSummary>;\n}\n\n/**\n * Subscribe a React component to an {@link OfflineSync} engine.\n *\n * Re-renders whenever the engine's {@link SyncState} changes (enqueue, flush\n * transition, outbox clear) via `useSyncExternalStore`, and optionally wires\n * auto-flush on mount, on the `online` event and on an interval. The engine\n * itself is created once by the app and passed in — the hook never owns it, so\n * multiple components can observe the same queue.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param sync - The engine returned by `createOfflineSync`.\n * @param options - Auto-flush triggers.\n * @returns The reactive state merged with `enqueue`/`flush` actions.\n *\n * @example\n * const { pending, syncing, phase, flush } = useOfflineSync(notesSync, {\n * flushOnMount: true,\n * intervalMs: 30_000,\n * });\n * return <SyncStatusBadge pending={pending} syncing={syncing} phase={phase} />;\n */\nexport function useOfflineSync<TPayload>(\n sync: OfflineSync<TPayload>,\n options: UseOfflineSyncOptions = {},\n): UseOfflineSyncResult<TPayload> {\n const { flushOnMount = false, flushOnOnline = true, intervalMs = 0 } = options;\n\n const state = useSyncExternalStore(sync.subscribe, sync.getState, sync.getState);\n\n const flushRef = useRef(sync.flush);\n useEffect(() => {\n flushRef.current = sync.flush;\n }, [sync.flush]);\n\n useEffect(() => {\n if (flushOnMount) void flushRef.current(\"boot\");\n }, [flushOnMount]);\n\n useEffect(() => {\n if (!flushOnOnline || typeof window === \"undefined\") return;\n const handleOnline = (): void => {\n void flushRef.current(\"online-event\");\n };\n window.addEventListener(\"online\", handleOnline);\n return () => window.removeEventListener(\"online\", handleOnline);\n }, [flushOnOnline]);\n\n useEffect(() => {\n if (intervalMs <= 0 || typeof window === \"undefined\") return;\n const id = window.setInterval(() => {\n void flushRef.current(\"interval\");\n }, intervalMs);\n return () => window.clearInterval(id);\n }, [intervalMs]);\n\n return {\n ...state,\n syncing: state.phase === \"syncing\",\n enqueue: sync.enqueue,\n flush: sync.flush,\n };\n}\n\n/**\n * Presentation-ready tone for a sync status indicator. Collapses the engine's\n * {@link SyncState} into the single most relevant signal for a badge/pill.\n */\nexport type SyncTone = \"idle\" | \"syncing\" | \"pending\" | \"offline\" | \"error\";\n\n/**\n * Compact status snapshot for a status badge/pill. Prefer this over\n * {@link useOfflineSync} when a component only needs to *display* status and\n * does not trigger flushes itself.\n */\nexport interface SyncStatus {\n /** The dominant tone to render. */\n tone: SyncTone;\n /** Number of mutations still queued. */\n pending: number;\n /** `true` while a flush run is in progress. */\n syncing: boolean;\n /** `true` when the last run was skipped for being offline. */\n offline: boolean;\n /** Message of the most recent delivery failure, or `null`. */\n lastError: string | null;\n}\n\n/**\n * Derive the dominant {@link SyncTone} from an engine snapshot.\n *\n * Precedence: syncing → offline → error → pending → idle. `syncing` wins so an\n * in-flight run always reads as active even while entries remain queued.\n *\n * @param state - The engine {@link SyncState}.\n * @returns The tone to render.\n */\nfunction toneFromState(state: SyncState): SyncTone {\n if (state.phase === \"syncing\") return \"syncing\";\n if (state.phase === \"offline\") return \"offline\";\n if (state.phase === \"error\") return \"error\";\n if (state.pending > 0) return \"pending\";\n return \"idle\";\n}\n\n/**\n * Subscribe to an {@link OfflineSync} engine and return a display-only\n * {@link SyncStatus}. A thin read-only companion to {@link useOfflineSync},\n * intended to feed a `<SyncStatusBadge>` without exposing flush actions.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param sync - The engine returned by `createOfflineSync`.\n * @returns The compact status snapshot.\n */\nexport function useSyncStatus<TPayload>(sync: OfflineSync<TPayload>): SyncStatus {\n const state = useSyncExternalStore(sync.subscribe, sync.getState, sync.getState);\n return {\n tone: toneFromState(state),\n pending: state.pending,\n syncing: state.phase === \"syncing\",\n offline: state.phase === \"offline\",\n lastError: state.lastError,\n };\n}\n"],"mappings":"uBAkEA,SAAgB,EACZ,EACA,EAAiC,CAAC,EACJ,CAC9B,GAAM,CAAE,eAAe,GAAO,gBAAgB,GAAM,aAAa,GAAM,EAEjE,GAAA,
|
|
1
|
+
{"version":3,"file":"use-offline-sync.cjs","names":[],"sources":["../../src/offline/use-offline-sync.ts"],"sourcesContent":["import { useEffect, useRef, useSyncExternalStore } from \"react\";\nimport type {\n OfflineSync,\n OutboxOp,\n SyncRunSummary,\n SyncState,\n SyncTrigger,\n} from \"./create-offline-sync\";\n\n/**\n * Options for {@link useOfflineSync}. All auto-flush triggers are opt-in except\n * `flushOnOnline`, which defaults to `true` so the app catches up the moment\n * connectivity returns.\n */\nexport interface UseOfflineSyncOptions {\n /** Flush once when the component mounts (trigger `\"boot\"`). Default `false`. */\n flushOnMount?: boolean;\n /**\n * Flush when the browser fires the `online` event (trigger\n * `\"online-event\"`). Default `true`.\n */\n flushOnOnline?: boolean;\n /**\n * Flush on this interval in milliseconds (trigger `\"interval\"`). `0`\n * disables the timer. Default `0`.\n */\n intervalMs?: number;\n}\n\n/**\n * Reactive view of an {@link OfflineSync} engine, plus its imperative actions.\n * Extends {@link SyncState} so `phase`, `pending`, `lastSummary`, `lastError`\n * and `lastSyncedAt` are read directly off the result.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n */\nexport interface UseOfflineSyncResult<TPayload> extends SyncState {\n /** `true` while a flush run is in progress (`phase === \"syncing\"`). */\n syncing: boolean;\n /** Queue a mutation. Mirrors {@link OfflineSync.enqueue}. */\n enqueue: (op: OutboxOp, recordId: string, payload?: TPayload) => Promise<string>;\n /** Trigger a flush run. Mirrors {@link OfflineSync.flush}. */\n flush: (trigger?: SyncTrigger) => Promise<SyncRunSummary>;\n}\n\n/**\n * Subscribe a React component to an {@link OfflineSync} engine.\n *\n * Re-renders whenever the engine's {@link SyncState} changes (enqueue, flush\n * transition, outbox clear) via `useSyncExternalStore`, and optionally wires\n * auto-flush on mount, on the `online` event and on an interval. The engine\n * itself is created once by the app and passed in — the hook never owns it, so\n * multiple components can observe the same queue.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param sync - The engine returned by `createOfflineSync`.\n * @param options - Auto-flush triggers.\n * @returns The reactive state merged with `enqueue`/`flush` actions.\n *\n * @example\n * const { pending, syncing, phase, flush } = useOfflineSync(notesSync, {\n * flushOnMount: true,\n * intervalMs: 30_000,\n * });\n * return <SyncStatusBadge pending={pending} syncing={syncing} phase={phase} />;\n */\nexport function useOfflineSync<TPayload>(\n sync: OfflineSync<TPayload>,\n options: UseOfflineSyncOptions = {},\n): UseOfflineSyncResult<TPayload> {\n const { flushOnMount = false, flushOnOnline = true, intervalMs = 0 } = options;\n\n const state = useSyncExternalStore(sync.subscribe, sync.getState, sync.getState);\n\n const flushRef = useRef(sync.flush);\n useEffect(() => {\n flushRef.current = sync.flush;\n }, [sync.flush]);\n\n useEffect(() => {\n if (flushOnMount) void flushRef.current(\"boot\");\n }, [flushOnMount]);\n\n useEffect(() => {\n if (!flushOnOnline || typeof window === \"undefined\") return;\n const handleOnline = (): void => {\n void flushRef.current(\"online-event\");\n };\n window.addEventListener(\"online\", handleOnline);\n return () => window.removeEventListener(\"online\", handleOnline);\n }, [flushOnOnline]);\n\n useEffect(() => {\n if (intervalMs <= 0 || typeof window === \"undefined\") return;\n const id = window.setInterval(() => {\n void flushRef.current(\"interval\");\n }, intervalMs);\n return () => window.clearInterval(id);\n }, [intervalMs]);\n\n return {\n ...state,\n syncing: state.phase === \"syncing\",\n enqueue: sync.enqueue,\n flush: sync.flush,\n };\n}\n\n/**\n * Presentation-ready tone for a sync status indicator. Collapses the engine's\n * {@link SyncState} into the single most relevant signal for a badge/pill.\n */\nexport type SyncTone = \"idle\" | \"syncing\" | \"pending\" | \"offline\" | \"error\";\n\n/**\n * Compact status snapshot for a status badge/pill. Prefer this over\n * {@link useOfflineSync} when a component only needs to *display* status and\n * does not trigger flushes itself.\n */\nexport interface SyncStatus {\n /** The dominant tone to render. */\n tone: SyncTone;\n /** Number of mutations still queued. */\n pending: number;\n /** `true` while a flush run is in progress. */\n syncing: boolean;\n /** `true` when the last run was skipped for being offline. */\n offline: boolean;\n /** Message of the most recent delivery failure, or `null`. */\n lastError: string | null;\n}\n\n/**\n * Derive the dominant {@link SyncTone} from an engine snapshot.\n *\n * Precedence: syncing → offline → error → pending → idle. `syncing` wins so an\n * in-flight run always reads as active even while entries remain queued.\n *\n * @param state - The engine {@link SyncState}.\n * @returns The tone to render.\n */\nfunction toneFromState(state: SyncState): SyncTone {\n if (state.phase === \"syncing\") return \"syncing\";\n if (state.phase === \"offline\") return \"offline\";\n if (state.phase === \"error\") return \"error\";\n if (state.pending > 0) return \"pending\";\n return \"idle\";\n}\n\n/**\n * Subscribe to an {@link OfflineSync} engine and return a display-only\n * {@link SyncStatus}. A thin read-only companion to {@link useOfflineSync},\n * intended to feed a `<SyncStatusBadge>` without exposing flush actions.\n *\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param sync - The engine returned by `createOfflineSync`.\n * @returns The compact status snapshot.\n */\nexport function useSyncStatus<TPayload>(sync: OfflineSync<TPayload>): SyncStatus {\n const state = useSyncExternalStore(sync.subscribe, sync.getState, sync.getState);\n return {\n tone: toneFromState(state),\n pending: state.pending,\n syncing: state.phase === \"syncing\",\n offline: state.phase === \"offline\",\n lastError: state.lastError,\n };\n}\n"],"mappings":"uBAkEA,SAAgB,EACZ,EACA,EAAiC,CAAC,EACJ,CAC9B,GAAM,CAAE,eAAe,GAAO,gBAAgB,GAAM,aAAa,GAAM,EAEjE,GAAA,EAAQ,EAAA,qBAAA,CAAqB,EAAK,UAAW,EAAK,SAAU,EAAK,QAAQ,EAEzE,GAAA,EAAW,EAAA,OAAA,CAAO,EAAK,KAAK,EA0BlC,OAzBA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAS,QAAU,EAAK,KAC5B,EAAG,CAAC,EAAK,KAAK,CAAC,GAEf,EAAA,EAAA,UAAA,KAAgB,CACR,GAAc,EAAc,QAAQ,MAAM,CAClD,EAAG,CAAC,CAAY,CAAC,GAEjB,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,GAAiB,OAAO,OAAW,IAAa,OACrD,IAAM,MAA2B,CAC7B,EAAc,QAAQ,cAAc,CACxC,EAEA,OADA,OAAO,iBAAiB,SAAU,CAAY,MACjC,OAAO,oBAAoB,SAAU,CAAY,CAClE,EAAG,CAAC,CAAa,CAAC,GAElB,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,GAAc,GAAK,OAAO,OAAW,IAAa,OACtD,IAAM,EAAK,OAAO,gBAAkB,CAChC,EAAc,QAAQ,UAAU,CACpC,EAAG,CAAU,EACb,UAAa,OAAO,cAAc,CAAE,CACxC,EAAG,CAAC,CAAU,CAAC,EAER,CACH,GAAG,EACH,QAAS,EAAM,QAAU,UACzB,QAAS,EAAK,QACd,MAAO,EAAK,KAChB,CACJ,CAmCA,SAAS,EAAc,EAA4B,CAK/C,OAJI,EAAM,QAAU,UAAkB,UAClC,EAAM,QAAU,UAAkB,UAClC,EAAM,QAAU,QAAgB,QAChC,EAAM,QAAU,EAAU,UACvB,MACX,CAWA,SAAgB,EAAwB,EAAyC,CAC7E,IAAM,GAAA,EAAQ,EAAA,qBAAA,CAAqB,EAAK,UAAW,EAAK,SAAU,EAAK,QAAQ,EAC/E,MAAO,CACH,KAAM,EAAc,CAAK,EACzB,QAAS,EAAM,QACf,QAAS,EAAM,QAAU,UACzB,QAAS,EAAM,QAAU,UACzB,UAAW,EAAM,SACrB,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-push-subscription.cjs","names":[],"sources":["../../src/push/use-push-subscription.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- the ref is read inside deferred callbacks, not during render */\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { WebPushClient, type WebPushClientConfig } from \"./web-push-client\";\nimport { isPushSupported } from \"./utils\";\n\nexport interface UsePushSubscriptionResult {\n /** True when the browser exposes the Push + Notification APIs. */\n supported: boolean;\n /** Current `Notification.permission` value, or `\"unsupported\"`. */\n permission: NotificationPermission | \"unsupported\";\n /** True when a subscription is active on this device. */\n subscribed: boolean;\n /** True while a subscribe/unsubscribe call is in-flight. */\n loading: boolean;\n /** Last error thrown by subscribe/unsubscribe, if any. */\n error: Error | null;\n subscribe: () => Promise<void>;\n unsubscribe: () => Promise<void>;\n /** Re-read the current subscription/permission state from the browser. */\n refresh: () => Promise<void>;\n}\n\n/**\n * React hook around {@link WebPushClient}. Tracks subscription, permission and\n * loading state; exposes imperative `subscribe`/`unsubscribe` actions.\n *\n * The hook does NOT register the service worker — the host app must do that\n * (e.g. via `vite-plugin-pwa` or a manual `navigator.serviceWorker.register`).\n *\n * @example\n * const push = usePushSubscription({\n * vapidPublicKey: import.meta.env.VITE_VAPID_PUBLIC_KEY,\n * onSubscribe: (sub) => api.post(\"/webpush/subscribe\", { body: sub }),\n * onUnsubscribe: () => api.delete(\"/webpush/my\"),\n * });\n */\nexport function usePushSubscription(config: WebPushClientConfig): UsePushSubscriptionResult {\n const configRef = useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const client = useMemo(\n () =>\n new WebPushClient({\n vapidPublicKey: config.vapidPublicKey,\n onSubscribe: (sub) => configRef.current.onSubscribe(sub),\n onUnsubscribe: (sub) => configRef.current.onUnsubscribe?.(sub),\n getRegistration: config.getRegistration,\n }),\n [config.vapidPublicKey, config.getRegistration],\n );\n\n const [supported] = useState<boolean>(() => isPushSupported());\n const [permission, setPermission] = useState<NotificationPermission | \"unsupported\">(() =>\n client.permission(),\n );\n const [subscribed, setSubscribed] = useState<boolean>(false);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const refresh = useCallback(async () => {\n if (!supported) return;\n setPermission(client.permission());\n try {\n const active = await client.isSubscribed();\n setSubscribed(active);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n }, [client, supported]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const subscribe = useCallback(async () => {\n if (!supported) return;\n setLoading(true);\n setError(null);\n try {\n await client.subscribe();\n setSubscribed(true);\n setPermission(client.permission());\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n throw err;\n } finally {\n setLoading(false);\n }\n }, [client, supported]);\n\n const unsubscribe = useCallback(async () => {\n if (!supported) return;\n setLoading(true);\n setError(null);\n try {\n await client.unsubscribe();\n setSubscribed(false);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n throw err;\n } finally {\n setLoading(false);\n }\n }, [client, supported]);\n\n return {\n supported,\n permission,\n subscribed,\n loading,\n error,\n subscribe,\n unsubscribe,\n refresh,\n };\n}\n"],"mappings":"yFAoCA,SAAgB,EAAoB,EAAwD,CACxF,IAAM,GAAA,
|
|
1
|
+
{"version":3,"file":"use-push-subscription.cjs","names":[],"sources":["../../src/push/use-push-subscription.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- the ref is read inside deferred callbacks, not during render */\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { WebPushClient, type WebPushClientConfig } from \"./web-push-client\";\nimport { isPushSupported } from \"./utils\";\n\nexport interface UsePushSubscriptionResult {\n /** True when the browser exposes the Push + Notification APIs. */\n supported: boolean;\n /** Current `Notification.permission` value, or `\"unsupported\"`. */\n permission: NotificationPermission | \"unsupported\";\n /** True when a subscription is active on this device. */\n subscribed: boolean;\n /** True while a subscribe/unsubscribe call is in-flight. */\n loading: boolean;\n /** Last error thrown by subscribe/unsubscribe, if any. */\n error: Error | null;\n subscribe: () => Promise<void>;\n unsubscribe: () => Promise<void>;\n /** Re-read the current subscription/permission state from the browser. */\n refresh: () => Promise<void>;\n}\n\n/**\n * React hook around {@link WebPushClient}. Tracks subscription, permission and\n * loading state; exposes imperative `subscribe`/`unsubscribe` actions.\n *\n * The hook does NOT register the service worker — the host app must do that\n * (e.g. via `vite-plugin-pwa` or a manual `navigator.serviceWorker.register`).\n *\n * @example\n * const push = usePushSubscription({\n * vapidPublicKey: import.meta.env.VITE_VAPID_PUBLIC_KEY,\n * onSubscribe: (sub) => api.post(\"/webpush/subscribe\", { body: sub }),\n * onUnsubscribe: () => api.delete(\"/webpush/my\"),\n * });\n */\nexport function usePushSubscription(config: WebPushClientConfig): UsePushSubscriptionResult {\n const configRef = useRef(config);\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n const client = useMemo(\n () =>\n new WebPushClient({\n vapidPublicKey: config.vapidPublicKey,\n onSubscribe: (sub) => configRef.current.onSubscribe(sub),\n onUnsubscribe: (sub) => configRef.current.onUnsubscribe?.(sub),\n getRegistration: config.getRegistration,\n }),\n [config.vapidPublicKey, config.getRegistration],\n );\n\n const [supported] = useState<boolean>(() => isPushSupported());\n const [permission, setPermission] = useState<NotificationPermission | \"unsupported\">(() =>\n client.permission(),\n );\n const [subscribed, setSubscribed] = useState<boolean>(false);\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const refresh = useCallback(async () => {\n if (!supported) return;\n setPermission(client.permission());\n try {\n const active = await client.isSubscribed();\n setSubscribed(active);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n }\n }, [client, supported]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const subscribe = useCallback(async () => {\n if (!supported) return;\n setLoading(true);\n setError(null);\n try {\n await client.subscribe();\n setSubscribed(true);\n setPermission(client.permission());\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n throw err;\n } finally {\n setLoading(false);\n }\n }, [client, supported]);\n\n const unsubscribe = useCallback(async () => {\n if (!supported) return;\n setLoading(true);\n setError(null);\n try {\n await client.unsubscribe();\n setSubscribed(false);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n throw err;\n } finally {\n setLoading(false);\n }\n }, [client, supported]);\n\n return {\n supported,\n permission,\n subscribed,\n loading,\n error,\n subscribe,\n unsubscribe,\n refresh,\n };\n}\n"],"mappings":"yFAoCA,SAAgB,EAAoB,EAAwD,CACxF,IAAM,GAAA,EAAY,EAAA,OAAA,CAAO,CAAM,GAC/B,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAU,QAAU,CACxB,EAAG,CAAC,CAAM,CAAC,EAEX,IAAM,GAAA,EAAS,EAAA,QAAA,KAEP,IAAI,EAAA,cAAc,CACd,eAAgB,EAAO,eACvB,YAAc,GAAQ,EAAU,QAAQ,YAAY,CAAG,EACvD,cAAgB,GAAQ,EAAU,QAAQ,gBAAgB,CAAG,EAC7D,gBAAiB,EAAO,eAC5B,CAAC,EACL,CAAC,EAAO,eAAgB,EAAO,eAAe,CAClD,EAEM,CAAC,IAAA,EAAa,EAAA,SAAA,KAAwB,EAAA,gBAAgB,CAAC,EACvD,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,KAChC,EAAO,WAAW,CACtB,EACM,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,CAAkB,EAAK,EACrD,CAAC,EAAS,IAAA,EAAc,EAAA,SAAA,CAAkB,EAAK,EAC/C,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAAuB,IAAI,EAE/C,GAAA,EAAU,EAAA,YAAA,CAAY,SAAY,CAC/B,KACL,GAAc,EAAO,WAAW,CAAC,EACjC,GAAI,CACA,IAAM,EAAS,MAAM,EAAO,aAAa,EACzC,EAAc,CAAM,CACxB,OAAS,EAAK,CACV,EAAS,aAAe,MAAQ,EAAU,MAAM,OAAO,CAAG,CAAC,CAAC,CAChE,CANiC,CAOrC,EAAG,CAAC,EAAQ,CAAS,CAAC,EAqCtB,OAnCA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAa,CACjB,EAAG,CAAC,CAAO,CAAC,EAiCL,CACH,YACA,aACA,aACA,UACA,QACA,WAAA,EArCc,EAAA,YAAA,CAAY,SAAY,CACjC,KAEL,CADA,EAAW,EAAI,EACf,EAAS,IAAI,EACb,GAAI,CACA,MAAM,EAAO,UAAU,EACvB,EAAc,EAAI,EAClB,EAAc,EAAO,WAAW,CAAC,CACrC,OAAS,EAAK,CAEV,MADA,EAAS,aAAe,MAAQ,EAAU,MAAM,OAAO,CAAG,CAAC,CAAC,EACtD,CACV,QAAU,CACN,EAAW,EAAK,CACpB,CAVa,CAWjB,EAAG,CAAC,EAAQ,CAAS,CAuBjB,EACA,aAAA,EAtBgB,EAAA,YAAA,CAAY,SAAY,CACnC,KAEL,CADA,EAAW,EAAI,EACf,EAAS,IAAI,EACb,GAAI,CACA,MAAM,EAAO,YAAY,EACzB,EAAc,EAAK,CACvB,OAAS,EAAK,CAEV,MADA,EAAS,aAAe,MAAQ,EAAU,MAAM,OAAO,CAAG,CAAC,CAAC,EACtD,CACV,QAAU,CACN,EAAW,EAAK,CACpB,CATa,CAUjB,EAAG,CAAC,EAAQ,CAAS,CASjB,EACA,SACJ,CACJ"}
|
|
@@ -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\";\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, 1 retry).\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: 1,\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":"4HAkBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,GAAM,CAAC,IAAA,
|
|
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\";\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, 1 retry).\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: 1,\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":"4HAkBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,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,EACP,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"}
|
package/dist/query/constants.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={SHORT:
|
|
1
|
+
var e={SHORT:3e4,DEFAULT:3e5,LONG:18e5,INFINITE:1/0},t={SHORT:3e5,DEFAULT:18e5,LONG:36e5},n={REALTIME:5e3,FAST:3e4,DEFAULT:6e4,SLOW:3e5};exports.CACHE_TIME=t,exports.REFETCH_TIME=n,exports.STALE_TIME=e;
|
|
2
2
|
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/query/constants.ts"],"sourcesContent":["/** Recommended `staleTime` presets (milliseconds). */\nexport const STALE_TIME = {\n SHORT: 30 * 1000,\n DEFAULT: 5 * 60 * 1000,\n LONG: 30 * 60 * 1000,\n INFINITE: Infinity,\n} as const;\n\n/** Recommended `gcTime` presets (milliseconds). */\nexport const CACHE_TIME = {\n SHORT: 5 * 60 * 1000,\n DEFAULT: 30 * 60 * 1000,\n LONG: 60 * 60 * 1000,\n} as const;\n\n/** Recommended refetch intervals (milliseconds). */\nexport const REFETCH_TIME = {\n REALTIME: 5 * 1000,\n FAST: 30 * 1000,\n DEFAULT: 60 * 1000,\n SLOW: 5 * 60 * 1000,\n} as const;\n"],"mappings":"AACA,IAAa,EAAa,CACtB,MAAO,
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/query/constants.ts"],"sourcesContent":["/** Recommended `staleTime` presets (milliseconds). */\nexport const STALE_TIME = {\n SHORT: 30 * 1000,\n DEFAULT: 5 * 60 * 1000,\n LONG: 30 * 60 * 1000,\n INFINITE: Infinity,\n} as const;\n\n/** Recommended `gcTime` presets (milliseconds). */\nexport const CACHE_TIME = {\n SHORT: 5 * 60 * 1000,\n DEFAULT: 30 * 60 * 1000,\n LONG: 60 * 60 * 1000,\n} as const;\n\n/** Recommended refetch intervals (milliseconds). */\nexport const REFETCH_TIME = {\n REALTIME: 5 * 1000,\n FAST: 30 * 1000,\n DEFAULT: 60 * 1000,\n SLOW: 5 * 60 * 1000,\n} as const;\n"],"mappings":"AACA,IAAa,EAAa,CACtB,MAAO,IACP,QAAS,IACT,KAAM,KACN,SAAU,GACd,EAGa,EAAa,CACtB,MAAO,IACP,QAAS,KACT,KAAM,IACV,EAGa,EAAe,CACxB,SAAU,IACV,KAAM,IACN,QAAS,IACT,KAAM,GACV"}
|
package/dist/query/constants.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
//#region src/query/constants.ts
|
|
2
2
|
var e = {
|
|
3
|
-
SHORT:
|
|
4
|
-
DEFAULT:
|
|
5
|
-
LONG:
|
|
3
|
+
SHORT: 3e4,
|
|
4
|
+
DEFAULT: 3e5,
|
|
5
|
+
LONG: 18e5,
|
|
6
6
|
INFINITE: Infinity
|
|
7
7
|
}, t = {
|
|
8
|
-
SHORT:
|
|
9
|
-
DEFAULT:
|
|
10
|
-
LONG:
|
|
8
|
+
SHORT: 3e5,
|
|
9
|
+
DEFAULT: 18e5,
|
|
10
|
+
LONG: 36e5
|
|
11
11
|
}, n = {
|
|
12
|
-
REALTIME:
|
|
13
|
-
FAST:
|
|
14
|
-
DEFAULT:
|
|
15
|
-
SLOW:
|
|
12
|
+
REALTIME: 5e3,
|
|
13
|
+
FAST: 3e4,
|
|
14
|
+
DEFAULT: 6e4,
|
|
15
|
+
SLOW: 3e5
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
18
|
export { t as CACHE_TIME, n as REFETCH_TIME, e as STALE_TIME };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../src/query/constants.ts"],"sourcesContent":["/** Recommended `staleTime` presets (milliseconds). */\nexport const STALE_TIME = {\n SHORT: 30 * 1000,\n DEFAULT: 5 * 60 * 1000,\n LONG: 30 * 60 * 1000,\n INFINITE: Infinity,\n} as const;\n\n/** Recommended `gcTime` presets (milliseconds). */\nexport const CACHE_TIME = {\n SHORT: 5 * 60 * 1000,\n DEFAULT: 30 * 60 * 1000,\n LONG: 60 * 60 * 1000,\n} as const;\n\n/** Recommended refetch intervals (milliseconds). */\nexport const REFETCH_TIME = {\n REALTIME: 5 * 1000,\n FAST: 30 * 1000,\n DEFAULT: 60 * 1000,\n SLOW: 5 * 60 * 1000,\n} as const;\n"],"mappings":";AACA,IAAa,IAAa;CACtB,OAAO
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/query/constants.ts"],"sourcesContent":["/** Recommended `staleTime` presets (milliseconds). */\nexport const STALE_TIME = {\n SHORT: 30 * 1000,\n DEFAULT: 5 * 60 * 1000,\n LONG: 30 * 60 * 1000,\n INFINITE: Infinity,\n} as const;\n\n/** Recommended `gcTime` presets (milliseconds). */\nexport const CACHE_TIME = {\n SHORT: 5 * 60 * 1000,\n DEFAULT: 30 * 60 * 1000,\n LONG: 60 * 60 * 1000,\n} as const;\n\n/** Recommended refetch intervals (milliseconds). */\nexport const REFETCH_TIME = {\n REALTIME: 5 * 1000,\n FAST: 30 * 1000,\n DEFAULT: 60 * 1000,\n SLOW: 5 * 60 * 1000,\n} as const;\n"],"mappings":";AACA,IAAa,IAAa;CACtB,OAAO;CACP,SAAS;CACT,MAAM;CACN,UAAU;AACd,GAGa,IAAa;CACtB,OAAO;CACP,SAAS;CACT,MAAM;AACV,GAGa,IAAe;CACxB,UAAU;CACV,MAAM;CACN,SAAS;CACT,MAAM;AACV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){let n={all:[e]};for(let[r,i]of Object.entries(t))typeof i==`function`?
|
|
1
|
+
function e(e,t){let n={all:[e]};for(let[r,i]of Object.entries(t))n[r]=typeof i==`function`?(...t)=>[e,...i(...t)]:[e,...i];return n}exports.createQueryKeys=e;
|
|
2
2
|
//# sourceMappingURL=create-query-keys.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-query-keys.cjs","names":[],"sources":["../../src/query/create-query-keys.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype KeyBuilder = (...args: any[]) => readonly unknown[];\n\n/**\n * Build a typed query-key factory for a domain. Each entry can be a static\n * tuple or a function returning a tuple. The returned object is `as const`\n * so TanStack Query infers literal keys.\n *\n * @example\n * const userKeys = createQueryKeys(\"user\", {\n * me: () => [\"me\"] as const,\n * byId: (id: string) => [id] as const,\n * list: (filters: { page: number }) => [\"list\", filters] as const,\n * });\n * // userKeys.byId(\"42\") === [\"user\", \"42\"]\n */\nexport function createQueryKeys<\n TKey extends string,\n TEntries extends Record<string, KeyBuilder | readonly unknown[]>,\n>(scope: TKey, entries: TEntries) {\n const output = { all: [scope] as const } as { all: readonly [TKey] } & {\n [K in keyof TEntries]: TEntries[K] extends KeyBuilder\n ? (...args: Parameters<TEntries[K]>) => readonly [TKey, ...ReturnType<TEntries[K]>]\n : TEntries[K] extends readonly unknown[]\n ? readonly [TKey, ...TEntries[K]]\n : never;\n };\n\n for (const [name, entry] of Object.entries(entries) as [\n keyof TEntries,\n KeyBuilder | readonly unknown[],\n ][]) {\n if (typeof entry === \"function\") {\n (output as Record<string, unknown>)[name as string] = (...args: unknown[]) =>\n [scope, ...entry(...args)] as const;\n } else {\n (output as Record<string, unknown>)[name as string] = [scope, ...entry] as const;\n }\n }\n\n return output;\n}\n"],"mappings":"AAgBA,SAAgB,EAGd,EAAa,EAAmB,CAC9B,IAAM,EAAS,CAAE,IAAK,CAAC,CAAK,CAAW,EAQvC,IAAK,GAAM,CAAC,EAAM,KAAU,OAAO,QAAQ,CAAO,
|
|
1
|
+
{"version":3,"file":"create-query-keys.cjs","names":[],"sources":["../../src/query/create-query-keys.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype KeyBuilder = (...args: any[]) => readonly unknown[];\n\n/**\n * Build a typed query-key factory for a domain. Each entry can be a static\n * tuple or a function returning a tuple. The returned object is `as const`\n * so TanStack Query infers literal keys.\n *\n * @example\n * const userKeys = createQueryKeys(\"user\", {\n * me: () => [\"me\"] as const,\n * byId: (id: string) => [id] as const,\n * list: (filters: { page: number }) => [\"list\", filters] as const,\n * });\n * // userKeys.byId(\"42\") === [\"user\", \"42\"]\n */\nexport function createQueryKeys<\n TKey extends string,\n TEntries extends Record<string, KeyBuilder | readonly unknown[]>,\n>(scope: TKey, entries: TEntries) {\n const output = { all: [scope] as const } as { all: readonly [TKey] } & {\n [K in keyof TEntries]: TEntries[K] extends KeyBuilder\n ? (...args: Parameters<TEntries[K]>) => readonly [TKey, ...ReturnType<TEntries[K]>]\n : TEntries[K] extends readonly unknown[]\n ? readonly [TKey, ...TEntries[K]]\n : never;\n };\n\n for (const [name, entry] of Object.entries(entries) as [\n keyof TEntries,\n KeyBuilder | readonly unknown[],\n ][]) {\n if (typeof entry === \"function\") {\n (output as Record<string, unknown>)[name as string] = (...args: unknown[]) =>\n [scope, ...entry(...args)] as const;\n } else {\n (output as Record<string, unknown>)[name as string] = [scope, ...entry] as const;\n }\n }\n\n return output;\n}\n"],"mappings":"AAgBA,SAAgB,EAGd,EAAa,EAAmB,CAC9B,IAAM,EAAS,CAAE,IAAK,CAAC,CAAK,CAAW,EAQvC,IAAK,GAAM,CAAC,EAAM,KAAU,OAAO,QAAQ,CAAO,EAI9C,AAII,EAAoC,GAJpC,OAAO,GAAU,YACsC,GAAG,IACtD,CAAC,EAAO,GAAG,EAAM,GAAG,CAAI,CAAC,EAEyB,CAAC,EAAO,GAAG,CAAK,EAI9E,OAAO,CACX"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/query/create-query-keys.ts
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
let n = { all: [e] };
|
|
4
|
-
for (let [r, i] of Object.entries(t)) typeof i == "function" ?
|
|
4
|
+
for (let [r, i] of Object.entries(t)) n[r] = typeof i == "function" ? (...t) => [e, ...i(...t)] : [e, ...i];
|
|
5
5
|
return n;
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-query-keys.js","names":[],"sources":["../../src/query/create-query-keys.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype KeyBuilder = (...args: any[]) => readonly unknown[];\n\n/**\n * Build a typed query-key factory for a domain. Each entry can be a static\n * tuple or a function returning a tuple. The returned object is `as const`\n * so TanStack Query infers literal keys.\n *\n * @example\n * const userKeys = createQueryKeys(\"user\", {\n * me: () => [\"me\"] as const,\n * byId: (id: string) => [id] as const,\n * list: (filters: { page: number }) => [\"list\", filters] as const,\n * });\n * // userKeys.byId(\"42\") === [\"user\", \"42\"]\n */\nexport function createQueryKeys<\n TKey extends string,\n TEntries extends Record<string, KeyBuilder | readonly unknown[]>,\n>(scope: TKey, entries: TEntries) {\n const output = { all: [scope] as const } as { all: readonly [TKey] } & {\n [K in keyof TEntries]: TEntries[K] extends KeyBuilder\n ? (...args: Parameters<TEntries[K]>) => readonly [TKey, ...ReturnType<TEntries[K]>]\n : TEntries[K] extends readonly unknown[]\n ? readonly [TKey, ...TEntries[K]]\n : never;\n };\n\n for (const [name, entry] of Object.entries(entries) as [\n keyof TEntries,\n KeyBuilder | readonly unknown[],\n ][]) {\n if (typeof entry === \"function\") {\n (output as Record<string, unknown>)[name as string] = (...args: unknown[]) =>\n [scope, ...entry(...args)] as const;\n } else {\n (output as Record<string, unknown>)[name as string] = [scope, ...entry] as const;\n }\n }\n\n return output;\n}\n"],"mappings":";AAgBA,SAAgB,EAGd,GAAa,GAAmB;CAC9B,IAAM,IAAS,EAAE,KAAK,CAAC,CAAK,EAAW;CAQvC,KAAK,IAAM,CAAC,GAAM,MAAU,OAAO,QAAQ,CAAO,GAI9C,
|
|
1
|
+
{"version":3,"file":"create-query-keys.js","names":[],"sources":["../../src/query/create-query-keys.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype KeyBuilder = (...args: any[]) => readonly unknown[];\n\n/**\n * Build a typed query-key factory for a domain. Each entry can be a static\n * tuple or a function returning a tuple. The returned object is `as const`\n * so TanStack Query infers literal keys.\n *\n * @example\n * const userKeys = createQueryKeys(\"user\", {\n * me: () => [\"me\"] as const,\n * byId: (id: string) => [id] as const,\n * list: (filters: { page: number }) => [\"list\", filters] as const,\n * });\n * // userKeys.byId(\"42\") === [\"user\", \"42\"]\n */\nexport function createQueryKeys<\n TKey extends string,\n TEntries extends Record<string, KeyBuilder | readonly unknown[]>,\n>(scope: TKey, entries: TEntries) {\n const output = { all: [scope] as const } as { all: readonly [TKey] } & {\n [K in keyof TEntries]: TEntries[K] extends KeyBuilder\n ? (...args: Parameters<TEntries[K]>) => readonly [TKey, ...ReturnType<TEntries[K]>]\n : TEntries[K] extends readonly unknown[]\n ? readonly [TKey, ...TEntries[K]]\n : never;\n };\n\n for (const [name, entry] of Object.entries(entries) as [\n keyof TEntries,\n KeyBuilder | readonly unknown[],\n ][]) {\n if (typeof entry === \"function\") {\n (output as Record<string, unknown>)[name as string] = (...args: unknown[]) =>\n [scope, ...entry(...args)] as const;\n } else {\n (output as Record<string, unknown>)[name as string] = [scope, ...entry] as const;\n }\n }\n\n return output;\n}\n"],"mappings":";AAgBA,SAAgB,EAGd,GAAa,GAAmB;CAC9B,IAAM,IAAS,EAAE,KAAK,CAAC,CAAK,EAAW;CAQvC,KAAK,IAAM,CAAC,GAAM,MAAU,OAAO,QAAQ,CAAO,GAI9C,AAII,EAAoC,KAJpC,OAAO,KAAU,cACsC,GAAG,MACtD,CAAC,GAAO,GAAG,EAAM,GAAG,CAAI,CAAC,IAEyB,CAAC,GAAO,GAAG,CAAK;CAI9E,OAAO;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offline-persistence.cjs","names":[],"sources":["../../src/query/offline-persistence.ts"],"sourcesContent":["import { dehydrate, hydrate, type QueryClient } from \"@tanstack/react-query\";\nimport { createOfflineStore } from \"../offline/create-offline-store\";\n\n/** Options for {@link persistQueryClientOffline}. */\nexport interface OfflineQueryPersistenceOptions {\n /** The `QueryClient` to snapshot and restore. */\n queryClient: QueryClient;\n /** IndexedDB database name for the snapshot. Default `\"TempestQueryCache\"`. */\n databaseName?: string;\n /** Row key under which the snapshot is stored. Default `\"tanstack-query\"`. */\n key?: string;\n /**\n * Minimum gap between snapshot writes, in ms — cache churn is coalesced into\n * one trailing write per window. Default `1000`.\n */\n throttleMs?: number;\n}\n\n/** Handle returned by {@link persistQueryClientOffline}. */\nexport interface OfflineQueryPersistence {\n /**\n * Load the persisted snapshot into the `QueryClient`. Call once on boot,\n * before rendering queries, so cached data is available offline.\n */\n restore: () => Promise<void>;\n /** Write the current cache snapshot immediately (bypassing the throttle). */\n flush: () => Promise<void>;\n /** Stop persisting and drop the pending write. */\n unsubscribe: () => void;\n /** Delete the persisted snapshot (e.g. on logout). */\n clear: () => Promise<void>;\n}\n\ninterface Snapshot {\n id: string;\n state: ReturnType<typeof dehydrate>;\n}\n\n/**\n * Persist a TanStack `QueryClient` cache to IndexedDB (via\n * {@link createOfflineStore}) and restore it on boot — so a reload or a cold\n * offline start shows the last-known data instead of empty screens.\n *\n * Self-contained: uses `dehydrate`/`hydrate` from `@tanstack/react-query`\n * directly, so no `@tanstack/react-query-persist-client` dependency is needed.\n * Writes are throttled and subscribe to the query cache; call `unsubscribe` on\n * teardown. Dexie is a peer dependency of the offline store — install it.\n *\n * @param options - The client plus storage/throttle configuration.\n * @returns A handle with `restore`, `flush`, `clear` and `unsubscribe`.\n *\n * @example\n * const persistence = persistQueryClientOffline({ queryClient });\n * await persistence.restore(); // before first render\n * // ... later, on logout:\n * await persistence.clear();\n */\nexport function persistQueryClientOffline(\n options: OfflineQueryPersistenceOptions,\n): OfflineQueryPersistence {\n const { queryClient, throttleMs = 1000 } = options;\n const key = options.key ?? \"tanstack-query\";\n const store = createOfflineStore<Snapshot, string>({\n databaseName: options.databaseName ?? \"TempestQueryCache\",\n version: 1,\n tableName: \"cache\",\n indexes: \"&id\",\n keyPath: \"id\",\n });\n\n async function save(): Promise<void> {\n await store.put({ id: key, state: dehydrate(queryClient) });\n }\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n function schedule(): void {\n if (timer) return;\n timer = setTimeout(() => {\n timer = null;\n void save();\n }, throttleMs);\n }\n\n const unsubscribeCache = queryClient.getQueryCache().subscribe(schedule);\n\n return {\n async restore() {\n const snapshot = await store.get(key);\n if (snapshot) hydrate(queryClient, snapshot.state);\n },\n async flush() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n await save();\n },\n unsubscribe() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n unsubscribeCache();\n },\n async clear() {\n await store.delete(key);\n },\n };\n}\n"],"mappings":"8FAyDA,SAAgB,EACZ,EACuB,CACvB,GAAM,CAAE,cAAa,aAAa,KAAS,EACrC,EAAM,EAAQ,KAAO,iBACrB,EAAQ,EAAA,mBAAqC,CAC/C,aAAc,EAAQ,cAAgB,oBACtC,QAAS,EACT,UAAW,QACX,QAAS,MACT,QAAS,IACb,CAAC,EAED,eAAe,GAAsB,CACjC,MAAM,EAAM,IAAI,CAAE,GAAI,EAAK,OAAA,
|
|
1
|
+
{"version":3,"file":"offline-persistence.cjs","names":[],"sources":["../../src/query/offline-persistence.ts"],"sourcesContent":["import { dehydrate, hydrate, type QueryClient } from \"@tanstack/react-query\";\nimport { createOfflineStore } from \"../offline/create-offline-store\";\n\n/** Options for {@link persistQueryClientOffline}. */\nexport interface OfflineQueryPersistenceOptions {\n /** The `QueryClient` to snapshot and restore. */\n queryClient: QueryClient;\n /** IndexedDB database name for the snapshot. Default `\"TempestQueryCache\"`. */\n databaseName?: string;\n /** Row key under which the snapshot is stored. Default `\"tanstack-query\"`. */\n key?: string;\n /**\n * Minimum gap between snapshot writes, in ms — cache churn is coalesced into\n * one trailing write per window. Default `1000`.\n */\n throttleMs?: number;\n}\n\n/** Handle returned by {@link persistQueryClientOffline}. */\nexport interface OfflineQueryPersistence {\n /**\n * Load the persisted snapshot into the `QueryClient`. Call once on boot,\n * before rendering queries, so cached data is available offline.\n */\n restore: () => Promise<void>;\n /** Write the current cache snapshot immediately (bypassing the throttle). */\n flush: () => Promise<void>;\n /** Stop persisting and drop the pending write. */\n unsubscribe: () => void;\n /** Delete the persisted snapshot (e.g. on logout). */\n clear: () => Promise<void>;\n}\n\ninterface Snapshot {\n id: string;\n state: ReturnType<typeof dehydrate>;\n}\n\n/**\n * Persist a TanStack `QueryClient` cache to IndexedDB (via\n * {@link createOfflineStore}) and restore it on boot — so a reload or a cold\n * offline start shows the last-known data instead of empty screens.\n *\n * Self-contained: uses `dehydrate`/`hydrate` from `@tanstack/react-query`\n * directly, so no `@tanstack/react-query-persist-client` dependency is needed.\n * Writes are throttled and subscribe to the query cache; call `unsubscribe` on\n * teardown. Dexie is a peer dependency of the offline store — install it.\n *\n * @param options - The client plus storage/throttle configuration.\n * @returns A handle with `restore`, `flush`, `clear` and `unsubscribe`.\n *\n * @example\n * const persistence = persistQueryClientOffline({ queryClient });\n * await persistence.restore(); // before first render\n * // ... later, on logout:\n * await persistence.clear();\n */\nexport function persistQueryClientOffline(\n options: OfflineQueryPersistenceOptions,\n): OfflineQueryPersistence {\n const { queryClient, throttleMs = 1000 } = options;\n const key = options.key ?? \"tanstack-query\";\n const store = createOfflineStore<Snapshot, string>({\n databaseName: options.databaseName ?? \"TempestQueryCache\",\n version: 1,\n tableName: \"cache\",\n indexes: \"&id\",\n keyPath: \"id\",\n });\n\n async function save(): Promise<void> {\n await store.put({ id: key, state: dehydrate(queryClient) });\n }\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n function schedule(): void {\n if (timer) return;\n timer = setTimeout(() => {\n timer = null;\n void save();\n }, throttleMs);\n }\n\n const unsubscribeCache = queryClient.getQueryCache().subscribe(schedule);\n\n return {\n async restore() {\n const snapshot = await store.get(key);\n if (snapshot) hydrate(queryClient, snapshot.state);\n },\n async flush() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n await save();\n },\n unsubscribe() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n unsubscribeCache();\n },\n async clear() {\n await store.delete(key);\n },\n };\n}\n"],"mappings":"8FAyDA,SAAgB,EACZ,EACuB,CACvB,GAAM,CAAE,cAAa,aAAa,KAAS,EACrC,EAAM,EAAQ,KAAO,iBACrB,EAAQ,EAAA,mBAAqC,CAC/C,aAAc,EAAQ,cAAgB,oBACtC,QAAS,EACT,UAAW,QACX,QAAS,MACT,QAAS,IACb,CAAC,EAED,eAAe,GAAsB,CACjC,MAAM,EAAM,IAAI,CAAE,GAAI,EAAK,OAAA,EAAO,EAAA,UAAA,CAAU,CAAW,CAAE,CAAC,CAC9D,CAEA,IAAI,EAA8C,KAClD,SAAS,GAAiB,CAClB,AACJ,IAAQ,eAAiB,CACrB,EAAQ,KACR,EAAU,CACd,EAAG,CAAU,CACjB,CAEA,IAAM,EAAmB,EAAY,cAAc,CAAC,CAAC,UAAU,CAAQ,EAEvE,MAAO,CACH,MAAM,SAAU,CACZ,IAAM,EAAW,MAAM,EAAM,IAAI,CAAG,EAChC,IAAU,EAAA,EAAA,QAAA,CAAQ,EAAa,EAAS,KAAK,CACrD,EACA,MAAM,OAAQ,CACV,AAEI,KADA,aAAa,CAAK,EACV,MAEZ,MAAM,EAAK,CACf,EACA,aAAc,CACV,AAEI,KADA,aAAa,CAAK,EACV,MAEZ,EAAiB,CACrB,EACA,MAAM,OAAQ,CACV,MAAM,EAAM,OAAO,CAAG,CAC1B,CACJ,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-cursor-query.cjs","names":[],"sources":["../../src/query/use-cursor-query.ts"],"sourcesContent":["import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport type { InfiniteData, QueryKey, UseInfiniteQueryOptions } from \"@tanstack/react-query\";\n\nimport type { CursorPage, CursorParams } from \"./pagination\";\n\nexport interface UseCursorQueryOptions<T> extends Omit<\n UseInfiniteQueryOptions<\n CursorPage<T>,\n Error,\n InfiniteData<CursorPage<T>, string | null>,\n QueryKey,\n string | null\n >,\n \"queryKey\" | \"queryFn\" | \"initialPageParam\" | \"getNextPageParam\"\n> {\n /** Base query key — `limit`/sort is appended for cache isolation. */\n queryKey: QueryKey;\n /** Fetcher receiving the cursor params; return the backend envelope. */\n queryFn: (params: CursorParams) => Promise<CursorPage<T>> | CursorPage<T>;\n /** Batch size sent as `limit`. Default: 20. */\n limit?: number;\n /** Initial `order_by`. */\n orderBy?: string;\n /** Initial `ascending`. Default: false. */\n ascending?: boolean;\n}\n\nexport interface UseCursorQueryResult<T> {\n /** All rows fetched so far, flattened across batches. */\n items: T[];\n /** The raw batches, in fetch order. */\n pages: CursorPage<T>[];\n hasNextPage: boolean;\n isLoading: boolean;\n isFetchingNextPage: boolean;\n error: Error | null;\n /** Fetch the next batch (no-op when exhausted). */\n fetchNextPage: () => void;\n /** Refetch from the first batch. */\n refetch: () => void;\n}\n\n/**\n * Cursor-pagination hook over TanStack Query's `useInfiniteQuery` for the\n * Tempest `CursorPaginationSchema` envelope\n * (`{ items, next_cursor, has_more, limit }`).\n *\n * The opaque `next_cursor` is fed straight back as the next page param; the\n * loop stops when `has_more` is false (or `next_cursor` is null).\n *\n * @example\n * const feed = useCursorQuery<Post>({\n * queryKey: [\"feed\"],\n * limit: 30,\n * queryFn: (params) => postsService.listPosts(params),\n * });\n * // feed.items, feed.fetchNextPage(), feed.hasNextPage\n */\nexport function useCursorQuery<T>(options: UseCursorQueryOptions<T>): UseCursorQueryResult<T> {\n const { queryKey, queryFn, limit = 20, orderBy, ascending = false, ...queryOptions } = options;\n\n const query = useInfiniteQuery<\n CursorPage<T>,\n Error,\n InfiniteData<CursorPage<T>, string | null>,\n QueryKey,\n string | null\n >({\n ...queryOptions,\n queryKey: [...queryKey, { limit, orderBy, ascending }],\n initialPageParam: null,\n queryFn: ({ pageParam }) =>\n queryFn({ cursor: pageParam, limit, order_by: orderBy, ascending }),\n getNextPageParam: (last) => (last.has_more ? last.next_cursor : undefined),\n });\n\n const pages = query.data?.pages ?? [];\n\n return {\n items: pages.flatMap((p) => p.items),\n pages,\n hasNextPage: query.hasNextPage,\n isLoading: query.isLoading,\n isFetchingNextPage: query.isFetchingNextPage,\n error: query.error,\n fetchNextPage: () => void query.fetchNextPage(),\n refetch: () => void query.refetch(),\n };\n}\n"],"mappings":"uCA0DA,SAAgB,EAAkB,EAA4D,CAC1F,GAAM,CAAE,WAAU,UAAS,QAAQ,GAAI,UAAS,YAAY,GAAO,GAAG,GAAiB,EAEjF,GAAA,
|
|
1
|
+
{"version":3,"file":"use-cursor-query.cjs","names":[],"sources":["../../src/query/use-cursor-query.ts"],"sourcesContent":["import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport type { InfiniteData, QueryKey, UseInfiniteQueryOptions } from \"@tanstack/react-query\";\n\nimport type { CursorPage, CursorParams } from \"./pagination\";\n\nexport interface UseCursorQueryOptions<T> extends Omit<\n UseInfiniteQueryOptions<\n CursorPage<T>,\n Error,\n InfiniteData<CursorPage<T>, string | null>,\n QueryKey,\n string | null\n >,\n \"queryKey\" | \"queryFn\" | \"initialPageParam\" | \"getNextPageParam\"\n> {\n /** Base query key — `limit`/sort is appended for cache isolation. */\n queryKey: QueryKey;\n /** Fetcher receiving the cursor params; return the backend envelope. */\n queryFn: (params: CursorParams) => Promise<CursorPage<T>> | CursorPage<T>;\n /** Batch size sent as `limit`. Default: 20. */\n limit?: number;\n /** Initial `order_by`. */\n orderBy?: string;\n /** Initial `ascending`. Default: false. */\n ascending?: boolean;\n}\n\nexport interface UseCursorQueryResult<T> {\n /** All rows fetched so far, flattened across batches. */\n items: T[];\n /** The raw batches, in fetch order. */\n pages: CursorPage<T>[];\n hasNextPage: boolean;\n isLoading: boolean;\n isFetchingNextPage: boolean;\n error: Error | null;\n /** Fetch the next batch (no-op when exhausted). */\n fetchNextPage: () => void;\n /** Refetch from the first batch. */\n refetch: () => void;\n}\n\n/**\n * Cursor-pagination hook over TanStack Query's `useInfiniteQuery` for the\n * Tempest `CursorPaginationSchema` envelope\n * (`{ items, next_cursor, has_more, limit }`).\n *\n * The opaque `next_cursor` is fed straight back as the next page param; the\n * loop stops when `has_more` is false (or `next_cursor` is null).\n *\n * @example\n * const feed = useCursorQuery<Post>({\n * queryKey: [\"feed\"],\n * limit: 30,\n * queryFn: (params) => postsService.listPosts(params),\n * });\n * // feed.items, feed.fetchNextPage(), feed.hasNextPage\n */\nexport function useCursorQuery<T>(options: UseCursorQueryOptions<T>): UseCursorQueryResult<T> {\n const { queryKey, queryFn, limit = 20, orderBy, ascending = false, ...queryOptions } = options;\n\n const query = useInfiniteQuery<\n CursorPage<T>,\n Error,\n InfiniteData<CursorPage<T>, string | null>,\n QueryKey,\n string | null\n >({\n ...queryOptions,\n queryKey: [...queryKey, { limit, orderBy, ascending }],\n initialPageParam: null,\n queryFn: ({ pageParam }) =>\n queryFn({ cursor: pageParam, limit, order_by: orderBy, ascending }),\n getNextPageParam: (last) => (last.has_more ? last.next_cursor : undefined),\n });\n\n const pages = query.data?.pages ?? [];\n\n return {\n items: pages.flatMap((p) => p.items),\n pages,\n hasNextPage: query.hasNextPage,\n isLoading: query.isLoading,\n isFetchingNextPage: query.isFetchingNextPage,\n error: query.error,\n fetchNextPage: () => void query.fetchNextPage(),\n refetch: () => void query.refetch(),\n };\n}\n"],"mappings":"uCA0DA,SAAgB,EAAkB,EAA4D,CAC1F,GAAM,CAAE,WAAU,UAAS,QAAQ,GAAI,UAAS,YAAY,GAAO,GAAG,GAAiB,EAEjF,GAAA,EAAQ,EAAA,iBAAA,CAMZ,CACE,GAAG,EACH,SAAU,CAAC,GAAG,EAAU,CAAE,QAAO,UAAS,WAAU,CAAC,EACrD,iBAAkB,KAClB,SAAU,CAAE,eACR,EAAQ,CAAE,OAAQ,EAAW,QAAO,SAAU,EAAS,WAAU,CAAC,EACtE,iBAAmB,GAAU,EAAK,SAAW,EAAK,YAAc,IAAA,EACpE,CAAC,EAEK,EAAQ,EAAM,MAAM,OAAS,CAAC,EAEpC,MAAO,CACH,MAAO,EAAM,QAAS,GAAM,EAAE,KAAK,EACnC,QACA,YAAa,EAAM,YACnB,UAAW,EAAM,UACjB,mBAAoB,EAAM,mBAC1B,MAAO,EAAM,MACb,kBAAqB,KAAK,EAAM,cAAc,EAC9C,YAAe,KAAK,EAAM,QAAQ,CACtC,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-offline-mutation.cjs","names":[],"sources":["../../src/query/use-offline-mutation.ts"],"sourcesContent":["import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { QueryKey, UseMutationResult } from \"@tanstack/react-query\";\nimport type { OfflineSync, OutboxOp, SyncTrigger } from \"../offline\";\n\n/** The outbox entry a mutation's variables map to. */\nexport interface OutboxDraft<TPayload> {\n /** The mutation kind. */\n op: OutboxOp;\n /** Primary key of the affected record. */\n recordId: string;\n /** Record snapshot for `create`/`update` (omit for `delete`). */\n payload?: TPayload;\n}\n\n/**\n * Configuration for {@link useOfflineMutation}.\n *\n * @typeParam TVariables - The `mutate(variables)` input shape.\n * @typeParam TData - The cached query data optimistically patched.\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n */\nexport interface UseOfflineMutationOptions<TVariables, TData, TPayload> {\n /** The engine the mutation enqueues into. */\n sync: OfflineSync<TPayload>;\n /** Map `mutate` variables into an outbox entry. */\n toEntry: (variables: TVariables) => OutboxDraft<TPayload>;\n /**\n * Query key to optimistically patch and (optionally) invalidate. Omit to\n * only enqueue without touching the React Query cache.\n */\n queryKey?: QueryKey;\n /**\n * Produce the next cached value from the current one and the variables.\n * Runs in `onMutate`; the previous value is restored automatically if the\n * enqueue throws. Requires `queryKey`.\n */\n applyOptimistic?: (current: TData | undefined, variables: TVariables) => TData;\n /**\n * Trigger a flush after enqueueing. `true` (default) uses\n * `\"after-mutation\"`; pass a custom {@link SyncTrigger} string, or `false`\n * to leave flushing to the caller / auto-flush hooks.\n */\n flush?: boolean | SyncTrigger;\n /** Invalidate `queryKey` in `onSettled` so a later read refetches. Default `false`. */\n invalidate?: boolean;\n}\n\ninterface MutationContext<TData> {\n previous: TData | undefined;\n}\n\n/**\n * Optimistic mutation that writes to an {@link OfflineSync} outbox instead of\n * hitting the network directly, bridging the sync engine and TanStack Query.\n *\n * On `mutate` it enqueues the entry, optimistically patches the given query\n * cache key and kicks a flush; if the enqueue itself throws, the cache is\n * rolled back to its previous value. Server delivery happens later inside the\n * engine's flush loop, so the UI updates instantly and survives reloads and\n * offline periods.\n *\n * @typeParam TVariables - The `mutate(variables)` input shape.\n * @typeParam TData - The cached query data optimistically patched.\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param options - Engine, variables→entry mapping and cache wiring.\n * @returns The TanStack {@link UseMutationResult}; the mutation resolves to the\n * generated outbox entry id.\n *\n * @example\n * const addNote = useOfflineMutation({\n * sync: notesSync,\n * queryKey: [\"notes\"],\n * toEntry: (note: Note) => ({ op: \"create\", recordId: note.id, payload: note }),\n * applyOptimistic: (current: Note[] = [], note) => [...current, note],\n * });\n * addNote.mutate(newNote);\n */\nexport function useOfflineMutation<TVariables, TData = unknown, TPayload = unknown>(\n options: UseOfflineMutationOptions<TVariables, TData, TPayload>,\n): UseMutationResult<string, Error, TVariables, MutationContext<TData>> {\n const { sync, toEntry, queryKey, applyOptimistic, flush = true, invalidate = false } = options;\n const client = useQueryClient();\n\n return useMutation<string, Error, TVariables, MutationContext<TData>>({\n mutationFn: async (variables) => {\n const draft = toEntry(variables);\n const id = await sync.enqueue(draft.op, draft.recordId, draft.payload);\n if (flush !== false) {\n const trigger: SyncTrigger = flush === true ? \"after-mutation\" : flush;\n void sync.flush(trigger);\n }\n return id;\n },\n onMutate: async (variables) => {\n if (!queryKey || !applyOptimistic) return { previous: undefined };\n await client.cancelQueries({ queryKey });\n const previous = client.getQueryData<TData>(queryKey);\n client.setQueryData<TData>(queryKey, (current) => applyOptimistic(current, variables));\n return { previous };\n },\n onError: (_error, _variables, context) => {\n if (queryKey && context) client.setQueryData(queryKey, context.previous);\n },\n onSettled: () => {\n if (invalidate && queryKey) void client.invalidateQueries({ queryKey });\n },\n });\n}\n"],"mappings":"uCA6EA,SAAgB,EACZ,EACoE,CACpE,GAAM,CAAE,OAAM,UAAS,WAAU,kBAAiB,QAAQ,GAAM,aAAa,IAAU,EACjF,GAAA,
|
|
1
|
+
{"version":3,"file":"use-offline-mutation.cjs","names":[],"sources":["../../src/query/use-offline-mutation.ts"],"sourcesContent":["import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type { QueryKey, UseMutationResult } from \"@tanstack/react-query\";\nimport type { OfflineSync, OutboxOp, SyncTrigger } from \"../offline\";\n\n/** The outbox entry a mutation's variables map to. */\nexport interface OutboxDraft<TPayload> {\n /** The mutation kind. */\n op: OutboxOp;\n /** Primary key of the affected record. */\n recordId: string;\n /** Record snapshot for `create`/`update` (omit for `delete`). */\n payload?: TPayload;\n}\n\n/**\n * Configuration for {@link useOfflineMutation}.\n *\n * @typeParam TVariables - The `mutate(variables)` input shape.\n * @typeParam TData - The cached query data optimistically patched.\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n */\nexport interface UseOfflineMutationOptions<TVariables, TData, TPayload> {\n /** The engine the mutation enqueues into. */\n sync: OfflineSync<TPayload>;\n /** Map `mutate` variables into an outbox entry. */\n toEntry: (variables: TVariables) => OutboxDraft<TPayload>;\n /**\n * Query key to optimistically patch and (optionally) invalidate. Omit to\n * only enqueue without touching the React Query cache.\n */\n queryKey?: QueryKey;\n /**\n * Produce the next cached value from the current one and the variables.\n * Runs in `onMutate`; the previous value is restored automatically if the\n * enqueue throws. Requires `queryKey`.\n */\n applyOptimistic?: (current: TData | undefined, variables: TVariables) => TData;\n /**\n * Trigger a flush after enqueueing. `true` (default) uses\n * `\"after-mutation\"`; pass a custom {@link SyncTrigger} string, or `false`\n * to leave flushing to the caller / auto-flush hooks.\n */\n flush?: boolean | SyncTrigger;\n /** Invalidate `queryKey` in `onSettled` so a later read refetches. Default `false`. */\n invalidate?: boolean;\n}\n\ninterface MutationContext<TData> {\n previous: TData | undefined;\n}\n\n/**\n * Optimistic mutation that writes to an {@link OfflineSync} outbox instead of\n * hitting the network directly, bridging the sync engine and TanStack Query.\n *\n * On `mutate` it enqueues the entry, optimistically patches the given query\n * cache key and kicks a flush; if the enqueue itself throws, the cache is\n * rolled back to its previous value. Server delivery happens later inside the\n * engine's flush loop, so the UI updates instantly and survives reloads and\n * offline periods.\n *\n * @typeParam TVariables - The `mutate(variables)` input shape.\n * @typeParam TData - The cached query data optimistically patched.\n * @typeParam TPayload - Record snapshot carried by outbox entries.\n * @param options - Engine, variables→entry mapping and cache wiring.\n * @returns The TanStack {@link UseMutationResult}; the mutation resolves to the\n * generated outbox entry id.\n *\n * @example\n * const addNote = useOfflineMutation({\n * sync: notesSync,\n * queryKey: [\"notes\"],\n * toEntry: (note: Note) => ({ op: \"create\", recordId: note.id, payload: note }),\n * applyOptimistic: (current: Note[] = [], note) => [...current, note],\n * });\n * addNote.mutate(newNote);\n */\nexport function useOfflineMutation<TVariables, TData = unknown, TPayload = unknown>(\n options: UseOfflineMutationOptions<TVariables, TData, TPayload>,\n): UseMutationResult<string, Error, TVariables, MutationContext<TData>> {\n const { sync, toEntry, queryKey, applyOptimistic, flush = true, invalidate = false } = options;\n const client = useQueryClient();\n\n return useMutation<string, Error, TVariables, MutationContext<TData>>({\n mutationFn: async (variables) => {\n const draft = toEntry(variables);\n const id = await sync.enqueue(draft.op, draft.recordId, draft.payload);\n if (flush !== false) {\n const trigger: SyncTrigger = flush === true ? \"after-mutation\" : flush;\n void sync.flush(trigger);\n }\n return id;\n },\n onMutate: async (variables) => {\n if (!queryKey || !applyOptimistic) return { previous: undefined };\n await client.cancelQueries({ queryKey });\n const previous = client.getQueryData<TData>(queryKey);\n client.setQueryData<TData>(queryKey, (current) => applyOptimistic(current, variables));\n return { previous };\n },\n onError: (_error, _variables, context) => {\n if (queryKey && context) client.setQueryData(queryKey, context.previous);\n },\n onSettled: () => {\n if (invalidate && queryKey) void client.invalidateQueries({ queryKey });\n },\n });\n}\n"],"mappings":"uCA6EA,SAAgB,EACZ,EACoE,CACpE,GAAM,CAAE,OAAM,UAAS,WAAU,kBAAiB,QAAQ,GAAM,aAAa,IAAU,EACjF,GAAA,EAAS,EAAA,eAAA,CAAe,EAE9B,OAAA,EAAO,EAAA,YAAA,CAA+D,CAClE,WAAY,KAAO,IAAc,CAC7B,IAAM,EAAQ,EAAQ,CAAS,EACzB,EAAK,MAAM,EAAK,QAAQ,EAAM,GAAI,EAAM,SAAU,EAAM,OAAO,EACrE,GAAI,IAAU,GAAO,CACjB,IAAM,EAAuB,IAAU,GAAO,iBAAmB,EACjE,EAAU,MAAM,CAAO,CAC3B,CACA,OAAO,CACX,EACA,SAAU,KAAO,IAAc,CAC3B,GAAI,CAAC,GAAY,CAAC,EAAiB,MAAO,CAAE,SAAU,IAAA,EAAU,EAChE,MAAM,EAAO,cAAc,CAAE,UAAS,CAAC,EACvC,IAAM,EAAW,EAAO,aAAoB,CAAQ,EAEpD,OADA,EAAO,aAAoB,EAAW,GAAY,EAAgB,EAAS,CAAS,CAAC,EAC9E,CAAE,UAAS,CACtB,EACA,SAAU,EAAQ,EAAY,IAAY,CAClC,GAAY,GAAS,EAAO,aAAa,EAAU,EAAQ,QAAQ,CAC3E,EACA,cAAiB,CACT,GAAc,GAAU,EAAY,kBAAkB,CAAE,UAAS,CAAC,CAC1E,CACJ,CAAC,CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-paginated-query.cjs","names":[],"sources":["../../src/query/use-paginated-query.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { keepPreviousData, useQuery } from \"@tanstack/react-query\";\nimport type { QueryKey, UseQueryOptions } from \"@tanstack/react-query\";\n\nimport type { OffsetPage, OffsetParams } from \"./pagination\";\n\nexport interface UsePaginatedQueryOptions<T> extends Omit<\n UseQueryOptions<OffsetPage<T>, Error, OffsetPage<T>, QueryKey>,\n \"queryKey\" | \"queryFn\"\n> {\n /** Base query key — the current page/sort is appended for cache isolation. */\n queryKey: QueryKey;\n /** Fetcher receiving the offset params; return the backend envelope. */\n queryFn: (params: OffsetParams) => Promise<OffsetPage<T>> | OffsetPage<T>;\n /** Initial 1-based page. Default: 1. */\n initialPage?: number;\n /** Page size. Default: 20. */\n pageSize?: number;\n /**\n * Query-param name for the page size. fastapi-pagination uses `\"size\"`\n * (default); SDK `BasePaginationFilterSchema` configs may use `\"page_size\"`.\n */\n sizeParam?: \"size\" | \"page_size\";\n /** Initial `order_by` (only sent when set). */\n orderBy?: string;\n /** Initial `ascending` (only sent when `orderBy` is set). Default: false. */\n ascending?: boolean;\n}\n\nexport interface UsePaginatedQueryResult<T> {\n /** The current page envelope, or undefined while the first load is pending. */\n page: OffsetPage<T> | undefined;\n /** The rows of the current page (empty array while pending). */\n items: T[];\n /** Current 1-based page number (controlled by the hook). */\n pageNumber: number;\n /** Total page count from the last successful response. */\n pageCount: number;\n /** Total row count from the last successful response. */\n total: number;\n hasNext: boolean;\n hasPrev: boolean;\n isLoading: boolean;\n isFetching: boolean;\n error: Error | null;\n /** Jump to a specific 1-based page (clamped to >= 1). */\n setPage: (page: number) => void;\n /** Go to the next page when available. */\n next: () => void;\n /** Go to the previous page when available. */\n prev: () => void;\n /** Refetch the current page. */\n refetch: () => void;\n}\n\n/**\n * Offset-pagination hook over TanStack Query for the fastapi-pagination /\n * Tempest envelope (`{ items, total, page, size, pages }`).\n *\n * It owns the page state, sends `page` + the size param (`size` by default,\n * or `page_size` via `sizeParam`) plus optional `order_by`/`ascending` to your\n * fetcher, keeps the previous page visible while the next loads, and derives\n * `hasNext`/`hasPrev`/`pageCount`.\n *\n * @example\n * const users = usePaginatedQuery<User>({\n * queryKey: [\"users\"],\n * pageSize: 25,\n * queryFn: (params) => usersService.listUsers(params),\n * });\n * // users.items, users.next(), users.hasNext, users.pageCount\n */\nexport function usePaginatedQuery<T>(\n options: UsePaginatedQueryOptions<T>,\n): UsePaginatedQueryResult<T> {\n const {\n queryKey,\n queryFn,\n initialPage = 1,\n pageSize = 20,\n sizeParam = \"size\",\n orderBy,\n ascending = false,\n ...queryOptions\n } = options;\n\n const [pageNumber, setPageNumber] = useState(initialPage);\n\n const query = useQuery<OffsetPage<T>, Error>({\n ...queryOptions,\n queryKey: [...queryKey, { page: pageNumber, pageSize, sizeParam, orderBy, ascending }],\n queryFn: () => {\n const params: OffsetParams = { page: pageNumber, [sizeParam]: pageSize };\n if (orderBy) {\n params.order_by = orderBy;\n params.ascending = ascending;\n }\n return queryFn(params);\n },\n placeholderData: keepPreviousData,\n });\n\n const page = query.data;\n const pageCount = page?.pages ?? 0;\n const hasNext = pageNumber < pageCount;\n const hasPrev = pageNumber > 1;\n\n const setPage = useCallback((next: number) => setPageNumber(Math.max(1, next)), []);\n const next = useCallback(() => setPageNumber((p) => (p < pageCount ? p + 1 : p)), [pageCount]);\n const prev = useCallback(() => setPageNumber((p) => (p > 1 ? p - 1 : p)), []);\n\n return {\n page,\n items: page?.items ?? [],\n pageNumber,\n pageCount,\n total: page?.total ?? 0,\n hasNext,\n hasPrev,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n error: query.error,\n setPage,\n next,\n prev,\n refetch: () => void query.refetch(),\n };\n}\n"],"mappings":"0DAwEA,SAAgB,EACZ,EAC0B,CAC1B,GAAM,CACF,WACA,UACA,cAAc,EACd,WAAW,GACX,YAAY,OACZ,UACA,YAAY,GACZ,GAAG,GACH,EAEE,CAAC,EAAY,IAAA,
|
|
1
|
+
{"version":3,"file":"use-paginated-query.cjs","names":[],"sources":["../../src/query/use-paginated-query.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { keepPreviousData, useQuery } from \"@tanstack/react-query\";\nimport type { QueryKey, UseQueryOptions } from \"@tanstack/react-query\";\n\nimport type { OffsetPage, OffsetParams } from \"./pagination\";\n\nexport interface UsePaginatedQueryOptions<T> extends Omit<\n UseQueryOptions<OffsetPage<T>, Error, OffsetPage<T>, QueryKey>,\n \"queryKey\" | \"queryFn\"\n> {\n /** Base query key — the current page/sort is appended for cache isolation. */\n queryKey: QueryKey;\n /** Fetcher receiving the offset params; return the backend envelope. */\n queryFn: (params: OffsetParams) => Promise<OffsetPage<T>> | OffsetPage<T>;\n /** Initial 1-based page. Default: 1. */\n initialPage?: number;\n /** Page size. Default: 20. */\n pageSize?: number;\n /**\n * Query-param name for the page size. fastapi-pagination uses `\"size\"`\n * (default); SDK `BasePaginationFilterSchema` configs may use `\"page_size\"`.\n */\n sizeParam?: \"size\" | \"page_size\";\n /** Initial `order_by` (only sent when set). */\n orderBy?: string;\n /** Initial `ascending` (only sent when `orderBy` is set). Default: false. */\n ascending?: boolean;\n}\n\nexport interface UsePaginatedQueryResult<T> {\n /** The current page envelope, or undefined while the first load is pending. */\n page: OffsetPage<T> | undefined;\n /** The rows of the current page (empty array while pending). */\n items: T[];\n /** Current 1-based page number (controlled by the hook). */\n pageNumber: number;\n /** Total page count from the last successful response. */\n pageCount: number;\n /** Total row count from the last successful response. */\n total: number;\n hasNext: boolean;\n hasPrev: boolean;\n isLoading: boolean;\n isFetching: boolean;\n error: Error | null;\n /** Jump to a specific 1-based page (clamped to >= 1). */\n setPage: (page: number) => void;\n /** Go to the next page when available. */\n next: () => void;\n /** Go to the previous page when available. */\n prev: () => void;\n /** Refetch the current page. */\n refetch: () => void;\n}\n\n/**\n * Offset-pagination hook over TanStack Query for the fastapi-pagination /\n * Tempest envelope (`{ items, total, page, size, pages }`).\n *\n * It owns the page state, sends `page` + the size param (`size` by default,\n * or `page_size` via `sizeParam`) plus optional `order_by`/`ascending` to your\n * fetcher, keeps the previous page visible while the next loads, and derives\n * `hasNext`/`hasPrev`/`pageCount`.\n *\n * @example\n * const users = usePaginatedQuery<User>({\n * queryKey: [\"users\"],\n * pageSize: 25,\n * queryFn: (params) => usersService.listUsers(params),\n * });\n * // users.items, users.next(), users.hasNext, users.pageCount\n */\nexport function usePaginatedQuery<T>(\n options: UsePaginatedQueryOptions<T>,\n): UsePaginatedQueryResult<T> {\n const {\n queryKey,\n queryFn,\n initialPage = 1,\n pageSize = 20,\n sizeParam = \"size\",\n orderBy,\n ascending = false,\n ...queryOptions\n } = options;\n\n const [pageNumber, setPageNumber] = useState(initialPage);\n\n const query = useQuery<OffsetPage<T>, Error>({\n ...queryOptions,\n queryKey: [...queryKey, { page: pageNumber, pageSize, sizeParam, orderBy, ascending }],\n queryFn: () => {\n const params: OffsetParams = { page: pageNumber, [sizeParam]: pageSize };\n if (orderBy) {\n params.order_by = orderBy;\n params.ascending = ascending;\n }\n return queryFn(params);\n },\n placeholderData: keepPreviousData,\n });\n\n const page = query.data;\n const pageCount = page?.pages ?? 0;\n const hasNext = pageNumber < pageCount;\n const hasPrev = pageNumber > 1;\n\n const setPage = useCallback((next: number) => setPageNumber(Math.max(1, next)), []);\n const next = useCallback(() => setPageNumber((p) => (p < pageCount ? p + 1 : p)), [pageCount]);\n const prev = useCallback(() => setPageNumber((p) => (p > 1 ? p - 1 : p)), []);\n\n return {\n page,\n items: page?.items ?? [],\n pageNumber,\n pageCount,\n total: page?.total ?? 0,\n hasNext,\n hasPrev,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n error: query.error,\n setPage,\n next,\n prev,\n refetch: () => void query.refetch(),\n };\n}\n"],"mappings":"0DAwEA,SAAgB,EACZ,EAC0B,CAC1B,GAAM,CACF,WACA,UACA,cAAc,EACd,WAAW,GACX,YAAY,OACZ,UACA,YAAY,GACZ,GAAG,GACH,EAEE,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,CAAS,CAAW,EAElD,GAAA,EAAQ,EAAA,SAAA,CAA+B,CACzC,GAAG,EACH,SAAU,CAAC,GAAG,EAAU,CAAE,KAAM,EAAY,WAAU,YAAW,UAAS,WAAU,CAAC,EACrF,YAAe,CACX,IAAM,EAAuB,CAAE,KAAM,GAAa,GAAY,CAAS,EAKvE,OAJI,IACA,EAAO,SAAW,EAClB,EAAO,UAAY,GAEhB,EAAQ,CAAM,CACzB,EACA,gBAAiB,EAAA,gBACrB,CAAC,EAEK,EAAO,EAAM,KACb,EAAY,GAAM,OAAS,EAC3B,EAAU,EAAa,EACvB,EAAU,EAAa,EAEvB,GAAA,EAAU,EAAA,YAAA,CAAa,GAAiB,EAAc,KAAK,IAAI,EAAG,CAAI,CAAC,EAAG,CAAC,CAAC,EAC5E,GAAA,EAAO,EAAA,YAAA,KAAkB,EAAe,GAAO,EAAI,EAAY,EAAI,EAAI,CAAE,EAAG,CAAC,CAAS,CAAC,EACvF,GAAA,EAAO,EAAA,YAAA,KAAkB,EAAe,GAAO,EAAI,EAAI,EAAI,EAAI,CAAE,EAAG,CAAC,CAAC,EAE5E,MAAO,CACH,OACA,MAAO,GAAM,OAAS,CAAC,EACvB,aACA,YACA,MAAO,GAAM,OAAS,EACtB,UACA,UACA,UAAW,EAAM,UACjB,WAAY,EAAM,WAClB,MAAO,EAAM,MACb,UACA,OACA,OACA,YAAe,KAAK,EAAM,QAAQ,CACtC,CACJ"}
|
|
@@ -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,redirectTo:n,children:i}){return(0,r.jsx)(t.RouteGuard,{when:
|
|
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,redirectTo:n,children:i}){let a=typeof e==`function`?e():e;return(0,r.jsx)(t.RouteGuard,{when:a,redirectTo:n,children:i})}function l(e){return e.map((e,t)=>{let n=e.element;if(e.lazy){let t=s(e);n=(0,r.jsx)(t,{})}return e.guard!==void 0&&(n=(0,r.jsx)(c,{guard:e.guard,redirectTo:e.redirectTo,children:n})),e.index?(0,r.jsx)(i.Route,{index:!0,element:n},`index-${t}`):(0,r.jsx)(i.Route,{path:e.path,element:n,caseSensitive:e.caseSensitive,children:e.children?l(e.children):null},e.path??`route-${t}`)})}var u={browser:i.BrowserRouter,hash:i.HashRouter,memory:i.MemoryRouter};function d({routes:e,router:t=`browser`,basename:a,initialEntries:o,fallback:s=null}){let c=(0,n.useMemo)(()=>l(e),[e]),d=u[t];return(0,r.jsx)(d,{...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=d,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 | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): 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 guard={route.guard} redirectTo={route.redirectTo}>\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) : 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 /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7, declarative mode) from a {@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), [routes]);\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,CAEA,SAAS,EAAe,CACpB,QACA,aACA,YAKD,
|
|
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 | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): 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 guard={route.guard} redirectTo={route.redirectTo}>\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) : 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 /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7, declarative mode) from a {@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), [routes]);\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,CAEA,SAAS,EAAe,CACpB,QACA,aACA,YAKD,CACC,IAAM,EAAU,OAAO,GAAU,WAAa,EAAM,EAAI,EACxD,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,WAAD,CAAY,KAAM,EAAqB,aAClC,UACO,CAAA,CAEpB,CAEA,SAAS,EAAgB,EAAyC,CAC9D,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,CAaA,OAZI,EAAM,QAAU,IAAA,KAChB,GACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,MAAO,EAAM,MAAO,WAAY,EAAM,WACjD,SAAA,CACW,CAAA,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,QAAQ,EAAI,IACjD,EANE,EAAM,MAAQ,SAAS,GAMzB,CAEf,CAAC,CACL,CAEA,IAAM,EAAoD,CACtD,QAAS,EAAA,cACT,KAAM,EAAA,WACN,OAAQ,EAAA,YACZ,EAwBA,SAAgB,EAAU,CACtB,SACA,SAAS,UACT,WACA,iBACA,WAAW,MACI,CACf,IAAM,GAAA,EAAO,EAAA,QAAA,KAAc,EAAgB,CAAM,EAAG,CAAC,CAAM,CAAC,EACtD,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
|
@@ -13,8 +13,9 @@ function f(t) {
|
|
|
13
13
|
return n || (n = e(t.lazy), d.set(t, n)), n;
|
|
14
14
|
}
|
|
15
15
|
function p({ guard: e, redirectTo: n, children: r }) {
|
|
16
|
+
let a = typeof e == "function" ? e() : e;
|
|
16
17
|
return /* @__PURE__ */ i(t, {
|
|
17
|
-
when:
|
|
18
|
+
when: a,
|
|
18
19
|
redirectTo: n,
|
|
19
20
|
children: r
|
|
20
21
|
});
|
|
@@ -22,7 +23,11 @@ function p({ guard: e, redirectTo: n, children: r }) {
|
|
|
22
23
|
function m(e) {
|
|
23
24
|
return e.map((e, t) => {
|
|
24
25
|
let n = e.element;
|
|
25
|
-
|
|
26
|
+
if (e.lazy) {
|
|
27
|
+
let t = f(e);
|
|
28
|
+
n = /* @__PURE__ */ i(t, {});
|
|
29
|
+
}
|
|
30
|
+
return e.guard !== void 0 && (n = /* @__PURE__ */ i(p, {
|
|
26
31
|
guard: e.guard,
|
|
27
32
|
redirectTo: e.redirectTo,
|
|
28
33
|
children: n
|
|
@@ -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 | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): 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 guard={route.guard} redirectTo={route.redirectTo}>\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) : 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 /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7, declarative mode) from a {@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), [routes]);\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;AAEA,SAAS,EAAe,EACpB,UACA,eACA,eAKD;
|
|
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 | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): 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 guard={route.guard} redirectTo={route.redirectTo}>\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) : 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 /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7, declarative mode) from a {@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), [routes]);\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;AAEA,SAAS,EAAe,EACpB,UACA,eACA,eAKD;CACC,IAAM,IAAU,OAAO,KAAU,aAAa,EAAM,IAAI;CACxD,OACI,kBAAC,GAAD;EAAY,MAAM;EAAqB;EAClC;CACO,CAAA;AAEpB;AAEA,SAAS,EAAgB,GAAyC;CAC9D,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;EAaA,OAZI,EAAM,UAAU,KAAA,MAChB,IACI,kBAAC,GAAD;GAAgB,OAAO,EAAM;GAAO,YAAY,EAAM;GACjD,UAAA;EACW,CAAA,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,QAAQ,IAAI;EACjD,GANE,EAAM,QAAQ,SAAS,GAMzB;CAEf,CAAC;AACL;AAEA,IAAM,IAAoD;CACtD,SAAS;CACT,MAAM;CACN,QAAQ;AACZ;AAwBA,SAAgB,EAAU,EACtB,WACA,YAAS,WACT,aACA,mBACA,cAAW,QACI;CACf,IAAM,IAAO,QAAc,EAAgB,CAAM,GAAG,CAAC,CAAM,CAAC,GACtD,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-stream.cjs","names":[],"sources":["../../src/sse/use-event-stream.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport {\n createEventStream,\n type CreateEventStreamOptions,\n type EventStreamMessage,\n type EventStreamStatus,\n} from \"./create-event-stream\";\n\nexport interface UseEventStreamOptions<T> extends Omit<\n CreateEventStreamOptions<T>,\n \"onStatusChange\"\n> {\n /** When false, the stream is not opened. Useful for \"wait for auth\". Default: true. */\n enabled?: boolean;\n}\n\nexport interface UseEventStreamResult<T> {\n status: EventStreamStatus;\n /** Last message received (excluding heartbeats). */\n lastMessage: EventStreamMessage<T> | null;\n /** Force a reconnect. */\n reconnect: () => void;\n}\n\n/**\n * React hook wrapper around {@link createEventStream}. Connection lifecycle is\n * tied to the component (and the `url`/`enabled` dependencies); the stream\n * closes on unmount.\n *\n * @example\n * useEventStream<Notification>(`${API}/notifications/stream`, {\n * enabled: !!user,\n * withCredentials: true,\n * onMessage: ({ data }) => addNotification(data),\n * });\n */\nexport function useEventStream<T = unknown>(\n url: string,\n options: UseEventStreamOptions<T> = {},\n): UseEventStreamResult<T> {\n const { enabled = true, onMessage, ...rest } = options;\n const [status, setStatus] = useState<EventStreamStatus>(\"idle\");\n const [lastMessage, setLastMessage] = useState<EventStreamMessage<T> | null>(null);\n const reconnectRef = useRef<(() => void) | null>(null);\n\n const onMessageRef = useRef(onMessage);\n useEffect(() => {\n onMessageRef.current = onMessage;\n }, [onMessage]);\n\n useEffect(() => {\n if (!enabled || !url) {\n setStatus(\"idle\");\n return;\n }\n\n const controller = createEventStream<T>(url, {\n ...rest,\n onStatusChange: setStatus,\n onMessage: (message) => {\n setLastMessage(message);\n onMessageRef.current?.(message);\n },\n });\n reconnectRef.current = controller.reconnect;\n\n return () => {\n controller.close();\n reconnectRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, enabled]);\n\n return {\n status,\n lastMessage,\n reconnect: () => reconnectRef.current?.(),\n };\n}\n"],"mappings":"oEAoCA,SAAgB,EACZ,EACA,EAAoC,CAAC,EACd,CACvB,GAAM,CAAE,UAAU,GAAM,YAAW,GAAG,GAAS,EACzC,CAAC,EAAQ,IAAA,
|
|
1
|
+
{"version":3,"file":"use-event-stream.cjs","names":[],"sources":["../../src/sse/use-event-stream.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport {\n createEventStream,\n type CreateEventStreamOptions,\n type EventStreamMessage,\n type EventStreamStatus,\n} from \"./create-event-stream\";\n\nexport interface UseEventStreamOptions<T> extends Omit<\n CreateEventStreamOptions<T>,\n \"onStatusChange\"\n> {\n /** When false, the stream is not opened. Useful for \"wait for auth\". Default: true. */\n enabled?: boolean;\n}\n\nexport interface UseEventStreamResult<T> {\n status: EventStreamStatus;\n /** Last message received (excluding heartbeats). */\n lastMessage: EventStreamMessage<T> | null;\n /** Force a reconnect. */\n reconnect: () => void;\n}\n\n/**\n * React hook wrapper around {@link createEventStream}. Connection lifecycle is\n * tied to the component (and the `url`/`enabled` dependencies); the stream\n * closes on unmount.\n *\n * @example\n * useEventStream<Notification>(`${API}/notifications/stream`, {\n * enabled: !!user,\n * withCredentials: true,\n * onMessage: ({ data }) => addNotification(data),\n * });\n */\nexport function useEventStream<T = unknown>(\n url: string,\n options: UseEventStreamOptions<T> = {},\n): UseEventStreamResult<T> {\n const { enabled = true, onMessage, ...rest } = options;\n const [status, setStatus] = useState<EventStreamStatus>(\"idle\");\n const [lastMessage, setLastMessage] = useState<EventStreamMessage<T> | null>(null);\n const reconnectRef = useRef<(() => void) | null>(null);\n\n const onMessageRef = useRef(onMessage);\n useEffect(() => {\n onMessageRef.current = onMessage;\n }, [onMessage]);\n\n useEffect(() => {\n if (!enabled || !url) {\n setStatus(\"idle\");\n return;\n }\n\n const controller = createEventStream<T>(url, {\n ...rest,\n onStatusChange: setStatus,\n onMessage: (message) => {\n setLastMessage(message);\n onMessageRef.current?.(message);\n },\n });\n reconnectRef.current = controller.reconnect;\n\n return () => {\n controller.close();\n reconnectRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [url, enabled]);\n\n return {\n status,\n lastMessage,\n reconnect: () => reconnectRef.current?.(),\n };\n}\n"],"mappings":"oEAoCA,SAAgB,EACZ,EACA,EAAoC,CAAC,EACd,CACvB,GAAM,CAAE,UAAU,GAAM,YAAW,GAAG,GAAS,EACzC,CAAC,EAAQ,IAAA,EAAa,EAAA,SAAA,CAA4B,MAAM,EACxD,CAAC,EAAa,IAAA,EAAkB,EAAA,SAAA,CAAuC,IAAI,EAC3E,GAAA,EAAe,EAAA,OAAA,CAA4B,IAAI,EAE/C,GAAA,EAAe,EAAA,OAAA,CAAO,CAAS,EA4BrC,OA3BA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAa,QAAU,CAC3B,EAAG,CAAC,CAAS,CAAC,GAEd,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,GAAW,CAAC,EAAK,CAClB,EAAU,MAAM,EAChB,MACJ,CAEA,IAAM,EAAa,EAAA,kBAAqB,EAAK,CACzC,GAAG,EACH,eAAgB,EAChB,UAAY,GAAY,CACpB,EAAe,CAAO,EACtB,EAAa,UAAU,CAAO,CAClC,CACJ,CAAC,EAGD,MAFA,GAAa,QAAU,EAAW,cAErB,CACT,EAAW,MAAM,EACjB,EAAa,QAAU,IAC3B,CAEJ,EAAG,CAAC,EAAK,CAAO,CAAC,EAEV,CACH,SACA,cACA,cAAiB,EAAa,UAAU,CAC5C,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-store.cjs","names":[],"sources":["../../src/store/create-store.ts"],"sourcesContent":["import { create } from \"zustand\";\nimport type { StateCreator, StoreApi, UseBoundStore } from \"zustand\";\nimport { persist, createJSONStorage } from \"zustand/middleware\";\nimport type { PersistOptions } from \"zustand/middleware\";\n\n/**\n * Persistence options for {@link createStore}. Mirrors the subset of Zustand's\n * `persist` middleware that apps usually need, with sensible Tempest defaults.\n */\nexport interface CreateStorePersistOptions<T> {\n /** Storage key (required to enable persistence). */\n name: string;\n /** Which Web Storage to use (default: `\"local\"`). */\n storage?: \"local\" | \"session\";\n /**\n * Pick the slice of state to persist. Defaults to persisting the whole\n * state. Use this to avoid writing transient/derived fields.\n */\n partialize?: PersistOptions<T, Partial<T>>[\"partialize\"];\n /** Persisted schema version, forwarded to Zustand for migrations. */\n version?: number;\n /** Migration function forwarded to Zustand's `persist` middleware. */\n migrate?: PersistOptions<T, Partial<T>>[\"migrate\"];\n}\n\n/**\n * Options accepted by {@link createStore}.\n */\nexport interface CreateStoreOptions<T> {\n /** Enable `localStorage`/`sessionStorage` persistence for the store. */\n persist?: CreateStorePersistOptions<T>;\n}\n\n/**\n * Create a typed Zustand store with optional `persist` middleware, wired with\n * Tempest defaults. This is the generic counterpart to `createAuthStore`: use\n * it for any domain slice (cart, preferences, wizard state, …) without\n * re-writing the persistence boilerplate in every app.\n *\n * @typeParam T - The store state shape (state + actions).\n * @param initializer - Standard Zustand `StateCreator` (`(set, get) => state`).\n * @param options - Optional persistence configuration.\n * @returns A bound Zustand hook (`useStore`) with the usual `getState`/`setState`/`subscribe` API.\n *\n * @example\n * interface CartState {\n * items: string[];\n * add: (id: string) => void;\n * clear: () => void;\n * }\n *\n * const useCart = createStore<CartState>(\n * (set) => ({\n * items: [],\n * add: (id) => set((s) => ({ items: [...s.items, id] })),\n * clear: () => set({ items: [] }),\n * }),\n * { persist: { name: \"cart\", partialize: (s) => ({ items: s.items }) } },\n * );\n */\nexport function createStore<T>(\n initializer: StateCreator<T, [], []>,\n options: CreateStoreOptions<T> = {},\n): UseBoundStore<StoreApi<T>> {\n if (!options.persist) {\n return create<T>()(initializer);\n }\n\n const { name, storage = \"local\", partialize, version, migrate } = options.persist;\n const storageImpl = storage === \"session\" ? () => sessionStorage : () => localStorage;\n\n return create<T>()(\n persist(initializer, {\n name,\n storage: createJSONStorage(storageImpl),\n ...(partialize ? { partialize } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(migrate ? { migrate } : {}),\n }),\n );\n}\n"],"mappings":"yDA4DA,SAAgB,EACZ,EACA,EAAiC,CAAC,EACR,CAC1B,GAAI,CAAC,EAAQ,QACT,OAAA,
|
|
1
|
+
{"version":3,"file":"create-store.cjs","names":[],"sources":["../../src/store/create-store.ts"],"sourcesContent":["import { create } from \"zustand\";\nimport type { StateCreator, StoreApi, UseBoundStore } from \"zustand\";\nimport { persist, createJSONStorage } from \"zustand/middleware\";\nimport type { PersistOptions } from \"zustand/middleware\";\n\n/**\n * Persistence options for {@link createStore}. Mirrors the subset of Zustand's\n * `persist` middleware that apps usually need, with sensible Tempest defaults.\n */\nexport interface CreateStorePersistOptions<T> {\n /** Storage key (required to enable persistence). */\n name: string;\n /** Which Web Storage to use (default: `\"local\"`). */\n storage?: \"local\" | \"session\";\n /**\n * Pick the slice of state to persist. Defaults to persisting the whole\n * state. Use this to avoid writing transient/derived fields.\n */\n partialize?: PersistOptions<T, Partial<T>>[\"partialize\"];\n /** Persisted schema version, forwarded to Zustand for migrations. */\n version?: number;\n /** Migration function forwarded to Zustand's `persist` middleware. */\n migrate?: PersistOptions<T, Partial<T>>[\"migrate\"];\n}\n\n/**\n * Options accepted by {@link createStore}.\n */\nexport interface CreateStoreOptions<T> {\n /** Enable `localStorage`/`sessionStorage` persistence for the store. */\n persist?: CreateStorePersistOptions<T>;\n}\n\n/**\n * Create a typed Zustand store with optional `persist` middleware, wired with\n * Tempest defaults. This is the generic counterpart to `createAuthStore`: use\n * it for any domain slice (cart, preferences, wizard state, …) without\n * re-writing the persistence boilerplate in every app.\n *\n * @typeParam T - The store state shape (state + actions).\n * @param initializer - Standard Zustand `StateCreator` (`(set, get) => state`).\n * @param options - Optional persistence configuration.\n * @returns A bound Zustand hook (`useStore`) with the usual `getState`/`setState`/`subscribe` API.\n *\n * @example\n * interface CartState {\n * items: string[];\n * add: (id: string) => void;\n * clear: () => void;\n * }\n *\n * const useCart = createStore<CartState>(\n * (set) => ({\n * items: [],\n * add: (id) => set((s) => ({ items: [...s.items, id] })),\n * clear: () => set({ items: [] }),\n * }),\n * { persist: { name: \"cart\", partialize: (s) => ({ items: s.items }) } },\n * );\n */\nexport function createStore<T>(\n initializer: StateCreator<T, [], []>,\n options: CreateStoreOptions<T> = {},\n): UseBoundStore<StoreApi<T>> {\n if (!options.persist) {\n return create<T>()(initializer);\n }\n\n const { name, storage = \"local\", partialize, version, migrate } = options.persist;\n const storageImpl = storage === \"session\" ? () => sessionStorage : () => localStorage;\n\n return create<T>()(\n persist(initializer, {\n name,\n storage: createJSONStorage(storageImpl),\n ...(partialize ? { partialize } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(migrate ? { migrate } : {}),\n }),\n );\n}\n"],"mappings":"yDA4DA,SAAgB,EACZ,EACA,EAAiC,CAAC,EACR,CAC1B,GAAI,CAAC,EAAQ,QACT,OAAA,EAAO,EAAA,OAAA,CAAU,CAAC,CAAC,CAAW,EAGlC,GAAM,CAAE,OAAM,UAAU,QAAS,aAAY,UAAS,WAAY,EAAQ,QACpE,EAAc,IAAY,cAAkB,mBAAuB,aAEzE,OAAA,EAAO,EAAA,OAAA,CAAU,CAAC,EAAA,EACd,EAAA,QAAA,CAAQ,EAAa,CACjB,OACA,SAAA,EAAS,EAAA,kBAAA,CAAkB,CAAW,EACtC,GAAI,EAAa,CAAE,YAAW,EAAI,CAAC,EACnC,GAAI,IAAY,IAAA,GAA0B,CAAC,EAAf,CAAE,SAAQ,EACtC,GAAI,EAAU,CAAE,SAAQ,EAAI,CAAC,CACjC,CAAC,CACL,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tabular-predictor.cjs","names":[],"sources":["../../src/tabular/use-tabular-predictor.ts"],"sourcesContent":["/**\n * React binding for {@link TabularPredictor}.\n *\n * Loading a model is async, cancellable, and has to be undone on unmount —\n * three things every component that touches inference gets wrong the same\n * way. The hook owns that lifecycle so a component only deals with\n * `status` and `predict`.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { fetchModelBytes, type ModelCacheOptions } from \"./cache\";\nimport { TabularPredictor } from \"./predictor\";\nimport type {\n FeatureRow,\n TabularModelSource,\n TabularPrediction,\n TabularPredictorOptions,\n} from \"./types\";\n\n/** Lifecycle of the model behind the hook. */\nexport type TabularPredictorStatus = \"idle\" | \"loading\" | \"ready\" | \"error\";\n\n/** Options for {@link useTabularPredictor}. */\nexport interface UseTabularPredictorOptions extends TabularPredictorOptions {\n /**\n * Cache the model bytes on the device, so later loads work offline.\n *\n * On by default when the source is a URL: an app that runs inference in\n * the browser almost always wants it to keep working without a network,\n * and the failure mode of not caching only shows up in a tunnel.\n */\n readonly cache?: boolean | ModelCacheOptions;\n}\n\n/** What {@link useTabularPredictor} returns. */\nexport interface UseTabularPredictorResult {\n /** The loaded predictor, or `null` while loading or on error. */\n readonly predictor: TabularPredictor | null;\n /** Where the load is. */\n readonly status: TabularPredictorStatus;\n /** Why the load failed. */\n readonly error: Error | null;\n /** Whether the model is loaded and can answer. */\n readonly isReady: boolean;\n /**\n * Predict for a batch of rows.\n *\n * @throws When called before the model is ready — awaiting `isReady`\n * is the caller's job, and a silent empty result would hide the bug.\n */\n readonly predict: (rows: readonly FeatureRow[]) => Promise<TabularPrediction>;\n /** Load the model again, e.g. after a failure or a new version. */\n readonly reload: () => void;\n}\n\n/**\n * Load a tabular model and keep it for the component's lifetime.\n *\n * @example\n * ```tsx\n * function RiskWidget() {\n * const { predict, isReady } = useTabularPredictor(\"/models/risk-v3.onnx\");\n * const [score, setScore] = useState<number | null>(null);\n *\n * async function onSubmit(features: number[]) {\n * const { probabilities } = await predict([features]);\n * setScore(probabilities[0]?.[1] ?? null);\n * }\n *\n * return <button disabled={!isReady} onClick={() => onSubmit([1, 2, 3, 4])}>Score</button>;\n * }\n * ```\n *\n * @param source Model URL, or the bytes when the app already has them.\n * Pass `null` to hold off loading (a gate, a lazy tab).\n * @param options Predictor options plus caching.\n * @returns The predictor, its status, and a `predict` bound to it.\n */\nexport function useTabularPredictor(\n source: TabularModelSource | null,\n options: UseTabularPredictorOptions = {},\n): UseTabularPredictorResult {\n const [predictor, setPredictor] = useState<TabularPredictor | null>(null);\n const [status, setStatus] = useState<TabularPredictorStatus>(\"idle\");\n const [error, setError] = useState<Error | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n const optionsRef = useRef(options);\n\n useEffect(() => {\n optionsRef.current = options;\n });\n\n useEffect(() => {\n if (source === null) {\n setStatus(\"idle\");\n return;\n }\n\n let cancelled = false;\n let loaded: TabularPredictor | null = null;\n\n setStatus(\"loading\");\n setError(null);\n\n void (async () => {\n try {\n const current = optionsRef.current;\n const cache = current.cache ?? true;\n const bytes =\n typeof source === \"string\" && cache !== false\n ? await fetchModelBytes(source, typeof cache === \"object\" ? cache : {})\n : source;\n const created = await TabularPredictor.create(bytes, {\n providers: current.providers,\n warmup: current.warmup,\n sessionOptions: current.sessionOptions,\n });\n loaded = created;\n if (cancelled) {\n await created.dispose();\n return;\n }\n setPredictor(created);\n setStatus(\"ready\");\n } catch (caught) {\n if (cancelled) return;\n setPredictor(null);\n setError(caught instanceof Error ? caught : new Error(String(caught)));\n setStatus(\"error\");\n }\n })();\n\n return () => {\n cancelled = true;\n setPredictor(null);\n void loaded?.dispose();\n };\n }, [source, attempt]);\n\n const predict = useCallback(\n async (rows: readonly FeatureRow[]): Promise<TabularPrediction> => {\n if (predictor === null) {\n throw new Error(\n \"predict() was called before the model finished loading. \" +\n \"Gate on `isReady`.\",\n );\n }\n return await predictor.predict(rows);\n },\n [predictor],\n );\n\n const reload = useCallback(() => setAttempt((value) => value + 1), []);\n\n return {\n predictor,\n status,\n error,\n isReady: status === \"ready\" && predictor !== null,\n predict,\n reload,\n };\n}\n"],"mappings":"mFA+EA,SAAgB,EACZ,EACA,EAAsC,CAAC,EACd,CACzB,GAAM,CAAC,EAAW,IAAA,
|
|
1
|
+
{"version":3,"file":"use-tabular-predictor.cjs","names":[],"sources":["../../src/tabular/use-tabular-predictor.ts"],"sourcesContent":["/**\n * React binding for {@link TabularPredictor}.\n *\n * Loading a model is async, cancellable, and has to be undone on unmount —\n * three things every component that touches inference gets wrong the same\n * way. The hook owns that lifecycle so a component only deals with\n * `status` and `predict`.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { fetchModelBytes, type ModelCacheOptions } from \"./cache\";\nimport { TabularPredictor } from \"./predictor\";\nimport type {\n FeatureRow,\n TabularModelSource,\n TabularPrediction,\n TabularPredictorOptions,\n} from \"./types\";\n\n/** Lifecycle of the model behind the hook. */\nexport type TabularPredictorStatus = \"idle\" | \"loading\" | \"ready\" | \"error\";\n\n/** Options for {@link useTabularPredictor}. */\nexport interface UseTabularPredictorOptions extends TabularPredictorOptions {\n /**\n * Cache the model bytes on the device, so later loads work offline.\n *\n * On by default when the source is a URL: an app that runs inference in\n * the browser almost always wants it to keep working without a network,\n * and the failure mode of not caching only shows up in a tunnel.\n */\n readonly cache?: boolean | ModelCacheOptions;\n}\n\n/** What {@link useTabularPredictor} returns. */\nexport interface UseTabularPredictorResult {\n /** The loaded predictor, or `null` while loading or on error. */\n readonly predictor: TabularPredictor | null;\n /** Where the load is. */\n readonly status: TabularPredictorStatus;\n /** Why the load failed. */\n readonly error: Error | null;\n /** Whether the model is loaded and can answer. */\n readonly isReady: boolean;\n /**\n * Predict for a batch of rows.\n *\n * @throws When called before the model is ready — awaiting `isReady`\n * is the caller's job, and a silent empty result would hide the bug.\n */\n readonly predict: (rows: readonly FeatureRow[]) => Promise<TabularPrediction>;\n /** Load the model again, e.g. after a failure or a new version. */\n readonly reload: () => void;\n}\n\n/**\n * Load a tabular model and keep it for the component's lifetime.\n *\n * @example\n * ```tsx\n * function RiskWidget() {\n * const { predict, isReady } = useTabularPredictor(\"/models/risk-v3.onnx\");\n * const [score, setScore] = useState<number | null>(null);\n *\n * async function onSubmit(features: number[]) {\n * const { probabilities } = await predict([features]);\n * setScore(probabilities[0]?.[1] ?? null);\n * }\n *\n * return <button disabled={!isReady} onClick={() => onSubmit([1, 2, 3, 4])}>Score</button>;\n * }\n * ```\n *\n * @param source Model URL, or the bytes when the app already has them.\n * Pass `null` to hold off loading (a gate, a lazy tab).\n * @param options Predictor options plus caching.\n * @returns The predictor, its status, and a `predict` bound to it.\n */\nexport function useTabularPredictor(\n source: TabularModelSource | null,\n options: UseTabularPredictorOptions = {},\n): UseTabularPredictorResult {\n const [predictor, setPredictor] = useState<TabularPredictor | null>(null);\n const [status, setStatus] = useState<TabularPredictorStatus>(\"idle\");\n const [error, setError] = useState<Error | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n const optionsRef = useRef(options);\n\n useEffect(() => {\n optionsRef.current = options;\n });\n\n useEffect(() => {\n if (source === null) {\n setStatus(\"idle\");\n return;\n }\n\n let cancelled = false;\n let loaded: TabularPredictor | null = null;\n\n setStatus(\"loading\");\n setError(null);\n\n void (async () => {\n try {\n const current = optionsRef.current;\n const cache = current.cache ?? true;\n const bytes =\n typeof source === \"string\" && cache !== false\n ? await fetchModelBytes(source, typeof cache === \"object\" ? cache : {})\n : source;\n const created = await TabularPredictor.create(bytes, {\n providers: current.providers,\n warmup: current.warmup,\n sessionOptions: current.sessionOptions,\n });\n loaded = created;\n if (cancelled) {\n await created.dispose();\n return;\n }\n setPredictor(created);\n setStatus(\"ready\");\n } catch (caught) {\n if (cancelled) return;\n setPredictor(null);\n setError(caught instanceof Error ? caught : new Error(String(caught)));\n setStatus(\"error\");\n }\n })();\n\n return () => {\n cancelled = true;\n setPredictor(null);\n void loaded?.dispose();\n };\n }, [source, attempt]);\n\n const predict = useCallback(\n async (rows: readonly FeatureRow[]): Promise<TabularPrediction> => {\n if (predictor === null) {\n throw new Error(\n \"predict() was called before the model finished loading. \" +\n \"Gate on `isReady`.\",\n );\n }\n return await predictor.predict(rows);\n },\n [predictor],\n );\n\n const reload = useCallback(() => setAttempt((value) => value + 1), []);\n\n return {\n predictor,\n status,\n error,\n isReady: status === \"ready\" && predictor !== null,\n predict,\n reload,\n };\n}\n"],"mappings":"mFA+EA,SAAgB,EACZ,EACA,EAAsC,CAAC,EACd,CACzB,GAAM,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAkC,IAAI,EAClE,CAAC,EAAQ,IAAA,EAAa,EAAA,SAAA,CAAiC,MAAM,EAC7D,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAAuB,IAAI,EAC/C,CAAC,EAAS,IAAA,EAAc,EAAA,SAAA,CAAS,CAAC,EAElC,GAAA,EAAa,EAAA,OAAA,CAAO,CAAO,GAEjC,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAW,QAAU,CACzB,CAAC,GAED,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAW,KAAM,CACjB,EAAU,MAAM,EAChB,MACJ,CAEA,IAAI,EAAY,GACZ,EAAkC,KAiCtC,OA/BA,EAAU,SAAS,EACnB,EAAS,IAAI,GAEP,SAAY,CACd,GAAI,CACA,IAAM,EAAU,EAAW,QACrB,EAAQ,EAAQ,OAAS,GACzB,EACF,OAAO,GAAW,UAAY,IAAU,GAClC,MAAM,EAAA,gBAAgB,EAAQ,OAAO,GAAU,SAAW,EAAQ,CAAC,CAAC,EACpE,EACJ,EAAU,MAAM,EAAA,iBAAiB,OAAO,EAAO,CACjD,UAAW,EAAQ,UACnB,OAAQ,EAAQ,OAChB,eAAgB,EAAQ,cAC5B,CAAC,EAED,GADA,EAAS,EACL,EAAW,CACX,MAAM,EAAQ,QAAQ,EACtB,MACJ,CACA,EAAa,CAAO,EACpB,EAAU,OAAO,CACrB,OAAS,EAAQ,CACb,GAAI,EAAW,OACf,EAAa,IAAI,EACjB,EAAS,aAAkB,MAAQ,EAAa,MAAM,OAAO,CAAM,CAAC,CAAC,EACrE,EAAU,OAAO,CACrB,CACJ,EAAA,CAAG,MAEU,CACT,EAAY,GACZ,EAAa,IAAI,EACjB,GAAa,QAAQ,CACzB,CACJ,EAAG,CAAC,EAAQ,CAAO,CAAC,EAEpB,IAAM,GAAA,EAAU,EAAA,YAAA,CACZ,KAAO,IAA4D,CAC/D,GAAI,IAAc,KACd,MAAU,MACN,4EAEJ,EAEJ,OAAO,MAAM,EAAU,QAAQ,CAAI,CACvC,EACA,CAAC,CAAS,CACd,EAEM,GAAA,EAAS,EAAA,YAAA,KAAkB,EAAY,GAAU,EAAQ,CAAC,EAAG,CAAC,CAAC,EAErE,MAAO,CACH,YACA,SACA,QACA,QAAS,IAAW,SAAW,IAAc,KAC7C,UACA,QACJ,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TelemetryProvider.cjs","names":[],"sources":["../../src/telemetry/TelemetryProvider.tsx"],"sourcesContent":["import { createContext, useContext, useEffect, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { TelemetryAdapter } from \"./types\";\n\nconst TelemetryContext = createContext<TelemetryAdapter | null>(null);\n\nexport interface TelemetryProviderProps {\n adapter: TelemetryAdapter;\n children: ReactNode;\n}\n\n/**\n * Inject a telemetry adapter into the tree. Apps can swap implementations\n * (Sentry, Datadog, PostHog, console) without touching call sites.\n */\nexport function TelemetryProvider({ adapter, children }: TelemetryProviderProps) {\n useEffect(() => {\n void adapter.init?.();\n return () => {\n void adapter.flush?.();\n };\n }, [adapter]);\n const value = useMemo(() => adapter, [adapter]);\n return <TelemetryContext.Provider value={value}>{children}</TelemetryContext.Provider>;\n}\n\n/**\n * Access the active telemetry adapter. Returns `null` when no provider is\n * mounted (calls are silently dropped — useful for unit tests).\n */\nexport function useTelemetry(): TelemetryAdapter | null {\n return useContext(TelemetryContext);\n}\n"],"mappings":"sDAIA,IAAM,GAAA,
|
|
1
|
+
{"version":3,"file":"TelemetryProvider.cjs","names":[],"sources":["../../src/telemetry/TelemetryProvider.tsx"],"sourcesContent":["import { createContext, useContext, useEffect, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { TelemetryAdapter } from \"./types\";\n\nconst TelemetryContext = createContext<TelemetryAdapter | null>(null);\n\nexport interface TelemetryProviderProps {\n adapter: TelemetryAdapter;\n children: ReactNode;\n}\n\n/**\n * Inject a telemetry adapter into the tree. Apps can swap implementations\n * (Sentry, Datadog, PostHog, console) without touching call sites.\n */\nexport function TelemetryProvider({ adapter, children }: TelemetryProviderProps) {\n useEffect(() => {\n void adapter.init?.();\n return () => {\n void adapter.flush?.();\n };\n }, [adapter]);\n const value = useMemo(() => adapter, [adapter]);\n return <TelemetryContext.Provider value={value}>{children}</TelemetryContext.Provider>;\n}\n\n/**\n * Access the active telemetry adapter. Returns `null` when no provider is\n * mounted (calls are silently dropped — useful for unit tests).\n */\nexport function useTelemetry(): TelemetryAdapter | null {\n return useContext(TelemetryContext);\n}\n"],"mappings":"sDAIA,IAAM,GAAA,EAAmB,EAAA,cAAA,CAAuC,IAAI,EAWpE,SAAgB,EAAkB,CAAE,UAAS,YAAoC,EAC7E,EAAA,EAAA,UAAA,MACI,EAAa,OAAO,MACP,CACT,EAAa,QAAQ,CACzB,GACD,CAAC,CAAO,CAAC,EACZ,IAAM,GAAA,EAAQ,EAAA,QAAA,KAAc,EAAS,CAAC,CAAO,CAAC,EAC9C,OAAO,EAAA,EAAA,IAAA,CAAC,EAAiB,SAAlB,CAAkC,QAAQ,UAAoC,CAAA,CACzF,CAMA,SAAgB,GAAwC,CACpD,OAAA,EAAO,EAAA,WAAA,CAAW,CAAgB,CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.cjs","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useRef<typeof target>(target);\n useEffect(() => {\n targetRef.current = target;\n }, [target]);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useRef(themeColor);\n useEffect(() => {\n themeColorRef.current = themeColor;\n }, [themeColor]);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":"sDAuBA,IAAM,GAAA,
|
|
1
|
+
{"version":3,"file":"ThemeProvider.cjs","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useRef<typeof target>(target);\n useEffect(() => {\n targetRef.current = target;\n }, [target]);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useRef(themeColor);\n useEffect(() => {\n themeColorRef.current = themeColor;\n }, [themeColor]);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":"sDAuBA,IAAM,GAAA,EAAe,EAAA,cAAA,CAAwC,IAAI,EAgCjE,SAAS,EAAQ,EAAgC,CAG7C,OAFI,IAAS,QAAU,IAAS,QAAgB,EAC5C,OAAO,OAAW,IAAoB,QACnC,OAAO,WAAW,8BAA8B,CAAC,CAAC,QAAU,OAAS,OAChF,CAMA,SAAS,EACL,EACA,EACA,EACA,EACI,CACJ,IAAM,EAAQ,MAAM,QAAQ,CAAS,EAAI,EAAY,CAAC,CAAS,EAC/D,IAAK,IAAM,KAAQ,EAAO,EAAQ,aAAa,EAAM,CAAQ,EAC7D,GAAI,GAAc,OAAO,SAAa,IAAa,CAC/C,IAAM,EAAO,SAAS,cAA+B,0BAA0B,EAC3E,IAAM,EAAK,QAAU,EAAW,GACxC,CACJ,CAEA,SAAS,EAAW,EAA6C,CAC7D,GAAI,CAAC,GAAc,OAAO,OAAW,IAAa,OAAO,KACzD,GAAI,CACA,IAAM,EAAQ,OAAO,aAAa,QAAQ,CAAU,EAEpD,OADI,IAAU,SAAW,IAAU,QAAU,IAAU,SAAiB,EACjE,IACX,MAAQ,CACJ,OAAO,IACX,CACJ,CAeA,SAAgB,EAAc,CAC1B,WACA,eAAe,SACf,aAAa,gBACb,SACA,YAAY,qBACZ,cACmB,CACnB,GAAM,CAAC,EAAO,IAAA,EAAiB,EAAA,SAAA,KACrB,EAAW,CAAU,GAAK,CACpC,EACM,CAAC,EAAe,IAAA,EAAoB,EAAA,SAAA,KAA8B,EAAQ,CAAK,CAAC,EAEhF,GAAA,EAAY,EAAA,OAAA,CAAsB,CAAM,GAC9C,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAU,QAAU,CACxB,EAAG,CAAC,CAAM,CAAC,EAEX,IAAM,EAAe,MAAM,QAAQ,CAAS,EAAI,EAAU,KAAK,GAAG,EAAI,EAChE,GAAA,EAAgB,EAAA,OAAA,CAAO,CAAU,GACvC,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAc,QAAU,CAC5B,EAAG,CAAC,CAAU,CAAC,GAEf,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAO,EAAQ,CAAK,EAC1B,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CAGzB,EAAG,CAAC,EAAO,CAAY,CAAC,GAExB,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAU,UAAY,OAAO,OAAW,IAAa,OACzD,IAAM,EAAO,OAAO,WAAW,8BAA8B,EACvD,MAAsB,CACxB,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAsB,EAAK,QAAU,OAAS,QACpD,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CACzB,EAEA,OADA,EAAK,iBAAiB,SAAU,CAAO,MAC1B,EAAK,oBAAoB,SAAU,CAAO,CAE3D,EAAG,CAAC,EAAO,CAAY,CAAC,EAExB,IAAM,GAAA,EAAW,EAAA,YAAA,CACZ,GAAoB,CAEjB,GADA,EAAc,CAAI,EACd,GAAc,OAAO,OAAW,IAChC,GAAI,CACA,OAAO,aAAa,QAAQ,EAAY,CAAI,CAChD,MAAQ,CAER,CAER,EACA,CAAC,CAAU,CACf,EAEM,GAAA,EAAS,EAAA,YAAA,KAAkB,CAC7B,EAAS,IAAkB,OAAS,QAAU,MAAM,CACxD,EAAG,CAAC,EAAe,CAAQ,CAAC,EAEtB,GAAA,EAAQ,EAAA,QAAA,MACH,CAAE,QAAO,gBAAe,WAAU,QAAO,GAChD,CAAC,EAAO,EAAe,EAAU,CAAM,CAC3C,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAa,SAAd,CAA8B,QAAQ,UAAgC,CAAA,CACjF,CAKA,SAAgB,GAA8B,CAC1C,IAAM,GAAA,EAAM,EAAA,WAAA,CAAW,CAAY,EACnC,GAAI,CAAC,EAAK,MAAU,MAAM,gDAAgD,EAC1E,OAAO,CACX"}
|
package/dist/theme/color.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=[50,100,200,300,400,500,600,700,800,900],t={50:.966,100:.923,200:.844,300:.743,400:.642,500:.563,600:.48,700:.391,800:.325,900:.251},n={50:.982,100:.963,200:.927,300:.872,400:.71,500:.544,600:.442,700:.369,800:.278,900:.21},r={50:.159,100:.205,200:.254,300:.314,400:.381,500:.5,600:.571,700:.762,800:.86,900:.964},i={50:.238,100:.288,200:.362,300:.452,400:.544,500:.632,600:.712,700:.788,800:.862,900:.928},a={50:.18,100:.34,200:.6,300:.82,400:.95,500:1,600:.98,700:.88,800:.74,900:.58};function o(e,t,n){return Math.min(n,Math.max(t,e))}function s(e){let t=e.trim().replace(/^#/,``),n=t.length===3||t.length===4?t.slice(0,3).split(``).map(e=>e+e).join(``):t.slice(0,6);if(!/^[0-9a-fA-F]{6}$/.test(n))throw Error(`Invalid hex color: "${e}"`);return`#${n.toLowerCase()}`}function c(e){let t=s(e).slice(1);return{r:parseInt(t.slice(0,2),16)/255,g:parseInt(t.slice(2,4),16)/255,b:parseInt(t.slice(4,6),16)/255}}function l(e,t,n){let r=e=>Math.round(o(e,0,1)*255).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`}function u(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function d(e){return e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055}function f(e){let{r:t,g:n,b:r}=c(e),i=u(t),a=u(n),o=u(r),s=Math.cbrt(.4122214708*i+.5363325363*a+.0514459929*o),l=Math.cbrt(.2119034982*i+.6806995451*a+.1073969566*o),d=Math.cbrt(.0883024619*i+.2817188376*a+.6299787005*o),f=.2104542553*s+.793617785*l-.0040720468*d,p=1.9779984951*s-2.428592205*l+.4505937099*d,m=.0259040371*s+.7827717662*l-.808675766*d,h=Math.sqrt(p*p+m*m),g=h<1e-6?0:Math.atan2(m,p)*180/Math.PI;return{l:f,c:h,h:g<0?g+360:g}}function p({l:e,c:t,h:n}){let r=n*Math.PI/180,i=Math.cos(r)*t,a=Math.sin(r)*t,o=(e+.3963377774*i+.2158037573*a)**3,s=(e-.1055613458*i-.0638541728*a)**3,c=(e-.0894841775*i-1.291485548*a)**3;return{r:4.0767416621*o-3.3077115913*s+.2309699292*c,g:-1.2684380046*o+2.6097574011*s-.3413193965*c,b:-.0041960863*o-.7034186147*s+1.707614701*c}}function m({r:e,g:t,b:n}){return e>=-1e-4&&e<=1.0001&&t>=-1e-4&&t<=1.0001&&n>=-1e-4&&n<=1.0001}function h(e){let t=Math.max(0,e.c),n=p({...e,c:t});for(let r=0;r<24&&!m(n);r+=1)t*=.9,n=p({...e,c:t});return l(d(n.r),d(n.g),d(n.b))}function g(o,s=`light`,c={}){let l=f(o),u=c.neutral?s===`dark`?r:n:s===`dark`?i:t,d=c.anchor===!1?u:y(u,l.l,s),p={};for(let t of e)p[t]=h({l:d[t],c:l.c*a[t],h:l.h});return p}var _=.985,v=.12;function y(t,n,r){let i={},a=t[500],o=r===`dark`?t[900]:t[50],s=r===`dark`?t[50]:t[900],c=Math.min(_,Math.max(o,n+.05)),l=Math.max(v,Math.min(s,n-.05));for(let r of e){let e=t[r];
|
|
1
|
+
var e=[50,100,200,300,400,500,600,700,800,900],t={50:.966,100:.923,200:.844,300:.743,400:.642,500:.563,600:.48,700:.391,800:.325,900:.251},n={50:.982,100:.963,200:.927,300:.872,400:.71,500:.544,600:.442,700:.369,800:.278,900:.21},r={50:.159,100:.205,200:.254,300:.314,400:.381,500:.5,600:.571,700:.762,800:.86,900:.964},i={50:.238,100:.288,200:.362,300:.452,400:.544,500:.632,600:.712,700:.788,800:.862,900:.928},a={50:.18,100:.34,200:.6,300:.82,400:.95,500:1,600:.98,700:.88,800:.74,900:.58};function o(e,t,n){return Math.min(n,Math.max(t,e))}function s(e){let t=e.trim().replace(/^#/,``),n=t.length===3||t.length===4?t.slice(0,3).split(``).map(e=>e+e).join(``):t.slice(0,6);if(!/^[0-9a-fA-F]{6}$/.test(n))throw Error(`Invalid hex color: "${e}"`);return`#${n.toLowerCase()}`}function c(e){let t=s(e).slice(1);return{r:parseInt(t.slice(0,2),16)/255,g:parseInt(t.slice(2,4),16)/255,b:parseInt(t.slice(4,6),16)/255}}function l(e,t,n){let r=e=>Math.round(o(e,0,1)*255).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`}function u(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function d(e){return e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055}function f(e){let{r:t,g:n,b:r}=c(e),i=u(t),a=u(n),o=u(r),s=Math.cbrt(.4122214708*i+.5363325363*a+.0514459929*o),l=Math.cbrt(.2119034982*i+.6806995451*a+.1073969566*o),d=Math.cbrt(.0883024619*i+.2817188376*a+.6299787005*o),f=.2104542553*s+.793617785*l-.0040720468*d,p=1.9779984951*s-2.428592205*l+.4505937099*d,m=.0259040371*s+.7827717662*l-.808675766*d,h=Math.sqrt(p*p+m*m),g=h<1e-6?0:Math.atan2(m,p)*180/Math.PI;return{l:f,c:h,h:g<0?g+360:g}}function p({l:e,c:t,h:n}){let r=n*Math.PI/180,i=Math.cos(r)*t,a=Math.sin(r)*t,o=(e+.3963377774*i+.2158037573*a)**3,s=(e-.1055613458*i-.0638541728*a)**3,c=(e-.0894841775*i-1.291485548*a)**3;return{r:4.0767416621*o-3.3077115913*s+.2309699292*c,g:-1.2684380046*o+2.6097574011*s-.3413193965*c,b:-.0041960863*o-.7034186147*s+1.707614701*c}}function m({r:e,g:t,b:n}){return e>=-1e-4&&e<=1.0001&&t>=-1e-4&&t<=1.0001&&n>=-1e-4&&n<=1.0001}function h(e){let t=Math.max(0,e.c),n=p({...e,c:t});for(let r=0;r<24&&!m(n);r+=1)t*=.9,n=p({...e,c:t});return l(d(n.r),d(n.g),d(n.b))}function g(o,s=`light`,c={}){let l=f(o),u=c.neutral?s===`dark`?r:n:s===`dark`?i:t,d=c.anchor===!1?u:y(u,l.l,s),p={};for(let t of e)p[t]=h({l:d[t],c:l.c*a[t],h:l.h});return p}var _=.985,v=.12;function y(t,n,r){let i={},a=t[500],o=r===`dark`?t[900]:t[50],s=r===`dark`?t[50]:t[900],c=Math.min(_,Math.max(o,n+.05)),l=Math.max(v,Math.min(s,n-.05));for(let r of e){let e=t[r];i[r]=e===a?n:e>a?n+(e-a)/(o-a)*(c-n):n-(a-e)/(a-s)*(n-l)}return i}function b(e){let{r:t,g:n,b:r}=c(e);return .2126*u(t)+.7152*u(n)+.0722*u(r)}function x(e,t){let n=b(e),r=b(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function S(e,t=`#ffffff`,n=`#101828`){return x(e,t)>=x(e,n)?t:n}function C(e,t){let{r:n,g:r,b:i}=c(e),a=e=>Math.round(o(e,0,1)*255);return`rgb(${a(n)} ${a(r)} ${a(i)} / ${o(t,0,1)})`}exports.contrastRatio=x,exports.createColorScale=g,exports.hexToOklch=f,exports.hexToRgb=c,exports.hexToRgbaString=C,exports.oklchToHex=h,exports.readableForeground=S,exports.relativeLuminance=b,exports.rgbToHex=l;
|
|
2
2
|
//# sourceMappingURL=color.cjs.map
|