Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 0e657d9

Browse files
committed
Updated docs + rename to pwabuilder + package version
1 parent 4f6261f commit 0e657d9

File tree

17 files changed

+227
-227
lines changed

17 files changed

+227
-227
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
manifoldjs-lib
1+
pwabuilder-lib
22

33
Copyright (c) Microsoft Corporation
44

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# manifoldjs-lib
1+
# pwabuilder-lib
22

3-
## ManifoldJS Core Library
3+
## PWA Builder Core Library
44

5-
The library contains the core modules required by [ManifoldJS](https://github.com/manifoldjs/ManifoldJS), a tool for creating hosted web applications based on a [W3C Web App manifest](http://www.w3.org/TR/appmanifest/).
5+
The library contains the core modules required by [PWA Builder](https://github.com/manifoldjs/ManifoldJS), a tool for creating hosted web applications based on a [W3C Web App manifest](http://www.w3.org/TR/appmanifest/).
66

77
## Installation
88

99
```
10-
npm install manifoldjs-lib
10+
npm install pwabuilder-lib
1111
```
1212
In node.js:
1313

1414
```
15-
var lib = require('manifoldjs-lib')
15+
var lib = require('pwabuilder-lib')
1616
```
1717

1818
## Documentation
1919
To get started, visit our [wiki](https://github.com/manifoldjs/ManifoldJS/wiki).
2020

2121
## License
2222

23-
> manifoldjs-lib
23+
> pwabuilder-lib
2424
2525
> Copyright (c) Microsoft Corporation
2626
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//This is the "Offline page" service worker
2-
3-
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4-
if (navigator.serviceWorker.controller) {
5-
console.log('[Manifoldjs] active service worker found, no need to register')
6-
} else {
7-
//Register the ServiceWorker
8-
navigator.serviceWorker.register('manifoldjs-sw.js', {
9-
scope: './'
10-
}).then(function(reg) {
11-
console.log('Service worker has been registered for scope:'+ reg.scope);
12-
});
13-
}
14-
1+
//This is the "Offline page" service worker
2+
3+
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4+
if (navigator.serviceWorker.controller) {
5+
console.log('[PWA Builder] active service worker found, no need to register')
6+
} else {
7+
//Register the ServiceWorker
8+
navigator.serviceWorker.register('pwabuider-sw.js', {
9+
scope: './'
10+
}).then(function(reg) {
11+
console.log('Service worker has been registered for scope:'+ reg.scope);
12+
});
13+
}
14+
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
//This is the "Offline page" service worker
2-
3-
//Install stage sets up the offline page in the cahche and opens a new cache
4-
self.addEventListener('install', function(event) {
5-
var offlinePage = new Request('offline.html');
6-
event.waitUntil(
7-
fetch(offlinePage).then(function(response) {
8-
return caches.open('manifoldjs-offline').then(function(cache) {
9-
console.log('[Manifoldjs] Cached offline page during Install'+ response.url);
10-
return cache.put(offlinePage, response);
11-
});
12-
}));
13-
});
14-
15-
//If any fetch fails, it will show the offline page.
16-
//Maybe this should be limited to HTML documents?
17-
self.addEventListener('fetch', function(event) {
18-
event.respondWith(
19-
fetch(event.request).catch(function(error) {
20-
console.error( '[Manifoldjs] Network request Failed. Serving offline page ' + error );
21-
return caches.open('manifoldjs-offline').then(function(cache) {
22-
return cache.match('offline.html');
23-
});
24-
}));
25-
});
26-
27-
//This is a event that can be fired from your page to tell the SW to update the offline page
28-
self.addEventListener('refreshOffline', function(response) {
29-
return caches.open('manifoldjs-offline').then(function(cache) {
30-
console.log('[Manifoldjs] Offline page updated from refreshOffline event: '+ response.url);
31-
return cache.put(offlinePage, response);
32-
});
1+
//This is the "Offline page" service worker
2+
3+
//Install stage sets up the offline page in the cahche and opens a new cache
4+
self.addEventListener('install', function(event) {
5+
var offlinePage = new Request('offline.html');
6+
event.waitUntil(
7+
fetch(offlinePage).then(function(response) {
8+
return caches.open('pwabuilder-offline').then(function(cache) {
9+
console.log('[PWA Builder] Cached offline page during Install'+ response.url);
10+
return cache.put(offlinePage, response);
11+
});
12+
}));
13+
});
14+
15+
//If any fetch fails, it will show the offline page.
16+
//Maybe this should be limited to HTML documents?
17+
self.addEventListener('fetch', function(event) {
18+
event.respondWith(
19+
fetch(event.request).catch(function(error) {
20+
console.error( '[PWA Builder] Network request Failed. Serving offline page ' + error );
21+
return caches.open('pwabuilder-offline').then(function(cache) {
22+
return cache.match('offline.html');
23+
});
24+
}));
25+
});
26+
27+
//This is a event that can be fired from your page to tell the SW to update the offline page
28+
self.addEventListener('refreshOffline', function(response) {
29+
return caches.open('pwabuilder-offline').then(function(cache) {
30+
console.log('[PWA Builder] Offline page updated from refreshOffline event: '+ response.url);
31+
return cache.put(offlinePage, response);
32+
});
3333
});
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//This is the "Offline copy of pages" service worker
2-
3-
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4-
if (navigator.serviceWorker.controller) {
5-
console.log('[Manifoldjs] active service worker found, no need to register')
6-
} else {
7-
//Register the ServiceWorker
8-
navigator.serviceWorker.register('manifoldjs-sw.js', {
9-
scope: './'
10-
}).then(function(reg) {
11-
console.log('Service worker has been registered for scope:'+ reg.scope);
12-
});
13-
}
14-
1+
//This is the "Offline copy of pages" service worker
2+
3+
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4+
if (navigator.serviceWorker.controller) {
5+
console.log('[PWA Builder] active service worker found, no need to register')
6+
} else {
7+
//Register the ServiceWorker
8+
navigator.serviceWorker.register('pwabuilder-sw.js', {
9+
scope: './'
10+
}).then(function(reg) {
11+
console.log('Service worker has been registered for scope:'+ reg.scope);
12+
});
13+
}
14+
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
//This is the "Offline copy of pages" wervice worker
2-
3-
//Install stage sets up the index page (home page) in the cahche and opens a new cache
4-
self.addEventListener('install', function(event) {
5-
var indexPage = new Request('index.html');
6-
event.waitUntil(
7-
fetch(indexPage).then(function(response) {
8-
return caches.open('manifoldjs-offline').then(function(cache) {
9-
console.log('[Manifoldjs] Cached index page during Install'+ response.url);
10-
return cache.put(indexPage, response);
11-
});
12-
}));
13-
});
14-
15-
//If any fetch fails, it will look for the request in the cache and serve it from there first
16-
self.addEventListener('fetch', function(event) {
17-
var updateCache = function(request){
18-
return caches.open('manifoldjs-offline').then(function (cache) {
19-
return fetch(request).then(function (response) {
20-
console.log('[manifoldjs] add page to offline'+response.url)
21-
return cache.put(request, response);
22-
});
23-
});
24-
};
25-
26-
event.waitUntil(updateCache(event.request));
27-
28-
event.respondWith(
29-
fetch(event.request).catch(function(error) {
30-
console.log( '[Manifoldjs] Network request Failed. Serving content from cache: ' + error );
31-
32-
//Check to see if you have it in the cache
33-
//Return response
34-
//If not in the cache, then return error page
35-
return caches.open('manifoldjs-offline').then(function (cache) {
36-
return cache.match(event.request).then(function (matching) {
37-
var report = !matching || matching.status == 404?Promise.reject('no-match'): matching;
38-
return report
39-
});
40-
});
41-
})
42-
);
43-
})
1+
//This is the "Offline copy of pages" wervice worker
2+
3+
//Install stage sets up the index page (home page) in the cahche and opens a new cache
4+
self.addEventListener('install', function(event) {
5+
var indexPage = new Request('index.html');
6+
event.waitUntil(
7+
fetch(indexPage).then(function(response) {
8+
return caches.open('pwabuilder-offline').then(function(cache) {
9+
console.log('[PWA Builder] Cached index page during Install'+ response.url);
10+
return cache.put(indexPage, response);
11+
});
12+
}));
13+
});
14+
15+
//If any fetch fails, it will look for the request in the cache and serve it from there first
16+
self.addEventListener('fetch', function(event) {
17+
var updateCache = function(request){
18+
return caches.open('pwabuilder-offline').then(function (cache) {
19+
return fetch(request).then(function (response) {
20+
console.log('[PWA Builder] add page to offline'+response.url)
21+
return cache.put(request, response);
22+
});
23+
});
24+
};
25+
26+
event.waitUntil(updateCache(event.request));
27+
28+
event.respondWith(
29+
fetch(event.request).catch(function(error) {
30+
console.log( '[PWA Builder] Network request Failed. Serving content from cache: ' + error );
31+
32+
//Check to see if you have it in the cache
33+
//Return response
34+
//If not in the cache, then return error page
35+
return caches.open('pwabuilder-offline').then(function (cache) {
36+
return cache.match(event.request).then(function (matching) {
37+
var report = !matching || matching.status == 404?Promise.reject('no-match'): matching;
38+
return report
39+
});
40+
});
41+
})
42+
);
43+
})
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
2-
3-
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4-
if (navigator.serviceWorker.controller) {
5-
console.log('[Manifoldjs] active service worker found, no need to register')
6-
} else {
7-
8-
//Register the ServiceWorker
9-
navigator.serviceWorker.register('manifoldjs-sw.js', {
10-
scope: './'
11-
}).then(function(reg) {
12-
console.log('Service worker has been registered for scope:'+ reg.scope);
13-
});
14-
}
15-
1+
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
2+
3+
//Add this below content to your HTML page, or add the js file to your page at the very top to register sercie worker
4+
if (navigator.serviceWorker.controller) {
5+
console.log('[PWA Builder] active service worker found, no need to register')
6+
} else {
7+
8+
//Register the ServiceWorker
9+
navigator.serviceWorker.register('pwabuilder-sw.js', {
10+
scope: './'
11+
}).then(function(reg) {
12+
console.log('Service worker has been registered for scope:'+ reg.scope);
13+
});
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
2-
3-
//Install stage sets up the offline page in the cahche and opens a new cache
4-
self.addEventListener('install', function(event) {
5-
event.waitUntil(preLoad());
6-
});
7-
8-
var preLoad = function(){
9-
console.log('[Manifoldjs] Install Event processing');
10-
return caches.open('manifoldjs-offline').then(function(cache) {
11-
console.log('[Manifoldjs] Cached index and offline page during Install');
12-
return cache.addAll(['/offline.html', '/index.html']);
13-
});
14-
}
15-
16-
self.addEventListener('fetch', function(event) {
17-
console.log('The service worker is serving the asset.');
18-
event.respondWith(checkResponse(event.request).catch(function() {
19-
return returnFromCache(event.request)}
20-
));
21-
event.waitUntil(addToCache(event.request));
22-
});
23-
24-
var checkResponse = function(request){
25-
return new Promise(function(fulfill, reject) {
26-
fetch(request).then(function(response){
27-
if(response.status !== 404) {
28-
fulfill(response)
29-
} else {
30-
reject()
31-
}
32-
}, reject)
33-
});
34-
};
35-
36-
var addToCache = function(request){
37-
return caches.open('manifoldjs-offline').then(function (cache) {
38-
return fetch(request).then(function (response) {
39-
console.log('[manifoldjs] add page to offline'+response.url)
40-
return cache.put(request, response);
41-
});
42-
});
43-
};
44-
45-
var returnFromCache = function(request){
46-
return caches.open('manifoldjs-offline').then(function (cache) {
47-
return cache.match(request).then(function (matching) {
48-
if(!matching || matching.status == 404) {
49-
return cache.match('offline.html')
50-
} else {
51-
return matching
52-
}
53-
});
54-
});
1+
//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
2+
3+
//Install stage sets up the offline page in the cahche and opens a new cache
4+
self.addEventListener('install', function(event) {
5+
event.waitUntil(preLoad());
6+
});
7+
8+
var preLoad = function(){
9+
console.log('[PWA Builder] Install Event processing');
10+
return caches.open('pwabuilder-offline').then(function(cache) {
11+
console.log('[PWA Builder] Cached index and offline page during Install');
12+
return cache.addAll(['/offline.html', '/index.html']);
13+
});
14+
}
15+
16+
self.addEventListener('fetch', function(event) {
17+
console.log('The service worker is serving the asset.');
18+
event.respondWith(checkResponse(event.request).catch(function() {
19+
return returnFromCache(event.request)}
20+
));
21+
event.waitUntil(addToCache(event.request));
22+
});
23+
24+
var checkResponse = function(request){
25+
return new Promise(function(fulfill, reject) {
26+
fetch(request).then(function(response){
27+
if(response.status !== 404) {
28+
fulfill(response)
29+
} else {
30+
reject()
31+
}
32+
}, reject)
33+
});
34+
};
35+
36+
var addToCache = function(request){
37+
return caches.open('pwabuilder-offline').then(function (cache) {
38+
return fetch(request).then(function (response) {
39+
console.log('[PWA Builder] add page to offline'+response.url)
40+
return cache.put(request, response);
41+
});
42+
});
43+
};
44+
45+
var returnFromCache = function(request){
46+
return caches.open('pwabuilder-offline').then(function (cache) {
47+
return cache.match(request).then(function (matching) {
48+
if(!matching || matching.status == 404) {
49+
return cache.match('offline.html')
50+
} else {
51+
return matching
52+
}
53+
});
54+
});
5555
};

0 commit comments

Comments
 (0)