easyproctor-hml 2.7.6 → 2.7.7
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 +43 -34
- package/index.js +43 -34
- package/new-flow/chunk/BackgroundUploadService.d.ts +1 -0
- package/new-flow/chunk/ChunkStorageService.d.ts +1 -1
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +32 -32
package/esm/index.js
CHANGED
|
@@ -13551,8 +13551,8 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
13551
13551
|
}
|
|
13552
13552
|
};
|
|
13553
13553
|
_ChunkStorageService.DB_NAME = "EasyProctorChunksDb";
|
|
13554
|
-
/**
|
|
13555
|
-
_ChunkStorageService.DB_VERSION =
|
|
13554
|
+
/** v2: índices numéricos; v3: payload em ArrayBuffer (Safari/iOS com Blob no IDB) */
|
|
13555
|
+
_ChunkStorageService.DB_VERSION = 3;
|
|
13556
13556
|
_ChunkStorageService.STORE_NAME = "chunks";
|
|
13557
13557
|
var ChunkStorageService = _ChunkStorageService;
|
|
13558
13558
|
|
|
@@ -13712,7 +13712,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13712
13712
|
* @param isFinal Se true, não alinha a 256KB e fecha a sessão com /TOTAL no header.
|
|
13713
13713
|
*/
|
|
13714
13714
|
async processQueue(isFinal = false) {
|
|
13715
|
-
var _a2, _b;
|
|
13715
|
+
var _a2, _b, _c2, _d, _e3, _f;
|
|
13716
13716
|
if (this.isProcessing) return;
|
|
13717
13717
|
this.isProcessing = true;
|
|
13718
13718
|
try {
|
|
@@ -13735,31 +13735,31 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13735
13735
|
let virtualStart = this.totalBytesPurged;
|
|
13736
13736
|
const chunksWithMeta = allChunks.map((c3) => {
|
|
13737
13737
|
const start = virtualStart;
|
|
13738
|
-
const end = start + c3.
|
|
13739
|
-
virtualStart += c3.
|
|
13738
|
+
const end = start + c3.arrayBuffer.byteLength - 1;
|
|
13739
|
+
virtualStart += c3.arrayBuffer.byteLength;
|
|
13740
13740
|
return { chunk: c3, start, end };
|
|
13741
13741
|
});
|
|
13742
|
-
|
|
13742
|
+
const combinedBufferParts = [];
|
|
13743
13743
|
let lastProcessedChunkId = null;
|
|
13744
13744
|
let finalChunkIndex = 0;
|
|
13745
|
-
|
|
13745
|
+
const mimeType = (_d = (_c2 = (_a2 = pendingChunks[0]) == null ? void 0 : _a2.mimeType) != null ? _c2 : (_b = allChunks[allChunks.length - 1]) == null ? void 0 : _b.mimeType) != null ? _d : "video/webm";
|
|
13746
13746
|
for (const meta of chunksWithMeta) {
|
|
13747
13747
|
if (this.currentOffset > meta.end) continue;
|
|
13748
13748
|
const sliceStart = Math.max(0, this.currentOffset - meta.start);
|
|
13749
|
-
const chunkSlice = meta.chunk.
|
|
13750
|
-
|
|
13749
|
+
const chunkSlice = meta.chunk.arrayBuffer.slice(sliceStart);
|
|
13750
|
+
combinedBufferParts.push(chunkSlice);
|
|
13751
13751
|
lastProcessedChunkId = meta.chunk.id;
|
|
13752
13752
|
finalChunkIndex = meta.chunk.chunkIndex;
|
|
13753
13753
|
}
|
|
13754
|
-
if (
|
|
13754
|
+
if (combinedBufferParts.length === 0 && !isFinal) {
|
|
13755
13755
|
this.isProcessing = false;
|
|
13756
13756
|
return;
|
|
13757
13757
|
}
|
|
13758
|
-
|
|
13759
|
-
let sendableSize =
|
|
13758
|
+
const fullBuffer = _BackgroundUploadService.concatArrayBuffers(combinedBufferParts);
|
|
13759
|
+
let sendableSize = fullBuffer.byteLength;
|
|
13760
13760
|
let totalSizeForHeader = void 0;
|
|
13761
13761
|
if (!isFinal) {
|
|
13762
|
-
sendableSize = Math.floor(
|
|
13762
|
+
sendableSize = Math.floor(fullBuffer.byteLength / this.GCS_CHUNK_SIZE) * this.GCS_CHUNK_SIZE;
|
|
13763
13763
|
if (sendableSize === 0) {
|
|
13764
13764
|
console.log("[BackgroundUpload] Dados insuficientes para atingir 256KB. Aguardando novo chunk...");
|
|
13765
13765
|
this.isProcessing = false;
|
|
@@ -13768,20 +13768,23 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13768
13768
|
} else {
|
|
13769
13769
|
totalSizeForHeader = virtualStart;
|
|
13770
13770
|
}
|
|
13771
|
-
const
|
|
13771
|
+
const bufferToSend = sendableSize < fullBuffer.byteLength ? fullBuffer.slice(0, sendableSize) : fullBuffer;
|
|
13772
13772
|
try {
|
|
13773
|
-
await this.uploadData(
|
|
13773
|
+
await this.uploadData(bufferToSend, mimeType, finalChunkIndex, totalSizeForHeader);
|
|
13774
13774
|
for (const meta of chunksWithMeta) {
|
|
13775
13775
|
if (meta.chunk.uploaded === 0 && meta.end < this.currentOffset) {
|
|
13776
13776
|
await this.chunkStorage.markAsUploaded(meta.chunk.id);
|
|
13777
13777
|
this.retryCount.delete(meta.chunk.id);
|
|
13778
|
-
(
|
|
13778
|
+
(_e3 = this.onChunkUploaded) == null ? void 0 : _e3.call(this, meta.chunk.id, meta.chunk.chunkIndex);
|
|
13779
13779
|
console.log(`[BackgroundUpload] Chunk ${meta.chunk.chunkIndex} marcado como enviado.`);
|
|
13780
13780
|
}
|
|
13781
13781
|
}
|
|
13782
13782
|
if (this.config.cleanAfterUpload) {
|
|
13783
13783
|
const chunksToClear = chunksWithMeta.filter((meta) => meta.chunk.uploaded === 1 || meta.chunk.uploaded === 0 && meta.end < this.currentOffset);
|
|
13784
|
-
const sizePurged = chunksToClear.reduce(
|
|
13784
|
+
const sizePurged = chunksToClear.reduce(
|
|
13785
|
+
(acc, meta) => acc + meta.chunk.arrayBuffer.byteLength,
|
|
13786
|
+
0
|
|
13787
|
+
);
|
|
13785
13788
|
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
13786
13789
|
if (sizePurged > 0) {
|
|
13787
13790
|
this.totalBytesPurged += sizePurged;
|
|
@@ -13794,7 +13797,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13794
13797
|
}
|
|
13795
13798
|
} catch (error) {
|
|
13796
13799
|
console.error("[BackgroundUpload] Falha no upload:", error);
|
|
13797
|
-
(
|
|
13800
|
+
(_f = this.onUploadError) == null ? void 0 : _f.call(this, lastProcessedChunkId || 0, error);
|
|
13798
13801
|
}
|
|
13799
13802
|
} catch (error) {
|
|
13800
13803
|
console.error("[BackgroundUpload] Erro ao processar fila:", error);
|
|
@@ -13805,7 +13808,18 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13805
13808
|
/**
|
|
13806
13809
|
* Faz o upload bruto de dados para a sessão GCS.
|
|
13807
13810
|
*/
|
|
13808
|
-
|
|
13811
|
+
static concatArrayBuffers(parts) {
|
|
13812
|
+
if (parts.length === 0) return new ArrayBuffer(0);
|
|
13813
|
+
const total = parts.reduce((sum, p3) => sum + p3.byteLength, 0);
|
|
13814
|
+
const merged = new Uint8Array(total);
|
|
13815
|
+
let offset = 0;
|
|
13816
|
+
for (const p3 of parts) {
|
|
13817
|
+
merged.set(new Uint8Array(p3), offset);
|
|
13818
|
+
offset += p3.byteLength;
|
|
13819
|
+
}
|
|
13820
|
+
return merged.buffer.byteLength === total ? merged.buffer : merged.buffer.slice(merged.byteOffset, merged.byteOffset + merged.byteLength);
|
|
13821
|
+
}
|
|
13822
|
+
async uploadData(data, mimeType, chunkIndex, totalSize) {
|
|
13809
13823
|
const fileName = `EP_${this.proctoringId}_camera_0.webm`;
|
|
13810
13824
|
if (!this.sessionUrl) {
|
|
13811
13825
|
const initiateUrl = await this.backend.initiateUpload(this.token, `${this.proctoringId}/${fileName}`, mimeType);
|
|
@@ -13837,15 +13851,16 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13837
13851
|
console.log(`[BackgroundUpload] Usando sess\xE3o GCS existente: ${this.sessionUrl}`);
|
|
13838
13852
|
}
|
|
13839
13853
|
const start = this.currentOffset;
|
|
13840
|
-
const end = start +
|
|
13854
|
+
const end = start + data.byteLength - 1;
|
|
13841
13855
|
const totalHeader = totalSize !== void 0 ? totalSize.toString() : "*";
|
|
13842
|
-
const contentRangeHeader =
|
|
13843
|
-
console.log(
|
|
13856
|
+
const contentRangeHeader = data.byteLength === 0 && totalSize !== void 0 ? `bytes */${totalHeader}` : `bytes ${start}-${end}/${totalHeader}`;
|
|
13857
|
+
console.log(
|
|
13858
|
+
`[BackgroundUpload] Enviando ${data.byteLength > 0 ? "dados" : "finaliza\xE7\xE3o"}: ${contentRangeHeader} (Size: ${data.byteLength})`
|
|
13859
|
+
);
|
|
13844
13860
|
const response = await fetch(this.sessionUrl, {
|
|
13845
13861
|
method: "PUT",
|
|
13846
13862
|
headers: { "Content-Range": contentRangeHeader },
|
|
13847
|
-
body:
|
|
13848
|
-
// Usa null para garantir corpo vazio se necessário
|
|
13863
|
+
body: data.byteLength > 0 ? data : null
|
|
13849
13864
|
});
|
|
13850
13865
|
console.log(`[BackgroundUpload] Resposta GCS (uploadData): ${response.status}`);
|
|
13851
13866
|
if (response.status !== 200 && response.status !== 201 && response.status !== 308) {
|
|
@@ -13858,13 +13873,13 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
13858
13873
|
const lastByte = parseInt(rangeHeader.split("-")[1], 10);
|
|
13859
13874
|
this.currentOffset = lastByte + 1;
|
|
13860
13875
|
} else {
|
|
13861
|
-
this.currentOffset +=
|
|
13876
|
+
this.currentOffset += data.byteLength;
|
|
13862
13877
|
}
|
|
13863
13878
|
this.saveSessionState();
|
|
13864
13879
|
trackers.registerUploadFile(
|
|
13865
13880
|
this.proctoringId,
|
|
13866
13881
|
`GCS Stream Upload
|
|
13867
|
-
Size: ${
|
|
13882
|
+
Size: ${data.byteLength}
|
|
13868
13883
|
Range: ${start}-${end}
|
|
13869
13884
|
Last Index: ${chunkIndex}`,
|
|
13870
13885
|
"CameraChunk"
|
|
@@ -14407,10 +14422,11 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
14407
14422
|
const savePromise = (async () => {
|
|
14408
14423
|
var _a2;
|
|
14409
14424
|
try {
|
|
14425
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
14410
14426
|
await this.chunkStorage.saveChunk({
|
|
14411
14427
|
proctoringId: this.proctoringId,
|
|
14412
14428
|
chunkIndex: this.chunkIndex,
|
|
14413
|
-
|
|
14429
|
+
arrayBuffer,
|
|
14414
14430
|
timestamp: Date.now(),
|
|
14415
14431
|
uploaded: 0,
|
|
14416
14432
|
mimeType: ((_a2 = this.recorderOptions) == null ? void 0 : _a2.mimeType) || "video/webm"
|
|
@@ -23730,15 +23746,11 @@ Error: ${error}`
|
|
|
23730
23746
|
await this.recorder.stopAll();
|
|
23731
23747
|
this.spyCam && this.spyCam.stopCheckSpyCam();
|
|
23732
23748
|
this.appChecker && await this.appChecker.disconnectWebSocket();
|
|
23733
|
-
trackers.registerError(this.proctoringId, `finish saveAllOnSession`);
|
|
23734
23749
|
await this.recorder.saveAllOnSession();
|
|
23735
|
-
trackers.registerError(this.proctoringId, `finish sendPendingRealtimeAlerts`);
|
|
23736
23750
|
await this.sendPendingRealtimeAlerts();
|
|
23737
|
-
trackers.registerError(this.proctoringId, `finish this.repository.save`);
|
|
23738
23751
|
await this.repository.save(this.proctoringSession);
|
|
23739
23752
|
let uploader;
|
|
23740
23753
|
let uploaderServices;
|
|
23741
|
-
trackers.registerError(this.proctoringId, `finish uploader`);
|
|
23742
23754
|
if (versionVerify() !== "1.0.0.0") {
|
|
23743
23755
|
uploader = new ProctoringUploader(
|
|
23744
23756
|
this.proctoringSession,
|
|
@@ -23812,7 +23824,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
23812
23824
|
this.serviceType
|
|
23813
23825
|
);
|
|
23814
23826
|
}
|
|
23815
|
-
trackers.registerError(this.proctoringId, `finish uploader success`);
|
|
23816
23827
|
if (this.proctoringSession.alerts.length > 0) {
|
|
23817
23828
|
await this.backend.saveAlerts(this.context, this.proctoringSession).catch((err) => {
|
|
23818
23829
|
trackers.registerFinish(
|
|
@@ -23822,7 +23833,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
23822
23833
|
);
|
|
23823
23834
|
});
|
|
23824
23835
|
}
|
|
23825
|
-
trackers.registerError(this.proctoringId, `finish saveAlerts ok`);
|
|
23826
23836
|
await this.backend.finishAndSendUrls(this.context).then((finishResponse) => {
|
|
23827
23837
|
var _a2, _b, _c2, _d;
|
|
23828
23838
|
trackers.registerFinish(this.proctoringSession.id, true, "");
|
|
@@ -23834,7 +23844,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
23834
23844
|
"finish error: " + error
|
|
23835
23845
|
);
|
|
23836
23846
|
});
|
|
23837
|
-
trackers.registerError(this.proctoringId, `finish call`);
|
|
23838
23847
|
if (this.appChecker) {
|
|
23839
23848
|
const externalSessionId = this.appChecker.getExternalCameraSessionId();
|
|
23840
23849
|
if (externalSessionId != "null") {
|
package/index.js
CHANGED
|
@@ -31648,8 +31648,8 @@ var _ChunkStorageService = class _ChunkStorageService {
|
|
|
31648
31648
|
}
|
|
31649
31649
|
};
|
|
31650
31650
|
_ChunkStorageService.DB_NAME = "EasyProctorChunksDb";
|
|
31651
|
-
/**
|
|
31652
|
-
_ChunkStorageService.DB_VERSION =
|
|
31651
|
+
/** v2: índices numéricos; v3: payload em ArrayBuffer (Safari/iOS com Blob no IDB) */
|
|
31652
|
+
_ChunkStorageService.DB_VERSION = 3;
|
|
31653
31653
|
_ChunkStorageService.STORE_NAME = "chunks";
|
|
31654
31654
|
var ChunkStorageService = _ChunkStorageService;
|
|
31655
31655
|
|
|
@@ -31809,7 +31809,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31809
31809
|
* @param isFinal Se true, não alinha a 256KB e fecha a sessão com /TOTAL no header.
|
|
31810
31810
|
*/
|
|
31811
31811
|
async processQueue(isFinal = false) {
|
|
31812
|
-
var _a2, _b;
|
|
31812
|
+
var _a2, _b, _c2, _d, _e3, _f;
|
|
31813
31813
|
if (this.isProcessing) return;
|
|
31814
31814
|
this.isProcessing = true;
|
|
31815
31815
|
try {
|
|
@@ -31832,31 +31832,31 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31832
31832
|
let virtualStart = this.totalBytesPurged;
|
|
31833
31833
|
const chunksWithMeta = allChunks.map((c3) => {
|
|
31834
31834
|
const start = virtualStart;
|
|
31835
|
-
const end = start + c3.
|
|
31836
|
-
virtualStart += c3.
|
|
31835
|
+
const end = start + c3.arrayBuffer.byteLength - 1;
|
|
31836
|
+
virtualStart += c3.arrayBuffer.byteLength;
|
|
31837
31837
|
return { chunk: c3, start, end };
|
|
31838
31838
|
});
|
|
31839
|
-
|
|
31839
|
+
const combinedBufferParts = [];
|
|
31840
31840
|
let lastProcessedChunkId = null;
|
|
31841
31841
|
let finalChunkIndex = 0;
|
|
31842
|
-
|
|
31842
|
+
const mimeType = (_d = (_c2 = (_a2 = pendingChunks[0]) == null ? void 0 : _a2.mimeType) != null ? _c2 : (_b = allChunks[allChunks.length - 1]) == null ? void 0 : _b.mimeType) != null ? _d : "video/webm";
|
|
31843
31843
|
for (const meta of chunksWithMeta) {
|
|
31844
31844
|
if (this.currentOffset > meta.end) continue;
|
|
31845
31845
|
const sliceStart = Math.max(0, this.currentOffset - meta.start);
|
|
31846
|
-
const chunkSlice = meta.chunk.
|
|
31847
|
-
|
|
31846
|
+
const chunkSlice = meta.chunk.arrayBuffer.slice(sliceStart);
|
|
31847
|
+
combinedBufferParts.push(chunkSlice);
|
|
31848
31848
|
lastProcessedChunkId = meta.chunk.id;
|
|
31849
31849
|
finalChunkIndex = meta.chunk.chunkIndex;
|
|
31850
31850
|
}
|
|
31851
|
-
if (
|
|
31851
|
+
if (combinedBufferParts.length === 0 && !isFinal) {
|
|
31852
31852
|
this.isProcessing = false;
|
|
31853
31853
|
return;
|
|
31854
31854
|
}
|
|
31855
|
-
|
|
31856
|
-
let sendableSize =
|
|
31855
|
+
const fullBuffer = _BackgroundUploadService.concatArrayBuffers(combinedBufferParts);
|
|
31856
|
+
let sendableSize = fullBuffer.byteLength;
|
|
31857
31857
|
let totalSizeForHeader = void 0;
|
|
31858
31858
|
if (!isFinal) {
|
|
31859
|
-
sendableSize = Math.floor(
|
|
31859
|
+
sendableSize = Math.floor(fullBuffer.byteLength / this.GCS_CHUNK_SIZE) * this.GCS_CHUNK_SIZE;
|
|
31860
31860
|
if (sendableSize === 0) {
|
|
31861
31861
|
console.log("[BackgroundUpload] Dados insuficientes para atingir 256KB. Aguardando novo chunk...");
|
|
31862
31862
|
this.isProcessing = false;
|
|
@@ -31865,20 +31865,23 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31865
31865
|
} else {
|
|
31866
31866
|
totalSizeForHeader = virtualStart;
|
|
31867
31867
|
}
|
|
31868
|
-
const
|
|
31868
|
+
const bufferToSend = sendableSize < fullBuffer.byteLength ? fullBuffer.slice(0, sendableSize) : fullBuffer;
|
|
31869
31869
|
try {
|
|
31870
|
-
await this.uploadData(
|
|
31870
|
+
await this.uploadData(bufferToSend, mimeType, finalChunkIndex, totalSizeForHeader);
|
|
31871
31871
|
for (const meta of chunksWithMeta) {
|
|
31872
31872
|
if (meta.chunk.uploaded === 0 && meta.end < this.currentOffset) {
|
|
31873
31873
|
await this.chunkStorage.markAsUploaded(meta.chunk.id);
|
|
31874
31874
|
this.retryCount.delete(meta.chunk.id);
|
|
31875
|
-
(
|
|
31875
|
+
(_e3 = this.onChunkUploaded) == null ? void 0 : _e3.call(this, meta.chunk.id, meta.chunk.chunkIndex);
|
|
31876
31876
|
console.log(`[BackgroundUpload] Chunk ${meta.chunk.chunkIndex} marcado como enviado.`);
|
|
31877
31877
|
}
|
|
31878
31878
|
}
|
|
31879
31879
|
if (this.config.cleanAfterUpload) {
|
|
31880
31880
|
const chunksToClear = chunksWithMeta.filter((meta) => meta.chunk.uploaded === 1 || meta.chunk.uploaded === 0 && meta.end < this.currentOffset);
|
|
31881
|
-
const sizePurged = chunksToClear.reduce(
|
|
31881
|
+
const sizePurged = chunksToClear.reduce(
|
|
31882
|
+
(acc, meta) => acc + meta.chunk.arrayBuffer.byteLength,
|
|
31883
|
+
0
|
|
31884
|
+
);
|
|
31882
31885
|
await this.chunkStorage.clearUploadedChunks(this.proctoringId);
|
|
31883
31886
|
if (sizePurged > 0) {
|
|
31884
31887
|
this.totalBytesPurged += sizePurged;
|
|
@@ -31891,7 +31894,7 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31891
31894
|
}
|
|
31892
31895
|
} catch (error) {
|
|
31893
31896
|
console.error("[BackgroundUpload] Falha no upload:", error);
|
|
31894
|
-
(
|
|
31897
|
+
(_f = this.onUploadError) == null ? void 0 : _f.call(this, lastProcessedChunkId || 0, error);
|
|
31895
31898
|
}
|
|
31896
31899
|
} catch (error) {
|
|
31897
31900
|
console.error("[BackgroundUpload] Erro ao processar fila:", error);
|
|
@@ -31902,7 +31905,18 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31902
31905
|
/**
|
|
31903
31906
|
* Faz o upload bruto de dados para a sessão GCS.
|
|
31904
31907
|
*/
|
|
31905
|
-
|
|
31908
|
+
static concatArrayBuffers(parts) {
|
|
31909
|
+
if (parts.length === 0) return new ArrayBuffer(0);
|
|
31910
|
+
const total = parts.reduce((sum, p3) => sum + p3.byteLength, 0);
|
|
31911
|
+
const merged = new Uint8Array(total);
|
|
31912
|
+
let offset = 0;
|
|
31913
|
+
for (const p3 of parts) {
|
|
31914
|
+
merged.set(new Uint8Array(p3), offset);
|
|
31915
|
+
offset += p3.byteLength;
|
|
31916
|
+
}
|
|
31917
|
+
return merged.buffer.byteLength === total ? merged.buffer : merged.buffer.slice(merged.byteOffset, merged.byteOffset + merged.byteLength);
|
|
31918
|
+
}
|
|
31919
|
+
async uploadData(data, mimeType, chunkIndex, totalSize) {
|
|
31906
31920
|
const fileName = `EP_${this.proctoringId}_camera_0.webm`;
|
|
31907
31921
|
if (!this.sessionUrl) {
|
|
31908
31922
|
const initiateUrl = await this.backend.initiateUpload(this.token, `${this.proctoringId}/${fileName}`, mimeType);
|
|
@@ -31934,15 +31948,16 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31934
31948
|
console.log(`[BackgroundUpload] Usando sess\xE3o GCS existente: ${this.sessionUrl}`);
|
|
31935
31949
|
}
|
|
31936
31950
|
const start = this.currentOffset;
|
|
31937
|
-
const end = start +
|
|
31951
|
+
const end = start + data.byteLength - 1;
|
|
31938
31952
|
const totalHeader = totalSize !== void 0 ? totalSize.toString() : "*";
|
|
31939
|
-
const contentRangeHeader =
|
|
31940
|
-
console.log(
|
|
31953
|
+
const contentRangeHeader = data.byteLength === 0 && totalSize !== void 0 ? `bytes */${totalHeader}` : `bytes ${start}-${end}/${totalHeader}`;
|
|
31954
|
+
console.log(
|
|
31955
|
+
`[BackgroundUpload] Enviando ${data.byteLength > 0 ? "dados" : "finaliza\xE7\xE3o"}: ${contentRangeHeader} (Size: ${data.byteLength})`
|
|
31956
|
+
);
|
|
31941
31957
|
const response = await fetch(this.sessionUrl, {
|
|
31942
31958
|
method: "PUT",
|
|
31943
31959
|
headers: { "Content-Range": contentRangeHeader },
|
|
31944
|
-
body:
|
|
31945
|
-
// Usa null para garantir corpo vazio se necessário
|
|
31960
|
+
body: data.byteLength > 0 ? data : null
|
|
31946
31961
|
});
|
|
31947
31962
|
console.log(`[BackgroundUpload] Resposta GCS (uploadData): ${response.status}`);
|
|
31948
31963
|
if (response.status !== 200 && response.status !== 201 && response.status !== 308) {
|
|
@@ -31955,13 +31970,13 @@ var BackgroundUploadService = class _BackgroundUploadService {
|
|
|
31955
31970
|
const lastByte = parseInt(rangeHeader.split("-")[1], 10);
|
|
31956
31971
|
this.currentOffset = lastByte + 1;
|
|
31957
31972
|
} else {
|
|
31958
|
-
this.currentOffset +=
|
|
31973
|
+
this.currentOffset += data.byteLength;
|
|
31959
31974
|
}
|
|
31960
31975
|
this.saveSessionState();
|
|
31961
31976
|
trackers.registerUploadFile(
|
|
31962
31977
|
this.proctoringId,
|
|
31963
31978
|
`GCS Stream Upload
|
|
31964
|
-
Size: ${
|
|
31979
|
+
Size: ${data.byteLength}
|
|
31965
31980
|
Range: ${start}-${end}
|
|
31966
31981
|
Last Index: ${chunkIndex}`,
|
|
31967
31982
|
"CameraChunk"
|
|
@@ -32504,10 +32519,11 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32504
32519
|
const savePromise = (async () => {
|
|
32505
32520
|
var _a2;
|
|
32506
32521
|
try {
|
|
32522
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
32507
32523
|
await this.chunkStorage.saveChunk({
|
|
32508
32524
|
proctoringId: this.proctoringId,
|
|
32509
32525
|
chunkIndex: this.chunkIndex,
|
|
32510
|
-
|
|
32526
|
+
arrayBuffer,
|
|
32511
32527
|
timestamp: Date.now(),
|
|
32512
32528
|
uploaded: 0,
|
|
32513
32529
|
mimeType: ((_a2 = this.recorderOptions) == null ? void 0 : _a2.mimeType) || "video/webm"
|
|
@@ -38979,15 +38995,11 @@ Error: ${error}`
|
|
|
38979
38995
|
await this.recorder.stopAll();
|
|
38980
38996
|
this.spyCam && this.spyCam.stopCheckSpyCam();
|
|
38981
38997
|
this.appChecker && await this.appChecker.disconnectWebSocket();
|
|
38982
|
-
trackers.registerError(this.proctoringId, `finish saveAllOnSession`);
|
|
38983
38998
|
await this.recorder.saveAllOnSession();
|
|
38984
|
-
trackers.registerError(this.proctoringId, `finish sendPendingRealtimeAlerts`);
|
|
38985
38999
|
await this.sendPendingRealtimeAlerts();
|
|
38986
|
-
trackers.registerError(this.proctoringId, `finish this.repository.save`);
|
|
38987
39000
|
await this.repository.save(this.proctoringSession);
|
|
38988
39001
|
let uploader;
|
|
38989
39002
|
let uploaderServices;
|
|
38990
|
-
trackers.registerError(this.proctoringId, `finish uploader`);
|
|
38991
39003
|
if (versionVerify() !== "1.0.0.0") {
|
|
38992
39004
|
uploader = new ProctoringUploader(
|
|
38993
39005
|
this.proctoringSession,
|
|
@@ -39061,7 +39073,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
39061
39073
|
this.serviceType
|
|
39062
39074
|
);
|
|
39063
39075
|
}
|
|
39064
|
-
trackers.registerError(this.proctoringId, `finish uploader success`);
|
|
39065
39076
|
if (this.proctoringSession.alerts.length > 0) {
|
|
39066
39077
|
await this.backend.saveAlerts(this.context, this.proctoringSession).catch((err) => {
|
|
39067
39078
|
trackers.registerFinish(
|
|
@@ -39071,7 +39082,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
39071
39082
|
);
|
|
39072
39083
|
});
|
|
39073
39084
|
}
|
|
39074
|
-
trackers.registerError(this.proctoringId, `finish saveAlerts ok`);
|
|
39075
39085
|
await this.backend.finishAndSendUrls(this.context).then((finishResponse) => {
|
|
39076
39086
|
var _a2, _b, _c2, _d;
|
|
39077
39087
|
trackers.registerFinish(this.proctoringSession.id, true, "");
|
|
@@ -39083,7 +39093,6 @@ Upload Services: ${uploaderServices}`,
|
|
|
39083
39093
|
"finish error: " + error
|
|
39084
39094
|
);
|
|
39085
39095
|
});
|
|
39086
|
-
trackers.registerError(this.proctoringId, `finish call`);
|
|
39087
39096
|
if (this.appChecker) {
|
|
39088
39097
|
const externalSessionId = this.appChecker.getExternalCameraSessionId();
|
|
39089
39098
|
if (externalSessionId != "null") {
|
|
@@ -32,6 +32,7 @@ export declare class BackgroundUploadService {
|
|
|
32
32
|
flush(): Promise<void>;
|
|
33
33
|
private syncOffset;
|
|
34
34
|
private processQueue;
|
|
35
|
+
private static concatArrayBuffers;
|
|
35
36
|
private uploadData;
|
|
36
37
|
static recoverPendingUploads(backend: BackendService, token: string): Promise<string[]>;
|
|
37
38
|
private sleep;
|