@adriansteffan/reactive 0.2.3 → 0.2.5
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/dist/{mod-kduyZSvT.js → mod-CHZCELgX.js} +3454 -3450
- package/dist/mod.d.ts +2 -0
- package/dist/reactive.es.js +1 -1
- package/dist/reactive.umd.js +615 -615
- package/dist/{web-BDKz297R.js → web-BNJX4siP.js} +1 -1
- package/dist/{web-Cng80F8T.js → web-DabPva5b.js} +1 -1
- package/package.json +1 -1
- package/src/components/upload.tsx +14 -8
- package/src/utils/common.ts +2 -0
- package/src/utils/upload.ts +9 -10
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
Store,
|
|
13
13
|
TrialData,
|
|
14
14
|
} from '../utils/common';
|
|
15
|
-
import { BlobWriter, TextReader, ZipWriter } from '@zip.js/zip.js';
|
|
15
|
+
import { BlobReader, BlobWriter, TextReader, ZipWriter } from '@zip.js/zip.js';
|
|
16
16
|
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
|
17
17
|
import { buildUploadFiles, convertArrayOfObjectsToCSV } from '../utils/upload';
|
|
18
18
|
import { registerSimulation, getBackendUrl, getInitialParticipant } from '../utils/simulation';
|
|
@@ -283,7 +283,12 @@ export default function Upload({
|
|
|
283
283
|
const zipWriter = new ZipWriter(new BlobWriter());
|
|
284
284
|
|
|
285
285
|
for (const file of files) {
|
|
286
|
-
|
|
286
|
+
if (file.encoding === 'base64') {
|
|
287
|
+
const binary = Uint8Array.from(atob(file.content), (c) => c.charCodeAt(0));
|
|
288
|
+
await zipWriter.add(file.filename, new BlobReader(new Blob([binary])));
|
|
289
|
+
} else {
|
|
290
|
+
await zipWriter.add(file.filename, new TextReader(file.content));
|
|
291
|
+
}
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
const blob = await zipWriter.close();
|
|
@@ -318,17 +323,18 @@ export default function Upload({
|
|
|
318
323
|
});
|
|
319
324
|
|
|
320
325
|
try {
|
|
326
|
+
if (shouldDownload) {
|
|
327
|
+
await downloadFiles(files);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Filter out eagerly uploaded files for the server upload (they're already there)
|
|
331
|
+
const filesToUpload = files.filter((f) => !f._alreadyUploaded);
|
|
321
332
|
const payload: UploadPayload = {
|
|
322
333
|
sessionId: sessionIDUpload,
|
|
323
|
-
// Include _uploadId so the backend can rename the eager-upload folder
|
|
324
334
|
...(store?._uploadId && store._uploadId !== sessionIDUpload ? { _uploadId: store._uploadId } : {}),
|
|
325
|
-
files:
|
|
335
|
+
files: filesToUpload.map((file) => ({ ...file, encoding: file.encoding ?? 'utf8' })),
|
|
326
336
|
};
|
|
327
337
|
|
|
328
|
-
if (shouldDownload) {
|
|
329
|
-
await downloadFiles(files);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
338
|
if (!shouldUpload) {
|
|
333
339
|
next({});
|
|
334
340
|
return;
|
package/src/utils/common.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface FileUpload {
|
|
|
36
36
|
filename: string;
|
|
37
37
|
content: string;
|
|
38
38
|
encoding?: 'base64' | 'utf8';
|
|
39
|
+
/** Internal flag: file was already eagerly uploaded, skip in upload but include in download. */
|
|
40
|
+
_alreadyUploaded?: boolean;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export interface ExperimentConfig {
|
package/src/utils/upload.ts
CHANGED
|
@@ -199,16 +199,15 @@ function extractAudioRecordings(data: any[]): FileUpload[] {
|
|
|
199
199
|
const files: FileUpload[] = [];
|
|
200
200
|
|
|
201
201
|
const processRecording = (obj: any, nameHint: string) => {
|
|
202
|
-
if (obj?.type === 'audiorecording') {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
202
|
+
if (obj?.type === 'audiorecording' && obj.data64) {
|
|
203
|
+
const filename = obj._audioPreUploadedFilename ?? generateAudioFilename(nameHint);
|
|
204
|
+
files.push({
|
|
205
|
+
filename,
|
|
206
|
+
content: obj.data64,
|
|
207
|
+
encoding: 'base64' as const,
|
|
208
|
+
_alreadyUploaded: !!obj._audioPreUploaded,
|
|
209
|
+
});
|
|
210
|
+
obj.audioFile = filename;
|
|
212
211
|
delete obj.data64;
|
|
213
212
|
delete obj.blob;
|
|
214
213
|
delete obj.url;
|