From 7ea7af287774a8cb7fcc78945124e306c79285d5 Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Sun, 11 Sep 2016 02:30:50 -0300 Subject: [PATCH 1/7] Updated live demo url --- readme.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 8e80fe7..fcd9f31 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ If you are starting from scratch and want to see it working right away, you can You can access this page and see a live demo of DSW working. After loading the page the first time, it will install the service worker. When opening it the second time, it will cache everything according to the defined rules (described in each block and link). You can then go offline and reload the page to validate it. -[Dynamic Service Worker demo](https://dsw-demo-zrrauyeple.now.sh) +[Dynamic Service Worker demo](https://dsw-demo-jmfnlolzjo.now.sh) ## Advantages @@ -42,14 +42,10 @@ Or locally: ```npm install dsw --save-dev``` -## TL;DR - -Want to just see it working as fast as possible?
-Clone the project, go to its directory, install it and run `npm run try` ## Using it -DSW will look for a file called `dswfile.json`. So: +DSW will look for a file called `dswfile.json`, just like gulp or grunt. So: ``` cd path-to-your-project @@ -531,6 +527,11 @@ DSW.onNetworkStatusChange(function(connected){ * This depends on browser support...some browser will say the device is online even though there is no internet connection, just because the device is connected to a private network(with a rounter). +## Sandbox + +Want to just see it working as fast as possible?
+Clone the project, go to its directory, install it and run `npm run try` + # Contributing So, you want to contribute? Cool! We need it! :) From 62f0e21aeea92273c2f409832b49a1d8038c7537 Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Sat, 10 Sep 2016 23:28:36 -0700 Subject: [PATCH 2/7] Remove travis ci semvar locks --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 118408e..fdbd0f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js + node_js: - - "4.2.6" - - "5.10" - - "6.1" + - 6 + - 5 + - 4 From ca4f34e73419eae07b0496114b7bdadeb57cc027 Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Sat, 10 Sep 2016 23:30:30 -0700 Subject: [PATCH 3/7] Fixed indentation in readme --- readme.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/readme.md b/readme.md index 8e80fe7..56eca06 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ Clone the project, go to its directory, install it and run `npm run try` DSW will look for a file called `dswfile.json`. So: -``` +```bash cd path-to-your-project touch dswfile.json ``` @@ -61,19 +61,19 @@ You will use your prefered editor to make changes to this file later. And now, you will add this to your `index.html` file, like so, in the `head` element: ```html - - - - + + + + ``` Done! Now, for any change in your Dynamic Service Worker configuration, just run the `dsw` command line on your project.
From 385d271585085750dbac59b054cabedbf2988052 Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Mon, 12 Sep 2016 00:40:06 -0300 Subject: [PATCH 4/7] Describing the trace feature in Readme --- readme.md | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index fcd9f31..a6da2e0 100644 --- a/readme.md +++ b/readme.md @@ -21,9 +21,10 @@ You can then go offline and reload the page to validate it. ## Advantages -- Use of variables +- Use of variables to build URLs and redirects - Different strategies (offline-first, online-first or fastest) - Easy-to-set rules for 404 pages, redirects, cache or use indexedDB, or outpus +- Trace requests to debug your configuration, rules and filters - Decision over cache naming and versioning for each matching request - Many named rules (for future debugging tooling...I imagine we can have a lighthouse-like page for debugging your service workers and your rules) - Support for indexedDB @@ -45,7 +46,10 @@ Or locally: ## Using it -DSW will look for a file called `dswfile.json`, just like gulp or grunt. So: +DSW will look for a file called `dswfile.json`, just like gulp or grunt do.
+So: + +1) Go to your project's root directory and create the `dswfile.json`. ``` cd path-to-your-project @@ -54,7 +58,7 @@ touch dswfile.json You will use your prefered editor to make changes to this file later. -And now, you will add this to your `index.html` file, like so, in the `head` element: +2) Add this to your `index.html` file, in the `head` element: ```html @@ -72,13 +76,19 @@ And now, you will add this to your `index.html` file, like so, in the `head` ele ``` -Done! Now, for any change in your Dynamic Service Worker configuration, just run the `dsw` command line on your project.
-For ever new change or version, you will have to run `dsw` again, so it will generate the updated service worker file.
+3) Now, for any change in your Dynamic Service Worker configuration, just run(in your project's root directory): + +```dsw``` + +You can also use `dsw path-to-your/project`.
+This will generate the `webapp.manifest` and `dsw.js` files in your project's root directory. + +4) For every new change or version, you will have to run `dsw` again, so it will generate the updated service worker file.
This will create the `manifest` (if not there, already) and the `dsw.js` file. To do so, if you installed it globally: -```dsw path-to-your-project``` +```dsw path-to-your/project``` If you installed locally, though: @@ -88,8 +98,6 @@ This second example is specially useful if you intend to run it in a stand alone From now on, let's work as if you had installed it globally in our examples. -You will notice a `dsw.js` file that has been created in your project's root path. - Now, let's set up your project's offline configuration. When you change something in your `dswfile.json`, you shall re-execute the command above. @@ -246,6 +254,19 @@ Well, it uses the `cacheApi` to store as requests, only your keys. When you try This way, you can access the information in your IndexedDB by yourself, while your requests will automatically deal with it, too. +### Tracing and debugging + +Yes, you can debug your configuration and trace requests!
+The API for that is quite simple and very powerful. + +```js +DSW.trace('/some/matching-pattern', function(data){ + console.log(data); +}); +``` + +This is it. Now, any request that matches `/some/matching-pattern` will be sent to your callback function with all the trace information.
+This data includes all the steps and different states your requests have been through. This way you validate and debug your rules. # Examples From ff84c52c7f4053e6f02b6af10d21c68e1b6d20c2 Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Mon, 12 Sep 2016 00:47:17 -0300 Subject: [PATCH 5/7] Better readme --- readme.md | 4 ++-- sandbox/index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 5f7846a..99ca682 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ If you are starting from scratch and want to see it working right away, you can You can access this page and see a live demo of DSW working. After loading the page the first time, it will install the service worker. When opening it the second time, it will cache everything according to the defined rules (described in each block and link). You can then go offline and reload the page to validate it. -[Dynamic Service Worker demo](https://dsw-demo-jmfnlolzjo.now.sh) +[Dynamic Service Worker demo](https://dsw-demo-jxhxbuvhpi.now.sh) ## Advantages @@ -43,7 +43,6 @@ Or locally: ```npm install dsw --save-dev``` - ## Using it DSW will look for a file called `dswfile.json`, just like gulp or grunt do.
@@ -68,6 +67,7 @@ You will use your prefered editor to make changes to this file later. DSW.setup() .then(() => { // inform the user your page works offline, now! + // maybe, consider reloading the page automaticaly }) .catch(() => { // do something if the page will not work offline diff --git a/sandbox/index.html b/sandbox/index.html index 6f1a572..1e4f043 100644 --- a/sandbox/index.html +++ b/sandbox/index.html @@ -23,7 +23,7 @@ el.classList.add('offline-support'); el.innerHTML = 'Offline enabled
(Reloading the page)'; setTimeout(function(){ - //history.go(0); + history.go(0); }, 6000); }) .catch(function(error){ From 6aaeb2bf915b229b4db3e682b9d5be39cb3067fb Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Mon, 12 Sep 2016 00:49:57 -0300 Subject: [PATCH 6/7] Added npm log to gitignore --- .gitignore | 1 + sandbox/package.json | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e5ed4ef..ab299fc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .DS_Store tests/index/ .tmp-dsw-lib.js +npm-debug.log diff --git a/sandbox/package.json b/sandbox/package.json index b559d3b..89e7bc5 100644 --- a/sandbox/package.json +++ b/sandbox/package.json @@ -1,11 +1,11 @@ { - "name": "dsw-demo", - "version": "0.0.1", - "dependencies": { - "dsw": "*", - "http-server": "*" - }, - "scripts": { - "start": "http-server -p 80" - } -} \ No newline at end of file + "name": "dsw-demo", + "version": "0.0.1", + "dependencies": { + "dsw": "*", + "http-server": "*" + }, + "scripts": { + "start": "http-server -p 80" + } +} From 80526752fd209c8bfc918057e005a443524115db Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Mon, 12 Sep 2016 00:50:37 -0300 Subject: [PATCH 7/7] 1.8.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5683db7..a5415bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsw", - "version": "1.8.0", + "version": "1.8.1", "description": "Dynamic Service Worker, offline Progressive Web Apps much easier", "bin": { "dsw": "./bin/index.js"