pouchdb-adapter-idb
Advanced tools
Comparing version 6.4.1 to 6.4.2
@@ -1,9 +0,9 @@ | ||
import { Map, Set } from 'pouchdb-collections'; | ||
import { assign, changesHandler, clone, filterChange, guardedConsole, hasLocalStorage, nextTick, pick, toPromise, uuid } from 'pouchdb-utils'; | ||
import { collectConflicts, compactTree, isDeleted, isLocalId, latest, traverseRevTree, winningRev } from 'pouchdb-merge'; | ||
import { IDB_ERROR, MISSING_DOC, MISSING_STUB, REV_CONFLICT, createError } from 'pouchdb-errors'; | ||
import { isLocalId as isLocalId$1, parseDoc, preprocessAttachments, processDocs } from 'pouchdb-adapter-utils'; | ||
import { assign, pick, changesHandler, nextTick, clone, filterChange, uuid, guardedConsole, toPromise, hasLocalStorage } from 'pouchdb-utils'; | ||
import Promise from 'pouchdb-promise'; | ||
import { createError, IDB_ERROR, MISSING_STUB, MISSING_DOC, REV_CONFLICT } from 'pouchdb-errors'; | ||
import { safeJsonParse, safeJsonStringify } from 'pouchdb-json'; | ||
import { base64StringToBlobOrBuffer, blob, btoa, readAsBinaryString } from 'pouchdb-binary-utils'; | ||
import { btoa, readAsBinaryString, base64StringToBlobOrBuffer, blob } from 'pouchdb-binary-utils'; | ||
import { Map, Set } from 'pouchdb-collections'; | ||
import { preprocessAttachments, processDocs, isLocalId, parseDoc } from 'pouchdb-adapter-utils'; | ||
import { compactTree, collectConflicts, isDeleted, isLocalId as isLocalId$1, traverseRevTree, winningRev, latest } from 'pouchdb-merge'; | ||
@@ -52,6 +52,6 @@ // IndexedDB requires a versioned database structure, so we use the | ||
// format for the revision trees other than JSON. | ||
function encodeMetadata(metadata, winningRev$$1, deleted) { | ||
function encodeMetadata(metadata, winningRev, deleted) { | ||
return { | ||
data: safeJsonStringify(metadata), | ||
winningRev: winningRev$$1, | ||
winningRev: winningRev, | ||
deletedOrLocal: deleted ? '1' : '0', | ||
@@ -262,3 +262,3 @@ seq: metadata.seq, // highest seq for this doc | ||
var doc = docInfos[i]; | ||
if (doc._id && isLocalId$1(doc._id)) { | ||
if (doc._id && isLocalId(doc._id)) { | ||
continue; | ||
@@ -371,3 +371,3 @@ } | ||
var docInfo = docInfos[i]; | ||
if (docInfo._id && isLocalId$1(docInfo._id)) { | ||
if (docInfo._id && isLocalId(docInfo._id)) { | ||
checkDone(); // skip local docs | ||
@@ -441,6 +441,6 @@ continue; | ||
function writeDoc(docInfo, winningRev$$1, winningRevIsDeleted, newRevIsDeleted, | ||
function writeDoc(docInfo, winningRev, winningRevIsDeleted, newRevIsDeleted, | ||
isUpdate, delta, resultsIdx, callback) { | ||
docInfo.metadata.winningRev = winningRev$$1; | ||
docInfo.metadata.winningRev = winningRev; | ||
docInfo.metadata.deleted = winningRevIsDeleted; | ||
@@ -459,3 +459,3 @@ | ||
if (hasAttachments) { | ||
return writeAttachments(docInfo, winningRev$$1, winningRevIsDeleted, | ||
return writeAttachments(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
@@ -467,7 +467,7 @@ } | ||
finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
} | ||
function finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
function finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback) { | ||
@@ -496,3 +496,3 @@ | ||
// delete metadata.rev; | ||
var metadataToStore = encodeMetadata(metadata, winningRev$$1, | ||
var metadataToStore = encodeMetadata(metadata, winningRev, | ||
winningRevIsDeleted); | ||
@@ -531,3 +531,3 @@ var metaDataReq = docStore.put(metadataToStore); | ||
function writeAttachments(docInfo, winningRev$$1, winningRevIsDeleted, | ||
function writeAttachments(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback) { | ||
@@ -543,3 +543,3 @@ | ||
if (numDone === attachments.length) { | ||
finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
@@ -559,3 +559,3 @@ } | ||
delete att.data; | ||
att.revpos = parseInt(winningRev$$1, 10); | ||
att.revpos = parseInt(winningRev, 10); | ||
var digest = att.digest; | ||
@@ -858,4 +858,4 @@ saveAttachment(digest, data, attachmentSaved); | ||
// want to block the main cursor while we're fetching the doc | ||
function fetchDocAsynchronously(metadata, row, winningRev$$1) { | ||
var key = metadata.id + "::" + winningRev$$1; | ||
function fetchDocAsynchronously(metadata, row, winningRev) { | ||
var key = metadata.id + "::" + winningRev; | ||
docIdRevIndex.get(key).onsuccess = function onGetDoc(e) { | ||
@@ -873,3 +873,3 @@ row.doc = decodeDoc(e.target.result); | ||
function allDocsInner(winningRev$$1, metadata) { | ||
function allDocsInner(winningRev, metadata) { | ||
var row = { | ||
@@ -879,3 +879,3 @@ id: metadata.id, | ||
value: { | ||
rev: winningRev$$1 | ||
rev: winningRev | ||
} | ||
@@ -894,3 +894,3 @@ }; | ||
if (opts.include_docs) { | ||
fetchDocAsynchronously(metadata, row, winningRev$$1); | ||
fetchDocAsynchronously(metadata, row, winningRev); | ||
} | ||
@@ -912,4 +912,4 @@ } | ||
var metadata = decodeMetadata(batchValue); | ||
var winningRev$$1 = metadata.winningRev; | ||
allDocsInner(winningRev$$1, metadata); | ||
var winningRev = metadata.winningRev; | ||
allDocsInner(winningRev, metadata); | ||
} | ||
@@ -987,4 +987,4 @@ } | ||
return new Promise(function (resolve) { | ||
var blob$$1 = blob(['']); | ||
var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob$$1, 'key'); | ||
var blob = blob(['']); | ||
var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key'); | ||
@@ -1327,3 +1327,3 @@ req.onsuccess = function () { | ||
var docId = metadata.id; | ||
var local = isLocalId(docId); | ||
var local = isLocalId$1(docId); | ||
var rev = winningRev(metadata); | ||
@@ -1672,6 +1672,6 @@ if (local) { | ||
compactRevs(revs, docId, txn); | ||
var winningRev$$1 = metadata.winningRev; | ||
var winningRev = metadata.winningRev; | ||
var deleted = metadata.deleted; | ||
txn.objectStore(DOC_STORE).put( | ||
encodeMetadata(metadata, winningRev$$1, deleted)); | ||
encodeMetadata(metadata, winningRev, deleted)); | ||
}; | ||
@@ -1988,2 +1988,3 @@ txn.onabort = idbError(callback); | ||
}; | ||
txn.onabort = idbError(callback); | ||
}; | ||
@@ -2007,2 +2008,7 @@ | ||
// 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 | ||
var hasFetch = typeof fetch === 'function' && | ||
fetch.toString().indexOf('[native code') !== -1; | ||
// On Firefox SecurityError is thrown while referencing indexedDB if cookies | ||
@@ -2013,3 +2019,3 @@ // are not allowed. `typeof indexedDB` also triggers the error. | ||
// and HTC Android devices <4.4 are missing IDBKeyRange | ||
return !isSafari && typeof indexedDB !== 'undefined' && | ||
return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' && | ||
typeof IDBKeyRange !== 'undefined'; | ||
@@ -2016,0 +2022,0 @@ } catch (e) { |
@@ -5,10 +5,10 @@ 'use strict'; | ||
var pouchdbCollections = require('pouchdb-collections'); | ||
var pouchdbUtils = require('pouchdb-utils'); | ||
var pouchdbMerge = require('pouchdb-merge'); | ||
var Promise = _interopDefault(require('pouchdb-promise')); | ||
var pouchdbErrors = require('pouchdb-errors'); | ||
var pouchdbAdapterUtils = require('pouchdb-adapter-utils'); | ||
var Promise = _interopDefault(require('pouchdb-promise')); | ||
var pouchdbJson = require('pouchdb-json'); | ||
var pouchdbBinaryUtils = require('pouchdb-binary-utils'); | ||
var pouchdbCollections = require('pouchdb-collections'); | ||
var pouchdbAdapterUtils = require('pouchdb-adapter-utils'); | ||
var pouchdbMerge = require('pouchdb-merge'); | ||
@@ -57,6 +57,6 @@ // IndexedDB requires a versioned database structure, so we use the | ||
// format for the revision trees other than JSON. | ||
function encodeMetadata(metadata, winningRev$$1, deleted) { | ||
function encodeMetadata(metadata, winningRev, deleted) { | ||
return { | ||
data: pouchdbJson.safeJsonStringify(metadata), | ||
winningRev: winningRev$$1, | ||
winningRev: winningRev, | ||
deletedOrLocal: deleted ? '1' : '0', | ||
@@ -252,3 +252,3 @@ seq: metadata.seq, // highest seq for this doc | ||
var changesHandler$1 = new pouchdbUtils.changesHandler(); | ||
var changesHandler = new pouchdbUtils.changesHandler(); | ||
@@ -390,3 +390,3 @@ function idbBulkDocs(dbOpts, req, opts, api, idb, callback) { | ||
changesHandler$1.notify(api._meta.name); | ||
changesHandler.notify(api._meta.name); | ||
callback(null, results); | ||
@@ -446,6 +446,6 @@ } | ||
function writeDoc(docInfo, winningRev$$1, winningRevIsDeleted, newRevIsDeleted, | ||
function writeDoc(docInfo, winningRev, winningRevIsDeleted, newRevIsDeleted, | ||
isUpdate, delta, resultsIdx, callback) { | ||
docInfo.metadata.winningRev = winningRev$$1; | ||
docInfo.metadata.winningRev = winningRev; | ||
docInfo.metadata.deleted = winningRevIsDeleted; | ||
@@ -464,3 +464,3 @@ | ||
if (hasAttachments) { | ||
return writeAttachments(docInfo, winningRev$$1, winningRevIsDeleted, | ||
return writeAttachments(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
@@ -472,7 +472,7 @@ } | ||
finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
} | ||
function finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
function finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback) { | ||
@@ -501,3 +501,3 @@ | ||
// delete metadata.rev; | ||
var metadataToStore = encodeMetadata(metadata, winningRev$$1, | ||
var metadataToStore = encodeMetadata(metadata, winningRev, | ||
winningRevIsDeleted); | ||
@@ -536,3 +536,3 @@ var metaDataReq = docStore.put(metadataToStore); | ||
function writeAttachments(docInfo, winningRev$$1, winningRevIsDeleted, | ||
function writeAttachments(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback) { | ||
@@ -548,3 +548,3 @@ | ||
if (numDone === attachments.length) { | ||
finishDoc(docInfo, winningRev$$1, winningRevIsDeleted, | ||
finishDoc(docInfo, winningRev, winningRevIsDeleted, | ||
isUpdate, resultsIdx, callback); | ||
@@ -564,3 +564,3 @@ } | ||
delete att.data; | ||
att.revpos = parseInt(winningRev$$1, 10); | ||
att.revpos = parseInt(winningRev, 10); | ||
var digest = att.digest; | ||
@@ -863,4 +863,4 @@ saveAttachment(digest, data, attachmentSaved); | ||
// want to block the main cursor while we're fetching the doc | ||
function fetchDocAsynchronously(metadata, row, winningRev$$1) { | ||
var key = metadata.id + "::" + winningRev$$1; | ||
function fetchDocAsynchronously(metadata, row, winningRev) { | ||
var key = metadata.id + "::" + winningRev; | ||
docIdRevIndex.get(key).onsuccess = function onGetDoc(e) { | ||
@@ -878,3 +878,3 @@ row.doc = decodeDoc(e.target.result); | ||
function allDocsInner(winningRev$$1, metadata) { | ||
function allDocsInner(winningRev, metadata) { | ||
var row = { | ||
@@ -884,3 +884,3 @@ id: metadata.id, | ||
value: { | ||
rev: winningRev$$1 | ||
rev: winningRev | ||
} | ||
@@ -899,3 +899,3 @@ }; | ||
if (opts.include_docs) { | ||
fetchDocAsynchronously(metadata, row, winningRev$$1); | ||
fetchDocAsynchronously(metadata, row, winningRev); | ||
} | ||
@@ -917,4 +917,4 @@ } | ||
var metadata = decodeMetadata(batchValue); | ||
var winningRev$$1 = metadata.winningRev; | ||
allDocsInner(winningRev$$1, metadata); | ||
var winningRev = metadata.winningRev; | ||
allDocsInner(winningRev, metadata); | ||
} | ||
@@ -992,4 +992,4 @@ } | ||
return new Promise(function (resolve) { | ||
var blob$$1 = pouchdbBinaryUtils.blob(['']); | ||
var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob$$1, 'key'); | ||
var blob = pouchdbBinaryUtils.blob(['']); | ||
var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key'); | ||
@@ -1068,7 +1068,7 @@ req.onsuccess = function () { | ||
var id = dbName + ':' + pouchdbUtils.uuid(); | ||
changesHandler$1.addListener(dbName, id, api, opts); | ||
changesHandler$1.notify(dbName); | ||
changesHandler.addListener(dbName, id, api, opts); | ||
changesHandler.notify(dbName); | ||
return { | ||
cancel: function () { | ||
changesHandler$1.removeListener(dbName, id); | ||
changesHandler.removeListener(dbName, id); | ||
} | ||
@@ -1677,6 +1677,6 @@ }; | ||
compactRevs(revs, docId, txn); | ||
var winningRev$$1 = metadata.winningRev; | ||
var winningRev = metadata.winningRev; | ||
var deleted = metadata.deleted; | ||
txn.objectStore(DOC_STORE).put( | ||
encodeMetadata(metadata, winningRev$$1, deleted)); | ||
encodeMetadata(metadata, winningRev, deleted)); | ||
}; | ||
@@ -1814,3 +1814,3 @@ txn.onabort = idbError(callback); | ||
api._destroy = function (opts, callback) { | ||
changesHandler$1.removeAllListeners(dbName); | ||
changesHandler.removeAllListeners(dbName); | ||
@@ -1994,2 +1994,3 @@ //Close open request for "dbName" database to fix ie delay. | ||
}; | ||
txn.onabort = idbError(callback); | ||
}; | ||
@@ -2013,2 +2014,7 @@ | ||
// 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 | ||
var hasFetch = typeof fetch === 'function' && | ||
fetch.toString().indexOf('[native code') !== -1; | ||
// On Firefox SecurityError is thrown while referencing indexedDB if cookies | ||
@@ -2019,3 +2025,3 @@ // are not allowed. `typeof indexedDB` also triggers the error. | ||
// and HTC Android devices <4.4 are missing IDBKeyRange | ||
return !isSafari && typeof indexedDB !== 'undefined' && | ||
return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' && | ||
typeof IDBKeyRange !== 'undefined'; | ||
@@ -2022,0 +2028,0 @@ } catch (e) { |
{ | ||
"name": "pouchdb-adapter-idb", | ||
"version": "6.4.1", | ||
"version": "6.4.2", | ||
"description": "PouchDB adapter using IndexedDB as its data store.", | ||
@@ -12,10 +12,10 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"pouchdb-adapter-utils": "6.4.1", | ||
"pouchdb-binary-utils": "6.4.1", | ||
"pouchdb-collections": "6.4.1", | ||
"pouchdb-errors": "6.4.1", | ||
"pouchdb-json": "6.4.1", | ||
"pouchdb-merge": "6.4.1", | ||
"pouchdb-promise": "6.4.1", | ||
"pouchdb-utils": "6.4.1" | ||
"pouchdb-adapter-utils": "6.4.2", | ||
"pouchdb-binary-utils": "6.4.2", | ||
"pouchdb-collections": "6.4.2", | ||
"pouchdb-errors": "6.4.2", | ||
"pouchdb-json": "6.4.2", | ||
"pouchdb-merge": "6.4.2", | ||
"pouchdb-promise": "6.4.2", | ||
"pouchdb-utils": "6.4.2" | ||
}, | ||
@@ -22,0 +22,0 @@ "module": "./lib/index.es.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128749
3556
4
+ Addedpouchdb-adapter-utils@6.4.2(transitive)
+ Addedpouchdb-binary-utils@6.4.2(transitive)
+ Addedpouchdb-collections@6.4.2(transitive)
+ Addedpouchdb-errors@6.4.2(transitive)
+ Addedpouchdb-json@6.4.2(transitive)
+ Addedpouchdb-md5@6.4.2(transitive)
+ Addedpouchdb-merge@6.4.2(transitive)
+ Addedpouchdb-promise@6.4.2(transitive)
+ Addedpouchdb-utils@6.4.2(transitive)
+ Addeduuid@3.2.1(transitive)
- Removedpouchdb-adapter-utils@6.4.1(transitive)
- Removedpouchdb-binary-utils@6.4.1(transitive)
- Removedpouchdb-collections@6.4.1(transitive)
- Removedpouchdb-errors@6.4.1(transitive)
- Removedpouchdb-json@6.4.1(transitive)
- Removedpouchdb-md5@6.4.1(transitive)
- Removedpouchdb-merge@6.4.1(transitive)
- Removedpouchdb-promise@6.4.1(transitive)
- Removedpouchdb-utils@6.4.1(transitive)
- Removeduuid@3.4.0(transitive)
Updatedpouchdb-adapter-utils@6.4.2
Updatedpouchdb-binary-utils@6.4.2
Updatedpouchdb-collections@6.4.2
Updatedpouchdb-errors@6.4.2
Updatedpouchdb-json@6.4.2
Updatedpouchdb-merge@6.4.2
Updatedpouchdb-promise@6.4.2
Updatedpouchdb-utils@6.4.2