broccoli-serviceworker
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -5,2 +5,3 @@ var path = require('path'); | ||
var funnel = require('broccoli-funnel'); | ||
var stringifile = require('stringifile'); | ||
@@ -11,3 +12,3 @@ var serviceWorker = require('./service-worker.js'); | ||
name: 'broccoli-serviceworker', | ||
included: function (app) { | ||
@@ -17,3 +18,3 @@ this.app = app; | ||
}, | ||
initializeOptions: function () { | ||
@@ -35,6 +36,6 @@ var appOptions = this.app.project.config(this.app.env); | ||
this.serviceWorkerOptions = options; | ||
}, | ||
}, | ||
postprocessTree: function (type, tree) { | ||
var options = this.serviceWorkerOptions; | ||
var options = this.serviceWorkerOptions; | ||
@@ -51,3 +52,9 @@ if (type === 'all' && options.enabled) { | ||
treeFor: function() {} | ||
treeFor: function() {}, | ||
contentFor: function(type, config) { | ||
if (config.environment !== 'test' && type === 'body-footer') { | ||
return stringifile('registration.js', 'script', __dirname); | ||
} | ||
} | ||
}; |
@@ -15,2 +15,3 @@ var fs = require("fs"); | ||
this.addPolyfill = options.addPolyfill || true; | ||
this.skipWaiting = options.skipWaiting || false; | ||
this.debug = options.debug || true; | ||
@@ -30,2 +31,3 @@ this.dynamicCache = options.dynamicCache || []; | ||
var addPolyfill = this.addPolyfill; | ||
var skipWaiting = this.skipWaiting; | ||
var debug = this.debug; | ||
@@ -82,3 +84,3 @@ var dynamicCache = this.dynamicCache; | ||
return; | ||
lines.push(createArrayLine("'"+file+"'", idx, array.length)); | ||
lines.push(createArrayLine(" '"+file+"'", idx, array.length)); | ||
}); | ||
@@ -93,2 +95,7 @@ lines.push("];"); | ||
addDebugLine("'Handling install event. Resources to pre-fetch:', urlsToPrefetch", debug, lines); | ||
if (skipWaiting) { | ||
lines.push(" if (self.skipWaiting) { self.skipWaiting(); }"); | ||
} | ||
lines.push(" event.waitUntil("); | ||
@@ -95,0 +102,0 @@ lines.push(" caches.open(CURRENT_CACHES['prefetch']).then(function(cache) {"); |
{ | ||
"name": "broccoli-serviceworker", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A broccoli plugin automating ServiceWorker file creation for Broccoli and Ember.js", | ||
@@ -29,8 +29,9 @@ "main": "lib/service-worker.js", | ||
"dependencies": { | ||
"broccoli-funnel": "~0.2.3", | ||
"broccoli-kitchen-sink-helpers": "~0.2.2", | ||
"broccoli-merge-trees": "~0.1.4", | ||
"broccoli-funnel": "~1.0.1", | ||
"broccoli-kitchen-sink-helpers": "~0.3.1", | ||
"broccoli-merge-trees": "~1.0.0", | ||
"broccoli-writer": "~0.1.1", | ||
"serviceworker-cache-polyfill": "^3.0.0" | ||
"serviceworker-cache-polyfill": "^3.0.0", | ||
"stringifile": "^0.1.1" | ||
} | ||
} |
@@ -34,2 +34,3 @@ broccoli-serviceworker | ||
Upgrade your `index.html` (see below) and you are done. | ||
The service worker bootstrap logic will be added to your index.html automatically, using contentFor hooks. | ||
@@ -69,3 +70,4 @@ Usage for Broccoli.js | ||
'/api/todos' | ||
] | ||
], | ||
skipWaiting: true | ||
}); | ||
@@ -87,3 +89,4 @@ ``` | ||
In order to use the generated serviceworker, you will need to register the serviceworker. You can do so with the following code: | ||
In order to use the generated serviceworker, you will need to register the serviceworker. This is done automatically if using as an Ember.js addon. | ||
If you're not using Ember.js, you can use the following code: | ||
```HTML | ||
@@ -90,0 +93,0 @@ <!DOCTYPE html> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18330
8
291
105
6
+ Addedstringifile@^0.1.1
+ Addedbroccoli-funnel@1.0.9(transitive)
+ Addedbroccoli-kitchen-sink-helpers@0.3.1(transitive)
+ Addedbroccoli-merge-trees@1.0.0(transitive)
+ Addedexists-sync@0.0.4(transitive)
+ Addedfs-tree-diff@0.5.9(transitive)
+ Addedheimdalljs@0.2.6(transitive)
+ Addedheimdalljs-logger@0.1.10(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedrsvp@3.2.1(transitive)
+ Addedstringifile@0.1.1(transitive)
+ Addedwalk-sync@0.3.4(transitive)
- Removedbroccoli-funnel@0.2.15(transitive)
- Removedbroccoli-kitchen-sink-helpers@0.2.9(transitive)
- Removedbroccoli-merge-trees@0.1.4(transitive)
- Removedfs-tree-diff@0.3.1(transitive)
- Removedminimatch@2.0.10(transitive)
- Removedwalk-sync@0.1.30.2.7(transitive)
Updatedbroccoli-funnel@~1.0.1
Updatedbroccoli-merge-trees@~1.0.0