From 4fd0954bbcc62c69db225821c8b611219bbfe0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20S=C5=82uszniak?= Date: Wed, 22 Apr 2026 10:38:57 +0200 Subject: [PATCH 1/2] docs: clarify ResourceFetcher class docstring The file-level and class-level docstrings listed pauseFetching, resumeFetching, cancelFetching, getFilesTotalSize, listDownloadedFiles, listDownloadedModels, and deleteResources as available on ResourceFetcher. Those methods only exist on the concrete adapter implementations (ExpoResourceFetcher, BareResourceFetcher). Rewrite both docstrings to describe ResourceFetcher as the static entry point that delegates to a configured adapter, and direct readers to the adapter packages when they want the storage-management utilities. Refs #1086 (item 4). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/utils/ResourceFetcher.ts | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/react-native-executorch/src/utils/ResourceFetcher.ts b/packages/react-native-executorch/src/utils/ResourceFetcher.ts index bf5db8267..145adece0 100644 --- a/packages/react-native-executorch/src/utils/ResourceFetcher.ts +++ b/packages/react-native-executorch/src/utils/ResourceFetcher.ts @@ -1,31 +1,27 @@ /** * Resource Fetcher * - * Provides an interface for downloading files (via `ResourceFetcher.fetch()`) + * Static entry point that delegates resource operations to a configured + * `ResourceFetcherAdapter`. The adapter is registered for you when you call + * `initExecutorch({ resourceFetcher })` from one of the platform packages: * - * Key functionality: - * - Download control: pause, resume, and cancel operations through: - * - Single file: `.pauseFetching()`, `.resumeFetching()`, `.cancelFetching()` - * - Downloaded file management: - * - `.getFilesTotalSize()`, `.listDownloadedFiles()`, `.listDownloadedModels()`, `.deleteResources()` + * - `react-native-executorch-expo-resource-fetcher` (Expo apps) + * - `react-native-executorch-bare-resource-fetcher` (bare React Native) * - * Remark: The pausing/resuming/canceling works only for fetching remote resources. + * Methods on this class: + * - `setAdapter` / `resetAdapter` / `getAdapter` — adapter lifecycle. Usually + * handled by `initExecutorch`, not called directly by application code. + * - `fetch(callback, ...sources)` — delegates to the adapter's `fetch` and + * additionally fires HuggingFace download counters for known model URLs. + * - `fs.readAsString(path)` — delegates to the adapter for reading config + * files as text. * - * Most exported functions accept: - * - Multiple `ResourceSource` arguments, (union type of string, number or object) - * - * Method `.fetch()` takes argument as callback that reports download progress. - * Method`.fetch()` returns array of paths to successfully saved files or null if the download was paused or cancelled (then resume functions can return paths). - * - * Technical Implementation: - * - Maintains a `downloads` Map instance that tracks: - * - Currently downloading resources - * - Paused downloads - * - Successful downloads are automatically removed from the `downloads` Map - * - Uses the `ResourceSourceExtended` interface to enable pause/resume functionality: - * - Wraps user-provided `ResourceSource` elements - * - Implements linked list behavior via the `.next` attribute - * - Automatically processes subsequent downloads when `.next` contains a valid resource + * Storage-management utilities such as `pauseFetching`, `resumeFetching`, + * `cancelFetching`, `getFilesTotalSize`, `listDownloadedFiles`, + * `listDownloadedModels`, and `deleteResources` are NOT methods on this + * class. They live on the concrete adapter implementations + * (`ExpoResourceFetcher`, `BareResourceFetcher`); use the adapter directly + * if you need them. */ import { ResourceSource } from '../types/common'; @@ -71,8 +67,14 @@ 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. + * Static entry point that delegates resource operations to the configured + * `ResourceFetcherAdapter` (registered via `initExecutorch({ resourceFetcher })`). + * + * For storage-management utilities — deleting downloaded models, listing + * downloaded files, getting their total size, and pausing/resuming/cancelling + * downloads — use the adapter implementation directly. See `ExpoResourceFetcher` + * (in `react-native-executorch-expo-resource-fetcher`) or `BareResourceFetcher` + * (in `react-native-executorch-bare-resource-fetcher`). * @category Utilities - General */ export class ResourceFetcher { From 7915e5e2dddc7a2b3f9534d8e591b0e2b3ed9df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20S=C5=82uszniak?= Date: Fri, 24 Apr 2026 17:10:16 +0200 Subject: [PATCH 2/2] docs: drop file-level ResourceFetcher docstring It duplicated the class docstring and caused the original drift flagged in #1086. The class-level block is self-contained. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/utils/ResourceFetcher.ts | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/packages/react-native-executorch/src/utils/ResourceFetcher.ts b/packages/react-native-executorch/src/utils/ResourceFetcher.ts index 145adece0..7b31f6558 100644 --- a/packages/react-native-executorch/src/utils/ResourceFetcher.ts +++ b/packages/react-native-executorch/src/utils/ResourceFetcher.ts @@ -1,29 +1,3 @@ -/** - * Resource Fetcher - * - * Static entry point that delegates resource operations to a configured - * `ResourceFetcherAdapter`. The adapter is registered for you when you call - * `initExecutorch({ resourceFetcher })` from one of the platform packages: - * - * - `react-native-executorch-expo-resource-fetcher` (Expo apps) - * - `react-native-executorch-bare-resource-fetcher` (bare React Native) - * - * Methods on this class: - * - `setAdapter` / `resetAdapter` / `getAdapter` — adapter lifecycle. Usually - * handled by `initExecutorch`, not called directly by application code. - * - `fetch(callback, ...sources)` — delegates to the adapter's `fetch` and - * additionally fires HuggingFace download counters for known model URLs. - * - `fs.readAsString(path)` — delegates to the adapter for reading config - * files as text. - * - * Storage-management utilities such as `pauseFetching`, `resumeFetching`, - * `cancelFetching`, `getFilesTotalSize`, `listDownloadedFiles`, - * `listDownloadedModels`, and `deleteResources` are NOT methods on this - * class. They live on the concrete adapter implementations - * (`ExpoResourceFetcher`, `BareResourceFetcher`); use the adapter directly - * if you need them. - */ - import { ResourceSource } from '../types/common'; import { RnExecutorchError } from '../errors/errorUtils'; import { RnExecutorchErrorCode } from '../errors/ErrorCodes';