๐Ÿ“„ src/downloader/client/progress.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library โ€” The World Library
4 * 
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 * 
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15// v1-compat window CustomEvent dispatch for download progress (ยง5.0 table).
16
17export function emitProgress(txId: string, loaded: number, total?: number): void {
18    if (typeof window === 'undefined') return;
19    window.dispatchEvent(
20        new CustomEvent('ARWEAVE_DOWNLOAD_PROGRESS', {
21            detail: { txId, loaded, total },
22            bubbles: true,
23        }),
24    );
25}
26
27export function emitDone(txId: string, mime: 'pdf' | 'preview'): void {
28    if (typeof window === 'undefined') return;
29    window.dispatchEvent(
30        new CustomEvent('ARWEAVE_DOWNLOAD_DONE', {
31            detail: { txId, mime },
32            bubbles: true,
33        }),
34    );
35}
36