Skip to content
Open
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
55 changes: 54 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
const path = require('path');

const VALID_CATEGORIES = [
'Hooks',
'Interfaces',
'Models - Classification',
'Models - Image Embeddings',
'Models - Image Generation',
'Models - LMM',
'Models - Object Detection',
'Models - Semantic Segmentation',
'Models - Speech To Text',
'Models - Style Transfer',
'Models - Text Embeddings',
'Models - Text to Speech',
'Models - Voice Activity Detection',
'OCR Supported Alphabets',
'TTS Supported Voices',
'Types',
'Typescript API',
'Utils',
'Utilities - General',
'Utilities - LLM',
];

const CATEGORY_TAG_MATCH = `^(${VALID_CATEGORIES.join('|')})$`;

module.exports = {
parserOptions: {
requireConfigFile: false,
Expand All @@ -13,6 +38,7 @@ module.exports = {
'plugin:@cspell/recommended',
'plugin:prettier/recommended',
'plugin:markdown/recommended-legacy',
'plugin:jsdoc/recommended-typescript',
],
rules: {
'react/react-in-jsx-scope': 'off',
Expand All @@ -33,8 +59,28 @@ module.exports = {
},
],
'camelcase': 'error',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param': ['error', { checkDestructured: false }],
'jsdoc/check-param-names': ['error', { checkDestructured: false }],
'jsdoc/require-yields-type': 'off',
'jsdoc/require-yields-description': 'warn',
'jsdoc/check-tag-names': ['error', { definedTags: ['property'] }],
'jsdoc/match-description': [
'error',
{
contexts: ['any'],
mainDescription: false,
tags: {
category: {
message:
'@category must be one of categories defined in .eslintrc.js',
match: CATEGORY_TAG_MATCH,
},
},
},
],
},
plugins: ['prettier', 'markdown'],
plugins: ['prettier', 'markdown', 'jsdoc'],
overrides: [
{
files: ['packages/react-native-executorch/src/**/*.{js,jsx,ts,tsx}'],
Expand All @@ -58,4 +104,11 @@ module.exports = {
},
],
ignorePatterns: ['node_modules/', 'lib/'],
settings: {
jsdoc: {
tagNamePreference: {
typeParam: 'typeParam',
},
},
},
};
1 change: 1 addition & 0 deletions apps/speech/screens/TextToSpeechScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SWMIcon from '../assets/swm_icon.svg';
/**
* Converts an audio vector (Float32Array) to an AudioBuffer for playback
* @param audioVector - The generated audio samples from the model
* @param audioContext - An optional AudioContext to create the buffer in. If not provided, a new one will be created.
* @param sampleRate - The sample rate (default: 24000 Hz for Kokoro)
* @returns AudioBuffer ready for playback
*/
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/06-api-reference/classes/ClassificationModule.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Class: ClassificationModule

Defined in: [modules/computer_vision/ClassificationModule.ts:13](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L13)
Defined in: [modules/computer_vision/ClassificationModule.ts:12](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L12)

Module for image classification tasks.

Expand Down Expand Up @@ -42,7 +42,7 @@ Native module instance

> **delete**(): `void`

Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
Defined in: [modules/BaseModule.ts:39](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L39)

Unloads the model from memory.

Expand All @@ -60,7 +60,7 @@ Unloads the model from memory.

> **forward**(`imageSource`): `Promise`\<\{\[`category`: `string`\]: `number`; \}\>

Defined in: [modules/computer_vision/ClassificationModule.ts:51](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L51)
Defined in: [modules/computer_vision/ClassificationModule.ts:48](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L48)

Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string.

Expand All @@ -84,7 +84,7 @@ The classification result.

> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>

Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
Defined in: [modules/BaseModule.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L22)

Runs the model's forward method with the given input tensors.
It returns the output tensors that mimic the structure of output from ExecuTorch.
Expand Down Expand Up @@ -113,7 +113,7 @@ Array of output tensors.

> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>

Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
Defined in: [modules/BaseModule.ts:32](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L32)

Gets the input shape for a given method and index.

Expand Down Expand Up @@ -147,7 +147,7 @@ The input shape as an array of numbers.

> **load**(`model`, `onDownloadProgressCallback?`): `Promise`\<`void`\>

Defined in: [modules/computer_vision/ClassificationModule.ts:21](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L21)
Defined in: [modules/computer_vision/ClassificationModule.ts:19](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts#L19)

Loads the model, where `modelSource` is a string that specifies the location of the model binary.
To track the download progress, supply a callback function `onDownloadProgressCallback`.
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/06-api-reference/classes/ExecutorchModule.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Class: ExecutorchModule

Defined in: [modules/general/ExecutorchModule.ts:14](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L14)
Defined in: [modules/general/ExecutorchModule.ts:13](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L13)

General module for executing custom Executorch models.

Expand Down Expand Up @@ -42,7 +42,7 @@ Native module instance

> **delete**(): `void`

Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
Defined in: [modules/BaseModule.ts:39](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L39)

Unloads the model from memory.

Expand All @@ -60,7 +60,7 @@ Unloads the model from memory.

> **forward**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>

Defined in: [modules/general/ExecutorchModule.ts:51](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L51)
Defined in: [modules/general/ExecutorchModule.ts:48](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L48)

Executes the model's forward pass, where input is an array of `TensorPtr` objects.
If the inference is successful, an array of tensor pointers is returned.
Expand All @@ -85,7 +85,7 @@ An array of output tensor pointers.

> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>

Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
Defined in: [modules/BaseModule.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L22)

Runs the model's forward method with the given input tensors.
It returns the output tensors that mimic the structure of output from ExecuTorch.
Expand Down Expand Up @@ -114,7 +114,7 @@ Array of output tensors.

> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>

Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
Defined in: [modules/BaseModule.ts:32](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L32)

Gets the input shape for a given method and index.

Expand Down Expand Up @@ -148,7 +148,7 @@ The input shape as an array of numbers.

> **load**(`modelSource`, `onDownloadProgressCallback?`): `Promise`\<`void`\>

Defined in: [modules/general/ExecutorchModule.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L22)
Defined in: [modules/general/ExecutorchModule.ts:20](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts#L20)

Loads the model, where `modelSource` is a string, number, or object that specifies the location of the model binary.
Optionally accepts a download progress callback.
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/06-api-reference/classes/ImageEmbeddingsModule.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Class: ImageEmbeddingsModule

Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:13](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L13)
Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:12](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L12)

Module for generating image embeddings from input images.

Expand Down Expand Up @@ -42,7 +42,7 @@ Native module instance

> **delete**(): `void`

Defined in: [modules/BaseModule.ts:41](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L41)
Defined in: [modules/BaseModule.ts:39](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L39)

Unloads the model from memory.

Expand All @@ -60,7 +60,7 @@ Unloads the model from memory.

> **forward**(`imageSource`): `Promise`\<`Float32Array`\<`ArrayBufferLike`\>\>

Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:50](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L50)
Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:47](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L47)

