webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
80 stars 9 forks source link

Feature: @webdoc/default-template service worker #190

Closed ShukantPal closed 2 years ago

ShukantPal commented 2 years ago

Synopsis

This PR adds a service worker to the sites generated by the default template to

It also adds an IndexedDB layer that holds the manifest data. The manifest is used to get all the pages in the site to be cached.

Service Worker

The protocol/ folder in the site source contains the interface b/w the main & service-worker threads.

The service worker accepts 2 types of messages:

Caching

There are 2 types of caches:

The "offline storage" setting lets the user cache the whole website immediately (well all the pages in the manifest registry, which doesn't include things like README and settings pages). It's an opt-in setting; however, the service worker will cache each HTML page when the user visits them into the ephemeral cache anyway.

IndexedDB

There are 2 object stores in the current database model:

UI

Toolbar in explorer & settings page

This toolbar has the new settings page link [button]

Screen Shot 2022-08-25 at 6 37 50 AM

The settings page lets you toggle offline storage:

Screen Shot 2022-08-25 at 6 38 44 AM

Toasts for offline / stale pages

These toasts let the user know if

Screen Shot 2022-08-25 at 6 33 45 AM Screen Shot 2022-08-25 at 6 34 18 AM