This is mostly because I am not 100% certain about how stable our own
optimized version is. While it does perform a lot better, there is
significant risk that things might break in production. To avoid
that, I am replacing it with the upstream version which is much more
heavily tested.
This replaces DOMParser with htmlparser2 which is much, much faster.
How much faster? 80%. This new implementation can parse at 50mb/s
which is insane! The old one could only do 5-10mb/s
We still haven't gotten rid of the DOMParser though since HTML-to-MD
conversion still needs it. This will be done soon though by using `dr-sax`.
This uses a custom implementation of htmlparser2 instead of the default
one which is 50% faster.
Since HTML is a tree-like language it is futile to compare it character
for character. `html1 === html2` is almost always false. This commit
introduces a simple diffing algorithm that only checks the text inside
the html + a few other attributes to decide whether the 2 HTMLs are
actually different or not. This is obviously not foolproof and it will
ignore everything aesthetic (b, em, strong tags etc.). This is actually
desireable because in our case only the text difference should
warrant a conflict. Everything else can easily be brought back.
Similarly, this also ignores whitespace differences surrouding the
tags.
All in all it'll provide a more reliable alternative to MD5 hashing the
2 HTMLs.
* feat: note version history
* fix bugs
* add tests for session history
* update tests
* add tests for restoring content
* add more tests
* update jsdoc
* return empty array if no session history present for a note
* init note history with await
* add note history versions limit
* cleanup note history after adding a new session
* fix tests
* add test for session cleanup
* test: add collector tests
* feat: dateEdited -> dateModified
* feat: migrate to liqe for searching
* chore: forceExit jest after test run
* feat: note version history
* fix bugs
* add tests for session history
* update tests
* add tests for restoring content
* add more tests
* update jsdoc
* return empty array if no session history present for a note
* init note history with await
* add note history versions limit
* cleanup note history after adding a new session
* fix tests
* add test for session cleanup
* init ContentHistory with await
* fix reference to db in init
* make sessionId in db
* check if note is locked through note metadata
* make cleanup method private
* use remove methods in notehistory and contenthistory
* restore note content via notes.add method if note is not locked
* move getting all items to seperate functions
* check if parsed json is valid
* deserialize a session only if it's sessionContent exists
* add locked property to sessionContent
* remove makeSessionId function
* update tests
* remove yarn.lock file
* update tests
Co-authored-by: ammarahm-ed <ammarahmed6506@gmail.com>