unroll / lib /version.js
SharpMeow's picture
Public API at window.unroll (schema, help, coverage test; ui and bench groups), embed mode with postMessage bridge and oEmbed, version 0.9.4 in About and API, ink_9um (9 µm) label and credit, Ink Bench hardening from the audit, hashchange without reload, capped test hooks
cc6b6d8
Raw History Blame Contribute Delete
853 Bytes
// The app version, from version.json (the single source of truth). Shown in the About footer,
// returned by window.unroll.version() and kept on window.UNROLL_VERSION for add-ons such as the Bench export.
import { API_VERSION } from './apispec.js';
export const VERSION = fetch(new URL('../version.json', import.meta.url), { cache: 'no-cache' })
.then((r) => (r.ok ? r.json() : Promise.reject(new Error(`version.json: HTTP ${r.status}`))))
.then((v) => ({ version: v.version, date: v.date, sha: v.sha, api: API_VERSION }))
.catch(() => ({ version: 'unknown', date: null, sha: null, api: API_VERSION }))
.then((v) => {
window.UNROLL_VERSION = Object.freeze(v);
const el = document.getElementById('aVersion');
if (el) el.textContent = `v${v.version}${v.sha ? ` · ${v.sha}` : ''}${v.date ? ` · ${v.date}` : ''}`;
return v;
});