expo-file-system
Advanced tools
Comparing version 18.0.5 to 18.1.0-canary-20241211-61c49bd
@@ -0,1 +1,13 @@ | ||
type CreateOptions = { | ||
/** | ||
* Whether to create intermediate directories if they do not exist. | ||
* @default false | ||
*/ | ||
intermediates?: boolean; | ||
/** | ||
* Whether to overwrite the file or directory if it exists. | ||
* @default false | ||
*/ | ||
overwrite?: boolean; | ||
}; | ||
export declare class Directory { | ||
@@ -36,3 +48,3 @@ /** | ||
*/ | ||
create(): void; | ||
create(options?: CreateOptions): void; | ||
/** | ||
@@ -115,3 +127,3 @@ * Copies a directory. | ||
*/ | ||
create(): void; | ||
create(options?: CreateOptions): void; | ||
/** | ||
@@ -149,2 +161,6 @@ * Copies a file. | ||
md5: string | null; | ||
/** | ||
* A mime type of the file. Null if the file does not exist or it cannot be read. | ||
*/ | ||
type: string | null; | ||
} | ||
@@ -158,2 +174,3 @@ export declare class FileHandle { | ||
} | ||
export {}; | ||
//# sourceMappingURL=ExpoFileSystem.types.d.ts.map |
@@ -15,2 +15,15 @@ import { ReadableStream, WritableStream } from 'web-streams-polyfill'; | ||
} | ||
export declare class FileBlob extends Blob { | ||
file: File; | ||
key: string; | ||
constructor(file: File); | ||
get size(): number; | ||
get name(): string; | ||
get type(): string; | ||
arrayBuffer(): Promise<ArrayBuffer>; | ||
text(): Promise<string>; | ||
bytes(): Promise<Uint8Array>; | ||
stream(): ReadableStream<Uint8Array>; | ||
slice(start?: number, end?: number, contentType?: string): Blob; | ||
} | ||
export declare class File extends ExpoFileSystem.FileSystemFile { | ||
@@ -26,2 +39,3 @@ /** | ||
constructor(...uris: (string | File | Directory)[]); | ||
blob(): Blob; | ||
get parentDirectory(): Directory; | ||
@@ -28,0 +42,0 @@ /** |
@@ -9,8 +9,5 @@ # Changelog | ||
### 🐛 Bug fixes | ||
- [next] Add blob support and `.blob()` function. ([#33152](https://github.com/expo/expo/pull/33152) by [@aleqsio](https://github.com/aleqsio)) | ||
- [expo-file-system][next] Add options to the create function. ([#32909](https://github.com/expo/expo/pull/32909) by [@aleqsio](https://github.com/aleqsio)) | ||
### 💡 Others | ||
## 18.0.5 — 2024-12-10 | ||
### 🐛 Bug fixes | ||
@@ -20,2 +17,4 @@ | ||
### 💡 Others | ||
## 18.0.4 — 2024-11-19 | ||
@@ -22,0 +21,0 @@ |
{ | ||
"name": "expo-file-system", | ||
"version": "18.0.5", | ||
"version": "18.1.0-canary-20241211-61c49bd", | ||
"description": "Provides access to the local file system on the device.", | ||
@@ -38,7 +38,7 @@ "main": "src/index.ts", | ||
"devDependencies": { | ||
"expo-module-scripts": "^4.0.0", | ||
"jest-expo": "~52.0.0" | ||
"expo-module-scripts": "4.0.3-canary-20241211-61c49bd", | ||
"jest-expo": "53.0.0-canary-20241211-61c49bd" | ||
}, | ||
"peerDependencies": { | ||
"expo": "*", | ||
"expo": "53.0.0-canary-20241211-61c49bd", | ||
"react-native": "*" | ||
@@ -48,4 +48,3 @@ }, | ||
"web-streams-polyfill": "^3.3.2" | ||
}, | ||
"gitHead": "1faceb8d22bebee4571ef3a2f9578bec33dc26b1" | ||
} | ||
} |
@@ -0,1 +1,14 @@ | ||
type CreateOptions = { | ||
/** | ||
* Whether to create intermediate directories if they do not exist. | ||
* @default false | ||
*/ | ||
intermediates?: boolean; | ||
/** | ||
* Whether to overwrite the file or directory if it exists. | ||
* @default false | ||
*/ | ||
overwrite?: boolean; | ||
}; | ||
export declare class Directory { | ||
@@ -41,3 +54,3 @@ /** | ||
*/ | ||
create(): void; | ||
create(options?: CreateOptions): void; | ||
@@ -131,3 +144,3 @@ /** | ||
*/ | ||
create(): void; | ||
create(options?: CreateOptions): void; | ||
@@ -171,2 +184,7 @@ /** | ||
md5: string | null; | ||
/** | ||
* A mime type of the file. Null if the file does not exist or it cannot be read. | ||
*/ | ||
type: string | null; | ||
} | ||
@@ -173,0 +191,0 @@ |
@@ -31,2 +31,44 @@ import { ReadableStream, WritableStream } from 'web-streams-polyfill'; | ||
export class FileBlob extends Blob { | ||
file: File; | ||
key: string = 'FileBlob'; | ||
constructor(file: File) { | ||
super(); | ||
this.file = file; | ||
} | ||
get size(): number { | ||
return this.file.size ?? 0; | ||
} | ||
get name(): string { | ||
return this.file.name; | ||
} | ||
get type(): string { | ||
return this.file.type ?? ''; | ||
} | ||
async arrayBuffer(): Promise<ArrayBuffer> { | ||
return this.file.bytes().buffer; | ||
} | ||
async text(): Promise<string> { | ||
return this.file.text(); | ||
} | ||
async bytes(): Promise<Uint8Array> { | ||
return this.file.bytes(); | ||
} | ||
stream(): ReadableStream<Uint8Array> { | ||
return this.file.readableStream(); | ||
} | ||
slice(start?: number, end?: number, contentType?: string): Blob { | ||
return new Blob([this.file.bytes().slice(start, end)], { type: contentType }); | ||
} | ||
} | ||
export class File extends ExpoFileSystem.FileSystemFile { | ||
@@ -47,2 +89,9 @@ /** | ||
/* | ||
* Returns the file as a Blob. The blob can be used in `@expo/fetch` to send files over network and for other uses. | ||
*/ | ||
blob(): Blob { | ||
return new FileBlob(this); | ||
} | ||
/* | ||
* Directory containing the file. | ||
@@ -49,0 +98,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
313096
119
3243
1