recappi 0.1.63 → 0.1.64
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/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -19296,6 +19296,13 @@ var RecappiApiClient = class {
|
|
|
19296
19296
|
for (const filePath of files) {
|
|
19297
19297
|
attemptedCount += 1;
|
|
19298
19298
|
try {
|
|
19299
|
+
opts.onEvent?.({
|
|
19300
|
+
type: "progress",
|
|
19301
|
+
command: "upload",
|
|
19302
|
+
filePath,
|
|
19303
|
+
status: "checking_audio",
|
|
19304
|
+
message: `Checking ${filePath}`
|
|
19305
|
+
});
|
|
19299
19306
|
const plan = await planAudioFile(filePath, files.length === 1 ? opts.title : void 0);
|
|
19300
19307
|
const result = await this.uploadFile(plan, opts);
|
|
19301
19308
|
successes.push(result);
|
|
@@ -19338,10 +19345,19 @@ var RecappiApiClient = class {
|
|
|
19338
19345
|
async uploadFile(plan, opts) {
|
|
19339
19346
|
const relative = plan.filePath;
|
|
19340
19347
|
opts.onEvent?.({
|
|
19341
|
-
type: "
|
|
19348
|
+
type: "progress",
|
|
19342
19349
|
command: "upload",
|
|
19343
19350
|
filePath: relative,
|
|
19344
|
-
|
|
19351
|
+
status: "starting_upload",
|
|
19352
|
+
message: `Starting upload ${relative}`,
|
|
19353
|
+
data: {
|
|
19354
|
+
file: {
|
|
19355
|
+
title: plan.title,
|
|
19356
|
+
contentType: plan.contentType,
|
|
19357
|
+
sizeBytes: plan.sizeBytes,
|
|
19358
|
+
...plan.durationMs ? { durationMs: plan.durationMs } : {}
|
|
19359
|
+
}
|
|
19360
|
+
}
|
|
19345
19361
|
});
|
|
19346
19362
|
const init = await this.postJson("/api/recordings", {
|
|
19347
19363
|
title: plan.title,
|
|
@@ -20622,8 +20638,7 @@ function formatHumanProgress(event, opts) {
|
|
|
20622
20638
|
const scope = progressScope(event);
|
|
20623
20639
|
let line;
|
|
20624
20640
|
if (event.type === "started") {
|
|
20625
|
-
|
|
20626
|
-
line = label ? `Preparing ${label}` : "Preparing upload";
|
|
20641
|
+
line = event.message;
|
|
20627
20642
|
} else if (event.command === "upload") {
|
|
20628
20643
|
line = formatUploadProgress(event, opts, scope);
|
|
20629
20644
|
} else if (event.command === "jobs wait") {
|
|
@@ -20639,13 +20654,20 @@ function formatHumanProgress(event, opts) {
|
|
|
20639
20654
|
return line;
|
|
20640
20655
|
}
|
|
20641
20656
|
function formatUploadProgress(event, opts, scope) {
|
|
20657
|
+
const label = event.filePath ? humanFileLabel(event.filePath) : void 0;
|
|
20658
|
+
if (event.status === "checking_audio") {
|
|
20659
|
+
return label ? `Checking ${label}` : "Checking audio file";
|
|
20660
|
+
}
|
|
20661
|
+
if (event.status === "starting_upload") {
|
|
20662
|
+
return label ? `Starting upload ${label}` : "Starting upload";
|
|
20663
|
+
}
|
|
20642
20664
|
if (event.status === "uploading" && typeof event.percent === "number") {
|
|
20643
20665
|
const state = opts.progress;
|
|
20644
20666
|
const bucket = Math.min(100, Math.max(0, Math.floor(event.percent / 10) * 10));
|
|
20645
20667
|
const previous = state?.lastUploadBucketByScope.get(scope);
|
|
20646
20668
|
if (previous !== void 0 && bucket <= previous && bucket !== 100) return void 0;
|
|
20647
20669
|
state?.lastUploadBucketByScope.set(scope, bucket);
|
|
20648
|
-
return `Uploading${
|
|
20670
|
+
return `Uploading${label ? ` ${label}` : ""}: ${event.percent}%`;
|
|
20649
20671
|
}
|
|
20650
20672
|
if (event.status === "finishing_upload") return "Finalizing upload";
|
|
20651
20673
|
if (event.status === "uploaded") {
|