expo-file-system 58.0.6 → 58.0.7
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.
- package/CHANGELOG.md +7 -0
- package/android/build.gradle +2 -2
- package/build/ExpoFileSystem.d.ts +3 -0
- package/build/ExpoFileSystem.js.map +1 -1
- package/build/File.d.ts +36 -1
- package/build/File.js +86 -1
- package/build/File.js.map +1 -1
- package/build/File.types.d.ts +22 -0
- package/build/File.types.js.map +1 -1
- package/build/NetworkTasks.d.ts +8 -0
- package/build/NetworkTasks.js +20 -2
- package/build/NetworkTasks.js.map +1 -1
- package/build/NetworkTasks.types.d.ts +11 -0
- package/build/index.d.ts +1 -1
- package/build/index.js.map +1 -1
- package/build/internal/NativeFileSystem.types.d.ts +4 -0
- package/build/internal/NativeFileSystem.types.js.map +1 -1
- package/ios/BackgroundSessionCompletion.swift +77 -0
- package/ios/ExpoFileSystem.podspec +11 -0
- package/ios/FileSystemDownloadTask.swift +42 -11
- package/ios/FileSystemExceptions.swift +12 -0
- package/ios/FileSystemModule.swift +82 -32
- package/ios/FileSystemPreview.swift +13 -7
- package/ios/Legacy/FileSystemBackgroundSessionHandler.swift +24 -7
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.module → 58.0.7/expo.modules.filesystem-58.0.7.module} +7 -7
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.pom → 58.0.7/expo.modules.filesystem-58.0.7.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.7/expo.modules.filesystem-58.0.7.pom.sha512 +1 -0
- package/mocks/FileSystem.ts +26 -0
- package/package.json +3 -3
- package/prebuilds/output/debug/xcframeworks/ExpoFileSystem.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoFileSystem.tar.gz +0 -0
- package/src/ExpoFileSystem.ts +3 -0
- package/src/File.ts +89 -1
- package/src/File.types.ts +23 -0
- package/src/NetworkTasks.ts +24 -0
- package/src/NetworkTasks.types.ts +12 -0
- package/src/index.ts +1 -0
- package/src/internal/NativeFileSystem.types.ts +4 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/58.0.6/expo.modules.filesystem-58.0.6.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6-sources.jar → 58.0.7/expo.modules.filesystem-58.0.7-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6-sources.jar.md5 → 58.0.7/expo.modules.filesystem-58.0.7-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6-sources.jar.sha1 → 58.0.7/expo.modules.filesystem-58.0.7-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6-sources.jar.sha256 → 58.0.7/expo.modules.filesystem-58.0.7-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6-sources.jar.sha512 → 58.0.7/expo.modules.filesystem-58.0.7-sources.jar.sha512} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.aar → 58.0.7/expo.modules.filesystem-58.0.7.aar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.aar.md5 → 58.0.7/expo.modules.filesystem-58.0.7.aar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.aar.sha1 → 58.0.7/expo.modules.filesystem-58.0.7.aar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.aar.sha256 → 58.0.7/expo.modules.filesystem-58.0.7.aar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.filesystem/{58.0.6/expo.modules.filesystem-58.0.6.aar.sha512 → 58.0.7/expo.modules.filesystem-58.0.7.aar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [iOS] Add opt-in control over background download completion with `DownloadTask.acknowledgeBackgroundCompletionAsync()`, so apps can finish processing downloads before returning control to iOS. ([#50543](https://github.com/expo/expo/pull/50543) by [@savv](https://github.com/savv))
|
|
8
|
+
- Added static `File.preview()` and `File.canPreview()` methods for a file or array of files, with multi-file previews and initial selection on iOS. ([#50696](https://github.com/expo/expo/pull/50696) by [@eliotgevers](https://github.com/eliotgevers))
|
|
9
|
+
|
|
3
10
|
## 58.0.6
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '58.0.
|
|
7
|
+
version = '58.0.7'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.filesystem"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 30
|
|
13
|
-
versionName "58.0.
|
|
13
|
+
versionName "58.0.7"
|
|
14
14
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
15
15
|
}
|
|
16
16
|
testOptions {
|
|
@@ -18,6 +18,9 @@ declare class ExpoFileSystemModule extends NativeModule<FileSystemEvents> {
|
|
|
18
18
|
FileSystemDownloadTask: typeof FileSystemDownloadTask;
|
|
19
19
|
FileSystemWatcher: typeof NativeFileSystemWatcher;
|
|
20
20
|
downloadFileAsync(url: string, destination: File | Directory, options?: DownloadOptions, uuid?: string): Promise<string>;
|
|
21
|
+
/** Native iOS collection previews. Single-file requests use the File instance methods. */
|
|
22
|
+
canPreview(files: File[]): Promise<boolean>;
|
|
23
|
+
preview(files: File[], initialIndex: number): Promise<void>;
|
|
21
24
|
cancelDownloadAsync(uuid: string): void;
|
|
22
25
|
pickDirectoryAsync(initialUri?: string): Promise<Directory>;
|
|
23
26
|
pickFileAsync(options: PickSingleFileOptions): Promise<File>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ExpoFileSystem.ts"],"sourcesContent":[null],"names":["NativeModule","requireNativeModule"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["ExpoFileSystem.ts"],"sourcesContent":[null],"names":["NativeModule","requireNativeModule"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,oBAAoB;AA+CtE,eAAeA,oBAA0C,cAAc"}
|
package/build/File.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Directory } from './Directory';
|
|
2
2
|
import ExpoFileSystem from './ExpoFileSystem';
|
|
3
|
-
import { type FileCanPreviewOptions, type FilePreviewOptions, type PickMultipleFilesOptions, type PickMultipleFilesResult, type PickSingleFileOptions, type PickSingleFileResult } from './File.types';
|
|
3
|
+
import { type FileCanPreviewOptions, type FilePreviewOptions, type FilePreviewCollectionOptions, type PickMultipleFilesOptions, type PickMultipleFilesResult, type PickSingleFileOptions, type PickSingleFileResult } from './File.types';
|
|
4
4
|
import { type WatchEvent, type WatchOptions, type WatchSubscription } from './FileSystemWatcher.types';
|
|
5
5
|
import { DownloadTask, UploadTask } from './NetworkTasks';
|
|
6
6
|
import { type DownloadOptions, type DownloadTaskOptions, type UploadOptions, type UploadResult } from './NetworkTasks.types';
|
|
@@ -16,6 +16,41 @@ import { type DownloadOptions, type DownloadTaskOptions, type UploadOptions, typ
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare class File extends ExpoFileSystem.FileSystemFile implements Blob {
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether every supplied local file can be previewed.
|
|
21
|
+
* Android resolves to `false` for more than one file. Only iOS previews multiple files.
|
|
22
|
+
* An array with one file behaves like a single `File`.
|
|
23
|
+
* Rejects empty arrays and invalid arguments.
|
|
24
|
+
* @platform ios
|
|
25
|
+
* @platform android
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const files = [new File(Paths.cache, 'report.pdf'), new File(Paths.cache, 'notes.txt')];
|
|
30
|
+
* const canPreviewAll = await File.canPreview(files);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
static canPreview(input: File | File[], options?: FileCanPreviewOptions): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Previews local files in the supplied order, starting at `initialIndex` (default `0`).
|
|
36
|
+
* Android rejects more than one file. Only iOS previews multiple files.
|
|
37
|
+
* An array with one file behaves like a single `File`.
|
|
38
|
+
* Rejects if you pass `title` or `mimeType` with more than one file.
|
|
39
|
+
* Also rejects empty arrays, an invalid `initialIndex`, and files that cannot be previewed.
|
|
40
|
+
* Resolves at presentation or handoff to another app, not when the viewer closes.
|
|
41
|
+
* @platform ios
|
|
42
|
+
* @platform android
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // The files must exist before previewing.
|
|
47
|
+
* const files = [new File(Paths.cache, 'report.pdf'), new File(Paths.cache, 'notes.txt')];
|
|
48
|
+
* if (await File.canPreview(files)) {
|
|
49
|
+
* await File.preview(files, { initialIndex: 1 });
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
static preview(input: File | File[], options?: FilePreviewOptions & FilePreviewCollectionOptions): Promise<void>;
|
|
19
54
|
/**
|
|
20
55
|
* A static method that downloads a file from the network.
|
|
21
56
|
*
|
package/build/File.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { uuid } from 'expo-modules-core';
|
|
1
|
+
import { UnavailabilityError, uuid } from 'expo-modules-core';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
2
3
|
import { Directory } from './Directory';
|
|
3
4
|
import ExpoFileSystem from './ExpoFileSystem';
|
|
4
5
|
import { FileMode } from './File.types';
|
|
@@ -18,6 +19,69 @@ import { FileSystemReadableStreamSource, FileSystemWritableSink } from './intern
|
|
|
18
19
|
* ```
|
|
19
20
|
*/ export class File extends ExpoFileSystem.FileSystemFile {
|
|
20
21
|
/**
|
|
22
|
+
* Checks whether every supplied local file can be previewed.
|
|
23
|
+
* Android resolves to `false` for more than one file. Only iOS previews multiple files.
|
|
24
|
+
* An array with one file behaves like a single `File`.
|
|
25
|
+
* Rejects empty arrays and invalid arguments.
|
|
26
|
+
* @platform ios
|
|
27
|
+
* @platform android
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const files = [new File(Paths.cache, 'report.pdf'), new File(Paths.cache, 'notes.txt')];
|
|
32
|
+
* const canPreviewAll = await File.canPreview(files);
|
|
33
|
+
* ```
|
|
34
|
+
*/ static async canPreview(input, options) {
|
|
35
|
+
const files = normalizePreviewFiles(input);
|
|
36
|
+
validateCollectionPreviewOptions(files, options);
|
|
37
|
+
if (files.length === 1) {
|
|
38
|
+
return files[0].canPreview(options);
|
|
39
|
+
}
|
|
40
|
+
if (Platform.OS !== 'ios' || Platform.isTV) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (!ExpoFileSystem.canPreview) {
|
|
44
|
+
throw new UnavailabilityError('expo-file-system', 'File.canPreview');
|
|
45
|
+
}
|
|
46
|
+
return ExpoFileSystem.canPreview(files);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Previews local files in the supplied order, starting at `initialIndex` (default `0`).
|
|
50
|
+
* Android rejects more than one file. Only iOS previews multiple files.
|
|
51
|
+
* An array with one file behaves like a single `File`.
|
|
52
|
+
* Rejects if you pass `title` or `mimeType` with more than one file.
|
|
53
|
+
* Also rejects empty arrays, an invalid `initialIndex`, and files that cannot be previewed.
|
|
54
|
+
* Resolves at presentation or handoff to another app, not when the viewer closes.
|
|
55
|
+
* @platform ios
|
|
56
|
+
* @platform android
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* // The files must exist before previewing.
|
|
61
|
+
* const files = [new File(Paths.cache, 'report.pdf'), new File(Paths.cache, 'notes.txt')];
|
|
62
|
+
* if (await File.canPreview(files)) {
|
|
63
|
+
* await File.preview(files, { initialIndex: 1 });
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/ static async preview(input, options) {
|
|
67
|
+
const files = normalizePreviewFiles(input);
|
|
68
|
+
const initialIndex = options?.initialIndex ?? 0;
|
|
69
|
+
if (!Number.isInteger(initialIndex) || initialIndex < 0 || initialIndex >= files.length) {
|
|
70
|
+
throw new RangeError('initialIndex must be an integer within the preview collection.');
|
|
71
|
+
}
|
|
72
|
+
validateCollectionPreviewOptions(files, options);
|
|
73
|
+
if (files.length === 1) {
|
|
74
|
+
return files[0].preview({
|
|
75
|
+
title: options?.title,
|
|
76
|
+
mimeType: options?.mimeType
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (Platform.OS !== 'ios' || Platform.isTV || !ExpoFileSystem.preview) {
|
|
80
|
+
throw new UnavailabilityError('expo-file-system', 'File.preview (multiple files)');
|
|
81
|
+
}
|
|
82
|
+
return ExpoFileSystem.preview(files, initialIndex);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
21
85
|
* A static method that downloads a file from the network.
|
|
22
86
|
*
|
|
23
87
|
* On Android, the response body streams directly into the target file. If the download fails after
|
|
@@ -332,5 +396,26 @@ File.downloadFileAsync = async function downloadFileAsync(url, to, options) {
|
|
|
332
396
|
usingOldAPI: mimeType !== undefined || typeof initialUriOrOptions === 'string'
|
|
333
397
|
};
|
|
334
398
|
}
|
|
399
|
+
function normalizePreviewFiles(input) {
|
|
400
|
+
const files = Array.isArray(input) ? [
|
|
401
|
+
...input
|
|
402
|
+
] : [
|
|
403
|
+
input
|
|
404
|
+
];
|
|
405
|
+
if (files.length === 0) {
|
|
406
|
+
throw new RangeError('At least one file is required for a preview.');
|
|
407
|
+
}
|
|
408
|
+
for (const file of files){
|
|
409
|
+
if (!(file instanceof ExpoFileSystem.FileSystemFile)) {
|
|
410
|
+
throw new TypeError('Preview input must contain File instances.');
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return files;
|
|
414
|
+
}
|
|
415
|
+
function validateCollectionPreviewOptions(files, options) {
|
|
416
|
+
if (files.length > 1 && (options?.title !== undefined || options?.mimeType !== undefined)) {
|
|
417
|
+
throw new TypeError('title and mimeType are only supported for single-file previews.');
|
|
418
|
+
}
|
|
419
|
+
}
|
|
335
420
|
|
|
336
421
|
//# sourceMappingURL=File.js.map
|
package/build/File.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["File.ts"],"sourcesContent":[null],"names":["uuid","Directory","ExpoFileSystem","FileMode","DownloadTask","UploadTask","Paths","FileSystemWatcher","FileSystemReadableStreamSource","FileSystemWritableSink","File","FileSystemFile","
|
|
1
|
+
{"version":3,"sources":["File.ts"],"sourcesContent":[null],"names":["UnavailabilityError","uuid","Platform","Directory","ExpoFileSystem","FileMode","DownloadTask","UploadTask","Paths","FileSystemWatcher","FileSystemReadableStreamSource","FileSystemWritableSink","File","FileSystemFile","canPreview","input","options","files","normalizePreviewFiles","validateCollectionPreviewOptions","length","OS","isTV","preview","initialIndex","Number","isInteger","RangeError","title","mimeType","downloadFileAsync","pickFileAsync","initialUriOrOptions","usingOldAPI","parsePickFileOptions","multipleFiles","result","map","file","uri","canceled","e","uris","join","validatePath","parentDirectory","dirname","extension","extname","name","basename","readableStream","ReadableStream","open","ReadOnly","writableStream","WritableStream","WriteOnly","arrayBuffer","bytes","buffer","json","JSON","parse","text","formData","Response","headers","type","undefined","stream","slice","start","end","contentType","Blob","bytesSync","upload","url","uploadAsync","createUploadTask","createDownloadTask","destination","watch","callback","createAbortError","reason","error","Error","to","needsUuid","onProgress","signal","downloadUuid","v4","subscription","abortHandler","lastProgress","aborted","addListener","event","data","cancelDownloadAsync","addEventListener","once","outputURI","fileSize","size","bytesWritten","totalBytes","remove","removeEventListener","initialUri","mimeTypes","Array","isArray","TypeError"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,IAAI,QAAgC,oBAAoB;AACtF,SAASC,QAAQ,QAAQ,eAAe;AAExC,SAASC,SAAS,QAAQ,cAAc;AACxC,OAAOC,oBAAoB,mBAAmB;AAC9C,SACEC,QAAQ,QASH,eAAe;AAMtB,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAQ1D,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,iBAAiB,QAAQ,+BAA+B;AACjE,SAASC,8BAA8B,EAAEC,sBAAsB,QAAQ,qBAAqB;AAE5F;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,aAAaR,eAAeS,cAAc;IACrD;;;;;;;;;;;;;GAaC,GACD,aAAaC,WAAWC,KAAoB,EAAEC,OAA+B,EAAoB;QAC/F,MAAMC,QAAQC,sBAAsBH;QACpCI,iCAAiCF,OAAOD;QACxC,IAAIC,MAAMG,MAAM,KAAK,GAAG;YACtB,OAAOH,KAAK,CAAC,EAAE,CAAEH,UAAU,CAACE;QAC9B;QACA,IAAId,SAASmB,EAAE,KAAK,SAASnB,SAASoB,IAAI,EAAE;YAC1C,OAAO;QACT;QACA,IAAI,CAAClB,eAAeU,UAAU,EAAE;YAC9B,MAAM,IAAId,oBAAoB,oBAAoB;QACpD;QACA,OAAOI,eAAeU,UAAU,CAACG;IACnC;IAEA;;;;;;;;;;;;;;;;;;GAkBC,GACD,aAAaM,QACXR,KAAoB,EACpBC,OAA2D,EAC5C;QACf,MAAMC,QAAQC,sBAAsBH;QACpC,MAAMS,eAAeR,SAASQ,gBAAgB;QAC9C,IAAI,CAACC,OAAOC,SAAS,CAACF,iBAAiBA,eAA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OrC,wBAAwB;IACxE;AACF;AAEA,SAASd,sBAAsBH,KAAoB;IACjD,MAAME,QAAQiG,MAAMC,OAAO,CAACpG,SAAS;WAAIA;KAAM,GAAG;QAACA;KAAM;IACzD,IAAIE,MAAMG,MAAM,KAAK,GAAG;QACtB,MAAM,IAAIO,WAAW;IACvB;IACA,KAAK,MAAMW,QAAQrB,MAAO;QACxB,IAAI,CAAEqB,CAAAA,gBAAgBlC,eAAeS,cAAc,AAAD,GAAI;YACpD,MAAM,IAAIuG,UAAU;QACtB;IACF;IACA,OAAOnG;AACT;AAEA,SAASE,iCAAiCF,KAAa,EAAED,OAA4B;IACnF,IAAIC,MAAMG,MAAM,GAAG,KAAMJ,CAAAA,SAASY,UAAUyC,aAAarD,SAASa,aAAawC,SAAQ,GAAI;QACzF,MAAM,IAAI+C,UAAU;IACtB;AACF"}
|
package/build/File.types.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export type FileWriteOptions = {
|
|
|
43
43
|
*/
|
|
44
44
|
append?: boolean;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Options for checking whether a file can be previewed.
|
|
48
|
+
* @platform android
|
|
49
|
+
* @platform ios
|
|
50
|
+
*/
|
|
46
51
|
export type FileCanPreviewOptions = {
|
|
47
52
|
/**
|
|
48
53
|
* MIME type of the file. Android uses this value to find a matching app for the preview intent.
|
|
@@ -50,6 +55,23 @@ export type FileCanPreviewOptions = {
|
|
|
50
55
|
*/
|
|
51
56
|
mimeType?: string;
|
|
52
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Options for choosing which file `File.preview()` displays first.
|
|
60
|
+
* @platform android
|
|
61
|
+
* @platform ios
|
|
62
|
+
*/
|
|
63
|
+
export type FilePreviewCollectionOptions = {
|
|
64
|
+
/**
|
|
65
|
+
* Zero-based index of the file to display first. Must be within the supplied array.
|
|
66
|
+
* @default 0
|
|
67
|
+
*/
|
|
68
|
+
initialIndex?: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Options for previewing a single file.
|
|
72
|
+
* @platform android
|
|
73
|
+
* @platform ios
|
|
74
|
+
*/
|
|
53
75
|
export type FilePreviewOptions = {
|
|
54
76
|
/**
|
|
55
77
|
* Optional display title for the preview when the platform supports one.
|
package/build/File.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["File.types.ts"],"sourcesContent":[null],"names":["EncodingType","FileMode"],"mappings":"AA0BA,OAAO,IAAA,AAAKA,sCAAAA;IACV;;GAEC;IAED;;GAEC;WAPSA;MASX;
|
|
1
|
+
{"version":3,"sources":["File.types.ts"],"sourcesContent":[null],"names":["EncodingType","FileMode"],"mappings":"AA0BA,OAAO,IAAA,AAAKA,sCAAAA;IACV;;GAEC;IAED;;GAEC;WAPSA;MASX;AA0DD;;CAEC,GACD,OAAO,IAAA,AAAKC,kCAAAA;IACV;;;;;GAKC;IAGD;;;GAGC;IAGD;;;GAGC;IAGD;;;;;;GAMC;IAGD;;GAEC;WAhCSA;MAkCX"}
|
package/build/NetworkTasks.d.ts
CHANGED
|
@@ -99,6 +99,14 @@ export declare class DownloadTask {
|
|
|
99
99
|
* The current state of the download task.
|
|
100
100
|
*/
|
|
101
101
|
get state(): DownloadTaskState;
|
|
102
|
+
/**
|
|
103
|
+
* Acknowledges that processing this successful download has finished.
|
|
104
|
+
* Requires `deferBackgroundSessionCompletion`. Call after `downloadAsync()` or `resumeAsync()`
|
|
105
|
+
* resolves, normally in a `finally` block around processing. Early calls reject; repeated calls
|
|
106
|
+
* after completion are harmless. Android and foreground sessions require no acknowledgment.
|
|
107
|
+
* @platform ios
|
|
108
|
+
*/
|
|
109
|
+
acknowledgeBackgroundCompletionAsync(): Promise<void>;
|
|
102
110
|
/**
|
|
103
111
|
* Starts the download operation.
|
|
104
112
|
*
|
package/build/NetworkTasks.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
import { Directory } from './Directory';
|
|
2
3
|
import ExpoFileSystem from './ExpoFileSystem';
|
|
3
4
|
import { File } from './File';
|
|
@@ -200,6 +201,21 @@ function cleanupNetworkTask(signal, subscription, abortHandler) {
|
|
|
200
201
|
return this._state;
|
|
201
202
|
}
|
|
202
203
|
/**
|
|
204
|
+
* Acknowledges that processing this successful download has finished.
|
|
205
|
+
* Requires `deferBackgroundSessionCompletion`. Call after `downloadAsync()` or `resumeAsync()`
|
|
206
|
+
* resolves, normally in a `finally` block around processing. Early calls reject; repeated calls
|
|
207
|
+
* after completion are harmless. Android and foreground sessions require no acknowledgment.
|
|
208
|
+
* @platform ios
|
|
209
|
+
*/ async acknowledgeBackgroundCompletionAsync() {
|
|
210
|
+
if (Platform.OS !== 'ios' || !this._options?.deferBackgroundSessionCompletion || this._options?.sessionType === 'foreground') {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this._state !== 'completed') {
|
|
214
|
+
throw new Error('Background completion can only be acknowledged after a successful download');
|
|
215
|
+
}
|
|
216
|
+
await this._nativeTask.acknowledgeBackgroundCompletionAsync();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
203
219
|
* Starts the download operation.
|
|
204
220
|
*
|
|
205
221
|
* This method can only be called once, while the task is `idle`. The promise resolves with
|
|
@@ -217,7 +233,8 @@ function cleanupNetworkTask(signal, subscription, abortHandler) {
|
|
|
217
233
|
this._pauseRequest = undefined;
|
|
218
234
|
const operation = this._runDownloadOperation(()=>this._nativeTask.start(this._url, this._destination, {
|
|
219
235
|
headers: this._options?.headers,
|
|
220
|
-
sessionType: this._options?.sessionType
|
|
236
|
+
sessionType: this._options?.sessionType,
|
|
237
|
+
deferBackgroundSessionCompletion: this._options?.deferBackgroundSessionCompletion
|
|
221
238
|
}));
|
|
222
239
|
this._inFlightOperation = operation;
|
|
223
240
|
return operation;
|
|
@@ -267,7 +284,8 @@ function cleanupNetworkTask(signal, subscription, abortHandler) {
|
|
|
267
284
|
this._pauseRequest = undefined;
|
|
268
285
|
const operation = this._runDownloadOperation(()=>this._nativeTask.resume(this._url, this._destination, this._resumeData, {
|
|
269
286
|
headers: this._options?.headers,
|
|
270
|
-
sessionType: this._options?.sessionType
|
|
287
|
+
sessionType: this._options?.sessionType,
|
|
288
|
+
deferBackgroundSessionCompletion: this._options?.deferBackgroundSessionCompletion
|
|
271
289
|
}));
|
|
272
290
|
this._inFlightOperation = operation;
|
|
273
291
|
return operation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NetworkTasks.ts"],"sourcesContent":[null],"names":["Directory","ExpoFileSystem","File","createAbortError","reason","error","Error","name","assertNetworkTaskState","state","allowedStates","methodName","includes","wireNetworkTaskAbortSignal","signal","cancel","aborted","abortHandler","addEventListener","once","undefined","wireNetworkTaskProgress","onProgress","addListener","cleanupNetworkTask","subscription","remove","removeEventListener","UploadTask","_state","_file","_url","_options","_subscription","_abortHandler","_nativeTask","file","url","options","FileSystemUploadTask","uploadAsync","listener","nativeOpts","httpMethod","uploadType","headers","fieldName","mimeType","parameters","sessionType","result","start","exists","size","bytesSent","totalBytes","eventName","release","DownloadTask","_destination","_resumeData","_inFlightOperation","_pauseRequest","destination","FileSystemDownloadTask","downloadAsync","operation","_runDownloadOperation","pause","Promise","resolve","then","resumeData","pauseAsync","resumeAsync","resume","savable","fileUri","uri","isDirectory","fromSavable","dest","mergedOptions","task","_emitFinalProgressEvent","fileSize","bytesWritten"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["NetworkTasks.ts"],"sourcesContent":[null],"names":["Platform","Directory","ExpoFileSystem","File","createAbortError","reason","error","Error","name","assertNetworkTaskState","state","allowedStates","methodName","includes","wireNetworkTaskAbortSignal","signal","cancel","aborted","abortHandler","addEventListener","once","undefined","wireNetworkTaskProgress","onProgress","addListener","cleanupNetworkTask","subscription","remove","removeEventListener","UploadTask","_state","_file","_url","_options","_subscription","_abortHandler","_nativeTask","file","url","options","FileSystemUploadTask","uploadAsync","listener","nativeOpts","httpMethod","uploadType","headers","fieldName","mimeType","parameters","sessionType","result","start","exists","size","bytesSent","totalBytes","eventName","release","DownloadTask","_destination","_resumeData","_inFlightOperation","_pauseRequest","destination","FileSystemDownloadTask","acknowledgeBackgroundCompletionAsync","OS","deferBackgroundSessionCompletion","downloadAsync","operation","_runDownloadOperation","pause","Promise","resolve","then","resumeData","pauseAsync","resumeAsync","resume","savable","fileUri","uri","isDirectory","fromSavable","dest","mergedOptions","task","_emitFinalProgressEvent","fileSize","bytesWritten"],"mappings":"AACA,SAASA,QAAQ,QAAQ,eAAe;AAExC,SAASC,SAAS,QAAQ,cAAc;AACxC,OAAOC,oBAAoB,mBAAmB;AAC9C,SAASC,IAAI,QAAQ,SAAS;AAmB9B,SAASC,iBAAiBC,MAAe;IACvC,MAAMC,QAAQ,IAAIC,MAAMF,UAAU;IAClCC,MAAME,IAAI,GAAG;IACb,OAAOF;AACT;AAEA,SAASG,uBACPC,KAAa,EACbC,aAAgC,EAChCC,UAAkB;IAElB,IAAI,CAACD,cAAcE,QAAQ,CAACH,QAAQ;QAClC,MAAM,IAAIH,MAAM,CAAC,YAAY,EAAEK,WAAW,aAAa,EAAEF,MAAM,CAAC,CAAC;IACnE;AACF;AAEA,SAASI,2BACPC,MAA2C,EAC3CC,MAAkB;IAElB,IAAID,QAAQE,SAAS;QACnB,MAAMb;IACR;IACA,IAAIW,QAAQ;QACV,MAAMG,eAAe,IAAMF;QAC3BD,OAAOI,gBAAgB,CAAC,SAASD,cAAc;YAAEE,MAAM;QAAK;QAC5D,OAAOF;IACT;IACA,OAAOG;AACT;AAEA,SAASC,wBACPC,UAAuD,EACvDC,WAA2E;IAE3E,IAAID,YAAY;QACd,OAAOC,YAAYD;IACrB;IACA,OAAOF;AACT;AAEA,SAASI,mBACPV,MAA2C,EAC3CW,YAA2C,EAC3CR,YAAsC;IAEtCQ,cAAcC;IACd,IAAIT,gBAAgBH,QAAQ;QAC1BA,OAAOa,mBAAmB,CAAC,SAASV;IACtC;AACF;AAEA;;;;;CAKC,GACD,O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,EAAE;QAChD,iEAAiE;QACjE,8EAA8E;QAC9E,iFAAiF;QACjF,IAAI,IAAI,CAACxD,QAAQ,EAAEV,YAAY;YAC7B,IAAIkE,WAAW,GAAG;gBAChB,IAAI,CAACxD,QAAQ,CAACV,UAAU,CAAC;oBAAEmE,cAAcD;oBAAUjC,YAAYiC;gBAAS;YAC1E;QACF;IACF;AACF"}
|
|
@@ -150,6 +150,17 @@ export type DownloadTaskOptions = {
|
|
|
150
150
|
* Custom headers to include in the request.
|
|
151
151
|
*/
|
|
152
152
|
headers?: Record<string, string>;
|
|
153
|
+
/**
|
|
154
|
+
* Delays the iOS background session completion handler until processing is acknowledged with
|
|
155
|
+
* `DownloadTask.acknowledgeBackgroundCompletionAsync()` after the download succeeds.
|
|
156
|
+
* Every successful opted-in download needs its own acknowledgment. A 25-second deadline covers
|
|
157
|
+
* event delivery and JS processing; the system handler is never called before all events arrive.
|
|
158
|
+
* Applies only to iOS background sessions. Android and foreground sessions ignore this option.
|
|
159
|
+
* Does not restore JS tasks or acknowledgment state after process termination.
|
|
160
|
+
* @default false
|
|
161
|
+
* @platform ios
|
|
162
|
+
*/
|
|
163
|
+
deferBackgroundSessionCompletion?: boolean;
|
|
153
164
|
/**
|
|
154
165
|
* Determines whether the iOS native session should continue in the background.
|
|
155
166
|
* Android accepts this option for API consistency and ignores it.
|
package/build/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { Paths } from './Paths';
|
|
|
2
2
|
export { File } from './File';
|
|
3
3
|
export { Directory } from './Directory';
|
|
4
4
|
export { UploadTask, DownloadTask } from './NetworkTasks';
|
|
5
|
-
export { DEFAULT_DEBOUNCE_MS, type FileCreateOptions, type FileDigestAlgorithm, type DirectoryCreateOptions, type RelocationOptions, type FileHandle, type FileInfo, type FileCanPreviewOptions, type FilePreviewOptions, type FileWriteOptions, type InfoOptions, type PathInfo, type DirectoryInfo, type DownloadOptions, type DownloadProgress, FileMode, EncodingType, UploadType, type PickFileOptions, type PickSingleFileOptions, type PickMultipleFilesOptions, type PickFileGeneralOptions, type PickSingleFileSuccessResult, type PickSingleFileResult, type PickMultipleFilesResult, type PickMultipleFilesSuccessResult, type PickFileCanceledResult, type UploadOptions, type UploadProgress, type UploadResult, type DownloadTaskOptions, type NetworkTaskSessionType, type DownloadPauseState, type UploadTaskState, type DownloadTaskState, type WatchEventType, type WatchEvent, type WatchOptions, type WatchSubscription, } from './FileSystem.types';
|
|
5
|
+
export { DEFAULT_DEBOUNCE_MS, type FileCreateOptions, type FileDigestAlgorithm, type DirectoryCreateOptions, type RelocationOptions, type FileHandle, type FileInfo, type FileCanPreviewOptions, type FilePreviewOptions, type FilePreviewCollectionOptions, type FileWriteOptions, type InfoOptions, type PathInfo, type DirectoryInfo, type DownloadOptions, type DownloadProgress, FileMode, EncodingType, UploadType, type PickFileOptions, type PickSingleFileOptions, type PickMultipleFilesOptions, type PickFileGeneralOptions, type PickSingleFileSuccessResult, type PickSingleFileResult, type PickMultipleFilesResult, type PickMultipleFilesSuccessResult, type PickFileCanceledResult, type UploadOptions, type UploadProgress, type UploadResult, type DownloadTaskOptions, type NetworkTaskSessionType, type DownloadPauseState, type UploadTaskState, type DownloadTaskState, type WatchEventType, type WatchEvent, type WatchOptions, type WatchSubscription, } from './FileSystem.types';
|
|
6
6
|
export * from './legacyWarnings';
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":["Paths","File","Directory","UploadTask","DownloadTask","DEFAULT_DEBOUNCE_MS","FileMode","EncodingType","UploadType"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAChC,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAE1D,SACEC,mBAAmB,
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":["Paths","File","Directory","UploadTask","DownloadTask","DEFAULT_DEBOUNCE_MS","FileMode","EncodingType","UploadType"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAChC,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAE1D,SACEC,mBAAmB,EAgBnBC,QAAQ,EACRC,YAAY,EACZC,UAAU,QAsBL,qBAAqB;AAE5B,cAAc,mBAAmB"}
|
|
@@ -303,6 +303,10 @@ export declare class FileSystemDownloadTask extends SharedObject<DownloadTaskEve
|
|
|
303
303
|
* @hidden
|
|
304
304
|
*/
|
|
305
305
|
resume(url: string, to: PublicFile | PublicDirectory, resumeData: string, options?: Record<string, any>): Promise<string | null>;
|
|
306
|
+
/**
|
|
307
|
+
* @hidden
|
|
308
|
+
*/
|
|
309
|
+
acknowledgeBackgroundCompletionAsync(): Promise<void>;
|
|
306
310
|
/**
|
|
307
311
|
* @hidden
|
|
308
312
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["internal/NativeFileSystem.types.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["internal/NativeFileSystem.types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAsaA;;CAEC,GACD,WAIC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2026-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
// Accessed only on the main queue by FileSystemBackgroundSessionHandler.
|
|
6
|
+
final class BackgroundSessionCompletion {
|
|
7
|
+
private struct Session {
|
|
8
|
+
let token: UUID
|
|
9
|
+
var completions: [() -> Void]
|
|
10
|
+
var finishedEvents = false
|
|
11
|
+
var deadlineReached = false
|
|
12
|
+
var awaitingAcknowledgment: Set<ObjectIdentifier> = []
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private var sessions: [String: Session] = [:]
|
|
16
|
+
private var downloads: [ObjectIdentifier: String] = [:]
|
|
17
|
+
|
|
18
|
+
func register(_ task: AnyObject, session identifier: String) {
|
|
19
|
+
discard(task)
|
|
20
|
+
downloads[ObjectIdentifier(task)] = identifier
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func finish(_ task: AnyObject, succeeded: Bool) {
|
|
24
|
+
let key = ObjectIdentifier(task)
|
|
25
|
+
guard let identifier = downloads[key] else { return }
|
|
26
|
+
// Foreground completions have no system handler to defer. Do not retain them for a later wake.
|
|
27
|
+
guard succeeded, sessions[identifier] != nil else {
|
|
28
|
+
discard(task)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
sessions[identifier]?.awaitingAcknowledgment.insert(key)
|
|
32
|
+
completeIfReady(identifier)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func discard(_ task: AnyObject) {
|
|
36
|
+
let key = ObjectIdentifier(task)
|
|
37
|
+
guard let identifier = downloads.removeValue(forKey: key) else { return }
|
|
38
|
+
sessions[identifier]?.awaitingAcknowledgment.remove(key)
|
|
39
|
+
completeIfReady(identifier)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@discardableResult
|
|
43
|
+
func receiveHandler(_ identifier: String, completion: @escaping () -> Void) -> UUID {
|
|
44
|
+
if let token = sessions[identifier]?.token {
|
|
45
|
+
// Keep pending processing and the original deadline, but wait for the new handler's final event.
|
|
46
|
+
sessions[identifier]?.completions.append(completion)
|
|
47
|
+
sessions[identifier]?.finishedEvents = false
|
|
48
|
+
return token
|
|
49
|
+
}
|
|
50
|
+
let token = UUID()
|
|
51
|
+
sessions[identifier] = Session(token: token, completions: [completion])
|
|
52
|
+
return token
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func finishEvents(_ identifier: String) {
|
|
56
|
+
sessions[identifier]?.finishedEvents = true
|
|
57
|
+
completeIfReady(identifier)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func expire(_ identifier: String, token: UUID) {
|
|
61
|
+
guard sessions[identifier]?.token == token else { return }
|
|
62
|
+
sessions[identifier]?.deadlineReached = true
|
|
63
|
+
completeIfReady(identifier)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private func completeIfReady(_ identifier: String) {
|
|
67
|
+
guard let session = sessions[identifier], session.finishedEvents,
|
|
68
|
+
session.deadlineReached || session.awaitingAcknowledgment.isEmpty else { return }
|
|
69
|
+
sessions.removeValue(forKey: identifier)
|
|
70
|
+
for key in session.awaitingAcknowledgment {
|
|
71
|
+
downloads.removeValue(forKey: key)
|
|
72
|
+
}
|
|
73
|
+
for completion in session.completions {
|
|
74
|
+
completion()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -29,4 +29,15 @@ Pod::Spec.new do |s|
|
|
|
29
29
|
s.resource_bundles = {'ExpoFileSystem_privacy' => ['PrivacyInfo.xcprivacy']}
|
|
30
30
|
|
|
31
31
|
s.source_files = "**/*.{h,m,swift}"
|
|
32
|
+
s.exclude_files = 'Tests/'
|
|
33
|
+
|
|
34
|
+
s.test_spec 'Tests' do |test_spec|
|
|
35
|
+
# ExpoModulesCore requires React-hermes or React-jsc in tests.
|
|
36
|
+
test_spec.dependency 'ExpoModulesTestCore'
|
|
37
|
+
test_spec.source_files = 'Tests/**/*.{m,swift}'
|
|
38
|
+
# Test bundles do not inherit ExpoModulesCore's user_target_xcconfig linker flags.
|
|
39
|
+
test_spec.pod_target_xcconfig = {
|
|
40
|
+
'OTHER_LDFLAGS' => '$(inherited) -lc++'
|
|
41
|
+
}
|
|
42
|
+
end
|
|
32
43
|
end
|