Skip to content
Closed
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
3 changes: 0 additions & 3 deletions .github/workflows/react-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
with:
node-version: lts/*

- name: Pre-build dependencies
run: npm install yarn

- name: Run Binding Linter
run: yarn && yarn lint
working-directory: binding/react
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/react-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
node-version: [ 16.x, 18.x, 20.x ]
node-version: [ 18.x, 20.x, 22.x, 24.x ]

steps:
- uses: actions/checkout@v3
Expand All @@ -36,8 +36,15 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
# ************** REMOVE AFTER RELEASE ********************
- name: Build Web SDK
run: yarn install && yarn copywasm && yarn copyppn && yarn build
working-directory: binding/web

- name: Install dependencies
run: yarn install && yarn build
working-directory: binding/react
# ************** REMOVE AFTER RELEASE ********************

- name: Install dependencies
run: yarn install
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
device: [ cpu:1, cpu ]
node-version: [ 18.x, 20.x, 22.x, 24.x ]

steps:
- uses: actions/checkout@v3
Expand All @@ -39,8 +40,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
# ************** REMOVE AFTER RELEASE ********************
- name: Build Web SDK
run: yarn install && yarn copywasm && yarn copyppn && yarn build
working-directory: binding/web
# ************** REMOVE AFTER RELEASE ********************

- name: Install dependencies
run: yarn install
Expand All @@ -55,4 +59,4 @@ jobs:
run: yarn setup-test

- name: Run test
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}}
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},DEVICE=${{ matrix.device }}
11 changes: 4 additions & 7 deletions .github/workflows/web-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
push:
branches: [ master ]
paths:
- '**/web/*.js'
- '**/web/*.ts'
- 'binding/web/*.js'
- 'binding/web/*.ts'
- '.github/workflows/web-codestyle.yml'
pull_request:
branches: [ master, 'v[0-9]+.[0-9]+' ]
paths:
- '**/web/*.js'
- '**/web/*.ts'
- 'binding/web/*.js'
- 'binding/web/*.ts'
- '.github/workflows/web-codestyle.yml'

jobs:
Expand All @@ -27,9 +27,6 @@ jobs:
with:
node-version: lts/*

- name: Pre-build dependencies
run: npm install yarn

- name: Run Binding Linter
run: yarn && yarn lint
working-directory: binding/web
9 changes: 6 additions & 3 deletions .github/workflows/web-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -35,8 +35,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
# ************** REMOVE AFTER RELEASE ********************
- name: Build Web SDK
run: yarn install && yarn copywasm && yarn copyppn && yarn build
working-directory: binding/web
# ************** REMOVE AFTER RELEASE ********************

- name: Install dependencies
run: yarn install
5 changes: 1 addition & 4 deletions .github/workflows/web-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn

- name: Install dependencies
run: yarn install

Expand All @@ -55,4 +52,4 @@ jobs:
run: yarn setup-test

- name: Test
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},NUM_TEST_ITERATIONS=20,INIT_PERFORMANCE_THRESHOLD_SEC=${{matrix.initPerformanceThresholdSec}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.procPerformanceThresholdSec}}
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},DEVICE=cpu:1,NUM_TEST_ITERATIONS=20,INIT_PERFORMANCE_THRESHOLD_SEC=${{matrix.initPerformanceThresholdSec}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.procPerformanceThresholdSec}}
8 changes: 3 additions & 5 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
device: [ cpu:1, cpu ]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -45,9 +46,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn

- name: Install dependencies
run: yarn install

Expand All @@ -61,4 +59,4 @@ jobs:
run: yarn setup-test

- name: Test
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}}
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},DEVICE=${{ matrix.device }}
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/rhino-react",
"version": "3.0.3",
"version": "4.0.0",
"description": "React component for Rhino Web SDK",
"entry": "src/index.ts",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -73,6 +73,6 @@
"react-dom": ">=17"
},
"dependencies": {
"@picovoice/rhino-web": "=3.0.3"
"@picovoice/rhino-web": "file:../web"
}
}
19 changes: 13 additions & 6 deletions binding/react/test/use_rhino.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import rhinoParams from '@/rhino_params.js';
import testData from './test_data.json';

const ACCESS_KEY = Cypress.env('ACCESS_KEY');
const DEVICE = Cypress.env('DEVICE');

describe('Rhino binding', () => {
it('should be able to init via public path', () => {
Expand All @@ -16,7 +17,8 @@ describe('Rhino binding', () => {
() => result.current.init(
ACCESS_KEY,
{ publicPath: "/test/contexts/coffee_maker_wasm.rhn", forceWrite: true },
{ publicPath: "/test/rhino_params.pv", forceWrite: true }
{ publicPath: "/test/rhino_params.pv", forceWrite: true },
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.true;
Expand All @@ -36,7 +38,8 @@ describe('Rhino binding', () => {
() => result.current.init(
ACCESS_KEY,
{ publicPath: "/test/contexts/coffee_maker_wasm.rhn", forceWrite: true },
{ base64: rhinoParams, forceWrite: true }
{ base64: rhinoParams, forceWrite: true },
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.true;
Expand All @@ -50,7 +53,8 @@ describe('Rhino binding', () => {
() => result.current.init(
ACCESS_KEY,
{ publicPath: "/test/contexts/coffee_maker_wasm.rhn", forceWrite: true },
{ publicPath: "/rhino_params_failed.pv", forceWrite: true }
{ publicPath: "/rhino_params_failed.pv", forceWrite: true },
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.false;
Expand All @@ -65,7 +69,8 @@ describe('Rhino binding', () => {
() => result.current.init(
'',
{ publicPath: "/test/contexts/coffee_maker_wasm.rhn", forceWrite: true },
{ publicPath: "/test/rhino_params.pv", forceWrite: true }
{ publicPath: "/test/rhino_params.pv", forceWrite: true },
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.false;
Expand All @@ -87,7 +92,8 @@ describe('Rhino binding', () => {
{
publicPath: testInfo.language === 'en' ? "/test/rhino_params.pv" : `/test/rhino_params_${testInfo.language}.pv`,
forceWrite: true,
}
},
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.true;
Expand Down Expand Up @@ -124,7 +130,8 @@ describe('Rhino binding', () => {
{
publicPath: testInfo.language === 'en' ? "/test/rhino_params.pv" : `/test/rhino_params_${testInfo.language}.pv`,
forceWrite: true,
}
},
{ device: DEVICE }
)
).then(() => {
expect(result.current.isLoaded).to.be.true;
Expand Down
2 changes: 1 addition & 1 deletion binding/web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
dist
lib/pv_rhino*.wasm
src/lib/*
src/rhino_64.ts
contexts/*.rhn
test/contexts/*.rhn
Expand Down
17 changes: 17 additions & 0 deletions binding/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,28 @@ Rhino is:
- Firefox
- Safari

## Requirements

The Eagle Web Binding uses [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).

Include the following headers in the response to enable the use of `SharedArrayBuffers`:

```
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
```

Refer to our [Web demo](../../demo/web) for an example on creating a server with the corresponding response headers.

Browsers that don't support `SharedArrayBuffers` or applications that don't include the required headers will fall back to using standard `ArrayBuffers`. This will disable multithreaded processing.

### Restrictions

IndexedDB is required to use `Rhino` in a worker thread. Browsers without IndexedDB support
(i.e. Firefox Incognito Mode) should use `Rhino` in the main thread.

Multi-threading is only enabled for Rhino when using on a web worker.

## Installation

### Package
Expand Down
10 changes: 9 additions & 1 deletion binding/web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
"PROC_PERFORMANCE_THRESHOLD_SEC": 1.2
},
e2e: {
defaultCommandTimeout: 30000,
supportFile: "cypress/support/index.ts",
specPattern: "test/*.test.{js,jsx,ts,tsx}",
video: false,
screenshotOnRunFailure: false,
defaultCommandTimeout: 30000,
setupNodeEvents(on, config) {

Check warning on line 15 in binding/web/cypress.config.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

'config' is defined but never used
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--enable-features=SharedArrayBuffer');
}
return launchOptions;
});
},
},
});
2 changes: 1 addition & 1 deletion binding/web/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["cypress"]
"types": ["cypress", "node"]
},
"include": [
"../test/**/*.ts",
Expand Down
5 changes: 5 additions & 0 deletions binding/web/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ declare module "*.rhn" {
export default content;
}

