transcend-io / penumbra

Encrypt/decrypt anything in the browser using streams on background threads.

Home Page:https://penumbra-example.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`penumbra.saveZip()` Background Fetch integration for rich download UI

eligrey opened this issue · comments

We could add an optional resources field onto ZipOptions consisting of uninitialized RemoteResource descriptors. A Service Worker could handle downloading these resources with Background Fetch which enables us to create rich download UIs and persistent downloads that continue when the tab is closed.

Rich download UI example screenshot:

Screen Shot 2020-10-27 at 3 01 40 PM

Background Fetch example (from https://developers.google.com/web/updates/2018/12/background-fetch)

navigator.serviceWorker.ready.then(async (swReg) => {
  const bgFetch = await swReg.backgroundFetch.fetch('my-fetch', ['/ep-5.mp3', 'ep-5-artwork.jpg'], {
    title: 'Episode 5: Interesting things.',
    icons: [{
      sizes: '300x300',
      src: '/ep-5-icon.png',
      type: 'image/png',
    }],
    downloadTotal: 60 * 1024 * 1024,
  });
});

Limitations

This feature might not be compatible with use cases that involve an unknown amount of async paginated resources.