Compress huge saves with the browser's gzip (#176)

This commit is contained in:
Frederic Jung 2026-10-27 21:34:35 +01:00
parent 8c3ac4e9df
commit 146fae0faf
No known key found for this signature in database
5 changed files with 86 additions and 7 deletions

View file

@ -32,6 +32,8 @@ function load(opts = {}) {
// A non-English game: jsdom does not fetch the dictionary script, so register it up front.
// (opts.dir: the folder the dictionary comes from, e.g. a build's _site/i18n.)
if (opts.lang) { window.localStorage.setItem('sot-lang', opts.lang); window.eval(fs.readFileSync(path.join(opts.dir || path.join(__dirname, '..', 'site', 'i18n'), opts.lang + '.js'), 'utf8')); }
// jsdom has no CompressionStream; {gzip:true} lends the page Node's, the same API browsers have (#176).
if (opts.gzip) for (const k of ['CompressionStream', 'DecompressionStream', 'TextEncoder', 'TextDecoder']) window[k] = globalThis[k];
window.Path2D = class { moveTo() {} lineTo() {} quadraticCurveTo() {} bezierCurveTo() {} arc() {} rect() {} closePath() {} };
// A recording 2D context, so draw code really runs under test (jsdom has no canvas).
const fake = () => { const calls = { n: 0 };