diff --git a/.cspell-wordlist.txt b/.cspell-wordlist.txt index 07f647238c..9daa4dc166 100644 --- a/.cspell-wordlist.txt +++ b/.cspell-wordlist.txt @@ -179,3 +179,4 @@ nˈɛvəɹ ɹˈiᵊli ˈɛniwˌʌn ˈɛls +Synchronizable diff --git a/.eslintrc.js b/.eslintrc.js index a9613d48ed..c3e22268cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,33 @@ const path = require('path'); +const VALID_CATEGORIES = [ + 'Base Classes', + 'Hooks', + 'Interfaces', + 'Models - Classification', + 'Models - Image Embeddings', + 'Models - Image Generation', + 'Models - LMM', + 'Models - Object Detection', + 'Models - Instance Segmentation', + 'Models - Semantic Segmentation', + 'Models - Speech To Text', + 'Models - Style Transfer', + 'Models - Text Embeddings', + 'Models - Text to Speech', + 'Models - VLM', + '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, @@ -13,6 +41,7 @@ module.exports = { 'plugin:@cspell/recommended', 'plugin:prettier/recommended', 'plugin:markdown/recommended-legacy', + 'plugin:jsdoc/recommended-typescript', ], rules: { 'react/react-in-jsx-scope': 'off', @@ -33,8 +62,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}'], @@ -58,4 +107,11 @@ module.exports = { }, ], ignorePatterns: ['node_modules/', 'lib/'], + settings: { + jsdoc: { + tagNamePreference: { + typeParam: 'typeParam', + }, + }, + }, }; diff --git a/apps/computer-vision/components/ImageWithMasks.tsx b/apps/computer-vision/components/ImageWithMasks.tsx index 0403098bd3..bd768909b2 100644 --- a/apps/computer-vision/components/ImageWithMasks.tsx +++ b/apps/computer-vision/components/ImageWithMasks.tsx @@ -38,6 +38,8 @@ export interface DisplayInstance { * Convert raw segmentation output into lightweight display instances. * Call this eagerly (in the forward callback) so raw Uint8Array masks * can be garbage-collected immediately. + * @param rawInstances - Array of raw segmentation instances with mask buffers to convert. + * @returns Array of lightweight {@link DisplayInstance} objects with pre-rendered Skia images. */ export function buildDisplayInstances( rawInstances: { diff --git a/apps/speech/screens/TextToSpeechLLMScreen.tsx b/apps/speech/screens/TextToSpeechLLMScreen.tsx index 04856cf3e7..e99072869b 100644 --- a/apps/speech/screens/TextToSpeechLLMScreen.tsx +++ b/apps/speech/screens/TextToSpeechLLMScreen.tsx @@ -30,6 +30,7 @@ interface TextToSpeechLLMProps { /** * Converts an audio vector (Float32Array) to an AudioBuffer for playback * @param audioVector - The generated audio samples from the model + * @param audioContext - The audio context used to create the buffer. * @param sampleRate - The sample rate (default: 24000 Hz for Kokoro) * @returns AudioBuffer ready for playback */ diff --git a/apps/speech/screens/TextToSpeechScreen.tsx b/apps/speech/screens/TextToSpeechScreen.tsx index 480ae255ef..ac89b72546 100644 --- a/apps/speech/screens/TextToSpeechScreen.tsx +++ b/apps/speech/screens/TextToSpeechScreen.tsx @@ -53,6 +53,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 */ diff --git a/docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md b/docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md index 986442ed6d..2795249ae3 100644 --- a/docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md +++ b/docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md @@ -184,20 +184,17 @@ export default function App() { const frameOutput = useFrameOutput({ pixelFormat: 'rgb', dropFramesWhileBusy: true, - onFrame: useCallback( - (frame: Frame) => { - 'worklet'; - try { - if (!runOnFrame) return; - const isFrontCamera = cameraPositionSync.getDirty() === 'front'; - const result = runOnFrame(frame, isFrontCamera); - // ... handle result - } finally { - frame.dispose(); - } - }, - [runOnFrame] - ), + onFrame: useCallback((frame: Frame) => { + 'worklet'; + try { + if (!runOnFrame) return; + const isFrontCamera = cameraPositionSync.getDirty() === 'front'; + const result = runOnFrame(frame, isFrontCamera); + // ... handle result + } finally { + frame.dispose(); + } + }, []), }); // ... diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index c2415c8e31..a565446671 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -18,6 +18,7 @@ const config = { projectName: 'react-native-executorch', onBrokenLinks: 'throw', + onBrokenAnchors: 'throw', markdown: { hooks: { onBrokenMarkdownLinks: 'warn', diff --git a/package.json b/package.json index 145733ff9a..a93659a86a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "cspell": "^8.19.0", "eslint": "^8.57.0", "eslint-plugin-ft-flow": "^2.0.3", + "eslint-plugin-jsdoc": "^62.7.1", "eslint-plugin-markdown": "^5.1.0", "eslint-plugin-prettier": "^5.0.1", "expo-router": "~6.0.17", diff --git a/packages/bare-resource-fetcher/src/ResourceFetcher.ts b/packages/bare-resource-fetcher/src/ResourceFetcher.ts index 7994a7fc75..fc148526f0 100644 --- a/packages/bare-resource-fetcher/src/ResourceFetcher.ts +++ b/packages/bare-resource-fetcher/src/ResourceFetcher.ts @@ -4,9 +4,7 @@ * This module provides functions to download and manage files stored in the application's document directory * inside the `react-native-executorch/` directory. These utilities help manage storage and clean up downloaded * files when they are no longer needed. - * * @category Utilities - General - * * @remarks * **Key Functionality:** * - **Download Control**: Pause, resume, and cancel operations through: @@ -102,7 +100,6 @@ interface BareResourceFetcherInterface extends ResourceFetcherAdapter { /** * This module provides functions to download and work with downloaded files stored in the application's document directory inside the `react-native-executorch/` directory. * These utilities can help you manage your storage and clean up the downloaded files when they are no longer needed. - * * @category Utilities - General */ export const BareResourceFetcher: BareResourceFetcherInterface = { @@ -110,7 +107,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch. - * * @param callback - Optional callback to track progress of all downloads, reported between 0 and 1. * @param sources - Multiple resources that can be strings, asset references, or objects. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded/stored resources (without file:// prefix). @@ -320,7 +316,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Pauses an ongoing download of files. - * * @param sources - The resource identifiers used when calling `fetch`. * @returns A promise that resolves once the download is paused. */ @@ -331,7 +326,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Resumes a paused download of files. - * * @param sources - The resource identifiers used when calling fetch. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded resources (without file:// prefix). * If the fetch was again interrupted by `pauseFetching` or `cancelFetching`, it returns a promise which resolves to `null`. @@ -343,7 +337,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Cancels an ongoing/paused download of files. - * * @param sources - The resource identifiers used when calling `fetch()`. * @returns A promise that resolves once the download is canceled. */ @@ -366,7 +359,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Lists all the downloaded files used by React Native ExecuTorch. - * * @returns A promise, which resolves to an array of URIs for all the downloaded files. */ async listDownloadedFiles() { @@ -376,7 +368,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Lists all the downloaded models used by React Native ExecuTorch. - * * @returns A promise, which resolves to an array of URIs for all the downloaded models. */ async listDownloadedModels() { @@ -386,7 +377,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Deletes downloaded resources from the local filesystem. - * * @param sources - The resource identifiers used when calling `fetch`. * @returns A promise that resolves once all specified resources have been removed. */ @@ -404,7 +394,6 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Fetches the info about files size. Works only for remote files. - * * @param sources - The resource identifiers (URLs). * @returns A promise that resolves to combined size of files in bytes. */ @@ -635,10 +624,8 @@ export const BareResourceFetcher: BareResourceFetcherInterface = { /** * Reads the contents of a file as a string. - * * @param path - Absolute file path to read. * @returns A promise that resolves to the file contents as a string. - * * @remarks * **REQUIRED**: Used internally for reading configuration files (e.g., tokenizer configs). */ diff --git a/packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts b/packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts index 74e25f54b9..859e6f892b 100644 --- a/packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts +++ b/packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts @@ -18,7 +18,6 @@ export type { ResourceSourceExtended }; /** * Utility functions for fetching and managing resources. - * * @category Utilities - General */ export namespace ResourceFetcherUtils { diff --git a/packages/expo-resource-fetcher/src/ResourceFetcher.ts b/packages/expo-resource-fetcher/src/ResourceFetcher.ts index 4a81bdfe62..e1c0373936 100644 --- a/packages/expo-resource-fetcher/src/ResourceFetcher.ts +++ b/packages/expo-resource-fetcher/src/ResourceFetcher.ts @@ -4,9 +4,7 @@ * This module provides functions to download and manage files stored in the application's document directory * inside the `react-native-executorch/` directory. These utilities help manage storage and clean up downloaded * files when they are no longer needed. - * * @category Utilities - General - * * @remarks * **Key Functionality:** * - **Download Control**: Pause, resume, and cancel operations through: @@ -94,7 +92,6 @@ interface ExpoResourceFetcherInterface extends ResourceFetcherAdapter { /** * This module provides functions to download and work with downloaded files stored in the application's document directory inside the `react-native-executorch/` directory. * These utilities can help you manage your storage and clean up the downloaded files when they are no longer needed. - * * @category Utilities - General */ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { @@ -102,7 +99,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch. - * * @param callback - Optional callback to track progress of all downloads, reported between 0 and 1. * @param sources - Multiple resources that can be strings, asset references, or objects. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded/stored resources (without file:// prefix). @@ -288,7 +284,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Pauses an ongoing download of files. - * * @param sources - The resource identifiers used when calling `fetch`. * @returns A promise that resolves once the download is paused. */ @@ -299,7 +294,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Resumes a paused download of files. - * * @param sources - The resource identifiers used when calling fetch. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded resources (without file:// prefix). * If the fetch was again interrupted by `pauseFetching` or `cancelFetching`, it returns a promise which resolves to `null`. @@ -311,7 +305,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Cancels an ongoing/paused download of files. - * * @param sources - The resource identifiers used when calling `fetch()`. * @returns A promise that resolves once the download is canceled. */ @@ -334,7 +327,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Lists all the downloaded files used by React Native ExecuTorch. - * * @returns A promise, which resolves to an array of URIs for all the downloaded files. */ async listDownloadedFiles() { @@ -344,7 +336,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Lists all the downloaded models used by React Native ExecuTorch. - * * @returns A promise, which resolves to an array of URIs for all the downloaded models. */ async listDownloadedModels() { @@ -354,7 +345,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Deletes downloaded resources from the local filesystem. - * * @param sources - The resource identifiers used when calling `fetch`. * @returns A promise that resolves once all specified resources have been removed. */ @@ -372,7 +362,6 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Fetches the info about files size. Works only for remote files. - * * @param sources - The resource identifiers (URLs). * @returns A promise that resolves to combined size of files in bytes. */ @@ -543,10 +532,8 @@ export const ExpoResourceFetcher: ExpoResourceFetcherInterface = { /** * Reads the contents of a file as a string. - * * @param path - Absolute file path or file URI to read. * @returns A promise that resolves to the file contents as a string. - * * @remarks * **REQUIRED**: Used internally for reading configuration files (e.g., tokenizer configs). * diff --git a/packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts b/packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts index 3165d39c97..98347e0daf 100644 --- a/packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts +++ b/packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts @@ -31,7 +31,6 @@ export interface DownloadResource { /** * Utility functions for fetching and managing resources. - * * @category Utilities - General */ export namespace ResourceFetcherUtils { diff --git a/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp index 314058335d..3d2f9d1715 100644 --- a/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp +++ b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp @@ -123,7 +123,8 @@ std::vector BaseInstanceSegmentation::generateFromFrame( for (auto &inst : instances) { utils::inverseRotateBbox(inst.bbox, orient, rotated.size()); // Inverse-rotate the mask to match the screen orientation - cv::Mat maskMat(inst.maskHeight, inst.maskWidth, CV_8UC1, inst.mask->data()); + cv::Mat maskMat(inst.maskHeight, inst.maskWidth, CV_8UC1, + inst.mask->data()); cv::Mat invMask = utils::inverseRotateMat(maskMat, orient); inst.mask = std::make_shared( invMask.data, static_cast(invMask.total())); diff --git a/packages/react-native-executorch/src/constants/classification.ts b/packages/react-native-executorch/src/constants/classification.ts index f43c93c26a..ffd33fe894 100644 --- a/packages/react-native-executorch/src/constants/classification.ts +++ b/packages/react-native-executorch/src/constants/classification.ts @@ -1,7 +1,6 @@ /** * ImageNet-1K class labels used for image classification. * Contains 1000 classes from the ImageNet Large Scale Visual Recognition Challenge. - * * @category Types */ export enum Imagenet1kLabel { diff --git a/packages/react-native-executorch/src/constants/commonVision.ts b/packages/react-native-executorch/src/constants/commonVision.ts index ffe59372ef..ecea0f8069 100644 --- a/packages/react-native-executorch/src/constants/commonVision.ts +++ b/packages/react-native-executorch/src/constants/commonVision.ts @@ -9,7 +9,6 @@ export const IMAGENET1K_STD: Triple = [0.229, 0.224, 0.225]; * This enum is **1-indexed** and contains **91 classes**, matching the original COCO * dataset category IDs. For **YOLO** models (object detection or instance segmentation), * use {@link CocoLabelYolo} instead — a 0-indexed, 80-class variant. - * * @see {@link CocoLabelYolo} for the YOLO-specific variant * @category Types */ @@ -116,7 +115,6 @@ export enum CocoLabel { * * Use this enum when working with YOLO models (e.g. `yolo26n-seg`). * For RF-DETR or SSDLite models, use {@link CocoLabel}. - * * @see {@link CocoLabel} for the RF-DETR / SSDLite variant * @category Types */ diff --git a/packages/react-native-executorch/src/constants/llmDefaults.ts b/packages/react-native-executorch/src/constants/llmDefaults.ts index 77bf5add9c..a27a2f7a4f 100644 --- a/packages/react-native-executorch/src/constants/llmDefaults.ts +++ b/packages/react-native-executorch/src/constants/llmDefaults.ts @@ -3,7 +3,6 @@ import { SlidingWindowContextStrategy } from '../utils/llms/context_strategy'; /** * Default system prompt used to guide the behavior of Large Language Models (LLMs). - * * @category Utilities - LLM */ export const DEFAULT_SYSTEM_PROMPT = @@ -11,7 +10,6 @@ export const DEFAULT_SYSTEM_PROMPT = /** * Generates a default structured output prompt based on the provided JSON schema. - * * @category Utilities - LLM * @param structuredOutputSchema - A string representing the JSON schema for the desired output format. * @returns A prompt string instructing the model to format its output according to the given schema. @@ -29,21 +27,18 @@ ${structuredOutputSchema} /** * Default message history for Large Language Models (LLMs). - * * @category Utilities - LLM */ export const DEFAULT_MESSAGE_HISTORY: Message[] = []; /** * Default context buffer tokens (number of tokens to keep for the model response) for Large Language Models (LLMs). - * * @category Utilities - LLM */ export const DEFAULT_CONTEXT_BUFFER_TOKENS = 512; /** * Default chat configuration for Large Language Models (LLMs). - * * @category Utilities - LLM */ export const DEFAULT_CHAT_CONFIG: ChatConfig = { diff --git a/packages/react-native-executorch/src/constants/tts/models.ts b/packages/react-native-executorch/src/constants/tts/models.ts index a7ac8703a1..7b05a580c8 100644 --- a/packages/react-native-executorch/src/constants/tts/models.ts +++ b/packages/react-native-executorch/src/constants/tts/models.ts @@ -9,7 +9,6 @@ const KOKORO_EN_MEDIUM_MODELS_ROOT = `${KOKORO_EN_MODELS_ROOT}/medium`; * A Kokoro model instance which processes the text in batches of maximum 64 tokens. * Uses significant less memory than the medium model, but could produce * a lower quality speech due to forced, aggressive text splitting. - * * @category Models - Text to Speech */ export const KOKORO_SMALL = { @@ -20,7 +19,6 @@ export const KOKORO_SMALL = { /** * A standard Kokoro instance which processes the text in batches of maximum 128 tokens. - * * @category Models - Text to Speech */ export const KOKORO_MEDIUM = { diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useClassification.ts b/packages/react-native-executorch/src/hooks/computer_vision/useClassification.ts index b000511723..abb649d413 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useClassification.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useClassification.ts @@ -12,7 +12,6 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing a Classification model instance. - * * @typeParam C - A {@link ClassificationModelSources} config specifying which built-in model to load. * @category Hooks * @param props - Configuration object containing `model` source and optional `preventLoad` flag. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useImageEmbeddings.ts b/packages/react-native-executorch/src/hooks/computer_vision/useImageEmbeddings.ts index 8c0e6209e5..84c2a5cbbc 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useImageEmbeddings.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useImageEmbeddings.ts @@ -8,7 +8,6 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing an Image Embeddings model instance. - * * @category Hooks * @param ImageEmbeddingsProps - Configuration object containing `model` source and optional `preventLoad` flag. * @returns Ready to use Image Embeddings model. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts b/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts index a66d43c0d3..75f9fee72d 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts @@ -11,11 +11,9 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing an Instance Segmentation model instance. - * * @typeParam C - A {@link InstanceSegmentationModelSources} config specifying which model to load. * @param props - Configuration object containing `model` config and optional `preventLoad` flag. * @returns An object with model state (`error`, `isReady`, `isGenerating`, `downloadProgress`) and a typed `forward` function. - * * @example * ```ts * const { isReady, isGenerating, forward, error, downloadProgress } = @@ -35,7 +33,6 @@ import { useModuleFactory } from '../useModuleFactory'; * inputSize: 640, * }); * ``` - * * @category Hooks */ export const useInstanceSegmentation = < diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useOCR.ts b/packages/react-native-executorch/src/hooks/computer_vision/useOCR.ts index f396846aef..516c08b49f 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useOCR.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useOCR.ts @@ -6,7 +6,6 @@ import { OCRDetection, OCRProps, OCRType } from '../../types/ocr'; /** * React hook for managing an OCR instance. - * * @category Hooks * @param OCRProps - Configuration object containing `model` sources and optional `preventLoad` flag. * @returns Ready to use OCR model. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useObjectDetection.ts b/packages/react-native-executorch/src/hooks/computer_vision/useObjectDetection.ts index 5dfc552b63..c19b819318 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useObjectDetection.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useObjectDetection.ts @@ -12,7 +12,6 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing an Object Detection model instance. - * * @typeParam C - A {@link ObjectDetectionModelSources} config specifying which built-in model to load. * @category Hooks * @param props - Configuration object containing `model` config and optional `preventLoad` flag. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useSemanticSegmentation.ts b/packages/react-native-executorch/src/hooks/computer_vision/useSemanticSegmentation.ts index 5c1e00ed0e..6b9309f7ff 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useSemanticSegmentation.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useSemanticSegmentation.ts @@ -13,18 +13,15 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing a Semantic Segmentation model instance. - * * @typeParam C - A {@link SemanticSegmentationModelSources} config specifying which built-in model to load. * @param props - Configuration object containing `model` config and optional `preventLoad` flag. * @returns An object with model state (`error`, `isReady`, `isGenerating`, `downloadProgress`) and a typed `forward` function. - * * @example * ```ts * const { isReady, forward } = useSemanticSegmentation({ * model: { modelName: 'deeplab-v3-resnet50', modelSource: DEEPLAB_V3_RESNET50 }, * }); * ``` - * * @category Hooks */ export const useSemanticSegmentation = < diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useStyleTransfer.ts b/packages/react-native-executorch/src/hooks/computer_vision/useStyleTransfer.ts index dfa9095cc7..35eac71fd2 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useStyleTransfer.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useStyleTransfer.ts @@ -8,7 +8,6 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing a Style Transfer model instance. - * * @category Hooks * @param StyleTransferProps - Configuration object containing `model` source and optional `preventLoad` flag. * @returns Ready to use Style Transfer model. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useTextToImage.ts b/packages/react-native-executorch/src/hooks/computer_vision/useTextToImage.ts index 6a393ebd5b..6fbd8f403f 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useTextToImage.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useTextToImage.ts @@ -6,7 +6,6 @@ import { TextToImageProps, TextToImageType } from '../../types/tti'; /** * React hook for managing a Text to Image instance. - * * @category Hooks * @param TextToImageProps - Configuration object containing `model` source, `inferenceCallback`, and optional `preventLoad` flag. * @returns Ready to use Text to Image model. diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useVerticalOCR.ts b/packages/react-native-executorch/src/hooks/computer_vision/useVerticalOCR.ts index 5e33f6e7f2..df7e99add5 100644 --- a/packages/react-native-executorch/src/hooks/computer_vision/useVerticalOCR.ts +++ b/packages/react-native-executorch/src/hooks/computer_vision/useVerticalOCR.ts @@ -6,7 +6,6 @@ import { OCRDetection, OCRType, VerticalOCRProps } from '../../types/ocr'; /** * React hook for managing a Vertical OCR instance. - * * @category Hooks * @param VerticalOCRProps - Configuration object containing `model` sources, optional `independentCharacters` and `preventLoad` flag. * @returns Ready to use Vertical OCR model. diff --git a/packages/react-native-executorch/src/hooks/general/useExecutorchModule.ts b/packages/react-native-executorch/src/hooks/general/useExecutorchModule.ts index e0b16535a5..f41524fc4d 100644 --- a/packages/react-native-executorch/src/hooks/general/useExecutorchModule.ts +++ b/packages/react-native-executorch/src/hooks/general/useExecutorchModule.ts @@ -7,7 +7,6 @@ import { useModule } from '../useModule'; /** * React hook for managing an arbitrary Executorch module instance. - * * @category Hooks * @param executorchModuleProps - Configuration object containing `modelSource` and optional `preventLoad` flag. * @returns Ready to use Executorch module. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts index 284665506e..feb7a931e3 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useLLM.ts @@ -13,7 +13,6 @@ import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils'; /** * React hook for managing a Large Language Model (LLM) instance. - * * @category Hooks * @param props - Object containing model, tokenizer, and tokenizer config sources. * @returns An object implementing the `LLMTypeMultimodal` interface when `model.capabilities` is provided, otherwise `LLMType`. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useSpeechToText.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useSpeechToText.ts index 5a3d77fcac..9f428c98b2 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useSpeechToText.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useSpeechToText.ts @@ -11,7 +11,6 @@ import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils'; /** * React hook for managing a Speech to Text (STT) instance. - * * @category Hooks * @param speechToTextProps - Configuration object containing `model` source and optional `preventLoad` flag. * @returns Ready to use Speech to Text model. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useTextEmbeddings.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useTextEmbeddings.ts index 664f12caf9..31ee179925 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useTextEmbeddings.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useTextEmbeddings.ts @@ -7,7 +7,6 @@ import { /** * React hook for managing a Text Embeddings model instance. - * * @category Hooks * @param TextEmbeddingsProps - Configuration object containing `model` source and optional `preventLoad` flag. * @returns Ready to use Text Embeddings model. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts index b5e03ceb59..8942ea3b44 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useTextToSpeech.ts @@ -13,7 +13,6 @@ import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils'; /** * React hook for managing Text to Speech instance. - * * @category Hooks * @param TextToSpeechProps - Configuration object containing `model` source, `voice` and optional `preventLoad`. * @returns Ready to use Text to Speech model. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useTokenizer.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useTokenizer.ts index ea55157bc8..0c6da02826 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useTokenizer.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useTokenizer.ts @@ -6,7 +6,6 @@ import { TokenizerProps, TokenizerType } from '../../types/tokenizer'; /** * React hook for managing a Tokenizer instance. - * * @category Hooks * @param tokenizerProps - Configuration object containing `tokenizer` source and optional `preventLoad` flag. * @returns Ready to use Tokenizer model. diff --git a/packages/react-native-executorch/src/hooks/natural_language_processing/useVAD.ts b/packages/react-native-executorch/src/hooks/natural_language_processing/useVAD.ts index 3e5be0214a..82a140288a 100644 --- a/packages/react-native-executorch/src/hooks/natural_language_processing/useVAD.ts +++ b/packages/react-native-executorch/src/hooks/natural_language_processing/useVAD.ts @@ -4,7 +4,6 @@ import { useModuleFactory } from '../useModuleFactory'; /** * React hook for managing a VAD model instance. - * * @category Hooks * @param VADProps - Configuration object containing `model` source and optional `preventLoad` flag. * @returns Ready to use VAD model. diff --git a/packages/react-native-executorch/src/hooks/useModule.ts b/packages/react-native-executorch/src/hooks/useModule.ts index 632e94d3ea..2a96fa615d 100644 --- a/packages/react-native-executorch/src/hooks/useModule.ts +++ b/packages/react-native-executorch/src/hooks/useModule.ts @@ -135,7 +135,6 @@ export const useModule = < * * **Use this for VisionCamera frame processing in worklets.** * For async processing, use `forward()` instead. - * * @example * ```typescript * const { runOnFrame } = useObjectDetection({ model: MODEL }); diff --git a/packages/react-native-executorch/src/hooks/useModuleFactory.ts b/packages/react-native-executorch/src/hooks/useModuleFactory.ts index bb3140518d..d6ca51e0c0 100644 --- a/packages/react-native-executorch/src/hooks/useModuleFactory.ts +++ b/packages/react-native-executorch/src/hooks/useModuleFactory.ts @@ -13,7 +13,8 @@ type RunOnFrame = M extends { runOnFrame: infer R } ? R : never; * Handles model loading, download progress, error state, and enforces the * not-loaded / already-generating guards so individual hooks only need to * define their typed `forward` wrapper. - * + * @param props - Options object containing the factory function, config, deps array, and optional preventLoad flag. + * @returns An object with error, isReady, isGenerating, downloadProgress, runForward, instance, and runOnFrame. * @internal */ export function useModuleFactory({ diff --git a/packages/react-native-executorch/src/index.ts b/packages/react-native-executorch/src/index.ts index 4c96a8957f..f9d9e32be9 100644 --- a/packages/react-native-executorch/src/index.ts +++ b/packages/react-native-executorch/src/index.ts @@ -8,7 +8,6 @@ import { LLMCapability } from './types/llm'; /** * Configuration that goes to the `initExecutorch`. * You can pass either bare React Native or Expo configuration. - * * @category Utilities - General */ export interface ExecutorchConfig { @@ -17,7 +16,6 @@ export interface ExecutorchConfig { /** * Function that setups the provided resource fetcher. - * * @category Utilities - General * @param config - Configuration that you want to use in resource fetching. */ @@ -27,7 +25,6 @@ export function initExecutorch(config: ExecutorchConfig) { /** * Function that cleans current setup of fetching resources. - * * @category Utilities - General */ export function cleanupExecutorch() { diff --git a/packages/react-native-executorch/src/modules/BaseModule.ts b/packages/react-native-executorch/src/modules/BaseModule.ts index c844cf358b..7545734f74 100644 --- a/packages/react-native-executorch/src/modules/BaseModule.ts +++ b/packages/react-native-executorch/src/modules/BaseModule.ts @@ -6,7 +6,6 @@ import { TensorPtr } from '../types/common'; * * Provides core functionality for loading models, running inference, * and managing native resources. - * * @category Base Classes */ export abstract class BaseModule { @@ -46,11 +45,9 @@ export abstract class BaseModule { * } * }); * ``` - * * @param frameData Frame data object with either nativeBuffer (zero-copy) or data (ArrayBuffer) * @param args Additional model-specific arguments (e.g., threshold, options) * @returns Model-specific output (e.g., detections, classifications, embeddings) - * * @see {@link Frame} for frame data format details */ public generateFromFrame!: (frameData: Frame, ...args: any[]) => any; @@ -58,7 +55,6 @@ export abstract class BaseModule { /** * Runs the model's forward method with the given input tensors. * It returns the output tensors that mimic the structure of output from ExecuTorch. - * * @param inputTensor - Array of input tensors. * @returns Array of output tensors. * @internal @@ -69,7 +65,6 @@ export abstract class BaseModule { /** * Gets the input shape for a given method and index. - * * @param methodName method name * @param index index of the argument which shape is requested * @returns The input shape as an array of numbers. diff --git a/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts b/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts index 78c7916820..f9baac8ed1 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/ClassificationModule.ts @@ -27,9 +27,7 @@ type ModelConfigsType = typeof ModelConfigs; /** * Resolves the {@link LabelEnum} for a given built-in classification model name. - * * @typeParam M - A built-in model name from {@link ClassificationModelName}. - * * @category Types */ export type ClassificationLabels = @@ -43,10 +41,8 @@ type ResolveLabels = /** * Generic classification module with type-safe label maps. - * * @typeParam T - Either a built-in model name (e.g. `'efficientnet-v2-s'`) * or a custom {@link LabelEnum} label map. - * * @category Typescript API */ export class ClassificationModule< @@ -61,7 +57,6 @@ export class ClassificationModule< /** * Creates a classification instance for a built-in model. - * * @param namedSources - A {@link ClassificationModelSources} object specifying which model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `ClassificationModule` instance typed to the chosen model's label map. @@ -110,7 +105,6 @@ export class ClassificationModule< * * **Output:** one `float32` tensor of shape `[1, C]` containing raw logits — one value per class, * in the same order as the entries in your `labelMap`. Softmax is applied by the native runtime. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param config - A {@link ClassificationConfig} object with the label map and optional preprocessing parameters. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. @@ -145,7 +139,6 @@ export class ClassificationModule< /** * Executes the model's forward pass to classify the provided image. - * * @param input - A string image source (file path, URI, or Base64) or a {@link PixelData} object. * @returns A Promise resolving to an object mapping label keys to confidence scores. */ diff --git a/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts b/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts index 22ed586bf3..44f1168b44 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/ImageEmbeddingsModule.ts @@ -8,7 +8,6 @@ import { VisionModule } from './VisionModule'; /** * Module for generating image embeddings from input images. - * * @category Typescript API */ export class ImageEmbeddingsModule extends VisionModule { @@ -18,7 +17,6 @@ export class ImageEmbeddingsModule extends VisionModule { } /** * Creates an image embeddings instance for a built-in model. - * * @param namedSources - An object specifying which built-in model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `ImageEmbeddingsModule` instance. @@ -55,10 +53,8 @@ export class ImageEmbeddingsModule extends VisionModule { /** * Creates an image embeddings instance with a user-provided model binary. * Use this when working with a custom-exported model that is not one of the built-in presets. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `ImageEmbeddingsModule` instance. diff --git a/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts b/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts index 4546b9e13f..fa1c2eb5dc 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts @@ -55,6 +55,8 @@ const RF_DETR_NANO_SEG_CONFIG = { * Builds a reverse map from 0-based model class index to label key name, and * computes the minimum enum value (offset) so TS enum values can be converted * to 0-based model indices. + * @param labelMap - The label enum to build the index map from. + * @returns An object containing `indexToLabel` map and `minValue` offset. */ function buildClassIndexMap(labelMap: LabelEnum): { indexToLabel: Map; @@ -90,9 +92,7 @@ type ModelConfigsType = typeof ModelConfigs; /** * Resolves the label map type for a given built-in model name. - * * @typeParam M - A built-in model name from {@link InstanceSegmentationModelName}. - * * @category Types */ export type InstanceSegmentationLabels< @@ -100,9 +100,9 @@ export type InstanceSegmentationLabels< > = ResolveLabels; /** - * @internal * Resolves the label type: if `T` is a {@link InstanceSegmentationModelName}, looks up its labels * from the built-in config; otherwise uses `T` directly as a {@link LabelEnum}. + * @internal */ type ResolveLabels = ResolveLabelsFor; @@ -115,12 +115,9 @@ type ResolveLabels = * Supported models (download from HuggingFace): * - `yolo26n-seg`, `yolo26s-seg`, `yolo26m-seg`, `yolo26l-seg`, `yolo26x-seg` - YOLO models with COCO labels (80 classes) * - `rfdetr-nano-seg` - RF-DETR Nano model with COCO labels (80 classes) - * * @typeParam T - Either a pre-configured model name from {@link InstanceSegmentationModelName} * or a custom label map conforming to {@link LabelEnum}. - * * @category Typescript API - * * @example * ```ts * const segmentation = await InstanceSegmentationModule.fromModelName({ @@ -162,11 +159,9 @@ export class InstanceSegmentationModule< /** * Creates an instance segmentation module for a pre-configured model. * The config object is discriminated by `modelName` — each model can require different fields. - * * @param config - A {@link InstanceSegmentationModelSources} object specifying which model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `InstanceSegmentationModule` instance typed to the chosen model's label map. - * * @example * ```ts * const segmentation = await InstanceSegmentationModule.fromModelName({ @@ -212,12 +207,10 @@ export class InstanceSegmentationModule< /** * Creates an instance segmentation module with a user-provided label map and custom config. * Use this when working with a custom-exported segmentation model that is not one of the pre-configured models. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param config - A {@link InstanceSegmentationConfig} object with the label map and optional preprocessing parameters. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `InstanceSegmentationModule` instance typed to the provided label map. - * * @example * ```ts * const MyLabels = { PERSON: 0, CAR: 1 } as const; @@ -268,9 +261,7 @@ export class InstanceSegmentationModule< /** * Returns the available input sizes for this model, or undefined if the model accepts any size. - * * @returns An array of available input sizes, or undefined if not constrained. - * * @example * ```ts * const sizes = segmentation.getAvailableInputSizes(); @@ -285,6 +276,7 @@ export class InstanceSegmentationModule< * Override runOnFrame to add label mapping for VisionCamera integration. * The parent's runOnFrame returns raw native results with class indices; * this override maps them to label strings and provides an options-based API. + * @returns A worklet function for VisionCamera frame processing, or null if the model is not loaded. */ override get runOnFrame(): | (( @@ -368,12 +360,10 @@ export class InstanceSegmentationModule< * Supports two input types: * 1. **String path/URI**: File path, URL, or Base64-encoded string * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) - * * @param input - Image source (string path or PixelData object) * @param options - Optional configuration for the segmentation process. Includes `confidenceThreshold`, `iouThreshold`, `maxInstances`, `classesOfInterest`, `returnMaskAtOriginalResolution`, and `inputSize`. * @returns A Promise resolving to an array of {@link SegmentedInstance} objects with `bbox`, `mask`, `maskWidth`, `maskHeight`, `label`, `score`. * @throws {RnExecutorchError} If the model is not loaded or if an invalid `inputSize` is provided. - * * @example * ```ts * const results = await segmentation.forward('path/to/image.jpg', { diff --git a/packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts b/packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts index dbdce026ef..69faca6980 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts @@ -6,7 +6,6 @@ import { parseUnknownError } from '../../errors/errorUtils'; /** * Module for Optical Character Recognition (OCR) tasks. - * * @category Typescript API */ export class OCRModule { @@ -18,11 +17,9 @@ export class OCRModule { /** * Creates an OCR instance for a built-in model. - * * @param namedSources - An object specifying the model name, detector source, recognizer source, and language. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `OCRModule` instance. - * * @example * ```ts * import { OCRModule, OCR_ENGLISH } from 'react-native-executorch'; @@ -57,10 +54,8 @@ export class OCRModule { * Creates an OCR instance with a user-provided model binary. * Use this when working with a custom-exported OCR model. * Internally uses `'custom'` as the model name for telemetry. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param detectorSource - A fetchable resource pointing to the text detector model binary. * @param recognizerSource - A fetchable resource pointing to the text recognizer model binary. * @param language - The language for the OCR model. @@ -86,7 +81,6 @@ export class OCRModule { /** * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string. - * * @param imageSource - The image source to be processed. * @returns The OCR result as a `OCRDetection[]`. */ diff --git a/packages/react-native-executorch/src/modules/computer_vision/ObjectDetectionModule.ts b/packages/react-native-executorch/src/modules/computer_vision/ObjectDetectionModule.ts index 20eb51db56..cbb3847ffa 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/ObjectDetectionModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/ObjectDetectionModule.ts @@ -34,9 +34,7 @@ type ModelConfigsType = typeof ModelConfigs; /** * Resolves the {@link LabelEnum} for a given built-in object detection model name. - * * @typeParam M - A built-in model name from {@link ObjectDetectionModelName}. - * * @category Types */ export type ObjectDetectionLabels = @@ -50,10 +48,8 @@ type ResolveLabels = /** * Generic object detection module with type-safe label maps. - * * @typeParam T - Either a built-in model name (e.g. `'ssdlite-320-mobilenet-v3-large'`) * or a custom {@link LabelEnum} label map. - * * @category Typescript API */ export class ObjectDetectionModule< @@ -65,7 +61,6 @@ export class ObjectDetectionModule< /** * Creates an object detection instance for a built-in model. - * * @param namedSources - A {@link ObjectDetectionModelSources} object specifying which model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to an `ObjectDetectionModule` instance typed to the chosen model's label map. @@ -102,7 +97,6 @@ export class ObjectDetectionModule< /** * Executes the model's forward pass to detect objects within the provided image. - * * @param input - A string image source (file path, URI, or Base64) or a {@link PixelData} object. * @param detectionThreshold - Minimum confidence score for a detection to be included. Default is 0.7. * @returns A Promise resolving to an array of {@link Detection} objects. @@ -137,7 +131,6 @@ export class ObjectDetectionModule< * Preprocessing (resize → normalize) and postprocessing (coordinate rescaling, threshold * filtering, NMS) are handled by the native runtime — your model only needs to produce * the raw detections above. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param config - A {@link ObjectDetectionConfig} object with the label map and optional preprocessing parameters. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. diff --git a/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts b/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts index a35df92d83..2cd2ceadd9 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts @@ -48,9 +48,7 @@ type ModelConfigsType = typeof ModelConfigs; /** * Resolves the {@link LabelEnum} for a given built-in model name. - * * @typeParam M - A built-in model name from {@link SemanticSegmentationModelName}. - * * @category Types */ export type SegmentationLabels = @@ -64,7 +62,6 @@ type ResolveLabels = * Generic semantic segmentation module with type-safe label maps. * Use a model name (e.g. `'deeplab-v3-resnet50'`) as the generic parameter for built-in models, * or a custom label enum for custom configs. - * * @typeParam T - Either a built-in model name (`'deeplab-v3-resnet50'`, * `'deeplab-v3-resnet50-quantized'`, `'deeplab-v3-resnet101'`, * `'deeplab-v3-resnet101-quantized'`, `'deeplab-v3-mobilenet-v3-large'`, @@ -72,7 +69,6 @@ type ResolveLabels = * `'lraspp-mobilenet-v3-large-quantized'`, `'fcn-resnet50'`, * `'fcn-resnet50-quantized'`, `'fcn-resnet101'`, `'fcn-resnet101-quantized'`, * `'selfie-segmentation'`) or a custom {@link LabelEnum} label map. - * * @category Typescript API */ export class SemanticSegmentationModule< @@ -88,11 +84,9 @@ export class SemanticSegmentationModule< /** * Creates a segmentation instance for a built-in model. * The config object is discriminated by `modelName` — each model can require different fields. - * * @param namedSources - A {@link SemanticSegmentationModelSources} object specifying which model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `SemanticSegmentationModule` instance typed to the chosen model's label map. - * * @example * ```ts * const segmentation = await SemanticSegmentationModule.fromModelName(DEEPLAB_V3_RESNET50); @@ -144,12 +138,10 @@ export class SemanticSegmentationModule< * * Preprocessing (resize → normalize) and postprocessing (softmax, argmax, resize back to * original dimensions) are handled by the native runtime. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param config - A {@link SemanticSegmentationConfig} object with the label map and optional preprocessing parameters. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `SemanticSegmentationModule` instance typed to the provided label map. - * * @example * ```ts * const MyLabels = { BACKGROUND: 0, FOREGROUND: 1 } as const; @@ -190,7 +182,6 @@ export class SemanticSegmentationModule< * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or PixelData object) * @param classesOfInterest - An optional list of label keys indicating which per-class probability masks to include in the output. `ARGMAX` is always returned regardless. * @param resizeToInput - Whether to resize the output masks to the original input image dimensions. If `false`, returns the raw model output dimensions. Defaults to `true`. diff --git a/packages/react-native-executorch/src/modules/computer_vision/StyleTransferModule.ts b/packages/react-native-executorch/src/modules/computer_vision/StyleTransferModule.ts index 6519a29b91..b10ac4e632 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/StyleTransferModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/StyleTransferModule.ts @@ -8,7 +8,6 @@ import { VisionModule } from './VisionModule'; /** * Module for style transfer tasks. - * * @category Typescript API */ export class StyleTransferModule extends VisionModule { @@ -18,7 +17,6 @@ export class StyleTransferModule extends VisionModule { } /** * Creates a style transfer instance for a built-in model. - * * @param namedSources - An object specifying which built-in model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `StyleTransferModule` instance. @@ -53,10 +51,8 @@ export class StyleTransferModule extends VisionModule { /** * Creates a style transfer instance with a user-provided model binary. * Use this when working with a custom-exported model that is not one of the built-in presets. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `StyleTransferModule` instance. diff --git a/packages/react-native-executorch/src/modules/computer_vision/TextToImageModule.ts b/packages/react-native-executorch/src/modules/computer_vision/TextToImageModule.ts index 7f290b0a89..38b85a1774 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/TextToImageModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/TextToImageModule.ts @@ -10,7 +10,6 @@ import { Logger } from '../../common/Logger'; /** * Module for text-to-image generation tasks. - * * @category Typescript API */ export class TextToImageModule extends BaseModule { @@ -29,11 +28,9 @@ export class TextToImageModule extends BaseModule { /** * Creates a Text to Image instance for a built-in model. - * * @param namedSources - An object specifying the model name, pipeline sources, and optional inference callback. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `TextToImageModule` instance. - * * @example * ```ts * import { TextToImageModule, BK_SDM_TINY_VPRED_512 } from 'react-native-executorch'; @@ -71,10 +68,8 @@ export class TextToImageModule extends BaseModule { * Creates a Text to Image instance with user-provided model binaries. * Use this when working with a custom-exported diffusion pipeline. * Internally uses `'custom'` as the model name for telemetry. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param sources - An object containing the pipeline source paths. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @param inferenceCallback - Optional callback triggered after each diffusion step. @@ -159,7 +154,6 @@ export class TextToImageModule extends BaseModule { /** * Runs the model to generate an image described by `input`, and conditioned by `seed`, performing `numSteps` inference steps. * The resulting image, with dimensions `imageSize`×`imageSize` pixels, is returned as a base64-encoded string. - * * @param input - The text prompt to generate the image from. * @param imageSize - The desired width and height of the output image in pixels. * @param numSteps - The number of inference steps to perform. diff --git a/packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts b/packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts index 069c705ebc..f9a818d4dc 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts @@ -6,7 +6,6 @@ import { OCRDetection, OCRLanguage, OCRModelName } from '../../types/ocr'; /** * Module for Vertical Optical Character Recognition (Vertical OCR) tasks. - * * @category Typescript API */ export class VerticalOCRModule { @@ -18,11 +17,9 @@ export class VerticalOCRModule { /** * Creates a Vertical OCR instance for a built-in model. - * * @param namedSources - An object specifying the model name, detector source, recognizer source, language, and optional independent characters flag. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `VerticalOCRModule` instance. - * * @example * ```ts * import { VerticalOCRModule, OCR_JAPANESE } from 'react-native-executorch'; @@ -59,10 +56,8 @@ export class VerticalOCRModule { * Creates a Vertical OCR instance with a user-provided model binary. * Use this when working with a custom-exported Vertical OCR model. * Internally uses `'custom'` as the model name for telemetry. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param detectorSource - A fetchable resource pointing to the text detector model binary. * @param recognizerSource - A fetchable resource pointing to the text recognizer model binary. * @param language - The language for the OCR model. @@ -91,7 +86,6 @@ export class VerticalOCRModule { /** * Executes the model's forward pass, where `imageSource` can be a fetchable resource or a Base64-encoded string. - * * @param imageSource - The image source to be processed. * @returns The OCR result as a `OCRDetection[]`. */ diff --git a/packages/react-native-executorch/src/modules/computer_vision/VisionLabeledModule.ts b/packages/react-native-executorch/src/modules/computer_vision/VisionLabeledModule.ts index 188b03c8c9..19adaa9ab4 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/VisionLabeledModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/VisionLabeledModule.ts @@ -9,7 +9,9 @@ export { ResolveLabels } from '../../types/computerVision'; /** * Fetches a model binary and returns its local path, throwing if the download * was interrupted (paused or cancelled). - * + * @param source - The resource source to fetch the model binary from. + * @param onDownloadProgress - Callback invoked with download progress (0–1). + * @returns A promise resolving to the local file path of the downloaded model. * @internal */ export async function fetchModelPath( @@ -29,7 +31,6 @@ export async function fetchModelPath( /** * Base class for computer vision modules that carry a type-safe label map * and support the full VisionModule API (string/PixelData forward + runOnFrame). - * * @typeParam TOutput - The model's output type. * @typeParam LabelMap - The resolved {@link LabelEnum} for the model's output classes. * @internal diff --git a/packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts b/packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts index f199cfe68a..553a3ab112 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts @@ -26,7 +26,6 @@ export function isPixelData(input: unknown): input is PixelData { * - Shared frame processor creation logic * * Subclasses implement model-specific loading logic and may override `forward` for typed signatures. - * * @category Typescript API */ export abstract class VisionModule extends BaseModule { @@ -37,7 +36,6 @@ export abstract class VisionModule extends BaseModule { * * **Use this for VisionCamera frame processing in worklets.** * For async processing, use `forward()` instead. - * * @example * ```typescript * const model = new ClassificationModule(); @@ -57,6 +55,7 @@ export abstract class VisionModule extends BaseModule { * } * }); * ``` + * @returns A worklet function for frame processing, or null if the model is not loaded. */ get runOnFrame(): ((frame: Frame, ...args: any[]) => TOutput) | null { if (!this.nativeModule) { @@ -80,7 +79,7 @@ export abstract class VisionModule extends BaseModule { Currently isMirrored is never set to true in VisionCamera. That's why we need to use our own property to determine if we need to mirror the results - **/ + */ const frameData = { nativeBuffer: nativeBuffer.pointer, orientation: frame.orientation, @@ -104,11 +103,9 @@ export abstract class VisionModule extends BaseModule { * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. * This method is async and cannot be called in worklet context. - * * @param input - Image source (string path or PixelData object) * @param args - Additional model-specific arguments * @returns A Promise that resolves to the model output. - * * @example * ```typescript * // String path (async) diff --git a/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts b/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts index cfa7dd1bb0..5986bdf2b8 100644 --- a/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts +++ b/packages/react-native-executorch/src/modules/general/ExecutorchModule.ts @@ -8,14 +8,12 @@ import { Logger } from '../../common/Logger'; /** * General module for executing custom Executorch models. - * * @category Typescript API */ export class ExecutorchModule extends BaseModule { /** * 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. - * * @param modelSource - Source of the model to be loaded. * @param onDownloadProgressCallback - Optional callback to monitor download progress. */ @@ -44,7 +42,6 @@ export class ExecutorchModule extends BaseModule { /** * 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. - * * @param inputTensor - Array of input tensor pointers. * @returns An array of output tensor pointers. */ diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts index 707b08813e..b1d40ac684 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts @@ -12,7 +12,6 @@ import { /** * Module for managing a Large Language Model (LLM) instance. - * * @category Typescript API */ export class LLMModule { @@ -33,14 +32,12 @@ export class LLMModule { /** * Creates an LLM instance for a built-in model. - * * @param namedSources - An object specifying the model name, model source, tokenizer source, * tokenizer config source, and optional capabilities. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @param tokenCallback - Optional callback invoked on every generated token. * @param messageHistoryCallback - Optional callback invoked when the model finishes a response, with the full message history. * @returns A Promise resolving to an `LLMModule` instance. - * * @example * ```ts * import { LLMModule, LLAMA3_2_3B } from 'react-native-executorch'; @@ -85,7 +82,6 @@ export class LLMModule { * [ExecuTorch LLM export process](https://docs.pytorch.org/executorch/1.1/llm/export-llm.html). * The native runner expects the standard ExecuTorch text-generation interface — KV-cache * management, prefill/decode phases, and logit sampling are all handled by the runtime. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param tokenizerSource - A fetchable resource pointing to the tokenizer JSON file. * @param tokenizerConfigSource - A fetchable resource pointing to the tokenizer config JSON file. @@ -117,7 +113,6 @@ export class LLMModule { /** * Sets new token callback invoked on every token batch. - * * @param tokenCallback - Callback function to handle new tokens. */ setTokenCallback({ @@ -131,7 +126,6 @@ export class LLMModule { /** * Configures chat and tool calling and generation settings. * See [Configuring the model](https://docs.swmansion.com/react-native-executorch/docs/hooks/natural-language-processing/useLLM#configuring-the-model) for details. - * * @param config - Configuration object containing `chatConfig`, `toolsConfig`, and `generationConfig`. */ configure(config: LLMConfig) { @@ -143,8 +137,8 @@ export class LLMModule { * You need to provide entire conversation and prompt (in correct format and with special tokens!) in input string to this method. * It doesn't manage conversation context. It is intended for users that need access to the model itself without any wrapper. * If you want a simple chat with model the consider using `sendMessage` - * * @param input - Raw input string containing the prompt and conversation history. + * @param imagePaths - Optional array of local image paths for multimodal inference. * @returns The generated response as a string. */ async forward(input: string, imagePaths?: string[]): Promise { @@ -154,7 +148,6 @@ export class LLMModule { /** * Runs model to complete chat passed in `messages` argument. It doesn't manage conversation context. * For multimodal models, set `mediaPath` on user messages to include images. - * * @param messages - Array of messages representing the chat history. User messages may include a `mediaPath` field with a local image path. * @param tools - Optional array of tools that can be used during generation. * @returns The generated response as a string. @@ -167,8 +160,8 @@ export class LLMModule { * Method to add user message to conversation. * After model responds it will call `messageHistoryCallback()` containing both user message and model response. * It also returns them. - * * @param message - The message string to send. + * @param media - Optional media object containing a local image path for multimodal models. * @returns - Updated message history including the new user message and model response. */ async sendMessage( @@ -183,7 +176,6 @@ export class LLMModule { * Deletes all messages starting with message on `index` position. * After deletion it will call `messageHistoryCallback()` containing new history. * It also returns it. - * * @param index - The index of the message to delete from history. * @returns - Updated message history after deletion. */ @@ -201,7 +193,6 @@ export class LLMModule { /** * Returns the number of tokens generated in the last response. - * * @returns The count of generated tokens. */ getGeneratedTokenCount(): number { @@ -210,7 +201,6 @@ export class LLMModule { /** * Returns the number of prompt tokens in the last message. - * * @returns The count of prompt token. */ getPromptTokensCount() { @@ -219,7 +209,6 @@ export class LLMModule { /** * Returns the number of total tokens from the previous generation. This is a sum of prompt tokens and generated tokens. - * * @returns The count of prompt and generated tokens. */ getTotalTokensCount() { diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/SpeechToTextModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/SpeechToTextModule.ts index d981e7e1ec..a1bf6231ad 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/SpeechToTextModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/SpeechToTextModule.ts @@ -12,7 +12,6 @@ import { Logger } from '../../common/Logger'; /** * Module for Speech to Text (STT) functionalities. - * * @category Typescript API */ export class SpeechToTextModule { @@ -29,11 +28,9 @@ export class SpeechToTextModule { /** * Creates a Speech to Text instance for a built-in model. - * * @param namedSources - Configuration object containing model name, sources, and multilingual flag. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `SpeechToTextModule` instance. - * * @example * ```ts * import { SpeechToTextModule, WHISPER_TINY_EN } from 'react-native-executorch'; @@ -60,11 +57,9 @@ export class SpeechToTextModule { * Creates a Speech to Text instance with user-provided model binaries. * Use this when working with a custom-exported STT model. * Internally uses `'custom'` as the model name for telemetry. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Currently only the Whisper architecture is supported by the native runner. * Refer to the native source code for the current expected interface. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param tokenizerSource - A fetchable resource pointing to the tokenizer file. * @param isMultilingual - Whether the model supports multiple languages. @@ -128,7 +123,6 @@ export class SpeechToTextModule { /** * Runs the encoding part of the model on the provided waveform. * Returns the encoded waveform as a Float32Array. - * * @param waveform - The input audio waveform. * @returns The encoded output. */ @@ -139,7 +133,6 @@ export class SpeechToTextModule { /** * Runs the decoder of the model. - * * @param tokens - The input tokens. * @param encoderOutput - The encoder output. * @returns Decoded output. @@ -156,7 +149,6 @@ export class SpeechToTextModule { * Starts a transcription process for a given input array (16kHz waveform). * For multilingual models, specify the language in `options`. * Returns the transcription as a string. Passing `number[]` is deprecated. - * * @param waveform - The Float32Array audio data. * @param options - Decoding options including language. * @returns The transcription string. @@ -181,8 +173,8 @@ export class SpeechToTextModule { * Non-committed transcription contains the part of the transcription that is still being processed and may change. * Useful for displaying live, partial results during streaming. * Use with `streamInsert` and `streamStop` to control the stream. - * * @param options - Decoding options including language. + * @yields An object containing `committed` and `nonCommitted` transcription results. * @returns An async generator yielding transcription updates. */ public async *stream(options: DecodingOptions = {}): AsyncGenerator<{ @@ -255,7 +247,6 @@ export class SpeechToTextModule { /** * Inserts a new audio chunk into the streaming transcription session. - * * @param waveform - The audio chunk to insert. */ public streamInsert(waveform: Float32Array): void { diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts index 5720c6399c..b1de3e3a51 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts @@ -8,7 +8,6 @@ import { Logger } from '../../common/Logger'; /** * Module for generating text embeddings from input text. - * * @category Typescript API */ export class TextEmbeddingsModule extends BaseModule { @@ -19,7 +18,6 @@ export class TextEmbeddingsModule extends BaseModule { /** * Creates a text embeddings instance for a built-in model. - * * @param namedSources - An object specifying which built-in model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `TextEmbeddingsModule` instance. @@ -57,10 +55,8 @@ export class TextEmbeddingsModule extends BaseModule { /** * Creates a text embeddings instance with a user-provided model binary and tokenizer. * Use this when working with a custom-exported model that is not one of the built-in presets. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param tokenizerSource - A fetchable resource pointing to the tokenizer file. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. @@ -83,7 +79,6 @@ export class TextEmbeddingsModule extends BaseModule { /** * Executes the model's forward pass to generate an embedding for the provided text. - * * @param input - The text string to embed. * @returns A Promise resolving to a `Float32Array` containing the embedding vector. */ diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts index fb27dd29ba..6ab28543c6 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/TextToSpeechModule.ts @@ -12,7 +12,6 @@ import { Logger } from '../../common/Logger'; /** * Module for Text to Speech (TTS) functionalities. - * * @category Typescript API */ export class TextToSpeechModule { @@ -25,12 +24,10 @@ export class TextToSpeechModule { /** * Creates a Text to Speech instance. - * * @param config - Configuration object containing `model` and `voice`. * Pass one of the built-in constants (e.g. `{ model: KOKORO_MEDIUM, voice: KOKORO_VOICE_AF_HEART }`), or use require() to pass them. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `TextToSpeechModule` instance. - * * @example * ```ts * import { TextToSpeechModule, KOKORO_MEDIUM, KOKORO_VOICE_AF_HEART } from 'react-native-executorch'; @@ -113,7 +110,6 @@ export class TextToSpeechModule { /** * Synthesizes the provided text into speech. * Returns a promise that resolves to the full audio waveform as a `Float32Array`. - * * @param text The input text to be synthesized. * @param speed Optional speed multiplier for the speech synthesis (default is 1.0). * @returns A promise resolving to the synthesized audio waveform. @@ -130,7 +126,6 @@ export class TextToSpeechModule { * Synthesizes pre-computed phonemes into speech, bypassing the built-in phonemizer. * This allows using an external G2P system (e.g. the Python `phonemizer` library, * espeak-ng, or any custom phonemizer). - * * @param phonemes The pre-computed IPA phoneme string. * @param speed Optional speed multiplier for the speech synthesis (default is 1.0). * @returns A promise resolving to the synthesized audio waveform. @@ -145,8 +140,8 @@ export class TextToSpeechModule { /** * Starts a streaming synthesis session. Yields audio chunks as they are generated. - * * @param input - Input object containing text and optional speed. + * @yields An audio chunk generated during synthesis. * @returns An async generator yielding Float32Array audio chunks. */ public async *stream({ @@ -202,8 +197,8 @@ export class TextToSpeechModule { /** * Starts a streaming synthesis session from pre-computed phonemes. * Bypasses the built-in phonemizer, allowing use of external G2P systems. - * * @param input - Input object containing phonemes and optional speed. + * @yields An audio chunk generated during synthesis. * @returns An async generator yielding Float32Array audio chunks. */ public async *streamFromPhonemes({ @@ -255,6 +250,7 @@ export class TextToSpeechModule { /** * Inserts new text chunk into the buffer to be processed in streaming mode. + * @param textChunk - The text fragment to append to the streaming buffer. */ public streamInsert(textChunk: string): void { this.nativeModule.streamInsert(textChunk); @@ -262,8 +258,7 @@ export class TextToSpeechModule { /** * Stops the streaming process if there is any ongoing. - * - * * @param instant If true, stops the streaming as soon as possible. Otherwise + * @param instant - If true, stops the streaming as soon as possible. Otherwise * allows the module to complete processing for the remains of the buffer. */ public streamStop(instant: boolean = true): void { diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/TokenizerModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/TokenizerModule.ts index 0c67ac378d..dcfa030d2f 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/TokenizerModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/TokenizerModule.ts @@ -6,7 +6,6 @@ import { Logger } from '../../common/Logger'; /** * Module for Tokenizer functionalities. - * * @category Typescript API */ export class TokenizerModule { @@ -18,7 +17,6 @@ export class TokenizerModule { /** * Loads the tokenizer from the specified source. * `tokenizerSource` is a string that points to the location of the tokenizer JSON file. - * * @param tokenizer - Object containing `tokenizerSource`. * @param onDownloadProgressCallback - Optional callback to monitor download progress. */ @@ -47,7 +45,6 @@ export class TokenizerModule { /** * Converts a string into an array of token IDs. - * * @param input - The input string to be tokenized. * @returns An array of token IDs. */ @@ -57,7 +54,6 @@ export class TokenizerModule { /** * Converts an array of token IDs into a string. - * * @param tokens - Array of token IDs to be decoded. * @param skipSpecialTokens - Whether to skip special tokens during decoding (default: true). * @returns The decoded string. @@ -74,7 +70,6 @@ export class TokenizerModule { /** * Returns the size of the tokenizer's vocabulary. - * * @returns The vocabulary size. */ async getVocabSize(): Promise { @@ -83,7 +78,6 @@ export class TokenizerModule { /** * Returns the token associated to the ID. - * * @param tokenId - ID of the token. * @returns The token string associated to ID. */ @@ -93,7 +87,6 @@ export class TokenizerModule { /** * Returns the ID associated to the token. - * * @param token - The token string. * @returns The ID associated to the token. */ diff --git a/packages/react-native-executorch/src/modules/natural_language_processing/VADModule.ts b/packages/react-native-executorch/src/modules/natural_language_processing/VADModule.ts index c59ec5d0c9..e82b4ea9bf 100644 --- a/packages/react-native-executorch/src/modules/natural_language_processing/VADModule.ts +++ b/packages/react-native-executorch/src/modules/natural_language_processing/VADModule.ts @@ -8,7 +8,6 @@ import { Logger } from '../../common/Logger'; /** * Module for Voice Activity Detection (VAD) functionalities. - * * @category Typescript API */ export class VADModule extends BaseModule { @@ -19,7 +18,6 @@ export class VADModule extends BaseModule { /** * Creates a VAD instance for a built-in model. - * * @param namedSources - An object specifying which built-in model to load and where to fetch it from. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `VADModule` instance. @@ -49,10 +47,8 @@ export class VADModule extends BaseModule { /** * Creates a VAD instance with a user-provided model binary. * Use this when working with a custom-exported model that is not one of the built-in presets. - * * @remarks The native model contract for this method is not formally defined and may change * between releases. Refer to the native source code for the current expected tensor interface. - * * @param modelSource - A fetchable resource pointing to the model binary. * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. * @returns A Promise resolving to a `VADModule` instance. @@ -69,7 +65,6 @@ export class VADModule extends BaseModule { /** * Executes the model's forward pass to detect speech segments within the provided audio. - * * @param waveform - A `Float32Array` representing a mono audio signal sampled at 16kHz. * @returns A Promise resolving to an array of {@link Segment} objects. */ diff --git a/packages/react-native-executorch/src/types/classification.ts b/packages/react-native-executorch/src/types/classification.ts index 3c9ba6a0f2..f4eba97ad8 100644 --- a/packages/react-native-executorch/src/types/classification.ts +++ b/packages/react-native-executorch/src/types/classification.ts @@ -5,13 +5,11 @@ export { Imagenet1kLabel }; /** * Configuration for a custom classification model. - * * @typeParam T - The {@link LabelEnum} type for the model. * @property labelMap - The enum-like object mapping class names to indices. * @property preprocessorConfig - Optional preprocessing parameters. * @property preprocessorConfig.normMean - Per-channel mean values for input normalization. * @property preprocessorConfig.normStd - Per-channel standard deviation values for input normalization. - * * @category Types */ export type ClassificationConfig = { @@ -22,7 +20,6 @@ export type ClassificationConfig = { /** * Per-model config for {@link ClassificationModule.fromModelName}. * Each model name maps to its required fields. - * * @category Types */ export type ClassificationModelSources = @@ -31,18 +28,15 @@ export type ClassificationModelSources = /** * Union of all built-in classification model names. - * * @category Types */ export type ClassificationModelName = ClassificationModelSources['modelName']; /** * Props for the `useClassification` hook. - * * @typeParam C - A {@link ClassificationModelSources} config specifying which built-in model to load. * @property model - The model config containing `modelName` and `modelSource`. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. - * * @category Types */ export interface ClassificationProps { @@ -53,9 +47,7 @@ export interface ClassificationProps { /** * Return type for the `useClassification` hook. * Manages the state and operations for Computer Vision image classification. - * * @typeParam L - The {@link LabelEnum} representing the model's class labels. - * * @category Types */ export interface ClassificationType { @@ -87,7 +79,6 @@ export interface ClassificationType { * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or PixelData object) * @returns A Promise that resolves to the classification result mapping label keys to confidence scores. * @throws {RnExecutorchError} If the model is not loaded or is currently processing another image. @@ -102,7 +93,6 @@ export interface ClassificationType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @returns Object mapping class labels to confidence scores. */ diff --git a/packages/react-native-executorch/src/types/common.ts b/packages/react-native-executorch/src/types/common.ts index 16b16587d3..e8afa8ff4d 100644 --- a/packages/react-native-executorch/src/types/common.ts +++ b/packages/react-native-executorch/src/types/common.ts @@ -4,14 +4,12 @@ /** * Represents a source of a resource, which can be a string (e.g., URL or file path), a number (e.g., resource ID), or an object (e.g., binary data). - * * @category Types */ export type ResourceSource = string | number | object; /** * Enum representing the scalar types of tensors. - * * @category Types */ export enum ScalarType { @@ -107,7 +105,6 @@ export enum ScalarType { /** * Represents the data buffer of a tensor, which can be one of several typed array formats. - * * @category Types */ export type TensorBuffer = @@ -125,7 +122,6 @@ export type TensorBuffer = /** * Represents a pointer to a tensor, including its data buffer, size dimensions, and scalar type. - * * @category Types * @property {TensorBuffer} dataPtr - The data buffer of the tensor. * @property {number[]} sizes - An array representing the size of each dimension of the tensor. @@ -140,14 +136,12 @@ export interface TensorPtr { /** * A readonly record mapping string keys to numeric or string values. * Used to represent enum-like label maps for models. - * * @category Types */ export type LabelEnum = Readonly>; /** * A readonly triple of values, typically used for per-channel normalization parameters. - * * @category Types */ export type Triple = readonly [T, T, T]; @@ -158,7 +152,6 @@ export type Triple = readonly [T, T, T]; * - dataPtr must be Uint8Array (8-bit unsigned integers) * - scalarType is always BYTE (ScalarType.BYTE) * - sizes represents [height, width, channels] where channels must be 3 (RGB) - * * @category Types * @example * ```typescript diff --git a/packages/react-native-executorch/src/types/computerVision.ts b/packages/react-native-executorch/src/types/computerVision.ts index 62357f1402..a5d1dee7b2 100644 --- a/packages/react-native-executorch/src/types/computerVision.ts +++ b/packages/react-native-executorch/src/types/computerVision.ts @@ -4,7 +4,6 @@ import { LabelEnum } from './common'; * Given a model configs record (mapping model names to `{ labelMap }`) and a * type `T` (either a model name key or a raw {@link LabelEnum}), resolves to * the label map for that model or `T` itself. - * * @internal */ export type ResolveLabels< diff --git a/packages/react-native-executorch/src/types/executorchModule.ts b/packages/react-native-executorch/src/types/executorchModule.ts index edf1710862..e058d13eb7 100644 --- a/packages/react-native-executorch/src/types/executorchModule.ts +++ b/packages/react-native-executorch/src/types/executorchModule.ts @@ -3,7 +3,6 @@ import { RnExecutorchError } from '../errors/errorUtils'; /** * Props for the `useExecutorchModule` hook. - * * @category Types * @property {ResourceSource} modelSource - The source of the ExecuTorch model binary. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. @@ -16,7 +15,6 @@ export interface ExecutorchModuleProps { /** * Return type for the `useExecutorchModule` hook. * Manages the state and core execution methods for a general ExecuTorch model. - * * @category Types */ export interface ExecutorchModuleType { diff --git a/packages/react-native-executorch/src/types/imageEmbeddings.ts b/packages/react-native-executorch/src/types/imageEmbeddings.ts index 7130ac5b84..1ecea1ffd2 100644 --- a/packages/react-native-executorch/src/types/imageEmbeddings.ts +++ b/packages/react-native-executorch/src/types/imageEmbeddings.ts @@ -3,7 +3,6 @@ import { ResourceSource, PixelData, Frame } from './common'; /** * Union of all built-in image embeddings model names. - * * @category Types */ export type ImageEmbeddingsModelName = @@ -12,9 +11,8 @@ export type ImageEmbeddingsModelName = /** * Props for the `useImageEmbeddings` hook. - * * @category Types - * @property {Object} model - An object containing the model configuration. + * @property {object} model - An object containing the model configuration. * @property {ImageEmbeddingsModelName} model.modelName - Unique name identifying the model. * @property {ResourceSource} model.modelSource - The source of the image embeddings model binary. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. @@ -27,7 +25,6 @@ export interface ImageEmbeddingsProps { /** * Return type for the `useImageEmbeddings` hook. * Manages the state and operations for generating image embeddings (feature vectors) used in Computer Vision tasks. - * * @category Types */ export interface ImageEmbeddingsType { @@ -59,7 +56,6 @@ export interface ImageEmbeddingsType { * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or {@link PixelData} object) * @returns A Promise that resolves to a `Float32Array` containing the generated embedding vector. * @throws {RnExecutorchError} If the model is not loaded or is currently processing another image. @@ -74,7 +70,6 @@ export interface ImageEmbeddingsType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @returns Float32Array containing the embedding vector for the frame. */ diff --git a/packages/react-native-executorch/src/types/instanceSegmentation.ts b/packages/react-native-executorch/src/types/instanceSegmentation.ts index 01c52b9c0f..55b52def3b 100644 --- a/packages/react-native-executorch/src/types/instanceSegmentation.ts +++ b/packages/react-native-executorch/src/types/instanceSegmentation.ts @@ -5,7 +5,6 @@ import { Bbox } from './objectDetection'; /** * Raw instance returned from the native C++ side, carrying a numeric * `classIndex` instead of a resolved label string. - * * @internal */ export interface NativeSegmentedInstance { @@ -19,7 +18,6 @@ export interface NativeSegmentedInstance { /** * Represents a single detected instance in instance segmentation output. - * * @typeParam L - The label map type for the model, must conform to {@link LabelEnum}. * @category Types * @property {Bbox} bbox - The bounding box of the instance. @@ -40,7 +38,6 @@ export interface SegmentedInstance { /** * Options for instance segmentation forward pass. - * * @typeParam L - The label map type for the model, must conform to {@link LabelEnum}. * @category Types */ @@ -77,10 +74,8 @@ export interface InstanceSegmentationOptions { /** * Configuration for an instance segmentation model. - * * @typeParam T - The label map type for the model, must conform to {@link LabelEnum}. * @category Types - * * @remarks * The `availableInputSizes` and `defaultInputSize` fields are mutually inclusive: * - **Either both must be provided** (for models with multiple input sizes), or @@ -111,7 +106,6 @@ export type InstanceSegmentationConfig = { /** * Per-model config for {@link InstanceSegmentationModule.fromModelName}. * Each model name maps to its required fields. - * * @category Types */ export type InstanceSegmentationModelSources = @@ -124,7 +118,6 @@ export type InstanceSegmentationModelSources = /** * Union of all built-in instance segmentation model names. - * * @category Types */ export type InstanceSegmentationModelName = @@ -132,7 +125,6 @@ export type InstanceSegmentationModelName = /** * Extracts the instance segmentation model name from a {@link InstanceSegmentationModelSources} config object. - * * @category Types */ export type InstanceModelNameOf = @@ -140,11 +132,9 @@ export type InstanceModelNameOf = /** * Props for the `useInstanceSegmentation` hook. - * * @typeParam C - A {@link InstanceSegmentationModelSources} config specifying which built-in model to load. * @property model - The model config containing `modelName` and `modelSource`. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. - * * @category Types */ export interface InstanceSegmentationProps< @@ -157,9 +147,7 @@ export interface InstanceSegmentationProps< /** * Return type for the `useInstanceSegmentation` hook. * Manages the state and operations for instance segmentation models. - * * @typeParam L - The label map type for the model, must conform to {@link LabelEnum}. - * * @category Types */ export interface InstanceSegmentationType { @@ -209,7 +197,6 @@ export interface InstanceSegmentationType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @param isFrontCamera - Whether the front camera is active (for mirroring correction). * @param options - Optional configuration for the segmentation process. diff --git a/packages/react-native-executorch/src/types/llm.ts b/packages/react-native-executorch/src/types/llm.ts index a1e610256a..4cb4b58062 100644 --- a/packages/react-native-executorch/src/types/llm.ts +++ b/packages/react-native-executorch/src/types/llm.ts @@ -16,7 +16,6 @@ export type MediaArg = /** * Union of all built-in LLM model names. - * * @category Types */ export type LLMModelName = @@ -58,7 +57,6 @@ export type LLMModelName = /** * Properties for initializing and configuring a Large Language Model (LLM) instance. - * * @category Types */ export interface LLMProps { @@ -95,7 +93,6 @@ export interface LLMProps { /** * Base return type for `useLLM`. Contains all fields except `sendMessage`. - * * @category Types */ export interface LLMTypeBase { @@ -137,21 +134,18 @@ export interface LLMTypeBase { /** * Configures chat and tool calling. * See [Configuring the model](https://docs.swmansion.com/react-native-executorch/docs/hooks/natural-language-processing/useLLM#configuring-the-model) for details. - * * @param {LLMConfig} configuration - Configuration object containing `chatConfig`, `toolsConfig`, and `generationConfig`. */ configure: ({ chatConfig, toolsConfig, generationConfig }: LLMConfig) => void; /** * Returns the number of tokens generated so far in the current generation. - * * @returns The count of generated tokens. */ getGeneratedTokenCount: () => number; /** * Runs model to complete chat passed in `messages` argument. It doesn't manage conversation context. * For multimodal models, set `mediaPath` on user messages to include images. - * * @param messages - Array of messages representing the chat history. User messages may include a `mediaPath` field with a local image path. * @param tools - Optional array of tools that can be used during generation. * @returns The generated tokens as `string`. @@ -159,20 +153,17 @@ export interface LLMTypeBase { generate: (messages: Message[], tools?: LLMTool[]) => Promise; /** * Returns the number of total tokens from the previous generation. This is a sum of prompt tokens and generated tokens. - * * @returns The count of prompt and generated tokens. */ getTotalTokenCount: () => number; /** * Returns the number of prompt tokens in the last message. - * * @returns The count of prompt token. */ getPromptTokenCount: () => number; /** * Deletes all messages starting with message on `index` position. After deletion `messageHistory` will be updated. - * * @param index - The index of the message to delete from history. */ deleteMessage: (index: number) => void; @@ -195,7 +186,6 @@ export interface LLMTypeMultimodal< * Function to add user message to conversation. * Pass a `media` object whose shape is determined by the declared capabilities. * After model responds, `messageHistory` will be updated. - * * @param message - The message string to send. * @param media - Optional media object (e.g. `{ imagePath }` for vision. * @returns The model's response as a `string`. @@ -206,14 +196,12 @@ export interface LLMTypeMultimodal< /** * Return type for `useLLM` when `model.capabilities` is absent or does not include `'vision'`. * `sendMessage` accepts only text. - * * @category Types */ export interface LLMType extends LLMTypeBase { /** * Function to add user message to conversation. * After model responds, `messageHistory` will be updated. - * * @param message - The message string to send. * @returns The model's response as a `string`. */ @@ -222,7 +210,6 @@ export interface LLMType extends LLMTypeBase { /** * Configuration object for initializing and customizing a Large Language Model (LLM) instance. - * * @category Types */ export interface LLMConfig { @@ -264,14 +251,12 @@ export interface LLMConfig { /** * Roles that a message sender can have. - * * @category Types */ export type MessageRole = 'user' | 'assistant' | 'system'; /** * Represents a message in the conversation. - * * @category Types * @property {MessageRole} role - Role of the message sender of type `MessageRole`. * @property {string} content - Content of the message. @@ -288,10 +273,9 @@ export interface Message { /** * Represents a tool call made by the model. - * * @category Types * @property {string} toolName - The name of the tool being called. - * @property {Object} arguments - The arguments passed to the tool. + * @property {object} arguments - The arguments passed to the tool. */ export interface ToolCall { toolName: string; @@ -302,14 +286,12 @@ export interface ToolCall { * Represents a tool that can be used by the model. * Usually tool is represented with dictionary (Object), but fields depend on the model. * Unfortunately there's no one standard so it's hard to type it better. - * * @category Types */ export type LLMTool = Object; /** * Object configuring chat management. - * * @category Types * @property {Message[]} initialMessageHistory - An array of `Message` objects that represent the conversation history. This can be used to provide initial context to the model. * @property {string} systemPrompt - Often used to tell the model what is its purpose, for example - "Be a helpful translator". @@ -323,7 +305,6 @@ export interface ChatConfig { /** * Object configuring options for enabling and managing tool use. **It will only have effect if your model's chat template support it**. - * * @category Types * @property {LLMTool[]} tools - List of objects defining tools. * @property {(call: ToolCall) => Promise} executeToolCallback - Function that accepts `ToolCall`, executes tool and returns the string to model. @@ -337,7 +318,6 @@ export interface ToolsConfig { /** * Object configuring generation settings. - * * @category Types * @property {number} [temperature] - Scales output logits by the inverse of temperature. Controls the randomness / creativity of text generation. * @property {number} [topp] - Only samples from the smallest set of tokens whose cumulative probability exceeds topp. @@ -353,13 +333,12 @@ export interface GenerationConfig { /** * Defines a strategy for managing the conversation context window and message history. - * * @category Types */ export interface ContextStrategy { /** * Constructs the final array of messages to be sent to the model for the current inference step. - * * @param systemPrompt - The top-level instructions or persona assigned to the model. + * @param systemPrompt - The top-level instructions or persona assigned to the model. * @param history - The complete conversation history up to the current point. * @param maxContextLength - The maximum number of tokens that the model can keep in the context. * @param getTokenCount - A callback function provided by the LLM controller that calculates the exact number of tokens a specific array of messages will consume once formatted. @@ -375,7 +354,6 @@ export interface ContextStrategy { /** * Special tokens used in Large Language Models (LLMs). - * * @category Types */ export const SPECIAL_TOKENS = { diff --git a/packages/react-native-executorch/src/types/objectDetection.ts b/packages/react-native-executorch/src/types/objectDetection.ts index 71666f94a0..8e8bf02896 100644 --- a/packages/react-native-executorch/src/types/objectDetection.ts +++ b/packages/react-native-executorch/src/types/objectDetection.ts @@ -5,7 +5,6 @@ export { CocoLabel }; /** * Represents a bounding box for a detected object in an image. - * * @category Types * @property {number} x1 - The x-coordinate of the bottom-left corner of the bounding box. * @property {number} y1 - The y-coordinate of the bottom-left corner of the bounding box. @@ -21,7 +20,6 @@ export interface Bbox { /** * Represents a detected object within an image, including its bounding box, label, and confidence score. - * * @category Types * @typeParam L - The label enum type for the detected object. Defaults to {@link CocoLabel}. * @property {Bbox} bbox - The bounding box of the detected object, defined by its top-left (x1, y1) and bottom-right (x2, y2) coordinates. @@ -37,7 +35,6 @@ export interface Detection { /** * Per-model config for {@link ObjectDetectionModule.fromModelName}. * Each model name maps to its required fields. - * * @category Types */ export type ObjectDetectionModelSources = @@ -46,14 +43,12 @@ export type ObjectDetectionModelSources = /** * Union of all built-in object detection model names. - * * @category Types */ export type ObjectDetectionModelName = ObjectDetectionModelSources['modelName']; /** * Configuration for a custom object detection model. - * * @category Types */ export type ObjectDetectionConfig = { @@ -63,7 +58,6 @@ export type ObjectDetectionConfig = { /** * Props for the `useObjectDetection` hook. - * * @typeParam C - A {@link ObjectDetectionModelSources} config specifying which built-in model to load. * @category Types * @property model - The model config containing `modelName` and `modelSource`. @@ -77,9 +71,7 @@ export interface ObjectDetectionProps { /** * Return type for the `useObjectDetection` hook. * Manages the state and operations for Computer Vision object detection tasks. - * * @typeParam L - The {@link LabelEnum} representing the model's class labels. - * * @category Types */ export interface ObjectDetectionType { @@ -105,12 +97,10 @@ export interface ObjectDetectionType { /** * Executes the model's forward pass with automatic input type detection. - * * @param input - Image source (string path/URI or PixelData object) * @param detectionThreshold - An optional number between 0 and 1 representing the minimum confidence score. Default is 0.7. * @returns A Promise that resolves to an array of `Detection` objects. * @throws {RnExecutorchError} If the model is not loaded or is currently processing another image. - * * @example * ```typescript * // String path @@ -137,7 +127,6 @@ export interface ObjectDetectionType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @param isFrontCamera - Whether the front camera is active, used for mirroring corrections. * @param detectionThreshold - The threshold for detection sensitivity. diff --git a/packages/react-native-executorch/src/types/ocr.ts b/packages/react-native-executorch/src/types/ocr.ts index ea82cf2e22..d2f3781095 100644 --- a/packages/react-native-executorch/src/types/ocr.ts +++ b/packages/react-native-executorch/src/types/ocr.ts @@ -5,7 +5,6 @@ import { Frame, PixelData, ResourceSource } from './common'; /** * OCRDetection represents a single detected text instance in an image, * including its bounding box, recognized text, and confidence score. - * * @category Types * @property {Point[]} bbox - An array of points defining the bounding box around the detected text. * @property {string} text - The recognized text within the bounding box. @@ -19,7 +18,6 @@ export interface OCRDetection { /** * Point represents a coordinate in 2D space. - * * @category Types * @property {number} x - The x-coordinate of the point. * @property {number} y - The y-coordinate of the point. @@ -31,7 +29,6 @@ export interface Point { /** * Configuration properties for the `useOCR` hook. - * * @category Types */ export interface OCRProps { @@ -70,7 +67,6 @@ export interface OCRProps { /** * Configuration properties for the `useVerticalOCR` hook. - * * @category Types */ export interface VerticalOCRProps extends OCRProps { @@ -84,7 +80,6 @@ export interface VerticalOCRProps extends OCRProps { /** * Return type for the `useOCR` hook. * Manages the state and operations for Optical Character Recognition (OCR). - * * @category Types */ export interface OCRType { @@ -116,7 +111,6 @@ export interface OCRType { * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or PixelData object) * @returns A Promise that resolves to the OCR results (recognized text and bounding boxes). * @throws {RnExecutorchError} If the models are not loaded or are currently processing another image. @@ -134,7 +128,6 @@ export interface OCRType { * achieve real-time frame rates. Frames may be dropped if inference is still running. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @param isFrontCamera - Whether the front camera is active, used for mirroring corrections. * @returns Array of OCRDetection results for the frame. @@ -144,7 +137,6 @@ export interface OCRType { /** * Enumeration of supported OCR languages based on available symbol sets. - * * @category Types */ export type OCRLanguage = keyof typeof symbols; @@ -152,7 +144,6 @@ export type OCRLanguage = keyof typeof symbols; /** * Union of all built-in OCR model names. * Each name is derived from the language code, e.g. `'ocr-en'`, `'ocr-ja'`. - * * @category Types */ export type OCRModelName = `ocr-${OCRLanguage}`; diff --git a/packages/react-native-executorch/src/types/semanticSegmentation.ts b/packages/react-native-executorch/src/types/semanticSegmentation.ts index 5594e2a411..8f13a65eb7 100644 --- a/packages/react-native-executorch/src/types/semanticSegmentation.ts +++ b/packages/react-native-executorch/src/types/semanticSegmentation.ts @@ -3,13 +3,11 @@ import { LabelEnum, Triple, ResourceSource, PixelData, Frame } from './common'; /** * Configuration for a custom semantic segmentation model. - * * @typeParam T - The {@link LabelEnum} type for the model. * @property labelMap - The enum-like object mapping class names to indices. * @property preprocessorConfig - Optional preprocessing parameters. * @property preprocessorConfig.normMean - Per-channel mean values for input normalization. * @property preprocessorConfig.normStd - Per-channel standard deviation values for input normalization. - * * @category Types */ export type SemanticSegmentationConfig = { @@ -21,7 +19,6 @@ export type SemanticSegmentationConfig = { * Per-model config for {@link SemanticSegmentationModule.fromModelName}. * Each model name maps to its required fields. * Add new union members here when a model needs extra sources or options. - * * @category Types */ export type SemanticSegmentationModelSources = @@ -48,7 +45,6 @@ export type SemanticSegmentationModelSources = /** * Union of all built-in semantic segmentation model names * (e.g. `'deeplab-v3-resnet50'`, `'selfie-segmentation'`). - * * @category Types */ export type SemanticSegmentationModelName = @@ -56,7 +52,6 @@ export type SemanticSegmentationModelName = /** * Extracts the model name from a {@link SemanticSegmentationModelSources} config object. - * * @category Types */ export type ModelNameOf = @@ -64,7 +59,6 @@ export type ModelNameOf = /** * Labels used in the DeepLab semantic segmentation model. - * * @category Types */ export enum DeeplabLabel { @@ -93,7 +87,6 @@ export enum DeeplabLabel { /** * Labels used in the selfie semantic segmentation model. - * * @category Types */ export enum SelfieSegmentationLabel { @@ -103,11 +96,9 @@ export enum SelfieSegmentationLabel { /** * Props for the `useSemanticSegmentation` hook. - * * @typeParam C - A {@link SemanticSegmentationModelSources} config specifying which built-in model to load. * @property model - The model config containing `modelName` and `modelSource`. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. - * * @category Types */ export interface SemanticSegmentationProps< @@ -120,9 +111,7 @@ export interface SemanticSegmentationProps< /** * Return type for the `useSemanticSegmentation` hook. * Manages the state and operations for semantic segmentation models. - * * @typeParam L - The {@link LabelEnum} representing the model's class labels. - * * @category Types */ export interface SemanticSegmentationType { @@ -154,7 +143,6 @@ export interface SemanticSegmentationType { * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or PixelData object) * @param classesOfInterest - An optional array of label keys indicating which per-class probability masks to include in the output. `ARGMAX` is always returned regardless. * @param resizeToInput - Whether to resize the output masks to the original input image dimensions. If `false`, returns the raw model output dimensions. Defaults to `true`. @@ -175,7 +163,6 @@ export interface SemanticSegmentationType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @param isFrontCamera - Whether the front camera is active, used for mirroring corrections. * @param classesOfInterest - Labels for which to return per-class probability masks. diff --git a/packages/react-native-executorch/src/types/stt.ts b/packages/react-native-executorch/src/types/stt.ts index e3217c8da6..0a6ed11f70 100644 --- a/packages/react-native-executorch/src/types/stt.ts +++ b/packages/react-native-executorch/src/types/stt.ts @@ -3,7 +3,6 @@ import { RnExecutorchError } from '../errors/errorUtils'; /** * Named Speech to Text model variants. - * * @category Types */ export type SpeechToTextModelName = @@ -19,7 +18,6 @@ export type SpeechToTextModelName = /** * Configuration for Speech to Text model. - * * @category Types */ export interface SpeechToTextProps { @@ -35,7 +33,6 @@ export interface SpeechToTextProps { /** * React hook for managing Speech to Text (STT) instance. - * * @category Types */ export interface SpeechToTextType { @@ -120,7 +117,6 @@ export interface SpeechToTextType { /** * Languages supported by whisper (not whisper.en) - * * @category Types */ export type SpeechToTextLanguage = @@ -202,7 +198,6 @@ export type SpeechToTextLanguage = /** * Options for decoding speech to text. - * * @category Types * @property {SpeechToTextLanguage} [language] - Optional language code to guide the transcription. * @property {boolean} [verbose] - Optional flag. If set, transcription result is presented with timestamps @@ -215,7 +210,6 @@ export interface DecodingOptions { /** * Structure that represent single token with timestamp information. - * * @category Types * @property {string} [word] - Token as a string value. * @property {number} [start] - Timestamp of the beginning of the token in audio (in seconds). @@ -229,7 +223,6 @@ export interface Word { /** * Structure that represent single Segment of transcription. - * * @category Types * @property {number} [start] - Timestamp of the beginning of the segment in audio (in seconds). * @property {number} [end] - Timestamp of the end of the segment in audio (in seconds). @@ -254,7 +247,6 @@ export interface TranscriptionSegment { /** * Structure that represent result of transcription for a one function call (either `transcribe` or `stream`). - * * @category Types * @property {'transcribe' | 'stream'} [task] - String indicating task, either 'transcribe' or 'stream'. * @property {string} [language] - Language chosen for transcription. @@ -273,7 +265,6 @@ export interface TranscriptionResult { /** * Configuration for Speech to Text model. - * * @category Types */ export interface SpeechToTextModelConfig { diff --git a/packages/react-native-executorch/src/types/styleTransfer.ts b/packages/react-native-executorch/src/types/styleTransfer.ts index 568d648eca..ca08366f34 100644 --- a/packages/react-native-executorch/src/types/styleTransfer.ts +++ b/packages/react-native-executorch/src/types/styleTransfer.ts @@ -3,7 +3,6 @@ import { ResourceSource, PixelData, Frame } from './common'; /** * Union of all built-in style transfer model names. - * * @category Types */ export type StyleTransferModelName = @@ -18,9 +17,8 @@ export type StyleTransferModelName = /** * Configuration properties for the `useStyleTransfer` hook. - * * @category Types - * @property {Object} model - Object containing the model configuration. + * @property {object} model - Object containing the model configuration. * @property {StyleTransferModelName} model.modelName - Unique name identifying the model. * @property {ResourceSource} model.modelSource - `ResourceSource` that specifies the location of the style transfer model binary. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if loaded for the first time) after running the hook. @@ -33,7 +31,6 @@ export interface StyleTransferProps { /** * Return type for the `useStyleTransfer` hook. * Manages the state and operations for applying artistic style transfer to images. - * * @category Types */ export interface StyleTransferType { @@ -65,7 +62,6 @@ export interface StyleTransferType { * 2. **PixelData**: Raw pixel data from image libraries (e.g., NitroImage) * * **Note**: For VisionCamera frame processing, use `runOnFrame` instead. - * * @param input - Image source (string or PixelData object) * @param outputType - Output format: `'pixelData'` (default) returns raw RGBA pixel data; `'url'` saves the result to a temp file and returns its `file://` path. * @returns A Promise resolving to `PixelData` when `outputType` is `'pixelData'` (default), or a `file://` URL string when `outputType` is `'url'`. @@ -84,7 +80,6 @@ export interface StyleTransferType { * For async processing, use `forward()` instead. * * Available after model is loaded (`isReady: true`). - * * @param frame - VisionCamera Frame object * @param isFrontCamera - Whether the front camera is active, used for mirroring corrections. * @returns PixelData containing the stylized frame as raw RGB pixel data. diff --git a/packages/react-native-executorch/src/types/textEmbeddings.ts b/packages/react-native-executorch/src/types/textEmbeddings.ts index 2614bbbc40..87b5d6375f 100644 --- a/packages/react-native-executorch/src/types/textEmbeddings.ts +++ b/packages/react-native-executorch/src/types/textEmbeddings.ts @@ -3,7 +3,6 @@ import { ResourceSource } from '../types/common'; /** * Union of all built-in text embeddings model names. - * * @category Types */ export type TextEmbeddingsModelName = @@ -15,9 +14,8 @@ export type TextEmbeddingsModelName = /** * Props for the useTextEmbeddings hook. - * * @category Types - * @property {Object} model - An object containing the model configuration. + * @property {object} model - An object containing the model configuration. * @property {TextEmbeddingsModelName} model.modelName - Unique name identifying the model. * @property {ResourceSource} model.modelSource - The source of the text embeddings model binary. * @property {ResourceSource} model.tokenizerSource - The source of the tokenizer JSON file. @@ -43,7 +41,6 @@ export interface TextEmbeddingsProps { /** * React hook state and methods for managing a Text Embeddings model instance. - * * @category Types */ export interface TextEmbeddingsType { diff --git a/packages/react-native-executorch/src/types/tokenizer.ts b/packages/react-native-executorch/src/types/tokenizer.ts index 47b58124cd..dba7d61e77 100644 --- a/packages/react-native-executorch/src/types/tokenizer.ts +++ b/packages/react-native-executorch/src/types/tokenizer.ts @@ -3,7 +3,6 @@ import { ResourceSource } from './common'; /** * Parameters for initializing and configuring a Tokenizer instance. - * * @category Types */ export interface TokenizerProps { @@ -22,7 +21,6 @@ export interface TokenizerProps { /** * React hook state and methods for managing a Tokenizer instance. - * * @category Types */ export interface TokenizerType { diff --git a/packages/react-native-executorch/src/types/tti.ts b/packages/react-native-executorch/src/types/tti.ts index 543c99ce19..84ebd29fac 100644 --- a/packages/react-native-executorch/src/types/tti.ts +++ b/packages/react-native-executorch/src/types/tti.ts @@ -3,7 +3,6 @@ import { ResourceSource } from '../types/common'; /** * Union of all built-in Text-to-Image model names. - * * @category Types */ export type TextToImageModelName = @@ -12,7 +11,6 @@ export type TextToImageModelName = /** * Configuration properties for the `useTextToImage` hook. - * * @category Types */ export interface TextToImageProps { @@ -54,7 +52,6 @@ export interface TextToImageProps { /** * Return type for the `useTextToImage` hook. * Manages the state and operations for generating images from text prompts using a diffusion model pipeline. - * * @category Types */ export interface TextToImageType { diff --git a/packages/react-native-executorch/src/types/tts.ts b/packages/react-native-executorch/src/types/tts.ts index e515d13b42..82a5a5471c 100644 --- a/packages/react-native-executorch/src/types/tts.ts +++ b/packages/react-native-executorch/src/types/tts.ts @@ -3,14 +3,12 @@ import { RnExecutorchError } from '../errors/errorUtils'; /** * Union of all built-in Text to Speech model names. - * * @category Types */ export type TextToSpeechModelName = 'kokoro-small' | 'kokoro-medium'; /** * List all the languages available in TTS models (as lang shorthands) - * * @category Types */ export type TextToSpeechLanguage = @@ -21,7 +19,6 @@ export type TextToSpeechLanguage = * Voice configuration * * So far in Kokoro, each voice is directly associated with a language. - * * @category Types * @property {TextToSpeechLanguage} lang - speaker's language * @property {ResourceSource} voiceSource - a source to a binary file with voice embedding @@ -35,7 +32,6 @@ export interface VoiceConfig { /** * Kokoro-specific voice extra props - * * @category Types * @property {ResourceSource} taggerSource - source to Kokoro's tagger model binary * @property {ResourceSource} lexiconSource - source to Kokoro's lexicon binary @@ -48,7 +44,6 @@ export interface KokoroVoiceExtras { /** * Kokoro model configuration. * Only the core Kokoro model sources, as phonemizer sources are included in voice configuration. - * * @category Types * @property {TextToSpeechModelName} modelName - model name identifier * @property {ResourceSource} durationPredictorSource - source to Kokoro's duration predictor model binary @@ -62,7 +57,6 @@ export interface KokoroConfig { /** * General Text to Speech module configuration - * * @category Types * @property {KokoroConfig} model - a selected T2S model * @property {VoiceConfig} voice - a selected speaker's voice @@ -75,10 +69,8 @@ export interface TextToSpeechConfig { /** * Props for the useTextToSpeech hook. - * * @category Types - * @extends TextToSpeechConfig - * + * @augments TextToSpeechConfig * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. */ export interface TextToSpeechProps extends TextToSpeechConfig { @@ -87,7 +79,6 @@ export interface TextToSpeechProps extends TextToSpeechConfig { /** * Text to Speech module input definition - * * @category Types * @property {string} text - a text to be spoken * @property {number} [speed] - optional speed argument - the higher it is, the faster the speech becomes @@ -102,7 +93,6 @@ export interface TextToSpeechInput { * Use this when you have your own phonemizer (e.g. the Python `phonemizer` * library, espeak-ng, or any custom G2P system) and want to bypass the * built-in phonemizer pipeline. - * * @category Types * @property {string} phonemes - pre-computed IPA phoneme string * @property {number} [speed] - optional speed argument - the higher it is, the faster the speech becomes @@ -115,7 +105,6 @@ export interface TextToSpeechPhonemeInput { /** * Return type for the `useTextToSpeech` hook. * Manages the state and operations for Text-to-Speech generation. - * * @category Types */ export interface TextToSpeechType { @@ -141,7 +130,7 @@ export interface TextToSpeechType { /** * Runs the model to convert the provided text into speech audio in a single pass. - * * @param input - The `TextToSpeechInput` object containing the `text` to synthesize and optional `speed`. + * @param input - The `TextToSpeechInput` object containing the `text` to synthesize and optional `speed`. * @returns A Promise that resolves with the generated audio data (typically a `Float32Array`). * @throws {RnExecutorchError} If the model is not loaded or is currently generating. */ @@ -150,7 +139,6 @@ export interface TextToSpeechType { /** * Synthesizes pre-computed phonemes into speech audio in a single pass. * Bypasses the built-in phonemizer, allowing use of external G2P systems. - * * @param input - The `TextToSpeechPhonemeInput` object containing pre-computed `phonemes` and optional `speed`. * @returns A Promise that resolves with the generated audio data. * @throws {RnExecutorchError} If the model is not loaded or is currently generating. @@ -162,7 +150,7 @@ export interface TextToSpeechType { /** * Streams the generated audio data incrementally. * This is optimal for real-time playback, allowing audio to start playing before the full text is synthesized. - * * @param input - The `TextToSpeechStreamingInput` object containing `text`, optional `speed`, and lifecycle callbacks (`onBegin`, `onNext`, `onEnd`). + * @param input - The `TextToSpeechStreamingInput` object containing `text`, optional `speed`, and lifecycle callbacks (`onBegin`, `onNext`, `onEnd`). * @returns A Promise that resolves when the streaming process is complete. * @throws {RnExecutorchError} If the model is not loaded or is currently generating. */ @@ -170,7 +158,6 @@ export interface TextToSpeechType { /** * Streams pre-computed phonemes incrementally, bypassing the built-in phonemizer. - * * @param input - The streaming input with pre-computed `phonemes` instead of `text`. * @returns A Promise that resolves when the streaming process is complete. * @throws {RnExecutorchError} If the model is not loaded or is currently generating. @@ -186,7 +173,6 @@ export interface TextToSpeechType { /** * Interrupts and stops the currently active audio generation stream. - * * @param instant If true, stops the streaming as soon as possible. Otherwise * allows the module to complete processing for the remains of the buffer. */ @@ -195,7 +181,6 @@ export interface TextToSpeechType { /** * Shared streaming lifecycle callbacks for TTS streaming modes. - * * @category Types * @property {() => void | Promise} [onBegin] - Called when streaming begins * @property {(audio: Float32Array) => void | Promise} [onNext] - Called after each audio chunk gets calculated. @@ -217,7 +202,6 @@ export interface TextToSpeechStreamingCallbacks { * * Enables an incrementally expanded input, in other words adding * new text chunks with streamInsert() as the streaming is running. - * * @category Types * @property {boolean} [stopAutomatically] - If true, streaming will stop automatically when the buffer is empty. */ @@ -229,7 +213,6 @@ export interface TextToSpeechStreamingInput /** * Streaming input definition for pre-computed phonemes. * Same as `TextToSpeechStreamingInput` but accepts `phonemes` instead of `text`. - * * @category Types */ export interface TextToSpeechStreamingPhonemeInput diff --git a/packages/react-native-executorch/src/types/vad.ts b/packages/react-native-executorch/src/types/vad.ts index 57bd112628..5c0868c5d7 100644 --- a/packages/react-native-executorch/src/types/vad.ts +++ b/packages/react-native-executorch/src/types/vad.ts @@ -3,16 +3,14 @@ import { RnExecutorchError } from '../errors/errorUtils'; /** * Union of all built-in VAD model names. - * * @category Types */ export type VADModelName = 'fsmn-vad'; /** * Props for the useVAD hook. - * * @category Types - * @property {Object} model - An object containing the model configuration. + * @property {object} model - An object containing the model configuration. * @property {VADModelName} model.modelName - Unique name identifying the model. * @property {ResourceSource} model.modelSource - The source of the VAD model binary. * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. @@ -24,7 +22,6 @@ export interface VADProps { /** * Represents a detected audio segment with start and end timestamps. - * * @category Types * @property {number} start - Start time of the segment in seconds. * @property {number} end - End time of the segment in seconds. @@ -36,7 +33,6 @@ export interface Segment { /** * React hook state and methods for managing a Voice Activity Detection (VAD) model instance. - * * @category Types */ export interface VADType { diff --git a/packages/react-native-executorch/src/utils/ResourceFetcher.ts b/packages/react-native-executorch/src/utils/ResourceFetcher.ts index f0905dda37..bd92c07f2f 100644 --- a/packages/react-native-executorch/src/utils/ResourceFetcher.ts +++ b/packages/react-native-executorch/src/utils/ResourceFetcher.ts @@ -38,9 +38,7 @@ import { ResourceFetcherUtils } from './ResourceFetcherUtils'; * **Required Methods:** * - `fetch`: Download resources to local storage (used by all modules) * - `readAsString`: Read file contents as string (used for config files) - * * @category Utilities - General - * * @remarks * This interface is intentionally minimal. Custom fetchers only need to implement * these two methods for the library to function correctly. @@ -48,12 +46,10 @@ import { ResourceFetcherUtils } from './ResourceFetcherUtils'; export interface ResourceFetcherAdapter { /** * Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch. - * * @param callback - Optional callback to track progress of all downloads, reported between 0 and 1. * @param sources - Multiple resources that can be strings, asset references, or objects. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded/stored resources (without file:// prefix). * If the fetch was interrupted, it returns a promise which resolves to `null`. - * * @remarks * **REQUIRED**: Used by all library modules for downloading models and resources. */ @@ -64,10 +60,8 @@ export interface ResourceFetcherAdapter { /** * Read file contents as a string. - * * @param path - Absolute file path * @returns File contents as string - * * @remarks * **REQUIRED**: Used internally for reading configuration files (e.g., tokenizer configs). */ @@ -77,7 +71,6 @@ export interface ResourceFetcherAdapter { /** * This module provides functions to download and work with downloaded files stored in the application's document directory inside the `react-native-executorch/` directory. * These utilities can help you manage your storage and clean up the downloaded files when they are no longer needed. - * * @category Utilities - General */ export class ResourceFetcher { @@ -85,9 +78,7 @@ export class ResourceFetcher { /** * Sets a custom resource fetcher adapter for resource operations. - * * @param adapter - The adapter instance to use for fetching resources. - * * @remarks * **INTERNAL**: Used by platform-specific init functions (expo/bare) to inject their fetcher implementation. */ @@ -97,7 +88,6 @@ export class ResourceFetcher { /** * Resets the resource fetcher adapter to null. - * * @remarks * **INTERNAL**: Used primarily for testing purposes to clear the adapter state. */ @@ -107,10 +97,8 @@ export class ResourceFetcher { /** * Gets the current resource fetcher adapter instance. - * * @returns The configured ResourceFetcherAdapter instance. * @throws {RnExecutorchError} If no adapter has been set via {@link setAdapter}. - * * @remarks * **INTERNAL**: Used internally by all resource fetching operations. */ @@ -126,7 +114,6 @@ export class ResourceFetcher { /** * Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch. - * * @param callback - Optional callback to track progress of all downloads, reported between 0 and 1. * @param sources - Multiple resources that can be strings, asset references, or objects. * @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded/stored resources (without file:// prefix). @@ -150,7 +137,6 @@ export class ResourceFetcher { /** * Filesystem utilities for reading downloaded resources. - * * @remarks * Provides access to filesystem operations through the configured adapter. * Currently supports reading file contents as strings for configuration files. @@ -158,10 +144,8 @@ export class ResourceFetcher { static fs = { /** * Reads the contents of a file as a string. - * * @param path - Absolute file path to read. * @returns A promise that resolves to the file contents as a string. - * * @remarks * **REQUIRED**: Used internally for reading configuration files (e.g., tokenizer configs). */ diff --git a/packages/react-native-executorch/src/utils/ResourceFetcherUtils.ts b/packages/react-native-executorch/src/utils/ResourceFetcherUtils.ts index 6aab9d2a49..b98496af58 100644 --- a/packages/react-native-executorch/src/utils/ResourceFetcherUtils.ts +++ b/packages/react-native-executorch/src/utils/ResourceFetcherUtils.ts @@ -2,22 +2,22 @@ import { ResourceSource } from '..'; /** * Http status codes - * * @category Types */ export enum HTTP_CODE { - /** * Everything is ok. + /** + Everything is ok. */ OK = 200, - /** * Server has fulfilled a client request for a specific part of a resource, instead of sending the entire file. + /** + Server has fulfilled a client request for a specific part of a resource, instead of sending the entire file. */ PARTIAL_CONTENT = 206, } /** * Download status of the file. - * * @category Types */ export enum DownloadStatus { @@ -34,7 +34,6 @@ export enum DownloadStatus { /** * Types of sources that can be downloaded - * * @category Types */ export enum SourceType { @@ -66,7 +65,6 @@ export enum SourceType { /** * Extended interface for resource sources, tracking download state and file locations. - * * @category Interfaces */ export interface ResourceSourceExtended { @@ -113,7 +111,6 @@ export interface ResourceSourceExtended { /** * Utility functions for fetching and managing resources. - * * @category Utilities - General */ export namespace ResourceFetcherUtils { diff --git a/packages/react-native-executorch/src/utils/llm.ts b/packages/react-native-executorch/src/utils/llm.ts index 5b4383ffb3..4dedfe0188 100644 --- a/packages/react-native-executorch/src/utils/llm.ts +++ b/packages/react-native-executorch/src/utils/llm.ts @@ -8,7 +8,6 @@ import { Logger } from '../common/Logger'; /** * Parses tool calls from a given message string. - * * @category Utilities - LLM * @param message - The message string containing tool calls in JSON format. * @returns An array of `ToolCall` objects extracted from the message. @@ -56,7 +55,6 @@ const filterObjectKeys = (obj: object, keysToRemove: string[]) => { /** * Generates a structured output prompt based on the provided schema. - * * @category Utilities - LLM * @param responseSchema - The schema (Zod or JSON Schema) defining the desired output format. * @returns A prompt string instructing the model to format its output according to the given schema. @@ -93,7 +91,6 @@ const extractBetweenBrackets = (text: string): string => { /** * Fixes and validates structured output from LLMs against a provided schema. - * * @category Utilities - LLM * @param output - The raw output string from the LLM. * @param responseSchema - The schema (Zod or JSON Schema) to validate the output against. diff --git a/packages/react-native-executorch/src/utils/llms/context_strategy/MessageCountContextStrategy.ts b/packages/react-native-executorch/src/utils/llms/context_strategy/MessageCountContextStrategy.ts index 83a391547a..c967561377 100644 --- a/packages/react-native-executorch/src/utils/llms/context_strategy/MessageCountContextStrategy.ts +++ b/packages/react-native-executorch/src/utils/llms/context_strategy/MessageCountContextStrategy.ts @@ -3,24 +3,22 @@ import { ContextStrategy, Message } from '../../../types/llm'; /** * A simple context strategy that retains a fixed number of the most recent messages. * This strategy trims the conversation history based purely on the message count. - * * @category Utils */ export class MessageCountContextStrategy implements ContextStrategy { /** * Initializes the MessageCountContextStrategy. - * * @param {number} windowLength - The maximum number of recent messages to retain in the context. Defaults to 5. + * @param windowLength - The maximum number of recent messages to retain in the context. Defaults to 5. */ constructor(private readonly windowLength: number = 5) {} /** * Builds the context by slicing the history to retain only the most recent `windowLength` messages. - * - * @param {string} systemPrompt - The top-level instructions for the model. - * @param {Message[]} history - The complete conversation history. - * @param {(messages: Message[]) => number} _getTokenCount - Unused in this strategy. - * @param {number} _maxContextLength - Unused in this strategy. - * @returns {Message[]} The truncated message history with the system prompt at the beginning. + * @param systemPrompt - The top-level instructions for the model. + * @param history - The complete conversation history. + * @param _maxContextLength - Unused in this strategy. + * @param _getTokenCount - Unused in this strategy. + * @returns The truncated message history with the system prompt at the beginning. */ buildContext( systemPrompt: string, diff --git a/packages/react-native-executorch/src/utils/llms/context_strategy/NoopContextStrategy.ts b/packages/react-native-executorch/src/utils/llms/context_strategy/NoopContextStrategy.ts index 2438492665..a9dee23f93 100644 --- a/packages/react-native-executorch/src/utils/llms/context_strategy/NoopContextStrategy.ts +++ b/packages/react-native-executorch/src/utils/llms/context_strategy/NoopContextStrategy.ts @@ -2,20 +2,18 @@ import { ContextStrategy, Message } from '../../../types/llm'; /** * A context strategy that performs no filtering or trimming of the message history. - * * This strategy is ideal when the developer wants to manually manage the conversation + * This strategy is ideal when the developer wants to manually manage the conversation * context. - * * @category Utils */ export class NoopContextStrategy implements ContextStrategy { /** * Builds the context by prepending the system prompt to the entire unfiltered history. - * - * @param {string} systemPrompt - The top-level instructions for the model. - * @param {Message[]} history - The complete conversation history. - * @param {number} _maxContextLength - Unused in this strategy. - * @param {(messages: Message[]) => number} _getTokenCount - Unused in this strategy. - * @returns {Message[]} The unedited message history with the system prompt at the beginning. + * @param systemPrompt - The top-level instructions for the model. + * @param history - The complete conversation history. + * @param _maxContextLength - Unused in this strategy. + * @param _getTokenCount - Unused in this strategy. + * @returns The unedited message history with the system prompt at the beginning. */ buildContext( systemPrompt: string, diff --git a/packages/react-native-executorch/src/utils/llms/context_strategy/SlidingWindowContextStrategy.ts b/packages/react-native-executorch/src/utils/llms/context_strategy/SlidingWindowContextStrategy.ts index 096be005ef..fcbe1c295b 100644 --- a/packages/react-native-executorch/src/utils/llms/context_strategy/SlidingWindowContextStrategy.ts +++ b/packages/react-native-executorch/src/utils/llms/context_strategy/SlidingWindowContextStrategy.ts @@ -3,17 +3,16 @@ import { ContextStrategy, Message } from '../../../types/llm'; /** * An advanced, token-aware context strategy that dynamically trims the message history * to ensure it fits within the model's physical context limits. - * * This strategy calculates the exact token count of the formatted prompt. If the prompt + * This strategy calculates the exact token count of the formatted prompt. If the prompt * exceeds the allowed token budget (`maxContextLength` - `bufferTokens`), it recursively * removes the oldest messages. - * * @category Utils */ export class SlidingWindowContextStrategy implements ContextStrategy { /** * Initializes the SlidingWindowContextStrategy. - * @param {number} bufferTokens - The number of tokens to keep free for the model's generated response (e.g., 1000). - * @param {boolean} allowOrphanedAssistantMessages - Whether to allow orphaned assistant messages when trimming the history. + * @param bufferTokens - The number of tokens to keep free for the model's generated response (e.g., 1000). + * @param allowOrphanedAssistantMessages - Whether to allow orphaned assistant messages when trimming the history. * If false, the strategy will ensure that an assistant message is not left without its preceding user message. */ constructor( @@ -24,12 +23,11 @@ export class SlidingWindowContextStrategy implements ContextStrategy { /** * Builds the context by recursively evicting the oldest messages until the total * token count is safely within the defined budget. - * - * @param {string} systemPrompt - The top-level instructions for the model. - * @param {Message[]} history - The complete conversation history. - * @param {number} maxContextLength - Unused in this strategy, as the strategy relies on token count rather than message count. - * @param {(messages: Message[]) => number} getTokenCount - Callback to calculate the exact token count of the rendered template. - * @returns {Message[]} The optimized message history guaranteed to fit the token budget. + * @param systemPrompt - The top-level instructions for the model. + * @param history - The complete conversation history. + * @param maxContextLength - Unused in this strategy, as the strategy relies on token count rather than message count. + * @param getTokenCount - Callback to calculate the exact token count of the rendered template. + * @returns The optimized message history guaranteed to fit the token budget. */ buildContext( systemPrompt: string, diff --git a/yarn.lock b/yarn.lock index 55dacec67a..23d84b41f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2360,6 +2360,26 @@ __metadata: languageName: node linkType: hard +"@es-joy/jsdoccomment@npm:~0.84.0": + version: 0.84.0 + resolution: "@es-joy/jsdoccomment@npm:0.84.0" + dependencies: + "@types/estree": "npm:^1.0.8" + "@typescript-eslint/types": "npm:^8.54.0" + comment-parser: "npm:1.4.5" + esquery: "npm:^1.7.0" + jsdoc-type-pratt-parser: "npm:~7.1.1" + checksum: 10/3387c5f7ae9bb52e1b9bd65757d74e4e7628741da6fe67dac08e2aa3f69de4a7cf60148707e259747a773f85ee0b40850f3839e21569d904ed705a50cbbc0ee1 + languageName: node + linkType: hard + +"@es-joy/resolve.exports@npm:1.2.0": + version: 1.2.0 + resolution: "@es-joy/resolve.exports@npm:1.2.0" + checksum: 10/238189f011902b3db0dcf9cd01d403eb565cfc80fb2614cba01c0c1f66b607575132f9952ac914a7395074fbca13415137a50152afc17b1dcb5ae032a84a680d + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.9.1 resolution: "@eslint-community/eslint-utils@npm:4.9.1" @@ -4994,6 +5014,13 @@ __metadata: languageName: node linkType: hard +"@sindresorhus/base62@npm:^1.0.0": + version: 1.0.0 + resolution: "@sindresorhus/base62@npm:1.0.0" + checksum: 10/ba1a1ccfc9de0995f0e4506b8cabff3436fd1a9815f9c1a44f6833694bba6b3db7fa61fa5fc2f63180edda01abf3c26ffd16325be0ab25409f992ba91ea6dcd0 + languageName: node + linkType: hard + "@sinonjs/commons@npm:^3.0.0, @sinonjs/commons@npm:^3.0.1": version: 3.0.1 resolution: "@sinonjs/commons@npm:3.0.1" @@ -5227,6 +5254,13 @@ __metadata: languageName: node linkType: hard +"@types/estree@npm:^1.0.8": + version: 1.0.8 + resolution: "@types/estree@npm:1.0.8" + checksum: 10/25a4c16a6752538ffde2826c2cc0c6491d90e69cd6187bef4a006dd2c3c45469f049e643d7e516c515f21484dc3d48fd5c870be158a5beb72f5baf3dc43e4099 + languageName: node + linkType: hard + "@types/graceful-fs@npm:^4.1.3": version: 4.1.9 resolution: "@types/graceful-fs@npm:4.1.9" @@ -5501,6 +5535,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:^8.54.0": + version: 8.56.1 + resolution: "@typescript-eslint/types@npm:8.56.1" + checksum: 10/4bcffab5b0fd48adb731fcade86a776ca4a66e229defa5a282b58ba9c95af16ffc459a7d188e27c988a35be1f6fb5b812f9cf0952692eac38d5b3e87daafb20a + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/typescript-estree@npm:5.62.0" @@ -5820,7 +5861,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.15.0, acorn@npm:^8.9.0": +"acorn@npm:^8.15.0, acorn@npm:^8.16.0, acorn@npm:^8.9.0": version: 8.16.0 resolution: "acorn@npm:8.16.0" bin: @@ -5974,6 +6015,13 @@ __metadata: languageName: node linkType: hard +"are-docs-informative@npm:^0.0.2": + version: 0.0.2 + resolution: "are-docs-informative@npm:0.0.2" + checksum: 10/12cdae51a4bb369832ef1a35840604247d4ed0cbc8392f2519988d170f92c3f8c60e465844f41acba1ec3062d0edb2e9133fca38cb9c1214309153d50a25fa29 + languageName: node + linkType: hard + "arg@npm:^5.0.2": version: 5.0.2 resolution: "arg@npm:5.0.2" @@ -7172,7 +7220,7 @@ __metadata: languageName: node linkType: hard -"comment-parser@npm:^1.4.0": +"comment-parser@npm:1.4.5, comment-parser@npm:^1.4.0": version: 1.4.5 resolution: "comment-parser@npm:1.4.5" checksum: 10/4b5cacc7ab1ec48e3f51b788bd7cda567f5c83040e029e5c92eacf0785735a9b44ac49fdaf73d9bd4af9464aa4cc8cc7184902090b55b0023605a845f2666ba4 @@ -8328,6 +8376,30 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-jsdoc@npm:^62.7.1": + version: 62.7.1 + resolution: "eslint-plugin-jsdoc@npm:62.7.1" + dependencies: + "@es-joy/jsdoccomment": "npm:~0.84.0" + "@es-joy/resolve.exports": "npm:1.2.0" + are-docs-informative: "npm:^0.0.2" + comment-parser: "npm:1.4.5" + debug: "npm:^4.4.3" + escape-string-regexp: "npm:^4.0.0" + espree: "npm:^11.1.0" + esquery: "npm:^1.7.0" + html-entities: "npm:^2.6.0" + object-deep-merge: "npm:^2.0.0" + parse-imports-exports: "npm:^0.2.4" + semver: "npm:^7.7.4" + spdx-expression-parse: "npm:^4.0.0" + to-valid-identifier: "npm:^1.0.0" + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 + checksum: 10/cd4e6b0fa84747456f84ae1a5266de61b4e2171121ad57b6a27b58b09c9130dd4088d4e876b57fa7f0c88dc8c2029d6ee0e2d982fcfb164a75076e25ddc8949e + languageName: node + linkType: hard + "eslint-plugin-markdown@npm:^5.1.0": version: 5.1.0 resolution: "eslint-plugin-markdown@npm:5.1.0" @@ -8457,6 +8529,13 @@ __metadata: languageName: node linkType: hard +"eslint-visitor-keys@npm:^5.0.1": + version: 5.0.1 + resolution: "eslint-visitor-keys@npm:5.0.1" + checksum: 10/f9cc1a57b75e0ef949545cac33d01e8367e302de4c1483266ed4d8646ee5c306376660196bbb38b004e767b7043d1e661cb4336b49eff634a1bbe75c1db709ec + languageName: node + linkType: hard + "eslint@npm:^8.19.0, eslint@npm:^8.57.0": version: 8.57.1 resolution: "eslint@npm:8.57.1" @@ -8505,6 +8584,17 @@ __metadata: languageName: node linkType: hard +"espree@npm:^11.1.0": + version: 11.1.1 + resolution: "espree@npm:11.1.1" + dependencies: + acorn: "npm:^8.16.0" + acorn-jsx: "npm:^5.3.2" + eslint-visitor-keys: "npm:^5.0.1" + checksum: 10/58ecfae40f4e1f2c54a825ff7a50c5f9cda42901468ba93354c13a1eb69aba0f15d68df5822bbcb02058f822214aba7ca24389eee2e6c27bb0cd3a05972606ae + languageName: node + linkType: hard + "espree@npm:^9.6.0, espree@npm:^9.6.1": version: 9.6.1 resolution: "espree@npm:9.6.1" @@ -8526,7 +8616,7 @@ __metadata: languageName: node linkType: hard -"esquery@npm:^1.4.2": +"esquery@npm:^1.4.2, esquery@npm:^1.7.0": version: 1.7.0 resolution: "esquery@npm:1.7.0" dependencies: @@ -9678,6 +9768,13 @@ __metadata: languageName: node linkType: hard +"html-entities@npm:^2.6.0": + version: 2.6.0 + resolution: "html-entities@npm:2.6.0" + checksum: 10/06d4e7a3ba6243bba558af176e56f85e09894b26d911bc1ef7b2b9b3f18b46604360805b32636f080e954778e9a34313d1982479a05a5aa49791afd6a4229346 + languageName: node + linkType: hard + "html-escaper@npm:^2.0.0": version: 2.0.2 resolution: "html-escaper@npm:2.0.2" @@ -11367,6 +11464,13 @@ __metadata: languageName: node linkType: hard +"jsdoc-type-pratt-parser@npm:~7.1.1": + version: 7.1.1 + resolution: "jsdoc-type-pratt-parser@npm:7.1.1" + checksum: 10/2fd8a4b2b373d63d7d74993be3098230faebc24a7a964f78cfde42deb484646c3bd00d7388e44965a44f86d250d218d536d4e0e12b150fa85117532d877a482e + languageName: node + linkType: hard + "jsesc@npm:^3.0.2, jsesc@npm:~3.1.0": version: 3.1.0 resolution: "jsesc@npm:3.1.0" @@ -13427,6 +13531,13 @@ __metadata: languageName: node linkType: hard +"object-deep-merge@npm:^2.0.0": + version: 2.0.0 + resolution: "object-deep-merge@npm:2.0.0" + checksum: 10/d2f9aa0b2160118f3e261fe51634a958b9f19993f64479911df3d3b4daa0212cb01bf2a7cf2c3ab1a1830cc167151a408ecf8c3e47efa44343b516777d6ef11c + languageName: node + linkType: hard + "object-inspect@npm:^1.13.3, object-inspect@npm:^1.13.4": version: 1.13.4 resolution: "object-inspect@npm:1.13.4" @@ -13727,6 +13838,15 @@ __metadata: languageName: node linkType: hard +"parse-imports-exports@npm:^0.2.4": + version: 0.2.4 + resolution: "parse-imports-exports@npm:0.2.4" + dependencies: + parse-statements: "npm:1.0.11" + checksum: 10/144d459771d1aeaa80eebffe43a2074c34e5b79a86d326c907efea90b62ff41af9555600b8e117e6cab717654d8e20b440e9ab09cdbbc9092f352cb0a9e1f3a3 + languageName: node + linkType: hard + "parse-json@npm:^4.0.0": version: 4.0.0 resolution: "parse-json@npm:4.0.0" @@ -13758,6 +13878,13 @@ __metadata: languageName: node linkType: hard +"parse-statements@npm:1.0.11": + version: 1.0.11 + resolution: "parse-statements@npm:1.0.11" + checksum: 10/287c2739f4cbffa08e28a95ea2d3ff4a8a51ddb367df6212ae2cd80580a1189e09c6edcb8277fc05d0fdbcb93c86ad16b591f317e2fe12ac4189de738863e514 + languageName: node + linkType: hard + "parseurl@npm:~1.3.3": version: 1.3.3 resolution: "parseurl@npm:1.3.3" @@ -14358,6 +14485,7 @@ __metadata: cspell: "npm:^8.19.0" eslint: "npm:^8.57.0" eslint-plugin-ft-flow: "npm:^2.0.3" + eslint-plugin-jsdoc: "npm:^62.7.1" eslint-plugin-markdown: "npm:^5.1.0" eslint-plugin-prettier: "npm:^5.0.1" expo-router: "npm:~6.0.17" @@ -14905,6 +15033,13 @@ __metadata: languageName: node linkType: hard +"reserved-identifiers@npm:^1.0.0": + version: 1.2.0 + resolution: "reserved-identifiers@npm:1.2.0" + checksum: 10/02722585aa97f25384a59a33055529a90c8fa8ce3d32f02be4bcec1454254fb385429fc3168a85fe56bb952ad632ea8fecb8fa2addb47e7d97a1ab4922827ad9 + languageName: node + linkType: hard + "resolve-cwd@npm:^3.0.0": version: 3.0.0 resolution: "resolve-cwd@npm:3.0.0" @@ -15175,7 +15310,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.1.3, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.7.1, semver@npm:^7.7.2, semver@npm:^7.7.3": +"semver@npm:^7.1.3, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.7.1, semver@npm:^7.7.2, semver@npm:^7.7.3, semver@npm:^7.7.4": version: 7.7.4 resolution: "semver@npm:7.7.4" bin: @@ -15521,6 +15656,30 @@ __metadata: languageName: node linkType: hard +"spdx-exceptions@npm:^2.1.0": + version: 2.5.0 + resolution: "spdx-exceptions@npm:2.5.0" + checksum: 10/bb127d6e2532de65b912f7c99fc66097cdea7d64c10d3ec9b5e96524dbbd7d20e01cba818a6ddb2ae75e62bb0c63d5e277a7e555a85cbc8ab40044984fa4ae15 + languageName: node + linkType: hard + +"spdx-expression-parse@npm:^4.0.0": + version: 4.0.0 + resolution: "spdx-expression-parse@npm:4.0.0" + dependencies: + spdx-exceptions: "npm:^2.1.0" + spdx-license-ids: "npm:^3.0.0" + checksum: 10/936be681fbf5edeec3a79c023136479f70d6edb3fd3875089ac86cd324c6c8c81add47399edead296d1d0af17ae5ce88c7f88885eb150b62c2ff6e535841ca6a + languageName: node + linkType: hard + +"spdx-license-ids@npm:^3.0.0": + version: 3.0.23 + resolution: "spdx-license-ids@npm:3.0.23" + checksum: 10/fead6be44478e4dd73a0721ae569f4a04f358846d8d82e8d92efae64aca928592e380cf17e8b84c25c948f3a7d8a0b4fc781a1830f3911ca87d52733265176b5 + languageName: node + linkType: hard + "speech@workspace:apps/speech": version: 0.0.0-use.local resolution: "speech@workspace:apps/speech" @@ -16061,6 +16220,16 @@ __metadata: languageName: node linkType: hard +"to-valid-identifier@npm:^1.0.0": + version: 1.0.0 + resolution: "to-valid-identifier@npm:1.0.0" + dependencies: + "@sindresorhus/base62": "npm:^1.0.0" + reserved-identifiers: "npm:^1.0.0" + checksum: 10/fba7ebdf464c92c92ccde887f917c9461792f99b738d36bebe5c3bd07562c3fdceedfd120ac115da359162b115798136bb8b9ea7417d7e3a663db9425ff1bcc1 + languageName: node + linkType: hard + "toidentifier@npm:~1.0.1": version: 1.0.1 resolution: "toidentifier@npm:1.0.1"