Skip to content

Commit

Permalink
export utils from vad-react
Browse files Browse the repository at this point in the history
  • Loading branch information
ricky0123 committed May 13, 2023
1 parent e3c9d76 commit cf567b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react"
],
"homepage": "https://github.com/ricky0123/vad",
"version": "0.0.16",
"version": "0.0.17",
"license": "ISC",
"main": "dist/index.js",
"devDependencies": {
Expand Down
16 changes: 11 additions & 5 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MicVAD, defaultRealTimeVADOptions } from "@ricky0123/vad-web"
import type { RealTimeVADOptions } from "@ricky0123/vad-web"
import { useEffect, useReducer, useState } from "react"
import React from "react"
import { MicVAD, defaultRealTimeVADOptions } from "@ricky0123/vad-web"
import React, { useEffect, useReducer, useState } from "react"

export { utils } from "@ricky0123/vad-web"

interface ReactOptions {
startOnLoad: boolean
Expand Down Expand Up @@ -30,7 +31,9 @@ const _filter = (keys: string[], obj: any) => {
}, {} as { [key: string]: any })
}

function useOptions(options: Partial<ReactRealTimeVADOptions>): [ReactOptions, RealTimeVADOptions] {
function useOptions(
options: Partial<ReactRealTimeVADOptions>
): [ReactOptions, RealTimeVADOptions] {
options = { ...defaultReactRealTimeVADOptions, ...options }
const reactOptions = _filter(reactOptionKeys, options) as ReactOptions
const vadOptions = _filter(vadOptionKeys, options) as RealTimeVADOptions
Expand All @@ -45,7 +48,10 @@ function useEventCallback<T extends (...args: any[]) => any>(fn: T): T {
ref.current = fn
})

return React.useCallback((...args: any[]) => ref.current.apply(void 0, args), []) as T
return React.useCallback(
(...args: any[]) => ref.current.apply(void 0, args),
[]
) as T
}

export function useMicVAD(options: Partial<ReactRealTimeVADOptions>) {
Expand Down

0 comments on commit cf567b6

Please sign in to comment.