-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathserviceWorker.ts
More file actions
54 lines (48 loc) · 2.2 KB
/
serviceWorker.ts
File metadata and controls
54 lines (48 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {BASE_PATH} from 'src/shared/constants'
export const registerServiceWorker = (): Promise<ServiceWorkerRegistration> => {
// Worker -- load prior to page load event, in order to intercept fetch in http/2.
// see service worker life cycle. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
let workerRegistration = null
if ('serviceWorker' in navigator) {
workerRegistration = navigator.serviceWorker.register(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
new URL('../workers/downloadHelper.ts', import.meta.url),
{scope: `${BASE_PATH}api/v2/query`}
/* webpackChunkName: "interceptor" */
)
}
return workerRegistration
}
export const registerServiceWorkerInfluxQL =
(): Promise<ServiceWorkerRegistration> => {
// Worker -- load prior to page load event, in order to intercept fetch in http/2.
// see service worker life cycle. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
let workerRegistrationInfluxQL = null
if ('serviceWorker' in navigator) {
workerRegistrationInfluxQL = navigator.serviceWorker.register(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
new URL('../workers/downloadHelper.ts', import.meta.url),
{scope: `${BASE_PATH}query`}
/* webpackChunkName: "interceptor" */
)
}
return workerRegistrationInfluxQL
}
export const registerServiceWorkerSQL =
(): Promise<ServiceWorkerRegistration> => {
// Worker -- load prior to page load event, in order to intercept fetch in http/2.
// see service worker life cycle. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
let workerRegistrationSQL = null
if ('serviceWorker' in navigator) {
workerRegistrationSQL = navigator.serviceWorker.register(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
new URL('../workers/downloadHelper.ts', import.meta.url),
{scope: `${BASE_PATH}api/v2private/query`}
/* webpackChunkName: "interceptor" */
)
}
return workerRegistrationSQL
}