diff --git a/packages/expo-file-system/build/FileSystem.d.ts b/packages/expo-file-system/build/FileSystem.d.ts index 78cebda2c134a..5df6c1c0974ee 100644 --- a/packages/expo-file-system/build/FileSystem.d.ts +++ b/packages/expo-file-system/build/FileSystem.d.ts @@ -1,6 +1,6 @@ import { EventEmitter, Subscription } from '@unimodules/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, }; +import { DownloadOptions, DownloadResult, DownloadProgressCallback, DownloadProgressData, DownloadPauseState, FileInfo, EncodingType, ReadingOptions, WritingOptions, ProgressEvent, FileSystemContentUri } from './FileSystem.types'; +export { DownloadOptions, DownloadResult, DownloadProgressCallback, DownloadProgressData, DownloadPauseState, FileInfo, EncodingType, ReadingOptions, WritingOptions, ProgressEvent, FileSystemContentUri, }; export declare const documentDirectory: string | null; export declare const cacheDirectory: string | null; export declare const bundledAssets: string | null, bundleDirectory: string | null; @@ -9,7 +9,7 @@ export declare function getInfoAsync(fileUri: string, options?: { size?: boolean; }): Promise; export declare function readAsStringAsync(fileUri: string, options?: ReadingOptions): Promise; -export declare function getContentUriAsync(fileUri: string): Promise; +export declare function getContentUriAsync(fileUri: string): Promise; export declare function writeAsStringAsync(fileUri: string, contents: string, options?: WritingOptions): Promise; export declare function deleteAsync(fileUri: string, options?: { idempotent?: boolean; diff --git a/packages/expo-file-system/build/FileSystem.js b/packages/expo-file-system/build/FileSystem.js index ac7736385137d..c75c4e14ab4fa 100644 --- a/packages/expo-file-system/build/FileSystem.js +++ b/packages/expo-file-system/build/FileSystem.js @@ -39,7 +39,7 @@ export async function getContentUriAsync(fileUri) { } else { return new Promise(function (resolve, reject) { - resolve(fileUri); + resolve({ uri: fileUri }); }); } } diff --git a/packages/expo-file-system/build/FileSystem.js.map b/packages/expo-file-system/build/FileSystem.js.map index 25d3c4e4d1033..2dc513780292e 100644 --- a/packages/expo-file-system/build/FileSystem.js.map +++ b/packages/expo-file-system/build/FileSystem.js.map @@ -1 +1 @@ -{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../src/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAOL,YAAY,GAIb,MAAM,oBAAoB,CAAC;AAE5B,IAAI,CAAC,kBAAkB,EAAE;IACvB,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;CACH;AACD,qCAAqC;AACrC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,sBAAsB;AAE5E,OAAO,EAOL,YAAY,GAIb,CAAC;AAEF,SAAS,oBAAoB,CAAC,CAAgB;IAC5C,IAAI,CAAC,IAAI,IAAI,EAAE;QACb,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;KACpC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,kBAAkB,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EACf,UAA6C,EAAE;IAE/C,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE;QACpC,MA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sourcesContent":["import { EventEmitter, Subscription, UnavailabilityError } from '@unimodules/core';\nimport { Platform } from 'react-native';\nimport uuidv4 from 'uuid/v4';\n\nimport ExponentFileSystem from './ExponentFileSystem';\nimport {\n DownloadOptions,\n DownloadResult,\n DownloadProgressCallback,\n DownloadProgressData,\n DownloadPauseState,\n FileInfo,\n EncodingType,\n ReadingOptions,\n WritingOptions,\n ProgressEvent,\n} from './FileSystem.types';\n\nif (!ExponentFileSystem) {\n console.warn(\n \"No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?\"\n );\n}\n// Prevent webpack from pruning this.\nconst _unused = new EventEmitter(ExponentFileSystem); // eslint-disable-line\n\nexport {\n DownloadOptions,\n DownloadResult,\n DownloadProgressCallback,\n DownloadProgressData,\n DownloadPauseState,\n FileInfo,\n EncodingType,\n ReadingOptions,\n WritingOptions,\n ProgressEvent,\n};\n\nfunction normalizeEndingSlash(p: string | null): string | null {\n if (p != null) {\n return p.replace(/\\/*$/, '') + '/';\n }\n return null;\n}\n\nexport const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory);\nexport const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory);\n\nexport const { bundledAssets, bundleDirectory } = ExponentFileSystem;\n\nexport async function getInfoAsync(\n fileUri: string,\n options: { md5?: boolean; size?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.getInfoAsync) {\n throw new UnavailabilityError('expo-file-system', 'getInfoAsync');\n }\n return await ExponentFileSystem.getInfoAsync(fileUri, options);\n}\n\nexport async function readAsStringAsync(\n fileUri: string,\n options?: ReadingOptions\n): Promise {\n if (!ExponentFileSystem.readAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'readAsStringAsync');\n }\n return await ExponentFileSystem.readAsStringAsync(fileUri, options || {});\n}\n\nexport async function getContentUriAsync(fileUri: string): Promise {\n if (Platform.OS === 'android') {\n if (!ExponentFileSystem.getContentUriAsync) {\n throw new UnavailabilityError('expo-file-system', 'getContentUriAsync');\n }\n return await ExponentFileSystem.getContentUriAsync(fileUri);\n } else {\n return new Promise(function(resolve, reject) {\n resolve(fileUri);\n });\n }\n}\n\nexport async function writeAsStringAsync(\n fileUri: string,\n contents: string,\n options: WritingOptions = {}\n): Promise {\n if (!ExponentFileSystem.writeAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync');\n }\n return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options);\n}\n\nexport async function deleteAsync(\n fileUri: string,\n options: { idempotent?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.deleteAsync) {\n throw new UnavailabilityError('expo-file-system', 'deleteAsync');\n }\n return await ExponentFileSystem.deleteAsync(fileUri, options);\n}\n\nexport async function deleteLegacyDocumentDirectoryAndroid(): Promise {\n if (Platform.OS !== 'android' || documentDirectory == null) {\n return;\n }\n const legacyDocumentDirectory = `${documentDirectory}ExperienceData/`;\n return await deleteAsync(legacyDocumentDirectory, { idempotent: true });\n}\n\nexport async function moveAsync(options: { from: string; to: string }): Promise {\n if (!ExponentFileSystem.moveAsync) {\n throw new UnavailabilityError('expo-file-system', 'moveAsync');\n }\n return await ExponentFileSystem.moveAsync(options);\n}\n\nexport async function copyAsync(options: { from: string; to: string }): Promise {\n if (!ExponentFileSystem.copyAsync) {\n throw new UnavailabilityError('expo-file-system', 'copyAsync');\n }\n return await ExponentFileSystem.copyAsync(options);\n}\n\nexport async function makeDirectoryAsync(\n fileUri: string,\n options: { intermediates?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.makeDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync');\n }\n return await ExponentFileSystem.makeDirectoryAsync(fileUri, options);\n}\n\nexport async function readDirectoryAsync(fileUri: string): Promise {\n if (!ExponentFileSystem.readDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync');\n }\n return await ExponentFileSystem.readDirectoryAsync(fileUri, {});\n}\n\nexport async function getFreeDiskStorageAsync(): Promise {\n if (!ExponentFileSystem.getFreeDiskStorageAsync) {\n throw new UnavailabilityError('expo-file-system', 'getFreeDiskStorageAsync');\n }\n return await ExponentFileSystem.getFreeDiskStorageAsync();\n}\n\nexport async function getTotalDiskCapacityAsync(): Promise {\n if (!ExponentFileSystem.getTotalDiskCapacityAsync) {\n throw new UnavailabilityError('expo-file-system', 'getTotalDiskCapacityAsync');\n }\n return await ExponentFileSystem.getTotalDiskCapacityAsync();\n}\n\nexport async function downloadAsync(\n uri: string,\n fileUri: string,\n options: DownloadOptions = {}\n): Promise {\n if (!ExponentFileSystem.downloadAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadAsync');\n }\n return await ExponentFileSystem.downloadAsync(uri, fileUri, options);\n}\n\nexport function createDownloadResumable(\n uri: string,\n fileUri: string,\n options?: DownloadOptions,\n callback?: DownloadProgressCallback,\n resumeData?: string\n): DownloadResumable {\n return new DownloadResumable(uri, fileUri, options, callback, resumeData);\n}\n\nexport class DownloadResumable {\n _uuid: string;\n _url: string;\n _fileUri: string;\n _options: DownloadOptions;\n _resumeData?: string;\n _callback?: DownloadProgressCallback;\n _subscription?: Subscription | null;\n _emitter: EventEmitter;\n\n constructor(\n url: string,\n fileUri: string,\n options: DownloadOptions = {},\n callback?: DownloadProgressCallback,\n resumeData?: string\n ) {\n this._uuid = uuidv4();\n this._url = url;\n this._fileUri = fileUri;\n this._options = options;\n this._resumeData = resumeData;\n this._callback = callback;\n this._subscription = null;\n this._emitter = new EventEmitter(ExponentFileSystem);\n }\n\n async downloadAsync(): Promise {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n this._addSubscription();\n return await ExponentFileSystem.downloadResumableStartAsync(\n this._url,\n this._fileUri,\n this._uuid,\n this._options,\n this._resumeData\n );\n }\n\n async pauseAsync(): Promise {\n if (!ExponentFileSystem.downloadResumablePauseAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync');\n }\n const pauseResult = await ExponentFileSystem.downloadResumablePauseAsync(this._uuid);\n this._removeSubscription();\n if (pauseResult) {\n this._resumeData = pauseResult.resumeData;\n return this.savable();\n } else {\n throw new Error('Unable to generate a savable pause state');\n }\n }\n\n async resumeAsync(): Promise {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n this._addSubscription();\n return await ExponentFileSystem.downloadResumableStartAsync(\n this._url,\n this._fileUri,\n this._uuid,\n this._options,\n this._resumeData\n );\n }\n\n savable(): DownloadPauseState {\n return {\n url: this._url,\n fileUri: this._fileUri,\n options: this._options,\n resumeData: this._resumeData,\n };\n }\n\n _addSubscription(): void {\n if (this._subscription) {\n return;\n }\n this._subscription = this._emitter.addListener(\n 'Exponent.downloadProgress',\n (event: ProgressEvent) => {\n if (event.uuid === this._uuid) {\n const callback = this._callback;\n if (callback) {\n callback(event.data);\n }\n }\n }\n );\n }\n\n _removeSubscription(): void {\n if (!this._subscription) {\n return;\n }\n this._emitter.removeSubscription(this._subscription);\n this._subscription = null;\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../src/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAOL,YAAY,GAKb,MAAM,oBAAoB,CAAC;AAE5B,IAAI,CAAC,kBAAkB,EAAE;IACvB,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;CACH;AACD,qCAAqC;AACrC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,sBAAsB;AAE5E,OAAO,EAOL,YAAY,GAKb,CAAC;AAEF,SAA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AE;YACtB,OAAO;SACR;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAC5C,2BAA2B,EAC3B,CAAC,KAAoB,EAAE,EAAE;YACvB,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;gBAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;gBAChC,IAAI,QAAQ,EAAE;oBACZ,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;iBACtB;aACF;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,OAAO;SACR;QACD,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { EventEmitter, Subscription, UnavailabilityError } from '@unimodules/core';\nimport { Platform } from 'react-native';\nimport uuidv4 from 'uuid/v4';\n\nimport ExponentFileSystem from './ExponentFileSystem';\nimport {\n DownloadOptions,\n DownloadResult,\n DownloadProgressCallback,\n DownloadProgressData,\n DownloadPauseState,\n FileInfo,\n EncodingType,\n ReadingOptions,\n WritingOptions,\n ProgressEvent,\n FileSystemContentUri,\n} from './FileSystem.types';\n\nif (!ExponentFileSystem) {\n console.warn(\n \"No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?\"\n );\n}\n// Prevent webpack from pruning this.\nconst _unused = new EventEmitter(ExponentFileSystem); // eslint-disable-line\n\nexport {\n DownloadOptions,\n DownloadResult,\n DownloadProgressCallback,\n DownloadProgressData,\n DownloadPauseState,\n FileInfo,\n EncodingType,\n ReadingOptions,\n WritingOptions,\n ProgressEvent,\n FileSystemContentUri,\n};\n\nfunction normalizeEndingSlash(p: string | null): string | null {\n if (p != null) {\n return p.replace(/\\/*$/, '') + '/';\n }\n return null;\n}\n\nexport const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory);\nexport const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory);\n\nexport const { bundledAssets, bundleDirectory } = ExponentFileSystem;\n\nexport async function getInfoAsync(\n fileUri: string,\n options: { md5?: boolean; size?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.getInfoAsync) {\n throw new UnavailabilityError('expo-file-system', 'getInfoAsync');\n }\n return await ExponentFileSystem.getInfoAsync(fileUri, options);\n}\n\nexport async function readAsStringAsync(\n fileUri: string,\n options?: ReadingOptions\n): Promise {\n if (!ExponentFileSystem.readAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'readAsStringAsync');\n }\n return await ExponentFileSystem.readAsStringAsync(fileUri, options || {});\n}\n\nexport async function getContentUriAsync(fileUri: string): Promise {\n if (Platform.OS === 'android') {\n if (!ExponentFileSystem.getContentUriAsync) {\n throw new UnavailabilityError('expo-file-system', 'getContentUriAsync');\n }\n return await ExponentFileSystem.getContentUriAsync(fileUri);\n } else {\n return new Promise(function(resolve, reject) {\n resolve({ uri: fileUri });\n });\n }\n}\n\nexport async function writeAsStringAsync(\n fileUri: string,\n contents: string,\n options: WritingOptions = {}\n): Promise {\n if (!ExponentFileSystem.writeAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync');\n }\n return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options);\n}\n\nexport async function deleteAsync(\n fileUri: string,\n options: { idempotent?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.deleteAsync) {\n throw new UnavailabilityError('expo-file-system', 'deleteAsync');\n }\n return await ExponentFileSystem.deleteAsync(fileUri, options);\n}\n\nexport async function deleteLegacyDocumentDirectoryAndroid(): Promise {\n if (Platform.OS !== 'android' || documentDirectory == null) {\n return;\n }\n const legacyDocumentDirectory = `${documentDirectory}ExperienceData/`;\n return await deleteAsync(legacyDocumentDirectory, { idempotent: true });\n}\n\nexport async function moveAsync(options: { from: string; to: string }): Promise {\n if (!ExponentFileSystem.moveAsync) {\n throw new UnavailabilityError('expo-file-system', 'moveAsync');\n }\n return await ExponentFileSystem.moveAsync(options);\n}\n\nexport async function copyAsync(options: { from: string; to: string }): Promise {\n if (!ExponentFileSystem.copyAsync) {\n throw new UnavailabilityError('expo-file-system', 'copyAsync');\n }\n return await ExponentFileSystem.copyAsync(options);\n}\n\nexport async function makeDirectoryAsync(\n fileUri: string,\n options: { intermediates?: boolean } = {}\n): Promise {\n if (!ExponentFileSystem.makeDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync');\n }\n return await ExponentFileSystem.makeDirectoryAsync(fileUri, options);\n}\n\nexport async function readDirectoryAsync(fileUri: string): Promise {\n if (!ExponentFileSystem.readDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync');\n }\n return await ExponentFileSystem.readDirectoryAsync(fileUri, {});\n}\n\nexport async function getFreeDiskStorageAsync(): Promise {\n if (!ExponentFileSystem.getFreeDiskStorageAsync) {\n throw new UnavailabilityError('expo-file-system', 'getFreeDiskStorageAsync');\n }\n return await ExponentFileSystem.getFreeDiskStorageAsync();\n}\n\nexport async function getTotalDiskCapacityAsync(): Promise {\n if (!ExponentFileSystem.getTotalDiskCapacityAsync) {\n throw new UnavailabilityError('expo-file-system', 'getTotalDiskCapacityAsync');\n }\n return await ExponentFileSystem.getTotalDiskCapacityAsync();\n}\n\nexport async function downloadAsync(\n uri: string,\n fileUri: string,\n options: DownloadOptions = {}\n): Promise {\n if (!ExponentFileSystem.downloadAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadAsync');\n }\n return await ExponentFileSystem.downloadAsync(uri, fileUri, options);\n}\n\nexport function createDownloadResumable(\n uri: string,\n fileUri: string,\n options?: DownloadOptions,\n callback?: DownloadProgressCallback,\n resumeData?: string\n): DownloadResumable {\n return new DownloadResumable(uri, fileUri, options, callback, resumeData);\n}\n\nexport class DownloadResumable {\n _uuid: string;\n _url: string;\n _fileUri: string;\n _options: DownloadOptions;\n _resumeData?: string;\n _callback?: DownloadProgressCallback;\n _subscription?: Subscription | null;\n _emitter: EventEmitter;\n\n constructor(\n url: string,\n fileUri: string,\n options: DownloadOptions = {},\n callback?: DownloadProgressCallback,\n resumeData?: string\n ) {\n this._uuid = uuidv4();\n this._url = url;\n this._fileUri = fileUri;\n this._options = options;\n this._resumeData = resumeData;\n this._callback = callback;\n this._subscription = null;\n this._emitter = new EventEmitter(ExponentFileSystem);\n }\n\n async downloadAsync(): Promise {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n this._addSubscription();\n return await ExponentFileSystem.downloadResumableStartAsync(\n this._url,\n this._fileUri,\n this._uuid,\n this._options,\n this._resumeData\n );\n }\n\n async pauseAsync(): Promise {\n if (!ExponentFileSystem.downloadResumablePauseAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync');\n }\n const pauseResult = await ExponentFileSystem.downloadResumablePauseAsync(this._uuid);\n this._removeSubscription();\n if (pauseResult) {\n this._resumeData = pauseResult.resumeData;\n return this.savable();\n } else {\n throw new Error('Unable to generate a savable pause state');\n }\n }\n\n async resumeAsync(): Promise {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n this._addSubscription();\n return await ExponentFileSystem.downloadResumableStartAsync(\n this._url,\n this._fileUri,\n this._uuid,\n this._options,\n this._resumeData\n );\n }\n\n savable(): DownloadPauseState {\n return {\n url: this._url,\n fileUri: this._fileUri,\n options: this._options,\n resumeData: this._resumeData,\n };\n }\n\n _addSubscription(): void {\n if (this._subscription) {\n return;\n }\n this._subscription = this._emitter.addListener(\n 'Exponent.downloadProgress',\n (event: ProgressEvent) => {\n if (event.uuid === this._uuid) {\n const callback = this._callback;\n if (callback) {\n callback(event.data);\n }\n }\n }\n );\n }\n\n _removeSubscription(): void {\n if (!this._subscription) {\n return;\n }\n this._emitter.removeSubscription(this._subscription);\n this._subscription = null;\n }\n}\n"]} \ No newline at end of file diff --git a/packages/expo-file-system/build/FileSystem.types.d.ts b/packages/expo-file-system/build/FileSystem.types.d.ts index 7b7dda28c182f..cefc17331f513 100644 --- a/packages/expo-file-system/build/FileSystem.types.d.ts +++ b/packages/expo-file-system/build/FileSystem.types.d.ts @@ -58,6 +58,9 @@ export declare type ProgressEvent = { totalBytesExpectedToWrite: number; }; }; +export declare type FileSystemContentUri = { + uri: string; +}; declare type PlatformMethod = (...args: any[]) => Promise; export interface ExponentFileSystemModule { readonly name: 'ExponentFileSystem'; diff --git a/packages/expo-file-system/build/FileSystem.types.js.map b/packages/expo-file-system/build/FileSystem.types.js.map index a0fd492a71cd5..954e033560162 100644 --- a/packages/expo-file-system/build/FileSystem.types.js.map +++ b/packages/expo-file-system/build/FileSystem.types.js.map @@ -1 +1 @@ -{"version":3,"file":"FileSystem.types.js","sourceRoot":"","sources":["../src/FileSystem.types.ts"],"names":[],"mappings":"AA6CA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["export type DownloadOptions = {\n md5?: boolean;\n cache?: boolean;\n headers?: { [name: string]: string };\n};\n\nexport type DownloadResult = {\n uri: string;\n status: number;\n headers: { [name: string]: string };\n md5?: string;\n};\n\nexport type DownloadProgressCallback = (data: DownloadProgressData) => void;\n\nexport type DownloadProgressData = {\n totalBytesWritten: number;\n totalBytesExpectedToWrite: number;\n};\n\nexport type DownloadPauseState = {\n url: string;\n fileUri: string;\n options: DownloadOptions;\n resumeData?: string;\n};\n\nexport type FileInfo =\n | {\n exists: true;\n uri: string;\n size: number;\n isDirectory: boolean;\n modificationTime: number;\n md5?: string;\n }\n | {\n exists: false;\n uri: string;\n size: undefined;\n isDirectory: false;\n modificationTime: undefined;\n md5: undefined;\n };\n\nexport enum EncodingType {\n UTF8 = 'utf8',\n Base64 = 'base64',\n}\n\nexport type ReadingOptions = {\n encoding?: EncodingType | 'utf8' | 'base64';\n position?: number;\n length?: number;\n};\n\nexport type WritingOptions = {\n encoding?: EncodingType | 'utf8' | 'base64';\n};\n\nexport type ProgressEvent = {\n uuid: string;\n data: {\n totalBytesWritten: number;\n totalBytesExpectedToWrite: number;\n };\n};\n\ntype PlatformMethod = (...args: any[]) => Promise;\n\nexport interface ExponentFileSystemModule {\n readonly name: 'ExponentFileSystem';\n readonly documentDirectory: string | null;\n readonly cacheDirectory: string | null;\n readonly bundledAssets: string | null;\n readonly bundleDirectory: string | null;\n readonly getInfoAsync?: PlatformMethod;\n readonly readAsStringAsync?: PlatformMethod;\n readonly writeAsStringAsync?: PlatformMethod;\n readonly deleteAsync?: PlatformMethod;\n readonly moveAsync?: PlatformMethod;\n readonly copyAsync?: PlatformMethod;\n readonly makeDirectoryAsync?: PlatformMethod;\n readonly readDirectoryAsync?: PlatformMethod;\n readonly downloadAsync?: PlatformMethod;\n readonly downloadResumableStartAsync?: PlatformMethod;\n readonly downloadResumablePauseAsync?: PlatformMethod;\n readonly getContentUriAsync?: PlatformMethod;\n readonly getFreeDiskStorageAsync?: PlatformMethod;\n readonly getTotalDiskCapacityAsync?: PlatformMethod;\n startObserving?: () => void;\n stopObserving?: () => void;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n"]} \ No newline at end of file +{"version":3,"file":"FileSystem.types.js","sourceRoot":"","sources":["../src/FileSystem.types.ts"],"names":[],"mappings":"AA6CA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["export type DownloadOptions = {\n md5?: boolean;\n cache?: boolean;\n headers?: { [name: string]: string };\n};\n\nexport type DownloadResult = {\n uri: string;\n status: number;\n headers: { [name: string]: string };\n md5?: string;\n};\n\nexport type DownloadProgressCallback = (data: DownloadProgressData) => void;\n\nexport type DownloadProgressData = {\n totalBytesWritten: number;\n totalBytesExpectedToWrite: number;\n};\n\nexport type DownloadPauseState = {\n url: string;\n fileUri: string;\n options: DownloadOptions;\n resumeData?: string;\n};\n\nexport type FileInfo =\n | {\n exists: true;\n uri: string;\n size: number;\n isDirectory: boolean;\n modificationTime: number;\n md5?: string;\n }\n | {\n exists: false;\n uri: string;\n size: undefined;\n isDirectory: false;\n modificationTime: undefined;\n md5: undefined;\n };\n\nexport enum EncodingType {\n UTF8 = 'utf8',\n Base64 = 'base64',\n}\n\nexport type ReadingOptions = {\n encoding?: EncodingType | 'utf8' | 'base64';\n position?: number;\n length?: number;\n};\n\nexport type WritingOptions = {\n encoding?: EncodingType | 'utf8' | 'base64';\n};\n\nexport type ProgressEvent = {\n uuid: string;\n data: {\n totalBytesWritten: number;\n totalBytesExpectedToWrite: number;\n };\n};\n\nexport type FileSystemContentUri = {\n uri: string;\n};\n\ntype PlatformMethod = (...args: any[]) => Promise;\n\nexport interface ExponentFileSystemModule {\n readonly name: 'ExponentFileSystem';\n readonly documentDirectory: string | null;\n readonly cacheDirectory: string | null;\n readonly bundledAssets: string | null;\n readonly bundleDirectory: string | null;\n readonly getInfoAsync?: PlatformMethod;\n readonly readAsStringAsync?: PlatformMethod;\n readonly writeAsStringAsync?: PlatformMethod;\n readonly deleteAsync?: PlatformMethod;\n readonly moveAsync?: PlatformMethod;\n readonly copyAsync?: PlatformMethod;\n readonly makeDirectoryAsync?: PlatformMethod;\n readonly readDirectoryAsync?: PlatformMethod;\n readonly downloadAsync?: PlatformMethod;\n readonly downloadResumableStartAsync?: PlatformMethod;\n readonly downloadResumablePauseAsync?: PlatformMethod;\n readonly getContentUriAsync?: PlatformMethod;\n readonly getFreeDiskStorageAsync?: PlatformMethod;\n readonly getTotalDiskCapacityAsync?: PlatformMethod;\n startObserving?: () => void;\n stopObserving?: () => void;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-file-system/src/FileSystem.ts b/packages/expo-file-system/src/FileSystem.ts index 11d462c04bfbc..06ee975850526 100644 --- a/packages/expo-file-system/src/FileSystem.ts +++ b/packages/expo-file-system/src/FileSystem.ts @@ -14,6 +14,7 @@ import { ReadingOptions, WritingOptions, ProgressEvent, + FileSystemContentUri, } from './FileSystem.types'; if (!ExponentFileSystem) { @@ -35,6 +36,7 @@ export { ReadingOptions, WritingOptions, ProgressEvent, + FileSystemContentUri, }; function normalizeEndingSlash(p: string | null): string | null { @@ -69,7 +71,7 @@ export async function readAsStringAsync( return await ExponentFileSystem.readAsStringAsync(fileUri, options || {}); } -export async function getContentUriAsync(fileUri: string): Promise { +export async function getContentUriAsync(fileUri: string): Promise { if (Platform.OS === 'android') { if (!ExponentFileSystem.getContentUriAsync) { throw new UnavailabilityError('expo-file-system', 'getContentUriAsync'); @@ -77,7 +79,7 @@ export async function getContentUriAsync(fileUri: string): Promise { return await ExponentFileSystem.getContentUriAsync(fileUri); } else { return new Promise(function(resolve, reject) { - resolve(fileUri); + resolve({ uri: fileUri }); }); } } diff --git a/packages/expo-file-system/src/FileSystem.types.ts b/packages/expo-file-system/src/FileSystem.types.ts index e520ea7ef3a9c..f5aa9fc1fb0d8 100644 --- a/packages/expo-file-system/src/FileSystem.types.ts +++ b/packages/expo-file-system/src/FileSystem.types.ts @@ -66,6 +66,10 @@ export type ProgressEvent = { }; }; +export type FileSystemContentUri = { + uri: string; +}; + type PlatformMethod = (...args: any[]) => Promise; export interface ExponentFileSystemModule {