easyproctor-hml 2.7.8 → 2.7.10
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/esm/index.js +78 -53
- package/index.js +78 -53
- package/new-flow/chunk/ChunkStorageService.d.ts +1 -1
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +17 -17
package/esm/index.js
CHANGED
|
@@ -13434,44 +13434,35 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
13434
13434
|
});
|
|
13435
13435
|
}
|
|
13436
13436
|
/**
|
|
13437
|
-
*
|
|
13437
|
+
* Remove vários chunks numa única transação (delete por chave — sem put com buffer).
|
|
13438
13438
|
*/
|
|
13439
|
-
async
|
|
13439
|
+
async deleteChunkIds(chunkIds) {
|
|
13440
|
+
if (chunkIds.length === 0) return;
|
|
13440
13441
|
const db = await this.connect();
|
|
13441
13442
|
return new Promise((resolve, reject) => {
|
|
13442
13443
|
const transaction = db.transaction(_ChunkStorageService.STORE_NAME, "readwrite");
|
|
13443
13444
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
id: chunk.id,
|
|
13453
|
-
proctoringId: chunk.proctoringId,
|
|
13454
|
-
chunkIndex: chunk.chunkIndex,
|
|
13455
|
-
arrayBuffer: _ChunkStorageService.detachedArrayBufferCopy(chunk.arrayBuffer),
|
|
13456
|
-
timestamp: chunk.timestamp,
|
|
13457
|
-
uploaded: 1,
|
|
13458
|
-
mimeType: chunk.mimeType
|
|
13459
|
-
};
|
|
13460
|
-
const putRequest = store.put(updated);
|
|
13461
|
-
putRequest.onsuccess = () => resolve();
|
|
13462
|
-
putRequest.onerror = () => {
|
|
13463
|
-
var _a2;
|
|
13464
|
-
return reject(new Error(`Erro ao marcar chunk como enviado: ${(_a2 = putRequest.error) == null ? void 0 : _a2.message}`));
|
|
13465
|
-
};
|
|
13445
|
+
transaction.oncomplete = () => resolve();
|
|
13446
|
+
transaction.onerror = () => {
|
|
13447
|
+
var _a2, _b;
|
|
13448
|
+
return reject(
|
|
13449
|
+
new Error(
|
|
13450
|
+
`Erro ao remover chunks em lote: ${(_b = (_a2 = transaction.error) == null ? void 0 : _a2.message) != null ? _b : "unknown"}`
|
|
13451
|
+
)
|
|
13452
|
+
);
|
|
13466
13453
|
};
|
|
13467
|
-
|
|
13468
|
-
var _a2;
|
|
13469
|
-
return reject(new Error(`
|
|
13454
|
+
transaction.onabort = () => {
|
|
13455
|
+
var _a2, _b;
|
|
13456
|
+
return reject(new Error(`Remo\xE7\xE3o em lote abortada: ${(_b = (_a2 = transaction.error) == null ? void 0 : _a2.message) != null ? _b : "unknown"}`));
|
|
13470
13457
|
};
|
|
13458
|
+
for (const id of chunkIds) {
|
|
13459
|
+
store.delete(id);
|
|
13460
|
+
}
|
|
13471
13461
|
});
|
|
13472
13462
|
}
|
|
13473
13463
|
/**
|
|
13474
|
-
* Remove
|
|
13464
|
+
* Remove registros com uploaded = 1 (vestígio de versões antigas que faziam put).
|
|
13465
|
+
* Usa openKeyCursor + delete por primaryKey para não materializar o valor (WebKit/iOS).
|
|
13475
13466
|
*/
|
|
13476
13467
|
async clearUploadedChunks(proctoringId2) {
|
|
13477
13468
|
const db = await this.connect();
|
|
@@ -13480,11 +13471,11 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
13480
13471
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
13481
13472
|
const index = store.index("proctoringId_uploaded");
|
|
13482
13473
|
const range = IDBKeyRange.only([proctoringId2, 1]);
|
|
13483
|
-
const request = index.
|
|
13474
|
+
const request = index.openKeyCursor(range);
|
|
13484
13475
|
request.onsuccess = () => {
|
|
13485
13476
|
const cursor = request.result;
|
|
13486
13477
|
if (cursor) {
|
|
13487
|
-
|
|
13478
|
+
store.delete(cursor.primaryKey);
|
|
13488
13479
|
cursor.continue();
|
|
13489
13480
|
} else {
|
|
13490
13481
|
resolve();
|
|
@@ -13506,11 +13497,11 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
13506
13497
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
13507
13498
|
const index = store.index("proctoringId");
|
|
13508
13499
|
const range = IDBKeyRange.only(proctoringId2);
|
|
13509
|
-
const request = index.
|
|
13500
|
+
const request = index.openKeyCursor(range);
|
|
13510
13501
|
request.onsuccess = () => {
|
|
13511
13502
|
const cursor = request.result;
|
|
13512
13503
|
if (cursor) {
|
|
13513
|
-
|
|
13504
|
+
store.delete(cursor.primaryKey);
|
|
13514
13505
|
cursor.continue();
|
|
13515
13506
|
} else {
|
|
13516
13507
|
resolve();
|
|
@@ -13738,7 +13729,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13738
13729
|
* @param isFinal Se true, não alinha a 256KB e fecha a sessão com /TOTAL no header.
|
|
13739
13730
|
*/
|
|
13740
13731
|
async processQueue(isFinal = false) {
|
|
13741
|
-
var _a2, _b, _c2, _d, _e3, _f;
|
|
13732
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
|
|
13742
13733
|
console.log(`[BackgroundUpload] processQueue init`);
|
|
13743
13734
|
if (this.isProcessing) return;
|
|
13744
13735
|
this.isProcessing = true;
|
|
@@ -13760,6 +13751,26 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13760
13751
|
this.isProcessing = false;
|
|
13761
13752
|
return;
|
|
13762
13753
|
}
|
|
13754
|
+
if (pendingChunks.length === 0 && isFinal) {
|
|
13755
|
+
const mimeTypeFallback = (_b = (_a2 = allChunks[allChunks.length - 1]) == null ? void 0 : _a2.mimeType) != null ? _b : "video/webm";
|
|
13756
|
+
try {
|
|
13757
|
+
if (!this.sessionUrl) {
|
|
13758
|
+
this.clearSessionState();
|
|
13759
|
+
return;
|
|
13760
|
+
}
|
|
13761
|
+
const totalBytes = this.currentOffset;
|
|
13762
|
+
await this.uploadData(new ArrayBuffer(0), mimeTypeFallback, 0, totalBytes);
|
|
13763
|
+
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
13764
|
+
this.clearSessionState();
|
|
13765
|
+
} catch (error) {
|
|
13766
|
+
console.error(
|
|
13767
|
+
"[BackgroundUpload] Falha ao finalizar upload (flush sem pendentes):",
|
|
13768
|
+
error
|
|
13769
|
+
);
|
|
13770
|
+
(_c2 = this.onUploadError) == null ? void 0 : _c2.call(this, 0, error);
|
|
13771
|
+
}
|
|
13772
|
+
return;
|
|
13773
|
+
}
|
|
13763
13774
|
console.log(`[BackgroundUpload] ${pendingChunks.length} chunks pendentes encontrados. Modo final: ${isFinal}`);
|
|
13764
13775
|
let virtualStart = this.totalBytesPurged;
|
|
13765
13776
|
const chunksWithMeta = allChunks.map((c3) => {
|
|
@@ -13771,7 +13782,8 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13771
13782
|
const combinedBufferParts = [];
|
|
13772
13783
|
let lastProcessedChunkId = null;
|
|
13773
13784
|
let finalChunkIndex = 0;
|
|
13774
|
-
const mimeType = (
|
|
13785
|
+
const mimeType = (_g = (_f = (_d = pendingChunks[0]) == null ? void 0 : _d.mimeType) != null ? _f : (_e3 = allChunks[allChunks.length - 1]) == null ? void 0 : _e3.mimeType) != null ? _g : "video/webm";
|
|
13786
|
+
console.log(`[BackgroundUpload] passo 1 ok`);
|
|
13775
13787
|
for (const meta of chunksWithMeta) {
|
|
13776
13788
|
if (this.currentOffset > meta.end) continue;
|
|
13777
13789
|
const sliceStart = Math.max(0, this.currentOffset - meta.start);
|
|
@@ -13780,11 +13792,13 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13780
13792
|
lastProcessedChunkId = meta.chunk.id;
|
|
13781
13793
|
finalChunkIndex = meta.chunk.chunkIndex;
|
|
13782
13794
|
}
|
|
13795
|
+
console.log(`[BackgroundUpload] passo 2 ok`);
|
|
13783
13796
|
if (combinedBufferParts.length === 0 && !isFinal) {
|
|
13784
13797
|
this.isProcessing = false;
|
|
13785
13798
|
return;
|
|
13786
13799
|
}
|
|
13787
13800
|
const fullBuffer = _BackgroundUploadService.concatArrayBuffers(combinedBufferParts);
|
|
13801
|
+
console.log(`[BackgroundUpload] passo 3 ok`);
|
|
13788
13802
|
let sendableSize = fullBuffer.byteLength;
|
|
13789
13803
|
let totalSizeForHeader = void 0;
|
|
13790
13804
|
if (!isFinal) {
|
|
@@ -13795,38 +13809,49 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13795
13809
|
return;
|
|
13796
13810
|
}
|
|
13797
13811
|
} else {
|
|
13798
|
-
totalSizeForHeader = virtualStart;
|
|
13812
|
+
totalSizeForHeader = fullBuffer.byteLength > 0 ? virtualStart : Math.max(virtualStart, this.currentOffset);
|
|
13799
13813
|
}
|
|
13814
|
+
console.log(`[BackgroundUpload] passo 4 ok`);
|
|
13800
13815
|
const bufferToSend = sendableSize < fullBuffer.byteLength ? fullBuffer.slice(0, sendableSize) : fullBuffer;
|
|
13801
13816
|
try {
|
|
13802
13817
|
await this.uploadData(bufferToSend, mimeType, finalChunkIndex, totalSizeForHeader);
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13818
|
+
console.log(`[BackgroundUpload] passo 5 ok`);
|
|
13819
|
+
const fullySent = chunksWithMeta.filter(
|
|
13820
|
+
(meta) => meta.chunk.uploaded === 0 && meta.end < this.currentOffset && meta.chunk.id != null
|
|
13821
|
+
);
|
|
13822
|
+
const sizePurged = fullySent.reduce(
|
|
13823
|
+
(acc, meta) => acc + meta.chunk.arrayBuffer.byteLength,
|
|
13824
|
+
0
|
|
13825
|
+
);
|
|
13826
|
+
const idsToDelete = fullySent.map((m3) => m3.chunk.id);
|
|
13827
|
+
if (idsToDelete.length > 0) {
|
|
13828
|
+
await this.chunkStorage.deleteChunkIds(idsToDelete);
|
|
13829
|
+
for (const meta of fullySent) {
|
|
13806
13830
|
this.retryCount.delete(meta.chunk.id);
|
|
13807
|
-
(
|
|
13808
|
-
console.log(
|
|
13831
|
+
(_h = this.onChunkUploaded) == null ? void 0 : _h.call(this, meta.chunk.id, meta.chunk.chunkIndex);
|
|
13832
|
+
console.log(
|
|
13833
|
+
`[BackgroundUpload] Chunk ${meta.chunk.chunkIndex} removido do IndexedDB ap\xF3s upload.`
|
|
13834
|
+
);
|
|
13809
13835
|
}
|
|
13810
13836
|
}
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13837
|
+
console.log(`[BackgroundUpload] passo 6 ok`);
|
|
13838
|
+
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
13839
|
+
console.log(`[BackgroundUpload] passo 7 ok`);
|
|
13840
|
+
if (this.config.cleanAfterUpload && sizePurged > 0) {
|
|
13841
|
+
this.totalBytesPurged += sizePurged;
|
|
13842
|
+
this.saveSessionState();
|
|
13843
|
+
console.log(
|
|
13844
|
+
`[BackgroundUpload] ${sizePurged} bytes limpos do armazenamento local. Total purgado: ${this.totalBytesPurged}`
|
|
13816
13845
|
);
|
|
13817
|
-
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
13818
|
-
if (sizePurged > 0) {
|
|
13819
|
-
this.totalBytesPurged += sizePurged;
|
|
13820
|
-
this.saveSessionState();
|
|
13821
|
-
console.log(`[BackgroundUpload] ${sizePurged} bytes limpos do armazenamento local. Total purgado: ${this.totalBytesPurged}`);
|
|
13822
|
-
}
|
|
13823
13846
|
}
|
|
13847
|
+
console.log(`[BackgroundUpload] passo 8 ok`);
|
|
13824
13848
|
if (isFinal) {
|
|
13825
13849
|
this.clearSessionState();
|
|
13826
13850
|
}
|
|
13851
|
+
console.log(`[BackgroundUpload] passo 9 ok`);
|
|
13827
13852
|
} catch (error) {
|
|
13828
13853
|
console.error("[BackgroundUpload] Falha no upload:", error);
|
|
13829
|
-
(
|
|
13854
|
+
(_i3 = this.onUploadError) == null ? void 0 : _i3.call(this, lastProcessedChunkId || 0, error);
|
|
13830
13855
|
}
|
|
13831
13856
|
} catch (error) {
|
|
13832
13857
|
console.error("[BackgroundUpload] Erro ao processar fila:", error);
|
|
@@ -14447,7 +14472,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
14447
14472
|
* Salva o chunk no IndexedDB para persistência e recuperação.
|
|
14448
14473
|
*/
|
|
14449
14474
|
async handleNewChunk(blob, idx) {
|
|
14450
|
-
if (!this.proctoringId || !this.chunkStorage) return;
|
|
14475
|
+
if (!this.proctoringId || !this.chunkStorage || blob.size == 0) return;
|
|
14451
14476
|
const savePromise = (async () => {
|
|
14452
14477
|
var _a2;
|
|
14453
14478
|
try {
|
package/index.js
CHANGED
|
@@ -31531,44 +31531,35 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
31531
31531
|
});
|
|
31532
31532
|
}
|
|
31533
31533
|
/**
|
|
31534
|
-
*
|
|
31534
|
+
* Remove vários chunks numa única transação (delete por chave — sem put com buffer).
|
|
31535
31535
|
*/
|
|
31536
|
-
async
|
|
31536
|
+
async deleteChunkIds(chunkIds) {
|
|
31537
|
+
if (chunkIds.length === 0) return;
|
|
31537
31538
|
const db = await this.connect();
|
|
31538
31539
|
return new Promise((resolve, reject) => {
|
|
31539
31540
|
const transaction = db.transaction(_ChunkStorageService.STORE_NAME, "readwrite");
|
|
31540
31541
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
31541
|
-
|
|
31542
|
-
|
|
31543
|
-
|
|
31544
|
-
|
|
31545
|
-
|
|
31546
|
-
|
|
31547
|
-
|
|
31548
|
-
|
|
31549
|
-
id: chunk.id,
|
|
31550
|
-
proctoringId: chunk.proctoringId,
|
|
31551
|
-
chunkIndex: chunk.chunkIndex,
|
|
31552
|
-
arrayBuffer: _ChunkStorageService.detachedArrayBufferCopy(chunk.arrayBuffer),
|
|
31553
|
-
timestamp: chunk.timestamp,
|
|
31554
|
-
uploaded: 1,
|
|
31555
|
-
mimeType: chunk.mimeType
|
|
31556
|
-
};
|
|
31557
|
-
const putRequest = store.put(updated);
|
|
31558
|
-
putRequest.onsuccess = () => resolve();
|
|
31559
|
-
putRequest.onerror = () => {
|
|
31560
|
-
var _a2;
|
|
31561
|
-
return reject(new Error(`Erro ao marcar chunk como enviado: ${(_a2 = putRequest.error) == null ? void 0 : _a2.message}`));
|
|
31562
|
-
};
|
|
31542
|
+
transaction.oncomplete = () => resolve();
|
|
31543
|
+
transaction.onerror = () => {
|
|
31544
|
+
var _a2, _b;
|
|
31545
|
+
return reject(
|
|
31546
|
+
new Error(
|
|
31547
|
+
`Erro ao remover chunks em lote: ${(_b = (_a2 = transaction.error) == null ? void 0 : _a2.message) != null ? _b : "unknown"}`
|
|
31548
|
+
)
|
|
31549
|
+
);
|
|
31563
31550
|
};
|
|
31564
|
-
|
|
31565
|
-
var _a2;
|
|
31566
|
-
return reject(new Error(`
|
|
31551
|
+
transaction.onabort = () => {
|
|
31552
|
+
var _a2, _b;
|
|
31553
|
+
return reject(new Error(`Remo\xE7\xE3o em lote abortada: ${(_b = (_a2 = transaction.error) == null ? void 0 : _a2.message) != null ? _b : "unknown"}`));
|
|
31567
31554
|
};
|
|
31555
|
+
for (const id of chunkIds) {
|
|
31556
|
+
store.delete(id);
|
|
31557
|
+
}
|
|
31568
31558
|
});
|
|
31569
31559
|
}
|
|
31570
31560
|
/**
|
|
31571
|
-
* Remove
|
|
31561
|
+
* Remove registros com uploaded = 1 (vestígio de versões antigas que faziam put).
|
|
31562
|
+
* Usa openKeyCursor + delete por primaryKey para não materializar o valor (WebKit/iOS).
|
|
31572
31563
|
*/
|
|
31573
31564
|
async clearUploadedChunks(proctoringId2) {
|
|
31574
31565
|
const db = await this.connect();
|
|
@@ -31577,11 +31568,11 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
31577
31568
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
31578
31569
|
const index = store.index("proctoringId_uploaded");
|
|
31579
31570
|
const range = IDBKeyRange.only([proctoringId2, 1]);
|
|
31580
|
-
const request = index.
|
|
31571
|
+
const request = index.openKeyCursor(range);
|
|
31581
31572
|
request.onsuccess = () => {
|
|
31582
31573
|
const cursor = request.result;
|
|
31583
31574
|
if (cursor) {
|
|
31584
|
-
|
|
31575
|
+
store.delete(cursor.primaryKey);
|
|
31585
31576
|
cursor.continue();
|
|
31586
31577
|
} else {
|
|
31587
31578
|
resolve();
|
|
@@ -31603,11 +31594,11 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
31603
31594
|
const store = transaction.objectStore(_ChunkStorageService.STORE_NAME);
|
|
31604
31595
|
const index = store.index("proctoringId");
|
|
31605
31596
|
const range = IDBKeyRange.only(proctoringId2);
|
|
31606
|
-
const request = index.
|
|
31597
|
+
const request = index.openKeyCursor(range);
|
|
31607
31598
|
request.onsuccess = () => {
|
|
31608
31599
|
const cursor = request.result;
|
|
31609
31600
|
if (cursor) {
|
|
31610
|
-
|
|
31601
|
+
store.delete(cursor.primaryKey);
|
|
31611
31602
|
cursor.continue();
|
|
31612
31603
|
} else {
|
|
31613
31604
|
resolve();
|
|
@@ -31835,7 +31826,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31835
31826
|
* @param isFinal Se true, não alinha a 256KB e fecha a sessão com /TOTAL no header.
|
|
31836
31827
|
*/
|
|
31837
31828
|
async processQueue(isFinal = false) {
|
|
31838
|
-
var _a2, _b, _c2, _d, _e3, _f;
|
|
31829
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
|
|
31839
31830
|
console.log(`[BackgroundUpload] processQueue init`);
|
|
31840
31831
|
if (this.isProcessing) return;
|
|
31841
31832
|
this.isProcessing = true;
|
|
@@ -31857,6 +31848,26 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31857
31848
|
this.isProcessing = false;
|
|
31858
31849
|
return;
|
|
31859
31850
|
}
|
|
31851
|
+
if (pendingChunks.length === 0 && isFinal) {
|
|
31852
|
+
const mimeTypeFallback = (_b = (_a2 = allChunks[allChunks.length - 1]) == null ? void 0 : _a2.mimeType) != null ? _b : "video/webm";
|
|
31853
|
+
try {
|
|
31854
|
+
if (!this.sessionUrl) {
|
|
31855
|
+
this.clearSessionState();
|
|
31856
|
+
return;
|
|
31857
|
+
}
|
|
31858
|
+
const totalBytes = this.currentOffset;
|
|
31859
|
+
await this.uploadData(new ArrayBuffer(0), mimeTypeFallback, 0, totalBytes);
|
|
31860
|
+
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
31861
|
+
this.clearSessionState();
|
|
31862
|
+
} catch (error) {
|
|
31863
|
+
console.error(
|
|
31864
|
+
"[BackgroundUpload] Falha ao finalizar upload (flush sem pendentes):",
|
|
31865
|
+
error
|
|
31866
|
+
);
|
|
31867
|
+
(_c2 = this.onUploadError) == null ? void 0 : _c2.call(this, 0, error);
|
|
31868
|
+
}
|
|
31869
|
+
return;
|
|
31870
|
+
}
|
|
31860
31871
|
console.log(`[BackgroundUpload] ${pendingChunks.length} chunks pendentes encontrados. Modo final: ${isFinal}`);
|
|
31861
31872
|
let virtualStart = this.totalBytesPurged;
|
|
31862
31873
|
const chunksWithMeta = allChunks.map((c3) => {
|
|
@@ -31868,7 +31879,8 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31868
31879
|
const combinedBufferParts = [];
|
|
31869
31880
|
let lastProcessedChunkId = null;
|
|
31870
31881
|
let finalChunkIndex = 0;
|
|
31871
|
-
const mimeType = (
|
|
31882
|
+
const mimeType = (_g = (_f = (_d = pendingChunks[0]) == null ? void 0 : _d.mimeType) != null ? _f : (_e3 = allChunks[allChunks.length - 1]) == null ? void 0 : _e3.mimeType) != null ? _g : "video/webm";
|
|
31883
|
+
console.log(`[BackgroundUpload] passo 1 ok`);
|
|
31872
31884
|
for (const meta of chunksWithMeta) {
|
|
31873
31885
|
if (this.currentOffset > meta.end) continue;
|
|
31874
31886
|
const sliceStart = Math.max(0, this.currentOffset - meta.start);
|
|
@@ -31877,11 +31889,13 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31877
31889
|
lastProcessedChunkId = meta.chunk.id;
|
|
31878
31890
|
finalChunkIndex = meta.chunk.chunkIndex;
|
|
31879
31891
|
}
|
|
31892
|
+
console.log(`[BackgroundUpload] passo 2 ok`);
|
|
31880
31893
|
if (combinedBufferParts.length === 0 && !isFinal) {
|
|
31881
31894
|
this.isProcessing = false;
|
|
31882
31895
|
return;
|
|
31883
31896
|
}
|
|
31884
31897
|
const fullBuffer = _BackgroundUploadService.concatArrayBuffers(combinedBufferParts);
|
|
31898
|
+
console.log(`[BackgroundUpload] passo 3 ok`);
|
|
31885
31899
|
let sendableSize = fullBuffer.byteLength;
|
|
31886
31900
|
let totalSizeForHeader = void 0;
|
|
31887
31901
|
if (!isFinal) {
|
|
@@ -31892,38 +31906,49 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31892
31906
|
return;
|
|
31893
31907
|
}
|
|
31894
31908
|
} else {
|
|
31895
|
-
totalSizeForHeader = virtualStart;
|
|
31909
|
+
totalSizeForHeader = fullBuffer.byteLength > 0 ? virtualStart : Math.max(virtualStart, this.currentOffset);
|
|
31896
31910
|
}
|
|
31911
|
+
console.log(`[BackgroundUpload] passo 4 ok`);
|
|
31897
31912
|
const bufferToSend = sendableSize < fullBuffer.byteLength ? fullBuffer.slice(0, sendableSize) : fullBuffer;
|
|
31898
31913
|
try {
|
|
31899
31914
|
await this.uploadData(bufferToSend, mimeType, finalChunkIndex, totalSizeForHeader);
|
|
31900
|
-
|
|
31901
|
-
|
|
31902
|
-
|
|
31915
|
+
console.log(`[BackgroundUpload] passo 5 ok`);
|
|
31916
|
+
const fullySent = chunksWithMeta.filter(
|
|
31917
|
+
(meta) => meta.chunk.uploaded === 0 && meta.end < this.currentOffset && meta.chunk.id != null
|
|
31918
|
+
);
|
|
31919
|
+
const sizePurged = fullySent.reduce(
|
|
31920
|
+
(acc, meta) => acc + meta.chunk.arrayBuffer.byteLength,
|
|
31921
|
+
0
|
|
31922
|
+
);
|
|
31923
|
+
const idsToDelete = fullySent.map((m3) => m3.chunk.id);
|
|
31924
|
+
if (idsToDelete.length > 0) {
|
|
31925
|
+
await this.chunkStorage.deleteChunkIds(idsToDelete);
|
|
31926
|
+
for (const meta of fullySent) {
|
|
31903
31927
|
this.retryCount.delete(meta.chunk.id);
|
|
31904
|
-
(
|
|
31905
|
-
console.log(
|
|
31928
|
+
(_h = this.onChunkUploaded) == null ? void 0 : _h.call(this, meta.chunk.id, meta.chunk.chunkIndex);
|
|
31929
|
+
console.log(
|
|
31930
|
+
`[BackgroundUpload] Chunk ${meta.chunk.chunkIndex} removido do IndexedDB ap\xF3s upload.`
|
|
31931
|
+
);
|
|
31906
31932
|
}
|
|
31907
31933
|
}
|
|
31908
|
-
|
|
31909
|
-
|
|
31910
|
-
|
|
31911
|
-
|
|
31912
|
-
|
|
31934
|
+
console.log(`[BackgroundUpload] passo 6 ok`);
|
|
31935
|
+
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
31936
|
+
console.log(`[BackgroundUpload] passo 7 ok`);
|
|
31937
|
+
if (this.config.cleanAfterUpload && sizePurged > 0) {
|
|
31938
|
+
this.totalBytesPurged += sizePurged;
|
|
31939
|
+
this.saveSessionState();
|
|
31940
|
+
console.log(
|
|
31941
|
+
`[BackgroundUpload] ${sizePurged} bytes limpos do armazenamento local. Total purgado: ${this.totalBytesPurged}`
|
|
31913
31942
|
);
|
|
31914
|
-
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
31915
|
-
if (sizePurged > 0) {
|
|
31916
|
-
this.totalBytesPurged += sizePurged;
|
|
31917
|
-
this.saveSessionState();
|
|
31918
|
-
console.log(`[BackgroundUpload] ${sizePurged} bytes limpos do armazenamento local. Total purgado: ${this.totalBytesPurged}`);
|
|
31919
|
-
}
|
|
31920
31943
|
}
|
|
31944
|
+
console.log(`[BackgroundUpload] passo 8 ok`);
|
|
31921
31945
|
if (isFinal) {
|
|
31922
31946
|
this.clearSessionState();
|
|
31923
31947
|
}
|
|
31948
|
+
console.log(`[BackgroundUpload] passo 9 ok`);
|
|
31924
31949
|
} catch (error) {
|
|
31925
31950
|
console.error("[BackgroundUpload] Falha no upload:", error);
|
|
31926
|
-
(
|
|
31951
|
+
(_i3 = this.onUploadError) == null ? void 0 : _i3.call(this, lastProcessedChunkId || 0, error);
|
|
31927
31952
|
}
|
|
31928
31953
|
} catch (error) {
|
|
31929
31954
|
console.error("[BackgroundUpload] Erro ao processar fila:", error);
|
|
@@ -32544,7 +32569,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32544
32569
|
* Salva o chunk no IndexedDB para persistência e recuperação.
|
|
32545
32570
|
*/
|
|
32546
32571
|
async handleNewChunk(blob, idx) {
|
|
32547
|
-
if (!this.proctoringId || !this.chunkStorage) return;
|
|
32572
|
+
if (!this.proctoringId || !this.chunkStorage || blob.size == 0) return;
|
|
32548
32573
|
const savePromise = (async () => {
|
|
32549
32574
|
var _a2;
|
|
32550
32575
|
try {
|
|
@@ -17,7 +17,7 @@ export declare class ChunkStorageService {
|
|
|
17
17
|
saveChunk(chunk: Omit<VideoChunk, "id">): Promise<number>;
|
|
18
18
|
getPendingChunks(proctoringId: string): Promise<VideoChunk[]>;
|
|
19
19
|
getAllChunks(proctoringId: string): Promise<VideoChunk[]>;
|
|
20
|
-
|
|
20
|
+
deleteChunkIds(chunkIds: number[]): Promise<void>;
|
|
21
21
|
clearUploadedChunks(proctoringId: string): Promise<void>;
|
|
22
22
|
clearAllChunks(proctoringId: string): Promise<void>;
|
|
23
23
|
hasAnyPendingChunks(): Promise<boolean>;
|