This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export function trackModelDownload(response, {id, postMessage}) {
|
||||
export function trackDownloadProgress(response, {id, postMessage, asset = 'model', file}) {
|
||||
const reader = response.body?.getReader?.();
|
||||
if (!reader || typeof ReadableStream !== 'function' || typeof Response !== 'function') return response;
|
||||
|
||||
@@ -13,7 +13,9 @@ export function trackModelDownload(response, {id, postMessage}) {
|
||||
return;
|
||||
}
|
||||
loaded += value.byteLength;
|
||||
postMessage({id, type: 'progress', progress: {loaded, total}});
|
||||
const progress = {asset, loaded, total};
|
||||
if (file) progress.file = file;
|
||||
postMessage({id, type: 'progress', progress});
|
||||
controller.enqueue(value);
|
||||
} catch (error) {
|
||||
controller.error(error);
|
||||
|
||||
Reference in New Issue
Block a user