@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 +22 -13
- package/docs/CACHE_PROXY_ARCHITECTURE.md +165 -368
- package/package.json +2 -2
- package/src/cache-analyzer.js +9 -5
- package/src/cache-analyzer.test.js +6 -6
- package/src/cache-proxy.test.js +239 -237
- package/src/cache.js +3 -6
- package/src/cache.test.js +2 -30
- package/src/download-client.js +222 -0
- package/src/download-manager.js +48 -5
- package/src/index.js +3 -2
- package/src/store-client.js +114 -0
- package/src/widget-html.js +70 -54
- package/src/widget-html.test.js +71 -62
- package/src/cache-proxy.js +0 -532
package/README.md
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
# @xiboplayer/cache
|
|
2
2
|
|
|
3
|
-
**Offline caching and download management with
|
|
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
|
-
- **
|
|
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 {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
const
|
|
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
|
-
| `
|
|
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
|
|