Skip to content

Commit 55e1e8b

Browse files
committed
fix(polyfills): migrate to new expo-file-system API for Expo 54
1 parent 9ca5264 commit 55e1e8b

File tree

5 files changed

+248
-183
lines changed

5 files changed

+248
-183
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
"eslint-plugin-prettier": "^4.0.0",
6969
"eslint-plugin-react": "^7.29.4",
7070
"eslint-plugin-react-hooks": "^4.4.0",
71-
"expo-asset": "^8.6.0",
72-
"expo-file-system": "^15.4.3",
71+
"expo-asset": "^12.0.9",
72+
"expo-file-system": "^19.0.17",
7373
"expo-gl": "^11.4.0",
7474
"husky": "^7.0.4",
7575
"jest": "^29.7.0",
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
export const EncodingType = { UTF8: 'utf8', Base64: 'base64' }
2-
export const cacheDirectory = 'file:///test/'
3-
export const readAsStringAsync = async () => ''
4-
export const writeAsStringAsync = async () => {}
5-
export const copyAsync = async () => {}
1+
export const Paths = { cache: { uri: 'file:///test/' } }
2+
export class File {
3+
async write(data: string) {}
4+
async base64() {
5+
return ''
6+
}
7+
async copy(to: File) {}
8+
}

packages/fiber/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757
"zustand": "^5.0.3"
5858
},
5959
"peerDependencies": {
60-
"expo": ">=43.0",
61-
"expo-asset": ">=8.4",
62-
"expo-file-system": ">=11.0",
63-
"expo-gl": ">=11.0",
60+
"expo": ">=54.0",
61+
"expo-asset": ">=12.0",
62+
"expo-file-system": ">=19.0",
63+
"expo-gl": ">=16.0",
6464
"react": "^19.0.0",
6565
"react-dom": "^19.0.0",
66-
"react-native": ">=0.78",
66+
"react-native": ">=0.81",
6767
"three": ">=0.156"
6868
},
6969
"peerDependenciesMeta": {

packages/fiber/src/native/polyfills.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ async function getAsset(input: string | number): Promise<string> {
4646
const [header, data] = input.split(';base64,')
4747
const [, type] = header.split('/')
4848

49-
const uri = fs.cacheDirectory + uuidv4() + `.${type}`
50-
await fs.writeAsStringAsync(uri, data, { encoding: fs.EncodingType.Base64 })
49+
const uri = fs.Paths.cache.uri + uuidv4() + `.${type}`
50+
await new fs.File(uri).write(data, { encoding: 'base64' })
5151

5252
return uri
5353
}
@@ -59,8 +59,8 @@ async function getAsset(input: string | number): Promise<string> {
5959

6060
// Unpack assets in Android Release Mode
6161
if (!uri.includes(':')) {
62-
const file = `${fs.cacheDirectory}ExponentAsset-${asset.hash}.${asset.type}`
63-
await fs.copyAsync({ from: uri, to: file })
62+
const file = `${fs.Paths.cache.uri}ExponentAsset-${asset.hash}.${asset.type}`
63+
await new fs.File(uri).copy(new fs.File(file))
6464
uri = file
6565
}
6666

@@ -160,7 +160,7 @@ export function polyfills() {
160160

161161
getAsset(url)
162162
.then(async (uri) => {
163-
const base64 = await fs.readAsStringAsync(uri, { encoding: fs.EncodingType.Base64 })
163+
const base64 = await new fs.File(uri).base64()
164164
const data = Buffer.from(base64, 'base64')
165165
onLoad?.(data.buffer)
166166
})

0 commit comments

Comments
 (0)