From 809546da5764c9b4d2c1b97af902d73edb9256b0 Mon Sep 17 00:00:00 2001 From: Andrew Dodson Date: Tue, 24 Apr 2018 21:54:04 +0100 Subject: [PATCH 1/4] feat: adorn_sw --- .eslintignore | 1 + README.md | 50 +++++++++++++- adorn_sw.js | 2 + adorn_sw.js.map | 1 + manifest.json | 1 + src/adorn_sw.js | 158 +++++++++++++++++++++++++++++++++++++++++++++ src/lib/indexdb.js | 132 +++++++++++++++++++++++++++++++++++++ webpack.config.js | 37 ++++++++--- 8 files changed, 371 insertions(+), 11 deletions(-) create mode 100644 adorn_sw.js create mode 100644 adorn_sw.js.map create mode 100644 src/adorn_sw.js create mode 100644 src/lib/indexdb.js diff --git a/.eslintignore b/.eslintignore index e070725..1e5f799 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ /node_modules /adorn.js +/adorn_sw.js /_site diff --git a/README.md b/README.md index 0c7bd80..18e2591 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,59 @@ Adorn is a theme for *plain* markup. It aims to make unstyled HTML much more user friendly with minimal fuss. Simply include a style and a script into the document. -Take a look at the simple source of this page [right click view source] - It comprises of two external files: - `/adorn/adorn.css` Basic style for plain markup - `/adorn/adorn.js` Navigtational UI Components, etc... +Take a look at the simple source of this page [right click view source] + + +## Options + +Adorn will derive options from a few places + +- A [Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) + If a Link tag such as `` can be found it will load the address defined there or take a bet on it being in the root at `/manifest.json`, but if neither exists it'll carry on regardless. + +- Document overides come from `` tags with a matching `name` property. + + + +Default site Favicon to be put into page + + "favicon" : "/favicon.ico", + +Github name or name/repo for linking through, edit options + + "github" : "MrSwitch", + +Twitter sharing link + + "twitter:creator" : "@setData", + +Shoutout message appears in top right of navbar + + "shoutout": "Adorn: make more beautiful or attractive.", + +Footer Author link + + "author" : "Andrew Dodson, https://adodson.com", + +Serviceworker URL to register. + + "serviceworker": "./adorn_sw.js", + +Fallover, page to show when offline + + "fallover" : [{ + "mode": "navigate", + "fallover": "/offline.html" + }], + + + + ## Rules diff --git a/adorn_sw.js b/adorn_sw.js new file mode 100644 index 0000000..606cb0f --- /dev/null +++ b/adorn_sw.js @@ -0,0 +1,2 @@ +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=class{constructor(e,t,n){return this.db_name=e||"__adorn__","object"==typeof t?(this.version=1,this.schema=t):(this.version=t||1,this.schema=n),this.table_name="__adorn__",Object.assign(this.scope.bind(this),this)}scope(e){const t=Object.create(this);return t.table_name=e,t}open(e){return new Promise((e,t)=>{const n=self.indexedDB.open(this.db_name,this.version);n.onsuccess=(t=>{e(t.target.result)}),n.onerror=t,n.onupgradeneeded=(e=>{const t=e.target.result;for(const e in this.schema)t.objectStoreNames.contains(e)||t.createObjectStore(e,this.schema[e])})}).then(t=>t.transaction([this.table_name],e).objectStore(this.table_name))}get(e){return new Promise((t,n)=>{this.open().then(r=>{const o=r.get(e);o.onsuccess=(e=>{t(e.target.result)}),o.onerror=(e=>{n(e.target.result)})})})}all(){return new Promise((e,t)=>{this.open().then(n=>{const r=n.openCursor();r.onerror=(e=>{t(e.target.result)});const o=[];r.onsuccess=(t=>{const n=t.target.result;n?(o.push(n.value),n.continue()):e(o)})})})}put(e,t){return new Promise((n,r)=>{"object"==typeof e?t=e:t.key=e,this.open("readwrite").then(e=>{const o=e.put(t);o.onsuccess=(e=>{n(e.target.result)}),o.onerror=(e=>{r(e.target.result)})}).catch(r)})}}},function(e,t,n){const r=new(n(0))("adorn_sw",1,{falloverStore:{autoIncrement:!0}})("falloverStore");var o;function s(e){if(!e)throw"not found";return e}self.addEventListener("install",e=>{e.waitUntil(caches.open("adorn_sw").then(()=>{}))}),self.addEventListener("fetch",e=>{const t=e.request;let n;e.respondWith((async()=>{const e=caches.match(t).then(e=>(e&&(n=n||"cache wins"),e)),c=fetch(t).then(e=>(e&&(n=n||"network wins"),e)),a=(o=[e,c],new Promise((e,t)=>{(o=o.map(e=>Promise.resolve(e).then(s))).forEach(t=>t.then(e)),o.reduce((e,t)=>e.catch(()=>t)).catch(()=>t(Error("All failed")))}));return a.then(()=>{}),c.then(function(e,t){if(!t||200!==t.status||"basic"!==t.type)return t;const n=t.clone();return caches.open("adorn_sw").then(t=>{t.put(e,n)}),t}.bind(null,t)),a.catch(async function(e){const t=(await r.all()).filter(t=>(!t.mode||t.mode===e.mode)&&(!t.url||e.url.match(t.url)))[0];if(t)return caches.match(new Request(t.fallover))}.bind(null,t))})())}),self.addEventListener("message",e=>{const t=e.data;caches.open("adorn_sw").then(e=>{switch(t.type){case"fallover":r.all().then(n=>{const o=n.filter(e=>e.mode===t.mode&&e.url===t.url)[0];if(o&&o.fallover===t.fallover)return;const s=new Request(t.fallover,{mode:"no-cors"});fetch(s).then(n=>(o?o.fallover=t.fallover:r.put(t),e.put(t.fallover,n)))});break;case"add":{const n=new Request(t.url,{mode:"no-cors"});return fetch(n).then(n=>e.put(t.url,n))}}})})}]); +//# sourceMappingURL=adorn_sw.js.map \ No newline at end of file diff --git a/adorn_sw.js.map b/adorn_sw.js.map new file mode 100644 index 0000000..e0566ee --- /dev/null +++ b/adorn_sw.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/lib/indexdb.js","webpack:///./src/adorn_sw.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","default","object","property","prototype","hasOwnProperty","p","s","e","t","[object Object]","version","schema","this","db_name","table_name","assign","scope","bind","inst","create","mode","Promise","accept","reject","db","self","indexedDB","open","onsuccess","event","target","result","onerror","onupgradeneeded","x","objectStoreNames","contains","createObjectStore","then","transaction","objectStore","key","request","openCursor","a","cursor","push","continue","data","put","catch","falloverStore","autoIncrement","promises","emptyHandler","addEventListener","waitUntil","caches","status","respondWith","fromCache","match","b","fromFetch","fetch","promise","resolve","map","forEach","reduce","Error","response","type","responseToCache","clone","cache","async","all","filter","item","url","Request","fallover","frequest"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,KACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,KAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,gBACAC,cACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,YAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAAoB,SAC3B,WAAiC,OAAApB,GAEjC,OADAH,EAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAW,EAAAC,GAAsD,OAAAX,OAAAY,UAAAC,eAAApB,KAAAiB,EAAAC,IAGtDzB,EAAA4B,EAAA,GAIA5B,IAAA6B,EAAA,cAAAC,EAAAC,GCgEA5B,EAAAD,cA5HA8B,YAAArB,EAAAsB,EAAAC,GAeA,OAZAC,KAAAC,QAAAzB,GAAA,YACA,iBAAAsB,GACAE,KAAAF,QAAA,EACAE,K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OAEAC,OAAAC,KACAA,EAAA3D,MAAA2D,EAAA3D,OAAAsB,EAAAtB,SACA2D,EAAAC,KAAAtC,EAAAsC,IAAAnB,MAAAkB,EAAAC,OACA,GAEA,GAAAnB,EACA,OAAAJ,OAAAI,MAAA,IAAAoB,QAAApB,EAAAqB,YAlGAjE,KAAA,KAAAyB,KA3BA,MAkCAjB,KAAA8B,iBAAA,UAAA1B,IAEA,MAAAmB,EAAAnB,EAAAmB,KAGAS,OAAA9B,KA/DA,YA+DAW,KAAAqC,IACA,OAAA3B,EAAAwB,MAEA,eAEArB,EAAA0B,MAAAvC,KAAA4C,IACA,MAAArB,EAAAqB,EAAAJ,OAAAC,KAAA3D,OAAA4B,EAAA5B,MAAA2D,EAAAC,MAAAhC,EAAAgC,KAAA,GACA,GAAAnB,GAEAA,EAAAqB,WAAAlC,EAAAkC,SAEA,OAGA,MAAAC,EAAA,IAAAF,QAAAjC,EAAAkC,UAAkD9D,KAAA,YAElD4C,MAAAmB,GAAA7C,KAAAiC,IAEAV,EACAA,EAAAqB,SAAAlC,EAAAkC,SAGA/B,EAAAF,IAAAD,GAEA2B,EAAA1B,IAAAD,EAAAkC,SAAAX,OAGA,MAEA,WACA,MAAA7B,EAAA,IAAAuC,QAAAjC,EAAAgC,KAA2C5D,KAAA,YAC3C,OAAA4C,MAAAtB,GAAAJ,KAAAiC,GAAAI,EAAA1B,IAAAD,EAAAgC,IAAAT","file":"adorn_sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// indexStorage\n// This wraps an interface around IndexDB to create an object store\n\n// Create an instance of the db\n// The Cache name is optional, it will allow us to group various datasets (the default is __tricks__)\n\nclass DB {\n\tconstructor (name, version, schema) {\n\n\t\t// Define the schema to use in the connection\n\t\tthis.db_name = name || '__adorn__';\n\t\tif (typeof version === 'object') {\n\t\t\tthis.version = 1;\n\t\t\tthis.schema = version;\n\t\t}\n\t\telse {\n\t\t\tthis.version = version || 1;\n\t\t\tthis.schema = schema;\n\t\t}\n\t\tthis.table_name = '__adorn__';\n\n\t\t// Return a function\n\t\treturn Object.assign(this.scope.bind(this), this);\n\t}\n\n\tscope (name) {\n\t\t// Create a new store instance\n\t\tconst inst = Object.create(this);\n\t\tinst.table_name = name;\n\t\treturn inst;\n\t}\n\n\topen(mode) {\n\t\treturn new Promise((accept, reject) => {\n\t\t\tconst db = self.indexedDB.open(this.db_name, this.version);\n\t\t\tdb.onsuccess = event => {\n\t\t\t\taccept(event.target.result);\n\t\t\t};\n\t\t\tdb.onerror = reject;\n\t\t\tdb.onupgradeneeded = event => {\n\t\t\t\tconst db = event.target.result;\n\n\t\t\t\t// this should probably do something;\n\t\t\t\tfor (const x in this.schema) {\n\t\t\t\t\tif (!db.objectStoreNames.contains(x)) {\n\t\t\t\t\t\tdb.createObjectStore(x, this.schema[x]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t})\n\t\t\t.then(db => {\n\t\t\t// The DB connection has been established\n\t\t\t// Lets create a connection to it\n\t\t\t\tconst transaction = db.transaction([this.table_name], mode);\n\n\t\t\t\t// Return the API for the Object Store\n\t\t\t\treturn transaction.objectStore(this.table_name);\n\t\t\t});\n\t}\n\n\tget (key) {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.get(key);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tall () {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.openCursor();\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\n\t\t\t\tconst a = [];\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\tconst cursor = event.target.result;\n\t\t\t\t\tif (cursor) {\n\t\t\t\t\t\ta.push(cursor.value);\n\t\t\t\t\t\tcursor.continue();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\taccept(a);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tput (key, data) {\n\n\t\treturn new Promise((accept, reject) => {\n\n\t\t\t// Allow data as a thing on its own.\n\t\t\tif (typeof key === 'object') {\n\t\t\t\tdata = key;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdata.key = key;\n\t\t\t}\n\n\t\t\t// Open up a connection to indexdb\n\t\t\tthis.open('readwrite').then(objectStore => {\n\t\t\t\tconst request = objectStore.put(data);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t})\n\t\t\t\t.catch(reject);\n\n\t\t});\n\t}\n}\n\nmodule.exports = DB;\n","// Service Worker\n// Caches pages visited by agent for viewing offline\n\nconst CACHE_NAME = 'adorn_sw';\nconst VERSION = 1;\n\nconst DB = require('./lib/indexdb');\nconst db = new DB('adorn_sw', VERSION, {\n\tfalloverStore: {\n\t\tautoIncrement: true\n\t}\n});\n\nconst falloverStore = db('falloverStore');\n\nself.addEventListener('install', event => {\n\t// Perform install steps\n\tevent.waitUntil(\n\t\tcaches.open(CACHE_NAME).then(() => {\n\t\t\t// Opened cache\n\t\t})\n\t);\n});\n\nself.addEventListener('fetch', event => {\n\tconst request = event.request;\n\tlet status;\n\tevent.respondWith((async () => {\n\t\tconst fromCache = caches.match(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'cache wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst fromFetch = fetch(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'network wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst promise = promiseAny([fromCache, fromFetch]);\n\n\t\tpromise.then(() => {\n\t\t\t// Report the success\n\t\t\tconsole.log(status, request.url); // eslint-disable-line no-console\n\t\t});\n\n\t\t// Save\n\t\tfromFetch.then(cacheUpdate.bind(null, request));\n\n\t\treturn promise.catch(offlineFallback.bind(null, request));\n\n\t})());\n\n});\n\n\n// https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/\n\nfunction promiseAny(promises) {\n\treturn new Promise((resolve, reject) => {\n\t\t// make sure promises are all promises\n\t\tpromises = promises.map(p => Promise.resolve(p).then(emptyHandler));\n\t\t// resolve this promise as soon as one resolves\n\t\tpromises.forEach(p => p.then(resolve));\n\t\t// reject if all promises reject\n\t\tpromises\n\t\t\t.reduce((a, b) => a.catch(() => b))\n\t\t\t.catch(() => reject(Error('All failed')));\n\t});\n}\n\n\nfunction emptyHandler(r) {\n\tif (!r) {\n\t\tthrow 'not found';\n\t}\n\treturn r;\n}\n\nfunction cacheUpdate(request, response) {\n\n\t// Check if we received a valid response\n\tif (!response || response.status !== 200 || response.type !== 'basic') {\n\t\treturn response;\n\t}\n\n\tconst responseToCache = response.clone();\n\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tcache.put(request, responseToCache);\n\t});\n\n\treturn response;\n}\n\nasync function offlineFallback(request) {\n\n\tconst fallover = await falloverStore.all();\n\n\tconst match = fallover.filter(item => (\n\t\t(!item.mode || item.mode === request.mode)\n\t\t&& (!item.url || request.url.match(item.url))\n\t))[0];\n\n\tif (match) {\n\t\treturn caches.match(new Request(match.fallover));\n\t}\n\n\treturn;\n}\n\n\nself.addEventListener('message', event => {\n\n\tconst data = event.data;\n\n\t// Open cache for actions\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tswitch (data.type) {\n\n\t\t\tcase 'fallover': {\n\t\t\t\t// Has this already been added?\n\t\t\t\tfalloverStore.all().then(fallover => {\n\t\t\t\t\tconst match = fallover.filter(item => item.mode === data.mode && item.url === data.url)[0];\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\t// does this need\n\t\t\t\t\t\tif (match.fallover === data.fallover) {\n\t\t\t\t\t\t\t// nothing to do\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst frequest = new Request(data.fallover, {mode: 'no-cors'});\n\n\t\t\t\t\tfetch(frequest).then(response => {\n\t\t\t\t\t\t// Just update the existing record\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tmatch.fallover = data.fallover;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tfalloverStore.put(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn cache.put(data.fallover, response);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'add': {\n\t\t\t\tconst request = new Request(data.url, {mode: 'no-cors'});\n\t\t\t\treturn fetch(request).then(response => cache.put(data.url, response));\n\t\t\t}\n\t\t}\n\t});\n});"],"sourceRoot":""} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 42d75b3..4652789 100644 --- a/manifest.json +++ b/manifest.json @@ -26,6 +26,7 @@ "type" : "image/png" }], "display": "standalone", + "serviceworker": "./adorn_sw.js", "orientation": "portrait-primary", "favicon" : "/favicon.ico", "github" : "MrSwitch", diff --git a/src/adorn_sw.js b/src/adorn_sw.js new file mode 100644 index 0000000..4b4fbcd --- /dev/null +++ b/src/adorn_sw.js @@ -0,0 +1,158 @@ +// Service Worker +// Caches pages visited by agent for viewing offline + +const CACHE_NAME = 'adorn_sw'; +const VERSION = 1; + +const DB = require('./lib/indexdb'); +const db = new DB('adorn_sw', VERSION, { + falloverStore: { + autoIncrement: true + } +}); + +const falloverStore = db('falloverStore'); + +self.addEventListener('install', event => { + // Perform install steps + event.waitUntil( + caches.open(CACHE_NAME).then(() => { + // Opened cache + }) + ); +}); + +self.addEventListener('fetch', event => { + const request = event.request; + let status; + event.respondWith((async () => { + const fromCache = caches.match(request) + .then(b => { + if (b) { + status = status || 'cache wins'; + } + return b; + }); + + const fromFetch = fetch(request) + .then(b => { + if (b) { + status = status || 'network wins'; + } + return b; + }); + + const promise = promiseAny([fromCache, fromFetch]); + + promise.then(() => { + // Report the success + console.log(status, request.url); // eslint-disable-line no-console + }); + + // Save + fromFetch.then(cacheUpdate.bind(null, request)); + + return promise.catch(offlineFallback.bind(null, request)); + + })()); + +}); + + +// https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/ + +function promiseAny(promises) { + return new Promise((resolve, reject) => { + // make sure promises are all promises + promises = promises.map(p => Promise.resolve(p).then(emptyHandler)); + // resolve this promise as soon as one resolves + promises.forEach(p => p.then(resolve)); + // reject if all promises reject + promises + .reduce((a, b) => a.catch(() => b)) + .catch(() => reject(Error('All failed'))); + }); +} + + +function emptyHandler(r) { + if (!r) { + throw 'not found'; + } + return r; +} + +function cacheUpdate(request, response) { + + // Check if we received a valid response + if (!response || response.status !== 200 || response.type !== 'basic') { + return response; + } + + const responseToCache = response.clone(); + + caches.open(CACHE_NAME).then(cache => { + cache.put(request, responseToCache); + }); + + return response; +} + +async function offlineFallback(request) { + + const fallover = await falloverStore.all(); + + const match = fallover.filter(item => ( + (!item.mode || item.mode === request.mode) + && (!item.url || request.url.match(item.url)) + ))[0]; + + if (match) { + return caches.match(new Request(match.fallover)); + } + + return; +} + + +self.addEventListener('message', event => { + + const data = event.data; + + // Open cache for actions + caches.open(CACHE_NAME).then(cache => { + switch (data.type) { + + case 'fallover': { + // Has this already been added? + falloverStore.all().then(fallover => { + const match = fallover.filter(item => item.mode === data.mode && item.url === data.url)[0]; + if (match) { + // does this need + if (match.fallover === data.fallover) { + // nothing to do + return; + } + } + const frequest = new Request(data.fallover, {mode: 'no-cors'}); + + fetch(frequest).then(response => { + // Just update the existing record + if (match) { + match.fallover = data.fallover; + } + else { + falloverStore.put(data); + } + return cache.put(data.fallover, response); + }); + }); + break; + } + case 'add': { + const request = new Request(data.url, {mode: 'no-cors'}); + return fetch(request).then(response => cache.put(data.url, response)); + } + } + }); +}); \ No newline at end of file diff --git a/src/lib/indexdb.js b/src/lib/indexdb.js new file mode 100644 index 0000000..a38abe0 --- /dev/null +++ b/src/lib/indexdb.js @@ -0,0 +1,132 @@ +// indexStorage +// This wraps an interface around IndexDB to create an object store + +// Create an instance of the db +// The Cache name is optional, it will allow us to group various datasets (the default is __tricks__) + +class DB { + constructor (name, version, schema) { + + // Define the schema to use in the connection + this.db_name = name || '__adorn__'; + if (typeof version === 'object') { + this.version = 1; + this.schema = version; + } + else { + this.version = version || 1; + this.schema = schema; + } + this.table_name = '__adorn__'; + + // Return a function + return Object.assign(this.scope.bind(this), this); + } + + scope (name) { + // Create a new store instance + const inst = Object.create(this); + inst.table_name = name; + return inst; + } + + open(mode) { + return new Promise((accept, reject) => { + const db = self.indexedDB.open(this.db_name, this.version); + db.onsuccess = event => { + accept(event.target.result); + }; + db.onerror = reject; + db.onupgradeneeded = event => { + const db = event.target.result; + + // this should probably do something; + for (const x in this.schema) { + if (!db.objectStoreNames.contains(x)) { + db.createObjectStore(x, this.schema[x]); + } + } + }; + }) + .then(db => { + // The DB connection has been established + // Lets create a connection to it + const transaction = db.transaction([this.table_name], mode); + + // Return the API for the Object Store + return transaction.objectStore(this.table_name); + }); + } + + get (key) { + + // We've got all the information to make a request to IndexDB + return new Promise((accept, reject) => { + this.open().then(objectStore => { + // Find items in this table by Key + const request = objectStore.get(key); + request.onsuccess = event => { + accept(event.target.result); + }; + request.onerror = event => { + reject(event.target.result); + }; + }); + }); + } + + all () { + + // We've got all the information to make a request to IndexDB + return new Promise((accept, reject) => { + this.open().then(objectStore => { + // Find items in this table by Key + const request = objectStore.openCursor(); + request.onerror = event => { + reject(event.target.result); + }; + + const a = []; + request.onsuccess = event => { + const cursor = event.target.result; + if (cursor) { + a.push(cursor.value); + cursor.continue(); + } + else { + accept(a); + } + }; + }); + }); + } + + put (key, data) { + + return new Promise((accept, reject) => { + + // Allow data as a thing on its own. + if (typeof key === 'object') { + data = key; + } + else { + data.key = key; + } + + // Open up a connection to indexdb + this.open('readwrite').then(objectStore => { + const request = objectStore.put(data); + request.onsuccess = event => { + accept(event.target.result); + }; + request.onerror = event => { + reject(event.target.result); + }; + }) + .catch(reject); + + }); + } +} + +module.exports = DB; diff --git a/webpack.config.js b/webpack.config.js index b5f3a33..48622b4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,6 +7,16 @@ const { WATCH } = process.env; +const resolve = { + // directories where to look for modules + modules: [ + 'node_modules', + ], + + // extensions that are used + extensions: ['.js'], +}; + const configJS = { watch: !!WATCH, //eslint-disable-line mode: !WATCH ? 'production' : 'development', @@ -44,15 +54,23 @@ const configJS = { } ] }, - resolve: { - // directories where to look for modules - modules: [ - 'node_modules', - ], - - // extensions that are used - extensions: ['.js'], + resolve, + plugins: [] +}; + + +const SWJS = { + watch: !!WATCH, //eslint-disable-line + mode: !WATCH ? 'production' : 'development', + entry: { + adorn_sw: './src/adorn_sw.js' }, + output: { + path: __dirname, + filename: '[name].js', + }, + devtool: 'source-map', + resolve, plugins: [] }; @@ -126,6 +144,7 @@ if (!WATCH) { }); configJS.plugins.push(uglifyPlugin, prodModePlugin); + SWJS.plugins.push(uglifyPlugin, prodModePlugin); } -module.exports = [configJS, configCSS]; \ No newline at end of file +module.exports = [configJS, SWJS, configCSS]; \ No newline at end of file From a7b4025a0c944b2b9c84b612660e8e645476f072 Mon Sep 17 00:00:00 2001 From: Andrew Dodson Date: Mon, 30 Apr 2018 10:11:32 +0100 Subject: [PATCH 2/4] dont merge --- adorn_sw.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adorn_sw.js.map b/adorn_sw.js.map index e0566ee..eaf5e73 100644 --- a/adorn_sw.js.map +++ b/adorn_sw.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/lib/indexdb.js","webpack:///./src/adorn_sw.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","default","object","property","prototype","hasOwnProperty","p","s","e","t","[object Object]","version","schema","this","db_name","table_name","assign","scope","bind","inst","create","mode","Promise","accept","reject","db","self","indexedDB","open","onsuccess","event","target","result","onerror","onupgradeneeded","x","objectStoreNames","contains","createObjectStore","then","transaction","objectStore","key","request","openCursor","a","cursor","push","continue","data","put","catch","falloverStore","autoIncrement","promises","emptyHandler","addEventListener","waitUntil","caches","status","respondWith","fromCache","match","b","fromFetch","fetch","promise","resolve","map","forEach","reduce","Error","response","type","responseToCache","clone","cache","async","all","filter","item","url","Request","fallover","frequest"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,KACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,KAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,gBACAC,cACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,YAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAAoB,SAC3B,WAAiC,OAAApB,GAEjC,OADAH,EAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAW,EAAAC,GAAsD,OAAAX,OAAAY,UAAAC,eAAApB,KAAAiB,EAAAC,IAGtDzB,EAAA4B,EAAA,GAIA5B,IAAA6B,EAAA,cAAAC,EAAAC,GCgEA5B,EAAAD,cA5HA8B,YAAArB,EAAAsB,E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tD,KAAA,KAAAyB,IAEAuB,EAAAf,MAwFA0B,eAAAlC,GAEA,MAEAmB,SAFAV,EAAA0B,OAEAC,OAAAC,KACAA,EAAA3D,MAAA2D,EAAA3D,OAAAsB,EAAAtB,SACA2D,EAAAC,KAAAtC,EAAAsC,IAAAnB,MAAAkB,EAAAC,OACA,GAEA,GAAAnB,EACA,OAAAJ,OAAAI,MAAA,IAAAoB,QAAApB,EAAAqB,YAlGAjE,KAAA,KAAAyB,KA3BA,MAkCAjB,KAAA8B,iBAAA,UAAA1B,IAEA,MAAAmB,EAAAnB,EAAAmB,KAGAS,OAAA9B,KA/DA,YA+DAW,KAAAqC,IACA,OAAA3B,EAAAwB,MAEA,eAEArB,EAAA0B,MAAAvC,KAAA4C,IACA,MAAArB,EAAAqB,EAAAJ,OAAAC,KAAA3D,OAAA4B,EAAA5B,MAAA2D,EAAAC,MAAAhC,EAAAgC,KAAA,GACA,GAAAnB,GAEAA,EAAAqB,WAAAlC,EAAAkC,SAEA,OAGA,MAAAC,EAAA,IAAAF,QAAAjC,EAAAkC,UAAkD9D,KAAA,YAElD4C,MAAAmB,GAAA7C,KAAAiC,IAEAV,EACAA,EAAAqB,SAAAlC,EAAAkC,SAGA/B,EAAAF,IAAAD,GAEA2B,EAAA1B,IAAAD,EAAAkC,SAAAX,OAGA,MAEA,WACA,MAAA7B,EAAA,IAAAuC,QAAAjC,EAAAgC,KAA2C5D,KAAA,YAC3C,OAAA4C,MAAAtB,GAAAJ,KAAAiC,GAAAI,EAAA1B,IAAAD,EAAAgC,IAAAT","file":"adorn_sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// indexStorage\n// This wraps an interface around IndexDB to create an object store\n\n// Create an instance of the db\n// The Cache name is optional, it will allow us to group various datasets (the default is __tricks__)\n\nclass DB {\n\tconstructor (name, version, schema) {\n\n\t\t// Define the schema to use in the connection\n\t\tthis.db_name = name || '__adorn__';\n\t\tif (typeof version === 'object') {\n\t\t\tthis.version = 1;\n\t\t\tthis.schema = version;\n\t\t}\n\t\telse {\n\t\t\tthis.version = version || 1;\n\t\t\tthis.schema = schema;\n\t\t}\n\t\tthis.table_name = '__adorn__';\n\n\t\t// Return a function\n\t\treturn Object.assign(this.scope.bind(this), this);\n\t}\n\n\tscope (name) {\n\t\t// Create a new store instance\n\t\tconst inst = Object.create(this);\n\t\tinst.table_name = name;\n\t\treturn inst;\n\t}\n\n\topen(mode) {\n\t\treturn new Promise((accept, reject) => {\n\t\t\tconst db = self.indexedDB.open(this.db_name, this.version);\n\t\t\tdb.onsuccess = event => {\n\t\t\t\taccept(event.target.result);\n\t\t\t};\n\t\t\tdb.onerror = reject;\n\t\t\tdb.onupgradeneeded = event => {\n\t\t\t\tconst db = event.target.result;\n\n\t\t\t\t// this should probably do something;\n\t\t\t\tfor (const x in this.schema) {\n\t\t\t\t\tif (!db.objectStoreNames.contains(x)) {\n\t\t\t\t\t\tdb.createObjectStore(x, this.schema[x]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t})\n\t\t\t.then(db => {\n\t\t\t// The DB connection has been established\n\t\t\t// Lets create a connection to it\n\t\t\t\tconst transaction = db.transaction([this.table_name], mode);\n\n\t\t\t\t// Return the API for the Object Store\n\t\t\t\treturn transaction.objectStore(this.table_name);\n\t\t\t});\n\t}\n\n\tget (key) {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.get(key);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tall () {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.openCursor();\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\n\t\t\t\tconst a = [];\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\tconst cursor = event.target.result;\n\t\t\t\t\tif (cursor) {\n\t\t\t\t\t\ta.push(cursor.value);\n\t\t\t\t\t\tcursor.continue();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\taccept(a);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tput (key, data) {\n\n\t\treturn new Promise((accept, reject) => {\n\n\t\t\t// Allow data as a thing on its own.\n\t\t\tif (typeof key === 'object') {\n\t\t\t\tdata = key;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdata.key = key;\n\t\t\t}\n\n\t\t\t// Open up a connection to indexdb\n\t\t\tthis.open('readwrite').then(objectStore => {\n\t\t\t\tconst request = objectStore.put(data);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t})\n\t\t\t\t.catch(reject);\n\n\t\t});\n\t}\n}\n\nmodule.exports = DB;\n","// Service Worker\n// Caches pages visited by agent for viewing offline\n\nconst CACHE_NAME = 'adorn_sw';\nconst VERSION = 1;\n\nconst DB = require('./lib/indexdb');\nconst db = new DB('adorn_sw', VERSION, {\n\tfalloverStore: {\n\t\tautoIncrement: true\n\t}\n});\n\nconst falloverStore = db('falloverStore');\n\nself.addEventListener('install', event => {\n\t// Perform install steps\n\tevent.waitUntil(\n\t\tcaches.open(CACHE_NAME).then(() => {\n\t\t\t// Opened cache\n\t\t})\n\t);\n});\n\nself.addEventListener('fetch', event => {\n\tconst request = event.request;\n\tlet status;\n\tevent.respondWith((async () => {\n\t\tconst fromCache = caches.match(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'cache wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst fromFetch = fetch(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'network wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst promise = promiseAny([fromCache, fromFetch]);\n\n\t\tpromise.then(() => {\n\t\t\t// Report the success\n\t\t\tconsole.log(status, request.url); // eslint-disable-line no-console\n\t\t});\n\n\t\t// Save\n\t\tfromFetch.then(cacheUpdate.bind(null, request));\n\n\t\treturn promise.catch(offlineFallback.bind(null, request));\n\n\t})());\n\n});\n\n\n// https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/\n\nfunction promiseAny(promises) {\n\treturn new Promise((resolve, reject) => {\n\t\t// make sure promises are all promises\n\t\tpromises = promises.map(p => Promise.resolve(p).then(emptyHandler));\n\t\t// resolve this promise as soon as one resolves\n\t\tpromises.forEach(p => p.then(resolve));\n\t\t// reject if all promises reject\n\t\tpromises\n\t\t\t.reduce((a, b) => a.catch(() => b))\n\t\t\t.catch(() => reject(Error('All failed')));\n\t});\n}\n\n\nfunction emptyHandler(r) {\n\tif (!r) {\n\t\tthrow 'not found';\n\t}\n\treturn r;\n}\n\nfunction cacheUpdate(request, response) {\n\n\t// Check if we received a valid response\n\tif (!response || response.status !== 200 || response.type !== 'basic') {\n\t\treturn response;\n\t}\n\n\tconst responseToCache = response.clone();\n\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tcache.put(request, responseToCache);\n\t});\n\n\treturn response;\n}\n\nasync function offlineFallback(request) {\n\n\tconst fallover = await falloverStore.all();\n\n\tconst match = fallover.filter(item => (\n\t\t(!item.mode || item.mode === request.mode)\n\t\t&& (!item.url || request.url.match(item.url))\n\t))[0];\n\n\tif (match) {\n\t\treturn caches.match(new Request(match.fallover));\n\t}\n\n\treturn;\n}\n\n\nself.addEventListener('message', event => {\n\n\tconst data = event.data;\n\n\t// Open cache for actions\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tswitch (data.type) {\n\n\t\t\tcase 'fallover': {\n\t\t\t\t// Has this already been added?\n\t\t\t\tfalloverStore.all().then(fallover => {\n\t\t\t\t\tconst match = fallover.filter(item => item.mode === data.mode && item.url === data.url)[0];\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\t// does this need\n\t\t\t\t\t\tif (match.fallover === data.fallover) {\n\t\t\t\t\t\t\t// nothing to do\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst frequest = new Request(data.fallover, {mode: 'no-cors'});\n\n\t\t\t\t\tfetch(frequest).then(response => {\n\t\t\t\t\t\t// Just update the existing record\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tmatch.fallover = data.fallover;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tfalloverStore.put(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn cache.put(data.fallover, response);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'add': {\n\t\t\t\tconst request = new Request(data.url, {mode: 'no-cors'});\n\t\t\t\treturn fetch(request).then(response => cache.put(data.url, response));\n\t\t\t}\n\t\t}\n\t});\n});"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/lib/indexdb.js","webpack:///./src/adorn_sw.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","default","object","property","prototype","hasOwnProperty","p","s","e","t","[object Object]","version","schema","this","db_name","table_name","assign","scope","bind","inst","create","mode","Promise","accept","reject","db","self","indexedDB","open","onsuccess","event","target","result","onerror","onupgradeneeded","x","objectStoreNames","contains","createObjectStore","then","transaction","objectStore","key","request","openCursor","a","cursor","push","continue","data","put","catch","falloverStore","autoIncrement","promises","emptyHandler","addEventListener","waitUntil","caches","status","respondWith","fromCache","match","b","fromFetch","fetch","promise","resolve","map","forEach","reduce","Error","response","type","responseToCache","clone","cache","async","all","filter","item","url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,KAAAqC,IACA,OAAA3B,EAAAwB,MAEA,eAEArB,EAAA0B,MAAAvC,KAAA4C,IACA,MAAArB,EAAAqB,EAAAJ,OAAAC,KAAA3D,OAAA4B,EAAA5B,MAAA2D,EAAAC,MAAAhC,EAAAgC,KAAA,GACA,GAAAnB,GAEAA,EAAAqB,WAAAlC,EAAAkC,SAEA,OAGA,MAAAC,EAAA,IAAAF,QAAAjC,EAAAkC,UAAkD9D,KAAA,YAElD4C,MAAAmB,GAAA7C,KAAAiC,IAEAV,EACAA,EAAAqB,SAAAlC,EAAAkC,SAGA/B,EAAAF,IAAAD,GAEA2B,EAAA1B,IAAAD,EAAAkC,SAAAX,OAGA,MAEA,WACA,MAAA7B,EAAA,IAAAuC,QAAAjC,EAAAgC,KAA2C5D,KAAA,YAC3C,OAAA4C,MAAAtB,GAAAJ,KAAAiC,GAAAI,EAAA1B,IAAAD,EAAAgC,IAAAT","file":"adorn_sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// indexStorage\n// This wraps an interface around IndexDB to create an object store\n\n// Create an instance of the db\n// The Cache name is optional, it will allow us to group various datasets (the default is __tricks__)\n\nclass DB {\n\tconstructor (name, version, schema) {\n\n\t\t// Define the schema to use in the connection\n\t\tthis.db_name = name || '__adorn__';\n\t\tif (typeof version === 'object') {\n\t\t\tthis.version = 1;\n\t\t\tthis.schema = version;\n\t\t}\n\t\telse {\n\t\t\tthis.version = version || 1;\n\t\t\tthis.schema = schema;\n\t\t}\n\t\tthis.table_name = '__adorn__';\n\n\t\t// Return a function\n\t\treturn Object.assign(this.scope.bind(this), this);\n\t}\n\n\tscope (name) {\n\t\t// Create a new store instance\n\t\tconst inst = Object.create(this);\n\t\tinst.table_name = name;\n\t\treturn inst;\n\t}\n\n\topen(mode) {\n\t\treturn new Promise((accept, reject) => {\n\t\t\tconst db = self.indexedDB.open(this.db_name, this.version);\n\t\t\tdb.onsuccess = event => {\n\t\t\t\taccept(event.target.result);\n\t\t\t};\n\t\t\tdb.onerror = reject;\n\t\t\tdb.onupgradeneeded = event => {\n\t\t\t\tconst db = event.target.result;\n\n\t\t\t\t// this should probably do something;\n\t\t\t\tfor (const x in this.schema) {\n\t\t\t\t\tif (!db.objectStoreNames.contains(x)) {\n\t\t\t\t\t\tdb.createObjectStore(x, this.schema[x]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t})\n\t\t\t.then(db => {\n\t\t\t// The DB connection has been established\n\t\t\t// Lets create a connection to it\n\t\t\t\tconst transaction = db.transaction([this.table_name], mode);\n\n\t\t\t\t// Return the API for the Object Store\n\t\t\t\treturn transaction.objectStore(this.table_name);\n\t\t\t});\n\t}\n\n\tget (key) {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.get(key);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tall () {\n\n\t\t// We've got all the information to make a request to IndexDB\n\t\treturn new Promise((accept, reject) => {\n\t\t\tthis.open().then(objectStore => {\n\t\t\t\t// Find items in this table by Key\n\t\t\t\tconst request = objectStore.openCursor();\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\n\t\t\t\tconst a = [];\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\tconst cursor = event.target.result;\n\t\t\t\t\tif (cursor) {\n\t\t\t\t\t\ta.push(cursor.value);\n\t\t\t\t\t\tcursor.continue();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\taccept(a);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tput (key, data) {\n\n\t\treturn new Promise((accept, reject) => {\n\n\t\t\t// Allow data as a thing on its own.\n\t\t\tif (typeof key === 'object') {\n\t\t\t\tdata = key;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdata.key = key;\n\t\t\t}\n\n\t\t\t// Open up a connection to indexdb\n\t\t\tthis.open('readwrite').then(objectStore => {\n\t\t\t\tconst request = objectStore.put(data);\n\t\t\t\trequest.onsuccess = event => {\n\t\t\t\t\taccept(event.target.result);\n\t\t\t\t};\n\t\t\t\trequest.onerror = event => {\n\t\t\t\t\treject(event.target.result);\n\t\t\t\t};\n\t\t\t})\n\t\t\t\t.catch(reject);\n\n\t\t});\n\t}\n}\n\nmodule.exports = DB;\n","// Service Worker\n// Caches pages visited by agent for viewing offline\n\nconst CACHE_NAME = 'adorn_sw';\nconst VERSION = 1;\n\nconst DB = require('./lib/indexdb');\nconst db = new DB('adorn_sw', VERSION, {\n\tfalloverStore: {\n\t\tautoIncrement: true\n\t}\n});\n\nconst falloverStore = db('falloverStore');\n\nself.addEventListener('install', event => {\n\t// Perform install steps\n\tevent.waitUntil(\n\t\tcaches.open(CACHE_NAME).then(() => {\n\t\t\t// Opened cache\n\t\t})\n\t);\n});\n\nself.addEventListener('fetch', event => {\n\tconst request = event.request;\n\tconsole.log('log', request.url);\n\tlet status;\n\tevent.respondWith((async () => {\n\t\tconst fromCache = caches.match(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'cache wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst fromFetch = fetch(request)\n\t\t\t.then(b => {\n\t\t\t\tif (b) {\n\t\t\t\t\tstatus = status || 'network wins';\n\t\t\t\t}\n\t\t\t\treturn b;\n\t\t\t});\n\n\t\tconst promise = promiseAny([fromCache, fromFetch]);\n\n\t\tpromise.then(() => {\n\t\t\t// Report the success\n\t\t\tconsole.log(status, request.url); // eslint-disable-line no-console\n\t\t});\n\n\t\t// Save\n\t\tfromFetch.then(cacheUpdate.bind(null, request));\n\n\t\treturn promise.catch(offlineFallback.bind(null, request));\n\n\t})());\n\n});\n\n\n// https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/\n\nfunction promiseAny(promises) {\n\treturn new Promise((resolve, reject) => {\n\t\t// make sure promises are all promises\n\t\tpromises = promises.map(p => Promise.resolve(p).then(emptyHandler));\n\t\t// resolve this promise as soon as one resolves\n\t\tpromises.forEach(p => p.then(resolve));\n\t\t// reject if all promises reject\n\t\tpromises\n\t\t\t.reduce((a, b) => a.catch(() => b))\n\t\t\t.catch(() => reject(Error('All failed')));\n\t});\n}\n\n\nfunction emptyHandler(r) {\n\tif (!r) {\n\t\tthrow 'not found';\n\t}\n\treturn r;\n}\n\nfunction cacheUpdate(request, response) {\n\n\t// Check if we received a valid response\n\tif (!response || response.status !== 200 || response.type !== 'basic') {\n\t\treturn response;\n\t}\n\n\tconst responseToCache = response.clone();\n\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tcache.put(request, responseToCache);\n\t});\n\n\treturn response;\n}\n\nasync function offlineFallback(request) {\n\n\tconst fallover = await falloverStore.all();\n\n\tconst match = fallover.filter(item => (\n\t\t(!item.mode || item.mode === request.mode)\n\t\t&& (!item.url || request.url.match(item.url))\n\t))[0];\n\n\tif (match) {\n\t\treturn caches.match(new Request(match.fallover));\n\t}\n\n\treturn;\n}\n\n\nself.addEventListener('message', event => {\n\n\tconst data = event.data;\n\n\t// Open cache for actions\n\tcaches.open(CACHE_NAME).then(cache => {\n\t\tswitch (data.type) {\n\n\t\t\tcase 'fallover': {\n\t\t\t\t// Has this already been added?\n\t\t\t\tfalloverStore.all().then(fallover => {\n\t\t\t\t\tconst match = fallover.filter(item => item.mode === data.mode && item.url === data.url)[0];\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\t// does this need\n\t\t\t\t\t\tif (match.fallover === data.fallover) {\n\t\t\t\t\t\t\t// nothing to do\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst frequest = new Request(data.fallover, {mode: 'no-cors'});\n\n\t\t\t\t\tfetch(frequest).then(response => {\n\t\t\t\t\t\t// Just update the existing record\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tmatch.fallover = data.fallover;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tfalloverStore.put(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn cache.put(data.fallover, response);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'add': {\n\t\t\t\tconst request = new Request(data.url, {mode: 'no-cors'});\n\t\t\t\treturn fetch(request).then(response => cache.put(data.url, response));\n\t\t\t}\n\t\t}\n\t});\n});"],"sourceRoot":""} \ No newline at end of file From ddb2cd903fde714648b13b2095d0d6e9cb1cb9c5 Mon Sep 17 00:00:00 2001 From: Andrew Dodson Date: Wed, 9 May 2018 21:08:54 +0100 Subject: [PATCH 3/4] working sw --- adorn.js | 3415 ++++++++++++++++++++++++++++++++++++++++++++- adorn.js.map | 2 +- adorn_sw.js | 388 ++++- adorn_sw.js.map | 2 +- src/adorn_sw.js | 2 + webpack.config.js | 2 +- 6 files changed, 3806 insertions(+), 5 deletions(-) diff --git a/adorn.js b/adorn.js index 0855926..5140b4c 100644 --- a/adorn.js +++ b/adorn.js @@ -1,2 +1,3415 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=66)}([function(t,e,n){"use strict";var r=n(57),o=n(18),i=n(56);t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return r(t)?t=[t]:"string"==typeof t&&(t=document.querySelectorAll(t)),o(t,Array)||(t=i(t)),e&&t.forEach(e),t}},function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="string"==typeof t?document.createElement(t):t;for(var a in e)if(e.hasOwnProperty(a))if("text"===a)i.appendChild(document.createTextNode(e[a]));else if("html"===a)"string"==typeof e[a]?i.innerHTML=e[a]:i.appendChild(e[a]);else if("object"===r(e[a]))for(var u in e[a])e[a].hasOwnProperty(u)&&(i[a][u]=e[a][u]);else i.setAttribute(a,e[a]);return n.forEach(function(t){"string"==typeof t&&(t=document.createTextNode(t)),t&&i.appendChild(t)}),o&&o.appendChild(i),i}},function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=n(0),i=/[\s,]+/,a=!1;try{var u=Object.defineProperty({},"passive",{get:function(){a=!0}});window.addEventListener("test",null,u)}catch(t){}t.exports=function(t,e,n){var u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"object"===(void 0===u?"undefined":r(u))&&u.passive&&!a&&(u=!1),e=e.split(i),o(t,function(t){return e.forEach(function(e){return t.addEventListener(e,n,u)})})}},function(t,e,n){"use strict";t.exports=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector(t)}},function(t,e,n){"use strict";var r=n(2);t.exports=function(t){"loading"!==document.readyState&&document.body?t():r(document,"DOMContentLoaded",t)}},function(t,e,n){"use strict";t.exports=function(t){try{return t.call(null)}catch(t){}}},function(t,e,n){"use strict";t.exports=function(t){if(t.id)return t.id;var e=(t.innerText||t.textContent||t.innerHTML).toLowerCase().replace(/\s/g,"-").replace(/[^a-z0-9_-]/g,"");return t.id=e,e}},function(t,e,n){"use strict";var r=[];function o(){var t=window.location.hash.substr(1);r.forEach(function(e){e.call(null,t)})}n(2)(window,"hashchange",o),t.exports=function(t){t?r.push(t):o()}},function(t,e,n){"use strict";var r=n(0);t.exports=function(t,e){var n=void 0;return r(t,function(t){n||(n=e(t))}),n}},function(t,e,n){"use strict";t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"=",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(t){return t};return Object.keys(t).map(function(e){var o=r(t[e]);return e+(null!==o?n+o:"")}).join(e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=h(n(0)),o=h(n(8)),i=h(n(11)),a=h(n(2)),u=h(n(1)),c=h(n(35)),s=h(n(6)),l=h(n(4)),f=h(n(7)),d=h(n(34)),p=h(n(33));function h(t){return t&&t.__esModule?t:{default:t}}var m=new d.default;(0,l.default)(function(){var t=(0,r.default)("h1,h2");if(document.querySelector&&!(document.documentElement.className||"").match(/adorn-(nav|toc)-off/)){(0,r.default)(t,function(t){var e=(0,s.default)(t);t.insertBefore((0,u.default)("a",{name:e,href:"#"+e,"aria-label":"Jump to "+t.innerText,class:"adorn-anchor"}),t.firstChild)});var e=window.location.hash;if(e&&e.length>2){var n=document.querySelector(window.location.hash);n&&n.scrollIntoView()}t.length&&setTimeout(function(){(0,i.default)(document.documentElement,"adorn-toc-on")}),m.resolve(t);var l=(0,p.default)();(0,a.default)(window,"scroll",function(){(0,p.default)(function(t){if("complete"===document.readyState){var e=window.scrollY||window.pageYOffset,n=window.innerHeight,r=document.querySelector(".adorn-toolbar"),i=void 0,a=r&&r.offsetHeight||50,u=window.location.hash;if(u){var s=document.querySelector(u);if(s){var l=(0,c.default)(s)[1];if(l>e&&l2&&void 0!==arguments[2]?arguments[2]:0,i=0,a=void 0,u=document.getElementsByTagName("script")[0].parentNode,c=function(t){!i++&&e&&e(t),a&&clearTimeout(a)};n&&(a=window.setTimeout(function(){c(o("timeout"))},n));var s=r("script",{src:t,onerror:c,onload:c,onreadystatechange:function(){/loaded|complete/i.test(s.readyState)&&c(o("load"))}});return s.async=!0,u.insertBefore(s,u.firstChild),s}},function(t,e,n){"use strict";var r=n(8),o=document.createElement("div"),i=o.matches||o.mozMatchesSelector||o.webkitMatchesSelector||o.msMatchesSelector||o.oMatchesSelector;t.exports=function(t,e){var n=e;return"string"==typeof e&&(n=function(t){return i.call(t,e)}),r(t,n)}},function(t,e,n){"use strict";t.exports=function(t,e){return e.parentNode.insertBefore(t,e)}},function(t,e,n){"use strict";t.exports=document.documentElement||document.body.parentNode},function(t,e,n){"use strict";t.exports=function(t,e){return e&&t instanceof e}},function(t,e,n){"use strict";var r=n(8);t.exports=function(t,e){var n=new RegExp("(^|\\s)"+e+"($|\\s)","i");return r(t,function(t){return(t.className||"").match(n)})}},function(t,e,n){"use strict";var r=n(5),o=n(3);t.exports=function(t){return r(function(){return o('meta[name="'+t+'"]').content})}},function(t,e,n){"use strict";t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"./";if(!t)return"";try{return new URL(t,new URL(e,window.location)).href||t}catch(e){return t}}},function(t,e,n){"use strict";var r=n(9),o=document.documentElement,i=[["Top","Height"],["Left","Width"]];t.exports=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return i.forEach(function(t){var e=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}(t,2),n=e[0],r=e[1],i=n.toLowerCase(),a=r.toLowerCase();if(this[a]&&!(i in this)){var u=void 0!==window["screen"+n]?window["screen"+n]:screen[i],c=screen[a]||window["inner"+r]||o["client"+r];this[i]=parseInt((c-this[a])/2,10)+u}}.bind(n)),window.open(t,e,r(n,","))}},function(t,e,n){"use strict";var r=n(9),o=function(t){return"?"===t?"?":encodeURIComponent(t)};t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return r(t,"&","=",e)}},function(t,e,n){"use strict";t.exports=function(){for(var t=arguments.length,e=Array(t),n=0;n2&&void 0!==arguments[2]?arguments[2]:"_tricks_";return e=e||n+r(),window[e]=function(t,e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o3&&void 0!==arguments[3]?arguments[3]:6e4,u=void 0;n=r(function(t){return u=t,!0},n),t=t.replace(i,"="+n+"$1");var c=o(t,function(){e(u),c.parentNode.removeChild(c)},a);return c}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.github_btn=function(t){var e=[],n=t.paths;if(t.github){var i=t.github;if(!i.match("/")&&n.length&&(i+="/"+n[0].replace(/\/$/,"")),i.match("/")){var c="https://github.com/"+i,s=h("source")||(window.location.pathname||"").replace(/^\/?([^/]+)/g,"").replace(/\/$/,"index.html").replace(/^\//,"");return e.push((0,a.default)("a",{href:(0,d.default)(s,c+"/blob/master/"),target:"_blank",rel:"noopener",id:"adorn-edit"},["Edit this page"]),(0,a.default)("span"),(0,a.default)("a",{href:""+c,target:"_blank",rel:"noopener",title:"Stars",id:"adorn-github-button"},[(0,a.default)("i",{class:"adorn-icon-github"}),(0,a.default)("span",{class:"adorn-speeach-bubble"})])),(0,o.default)("https://api.github.com/repos/"+i+"?callback=?",function(t){t&&t.data&&t.data.watchers&&(0,r.default)(".adorn-github-button span.adorn-speeach-bubble",function(e){e.innerHTML=t.data.watchers||""})}),u.default.apply(void 0,e)}}},e.twitter_btn=function(t){var e=[],n=t["twitter:creator"]||(0,s.default)("twitter:creator");if(n){var l=(0,a.default)("a",{href:"https://twitter.com/share",class:"adorn-twitter-button",target:"_blank",rel:"noopener","data-via":n.replace("@",""),title:"Tweet"},[(0,a.default)("i",{class:"adorn-icon-twitter"})]);return e.push(l,(0,a.default)("a",{href:"https://twitter.com/search?ref_src=twsrc%5Etfw&q="+encodeURIComponent(m),class:"adorn-twitter-count",rel:"noopener","aria-label":"Twitter comments",target:"_blank"},[(0,a.default)("i",{class:"adorn-speeach-bubble"})])),(0,o.default)("https://cdn.syndication.twitter.com/widgets/tweetbutton/count.json?url="+encodeURIComponent(m),function(t){t&&(0,r.default)(".adorn-twitter-count span.adorn-speeach-bubble",function(e){e.innerHTML=t.count||"",e.title="This page has been shared "+t.count+" times, view these tweets"})}),(0,i.default)(l,"click",function(e){e.preventDefault();var r={text:document.title,via:n.replace("@",""),url:window.location.href.replace(/#.*/,"")},o=(0,s.default)("twitter:hashtag")||t["twitter:hashtag"];o&&(r.hashtag=o),(0,f.default)("https://twitter.com/intent/tweet?"+(0,c.default)(r),"twitter",{width:550,height:250})}),u.default.apply(void 0,e)}},e.share_btn=function(){if("share"in navigator){var t=[],e=(0,a.default)("button",{class:"adorn-icon-share",target:"_blank",rel:"noopener",title:"Share"});return t.push(e),(0,i.default)(e,"click",function(){try{navigator.share({title:document.title,text:document.title,url:location.href}).then(function(){e.style.color="green"})}catch(t){e.style.color="red"}}),u.default.apply(void 0,t)}};var r=p(n(0)),o=p(n(27)),i=p(n(2)),a=p(n(1)),u=p(n(24)),c=p(n(23)),s=p(n(20)),l=p(n(3)),f=p(n(22)),d=p(n(21));function p(t){return t&&t.__esModule?t:{default:t}}var h=function(){var t=(0,l.default)("link[rel=source]");if(t)return t.getAttribute("href")},m=window.location.href},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=s(n(0)),o=s(n(2)),i=s(n(1)),a=s(n(6)),u=s(n(7)),c=s(n(10));function s(t){return t&&t.__esModule?t:{default:t}}e.default=function(t){(0,c.default)(function(e){if(!(e.lenth<2)){var n=function(t){var e=(0,i.default)("div",{class:"adorn-toc"}),n=(0,i.default)("select",{"aria-label":"menu"},[],e),c=[];(0,o.default)(n,"change",function(){window.location.hash=n.options[n.selectedIndex].value});var s=n;return(0,r.default)(t,function(t){var e=+t.tagName.match(/[0-9]/)[0],r=t.innerText||t.textContent||t.innerHTML,o=(0,a.default)(t);1===e&&(s=(0,i.default)("optgroup",{label:r},[],n)),(0,i.default)("option",{value:o},[r],s),c.push(o)}),(0,u.default)(function(t){n.selectedIndex=c.indexOf(t)}),e}(e);t.appendChild(n)}})},t.exports=e.default},function(t,e,n){"use strict";t.exports=function(t,e){return e&&0===t.indexOf(e)?t.slice(e.length):t}},function(t,e,n){"use strict";t.exports=function(t){if(t){if(window.URL&&URL instanceof Function&&0!==URL.length)return new URL(t,window.location);var e=document.createElement("a");return e.href=t,e.cloneNode(!1)}return window.location}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=s(n(1)),o=s(n(31)),i=s(n(30)),a=s(n(16)),u=s(n(29)),c=n(28);function s(t){return t&&t.__esModule?t:{default:t}}e.default=function(t){var e=window.location.pathname||"",n=(0,o.default)(t.root).pathname,s=(e=(e=(0,i.default)(e,n)).replace(/^\//g,"")).split(/([^/]+\/?)/).filter(function(t){return!!t});t.paths=s;var l=[(0,r.default)("a",{href:t.root},[(0,r.default)("img",{src:t.favicon,alt:window.location.hostname,title:t.name})])];s.forEach(function(e,n){var o=t.root+s.slice(0,n+1).join(""),i=e.replace(/\.(html?)$/,"");l.push(" ",(0,r.default)("a",{href:o},[i]))});var f=(0,r.default)("div",{class:"adorn-breadcrumbs"},l),d=[(0,c.github_btn)(t),(0,c.twitter_btn)(t),(0,c.share_btn)(t)].reduce(function(t,e){return e?(t.length&&t.push((0,r.default)("span")),t.push(e),t):t},[]),p=(0,r.default)("div",{class:"adorn-links"},d);t.shoutout&&(p.appendChild((0,r.default)("span")),p.insertAdjacentHTML("beforeend",t.shoutout));var h=(0,r.default)("aside",{class:"adorn-toolbar"},[f,p]);(0,a.default)(h,document.body.firstElementChild||document.body.firstChild),(0,u.default)(f)},t.exports=e.default},function(t,e,n){"use strict";var r=1,o={};t.exports=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r++;return n&&o[n]&&(clearTimeout(o[n]),delete o[n]),t&&(o[n]=setTimeout(function(){t()},e)),n}},function(t,e,n){"use strict";var r=function(){function t(t,e){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:document.body,o=r(t,e);return n.insertBefore(o,n.firstChild),o}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=d(n(0)),o=d(n(11)),i=d(n(1)),a=d(n(39)),u=d(n(38)),c=d(n(36)),s=d(n(7)),l=d(n(10)),f=d(n(6));function d(t){return t&&t.__esModule?t:{default:t}}e.default=function(){(0,l.default)(function(t){if(t.length<2)(0,o.default)(document.documentElement,"adorn-sidebar-off");else{var e=0,n=(0,a.default)("aside",{class:"adorn-sidebar"}),l={};(0,r.default)(t,function(t){var r=+t.tagName.match(/[0-9]/)[0],o=function(t,e,n){if(en);return t}(n,e,r);e=r;var a=t.innerText||t.textContent||t.innerHTML,c=(0,f.default)(t);l[c]=n=(0,i.default)("li",{},[(0,i.default)("a",{href:"#"+c},[a])],o)}),(0,s.default)(function(t){var e=l[t];e&&((0,c.default)(".adorn-sidebar .selected","selected"),(0,o.default)(e,"selected"))})}})},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(n(4)),o=i(n(1));function i(t){return t&&t.__esModule?t:{default:t}}e.default=function(t){t.author&&(0,r.default)(function(){var e=t.author.split(/\s*, \s*/);if(e){var n=["Authored by "];e[1]?n.push((0,o.default)("a",{href:e[1],rel:"author"},[e[0]])):n.push(e[0]),(0,o.default)("footer",{},n,document.body)}})},t.exports=e.default},function(t,e,n){"use strict";t.exports=function(t,e){e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _each=__webpack_require__(0),_each2=_interopRequireDefault(_each),_on=__webpack_require__(2),_on2=_interopRequireDefault(_on),_create=__webpack_require__(1),_create2=_interopRequireDefault(_create),_insertAfter=__webpack_require__(42),_insertAfter2=_interopRequireDefault(_insertAfter);function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function tryitButton(pre,func){var btn=(0,_create2.default)("button",{class:"tryit"},["tryit"]);(0,_insertAfter2.default)(btn,pre),(0,_on2.default)(btn,"click",function(){if(func)func();else{if("function"==typeof tryit&&!tryit(pre.innerText))return;setTimeout(function(){return eval(pre.innerText)},100)}}),func||pre.setAttribute("contenteditable",!0)}exports.default=function(){(0,_each2.default)("pre",function(t){"tryit"!==t.className&&"tryitoffline"!==t.className||tryitButton(t)}),(0,_each2.default)("script",function(t){var e=t.getAttribute("data-tryit");e&&tryitButton(t,window[e]),t.getAttribute("src")&&(0,_on2.default)(t,"click",function(){window.open(t.getAttribute("src"),"_blank")})}),(0,_each2.default)("link",function(t){t.getAttribute("href")&&(0,_on2.default)(t,"click",function(){window.open(t.getAttribute("href"),"_blank")})})},module.exports=exports.default},function(t,e,n){"use strict";var r=i(n(4)),o=i(n(12));function i(t){return t&&t.__esModule?t:{default:t}}(0,r.default)(function(){(0,o.default)("a[target=_blank]:not([rel=noopener])",{rel:"noopener"})})},function(t,e,n){"use strict";var r={bubbles:!0,cancelable:!0},o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;return new Event(t,e)};try{o("test")}catch(t){o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=document.createEvent("Event");return n.initEvent(t,!!e.bubbles,!!e.cancelable),n}}t.exports=o},function(t,e,n){"use strict";var r=n(14);t.exports=function(t){window._gaq=window._gaq||[],_gaq.push(["_setAccount",t]),_gaq.push(["_trackPageview"]),r(("https:"===document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js")}},function(t,e,n){"use strict";var r=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t.exports=r},function(t,e,n){"use strict";var r=n(47),o=/^file:\/{3}[^/]/i.test(window.location.href);t.exports=r&&o},function(t,e,n){"use strict";var r=n(0),o=/[\s,]+/;t.exports=function(t,e,n){return e=e.split(o),r(t,function(t){return e.forEach(function(e){return t.removeEventListener(e,n)})})}},function(t,e,n){"use strict";var r=n(2),o=n(49),i=n(15);t.exports=function(t,e,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:document,u=function(e){for(var r=e.target;r;){if(i(r,t)){e.delegateTarget=r,n(e);break}r=r.parentNode}};return r(a,e,u),{remove:function(){return o(a,e,u)}}}},function(t,e,n){"use strict";var r=n(50),o=n(48);t.exports=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;if(!o)return!1;r("a","click",function(t){var e=t.delegateTarget;e.href&&e.href.match(/^https?:\/\//)&&(t.preventDefault(),window.open(e.href,"_system"))},t)}},function(t,e,n){"use strict";var r=i(n(16)),o=i(n(1));function i(t){return t&&t.__esModule?t:{default:t}}(0,i(n(3)).default)("meta[name=viewport]")||(0,r.default)((0,o.default)("meta",{name:"viewport",content:"width=device-width, initial-scale=1.0"}),document.getElementsByTagName("script")[0])},function(t,e,n){"use strict";"header,section,datalist,option,footer,nav,menu,aside,article,style,script".split(",").forEach(function(t){return document.createElement(t)})},function(t,e,n){"use strict";t.exports=function(t,e){document.documentElement.className=document.documentElement.className+" "+(e?"":"no-")+t}},function(t,e,n){"use strict";var r=n(54),o="ontouchstart"in window;r("touch",o),t.exports=o},function(t,e,n){"use strict";t.exports=function(t){return Array.prototype.slice.call(t)}},function(t,e,n){"use strict";var r=n(18),o="undefined"!=typeof HTMLElement&&HTMLElement||"undefined"!=typeof Element&&Element,i="undefined"!=typeof HTMLDocument&&HTMLDocument||"undefined"!=typeof Document&&Document,a=window.constructor;t.exports=function(t){return r(t,o)||r(t,i)||r(t,a)}},function(t,e,n){"use strict";var r=n(5),o=n(3);t.exports=function(t){return r(function(){return o('link[rel="'+t+'"]').href})}},function(t,e,n){"use strict";var r=n(5);t.exports=function(t){return r(function(){return JSON.parse(t)})}},function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=n(59),i=n(5);t.exports=function(t,e){var n=new XMLHttpRequest;n.onload=function(){var t="object"===r(n.response)?n.response:o(n.response);e(t)},n.onerror=e,n.open("GET",t),"responseType"in n&&i(function(){return n.responseType="json"}),n.send()}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,r=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var o,i=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(o=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:r+i.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")})}},function(t,e,n){var r,o,i={},a=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=r.apply(this,arguments)),o}),u=function(t){var e={};return function(t){if("function"==typeof t)return t();if(void 0===e[t]){var n=function(t){return document.querySelector(t)}.call(this,t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}}(),c=null,s=0,l=[],f=n(61);function d(t,e){for(var n=0;n=0&&l.splice(e,1)}function b(t){var e=document.createElement("style");return t.attrs.type="text/css",v(e,t.attrs),h(t,e),e}function v(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function w(t,e){var n,r,o,i;if(e.transform&&t.css){if(!(i=e.transform(t.css)))return function(){};t.css=i}if(e.singleton){var a=s++;n=c||(c=b(e)),r=x.bind(null,n,a,!1),o=x.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return t.attrs.type="text/css",t.attrs.rel="stylesheet",v(e,t.attrs),h(t,e),e}(e),r=function(t,e,n){var r=n.css,o=n.sourceMap,i=void 0===e.convertToAbsoluteUrls&&o;(e.convertToAbsoluteUrls||i)&&(r=f(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var a=new Blob([r],{type:"text/css"}),u=t.href;t.href=URL.createObjectURL(a),u&&URL.revokeObjectURL(u)}.bind(null,n,e),o=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=b(e),r=function(t,e){var n=e.css,r=e.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,n),o=function(){m(n)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else o()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=p(t,e);return d(n,e),function(t){for(var r=[],o=0;oa.adorn-anchor{opacity:.5}a.adorn-anchor:hover{opacity:1}a.adorn-anchor:before{content:\"#\";position:absolute;left:-1em;color:inherit;vertical-align:middle}a.adorn-anchor:hover:before{-webkit-transform:scale(1.1);-webkit-transform-origin:50% 50%;transform:scale(1.1);transform-origin:50% 50%}.adorn-toolbar{-webkit-transform:translateZ(0);-webkit-transform-origin:0 0;transform:translateZ(0);transform-origin:0 0;-webkit-animation:fadeIn .3s ease;animation:fadeIn .3s ease;background-color:#fff;height:50px;color:#000;display:-webkit-flex;display:flex;-webkit-flex-flow:row;flex-flow:row;-webkit-justify-content:space-between;justify-content:space-between;left:0;right:0;margin:0;padding:5px 10px;position:fixed;top:0;z-index:1;white-space:nowrap}.adorn-toolbar>:last-child{text-align:right;margin-left:20px}.adorn-toolbar>:first-child{text-align:left}.adorn-toolbar>*{flex:1 0 auto;-webkit-flex:1 0 auto;white-space:normal;display:inline-block}.adorn-toolbar:after{content:\"\";border-bottom:1px solid #c7c7c7;position:absolute;bottom:0;width:100%;left:0;z-index:-1;-webkit-animation:fillWidth 1s linear forwards;animation:fillWidth 1s linear forwards}@media (max-width:650px),screen and (max-device-width:480px){.adorn-toolbar{transition:-webkit-transform 1s;transition:transform 1s}.adorn-toolbar #adorn-edit,.adorn-toolbar #adorn-edit+*{display:none}}.adorn-breadcrumbs{white-space:nowrap}.adorn-breadcrumbs>*{display:inline-block;transition:all .3s ease-in}.adorn-breadcrumbs>*>img{margin:-5px 10px -5px 0;background:hsla(0,0%,100%,.2);border-radius:50%;height:36px;vertical-align:middle;width:36px;transition:all .3s}.adorn-breadcrumbs>*>img:hover{-webkit-transform:scale(2.5);-webkit-transform-origin:50% 50%;transform:scale(2.5);transform-origin:50% 50%;filter:none}.adorn-breadcrumbs>:hover~*{transition:all 1s ease-in;-webkit-transform:translateX(50px);-webkit-transform-origin:0 0;transform:translateX(50px);transform-origin:0 0;opacity:0;filter:alpha(opacity=0)}.adorn-breadcrumbs>:last-child{text-decoration:none;color:#444}.adorn-links{white-space:nowrap}.adorn-links>span{margin:0 20px}.adorn-links>span:after{content:\"\\22C5\"}@media (max-width:650px),screen and (max-device-width:480px){.adorn-links>span{margin:0 2px}}@-webkit-keyframes slideInDown{0%{transform:translateY(-100px);-webkit-transform:translateY(-100px)}}@keyframes slideInDown{0%{transform:translateY(-100px);-webkit-transform:translateY(-100px)}}@-webkit-keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.webkit{content:\"\"}@-webkit-keyframes fillWidth{0%{width:0;left:50%}to{width:100%;left:0}}.key{content:\"\"}@keyframes fillWidth{0%{width:0;left:50%}to{width:100%;left:0}}.adorn-toc{display:inline-block;margin-left:5px}.adorn-toc:before{content:\"#\"}.adorn-sidebar{background:#eee;border-right:1px solid #c7c7c7;height:calc(100% - 50px);left:0;overflow:auto;padding:10px;position:fixed;top:50px;width:200px;-webkit-animation:fadeIn 1s ease;animation:fadeIn 1s ease}@media (max-width:1048px){.adorn-sidebar{display:none}}.adorn-sidebar a{text-decoration:none;color:inherit}.adorn-sidebar a:hover{color:#0c50c7}.adorn-sidebar li,.adorn-sidebar ul{margin:0;padding:0}.adorn-sidebar>ul{margin:0 -10px}.adorn-sidebar>ul>li>a{font-weight:700}.adorn-sidebar li{list-style:none;padding:0 10px}.adorn-sidebar li.selected>a{color:#0c50c7}.adorn-sidebar li li{font-size:.9em}@supports (appearance:none) or (-webkit-appearance:none) or (-moz-appearance:none){.adorn-toc select{font:inherit;appearance:none;-webkit-appearance:none;-moz-appearance:none;text-decoration:underline;height:2em}.adorn-toc select:not(:focus){border-color:transparent;color:inherit;background-color:inherit}.adorn-toc select::-ms-expand{display:none}}.clearfix{display:inline-block}.clearfix:after{visibility:hidden;display:block;font-size:0;content:\" \";clear:both;height:0}* html .clearfix{height:1%}.clearfix{display:block}.adorn-icon-github{color:inherit;display:inline-block;font-style:normal;text-decoration:inherit}.adorn-icon-github:after{content:\"GitHub\"}.adorn-icon-twitter{background:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M27.49 10.126c.011.254.017.507.017.766 0 7.808-5.942 16.809-16.813 16.809a16.72 16.72 0 0 1-9.056-2.653c.463.058.932.083 1.408.083 2.769 0 5.317-.944 7.341-2.534a5.9 5.9 0 0 1-5.52-4.097c.36.067.729.104 1.111.104.54 0 1.185-.071 1.68-.208-2.704-.541-4.616-2.929-4.616-5.795v-.075c0 .441 1.584.711 2.552.74-1.584-1.06-2.69-2.87-2.69-4.917 0-1.085.261-2.101.768-2.974 2.916 3.578 7.255 5.928 12.167 6.173a5.702 5.702 0 0 1-.16-1.343 5.9 5.9 0 0 1 5.901-5.907 5.89 5.89 0 0 1 4.312 1.863 11.91 11.91 0 0 0 3.754-1.431 5.909 5.909 0 0 1-2.598 3.266 12.019 12.019 0 0 0 3.392-.928 11.983 11.983 0 0 1-2.948 3.057z' fill='%23black'/%3E%3C/svg%3E\") no-repeat 50%;background-size:1em}.adorn-icon-share,.adorn-icon-twitter{width:1em;height:1em;font-size:1.5em;vertical-align:middle;display:inline-block}.adorn-icon-share{background:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath stroke='null' d='M26.293 20.872a5.39 5.39 0 0 0-3.933 1.705l-11.563-5.7c.04-.266.067-.538.067-.818 0-.271-.026-.536-.064-.797l11.546-5.637a5.395 5.395 0 0 0 3.947 1.72c3 0 5.433-2.45 5.433-5.47 0-3.02-2.432-5.468-5.433-5.468s-5.432 2.448-5.432 5.469c0 .271.026.536.064.797L9.38 12.31a5.395 5.395 0 0 0-3.947-1.72C2.432 10.59 0 13.04 0 16.06c0 3.02 2.432 5.468 5.432 5.468 1.55 0 2.944-.656 3.933-1.704l11.563 5.7a5.43 5.43 0 0 0-.068.817c0 3.021 2.432 5.469 5.432 5.469s5.433-2.448 5.433-5.469c0-3.02-2.431-5.469-5.432-5.469z'/%3E%3C/svg%3E\") no-repeat 50%;background-size:1em}.adorn-speeach-bubble{color:#444;margin-left:5px;position:relative;line-height:1;text-align:center;display:inline-block;background-color:#fff;border:1px solid #444;color:#000;border-radius:15%;padding:5px;transition:all .3s cubic-bezier(.68,-.55,.265,1.55)}.adorn-speeach-bubble:after,.adorn-speeach-bubble:before{position:absolute;left:-6px;bottom:5px;content:\" \";width:0;height:0;padding:0;border:5px solid transparent;border-width:3.5px 5px;border-right-color:inherit;border-left-width:0}.adorn-speeach-bubble:after{border-right-color:#fff;left:-4px;border-width:2.975px 4.25px;border-left-width:0;bottom:5.5px}.adorn-speeach-bubble:empty{-webkit-transform:scale(.01);-webkit-transform-origin:50% 50%;transform:scale(.01);transform-origin:50% 50%;opacity:0}",""])},function(t,e,n){var r=n(64);"string"==typeof r&&(r=[[t.i,r,""]]),n(62)(r,{hmr:!0,transform:void 0,insertInto:void 0}),r.locals&&(t.exports=r.locals)},function(t,e,n){"use strict";n(65);var r=w(n(60)),o=w(n(21)),i=w(n(20)),a=w(n(58)),u=w(n(3)),c=w(n(1)),s=w(n(19)),l=w(n(17)),f=w(n(4));n(55),n(53),n(52);var d=w(n(51)),p=w(n(46));n(44);var h=w(n(43)),m=w(n(41)),b=w(n(40)),v=w(n(32));function w(t){return t&&t.__esModule?t:{default:t}}(0,f.default)(h.default);var g=(0,i.default)("manifest")||(0,a.default)("manifest")||"/manifest.json";(0,r.default)(g,function t(e,n){if(!n||(0,i.default)("manifest")||(0,a.default)("manifest")||(0,c.default)("link",{rel:"manifest",href:e},[],document.head),n&&n.theme_color&&!(0,i.default)("theme-color")&&(0,c.default)("meta",{name:"theme-color",content:n.theme_color},[],document.head),document.body){(n=n||{}).favicon=(0,i.default)("favicon")||(0,o.default)(n.favicon,e)||"/favicon.ico",n.author=(0,i.default)("author")||n.author,n.root=(0,i.default)("root")||(0,o.default)(n.root||"/",e),(0,s.default)(l.default,"no-adorn")||((0,v.default)(n),(0,b.default)(n),(0,m.default)(n)),l.default.getAttribute("lang")||l.default.setAttribute("lang",n.lang||"en"),document.title||(document.title=(0,u.default)("h1,h2").textContent||"");var r=(0,i.default)("ga:tracking")||n["ga:tracking"];r&&(0,p.default)(r);var d=(0,i.default)("sw")||(0,i.default)("serviceworker");d?d=(0,o.default)(d):(d=n.sw||n.serviceworker)&&(d=(0,o.default)(d,e));var h=navigator.serviceWorker;d&&h&&(h.ready.then(function(){var t=n.fallover;t&&t.forEach(function(t){var n=t.mode,r=t.fallover;r=(0,o.default)(r,e),h.controller.postMessage({type:"fallover",fallover:r,mode:n})})}),h.register(d).catch(function(t){}))}else(0,f.default)(t.bind(null,e,n))}.bind(null,g)),(0,d.default)()}]); +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/adorn.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/css-loader/index.js??ref--5-1!./node_modules/less-loader/dist/cjs.js!./src/components.less": +/*!********************************************************************************************************!*\ + !*** ./node_modules/css-loader??ref--5-1!./node_modules/less-loader/dist/cjs.js!./src/components.less ***! + \********************************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(/*! ../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false); +// imports + + +// module +exports.push([module.i, "h1:target,h2:target,h3:target,h4:target{-webkit-animation:slideInDown .3s cubic-bezier(.68,-.55,.265,1.55) alternate,fadeIn .3s cubic-bezier(.68,-.55,.265,1.55);animation:slideInDown .3s cubic-bezier(.68,-.55,.265,1.55) alternate,fadeIn .3s cubic-bezier(.68,-.55,.265,1.55)}a.adorn-anchor{position:relative;text-indent:0;text-decoration:none;outline:none;opacity:0;transition:opacity .3s}:hover>a.adorn-anchor{opacity:.5}a.adorn-anchor:hover{opacity:1}a.adorn-anchor:before{content:\"#\";position:absolute;left:-1em;color:inherit;vertical-align:middle}a.adorn-anchor:hover:before{-webkit-transform:scale(1.1);-webkit-transform-origin:50% 50%;transform:scale(1.1);transform-origin:50% 50%}.adorn-toolbar{-webkit-transform:translateZ(0);-webkit-transform-origin:0 0;transform:translateZ(0);transform-origin:0 0;-webkit-animation:fadeIn .3s ease;animation:fadeIn .3s ease;background-color:#fff;height:50px;color:#000;display:-webkit-flex;display:flex;-webkit-flex-flow:row;flex-flow:row;-webkit-justify-content:space-between;justify-content:space-between;left:0;right:0;margin:0;padding:5px 10px;position:fixed;top:0;z-index:1;white-space:nowrap}.adorn-toolbar>:last-child{text-align:right;margin-left:20px}.adorn-toolbar>:first-child{text-align:left}.adorn-toolbar>*{flex:1 0 auto;-webkit-flex:1 0 auto;white-space:normal;display:inline-block}.adorn-toolbar:after{content:\"\";border-bottom:1px solid #c7c7c7;position:absolute;bottom:0;width:100%;left:0;z-index:-1;-webkit-animation:fillWidth 1s linear forwards;animation:fillWidth 1s linear forwards}@media (max-width:650px),screen and (max-device-width:480px){.adorn-toolbar{transition:-webkit-transform 1s;transition:transform 1s}.adorn-toolbar #adorn-edit,.adorn-toolbar #adorn-edit+*{display:none}}.adorn-breadcrumbs{white-space:nowrap}.adorn-breadcrumbs>*{display:inline-block;transition:all .3s ease-in}.adorn-breadcrumbs>*>img{margin:-5px 10px -5px 0;background:hsla(0,0%,100%,.2);border-radius:50%;height:36px;vertical-align:middle;width:36px;transition:all .3s}.adorn-breadcrumbs>*>img:hover{-webkit-transform:scale(2.5);-webkit-transform-origin:50% 50%;transform:scale(2.5);transform-origin:50% 50%;filter:none}.adorn-breadcrumbs>:hover~*{transition:all 1s ease-in;-webkit-transform:translateX(50px);-webkit-transform-origin:0 0;transform:translateX(50px);transform-origin:0 0;opacity:0;filter:alpha(opacity=0)}.adorn-breadcrumbs>:last-child{text-decoration:none;color:#444}.adorn-links{white-space:nowrap}.adorn-links>span{margin:0 20px}.adorn-links>span:after{content:\"\\22C5\"}@media (max-width:650px),screen and (max-device-width:480px){.adorn-links>span{margin:0 2px}}@-webkit-keyframes slideInDown{0%{transform:translateY(-100px);-webkit-transform:translateY(-100px)}}@keyframes slideInDown{0%{transform:translateY(-100px);-webkit-transform:translateY(-100px)}}@-webkit-keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.webkit{content:\"\"}@-webkit-keyframes fillWidth{0%{width:0;left:50%}to{width:100%;left:0}}.key{content:\"\"}@keyframes fillWidth{0%{width:0;left:50%}to{width:100%;left:0}}.adorn-toc{display:inline-block;margin-left:5px}.adorn-toc:before{content:\"#\"}.adorn-sidebar{background:#eee;border-right:1px solid #c7c7c7;height:calc(100% - 50px);left:0;overflow:auto;padding:10px;position:fixed;top:50px;width:200px;-webkit-animation:fadeIn 1s ease;animation:fadeIn 1s ease}@media (max-width:1048px){.adorn-sidebar{display:none}}.adorn-sidebar a{text-decoration:none;color:inherit}.adorn-sidebar a:hover{color:#0c50c7}.adorn-sidebar li,.adorn-sidebar ul{margin:0;padding:0}.adorn-sidebar>ul{margin:0 -10px}.adorn-sidebar>ul>li>a{font-weight:700}.adorn-sidebar li{list-style:none;padding:0 10px}.adorn-sidebar li.selected>a{color:#0c50c7}.adorn-sidebar li li{font-size:.9em}@supports (appearance:none) or (-webkit-appearance:none) or (-moz-appearance:none){.adorn-toc select{font:inherit;appearance:none;-webkit-appearance:none;-moz-appearance:none;text-decoration:underline;height:2em}.adorn-toc select:not(:focus){border-color:transparent;color:inherit;background-color:inherit}.adorn-toc select::-ms-expand{display:none}}.clearfix{display:inline-block}.clearfix:after{visibility:hidden;display:block;font-size:0;content:\" \";clear:both;height:0}* html .clearfix{height:1%}.clearfix{display:block}.adorn-icon-github{color:inherit;display:inline-block;font-style:normal;text-decoration:inherit}.adorn-icon-github:after{content:\"GitHub\"}.adorn-icon-twitter{background:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M27.49 10.126c.011.254.017.507.017.766 0 7.808-5.942 16.809-16.813 16.809a16.72 16.72 0 0 1-9.056-2.653c.463.058.932.083 1.408.083 2.769 0 5.317-.944 7.341-2.534a5.9 5.9 0 0 1-5.52-4.097c.36.067.729.104 1.111.104.54 0 1.185-.071 1.68-.208-2.704-.541-4.616-2.929-4.616-5.795v-.075c0 .441 1.584.711 2.552.74-1.584-1.06-2.69-2.87-2.69-4.917 0-1.085.261-2.101.768-2.974 2.916 3.578 7.255 5.928 12.167 6.173a5.702 5.702 0 0 1-.16-1.343 5.9 5.9 0 0 1 5.901-5.907 5.89 5.89 0 0 1 4.312 1.863 11.91 11.91 0 0 0 3.754-1.431 5.909 5.909 0 0 1-2.598 3.266 12.019 12.019 0 0 0 3.392-.928 11.983 11.983 0 0 1-2.948 3.057z' fill='%23black'/%3E%3C/svg%3E\") no-repeat 50%;background-size:1em}.adorn-icon-share,.adorn-icon-twitter{width:1em;height:1em;font-size:1.5em;vertical-align:middle;display:inline-block}.adorn-icon-share{background:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath stroke='null' d='M26.293 20.872a5.39 5.39 0 0 0-3.933 1.705l-11.563-5.7c.04-.266.067-.538.067-.818 0-.271-.026-.536-.064-.797l11.546-5.637a5.395 5.395 0 0 0 3.947 1.72c3 0 5.433-2.45 5.433-5.47 0-3.02-2.432-5.468-5.433-5.468s-5.432 2.448-5.432 5.469c0 .271.026.536.064.797L9.38 12.31a5.395 5.395 0 0 0-3.947-1.72C2.432 10.59 0 13.04 0 16.06c0 3.02 2.432 5.468 5.432 5.468 1.55 0 2.944-.656 3.933-1.704l11.563 5.7a5.43 5.43 0 0 0-.068.817c0 3.021 2.432 5.469 5.432 5.469s5.433-2.448 5.433-5.469c0-3.02-2.431-5.469-5.432-5.469z'/%3E%3C/svg%3E\") no-repeat 50%;background-size:1em}.adorn-speeach-bubble{color:#444;margin-left:5px;position:relative;line-height:1;text-align:center;display:inline-block;background-color:#fff;border:1px solid #444;color:#000;border-radius:15%;padding:5px;transition:all .3s cubic-bezier(.68,-.55,.265,1.55)}.adorn-speeach-bubble:after,.adorn-speeach-bubble:before{position:absolute;left:-6px;bottom:5px;content:\" \";width:0;height:0;padding:0;border:5px solid transparent;border-width:3.5px 5px;border-right-color:inherit;border-left-width:0}.adorn-speeach-bubble:after{border-right-color:#fff;left:-4px;border-width:2.975px 4.25px;border-left-width:0;bottom:5.5px}.adorn-speeach-bubble:empty{-webkit-transform:scale(.01);-webkit-transform-origin:50% 50%;transform:scale(.01);transform-origin:50% 50%;opacity:0}", ""]); + +// exports + + +/***/ }), + +/***/ "./node_modules/css-loader/lib/css-base.js": +/*!*************************************************!*\ + !*** ./node_modules/css-loader/lib/css-base.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +// css base code, injected by the css-loader +module.exports = function(useSourceMap) { + var list = []; + + // return the list of modules as css string + list.toString = function toString() { + return this.map(function (item) { + var content = cssWithMappingToString(item, useSourceMap); + if(item[2]) { + return "@media " + item[2] + "{" + content + "}"; + } else { + return content; + } + }).join(""); + }; + + // import a list of modules into the list + list.i = function(modules, mediaQuery) { + if(typeof modules === "string") + modules = [[null, modules, ""]]; + var alreadyImportedModules = {}; + for(var i = 0; i < this.length; i++) { + var id = this[i][0]; + if(typeof id === "number") + alreadyImportedModules[id] = true; + } + for(i = 0; i < modules.length; i++) { + var item = modules[i]; + // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { + if(mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if(mediaQuery) { + item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; + } + list.push(item); + } + } + }; + return list; +}; + +function cssWithMappingToString(item, useSourceMap) { + var content = item[1] || ''; + var cssMapping = item[3]; + if (!cssMapping) { + return content; + } + + if (useSourceMap && typeof btoa === 'function') { + var sourceMapping = toComment(cssMapping); + var sourceURLs = cssMapping.sources.map(function (source) { + return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' + }); + + return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); + } + + return [content].join('\n'); +} + +// Adapted from convert-source-map (MIT) +function toComment(sourceMap) { + // eslint-disable-next-line no-undef + var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); + var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; + + return '/*# ' + data + ' */'; +} + + +/***/ }), + +/***/ "./node_modules/style-loader/lib/addStyles.js": +/*!****************************************************!*\ + !*** ./node_modules/style-loader/lib/addStyles.js ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ + +var stylesInDom = {}; + +var memoize = function (fn) { + var memo; + + return function () { + if (typeof memo === "undefined") memo = fn.apply(this, arguments); + return memo; + }; +}; + +var isOldIE = memoize(function () { + // Test for IE <= 9 as proposed by Browserhacks + // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 + // Tests for existence of standard globals is to allow style-loader + // to operate correctly into non-standard environments + // @see https://github.com/webpack-contrib/style-loader/issues/177 + return window && document && document.all && !window.atob; +}); + +var getTarget = function (target) { + return document.querySelector(target); +}; + +var getElement = (function (fn) { + var memo = {}; + + return function(target) { + // If passing function in options, then use it for resolve "head" element. + // Useful for Shadow Root style i.e + // { + // insertInto: function () { return document.querySelector("#foo").shadowRoot } + // } + if (typeof target === 'function') { + return target(); + } + if (typeof memo[target] === "undefined") { + var styleTarget = getTarget.call(this, target); + // Special case to return head of iframe instead of iframe itself + if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { + try { + // This will throw an exception if access to iframe is blocked + // due to cross-origin restrictions + styleTarget = styleTarget.contentDocument.head; + } catch(e) { + styleTarget = null; + } + } + memo[target] = styleTarget; + } + return memo[target] + }; +})(); + +var singleton = null; +var singletonCounter = 0; +var stylesInsertedAtTop = []; + +var fixUrls = __webpack_require__(/*! ./urls */ "./node_modules/style-loader/lib/urls.js"); + +module.exports = function(list, options) { + if (typeof DEBUG !== "undefined" && DEBUG) { + if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); + } + + options = options || {}; + + options.attrs = typeof options.attrs === "object" ? options.attrs : {}; + + // Force single-tag solution on IE6-9, which has a hard limit on the # of