Skip to content

Commit 6816409

Browse files
committed
docs: Change docs to align them with the current state of resource fetcher
1 parent f9e110d commit 6816409

6 files changed

Lines changed: 47 additions & 4 deletions

File tree

.cspell-wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ POTTEDPLANT
105105
TVMONITOR
106106
sublist
107107
TTFT
108+
pogodin
109+
kesha
110+
antonov

docs/docs/01-fundamentals/01-getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Installation is pretty straightforward, just use your favorite package manager.
6262
</TabItem>
6363
</Tabs>
6464

65-
If you're using bare React Native (instead of a managed Expo project), you also need to install Expo Modules because the underlying implementation relies on expo-file-system. Since expo-file-system is an Expo package, bare React Native projects need **Expo Modules** to properly integrate and use it. The link provided (https://docs.expo.dev/bare/installing-expo-modules/) offers guidance on setting up Expo Modules in a bare React Native environment.
65+
Our library offers support for both bare React Native and Expo projects. 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.
6666

6767
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`:
6868

docs/docs/01-fundamentals/02-loading-models.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,46 @@ title: Loading Models
44

55
There are three different methods available for loading model files, depending on their size and location.
66

7+
## Prerequisites
8+
9+
In our library, you can use two different resource fetching mechanisms. One is implemented using Expo module, the other one uses external file-system library. We encourage you to use implementation utilizing Expo if possible. But sometimes you cannot add Expo module to your project, then you should use bare React Native implementation.
10+
11+
To use initialize Expo adapter, please add these libraries:
12+
13+
```bash
14+
yarn add @rn-executorch/expo-adapter
15+
yarn add expo-file-system expo-asset
16+
```
17+
18+
and then add the following code in your React Native app:
19+
20+
```typescript
21+
import { initExecutorch } from 'react-native-executorch';
22+
import { ExpoResourceFetcher } from '@react-native-executorch/expo-resource-fetcher';
23+
24+
initExecutorch({
25+
resourceFetcher: ExpoResourceFetcher,
26+
});
27+
```
28+
29+
If you cannot use Expo in your project, proceed with the following steps:
30+
31+
```bash
32+
yarn add @rn-executorch/bare-adapter
33+
yarn add @dr.pogodin/react-native-fs @kesha-antonov/react-native-background-downloader
34+
```
35+
36+
and
37+
38+
```typescript
39+
import { initExecutorch } from 'react-native-executorch';
40+
import { BareResourceFetcher } from '@rn-executorch/bare-adapter';
41+
42+
initExecutorch({
43+
resourceFetcher: BareResourceFetcher,
44+
});
45+
```
46+
747
**1. Load from React Native assets folder (For Files < 512MB)**
848

949
```typescript

docs/docs/01-fundamentals/03-frequently-asked-questions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If your model doesn't support it, you can still work around it using context. Fo
3131

3232
### Can I use React Native ExecuTorch in bare React Native apps?
3333

34-
To use the library, you need to install Expo Modules first. For a setup guide, refer to [this tutorial](https://docs.expo.dev/bare/installing-expo-modules/). This is because we use Expo File System under the hood to download and manage the model binaries.
34+
Yes, staring from version `0.8.x` you can use React Native ExecuTorch in bare React Native apps. You just need to use bare React Native resource fetcher instead of Expo one, see: [Loading models section](./02-loading-models.md) for more details.
3535

3636
### Do you support the old architecture?
3737

packages/bare-resource-fetcher/src/ResourceFetcherUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export namespace ResourceFetcherUtils {
8888
await RNFS.mkdir(RNEDirectory);
8989
} catch (error) {
9090
throw new RnExecutorchError(
91-
RnExecutorchErrorCode.AccessFailed,
91+
RnExecutorchErrorCode.FileWriteFailed,
9292
`Failed to create directory at ${RNEDirectory}`,
9393
error
9494
);

packages/expo-resource-fetcher/src/ResourceFetcherUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export namespace ResourceFetcherUtils {
101101
await makeDirectoryAsync(RNEDirectory, { intermediates: true });
102102
} catch (error) {
103103
throw new RnExecutorchError(
104-
RnExecutorchErrorCode.AccessFailed,
104+
RnExecutorchErrorCode.FileWriteFailed,
105105
`Failed to create directory at ${RNEDirectory}`,
106106
error
107107
);

0 commit comments

Comments
 (0)