// STORED TEXT NEEDS node:zlib's zstd (Node >= 22.15; 23.8 on the 23 line) — // asked ONCE AT BOOT by every process that may read the corpus (the editor's // instrumentation, every common/bin CLI through runIfEntryPoint, umtool's bin // and its bare-node readers through lib/storedText-read.mjs). A process on an // older Node would read every caption or chat stored as `.zst` as unreadable: // the index would drop their text, a lane would schedule work for them. So it // REFUSES TO START with this sentence instead of running degraded (REVIEW-1 // F3, captions lane). Plain JS, no import but node:zlib: safe to load first. import zlib from "node:zlib"; export const ZSTD_NODE_NEEDED = ">= 22.15"; /** The problem, or null when this Node has zstd. @param {object} [z] node:zlib (a test passes a fake) @param {string} [version] */ export function zstdSupportProblem(z = zlib, version = process.version) { const ok = typeof z.zstdDecompress === "function" && typeof z.createZstdCompress === "function" && typeof z.createZstdDecompress === "function"; return ok ? null : `stored text (captions and live chats stored as .zst) needs node:zlib zstd — Node ${ZSTD_NODE_NEEDED} (this is ${version})`; } /** Throws the problem, naming who refuses. @param {string} who @param {object} [z] @param {string} [version] */ export function assertZstdSupport(who, z = zlib, version = process.version) { const p = zstdSupportProblem(z, version); if (p) throw new Error(`${who} refuses to start: ${p}`); }