#!/usr/bin/env node /** * check-packet-map-missing-loud — page 1 of a prayer packet must SAY when its map is missing. * * The packet's first page draws the zone map from `mapSvg`. When the map fetch fails — which every * build did until the dx-maps config shipped the poster sources (posterSources), and any build that * turns them off still does — the page used to interpolate an empty string: a title, a subtitle, a * privacy footnote, and nothing where the map belongs. A failed fetch and a successful render were * BYTE-INDISTINGUISHABLE in the printed PDF, and the packet read as undeveloped. * * ★ TWO-SIDED, because a one-sided test here passes a constant: * (1) mapSvg EMPTY → the notice appears, in the map's place, with real text (not the key) * (2) mapSvg PRESENT → the notice does NOT appear, and the SVG is on the page untouched * A renderer that ALWAYS printed the notice would pass (1) alone; one that never did would pass (2) * alone. Only both together describe "loud exactly when missing". * * Also asserts the per-key fallback: a locale with no translation for the notice (every locale but * English, by design) prints the English sentence rather than the raw key or nothing. A notice that * rendered as `map_unavailable` would be louder, but it would be wrong in a different way. * * Runs in both variants: lightweight keeps page 1, so it must be loud too. * * Exit 0 pass · 1 fail · 75 NOT MEASURED. */ import { readFileSync } from 'node:fs' import { resolve, dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const HERE = dirname(fileURLToPath(import.meta.url)) const REPO = resolve(HERE, '..') let createPacketRenderer, strings try { ;({ createPacketRenderer } = await import(join(REPO, 'library/packet/packet-render.js'))) strings = JSON.parse(readFileSync(join(REPO, 'library/scripts/posters/packet-strings.json'), 'utf8')) } catch (e) { console.error(`MAP-MISSING-LOUD: NOT MEASURED (exit 75) — the renderer or its strings did not load: ${e.message}`) process.exit(75) } const EN_NOTICE = strings.en?.map_unavailable if (!EN_NOTICE) { console.error('MAP-MISSING-LOUD: FAIL — packet-strings.json en has no map_unavailable sentence, so there is') console.error(' nothing for page 1 to say. The notice must be English-first; other locales fall back to it.') process.exit(1) } const zone = { id: 'probe-zone', label: 'Probe Zone' } // A recognisable SVG so side (2) can prove the REAL map survives, not just that the notice is absent. const SVG = '' /** The HTML of page 1 only — everything before the second sheet. */ function page1(html) { const starts = [...html.matchAll(/