@vidtreo/recorder 1.7.5 → 1.7.6
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.d.ts +3 -0
- package/dist/index.js +26 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2260,6 +2260,7 @@ export type VideoUploadOptions = {
|
|
|
2260
2260
|
apiKey: string;
|
|
2261
2261
|
backendUrl: string;
|
|
2262
2262
|
filename?: string;
|
|
2263
|
+
idempotencyKey?: string;
|
|
2263
2264
|
mimeType?: string;
|
|
2264
2265
|
metadata?: Record<string, unknown>;
|
|
2265
2266
|
userMetadata?: Record<string, unknown>;
|
|
@@ -2285,7 +2286,9 @@ export type VideoUploadResult = {
|
|
|
2285
2286
|
export declare class VideoUploadService {
|
|
2286
2287
|
uploadVideo(blob: Blob, options: VideoUploadOptions): Promise<VideoUploadResult>;
|
|
2287
2288
|
private uploadVideoFile;
|
|
2289
|
+
private resolveIdempotencyKey;
|
|
2288
2290
|
private reportProgress;
|
|
2291
|
+
private reportCompletion;
|
|
2289
2292
|
private createUploadBlob;
|
|
2290
2293
|
private resolveUploadMimeType;
|
|
2291
2294
|
private normalizeMimeType;
|
package/dist/index.js
CHANGED
|
@@ -3075,7 +3075,6 @@ var DEFAULT_RETENTION_HOURS = 24;
|
|
|
3075
3075
|
var MAX_RETRIES = 10;
|
|
3076
3076
|
var MILLISECONDS_PER_HOUR = 60 * 60 * 1000;
|
|
3077
3077
|
var ID_PREFIX = "upload-";
|
|
3078
|
-
var ID_RANDOM_LENGTH = 9;
|
|
3079
3078
|
var VERSION_ERROR_NAME = "VersionError";
|
|
3080
3079
|
var ERROR_SCHEMA_MISSING_STORE = "Database schema is missing required object store: pending-uploads";
|
|
3081
3080
|
var ERROR_SCHEMA_MISSING_STATUS_INDEX = "Database schema is missing required index: status";
|
|
@@ -3371,7 +3370,7 @@ class VideoStorageService {
|
|
|
3371
3370
|
});
|
|
3372
3371
|
}
|
|
3373
3372
|
generateUploadId() {
|
|
3374
|
-
return `${ID_PREFIX}${
|
|
3373
|
+
return `${ID_PREFIX}${crypto.randomUUID()}`;
|
|
3375
3374
|
}
|
|
3376
3375
|
executeTransaction(mode, operation) {
|
|
3377
3376
|
if (!this.db) {
|
|
@@ -6312,7 +6311,7 @@ function resolveDeviceError(input) {
|
|
|
6312
6311
|
// package.json
|
|
6313
6312
|
var package_default = {
|
|
6314
6313
|
name: "@vidtreo/recorder",
|
|
6315
|
-
version: "1.7.
|
|
6314
|
+
version: "1.7.6",
|
|
6316
6315
|
type: "module",
|
|
6317
6316
|
description: "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
|
|
6318
6317
|
main: "./dist/index.js",
|
|
@@ -7204,6 +7203,7 @@ class UploadQueueManager {
|
|
|
7204
7203
|
apiKey: upload.apiKey,
|
|
7205
7204
|
backendUrl: upload.backendUrl,
|
|
7206
7205
|
filename: upload.filename,
|
|
7206
|
+
idempotencyKey: upload.id,
|
|
7207
7207
|
mimeType: upload.mimeType,
|
|
7208
7208
|
metadata: upload.metadata,
|
|
7209
7209
|
userMetadata: upload.userMetadata,
|
|
@@ -7286,6 +7286,7 @@ class UploadQueueManager {
|
|
|
7286
7286
|
// src/core/upload/upload-service.ts
|
|
7287
7287
|
var API_UPLOAD_PATH = "/api/v1/videos/upload";
|
|
7288
7288
|
var MIME_TYPE_PARAMETER_SEPARATOR = ";";
|
|
7289
|
+
var MAX_TRANSFER_PROGRESS = 0.99;
|
|
7289
7290
|
var UPLOAD_INACTIVITY_TIMEOUT_MS = 45000;
|
|
7290
7291
|
var UPLOAD_INACTIVITY_ERROR = "Upload stalled after 45 seconds without progress";
|
|
7291
7292
|
|
|
@@ -7297,15 +7298,17 @@ class VideoUploadService {
|
|
|
7297
7298
|
if (!blob.type || blob.type.trim() === "") {
|
|
7298
7299
|
throw new Error("Blob type is required");
|
|
7299
7300
|
}
|
|
7300
|
-
|
|
7301
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.idempotencyKey);
|
|
7302
|
+
return this.uploadVideoFile(blob, options, idempotencyKey);
|
|
7301
7303
|
}
|
|
7302
|
-
uploadVideoFile(blob, options) {
|
|
7304
|
+
uploadVideoFile(blob, options, idempotencyKey) {
|
|
7303
7305
|
return new Promise((resolve, reject) => {
|
|
7304
7306
|
const xhr = new XMLHttpRequest;
|
|
7305
7307
|
const uploadBlob = this.createUploadBlob(blob, options.mimeType);
|
|
7306
7308
|
let inactivityTimeoutId = null;
|
|
7307
7309
|
let isSettled = false;
|
|
7308
7310
|
let loadedBytes = 0;
|
|
7311
|
+
let totalBytes = 0;
|
|
7309
7312
|
const clearInactivityTimeout = () => {
|
|
7310
7313
|
if (inactivityTimeoutId === null) {
|
|
7311
7314
|
return;
|
|
@@ -7330,6 +7333,7 @@ class VideoUploadService {
|
|
|
7330
7333
|
}
|
|
7331
7334
|
isSettled = true;
|
|
7332
7335
|
clearInactivityTimeout();
|
|
7336
|
+
this.reportCompletion(options, loadedBytes, totalBytes);
|
|
7333
7337
|
resolve(result);
|
|
7334
7338
|
};
|
|
7335
7339
|
const restartInactivityTimeout = () => {
|
|
@@ -7344,6 +7348,7 @@ class VideoUploadService {
|
|
|
7344
7348
|
return;
|
|
7345
7349
|
}
|
|
7346
7350
|
loadedBytes = event.loaded;
|
|
7351
|
+
totalBytes = event.total;
|
|
7347
7352
|
restartInactivityTimeout();
|
|
7348
7353
|
});
|
|
7349
7354
|
xhr.addEventListener("load", () => {
|
|
@@ -7362,6 +7367,7 @@ class VideoUploadService {
|
|
|
7362
7367
|
const url = `${options.backendUrl}${API_UPLOAD_PATH}`;
|
|
7363
7368
|
xhr.open("POST", url);
|
|
7364
7369
|
xhr.setRequestHeader("Authorization", `Bearer ${options.apiKey}`);
|
|
7370
|
+
xhr.setRequestHeader("Idempotency-Key", idempotencyKey);
|
|
7365
7371
|
const formData = new FormData;
|
|
7366
7372
|
formData.append("file", uploadBlob, options.filename);
|
|
7367
7373
|
const metadata = {
|
|
@@ -7376,11 +7382,17 @@ class VideoUploadService {
|
|
|
7376
7382
|
restartInactivityTimeout();
|
|
7377
7383
|
});
|
|
7378
7384
|
}
|
|
7385
|
+
resolveIdempotencyKey(idempotencyKey) {
|
|
7386
|
+
if (idempotencyKey) {
|
|
7387
|
+
return idempotencyKey;
|
|
7388
|
+
}
|
|
7389
|
+
return crypto.randomUUID();
|
|
7390
|
+
}
|
|
7379
7391
|
reportProgress(event, options) {
|
|
7380
7392
|
if (!event.lengthComputable) {
|
|
7381
7393
|
return;
|
|
7382
7394
|
}
|
|
7383
|
-
const progress = event.loaded / event.total;
|
|
7395
|
+
const progress = Math.min(event.loaded / event.total, MAX_TRANSFER_PROGRESS);
|
|
7384
7396
|
options.onProgress?.(progress);
|
|
7385
7397
|
options.onProgressDetails?.({
|
|
7386
7398
|
progress,
|
|
@@ -7388,6 +7400,14 @@ class VideoUploadService {
|
|
|
7388
7400
|
totalBytes: event.total
|
|
7389
7401
|
});
|
|
7390
7402
|
}
|
|
7403
|
+
reportCompletion(options, loadedBytes, totalBytes) {
|
|
7404
|
+
options.onProgress?.(1);
|
|
7405
|
+
options.onProgressDetails?.({
|
|
7406
|
+
progress: 1,
|
|
7407
|
+
loadedBytes,
|
|
7408
|
+
totalBytes
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7391
7411
|
createUploadBlob(blob, mimeType) {
|
|
7392
7412
|
const normalizedMimeType = this.resolveUploadMimeType(blob, mimeType);
|
|
7393
7413
|
if (normalizedMimeType === blob.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vidtreo/recorder",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
|
|
6
6
|
"main": "./dist/index.js",
|