Skip to content

Commit

Permalink
✨ feat: Add "npm run setup" command to "docs
Browse files Browse the repository at this point in the history
The package.json file has been modified to include the "npm run setup" command in the "docs:build" and "docs:dev" scripts. This change allows for easier setup and documentation building.

Add try-catch block to define SpeechRecognition variable in useRecognition.ts

A try-catch block has been added to the useRecognition.ts file to define the SpeechRecognition variable. This change improves error handling and ensures the variable is properly defined.
  • Loading branch information
canisminor1990 committed Nov 12, 2023
1 parent 4b8018a commit cddbebb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
"build:server": "tsc server.ts --declaration",
"ci": "npm run lint && npm run type-check",
"dev": "father dev",
"docs:build": "dumi build",
"docs:build": "npm run setup && dumi build",
"docs:build-analyze": "ANALYZE=1 dumi build",
"docs:dev": "dumi dev",
"docs:dev": "npm run setup && dumi dev",
"doctor": "father doctor",
"postinstall": "npm run setup",
"lint": "eslint \"{src,api,lib}/**/*.{js,jsx,ts,tsx}\" --fix",
"lint:md": "remark . --quiet --frail --output",
"prepare": "husky install",
Expand Down
9 changes: 6 additions & 3 deletions src/useSpeechRecognition/useRecognition.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { useCallback, useEffect, useState } from 'react';

const SpeechRecognition =
// @ts-ignore
(globalThis as any)?.SpeechRecognition || (window as any)?.webkitSpeechRecognition;
let SpeechRecognition: any;

try {
SpeechRecognition =
(globalThis as any)?.SpeechRecognition || (window as any)?.webkitSpeechRecognition;
} catch {}

export const useRecognition = (
locale: string,
Expand Down

0 comments on commit cddbebb

Please sign in to comment.