diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e92b04e..e951c6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # Playwright 1.56 has no browsers for Ubuntu 26.04, which ubuntu-latest became timeout-minutes: 15 steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba726e..f983cd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- **PDFs open a little faster** (v54, PDF app). The PDF reader now gets ready while the start screen is up, instead of when you pick a file, and one reader is kept for every PDF you open, so Open again and adding a notebook page no longer start a new one each time. Checking which PDF it is (to find its ink) now happens while the PDF opens, not before. - **Laser pointer sound** (v53, PDF app and HTML overlay). Turning on the laser pointer now plays a short, quiet, low laser sound, so it is clear what just happened. Turning it off is silent. - **Laser pointer** (v52, PDF app and HTML overlay). Tap the pen or highlighter color you already have selected, and its ring turns black, red, black. What you draw now stays for two seconds after you lift the pen, then fades away by itself. It is never saved, printed or added to Undo. Tap the color again, or pick another color or tool, to go back to writing. Your palm still erases. - **Blue toolbar and pink eraser** (v51, PDF app and HTML overlay). The toolbar, its menus, Settings, the Timer and the Chapters / Find panel are now dark navy with light sky-blue buttons and black text, instead of black and yellow, to match the boat icon. The Eraser button is eraser pink. A selected tool has a white ring. Pen, highlighter and cover colors are unchanged. diff --git a/app/index.html b/app/index.html index c939fa2..151f2df 100644 --- a/app/index.html +++ b/app/index.html @@ -5,7 +5,7 @@ OverBoard PDF - + @@ -47,7 +47,7 @@

Open again

Your PDF and your ink stay in this browser on this computer. Nothing is uploaded. Have a Word file? In Word, choose File → Save as PDF, then drop the PDF here. Have an HTML worksheet? Drop it here to get a _board.html copy you can write on. -
About OverBoard · Board not working? · v53

+
About OverBoard · Board not working? · v54

