summaryrefslogtreecommitdiff
path: root/www/lib/localforage/dist/localforage.nopromises.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
committerPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
commite18708f10b04455be151a5a799f0109c34f20a25 (patch)
tree9e4559ef0fff8b366474e7768308ddca1e32268a /www/lib/localforage/dist/localforage.nopromises.js
parent97a1cb3ae199c7b5455dcba0001efd5b4c32040a (diff)
package updates to set up bower correctly #535
Diffstat (limited to 'www/lib/localforage/dist/localforage.nopromises.js')
-rw-r--r--www/lib/localforage/dist/localforage.nopromises.js165
1 files changed, 91 insertions, 74 deletions
diff --git a/www/lib/localforage/dist/localforage.nopromises.js b/www/lib/localforage/dist/localforage.nopromises.js
index 76993df5..1a2042c7 100644
--- a/www/lib/localforage/dist/localforage.nopromises.js
+++ b/www/lib/localforage/dist/localforage.nopromises.js
@@ -1,8 +1,8 @@
/*!
localForage -- Offline Storage, Improved
- Version 1.4.2
- https://mozilla.github.io/localForage
- (c) 2013-2015 Mozilla, Apache License 2.0
+ Version 1.5.0
+ https://localforage.github.io/localForage
+ (c) 2013-2017 Mozilla, Apache License 2.0
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.localforage = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw (f.code="MODULE_NOT_FOUND", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
@@ -13,21 +13,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function getIDB() {
/* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */
- if (typeof indexedDB !== 'undefined') {
- return indexedDB;
- }
- if (typeof webkitIndexedDB !== 'undefined') {
- return webkitIndexedDB;
- }
- if (typeof mozIndexedDB !== 'undefined') {
- return mozIndexedDB;
- }
- if (typeof OIndexedDB !== 'undefined') {
- return OIndexedDB;
- }
- if (typeof msIndexedDB !== 'undefined') {
- return msIndexedDB;
- }
+ try {
+ if (typeof indexedDB !== 'undefined') {
+ return indexedDB;
+ }
+ if (typeof webkitIndexedDB !== 'undefined') {
+ return webkitIndexedDB;
+ }
+ if (typeof mozIndexedDB !== 'undefined') {
+ return mozIndexedDB;
+ }
+ if (typeof OIndexedDB !== 'undefined') {
+ return OIndexedDB;
+ }
+ if (typeof msIndexedDB !== 'undefined') {
+ return msIndexedDB;
+ }
+ } catch (e) {}
}
var idb = getIDB();
@@ -39,24 +41,19 @@ function isIndexedDBValid() {
if (!idb) {
return false;
}
- // We mimic PouchDB here; just UA test for Safari (which, as of
- // iOS 8/Yosemite, doesn't properly support IndexedDB).
- // IndexedDB support is broken and different from Blink's.
- // This is faster than the test case (and it's sync), so we just
- // do this. *SIGH*
- // http://bl.ocks.org/nolanlawson/raw/c83e9039edf2278047e9/
+ // We mimic PouchDB here;
//
// We test for openDatabase because IE Mobile identifies itself
// as Safari. Oh the lulz...
- if (typeof openDatabase !== 'undefined' && typeof navigator !== 'undefined' && navigator.userAgent && /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) {
- return false;
- }
+ var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);
- return idb && typeof idb.open === 'function' &&
- // Some Samsung/HTC Android 4.0-4.3 devices
- // have older IndexedDB specs; if this isn't available
- // their IndexedDB is too old for us to use.
- // (Replaces the onupgradeneeded test.)
+ var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;
+
+ // Safari <10.1 does not meet our requirements for IDB support (#5572)
+ // since Safari 10.1 shipped with fetch, we can use that to detect it
+ return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&
+ // some outdated implementations of IDB that appear on Samsung
+ // and HTC Android devices <4.4 are missing IDBKeyRange
typeof IDBKeyRange !== 'undefined';
} catch (e) {
return false;
@@ -102,7 +99,9 @@ function createBlob(parts, properties) {
// This is CommonJS because lie is an external dependency, so Rollup
// can just ignore it.
-if (typeof Promise === 'undefined' && typeof _dereq_ !== 'undefined') {
+if (typeof Promise === 'undefined') {
+ // In the "nopromises" build this will just throw if you don't have
+ // a global promise object, but it would throw anyway later.
_dereq_('lie/polyfill');
}
var Promise$1 = Promise;
@@ -117,12 +116,23 @@ function executeCallback(promise, callback) {
}
}
+function executeTwoCallbacks(promise, callback, errorCallback) {
+ if (typeof callback === 'function') {
+ promise.then(callback);
+ }
+
+ if (typeof errorCallback === 'function') {
+ promise["catch"](errorCallback);
+ }
+}
+
// Some code originally from async_storage.js in
// [Gaia](https://github.com/mozilla-b2g/gaia).
var DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';
var supportsBlobs;
var dbContexts;
+var toString = Object.prototype.toString;
// Transform a binary string to an array buffer, because otherwise
// weird stuff happens when you try to work with the binary string directly.
@@ -152,10 +162,11 @@ function _binStringToArrayBuffer(bin) {
// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836
//
// Code borrowed from PouchDB. See:
-// https://github.com/pouchdb/pouchdb/blob/9c25a23/src/adapters/idb/blobSupport.js
+// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js
//
-function _checkBlobSupportWithoutCaching(txn) {
+function _checkBlobSupportWithoutCaching(idb) {
return new Promise$1(function (resolve) {
+ var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, 'readwrite');
var blob = createBlob(['']);
txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');
@@ -264,7 +275,8 @@ function _getConnection(dbInfo, upgradeNeeded) {
};
}
- openreq.onerror = function () {
+ openreq.onerror = function (e) {
+ e.preventDefault();
reject(openreq.error);
};
@@ -362,7 +374,7 @@ function _fullyReady(callback) {
}
});
- promise.then(callback, callback);
+ executeTwoCallbacks(promise, callback, callback);
return promise;
}
@@ -553,7 +565,7 @@ function setItem(key, value, callback) {
var dbInfo;
self.ready().then(function () {
dbInfo = self._dbInfo;
- if (value instanceof Blob) {
+ if (toString.call(value) === '[object Blob]') {
return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {
if (blobSupport) {
return value;
@@ -565,6 +577,7 @@ function setItem(key, value, callback) {
}).then(function (value) {
var transaction = dbInfo.db.transaction(dbInfo.storeName, 'readwrite');
var store = transaction.objectStore(dbInfo.storeName);
+ var req = store.put(value, key);
// The reason we don't _save_ null is because IE 10 does
// not support saving the `null` type in IndexedDB. How
@@ -591,8 +604,6 @@ function setItem(key, value, callback) {
var err = req.error ? req.error : req.transaction.error;
reject(err);
};
-
- var req = store.put(value, key);
})["catch"](reject);
});
@@ -813,6 +824,8 @@ var TYPE_FLOAT32ARRAY = 'fl32';
var TYPE_FLOAT64ARRAY = 'fl64';
var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;
+var toString$1 = Object.prototype.toString;
+
function stringToBuffer(serializedString) {
// Fill the string into a ArrayBuffer.
var bufferLength = serializedString.length * 0.75;
@@ -874,16 +887,16 @@ function bufferToString(buffer) {
// instructs the `setItem()` callback/promise to be executed). This is how
// we store binary data with localStorage.
function serialize(value, callback) {
- var valueString = '';
+ var valueType = '';
if (value) {
- valueString = value.toString();
+ valueType = toString$1.call(value);
}
// Cannot use `value instanceof ArrayBuffer` or such here, as these
// checks fail when running the tests using casper.js...
//
// TODO: See why those tests fail and use a better solution.
- if (value && (value.toString() === '[object ArrayBuffer]' || value.buffer && value.buffer.toString() === '[object ArrayBuffer]')) {
+ if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {
// Convert binary arrays to a string and prefix the string with
// a special marker.
var buffer;
@@ -895,23 +908,23 @@ function serialize(value, callback) {
} else {
buffer = value.buffer;
- if (valueString === '[object Int8Array]') {
+ if (valueType === '[object Int8Array]') {
marker += TYPE_INT8ARRAY;
- } else if (valueString === '[object Uint8Array]') {
+ } else if (valueType === '[object Uint8Array]') {
marker += TYPE_UINT8ARRAY;
- } else if (valueString === '[object Uint8ClampedArray]') {
+ } else if (valueType === '[object Uint8ClampedArray]') {
marker += TYPE_UINT8CLAMPEDARRAY;
- } else if (valueString === '[object Int16Array]') {
+ } else if (valueType === '[object Int16Array]') {
marker += TYPE_INT16ARRAY;
- } else if (valueString === '[object Uint16Array]') {
+ } else if (valueType === '[object Uint16Array]') {
marker += TYPE_UINT16ARRAY;
- } else if (valueString === '[object Int32Array]') {
+ } else if (valueType === '[object Int32Array]') {
marker += TYPE_INT32ARRAY;
- } else if (valueString === '[object Uint32Array]') {
+ } else if (valueType === '[object Uint32Array]') {
marker += TYPE_UINT32ARRAY;
- } else if (valueString === '[object Float32Array]') {
+ } else if (valueType === '[object Float32Array]') {
marker += TYPE_FLOAT32ARRAY;
- } else if (valueString === '[object Float64Array]') {
+ } else if (valueType === '[object Float64Array]') {
marker += TYPE_FLOAT64ARRAY;
} else {
callback(new Error('Failed to get type for BinaryArray'));
@@ -919,7 +932,7 @@ function serialize(value, callback) {
}
callback(marker + bufferToString(buffer));
- } else if (valueString === '[object Blob]') {
+ } else if (valueType === '[object Blob]') {
// Conver the blob to a binaryArray and then to a string.
var fileReader = new FileReader();
@@ -1137,7 +1150,7 @@ function iterate$1(iterator, callback) {
return promise;
}
-function setItem$1(key, value, callback) {
+function _setItem(key, value, callback, retriesLeft) {
var self = this;
// Cast the key to a string, as that's all we can set as a key.
@@ -1179,7 +1192,11 @@ function setItem$1(key, value, callback) {
// more storage on Safari, this error will
// be called.
//
- // TODO: Try to re-run the transaction.
+ // Try to re-run the transaction.
+ if (retriesLeft > 0) {
+ resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));
+ return;
+ }
reject(sqlError);
}
});
@@ -1192,6 +1209,10 @@ function setItem$1(key, value, callback) {
return promise;
}
+function setItem$1(key, value, callback) {
+ return _setItem.apply(this, [key, value, callback, 1]);
+}
+
function removeItem$1(key, callback) {
var self = this;
@@ -1590,16 +1611,6 @@ var localStorageWrapper = {
keys: keys$2
};
-function executeTwoCallbacks(promise, callback, errorCallback) {
- if (typeof callback === 'function') {
- promise.then(callback);
- }
-
- if (typeof errorCallback === 'function') {
- promise["catch"](errorCallback);
- }
-}
-
// Custom drivers are stored here when `defineDriver()` is called.
// They are shared across all instances of localForage.
var CustomDrivers = {};
@@ -1696,7 +1707,7 @@ var LocalForage = function () {
this._dbInfo = null;
this._wrapLibraryMethodsWithReady();
- this.setDriver(this._config.driver);
+ this.setDriver(this._config.driver)["catch"](function () {});
}
// Set any config values for localForage; can be called anytime before
@@ -1721,13 +1732,17 @@ var LocalForage = function () {
options[i] = options[i].replace(/\W/g, '_');
}
+ if (i === 'version' && typeof options[i] !== 'number') {
+ return new Error('Database version must be a number.');
+ }
+
this._config[i] = options[i];
}
// after all config options are set and
// the driver option is used, try setting it
if ('driver' in options && options.driver) {
- this.setDriver(this._config.driver);
+ return this.setDriver(this._config.driver);
}
return true;
@@ -1852,6 +1867,14 @@ var LocalForage = function () {
self._config.driver = self.driver();
}
+ function extendSelfWithDriver(driver) {
+ self._extend(driver);
+ setDriverToConfig();
+
+ self._ready = self._initStorage(self._config);
+ return self._ready;
+ }
+
function initDriver(supportedDrivers) {
return function () {
var currentDriverIndex = 0;
@@ -1864,13 +1887,7 @@ var LocalForage = function () {
self._dbInfo = null;
self._ready = null;
- return self.getDriver(driverName).then(function (driver) {
- self._extend(driver);
- setDriverToConfig();
-
- self._ready = self._initStorage(self._config);
- return self._ready;
- })["catch"](driverPromiseLoop);
+ return self.getDriver(driverName).then(extendSelfWithDriver)["catch"](driverPromiseLoop);
}
setDriverToConfig();