feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with
Range seeking; watch page served by the relay itself (#shade= fragment
links, grant never sent to a server)
- MSE live player with keyframe-aware joining, gap detection, latency control
- WebM splitter (init + clusters, keyframe detection) that puts blocks in
timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise
- Link mode for live channels: epoch seeds from a channel secret, so a
link survives publisher restarts and scheduled rotations
- File store streams byte ranges itself (Bun.file().slice() in a Response
sent whole files to Range requests)
- shade media serve|put|get|ls|rm, shade live text|webm|watch
Verified end to end in headless Chromium: VP9/Opus film plays and seeks,
live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:01:52 +02:00
|
|
|
/**
|
|
|
|
|
* Service Worker: makes a sealed file look like a normal one to the browser.
|
|
|
|
|
*
|
|
|
|
|
* The page points `<video src>` (or `<audio>`, `<img>`, a download link) at
|
|
|
|
|
* `<scope>media/<mediaId>`. This worker answers those requests itself —
|
|
|
|
|
* Range requests included, so seeking works — by fetching only the sealed
|
|
|
|
|
* segments under the requested range from wherever the grant says the file
|
|
|
|
|
* lives, verifying and decrypting them, and streaming the plaintext back.
|
|
|
|
|
*
|
|
|
|
|
* Keys live in this worker's memory only. A worker the browser stopped
|
|
|
|
|
* forgets them; it then asks the page (which still holds the grant) again.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2026-10-20 00:13:50 +02:00
|
|
|
import { installShadeMedia } from './worker.js';
|
|
|
|
|
import type { WorkerScope } from './worker.js';
|
feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with
Range seeking; watch page served by the relay itself (#shade= fragment
links, grant never sent to a server)
- MSE live player with keyframe-aware joining, gap detection, latency control
- WebM splitter (init + clusters, keyframe detection) that puts blocks in
timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise
- Link mode for live channels: epoch seeds from a channel secret, so a
link survives publisher restarts and scheduled rotations
- File store streams byte ranges itself (Bun.file().slice() in a Response
sent whole files to Range requests)
- shade media serve|put|get|ls|rm, shade live text|webm|watch
Verified end to end in headless Chromium: VP9/Opus film plays and seeks,
live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:01:52 +02:00
|
|
|
|
|
|
|
|
declare const self: WorkerScope;
|
|
|
|
|
|
2026-10-20 00:13:50 +02:00
|
|
|
// Standalone: this worker owns its scope and takes over open pages at once.
|
feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with
Range seeking; watch page served by the relay itself (#shade= fragment
links, grant never sent to a server)
- MSE live player with keyframe-aware joining, gap detection, latency control
- WebM splitter (init + clusters, keyframe detection) that puts blocks in
timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise
- Link mode for live channels: epoch seeds from a channel secret, so a
link survives publisher restarts and scheduled rotations
- File store streams byte ranges itself (Bun.file().slice() in a Response
sent whole files to Range requests)
- shade media serve|put|get|ls|rm, shade live text|webm|watch
Verified end to end in headless Chromium: VP9/Opus film plays and seeks,
live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:01:52 +02:00
|
|
|
self.addEventListener('install', () => {
|
|
|
|
|
void self.skipWaiting();
|
|
|
|
|
});
|
|
|
|
|
self.addEventListener('activate', (e) => e.waitUntil(self.clients.claim()));
|
2026-10-20 00:13:50 +02:00
|
|
|
installShadeMedia(self);
|