chore: update documentation

This commit is contained in:
Lucas Nogueira
2026-09-22 11:30:47 -03:00
parent d869c162a7
commit a87a3c7d44
104 changed files with 4875 additions and 222 deletions
+14
View File
@@ -73,12 +73,26 @@ export const commands = {
/** user-defined types **/
export type Error = never
/**
* The style of an impact-feedback haptic.
*
* On iOS this maps directly to a `UIImpactFeedbackGenerator.FeedbackStyle` case. On Android,
* which has no equivalent system API, each style instead plays a distinct vibration waveform of
* increasing intensity. Has no effect on desktop platforms. Defaults to `Medium`.
*/
export type ImpactFeedbackStyle =
| 'light'
| 'medium'
| 'heavy'
| 'soft'
| 'rigid'
/**
* The type of notification feedback, indicating the outcome of a task or action.
*
* On iOS this maps directly to a `UINotificationFeedbackGenerator.FeedbackType` case. On
* Android, which has no equivalent system API, each type instead plays a distinct vibration
* waveform. Has no effect on desktop platforms. Defaults to `Success`.
*/
export type NotificationFeedbackType = 'success' | 'warning' | 'error'
//export type RandomNumber = number;
+93 -7
View File
@@ -2,16 +2,102 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/* eslint-disable @typescript-eslint/unbound-method */
/**
* Trigger haptic feedback on Android and iOS.
*
* @module
*/
import { commands } from './bindings'
import type {
ImpactFeedbackStyle,
NotificationFeedbackType,
Result,
Error
} from './bindings'
export const {
vibrate,
impactFeedback,
notificationFeedback,
selectionFeedback
} = commands
/**
* Triggers a vibration for `duration` milliseconds.
*
* Has no effect on desktop platforms.
*
* @example
* ```typescript
* import { vibrate } from '@tauri-apps/plugin-haptics'
* await vibrate(300)
* ```
*
* @param duration Duration of the vibration, in milliseconds.
* @returns A promise resolving to the {@link Result} of the operation.
* @since 2.0.0
*/
export async function vibrate(duration: number): Promise<Result<null, Error>> {
return commands.vibrate(duration)
}
/**
* Triggers an impact-feedback haptic, indicating a collision between user interface elements.
*
* On iOS this maps to a `UIImpactFeedbackGenerator` of the given style. On Android, which has
* no equivalent system API, each style plays a distinct vibration waveform. Has no effect on
* desktop platforms.
*
* @example
* ```typescript
* import { impactFeedback } from '@tauri-apps/plugin-haptics'
* await impactFeedback('medium')
* ```
*
* @param style The style of the impact.
* @returns A promise resolving to the {@link Result} of the operation.
* @since 2.0.0
*/
export async function impactFeedback(
style: ImpactFeedbackStyle
): Promise<Result<null, Error>> {
return commands.impactFeedback(style)
}
/**
* Triggers a notification-feedback haptic, indicating the outcome of a task or action.
*
* On iOS this maps to a `UINotificationFeedbackGenerator` of the given type. On Android, which
* has no equivalent system API, each type plays a distinct vibration waveform. Has no effect on
* desktop platforms.
*
* @example
* ```typescript
* import { notificationFeedback } from '@tauri-apps/plugin-haptics'
* await notificationFeedback('success')
* ```
*
* @param type The outcome to convey.
* @returns A promise resolving to the {@link Result} of the operation.
* @since 2.0.0
*/
export async function notificationFeedback(
type: NotificationFeedbackType
): Promise<Result<null, Error>> {
return commands.notificationFeedback(type)
}
/**
* Triggers a haptic indicating that a selection changed, e.g. the value of a picker control.
*
* Has no effect on desktop platforms.
*
* @example
* ```typescript
* import { selectionFeedback } from '@tauri-apps/plugin-haptics'
* await selectionFeedback()
* ```
*
* @returns A promise resolving to the {@link Result} of the operation.
* @since 2.0.0
*/
export async function selectionFeedback(): Promise<Result<null, Error>> {
return commands.selectionFeedback()
}
export { ImpactFeedbackStyle, NotificationFeedbackType } from './bindings'