Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/web-haptics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { version } from "./../package.json";

export { WebHaptics } from "./lib/web-haptics";
export { defaultPatterns } from "./lib/web-haptics/patterns";
export type { DefaultPatternName } from "./lib/web-haptics/patterns";
export type {
Vibration,
HapticPattern,
Expand Down
2 changes: 2 additions & 0 deletions packages/web-haptics/src/lib/web-haptics/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ export const defaultPatterns = {
pattern: [{ duration: 1000, intensity: 1 }],
},
} as const satisfies Record<string, HapticPreset>;

export type DefaultPatternName = keyof typeof defaultPatterns;
8 changes: 7 additions & 1 deletion packages/web-haptics/src/lib/web-haptics/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { DefaultPatternName } from "./patterns";

export interface Vibration {
duration: number;
intensity?: number;
Expand All @@ -10,7 +12,11 @@ export interface HapticPreset {
pattern: Vibration[];
}

export type HapticInput = number | string | HapticPattern | HapticPreset;
export type HapticInput =
| number
| DefaultPatternName
| HapticPattern
| HapticPreset;

export interface TriggerOptions {
intensity?: number;
Expand Down