
Security News
/Company News
Securing the Financial Frontier: How Capital One Uses Socket for Open Source Security
Capital One is partnering with Socket to proactively secure its open source supply chain.
@xiboplayer/cache
Advanced tools
Offline caching and download management with parallel chunk downloads
Offline caching and download management with parallel chunk downloads, resume support, and storage health monitoring.
Manages the complete lifecycle of media files from CMS to local storage:
No Cache API is used. All content is stored on the filesystem via the proxy's ContentStore.
CMS (RequiredFiles: size, URL, MD5)
|
v
+-------------------------------------+
| DownloadManager (Facade) |
| +- enqueue(fileInfo) |
| +- prioritizeLayoutFiles(mediaIds) |
| +- urgentChunk(type, id, idx) |
+-------------------------------------+
|
v
DownloadQueue (Flat)
+-----------------------------+
| [Task, Task, BARRIER, |
| Task, Task, Task] |
| |
| Global concurrency: 6 |
| Per-file chunks: 2-3 |
+-----------------------------+
|
+-> DownloadTask (chunk-0, high priority)
+-> DownloadTask (chunk-last, high priority)
+-> BARRIER (gate: waits for above to finish)
+-> DownloadTask (bulk chunks, normal priority)
|
v
HTTP Range GET
|
v
ContentStore (proxy)
/store/media/{id}
/store/layout/{id}
/store/widget/{L}/{R}/{M}
npm install @xiboplayer/cache
import { StoreClient } from '@xiboplayer/cache';
const store = new StoreClient();
// Check existence
const exists = await store.has('media', '123');
// Retrieve file
const blob = await store.get('media', '456');
// Store widget HTML
const html = new Blob(['<h1>Widget</h1>'], { type: 'text/html' });
await store.put('widget', 'layout/1/region/2/media/3', html, 'text/html');
// List all cached files
const files = await store.list();
// Delete orphaned files
await store.remove([
{ type: 'media', id: '999' },
{ type: 'media', id: '1000' },
]);
import { DownloadManager } from '@xiboplayer/cache';
const dm = new DownloadManager({
concurrency: 6,
chunkSize: 50 * 1024 * 1024,
chunksPerFile: 2,
});
// Enqueue a file
const media = dm.enqueue({
id: '123',
type: 'media',
path: 'https://cdn.example.com/video.mp4',
size: 250 * 1024 * 1024,
md5: 'abc123def456',
});
// Wait for completion
const blob = await media.wait();
// Get progress
const progress = dm.getProgress();
// { 'media/123': { downloaded: 50M, total: 250M, percent: '20.0', state: 'downloading' } }
// Boost files needed by current layout
dm.prioritizeLayoutFiles(['123', '456']);
// Emergency: chunk needed for video playback is stalled
// Moves to front of queue, reduces global concurrency to 2
dm.urgentChunk('media', '789', 3);
import { CacheAnalyzer } from '@xiboplayer/cache';
const analyzer = new CacheAnalyzer(store, { threshold: 80 });
const report = await analyzer.analyze(requiredFiles);
console.log(`Storage: ${report.storage.percent}%`);
console.log(`Orphaned: ${report.files.orphaned} files`);
console.log(`Evicted: ${report.evicted.length} files`);
Files flow through stages:
type/id key, URL refresh if new URL has longer expiryskipChunks Set; only missing chunks downloaded| Type | Max retries | Backoff | Notes |
|---|---|---|---|
| media | 3 | 500ms | Large, cacheable files |
| layout | 3 | 500ms | Layout XML, stable URL |
| dataset | 4 | 15s, 30s, 60s, 120s | Re-enqueues 5x for "cache not ready" |
| static | 3 | 500ms | Widget dependencies (CSS, fonts) |
| Method | Signature | Returns | Description |
|---|---|---|---|
has() | has(type, id) | Promise<boolean> | Check if file exists |
get() | get(type, id) | Promise<Blob | null> | Retrieve file as Blob |
put() | put(type, id, body, contentType?) | Promise<boolean> | Store file |
remove() | remove(files) | Promise<{deleted, total}> | Delete files |
list() | list() | Promise<Array> | List all cached files |
new DownloadManager({ concurrency?, chunkSize?, chunksPerFile? })
| Method | Signature | Returns | Description |
|---|---|---|---|
enqueue() | enqueue(fileInfo) | FileDownload | Add file to download queue |
getTask() | getTask(key) | FileDownload | null | Get task by "type/id" key |
getProgress() | getProgress() | Record<string, Progress> | All in-progress downloads |
prioritizeLayoutFiles() | prioritizeLayoutFiles(mediaIds) | void | Boost priority for layout files |
urgentChunk() | urgentChunk(type, id, chunkIndex) | boolean | Move chunk to front, reduce concurrency |
clear() | clear() | void | Cancel all, clear queue |
new CacheAnalyzer(storeClient, { threshold: 80 })
| Method | Signature | Returns | Description |
|---|---|---|---|
analyze() | analyze(requiredFiles) | Promise<Report> | Compare cache vs required, evict if needed |
Report:
{
storage: { usage, quota, percent },
files: { required, orphaned, total },
orphaned: [{ id, type, size, cachedAt }],
evicted: [{ id, type, size }],
threshold: 80
}
| Method | Signature | Returns | Description |
|---|---|---|---|
getCacheKey() | getCacheKey(type, id) | string | Get cache key path |
addDependant() | addDependant(mediaId, layoutId) | void | Track layout -> media reference |
removeLayoutDependants() | removeLayoutDependants(layoutId) | string[] | Remove layout, return orphaned media IDs |
isMediaReferenced() | isMediaReferenced(mediaId) | boolean | Check if media is still used |
@xiboplayer/utils -- loggerspark-md5 -- MD5 hashing for file verificationxiboplayer.org · Part of the XiboPlayer SDK
FAQs
Offline caching and download management with parallel chunk downloads
The npm package @xiboplayer/cache receives a total of 23 weekly downloads. As such, @xiboplayer/cache popularity was classified as not popular.
We found that @xiboplayer/cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
/Company News
Capital One is partnering with Socket to proactively secure its open source supply chain.

Security News
Socket CTO Ahmad Nassri discusses how to keep AI agents from bypassing package blocks, limit credential access, and monitor their actions.

Security News
GPT-6 Astra tried to plant malicious code in simulated open source projects using fake GitHub accounts and deceptive PRs during an assigned CTF challenge.