Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add service worker #550

Merged
merged 174 commits into from
Jul 23, 2021
Merged

feat: add service worker #550

merged 174 commits into from
Jul 23, 2021

Conversation

KaiVandivier
Copy link
Contributor

@KaiVandivier KaiVandivier commented Apr 23, 2021

Enables offline caching; relates to these notes and Jira issue DHIS2-8341

Summary of changes, by package

  • SW (package added)
    • Adds code for setting up a service worker which handles offline caching if PWA is enabled, or tears down any existing service worker if PWA is not enabled
    • Adds OfflineInterface which provides an interface for communicating between an app and the service worker and some read and delete functions for the Cache Storage API and a recorded section IndexedDB, and is intended to be used by the offline service React API
  • App shell
    • Service worker registration logic was moved out of index.js into the sw package
    • A service-worker.js file is added which imports and executes the set-up code from the sw package
  • CLI
    • Adds some PWA-related environment variables for app and service worker to consume
    • Generates a manifest.json file for PWA purposes
    • Injects a workbox precache manifest into a built service worker
  • App adapter
    • Instantiates an OfflineInterface
    • An OfflineProvider from the App Runtime is added to provide the Offline Interface and other context to the app
  • PWA Test app
    • Tests out service worker, offline interface, and offline service features
    • Demonstrates offline service APIs

To do before alpha release, after runtime release:

  • Catch alpha and this branch up with master
  • Use alpha version of @dhis2/app-service-offline instead of local version
  • Import from @dhis2/app-runtime instead
  • Change app adapter to use only Provider which includes OfflineProvider

To do after:

  • Important: Add development mode so a whole app doesn't need to be rebuilt each time
  • Add error boundary around app and header bar
  • Normalize caching
  • Enable at-rest encryption of cached data
  • Smartly determine cacheable components' data requirements so 'URL filtering' is not necessary

@KaiVandivier KaiVandivier changed the base branch from alpha to master July 22, 2021 08:45
@KaiVandivier KaiVandivier changed the base branch from master to alpha July 22, 2021 08:46
@KaiVandivier KaiVandivier changed the base branch from alpha to master July 23, 2021 13:12
@KaiVandivier KaiVandivier changed the base branch from master to alpha July 23, 2021 13:13
examples/pwa-app/src/App.js Outdated Show resolved Hide resolved
@KaiVandivier KaiVandivier merged commit 225069e into alpha Jul 23, 2021
@KaiVandivier KaiVandivier deleted the feat-add-service-worker branch July 23, 2021 13:43
dhis2-bot added a commit that referenced this pull request Jul 23, 2021
# [7.3.0-alpha.1](v7.2.0...v7.3.0-alpha.1) (2021-07-23)

### Features

* add service worker and pwa capabilities ([#550](#550)) ([225069e](225069e)), closes [#580](#580) [#582](#582) [#592](#592)
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 7.3.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Aug 31, 2021
# [7.6.0-alpha.1](v7.5.1...v7.6.0-alpha.1) (2021-08-31)

### Bug Fixes

* catch errors in completeRecording ([e67ae82](e67ae82))
* check whole URL against filter patterns ([5468114](5468114))
* only return sections with cached data from getCachedSections ([f6242d1](f6242d1))
* reopen indexedDB if global state resets ([0aded68](0aded68))
* return true if either cache or idb entry is removed ([43d8001](43d8001))
* simplify message payload to be compatible with firefox ([5e5a633](5e5a633))

### Features

* add service worker and pwa capabilities ([#550](#550)) ([225069e](225069e)), closes [#580](#580) [#582](#582) [#592](#592)
* allow RegEx for filter patterns in d2.config.js ([9699330](9699330))
* use new headerbar with online status indicator ([#626](#626)) ([3bd7d37](3bd7d37))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 7.6.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Aug 31, 2021
# [7.6.0](v7.5.1...v7.6.0) (2021-08-31)

### Bug Fixes

* catch errors in completeRecording ([e67ae82](e67ae82))
* check whole URL against filter patterns ([5468114](5468114))
* only return sections with cached data from getCachedSections ([f6242d1](f6242d1))
* reopen indexedDB if global state resets ([0aded68](0aded68))
* return true if either cache or idb entry is removed ([43d8001](43d8001))
* simplify message payload to be compatible with firefox ([5e5a633](5e5a633))

### Features

* add service worker and pwa capabilities ([#550](#550)) ([225069e](225069e)), closes [#580](#580) [#582](#582) [#592](#592)
* allow RegEx for filter patterns in d2.config.js ([9699330](9699330))
* use new headerbar with online status indicator ([#626](#626)) ([3bd7d37](3bd7d37))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 7.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Sep 8, 2021
# [8.0.0-beta.4](v8.0.0-beta.3...v8.0.0-beta.4) (2021-09-08)

### Bug Fixes

* **dependencies:** update app-runtime to v3 ([8777699](8777699))
* **offline-interface:** prevent infinite update loop in Chrome ([#638](#638)) ([079f6ea](079f6ea))
* **recording-mode:** handle fulfilled requests after recording error ([#642](#642)) ([928e2cb](928e2cb))
* import index.css in index.js so styles are applied ([8db1bf8](8db1bf8))
* **shell:** create new stacking context for roots ([324a095](324a095))
* catch errors in completeRecording ([e67ae82](e67ae82))
* check whole URL against filter patterns ([5468114](5468114))
* only return sections with cached data from getCachedSections ([f6242d1](f6242d1))
* reopen indexedDB if global state resets ([0aded68](0aded68))
* return true if either cache or idb entry is removed ([43d8001](43d8001))
* simplify message payload to be compatible with firefox ([5e5a633](5e5a633))

### Features

* add service worker and pwa capabilities ([#550](#550)) ([225069e](225069e)), closes [#580](#580) [#582](#582) [#592](#592)
* allow RegEx for filter patterns in d2.config.js ([9699330](9699330))
* use new headerbar with online status indicator ([#626](#626)) ([3bd7d37](3bd7d37))

### BREAKING CHANGES

* **dependencies:** This updates the app-platform to version 3 of the
app-runtime. That means that this version of the app-platform will only
work with apps that use version 3 of the app-runtime.
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 8.0.0-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants