| Index: polymer_1.0.4/bower_components/platinum-sw/platinum-sw-cache.html
|
| diff --git a/polymer_1.0.4/bower_components/platinum-sw/platinum-sw-cache.html b/polymer_1.0.4/bower_components/platinum-sw/platinum-sw-cache.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5769af13c00c9817b42aeaabf70beb613270fc62
|
| --- /dev/null
|
| +++ b/polymer_1.0.4/bower_components/platinum-sw/platinum-sw-cache.html
|
| @@ -0,0 +1,116 @@
|
| +<!--
|
| +Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
| +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
| +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
| +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
| +Code distributed by Google as part of the polymer project is also
|
| +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
| +-->
|
| +<link rel="import" href="../polymer/polymer.html">
|
| +
|
| +<script>
|
| + /**
|
| + * The `<platinum-sw-cache>` element makes it easy to precache specific resources, perform runtime
|
| + * caching, and serve your cached resources when a network is unavailable.
|
| + * Under the hood, the [sw-toolbox](https://github.com/googlechrome/sw-toolbox) library is used
|
| + * for all the caching and request handling logic.
|
| + * `<platinum-sw-cache>` needs to be a child element of `<platinum-sw-register>`.
|
| + * A simple, yet useful configuration is
|
| + *
|
| + * <platinum-sw-register>
|
| + * <platinum-sw-cache></platinum-sw-cache>
|
| + * </platinum-sw-register>
|
| + *
|
| + * This is enough to have all of the (local) resources your site uses cached at runtime.
|
| + * (It uses the default `defaultCacheStrategy` of "networkFirst".)
|
| + * When there's a network available, visits to your site will go against the network copy of the
|
| + * resources, but if someone visits your site when they're offline, all the cached resources will
|
| + * be used.
|
| + *
|
| + * @demo demo/index.html An offline-capable eReader demo.
|
| + */
|
| + Polymer({
|
| + is: 'platinum-sw-cache',
|
| +
|
| + properties: {
|
| + /**
|
| + * The caching strategy used for all local (i.e. same-origin) requests.
|
| + *
|
| + * For a list of strategies, see the [`sw-toolbox` documentation](https://github.com/GoogleChrome/sw-toolbox#built-in-handlers).
|
| + * Specify a strategy as a string, without the "toolbox" prefix. E.g., for
|
| + * `toolbox.networkFirst`, set `defaultCacheStrategy` to "networkFirst".
|
| + *
|
| + * Note that the "cacheFirst" and "cacheOnly" strategies are not recommended, and may be
|
| + * explicitly prevented in a future release. More information can be found at
|
| + * https://github.com/PolymerElements/platinum-sw#cacheonly--cachefirst-defaultcachestrategy-considered-harmful
|
| + *
|
| + * @see {@link https://github.com/GoogleChrome/sw-toolbox#built-in-handlers}
|
| + */
|
| + defaultCacheStrategy: {
|
| + type: String,
|
| + value: 'networkFirst'
|
| + },
|
| +
|
| + /**
|
| + * Used to provide a list of URLs that are always precached as soon as the service worker is
|
| + * installed. Corresponds to [`sw-toolbox`'s `precache()` method](https://github.com/GoogleChrome/sw-toolbox#toolboxprecachearrayofurls).
|
| + *
|
| + * This is useful for URLs that that wouldn't necessarily be picked up by runtime caching,
|
| + * i.e. a list of resources that are needed by one of the subpages of your site, or a list of
|
| + * resources that are only loaded via user interaction.
|
| + *
|
| + * `precache` can be used in conjunction with `precacheFile`, and the two arrays will be
|
| + * concatenated.
|
| + *
|
| + * @see {@link https://github.com/GoogleChrome/sw-toolbox#toolboxprecachearrayofurls}
|
| + */
|
| + precache: {
|
| + type: Array,
|
| + value: function() { return []; }
|
| + },
|
| +
|
| + /**
|
| + * Used to provide a list of URLs that are always precached as soon as the service worker is
|
| + * installed. Corresponds to [`sw-toolbox`'s `precache()` method](https://github.com/GoogleChrome/sw-toolbox#toolboxprecachearrayofurls).
|
| + *
|
| + * While the `precache` option supports provided the array of URLs in as an inline attribute,
|
| + * this option supports providing them as an array in JSON file, which is fetched at runtime.
|
| + * This is useful if the array is generated via a separate build step, as it's easier to
|
| + * write that output to a file then it is to modify inline HTML content.
|
| + *
|
| + * `precacheFile` can be used in conjunction with `precache`, and the two arrays will be
|
| + * concatenated.
|
| + *
|
| + * @see {@link https://github.com/GoogleChrome/sw-toolbox#toolboxprecachearrayofurls}
|
| + */
|
| + precacheFile: String
|
| + },
|
| +
|
| + _getParameters: function(baseURI) {
|
| + return new Promise(function(resolve) {
|
| + var params = {
|
| + importscriptLate: new URL('bootstrap/sw-toolbox-setup.js', baseURI).href,
|
| + defaultCacheStrategy: this.defaultCacheStrategy,
|
| + precache: this.precache
|
| + };
|
| +
|
| + if (this.precacheFile) {
|
| + window.fetch(this.precacheFile).then(function(response) {
|
| + if (!response.ok) {
|
| + throw Error('unable to load ' + this.precacheFile);
|
| + }
|
| + return response.json();
|
| + }.bind(this)).then(function(files) {
|
| + params.precache = params.precache.concat(files);
|
| + }).catch(function(error) {
|
| + console.info('Skipping precaching: ' + error.message);
|
| + }).then(function() {
|
| + resolve(params);
|
| + });
|
| + } else {
|
| + resolve(params);
|
| + }
|
| + }.bind(this));
|
| + }
|
| + });
|
| +</script>
|
|
|