Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 react #320

Merged
merged 2 commits into from
Nov 27, 2023
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/react-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

- name: Build Local Web SDK
run: yarn && yarn copywasm && yarn build
working-directory: binding/web

- name: Build Local React SDK
run: yarn && yarn build
working-directory: binding/react

- name: Run Binding Linter
run: yarn && yarn lint
working-directory: binding/react
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/react-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

- name: Build Local Web SDK
run: yarn && yarn copywasm && yarn build
working-directory: binding/web

- name: Build Local React SDK
run: yarn && yarn build
working-directory: binding/react

- name: Install dependencies
run: yarn install

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

- name: Build Local Web SDK
run: yarn && yarn copywasm && yarn build
working-directory: binding/web

- name: Install dependencies
run: yarn install

Expand Down
10 changes: 6 additions & 4 deletions binding/react/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { WebVoiceProcessor } from '@picovoice/web-voice-processor';
import { act } from '@testing-library/react-hooks/dom';

const WAV_HEADER_SIZE = 44;

Cypress.Commands.add('wrapHook', (fn: () => Promise<void>) =>
cy.wrap(null).then(async () => {
await act(async () => {
Expand All @@ -15,7 +17,7 @@ Cypress.Commands.add('getFileObj', (path: string) => {
.then(blob => new File([blob], 'test_audio'));
});

Cypress.Commands.add('mockRecording', (path: string, delayMs = 1000) => {
Cypress.Commands.add('mockRecording', (path: string) => {
// @ts-ignore
const instance = WebVoiceProcessor.instance();

Expand All @@ -26,12 +28,12 @@ Cypress.Commands.add('mockRecording', (path: string, delayMs = 1000) => {
cy.fixture(path, 'base64')
.then(Cypress.Blob.base64StringToBlob)
.then(async blob => {
const data = new Int16Array(await blob.arrayBuffer());
let data = new Int16Array(await blob.arrayBuffer());
data = data.slice(WAV_HEADER_SIZE / Int16Array.BYTES_PER_ELEMENT);
for (let i = 0; i < data.length; i += 512) {
instance.recorderCallback(data.slice(i, i + 512));
}
})
.wait(delayMs);
});

instance._microphoneStream?.getAudioTracks().forEach((track: any) => {
track.enabled = true;
Expand Down
2 changes: 1 addition & 1 deletion binding/react/cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import './commands';

declare global {
namespace Cypress {

Check warning on line 4 in binding/react/cypress/support/index.ts

View workflow job for this annotation

GitHub Actions / check-react-codestyle

'Cypress' is defined but never used
interface Chainable {
wrapHook(fn: () => Promise<any>): Chainable<void>;

Check warning on line 6 in binding/react/cypress/support/index.ts

View workflow job for this annotation

GitHub Actions / check-react-codestyle

'fn' is defined but never used
getFileObj(path: string): Chainable<File>;

Check warning on line 7 in binding/react/cypress/support/index.ts

View workflow job for this annotation

GitHub Actions / check-react-codestyle

'path' is defined but never used
mockRecording(path: string, delayMs?: number): Chainable<void>;
mockRecording(path: string): Chainable<void>;

Check warning on line 8 in binding/react/cypress/support/index.ts

View workflow job for this annotation

GitHub Actions / check-react-codestyle

'path' is defined but never used
}
}
}
4 changes: 2 additions & 2 deletions binding/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/leopard-react",
"version": "1.2.0",
"version": "2.0.0",
"description": "React hook for Leopard Web SDK",
"entry": "src/index.ts",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"test": "cypress run --component"
},
"dependencies": {
"@picovoice/leopard-web": "=1.2.2"
"@picovoice/leopard-web": "=2.0.0"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand Down
Loading