Executes the model's forward pass. Returns an embedding array for a given sentence.

Expand All @@ -84,7 +84,7 @@ A Float32Array containing the image embeddings.

> `protected` **forwardET**(`inputTensor`): `Promise`\<[`TensorPtr`](../interfaces/TensorPtr.md)[]\>

Defined in: [modules/BaseModule.ts:23](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L23)
Defined in: [modules/BaseModule.ts:22](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L22)

Runs the model's forward method with the given input tensors.
It returns the output tensors that mimic the structure of output from ExecuTorch.
Expand Down Expand Up @@ -113,7 +113,7 @@ Array of output tensors.

> **getInputShape**(`methodName`, `index`): `Promise`\<`number`[]\>

Defined in: [modules/BaseModule.ts:34](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L34)
Defined in: [modules/BaseModule.ts:32](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/BaseModule.ts#L32)

Gets the input shape for a given method and index.

Expand Down Expand Up @@ -147,7 +147,7 @@ The input shape as an array of numbers.

> **load**(`model`, `onDownloadProgressCallback?`): `Promise`\<`void`\>

Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:20](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L20)
Defined in: [modules/computer_vision/ImageEmbeddingsModule.ts:18](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts#L18)

Loads the model, where `modelSource` is a string that specifies the location of the model binary.

Expand Down
Loading
Loading