diff --git a/Gruntfile.js b/Gruntfile.js index ef614e330..384ab0182 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -217,6 +217,8 @@ module.exports = function(grunt) { // dest/js/piskel-packaged-min.js should have been created by the uglify task {src: ['dest/tmp/js/piskel-packaged-min.js'], dest: 'dest/prod/js/piskel-packaged-min' + version + '.js'}, {src: ['dest/tmp/index.html'], dest: 'dest/prod/index.html'}, + {src: ['src/manifest.webmanifest'], dest: 'dest/prod/manifest.webmanifest'}, + {src: ['src/service-worker.js'], dest: 'dest/prod/service-worker.js'}, {src: ['src/logo.png'], dest: 'dest/prod/logo.png'}, {src: ['src/js/lib/gif/gif.ie.worker.js'], dest: 'dest/prod/js/lib/gif/gif.ie.worker.js'}, {expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/prod/', filter: 'isFile'}, @@ -229,6 +231,8 @@ module.exports = function(grunt) { {src: ['dest/tmp/index.html'], dest: 'dest/dev/index.html'}, {src: ['src/piskel-script-list.js'], dest: 'dest/dev/piskel-script-list.js'}, {src: ['src/piskel-style-list.js'], dest: 'dest/dev/piskel-style-list.js'}, + {src: ['src/manifest.webmanifest'], dest: 'dest/dev/manifest.webmanifest'}, + {src: ['src/service-worker.js'], dest: 'dest/dev/service-worker.js'}, {expand: true, src: ['js/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'}, {expand: true, src: ['css/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'}, {expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/dev/', filter: 'isFile'}, diff --git a/src/img/app-192.png b/src/img/app-192.png new file mode 100644 index 000000000..705260636 Binary files /dev/null and b/src/img/app-192.png differ diff --git a/src/img/app-512.png b/src/img/app-512.png new file mode 100644 index 000000000..fffa64b82 Binary files /dev/null and b/src/img/app-512.png differ diff --git a/src/index.html b/src/index.html index 946f71d68..93f43b64c 100644 --- a/src/index.html +++ b/src/index.html @@ -7,6 +7,7 @@ +
navigator.serviceWorker.register("service-worker.js")); + /** * See @Gruntfile.js => after build, @@version is replaced by the build version */ diff --git a/src/service-worker.js b/src/service-worker.js new file mode 100644 index 000000000..60dbc6093 --- /dev/null +++ b/src/service-worker.js @@ -0,0 +1,18 @@ +self.Piskel = { + version: 0.152, + cache: true +} +self.addEventListener("activate",event => { + event.waitUntil(caches.keys().then(versions => Promise.all(versions.map(cache => { + if (cache !== Piskel.version) return caches.delete(cache); + })))); + event.waitUntil(clients.claim()); +}); +self.addEventListener("fetch",event => { + event.respondWith(caches.match(event.request).then(response => { + return response || fetch(event.request).then(async response => { + if (Piskel.cache) caches.open(Piskel.version).then(cache => cache.put(event.request,response)); + return response.clone(); + }); + })); +}); \ No newline at end of file diff --git a/src/templates/debug-header.html b/src/templates/debug-header.html index c59f4684b..0f203386f 100644 --- a/src/templates/debug-header.html +++ b/src/templates/debug-header.html @@ -5,13 +5,21 @@ .fake-piskelapp-header { position: relative; + left: env(titlebar-area-x); + top: env(titlebar-area-y); text-align: center; + max-width: env(titlebar-area-width); height: 40px; + max-height: env(titlebar-area-height); line-height: 40px; font-size: 24px; - background: black; + background: #2d2d2d; color: gold; z-index: 100; + -webkit-app-region: drag; + } + .fake-piskelapp-header > * { + -webkit-app-region: no-drag; } .piskel-name.piskel-name-saving {