You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pouchdb.apache.org by ja...@apache.org on 2026/05/16 09:39:24 UTC
(pouchdb) 11/18: fix: formatting issues in serviceworker output
This is an automated email from the ASF dual-hosted git repository.
janl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pouchdb.git
commit c4ed95ed8b27c43b371d7d9051f1b12f8a7ddb75
Author: Alex Feyerke <al...@neighbourhood.ie>
AuthorDate: Mon May 4 14:34:34 2026 +0200
fix: formatting issues in serviceworker output
---
docs/serviceWorker.js.liquid | 43 +++++++++++++++++++------------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/docs/serviceWorker.js.liquid b/docs/serviceWorker.js.liquid
index 1a557c4a1..7cd76c4f3 100644
--- a/docs/serviceWorker.js.liquid
+++ b/docs/serviceWorker.js.liquid
@@ -13,21 +13,16 @@ var criticalAssets = [
'/static/css/pouchdb.css',
];
+{%- assign pages = collections.pages | where_exp: "page", "page.url != '/manifest.appcache'" -%}
+{% assign guides = collections.guides %}
+
var pages = [
- {% for page in collections.pages %}
- {% if page.url != '/manifest.appcache' %}
- '{{ page.url | replace:'index.html','' }}',
- {% endif %}
- {% endfor %}
- {% for page in collections.guides %}
- '{{ page.url | replace:'index.html','' }}',
- {% endfor %}
-];
+ {% for page in pages %}'{{ page.url | replace:'index.html','' }}',
+ {% endfor %}{% for page in guides %}'{{ page.url | replace:'index.html','' }}'{% unless forloop.last %},{% endunless %}
+ {% endfor %}];
-var blogPosts = [
- {% for page in collections.posts %}
- '{{ page.url | replace:'index.html','' }}',
- {% endfor %}
+var blogPosts = [{% for page in collections.posts %}
+ '{{ page.url | replace:'index.html','' }}',{% endfor %}
];
// Only cache the first blog page
@@ -40,33 +35,33 @@ var nonCriticalAssets =
'https://cdn.jsdelivr.net/npm/pouchdb/dist/pouchdb.min.js',
]
.concat(pages)
- .filter(function(file) {
+ .filter(function (file) {
return file.indexOf('/blog/page') === -1;
})
.concat(blogPosts.slice(0, 5)); // Let's only cache the first five by default
-self.addEventListener('install', function(event) {
+self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(newCacheName)
- .then(function(cache) {
+ .then(function (cache) {
cache.addAll(nonCriticalAssets);
// Only return the criticalAssets to waitUntil
// This will allow the noncritical assets to fail
return cache.addAll(criticalAssets);
})
- .then(function() {
+ .then(function () {
return self.skipWaiting();
})
);
});
-self.addEventListener('activate', function(event) {
+self.addEventListener('activate', function (event) {
// remove caches beginning "pouchdb-" that aren't the new cache
event.waitUntil(
caches.keys()
- .then(function(cacheNames) {
+ .then(function (cacheNames) {
return Promise.all(
- cacheNames.map(function(cacheName) {
+ cacheNames.map(function (cacheName) {
if (!/^pouchdb-/.test(cacheName)) {
return;
}
@@ -76,19 +71,19 @@ self.addEventListener('activate', function(event) {
})
);
})
- .then(function() {
+ .then(function () {
return self.clients.claim();
})
);
});
-self.addEventListener('fetch', function(event) {
+self.addEventListener('fetch', function (event) {
// Try the cache, if it's not in there try the network, then cache that response
// if that network request fails show the offline.html page.
event.respondWith(
- caches.open(newCacheName).then(function(cache) {
+ caches.open(newCacheName).then(function (cache) {
return cache.match(event.request).then(function (response) {
- return response || fetch(event.request).then(function(response) {
+ return response || fetch(event.request).then(function (response) {
cache.put(event.request, response.clone());
return response;
}).catch(function () {