diff --git a/app/libs.js b/app/libs.js index c6388ce..5c2d091 100644 --- a/app/libs.js +++ b/app/libs.js @@ -23,6 +23,25 @@ export function loadPdfjs() { return pdfjsPromise; } +/* One PDF reader for every PDF this tab opens. Starting one means loading and starting the 1.4 MB + pdf.worker file, so sharing it makes opening a PDF, Open again, and adding a notebook page faster. + Closing a PDF doesn't stop it (PDF.js only stops readers it made itself). */ +let worker = null; +export function pdfWorker(lib) { + if (!worker || worker.destroyed) worker = new lib.PDFWorker({ name: 'overboard' }); + return worker; +} +export function dropPdfWorker() { // after a PDF failed to open: the next one gets a fresh reader, in case this one broke + if (worker) { try { worker.destroy(); } catch (e) { /* already gone */ } } + worker = null; +} + +/* get PDF.js and its reader ready while the start screen is up, so the first PDF opens sooner */ +export function warmPdfjs() { + const go = () => loadPdfjs().then(pdfWorker, () => {}); + if (window.requestIdleCallback) requestIdleCallback(go, { timeout: 3000 }); else setTimeout(go, 500); +} + let pdflibPromise = null; export function loadPdfLib() { // only needed for exporting and "Save ink into PDF", so it loads on first use if (!pdflibPromise) { diff --git a/app/main.js b/app/main.js index ad0d1bc..f8071de 100644 --- a/app/main.js +++ b/app/main.js @@ -3,7 +3,7 @@ import { obLangs, obLang, obT, obTranslate } from '../shared/strings.js'; import { showLaser, makeTimer, paletteColors, setPalette, fitTools, makePopMenu, historyKey, hlInk, makeHlMenu, holdRepeat, confirmTap, flashBtn, makePeriodPicker, makeSettings, loadPeriods, startPen, remapPeriods, makeSelect, makeTyping } from '../shared/ink-core.js'; -import { loadPdfjs, PDFJS_CMAPS_URL, PDFJS_FONTS_URL } from './libs.js'; +import { loadPdfjs, pdfWorker, dropPdfWorker, warmPdfjs, PDFJS_CMAPS_URL, PDFJS_FONTS_URL } from './libs.js'; import { Viewer } from './viewer.js'; import { Ink, PT_PER_UNIT } from './ink.js'; import { Finder } from './find.js'; @@ -310,16 +310,19 @@ async function openFile(file, handlePromise) { drop.textContent = tr('opening', { f: file.name }); try { if (doc) await closeDoc(false); + const libP = loadPdfjs(); // usually ready already (warmPdfjs); if not, it loads while the file is read const buf = await file.arrayBuffer(); const base = findBase(new Uint8Array(buf)); // a PDF OverBoard saved ink into: the original bytes come first - let hash = await store.hashBytes(new Uint8Array(buf, 0, base)); - const lib = await loadPdfjs(); - const task = lib.getDocument({ data: new Uint8Array(buf), ...PDF_OPTS }); + const hashP = store.hashBytes(new Uint8Array(buf, 0, base)); // copies the bytes now, so the PDF can open meanwhile + const lib = await libP; + const task = lib.getDocument({ data: new Uint8Array(buf), worker: pdfWorker(lib), ...PDF_OPTS }); // hands the bytes to the reader task.onPassword = (give, reason) => { const pw = prompt(reason === 2 ? 'Wrong password. Try again:' : 'This PDF has a password:'); if (pw === null) task.destroy(); else give(pw); }; + hashP.catch(() => {}); // (if the PDF fails first, that's the error to show) const pdf = await task.promise; + let hash = await hashP; // a blank notebook OverBoard made: its ink is kept under the notebook's ID, which stays the same as pages are added // a picture OverBoard turned into a PDF: its ink is kept under the picture's ID (app/image.js) let nb = null, im = null; @@ -362,6 +365,7 @@ async function openFile(file, handlePromise) { } catch (e) { console.error(e); doc = null; D = null; + if (!e || e.name !== 'PasswordException') dropPdfWorker(); document.body.classList.add('start'); bar.hidden = true; addPageEl.hidden = true; showError(e && e.name === 'PasswordException' ? tr('err_password') : e && /fetch|import|module/i.test(String(e.message)) ? tr('err_pdf_reader') : @@ -858,7 +862,7 @@ async function changePages(change, at, by, show, msg) { try { const bytes = await change(new Uint8Array(await baseBlob().arrayBuffer())); const lib = await loadPdfjs(); - const pdf = await lib.getDocument({ data: bytes.slice(), ...PDF_OPTS }).promise; + const pdf = await lib.getDocument({ data: bytes.slice(), worker: pdfWorker(lib), ...PDF_OPTS }).promise; if (doc !== d) { pdf.destroy(); return; } // closed in the meantime const old = d.pdf; d.file = new File([bytes], d.name, { type: 'application/pdf' }); @@ -999,6 +1003,7 @@ $('#ob-inkfile').addEventListener('change', (e) => { const f = e.target.files[0] /* ---------- start ---------- */ translateAll(); refresh(); renderRecent(); +warmPdfjs(); setupOffline(openFile); (() => { // reopen the PDF after a reload; typing or clicking the address shows the start screen const nav = performance.getEntriesByType && performance.getEntriesByType('navigation')[0]; diff --git a/app/report/index.html b/app/report/index.html index fd2f1e4..e664a2d 100644 --- a/app/report/index.html +++ b/app/report/index.html @@ -98,7 +98,7 @@

Is OverBoard not working on your board?

If something doesn't work the way the page asks, that's fine. That's exactly what I need to know. Just keep going.

Nothing is sent until you press Send at the very end, and you'll see everything first. No worksheets, PDFs or ink are ever included.

-

OverBoard v53

+

OverBoard v54

diff --git a/app/sw.js b/app/sw.js index 6cc96fa..530b63f 100644 --- a/app/sw.js +++ b/app/sw.js @@ -1,7 +1,7 @@ // ===== GENERATED by tools/build.py: every file the app needs, with the start of its SHA-256. Do not edit by hand. ===== -const VERSION = 'ad523d024e67'; +const VERSION = '911d716dff20'; const FILES = { - "../overlay/ink_overlay.html": "ccbeec7f9a193362", + "../overlay/ink_overlay.html": "658c92c6773cccf9", "../shared/ink-core.js": "b65c19035e241559", "../shared/strings.js": "b247836e7165abf0", "../shared/toolbar.css": "a611595b897560c5", @@ -17,14 +17,14 @@ const FILES = { "icons/icon-512.png": "46ca8bd2d6a32612", "icons/maskable-512.png": "c7d41ed2fa4ad874", "image.js": "d396b7d4f5aced4e", - "index.html": "07e71eee1c4df161", + "index.html": "9460c8776a417eb4", "ink.js": "3dc693cb202efe0c", - "libs.js": "c09f60186ab9029a", - "main.js": "ed783dc63ed7a6dd", + "libs.js": "bedbbbc2c8495fdf", + "main.js": "e842901e26803484", "manifest.json": "416c107c34c8610b", "notebook.js": "7346e40dda6ff149", "offline.js": "6504935b2738711a", - "report/index.html": "480150bf36208394", + "report/index.html": "8885a58fbb345993", "store.js": "155ec064f6ffe569", "textlayer.js": "383ad22e91afb648", "vendor/pdf-lib@1.17.1/LICENSE.md": "f2c9fc00fdb66eb9", @@ -217,7 +217,7 @@ const FILES = { "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-BoldItalic.ttf": "a224075ac17495ad", "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-Italic.ttf": "832b4406dbef2362", "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-Regular.ttf": "f8ace1f892b2bd9d", - "version.json": "7b8de4a25ae70b82", + "version.json": "fe7d8c7110d62f35", "viewer.js": "1cffd9d5c7158958" }; // ===== END GENERATED ===== diff --git a/app/version.json b/app/version.json index 85c577e..d5ea20d 100644 --- a/app/version.json +++ b/app/version.json @@ -1,5 +1,5 @@ { - "v": "a4543e5866fb", + "v": "4831a1cabadf", "js": [ "embed.js", "export.js", diff --git a/index.html b/index.html index 5b43e8b..3504784 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@

Exit ticket

OverBoard · page 2 / 2 · Your ink saves in this browser only. Nothing is uploaded.
-