Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell-wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,4 @@ nˈɛvəɹ
ɹˈiᵊli
ˈɛniwˌʌn
ˈɛls
Synchronizable
58 changes: 57 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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',
Expand All @@ -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}'],
Expand All @@ -58,4 +107,11 @@ module.exports = {
},
],
ignorePatterns: ['node_modules/', 'lib/'],
settings: {
jsdoc: {
tagNamePreference: {
typeParam: 'typeParam',
},
},
},
};
2 changes: 2 additions & 0 deletions apps/computer-vision/components/ImageWithMasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions apps/speech/screens/TextToSpeechLLMScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions apps/speech/screens/TextToSpeechScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
25 changes: 11 additions & 14 deletions docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}, []),
});

// ...
Expand Down
1 change: 1 addition & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const config = {
projectName: 'react-native-executorch',

onBrokenLinks: 'throw',
onBrokenAnchors: 'throw',
markdown: {
hooks: {
onBrokenMarkdownLinks: 'warn',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 0 additions & 13 deletions packages/bare-resource-fetcher/src/ResourceFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -102,15 +100,13 @@ 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 = {
downloads: new Map<ResourceSource, DownloadResource>(), //map of currently downloading (or paused) files, if the download was started by .fetch() method.

/**
* 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).
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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`.
Expand All @@ -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.
*/
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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).
*/
Expand Down
1 change: 0 additions & 1 deletion packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type { ResourceSourceExtended };

/**
* Utility functions for fetching and managing resources.
*
* @category Utilities - General
*/
export namespace ResourceFetcherUtils {
Expand Down
13 changes: 0 additions & 13 deletions packages/expo-resource-fetcher/src/ResourceFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -94,15 +92,13 @@ 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 = {
downloads: new Map<ResourceSource, DownloadResource>(), //map of currently downloading (or paused) files, if the download was started by .fetch() method.

/**
* 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).
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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`.
Expand All @@ -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.
*/
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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).
*
Expand Down
1 change: 0 additions & 1 deletion packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface DownloadResource {

/**
* Utility functions for fetching and managing resources.
*
* @category Utilities - General
*/
export namespace ResourceFetcherUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ std::vector<types::Instance> 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<OwningArrayBuffer>(
invMask.data, static_cast<size_t>(invMask.total()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const IMAGENET1K_STD: Triple<number> = [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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
Loading
Loading