@xiboplayer/cache 0.5.7 → 0.5.9

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/README.md CHANGED
@@ -1,19 +1,23 @@
1
1
  # @xiboplayer/cache
2
2
 
3
- **Offline caching and download management with parallel chunk downloads.**
3
+ **Offline caching and download management with durable filesystem storage.**
4
4
 
5
5
  ## Overview
6
6
 
7
7
  Manages media downloads and offline storage for Xibo players:
8
8
 
9
+ - **StoreClient** — pure REST client for reading/writing content in the ContentStore (filesystem via proxy)
10
+ - **DownloadClient** — Service Worker postMessage client for managing background downloads
9
11
  - **Parallel chunk downloads** — large files (100MB+) split into configurable chunks, downloaded concurrently
10
12
  - **Header+trailer first** — MP4 moov atom fetched first for instant playback start before full download
11
13
  - **MD5 verification** — integrity checking with CRC32-based skip optimization
12
14
  - **Download queue** — flat queue with barriers for layout-ordered downloading
13
- - **CacheProxy** — browser-side proxy that communicates with a Service Worker backend
15
+ - **CacheAnalyzer** — stale media detection and storage-pressure eviction
14
16
  - **Widget data via enriched RequiredFiles** — RSS/dataset widget data is fetched through server-side enriched RequiredFiles paths (CMS adds download URLs), not via client-side pre-fetching
15
17
  - **Dynamic BASE path** — widget HTML `<base>` tag uses a dynamic path within the Service Worker scope for correct relative URL resolution
16
18
 
19
+ No Cache API is used anywhere. All content is stored on the filesystem via the proxy's ContentStore.
20
+
17
21
  ## Installation
18
22
 
19
23
  ```bash
@@ -23,24 +27,29 @@ npm install @xiboplayer/cache
23
27
  ## Usage
24
28
 
25
29
  ```javascript
26
- import { CacheProxy } from '@xiboplayer/cache';
27
-
28
- const cache = new CacheProxy();
29
- await cache.init();
30
-
31
- // Request downloads (delegated to Service Worker)
32
- await cache.requestDownload({ layoutOrder, files });
33
-
34
- // Check if a file is cached
35
- const isCached = await cache.has(fileId);
30
+ import { StoreClient, DownloadClient } from '@xiboplayer/cache';
31
+
32
+ // Storage operations (pure REST, no SW needed)
33
+ const store = new StoreClient();
34
+ const { exists, size } = await store.has('media', '123');
35
+ const blob = await store.get('media', '123');
36
+ await store.put('widget', '472/221/190', htmlBlob, 'text/html');
37
+
38
+ // Download management (SW postMessage)
39
+ const downloads = new DownloadClient();
40
+ await downloads.init();
41
+ await downloads.download(files);
42
+ const progress = await downloads.getProgress();
36
43
  ```
37
44
 
38
45
  ## Exports
39
46
 
40
47
  | Export | Description |
41
48
  |--------|-------------|
42
- | `CacheProxy` | Browser-side proxy communicating with SW backend |
49
+ | `StoreClient` | Pure REST client for ContentStore has/get/put/remove/list |
50
+ | `DownloadClient` | SW postMessage client for background downloads |
43
51
  | `DownloadManager` | Core download queue with barrier-based ordering |
52
+ | `CacheAnalyzer` | Stale media detection and eviction |
44
53
 
45
54
  ## Dependencies
46
55