๐Ÿ“„ src/downloader/adapters/vue.ts
D-OPEN SOVEREIGN

Documentation & Insights

Reactive LRU auto-cleanup state.

Usage:
  const pruning = usePruning()
  // pruning.value.active      โ†’ true while cleanup is running
  // pruning.value.freedBytes  โ†’ bytes freed in the last run
  // pruning.value.removedCount โ†’ number of PDFs removed
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// Vue 3 adapter โ€” thin reactive bridge over the framework-agnostic store (ยง5.6.4).
16import { computed, shallowRef } from 'vue';
17import { downloadState } from '../state';
18
19const tick = shallowRef(0);
20downloadState.subscribe(() => tick.value++);
21
22export const useFileStatus = (txId: string) =>
23    computed(() => (tick.value, downloadState.get(txId)));
24
25export const useRenderStatus = (txId: string) =>
26    computed(() => (tick.value, downloadState.getRender(txId)));
27
28export const useGlobalProgress = () =>
29    computed(() => (tick.value, downloadState.summary()));
30
31/**
32 * Reactive LRU auto-cleanup state.
33 *
34 * Usage:
35 *   const pruning = usePruning()
36 *   // pruning.value.active      โ†’ true while cleanup is running
37 *   // pruning.value.freedBytes  โ†’ bytes freed in the last run
38 *   // pruning.value.removedCount โ†’ number of PDFs removed
39 */
40export const usePruning = () =>
41    computed(() => (tick.value, downloadState.pruning));
42