1+ // System Designer - Copyright 2019 Erwan Carriou
2+ // Licensed under the Apache License, Version 2.0 (the "License")
3+
4+ const version = 'v3.6.0' ;
5+
6+ const clearCaches = ( ) => {
7+ return caches . keys ( ) . then ( keys => {
8+ return Promise . all ( keys . filter ( key => {
9+ return key . indexOf ( version ) !== 0 ;
10+ } ) . map ( key => {
11+ return caches . delete ( key ) ;
12+ } )
13+ ) ;
14+ } )
15+ }
16+
17+ self . addEventListener ( 'install' , e => {
18+ e . waitUntil (
19+ caches . open ( version ) . then ( cache => {
20+ return cache . addAll ( [
21+ '/' ,
22+ 'app/index.html' ,
23+ 'img/icon.png' ,
24+ 'img/logo.png' ,
25+ 'lib/bootstrap/dist/css/bootstrap.min.css' ,
26+ 'lib/bootstrap/dist/css/bootstrap.min.css.map' ,
27+ 'lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff' ,
28+ 'lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2' ,
29+ 'lib/codemirror/addon/hint/show-hint.css' ,
30+ 'lib/codemirror/theme/eclipse.css' ,
31+ 'lib/codemirror/codemirror.css' ,
32+ 'lib/designer/vendor.js' ,
33+ 'lib/editor/vendor.js' ,
34+ 'lib/prism/prism.css' ,
35+ 'lib/system-runtime/system-runtime.min.js' ,
36+ 'scripts/designer-runtime.js' ,
37+ 'scripts/diagram.js' ,
38+ 'scripts/editor-behavior.js' ,
39+ 'scripts/editor-component.js' ,
40+ 'scripts/editor-model.js' ,
41+ 'scripts/editor-schema.js' ,
42+ 'scripts/editor-system.js' ,
43+ 'scripts/editor-type.js' ,
44+ 'scripts/mobile.js' ,
45+ 'scripts/system-designer.js' ,
46+ 'styles/designer.css' ,
47+ 'styles/diagram.css' ,
48+ 'styles/editor.css' ,
49+ 'styles/mobile.css' ,
50+ 'behavior.html' ,
51+ 'component.html' ,
52+ 'cordova.js' ,
53+ 'index.html' ,
54+ 'model.html' ,
55+ 'schema.html' ,
56+ 'system.html' ,
57+ 'type.html'
58+ ] ) . then ( ( ) => self . skipWaiting ( ) ) ;
59+ } )
60+ ) ;
61+ } ) ;
62+
63+ self . addEventListener ( 'activate' , event => {
64+ event . waitUntil (
65+ clearCaches ( ) . then ( ( ) => {
66+ return self . clients . claim ( ) ;
67+ } )
68+ ) ;
69+ } ) ;
70+
71+ self . addEventListener ( 'fetch' , event => {
72+ if ( event . request . cache === 'only-if-cached' && event . request . mode !== 'same-origin' ) {
73+ return ;
74+ }
75+ event . respondWith (
76+ caches . match ( event . request , { ignoreSearch : true } ) . then ( response => {
77+ return response || fetch ( event . request ) ;
78+ } )
79+ ) ;
80+ } ) ;
0 commit comments