expo-file-system
Advanced tools
Comparing version 2.1.0-alpha.2 to 3.0.0
@@ -1,6 +0,3 @@ | ||
declare const _default: { | ||
[propertyName: string]: any; | ||
addListener: (eventName: string) => void; | ||
removeListeners: (count: number) => void; | ||
}; | ||
import { ExponentFileSystemModule } from './FileSystem.types'; | ||
declare const _default: ExponentFileSystemModule; | ||
export default _default; |
import { NativeModulesProxy } from 'expo-core'; | ||
export default NativeModulesProxy.ExponentFileSystem; | ||
import ExponentFileSystemShim from './ExponentFileSystemShim'; | ||
let platformModule; | ||
if (NativeModulesProxy.ExponentFileSystem) { | ||
platformModule = NativeModulesProxy.ExponentFileSystem; | ||
} | ||
else { | ||
platformModule = ExponentFileSystemShim; | ||
} | ||
export default platformModule; | ||
//# sourceMappingURL=ExponentFileSystem.js.map |
@@ -1,8 +0,2 @@ | ||
declare const _default: { | ||
readonly name: string; | ||
readonly documentDirectory: string | null; | ||
readonly cacheDirectory: string | null; | ||
readonly bundledAssets: string | null; | ||
readonly bundleDirectory: string | null; | ||
}; | ||
export default _default; | ||
import ExponentFileSystemShim from './ExponentFileSystemShim'; | ||
export default ExponentFileSystemShim; |
@@ -1,18 +0,3 @@ | ||
export default { | ||
get name() { | ||
return 'ExponentFileSystem'; | ||
}, | ||
get documentDirectory() { | ||
return null; | ||
}, | ||
get cacheDirectory() { | ||
return null; | ||
}, | ||
get bundledAssets() { | ||
return null; | ||
}, | ||
get bundleDirectory() { | ||
return null; | ||
}, | ||
}; | ||
import ExponentFileSystemShim from './ExponentFileSystemShim'; | ||
export default ExponentFileSystemShim; | ||
//# sourceMappingURL=ExponentFileSystem.web.js.map |
import { EventEmitter, Subscription } from 'expo-core'; | ||
import { DownloadOptions, DownloadResult, DownloadProgressCallback, DownloadProgressData, DownloadPauseState, FileInfo, EncodingType, ReadingOptions, WritingOptions, ProgressEvent } from './FileSystem.types'; | ||
export { DownloadOptions, DownloadResult, DownloadProgressCallback, DownloadProgressData, DownloadPauseState, FileInfo, EncodingType, ReadingOptions, WritingOptions, ProgressEvent, }; | ||
export declare const documentDirectory: any, cacheDirectory: any, bundledAssets: any, bundleDirectory: any; | ||
export declare const documentDirectory: string | null; | ||
export declare const cacheDirectory: string | null; | ||
export declare const bundledAssets: string | null, bundleDirectory: string | null; | ||
export declare function getInfoAsync(fileUri: string, options?: { | ||
@@ -6,0 +8,0 @@ md5?: boolean; |
import { UnavailabilityError } from 'expo-errors'; | ||
import { EventEmitter } from 'expo-core'; | ||
import UUID from 'uuid-js'; | ||
import FS from './ExponentFileSystem'; | ||
import ExponentFileSystem from './ExponentFileSystem'; | ||
import { EncodingType, } from './FileSystem.types'; | ||
if (!FS) { | ||
if (!ExponentFileSystem) { | ||
console.warn("No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?"); | ||
@@ -16,58 +16,58 @@ } | ||
} | ||
FS.documentDirectory = normalizeEndingSlash(FS.documentDirectory); | ||
FS.cacheDirectory = normalizeEndingSlash(FS.cacheDirectory); | ||
export const { documentDirectory, cacheDirectory, bundledAssets, bundleDirectory } = FS; | ||
export const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory); | ||
export const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory); | ||
export const { bundledAssets, bundleDirectory } = ExponentFileSystem; | ||
export async function getInfoAsync(fileUri, options = {}) { | ||
if (!FS.getInfoAsync) { | ||
if (!ExponentFileSystem.getInfoAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'getInfoAsync'); | ||
} | ||
return await FS.getInfoAsync(fileUri, options); | ||
return await ExponentFileSystem.getInfoAsync(fileUri, options); | ||
} | ||
export async function readAsStringAsync(fileUri, options) { | ||
if (!FS.readAsStringAsync) { | ||
if (!ExponentFileSystem.readAsStringAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'readAsStringAsync'); | ||
} | ||
return await FS.readAsStringAsync(fileUri, options || {}); | ||
return await ExponentFileSystem.readAsStringAsync(fileUri, options || {}); | ||
} | ||
export async function writeAsStringAsync(fileUri, contents, options = {}) { | ||
if (!FS.writeAsStringAsync) { | ||
if (!ExponentFileSystem.writeAsStringAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync'); | ||
} | ||
return await FS.writeAsStringAsync(fileUri, contents, options); | ||
return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options); | ||
} | ||
export async function deleteAsync(fileUri, options = {}) { | ||
if (!FS.deleteAsync) { | ||
if (!ExponentFileSystem.deleteAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'deleteAsync'); | ||
} | ||
return await FS.deleteAsync(fileUri, options); | ||
return await ExponentFileSystem.deleteAsync(fileUri, options); | ||
} | ||
export async function moveAsync(options) { | ||
if (!FS.moveAsync) { | ||
if (!ExponentFileSystem.moveAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'moveAsync'); | ||
} | ||
return await FS.moveAsync(options); | ||
return await ExponentFileSystem.moveAsync(options); | ||
} | ||
export async function copyAsync(options) { | ||
if (!FS.copyAsync) { | ||
if (!ExponentFileSystem.copyAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'copyAsync'); | ||
} | ||
return await FS.copyAsync(options); | ||
return await ExponentFileSystem.copyAsync(options); | ||
} | ||
export async function makeDirectoryAsync(fileUri, options = {}) { | ||
if (!FS.makeDirectoryAsync) { | ||
if (!ExponentFileSystem.makeDirectoryAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync'); | ||
} | ||
return await FS.makeDirectoryAsync(fileUri, options); | ||
return await ExponentFileSystem.makeDirectoryAsync(fileUri, options); | ||
} | ||
export async function readDirectoryAsync(fileUri) { | ||
if (!FS.readDirectoryAsync) { | ||
if (!ExponentFileSystem.readDirectoryAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync'); | ||
} | ||
return await FS.readDirectoryAsync(fileUri, {}); | ||
return await ExponentFileSystem.readDirectoryAsync(fileUri, {}); | ||
} | ||
export async function downloadAsync(uri, fileUri, options = {}) { | ||
if (!FS.downloadAsync) { | ||
if (!ExponentFileSystem.downloadAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadAsync'); | ||
} | ||
return await FS.downloadAsync(uri, fileUri, options); | ||
return await ExponentFileSystem.downloadAsync(uri, fileUri, options); | ||
} | ||
@@ -86,16 +86,16 @@ export function createDownloadResumable(uri, fileUri, options, callback, resumeData) { | ||
this._subscription = null; | ||
this._emitter = new EventEmitter(FS); | ||
this._emitter = new EventEmitter(ExponentFileSystem); | ||
} | ||
async downloadAsync() { | ||
if (!FS.downloadResumableStartAsync) { | ||
if (!ExponentFileSystem.downloadResumableStartAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync'); | ||
} | ||
this._addSubscription(); | ||
return await FS.downloadResumableStartAsync(this._url, this._fileUri, this._uuid, this._options, this._resumeData); | ||
return await ExponentFileSystem.downloadResumableStartAsync(this._url, this._fileUri, this._uuid, this._options, this._resumeData); | ||
} | ||
async pauseAsync() { | ||
if (!FS.downloadResumablePauseAsync) { | ||
if (!ExponentFileSystem.downloadResumablePauseAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync'); | ||
} | ||
const pauseResult = await FS.downloadResumablePauseAsync(this._uuid); | ||
const pauseResult = await ExponentFileSystem.downloadResumablePauseAsync(this._uuid); | ||
this._removeSubscription(); | ||
@@ -111,7 +111,7 @@ if (pauseResult) { | ||
async resumeAsync() { | ||
if (!FS.downloadResumableStartAsync) { | ||
if (!ExponentFileSystem.downloadResumableStartAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync'); | ||
} | ||
this._addSubscription(); | ||
return await FS.downloadResumableStartAsync(this._url, this._fileUri, this._uuid, this._options, this._resumeData); | ||
return await ExponentFileSystem.downloadResumableStartAsync(this._url, this._fileUri, this._uuid, this._options, this._resumeData); | ||
} | ||
@@ -118,0 +118,0 @@ savable() { |
@@ -61,1 +61,25 @@ export declare type DownloadOptions = { | ||
}; | ||
declare type PlatformMethod = (...args: any[]) => Promise<any>; | ||
export interface ExponentFileSystemModule { | ||
readonly name: 'ExponentFileSystem'; | ||
readonly documentDirectory: string | null; | ||
readonly cacheDirectory: string | null; | ||
readonly bundledAssets: string | null; | ||
readonly bundleDirectory: string | null; | ||
readonly getInfoAsync?: PlatformMethod; | ||
readonly readAsStringAsync?: PlatformMethod; | ||
readonly writeAsStringAsync?: PlatformMethod; | ||
readonly deleteAsync?: PlatformMethod; | ||
readonly moveAsync?: PlatformMethod; | ||
readonly copyAsync?: PlatformMethod; | ||
readonly makeDirectoryAsync?: PlatformMethod; | ||
readonly readDirectoryAsync?: PlatformMethod; | ||
readonly downloadAsync?: PlatformMethod; | ||
readonly downloadResumableStartAsync?: PlatformMethod; | ||
readonly downloadResumablePauseAsync?: PlatformMethod; | ||
startObserving?: () => void; | ||
stopObserving?: () => void; | ||
addListener: (eventName: string) => void; | ||
removeListeners: (count: number) => void; | ||
} | ||
export {}; |
{ | ||
"name": "expo-file-system", | ||
"version": "2.1.0-alpha.2", | ||
"description": "Expo File System standalone universal module", | ||
"version": "3.0.0", | ||
"description": "Provides access to the local file system on the device.", | ||
"main": "build/index.js", | ||
@@ -30,3 +30,3 @@ "types": "build/index.d.ts", | ||
"license": "MIT", | ||
"homepage": "https://github.com/expo/expo/tree/master/packages/expo-file-system", | ||
"homepage": "https://docs.expo.io/versions/latest/sdk/filesystem/", | ||
"jest": { | ||
@@ -42,3 +42,3 @@ "preset": "expo-module-scripts" | ||
}, | ||
"gitHead": "f15abc53c111bd0438cd36dc456c59cfa7c56a58" | ||
"gitHead": "d87c47ba13c7dde7a5d120caf873c98258a42710" | ||
} |
# expo-file-system | ||
`expo-file-system` provides access to a file system stored locally on the device. Each Expo app has a separate file systems and has no access to the file system of other Expo apps. The API takes `file://` URIs pointing to local files on the device to identify files. | ||
Provides access to the local file system on the device. | ||
See [FileSystem docs](https://docs.expo.io/versions/latest/sdk/filesystem) for documentation of this universal module's API. | ||
# API documentation | ||
- [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/filesystem.md) | ||
- [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/filesystem/) | ||
# Installation | ||
This package is pre-installed in [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects. You may skip the rest of the installation guide if this applies to you. | ||
For bare React Native projects, you must ensure that you have [installed and configured the `@unimodules/core` package](https://github.com/unimodules/core) before continuing. | ||
### Add the package to your npm dependencies | ||
``` | ||
npm install expo-file-system | ||
``` | ||
### Configure for iOS | ||
Add the dependency to your `Podfile` and then run `pod install`. | ||
```ruby | ||
pod 'EXFileSystem', path: '../node_modules/expo-file-system/ios' | ||
``` | ||
### Configure for Android | ||
1. Append the following lines to `android/settings.gradle`: | ||
```gradle | ||
include ':expo-file-system' | ||
project(':expo-file-system').projectDir = new File(rootProject.projectDir, '../node_modules/expo-file-system/android') | ||
``` | ||
2. Insert the following lines inside the dependencies block in `android/app/build.gradle`: | ||
```gradle | ||
api project(':expo-file-system') | ||
``` | ||
3. In `MainApplication.java`, import the package and add it to the `ReactModuleRegistryProvider` list: | ||
```java | ||
import expo.modules.expo.modules.filesystem.FileSystemPackage; | ||
``` | ||
```java | ||
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(Arrays.<Package>asList( | ||
// Your other packages will be here | ||
new FileSystemPackage() | ||
), Arrays.<SingletonModule>asList()); | ||
``` | ||
# Contributing | ||
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing). |
import { NativeModulesProxy } from 'expo-core'; | ||
export default NativeModulesProxy.ExponentFileSystem; | ||
import ExponentFileSystemShim from './ExponentFileSystemShim'; | ||
import { ExponentFileSystemModule } from './FileSystem.types'; | ||
let platformModule; | ||
if (NativeModulesProxy.ExponentFileSystem) { | ||
platformModule = NativeModulesProxy.ExponentFileSystem; | ||
} else { | ||
platformModule = ExponentFileSystemShim; | ||
} | ||
export default platformModule as ExponentFileSystemModule; |
@@ -1,17 +0,2 @@ | ||
export default { | ||
get name(): string { | ||
return 'ExponentFileSystem'; | ||
}, | ||
get documentDirectory(): string | null { | ||
return null; | ||
}, | ||
get cacheDirectory(): string | null { | ||
return null; | ||
}, | ||
get bundledAssets(): string | null { | ||
return null; | ||
}, | ||
get bundleDirectory(): string | null { | ||
return null; | ||
}, | ||
}; | ||
import ExponentFileSystemShim from './ExponentFileSystemShim'; | ||
export default ExponentFileSystemShim; |
import { UnavailabilityError } from 'expo-errors'; | ||
import { EventEmitter, Subscription } from 'expo-core'; | ||
import UUID from 'uuid-js'; | ||
import FS from './ExponentFileSystem'; | ||
import ExponentFileSystem from './ExponentFileSystem'; | ||
@@ -19,3 +19,3 @@ import { | ||
if (!FS) { | ||
if (!ExponentFileSystem) { | ||
console.warn( | ||
@@ -46,6 +46,6 @@ "No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?" | ||
FS.documentDirectory = normalizeEndingSlash(FS.documentDirectory); | ||
FS.cacheDirectory = normalizeEndingSlash(FS.cacheDirectory); | ||
export const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory); | ||
export const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory); | ||
export const { documentDirectory, cacheDirectory, bundledAssets, bundleDirectory } = FS; | ||
export const { bundledAssets, bundleDirectory } = ExponentFileSystem; | ||
@@ -56,6 +56,6 @@ export async function getInfoAsync( | ||
): Promise<FileInfo> { | ||
if (!FS.getInfoAsync) { | ||
if (!ExponentFileSystem.getInfoAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'getInfoAsync'); | ||
} | ||
return await FS.getInfoAsync(fileUri, options); | ||
return await ExponentFileSystem.getInfoAsync(fileUri, options); | ||
} | ||
@@ -67,6 +67,6 @@ | ||
): Promise<string> { | ||
if (!FS.readAsStringAsync) { | ||
if (!ExponentFileSystem.readAsStringAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'readAsStringAsync'); | ||
} | ||
return await FS.readAsStringAsync(fileUri, options || {}); | ||
return await ExponentFileSystem.readAsStringAsync(fileUri, options || {}); | ||
} | ||
@@ -79,6 +79,6 @@ | ||
): Promise<void> { | ||
if (!FS.writeAsStringAsync) { | ||
if (!ExponentFileSystem.writeAsStringAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync'); | ||
} | ||
return await FS.writeAsStringAsync(fileUri, contents, options); | ||
return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options); | ||
} | ||
@@ -90,20 +90,20 @@ | ||
): Promise<void> { | ||
if (!FS.deleteAsync) { | ||
if (!ExponentFileSystem.deleteAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'deleteAsync'); | ||
} | ||
return await FS.deleteAsync(fileUri, options); | ||
return await ExponentFileSystem.deleteAsync(fileUri, options); | ||
} | ||
export async function moveAsync(options: { from: string; to: string }): Promise<void> { | ||
if (!FS.moveAsync) { | ||
if (!ExponentFileSystem.moveAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'moveAsync'); | ||
} | ||
return await FS.moveAsync(options); | ||
return await ExponentFileSystem.moveAsync(options); | ||
} | ||
export async function copyAsync(options: { from: string; to: string }): Promise<void> { | ||
if (!FS.copyAsync) { | ||
if (!ExponentFileSystem.copyAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'copyAsync'); | ||
} | ||
return await FS.copyAsync(options); | ||
return await ExponentFileSystem.copyAsync(options); | ||
} | ||
@@ -115,13 +115,13 @@ | ||
): Promise<void> { | ||
if (!FS.makeDirectoryAsync) { | ||
if (!ExponentFileSystem.makeDirectoryAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync'); | ||
} | ||
return await FS.makeDirectoryAsync(fileUri, options); | ||
return await ExponentFileSystem.makeDirectoryAsync(fileUri, options); | ||
} | ||
export async function readDirectoryAsync(fileUri: string): Promise<string[]> { | ||
if (!FS.readDirectoryAsync) { | ||
if (!ExponentFileSystem.readDirectoryAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync'); | ||
} | ||
return await FS.readDirectoryAsync(fileUri, {}); | ||
return await ExponentFileSystem.readDirectoryAsync(fileUri, {}); | ||
} | ||
@@ -134,6 +134,6 @@ | ||
): Promise<DownloadResult> { | ||
if (!FS.downloadAsync) { | ||
if (!ExponentFileSystem.downloadAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadAsync'); | ||
} | ||
return await FS.downloadAsync(uri, fileUri, options); | ||
return await ExponentFileSystem.downloadAsync(uri, fileUri, options); | ||
} | ||
@@ -175,11 +175,11 @@ | ||
this._subscription = null; | ||
this._emitter = new EventEmitter(FS); | ||
this._emitter = new EventEmitter(ExponentFileSystem); | ||
} | ||
async downloadAsync(): Promise<DownloadResult | undefined> { | ||
if (!FS.downloadResumableStartAsync) { | ||
if (!ExponentFileSystem.downloadResumableStartAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync'); | ||
} | ||
this._addSubscription(); | ||
return await FS.downloadResumableStartAsync( | ||
return await ExponentFileSystem.downloadResumableStartAsync( | ||
this._url, | ||
@@ -194,6 +194,6 @@ this._fileUri, | ||
async pauseAsync(): Promise<DownloadPauseState> { | ||
if (!FS.downloadResumablePauseAsync) { | ||
if (!ExponentFileSystem.downloadResumablePauseAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync'); | ||
} | ||
const pauseResult = await FS.downloadResumablePauseAsync(this._uuid); | ||
const pauseResult = await ExponentFileSystem.downloadResumablePauseAsync(this._uuid); | ||
this._removeSubscription(); | ||
@@ -209,7 +209,7 @@ if (pauseResult) { | ||
async resumeAsync(): Promise<DownloadResult | undefined> { | ||
if (!FS.downloadResumableStartAsync) { | ||
if (!ExponentFileSystem.downloadResumableStartAsync) { | ||
throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync'); | ||
} | ||
this._addSubscription(); | ||
return await FS.downloadResumableStartAsync( | ||
return await ExponentFileSystem.downloadResumableStartAsync( | ||
this._url, | ||
@@ -216,0 +216,0 @@ this._fileUri, |
@@ -68,1 +68,27 @@ export type DownloadOptions = { | ||
}; | ||
type PlatformMethod = (...args: any[]) => Promise<any>; | ||
export interface ExponentFileSystemModule { | ||
readonly name: 'ExponentFileSystem'; | ||
readonly documentDirectory: string | null; | ||
readonly cacheDirectory: string | null; | ||
readonly bundledAssets: string | null; | ||
readonly bundleDirectory: string | null; | ||
readonly getInfoAsync?: PlatformMethod; | ||
readonly readAsStringAsync?: PlatformMethod; | ||
readonly writeAsStringAsync?: PlatformMethod; | ||
readonly deleteAsync?: PlatformMethod; | ||
readonly moveAsync?: PlatformMethod; | ||
readonly copyAsync?: PlatformMethod; | ||
readonly makeDirectoryAsync?: PlatformMethod; | ||
readonly readDirectoryAsync?: PlatformMethod; | ||
readonly downloadAsync?: PlatformMethod; | ||
readonly downloadResumableStartAsync?: PlatformMethod; | ||
readonly downloadResumablePauseAsync?: PlatformMethod; | ||
startObserving?: () => void; | ||
stopObserving?: () => void; | ||
addListener: (eventName: string) => void; | ||
removeListeners: (count: number) => void; | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
127367
46
768
0
58