From 149b5cf59cc760fa98c9753f4b4ec12d4b884d9a Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 19 Sep 2019 08:19:39 -0400 Subject: [PATCH] Reomving now obsolete Safari code base See README.md file: https://github.com/gorhill/uBlock/tree/master/platform/safari/README.md --- platform/safari/Info.plist | 91 -- platform/safari/README.md | 11 + platform/safari/Settings.plist | 22 - platform/safari/Update.plist | 21 - .../img/browsericons/safari-icon16-off.png | Bin 113 -> 0 bytes .../img/browsericons/safari-icon16-off.svg | 4 - .../img/browsericons/safari-icon16-off@2x.png | Bin 161 -> 0 bytes .../safari/img/browsericons/safari-icon16.png | Bin 239 -> 0 bytes .../safari/img/browsericons/safari-icon16.svg | 4 - .../img/browsericons/safari-icon16@2x.png | Bin 308 -> 0 bytes platform/safari/vapi-background.js | 895 ------------------ platform/safari/vapi-client.js | 343 ------- platform/safari/vapi-common.js | 148 --- platform/safari/vapi-popup.js | 52 - 14 files changed, 11 insertions(+), 1580 deletions(-) delete mode 100644 platform/safari/Info.plist create mode 100644 platform/safari/README.md delete mode 100644 platform/safari/Settings.plist delete mode 100644 platform/safari/Update.plist delete mode 100644 platform/safari/img/browsericons/safari-icon16-off.png delete mode 100644 platform/safari/img/browsericons/safari-icon16-off.svg delete mode 100644 platform/safari/img/browsericons/safari-icon16-off@2x.png delete mode 100644 platform/safari/img/browsericons/safari-icon16.png delete mode 100644 platform/safari/img/browsericons/safari-icon16.svg delete mode 100644 platform/safari/img/browsericons/safari-icon16@2x.png delete mode 100644 platform/safari/vapi-background.js delete mode 100644 platform/safari/vapi-client.js delete mode 100644 platform/safari/vapi-common.js delete mode 100644 platform/safari/vapi-popup.js diff --git a/platform/safari/Info.plist b/platform/safari/Info.plist deleted file mode 100644 index a36cc034f..000000000 --- a/platform/safari/Info.plist +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Author - Chris Aljoudi - Builder Version - 534.57.2 - CFBundleDisplayName - {name} - CFBundleIdentifier - net.gorhill.uBlock - CFBundleInfoDictionaryVersion - 6.0 - CFBundleShortVersionString - {version} - CFBundleVersion - {buildNumber} - Chrome - - Database Quota - 104857600 - Global Page - background.html - Popovers - - - Filename - popup.html - Identifier - popover - - - Toolbar Items - - - Identifier - toolbarItem - Image - img/browsericons/safari-icon16.png - Label - {name} - Palette Label - {name} - Popover - popover - Tool Tip - {name} {version} - - - - Content - - Scripts - - End - - js/contentscript-end.js - - Start - - js/vapi-client.js - js/contentscript-start.js - - - Whitelist - - http://*/* - https://*/* - - - Description - {description} - ExtensionInfoDictionaryVersion - 1.0 - Permissions - - Website Access - - Include Secure Pages - - Level - All - - - Update Manifest URL - https://chrismatic.io/ublock/Update.plist - Website - https://chrismatic.io/ - - diff --git a/platform/safari/README.md b/platform/safari/README.md new file mode 100644 index 000000000..6519b90f9 --- /dev/null +++ b/platform/safari/README.md @@ -0,0 +1,11 @@ +# Safari platform + +The Safari platform does not support the WebExtensions +framwork and thus is no longer supported. Consequently +the code base has been removed. + +The last commit which contains the code is +917f3620e0c08b722bbd4d400bca2735d9f6975f. + +You can browse the last state of the removed code base at +. diff --git a/platform/safari/Settings.plist b/platform/safari/Settings.plist deleted file mode 100644 index 6c80bbb43..000000000 --- a/platform/safari/Settings.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - DefaultValue - - FalseValue - - Key - open_prefs - Secure - - Title - Click to see the Preferences - TrueValue - - Type - CheckBox - - - diff --git a/platform/safari/Update.plist b/platform/safari/Update.plist deleted file mode 100644 index 1b0c141a4..000000000 --- a/platform/safari/Update.plist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Extension Updates - - - CFBundleIdentifier - net.gorhill.uBlock - Developer Identifier - 96G4BAKDQ9 - CFBundleShortVersionString - {version} - CFBundleVersion - {buildNumber} - URL - https://chrismatic.io/ublock/ublock-latest.safariextz - - - - diff --git a/platform/safari/img/browsericons/safari-icon16-off.png b/platform/safari/img/browsericons/safari-icon16-off.png deleted file mode 100644 index d223bd5e9a3b0d98560c5b057318d94c435b52d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6EIeHtLn;{0o-$-?aNuFt;8F2> zYQvPtO)b*{SQyrr6!QqPdR1OwQrh2o<65}Imf$bZ5sS92?I~jPIU{}VSg7r1pcxFF Lu6{1-oD!M - - - diff --git a/platform/safari/img/browsericons/safari-icon16-off@2x.png b/platform/safari/img/browsericons/safari-icon16-off@2x.png deleted file mode 100644 index 69f8263a72686653dd458dd35acc47f8a727c082..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4U8J;eVAr*|t2RPjhYH%cEFgUSV z+-Epru5hp6FVFwR4UFgV8$NS32Qs_yI$SoGU&G9GKckIu&*cEK} zjT?>xI5=G5HAtxNpUKGM@Za3wZlS!#dG@w$2EC<=6GRvo*jX~I4vOlh1MOt+boFyt I=akR{04QBB4gdfE diff --git a/platform/safari/img/browsericons/safari-icon16.png b/platform/safari/img/browsericons/safari-icon16.png deleted file mode 100644 index 7ecd4dc882e207bda594571b339edafec6695234..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6wt2cZhEy=-o>Glk$|%8h!T8+| zsdXhL8&&owu-;|ilRoIVBUtmqgFJcG=kMEI7KfA~{Z~!E9neuvmuR zq+GAd+Hz+li_~)@%D&#v6_CrE@H*hdr=!!3e=}yV`>p!na{PQoJLU&sA6z?@95%0E z@~{%IEbM;2@5iJPjlyL|S7cs)$8bZuKQH8WkG__yO<8$JgpgdMY3j|56<1g?XDbCt nJ6ucq#N%-5&Fqgc+#eY7qBgTe~DWM4fdYxQV diff --git a/platform/safari/img/browsericons/safari-icon16.svg b/platform/safari/img/browsericons/safari-icon16.svg deleted file mode 100644 index f4e68c2b6..000000000 --- a/platform/safari/img/browsericons/safari-icon16.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/platform/safari/img/browsericons/safari-icon16@2x.png b/platform/safari/img/browsericons/safari-icon16@2x.png deleted file mode 100644 index a82406837069335e0bd8fcbfa32fc400fb3f19a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 308 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4Uzdcng-@CR! z-@((D_3(pt@A72d<%tS!;CZLl{yE;xS}*j;-U=t5km8e@m16_j{Y!Q{Sbrt)uq!Is zFT(3})G+%@;oqtCDf46XrcC2qaXc-+ZQJ*$_ovqEzVu0~G~+CjPyN&71-)M*#Z5R2 zzScLHo-}6{zw%Eor&Ux$qbVSG#YQfvHBEAi#};#ov1a^He!;0{A)sKr>p`1}qnG8R zn)DT#9$Jr$Cv~vvAKd!*@7ag>J(_Rz7Tz*!b5}d5JXvJZiKP=V-%SY%{lE=%Pk$^%_6j`bVtO1pmBXE>q messaging > unknown request: %o', request.message); - - // Unhandled: - // Need to callback anyways in case caller expected an answer, or - // else there is a memory leak on caller's side - callback(); - }; - - /******************************************************************************/ - - vAPI.messaging.setup = function(defaultHandler) { - // Already setup? - if(this.defaultHandler !== null) { - return; - } - - if(typeof defaultHandler !== 'function') { - defaultHandler = function() { - return vAPI.messaging.UNHANDLED; - }; - } - this.defaultHandler = defaultHandler; - - // the third parameter must stay false (bubbling), so later - // onBeforeRequest will use true (capturing), where we can invoke - // stopPropagation() (this way this.onMessage won't be fired) - safari.application.addEventListener('message', this.onMessage, false); - }; - - /******************************************************************************/ - - vAPI.messaging.broadcast = function(message) { - message = { - broadcast: true, - msg: message - }; - - for(var tabId in vAPI.tabs.stack) { - vAPI.tabs.stack[tabId].page.dispatchMessage('broadcast', message); - } - }; - - /******************************************************************************/ - - vAPI.net = {}; - - /******************************************************************************/ - - // Fast `contains` - - Array.prototype.contains = function(a) { - var b = this.length; - while(b--) { - if(this[b] === a) { - return true; - } - } - return false; - }; - - /******************************************************************************/ - - vAPI.net.registerListeners = function() { - var µb = µBlock; - - // Until Safari has more specific events, those are instead handled - // in the onBeforeRequestAdapter; clean them up so they're garbage-collected - vAPI.net.onBeforeSendHeaders = null; - vAPI.net.onHeadersReceived = null; - - var onBeforeRequest = vAPI.net.onBeforeRequest, - onBeforeRequestClient = onBeforeRequest.callback, - blockableTypes = onBeforeRequest.types; - - var onBeforeRequestAdapter = function(e) { - if(e.name !== "canLoad") { - return; - } - e.stopPropagation && e.stopPropagation(); - if(e.message.type === "main_frame") { - vAPI.tabs.onNavigation({ - url: e.message.url, - frameId: 0, - tabId: vAPI.tabs.getTabId(e.target) - }); - e.message.hostname = µb.URI.hostnameFromURI(e.message.url); - e.message.tabId = vAPI.tabs.getTabId(e.target); - var blockVerdict = onBeforeRequestClient(e.message); - if(blockVerdict && blockVerdict.redirectUrl) { - e.target.url = blockVerdict.redirectUrl; - e.message = false; - } - else { - e.message = true; - } - return; - } - switch(e.message.type) { - case "popup": - vAPI.tabs.popupCandidate = vAPI.tabs.getTabId(e.target); - if(e.message.url === "about:blank") { - e.message = false; - return; - } - else { - e.message = !vAPI.tabs.onPopup({ - targetURL: e.message.url, - targetTabId: 0, - openerTabId: vAPI.tabs.getTabId(e.target) - }); - } - break; - case "popstate": - vAPI.tabs.onUpdated(vAPI.tabs.getTabId(e.target), { - url: e.message.url - }, { - url: e.message.url - }); - break; - default: - e.message.hostname = µb.URI.hostnameFromURI(e.message.url); - e.message.tabId = vAPI.tabs.getTabId(e.target); - var blockVerdict = onBeforeRequestClient(e.message); - if(blockVerdict && blockVerdict.cancel) { - e.message = false; - return; - } - else { - e.message = true; - return; - } - } - return; - }; - safari.application.addEventListener("message", onBeforeRequestAdapter, true); - }; - - /******************************************************************************/ - - vAPI.contextMenu = { - contextMap: { - frame: 'insideFrame', - link: 'linkHref', - image: 'srcUrl', - editable: 'editable' - } - }; - - /******************************************************************************/ - - vAPI.contextMenu.create = function(details, callback) { - var contexts = details.contexts; - var menuItemId = details.id; - var menuTitle = details.title; - - if(Array.isArray(contexts) && contexts.length) { - contexts = contexts.indexOf('all') === -1 ? contexts : null; - } else { - // default in Chrome - contexts = ['page']; - } - - this.onContextMenu = function(e) { - var uI = e.userInfo; - - if(!uI || /^https?:\/\//i.test(uI.pageUrl) === false) { - return; - } - - if(contexts) { - var invalidContext = true; - var ctxMap = vAPI.contextMenu.contextMap; - - for(var i = 0; i < contexts.length; i++) { - var ctx = contexts[i]; - - if(ctx === 'audio' || ctx === 'video') { - if(uI[ctxMap['image']] && uI.tagName === ctx) { - invalidContext = false; - break; - } - } else if(uI[ctxMap[ctx]]) { - invalidContext = false; - break; - } else if(ctx === 'page') { - if(!(uI.insideFrame || uI.linkHref || uI.mediaType || uI.editable)) { - invalidContext = false; - break; - } - } - } - - if(invalidContext) { - return; - } - } - - e.contextMenu.appendContextMenuItem(menuItemId, menuTitle); - }; - - this.onContextMenuCmd = function(e) { - if(e.command === menuItemId) { - var tab = e.currentTarget.activeBrowserWindow.activeTab; - e.userInfo.menuItemId = menuItemId; - callback(e.userInfo, tab ? { - id: vAPI.tabs.getTabId(tab), - url: tab.url - } : undefined); - } - }; - - safari.application.addEventListener('contextmenu', this.onContextMenu); - safari.application.addEventListener('command', this.onContextMenuCmd); - }; - - /******************************************************************************/ - - vAPI.contextMenu.remove = function() { - safari.application.removeEventListener('contextmenu', this.onContextMenu); - safari.application.removeEventListener('command', this.onContextMenuCmd); - this.onContextMenu = null; - this.onContextMenuCmd = null; - }; - - /******************************************************************************/ - - vAPI.lastError = function() { - return null; - }; - - /******************************************************************************/ - - // This is called only once, when everything has been loaded in memory after - // the extension was launched. It can be used to inject content scripts - // in already opened web pages, to remove whatever nuisance could make it to - // the web pages before uBlock was ready. - - vAPI.onLoadAllCompleted = function() {}; - - /******************************************************************************/ - - vAPI.punycodeHostname = function(hostname) { - return hostname; - }; - - vAPI.punycodeURL = function(url) { - return url; - }; - - /******************************************************************************/ - - function initStorageLib() { - /*! - localForage -- Offline Storage, Improved - Version 1.2.2 - https://mozilla.github.io/localForage - (c) 2013-2015 Mozilla, Apache License 2.0 -*/ -!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;jb;b+=4)c=e.indexOf(a[b]),d=e.indexOf(a[b+1]),f=e.indexOf(a[b+2]),g=e.indexOf(a[b+3]),l[j++]=c<<2|d>>4,l[j++]=(15&d)<<4|f>>2,l[j++]=(3&f)<<6|63&g;return k}function d(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=e[(3&c[b])<<4|c[b+1]>>4],d+=e[(15&c[b+1])<<2|c[b+2]>>6],d+=e[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f="__lfsc__:",g=f.length,h="arbf",i="blob",j="si08",k="ui08",l="uic8",m="si16",n="si32",o="ur16",p="ui32",q="fl32",r="fl64",s=g+h.length,t={serialize:a,deserialize:b,stringToBuffer:c,bufferToString:d};"undefined"!=typeof module&&module.exports?module.exports=t:"function"==typeof define&&define.amd?define("localforageSerializer",function(){return t}):this.localforageSerializer=t}.call(window),function(){"use strict";function a(a){var b=this,c={db:null};if(a)for(var d in a)c[d]=a[d];return new m(function(a,d){var e=n.open(c.name,c.version);e.onerror=function(){d(e.error)},e.onupgradeneeded=function(){e.result.createObjectStore(c.storeName)},e.onsuccess=function(){c.db=e.result,b._dbInfo=c,a()}})}function b(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new m(function(b,d){c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.get(a);g.onsuccess=function(){var a=g.result;void 0===a&&(a=null),b(a)},g.onerror=function(){d(g.error)}})["catch"](d)});return k(d,b),d}function c(a,b){var c=this,d=new m(function(b,d){c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.openCursor(),h=1;g.onsuccess=function(){var c=g.result;if(c){var d=a(c.value,c.key,h++);void 0!==d?b(d):c["continue"]()}else b()},g.onerror=function(){d(g.error)}})["catch"](d)});return k(d,b),d}function d(a,b,c){var d=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var e=new m(function(c,e){d.ready().then(function(){var f=d._dbInfo,g=f.db.transaction(f.storeName,"readwrite"),h=g.objectStore(f.storeName);null===b&&(b=void 0);var i=h.put(b,a);g.oncomplete=function(){void 0===b&&(b=null),c(b)},g.onabort=g.onerror=function(){e(i.error)}})["catch"](e)});return k(e,c),e}function e(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new m(function(b,d){c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readwrite"),g=f.objectStore(e.storeName),h=g["delete"](a);f.oncomplete=function(){b()},f.onerror=function(){d(h.error)},f.onabort=function(a){var b=a.target.error;"QuotaExceededError"===b&&d(b)}})["catch"](d)});return k(d,b),d}function f(a){var b=this,c=new m(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readwrite"),f=e.objectStore(d.storeName),g=f.clear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){c(g.error)}})["catch"](c)});return k(c,a),c}function g(a){var b=this,c=new m(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.count();f.onsuccess=function(){a(f.result)},f.onerror=function(){c(f.error)}})["catch"](c)});return j(c,a),c}function h(a,b){var c=this,d=new m(function(b,d){return 0>a?void b(null):void c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=!1,h=f.openCursor();h.onsuccess=function(){var c=h.result;return c?void(0===a?b(c.key):g?b(c.key):(g=!0,c.advance(a))):void b(null)},h.onerror=function(){d(h.error)}})["catch"](d)});return j(d,b),d}function i(a){var b=this,c=new m(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.openCursor(),g=[];f.onsuccess=function(){var b=f.result;return b?(g.push(b.key),void b["continue"]()):void a(g)},f.onerror=function(){c(f.error)}})["catch"](c)});return j(c,a),c}function j(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}function k(a,b){b&&a.then(function(a){l(b,a)},function(a){b(a)})}function l(a,b){return a?setTimeout(function(){return a(null,b)},0):void 0}var m="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,n=n||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(n){var o={_driver:"asyncStorage",_initStorage:a,iterate:c,getItem:b,setItem:d,removeItem:e,clear:f,length:g,key:h,keys:i};"undefined"!=typeof module&&module.exports?module.exports=o:"function"==typeof define&&define.amd?define("asyncStorage",function(){return o}):this.asyncStorage=o}}.call(window),function(){"use strict";function a(a){var b=this,c={};if(a)for(var d in a)c[d]=a[d];c.keyPrefix=c.name+"/",b._dbInfo=c;var e=new k(function(a){q===p.DEFINE?require(["localforageSerializer"],a):a(q===p.EXPORT?require("./../utils/serializer"):l.localforageSerializer)});return e.then(function(a){return m=a,k.resolve()})}function b(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=n.length-1;c>=0;c--){var d=n.key(c);0===d.indexOf(a)&&n.removeItem(d)}});return j(c,a),c}function c(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=c.ready().then(function(){var b=c._dbInfo,d=n.getItem(b.keyPrefix+a);return d&&(d=m.deserialize(d)),d});return j(d,b),d}function d(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo.keyPrefix,d=b.length,e=n.length,f=0;e>f;f++){var g=n.key(f),h=n.getItem(g);if(h&&(h=m.deserialize(h)),h=a(h,g.substring(d),f+1),void 0!==h)return h}});return j(d,b),d}function e(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=n.key(a)}catch(e){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return j(d,b),d}function f(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo,c=n.length,d=[],e=0;c>e;e++)0===n.key(e).indexOf(a.keyPrefix)&&d.push(n.key(e).substring(a.keyPrefix.length));return d});return j(c,a),c}function g(a){var b=this,c=b.keys().then(function(a){return a.length});return j(c,a),c}function h(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=c.ready().then(function(){var b=c._dbInfo;n.removeItem(b.keyPrefix+a)});return j(d,b),d}function i(a,b,c){var d=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var e=d.ready().then(function(){void 0===b&&(b=null);var c=b;return new k(function(e,f){m.serialize(b,function(b,g){if(g)f(g);else try{var h=d._dbInfo;n.setItem(h.keyPrefix+a,b),e(c)}catch(i){("QuotaExceededError"===i.name||"NS_ERROR_DOM_QUOTA_REACHED"===i.name)&&f(i),f(i)}})})});return j(e,c),e}function j(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}var k="undefined"!=typeof module&&module.exports?require("promise"):this.Promise,l=this,m=null,n=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;n=this.localStorage}catch(o){return}var p={DEFINE:1,EXPORT:2,WINDOW:3},q=p.WINDOW;"undefined"!=typeof module&&module.exports?q=p.EXPORT:"function"==typeof define&&define.amd&&(q=p.DEFINE);var r={_driver:"localStorageWrapper",_initStorage:a,iterate:d,getItem:c,setItem:i,removeItem:h,clear:b,length:g,key:e,keys:f};q===p.EXPORT?module.exports=r:q===p.DEFINE?define("localStorageWrapper",function(){return r}):this.localStorageWrapper=r}.call(window),function(){"use strict";function a(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"!=typeof a[d]?a[d].toString():a[d];var e=new k(function(a){p===o.DEFINE?require(["localforageSerializer"],a):a(p===o.EXPORT?require("./../utils/serializer"):l.localforageSerializer)}),f=new k(function(d,e){try{c.db=n(c.name,String(c.version),c.description,c.size)}catch(f){return b.setDriver(b.LOCALSTORAGE).then(function(){return b._initStorage(a)}).then(d)["catch"](e)}c.db.transaction(function(a){a.executeSql("CREATE TABLE IF NOT EXISTS "+c.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){b._dbInfo=c,d()},function(a,b){e(b)})})});return e.then(function(a){return m=a,f})}function b(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new k(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=m.deserialize(d)),b(d)},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function c(a,b){var c=this,d=new k(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName,[],function(c,d){for(var e=d.rows,f=e.length,g=0;f>g;g++){var h=e.item(g),i=h.value;if(i&&(i=m.deserialize(i)),i=a(i,h.key,g+1),void 0!==i)return void b(i)}b()},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function d(a,b,c){var d=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var e=new k(function(c,e){d.ready().then(function(){void 0===b&&(b=null);var f=b;m.serialize(b,function(b,g){if(g)e(g);else{var h=d._dbInfo;h.db.transaction(function(d){d.executeSql("INSERT OR REPLACE INTO "+h.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c(f)},function(a,b){e(b)})},function(a){a.code===a.QUOTA_ERR&&e(a)})}})})["catch"](e)});return j(e,c),e}function e(a,b){var c=this;"string"!=typeof a&&(window.console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new k(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function f(a){var b=this,c=new k(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})})["catch"](c)});return j(c,a),c}function g(a){var b=this,c=new k(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})})["catch"](c)});return j(c,a),c}function h(a,b){var c=this,d=new k(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function i(a){var b=this,c=new k(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e