declare module "*.txt" {
const content: string;
export default content;
}

declare module 'web-worker:*' {
const WorkerFactory: new () => Worker;
export default WorkerFactory;
Expand Down
12 changes: 7 additions & 5 deletions binding/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Rhino Speech-to-Intent engine for web browsers (via WebAssembly)",
"author": "Picovoice Inc",
"license": "Apache-2.0",
"version": "3.0.3",
"version": "4.0.0",
"keywords": [
"rhino",
"web",
Expand All @@ -29,11 +29,11 @@
"format": "prettier --write \"**/*.{js,ts,json}\"",
"copywasm": "node scripts/copy_wasm.js",
"setup-test": "node scripts/setup_test.js && npx pvbase64 -i ./test/rhino_params.pv -o ./test/rhino_params.js",
"test": "cypress run --spec test/rhino.test.ts",
"test-perf": "cypress run --spec test/rhino_perf.test.ts"
"test": "cypress run --spec test/rhino.test.ts --browser chrome",
"test-perf": "cypress run --spec test/rhino_perf.test.ts --browser chrome"
},
"dependencies": {
"@picovoice/web-utils": "=1.3.1"
"@picovoice/web-utils": "=1.4.3"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand All @@ -45,6 +45,8 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/pluginutils": "^5.0.2",
"@types/emscripten": "1.40.0",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"async-mutex": "^0.4.0",
Expand All @@ -62,6 +64,6 @@
"wasm-feature-detect": "^1.5.0"
},
"engines": {
"node": ">=16"
"node": ">=18"
}
}
2 changes: 1 addition & 1 deletion binding/web/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
exclude: '**/node_modules/**',
}),
base64({
include: ['./lib/**/*.wasm'],
include: ['./src/lib/*.wasm', './src/lib/*.txt'],
}),
],
};
Loading
Loading