fancy-ui-vue 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PORTING.md +123 -2
- package/README.md +20 -15
- package/dist/components/accordion/Accordion.vue.d.ts +44 -0
- package/dist/components/accordion/Accordion.vue.js +88 -0
- package/dist/components/accordion/Accordion.vue2.js +4 -0
- package/dist/components/accordion/AccordionContent.vue.d.ts +25 -0
- package/dist/components/accordion/AccordionContent.vue.js +42 -0
- package/dist/components/accordion/AccordionContent.vue2.js +4 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +21 -0
- package/dist/components/accordion/AccordionItem.vue.js +66 -0
- package/dist/components/accordion/AccordionItem.vue2.js +4 -0
- package/dist/components/accordion/AccordionTrigger.vue.d.ts +24 -0
- package/dist/components/accordion/AccordionTrigger.vue.js +83 -0
- package/dist/components/accordion/AccordionTrigger.vue2.js +4 -0
- package/dist/components/accordion/accordion-core.d.ts +35 -0
- package/dist/components/accordion/accordion-core.js +44 -0
- package/dist/components/accordion/index.d.ts +11 -0
- package/dist/components/accordion/types.d.ts +45 -0
- package/dist/components/accordion/types.js +7 -0
- package/dist/components/alert-dialog/AlertDialog.vue.js +22 -3
- package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +3 -3
- package/dist/components/apple-card-carousel/AppleCard.vue.js +1 -1
- package/dist/components/autocomplete/Autocomplete.vue.js +1 -1
- package/dist/components/autocomplete/Autocomplete.vue2.js +22 -15
- package/dist/components/avatar/Avatar.vue.d.ts +27 -0
- package/dist/components/avatar/Avatar.vue.js +119 -0
- package/dist/components/avatar/Avatar.vue2.js +4 -0
- package/dist/components/avatar/avatar-core.d.ts +40 -0
- package/dist/components/avatar/avatar-core.js +57 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/badge/Badge.vue.d.ts +21 -0
- package/dist/components/badge/Badge.vue.js +46 -0
- package/dist/components/badge/Badge.vue2.js +4 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/bento-grid/BentoFrame.vue.js +1 -1
- package/dist/components/bento-grid/BentoFrame.vue2.js +6 -5
- package/dist/components/bento-grid/BentoGrid.vue.js +1 -1
- package/dist/components/bento-grid/BentoGrid.vue2.js +12 -12
- package/dist/components/bento-grid/BentoGridCard.vue.js +6 -5
- package/dist/components/bento-grid/BentoGridItem.vue.js +6 -5
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.d.ts +1 -1
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +1 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +1 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.js +47 -12
- package/dist/components/book/Book.vue.js +8 -9
- package/dist/components/book/BookDescription.vue.js +6 -5
- package/dist/components/book/BookHeader.vue.js +6 -5
- package/dist/components/book/BookTitle.vue.js +6 -5
- package/dist/components/box-reveal/BoxReveal.vue.js +6 -5
- package/dist/components/button/Button.vue.d.ts +6 -4
- package/dist/components/button/Button.vue.js +1 -1
- package/dist/components/button/Button.vue2.js +50 -22
- package/dist/components/card-3d/CardContainer.vue.js +1 -1
- package/dist/components/card-3d/CardItem.vue.js +1 -1
- package/dist/components/card-spotlight/CardSpotlight.vue.js +1 -1
- package/dist/components/chat-message/ChatMessageAction.vue.d.ts +4 -2
- package/dist/components/chat-message/ChatMessageAction.vue.js +4 -2
- package/dist/components/checkbox/Checkbox.vue.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.vue.js +1 -1
- package/dist/components/checkbox/Checkbox.vue2.js +17 -7
- package/dist/components/collapsible/Collapsible.vue.d.ts +31 -0
- package/dist/components/collapsible/Collapsible.vue.js +60 -0
- package/dist/components/collapsible/Collapsible.vue2.js +4 -0
- package/dist/components/collapsible/CollapsibleContent.vue.d.ts +26 -0
- package/dist/components/collapsible/CollapsibleContent.vue.js +81 -0
- package/dist/components/collapsible/CollapsibleContent.vue2.js +4 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue.d.ts +21 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue.js +57 -0
- package/dist/components/collapsible/CollapsibleTrigger.vue2.js +4 -0
- package/dist/components/collapsible/collapsible-core.d.ts +47 -0
- package/dist/components/collapsible/collapsible-core.js +40 -0
- package/dist/components/collapsible/index.d.ts +8 -0
- package/dist/components/collapsible/types.d.ts +24 -0
- package/dist/components/collapsible/types.js +5 -0
- package/dist/components/combobox/Combobox.vue.js +1 -1
- package/dist/components/combobox/Combobox.vue2.js +24 -16
- package/dist/components/command-menu/CommandMenu.vue.d.ts +5 -0
- package/dist/components/command-menu/CommandMenu.vue.js +1 -1
- package/dist/components/command-menu/CommandMenu.vue2.js +5 -2
- package/dist/components/compare/Compare.vue.d.ts +15 -5
- package/dist/components/compare/Compare.vue.js +1 -1
- package/dist/components/compare/Compare.vue2.js +28 -13
- package/dist/components/composer/ComposerInput.vue.js +1 -1
- package/dist/components/composer/ComposerInput.vue2.js +11 -11
- package/dist/components/composer/ComposerModelPicker.vue.d.ts +4 -0
- package/dist/components/composer/ComposerModelPicker.vue.js +1 -1
- package/dist/components/composer/ComposerModelPicker.vue2.js +29 -15
- package/dist/components/composer/ComposerSubmit.vue.d.ts +2 -0
- package/dist/components/composer/ComposerSubmit.vue.js +16 -15
- package/dist/components/confetti/ConfettiButton.vue.d.ts +9 -2
- package/dist/components/confetti/ConfettiButton.vue.js +24 -6
- package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +12 -13
- package/dist/components/copy-button/CopyButton.vue.d.ts +5 -0
- package/dist/components/copy-button/CopyButton.vue.js +1 -1
- package/dist/components/copy-button/CopyButton.vue2.js +72 -11
- package/dist/components/datamosh-transition/DatamoshTransition.vue.d.ts +6 -2
- package/dist/components/datamosh-transition/DatamoshTransition.vue.js +7 -4
- package/dist/components/date-picker/DatePicker.vue.js +1 -1
- package/dist/components/date-picker/DatePicker.vue2.js +27 -21
- package/dist/components/dialog/Dialog.vue.js +20 -1
- package/dist/components/dialog/DialogSurface.vue.js +1 -1
- package/dist/components/dialog/DialogSurface.vue2.js +5 -2
- package/dist/components/dialog/types.d.ts +2 -0
- package/dist/components/direction-aware-hover/DirectionAwareHover.vue.js +1 -1
- package/dist/components/direction-aware-hover/DirectionAwareHover.vue2.js +9 -7
- package/dist/components/displacement-text/DisplacementText.vue.d.ts +4 -1
- package/dist/components/displacement-text/DisplacementText.vue.js +38 -11
- package/dist/components/displacement-text/displacement-text-core.d.ts +94 -4
- package/dist/components/displacement-text/displacement-text-core.js +287 -97
- package/dist/components/drawer/Drawer.vue.d.ts +5 -0
- package/dist/components/drawer/Drawer.vue.js +1 -1
- package/dist/components/drawer/Drawer.vue2.js +5 -2
- package/dist/components/dropdown-menu/DropdownMenuContent.vue.js +2 -1
- package/dist/components/dropdown-menu/DropdownMenuItem.vue.d.ts +4 -0
- package/dist/components/dropdown-menu/DropdownMenuItem.vue.js +17 -10
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +8 -0
- package/dist/components/dropdown-menu/DropdownMenuSubTrigger.vue.js +28 -13
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.d.ts +4 -0
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuTrigger.vue2.js +20 -10
- package/dist/components/editorial-engine/EditorialEngine.vue.js +1 -1
- package/dist/components/editorial-engine/engine.js +13 -0
- package/dist/components/file-upload/FileUpload.vue.d.ts +2 -0
- package/dist/components/file-upload/FileUpload.vue.js +1 -1
- package/dist/components/file-upload/FileUpload.vue2.js +20 -10
- package/dist/components/fireworks-hdr/FireworksHdr.vue.js +2 -2
- package/dist/components/flickering-grid/FlickeringGrid.vue.d.ts +1 -1
- package/dist/components/flickering-grid/FlickeringGrid.vue.js +1 -1
- package/dist/components/flickering-grid/flickering-grid-core.d.ts +1 -1
- package/dist/components/flickering-grid/flickering-grid-core.js +51 -9
- package/dist/components/flip-card/FlipCard.vue.d.ts +3 -1
- package/dist/components/flip-card/FlipCard.vue.js +1 -1
- package/dist/components/flip-card/FlipCard.vue2.js +5 -3
- package/dist/components/fluid-cursor/FluidCursor.vue.js +37 -9
- package/dist/components/fluid-cursor/fluid-cursor-core.js +3 -3
- package/dist/components/fluid-cursor/webgpu-engine.js +3 -3
- package/dist/components/focus/Focus.vue.js +1 -1
- package/dist/components/focus/Focus.vue2.js +2 -2
- package/dist/components/follow-button/FollowButton.vue.d.ts +69 -0
- package/dist/components/follow-button/FollowButton.vue.js +7 -0
- package/dist/components/follow-button/FollowButton.vue2.js +239 -0
- package/dist/components/follow-button/follow-core.d.ts +83 -0
- package/dist/components/follow-button/follow-core.js +92 -0
- package/dist/components/follow-button/index.d.ts +2 -0
- package/dist/components/frosted-glass/FrostedGlass.vue.js +1 -1
- package/dist/components/glare-card/GlareCard.vue.js +1 -1
- package/dist/components/glare-card/GlareCard.vue2.js +4 -4
- package/dist/components/glowing-effect/GlowingEffect.vue.js +3 -3
- package/dist/components/glowing-effect/glowing-effect-core.js +4 -1
- package/dist/components/gradient-button/GradientButton.vue.d.ts +6 -4
- package/dist/components/gradient-button/GradientButton.vue.js +1 -1
- package/dist/components/gradient-button/GradientButton.vue2.js +13 -3
- package/dist/components/icon-button/IconButton.vue.d.ts +6 -4
- package/dist/components/icon-button/IconButton.vue.js +11 -8
- package/dist/components/image-trail-cursor/ImageTrailCursor.vue.js +17 -7
- package/dist/components/image-trail-cursor/trail-variants.js +3 -6
- package/dist/components/inline-citation/InlineCitation.vue.js +1 -1
- package/dist/components/inline-citation/InlineCitation.vue2.js +20 -14
- package/dist/components/input/Input.vue.js +1 -1
- package/dist/components/input/Input.vue2.js +18 -8
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue.js +1 -1
- package/dist/components/interactive-grid-pattern/InteractiveGridPattern.vue2.js +1 -1
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.d.ts +6 -3
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue.js +1 -1
- package/dist/components/interactive-hover-button/InteractiveHoverButton.vue2.js +12 -2
- package/dist/components/letter-pullup/LetterPullup.vue.js +4 -4
- package/dist/components/line-hover-link/LineHoverLink.vue.js +1 -1
- package/dist/components/line-hover-link/LineHoverLink.vue2.js +5 -6
- package/dist/components/link/Link.vue.d.ts +4 -2
- package/dist/components/link/Link.vue.js +1 -1
- package/dist/components/link/Link.vue2.js +11 -8
- package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
- package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
- package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
- package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
- package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
- package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
- package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
- package/dist/components/magnetic-field/index.d.ts +10 -0
- package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
- package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
- package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
- package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
- package/dist/components/magnetic-field/types.d.ts +14 -0
- package/dist/components/magnetic-field/types.js +5 -0
- package/dist/components/mosaic-glow/MosaicGlow.vue.d.ts +6 -0
- package/dist/components/mosaic-glow/MosaicGlow.vue.js +53 -9
- package/dist/components/mosaic-glow/mosaic-glow-core.d.ts +30 -0
- package/dist/components/mosaic-glow/mosaic-glow-core.js +27 -0
- package/dist/components/mosaic-glow/mosaic-glow-hdr.d.ts +24 -0
- package/dist/components/mosaic-glow/mosaic-glow-hdr.js +200 -0
- package/dist/components/navbar/NavbarLink.vue.d.ts +4 -2
- package/dist/components/navbar/NavbarLink.vue.js +1 -1
- package/dist/components/navbar/NavbarLink.vue2.js +16 -13
- package/dist/components/navigation-menu/NavigationMenu.vue.js +6 -3
- package/dist/components/navigation-menu/NavigationMenuLink.vue.js +1 -1
- package/dist/components/navigation-menu/NavigationMenuLink.vue2.js +8 -8
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue.d.ts +15 -0
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue.js +1 -1
- package/dist/components/navigation-menu/NavigationMenuTrigger.vue2.js +36 -15
- package/dist/components/neon-border/NeonBorder.vue.js +1 -1
- package/dist/components/neon-border/NeonBorder.vue2.js +10 -11
- package/dist/components/number-input/NumberInput.vue.js +1 -1
- package/dist/components/number-input/NumberInput.vue2.js +22 -12
- package/dist/components/password-input/PasswordInput.vue.js +1 -1
- package/dist/components/password-input/PasswordInput.vue2.js +18 -11
- package/dist/components/pixel-loader/PixelLoader.vue.js +1 -1
- package/dist/components/pixel-loader/PixelLoader.vue2.js +6 -6
- package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
- package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
- package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
- package/dist/components/pixel-scene/index.d.ts +4 -0
- package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
- package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
- package/dist/components/popover/Popover.vue.d.ts +4 -0
- package/dist/components/popover/Popover.vue.js +1 -1
- package/dist/components/popover/Popover.vue2.js +8 -6
- package/dist/components/popover/PopoverContent.vue.js +6 -2
- package/dist/components/pulse-beam/PulseBeam.vue.d.ts +6 -2
- package/dist/components/pulse-beam/PulseBeam.vue.js +1 -1
- package/dist/components/pulse-beam/PulseBeam.vue2.js +7 -4
- package/dist/components/radio-group/RadioGroup.vue.js +12 -11
- package/dist/components/radio-group/RadioGroupItem.vue.d.ts +2 -0
- package/dist/components/radio-group/RadioGroupItem.vue.js +1 -1
- package/dist/components/radio-group/RadioGroupItem.vue2.js +20 -7
- package/dist/components/rainbow-button/RainbowButton.vue.d.ts +11 -2
- package/dist/components/rainbow-button/RainbowButton.vue.js +1 -1
- package/dist/components/rainbow-button/RainbowButton.vue2.js +35 -18
- package/dist/components/ripple-button/RippleButton.vue.d.ts +6 -4
- package/dist/components/ripple-button/RippleButton.vue.js +1 -1
- package/dist/components/ripple-button/RippleButton.vue2.js +10 -5
- package/dist/components/search-input/SearchInput.vue.js +1 -1
- package/dist/components/search-input/SearchInput.vue2.js +19 -9
- package/dist/components/select/Select.vue.d.ts +1 -1
- package/dist/components/select/Select.vue.js +1 -1
- package/dist/components/select/Select.vue2.js +25 -17
- package/dist/components/sheet/Sheet.vue.d.ts +5 -0
- package/dist/components/sheet/Sheet.vue.js +5 -2
- package/dist/components/shimmer-button/ShimmerButton.vue.d.ts +2 -2
- package/dist/components/shimmer-button/ShimmerButton.vue.js +1 -1
- package/dist/components/shimmer-button/ShimmerButton.vue2.js +14 -6
- package/dist/components/sidebar/SidebarItem.vue.d.ts +4 -2
- package/dist/components/sidebar/SidebarItem.vue.js +1 -1
- package/dist/components/sidebar/SidebarItem.vue2.js +4 -2
- package/dist/components/slider/Slider.vue.d.ts +4 -0
- package/dist/components/slider/Slider.vue.js +1 -1
- package/dist/components/slider/Slider.vue2.js +20 -8
- package/dist/components/sources/SourcesTrigger.vue.js +1 -1
- package/dist/components/sources/SourcesTrigger.vue2.js +11 -11
- package/dist/components/sparkles/sparkles-core.d.ts +1 -1
- package/dist/components/sparkles/sparkles-core.js +36 -2
- package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
- package/dist/components/story-thread/StoryNode.vue.js +7 -0
- package/dist/components/story-thread/StoryNode.vue2.js +23 -0
- package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
- package/dist/components/story-thread/StoryThread.vue.js +7 -0
- package/dist/components/story-thread/StoryThread.vue2.js +103 -0
- package/dist/components/story-thread/index.d.ts +5 -0
- package/dist/components/story-thread/story-thread-core.d.ts +119 -0
- package/dist/components/story-thread/story-thread-core.js +491 -0
- package/dist/components/story-thread/types.d.ts +1 -0
- package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
- package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
- package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
- package/dist/components/sun-switch/index.d.ts +4 -0
- package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
- package/dist/components/sun-switch/pixel-wave-core.js +508 -0
- package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
- package/dist/components/sun-switch/sun-switch-core.js +546 -0
- package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
- package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
- package/dist/components/switch/Switch.vue.d.ts +2 -0
- package/dist/components/switch/Switch.vue.js +1 -1
- package/dist/components/switch/Switch.vue2.js +16 -6
- package/dist/components/tabs/TabsTrigger.vue.d.ts +6 -0
- package/dist/components/tabs/TabsTrigger.vue.js +1 -1
- package/dist/components/tabs/TabsTrigger.vue2.js +28 -15
- package/dist/components/terminal-block/TerminalBlock.vue.js +1 -1
- package/dist/components/terminal-block/TerminalBlock.vue2.js +10 -9
- package/dist/components/text-reveal-card/TextRevealCard.vue.js +1 -2
- package/dist/components/textarea/Textarea.vue.js +1 -1
- package/dist/components/textarea/Textarea.vue2.js +19 -12
- package/dist/components/tick-nav/TickNav.vue.d.ts +71 -0
- package/dist/components/tick-nav/TickNav.vue.js +7 -0
- package/dist/components/tick-nav/TickNav.vue2.js +285 -0
- package/dist/components/tick-nav/index.d.ts +3 -0
- package/dist/components/tick-nav/tick-nav-core.d.ts +102 -0
- package/dist/components/tick-nav/tick-nav-core.js +398 -0
- package/dist/components/tick-nav/tick-nav-hdr.d.ts +60 -0
- package/dist/components/tick-nav/tick-nav-hdr.js +284 -0
- package/dist/components/tick-nav/types.d.ts +13 -0
- package/dist/components/time-picker/TimePicker.vue.js +1 -1
- package/dist/components/time-picker/TimePicker.vue2.js +25 -17
- package/dist/components/toast/Toast.vue.js +1 -1
- package/dist/components/toast/Toast.vue2.js +16 -4
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/store.d.ts +23 -0
- package/dist/components/toast/store.js +35 -7
- package/dist/components/toggle/Toggle.vue.d.ts +12 -0
- package/dist/components/toggle/Toggle.vue.js +1 -1
- package/dist/components/toggle/Toggle.vue2.js +27 -11
- package/dist/components/toggle-group/ToggleGroup.vue.d.ts +11 -0
- package/dist/components/toggle-group/ToggleGroup.vue.js +1 -1
- package/dist/components/toggle-group/ToggleGroup.vue2.js +16 -3
- package/dist/components/toggle-group/ToggleGroupItem.vue.d.ts +6 -0
- package/dist/components/toggle-group/ToggleGroupItem.vue.js +1 -1
- package/dist/components/toggle-group/ToggleGroupItem.vue2.js +27 -14
- package/dist/components/tooltip/Tooltip.vue.js +13 -0
- package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
- package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
- package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
- package/dist/components/typing-indicator/TypingIndicator.vue.js +1 -1
- package/dist/components/typing-indicator/TypingIndicator.vue2.js +7 -6
- package/dist/index.d.ts +10 -0
- package/dist/index.js +466 -413
- package/dist/internals/anchor-position.js +3 -0
- package/dist/internals/call-listener.d.ts +11 -0
- package/dist/internals/call-listener.js +31 -0
- package/dist/internals/dismissable.d.ts +17 -0
- package/dist/internals/dismissable.js +44 -1
- package/dist/internals/env.d.ts +1 -0
- package/dist/internals/env.js +11 -0
- package/dist/internals/focus-trap.js +29 -4
- package/dist/internals/merge-ids.d.ts +6 -0
- package/dist/internals/merge-ids.js +11 -0
- package/dist/internals/motion/presence-core.d.ts +1 -1
- package/dist/sound/engine.js +23 -9
- package/dist/sound/themes.d.ts +4 -3
- package/dist/sound/themes.js +49 -211
- package/dist/sound/types.d.ts +9 -1
- package/dist/sound/types.js +2 -2
- package/dist/styles.css +1473 -571
- package/package.json +2 -2
- package/tailwind.css +9 -9
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
const SUN_PALETTE = Object.freeze([
|
|
2
|
+
"#f7cf4a",
|
|
3
|
+
"#f6a24e",
|
|
4
|
+
"#ef7a5e",
|
|
5
|
+
"#ea7d9c"
|
|
6
|
+
]);
|
|
7
|
+
const HORIZON_ALPHA = 0.16;
|
|
8
|
+
const DAY_REST_INK = 0.3;
|
|
9
|
+
const REFLECTION_ROWS = Object.freeze([0.85, 0.6, 0.35]);
|
|
10
|
+
const HALO_EXPONENT = 0.7;
|
|
11
|
+
const BAYER4_RAW = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5];
|
|
12
|
+
const BAYER4 = Object.freeze(BAYER4_RAW.map((v) => (v + 0.5) / 16));
|
|
13
|
+
function bayer4(x, y) {
|
|
14
|
+
return BAYER4[(y & 3) * 4 + (x & 3)] ?? 0;
|
|
15
|
+
}
|
|
16
|
+
function easeInOutCubic(t) {
|
|
17
|
+
if (!(t > 0)) return 0;
|
|
18
|
+
if (t >= 1) return 1;
|
|
19
|
+
return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
20
|
+
}
|
|
21
|
+
function haloDensity(D) {
|
|
22
|
+
if (!(D > 0)) return 0;
|
|
23
|
+
if (D >= 1) return 1;
|
|
24
|
+
return D ** HALO_EXPONENT;
|
|
25
|
+
}
|
|
26
|
+
function haloColorIndex(D) {
|
|
27
|
+
const i = Math.floor(D * 4);
|
|
28
|
+
return i <= 0 ? 0 : i >= 3 ? 3 : i;
|
|
29
|
+
}
|
|
30
|
+
function parseInk(css) {
|
|
31
|
+
const s = css.trim().toLowerCase();
|
|
32
|
+
if (s === "transparent") return { r: 0, g: 0, b: 0, a: 0 };
|
|
33
|
+
if (s.startsWith("#")) {
|
|
34
|
+
const hex = s.slice(1);
|
|
35
|
+
if (!/^[0-9a-f]+$/.test(hex)) return null;
|
|
36
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
37
|
+
const n = [...hex].map((c) => parseInt(c + c, 16));
|
|
38
|
+
return { r: n[0] ?? 0, g: n[1] ?? 0, b: n[2] ?? 0, a: n[3] === void 0 ? 1 : n[3] / 255 };
|
|
39
|
+
}
|
|
40
|
+
if (hex.length === 6 || hex.length === 8) {
|
|
41
|
+
const n = [0, 2, 4, 6].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
42
|
+
const a2 = hex.length === 8 ? (n[3] ?? 255) / 255 : 1;
|
|
43
|
+
return { r: n[0] ?? 0, g: n[1] ?? 0, b: n[2] ?? 0, a: a2 };
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const m = /^rgba?\(([^)]*)\)$/.exec(s);
|
|
48
|
+
if (!m) return null;
|
|
49
|
+
const parts = (m[1] ?? "").split(/[\s,/]+/).filter(Boolean);
|
|
50
|
+
if (parts.length < 3) return null;
|
|
51
|
+
const num = (p, scale) => {
|
|
52
|
+
if (p === void 0) return NaN;
|
|
53
|
+
return p.endsWith("%") ? parseFloat(p) / 100 * scale : parseFloat(p);
|
|
54
|
+
};
|
|
55
|
+
const r = num(parts[0], 255);
|
|
56
|
+
const g = num(parts[1], 255);
|
|
57
|
+
const b = num(parts[2], 255);
|
|
58
|
+
const a = parts[3] === void 0 ? 1 : num(parts[3], 1);
|
|
59
|
+
if ([r, g, b, a].some((v) => !Number.isFinite(v))) return null;
|
|
60
|
+
return { r, g, b, a: Math.min(1, Math.max(0, a)) };
|
|
61
|
+
}
|
|
62
|
+
const SUN_GLOW_DAY = 2.2;
|
|
63
|
+
const SUN_GLOW_LENS = 4.9;
|
|
64
|
+
const HORIZON_GLOW_LENS = 1.6;
|
|
65
|
+
function haloGlow(D) {
|
|
66
|
+
return 1.5 + 3.4 * Math.min(1, Math.max(0, D));
|
|
67
|
+
}
|
|
68
|
+
const RGB_CACHE = /* @__PURE__ */ new Map();
|
|
69
|
+
function rgbOf(css) {
|
|
70
|
+
const hit = RGB_CACHE.get(css);
|
|
71
|
+
if (hit !== void 0) return hit;
|
|
72
|
+
const c = parseInk(css);
|
|
73
|
+
const v = c && c.a > 0 ? Math.round(Math.min(255, Math.max(0, c.r))) << 16 | Math.round(Math.min(255, Math.max(0, c.g))) << 8 | Math.round(Math.min(255, Math.max(0, c.b))) : -1;
|
|
74
|
+
if (RGB_CACHE.size > 64) RGB_CACHE.clear();
|
|
75
|
+
RGB_CACHE.set(css, v);
|
|
76
|
+
return v;
|
|
77
|
+
}
|
|
78
|
+
function mixRgb(a, b, t) {
|
|
79
|
+
const ch = (s) => Math.round((a >> s & 255) * (1 - t) + (b >> s & 255) * t) & 255;
|
|
80
|
+
return ch(16) << 16 | ch(8) << 8 | ch(0);
|
|
81
|
+
}
|
|
82
|
+
function hash2(x, y) {
|
|
83
|
+
let h = Math.imul(x | 0, 668265261) ^ Math.imul(y | 0, 374761393);
|
|
84
|
+
h = Math.imul(h ^ h >>> 15, 2246822507);
|
|
85
|
+
h ^= h >>> 13;
|
|
86
|
+
return (h >>> 0) / 4294967296;
|
|
87
|
+
}
|
|
88
|
+
function rasterSun(o) {
|
|
89
|
+
const R = Math.max(1, Math.round(o.radius));
|
|
90
|
+
const size = 2 * R + 1;
|
|
91
|
+
const hY = o.horizon ? Math.round(0.6 * size) : size;
|
|
92
|
+
const rr = R + 0.5;
|
|
93
|
+
const cells = [];
|
|
94
|
+
for (let y = 0; y < hY; y++) {
|
|
95
|
+
const dy = y - R;
|
|
96
|
+
const half = Math.floor(Math.sqrt(Math.max(0, rr * rr - dy * dy)));
|
|
97
|
+
const color = Math.min(3, Math.floor(y * 4 / hY));
|
|
98
|
+
for (let x = R - half; x <= R + half; x++) cells.push({ x, y, color, layer: "sun" });
|
|
99
|
+
}
|
|
100
|
+
if (o.horizon && hY < size) {
|
|
101
|
+
for (let x = 0; x < size; x += 2) cells.push({ x, y: hY, color: 1, layer: "horizon" });
|
|
102
|
+
for (let k = 0; k < REFLECTION_ROWS.length; k++) {
|
|
103
|
+
const y = hY + 1 + k;
|
|
104
|
+
if (y >= size) break;
|
|
105
|
+
const w = Math.round(rr * (REFLECTION_ROWS[k] ?? 0));
|
|
106
|
+
for (let x = R - w; x <= R + w; x++) {
|
|
107
|
+
if ((x + y) % 4 === 3) continue;
|
|
108
|
+
const color = Math.min(3, 1 + Math.floor(hash2(y, x) * 3));
|
|
109
|
+
cells.push({ x, y, color, layer: "horizon" });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { size, horizonRow: hY, cells };
|
|
114
|
+
}
|
|
115
|
+
function gridOffset(origin, cell) {
|
|
116
|
+
return (origin % cell + cell) % cell;
|
|
117
|
+
}
|
|
118
|
+
function coverRadiusCells(origin, W, H, cell, halo) {
|
|
119
|
+
return Math.hypot(Math.max(origin.x, W - origin.x), Math.max(origin.y, H - origin.y)) / cell + halo;
|
|
120
|
+
}
|
|
121
|
+
function staircaseRows(tx, ty, innerRadius, cell, ox, oy) {
|
|
122
|
+
const rows = [];
|
|
123
|
+
if (!(innerRadius > 0)) return rows;
|
|
124
|
+
const last = Math.ceil(ty + innerRadius);
|
|
125
|
+
for (let r = Math.floor(ty - innerRadius); r <= last; r++) {
|
|
126
|
+
const dy = r + 0.5 - ty;
|
|
127
|
+
if (Math.abs(dy) > innerRadius) continue;
|
|
128
|
+
const h = Math.sqrt(innerRadius * innerRadius - dy * dy);
|
|
129
|
+
const y0 = r * cell + oy;
|
|
130
|
+
rows.push({
|
|
131
|
+
y0,
|
|
132
|
+
y1: y0 + cell,
|
|
133
|
+
x0: Math.floor(tx - h) * cell + ox,
|
|
134
|
+
x1: Math.ceil(tx + h) * cell + ox
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return rows;
|
|
138
|
+
}
|
|
139
|
+
function inStaircase(i, j, tx, ty, inner) {
|
|
140
|
+
if (!(inner > 0)) return false;
|
|
141
|
+
const dy = j + 0.5 - ty;
|
|
142
|
+
if (Math.abs(dy) > inner) return false;
|
|
143
|
+
const h = Math.sqrt(inner * inner - dy * dy);
|
|
144
|
+
return i >= Math.floor(tx - h) && i < Math.ceil(tx + h);
|
|
145
|
+
}
|
|
146
|
+
const EMPTY_POLYGON = "polygon(0 0, 0 0, 0 0)";
|
|
147
|
+
function staircaseVertices(rows) {
|
|
148
|
+
const pts = [];
|
|
149
|
+
for (const r of rows) pts.push(r.x1, r.y0, r.x1, r.y1);
|
|
150
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
151
|
+
const r = rows[i];
|
|
152
|
+
if (r) pts.push(r.x0, r.y1, r.x0, r.y0);
|
|
153
|
+
}
|
|
154
|
+
const out = [];
|
|
155
|
+
for (let i = 0; i < pts.length; i += 2) {
|
|
156
|
+
if (i > 0 && pts[i] === pts[i - 2] && pts[i + 1] === pts[i - 1]) continue;
|
|
157
|
+
out.push([pts[i] ?? 0, pts[i + 1] ?? 0]);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function staircasePolygon(rows) {
|
|
162
|
+
if (rows.length === 0) return EMPTY_POLYGON;
|
|
163
|
+
return `polygon(${staircaseVertices(rows).map(([x, y]) => `${x}px ${y}px`).join(", ")})`;
|
|
164
|
+
}
|
|
165
|
+
function staircaseHoleClip(rows, W, H) {
|
|
166
|
+
let d = `M0 0H${W}V${H}H0Z`;
|
|
167
|
+
const pts = rows.length > 0 ? staircaseVertices(rows) : [];
|
|
168
|
+
if (pts.length > 0) d += `M${pts.map(([x, y]) => `${x} ${y}`).join("L")}Z`;
|
|
169
|
+
return `path(evenodd, "${d}")`;
|
|
170
|
+
}
|
|
171
|
+
function paintHalo(ctx, p) {
|
|
172
|
+
const { cx: tx, cy: ty, R, halo, cell, ox, oy } = p;
|
|
173
|
+
if (!(R > 0) || !(halo > 0) || !(cell > 0)) return 0;
|
|
174
|
+
const dpr = p.dpr ?? 1;
|
|
175
|
+
const cols = Math.ceil(p.W / cell) + 1;
|
|
176
|
+
const rows = Math.ceil(p.H / cell) + 1;
|
|
177
|
+
const size = Math.max(1, Math.round(p.dot * dpr));
|
|
178
|
+
const Ri = R - halo;
|
|
179
|
+
let count = 0;
|
|
180
|
+
let lastColor = -1;
|
|
181
|
+
ctx.globalAlpha = 1;
|
|
182
|
+
const yEnd = Math.min(rows, Math.ceil(ty + R));
|
|
183
|
+
for (let y = Math.max(0, Math.floor(ty - R)); y < yEnd; y++) {
|
|
184
|
+
const dy = y + 0.5 - ty;
|
|
185
|
+
const hw = Math.sqrt(Math.max(0, R * R - dy * dy));
|
|
186
|
+
const iw = Ri > 0 && Math.abs(dy) < Ri ? Math.sqrt(Ri * Ri - dy * dy) : -1;
|
|
187
|
+
const skipA = iw > 1 ? Math.ceil(tx - iw + 1) : Infinity;
|
|
188
|
+
const skipB = iw > 1 ? Math.floor(tx + iw - 1) : -Infinity;
|
|
189
|
+
const x1 = Math.min(cols, Math.ceil(tx + hw));
|
|
190
|
+
const py = Math.round((y * cell + oy) * dpr);
|
|
191
|
+
for (let x = Math.max(0, Math.floor(tx - hw)); x < x1; x++) {
|
|
192
|
+
if (x >= skipA && x < skipB) {
|
|
193
|
+
x = skipB - 1;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const D = (R - Math.hypot(x + 0.5 - tx, dy)) / halo;
|
|
197
|
+
if (D < 0 || D > 1 || bayer4(x, y) > haloDensity(D)) continue;
|
|
198
|
+
const ci = haloColorIndex(D);
|
|
199
|
+
if (ci !== lastColor) {
|
|
200
|
+
ctx.fillStyle = p.palette[ci];
|
|
201
|
+
lastColor = ci;
|
|
202
|
+
}
|
|
203
|
+
const px = Math.round((x * cell + ox) * dpr);
|
|
204
|
+
ctx.fillRect(px, py, size, size);
|
|
205
|
+
if (p.glow) p.glow.push(px, py, rgbOf(p.palette[ci]), haloGlow(D));
|
|
206
|
+
count++;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return count;
|
|
210
|
+
}
|
|
211
|
+
function paintSheet(ctx, color, W, H, dpr, hole, keep) {
|
|
212
|
+
const X = (v) => Math.round(Math.min(W, Math.max(0, v)) * dpr);
|
|
213
|
+
const Y = (v) => Math.round(Math.min(H, Math.max(0, v)) * dpr);
|
|
214
|
+
const band = (x0, y0, x1, y1) => {
|
|
215
|
+
const ax = X(x0);
|
|
216
|
+
const ay = Y(y0);
|
|
217
|
+
const w = X(x1) - ax;
|
|
218
|
+
const h = Y(y1) - ay;
|
|
219
|
+
if (w > 0 && h > 0) ctx.fillRect(ax, ay, w, h);
|
|
220
|
+
};
|
|
221
|
+
ctx.globalAlpha = 1;
|
|
222
|
+
ctx.fillStyle = color;
|
|
223
|
+
if (!hole || hole.length === 0) {
|
|
224
|
+
band(0, 0, W, H);
|
|
225
|
+
} else {
|
|
226
|
+
const first = hole[0];
|
|
227
|
+
const last = hole[hole.length - 1];
|
|
228
|
+
if (first) band(0, 0, W, first.y0);
|
|
229
|
+
for (const r of hole) {
|
|
230
|
+
band(0, r.y0, r.x0, r.y1);
|
|
231
|
+
band(r.x1, r.y0, W, r.y1);
|
|
232
|
+
}
|
|
233
|
+
if (last) band(0, last.y1, W, H);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function createLens(o) {
|
|
237
|
+
const lerp = o.lerp ?? 0.35;
|
|
238
|
+
const inMs = o.inMs ?? 140;
|
|
239
|
+
const outMs = o.outMs ?? 260;
|
|
240
|
+
let x = 0;
|
|
241
|
+
let y = 0;
|
|
242
|
+
let r = 0;
|
|
243
|
+
let on = false;
|
|
244
|
+
let last = null;
|
|
245
|
+
const lens = {
|
|
246
|
+
get x() {
|
|
247
|
+
return x;
|
|
248
|
+
},
|
|
249
|
+
get y() {
|
|
250
|
+
return y;
|
|
251
|
+
},
|
|
252
|
+
get r() {
|
|
253
|
+
return r;
|
|
254
|
+
},
|
|
255
|
+
radius: o.radius,
|
|
256
|
+
resetClock() {
|
|
257
|
+
last = null;
|
|
258
|
+
},
|
|
259
|
+
step(nowMs, target, reduced) {
|
|
260
|
+
const frame = 1e3 / 60;
|
|
261
|
+
const dt = last === null ? frame : Math.min(64, Math.max(0, nowMs - last));
|
|
262
|
+
last = nowMs;
|
|
263
|
+
if (target.on && !on && r === 0) {
|
|
264
|
+
x = target.x;
|
|
265
|
+
y = target.y;
|
|
266
|
+
}
|
|
267
|
+
on = target.on;
|
|
268
|
+
const g = on ? Math.max(0, lens.radius) : 0;
|
|
269
|
+
if (reduced) {
|
|
270
|
+
x = target.x;
|
|
271
|
+
y = target.y;
|
|
272
|
+
r = g;
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
const k = 1 - Math.pow(1 - lerp, dt / frame);
|
|
276
|
+
x += (target.x - x) * k;
|
|
277
|
+
y += (target.y - y) * k;
|
|
278
|
+
r += (g - r) * (1 - Math.exp(-3 * dt / (on ? inMs : outMs)));
|
|
279
|
+
if (Math.abs(g - r) < 0.3) r = g;
|
|
280
|
+
return r !== g || Math.abs(target.x - x) + Math.abs(target.y - y) > 0.05;
|
|
281
|
+
},
|
|
282
|
+
covers(i, j) {
|
|
283
|
+
return r > 0.5 && Math.hypot(i + 0.5 - x, j + 0.5 - y) <= r;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
return lens;
|
|
287
|
+
}
|
|
288
|
+
function mergeOptions(base, next) {
|
|
289
|
+
return {
|
|
290
|
+
radius: next.radius ?? base.radius,
|
|
291
|
+
cell: next.cell ?? base.cell,
|
|
292
|
+
dot: next.dot ?? base.dot,
|
|
293
|
+
palette: next.palette ?? base.palette,
|
|
294
|
+
nightAlpha: next.nightAlpha ?? base.nightAlpha,
|
|
295
|
+
horizon: next.horizon ?? base.horizon,
|
|
296
|
+
lens: next.lens ?? base.lens,
|
|
297
|
+
lensRadius: next.lensRadius ?? base.lensRadius,
|
|
298
|
+
checked: next.checked ?? base.checked,
|
|
299
|
+
reducedMotion: next.reducedMotion ?? base.reducedMotion
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function paintSun(ctx, raster, o) {
|
|
303
|
+
const { cell, dpr } = o;
|
|
304
|
+
const size = Math.max(1, Math.round(Math.min(o.dot, cell) * dpr));
|
|
305
|
+
const f = o.front;
|
|
306
|
+
const ftx = f ? f.cx / cell : 0;
|
|
307
|
+
const fty = f ? f.cy / cell : 0;
|
|
308
|
+
const fin = f ? f.R / cell : 0;
|
|
309
|
+
let lastStyle = "";
|
|
310
|
+
let lastAlpha = -1;
|
|
311
|
+
const tint = [];
|
|
312
|
+
for (const c of raster.cells) {
|
|
313
|
+
let day = o.checked;
|
|
314
|
+
let ink = o.ink;
|
|
315
|
+
if (f) {
|
|
316
|
+
if (inStaircase(c.x, c.y, ftx, fty, fin)) {
|
|
317
|
+
day = f.nextChecked;
|
|
318
|
+
} else {
|
|
319
|
+
day = !f.nextChecked;
|
|
320
|
+
ink = f.oldInk;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
let style;
|
|
324
|
+
let alpha;
|
|
325
|
+
let mix = 0;
|
|
326
|
+
const lensed = !!o.lens && o.lens.covers(c.x, c.y);
|
|
327
|
+
if (lensed || c.layer === "sun" && day) {
|
|
328
|
+
style = o.palette[Math.min(3, Math.max(0, c.color))];
|
|
329
|
+
alpha = 1;
|
|
330
|
+
if (!lensed) mix = DAY_REST_INK;
|
|
331
|
+
} else {
|
|
332
|
+
style = ink;
|
|
333
|
+
alpha = c.layer === "sun" ? o.nightAlpha : HORIZON_ALPHA;
|
|
334
|
+
}
|
|
335
|
+
if (alpha <= 0) continue;
|
|
336
|
+
const px = Math.round(c.x * cell * dpr);
|
|
337
|
+
const py = Math.round(c.y * cell * dpr);
|
|
338
|
+
if (o.glow && alpha === 1) {
|
|
339
|
+
const rgb = rgbOf(style);
|
|
340
|
+
if (lensed) {
|
|
341
|
+
o.glow.push(px, py, rgb, c.layer === "sun" ? SUN_GLOW_LENS : HORIZON_GLOW_LENS);
|
|
342
|
+
} else if (mix > 0 && rgb >= 0) {
|
|
343
|
+
const inkC = parseInk(ink);
|
|
344
|
+
const inkRgb = rgbOf(ink);
|
|
345
|
+
const t = inkC && inkRgb >= 0 ? mix * inkC.a : 0;
|
|
346
|
+
o.glow.push(px, py, t > 0 ? mixRgb(rgb, inkRgb, t) : rgb, SUN_GLOW_DAY);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (style !== lastStyle) {
|
|
350
|
+
ctx.fillStyle = style;
|
|
351
|
+
lastStyle = style;
|
|
352
|
+
}
|
|
353
|
+
if (alpha !== lastAlpha) {
|
|
354
|
+
ctx.globalAlpha = alpha;
|
|
355
|
+
lastAlpha = alpha;
|
|
356
|
+
}
|
|
357
|
+
ctx.fillRect(px, py, size, size);
|
|
358
|
+
if (mix > 0) tint.push(px, py, ink);
|
|
359
|
+
}
|
|
360
|
+
for (let i = 0; i < tint.length; i += 3) {
|
|
361
|
+
const style = tint[i + 2];
|
|
362
|
+
if (style !== lastStyle) {
|
|
363
|
+
ctx.fillStyle = style;
|
|
364
|
+
lastStyle = style;
|
|
365
|
+
}
|
|
366
|
+
if (lastAlpha !== DAY_REST_INK) {
|
|
367
|
+
ctx.globalAlpha = DAY_REST_INK;
|
|
368
|
+
lastAlpha = DAY_REST_INK;
|
|
369
|
+
}
|
|
370
|
+
ctx.fillRect(tint[i], tint[i + 1], size, size);
|
|
371
|
+
}
|
|
372
|
+
ctx.globalAlpha = 1;
|
|
373
|
+
}
|
|
374
|
+
function createSunPainter(canvas, opts) {
|
|
375
|
+
const maybe = typeof canvas.getContext === "function" ? canvas.getContext("2d") : null;
|
|
376
|
+
if (!maybe) return null;
|
|
377
|
+
const ctx = maybe;
|
|
378
|
+
let o = mergeOptions(opts, {});
|
|
379
|
+
let raster = rasterSun({ radius: o.radius, horizon: o.horizon });
|
|
380
|
+
let ink = "rgb(0, 0, 0)";
|
|
381
|
+
let dpr = 1;
|
|
382
|
+
let front = null;
|
|
383
|
+
let glowTarget = null;
|
|
384
|
+
const lens = createLens({ radius: o.lensRadius });
|
|
385
|
+
const target = { x: 0, y: 0, on: false };
|
|
386
|
+
let raf = 0;
|
|
387
|
+
let suspended = false;
|
|
388
|
+
let destroyed = false;
|
|
389
|
+
let dirty = false;
|
|
390
|
+
const g = globalThis;
|
|
391
|
+
const request = (cb) => g.requestAnimationFrame ? g.requestAnimationFrame(cb) : 0;
|
|
392
|
+
const cancel = (id) => {
|
|
393
|
+
if (id && g.cancelAnimationFrame) g.cancelAnimationFrame(id);
|
|
394
|
+
};
|
|
395
|
+
function paint() {
|
|
396
|
+
dirty = false;
|
|
397
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
398
|
+
const hdr = glowTarget;
|
|
399
|
+
hdr?.sink.clear();
|
|
400
|
+
paintSun(ctx, raster, {
|
|
401
|
+
cell: o.cell,
|
|
402
|
+
dot: o.dot,
|
|
403
|
+
dpr,
|
|
404
|
+
palette: o.palette,
|
|
405
|
+
nightAlpha: o.nightAlpha,
|
|
406
|
+
checked: o.checked,
|
|
407
|
+
ink,
|
|
408
|
+
lens: o.lens ? lens : null,
|
|
409
|
+
front,
|
|
410
|
+
glow: hdr?.sink ?? null
|
|
411
|
+
});
|
|
412
|
+
hdr?.render(
|
|
413
|
+
canvas.width,
|
|
414
|
+
canvas.height,
|
|
415
|
+
Math.max(1, Math.round(Math.min(o.dot, o.cell) * dpr))
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
function frame(now) {
|
|
419
|
+
raf = 0;
|
|
420
|
+
if (destroyed || suspended) return;
|
|
421
|
+
const moving = o.lens ? lens.step(now, target, o.reducedMotion) : false;
|
|
422
|
+
paint();
|
|
423
|
+
if (moving || front) raf = request(frame);
|
|
424
|
+
}
|
|
425
|
+
function kick() {
|
|
426
|
+
if (destroyed) return;
|
|
427
|
+
if (suspended) {
|
|
428
|
+
dirty = true;
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (raf) return;
|
|
432
|
+
if (!g.requestAnimationFrame) {
|
|
433
|
+
paint();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
lens.resetClock();
|
|
437
|
+
raf = request(frame);
|
|
438
|
+
}
|
|
439
|
+
function resize() {
|
|
440
|
+
if (destroyed) return;
|
|
441
|
+
dpr = g.devicePixelRatio && g.devicePixelRatio > 0 ? g.devicePixelRatio : 1;
|
|
442
|
+
const css = raster.size * o.cell;
|
|
443
|
+
const w = Math.max(1, Math.round(css * dpr));
|
|
444
|
+
if (canvas.width !== w) canvas.width = w;
|
|
445
|
+
if (canvas.height !== w) canvas.height = w;
|
|
446
|
+
if (suspended) dirty = true;
|
|
447
|
+
else paint();
|
|
448
|
+
}
|
|
449
|
+
resize();
|
|
450
|
+
return {
|
|
451
|
+
setOptions(next) {
|
|
452
|
+
if (destroyed) return;
|
|
453
|
+
const prev = o;
|
|
454
|
+
o = mergeOptions(o, next);
|
|
455
|
+
lens.radius = o.lensRadius;
|
|
456
|
+
if (o.radius !== prev.radius || o.horizon !== prev.horizon) {
|
|
457
|
+
raster = rasterSun({ radius: o.radius, horizon: o.horizon });
|
|
458
|
+
}
|
|
459
|
+
if (o.radius !== prev.radius || o.cell !== prev.cell || o.horizon !== prev.horizon) {
|
|
460
|
+
resize();
|
|
461
|
+
}
|
|
462
|
+
kick();
|
|
463
|
+
},
|
|
464
|
+
setInk(css) {
|
|
465
|
+
if (destroyed || !css || css === ink) return;
|
|
466
|
+
ink = css;
|
|
467
|
+
kick();
|
|
468
|
+
},
|
|
469
|
+
pointer(cellX, cellY, on) {
|
|
470
|
+
if (destroyed) return;
|
|
471
|
+
target.x = cellX;
|
|
472
|
+
target.y = cellY;
|
|
473
|
+
target.on = on && o.lens;
|
|
474
|
+
kick();
|
|
475
|
+
},
|
|
476
|
+
setFront(next) {
|
|
477
|
+
if (destroyed) return;
|
|
478
|
+
front = next;
|
|
479
|
+
kick();
|
|
480
|
+
},
|
|
481
|
+
setGlowTarget(next) {
|
|
482
|
+
if (destroyed) return;
|
|
483
|
+
glowTarget = next;
|
|
484
|
+
if (suspended) dirty = true;
|
|
485
|
+
else paint();
|
|
486
|
+
},
|
|
487
|
+
resize,
|
|
488
|
+
wake() {
|
|
489
|
+
if (destroyed) return;
|
|
490
|
+
const was = suspended;
|
|
491
|
+
suspended = false;
|
|
492
|
+
if (was || dirty) {
|
|
493
|
+
lens.resetClock();
|
|
494
|
+
paint();
|
|
495
|
+
}
|
|
496
|
+
if (!raf && (front || o.lens && (target.on || lens.r > 0))) {
|
|
497
|
+
lens.resetClock();
|
|
498
|
+
raf = request(frame);
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
sleep() {
|
|
502
|
+
suspended = true;
|
|
503
|
+
cancel(raf);
|
|
504
|
+
raf = 0;
|
|
505
|
+
},
|
|
506
|
+
destroy() {
|
|
507
|
+
destroyed = true;
|
|
508
|
+
cancel(raf);
|
|
509
|
+
raf = 0;
|
|
510
|
+
front = null;
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
export {
|
|
515
|
+
BAYER4,
|
|
516
|
+
DAY_REST_INK,
|
|
517
|
+
EMPTY_POLYGON,
|
|
518
|
+
HALO_EXPONENT,
|
|
519
|
+
HORIZON_ALPHA,
|
|
520
|
+
HORIZON_GLOW_LENS,
|
|
521
|
+
REFLECTION_ROWS,
|
|
522
|
+
SUN_GLOW_DAY,
|
|
523
|
+
SUN_GLOW_LENS,
|
|
524
|
+
SUN_PALETTE,
|
|
525
|
+
bayer4,
|
|
526
|
+
coverRadiusCells,
|
|
527
|
+
createLens,
|
|
528
|
+
createSunPainter,
|
|
529
|
+
easeInOutCubic,
|
|
530
|
+
gridOffset,
|
|
531
|
+
haloColorIndex,
|
|
532
|
+
haloDensity,
|
|
533
|
+
haloGlow,
|
|
534
|
+
hash2,
|
|
535
|
+
inStaircase,
|
|
536
|
+
mixRgb,
|
|
537
|
+
paintHalo,
|
|
538
|
+
paintSheet,
|
|
539
|
+
paintSun,
|
|
540
|
+
parseInk,
|
|
541
|
+
rasterSun,
|
|
542
|
+
rgbOf,
|
|
543
|
+
staircaseHoleClip,
|
|
544
|
+
staircasePolygon,
|
|
545
|
+
staircaseRows
|
|
546
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SunSwitch HDR layer — framework-free, byte-identical in the Svelte, React
|
|
3
|
+
* and Vue trees (see shared-cores.json).
|
|
4
|
+
*
|
|
5
|
+
* The sun and the wave halo are painted in 2D canvases, which stop at SDR
|
|
6
|
+
* white. On HDR displays a WebGPU canvas is laid over each one
|
|
7
|
+
* (`rgba16float`, `colorSpace: "srgb"`, `toneMapping: { mode: "extended" }`)
|
|
8
|
+
* and the painted squares that carry a glow are drawn again there as hard
|
|
9
|
+
* squares at `glow ×` their colour, alpha 1: one instanced quad per square,
|
|
10
|
+
* no blur, no falloff term in the shader. The halo stays made of dithered
|
|
11
|
+
* cells; nothing soft is added.
|
|
12
|
+
*
|
|
13
|
+
* Encoding: the canvas reads its values as extended (gamma-encoded) sRGB, so
|
|
14
|
+
* each channel is sent as `encodeExt(srgbToLinear(c) × glow)`, computed on
|
|
15
|
+
* the CPU when a square is pushed. A glow of exactly 1 reproduces the 2D dot.
|
|
16
|
+
*
|
|
17
|
+
* One GPUDevice per page, reference-counted across layers; each layer owns
|
|
18
|
+
* its context, uniform, instance buffer and bind group. Nothing touches
|
|
19
|
+
* `window` or `navigator` at import.
|
|
20
|
+
*/
|
|
21
|
+
import type { GlowSink } from "./sun-switch-core.js";
|
|
22
|
+
/** SDR white ≈ 203 nits; 1000 nits / 203 ≈ 4.9. Every glow is clamped to it. */
|
|
23
|
+
export declare const SUN_HDR_PEAK = 4.9;
|
|
24
|
+
/**
|
|
25
|
+
* A lost device usually comes back (GPU process restarted, driver reset). The
|
|
26
|
+
* component starts its layer again after `SUN_HDR_RESTART_MS × attempt`, up to
|
|
27
|
+
* `SUN_HDR_RESTARTS` times per mount, before dropping the HDR canvas for good.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SUN_HDR_RESTARTS = 3;
|
|
30
|
+
export declare const SUN_HDR_RESTART_MS = 600;
|
|
31
|
+
/** sRGB channel (0–255) → linear light. */
|
|
32
|
+
export declare function srgbToLinear(c8: number): number;
|
|
33
|
+
/** Linear light → extended-sRGB encoded value; keeps going above 1 for HDR. */
|
|
34
|
+
export declare function encodeExt(v: number): number;
|
|
35
|
+
/** One channel (0–255) at `glow ×` SDR, encoded for the extended-sRGB canvas. */
|
|
36
|
+
export declare function encodeGlowChannel(c8: number, glow: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Sync and SSR-safe: WebGPU is exposed and the display reports
|
|
39
|
+
* `(dynamic-range: high)`. Decides whether an HDR canvas is created at all.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sunHdrAvailable(): boolean;
|
|
42
|
+
/** Next power of two ≥ n, at least the start capacity. */
|
|
43
|
+
export declare function hdrCapacityFor(n: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* The squares of one frame, encoded as they are pushed. Painters fill it
|
|
46
|
+
* through {@link GlowSink}; the layer uploads it as is.
|
|
47
|
+
*/
|
|
48
|
+
export interface SunHdrSquares extends GlowSink {
|
|
49
|
+
/** Squares pushed since the last `clear`. */
|
|
50
|
+
readonly n: number;
|
|
51
|
+
/** `FPI` floats per square; valid up to `n × 8`. */
|
|
52
|
+
readonly data: Float32Array<ArrayBuffer>;
|
|
53
|
+
}
|
|
54
|
+
export declare function createSunHdrSquares(): SunHdrSquares;
|
|
55
|
+
export interface SunHdrLayer {
|
|
56
|
+
/** Filled by the painter for the next `render`. */
|
|
57
|
+
readonly sink: SunHdrSquares;
|
|
58
|
+
/** Draws the squares in `sink` on a `width × height` backing, `size` device px each. */
|
|
59
|
+
render(width: number, height: number, size: number): void;
|
|
60
|
+
destroy(): void;
|
|
61
|
+
/** Resolves when the shared device is lost; the 2D picture carries on. */
|
|
62
|
+
readonly lost: Promise<void>;
|
|
63
|
+
/** Squares drawn by the last `render` (diagnostics, tests). */
|
|
64
|
+
readonly count: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Starts a layer on `canvas`. Resolves null when WebGPU, the adapter, the
|
|
68
|
+
* context or extended tone mapping is missing; never throws.
|
|
69
|
+
*/
|
|
70
|
+
export declare function startSunHdr(canvas: HTMLCanvasElement): Promise<SunHdrLayer | null>;
|