ISMIS Helper: cross-browser build, CI, PDF fixes, Chrome download fix #1

Merged
adrianbonpin merged 55 commits from feat/ismis-helper into prod 2026-08-18 19:13:50 +00:00
2 changed files with 25 additions and 15 deletions
Showing only changes of commit 79702cb847 - Show all commits
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

+21 -11
View File
@@ -94,21 +94,25 @@
return ''; return '';
} }
// Load the bundled header logo (JPEG) in the extension background page. // Load the bundled header logo. Prefer the transparent PNG (matches the
// Returns null in Node (tests) or if the asset is unavailable. // official PDF, which masks the JPEG's baked-in background) for a clean
// look on white; fall back to the JPEG in Node (tests) or if unavailable.
async function loadLogo() { async function loadLogo() {
const ext = (typeof browser !== 'undefined' && browser.runtime && browser.runtime.getURL);
const candidates = ['assets/logo.png', 'assets/logo.jpeg'];
for (const asset of candidates) {
try { try {
const url = (typeof browser !== 'undefined' && browser.runtime && browser.runtime.getURL) const url = ext ? browser.runtime.getURL(asset) : null;
? browser.runtime.getURL('assets/logo.jpeg')
: null;
if (!url) return null; if (!url) return null;
const resp = await fetch(url); const resp = await fetch(url);
if (!resp.ok) return null; if (!resp.ok) continue;
return new Uint8Array(await resp.arrayBuffer()); return { bytes: new Uint8Array(await resp.arrayBuffer()), transparent: /logo\.png$/.test(asset) };
} catch (e) { } catch (e) {
return null; continue;
} }
} }
return null;
}
// Builds a Letter-size PDF replicating the official ISMIS Study Load layout: // Builds a Letter-size PDF replicating the official ISMIS Study Load layout:
// header logo, title, semester + date range, date enrolled, a student info // header logo, title, semester + date range, date enrolled, a student info
@@ -134,10 +138,16 @@
const black = rgb(0, 0, 0); const black = rgb(0, 0, 0);
const gray = rgb(0.3, 0.3, 0.3); const gray = rgb(0.3, 0.3, 0.3);
const logoBytes = await loadLogo(); const logo = await loadLogo();
let logoImg = null; let logoImg = null;
if (logoBytes) { if (logo) {
try { logoImg = await doc.embedJpg(logoBytes); } catch (e) { logoImg = null; } try {
// Transparent PNG embeds with an alpha mask (matches official PDF);
// the JPEG is embedded as-is (no mask).
logoImg = logo.transparent
? await doc.embedPng(logo.bytes)
: await doc.embedJpg(logo.bytes);
} catch (e) { logoImg = null; }
} }
function center(text, size, f, dy) { function center(text, size, f, dy) {