@streamscloud/kit 0.37.0 → 0.38.0
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.
|
@@ -9,6 +9,12 @@ export type AddOptions = {
|
|
|
9
9
|
/** Stage an object URL for local preview. @default 'never' */
|
|
10
10
|
preview?: UploadPreviewMode;
|
|
11
11
|
};
|
|
12
|
+
export type UploadOutcome = {
|
|
13
|
+
/** Files whose upload ended in error, at the moment this call settled. */
|
|
14
|
+
failed: FailedUpload[];
|
|
15
|
+
/** Files that reached `success`. */
|
|
16
|
+
succeeded: SuccessfulUpload[];
|
|
17
|
+
};
|
|
12
18
|
export type UploadMediaStoreOptions = {
|
|
13
19
|
/**
|
|
14
20
|
* Auto-resize images before upload. Pass `false` to disable; pass an object to override the
|
|
@@ -47,7 +53,8 @@ export type UploadMediaStoreOptions = {
|
|
|
47
53
|
* on: { blobId: (f, id) => { avatarBlobId = id; } }
|
|
48
54
|
* });
|
|
49
55
|
* store.add(rawFile);
|
|
50
|
-
* await store.upload();
|
|
56
|
+
* const { failed } = await store.upload();
|
|
57
|
+
* if (failed.length > 0) { ... }
|
|
51
58
|
* ```
|
|
52
59
|
*/
|
|
53
60
|
export declare class UploadMediaStore {
|
|
@@ -94,7 +101,8 @@ export declare class UploadMediaStore {
|
|
|
94
101
|
* itself in `AppUploadActivity` for its duration, so a mounted `UploadProgressToaster` picks it up
|
|
95
102
|
* with no extra wiring.
|
|
96
103
|
*/
|
|
97
|
-
upload(): Promise<
|
|
104
|
+
upload(): Promise<UploadOutcome>;
|
|
105
|
+
private outcome;
|
|
98
106
|
private settled;
|
|
99
107
|
private runQueued;
|
|
100
108
|
private maybeResize;
|
|
@@ -29,7 +29,8 @@ const revokePreviewUrl = (file) => {
|
|
|
29
29
|
* on: { blobId: (f, id) => { avatarBlobId = id; } }
|
|
30
30
|
* });
|
|
31
31
|
* store.add(rawFile);
|
|
32
|
-
* await store.upload();
|
|
32
|
+
* const { failed } = await store.upload();
|
|
33
|
+
* if (failed.length > 0) { ... }
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
36
|
export class UploadMediaStore {
|
|
@@ -89,7 +90,7 @@ export class UploadMediaStore {
|
|
|
89
90
|
const queued = this._files.filter((f) => f.status === 'queued');
|
|
90
91
|
if (queued.length === 0) {
|
|
91
92
|
await this.settled();
|
|
92
|
-
return;
|
|
93
|
+
return this.outcome();
|
|
93
94
|
}
|
|
94
95
|
// Claim before the first await, or a second upload() during the strategy call re-claims the same files.
|
|
95
96
|
for (const entry of queued) {
|
|
@@ -109,6 +110,13 @@ export class UploadMediaStore {
|
|
|
109
110
|
})();
|
|
110
111
|
this._inFlight.set(runId, run);
|
|
111
112
|
await this.settled();
|
|
113
|
+
return this.outcome();
|
|
114
|
+
}
|
|
115
|
+
outcome() {
|
|
116
|
+
return {
|
|
117
|
+
failed: this._files.filter((f) => f.status === 'error'),
|
|
118
|
+
succeeded: this._files.filter((f) => f.status === 'success')
|
|
119
|
+
};
|
|
112
120
|
}
|
|
113
121
|
async settled() {
|
|
114
122
|
while (this._inFlight.size > 0) {
|