Feature: @webdoc/default-template service worker #190
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
webdocService
lets the main application initialize and pass messages to the service worker.webdocDB
is a wrapper around IndexedDB for data persistence. The "settings" store holds the application settings and the manifest url & hash.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]
The settings page lets you toggle offline storage:
Toasts for offline / stale pages
These toasts let the user know if