From 76ec2e13f5a4d6f28f5fa0403d51beab15abb424 Mon Sep 17 00:00:00 2001 From: chmjkb Date: Tue, 24 Mar 2026 11:45:28 +0100 Subject: [PATCH 1/7] docs: add a warning on getting started page, fix the link in resource fetcher error message --- .../01-fundamentals/01-getting-started.md | 29 ++++++++++++++++++- .../src/utils/ResourceFetcher.ts | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/docs/01-fundamentals/01-getting-started.md b/docs/docs/01-fundamentals/01-getting-started.md index b82322dd8c..5d88f5643d 100644 --- a/docs/docs/01-fundamentals/01-getting-started.md +++ b/docs/docs/01-fundamentals/01-getting-started.md @@ -38,13 +38,17 @@ For supported React Native and Expo versions, see the [Compatibility table](../0 ## Installation -Installation is pretty straightforward, just use your favorite package manager. +Installation is pretty straightforward, use your package manager of choice to install the package and some peer dependencies required to streamline model downloads. If you want to implement your custom model fetching logic, see [this document](). ``` npm install react-native-executorch + # For Expo projects + pnpm install react-native-executorch-expo-resource-fetcher + # For bare RN projects + npm install react-native-executorch-bare-resource-fetcher ``` @@ -52,6 +56,11 @@ Installation is pretty straightforward, just use your favorite package manager. ``` pnpm install react-native-executorch + # For Expo projects + pnpm install react-native-executorch-expo-resource-fetcher + # For bare RN projects + pnpm install react-native-executorch-bare-resource-fetcher + ``` @@ -59,11 +68,29 @@ Installation is pretty straightforward, just use your favorite package manager. ``` yarn add react-native-executorch + # For Expo projects + yarn install react-native-executorch-expo-resource-fetcher + # For bare RN projects + yarn install react-native-executorch-bare-resource-fetcher ``` +:::warning +Before using any other API, you must call `initExecutorch` with a resource fetcher adapter at the entry point of your app: + +```js +import { initExecutorch } from 'react-native-executorch'; +import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher'; +// or ExpoResourceFetcher for Expo projects + +initExecutorch({ resourceFetcher: BareResourceFetcher }); +``` + +Calling any library API without initializing first will throw a `ResourceFetcherAdapterNotInitialized` error. +::: + Our library offers support for both bare React Native and Expo projects. Please follow the instructions from [Loading models section](./02-loading-models.md) to make sure you setup your project correctly. We encourage you to use Expo project if possible. If you are planning to migrate from bare React Native to Expo project, the link (https://docs.expo.dev/bare/installing-expo-modules/) offers a guidance on setting up Expo Modules in a bare React Native environment. If you plan on using your models via require() instead of fetching them from a url, you also need to add following lines to your `metro.config.js`: diff --git a/packages/react-native-executorch/src/utils/ResourceFetcher.ts b/packages/react-native-executorch/src/utils/ResourceFetcher.ts index 52a3d1ca9a..cc3cfcb1a2 100644 --- a/packages/react-native-executorch/src/utils/ResourceFetcher.ts +++ b/packages/react-native-executorch/src/utils/ResourceFetcher.ts @@ -106,7 +106,7 @@ export class ResourceFetcher { static getAdapter(): ResourceFetcherAdapter { if (!this.adapter) { const errorMessage = - 'ResourceFetcher adapter is not initialized. Please call initExecutorch({ resourceFetcher: ... }) with a valid adapter, e.g., from react-native-executorch-expo-resource-fetcher or react-native-executorch-bare-resource-fetcher. For more details please refer: https://docs.swmansion.com/react-native-executorch/docs/next/fundamentals/loading-models'; + 'ResourceFetcher adapter is not initialized. Please call initExecutorch({ resourceFetcher: ... }) with a valid adapter, e.g., from react-native-executorch-expo-resource-fetcher or react-native-executorch-bare-resource-fetcher. For more details please refer to: https://docs.swmansion.com/react-native-executorch/docs/next/fundamentals/loading-models'; // for sanity :) Logger.error(errorMessage); throw new RnExecutorchError( From 2e4cd5bb50a5622f2aa4f8df0e31f04dfe693ddd Mon Sep 17 00:00:00 2001 From: chmjkb Date: Tue, 24 Mar 2026 19:30:09 +0100 Subject: [PATCH 2/7] docs: add a separate section for resource fetcher --- .cspell-wordlist.txt | 1 + .../01-fundamentals/01-getting-started.md | 8 +- .../01-usage.md} | 92 ++++++++------- .../08-resource-fetcher/02-custom-adapter.md | 110 ++++++++++++++++++ docs/docs/08-resource-fetcher/_category_.json | 6 + docs/sidebars.js | 5 + 6 files changed, 177 insertions(+), 45 deletions(-) rename docs/docs/{05-utilities/resource-fetcher.md => 08-resource-fetcher/01-usage.md} (50%) create mode 100644 docs/docs/08-resource-fetcher/02-custom-adapter.md create mode 100644 docs/docs/08-resource-fetcher/_category_.json diff --git a/.cspell-wordlist.txt b/.cspell-wordlist.txt index 9daa4dc166..36855896be 100644 --- a/.cspell-wordlist.txt +++ b/.cspell-wordlist.txt @@ -180,3 +180,4 @@ nˈɛvəɹ ˈɛniwˌʌn ˈɛls Synchronizable +stringifying diff --git a/docs/docs/01-fundamentals/01-getting-started.md b/docs/docs/01-fundamentals/01-getting-started.md index 5d88f5643d..10062d90bc 100644 --- a/docs/docs/01-fundamentals/01-getting-started.md +++ b/docs/docs/01-fundamentals/01-getting-started.md @@ -46,8 +46,8 @@ Installation is pretty straightforward, use your package manager of choice to in ``` npm install react-native-executorch # For Expo projects - pnpm install react-native-executorch-expo-resource-fetcher - # For bare RN projects + npm install react-native-executorch-expo-resource-fetcher + # For bare React Native projects npm install react-native-executorch-bare-resource-fetcher ``` @@ -58,7 +58,7 @@ Installation is pretty straightforward, use your package manager of choice to in pnpm install react-native-executorch # For Expo projects pnpm install react-native-executorch-expo-resource-fetcher - # For bare RN projects + # For bare React Native projects pnpm install react-native-executorch-bare-resource-fetcher ``` @@ -70,7 +70,7 @@ Installation is pretty straightforward, use your package manager of choice to in yarn add react-native-executorch # For Expo projects yarn install react-native-executorch-expo-resource-fetcher - # For bare RN projects + # For bare React Native projects yarn install react-native-executorch-bare-resource-fetcher ``` diff --git a/docs/docs/05-utilities/resource-fetcher.md b/docs/docs/08-resource-fetcher/01-usage.md similarity index 50% rename from docs/docs/05-utilities/resource-fetcher.md rename to docs/docs/08-resource-fetcher/01-usage.md index 1dfea89b3f..77afc3d1db 100644 --- a/docs/docs/05-utilities/resource-fetcher.md +++ b/docs/docs/08-resource-fetcher/01-usage.md @@ -1,19 +1,29 @@ --- -title: Resource Fetcher +title: Usage --- -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. +This page documents the resource fetcher APIs exposed by `react-native-executorch-expo-resource-fetcher` and `react-native-executorch-bare-resource-fetcher`. These adapters handle downloading and managing model files on disk. + +:::info +All examples below use `ExpoResourceFetcher`. If you're on bare React Native, replace the import with: + +```typescript +import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher'; +``` + +The API is identical between both adapters. +::: ## fetch -Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch. +Fetches resources (remote URLs, local files, or embedded assets) and stores them locally for use by React Native ExecuTorch. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const uris = await ResourceFetcher.fetch( +const uris = await ExpoResourceFetcher.fetch( (progress) => console.log('Total progress:', progress), 'https://.../llama3_2.pte', 'https://.../qwen3.pte' @@ -29,31 +39,31 @@ const uris = await ResourceFetcher.fetch( `Promise`: -- 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 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 by `pauseFetching` or `cancelFetching`, it returns a promise which resolves to `null`. :::info -If the resource is an object, it will be saved as a JSON file on disk. +If the resource is an object, it will be saved as a JSON file on disk. ::: ## pauseFetching -Pauses an ongoing download of files. +Pauses an ongoing download. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const uris = ResourceFetcher.fetch( +const uris = ExpoResourceFetcher.fetch( (progress) => console.log('Total progress:', progress), 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ).then((uris) => { - console.log('URI resolved to: ', uris); // since we pause the fetch, uris is resolved to null + console.log('URI resolved to: ', uris); // null, since we paused }); -await ResourceFetcher.pauseFetching( +await ExpoResourceFetcher.pauseFetching( 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ); @@ -69,31 +79,31 @@ await ResourceFetcher.pauseFetching( ## resumeFetching -Resumes a paused download of files. +Resumes a paused download. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const uris = ResourceFetcher.fetch( +const uris = ExpoResourceFetcher.fetch( (progress) => console.log('Total progress:', progress), 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ).then((uris) => { - console.log('URI resolved as: ', uris); // since we pause the fetch, uris is resolved to null + console.log('URI resolved as: ', uris); // null, since we paused }); -await ResourceFetcher.pauseFetching( +await ExpoResourceFetcher.pauseFetching( 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ); -const resolvedUris = await ResourceFetcher.resumeFetching( +const resolvedUris = await ExpoResourceFetcher.resumeFetching( 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ); -//resolvedUris is resolved to file paths to fetched resources, unless explicitly paused/cancel again. +// resolvedUris resolves to file paths, unless paused/cancelled again ``` ### Parameters @@ -104,31 +114,31 @@ const resolvedUris = await ResourceFetcher.resumeFetching( `Promise`: -- 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. +- 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`. :::info -The other way to resume paused resources is to simply call `fetch` again. However, `resumeFetching` is faster. +You can also resume a paused download by calling `fetch` again with the same sources. However, `resumeFetching` is faster as it resumes from where it left off. ::: ## cancelFetching -Cancels an ongoing/paused download of files. +Cancels an ongoing or paused download. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const uris = ResourceFetcher.fetch( +const uris = ExpoResourceFetcher.fetch( (progress) => console.log('Total progress:', progress), 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ).then((uris) => { - console.log('URI resolved as: ', uris); // since we cancel the fetch, uris is resolved to null + console.log('URI resolved as: ', uris); // null, since we cancelled }); -await ResourceFetcher.cancelFetching( +await ExpoResourceFetcher.cancelFetching( 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ); @@ -149,9 +159,9 @@ Deletes downloaded resources from the local filesystem. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -await ResourceFetcher.deleteResources('https://.../llama3_2.pte'); +await ExpoResourceFetcher.deleteResources('https://.../llama3_2.pte'); ``` ### Parameters @@ -164,14 +174,14 @@ await ResourceFetcher.deleteResources('https://.../llama3_2.pte'); ## getFilesTotalSize -Fetches the info about files size. Works only for remote files. +Fetches the combined size of remote files. Works only for remote URLs. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const totalSize = await ResourceFetcher.getFilesTotalSize( +const totalSize = await ExpoResourceFetcher.getFilesTotalSize( 'https://.../llama3_2.pte', 'https://.../qwen3.pte' ); @@ -183,36 +193,36 @@ const totalSize = await ResourceFetcher.getFilesTotalSize( ### Returns -`Promise` – A promise that resolves to combined size of files in bytes. +`Promise` – A promise that resolves to the combined size of files in bytes. ## listDownloadedFiles -Lists all the downloaded files used by React Native ExecuTorch. +Lists all files downloaded by React Native ExecuTorch. ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const filesUris = await ResourceFetcher.listDownloadedFiles(); +const filesUris = await ExpoResourceFetcher.listDownloadedFiles(); ``` ### Returns -`Promise` - A promise, which resolves to an array of URIs for all the downloaded files. +`Promise` - A promise that resolves to an array of URIs for all downloaded files. ## listDownloadedModels -Lists all the downloaded models used by React Native ExecuTorch. +Lists all downloaded model files (`.pte`). ### Reference ```typescript -import { ResourceFetcher } from 'react-native-executorch'; +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; -const modelsUris = await ResourceFetcher.listDownloadedModels(); +const modelsUris = await ExpoResourceFetcher.listDownloadedModels(); ``` ### Returns -`Promise` - A promise, which resolves to an array of URIs for all the downloaded models. +`Promise` - A promise that resolves to an array of URIs for all downloaded model files. diff --git a/docs/docs/08-resource-fetcher/02-custom-adapter.md b/docs/docs/08-resource-fetcher/02-custom-adapter.md new file mode 100644 index 0000000000..8242fd487b --- /dev/null +++ b/docs/docs/08-resource-fetcher/02-custom-adapter.md @@ -0,0 +1,110 @@ +--- +title: Custom Adapter +--- + +If the built-in `BareResourceFetcher` and `ExpoResourceFetcher` don't fit your needs, for example, you want to use a different download library, or fetch from a private server you can implement your own adapter and plug it into React Native ExecuTorch. + +## The ResourceFetcherAdapter interface + +Your adapter must implement the `ResourceFetcherAdapter` interface exported from `react-native-executorch`. This interface defines every method which is used under the hood by React Native ExecuTorch: + +```typescript +import { + ResourceFetcherAdapter, + ResourceSource, +} from 'react-native-executorch'; + +interface ResourceFetcherAdapter { + fetch( + callback: (downloadProgress: number) => void, + ...sources: ResourceSource[] + ): Promise; + + readAsString(path: string): Promise; +} +``` + +### `fetch` + +This is the core method called by every model hook and module whenever it needs to resolve a model or resource to a local file path. + +- `callback` — called with a progress value between `0` and `1` as downloads proceed. Called with `1` when complete. +- `...sources` — one or more `ResourceSource` values: + - `string` — a remote URL or an absolute local file path. + - `number` — a bundled asset reference from `require('./model.pte')`. + - `object` — an inline JS object (e.g. a tokenizer config) that should be JSON-serialized and written to disk. Your adapter is responsible for stringifying it and saving it as a file, then returning the local path. This allows callers to pass configs inline instead of hosting them at a URL. +- **Returns** an array of absolute local file paths (without `file://` prefix), one per source, in the same order. Return `null` if the fetch was intentionally interrupted (e.g. cancelled by the user). + +### `readAsString` + +Called internally to read configuration files (e.g. tokenizer configs) that were previously downloaded via `fetch`. + +- `path` — absolute path to the file on disk. +- **Returns** the file contents as a UTF-8 string. + +## Example + +Here's a minimal custom adapter that downloads files using the browser `fetch` API (useful for testing or web targets): + +```typescript +import * as FileSystem from 'expo-file-system'; +import { + ResourceFetcherAdapter, + ResourceSource, +} from 'react-native-executorch'; + +export const MyCustomFetcher: ResourceFetcherAdapter = { + async fetch(callback, ...sources: ResourceSource[]) { + const paths: string[] = []; + + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + + if (typeof source !== 'string') { + throw new Error('MyCustomFetcher only supports string URLs'); + } + + const filename = source.split('/').pop()!; + const localUri = FileSystem.documentDirectory + filename; + + const downloadResumable = FileSystem.createDownloadResumable( + source, + localUri, + {}, + ({ totalBytesWritten, totalBytesExpectedToWrite }) => { + const fileProgress = totalBytesWritten / totalBytesExpectedToWrite; + const overallProgress = (i + fileProgress) / sources.length; + callback(overallProgress); + } + ); + + const result = await downloadResumable.downloadAsync(); + if (!result) return null; + + paths.push(result.uri.replace('file://', '')); + } + + callback(1); + return paths; + }, + + async readAsString(path: string) { + return await FileSystem.readAsStringAsync('file://' + path, { + encoding: FileSystem.EncodingType.UTF8, + }); + }, +}; +``` + +## Registering your adapter + +Pass your adapter to `initExecutorch` at the entry point of your app, before any other library API is called: + +```typescript +import { initExecutorch } from 'react-native-executorch'; +import { MyCustomFetcher } from './MyCustomFetcher'; + +initExecutorch({ resourceFetcher: MyCustomFetcher }); +``` + +Any model hook or module used after this point will route all resource fetching through your adapter. diff --git a/docs/docs/08-resource-fetcher/_category_.json b/docs/docs/08-resource-fetcher/_category_.json new file mode 100644 index 0000000000..e6f56e8790 --- /dev/null +++ b/docs/docs/08-resource-fetcher/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Resource Fetcher", + "link": { + "type": "generated-index" + } +} diff --git a/docs/sidebars.js b/docs/sidebars.js index d1b6c57637..76e1313467 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -40,6 +40,11 @@ const sidebars = { label: 'Utilities', items: [{ type: 'autogenerated', dirName: '05-utilities' }], }, + { + type: 'category', + label: 'Resource Fetcher', + items: [{ type: 'autogenerated', dirName: '08-resource-fetcher' }], + }, { type: 'category', label: 'Other', From dfde74af9d716f9fbe18eefb8553e48d62297bec Mon Sep 17 00:00:00 2001 From: chmjkb Date: Tue, 24 Mar 2026 19:36:54 +0100 Subject: [PATCH 3/7] docs: add a proper link to the custom resource fetcher impl --- docs/docs/01-fundamentals/01-getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/01-fundamentals/01-getting-started.md b/docs/docs/01-fundamentals/01-getting-started.md index 10062d90bc..79dcef3f4b 100644 --- a/docs/docs/01-fundamentals/01-getting-started.md +++ b/docs/docs/01-fundamentals/01-getting-started.md @@ -38,7 +38,7 @@ For supported React Native and Expo versions, see the [Compatibility table](../0 ## Installation -Installation is pretty straightforward, use your package manager of choice to install the package and some peer dependencies required to streamline model downloads. If you want to implement your custom model fetching logic, see [this document](). +Installation is pretty straightforward, use your package manager of choice to install the package and some peer dependencies required to streamline model downloads. If you want to implement your custom model fetching logic, see [this document](../08-resource-fetcher/02-custom-adapter.md). From ded61e518e9ff6ba75cf58e3ac1b61b1570b3e7c Mon Sep 17 00:00:00 2001 From: chmjkb Date: Tue, 24 Mar 2026 19:38:34 +0100 Subject: [PATCH 4/7] docs: make the default example an Expo one --- docs/docs/01-fundamentals/01-getting-started.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/01-fundamentals/01-getting-started.md b/docs/docs/01-fundamentals/01-getting-started.md index 79dcef3f4b..f0a7941c93 100644 --- a/docs/docs/01-fundamentals/01-getting-started.md +++ b/docs/docs/01-fundamentals/01-getting-started.md @@ -82,10 +82,10 @@ Before using any other API, you must call `initExecutorch` with a resource fetch ```js import { initExecutorch } from 'react-native-executorch'; -import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher'; -// or ExpoResourceFetcher for Expo projects +import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher'; +// or BareResourceFetcher for Expo projects -initExecutorch({ resourceFetcher: BareResourceFetcher }); +initExecutorch({ resourceFetcher: ExpoResourceFetcher }); ``` Calling any library API without initializing first will throw a `ResourceFetcherAdapterNotInitialized` error. From 06a44b92d2804dd93d33a450d7d5ad4a4fa221cb Mon Sep 17 00:00:00 2001 From: chmjkb Date: Tue, 24 Mar 2026 19:44:36 +0100 Subject: [PATCH 5/7] chore: remove redundant exmplea --- .../08-resource-fetcher/02-custom-adapter.md | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/docs/docs/08-resource-fetcher/02-custom-adapter.md b/docs/docs/08-resource-fetcher/02-custom-adapter.md index 8242fd487b..b308be282f 100644 --- a/docs/docs/08-resource-fetcher/02-custom-adapter.md +++ b/docs/docs/08-resource-fetcher/02-custom-adapter.md @@ -42,60 +42,6 @@ Called internally to read configuration files (e.g. tokenizer configs) that were - `path` — absolute path to the file on disk. - **Returns** the file contents as a UTF-8 string. -## Example - -Here's a minimal custom adapter that downloads files using the browser `fetch` API (useful for testing or web targets): - -```typescript -import * as FileSystem from 'expo-file-system'; -import { - ResourceFetcherAdapter, - ResourceSource, -} from 'react-native-executorch'; - -export const MyCustomFetcher: ResourceFetcherAdapter = { - async fetch(callback, ...sources: ResourceSource[]) { - const paths: string[] = []; - - for (let i = 0; i < sources.length; i++) { - const source = sources[i]; - - if (typeof source !== 'string') { - throw new Error('MyCustomFetcher only supports string URLs'); - } - - const filename = source.split('/').pop()!; - const localUri = FileSystem.documentDirectory + filename; - - const downloadResumable = FileSystem.createDownloadResumable( - source, - localUri, - {}, - ({ totalBytesWritten, totalBytesExpectedToWrite }) => { - const fileProgress = totalBytesWritten / totalBytesExpectedToWrite; - const overallProgress = (i + fileProgress) / sources.length; - callback(overallProgress); - } - ); - - const result = await downloadResumable.downloadAsync(); - if (!result) return null; - - paths.push(result.uri.replace('file://', '')); - } - - callback(1); - return paths; - }, - - async readAsString(path: string) { - return await FileSystem.readAsStringAsync('file://' + path, { - encoding: FileSystem.EncodingType.UTF8, - }); - }, -}; -``` - ## Registering your adapter Pass your adapter to `initExecutorch` at the entry point of your app, before any other library API is called: From 541e1e15dc02b07307795bdff648ef0fd0ee5c41 Mon Sep 17 00:00:00 2001 From: chmjkb Date: Wed, 25 Mar 2026 08:27:51 +0100 Subject: [PATCH 6/7] chore: add a note about unsupported feats on Android --- docs/docs/08-resource-fetcher/01-usage.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/docs/08-resource-fetcher/01-usage.md b/docs/docs/08-resource-fetcher/01-usage.md index 77afc3d1db..135b196113 100644 --- a/docs/docs/08-resource-fetcher/01-usage.md +++ b/docs/docs/08-resource-fetcher/01-usage.md @@ -11,7 +11,7 @@ All examples below use `ExpoResourceFetcher`. If you're on bare React Native, re import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher'; ``` -The API is identical between both adapters. +The public API is identical between both adapters. ::: ## fetch @@ -50,6 +50,10 @@ If the resource is an object, it will be saved as a JSON file on disk. Pauses an ongoing download. +:::info +Bare Resource Fetcher doesn't support this feature on Android. +::: + ### Reference ```typescript @@ -79,6 +83,10 @@ await ExpoResourceFetcher.pauseFetching( ## resumeFetching +:::info +Bare Resource Fetcher doesn't support this feature on Android. +::: + Resumes a paused download. ### Reference From 01a52b1bf8cddde8d2c3cb02b56b668206178c19 Mon Sep 17 00:00:00 2001 From: chmjkb Date: Wed, 25 Mar 2026 12:07:23 +0100 Subject: [PATCH 7/7] docs: review changes --- docs/docs/01-fundamentals/01-getting-started.md | 2 +- docs/docs/08-resource-fetcher/02-custom-adapter.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/01-fundamentals/01-getting-started.md b/docs/docs/01-fundamentals/01-getting-started.md index f0a7941c93..1ec3f29499 100644 --- a/docs/docs/01-fundamentals/01-getting-started.md +++ b/docs/docs/01-fundamentals/01-getting-started.md @@ -116,7 +116,7 @@ Because we are using ExecuTorch under the hood, you won't be able to build iOS a Running the app with the library: ```bash -yarn run expo: -d +yarn -d ``` ## Supporting new models in React Native ExecuTorch diff --git a/docs/docs/08-resource-fetcher/02-custom-adapter.md b/docs/docs/08-resource-fetcher/02-custom-adapter.md index b308be282f..36d25a888d 100644 --- a/docs/docs/08-resource-fetcher/02-custom-adapter.md +++ b/docs/docs/08-resource-fetcher/02-custom-adapter.md @@ -2,7 +2,7 @@ title: Custom Adapter --- -If the built-in `BareResourceFetcher` and `ExpoResourceFetcher` don't fit your needs, for example, you want to use a different download library, or fetch from a private server you can implement your own adapter and plug it into React Native ExecuTorch. +If the built-in `BareResourceFetcher` and `ExpoResourceFetcher` don't fit your needs, you can implement your own adapter and plug it into React Native ExecuTorch. This is useful if you want to use a different download library, fetch from a private server, or add custom caching logic. ## The ResourceFetcherAdapter interface