diff --git a/package.json b/package.json index 5e5dfa1..96d5d92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-pitch-detector", - "version": "0.1.2", + "version": "0.1.3", "description": "High performance real time pitch detection.", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -140,4 +140,4 @@ "dependencies": { "react-native-permissions": "^3.8.0" } -} +} \ No newline at end of file diff --git a/src/internal/erros/__tests__/errors.spec.ts b/src/internal/erros/__tests__/errors.spec.ts index ec02571..67c66d5 100644 --- a/src/internal/erros/__tests__/errors.spec.ts +++ b/src/internal/erros/__tests__/errors.spec.ts @@ -1,9 +1,9 @@ -import { PicthDetectorErrors } from '../../../types'; -import { PicthDetectorError } from '..'; +import { PitchDetectorErrors } from '../../../types'; +import { PitchDetectorError } from '..'; describe('Errors', () => { it('should create base error', () => { - const error: any = new PicthDetectorError(PicthDetectorErrors.BASE); + const error: any = new PitchDetectorError(PitchDetectorErrors.BASE); expect(error?.message).toMatch(/You are not using Expo Go/); expect(error?.message).toMatch( @@ -12,16 +12,16 @@ describe('Errors', () => { }); it('should create link error', () => { - const error: any = new PicthDetectorError( - PicthDetectorErrors.LINKING_ERROR + const error: any = new PitchDetectorError( + PitchDetectorErrors.LINKING_ERROR ); expect(error?.message).toMatch(/doesn't seem to be linked/); }); it('should create permission error', () => { - const error: any = new PicthDetectorError( - PicthDetectorErrors.PERMISSIONS_ERROR + const error: any = new PitchDetectorError( + PitchDetectorErrors.PERMISSIONS_ERROR ); expect(error?.message).toMatch(/need audio record permission/); diff --git a/src/internal/erros/index.ts b/src/internal/erros/index.ts index 9947378..6b01a0e 100644 --- a/src/internal/erros/index.ts +++ b/src/internal/erros/index.ts @@ -1,5 +1,5 @@ import { Platform } from 'react-native'; -import { PicthDetectorErrors } from '../../types'; +import { PitchDetectorErrors } from '../../types'; const base = `The package 'react-native-pitch-detector' find a error. Make sure: \n\n` + @@ -22,13 +22,13 @@ const permission = android: `- You have added '' on AndroidManifest.xml and request permission before start record.\n`, }); -export class PicthDetectorError { - constructor(type: PicthDetectorErrors) { - if (type === PicthDetectorErrors.LINKING_ERROR) { +export class PitchDetectorError { + constructor(type: PitchDetectorErrors) { + if (type === PitchDetectorErrors.LINKING_ERROR) { return new Error(linking); } - if (type === PicthDetectorErrors.PERMISSIONS_ERROR) { + if (type === PitchDetectorErrors.PERMISSIONS_ERROR) { return new Error(permission); } diff --git a/src/internal/pitch-detector/__tests__/pitch-detector.spec.ts b/src/internal/pitch-detector/__tests__/pitch-detector.spec.ts index 9884fea..69642bc 100644 --- a/src/internal/pitch-detector/__tests__/pitch-detector.spec.ts +++ b/src/internal/pitch-detector/__tests__/pitch-detector.spec.ts @@ -1,7 +1,7 @@ import { NativeModules } from 'react-native'; -import { PicthDetectorErrors } from '../../../types'; -import { PicthDetectorError } from '../../erros'; +import { PitchDetectorErrors } from '../../../types'; +import { PitchDetectorError } from '../../erros'; import { Permissions } from '../../permissions'; import { PitchDetector } from '..'; @@ -54,7 +54,7 @@ describe('PitchDetector', () => { }); it('should throw error when start method will be called and not have audio record permission', async () => { - const error = new PicthDetectorError(PicthDetectorErrors.PERMISSIONS_ERROR); + const error = new PitchDetectorError(PitchDetectorErrors.PERMISSIONS_ERROR); const spy = jest.spyOn(console, 'warn'); Permissions.audio = asyncMock(false); diff --git a/src/internal/pitch-detector/index.ts b/src/internal/pitch-detector/index.ts index c6c9144..69f5675 100644 --- a/src/internal/pitch-detector/index.ts +++ b/src/internal/pitch-detector/index.ts @@ -1,16 +1,16 @@ import { NativeModules, NativeEventEmitter, Platform } from 'react-native'; import { Permissions } from '../permissions'; -import { PicthDetectorError } from '../erros'; +import { PitchDetectorError } from '../erros'; import { merge } from '../utils'; import { type Callback, type NativeModuleImplementation, - type PicthDetectorConfig, + type PitchDetectorConfig, type Subscription, - type PicthDetectorAndroidConfig, - type PicthDetectorIOSConfig, - PicthDetectorErrors, + type PitchDetectorAndroidConfig, + type PitchDetectorIOSConfig, + PitchDetectorErrors, } from '../../types'; export class InternalPitchDetector { @@ -24,13 +24,13 @@ export class InternalPitchDetector { this.event = new NativeEventEmitter(this.module); } else { /* istanbul ignore next */ - throw new PicthDetectorError(PicthDetectorErrors.LINKING_ERROR); + throw new PitchDetectorError(PitchDetectorErrors.LINKING_ERROR); } } /** - * Returns a default PicthDetector configs - * @returns PicthDetectorConfig + * Returns a default PitchDetector configs + * @returns PitchDetectorConfig * @example * ```ts * { @@ -46,7 +46,7 @@ export class InternalPitchDetector { * } * } */ - private getDefaultConfig(): PicthDetectorConfig { + private getDefaultConfig(): PitchDetectorConfig { return { android: { algorithm: 'YIN', @@ -88,15 +88,15 @@ export class InternalPitchDetector { * @param config * @returns Promise */ - async start(config?: PicthDetectorConfig): Promise { + async start(config?: PitchDetectorConfig): Promise { try { const permission = await this.hasPermissions(); if (!permission) { - throw new PicthDetectorError(PicthDetectorErrors.PERMISSIONS_ERROR); + throw new PitchDetectorError(PitchDetectorErrors.PERMISSIONS_ERROR); } - const configuration = merge( + const configuration = merge( this.getDefaultConfig(), config || {} ); @@ -104,7 +104,7 @@ export class InternalPitchDetector { const params = Platform.select({ android: configuration.android as unknown, ios: configuration.ios as unknown, - }) as PicthDetectorIOSConfig | PicthDetectorAndroidConfig; + }) as PitchDetectorIOSConfig | PitchDetectorAndroidConfig; await this.module?.start(params); } catch (err: unknown) { diff --git a/src/types/index.ts b/src/types/index.ts index 23372e5..d7d6475 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -29,7 +29,7 @@ export type PermissionsHandlers = { CheckPermission: (compare?: Comparable) => Response; }; -export enum PicthDetectorErrors { +export enum PitchDetectorErrors { BASE, LINKING_ERROR, PERMISSIONS_ERROR, @@ -100,14 +100,14 @@ export type PitchEstimationIOSAlgorithm = | 'QUINNS_SECOND' | 'YIN'; -export type PicthDetectorAndroidConfig = { +export type PitchDetectorAndroidConfig = { algorithm?: PitchEstimationAndroidAlgorithm; bufferOverLap?: Int32; bufferSize?: Int32; sampleRate?: Float; }; -export type PicthDetectorIOSConfig = { +export type PitchDetectorIOSConfig = { algorithm?: PitchEstimationIOSAlgorithm; bufferSize?: Int32; }; @@ -115,9 +115,9 @@ export type PicthDetectorIOSConfig = { /** * Pitch detector configuration. */ -export type PicthDetectorConfig = { - android?: PicthDetectorAndroidConfig; - ios?: PicthDetectorIOSConfig; +export type PitchDetectorConfig = { + android?: PitchDetectorAndroidConfig; + ios?: PitchDetectorIOSConfig; }; /** @@ -130,7 +130,7 @@ export interface NativeModuleImplementation extends NativeModule { * @returns Promise */ start: ( - config: PicthDetectorAndroidConfig | PicthDetectorIOSConfig + config: PitchDetectorAndroidConfig | PitchDetectorIOSConfig ) => Promise; /** diff --git a/website/docs/before-you-start.md b/website/docs/before-you-start.md index e70991d..a2937e4 100644 --- a/website/docs/before-you-start.md +++ b/website/docs/before-you-start.md @@ -1,6 +1,6 @@ # Before you start -React Native Picth Detector is a module created to be used alongside [React Native](https://github.com/facebook/react-native), so previous experience is required. If you need, can start with their [Getting Started](https://reactnative.dev/docs/getting-started) tutorial and come back here after. +React Native Pitch Detector is a module created to be used alongside [React Native](https://github.com/facebook/react-native), so previous experience is required. If you need, can start with their [Getting Started](https://reactnative.dev/docs/getting-started) tutorial and come back here after. This module is compatible with Android and iOS devices, we assume that you have Android and iOS environment configured, in the case that you don't have, we suggest that you setup enviroment before. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index a386a33..cfdb33c 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -6,7 +6,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula'); /** @type {import('@docusaurus/types').Config} */ const config = { - title: 'React Native Picth Detector', + title: 'React Native Pitch Detector', staticDirectories: ['static'], tagline: 'High performance real time pitch detection.', url: 'https://1fabiopereira.github.io/', @@ -51,9 +51,9 @@ const config = { /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ ({ navbar: { - title: 'React Native Picth Detector', + title: 'React Native Pitch Detector', logo: { - alt: 'React Native Picth Detector', + alt: 'React Native Pitch Detector', src: 'img/react-native-pitch-detector.svg', }, items: [