diff --git a/src/fs/lzma.d.ts b/src/fs/lzma.d.ts index 3ff923935..1767b2067 100644 --- a/src/fs/lzma.d.ts +++ b/src/fs/lzma.d.ts @@ -1 +1 @@ -declare module "lzma/src/lzma-d-min"; +declare module "lzma/src/lzma-d"; diff --git a/src/fs/migration.ts b/src/fs/migration.ts index 39f478e39..c09c7797f 100644 --- a/src/fs/migration.ts +++ b/src/fs/migration.ts @@ -5,6 +5,15 @@ */ import { toByteArray } from "base64-js"; +import lzma from "lzma/src/lzma-d"; + +// LZMA isn't a proper module. +// When bundled it assigns to window. At dev time it works via the above import. +const LZMA = + typeof window !== "undefined" && (window as any).LZMA + ? (window as any).LZMA + : lzma.LZMA; + // There are other fields that we don't use. export interface Migration { meta: { @@ -34,10 +43,7 @@ export const parseMigrationFromUrl = ( try { if (urlPart) { const bytes = toByteArray(urlPart); - const json = JSON.parse( - // FIXME, reinstate decompression with a working module. - /*LZMA.decompress(*/ new TextDecoder().decode(bytes) /*)*/ - ); + const json = JSON.parse(LZMA.decompress(bytes)); if (isMigration(json)) { let postMigrationUrl = parts[0]; // This was previously stripped off by the versioner but for now do it ourselves: