From db645b6b5c9abf7cb5daf1223a52bca29cd88270 Mon Sep 17 00:00:00 2001 From: Paolo Sanchi Date: Thu, 20 Jul 2023 16:31:14 +0200 Subject: [PATCH] - updated selenium so it works with latest versions of nodejs - updated pouchdb to 8.0.1 - dropped pouchdb-promise, replaced by native Promises - dropped pouchdb-memory, replaced by pouchdb-adapter-memory - fixed http tests to reflect CouchdDb's recent lastSeq behavior --- .jshintrc | 3 +- dist/pouchdb.replication-stream.js | 1865 ++++++++++-------------- dist/pouchdb.replication-stream.min.js | 8 +- lib/pouch-utils.js | 2 - lib/writable-stream.js | 1 - package.json | 6 +- test/test.js | 24 +- 7 files changed, 828 insertions(+), 1081 deletions(-) diff --git a/.jshintrc b/.jshintrc index 8b98e1a..cd3ed09 100755 --- a/.jshintrc +++ b/.jshintrc @@ -26,5 +26,6 @@ "afterEach", "it", "emit" - ] + ], + "esnext": true } \ No newline at end of file diff --git a/dist/pouchdb.replication-stream.js b/dist/pouchdb.replication-stream.js index f239493..85a0bd9 100644 --- a/dist/pouchdb.replication-stream.js +++ b/dist/pouchdb.replication-stream.js @@ -2,8 +2,6 @@ (function (process){ 'use strict'; -var Promise = _dereq_(33); - /* istanbul ignore next */ exports.once = function (fun) { var called = false; @@ -76,14 +74,14 @@ exports.toPromise = function (func) { }); }; -exports.inherits = _dereq_(13); +exports.inherits = _dereq_(12); -}).call(this,_dereq_(35)) -},{"13":13,"33":33,"35":35}],2:[function(_dereq_,module,exports){ +}).call(this,_dereq_(30)) +},{"12":12,"30":30}],2:[function(_dereq_,module,exports){ (function (Buffer){ 'use strict'; -var through = _dereq_(53).obj; +var through = _dereq_(50).obj; module.exports = function () { return through(function (chunk, _, next) { @@ -97,24 +95,23 @@ module.exports = function () { }); }; -}).call(this,_dereq_(8).Buffer) -},{"53":53,"8":8}],3:[function(_dereq_,module,exports){ +}).call(this,_dereq_(7).Buffer) +},{"50":50,"7":7}],3:[function(_dereq_,module,exports){ 'use strict'; -module.exports = _dereq_(59).version; +module.exports = _dereq_(56).version; -},{"59":59}],4:[function(_dereq_,module,exports){ +},{"56":56}],4:[function(_dereq_,module,exports){ (function (process){ 'use strict'; var utils = _dereq_(1); -var Promise = _dereq_(33); var ERROR_REV_CONFLICT = { status: 409, name: 'conflict', message: 'Document update conflict' }; -var ndj = _dereq_(19); +var ndj = _dereq_(17); var ERROR_MISSING_DOC = { status: 404, name: 'not_found', @@ -135,7 +132,8 @@ function WritableStreamPouch(opts, callback) { /* istanbul ignore next */ api.type = function () { - return 'writableStream'; + // see https://github.com/pouchdb/pouchdb/issues/6106 + return 'http'; }; api._remote = false; @@ -269,8 +267,8 @@ WritableStreamPouch.valid = function () { module.exports = WritableStreamPouch; -}).call(this,_dereq_(35)) -},{"1":1,"19":19,"33":33,"35":35}],5:[function(_dereq_,module,exports){ +}).call(this,_dereq_(30)) +},{"1":1,"17":17,"30":30}],5:[function(_dereq_,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -399,234 +397,11 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; },{}],6:[function(_dereq_,module,exports){ },{}],7:[function(_dereq_,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var Buffer = _dereq_(8).Buffer; - -var isBufferEncoding = Buffer.isEncoding - || function(encoding) { - switch (encoding && encoding.toLowerCase()) { - case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; - default: return false; - } - } - - -function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. CESU-8 is handled as part of the UTF-8 encoding. -// -// @TODO Handling all encodings inside a single object makes it very difficult -// to reason about this code, so it should be split up in the future. -// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code -// points as used by CESU-8. -var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } - - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; -}; - - -// write decodes the given buffer and returns it as JS string that is -// guaranteed to not contain any partial multi-byte characters. Any partial -// character found at the end of the buffer is buffered up, and will be -// returned when calling write again with the remaining bytes. -// -// Note: Converting a Buffer containing an orphan surrogate to a String -// currently works, but converting a String to a Buffer (via `new Buffer`, or -// Buffer#write) will replace incomplete surrogates with the unicode -// replacement character. See https://codereview.chromium.org/121173009/ . -StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } - - charStr += buffer.toString(this.encoding, 0, end); - - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } - - // or just emit the charStr - return charStr; -}; - -// detectIncompleteChar determines if there is an incomplete UTF-8 character at -// the end of the given buffer. If so, it sets this.charLength to the byte -// length that character, and sets this.charReceived to the number of bytes -// that are available for this character. -StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; -}; - -StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; -}; - -function passThroughWrite(buffer) { - return buffer.toString(this.encoding); -} - -function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; -} - -function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; -} - -},{"8":8}],8:[function(_dereq_,module,exports){ (function (global){ /*! * The buffer module from node.js, for the browser. * - * @author Feross Aboukhadijeh + * @author Feross Aboukhadijeh * @license MIT */ /* eslint-disable no-proto */ @@ -635,7 +410,7 @@ function base64DetectIncompleteChar(buffer) { var base64 = _dereq_(5) var ieee754 = _dereq_(11) -var isArray = _dereq_(15) +var isArray = _dereq_(8) exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer @@ -2173,8 +1948,14 @@ function blitBuffer (src, dst, offset, length) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"11":11,"15":15,"5":5}],9:[function(_dereq_,module,exports){ -(function (Buffer){ +},{"11":11,"5":5,"8":8}],8:[function(_dereq_,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],9:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -2277,14 +2058,13 @@ function isPrimitive(arg) { } exports.isPrimitive = isPrimitive; -exports.isBuffer = Buffer.isBuffer; +exports.isBuffer = _dereq_(7).Buffer.isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } -}).call(this,{"isBuffer":_dereq_(14)}) -},{"14":14}],10:[function(_dereq_,module,exports){ +},{"7":7}],10:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -2588,6 +2368,7 @@ function isUndefined(arg) { } },{}],11:[function(_dereq_,module,exports){ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -2674,104 +2455,35 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { } },{}],12:[function(_dereq_,module,exports){ -(function (global){ -'use strict'; -var Mutation = global.MutationObserver || global.WebKitMutationObserver; - -var scheduleDrain; - -{ - if (Mutation) { - var called = 0; - var observer = new Mutation(nextTick); - var element = global.document.createTextNode(''); - observer.observe(element, { - characterData: true - }); - scheduleDrain = function () { - element.data = (called = ++called % 2); - }; - } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') { - var channel = new global.MessageChannel(); - channel.port1.onmessage = nextTick; - scheduleDrain = function () { - channel.port2.postMessage(0); - }; - } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) { - scheduleDrain = function () { - - // Create a