Skip to content

Commit

Permalink
Merge branch 'master' into migration-before
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Nov 23, 2023
2 parents 12aafca + 15cd6a0 commit 25c56b7
Show file tree
Hide file tree
Showing 33 changed files with 206 additions and 192 deletions.
2 changes: 1 addition & 1 deletion bin/build-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function buildCSS() {
}

function buildJekyll(path) {
// Dont rebuild on website artifacts being written
// Don't rebuild on website artifacts being written
if (path && /^_site/.test(path.relative)) {
return;
}
Expand Down
120 changes: 49 additions & 71 deletions bin/test-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ testUrl += '?';
testUrl += new URLSearchParams(pickBy(qs, identity));

class RemoteRunner {
constructor() {
constructor(browser) {
this.browser = browser;
this.handlers = {};
this.completed = false;
this.failed = false;
this.handleEvent = this.handleEvent.bind(this);
}

on(name, handler) {
Expand All @@ -72,46 +72,47 @@ class RemoteRunner {
handlers[name].push(handler);
}

handleEvents(events) {
var handlers = this.handlers;

events.forEach((event) => {
this.completed = this.completed || event.name === 'end';
this.failed = this.failed || event.name === 'fail';

async handleEvent(event) {
try {
var additionalProps = ['pass', 'fail', 'pending'].indexOf(event.name) === -1 ? {} : {
slow: event.obj.slow ? function () { return event.obj.slow; } : function () { return 60; },
fullTitle: event.obj.fullTitle ? function () { return event.obj.fullTitle; } : undefined
};
var obj = Object.assign({}, event.obj, additionalProps);

handlers[event.name].forEach(function (handler) {
this.handlers[event.name].forEach(function (handler) {
handler(obj, event.err);
});

if (event.logs && event.logs.length > 0) {
event.logs.forEach(function (line) {
if (line.type === 'log') {
console.log(line.content);
} else if (line.type === 'error') {
console.error(line.content);
} else {
console.error('Invalid log line', line);
}
});
console.log();
switch (event.name) {
case 'fail': this.handleFailed(); break;
case 'end': this.handleEnd(); break;
}
});
}
} catch (e) {
console.error('Tests failed:', e);

bail() {
var handlers = this.handlers;
await this.browser.close();
process.exit(3);
}
}

handlers['end'].forEach(function (handler) {
handler();
});
async handleEnd(failed) {
await this.browser.close();
process.exit(!process.env.PERF && failed ? 1 : 0);
}

this.completed = true;
handleFailed() {
if (bail) {
try {
this.handlers['end'].forEach(function (handler) {
handler();
});
} catch (e) {
console.log('An error occurred while bailing:', e);
} finally {
this.handleEnd(true);
}
}
}
}

Expand Down Expand Up @@ -142,7 +143,13 @@ async function startTest() {

console.log('Starting', browserName, 'on', testUrl);

const runner = new RemoteRunner();
const options = {
headless: true,
};
const browser = await playwright[browserName].launch(options);
const page = await browser.newPage();

const runner = new RemoteRunner(browser);
new MochaSpecReporter(runner);
new BenchmarkConsoleReporter(runner);

Expand All @@ -154,11 +161,14 @@ async function startTest() {
new BenchmarkJsonReporter(runner);
}

const options = {
headless: true,
};
const browser = await playwright[browserName].launch(options);
const page = await browser.newPage();
page.exposeFunction('handleMochaEvent', runner.handleEvent);
page.addInitScript(() => {
window.addEventListener('message', (e) => {
if (e.data.type === 'mocha') {
window.handleMochaEvent(e.data.details);
}
});
});

page.on('pageerror', err => {
if (browserName === 'webkit' && err.toString()
Expand All @@ -174,46 +184,14 @@ async function startTest() {
process.exit(1);
});

if (process.env.BROWSER_CONSOLE) {
page.on('console', message => {
const { url, lineNumber } = message.location();
console.log('BROWSER', message.type().toUpperCase(), `${url}:${lineNumber}`, message.text());
});
}
page.on('console', message => {
console.log(message.text());
});

await page.goto(testUrl);

const userAgent = await page.evaluate('navigator.userAgent');
console.log('Testing on:', userAgent);

const interval = setInterval(async () => {
try {
const events = await page.evaluate('window.testEvents()');
runner.handleEvents(events);

if (runner.completed || (runner.failed && bail)) {
if (!runner.completed && runner.failed) {
try {
runner.bail();
} catch (e) {
// Temporary debugging of bailing failure
console.log('An error occurred while bailing:');
console.log(e);
}
}

clearInterval(interval);
await browser.close();
process.exit(!process.env.PERF && runner.failed ? 1 : 0);
}
} catch (e) {
console.error('Tests failed:', e);

clearInterval(interval);
await browser.close();
process.exit(3);
}
}, 1000);
}

devserver.start(function () {
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2014-04-01-pouchdb-2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ This release contains a database migration, which means that once you upgrade yo
* Improve error reporting from replicator ([#1714](http://github.com/daleharvey/pouchdb/issues/1714))
* Switch to readAsArrayBuffer for IE binary support ([#1667](http://github.com/daleharvey/pouchdb/issues/1667))
* Add `npm run shell` for quick shell experimenting ([#1610](http://github.com/daleharvey/pouchdb/issues/1610))
* Ensure we dont lose data when browsers upgrade from WebSQL to IDB ([#1289](http://github.com/daleharvey/pouchdb/issues/1289))
* Ensure we don't lose data when browsers upgrade from WebSQL to IDB ([#1289](http://github.com/daleharvey/pouchdb/issues/1289))

###### [Complete list of changes](https://github.com/daleharvey/pouchdb/compare/2.0.1...2.1.0)
4 changes: 2 additions & 2 deletions docs/_posts/2014-09-07-pouchdb-3.0.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We literally wrote [a custom JSON parser](https://github.com/nolanlawson/vuvuzel

The ["infinite recursion" bug](https://github.com/pouchdb/pouchdb/issues/2543) shows up when you have many (> 1000) revisions to the same document. For instance, imagine a text editor that `put()`s a new version of the document for every keystroke. This is fine in traditional databases, but it can be a big problem in PouchDB/CouchDB, because we store the entire history of the database.

Make no mistake: inifinitely-large revision histories will now work in PouchDB 3.0.5. However, it's a lot like riding a bicycle without a helmet: you _can_ do it, but you probably shouldn't.
Make no mistake: infinitely-large revision histories will now work in PouchDB 3.0.5. However, it's a lot like riding a bicycle without a helmet: you _can_ do it, but you probably shouldn't.

Your mental model for this can be something like Git. Imagine a new `git commit` for every keystroke, and you'll see why it might be a bit problematic.

Expand All @@ -45,4 +45,4 @@ Your mental model for this can be something like Git. Imagine a new `git commit`

Of course, you can always `compact()` to remove old versions, but this just removes the document data. PouchDB still needs to maintain a permanent tree of the `_rev` hashes in order for the replication algorithm to work properly. If this tree grows excessively, it can bloat your database, whether or not you do compaction.

What this means is that you should be very careful about updating your documents. Try to update your documents in larger batches, or use a pattern like [delta-pouch](https://github.com/redgeoff/delta-pouch) to avoid creating new revisions altogether.
What this means is that you should be very careful about updating your documents. Try to update your documents in larger batches, or use a pattern like [delta-pouch](https://github.com/redgeoff/delta-pouch) to avoid creating new revisions altogether.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ User agent sniffing! Yes, we should be ashamed of ourselves. But here's why we d
* Additionally, if you specify anywhere between 0 and 5000000, Safari and iOS will use that size as a hint for when, precisely, to show the popup. And in the case of PouchDB, we need to avoid the popup in our automated tests, because Selenium doesn't give us a way to press the "OK" button, meaning our tests would just fail if we request too much. So the ideal size to request is 0.
* However, in **PhantomJS** and older WebKit (Safari ~5), if you request 0, then it will blow up.

For the recored, here's what the dreaded Safari popup looks like:
For the record, here's what the dreaded Safari popup looks like:

{% include img.html src="safari_popup.png" alt="annoying Safari popup" %}

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2014-11-10-3.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ We keep a list of [plugins and related external projects]({{ site.baseurl }}/ext

* PouchDB [Dump](https://github.com/nolanlawson/pouchdb-dump-cli) and [Load](https://github.com/nolanlawson/pouchdb-load) are designed to help you load data into your newly started PouchDB app faster than replication will do currently.
* If you want to use PouchDB with Angular, you are in luck, there are now 4! adapters to help you integrate them: [angular-pouchdb](https://github.com/wspringer/angular-pouchdb), [Factoryng](https://github.com/redgeoff/factoryng), [ngPouch](https://github.com/jrhicks/ngPouch), [ng-pouchdb](https://github.com/danielzen/ng-pouchdb).
* Ember users arent left in the wild: [ember-pouchdb](https://github.com/taras/ember-pouchdb) should get you going with PouchDB and Ember.
* Ember users aren't left in the wild: [ember-pouchdb](https://github.com/taras/ember-pouchdb) should get you going with PouchDB and Ember.
* If you are using Blobs with PouchDB, you probably want to take a look at [blob-util](https://github.com/nolanlawson/blob-util).

### Bug fixes Galore
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2014-11-27-testing-pouchdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We use [Selenium](http://www.seleniumhq.org/) to drive tests in the browser, and

We are also finding some platforms (particularly iPhone and Internet Explorer) will become unstable on Saucelabs. The errors almost always come from our code, but it is hard to maintain a reliable test suite when the underlying platform changes and you have little control over it.

Before settling on Selenium, I had previously tried out [Testling](https://ci.testling.com/), and similiarly to Tape it was very easy to get started but opinionated. It was also broken on OSX with pull requests containing fixes that hadn't been touched for months. Selenium had the advantage that it was very widely used, and new frameworks or platforms are likely to have WebDriver support early on.
Before settling on Selenium, I had previously tried out [Testling](https://ci.testling.com/), and similarly to Tape it was very easy to get started but opinionated. It was also broken on OSX with pull requests containing fixes that hadn't been touched for months. Selenium had the advantage that it was very widely used, and new frameworks or platforms are likely to have WebDriver support early on.

I have however found Selenium as a project frustrating to use, from the first time visiting [http://www.seleniumhq.org/](http://www.seleniumhq.org/) to understanding what I needed to download and write a first test that started a browser, it was an unclear and confusing process. Even today getting ChromeDriver started correctly gets me confused, also the download cost of 30MB for what is mostly a proxy server is an annoyance.

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2015-03-05-taming-the-async-beast-with-es7.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ So if you want to play with it yourself, I've put together a [small demo library

### Conclusion

Async functions are an empowering new concept in ES7. They give us back our lost `return`s and `try`/`catch`es, and they reward the knowledge we've already gained from writing synchronous code with new idiioms that look a lot like the old ones, but are much more performant.
Async functions are an empowering new concept in ES7. They give us back our lost `return`s and `try`/`catch`es, and they reward the knowledge we've already gained from writing synchronous code with new idioms that look a lot like the old ones, but are much more performant.

Most importantly, async functions make APIs like PouchDB's a lot easier to work with. So hopefully this will lead to fewer user errors and confusion, as well as more elegant and readable code.

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ replication.on('paused', doneFun);
* Fix attachment length for stubs ([#3963](https://github.com/pouchdb/pouchdb/issues/3963))
* Reduce the number of checkpoint mismatches ([#4009](https://github.com/pouchdb/pouchdb/issues/4009))
* Fallback from checkpoint mismatch correctly (less replication start from the beginning) ([#3999](https://github.com/pouchdb/pouchdb/issues/3999))
* Dont fail replication when attachment request fails ([#4021](https://github.com/pouchdb/pouchdb/issues/4021))
* Don't fail replication when attachment request fails ([#4021](https://github.com/pouchdb/pouchdb/issues/4021))
* Fix check for `localStorage` in Safari private mode ([#4070](https://github.com/pouchdb/pouchdb/issues/4070))
### Coverage improvements
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2015-11-03-cover-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ We have had issues in the past with how to manage npm dependencies. Version rang
### Bugfixes

* Explain http error caused by checking for `_bulk_get` ([#4435](http://github.com/pouchdb/pouchdb/issues/4435))
* Dont create a database just to delete it ([#4467](http://github.com/pouchdb/pouchdb/issues/4467))
* Don't create a database just to delete it ([#4467](http://github.com/pouchdb/pouchdb/issues/4467))
* Add friendly err msg to common leveldown err ([#4447](http://github.com/pouchdb/pouchdb/issues/4447))
* Avoid empty bulkGet() ([#4474](http://github.com/pouchdb/pouchdb/issues/4474))
* Fix http url with port 80 ([#247](https://github.com/pouchdb/express-pouchdb/issues/247))
Expand Down
4 changes: 2 additions & 2 deletions docs/_posts/2016-06-06-pouchdb-5.4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This API was not removed, but will log a warning if you try to use it.
* ([#3923](https://github.com/pouchdb/pouchdb/issues/3923)) - Add ability to set url as prefix
* ([#4922](https://github.com/pouchdb/pouchdb/issues/4922)) - Do not call 'destroyed' twice for http instances
* ([#3609](https://github.com/pouchdb/pouchdb/issues/3609)) - opts.view implies filter=_view
* ([#4444](https://github.com/pouchdb/pouchdb/issues/4444)) - Dont leak event emitters
* ([#4444](https://github.com/pouchdb/pouchdb/issues/4444)) - Don't leak event emitters
* ([#5197](https://github.com/pouchdb/pouchdb/issues/5197)) - detect WebSQL invalid on WKWebView
* ([#5200](https://github.com/pouchdb/pouchdb/issues/5200)) - Don't clone special objects like Workers
* ([#5196](https://github.com/pouchdb/pouchdb/issues/5196)) - fix excessively long replication loop
Expand Down Expand Up @@ -123,7 +123,7 @@ This API was not removed, but will log a warning if you try to use it.

* ([#4575](https://github.com/pouchdb/pouchdb/issues/4575)) - Fix tests against CouchDB master
* ([#5260](https://github.com/pouchdb/pouchdb/issues/5260)) - Catches unhandled rejections in tests
* ([#2426](https://github.com/pouchdb/pouchdb/issues/2426)) - Add test to ensure doc_ids dont prevent replication
* ([#2426](https://github.com/pouchdb/pouchdb/issues/2426)) - Add test to ensure doc_ids don't prevent replication
* ([#4767](https://github.com/pouchdb/pouchdb/issues/4767)) - 100% code coverage
* ([#5186](https://github.com/pouchdb/pouchdb/issues/5186)) - build in Node 5, test in other Nodes

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2018-01-23-pouchdb-6.4.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Currently it looks likely that we will remove our [Promise Polyfill](https://git

## Other Changes

- [#7019](https://github.com/pouchdb/pouchdb/issues/7019) - Dont crash on empty HTTP requests
- [#7019](https://github.com/pouchdb/pouchdb/issues/7019) - Don't crash on empty HTTP requests
- [#7008](https://github.com/pouchdb/pouchdb/issues/7008) - Add Glitch bug helper
- [#6954](https://github.com/pouchdb/pouchdb/issues/6954) - Fix hang when storage quota is exceeded
- [#6958](https://github.com/pouchdb/pouchdb/issues/6958) - Fix PouchDB find with zero values
Expand Down
4 changes: 2 additions & 2 deletions docs/_posts/2022-11-11-pouchdb-7.3.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ We're happy to announce the release of PouchDB 7.3.1, bringing in some fixes and

### Bugfixes

* [7db104c5](https://github.com/pouchdb/pouchdb/commit/7db104c56248738598feb7ca1f22bc3b7bbd69be) ([#8463](https://github.com/pouchdb/pouchdb/issues/8463)) - check if docFieldValue is also null value. typeof null returns object in javasctipy. Fixes a bug when querying against and array with a null value, $elemMatch and $allMatch.
* [7db104c5](https://github.com/pouchdb/pouchdb/commit/7db104c56248738598feb7ca1f22bc3b7bbd69be) ([#8463](https://github.com/pouchdb/pouchdb/issues/8463)) - check if docFieldValue is also null value. typeof null returns object in javascript. Fixes a bug when querying against and array with a null value, $elemMatch and $allMatch.
* [719502dc](https://github.com/pouchdb/pouchdb/commit/719502dc6a75851dce9d0a35e44929b25943588c) ([#8225](https://github.com/pouchdb/pouchdb/issues/8225)) - Added check for blob.type setter
* [d5bb7bd6](https://github.com/pouchdb/pouchdb/commit/d5bb7bd6330339448f5918592bd69df78166bad2) ([#8389](https://github.com/pouchdb/pouchdb/pull/8389)) - `_id` was mappped to `data._id` instead of id
* [d5bb7bd6](https://github.com/pouchdb/pouchdb/commit/d5bb7bd6330339448f5918592bd69df78166bad2) ([#8389](https://github.com/pouchdb/pouchdb/pull/8389)) - `_id` was mapped to `data._id` instead of id
* [bbeb7e55](https://github.com/pouchdb/pouchdb/commit/bbeb7e557658fb405b5cf91dec50a79faf5278a3) ([#8531](https://github.com/pouchdb/pouchdb/pull/8531)) - fix sorted find including deleted docs

### Testing
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2022-12-14-pouchdb-8.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Example result:
* [774976a0](https://github.com/pouchdb/pouchdb/commit/774976a02781c3953727244706adfb0d5cce420a) feat: on-update view purging
* [94ec8932](https://github.com/pouchdb/pouchdb/commit/94ec8932fd79a2993c82a5381ae34d64c286375f) feat(core): `purged_infos_limit` support
* [ce8f8b30](https://github.com/pouchdb/pouchdb/commit/ce8f8b308f4509def96272693f797deac05b55e0) [wip] Purge leaves from multiple roots
* [4252a0f0](https://github.com/pouchdb/pouchdb/commit/4252a0f0ba71ab63f493709fe81e5e63baeb5dee) docs(purge): show result object seperately
* [4252a0f0](https://github.com/pouchdb/pouchdb/commit/4252a0f0ba71ab63f493709fe81e5e63baeb5dee) docs(purge): show result object separately
* [b856173b](https://github.com/pouchdb/pouchdb/commit/b856173b436c201d86c0c63319eaf0dc8396a772) chore(purge): add code comments
* [d5f4250a](https://github.com/pouchdb/pouchdb/commit/d5f4250a3539b62c430203441bcb02fa41e00ae2) chore(purge): remove unneeded logs and comments
* [2c0ddbb0](https://github.com/pouchdb/pouchdb/commit/2c0ddbb01e9d01ba2b4ccc754ff855a15173208c) feat(purge): simplify implementation of removeLeafFromTree()
Expand Down
2 changes: 1 addition & 1 deletion docs/external.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ AngularJS binding for PouchDB.

#### [ampersand-collection-pouchdb-mixin](https://github.com/svnlto/ampersand-collection-pouchdb-mixin)

A mixin for extending ampersand-collection with pouchdb persistance.
A mixin for extending ampersand-collection with pouchdb persistence.

### Backbone

Expand Down
Loading

0 comments on commit 25c56b7

Please sign in to comment.