Feature summary:
Compress and decompress stuff.
Use case(s):
Several userscripts of mine store data. As localStorage is limited and MediaWiki preferences even more so, compression is helpful.
Benefits:
Store more with less.
Currently we have mediaWiki.deflate (mw.loader.using('mediawiki.deflate',function(){console.log(mediaWiki.deflate('testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest'))});), see T236210. But the corresponding decompression function is only available on the server side as far as I can tell.
Could the corresponding inflate function be provided with JS as well? (it's fine if the mw.loader.using triggers a download for it) Another option is Pieroxy's lz-string which is about 3K but doesn't seem to compress quite as well. Compressing $('body')[0].innerHTML of enwiki's WP:VPT the character length of the compressed output is 1.9 times larger than mediawiki.deflate when using lz-string in base64 mode.
This should be relatively straightforward I'd suspect?
- Add pako inflate.js to https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/resources/lib/pako/
- Create mw.inflate.js that does the opposite of https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/resources/src/mediawiki.deflate/mw.deflate.js
- Put that in a new mediawiki.inflate directory on the same level as the current mediawiki.deflate
- Create entry in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/resources/Resources.php
If I had a testing environment I could almost do it myself, emphasis on almost.
Beware that MediaWiki uses the outdated pako 1.0.10 deflate, so either use inflate from 1.0.10 or upgrade both. The current version doesn't work as a drop-in replacement though. They probably changed the parameter format. Update: now uses 2.0.4.