@amazon-devices/expo-file-system 2.0.1758683737

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +317 -0
  3. package/CMakeLists.txt +52 -0
  4. package/LICENSE +7 -0
  5. package/README.kepler.md +260 -0
  6. package/README.md +46 -0
  7. package/THIRD_PARTY_NOTICES.txt +24 -0
  8. package/android/build.gradle +118 -0
  9. package/android/src/main/AndroidManifest.xml +17 -0
  10. package/android/src/main/java/expo/modules/filesystem/AppDirectoriesModule.kt +26 -0
  11. package/android/src/main/java/expo/modules/filesystem/CountingRequestBody.kt +52 -0
  12. package/android/src/main/java/expo/modules/filesystem/FilePermissionModule.kt +48 -0
  13. package/android/src/main/java/expo/modules/filesystem/FileSystemExceptions.kt +48 -0
  14. package/android/src/main/java/expo/modules/filesystem/FileSystemFileProvider.kt +5 -0
  15. package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +1110 -0
  16. package/android/src/main/java/expo/modules/filesystem/FileSystemPackage.kt +10 -0
  17. package/android/src/main/java/expo/modules/filesystem/FileSystemRecords.kt +92 -0
  18. package/android/src/main/res/xml/file_system_provider_paths.xml +5 -0
  19. package/app.plugin.js +1 -0
  20. package/build/ExponentFileSystem.d.ts +4 -0
  21. package/build/ExponentFileSystem.d.ts.map +1 -0
  22. package/build/ExponentFileSystem.js +5 -0
  23. package/build/ExponentFileSystem.js.map +1 -0
  24. package/build/ExponentFileSystem.kepler.d.ts +4 -0
  25. package/build/ExponentFileSystem.kepler.d.ts.map +1 -0
  26. package/build/ExponentFileSystem.kepler.js +112 -0
  27. package/build/ExponentFileSystem.kepler.js.map +1 -0
  28. package/build/ExponentFileSystem.web.d.ts +3 -0
  29. package/build/ExponentFileSystem.web.d.ts.map +1 -0
  30. package/build/ExponentFileSystem.web.js +3 -0
  31. package/build/ExponentFileSystem.web.js.map +1 -0
  32. package/build/ExponentFileSystemShim.d.ts +4 -0
  33. package/build/ExponentFileSystemShim.d.ts.map +1 -0
  34. package/build/ExponentFileSystemShim.js +21 -0
  35. package/build/ExponentFileSystemShim.js.map +1 -0
  36. package/build/FileSystem.d.ts +361 -0
  37. package/build/FileSystem.d.ts.map +1 -0
  38. package/build/FileSystem.js +616 -0
  39. package/build/FileSystem.js.map +1 -0
  40. package/build/FileSystem.types.d.ts +304 -0
  41. package/build/FileSystem.types.d.ts.map +1 -0
  42. package/build/FileSystem.types.js +47 -0
  43. package/build/FileSystem.types.js.map +1 -0
  44. package/build/index.d.ts +3 -0
  45. package/build/index.d.ts.map +1 -0
  46. package/build/index.js +3 -0
  47. package/build/index.js.map +1 -0
  48. package/build/types.d.ts +35 -0
  49. package/build/types.d.ts.map +1 -0
  50. package/build/types.js +2 -0
  51. package/build/types.js.map +1 -0
  52. package/expo-module.config.json +11 -0
  53. package/ios/EXFilePermissionModule.h +16 -0
  54. package/ios/EXFilePermissionModule.m +68 -0
  55. package/ios/EXFileSystem.h +25 -0
  56. package/ios/EXFileSystem.m +1084 -0
  57. package/ios/EXFileSystemAssetLibraryHandler.h +6 -0
  58. package/ios/EXFileSystemAssetLibraryHandler.m +142 -0
  59. package/ios/EXFileSystemHandler.h +17 -0
  60. package/ios/EXFileSystemLocalFileHandler.h +7 -0
  61. package/ios/EXFileSystemLocalFileHandler.m +79 -0
  62. package/ios/EXSessionTasks/EXSessionCancelableUploadTaskDelegate.h +16 -0
  63. package/ios/EXSessionTasks/EXSessionCancelableUploadTaskDelegate.m +55 -0
  64. package/ios/EXSessionTasks/EXSessionDownloadTaskDelegate.h +13 -0
  65. package/ios/EXSessionTasks/EXSessionDownloadTaskDelegate.m +64 -0
  66. package/ios/EXSessionTasks/EXSessionHandler.h +19 -0
  67. package/ios/EXSessionTasks/EXSessionHandler.m +49 -0
  68. package/ios/EXSessionTasks/EXSessionResumableDownloadTaskDelegate.h +18 -0
  69. package/ios/EXSessionTasks/EXSessionResumableDownloadTaskDelegate.m +66 -0
  70. package/ios/EXSessionTasks/EXSessionTaskDelegate.h +32 -0
  71. package/ios/EXSessionTasks/EXSessionTaskDelegate.m +58 -0
  72. package/ios/EXSessionTasks/EXSessionTaskDispatcher.h +19 -0
  73. package/ios/EXSessionTasks/EXSessionTaskDispatcher.m +96 -0
  74. package/ios/EXSessionTasks/EXSessionUploadTaskDelegate.h +8 -0
  75. package/ios/EXSessionTasks/EXSessionUploadTaskDelegate.m +52 -0
  76. package/ios/EXSessionTasks/EXTaskHandlersManager.h +21 -0
  77. package/ios/EXSessionTasks/EXTaskHandlersManager.m +56 -0
  78. package/ios/Encoding.swift +88 -0
  79. package/ios/ExpoFileSystem.h +1 -0
  80. package/ios/ExpoFileSystem.podspec +32 -0
  81. package/ios/FileSystemBackgroundSessionHandler.swift +25 -0
  82. package/ios/FileSystemExceptions.swift +69 -0
  83. package/ios/FileSystemHelpers.swift +66 -0
  84. package/ios/FileSystemModule.swift +263 -0
  85. package/ios/FileSystemRecords.swift +74 -0
  86. package/ios/NSData+EXFileSystem.h +9 -0
  87. package/ios/NSData+EXFileSystem.m +19 -0
  88. package/ios/NetworkingHelpers.swift +84 -0
  89. package/ios/Tests/EXFileSystemSpec.swift +55 -0
  90. package/jest.config.js +3 -0
  91. package/kepler/ExponentFileSystem.cpp +498 -0
  92. package/kepler/ExponentFileSystem.h +60 -0
  93. package/kepler/KeplerInit.cpp +28 -0
  94. package/kepler/NetworkingRequestHandler.cpp +47 -0
  95. package/kepler/test/FileSystem.cpp +425 -0
  96. package/package.json +1 -0
  97. package/plugin/build/withFileSystem.d.ts +3 -0
  98. package/plugin/build/withFileSystem.js +12 -0
  99. package/plugin/src/withFileSystem.ts +13 -0
  100. package/plugin/tsconfig.json +9 -0
  101. package/plugin/tsconfig.tsbuildinfo +1 -0
  102. package/react-native.config.js +21 -0
  103. package/src/ExponentFileSystem.kepler.ts +167 -0
  104. package/src/ExponentFileSystem.ts +7 -0
  105. package/src/ExponentFileSystem.web.ts +2 -0
  106. package/src/ExponentFileSystemShim.ts +23 -0
  107. package/src/FileSystem.ts +756 -0
  108. package/src/FileSystem.types.ts +339 -0
  109. package/src/index.ts +2 -0
  110. package/src/types.ts +34 -0
  111. package/tsconfig.json +9 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../src/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,mBAAmB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAUL,qBAAqB,EAGrB,oBAAoB,GAQrB,MAAM,oBAAoB,CAAC;AAE5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACxB,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;AACJ,CAAC;AACD,qCAAqC;AACrC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,sBAAsB;AAE5E,SAAS,oBAAoB,CAAC,CAAgB;IAC5C,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAE5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAEtF,eAAe;AACf,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,kBAAkB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,UAAu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IARqB,yCAAkB,qBAQvC,CAAA;IAED;;;;;;OAMG;IACI,KAAK,UAAU,eAAe,CACnC,SAAiB,EACjB,QAAgB,EAChB,QAAgB;QAEhB,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,CAAC;YAC3C,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,wCAAwC,CAAC,CAAC;QAC9F,CAAC;QACD,OAAO,MAAM,kBAAkB,CAAC,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpF,CAAC;IATqB,sCAAe,kBASpC,CAAA;IAED;;OAEG;IACU,yCAAkB,GAAG,sBAAsB,CAAC;IACzD;;OAEG;IACU,wCAAiB,GAAG,qBAAqB,CAAC;IACvD;;OAEG;IACU,kCAAW,GAAG,eAAe,CAAC;IAC3C;;OAEG;IACU,gCAAS,GAAG,aAAa,CAAC;IACvC;;OAEG;IACU,gCAAS,GAAG,aAAa,CAAC;AACzC,CAAC,EApGgB,sBAAsB,KAAtB,sBAAsB,QAoGtC","sourcesContent":["import { EventEmitter, Subscription, UnavailabilityError, uuid } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExponentFileSystem from './ExponentFileSystem';\nimport {\n DownloadOptions,\n DownloadPauseState,\n FileSystemNetworkTaskProgressCallback,\n DownloadProgressData,\n UploadProgressData,\n FileInfo,\n FileSystemAcceptedUploadHttpMethod,\n FileSystemDownloadResult,\n FileSystemRequestDirectoryPermissionsResult,\n FileSystemSessionType,\n FileSystemUploadOptions,\n FileSystemUploadResult,\n FileSystemUploadType,\n ProgressEvent,\n ReadingOptions,\n WritingOptions,\n DeletingOptions,\n InfoOptions,\n RelocatingOptions,\n MakeDirectoryOptions,\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\nfunction normalizeEndingSlash(p: string | null): string | null {\n if (p != null) {\n return p.replace(/\\/*$/, '') + '/';\n }\n return null;\n}\n\n/**\n * `file://` URI pointing to the directory where user documents for this app will be stored.\n * Files stored here will remain until explicitly deleted by the app. Ends with a trailing `/`.\n * Example uses are for files the user saves that they expect to see again.\n */\nexport const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory);\n\n/**\n * `file://` URI pointing to the directory where temporary files used by this app will be stored.\n * Files stored here may be automatically deleted by the system when low on storage.\n * Example uses are for downloaded or generated files that the app just needs for one-time usage.\n */\nexport const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory);\n\n// @docsMissing\nexport const { bundledAssets, bundleDirectory } = ExponentFileSystem;\n\n/**\n * Get metadata information about a file, directory or external content/asset.\n * @param fileUri URI to the file or directory. See [supported URI schemes](#supported-uri-schemes).\n * @param options A map of options represented by [`InfoOptions`](#infooptions) type.\n * @return A Promise that resolves to a `FileInfo` object. If no item exists at this URI,\n * the returned Promise resolves to `FileInfo` object in form of `{ exists: false, isDirectory: false }`.\n */\nexport async function getInfoAsync(fileUri: string, options: InfoOptions = {}): Promise<FileInfo> {\n if (!ExponentFileSystem.getInfoAsync) {\n throw new UnavailabilityError('expo-file-system', 'getInfoAsync');\n }\n return await ExponentFileSystem.getInfoAsync(fileUri, options);\n}\n\n/**\n * Read the entire contents of a file as a string. Binary will be returned in raw format, you will need to append `data:image/png;base64,` to use it as Base64.\n * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.\n * @param options A map of read options represented by [`ReadingOptions`](#readingoptions) type.\n * @return A Promise that resolves to a string containing the entire contents of the file.\n */\nexport async function readAsStringAsync(\n fileUri: string,\n options: ReadingOptions = {}\n): Promise<string> {\n if (!ExponentFileSystem.readAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'readAsStringAsync');\n }\n return await ExponentFileSystem.readAsStringAsync(fileUri, options);\n}\n\n/**\n * Takes a `file://` URI and converts it into content URI (`content://`) so that it can be accessed by other applications outside of Expo.\n * @param fileUri The local URI of the file. If there is no file at this URI, an exception will be thrown.\n * @example\n * ```js\n * FileSystem.getContentUriAsync(uri).then(cUri => {\n * console.log(cUri);\n * IntentLauncher.startActivityAsync('android.intent.action.VIEW', {\n * data: cUri,\n * flags: 1,\n * });\n * });\n * ```\n * @return Returns a Promise that resolves to a `string` containing a `content://` URI pointing to the file.\n * The URI is the same as the `fileUri` input parameter but in a different format.\n * @platform android\n */\nexport async function getContentUriAsync(fileUri: string): Promise<string> {\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 fileUri;\n }\n}\n\n/**\n * Write the entire contents of a file as a string.\n * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.\n * > Note: when you're using SAF URI the file needs to exist. You can't create a new file.\n * @param contents The string to replace the contents of the file with.\n * @param options A map of write options represented by [`WritingOptions`](#writingoptions) type.\n */\nexport async function writeAsStringAsync(\n fileUri: string,\n contents: string,\n options: WritingOptions = {}\n): Promise<void> {\n if (!ExponentFileSystem.writeAsStringAsync) {\n throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync');\n }\n return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options);\n}\n\n/**\n * Delete a file or directory. If the URI points to a directory, the directory and all its contents are recursively deleted.\n * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.\n * @param options A map of write options represented by [`DeletingOptions`](#deletingoptions) type.\n */\nexport async function deleteAsync(fileUri: string, options: DeletingOptions = {}): Promise<void> {\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<void> {\n if (Platform.OS !== 'android' || documentDirectory == null) {\n return;\n }\n const legacyDocumentDirectory = `${documentDirectory}ExperienceData/`;\n return await deleteAsync(legacyDocumentDirectory, { idempotent: true });\n}\n\n/**\n * Move a file or directory to a new location.\n * @param options A map of move options represented by [`RelocatingOptions`](#relocatingoptions) type.\n */\nexport async function moveAsync(options: RelocatingOptions): Promise<void> {\n if (!ExponentFileSystem.moveAsync) {\n throw new UnavailabilityError('expo-file-system', 'moveAsync');\n }\n return await ExponentFileSystem.moveAsync(options);\n}\n\n/**\n * Create a copy of a file or directory. Directories are recursively copied with all of their contents.\n * It can be also used to copy content shared by other apps to local filesystem.\n * @param options A map of move options represented by [`RelocatingOptions`](#relocatingoptions) type.\n */\nexport async function copyAsync(options: RelocatingOptions): Promise<void> {\n if (!ExponentFileSystem.copyAsync) {\n throw new UnavailabilityError('expo-file-system', 'copyAsync');\n }\n return await ExponentFileSystem.copyAsync(options);\n}\n\n/**\n * Create a new empty directory.\n * @param fileUri `file://` URI to the new directory to create.\n * @param options A map of create directory options represented by [`MakeDirectoryOptions`](#makedirectoryoptions) type.\n */\nexport async function makeDirectoryAsync(\n fileUri: string,\n options: MakeDirectoryOptions = {}\n): Promise<void> {\n if (!ExponentFileSystem.makeDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync');\n }\n return await ExponentFileSystem.makeDirectoryAsync(fileUri, options);\n}\n\n/**\n * Enumerate the contents of a directory.\n * @param fileUri `file://` URI to the directory.\n * @return A Promise that resolves to an array of strings, each containing the name of a file or directory contained in the directory at `fileUri`.\n */\nexport async function readDirectoryAsync(fileUri: string): Promise<string[]> {\n if (!ExponentFileSystem.readDirectoryAsync) {\n throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync');\n }\n return await ExponentFileSystem.readDirectoryAsync(fileUri);\n}\n\n/**\n * Gets the available internal disk storage size, in bytes. This returns the free space on the data partition that hosts all of the internal storage for all apps on the device.\n * @return Returns a Promise that resolves to the number of bytes available on the internal disk, or JavaScript's [`MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\n * if the capacity is greater than 2<sup>53</sup> - 1 bytes.\n */\nexport async function getFreeDiskStorageAsync(): Promise<number> {\n if (!ExponentFileSystem.getFreeDiskStorageAsync) {\n throw new UnavailabilityError('expo-file-system', 'getFreeDiskStorageAsync');\n }\n return await ExponentFileSystem.getFreeDiskStorageAsync();\n}\n\n/**\n * Gets total internal disk storage size, in bytes. This is the total capacity of the data partition that hosts all the internal storage for all apps on the device.\n * @return Returns a Promise that resolves to a number that specifies the total internal disk storage capacity in bytes, or JavaScript's [`MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\n * if the capacity is greater than 2<sup>53</sup> - 1 bytes.\n */\nexport async function getTotalDiskCapacityAsync(): Promise<number> {\n if (!ExponentFileSystem.getTotalDiskCapacityAsync) {\n throw new UnavailabilityError('expo-file-system', 'getTotalDiskCapacityAsync');\n }\n return await ExponentFileSystem.getTotalDiskCapacityAsync();\n}\n\n/**\n * Download the contents at a remote URI to a file in the app's file system. The directory for a local file uri must exist prior to calling this function.\n * @param uri The remote URI to download from.\n * @param fileUri The local URI of the file to download to. If there is no file at this URI, a new one is created.\n * If there is a file at this URI, its contents are replaced. The directory for the file must exist.\n * @param options A map of download options represented by [`DownloadOptions`](#downloadoptions) type.\n * @example\n * ```js\n * FileSystem.downloadAsync(\n * 'http://techslides.com/demos/sample-videos/small.mp4',\n * FileSystem.documentDirectory + 'small.mp4'\n * )\n * .then(({ uri }) => {\n * console.log('Finished downloading to ', uri);\n * })\n * .catch(error => {\n * console.error(error);\n * });\n * ```\n * @return Returns a Promise that resolves to a `FileSystemDownloadResult` object.\n */\nexport async function downloadAsync(\n uri: string,\n fileUri: string,\n options: DownloadOptions = {}\n): Promise<FileSystemDownloadResult> {\n if (!ExponentFileSystem.downloadAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadAsync');\n }\n\n return await ExponentFileSystem.downloadAsync(uri, fileUri, {\n sessionType: FileSystemSessionType.BACKGROUND,\n ...options,\n });\n}\n\n/**\n * Upload the contents of the file pointed by `fileUri` to the remote url.\n * @param url The remote URL, where the file will be sent.\n * @param fileUri The local URI of the file to send. The file must exist.\n * @param options A map of download options represented by [`FileSystemUploadOptions`](#filesystemuploadoptions) type.\n * @example\n * **Client**\n *\n * ```js\n * import * as FileSystem from '@amazon-devices/expo-file-system';\n *\n * try {\n * const response = await FileSystem.uploadAsync(`http://192.168.0.1:1234/binary-upload`, fileUri, {\n * fieldName: 'file',\n * httpMethod: 'PATCH',\n * uploadType: FileSystem.FileSystemUploadType.BINARY_CONTENT,\n * });\n * console.log(JSON.stringify(response, null, 4));\n * } catch (error) {\n * console.log(error);\n * }\n * ```\n *\n * **Server**\n *\n * Please refer to the \"[Server: Handling multipart requests](#server-handling-multipart-requests)\" example - there is code for a simple Node.js server.\n * @return Returns a Promise that resolves to `FileSystemUploadResult` object.\n */\nexport async function uploadAsync(\n url: string,\n fileUri: string,\n options: FileSystemUploadOptions = {}\n): Promise<FileSystemUploadResult> {\n if (!ExponentFileSystem.uploadAsync) {\n throw new UnavailabilityError('expo-file-system', 'uploadAsync');\n }\n\n return await ExponentFileSystem.uploadAsync(url, fileUri, {\n sessionType: FileSystemSessionType.BACKGROUND,\n uploadType: FileSystemUploadType.BINARY_CONTENT,\n ...options,\n httpMethod: (options.httpMethod || 'POST').toUpperCase(),\n });\n}\n\n/**\n * Create a `DownloadResumable` object which can start, pause, and resume a download of contents at a remote URI to a file in the app's file system.\n * > Note: You need to call `downloadAsync()`, on a `DownloadResumable` instance to initiate the download.\n * The `DownloadResumable` object has a callback that provides download progress updates.\n * Downloads can be resumed across app restarts by using `AsyncStorage` to store the `DownloadResumable.savable()` object for later retrieval.\n * The `savable` object contains the arguments required to initialize a new `DownloadResumable` object to resume the download after an app restart.\n * The directory for a local file uri must exist prior to calling this function.\n * @param uri The remote URI to download from.\n * @param fileUri The local URI of the file to download to. If there is no file at this URI, a new one is created.\n * If there is a file at this URI, its contents are replaced. The directory for the file must exist.\n * @param options A map of download options represented by [`DownloadOptions`](#downloadoptions) type.\n * @param callback This function is called on each data write to update the download progress.\n * > **Note**: When the app has been moved to the background, this callback won't be fired until it's moved to the foreground.\n * @param resumeData The string which allows the api to resume a paused download. This is set on the `DownloadResumable` object automatically when a download is paused.\n * When initializing a new `DownloadResumable` this should be `null`.\n */\nexport function createDownloadResumable(\n uri: string,\n fileUri: string,\n options?: DownloadOptions,\n callback?: FileSystemNetworkTaskProgressCallback<DownloadProgressData>,\n resumeData?: string\n): DownloadResumable {\n return new DownloadResumable(uri, fileUri, options, callback, resumeData);\n}\n\nexport function createUploadTask(\n url: string,\n fileUri: string,\n options?: FileSystemUploadOptions,\n callback?: FileSystemNetworkTaskProgressCallback<UploadProgressData>\n): UploadTask {\n return new UploadTask(url, fileUri, options, callback);\n}\n\nexport abstract class FileSystemCancellableNetworkTask<\n T extends DownloadProgressData | UploadProgressData,\n> {\n private _uuid = uuid.v4();\n protected taskWasCanceled = false;\n private emitter = new EventEmitter(ExponentFileSystem);\n private subscription?: Subscription | null;\n\n // @docsMissing\n public async cancelAsync(): Promise<void> {\n if (!ExponentFileSystem.networkTaskCancelAsync) {\n throw new UnavailabilityError('expo-file-system', 'networkTaskCancelAsync');\n }\n\n this.removeSubscription();\n this.taskWasCanceled = true;\n return await ExponentFileSystem.networkTaskCancelAsync(this.uuid);\n }\n\n protected isTaskCancelled(): boolean {\n if (this.taskWasCanceled) {\n console.warn('This task was already canceled.');\n return true;\n }\n\n return false;\n }\n\n protected get uuid(): string {\n return this._uuid;\n }\n\n protected abstract getEventName(): string;\n\n protected abstract getCallback(): FileSystemNetworkTaskProgressCallback<T> | undefined;\n\n protected addSubscription() {\n if (this.subscription) {\n return;\n }\n\n this.subscription = this.emitter.addListener(this.getEventName(), (event: ProgressEvent<T>) => {\n if (event.uuid === this.uuid) {\n const callback = this.getCallback();\n if (callback) {\n callback(event.data);\n }\n }\n });\n }\n\n protected removeSubscription() {\n if (!this.subscription) {\n return;\n }\n this.emitter.removeSubscription(this.subscription);\n this.subscription = null;\n }\n}\n\nexport class UploadTask extends FileSystemCancellableNetworkTask<UploadProgressData> {\n private options: FileSystemUploadOptions;\n\n constructor(\n private url: string,\n private fileUri: string,\n options?: FileSystemUploadOptions,\n private callback?: FileSystemNetworkTaskProgressCallback<UploadProgressData>\n ) {\n super();\n\n const httpMethod = (options?.httpMethod?.toUpperCase() ||\n 'POST') as FileSystemAcceptedUploadHttpMethod;\n\n this.options = {\n sessionType: FileSystemSessionType.BACKGROUND,\n uploadType: FileSystemUploadType.BINARY_CONTENT,\n ...options,\n httpMethod,\n };\n }\n\n protected getEventName(): string {\n return 'expo-file-system.uploadProgress';\n }\n protected getCallback(): FileSystemNetworkTaskProgressCallback<UploadProgressData> | undefined {\n return this.callback;\n }\n\n // @docsMissing\n public async uploadAsync(): Promise<FileSystemUploadResult | undefined> {\n if (!ExponentFileSystem.uploadTaskStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'uploadTaskStartAsync');\n }\n\n if (this.isTaskCancelled()) {\n return;\n }\n\n this.addSubscription();\n const result = await ExponentFileSystem.uploadTaskStartAsync(\n this.url,\n this.fileUri,\n this.uuid,\n this.options\n );\n this.removeSubscription();\n\n return result;\n }\n}\n\nexport class DownloadResumable extends FileSystemCancellableNetworkTask<DownloadProgressData> {\n constructor(\n private url: string,\n private _fileUri: string,\n private options: DownloadOptions = {},\n private callback?: FileSystemNetworkTaskProgressCallback<DownloadProgressData>,\n private resumeData?: string\n ) {\n super();\n }\n\n public get fileUri(): string {\n return this._fileUri;\n }\n\n protected getEventName(): string {\n return 'expo-file-system.downloadProgress';\n }\n\n protected getCallback(): FileSystemNetworkTaskProgressCallback<DownloadProgressData> | undefined {\n return this.callback;\n }\n\n /**\n * Download the contents at a remote URI to a file in the app's file system.\n * @return Returns a Promise that resolves to `FileSystemDownloadResult` object, or to `undefined` when task was cancelled.\n */\n async downloadAsync(): Promise<FileSystemDownloadResult | undefined> {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n\n if (this.isTaskCancelled()) {\n return;\n }\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 /**\n * Pause the current download operation. `resumeData` is added to the `DownloadResumable` object after a successful pause operation.\n * Returns an object that can be saved with `AsyncStorage` for future retrieval (the same object that is returned from calling `FileSystem.DownloadResumable.savable()`).\n * @return Returns a Promise that resolves to `DownloadPauseState` object.\n */\n async pauseAsync(): Promise<DownloadPauseState> {\n if (!ExponentFileSystem.downloadResumablePauseAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync');\n }\n\n if (this.isTaskCancelled()) {\n return {\n fileUri: this._fileUri,\n options: this.options,\n url: this.url,\n };\n }\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 /**\n * Resume a paused download operation.\n * @return Returns a Promise that resolves to `FileSystemDownloadResult` object, or to `undefined` when task was cancelled.\n */\n async resumeAsync(): Promise<FileSystemDownloadResult | undefined> {\n if (!ExponentFileSystem.downloadResumableStartAsync) {\n throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');\n }\n\n if (this.isTaskCancelled()) {\n return;\n }\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 /**\n * Method to get the object which can be saved with `AsyncStorage` for future retrieval.\n * @returns Returns object in shape of `DownloadPauseState` type.\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\nconst baseReadAsStringAsync = readAsStringAsync;\nconst baseWriteAsStringAsync = writeAsStringAsync;\nconst baseDeleteAsync = deleteAsync;\nconst baseMoveAsync = moveAsync;\nconst baseCopyAsync = copyAsync;\n\n/**\n * The `StorageAccessFramework` is a namespace inside of the `expo-file-system` module, which encapsulates all functions which can be used with [SAF URIs](#saf-uri).\n * You can read more about SAF in the [Android documentation](https://developer.android.com/guide/topics/providers/document-provider).\n *\n * @example\n * # Basic Usage\n *\n * ```ts\n * import { StorageAccessFramework } from '@amazon-devices/expo-file-system';\n *\n * // Requests permissions for external directory\n * const permissions = await StorageAccessFramework.requestDirectoryPermissionsAsync();\n *\n * if (permissions.granted) {\n * // Gets SAF URI from response\n * const uri = permissions.directoryUri;\n *\n * // Gets all files inside of selected directory\n * const files = await StorageAccessFramework.readDirectoryAsync(uri);\n * alert(`Files inside ${uri}:\\n\\n${JSON.stringify(files)}`);\n * }\n * ```\n *\n * # Migrating an album\n *\n * ```ts\n * import * as MediaLibrary from 'expo-media-library';\n * import * as FileSystem from '@amazon-devices/expo-file-system';\n * const { StorageAccessFramework } = FileSystem;\n *\n * async function migrateAlbum(albumName: string) {\n * // Gets SAF URI to the album\n * const albumUri = StorageAccessFramework.getUriForDirectoryInRoot(albumName);\n *\n * // Requests permissions\n * const permissions = await StorageAccessFramework.requestDirectoryPermissionsAsync(albumUri);\n * if (!permissions.granted) {\n * return;\n * }\n *\n * const permittedUri = permissions.directoryUri;\n * // Checks if users selected the correct folder\n * if (!permittedUri.includes(albumName)) {\n * return;\n * }\n *\n * const mediaLibraryPermissions = await MediaLibrary.requestPermissionsAsync();\n * if (!mediaLibraryPermissions.granted) {\n * return;\n * }\n *\n * // Moves files from external storage to internal storage\n * await StorageAccessFramework.moveAsync({\n * from: permittedUri,\n * to: FileSystem.documentDirectory!,\n * });\n *\n * const outputDir = FileSystem.documentDirectory! + albumName;\n * const migratedFiles = await FileSystem.readDirectoryAsync(outputDir);\n *\n * // Creates assets from local files\n * const [newAlbumCreator, ...assets] = await Promise.all(\n * migratedFiles.map<Promise<MediaLibrary.Asset>>(\n * async fileName => await MediaLibrary.createAssetAsync(outputDir + '/' + fileName)\n * )\n * );\n *\n * // Album was empty\n * if (!newAlbumCreator) {\n * return;\n * }\n *\n * // Creates a new album in the scoped directory\n * const newAlbum = await MediaLibrary.createAlbumAsync(albumName, newAlbumCreator, false);\n * if (assets.length) {\n * await MediaLibrary.addAssetsToAlbumAsync(assets, newAlbum, false);\n * }\n * }\n * ```\n * @platform Android\n */\nexport namespace StorageAccessFramework {\n /**\n * Gets a [SAF URI](#saf-uri) pointing to a folder in the Android root directory. You can use this function to get URI for\n * `StorageAccessFramework.requestDirectoryPermissionsAsync()` when you trying to migrate an album. In that case, the name of the album is the folder name.\n * @param folderName The name of the folder which is located in the Android root directory.\n * @return Returns a [SAF URI](#saf-uri) to a folder.\n */\n export function getUriForDirectoryInRoot(folderName: string) {\n return `content://com.android.externalstorage.documents/tree/primary:${folderName}/document/primary:${folderName}`;\n }\n\n /**\n * Allows users to select a specific directory, granting your app access to all of the files and sub-directories within that directory.\n * @param initialFileUrl The [SAF URI](#saf-uri) of the directory that the file picker should display when it first loads.\n * If URI is incorrect or points to a non-existing folder, it's ignored.\n * @platform android 11+\n * @return Returns a Promise that resolves to `FileSystemRequestDirectoryPermissionsResult` object.\n */\n export async function requestDirectoryPermissionsAsync(\n initialFileUrl: string | null = null\n ): Promise<FileSystemRequestDirectoryPermissionsResult> {\n if (!ExponentFileSystem.requestDirectoryPermissionsAsync) {\n throw new UnavailabilityError(\n 'expo-file-system',\n 'StorageAccessFramework.requestDirectoryPermissionsAsync'\n );\n }\n\n return await ExponentFileSystem.requestDirectoryPermissionsAsync(initialFileUrl);\n }\n\n /**\n * Enumerate the contents of a directory.\n * @param dirUri [SAF](#saf-uri) URI to the directory.\n * @return A Promise that resolves to an array of strings, each containing the full [SAF URI](#saf-uri) of a file or directory contained in the directory at `fileUri`.\n */\n export async function readDirectoryAsync(dirUri: string): Promise<string[]> {\n if (!ExponentFileSystem.readSAFDirectoryAsync) {\n throw new UnavailabilityError(\n 'expo-file-system',\n 'StorageAccessFramework.readDirectoryAsync'\n );\n }\n return await ExponentFileSystem.readSAFDirectoryAsync(dirUri);\n }\n\n /**\n * Creates a new empty directory.\n * @param parentUri The [SAF](#saf-uri) URI to the parent directory.\n * @param dirName The name of new directory.\n * @return A Promise that resolves to a [SAF URI](#saf-uri) to the created directory.\n */\n export async function makeDirectoryAsync(parentUri: string, dirName: string): Promise<string> {\n if (!ExponentFileSystem.makeSAFDirectoryAsync) {\n throw new UnavailabilityError(\n 'expo-file-system',\n 'StorageAccessFramework.makeDirectoryAsync'\n );\n }\n return await ExponentFileSystem.makeSAFDirectoryAsync(parentUri, dirName);\n }\n\n /**\n * Creates a new empty file.\n * @param parentUri The [SAF](#saf-uri) URI to the parent directory.\n * @param fileName The name of new file **without the extension**.\n * @param mimeType The MIME type of new file.\n * @return A Promise that resolves to a [SAF URI](#saf-uri) to the created file.\n */\n export async function createFileAsync(\n parentUri: string,\n fileName: string,\n mimeType: string\n ): Promise<string> {\n if (!ExponentFileSystem.createSAFFileAsync) {\n throw new UnavailabilityError('expo-file-system', 'StorageAccessFramework.createFileAsync');\n }\n return await ExponentFileSystem.createSAFFileAsync(parentUri, fileName, mimeType);\n }\n\n /**\n * Alias for [`writeAsStringAsync`](#filesystemwriteasstringasyncfileuri-contents-options) method.\n */\n export const writeAsStringAsync = baseWriteAsStringAsync;\n /**\n * Alias for [`readAsStringAsync`](#filesystemreadasstringasyncfileuri-options) method.\n */\n export const readAsStringAsync = baseReadAsStringAsync;\n /**\n * Alias for [`deleteAsync`](#filesystemdeleteasyncfileuri-options) method.\n */\n export const deleteAsync = baseDeleteAsync;\n /**\n * Alias for [`moveAsync`](#filesystemmoveasyncoptions) method.\n */\n export const moveAsync = baseMoveAsync;\n /**\n * Alias for [`copyAsync`](#filesystemcopyasyncoptions) method.\n */\n export const copyAsync = baseCopyAsync;\n}\n"]}
@@ -0,0 +1,304 @@
1
+ /**
2
+ * These values can be used to define how sessions work on iOS.
3
+ * @platform ios
4
+ */
5
+ export declare enum FileSystemSessionType {
6
+ /**
7
+ * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background.
8
+ * If the task completes while the application is in background, the Promise will be either resolved immediately or (if the application execution has already been stopped) once the app is moved to foreground again.
9
+ * > Note: The background session doesn't fail if the server or your connection is down. Rather, it continues retrying until the task succeeds or is canceled manually.
10
+ */
11
+ BACKGROUND = 0,
12
+ /**
13
+ * Using this mode means that downloading/uploading session on the native side will be terminated once the application becomes inactive (e.g. when it goes to background).
14
+ * Bringing the application to foreground again would trigger Promise rejection.
15
+ */
16
+ FOREGROUND = 1
17
+ }
18
+ export declare enum FileSystemUploadType {
19
+ /**
20
+ * The file will be sent as a request's body. The request can't contain additional data.
21
+ */
22
+ BINARY_CONTENT = 0,
23
+ /**
24
+ * An [RFC 2387-compliant](https://www.ietf.org/rfc/rfc2387.txt) request body. The provided file will be encoded into HTTP request.
25
+ * This request can contain additional data represented by [`UploadOptionsMultipart`](#uploadoptionsmultipart) type.
26
+ */
27
+ MULTIPART = 1
28
+ }
29
+ export type DownloadOptions = {
30
+ /**
31
+ * If `true`, include the MD5 hash of the file in the returned object. Provided for convenience since it is common to check the integrity of a file immediately after downloading.
32
+ * @default false
33
+ */
34
+ md5?: boolean;
35
+ cache?: boolean;
36
+ /**
37
+ * An object containing all the HTTP header fields and their values for the download network request. The keys and values of the object are the header names and values respectively.
38
+ */
39
+ headers?: Record<string, string>;
40
+ /**
41
+ * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it.
42
+ * @default FileSystemSessionType.BACKGROUND
43
+ * @platform ios
44
+ */
45
+ sessionType?: FileSystemSessionType;
46
+ };
47
+ export type FileSystemHttpResult = {
48
+ /**
49
+ * An object containing all the HTTP response header fields and their values for the download network request.
50
+ * The keys and values of the object are the header names and values respectively.
51
+ */
52
+ headers: Record<string, string>;
53
+ /**
54
+ * The HTTP response status code for the download network request.
55
+ */
56
+ status: number;
57
+ mimeType: string | null;
58
+ };
59
+ export type FileSystemDownloadResult = FileSystemHttpResult & {
60
+ /**
61
+ * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter.
62
+ */
63
+ uri: string;
64
+ /**
65
+ * Present if the `md5` option was truthy. Contains the MD5 hash of the file.
66
+ */
67
+ md5?: string;
68
+ };
69
+ /**
70
+ * @deprecated Use `FileSystemDownloadResult` instead.
71
+ */
72
+ export type DownloadResult = FileSystemDownloadResult;
73
+ export type FileSystemUploadOptions = (UploadOptionsBinary | UploadOptionsMultipart) & {
74
+ /**
75
+ * An object containing all the HTTP header fields and their values for the upload network request.
76
+ * The keys and values of the object are the header names and values respectively.
77
+ */
78
+ headers?: Record<string, string>;
79
+ /**
80
+ * The request method.
81
+ * @default FileSystemAcceptedUploadHttpMethod.POST
82
+ */
83
+ httpMethod?: FileSystemAcceptedUploadHttpMethod;
84
+ /**
85
+ * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it.
86
+ * @default FileSystemSessionType.BACKGROUND
87
+ * @platform ios
88
+ */
89
+ sessionType?: FileSystemSessionType;
90
+ };
91
+ /**
92
+ * Upload options when upload type is set to binary.
93
+ */
94
+ export type UploadOptionsBinary = {
95
+ /**
96
+ * Upload type determines how the file will be sent to the server.
97
+ * Value will be `FileSystemUploadType.BINARY_CONTENT`.
98
+ */
99
+ uploadType?: FileSystemUploadType;
100
+ };
101
+ /**
102
+ * Upload options when upload type is set to multipart.
103
+ */
104
+ export type UploadOptionsMultipart = {
105
+ /**
106
+ * Upload type determines how the file will be sent to the server.
107
+ * Value will be `FileSystemUploadType.MULTIPART`.
108
+ */
109
+ uploadType: FileSystemUploadType;
110
+ /**
111
+ * The name of the field which will hold uploaded file. Defaults to the file name without an extension.
112
+ */
113
+ fieldName?: string;
114
+ /**
115
+ * The MIME type of the provided file. If not provided, the module will try to guess it based on the extension.
116
+ */
117
+ mimeType?: string;
118
+ /**
119
+ * Additional form properties. They will be located in the request body.
120
+ */
121
+ parameters?: Record<string, string>;
122
+ };
123
+ export type FileSystemUploadResult = FileSystemHttpResult & {
124
+ /**
125
+ * The body of the server response.
126
+ */
127
+ body: string;
128
+ };
129
+ export type FileSystemNetworkTaskProgressCallback<T extends DownloadProgressData | UploadProgressData> = (data: T) => void;
130
+ /**
131
+ * @deprecated use `FileSystemNetworkTaskProgressCallback<DownloadProgressData>` instead.
132
+ */
133
+ export type DownloadProgressCallback = FileSystemNetworkTaskProgressCallback<DownloadProgressData>;
134
+ export type DownloadProgressData = {
135
+ /**
136
+ * The total bytes written by the download operation.
137
+ */
138
+ totalBytesWritten: number;
139
+ /**
140
+ * The total bytes expected to be written by the download operation. A value of `-1` means that the server did not return the `Content-Length` header
141
+ * and the total size is unknown. Without this header, you won't be able to track the download progress.
142
+ */
143
+ totalBytesExpectedToWrite: number;
144
+ };
145
+ export type UploadProgressData = {
146
+ /**
147
+ * The total bytes sent by the upload operation.
148
+ */
149
+ totalBytesSent: number;
150
+ /**
151
+ * The total bytes expected to be sent by the upload operation.
152
+ */
153
+ totalBytesExpectedToSend: number;
154
+ };
155
+ export type DownloadPauseState = {
156
+ /**
157
+ * The remote URI to download from.
158
+ */
159
+ url: string;
160
+ /**
161
+ * The local URI of the file to download to. If there is no file at this URI, a new one is created. If there is a file at this URI, its contents are replaced.
162
+ */
163
+ fileUri: string;
164
+ /**
165
+ * Object representing the file download options.
166
+ */
167
+ options: DownloadOptions;
168
+ /**
169
+ * The string which allows the API to resume a paused download.
170
+ */
171
+ resumeData?: string;
172
+ };
173
+ export type FileInfo =
174
+ /**
175
+ * Object returned when file exist.
176
+ */
177
+ {
178
+ /**
179
+ * Signifies that the requested file exist.
180
+ */
181
+ exists: true;
182
+ /**
183
+ * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter.
184
+ */
185
+ uri: string;
186
+ /**
187
+ * The size of the file in bytes. If operating on a source such as an iCloud file, only present if the `size` option was truthy.
188
+ */
189
+ size: number;
190
+ /**
191
+ * Boolean set to `true` if this is a directory and `false` if it is a file.
192
+ */
193
+ isDirectory: boolean;
194
+ /**
195
+ * The last modification time of the file expressed in seconds since epoch.
196
+ */
197
+ modificationTime: number;
198
+ /**
199
+ * Present if the `md5` option was truthy. Contains the MD5 hash of the file.
200
+ */
201
+ md5?: string;
202
+ } |
203
+ /**
204
+ * Object returned when file do not exist.
205
+ */
206
+ {
207
+ exists: false;
208
+ uri: string;
209
+ isDirectory: false;
210
+ };
211
+ /**
212
+ * These values can be used to define how file system data is read / written.
213
+ */
214
+ export declare enum EncodingType {
215
+ /**
216
+ * Standard encoding format.
217
+ */
218
+ UTF8 = "utf8",
219
+ /**
220
+ * Binary, radix-64 representation.
221
+ */
222
+ Base64 = "base64"
223
+ }
224
+ export type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH';
225
+ export type ReadingOptions = {
226
+ /**
227
+ * The encoding format to use when reading the file.
228
+ * @default EncodingType.UTF8
229
+ */
230
+ encoding?: EncodingType | 'utf8' | 'base64';
231
+ /**
232
+ * Optional number of bytes to skip. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `length` is defined.
233
+ * */
234
+ position?: number;
235
+ /**
236
+ * Optional number of bytes to read. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `position` is defined.
237
+ */
238
+ length?: number;
239
+ };
240
+ export type WritingOptions = {
241
+ /**
242
+ * The encoding format to use when writing the file.
243
+ * @default FileSystem.EncodingType.UTF8
244
+ */
245
+ encoding?: EncodingType | 'utf8' | 'base64';
246
+ };
247
+ export type DeletingOptions = {
248
+ /**
249
+ * If `true`, don't throw an error if there is no file or directory at this URI.
250
+ * @default false
251
+ */
252
+ idempotent?: boolean;
253
+ };
254
+ export type InfoOptions = {
255
+ /**
256
+ * Whether to return the MD5 hash of the file.
257
+ * @default false
258
+ */
259
+ md5?: boolean;
260
+ /**
261
+ * Explicitly specify that the file size should be included. For example, skipping this can prevent downloading the file if it's stored in iCloud.
262
+ * The size is always returned for `file://` locations.
263
+ */
264
+ size?: boolean;
265
+ };
266
+ export type RelocatingOptions = {
267
+ /**
268
+ * URI or [SAF](#saf-uri) URI to the asset, file, or directory. See [supported URI schemes](#supported-uri-schemes-1).
269
+ */
270
+ from: string;
271
+ /**
272
+ * `file://` URI to the file or directory which should be its new location.
273
+ */
274
+ to: string;
275
+ };
276
+ export type MakeDirectoryOptions = {
277
+ /**
278
+ * If `true`, don't throw an error if there is no file or directory at this URI.
279
+ * @default false
280
+ */
281
+ intermediates?: boolean;
282
+ };
283
+ export type ProgressEvent<T> = {
284
+ uuid: string;
285
+ data: T;
286
+ };
287
+ export type FileSystemRequestDirectoryPermissionsResult =
288
+ /**
289
+ * If the permissions were not granted.
290
+ */
291
+ {
292
+ granted: false;
293
+ } |
294
+ /**
295
+ * If the permissions were granted.
296
+ */
297
+ {
298
+ granted: true;
299
+ /**
300
+ * The [SAF URI](#saf-uri) to the user's selected directory. Available only if permissions were granted.
301
+ */
302
+ directoryUri: string;
303
+ };
304
+ //# sourceMappingURL=FileSystem.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSystem.types.d.ts","sourceRoot":"","sources":["../src/FileSystem.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B;;;;OAIG;IACH,UAAU,IAAI;IACd;;;OAGG;IACH,UAAU,IAAI;CACf;AAED,oBAAY,oBAAoB;IAC9B;;OAEG;IACH,cAAc,IAAI;IAClB;;;OAGG;IACH,SAAS,IAAI;CACd;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,o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OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC5C;;SAEK;IACL,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAGF,MAAM,MAAM,2CAA2C;AACrD;;GAEG;AACH;IACE,OAAO,EAAE,KAAK,CAAC;CAChB;AACD;;GAEG;AACH;IACE,OAAO,EAAE,IAAI,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * These values can be used to define how sessions work on iOS.
3
+ * @platform ios
4
+ */
5
+ export var FileSystemSessionType;
6
+ (function (FileSystemSessionType) {
7
+ /**
8
+ * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background.
9
+ * If the task completes while the application is in background, the Promise will be either resolved immediately or (if the application execution has already been stopped) once the app is moved to foreground again.
10
+ * > Note: The background session doesn't fail if the server or your connection is down. Rather, it continues retrying until the task succeeds or is canceled manually.
11
+ */
12
+ FileSystemSessionType[FileSystemSessionType["BACKGROUND"] = 0] = "BACKGROUND";
13
+ /**
14
+ * Using this mode means that downloading/uploading session on the native side will be terminated once the application becomes inactive (e.g. when it goes to background).
15
+ * Bringing the application to foreground again would trigger Promise rejection.
16
+ */
17
+ FileSystemSessionType[FileSystemSessionType["FOREGROUND"] = 1] = "FOREGROUND";
18
+ })(FileSystemSessionType || (FileSystemSessionType = {}));
19
+ export var FileSystemUploadType;
20
+ (function (FileSystemUploadType) {
21
+ /**
22
+ * The file will be sent as a request's body. The request can't contain additional data.
23
+ */
24
+ FileSystemUploadType[FileSystemUploadType["BINARY_CONTENT"] = 0] = "BINARY_CONTENT";
25
+ /**
26
+ * An [RFC 2387-compliant](https://www.ietf.org/rfc/rfc2387.txt) request body. The provided file will be encoded into HTTP request.
27
+ * This request can contain additional data represented by [`UploadOptionsMultipart`](#uploadoptionsmultipart) type.
28
+ */
29
+ FileSystemUploadType[FileSystemUploadType["MULTIPART"] = 1] = "MULTIPART";
30
+ })(FileSystemUploadType || (FileSystemUploadType = {}));
31
+ /* eslint-enable */
32
+ /**
33
+ * These values can be used to define how file system data is read / written.
34
+ */
35
+ export var EncodingType;
36
+ (function (EncodingType) {
37
+ /**
38
+ * Standard encoding format.
39
+ */
40
+ EncodingType["UTF8"] = "utf8";
41
+ /**
42
+ * Binary, radix-64 representation.
43
+ */
44
+ EncodingType["Base64"] = "base64";
45
+ })(EncodingType || (EncodingType = {}));
46
+ /* eslint-enable */
47
+ //# sourceMappingURL=FileSystem.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSystem.types.js","sourceRoot":"","sources":["../src/FileSystem.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,qBAYX;AAZD,WAAY,qBAAqB;IAC/B;;;;OAIG;IACH,6EAAc,CAAA;IACd;;;OAGG;IACH,6EAAc,CAAA;AAChB,CAAC,EAZW,qBAAqB,KAArB,qBAAqB,QAYhC;AAED,MAAM,CAAN,IAAY,oBAUX;AAVD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,mFAAkB,CAAA;IAClB;;;OAGG;IACH,yEAAa,CAAA;AACf,CAAC,EAVW,oBAAoB,KAApB,oBAAoB,QAU/B;AA2MD,mBAAmB;AAEnB;;GAEG;AACH,MAAM,CAAN,IAAY,YASX;AATD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IACb;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EATW,YAAY,KAAZ,YAAY,QASvB;AA6FD,mBAAmB","sourcesContent":["/**\n * These values can be used to define how sessions work on iOS.\n * @platform ios\n */\nexport enum FileSystemSessionType {\n /**\n * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background.\n * If the task completes while the application is in background, the Promise will be either resolved immediately or (if the application execution has already been stopped) once the app is moved to foreground again.\n * > Note: The background session doesn't fail if the server or your connection is down. Rather, it continues retrying until the task succeeds or is canceled manually.\n */\n BACKGROUND = 0,\n /**\n * Using this mode means that downloading/uploading session on the native side will be terminated once the application becomes inactive (e.g. when it goes to background).\n * Bringing the application to foreground again would trigger Promise rejection.\n */\n FOREGROUND = 1,\n}\n\nexport enum FileSystemUploadType {\n /**\n * The file will be sent as a request's body. The request can't contain additional data.\n */\n BINARY_CONTENT = 0,\n /**\n * An [RFC 2387-compliant](https://www.ietf.org/rfc/rfc2387.txt) request body. The provided file will be encoded into HTTP request.\n * This request can contain additional data represented by [`UploadOptionsMultipart`](#uploadoptionsmultipart) type.\n */\n MULTIPART = 1,\n}\n\nexport type DownloadOptions = {\n /**\n * If `true`, include the MD5 hash of the file in the returned object. Provided for convenience since it is common to check the integrity of a file immediately after downloading.\n * @default false\n */\n md5?: boolean;\n // @docsMissing\n cache?: boolean;\n /**\n * An object containing all the HTTP header fields and their values for the download network request. The keys and values of the object are the header names and values respectively.\n */\n headers?: Record<string, string>;\n /**\n * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it.\n * @default FileSystemSessionType.BACKGROUND\n * @platform ios\n */\n sessionType?: FileSystemSessionType;\n};\n\nexport type FileSystemHttpResult = {\n /**\n * An object containing all the HTTP response header fields and their values for the download network request.\n * The keys and values of the object are the header names and values respectively.\n */\n headers: Record<string, string>;\n /**\n * The HTTP response status code for the download network request.\n */\n status: number;\n // @docsMissing\n mimeType: string | null;\n};\n\nexport type FileSystemDownloadResult = FileSystemHttpResult & {\n /**\n * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter.\n */\n uri: string;\n /**\n * Present if the `md5` option was truthy. Contains the MD5 hash of the file.\n */\n md5?: string;\n};\n\n/**\n * @deprecated Use `FileSystemDownloadResult` instead.\n */\nexport type DownloadResult = FileSystemDownloadResult;\n\nexport type FileSystemUploadOptions = (UploadOptionsBinary | UploadOptionsMultipart) & {\n /**\n * An object containing all the HTTP header fields and their values for the upload network request.\n * The keys and values of the object are the header names and values respectively.\n */\n headers?: Record<string, string>;\n /**\n * The request method.\n * @default FileSystemAcceptedUploadHttpMethod.POST\n */\n httpMethod?: FileSystemAcceptedUploadHttpMethod;\n /**\n * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it.\n * @default FileSystemSessionType.BACKGROUND\n * @platform ios\n */\n sessionType?: FileSystemSessionType;\n};\n\n/**\n * Upload options when upload type is set to binary.\n */\nexport type UploadOptionsBinary = {\n /**\n * Upload type determines how the file will be sent to the server.\n * Value will be `FileSystemUploadType.BINARY_CONTENT`.\n */\n uploadType?: FileSystemUploadType;\n};\n\n/**\n * Upload options when upload type is set to multipart.\n */\nexport type UploadOptionsMultipart = {\n /**\n * Upload type determines how the file will be sent to the server.\n * Value will be `FileSystemUploadType.MULTIPART`.\n */\n uploadType: FileSystemUploadType;\n /**\n * The name of the field which will hold uploaded file. Defaults to the file name without an extension.\n */\n fieldName?: string;\n /**\n * The MIME type of the provided file. If not provided, the module will try to guess it based on the extension.\n */\n mimeType?: string;\n /**\n * Additional form properties. They will be located in the request body.\n */\n parameters?: Record<string, string>;\n};\n\nexport type FileSystemUploadResult = FileSystemHttpResult & {\n /**\n * The body of the server response.\n */\n body: string;\n};\n\n// @docsMissing\nexport type FileSystemNetworkTaskProgressCallback<\n T extends DownloadProgressData | UploadProgressData,\n> = (data: T) => void;\n\n/**\n * @deprecated use `FileSystemNetworkTaskProgressCallback<DownloadProgressData>` instead.\n */\nexport type DownloadProgressCallback = FileSystemNetworkTaskProgressCallback<DownloadProgressData>;\n\nexport type DownloadProgressData = {\n /**\n * The total bytes written by the download operation.\n */\n totalBytesWritten: number;\n /**\n * The total bytes expected to be written by the download operation. A value of `-1` means that the server did not return the `Content-Length` header\n * and the total size is unknown. Without this header, you won't be able to track the download progress.\n */\n totalBytesExpectedToWrite: number;\n};\n\nexport type UploadProgressData = {\n /**\n * The total bytes sent by the upload operation.\n */\n totalBytesSent: number;\n /**\n * The total bytes expected to be sent by the upload operation.\n */\n totalBytesExpectedToSend: number;\n};\n\nexport type DownloadPauseState = {\n /**\n * The remote URI to download from.\n */\n url: string;\n /**\n * The local URI of the file to download to. If there is no file at this URI, a new one is created. If there is a file at this URI, its contents are replaced.\n */\n fileUri: string;\n /**\n * Object representing the file download options.\n */\n options: DownloadOptions;\n /**\n * The string which allows the API to resume a paused download.\n */\n resumeData?: string;\n};\n\n/* eslint-disable */\nexport type FileInfo =\n /**\n * Object returned when file exist.\n */\n {\n /**\n * Signifies that the requested file exist.\n */\n exists: true;\n /**\n * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter.\n */\n uri: string;\n /**\n * The size of the file in bytes. If operating on a source such as an iCloud file, only present if the `size` option was truthy.\n */\n size: number;\n /**\n * Boolean set to `true` if this is a directory and `false` if it is a file.\n */\n isDirectory: boolean;\n /**\n * The last modification time of the file expressed in seconds since epoch.\n */\n modificationTime: number;\n /**\n * Present if the `md5` option was truthy. Contains the MD5 hash of the file.\n */\n md5?: string;\n } |\n /**\n * Object returned when file do not exist.\n */\n {\n exists: false;\n uri: string;\n isDirectory: false;\n };\n/* eslint-enable */\n\n/**\n * These values can be used to define how file system data is read / written.\n */\nexport enum EncodingType {\n /**\n * Standard encoding format.\n */\n UTF8 = 'utf8',\n /**\n * Binary, radix-64 representation.\n */\n Base64 = 'base64',\n}\n\n// @docsMissing\nexport type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH';\n\nexport type ReadingOptions = {\n /**\n * The encoding format to use when reading the file.\n * @default EncodingType.UTF8\n */\n encoding?: EncodingType | 'utf8' | 'base64';\n /**\n * Optional number of bytes to skip. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `length` is defined.\n * */\n position?: number;\n /**\n * Optional number of bytes to read. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `position` is defined.\n */\n length?: number;\n};\n\nexport type WritingOptions = {\n /**\n * The encoding format to use when writing the file.\n * @default FileSystem.EncodingType.UTF8\n */\n encoding?: EncodingType | 'utf8' | 'base64';\n};\n\nexport type DeletingOptions = {\n /**\n * If `true`, don't throw an error if there is no file or directory at this URI.\n * @default false\n */\n idempotent?: boolean;\n};\n\nexport type InfoOptions = {\n /**\n * Whether to return the MD5 hash of the file.\n * @default false\n */\n md5?: boolean;\n /**\n * Explicitly specify that the file size should be included. For example, skipping this can prevent downloading the file if it's stored in iCloud.\n * The size is always returned for `file://` locations.\n */\n size?: boolean;\n};\n\nexport type RelocatingOptions = {\n /**\n * URI or [SAF](#saf-uri) URI to the asset, file, or directory. See [supported URI schemes](#supported-uri-schemes-1).\n */\n from: string;\n /**\n * `file://` URI to the file or directory which should be its new location.\n */\n to: string;\n};\n\nexport type MakeDirectoryOptions = {\n /**\n * If `true`, don't throw an error if there is no file or directory at this URI.\n * @default false\n */\n intermediates?: boolean;\n};\n\n// @docsMissing\nexport type ProgressEvent<T> = {\n uuid: string;\n data: T;\n};\n\n/* eslint-disable */\nexport type FileSystemRequestDirectoryPermissionsResult =\n /**\n * If the permissions were not granted.\n */\n {\n granted: false;\n } |\n /**\n * If the permissions were granted.\n */\n {\n granted: true;\n /**\n * The [SAF URI](#saf-uri) to the user's selected directory. Available only if permissions were granted.\n */\n directoryUri: string;\n };\n/* eslint-enable */\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './FileSystem';
2
+ export * from './FileSystem.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './FileSystem';
2
+ export * from './FileSystem.types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './FileSystem';\nexport * from './FileSystem.types';\n"]}
@@ -0,0 +1,35 @@
1
+ type PlatformMethod = (...args: any[]) => Promise<any>;
2
+ export interface ExponentFileSystemModule {
3
+ readonly name: 'ExponentFileSystem';
4
+ readonly documentDirectory: string | null;
5
+ readonly cacheDirectory: string | null;
6
+ readonly bundledAssets: string | null;
7
+ readonly bundleDirectory: string | null;
8
+ readonly getInfoAsync?: PlatformMethod;
9
+ readonly readAsStringAsync?: PlatformMethod;
10
+ readonly writeAsStringAsync?: PlatformMethod;
11
+ readonly deleteAsync?: PlatformMethod;
12
+ readonly moveAsync?: PlatformMethod;
13
+ readonly copyAsync?: PlatformMethod;
14
+ readonly makeDirectoryAsync?: PlatformMethod;
15
+ readonly readDirectoryAsync?: PlatformMethod;
16
+ readonly downloadAsync?: PlatformMethod;
17
+ readonly uploadAsync?: PlatformMethod;
18
+ readonly downloadResumableStartAsync?: PlatformMethod;
19
+ readonly downloadResumablePauseAsync?: PlatformMethod;
20
+ readonly getContentUriAsync?: PlatformMethod;
21
+ readonly getFreeDiskStorageAsync?: PlatformMethod;
22
+ readonly getTotalDiskCapacityAsync?: PlatformMethod;
23
+ readonly requestDirectoryPermissionsAsync?: PlatformMethod;
24
+ readonly readSAFDirectoryAsync?: PlatformMethod;
25
+ readonly makeSAFDirectoryAsync?: PlatformMethod;
26
+ readonly createSAFFileAsync?: PlatformMethod;
27
+ readonly networkTaskCancelAsync?: PlatformMethod;
28
+ readonly uploadTaskStartAsync?: PlatformMethod;
29
+ startObserving?: () => void;
30
+ stopObserving?: () => void;
31
+ addListener: (eventName: string) => void;
32
+ removeListeners: (count: number) => void;
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEvD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC;IACtC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,cAAc,CAAC;IACtD,QAAQ,CAAC,2BAA2B,CAAC,EAAE,cAAc,CAAC;IACtD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAC7C,QAAQ,CAAC,uBAAuB,CAAC,EAAE,cAAc,CAAC;IAClD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,cAAc,CAAC;IACpD,QAAQ,CAAC,gCAAgC,CAAC,EAAE,cAAc,CAAC;IAC3D,QAAQ,CAAC,qBAAqB,CAAC,EAAE,cAAc,CAAC;IAChD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,cAAc,CAAC;IAChD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAC7C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACjD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAC;IAC/C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["type PlatformMethod = (...args: any[]) => Promise<any>;\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 uploadAsync?: PlatformMethod;\n readonly downloadResumableStartAsync?: PlatformMethod;\n readonly downloadResumablePauseAsync?: PlatformMethod;\n readonly getContentUriAsync?: PlatformMethod;\n readonly getFreeDiskStorageAsync?: PlatformMethod;\n readonly getTotalDiskCapacityAsync?: PlatformMethod;\n readonly requestDirectoryPermissionsAsync?: PlatformMethod;\n readonly readSAFDirectoryAsync?: PlatformMethod;\n readonly makeSAFDirectoryAsync?: PlatformMethod;\n readonly createSAFFileAsync?: PlatformMethod;\n readonly networkTaskCancelAsync?: PlatformMethod;\n readonly uploadTaskStartAsync?: PlatformMethod;\n startObserving?: () => void;\n stopObserving?: () => void;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "expo-file-system",
3
+ "platforms": ["ios", "android"],
4
+ "ios": {
5
+ "modules": ["FileSystemModule"],
6
+ "appDelegateSubscribers": ["FileSystemBackgroundSessionHandler"]
7
+ },
8
+ "android": {
9
+ "modules": ["expo.modules.filesystem.FileSystemModule"]
10
+ }
11
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ #import <Foundation/Foundation.h>
4
+ #import <ExpoModulesCore/EXFilePermissionModuleInterface.h>
5
+ #import <ExpoModulesCore/EXInternalModule.h>
6
+ #import <ExpoModulesCore/EXModuleRegistryConsumer.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface EXFilePermissionModule : NSObject <EXInternalModule, EXFilePermissionModuleInterface, EXModuleRegistryConsumer>
11
+
12
+ - (EXFileSystemPermissionFlags)getPathPermissions:(NSString *)path;
13
+
14
+ @end
15
+
16
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,68 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+ #import <ExpoFileSystem/EXFilePermissionModule.h>
3
+ #import <ExpoModulesCore/EXFileSystemInterface.h>
4
+
5
+ @interface EXFilePermissionModule ()
6
+
7
+ @property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
8
+
9
+ @end
10
+
11
+ @implementation EXFilePermissionModule
12
+
13
+ EX_REGISTER_MODULE();
14
+
15
+ + (const NSArray<Protocol *> *)exportedInterfaces
16
+ {
17
+ return @[@protocol(EXFilePermissionModuleInterface)];
18
+ }
19
+
20
+ - (EXFileSystemPermissionFlags)getPathPermissions:(NSString *)path
21
+ {
22
+ EXFileSystemPermissionFlags permissionsForInternalDirectories = [self getInternalPathPermissions:path];
23
+ if (permissionsForInternalDirectories != EXFileSystemPermissionNone) {
24
+ return permissionsForInternalDirectories;
25
+ } else {
26
+ return [self getExternalPathPermissions:path];
27
+ }
28
+ }
29
+
30
+ - (EXFileSystemPermissionFlags)getInternalPathPermissions:(NSString *)path
31
+ {
32
+ id<EXFileSystemInterface> fileSystem = [_moduleRegistry getModuleImplementingProtocol:@protocol(EXFileSystemInterface)];
33
+ NSArray<NSString *> *scopedDirs = @[fileSystem.cachesDirectory, fileSystem.documentDirectory];
34
+ NSString *standardizedPath = [path stringByStandardizingPath];
35
+ for (NSString *scopedDirectory in scopedDirs) {
36
+ if ([standardizedPath hasPrefix:[scopedDirectory stringByAppendingString:@"/"]] ||
37
+ [standardizedPath isEqualToString:scopedDirectory]) {
38
+ return EXFileSystemPermissionRead | EXFileSystemPermissionWrite;
39
+ }
40
+ }
41
+
42
+ NSString *bundleDirectory = fileSystem.bundleDirectory;
43
+ if (bundleDirectory != nil && [path hasPrefix:[bundleDirectory stringByAppendingString:@"/"]]) {
44
+ return EXFileSystemPermissionRead;
45
+ }
46
+
47
+ return EXFileSystemPermissionNone;
48
+ }
49
+
50
+ - (EXFileSystemPermissionFlags)getExternalPathPermissions:(NSString *)path
51
+ {
52
+ EXFileSystemPermissionFlags filePermissions = EXFileSystemPermissionNone;
53
+ if ([[NSFileManager defaultManager] isReadableFileAtPath:path]) {
54
+ filePermissions |= EXFileSystemPermissionRead;
55
+ }
56
+
57
+ if ([[NSFileManager defaultManager] isWritableFileAtPath:path]) {
58
+ filePermissions |= EXFileSystemPermissionWrite;
59
+ }
60
+
61
+ return filePermissions;
62
+ }
63
+
64
+ - (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry {
65
+ _moduleRegistry = moduleRegistry;
66
+ }
67
+
68
+ @end