-
Notifications
You must be signed in to change notification settings - Fork 276
/
tokens.ts
52 lines (44 loc) 路 1.16 KB
/
tokens.ts
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
import { Token } from '@lumino/coreutils';
import { ISignal } from '@lumino/signaling';
import SW_URL from './service-worker?text';
/**
* The token for the ServiceWorker.
*/
export const IServiceWorkerManager = new Token<IServiceWorkerManager>(
'@jupyterlite/server-extension:IServiceWorkerManager',
);
/**
* The interface for the ServiceWorkerRegistration.
*/
export interface IServiceWorkerManager {
/**
* Signal fired when the registration changed.
*/
readonly registrationChanged: ISignal<
IServiceWorkerManager,
ServiceWorkerRegistration | null
>;
/**
* Whether the ServiceWorker is enabled or not.
*/
readonly enabled: boolean;
/**
* A Promise that resolves when the ServiceWorker is registered, or rejects if it cannot
*/
ready: Promise<void>;
}
/**
* A namespace for `ServiceWorkerManager` class.
*/
export namespace IServiceWorkerManager {
/**
* An options object for initializing a worker manager.
*/
export interface IOptions {
/**
* URL to load the worker file. Default to "{baseURL}/service-worker.js"
*/
workerUrl?: string;
}
}
export const WORKER_NAME = `${SW_URL}`.split('/').slice(-1)[0];