13
13
< div class ="updates " style ="position: fixed; top: 0; z-index: 999; background-color: red; color: white ">
14
14
< div id ="output "> </ div >
15
15
</ div >
16
- < app-yt >
17
- < div class ="loading-app ">
18
- < i class ="fa fa-circle-o-notch fa-spin fa-2x fa-fw "> </ i >
19
- < span class ="sr-only "> Loading...</ span >
20
- </ div >
21
- </ app-yt >
22
- < script >
23
- const AutoUpdater = require ( "nw-autoupdater" ) ,
24
- updater = new AutoUpdater ( require ( "./package.json" ) ) ,
25
- output = document . querySelector ( "#output" ) ;
26
-
27
- async function main ( ) {
28
- try {
29
- // Update copy is running to replace app with the update
30
- if ( updater . isSwapRequest ( ) ) {
31
- output . innerHTML += `\nSwapping...` ;
32
- await updater . swap ( ) ;
33
- output . innerHTML += `\nDone...` ;
34
- await updater . restart ( ) ;
35
- return ;
36
- }
37
- // Download/unpack update if any available
38
- const rManifest = await updater . readRemoteManifest ( ) ;
39
- const needsUpdate = await updater . checkNewVersion ( rManifest ) ;
40
- if ( ! needsUpdate ) {
41
- output . innerHTML += `\nIs up to date...` ;
42
- return ;
43
- }
44
- if ( ! confirm ( "New release is available. Do you want to upgrade?" ) ) {
45
- return ;
46
- }
47
- // Subscribe for progress events
48
- updater . on ( "download" , ( downloadSize , totalSize ) => {
49
- output . innerHTML = `Downloading...` ;
50
- console . log ( "download progress" , Math . floor ( downloadSize / totalSize * 100 ) , "%" ) ;
51
- } ) ;
52
- updater . on ( "install" , ( installFiles , totalFiles ) => {
53
- output . innerHTML = `Installing...\n` ;
54
- console . log ( "install progress" , Math . floor ( installFiles / totalFiles * 100 ) , "%" ) ;
55
- } ) ;
56
- const updateFile = await updater . download ( rManifest ) ;
57
- await updater . unpack ( updateFile ) ;
58
- alert ( `The application will automatically restart to finish installing the update` ) ;
59
- await updater . restartToSwap ( ) ;
60
- } catch ( e ) {
61
- console . error ( e ) ;
16
+ < app-yt >
17
+ < div class ="loading-app ">
18
+ < i class ="fa fa-circle-o-notch fa-spin fa-2x fa-fw "> </ i >
19
+ < span class ="sr-only "> Loading...</ span >
20
+ </ div >
21
+ </ app-yt >
22
+ < script >
23
+ const AutoUpdater = require ( "nw-autoupdater" ) ,
24
+ updater = new AutoUpdater ( require ( "./package.json" ) ) ,
25
+ output = document . querySelector ( "#output" ) ;
26
+
27
+ async function main ( ) {
28
+ try {
29
+ // Update copy is running to replace app with the update
30
+ if ( updater . isSwapRequest ( ) ) {
31
+ output . innerHTML += `\nSwapping...` ;
32
+ await updater . swap ( ) ;
33
+ output . innerHTML += `\nDone...` ;
34
+ await updater . restart ( ) ;
35
+ return ;
36
+ }
37
+ // Download/unpack update if any available
38
+ const rManifest = await updater . readRemoteManifest ( ) ;
39
+ const needsUpdate = await updater . checkNewVersion ( rManifest ) ;
40
+ if ( ! needsUpdate ) {
41
+ output . innerHTML += `\nIs up to date...` ;
42
+ return ;
43
+ }
44
+ if ( ! confirm ( "New release is available. Do you want to upgrade?" ) ) {
45
+ return ;
46
+ }
47
+ // Subscribe for progress events
48
+ updater . on ( "download" , ( downloadSize , totalSize ) => {
49
+ output . innerHTML = `Downloading...` ;
50
+ console . log ( "download progress" , Math . floor ( downloadSize / totalSize * 100 ) , "%" ) ;
51
+ } ) ;
52
+ updater . on ( "install" , ( installFiles , totalFiles ) => {
53
+ output . innerHTML = `Installing...\n` ;
54
+ console . log ( "install progress" , Math . floor ( installFiles / totalFiles * 100 ) , "%" ) ;
55
+ } ) ;
56
+ const updateFile = await updater . download ( rManifest ) ;
57
+ await updater . unpack ( updateFile ) ;
58
+ alert ( `The application will automatically restart to finish installing the update` ) ;
59
+ await updater . restartToSwap ( ) ;
60
+ } catch ( e ) {
61
+ console . error ( e ) ;
62
+ }
62
63
}
63
- }
64
- output . innerHTML = `Application v${ nw . App . manifest . version } \n` ;
65
- main ( ) ;
64
+ output . innerHTML = `Application v${ nw . App . manifest . version } \n` ;
65
+ main ( ) ;
66
66
67
- </ script >
67
+ </ script >
68
+ < script type ="text/javascript " src ="inline.bundle.js "> </ script > < script type ="text/javascript " src ="polyfills.bundle.js "> </ script > < script type ="text/javascript " src ="styles.bundle.js "> </ script > < script type ="text/javascript " src ="vendor.bundle.js "> </ script > < script type ="text/javascript " src ="main.bundle.js "> </ script > </ body >
68
69
</ html >
69
- < script type ="text/javascript " src ="inline.bundle.js "> </ script > < script type ="text/javascript " src ="polyfills.bundle.js "> </ script > < script type ="text/javascript " src ="styles.bundle.js "> </ script > < script type ="text/javascript " src ="vendor.bundle.js "> </ script > < script type ="text/javascript " src ="main.bundle.js "> </ script >
0 commit comments