Make PDF Viewer a native feature
- Move the PDF Viewer plugin into src/lib/features/pdf/ with pdfjs-dist 6.4.299 (minified builds). - A static pdf document type marks PDF files and opens them as tabs. The first PDF tab loads the module. - The worker, the character maps, the fonts, and the decoders come from the app. One worker for each tab. - The toolbar uses IconButton and the shared tooltip, with the new zoom-in, zoom-out, fit-width, and rotate icons. - Add THIRD_PARTY_NOTICES.md for PDF.js and xterm. - Update the tests, the menu inventory, the docs, and UI-059.
This commit is contained in:
@@ -33,9 +33,9 @@ test("switches keep known booleans only, and missing keys take the default", ()
|
||||
assert.deepEqual(storedSwitches({ git: false, terminal: "no", csv: true, other: "yes" }), { git: false });
|
||||
assert.deepEqual(storedSwitches(null), {});
|
||||
assert.deepEqual(storedSwitches(["git"]), {});
|
||||
assert.deepEqual(switchesFrom(undefined), { git: true, background: true, terminal: true });
|
||||
assert.deepEqual(switchesFrom({ git: false, background: false, terminal: false }), { git: false, background: false, terminal: false });
|
||||
assert.deepEqual(switchesFrom({ git: "false" }), { git: true, background: true, terminal: true });
|
||||
assert.deepEqual(switchesFrom(undefined), { git: true, background: true, terminal: true, pdf: true });
|
||||
assert.deepEqual(switchesFrom({ git: false, background: false, terminal: false, pdf: false }), { git: false, background: false, terminal: false, pdf: false });
|
||||
assert.deepEqual(switchesFrom({ git: "false" }), { git: true, background: true, terminal: true, pdf: true });
|
||||
});
|
||||
|
||||
test("an installed package gives its state, and without a package the default applies", () => {
|
||||
@@ -71,10 +71,10 @@ test("the migration asks only for features without a switch, and keeps other key
|
||||
write: async (value: unknown) => { writes.push(value); },
|
||||
legacy: async (ids: string[]) => { asked.push(ids); return packages; },
|
||||
});
|
||||
assert.deepEqual(await migrateFeatures(host({ future: 1, background: false, terminal: true }, [{ id: "runestone.git", installed: true, enabled: false, settings: null }]), presentBackground(), presentTerminal()), ["git"]);
|
||||
assert.deepEqual(await migrateFeatures(host({ future: 1, background: false, terminal: true, pdf: true }, [{ id: "runestone.git", installed: true, enabled: false, settings: null }]), presentBackground(), presentTerminal()), ["git"]);
|
||||
assert.deepEqual(asked, [["runestone.git"]]);
|
||||
assert.deepEqual(writes, [{ future: 1, background: false, terminal: true, git: false }]);
|
||||
assert.deepEqual(await migrateFeatures(host({ git: true, background: true, terminal: true }, []), presentBackground(), presentTerminal()), []);
|
||||
assert.deepEqual(writes, [{ future: 1, background: false, terminal: true, pdf: true, git: false }]);
|
||||
assert.deepEqual(await migrateFeatures(host({ git: true, background: true, terminal: true, pdf: true }, []), presentBackground(), presentTerminal()), []);
|
||||
assert.equal(asked.length, 1, "A stored switch needs no package read.");
|
||||
assert.equal(writes.length, 1);
|
||||
});
|
||||
@@ -84,7 +84,7 @@ test("a missing background section asks for the slideshow package and makes the
|
||||
const switches: unknown[] = [];
|
||||
const sections: BackgroundSettings[] = [];
|
||||
const background: BackgroundMigrationHost = { missing: () => true, hasImage: () => true, migrateFolder: async () => true, write: async value => { sections.push(value); } };
|
||||
const host = { read: () => ({ git: true, background: false, terminal: true }), write: async (value: unknown) => { switches.push(value); }, legacy: async (ids: string[]) => { asked.push(ids); return []; } };
|
||||
const host = { read: () => ({ git: true, background: false, terminal: true, pdf: true }), write: async (value: unknown) => { switches.push(value); }, legacy: async (ids: string[]) => { asked.push(ids); return []; } };
|
||||
assert.deepEqual(await migrateFeatures(host, background, presentTerminal()), []);
|
||||
assert.deepEqual(asked, [["runestone.bg-slideshow"]]);
|
||||
assert.deepEqual(switches, [], "Stored switches stay.");
|
||||
@@ -93,8 +93,8 @@ test("a missing background section asks for the slideshow package and makes the
|
||||
// Both migrations together ask once for both packages.
|
||||
asked.length = 0;
|
||||
await migrateFeatures({ ...host, read: () => undefined }, background, presentTerminal());
|
||||
assert.deepEqual(asked, [["runestone.git", "runestone.bg-slideshow", "runestone.terminal"]]);
|
||||
assert.deepEqual(switches, [{ git: true, background: true, terminal: true }]);
|
||||
assert.deepEqual(asked, [["runestone.git", "runestone.bg-slideshow", "runestone.terminal", "runestone.pdf-viewer"]]);
|
||||
assert.deepEqual(switches, [{ git: true, background: true, terminal: true, pdf: true }]);
|
||||
});
|
||||
|
||||
test("a failed package read writes nothing, so the next start tries again", async () => {
|
||||
|
||||
Reference in New Issue
Block a user