Skip to content

Commit c16b439

Browse files
authored
Merge pull request #262 from odensc/master
Fix runtime typings.
2 parents 7d64434 + 2f71191 commit c16b439

File tree

3 files changed

+72
-75
lines changed

3 files changed

+72
-75
lines changed

offline-plugin.d.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
"lib/",
88
"tpls/",
99
"runtime.js",
10-
"offline-plugin.d.ts"
10+
"runtime.d.ts"
1111
],
12-
"types": "./offline-plugin.d.ts",
1312
"scripts": {
1413
"test": "node tests/legacy/run && eslint -c configs/eslint.tests.json 'tests/**/**.js'",
1514
"build": "./node_modules/.bin/babel src/ -d lib/",

runtime.d.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
export interface InstallOptions {
2+
/**
3+
* Event called exactly once when ServiceWorker or AppCache is installed.
4+
* Can be useful to display "App is ready for offline usage" message.
5+
*
6+
* @memberOf InstallOptions
7+
*/
8+
onInstalled?: () => void;
9+
10+
/**
11+
* Not supported for AppCache.
12+
* Event called when update is found and browsers started updating process.
13+
* At this moment, some assets are downloading.
14+
*
15+
* @memberOf InstallOptions
16+
*/
17+
onUpdating?: () => void;
18+
19+
/**
20+
* Event called when onUpdating phase finished.
21+
* All required assets are downloaded at this moment and are ready to be updated.
22+
* Call runtime.applyUpdate() to apply update.
23+
*
24+
* @memberOf InstallOptions
25+
*/
26+
onUpdateReady?: () => void;
27+
28+
/**
29+
* Event called when upUpdating phase failed by some reason.
30+
* Nothing is downloaded at this moment and current update process
31+
* in your code should be canceled or ignored.
32+
*
33+
* @memberOf InstallOptions
34+
*/
35+
onUpdateFailed?: () => void;
36+
37+
/**
38+
* Event called when update is applied,
39+
* either by calling runtime.applyUpdate() or
40+
* some other way by a browser itself.
41+
*
42+
* @memberOf InstallOptions
43+
*/
44+
onUpdated?: () => void;
45+
}
46+
47+
/**
48+
* Starts installation flow for ServiceWorker/AppCache
49+
* it's safe and must be called each time your page loads
50+
* (i.e. do not wrap it into any conditions).
51+
*
52+
* @param {InstallOptions} [options] The install options.
53+
*
54+
* @memberOf RuntimeStatic
55+
*/
56+
export function install(options?: InstallOptions): void;
57+
58+
/**
59+
* Used to apply update for existing installation.
60+
* See InstallOptions.
61+
*
62+
* @memberOf RuntimeStatic
63+
*/
64+
export function applyUpdate(): void;
65+
66+
/**
67+
* Performs check for updates of new ServiceWorker/AppCache.
68+
*
69+
* @memberOf RuntimeStatic
70+
*/
71+
export function update(): void;

0 commit comments

Comments
 (0)