fancy-ui-vue 0.1.1 → 0.3.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 +40 -13
- 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/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/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/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/typing-indicator/TypingIndicator.vue.js +1 -1
- package/dist/components/typing-indicator/TypingIndicator.vue2.js +7 -6
- package/dist/index.d.ts +6 -0
- package/dist/index.js +440 -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 +974 -571
- package/package.json +2 -2
- package/tailwind.css +9 -9
|
@@ -102,6 +102,9 @@ const anchorPosition = (node, opts) => {
|
|
|
102
102
|
const anchorEl = options.anchor();
|
|
103
103
|
if (!anchorEl) return;
|
|
104
104
|
const anchorRect = anchorEl.getBoundingClientRect();
|
|
105
|
+
node.style.position = "fixed";
|
|
106
|
+
node.style.left = "0px";
|
|
107
|
+
node.style.top = "0px";
|
|
105
108
|
const { x, y, side, align } = computePosition(anchorRect, measureFloating(), {
|
|
106
109
|
side: options.side,
|
|
107
110
|
align: options.align,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls a callback prop that may arrive as a single function or as an array of
|
|
3
|
+
* functions. Vue merges a listener attached at two levels (a wrapper component
|
|
4
|
+
* and its parent both writing `@click` on the same root) into an array, so a
|
|
5
|
+
* declared `onClick` prop cannot assume it holds one function.
|
|
6
|
+
*
|
|
7
|
+
* For an array whose first argument is an Event, an earlier handler calling
|
|
8
|
+
* `event.stopImmediatePropagation()` stops the later ones, matching Vue's own
|
|
9
|
+
* DOM listener invoker.
|
|
10
|
+
*/
|
|
11
|
+
export declare function callListener<A extends unknown[]>(listener: ((...args: A) => void) | ((...args: A) => void)[] | undefined, ...args: A): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function callListener(listener, ...args) {
|
|
2
|
+
if (!listener) return;
|
|
3
|
+
if (Array.isArray(listener)) {
|
|
4
|
+
const event = args[0];
|
|
5
|
+
if (!(event instanceof Event)) {
|
|
6
|
+
for (const fn of listener) if (typeof fn === "function") fn(...args);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let stopped = false;
|
|
10
|
+
const hadOwn = Object.prototype.hasOwnProperty.call(event, "stopImmediatePropagation");
|
|
11
|
+
const original = event.stopImmediatePropagation;
|
|
12
|
+
event.stopImmediatePropagation = () => {
|
|
13
|
+
original.call(event);
|
|
14
|
+
stopped = true;
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
for (const fn of listener) {
|
|
18
|
+
if (stopped) break;
|
|
19
|
+
if (typeof fn === "function") fn(...args);
|
|
20
|
+
}
|
|
21
|
+
} finally {
|
|
22
|
+
if (hadOwn) event.stopImmediatePropagation = original;
|
|
23
|
+
else delete event.stopImmediatePropagation;
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (typeof listener === "function") listener(...args);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
callListener
|
|
31
|
+
};
|
|
@@ -27,6 +27,23 @@ export interface DismissableOptions {
|
|
|
27
27
|
* behaviour every caller had before this option existed.
|
|
28
28
|
*/
|
|
29
29
|
active?: () => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether an outside press that dismisses should keep the focus the
|
|
32
|
+
* overlay hands back. Defaults to false. Only an overlay that returns focus
|
|
33
|
+
* to a trigger on dismiss passes true (dialog, sheet, drawer, popover, menu,
|
|
34
|
+
* command menu). A panel anchored to an input that keeps focus while it is
|
|
35
|
+
* open (combobox, autocomplete) leaves it off: there the press must blur
|
|
36
|
+
* the input as usual, or the field stays focused, a focus-to-open field
|
|
37
|
+
* never reopens on the next click, and a touch keyboard stays up.
|
|
38
|
+
*
|
|
39
|
+
* With `outsideClick: false` it also keeps focus that is inside the layer
|
|
40
|
+
* through an outside press that does not dismiss, so a modal that ignores
|
|
41
|
+
* such presses does not lose focus to `<body>`. That case cancels every
|
|
42
|
+
* outside mousedown while the layer holds focus, so only a modal layer may
|
|
43
|
+
* combine the two: a non-modal one that ignores outside presses (a
|
|
44
|
+
* non-dismissible popover) leaves `keepFocus` off and the page untouched.
|
|
45
|
+
*/
|
|
46
|
+
keepFocus?: boolean;
|
|
30
47
|
}
|
|
31
48
|
export declare const dismissable: DismissableAction<DismissableOptions>;
|
|
32
49
|
/** Test-only. Not exported from index.ts. */
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
const layers = [];
|
|
2
|
+
const FOCUS_TAKING_SELECTOR = 'a[href], area[href], button, input, select, textarea, label, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';
|
|
3
|
+
const TOUCH_MOUSEDOWN_WINDOW_MS = 750;
|
|
4
|
+
function keepFocusThroughPress(target) {
|
|
5
|
+
const el = target instanceof Element ? target : target.parentElement;
|
|
6
|
+
if (el?.closest(FOCUS_TAKING_SELECTOR)) return;
|
|
7
|
+
let timer;
|
|
8
|
+
let armed = true;
|
|
9
|
+
function preventBlur(event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
disarm();
|
|
12
|
+
}
|
|
13
|
+
function handlePointerup(event) {
|
|
14
|
+
const pointerType = event.pointerType;
|
|
15
|
+
if (pointerType === "touch" || pointerType === "pen") {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
timer = setTimeout(disarm, TOUCH_MOUSEDOWN_WINDOW_MS);
|
|
18
|
+
} else {
|
|
19
|
+
queueMicrotask(disarm);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function disarm() {
|
|
23
|
+
if (!armed) return;
|
|
24
|
+
armed = false;
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
document.removeEventListener("mousedown", preventBlur, true);
|
|
27
|
+
document.removeEventListener("click", disarm, true);
|
|
28
|
+
document.removeEventListener("pointercancel", disarm, true);
|
|
29
|
+
document.removeEventListener("contextmenu", disarm, true);
|
|
30
|
+
document.removeEventListener("pointerup", handlePointerup, true);
|
|
31
|
+
}
|
|
32
|
+
document.addEventListener("mousedown", preventBlur, true);
|
|
33
|
+
document.addEventListener("click", disarm, true);
|
|
34
|
+
document.addEventListener("pointercancel", disarm, true);
|
|
35
|
+
document.addEventListener("contextmenu", disarm, true);
|
|
36
|
+
document.addEventListener("pointerup", handlePointerup, true);
|
|
37
|
+
}
|
|
2
38
|
const dismissable = (node, opts) => {
|
|
3
39
|
if (typeof document === "undefined") {
|
|
4
40
|
return {};
|
|
@@ -8,6 +44,7 @@ const dismissable = (node, opts) => {
|
|
|
8
44
|
let outsideClick = opts.outsideClick ?? true;
|
|
9
45
|
let exclude = opts.exclude;
|
|
10
46
|
let isActive = opts.active ?? (() => true);
|
|
47
|
+
let keepFocus = opts.keepFocus ?? false;
|
|
11
48
|
function isTopLayer() {
|
|
12
49
|
for (let i = layers.length - 1; i >= 0; i -= 1) {
|
|
13
50
|
const candidate = layers[i];
|
|
@@ -25,12 +62,17 @@ const dismissable = (node, opts) => {
|
|
|
25
62
|
}
|
|
26
63
|
function handlePointerdown(event) {
|
|
27
64
|
if (!isActive()) return;
|
|
28
|
-
if (!outsideClick) return;
|
|
65
|
+
if (!outsideClick && !keepFocus) return;
|
|
29
66
|
if (!isTopLayer()) return;
|
|
30
67
|
const target = event.target;
|
|
31
68
|
if (!target || node.contains(target)) return;
|
|
32
69
|
const excluded = exclude?.() ?? [];
|
|
33
70
|
if (excluded.some((el) => el?.contains(target))) return;
|
|
71
|
+
if (!outsideClick) {
|
|
72
|
+
if (node.contains(document.activeElement)) keepFocusThroughPress(target);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (keepFocus) keepFocusThroughPress(target);
|
|
34
76
|
onDismiss();
|
|
35
77
|
}
|
|
36
78
|
const layer = { node, isActive: () => isActive() };
|
|
@@ -44,6 +86,7 @@ const dismissable = (node, opts) => {
|
|
|
44
86
|
outsideClick = newOpts.outsideClick ?? true;
|
|
45
87
|
exclude = newOpts.exclude;
|
|
46
88
|
isActive = newOpts.active ?? (() => true);
|
|
89
|
+
keepFocus = newOpts.keepFocus ?? false;
|
|
47
90
|
},
|
|
48
91
|
destroy() {
|
|
49
92
|
const i = layers.indexOf(layer);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isDev: boolean;
|
|
@@ -14,8 +14,33 @@ function isVisible(el) {
|
|
|
14
14
|
}
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
+
function radioGroupKey(el) {
|
|
18
|
+
if (!(el instanceof HTMLInputElement) || el.type !== "radio" || !el.name) return null;
|
|
19
|
+
return el.name;
|
|
20
|
+
}
|
|
21
|
+
function sameTabStop(a, b) {
|
|
22
|
+
if (a === b) return true;
|
|
23
|
+
if (!a) return false;
|
|
24
|
+
const key = radioGroupKey(a);
|
|
25
|
+
return key !== null && key === radioGroupKey(b) && a.form === b.form;
|
|
26
|
+
}
|
|
17
27
|
function getFocusableElements(node) {
|
|
18
|
-
|
|
28
|
+
const visible = Array.from(node.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
|
|
29
|
+
isVisible
|
|
30
|
+
);
|
|
31
|
+
return visible.filter((el) => {
|
|
32
|
+
if (radioGroupKey(el) === null) return true;
|
|
33
|
+
const group = visible.filter((other) => sameTabStop(other, el));
|
|
34
|
+
const stop = group.find((radio) => radio.checked) ?? group[0];
|
|
35
|
+
return stop === el;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function backwardEntry(node, stop) {
|
|
39
|
+
if (radioGroupKey(stop) === null || stop.checked) return stop;
|
|
40
|
+
const group = Array.from(node.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
|
|
41
|
+
(el) => isVisible(el) && sameTabStop(el, stop)
|
|
42
|
+
);
|
|
43
|
+
return group[group.length - 1] ?? stop;
|
|
19
44
|
}
|
|
20
45
|
const focusTrap = (node, opts = {}) => {
|
|
21
46
|
if (typeof document === "undefined") {
|
|
@@ -74,11 +99,11 @@ const focusTrap = (node, opts = {}) => {
|
|
|
74
99
|
if (!first || !last) return;
|
|
75
100
|
const active = document.activeElement;
|
|
76
101
|
if (event.shiftKey) {
|
|
77
|
-
if (active
|
|
102
|
+
if (sameTabStop(active, first) || !node.contains(active)) {
|
|
78
103
|
event.preventDefault();
|
|
79
|
-
last.focus();
|
|
104
|
+
backwardEntry(node, last).focus();
|
|
80
105
|
}
|
|
81
|
-
} else if (active
|
|
106
|
+
} else if (sameTabStop(active, last) || !node.contains(active)) {
|
|
82
107
|
event.preventDefault();
|
|
83
108
|
first.focus();
|
|
84
109
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joins id lists (each possibly space-separated) into one `aria-describedby`
|
|
3
|
+
* value: tokens are split on whitespace, de-duplicated in first-seen order, and
|
|
4
|
+
* the result is `undefined` when nothing is left.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mergeIds(...parts: Array<string | null | undefined | false>): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function mergeIds(...parts) {
|
|
2
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3
|
+
for (const part of parts) {
|
|
4
|
+
if (!part) continue;
|
|
5
|
+
for (const token of part.split(/\s+/)) if (token) seen.add(token);
|
|
6
|
+
}
|
|
7
|
+
return seen.size > 0 ? [...seen].join(" ") : void 0;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
mergeIds
|
|
11
|
+
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* for the identity/purity gate this file must keep passing.
|
|
8
8
|
*
|
|
9
9
|
* Framework-free means exactly that: no `import ... from "react"` (or
|
|
10
|
-
* "svelte"/"vue"), no
|
|
10
|
+
* "svelte"/"vue"), no bundler env reads, no `window`/`document`/`navigator`
|
|
11
11
|
* read at module scope. DOM types (`HTMLElement`, `Element`) are fine — they
|
|
12
12
|
* come from `lib.dom.d.ts`, not from a framework — and so is calling into a
|
|
13
13
|
* DOM API from inside a function, which only ever happens once a real node
|
package/dist/sound/engine.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SOUND_MIN_INTERVAL_MS, SOUND_LIMITS } from "./types.js";
|
|
2
2
|
import { FANCY_SOUND_THEME } from "./themes.js";
|
|
3
|
+
const EXP_FLOOR = 1e-4;
|
|
3
4
|
function clamp(value, min, max) {
|
|
4
5
|
return Math.min(max, Math.max(min, value));
|
|
5
6
|
}
|
|
@@ -85,10 +86,10 @@ function createSoundEngine(options = {}) {
|
|
|
85
86
|
if (typeof context.createDynamicsCompressor === "function") {
|
|
86
87
|
try {
|
|
87
88
|
const comp = context.createDynamicsCompressor();
|
|
88
|
-
comp.threshold.value = -
|
|
89
|
-
comp.knee.value =
|
|
90
|
-
comp.ratio.value =
|
|
91
|
-
comp.attack.value =
|
|
89
|
+
comp.threshold.value = -3;
|
|
90
|
+
comp.knee.value = 0;
|
|
91
|
+
comp.ratio.value = 20;
|
|
92
|
+
comp.attack.value = 1e-3;
|
|
92
93
|
comp.release.value = 0.1;
|
|
93
94
|
master.connect(comp);
|
|
94
95
|
comp.connect(context.destination);
|
|
@@ -163,8 +164,12 @@ function createSoundEngine(options = {}) {
|
|
|
163
164
|
if (layer.detune) osc.detune.value = layer.detune;
|
|
164
165
|
if (layer.frequencyEnd != null) {
|
|
165
166
|
const freqEnd = layer.frequencyEnd * pitchMul;
|
|
167
|
+
const glideMs = layer.glide != null && Number.isFinite(layer.glide) && layer.glide > 0 ? Math.min(layer.glide, durationMs) : durationMs;
|
|
166
168
|
osc.frequency.setValueAtTime(freqStart, t0);
|
|
167
|
-
osc.frequency.exponentialRampToValueAtTime(
|
|
169
|
+
osc.frequency.exponentialRampToValueAtTime(
|
|
170
|
+
Math.max(1, freqEnd),
|
|
171
|
+
t0 + glideMs / 1e3 / rate
|
|
172
|
+
);
|
|
168
173
|
}
|
|
169
174
|
source = osc;
|
|
170
175
|
} else {
|
|
@@ -201,12 +206,21 @@ function createSoundEngine(options = {}) {
|
|
|
201
206
|
const r = Math.max(layer.envelope.release, SOUND_LIMITS.MIN_RELEASE_MS) / 1e3 / rate;
|
|
202
207
|
const sustain = layer.envelope.sustain;
|
|
203
208
|
const peak = Math.min(layer.gain * recipeGain * volume, SOUND_LIMITS.LAYER_PEAK_CEILING);
|
|
204
|
-
const
|
|
209
|
+
const tDecayEnd = t0 + a + d;
|
|
210
|
+
const tRel = Math.max(t0 + durationSec - r, tDecayEnd);
|
|
205
211
|
gainNode.gain.setValueAtTime(0, t0);
|
|
206
212
|
gainNode.gain.linearRampToValueAtTime(peak, t0 + a);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
if (layer.envelope.curve === "exponential" && peak > EXP_FLOOR) {
|
|
214
|
+
const held = Math.max(peak * sustain, EXP_FLOOR);
|
|
215
|
+
if (d > 0) gainNode.gain.exponentialRampToValueAtTime(held, tDecayEnd);
|
|
216
|
+
gainNode.gain.setValueAtTime(held, tRel);
|
|
217
|
+
gainNode.gain.exponentialRampToValueAtTime(EXP_FLOOR, tRel + r);
|
|
218
|
+
gainNode.gain.setValueAtTime(0, tRel + r);
|
|
219
|
+
} else {
|
|
220
|
+
gainNode.gain.linearRampToValueAtTime(peak * sustain, tDecayEnd);
|
|
221
|
+
gainNode.gain.setValueAtTime(peak * sustain, tRel);
|
|
222
|
+
gainNode.gain.linearRampToValueAtTime(0, tRel + r);
|
|
223
|
+
}
|
|
210
224
|
if (layer.kind === "noise") source.start(t0, noiseStartOffset);
|
|
211
225
|
else source.start(t0);
|
|
212
226
|
source.stop(t0 + durationSec + 0.01);
|
package/dist/sound/themes.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sound themes — pure data plus a validator.
|
|
3
3
|
*
|
|
4
|
-
* `FANCY_SOUND_THEME` is the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `FANCY_SOUND_THEME` is the FancyUI palette: short tactile taps (one
|
|
5
|
+
* oscillator, a fast downward pitch sweep under an exponential decay) and a
|
|
6
|
+
* quiet sine bell kept for success. No noise, no held notes. Ascending pairs
|
|
7
|
+
* and sweeps read as positive/open, descending ones as negative/close.
|
|
7
8
|
*/
|
|
8
9
|
import { type SoundThemeDefinition, type SoundThemeName } from "./types.js";
|
|
9
10
|
export declare const FANCY_SOUND_THEME: SoundThemeDefinition;
|
package/dist/sound/themes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SOUND_CUES, SOUND_LIMITS } from "./types.js";
|
|
2
|
-
function
|
|
3
|
-
return { attack, decay, sustain, release };
|
|
2
|
+
function exp(attack, decay, sustain, release) {
|
|
3
|
+
return { attack, decay, sustain, release, curve: "exponential" };
|
|
4
4
|
}
|
|
5
5
|
function deepFreeze(value) {
|
|
6
6
|
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
@@ -11,243 +11,75 @@ function deepFreeze(value) {
|
|
|
11
11
|
}
|
|
12
12
|
return value;
|
|
13
13
|
}
|
|
14
|
+
function tap(frequency, frequencyEnd, gain, decay, extra = {}) {
|
|
15
|
+
return {
|
|
16
|
+
kind: "oscillator",
|
|
17
|
+
wave: "triangle",
|
|
18
|
+
frequency,
|
|
19
|
+
frequencyEnd,
|
|
20
|
+
glide: 2 + decay,
|
|
21
|
+
gain,
|
|
22
|
+
envelope: exp(2, decay, 0, 8),
|
|
23
|
+
duration: 2 + decay + 8,
|
|
24
|
+
...extra
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function bell(frequency, gain, decay, delay = 0) {
|
|
28
|
+
return {
|
|
29
|
+
kind: "oscillator",
|
|
30
|
+
wave: "sine",
|
|
31
|
+
frequency,
|
|
32
|
+
gain,
|
|
33
|
+
envelope: exp(2, decay, 0, 10),
|
|
34
|
+
duration: 2 + decay + 10,
|
|
35
|
+
delay
|
|
36
|
+
};
|
|
37
|
+
}
|
|
14
38
|
const FANCY_CUES = {
|
|
39
|
+
// Bright and tiny: present under the pointer, gone before it registers as a sound.
|
|
15
40
|
hover: {
|
|
16
|
-
layers: [
|
|
17
|
-
{
|
|
18
|
-
kind: "oscillator",
|
|
19
|
-
wave: "sine",
|
|
20
|
-
frequency: 1760,
|
|
21
|
-
frequencyEnd: 1975,
|
|
22
|
-
gain: 0.12,
|
|
23
|
-
envelope: env(2, 20, 0, 20),
|
|
24
|
-
duration: 45,
|
|
25
|
-
filter: { type: "highpass", frequency: 800 }
|
|
26
|
-
}
|
|
27
|
-
]
|
|
41
|
+
layers: [tap(1680, 420, 0.5, 10, { wave: "sine" })]
|
|
28
42
|
},
|
|
43
|
+
// The reference cue every other one is tuned against.
|
|
29
44
|
press: {
|
|
30
|
-
layers: [
|
|
31
|
-
{
|
|
32
|
-
kind: "oscillator",
|
|
33
|
-
wave: "triangle",
|
|
34
|
-
frequency: 520,
|
|
35
|
-
frequencyEnd: 440,
|
|
36
|
-
gain: 0.5,
|
|
37
|
-
envelope: env(2, 35, 0, 25),
|
|
38
|
-
duration: 70
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
kind: "noise",
|
|
42
|
-
gain: 0.18,
|
|
43
|
-
envelope: env(1, 18, 0, 8),
|
|
44
|
-
duration: 30,
|
|
45
|
-
filter: { type: "bandpass", frequency: 2400, q: 1.2 }
|
|
46
|
-
}
|
|
47
|
-
]
|
|
45
|
+
layers: [tap(850, 160, 0.8, 18)]
|
|
48
46
|
},
|
|
49
47
|
"toggle-on": {
|
|
50
|
-
layers: [
|
|
51
|
-
{
|
|
52
|
-
kind: "oscillator",
|
|
53
|
-
wave: "sine",
|
|
54
|
-
frequency: 660,
|
|
55
|
-
gain: 0.4,
|
|
56
|
-
envelope: env(3, 30, 0.2, 20),
|
|
57
|
-
duration: 55
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
kind: "oscillator",
|
|
61
|
-
wave: "sine",
|
|
62
|
-
frequency: 880,
|
|
63
|
-
gain: 0.4,
|
|
64
|
-
envelope: env(3, 40, 0, 25),
|
|
65
|
-
duration: 70,
|
|
66
|
-
delay: 45,
|
|
67
|
-
filter: { type: "lowpass", frequency: 4e3 }
|
|
68
|
-
}
|
|
69
|
-
]
|
|
48
|
+
layers: [tap(700, 150, 0.6, 16), tap(1100, 240, 0.6, 16, { delay: 45 })]
|
|
70
49
|
},
|
|
71
50
|
"toggle-off": {
|
|
72
|
-
layers: [
|
|
73
|
-
{
|
|
74
|
-
kind: "oscillator",
|
|
75
|
-
wave: "sine",
|
|
76
|
-
frequency: 880,
|
|
77
|
-
gain: 0.35,
|
|
78
|
-
envelope: env(3, 30, 0.2, 20),
|
|
79
|
-
duration: 55
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
kind: "oscillator",
|
|
83
|
-
wave: "sine",
|
|
84
|
-
frequency: 660,
|
|
85
|
-
gain: 0.32,
|
|
86
|
-
envelope: env(3, 35, 0, 20),
|
|
87
|
-
duration: 60,
|
|
88
|
-
delay: 45,
|
|
89
|
-
filter: { type: "lowpass", frequency: 3500 }
|
|
90
|
-
}
|
|
91
|
-
]
|
|
51
|
+
layers: [tap(1100, 240, 0.55, 16), tap(700, 150, 0.55, 16, { delay: 45 })]
|
|
92
52
|
},
|
|
53
|
+
// Rising and falling sine sweeps: direction tells open from close.
|
|
93
54
|
open: {
|
|
94
55
|
layers: [
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
wave: "triangle",
|
|
98
|
-
frequency: 392,
|
|
99
|
-
frequencyEnd: 784,
|
|
100
|
-
gain: 0.35,
|
|
101
|
-
envelope: env(5, 60, 0.3, 30),
|
|
102
|
-
duration: 110
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
kind: "noise",
|
|
106
|
-
gain: 0.08,
|
|
107
|
-
envelope: env(10, 50, 0, 30),
|
|
108
|
-
duration: 90,
|
|
109
|
-
filter: { type: "highpass", frequency: 3e3, frequencyEnd: 6e3 }
|
|
110
|
-
}
|
|
56
|
+
tap(420, 1260, 0.45, 34, { wave: "sine", glide: 24 }),
|
|
57
|
+
tap(850, 160, 0.35, 14, { delay: 4 })
|
|
111
58
|
]
|
|
112
59
|
},
|
|
113
60
|
close: {
|
|
114
61
|
layers: [
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
wave: "triangle",
|
|
118
|
-
frequency: 784,
|
|
119
|
-
frequencyEnd: 392,
|
|
120
|
-
gain: 0.3,
|
|
121
|
-
envelope: env(4, 50, 0.2, 30),
|
|
122
|
-
duration: 100
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
kind: "noise",
|
|
126
|
-
gain: 0.06,
|
|
127
|
-
envelope: env(5, 40, 0, 30),
|
|
128
|
-
duration: 80,
|
|
129
|
-
filter: { type: "lowpass", frequency: 1500, frequencyEnd: 600 }
|
|
130
|
-
}
|
|
62
|
+
tap(1260, 380, 0.4, 34, { wave: "sine", glide: 24 }),
|
|
63
|
+
tap(700, 140, 0.35, 14, { delay: 26 })
|
|
131
64
|
]
|
|
132
65
|
},
|
|
133
66
|
select: {
|
|
134
|
-
layers: [
|
|
135
|
-
{
|
|
136
|
-
kind: "oscillator",
|
|
137
|
-
wave: "sine",
|
|
138
|
-
frequency: 1046.5,
|
|
139
|
-
gain: 0.35,
|
|
140
|
-
envelope: env(2, 40, 0, 25),
|
|
141
|
-
duration: 70
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
kind: "oscillator",
|
|
145
|
-
wave: "sine",
|
|
146
|
-
frequency: 1568,
|
|
147
|
-
gain: 0.12,
|
|
148
|
-
envelope: env(2, 30, 0, 18),
|
|
149
|
-
duration: 50,
|
|
150
|
-
delay: 10
|
|
151
|
-
}
|
|
152
|
-
]
|
|
67
|
+
layers: [tap(1150, 230, 0.7, 14)]
|
|
153
68
|
},
|
|
154
69
|
success: {
|
|
155
|
-
layers: [
|
|
156
|
-
{
|
|
157
|
-
kind: "oscillator",
|
|
158
|
-
wave: "sine",
|
|
159
|
-
frequency: 523.25,
|
|
160
|
-
gain: 0.35,
|
|
161
|
-
envelope: env(4, 60, 0.3, 40),
|
|
162
|
-
duration: 110,
|
|
163
|
-
filter: { type: "lowpass", frequency: 5e3 }
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
kind: "oscillator",
|
|
167
|
-
wave: "sine",
|
|
168
|
-
frequency: 659.25,
|
|
169
|
-
gain: 0.35,
|
|
170
|
-
envelope: env(4, 60, 0.3, 40),
|
|
171
|
-
duration: 110,
|
|
172
|
-
delay: 70,
|
|
173
|
-
filter: { type: "lowpass", frequency: 5e3 }
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
kind: "oscillator",
|
|
177
|
-
wave: "sine",
|
|
178
|
-
frequency: 783.99,
|
|
179
|
-
gain: 0.4,
|
|
180
|
-
envelope: env(4, 60, 0.3, 40),
|
|
181
|
-
duration: 150,
|
|
182
|
-
delay: 140,
|
|
183
|
-
filter: { type: "lowpass", frequency: 5e3 }
|
|
184
|
-
}
|
|
185
|
-
]
|
|
70
|
+
layers: [tap(850, 160, 0.6, 18), bell(1046.5, 0.22, 110, 30), bell(1568, 0.18, 140, 90)]
|
|
186
71
|
},
|
|
187
72
|
error: {
|
|
188
73
|
layers: [
|
|
189
|
-
{
|
|
190
|
-
|
|
191
|
-
wave: "sawtooth",
|
|
192
|
-
frequency: 220,
|
|
193
|
-
detune: -8,
|
|
194
|
-
gain: 0.3,
|
|
195
|
-
envelope: env(5, 70, 0.4, 40),
|
|
196
|
-
duration: 130,
|
|
197
|
-
filter: { type: "lowpass", frequency: 900 }
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
kind: "oscillator",
|
|
201
|
-
wave: "sawtooth",
|
|
202
|
-
frequency: 233,
|
|
203
|
-
detune: 8,
|
|
204
|
-
gain: 0.3,
|
|
205
|
-
envelope: env(5, 70, 0.4, 40),
|
|
206
|
-
duration: 130,
|
|
207
|
-
delay: 110,
|
|
208
|
-
filter: { type: "lowpass", frequency: 900 }
|
|
209
|
-
}
|
|
74
|
+
tap(320, 120, 0.3, 40, { filter: { type: "lowpass", frequency: 1600 } }),
|
|
75
|
+
tap(240, 95, 0.3, 50, { delay: 95, filter: { type: "lowpass", frequency: 1600 } })
|
|
210
76
|
]
|
|
211
77
|
},
|
|
212
78
|
tick: {
|
|
213
|
-
layers: [
|
|
214
|
-
{
|
|
215
|
-
kind: "noise",
|
|
216
|
-
gain: 0.2,
|
|
217
|
-
envelope: env(1, 12, 0, 8),
|
|
218
|
-
duration: 22,
|
|
219
|
-
filter: { type: "bandpass", frequency: 3500, q: 2 }
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
kind: "oscillator",
|
|
223
|
-
wave: "sine",
|
|
224
|
-
frequency: 2093,
|
|
225
|
-
gain: 0.08,
|
|
226
|
-
envelope: env(1, 15, 0, 8),
|
|
227
|
-
duration: 25
|
|
228
|
-
}
|
|
229
|
-
]
|
|
79
|
+
layers: [tap(2700, 675, 0.3, 8, { wave: "sine" })]
|
|
230
80
|
},
|
|
231
81
|
copy: {
|
|
232
|
-
layers: [
|
|
233
|
-
{
|
|
234
|
-
kind: "noise",
|
|
235
|
-
gain: 0.15,
|
|
236
|
-
envelope: env(1, 10, 0, 8),
|
|
237
|
-
duration: 20,
|
|
238
|
-
filter: { type: "bandpass", frequency: 5e3, q: 1 }
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
kind: "oscillator",
|
|
242
|
-
wave: "sine",
|
|
243
|
-
frequency: 1318.5,
|
|
244
|
-
frequencyEnd: 1760,
|
|
245
|
-
gain: 0.3,
|
|
246
|
-
envelope: env(2, 50, 0, 25),
|
|
247
|
-
duration: 80,
|
|
248
|
-
delay: 8
|
|
249
|
-
}
|
|
250
|
-
]
|
|
82
|
+
layers: [tap(1300, 260, 0.6, 14), tap(1800, 360, 0.55, 14, { delay: 40 })]
|
|
251
83
|
}
|
|
252
84
|
};
|
|
253
85
|
const FANCY_SOUND_THEME = deepFreeze({
|
|
@@ -301,6 +133,9 @@ function validateSoundTheme(theme) {
|
|
|
301
133
|
if (Number.isFinite(layer.envelope.sustain) && (layer.envelope.sustain < 0 || layer.envelope.sustain > 1)) {
|
|
302
134
|
problems.push(`${label}: envelope.sustain must be between 0 and 1`);
|
|
303
135
|
}
|
|
136
|
+
if (layer.envelope.curve != null && layer.envelope.curve !== "linear" && layer.envelope.curve !== "exponential") {
|
|
137
|
+
problems.push(`${label}: invalid envelope.curve "${layer.envelope.curve}"`);
|
|
138
|
+
}
|
|
304
139
|
const requiredSpan = layer.envelope.attack + layer.envelope.decay + layer.envelope.release;
|
|
305
140
|
if (Number.isFinite(layer.duration) && layer.duration < requiredSpan) {
|
|
306
141
|
problems.push(`${label}: duration must be >= attack + decay + release`);
|
|
@@ -318,6 +153,9 @@ function validateSoundTheme(theme) {
|
|
|
318
153
|
if (layer.frequencyEnd != null && (!Number.isFinite(layer.frequencyEnd) || layer.frequencyEnd <= 0)) {
|
|
319
154
|
problems.push(`${label}: frequencyEnd must be a finite number > 0`);
|
|
320
155
|
}
|
|
156
|
+
if (layer.glide != null && (!Number.isFinite(layer.glide) || layer.glide <= 0 || Number.isFinite(layer.duration) && layer.glide > layer.duration)) {
|
|
157
|
+
problems.push(`${label}: glide must be a finite number > 0 and <= duration`);
|
|
158
|
+
}
|
|
321
159
|
if (layer.detune != null && !Number.isFinite(layer.detune)) {
|
|
322
160
|
problems.push(`${label}: detune must be a finite number`);
|
|
323
161
|
}
|
package/dist/sound/types.d.ts
CHANGED
|
@@ -41,6 +41,12 @@ export interface SoundEnvelope {
|
|
|
41
41
|
decay: number;
|
|
42
42
|
sustain: number;
|
|
43
43
|
release: number;
|
|
44
|
+
/**
|
|
45
|
+
* Shape of the decay and release segments. `"linear"` (default) ramps
|
|
46
|
+
* straight to the target; `"exponential"` falls off like a struck object,
|
|
47
|
+
* which is what makes short percussive taps sound natural. Attack is always linear.
|
|
48
|
+
*/
|
|
49
|
+
curve?: "linear" | "exponential";
|
|
44
50
|
}
|
|
45
51
|
export interface SoundFilter {
|
|
46
52
|
type: "lowpass" | "highpass" | "bandpass" | "notch" | "peaking";
|
|
@@ -65,8 +71,10 @@ export interface SoundOscillatorLayer extends SoundLayerBase {
|
|
|
65
71
|
wave: SoundWave;
|
|
66
72
|
/** Hz at start. */
|
|
67
73
|
frequency: number;
|
|
68
|
-
/** Hz at end; exponential glide over `duration` when set. */
|
|
74
|
+
/** Hz at end; exponential glide over `glide` (default `duration`) when set. */
|
|
69
75
|
frequencyEnd?: number;
|
|
76
|
+
/** Ms to reach `frequencyEnd`, > 0 and <= `duration`. Default `duration`. */
|
|
77
|
+
glide?: number;
|
|
70
78
|
/** Cents. Default 0. */
|
|
71
79
|
detune?: number;
|
|
72
80
|
}
|
package/dist/sound/types.js
CHANGED