feat: add support for the Web Share Target API (#1100)

Co-authored-by: userquin <userquin@gmail.com>
This commit is contained in:
Horváth Bálint 2023-01-14 21:58:52 +01:00 committed by GitHub
parent a6a825e553
commit bede92404b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 221 additions and 7 deletions

View file

@ -7,6 +7,7 @@ import { StaleWhileRevalidate } from 'workbox-strategies'
import { ExpirationPlugin } from 'workbox-expiration'
import { onNotificationClick, onPush } from './web-push-notifications'
import { onShareTarget } from './share-target'
declare const self: ServiceWorkerGlobalScope
@ -32,7 +33,7 @@ if (import.meta.env.DEV)
// deny api and server page calls
let denylist: undefined | RegExp[]
if (import.meta.env.PROD)
denylist = [/^\/api\//, /^\/login\//, /^\/oauth\//, /^\/signin\//]
denylist = [/^\/api\//, /^\/login\//, /^\/oauth\//, /^\/signin\//, /^\/web-share-target\//]
// only cache pages and external assets on local build + start or in production
if (import.meta.env.PROD) {
@ -90,3 +91,4 @@ registerRoute(new NavigationRoute(
self.addEventListener('push', onPush)
self.addEventListener('notificationclick', onNotificationClick)
self.addEventListener('fetch', onShareTarget)