Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 54 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"double-ended-queue": "2.1.0-0",
"fetch-cookie": "2.2.0",
"fetch-cookie": "3.2.0",
"fruitdown": "1.0.2",
"level": "6.0.1",
"level-codec": "9.0.2",
Expand All @@ -47,7 +47,6 @@
"localstorage-down": "0.6.7",
"ltgt": "2.2.1",
"memdown": "1.4.1",
"node-fetch": "2.6.9",
"readable-stream": "1.1.14",
"spark-md5": "3.0.2",
"through2": "3.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from 'pouchdb-collate';

import { generateErrorFromResponse } from 'pouchdb-errors';
import { Headers } from 'pouchdb-fetch';
import TaskQueue from './taskqueue';
import createView from './createView';
import {
Expand Down
33 changes: 7 additions & 26 deletions packages/node_modules/pouchdb-adapter-http/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pool from './promise-pool';

import { fetch, Headers } from 'pouchdb-fetch';
import { fetch } from 'pouchdb-fetch';

import {
createError,
Expand All @@ -23,6 +23,7 @@ import {
import {
atob,
btoa,
arrayBufferToBlobOrBuffer,
binaryStringToBlobOrBuffer as binStringToBluffer,
base64StringToBlobOrBuffer as b64StringToBluffer,
blobOrBufferToBase64 as blufferToBase64
Expand Down Expand Up @@ -514,20 +515,11 @@ function HttpPouch(opts, callback) {

const response = await ourFetch(genDBUrl(host, path));

let blob;
if ('buffer' in response) {
blob = await response.buffer();
} else {
/* istanbul ignore next */
blob = await response.blob();
}
const arrayBuffer = await response.arrayBuffer();
const blob = arrayBufferToBlobOrBuffer(arrayBuffer, att.content_type);

let data;
if (opts.binary) {
const typeFieldDescriptor = Object.getOwnPropertyDescriptor(blob.__proto__, 'type');
if (!typeFieldDescriptor || typeFieldDescriptor.set) {
blob.type = att.content_type;
}
data = blob;
} else {
data = await new Promise(function (resolve) {
Expand Down Expand Up @@ -635,21 +627,10 @@ function HttpPouch(opts, callback) {
}

contentType = response.headers.get('content-type');
let blob;
if (typeof process !== 'undefined' && !process.browser && typeof response.buffer === 'function') {
blob = await response.buffer();
} else {
/* istanbul ignore next */
blob = await response.blob();
}

// TODO: also remove
if (typeof process !== 'undefined' && !process.browser) {
const typeFieldDescriptor = Object.getOwnPropertyDescriptor(blob.__proto__, 'type');
if (!typeFieldDescriptor || typeFieldDescriptor.set) {
blob.type = contentType;
}
}
const arrayBuffer = await response.arrayBuffer();
const blob = arrayBufferToBlobOrBuffer(arrayBuffer, contentType);

callback(null, blob);
} catch (err) {
callback(err);
Expand Down
3 changes: 2 additions & 1 deletion packages/node_modules/pouchdb-binary-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./src/binaryStringToBlobOrBuffer.js": "./src/binaryStringToBlobOrBuffer-browser.js",
"./src/blobOrBufferToBase64.js": "./src/blobOrBufferToBase64-browser.js",
"./src/blobOrBufferToBinaryString.js": "./src/blobOrBufferToBinaryString-browser.js",
"./src/typedBuffer.js": "./src/typedBuffer-browser.js"
"./src/typedBuffer.js": "./src/typedBuffer-browser.js",
"./src/arrayBufferToBlobOrBuffer.js": "./src/arrayBufferToBlobOrBuffer-browser.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import blob from 'pouchdb-binary-utils/src/blob';

function arrayBufferToBlobOrBuffer(arrayBuffer, type) {
// In the browser, create a Blob
return blob([arrayBuffer], { type });
}

export default arrayBufferToBlobOrBuffer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function arrayBufferToBlobOrBuffer(arrayBuffer, type) {
// In Node.js, create a Buffer
const buffer = Buffer.from(arrayBuffer);
/* PouchDB uses `type` in various places, see `packages/node_modules/pouchdb-binary-utils/src/typedBuffer.js`
*/
buffer.type = type;
return buffer;
}

export default arrayBufferToBlobOrBuffer;
2 changes: 2 additions & 0 deletions packages/node_modules/pouchdb-binary-utils/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {atob, btoa} from './base64';
import arrayBufferToBlobOrBuffer from './arrayBufferToBlobOrBuffer';
import base64StringToBlobOrBuffer from './base64StringToBlobOrBuffer';
import binaryStringToArrayBuffer from './binaryStringToArrayBuffer';
import binaryStringToBlobOrBuffer from './binaryStringToBlobOrBuffer';
Expand All @@ -12,6 +13,7 @@ import typedBuffer from './typedBuffer';
export {
atob,
btoa,
arrayBufferToBlobOrBuffer,
base64StringToBlobOrBuffer,
binaryStringToArrayBuffer,
binaryStringToBlobOrBuffer,
Expand Down
3 changes: 1 addition & 2 deletions packages/node_modules/pouchdb-fetch/src/fetch-browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var f = fetch;
var h = Headers;

export { f as fetch, h as Headers };
export { f as fetch };
7 changes: 3 additions & 4 deletions packages/node_modules/pouchdb-fetch/src/fetch.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

import nodeFetch, {Headers} from 'node-fetch';
import fetchCookie from 'fetch-cookie';
import makeFetchCookie from 'fetch-cookie';

var fetch = fetchCookie(nodeFetch);
const fetchWithCookie = makeFetchCookie(fetch);

export { fetch, Headers };
export { fetchWithCookie as fetch };
2 changes: 1 addition & 1 deletion packages/node_modules/pouchdb-fetch/src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { fetch, Headers } from './fetch';
export { fetch } from './fetch';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createError, generateErrorFromResponse } from 'pouchdb-errors';
import { Headers } from 'pouchdb-fetch';
import massageCreateIndexRequest from '../../massageCreateIndexRequest';
import validateSelector from '../../validateSelector';

Expand Down
Loading
Loading