@mark1russell7/site-pages 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runCli, o as TYPESCRIPT_PROBE, s as probeScript } from "./chunks/build.js";
2
+ import { a as runCli, h as probeScript, m as TYPESCRIPT_PROBE, p as runFreshnessCli } from "./chunks/build.js";
3
3
  import { spawn } from "node:child_process";
4
4
  import { appendFileSync, createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { delimiter, extname, isAbsolute, join, normalize, resolve, sep } from "node:path";
@@ -758,7 +758,7 @@ const io = {
758
758
  stdout: (text) => process.stdout.write(text),
759
759
  stderr: (text) => process.stderr.write(text)
760
760
  };
761
- (argv[0] === "check" ? runCheckCli(argv.slice(1), io) : runCli(argv, io)).then((code) => {
761
+ (argv[0] === "check" ? runCheckCli(argv.slice(1), io) : argv[0] === "freshness" ? runFreshnessCli(argv.slice(1), io) : runCli(argv, io)).then((code) => {
762
762
  process.exitCode = code;
763
763
  }, (error) => {
764
764
  process.stderr.write(`site-pages: ${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
package/build/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/check/browser.ts","../src/check/measure.ts","../src/check/serve.ts","../src/check/check.ts","../src/cli.ts"],"sourcesContent":["/**\n * A small client of the Chrome DevTools protocol for the `check` command. It starts a Chromium\n * browser (Chrome, Edge or the Chromium of Playwright) in headless mode and drives one page. It\n * uses only Node.js, so the check needs no package install.\n */\n\nimport { spawn, type ChildProcess } from \"node:child_process\";\nimport { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from \"node:fs\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { delimiter, join } from \"node:path\";\n\n/** The paths that `findBrowser` examines after the option and the Playwright folder. */\nfunction systemBrowsers(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string[] {\n if (platform === \"win32\") {\n const roots = [env[\"PROGRAMFILES\"], env[\"PROGRAMFILES(X86)\"], env[\"LOCALAPPDATA\"]].filter((root): root is string => !!root);\n return roots.flatMap((root) => [join(root, \"Google/Chrome/Application/chrome.exe\"), join(root, \"Microsoft/Edge/Application/msedge.exe\")]);\n }\n if (platform === \"darwin\") {\n return [\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\", \"/Applications/Chromium.app/Contents/MacOS/Chromium\", \"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge\"];\n }\n const names = [\"google-chrome\", \"google-chrome-stable\", \"chromium\", \"chromium-browser\", \"microsoft-edge\"];\n const dirs = (env[\"PATH\"] ?? \"\").split(delimiter).filter(Boolean);\n return names.flatMap((name) => dirs.map((dir) => join(dir, name)));\n}\n\n/** The Chromium of the newest `chromium-<n>` folder of Playwright, or undefined. */\nfunction playwrightChromium(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string | undefined {\n const root =\n env[\"PLAYWRIGHT_BROWSERS_PATH\"] ||\n (platform === \"win32\" ? join(env[\"LOCALAPPDATA\"] ?? homedir(), \"ms-playwright\") : platform === \"darwin\" ? join(homedir(), \"Library/Caches/ms-playwright\") : join(homedir(), \".cache/ms-playwright\"));\n if (!existsSync(root)) return undefined;\n const builds = readdirSync(root)\n .map((name) => /^chromium-(\\d+)$/.exec(name))\n .filter((match): match is RegExpExecArray => match !== null)\n .sort((a, b) => Number(b[1]) - Number(a[1]));\n for (const [folder] of builds) {\n for (const sub of readdirSync(join(root, folder))) {\n const candidates =\n platform === \"win32\"\n ? [join(root, folder, sub, \"chrome.exe\")]\n : platform === \"darwin\"\n ? [join(root, folder, sub, \"Chromium.app/Contents/MacOS/Chromium\"), join(root, folder, sub, \"Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing\")]\n : [join(root, folder, sub, \"chrome\")];\n const found = candidates.find((file) => existsSync(file));\n if (found) return found;\n }\n }\n return undefined;\n}\n\n/**\n * This function finds a Chromium browser. It examines the given path, then `$SITE_CHECK_BROWSER`,\n * then the newest Chromium of Playwright, then a Chrome or an Edge of the system.\n *\n * @returns the path of the executable, or undefined when there is none\n */\nexport function findBrowser(given?: string, env: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform): string | undefined {\n const named = given || env[\"SITE_CHECK_BROWSER\"];\n if (named) return named;\n return playwrightChromium(platform, env) ?? systemBrowsers(platform, env).find((file) => existsSync(file));\n}\n\n/** A message of the DevTools protocol. */\ninterface Message {\n id?: number;\n method?: string;\n params?: Record<string, unknown>;\n result?: Record<string, unknown>;\n error?: { message: string };\n}\n\n/** An event handler of a page. */\ntype Listener = (params: Record<string, unknown>) => void;\n\n/** One page of a started browser. */\nexport interface Page {\n /** This function sends a command of the protocol and returns its result. */\n send(method: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;\n /** This function calls the listener on each event of the method. */\n on(method: string, listener: Listener): void;\n /** This function calls the listener on the next event of the method, or rejects after `ms`. */\n once(method: string, ms: number): Promise<Record<string, unknown>>;\n /** This function evaluates the expression in the page, and waits for a promise. */\n evaluate<T>(expression: string): Promise<T>;\n}\n\n/** A started browser. */\nexport interface Browser {\n page: Page;\n /** This function stops the browser and removes its profile. */\n close(): Promise<void>;\n}\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * This function starts the browser in headless mode with a new profile, and connects to its page.\n * The browser picks a free port, so two checks can run at the same time.\n *\n * @throws Error when the browser does not start in `timeoutMs`\n */\nexport async function launch(executable: string, timeoutMs = 30_000): Promise<Browser> {\n const profile = mkdtempSync(join(tmpdir(), \"site-check-\"));\n const args = [\n \"--headless=new\",\n \"--remote-debugging-port=0\",\n `--user-data-dir=${profile}`,\n \"--no-first-run\",\n \"--no-default-browser-check\",\n \"--disable-gpu\",\n \"--disable-extensions\",\n \"--disable-background-networking\",\n \"--disable-sync\",\n \"--hide-scrollbars\",\n \"--mute-audio\",\n // The sandbox of Chromium needs user namespaces, which Ubuntu 24.04 refuses to a browser that the\n // system did not install. Playwright also starts Chromium with no sandbox.\n ...(process.platform === \"linux\" ? [\"--no-sandbox\"] : []),\n \"about:blank\",\n ];\n const child: ChildProcess = spawn(executable, args, { stdio: \"ignore\" });\n let exited: string | undefined;\n child.once(\"exit\", (code, signal) => (exited = `the browser stopped (code ${code}, signal ${signal})`));\n child.once(\"error\", (error) => (exited = `the browser did not start: ${error.message}`));\n const stop = async () => {\n if (child.exitCode === null && child.signalCode === null) {\n child.kill();\n await Promise.race([new Promise((resolve) => child.once(\"exit\", resolve)), sleep(5000)]);\n }\n rmSync(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });\n };\n try {\n const portFile = join(profile, \"DevToolsActivePort\");\n const end = Date.now() + timeoutMs;\n let port = \"\";\n while (port === \"\") {\n if (exited !== undefined) throw new Error(`${executable}: ${exited}`);\n if (Date.now() > end) throw new Error(`${executable}: no DevTools port after ${timeoutMs} ms`);\n if (existsSync(portFile)) port = readFileSync(portFile, \"utf8\").split(\"\\n\")[0]?.trim() ?? \"\";\n if (port === \"\") await sleep(100);\n }\n let target: { type: string; webSocketDebuggerUrl: string } | undefined;\n while (target === undefined) {\n const list = (await (await fetch(`http://127.0.0.1:${port}/json/list`)).json()) as { type: string; webSocketDebuggerUrl: string }[];\n target = list.find((entry) => entry.type === \"page\");\n if (target === undefined) {\n if (Date.now() > end) throw new Error(`${executable}: no page target after ${timeoutMs} ms`);\n await sleep(100);\n }\n }\n const page = await connect(target.webSocketDebuggerUrl);\n return {\n page: page.page,\n close: async () => {\n page.close();\n await stop();\n },\n };\n } catch (error) {\n await stop();\n throw error;\n }\n}\n\nasync function connect(url: string): Promise<{ page: Page; close: () => void }> {\n const socket = new WebSocket(url);\n await new Promise<void>((resolve, reject) => {\n socket.addEventListener(\"open\", () => resolve(), { once: true });\n socket.addEventListener(\"error\", () => reject(new Error(`no connection to ${url}`)), { once: true });\n });\n let sequence = 0;\n const pending = new Map<number, { resolve: (value: Record<string, unknown>) => void; reject: (error: Error) => void }>();\n const listeners = new Map<string, Listener[]>();\n socket.addEventListener(\"message\", (event) => {\n const message = JSON.parse(String(event.data)) as Message;\n if (message.id !== undefined) {\n const call = pending.get(message.id);\n pending.delete(message.id);\n if (message.error) call?.reject(new Error(message.error.message));\n else call?.resolve(message.result ?? {});\n } else if (message.method) {\n for (const listener of listeners.get(message.method) ?? []) listener(message.params ?? {});\n }\n });\n socket.addEventListener(\"close\", () => {\n for (const call of pending.values()) call.reject(new Error(\"the browser closed the connection\"));\n pending.clear();\n });\n const page: Page = {\n send: (method, params = {}) =>\n new Promise((resolve, reject) => {\n const id = ++sequence;\n pending.set(id, { resolve, reject });\n socket.send(JSON.stringify({ id, method, params }));\n }),\n on: (method, listener) => listeners.set(method, [...(listeners.get(method) ?? []), listener]),\n once: (method, ms) =>\n new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n remove();\n reject(new Error(`no ${method} after ${ms} ms`));\n }, ms);\n const listener: Listener = (params) => {\n clearTimeout(timer);\n remove();\n resolve(params);\n };\n const remove = () => listeners.set(method, (listeners.get(method) ?? []).filter((entry) => entry !== listener));\n page.on(method, listener);\n }),\n evaluate: async <T>(expression: string): Promise<T> => {\n const reply = (await page.send(\"Runtime.evaluate\", { expression, awaitPromise: true, returnByValue: true })) as {\n result?: { value?: unknown };\n exceptionDetails?: { text?: string; exception?: { description?: string } };\n };\n if (reply.exceptionDetails) throw new Error(reply.exceptionDetails.exception?.description ?? reply.exceptionDetails.text ?? \"the expression failed\");\n return reply.result?.value as T;\n },\n };\n return { page, close: () => socket.close() };\n}\n","/**\n * The measurements that the `check` command makes in the page. Each is a string of JavaScript that\n * the browser evaluates, so the code can use only the APIs of the page.\n */\n\n/** Text past the edge of a box that cuts it: an entry of `Measure.cut`. */\nexport interface Cut {\n /**\n * The kind of the box:\n * - `clip`: the box has `overflow-x: hidden` or `clip`, so a visitor cannot reach the text,\n * - `table`: the box scrolls, and the text is in a table.\n */\n kind: \"clip\" | \"table\";\n /** The box. */\n box: string;\n /** The table, or the element of the text. */\n element: string;\n /** The width of the content of the box, in CSS pixels. */\n scrollWidth: number;\n /** The visible width of the box, in CSS pixels. */\n clientWidth: number;\n /** The start of the first text past the edge. */\n text: string;\n}\n\n/** The result of `MEASURE`. */\nexport interface Measure {\n innerWidth: number;\n scrollWidth: number;\n /** The height of the document, for the screenshot. */\n height: number;\n /** The number of characters of visible text. */\n text: number;\n /** The outermost elements that go past the right edge of the screen, at most 8. */\n past: string[];\n /** The text areas that hide a part of their text, at most 8. */\n clipped: string[];\n /** The boxes that cut text at their right edge, at most 8. `cutProblems` of `check.ts` tells which ones are problems. */\n cut: Cut[];\n}\n\n/**\n * This expression measures the page. An element counts as past the edge when its right side is\n * more than half a pixel past the width of the document. These elements do not count:\n * - an element in a container that scrolls or clips (`overflow-x` other than `visible`, below `body`),\n * - an element of zero size, a hidden element, or a fixed element that is fully past the edge (a closed drawer),\n * - an element in `.sr`, `.sr-only`, `.visually-hidden` or `.skip` (text for screen readers and skip links),\n * - an element in a `pre`, other than the `pre` itself.\n * Of a chain of elements past the edge, only the outermost one counts.\n *\n * `past` skips each element in a container that scrolls or clips, so `cut` examines those containers.\n * A box is the nearest element around a text, below `body`, with `overflow-x` other than `visible`. Its content is wider\n * than the box by more than 1 px. An element with `overflow-x: clip` is always a box, because it can report no overflow.\n * The text counts when a line of it ends more than 1 px past the right edge of the box.\n *\n * A box that scrolls counts only for text in a table (`table`, `role=\"table\"` or `role=\"grid\"`).\n * A code block, a hex view, a row of tabs and a carousel in such a box are meant to scroll.\n * A box that clips counts for each text, because a visitor cannot reach that text. These texts do not count:\n * - a text in a box with `text-overflow` other than `clip` (a person chose the ellipsis),\n * - a text in an element with `data-overflow-ok`, or in that element itself (a person chose the overflow),\n * - a text in a box with the class `scroll-cue` that scrolls (a shade shows the visitor that it scrolls),\n * - a text in `.sr`, `.sr-only`, `.visually-hidden`, `.skip`, `[aria-hidden=\"true\"]`, `select`, `textarea` or `svg`,\n * - a text in a fixed element, which the box does not clip,\n * - a text that is not visible, or with an element around it of 1 px or less or with `opacity: 0`.\n * Only the first text of a box counts. An element with no text does not count. Vertical overflow does not count.\n */\nexport const MEASURE = `(() => {\n const root = document.documentElement;\n const w = root.clientWidth;\n const name = (e) => e.tagName.toLowerCase() + (e.id ? \"#\" + e.id : \"\") + (typeof e.className === \"string\" && e.className.trim() ? \".\" + e.className.trim().split(/\\\\s+/).slice(0, 3).join(\".\") : \"\");\n const inScroller = (e) => {\n for (let p = e.parentElement; p && p !== document.body && p !== root; p = p.parentElement) {\n if (getComputedStyle(p).overflowX !== \"visible\") return true;\n }\n return false;\n };\n const counts = (e) => {\n const r = e.getBoundingClientRect();\n if (r.width === 0 || r.height === 0 || r.right <= w + 0.5) return false;\n if (e.closest(\".sr,.sr-only,.visually-hidden,.skip\")) return false;\n if (e.closest(\"pre\") && e.tagName !== \"PRE\") return false;\n const s = getComputedStyle(e);\n if (s.visibility === \"hidden\" || s.display === \"none\") return false;\n if (s.position === \"fixed\" && r.left >= w) return false;\n return !inScroller(e);\n };\n const over = new Set([...document.querySelectorAll(\"body *\")].filter(counts));\n const past = [...over]\n .filter((e) => { for (let p = e.parentElement; p; p = p.parentElement) if (over.has(p)) return false; return true; })\n .map((e) => name(e) + \" right=\" + Math.round(e.getBoundingClientRect().right));\n const clipped = [...document.querySelectorAll(\"textarea\")]\n .filter((e) => { const s = getComputedStyle(e); return (s.overflowY === \"hidden\" || s.overflowY === \"clip\") && e.getBoundingClientRect().height > 0 && e.scrollHeight > e.clientHeight + 1; })\n .map((e) => name(e) + \" \" + e.scrollHeight + \">\" + e.clientHeight);\n const boxOf = (e) => {\n for (let p = e; p && p !== document.body && p !== root; p = p.parentElement) {\n const s = getComputedStyle(p);\n if (s.overflowX === \"clip\" || (s.overflowX !== \"visible\" && p.scrollWidth > p.clientWidth + 1)) return p;\n if (s.position === \"fixed\") return undefined;\n }\n return undefined;\n };\n const shown = (e) => {\n if (e.closest(\".sr,.sr-only,.visually-hidden,.skip,[aria-hidden=true],select,textarea,svg\")) return false;\n if (getComputedStyle(e).visibility !== \"visible\") return false;\n for (let p = e; p && p !== root; p = p.parentElement) {\n const s = getComputedStyle(p);\n if (s.opacity === \"0\") return false;\n if (s.display === \"contents\") continue;\n const r = p.getBoundingClientRect();\n if (r.width <= 1 || r.height <= 1) return false;\n }\n return true;\n };\n const cuts = new Map();\n const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);\n const range = document.createRange();\n for (let t = walker.nextNode(); t; t = walker.nextNode()) {\n const e = t.parentElement;\n if (!e || !t.data.trim()) continue;\n const box = boxOf(e);\n if (!box || cuts.has(box)) continue;\n const s = getComputedStyle(box);\n if (s.textOverflow !== \"clip\") continue;\n const scrolls = s.overflowX === \"auto\" || s.overflowX === \"scroll\";\n const table = e.closest(\"table,[role=table],[role=grid]\");\n if (scrolls && !(table && box.contains(table))) continue;\n const left = box.getBoundingClientRect().left + box.clientLeft;\n range.selectNodeContents(t);\n const end = Math.max(...[...range.getClientRects()].filter((r) => r.width > 0).map((r) => r.right));\n if (end <= left + box.clientWidth + 1) continue;\n if (e.closest(\"[data-overflow-ok]\") || (scrolls && box.classList.contains(\"scroll-cue\")) || !shown(e)) continue;\n cuts.set(box, { kind: scrolls ? \"table\" : \"clip\", box: name(box), element: name(scrolls ? table : e), scrollWidth: Math.max(box.scrollWidth, Math.ceil(end - left)), clientWidth: box.clientWidth, text: t.data.trim().replace(/\\\\s+/g, \" \").slice(0, 40) });\n }\n return {\n innerWidth,\n scrollWidth: root.scrollWidth,\n height: Math.max(root.scrollHeight, document.body ? document.body.scrollHeight : 0),\n text: (document.body ? document.body.innerText : \"\").trim().length,\n past: past.slice(0, 8),\n clipped: clipped.slice(0, 8),\n cut: [...cuts.values()].slice(0, 8),\n };\n})()`;\n\n/** One check of a probe. */\nexport interface ProbeCheck {\n name: string;\n ok: boolean;\n detail?: string;\n}\n\n/**\n * This function wraps the code of a probe file into an expression. The code is the body of an async\n * function with these names:\n * - `check(name, ok, detail)` records a check,\n * - `wait(ms)` waits,\n * - `until(fn, ms)` waits until `fn()` gives a true value, at most `ms` (default 5000), and returns the value,\n * - `$(selector)` and `$$(selector)` find elements,\n * - `type(element, text)` writes the text into an input or a text area, with an `input` event,\n * - `click(element)` clicks an element, or the first element of a selector.\n * An exception stops the probe, and it counts as a failed check.\n */\nexport function probeExpression(code: string): string {\n return `(async () => {\n const __checks = [];\n const __text = (v) => { if (v === undefined) return undefined; if (typeof v === \"string\") return v; try { return JSON.stringify(v); } catch { return String(v); } };\n const check = (name, ok, detail) => { __checks.push({ name: String(name), ok: !!ok, ...(ok ? {} : { detail: __text(detail) }) }); return !!ok; };\n const wait = (ms) => new Promise((r) => setTimeout(r, ms));\n const until = async (fn, ms = 5000) => { const end = Date.now() + ms; for (;;) { const v = await fn(); if (v) return v; if (Date.now() > end) return v; await wait(50); } };\n const $ = (s) => document.querySelector(s);\n const $$ = (s) => [...document.querySelectorAll(s)];\n const __el = (e) => { const el = typeof e === \"string\" ? document.querySelector(e) : e; if (!el) throw new Error(\"no element: \" + e); return el; };\n const type = (e, text) => { const el = __el(e); el.focus(); el.value = text; el.dispatchEvent(new Event(\"input\", { bubbles: true })); el.dispatchEvent(new Event(\"change\", { bubbles: true })); };\n const click = (e) => __el(e).click();\n try {\n await (async () => {\n${code}\n })();\n } catch (e) {\n __checks.push({ name: \"the probe runs to its end\", ok: false, detail: String((e && e.stack) || e) });\n }\n return __checks;\n})()`;\n}\n","/**\n * A static file server for the `check` command. It serves a built site folder at the path of the\n * site home, as GitHub Pages does. Thus the links of the site work as on the live site.\n */\n\nimport { createReadStream, existsSync, statSync } from \"node:fs\";\nimport { createServer, type Server } from \"node:http\";\nimport { extname, join, normalize, resolve, sep } from \"node:path\";\n\nconst TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".wasm\": \"application/wasm\",\n \".txt\": \"text/plain; charset=utf-8\",\n \".md\": \"text/markdown; charset=utf-8\",\n \".xml\": \"application/xml\",\n \".webmanifest\": \"application/manifest+json\",\n \".map\": \"application/json; charset=utf-8\",\n};\n\n/**\n * This function maps the path of a request to a file of the folder, as GitHub Pages does. A folder\n * gives its `index.html`. For a path with no extension, the function also tries `<path>.html`.\n *\n * @returns the absolute file, or undefined when the path is outside the base or the file is missing\n */\nexport function resolveFile(root: string, base: string, pathname: string): string | undefined {\n let decoded: string;\n try {\n decoded = decodeURIComponent(pathname);\n } catch {\n return undefined;\n }\n const home = base.endsWith(\"/\") ? base : `${base}/`;\n if (decoded === home.slice(0, -1)) decoded = home;\n if (!decoded.startsWith(home)) return undefined;\n const top = resolve(root);\n const file = normalize(join(top, decoded.slice(home.length)));\n if (file !== top && !file.startsWith(top + sep)) return undefined;\n const candidates = [file, join(file, \"index.html\"), `${file}.html`];\n return candidates.find((candidate) => existsSync(candidate) && statSync(candidate).isFile());\n}\n\n/** A started server. */\nexport interface StaticServer {\n /** The URL of the site home, for example `http://127.0.0.1:50123/client/`. */\n url: string;\n close(): Promise<void>;\n}\n\n/**\n * This function serves the folder at `base` on a free port of 127.0.0.1. A missing file gives the\n * status 404 with the `404.html` of the folder, when it has one.\n */\nexport async function serve(root: string, base: string): Promise<StaticServer> {\n const server: Server = createServer((request, response) => {\n const pathname = new URL(request.url ?? \"/\", \"http://localhost\").pathname;\n const home = base.endsWith(\"/\") ? base : `${base}/`;\n if (pathname === home.slice(0, -1) && home !== \"/\") {\n response.writeHead(301, { location: home }).end();\n return;\n }\n const file = resolveFile(root, base, pathname);\n const missing = join(resolve(root), \"404.html\");\n const send = file ?? (existsSync(missing) ? missing : undefined);\n if (send === undefined) {\n response.writeHead(404, { \"content-type\": \"text/plain; charset=utf-8\" }).end(`404: ${pathname}\\n`);\n return;\n }\n response.writeHead(file ? 200 : 404, { \"content-type\": TYPES[extname(send).toLowerCase()] ?? \"application/octet-stream\", \"cache-control\": \"no-store\" });\n createReadStream(send).pipe(response);\n });\n await new Promise<void>((done, fail) => {\n server.once(\"error\", fail);\n server.listen(0, \"127.0.0.1\", () => done());\n });\n const address = server.address();\n if (address === null || typeof address === \"string\") throw new Error(\"the server has no port\");\n return {\n url: `http://127.0.0.1:${address.port}${base.endsWith(\"/\") ? base : `${base}/`}`,\n close: () => new Promise((done) => server.close(() => done())),\n };\n}\n","/**\n * The `site-pages check` command. It opens the pages of a built site (or of a live URL) in a\n * headless Chromium at phone and desktop widths, in the light and the dark scheme.\n *\n * A view fails when the page is wider than the screen or an element goes past the right edge. It\n * also fails when a text area hides its text, a box cuts text (`cutProblems`) or the page shows no text. A console error, an\n * exception and a failed request of the site also fail it. A script that does not load and a failed check of the probe\n * fail it too. The command\n * writes a screenshot of each view.\n */\n\nimport { appendFileSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findBrowser, launch, type Page } from \"./browser.ts\";\nimport { MEASURE, probeExpression, type Cut, type Measure, type ProbeCheck } from \"./measure.ts\";\nimport { probeScript, TYPESCRIPT_PROBE } from \"./probe.ts\";\nimport { serve } from \"./serve.ts\";\n\n/** A view narrower than this width in CSS pixels is a phone. */\nexport const PHONE_WIDTH = 768;\n\n/** The options of `checkSite`. */\nexport interface CheckOptions {\n /** The built site folder. Give `out` or `url`. */\n out?: string | undefined;\n /** The path of the site home, for `out`, for example `/client/`. */\n base?: string | undefined;\n /** The URL of a live site home. Give `out` or `url`. */\n url?: string | undefined;\n /** The pages, from the site home, for example `/` and `/releases/`. */\n pages: readonly string[];\n /** The widths in CSS pixels. A width under `PHONE_WIDTH` is a phone. */\n widths: readonly number[];\n /** The color schemes. */\n schemes: readonly (\"light\" | \"dark\")[];\n /** The code of a probe: the body of an async function (see `probeExpression`). It runs on the first page, in the light scheme, at each width. */\n probe?: string | undefined;\n /** The folder for the screenshots, `report.json` and `summary.md`. */\n shots?: string | undefined;\n /** The browser executable. */\n browser?: string | undefined;\n /** The time to wait after the load event, for the scripts of the page. */\n settleMs: number;\n /** The time limit of a page load. */\n timeoutMs: number;\n log?: ((line: string) => void) | undefined;\n}\n\n/** The result of one page at one width and scheme. */\nexport interface ViewResult {\n page: string;\n width: number;\n scheme: \"light\" | \"dark\";\n ok: boolean;\n /** What failed. */\n problems: string[];\n measure?: Measure | undefined;\n probe?: ProbeCheck[] | undefined;\n /** The file of the screenshot. */\n shot?: string | undefined;\n}\n\n/** The result of `checkSite`. */\nexport interface CheckResult {\n ok: boolean;\n url: string;\n browser: string;\n views: ViewResult[];\n}\n\n/**\n * This function gives the problems of the cuts of a view with the given width. A box that clips text is a problem at each width.\n * A table in a box that scrolls is a problem only on a phone. A phone shows no scroll bar, but a desktop shows one.\n * The summary and the log give the page of each problem.\n */\nexport function cutProblems(cuts: readonly Cut[], width: number): string[] {\n const widths = (cut: Cut) => `${cut.element} in ${cut.box}: content of ${cut.scrollWidth} px in a box of ${cut.clientWidth} px, \"${cut.text}\"`;\n return cuts.flatMap((cut) => {\n if (cut.kind === \"clip\") return [`a box cuts text at ${width} px: ${widths(cut)}. Make the content fit, or add data-overflow-ok to the box.`];\n if (width < PHONE_WIDTH) return [`a table goes out of view at ${width} px: ${widths(cut)}. Make the table fit, give the box the class scroll-cue, or add data-overflow-ok to the box.`];\n return [];\n });\n}\n\n/** This function gives the file name part of a page: `/` is `home`, `/releases/` is `releases`. */\nexport function pageSlug(page: string): string {\n const slug = page.replace(/^\\/+|\\/+$/g, \"\").replace(/[^A-Za-z0-9._-]+/g, \"_\");\n return slug === \"\" ? \"home\" : slug;\n}\n\n/**\n * This function checks the site. It starts one browser and, for `out`, one server, and stops both at\n * the end.\n *\n * @throws Error when there is no browser, or the browser does not start\n */\nexport async function checkSite(options: CheckOptions): Promise<CheckResult> {\n const log = options.log ?? (() => {});\n const executable = findBrowser(options.browser);\n if (executable === undefined) throw new Error(\"no Chromium browser was found: give --browser, set SITE_CHECK_BROWSER, or install the Chromium of Playwright\");\n if (options.pages.length === 0) throw new Error(\"no page to check\");\n const server = options.out !== undefined ? await serve(options.out, options.base ?? \"/\") : undefined;\n const home = server?.url ?? options.url;\n if (home === undefined) throw new Error(\"give out or url\");\n const homeUrl = new URL(home.endsWith(\"/\") ? home : `${home}/`);\n const browser = await launch(executable, options.timeoutMs);\n const views: ViewResult[] = [];\n try {\n const { page } = browser;\n const events = watch(page, homeUrl.origin);\n await Promise.all([page.send(\"Page.enable\"), page.send(\"Runtime.enable\"), page.send(\"Network.enable\")]);\n await page.send(\"Page.addScriptToEvaluateOnNewDocument\", { source: LOAD_WATCH });\n if (options.shots) mkdirSync(options.shots, { recursive: true });\n for (const [index, path] of options.pages.entries()) {\n const target = new URL(path.replace(/^\\/+/, \"\"), homeUrl).href;\n for (const width of options.widths) {\n for (const scheme of options.schemes) {\n const withProbe = options.probe !== undefined && index === 0 && scheme === options.schemes[0];\n const view = await checkView(page, events, { target, path, width, scheme, withProbe, options });\n views.push(view);\n log(`${view.ok ? \"PASS\" : \"FAIL\"} ${path} ${width} ${scheme}${view.measure ? ` scrollWidth=${view.measure.scrollWidth} innerWidth=${view.measure.innerWidth}` : \"\"}${view.probe ? ` probe ${view.probe.filter((c) => c.ok).length}/${view.probe.length}` : \"\"}${view.problems.length > 0 ? `\\n - ${view.problems.join(\"\\n - \")}` : \"\"}`);\n }\n }\n }\n } finally {\n await browser.close();\n await server?.close();\n }\n const result: CheckResult = { ok: views.length > 0 && views.every((view) => view.ok), url: homeUrl.href, browser: executable, views };\n if (options.shots) {\n writeFileSync(join(options.shots, \"report.json\"), `${JSON.stringify(result, null, 2)}\\n`);\n writeFileSync(join(options.shots, \"summary.md\"), summary(result));\n }\n return result;\n}\n\n/**\n * A script that each page starts before its own scripts. A script or a style sheet that does not load fires `error` on its\n * element. This script writes that event as a console error. Thus a module script whose imports do not load is a problem too.\n * Such a script throws no exception. Its failed request can go to another origin, for example `node:perf_hooks` in a page bundle.\n */\nexport const LOAD_WATCH = `addEventListener(\"error\", (event) => {\n const element = event.target;\n if (!(element instanceof HTMLScriptElement || element instanceof HTMLLinkElement)) return;\n console.error(\"failed to load \" + element.tagName.toLowerCase() + \": \" + (element.getAttribute(\"src\") ?? element.getAttribute(\"href\") ?? \"(inline)\"));\n}, true);`;\n\n/** The problems that the events of the page gave, since the last `reset`. */\ninterface Events {\n reset(): void;\n problems(): string[];\n}\n\nfunction watch(page: Page, origin: string): Events {\n let problems: string[] = [];\n const urls = new Map<string, string>();\n const own = (url: string) => {\n try {\n const parsed = new URL(url);\n // A browser asks for /favicon.ico on its own, also for a site under a path.\n return parsed.origin === origin && parsed.pathname !== \"/favicon.ico\";\n } catch {\n return false;\n }\n };\n page.on(\"Runtime.exceptionThrown\", (params) => {\n const details = params[\"exceptionDetails\"] as { text?: string; exception?: { description?: string } };\n problems.push(`exception: ${(details.exception?.description ?? details.text ?? \"\").split(\"\\n\")[0]}`);\n });\n page.on(\"Runtime.consoleAPICalled\", (params) => {\n if (params[\"type\"] !== \"error\" && params[\"type\"] !== \"assert\") return;\n const args = (params[\"args\"] as { value?: unknown; description?: string }[]) ?? [];\n problems.push(`console.error: ${args.map((arg) => String(arg.value ?? arg.description ?? \"\")).join(\" \").slice(0, 300)}`);\n });\n page.on(\"Network.requestWillBeSent\", (params) => {\n urls.set(String(params[\"requestId\"]), String((params[\"request\"] as { url: string }).url));\n });\n page.on(\"Network.responseReceived\", (params) => {\n const response = params[\"response\"] as { url: string; status: number };\n if (response.status >= 400 && own(response.url)) problems.push(`HTTP ${response.status}: ${response.url}`);\n });\n page.on(\"Network.loadingFailed\", (params) => {\n const url = urls.get(String(params[\"requestId\"])) ?? \"\";\n // A script of any origin counts: without it, the page does not work.\n if ((own(url) || params[\"type\"] === \"Script\") && params[\"canceled\"] !== true) problems.push(`request failed (${String(params[\"errorText\"])}): ${url}`);\n });\n return {\n reset: () => {\n problems = [];\n },\n problems: () => [...new Set(problems)],\n };\n}\n\ninterface ViewInput {\n target: string;\n path: string;\n width: number;\n scheme: \"light\" | \"dark\";\n withProbe: boolean;\n options: CheckOptions;\n}\n\nasync function checkView(page: Page, events: Events, input: ViewInput): Promise<ViewResult> {\n const { target, path, width, scheme, withProbe, options } = input;\n const view: ViewResult = { page: path, width, scheme, ok: false, problems: [] };\n try {\n await page.send(\"Emulation.setDeviceMetricsOverride\", { width, height: 900, deviceScaleFactor: 1, mobile: width < PHONE_WIDTH });\n await page.send(\"Emulation.setEmulatedMedia\", { features: [{ name: \"prefers-color-scheme\", value: scheme }] });\n events.reset();\n const loaded = page.once(\"Page.loadEventFired\", options.timeoutMs);\n const navigation = (await page.send(\"Page.navigate\", { url: target })) as { errorText?: string };\n if (navigation.errorText) {\n loaded.catch(() => {});\n throw new Error(`the page did not open: ${navigation.errorText}`);\n }\n await loaded;\n await page.evaluate(\"document.fonts ? document.fonts.ready.then(() => true) : true\");\n await new Promise((done) => setTimeout(done, options.settleMs));\n const measure = await page.evaluate<Measure>(MEASURE);\n view.measure = measure;\n // The screen width, not innerWidth: a phone browser can zoom out a page that is too wide.\n if (measure.scrollWidth > width) view.problems.push(`the page is wider than the screen: ${measure.scrollWidth} > ${width}`);\n for (const past of measure.past) view.problems.push(`past the right edge: ${past}`);\n for (const clipped of measure.clipped) view.problems.push(`a text area hides its text: ${clipped}`);\n view.problems.push(...cutProblems(measure.cut, width));\n if (measure.text === 0) view.problems.push(\"the page shows no text\");\n if (options.shots) {\n const file = join(options.shots, `${pageSlug(path)}-${width}-${scheme}.png`);\n const height = Math.min(Math.max(measure.height, 1), 8000);\n const shot = (await page.send(\"Page.captureScreenshot\", { format: \"png\", captureBeyondViewport: true, clip: { x: 0, y: 0, width, height, scale: 1 } })) as { data: string };\n writeFileSync(file, Buffer.from(shot.data, \"base64\"));\n view.shot = file;\n }\n if (withProbe && options.probe !== undefined) {\n const checks = (await page.evaluate<ProbeCheck[] | undefined>(probeExpression(options.probe))) ?? [];\n view.probe = checks;\n if (checks.length === 0) view.problems.push(\"the probe made no check\");\n for (const check of checks.filter((entry) => !entry.ok)) view.problems.push(`probe: ${check.name}${check.detail ? ` (${check.detail})` : \"\"}`);\n }\n } catch (error) {\n view.problems.push(error instanceof Error ? error.message : String(error));\n }\n view.problems.push(...events.problems());\n view.ok = view.problems.length === 0;\n return view;\n}\n\n/** This function makes a text safe for a cell of a Markdown table. It escapes `\\`, `|`, `<` and `>`. It changes each new line to a space. */\nexport function cell(text: string): string {\n return text.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\|/g, \"\\\\|\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\\r?\\n/g, \" \");\n}\n\n/** This function gives the Markdown summary of a result, for the job summary of a workflow. */\nexport function summary(result: CheckResult): string {\n const failed = result.views.filter((view) => !view.ok);\n const lines = [\n `### Site check: ${result.ok ? \"passed\" : \"failed\"}`,\n \"\",\n `${result.views.length - failed.length} of ${result.views.length} views passed, at ${result.url}.`,\n \"\",\n \"| Page | Width | Scheme | Result | Problems |\",\n \"| --- | ---: | --- | --- | --- |\",\n ...result.views.map(\n (view) =>\n `| \\`${view.page}\\` | ${view.width} | ${view.scheme} | ${view.ok ? \"pass\" : \"**fail**\"}${view.probe ? ` (probe ${view.probe.filter((c) => c.ok).length}/${view.probe.length})` : \"\"} | ${view.problems.map(cell).join(\"<br>\")} |`,\n ),\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n\n/** The input and output of the CLI. */\nexport interface CheckIo {\n cwd: string;\n env: NodeJS.ProcessEnv;\n stdout: (text: string) => void;\n stderr: (text: string) => void;\n}\n\nexport const CHECK_HELP = `Usage: site-pages check (--out <dir> | --url <url>) [options]\n\nOpens the pages of the site in a headless Chromium at phone and desktop widths, in the light and\nthe dark scheme, and fails when a page is wider than the screen, an element goes past the right\nedge, a text area hides its text, a box cuts text, a table goes out of view on a phone, a page\nshows no text, or on a console error, an exception, a failed request of the site, a script that\ndoes not load or a failed check of the probe. Add data-overflow-ok to a box that is meant to\nscroll or to clip.\n\nOptions:\n --out <dir> The built site folder. The check serves it at --base.\n --url <url> The URL of a live site home, in place of --out\n --repo <owner/name> The GitHub repository, for the default base (default: $GITHUB_REPOSITORY)\n --base </name/> The path of the site home (default: \"/<name>/\", or \"/\" for <owner>.github.io)\n --pages <paths> The pages, from the site home, separated by commas (default: /)\n --widths <px> The widths, separated by commas (default: 360,400,1280)\n --schemes <list> light, dark or both (default: light,dark)\n --probe <file> A JavaScript file: the body of an async function with check(name, ok, detail),\n wait, until, $, $$, type and click. It runs on the first page, in the first\n scheme, at each width. A .ts, .mts or .cts file is TypeScript: the check\n removes its types and its line export {}.\n --shots <dir> The folder for the screenshots, report.json and summary.md\n --browser <file> The Chromium executable (default: $SITE_CHECK_BROWSER, the Chromium of\n Playwright, else Chrome or Edge)\n --settle <ms> The wait after the load event (default: 1500)\n --timeout <ms> The time limit of a page load (default: 30000)\n --help Shows this text\n\nWith $GITHUB_STEP_SUMMARY, the check adds its table to the job summary.\n`;\n\n/** This function runs the `check` command with its arguments, without the word `check`. */\nexport async function runCheckCli(argv: readonly string[], io: CheckIo): Promise<number> {\n let values: Record<string, string | boolean | undefined>;\n try {\n ({ values } = parseArgs({\n args: [...argv],\n allowPositionals: false,\n options: {\n out: { type: \"string\" },\n url: { type: \"string\" },\n repo: { type: \"string\" },\n base: { type: \"string\" },\n pages: { type: \"string\" },\n widths: { type: \"string\" },\n schemes: { type: \"string\" },\n probe: { type: \"string\" },\n shots: { type: \"string\" },\n browser: { type: \"string\" },\n settle: { type: \"string\" },\n timeout: { type: \"string\" },\n help: { type: \"boolean\" },\n },\n }));\n } catch (error) {\n io.stderr(`site-pages check: ${error instanceof Error ? error.message : String(error)}\\n\\n${CHECK_HELP}`);\n return 2;\n }\n if (values[\"help\"]) {\n io.stdout(CHECK_HELP);\n return 0;\n }\n const usage = (message: string) => {\n io.stderr(`site-pages check: ${message}\\n\\n${CHECK_HELP}`);\n return 2;\n };\n const text = (key: string) => (typeof values[key] === \"string\" ? (values[key] as string) : undefined);\n const list = (key: string, fallback: string) => (text(key) ?? fallback).split(\",\").map((entry) => entry.trim()).filter(Boolean);\n const out = text(\"out\");\n const url = text(\"url\");\n if ((out === undefined) === (url === undefined)) return usage(\"give --out or --url, not both\");\n const widths = list(\"widths\", \"360,400,1280\").map(Number);\n if (widths.length === 0 || widths.some((width) => !Number.isInteger(width) || width < 200 || width > 4000)) return usage(\"--widths must be whole numbers from 200 to 4000\");\n const schemes = list(\"schemes\", \"light,dark\");\n if (schemes.length === 0 || schemes.some((scheme) => scheme !== \"light\" && scheme !== \"dark\")) return usage(\"--schemes must be light, dark or both\");\n const pages = list(\"pages\", \"/\");\n if (pages.length === 0) return usage(\"--pages has no page\");\n // Git Bash changes a bare \"/\" into \"C:/Program Files/Git/\". A page is a path, with no scheme or drive.\n const notPath = pages.find((entry) => entry.includes(\":\") || entry.includes(\"\\\\\"));\n if (notPath !== undefined) return usage(`a page is a path from the site home, not \"${notPath}\" (in Git Bash, set MSYS_NO_PATHCONV=1)`);\n const settleMs = Number(text(\"settle\") ?? 1500);\n const timeoutMs = Number(text(\"timeout\") ?? 30000);\n if (!(settleMs >= 0) || !(timeoutMs > 0)) return usage(\"--settle and --timeout must be numbers of milliseconds\");\n let base = text(\"base\");\n if (out !== undefined && base === undefined) {\n const name = (text(\"repo\") ?? io.env[\"GITHUB_REPOSITORY\"] ?? \"\").split(\"/\")[1];\n if (!name) return usage(\"give --base, --repo or set GITHUB_REPOSITORY\");\n base = /\\.github\\.io$/i.test(name) ? \"/\" : `/${name}/`;\n }\n if (base !== undefined) base = `/${base.replace(/^\\/+|\\/+$/g, \"\")}/`.replace(/^\\/\\/$/, \"/\");\n const at = (file: string) => (isAbsolute(file) ? file : resolve(io.cwd, file));\n const probeFile = text(\"probe\");\n let probe: string | undefined;\n if (probeFile !== undefined) {\n try {\n probe = readFileSync(at(probeFile), \"utf8\");\n } catch (error) {\n return usage(`the probe file ${probeFile} cannot be read: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (TYPESCRIPT_PROBE.test(probeFile)) {\n try {\n probe = probeScript(probe);\n } catch (error) {\n return usage(`the types of the probe file ${probeFile} cannot be removed: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n const shots = text(\"shots\");\n const result = await checkSite({\n out: out === undefined ? undefined : at(out),\n base,\n url,\n pages,\n widths,\n schemes: schemes as (\"light\" | \"dark\")[],\n probe,\n shots: shots === undefined ? undefined : at(shots),\n browser: text(\"browser\"),\n settleMs,\n timeoutMs,\n log: (line) => io.stdout(`${line}\\n`),\n });\n const failed = result.views.filter((view) => !view.ok).length;\n io.stdout(`site-pages check: ${result.views.length - failed} of ${result.views.length} views passed (${result.browser}).\\n`);\n const step = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (step) appendFileSync(step, summary(result));\n return result.ok ? 0 : 1;\n}\n","#!/usr/bin/env node\n// The bin `site-pages`. The work is in build.ts and check/check.ts, so a test can run the same CLI with its own fetch.\nimport { runCli } from \"./build.ts\";\nimport { runCheckCli } from \"./check/check.ts\";\n\nconst argv = process.argv.slice(2);\nconst io = {\n cwd: process.cwd(),\n env: process.env,\n stdout: (text: string) => process.stdout.write(text),\n stderr: (text: string) => process.stderr.write(text),\n};\n(argv[0] === \"check\" ? runCheckCli(argv.slice(1), io) : runCli(argv, io)).then(\n (code) => {\n process.exitCode = code;\n },\n (error: unknown) => {\n process.stderr.write(`site-pages: ${error instanceof Error ? (error.stack ?? error.message) :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WAAW;AACrB,CACF"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/check/browser.ts","../src/check/measure.ts","../src/check/serve.ts","../src/check/check.ts","../src/cli.ts"],"sourcesContent":["/**\n * A small client of the Chrome DevTools protocol for the `check` command. It starts a Chromium\n * browser (Chrome, Edge or the Chromium of Playwright) in headless mode and drives one page. It\n * uses only Node.js, so the check needs no package install.\n */\n\nimport { spawn, type ChildProcess } from \"node:child_process\";\nimport { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from \"node:fs\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { delimiter, join } from \"node:path\";\n\n/** The paths that `findBrowser` examines after the option and the Playwright folder. */\nfunction systemBrowsers(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string[] {\n if (platform === \"win32\") {\n const roots = [env[\"PROGRAMFILES\"], env[\"PROGRAMFILES(X86)\"], env[\"LOCALAPPDATA\"]].filter((root): root is string => !!root);\n return roots.flatMap((root) => [join(root, \"Google/Chrome/Application/chrome.exe\"), join(root, \"Microsoft/Edge/Application/msedge.exe\")]);\n }\n if (platform === \"darwin\") {\n return [\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\", \"/Applications/Chromium.app/Contents/MacOS/Chromium\", \"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge\"];\n }\n const names = [\"google-chrome\", \"google-chrome-stable\", \"chromium\", \"chromium-browser\", \"microsoft-edge\"];\n const dirs = (env[\"PATH\"] ?? \"\").split(delimiter).filter(Boolean);\n return names.flatMap((name) => dirs.map((dir) => join(dir, name)));\n}\n\n/** The Chromium of the newest `chromium-<n>` folder of Playwright, or undefined. */\nfunction playwrightChromium(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string | undefined {\n const root =\n env[\"PLAYWRIGHT_BROWSERS_PATH\"] ||\n (platform === \"win32\" ? join(env[\"LOCALAPPDATA\"] ?? homedir(), \"ms-playwright\") : platform === \"darwin\" ? join(homedir(), \"Library/Caches/ms-playwright\") : join(homedir(), \".cache/ms-playwright\"));\n if (!existsSync(root)) return undefined;\n const builds = readdirSync(root)\n .map((name) => /^chromium-(\\d+)$/.exec(name))\n .filter((match): match is RegExpExecArray => match !== null)\n .sort((a, b) => Number(b[1]) - Number(a[1]));\n for (const [folder] of builds) {\n for (const sub of readdirSync(join(root, folder))) {\n const candidates =\n platform === \"win32\"\n ? [join(root, folder, sub, \"chrome.exe\")]\n : platform === \"darwin\"\n ? [join(root, folder, sub, \"Chromium.app/Contents/MacOS/Chromium\"), join(root, folder, sub, \"Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing\")]\n : [join(root, folder, sub, \"chrome\")];\n const found = candidates.find((file) => existsSync(file));\n if (found) return found;\n }\n }\n return undefined;\n}\n\n/**\n * This function finds a Chromium browser. It examines the given path, then `$SITE_CHECK_BROWSER`,\n * then the newest Chromium of Playwright, then a Chrome or an Edge of the system.\n *\n * @returns the path of the executable, or undefined when there is none\n */\nexport function findBrowser(given?: string, env: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform): string | undefined {\n const named = given || env[\"SITE_CHECK_BROWSER\"];\n if (named) return named;\n return playwrightChromium(platform, env) ?? systemBrowsers(platform, env).find((file) => existsSync(file));\n}\n\n/** A message of the DevTools protocol. */\ninterface Message {\n id?: number;\n method?: string;\n params?: Record<string, unknown>;\n result?: Record<string, unknown>;\n error?: { message: string };\n}\n\n/** An event handler of a page. */\ntype Listener = (params: Record<string, unknown>) => void;\n\n/** One page of a started browser. */\nexport interface Page {\n /** This function sends a command of the protocol and returns its result. */\n send(method: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;\n /** This function calls the listener on each event of the method. */\n on(method: string, listener: Listener): void;\n /** This function calls the listener on the next event of the method, or rejects after `ms`. */\n once(method: string, ms: number): Promise<Record<string, unknown>>;\n /** This function evaluates the expression in the page, and waits for a promise. */\n evaluate<T>(expression: string): Promise<T>;\n}\n\n/** A started browser. */\nexport interface Browser {\n page: Page;\n /** This function stops the browser and removes its profile. */\n close(): Promise<void>;\n}\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * This function starts the browser in headless mode with a new profile, and connects to its page.\n * The browser picks a free port, so two checks can run at the same time.\n *\n * @throws Error when the browser does not start in `timeoutMs`\n */\nexport async function launch(executable: string, timeoutMs = 30_000): Promise<Browser> {\n const profile = mkdtempSync(join(tmpdir(), \"site-check-\"));\n const args = [\n \"--headless=new\",\n \"--remote-debugging-port=0\",\n `--user-data-dir=${profile}`,\n \"--no-first-run\",\n \"--no-default-browser-check\",\n \"--disable-gpu\",\n \"--disable-extensions\",\n \"--disable-background-networking\",\n \"--disable-sync\",\n \"--hide-scrollbars\",\n \"--mute-audio\",\n // The sandbox of Chromium needs user namespaces, which Ubuntu 24.04 refuses to a browser that the\n // system did not install. Playwright also starts Chromium with no sandbox.\n ...(process.platform === \"linux\" ? [\"--no-sandbox\"] : []),\n \"about:blank\",\n ];\n const child: ChildProcess = spawn(executable, args, { stdio: \"ignore\" });\n let exited: string | undefined;\n child.once(\"exit\", (code, signal) => (exited = `the browser stopped (code ${code}, signal ${signal})`));\n child.once(\"error\", (error) => (exited = `the browser did not start: ${error.message}`));\n const stop = async () => {\n if (child.exitCode === null && child.signalCode === null) {\n child.kill();\n await Promise.race([new Promise((resolve) => child.once(\"exit\", resolve)), sleep(5000)]);\n }\n rmSync(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });\n };\n try {\n const portFile = join(profile, \"DevToolsActivePort\");\n const end = Date.now() + timeoutMs;\n let port = \"\";\n while (port === \"\") {\n if (exited !== undefined) throw new Error(`${executable}: ${exited}`);\n if (Date.now() > end) throw new Error(`${executable}: no DevTools port after ${timeoutMs} ms`);\n if (existsSync(portFile)) port = readFileSync(portFile, \"utf8\").split(\"\\n\")[0]?.trim() ?? \"\";\n if (port === \"\") await sleep(100);\n }\n let target: { type: string; webSocketDebuggerUrl: string } | undefined;\n while (target === undefined) {\n const list = (await (await fetch(`http://127.0.0.1:${port}/json/list`)).json()) as { type: string; webSocketDebuggerUrl: string }[];\n target = list.find((entry) => entry.type === \"page\");\n if (target === undefined) {\n if (Date.now() > end) throw new Error(`${executable}: no page target after ${timeoutMs} ms`);\n await sleep(100);\n }\n }\n const page = await connect(target.webSocketDebuggerUrl);\n return {\n page: page.page,\n close: async () => {\n page.close();\n await stop();\n },\n };\n } catch (error) {\n await stop();\n throw error;\n }\n}\n\nasync function connect(url: string): Promise<{ page: Page; close: () => void }> {\n const socket = new WebSocket(url);\n await new Promise<void>((resolve, reject) => {\n socket.addEventListener(\"open\", () => resolve(), { once: true });\n socket.addEventListener(\"error\", () => reject(new Error(`no connection to ${url}`)), { once: true });\n });\n let sequence = 0;\n const pending = new Map<number, { resolve: (value: Record<string, unknown>) => void; reject: (error: Error) => void }>();\n const listeners = new Map<string, Listener[]>();\n socket.addEventListener(\"message\", (event) => {\n const message = JSON.parse(String(event.data)) as Message;\n if (message.id !== undefined) {\n const call = pending.get(message.id);\n pending.delete(message.id);\n if (message.error) call?.reject(new Error(message.error.message));\n else call?.resolve(message.result ?? {});\n } else if (message.method) {\n for (const listener of listeners.get(message.method) ?? []) listener(message.params ?? {});\n }\n });\n socket.addEventListener(\"close\", () => {\n for (const call of pending.values()) call.reject(new Error(\"the browser closed the connection\"));\n pending.clear();\n });\n const page: Page = {\n send: (method, params = {}) =>\n new Promise((resolve, reject) => {\n const id = ++sequence;\n pending.set(id, { resolve, reject });\n socket.send(JSON.stringify({ id, method, params }));\n }),\n on: (method, listener) => listeners.set(method, [...(listeners.get(method) ?? []), listener]),\n once: (method, ms) =>\n new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n remove();\n reject(new Error(`no ${method} after ${ms} ms`));\n }, ms);\n const listener: Listener = (params) => {\n clearTimeout(timer);\n remove();\n resolve(params);\n };\n const remove = () => listeners.set(method, (listeners.get(method) ?? []).filter((entry) => entry !== listener));\n page.on(method, listener);\n }),\n evaluate: async <T>(expression: string): Promise<T> => {\n const reply = (await page.send(\"Runtime.evaluate\", { expression, awaitPromise: true, returnByValue: true })) as {\n result?: { value?: unknown };\n exceptionDetails?: { text?: string; exception?: { description?: string } };\n };\n if (reply.exceptionDetails) throw new Error(reply.exceptionDetails.exception?.description ?? reply.exceptionDetails.text ?? \"the expression failed\");\n return reply.result?.value as T;\n },\n };\n return { page, close: () => socket.close() };\n}\n","/**\n * The measurements that the `check` command makes in the page. Each is a string of JavaScript that\n * the browser evaluates, so the code can use only the APIs of the page.\n */\n\n/** Text past the edge of a box that cuts it: an entry of `Measure.cut`. */\nexport interface Cut {\n /**\n * The kind of the box:\n * - `clip`: the box has `overflow-x: hidden` or `clip`, so a visitor cannot reach the text,\n * - `table`: the box scrolls, and the text is in a table.\n */\n kind: \"clip\" | \"table\";\n /** The box. */\n box: string;\n /** The table, or the element of the text. */\n element: string;\n /** The width of the content of the box, in CSS pixels. */\n scrollWidth: number;\n /** The visible width of the box, in CSS pixels. */\n clientWidth: number;\n /** The start of the first text past the edge. */\n text: string;\n}\n\n/** The result of `MEASURE`. */\nexport interface Measure {\n innerWidth: number;\n scrollWidth: number;\n /** The height of the document, for the screenshot. */\n height: number;\n /** The number of characters of visible text. */\n text: number;\n /** The outermost elements that go past the right edge of the screen, at most 8. */\n past: string[];\n /** The text areas that hide a part of their text, at most 8. */\n clipped: string[];\n /** The boxes that cut text at their right edge, at most 8. `cutProblems` of `check.ts` tells which ones are problems. */\n cut: Cut[];\n}\n\n/**\n * This expression measures the page. An element counts as past the edge when its right side is\n * more than half a pixel past the width of the document. These elements do not count:\n * - an element in a container that scrolls or clips (`overflow-x` other than `visible`, below `body`),\n * - an element of zero size, a hidden element, or a fixed element that is fully past the edge (a closed drawer),\n * - an element in `.sr`, `.sr-only`, `.visually-hidden` or `.skip` (text for screen readers and skip links),\n * - an element in a `pre`, other than the `pre` itself.\n * Of a chain of elements past the edge, only the outermost one counts.\n *\n * `past` skips each element in a container that scrolls or clips, so `cut` examines those containers.\n * A box is the nearest element around a text, below `body`, with `overflow-x` other than `visible`. Its content is wider\n * than the box by more than 1 px. An element with `overflow-x: clip` is always a box, because it can report no overflow.\n * The text counts when a line of it ends more than 1 px past the right edge of the box.\n *\n * A box that scrolls counts only for text in a table (`table`, `role=\"table\"` or `role=\"grid\"`).\n * A code block, a hex view, a row of tabs and a carousel in such a box are meant to scroll.\n * A box that clips counts for each text, because a visitor cannot reach that text. These texts do not count:\n * - a text in a box with `text-overflow` other than `clip` (a person chose the ellipsis),\n * - a text in an element with `data-overflow-ok`, or in that element itself (a person chose the overflow),\n * - a text in a box with the class `scroll-cue` that scrolls (a shade shows the visitor that it scrolls),\n * - a text in `.sr`, `.sr-only`, `.visually-hidden`, `.skip`, `[aria-hidden=\"true\"]`, `select`, `textarea` or `svg`,\n * - a text in a fixed element, which the box does not clip,\n * - a text that is not visible, or with an element around it of 1 px or less or with `opacity: 0`.\n * Only the first text of a box counts. An element with no text does not count. Vertical overflow does not count.\n */\nexport const MEASURE = `(() => {\n const root = document.documentElement;\n const w = root.clientWidth;\n const name = (e) => e.tagName.toLowerCase() + (e.id ? \"#\" + e.id : \"\") + (typeof e.className === \"string\" && e.className.trim() ? \".\" + e.className.trim().split(/\\\\s+/).slice(0, 3).join(\".\") : \"\");\n const inScroller = (e) => {\n for (let p = e.parentElement; p && p !== document.body && p !== root; p = p.parentElement) {\n if (getComputedStyle(p).overflowX !== \"visible\") return true;\n }\n return false;\n };\n const counts = (e) => {\n const r = e.getBoundingClientRect();\n if (r.width === 0 || r.height === 0 || r.right <= w + 0.5) return false;\n if (e.closest(\".sr,.sr-only,.visually-hidden,.skip\")) return false;\n if (e.closest(\"pre\") && e.tagName !== \"PRE\") return false;\n const s = getComputedStyle(e);\n if (s.visibility === \"hidden\" || s.display === \"none\") return false;\n if (s.position === \"fixed\" && r.left >= w) return false;\n return !inScroller(e);\n };\n const over = new Set([...document.querySelectorAll(\"body *\")].filter(counts));\n const past = [...over]\n .filter((e) => { for (let p = e.parentElement; p; p = p.parentElement) if (over.has(p)) return false; return true; })\n .map((e) => name(e) + \" right=\" + Math.round(e.getBoundingClientRect().right));\n const clipped = [...document.querySelectorAll(\"textarea\")]\n .filter((e) => { const s = getComputedStyle(e); return (s.overflowY === \"hidden\" || s.overflowY === \"clip\") && e.getBoundingClientRect().height > 0 && e.scrollHeight > e.clientHeight + 1; })\n .map((e) => name(e) + \" \" + e.scrollHeight + \">\" + e.clientHeight);\n const boxOf = (e) => {\n for (let p = e; p && p !== document.body && p !== root; p = p.parentElement) {\n const s = getComputedStyle(p);\n if (s.overflowX === \"clip\" || (s.overflowX !== \"visible\" && p.scrollWidth > p.clientWidth + 1)) return p;\n if (s.position === \"fixed\") return undefined;\n }\n return undefined;\n };\n const shown = (e) => {\n if (e.closest(\".sr,.sr-only,.visually-hidden,.skip,[aria-hidden=true],select,textarea,svg\")) return false;\n if (getComputedStyle(e).visibility !== \"visible\") return false;\n for (let p = e; p && p !== root; p = p.parentElement) {\n const s = getComputedStyle(p);\n if (s.opacity === \"0\") return false;\n if (s.display === \"contents\") continue;\n const r = p.getBoundingClientRect();\n if (r.width <= 1 || r.height <= 1) return false;\n }\n return true;\n };\n const cuts = new Map();\n const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);\n const range = document.createRange();\n for (let t = walker.nextNode(); t; t = walker.nextNode()) {\n const e = t.parentElement;\n if (!e || !t.data.trim()) continue;\n const box = boxOf(e);\n if (!box || cuts.has(box)) continue;\n const s = getComputedStyle(box);\n if (s.textOverflow !== \"clip\") continue;\n const scrolls = s.overflowX === \"auto\" || s.overflowX === \"scroll\";\n const table = e.closest(\"table,[role=table],[role=grid]\");\n if (scrolls && !(table && box.contains(table))) continue;\n const left = box.getBoundingClientRect().left + box.clientLeft;\n range.selectNodeContents(t);\n const end = Math.max(...[...range.getClientRects()].filter((r) => r.width > 0).map((r) => r.right));\n if (end <= left + box.clientWidth + 1) continue;\n if (e.closest(\"[data-overflow-ok]\") || (scrolls && box.classList.contains(\"scroll-cue\")) || !shown(e)) continue;\n cuts.set(box, { kind: scrolls ? \"table\" : \"clip\", box: name(box), element: name(scrolls ? table : e), scrollWidth: Math.max(box.scrollWidth, Math.ceil(end - left)), clientWidth: box.clientWidth, text: t.data.trim().replace(/\\\\s+/g, \" \").slice(0, 40) });\n }\n return {\n innerWidth,\n scrollWidth: root.scrollWidth,\n height: Math.max(root.scrollHeight, document.body ? document.body.scrollHeight : 0),\n text: (document.body ? document.body.innerText : \"\").trim().length,\n past: past.slice(0, 8),\n clipped: clipped.slice(0, 8),\n cut: [...cuts.values()].slice(0, 8),\n };\n})()`;\n\n/** One check of a probe. */\nexport interface ProbeCheck {\n name: string;\n ok: boolean;\n detail?: string;\n}\n\n/**\n * This function wraps the code of a probe file into an expression. The code is the body of an async\n * function with these names:\n * - `check(name, ok, detail)` records a check,\n * - `wait(ms)` waits,\n * - `until(fn, ms)` waits until `fn()` gives a true value, at most `ms` (default 5000), and returns the value,\n * - `$(selector)` and `$$(selector)` find elements,\n * - `type(element, text)` writes the text into an input or a text area, with an `input` event,\n * - `click(element)` clicks an element, or the first element of a selector.\n * An exception stops the probe, and it counts as a failed check.\n */\nexport function probeExpression(code: string): string {\n return `(async () => {\n const __checks = [];\n const __text = (v) => { if (v === undefined) return undefined; if (typeof v === \"string\") return v; try { return JSON.stringify(v); } catch { return String(v); } };\n const check = (name, ok, detail) => { __checks.push({ name: String(name), ok: !!ok, ...(ok ? {} : { detail: __text(detail) }) }); return !!ok; };\n const wait = (ms) => new Promise((r) => setTimeout(r, ms));\n const until = async (fn, ms = 5000) => { const end = Date.now() + ms; for (;;) { const v = await fn(); if (v) return v; if (Date.now() > end) return v; await wait(50); } };\n const $ = (s) => document.querySelector(s);\n const $$ = (s) => [...document.querySelectorAll(s)];\n const __el = (e) => { const el = typeof e === \"string\" ? document.querySelector(e) : e; if (!el) throw new Error(\"no element: \" + e); return el; };\n const type = (e, text) => { const el = __el(e); el.focus(); el.value = text; el.dispatchEvent(new Event(\"input\", { bubbles: true })); el.dispatchEvent(new Event(\"change\", { bubbles: true })); };\n const click = (e) => __el(e).click();\n try {\n await (async () => {\n${code}\n })();\n } catch (e) {\n __checks.push({ name: \"the probe runs to its end\", ok: false, detail: String((e && e.stack) || e) });\n }\n return __checks;\n})()`;\n}\n","/**\n * A static file server for the `check` command. It serves a built site folder at the path of the\n * site home, as GitHub Pages does. Thus the links of the site work as on the live site.\n */\n\nimport { createReadStream, existsSync, statSync } from \"node:fs\";\nimport { createServer, type Server } from \"node:http\";\nimport { extname, join, normalize, resolve, sep } from \"node:path\";\n\nconst TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".wasm\": \"application/wasm\",\n \".txt\": \"text/plain; charset=utf-8\",\n \".md\": \"text/markdown; charset=utf-8\",\n \".xml\": \"application/xml\",\n \".webmanifest\": \"application/manifest+json\",\n \".map\": \"application/json; charset=utf-8\",\n};\n\n/**\n * This function maps the path of a request to a file of the folder, as GitHub Pages does. A folder\n * gives its `index.html`. For a path with no extension, the function also tries `<path>.html`.\n *\n * @returns the absolute file, or undefined when the path is outside the base or the file is missing\n */\nexport function resolveFile(root: string, base: string, pathname: string): string | undefined {\n let decoded: string;\n try {\n decoded = decodeURIComponent(pathname);\n } catch {\n return undefined;\n }\n const home = base.endsWith(\"/\") ? base : `${base}/`;\n if (decoded === home.slice(0, -1)) decoded = home;\n if (!decoded.startsWith(home)) return undefined;\n const top = resolve(root);\n const file = normalize(join(top, decoded.slice(home.length)));\n if (file !== top && !file.startsWith(top + sep)) return undefined;\n const candidates = [file, join(file, \"index.html\"), `${file}.html`];\n return candidates.find((candidate) => existsSync(candidate) && statSync(candidate).isFile());\n}\n\n/** A started server. */\nexport interface StaticServer {\n /** The URL of the site home, for example `http://127.0.0.1:50123/client/`. */\n url: string;\n close(): Promise<void>;\n}\n\n/**\n * This function serves the folder at `base` on a free port of 127.0.0.1. A missing file gives the\n * status 404 with the `404.html` of the folder, when it has one.\n */\nexport async function serve(root: string, base: string): Promise<StaticServer> {\n const server: Server = createServer((request, response) => {\n const pathname = new URL(request.url ?? \"/\", \"http://localhost\").pathname;\n const home = base.endsWith(\"/\") ? base : `${base}/`;\n if (pathname === home.slice(0, -1) && home !== \"/\") {\n response.writeHead(301, { location: home }).end();\n return;\n }\n const file = resolveFile(root, base, pathname);\n const missing = join(resolve(root), \"404.html\");\n const send = file ?? (existsSync(missing) ? missing : undefined);\n if (send === undefined) {\n response.writeHead(404, { \"content-type\": \"text/plain; charset=utf-8\" }).end(`404: ${pathname}\\n`);\n return;\n }\n response.writeHead(file ? 200 : 404, { \"content-type\": TYPES[extname(send).toLowerCase()] ?? \"application/octet-stream\", \"cache-control\": \"no-store\" });\n createReadStream(send).pipe(response);\n });\n await new Promise<void>((done, fail) => {\n server.once(\"error\", fail);\n server.listen(0, \"127.0.0.1\", () => done());\n });\n const address = server.address();\n if (address === null || typeof address === \"string\") throw new Error(\"the server has no port\");\n return {\n url: `http://127.0.0.1:${address.port}${base.endsWith(\"/\") ? base : `${base}/`}`,\n close: () => new Promise((done) => server.close(() => done())),\n };\n}\n","/**\n * The `site-pages check` command. It opens the pages of a built site (or of a live URL) in a\n * headless Chromium at phone and desktop widths, in the light and the dark scheme.\n *\n * A view fails when the page is wider than the screen or an element goes past the right edge. It\n * also fails when a text area hides its text, a box cuts text (`cutProblems`) or the page shows no text. A console error, an\n * exception and a failed request of the site also fail it. A script that does not load and a failed check of the probe\n * fail it too. The command\n * writes a screenshot of each view.\n */\n\nimport { appendFileSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findBrowser, launch, type Page } from \"./browser.ts\";\nimport { MEASURE, probeExpression, type Cut, type Measure, type ProbeCheck } from \"./measure.ts\";\nimport { probeScript, TYPESCRIPT_PROBE } from \"./probe.ts\";\nimport { serve } from \"./serve.ts\";\n\n/** A view narrower than this width in CSS pixels is a phone. */\nexport const PHONE_WIDTH = 768;\n\n/** The options of `checkSite`. */\nexport interface CheckOptions {\n /** The built site folder. Give `out` or `url`. */\n out?: string | undefined;\n /** The path of the site home, for `out`, for example `/client/`. */\n base?: string | undefined;\n /** The URL of a live site home. Give `out` or `url`. */\n url?: string | undefined;\n /** The pages, from the site home, for example `/` and `/releases/`. */\n pages: readonly string[];\n /** The widths in CSS pixels. A width under `PHONE_WIDTH` is a phone. */\n widths: readonly number[];\n /** The color schemes. */\n schemes: readonly (\"light\" | \"dark\")[];\n /** The code of a probe: the body of an async function (see `probeExpression`). It runs on the first page, in the light scheme, at each width. */\n probe?: string | undefined;\n /** The folder for the screenshots, `report.json` and `summary.md`. */\n shots?: string | undefined;\n /** The browser executable. */\n browser?: string | undefined;\n /** The time to wait after the load event, for the scripts of the page. */\n settleMs: number;\n /** The time limit of a page load. */\n timeoutMs: number;\n log?: ((line: string) => void) | undefined;\n}\n\n/** The result of one page at one width and scheme. */\nexport interface ViewResult {\n page: string;\n width: number;\n scheme: \"light\" | \"dark\";\n ok: boolean;\n /** What failed. */\n problems: string[];\n measure?: Measure | undefined;\n probe?: ProbeCheck[] | undefined;\n /** The file of the screenshot. */\n shot?: string | undefined;\n}\n\n/** The result of `checkSite`. */\nexport interface CheckResult {\n ok: boolean;\n url: string;\n browser: string;\n views: ViewResult[];\n}\n\n/**\n * This function gives the problems of the cuts of a view with the given width. A box that clips text is a problem at each width.\n * A table in a box that scrolls is a problem only on a phone. A phone shows no scroll bar, but a desktop shows one.\n * The summary and the log give the page of each problem.\n */\nexport function cutProblems(cuts: readonly Cut[], width: number): string[] {\n const widths = (cut: Cut) => `${cut.element} in ${cut.box}: content of ${cut.scrollWidth} px in a box of ${cut.clientWidth} px, \"${cut.text}\"`;\n return cuts.flatMap((cut) => {\n if (cut.kind === \"clip\") return [`a box cuts text at ${width} px: ${widths(cut)}. Make the content fit, or add data-overflow-ok to the box.`];\n if (width < PHONE_WIDTH) return [`a table goes out of view at ${width} px: ${widths(cut)}. Make the table fit, give the box the class scroll-cue, or add data-overflow-ok to the box.`];\n return [];\n });\n}\n\n/** This function gives the file name part of a page: `/` is `home`, `/releases/` is `releases`. */\nexport function pageSlug(page: string): string {\n const slug = page.replace(/^\\/+|\\/+$/g, \"\").replace(/[^A-Za-z0-9._-]+/g, \"_\");\n return slug === \"\" ? \"home\" : slug;\n}\n\n/**\n * This function checks the site. It starts one browser and, for `out`, one server, and stops both at\n * the end.\n *\n * @throws Error when there is no browser, or the browser does not start\n */\nexport async function checkSite(options: CheckOptions): Promise<CheckResult> {\n const log = options.log ?? (() => {});\n const executable = findBrowser(options.browser);\n if (executable === undefined) throw new Error(\"no Chromium browser was found: give --browser, set SITE_CHECK_BROWSER, or install the Chromium of Playwright\");\n if (options.pages.length === 0) throw new Error(\"no page to check\");\n const server = options.out !== undefined ? await serve(options.out, options.base ?? \"/\") : undefined;\n const home = server?.url ?? options.url;\n if (home === undefined) throw new Error(\"give out or url\");\n const homeUrl = new URL(home.endsWith(\"/\") ? home : `${home}/`);\n const browser = await launch(executable, options.timeoutMs);\n const views: ViewResult[] = [];\n try {\n const { page } = browser;\n const events = watch(page, homeUrl.origin);\n await Promise.all([page.send(\"Page.enable\"), page.send(\"Runtime.enable\"), page.send(\"Network.enable\")]);\n await page.send(\"Page.addScriptToEvaluateOnNewDocument\", { source: LOAD_WATCH });\n if (options.shots) mkdirSync(options.shots, { recursive: true });\n for (const [index, path] of options.pages.entries()) {\n const target = new URL(path.replace(/^\\/+/, \"\"), homeUrl).href;\n for (const width of options.widths) {\n for (const scheme of options.schemes) {\n const withProbe = options.probe !== undefined && index === 0 && scheme === options.schemes[0];\n const view = await checkView(page, events, { target, path, width, scheme, withProbe, options });\n views.push(view);\n log(`${view.ok ? \"PASS\" : \"FAIL\"} ${path} ${width} ${scheme}${view.measure ? ` scrollWidth=${view.measure.scrollWidth} innerWidth=${view.measure.innerWidth}` : \"\"}${view.probe ? ` probe ${view.probe.filter((c) => c.ok).length}/${view.probe.length}` : \"\"}${view.problems.length > 0 ? `\\n - ${view.problems.join(\"\\n - \")}` : \"\"}`);\n }\n }\n }\n } finally {\n await browser.close();\n await server?.close();\n }\n const result: CheckResult = { ok: views.length > 0 && views.every((view) => view.ok), url: homeUrl.href, browser: executable, views };\n if (options.shots) {\n writeFileSync(join(options.shots, \"report.json\"), `${JSON.stringify(result, null, 2)}\\n`);\n writeFileSync(join(options.shots, \"summary.md\"), summary(result));\n }\n return result;\n}\n\n/**\n * A script that each page starts before its own scripts. A script or a style sheet that does not load fires `error` on its\n * element. This script writes that event as a console error. Thus a module script whose imports do not load is a problem too.\n * Such a script throws no exception. Its failed request can go to another origin, for example `node:perf_hooks` in a page bundle.\n */\nexport const LOAD_WATCH = `addEventListener(\"error\", (event) => {\n const element = event.target;\n if (!(element instanceof HTMLScriptElement || element instanceof HTMLLinkElement)) return;\n console.error(\"failed to load \" + element.tagName.toLowerCase() + \": \" + (element.getAttribute(\"src\") ?? element.getAttribute(\"href\") ?? \"(inline)\"));\n}, true);`;\n\n/** The problems that the events of the page gave, since the last `reset`. */\ninterface Events {\n reset(): void;\n problems(): string[];\n}\n\nfunction watch(page: Page, origin: string): Events {\n let problems: string[] = [];\n const urls = new Map<string, string>();\n const own = (url: string) => {\n try {\n const parsed = new URL(url);\n // A browser asks for /favicon.ico on its own, also for a site under a path.\n return parsed.origin === origin && parsed.pathname !== \"/favicon.ico\";\n } catch {\n return false;\n }\n };\n page.on(\"Runtime.exceptionThrown\", (params) => {\n const details = params[\"exceptionDetails\"] as { text?: string; exception?: { description?: string } };\n problems.push(`exception: ${(details.exception?.description ?? details.text ?? \"\").split(\"\\n\")[0]}`);\n });\n page.on(\"Runtime.consoleAPICalled\", (params) => {\n if (params[\"type\"] !== \"error\" && params[\"type\"] !== \"assert\") return;\n const args = (params[\"args\"] as { value?: unknown; description?: string }[]) ?? [];\n problems.push(`console.error: ${args.map((arg) => String(arg.value ?? arg.description ?? \"\")).join(\" \").slice(0, 300)}`);\n });\n page.on(\"Network.requestWillBeSent\", (params) => {\n urls.set(String(params[\"requestId\"]), String((params[\"request\"] as { url: string }).url));\n });\n page.on(\"Network.responseReceived\", (params) => {\n const response = params[\"response\"] as { url: string; status: number };\n if (response.status >= 400 && own(response.url)) problems.push(`HTTP ${response.status}: ${response.url}`);\n });\n page.on(\"Network.loadingFailed\", (params) => {\n const url = urls.get(String(params[\"requestId\"])) ?? \"\";\n // A script of any origin counts: without it, the page does not work.\n if ((own(url) || params[\"type\"] === \"Script\") && params[\"canceled\"] !== true) problems.push(`request failed (${String(params[\"errorText\"])}): ${url}`);\n });\n return {\n reset: () => {\n problems = [];\n },\n problems: () => [...new Set(problems)],\n };\n}\n\ninterface ViewInput {\n target: string;\n path: string;\n width: number;\n scheme: \"light\" | \"dark\";\n withProbe: boolean;\n options: CheckOptions;\n}\n\nasync function checkView(page: Page, events: Events, input: ViewInput): Promise<ViewResult> {\n const { target, path, width, scheme, withProbe, options } = input;\n const view: ViewResult = { page: path, width, scheme, ok: false, problems: [] };\n try {\n await page.send(\"Emulation.setDeviceMetricsOverride\", { width, height: 900, deviceScaleFactor: 1, mobile: width < PHONE_WIDTH });\n await page.send(\"Emulation.setEmulatedMedia\", { features: [{ name: \"prefers-color-scheme\", value: scheme }] });\n events.reset();\n const loaded = page.once(\"Page.loadEventFired\", options.timeoutMs);\n const navigation = (await page.send(\"Page.navigate\", { url: target })) as { errorText?: string };\n if (navigation.errorText) {\n loaded.catch(() => {});\n throw new Error(`the page did not open: ${navigation.errorText}`);\n }\n await loaded;\n await page.evaluate(\"document.fonts ? document.fonts.ready.then(() => true) : true\");\n await new Promise((done) => setTimeout(done, options.settleMs));\n const measure = await page.evaluate<Measure>(MEASURE);\n view.measure = measure;\n // The screen width, not innerWidth: a phone browser can zoom out a page that is too wide.\n if (measure.scrollWidth > width) view.problems.push(`the page is wider than the screen: ${measure.scrollWidth} > ${width}`);\n for (const past of measure.past) view.problems.push(`past the right edge: ${past}`);\n for (const clipped of measure.clipped) view.problems.push(`a text area hides its text: ${clipped}`);\n view.problems.push(...cutProblems(measure.cut, width));\n if (measure.text === 0) view.problems.push(\"the page shows no text\");\n if (options.shots) {\n const file = join(options.shots, `${pageSlug(path)}-${width}-${scheme}.png`);\n const height = Math.min(Math.max(measure.height, 1), 8000);\n const shot = (await page.send(\"Page.captureScreenshot\", { format: \"png\", captureBeyondViewport: true, clip: { x: 0, y: 0, width, height, scale: 1 } })) as { data: string };\n writeFileSync(file, Buffer.from(shot.data, \"base64\"));\n view.shot = file;\n }\n if (withProbe && options.probe !== undefined) {\n const checks = (await page.evaluate<ProbeCheck[] | undefined>(probeExpression(options.probe))) ?? [];\n view.probe = checks;\n if (checks.length === 0) view.problems.push(\"the probe made no check\");\n for (const check of checks.filter((entry) => !entry.ok)) view.problems.push(`probe: ${check.name}${check.detail ? ` (${check.detail})` : \"\"}`);\n }\n } catch (error) {\n view.problems.push(error instanceof Error ? error.message : String(error));\n }\n view.problems.push(...events.problems());\n view.ok = view.problems.length === 0;\n return view;\n}\n\n/** This function makes a text safe for a cell of a Markdown table. It escapes `\\`, `|`, `<` and `>`. It changes each new line to a space. */\nexport function cell(text: string): string {\n return text.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\|/g, \"\\\\|\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\\r?\\n/g, \" \");\n}\n\n/** This function gives the Markdown summary of a result, for the job summary of a workflow. */\nexport function summary(result: CheckResult): string {\n const failed = result.views.filter((view) => !view.ok);\n const lines = [\n `### Site check: ${result.ok ? \"passed\" : \"failed\"}`,\n \"\",\n `${result.views.length - failed.length} of ${result.views.length} views passed, at ${result.url}.`,\n \"\",\n \"| Page | Width | Scheme | Result | Problems |\",\n \"| --- | ---: | --- | --- | --- |\",\n ...result.views.map(\n (view) =>\n `| \\`${view.page}\\` | ${view.width} | ${view.scheme} | ${view.ok ? \"pass\" : \"**fail**\"}${view.probe ? ` (probe ${view.probe.filter((c) => c.ok).length}/${view.probe.length})` : \"\"} | ${view.problems.map(cell).join(\"<br>\")} |`,\n ),\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n\n/** The input and output of the CLI. */\nexport interface CheckIo {\n cwd: string;\n env: NodeJS.ProcessEnv;\n stdout: (text: string) => void;\n stderr: (text: string) => void;\n}\n\nexport const CHECK_HELP = `Usage: site-pages check (--out <dir> | --url <url>) [options]\n\nOpens the pages of the site in a headless Chromium at phone and desktop widths, in the light and\nthe dark scheme, and fails when a page is wider than the screen, an element goes past the right\nedge, a text area hides its text, a box cuts text, a table goes out of view on a phone, a page\nshows no text, or on a console error, an exception, a failed request of the site, a script that\ndoes not load or a failed check of the probe. Add data-overflow-ok to a box that is meant to\nscroll or to clip.\n\nOptions:\n --out <dir> The built site folder. The check serves it at --base.\n --url <url> The URL of a live site home, in place of --out\n --repo <owner/name> The GitHub repository, for the default base (default: $GITHUB_REPOSITORY)\n --base </name/> The path of the site home (default: \"/<name>/\", or \"/\" for <owner>.github.io)\n --pages <paths> The pages, from the site home, separated by commas (default: /)\n --widths <px> The widths, separated by commas (default: 360,400,1280)\n --schemes <list> light, dark or both (default: light,dark)\n --probe <file> A JavaScript file: the body of an async function with check(name, ok, detail),\n wait, until, $, $$, type and click. It runs on the first page, in the first\n scheme, at each width. A .ts, .mts or .cts file is TypeScript: the check\n removes its types and its line export {}.\n --shots <dir> The folder for the screenshots, report.json and summary.md\n --browser <file> The Chromium executable (default: $SITE_CHECK_BROWSER, the Chromium of\n Playwright, else Chrome or Edge)\n --settle <ms> The wait after the load event (default: 1500)\n --timeout <ms> The time limit of a page load (default: 30000)\n --help Shows this text\n\nWith $GITHUB_STEP_SUMMARY, the check adds its table to the job summary.\n`;\n\n/** This function runs the `check` command with its arguments, without the word `check`. */\nexport async function runCheckCli(argv: readonly string[], io: CheckIo): Promise<number> {\n let values: Record<string, string | boolean | undefined>;\n try {\n ({ values } = parseArgs({\n args: [...argv],\n allowPositionals: false,\n options: {\n out: { type: \"string\" },\n url: { type: \"string\" },\n repo: { type: \"string\" },\n base: { type: \"string\" },\n pages: { type: \"string\" },\n widths: { type: \"string\" },\n schemes: { type: \"string\" },\n probe: { type: \"string\" },\n shots: { type: \"string\" },\n browser: { type: \"string\" },\n settle: { type: \"string\" },\n timeout: { type: \"string\" },\n help: { type: \"boolean\" },\n },\n }));\n } catch (error) {\n io.stderr(`site-pages check: ${error instanceof Error ? error.message : String(error)}\\n\\n${CHECK_HELP}`);\n return 2;\n }\n if (values[\"help\"]) {\n io.stdout(CHECK_HELP);\n return 0;\n }\n const usage = (message: string) => {\n io.stderr(`site-pages check: ${message}\\n\\n${CHECK_HELP}`);\n return 2;\n };\n const text = (key: string) => (typeof values[key] === \"string\" ? (values[key] as string) : undefined);\n const list = (key: string, fallback: string) => (text(key) ?? fallback).split(\",\").map((entry) => entry.trim()).filter(Boolean);\n const out = text(\"out\");\n const url = text(\"url\");\n if ((out === undefined) === (url === undefined)) return usage(\"give --out or --url, not both\");\n const widths = list(\"widths\", \"360,400,1280\").map(Number);\n if (widths.length === 0 || widths.some((width) => !Number.isInteger(width) || width < 200 || width > 4000)) return usage(\"--widths must be whole numbers from 200 to 4000\");\n const schemes = list(\"schemes\", \"light,dark\");\n if (schemes.length === 0 || schemes.some((scheme) => scheme !== \"light\" && scheme !== \"dark\")) return usage(\"--schemes must be light, dark or both\");\n const pages = list(\"pages\", \"/\");\n if (pages.length === 0) return usage(\"--pages has no page\");\n // Git Bash changes a bare \"/\" into \"C:/Program Files/Git/\". A page is a path, with no scheme or drive.\n const notPath = pages.find((entry) => entry.includes(\":\") || entry.includes(\"\\\\\"));\n if (notPath !== undefined) return usage(`a page is a path from the site home, not \"${notPath}\" (in Git Bash, set MSYS_NO_PATHCONV=1)`);\n const settleMs = Number(text(\"settle\") ?? 1500);\n const timeoutMs = Number(text(\"timeout\") ?? 30000);\n if (!(settleMs >= 0) || !(timeoutMs > 0)) return usage(\"--settle and --timeout must be numbers of milliseconds\");\n let base = text(\"base\");\n if (out !== undefined && base === undefined) {\n const name = (text(\"repo\") ?? io.env[\"GITHUB_REPOSITORY\"] ?? \"\").split(\"/\")[1];\n if (!name) return usage(\"give --base, --repo or set GITHUB_REPOSITORY\");\n base = /\\.github\\.io$/i.test(name) ? \"/\" : `/${name}/`;\n }\n if (base !== undefined) base = `/${base.replace(/^\\/+|\\/+$/g, \"\")}/`.replace(/^\\/\\/$/, \"/\");\n const at = (file: string) => (isAbsolute(file) ? file : resolve(io.cwd, file));\n const probeFile = text(\"probe\");\n let probe: string | undefined;\n if (probeFile !== undefined) {\n try {\n probe = readFileSync(at(probeFile), \"utf8\");\n } catch (error) {\n return usage(`the probe file ${probeFile} cannot be read: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (TYPESCRIPT_PROBE.test(probeFile)) {\n try {\n probe = probeScript(probe);\n } catch (error) {\n return usage(`the types of the probe file ${probeFile} cannot be removed: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n }\n const shots = text(\"shots\");\n const result = await checkSite({\n out: out === undefined ? undefined : at(out),\n base,\n url,\n pages,\n widths,\n schemes: schemes as (\"light\" | \"dark\")[],\n probe,\n shots: shots === undefined ? undefined : at(shots),\n browser: text(\"browser\"),\n settleMs,\n timeoutMs,\n log: (line) => io.stdout(`${line}\\n`),\n });\n const failed = result.views.filter((view) => !view.ok).length;\n io.stdout(`site-pages check: ${result.views.length - failed} of ${result.views.length} views passed (${result.browser}).\\n`);\n const step = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (step) appendFileSync(step, summary(result));\n return result.ok ? 0 : 1;\n}\n","#!/usr/bin/env node\n// The bin `site-pages`. The work is in build.ts, check/check.ts and check/freshness.ts, so a test can run the same CLI with its own fetch.\nimport { runCli } from \"./build.ts\";\nimport { runCheckCli } from \"./check/check.ts\";\nimport { runFreshnessCli } from \"./check/freshness.ts\";\n\nconst argv = process.argv.slice(2);\nconst io = {\n cwd: process.cwd(),\n env: process.env,\n stdout: (text: string) => process.stdout.write(text),\n stderr: (text: string) => process.stderr.write(text),\n};\n(argv[0] === \"check\" ? runCheckCli(argv.slice(1), io) : argv[0] === \"freshness\" ? runFreshnessCli(argv.slice(1), io) : runCli(argv, io)).then(\n (code) => {\n process.exitCode = code;\n },\n (error: unknown) => {\n process.stderr.write(`site-pages: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\\n`);\n process.exitCode = 1;\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAS,eAAe,UAA2B,KAAkC;CACnF,IAAI,aAAa,SAEf,OADc;EAAC,IAAI;EAAiB,IAAI;EAAsB,IAAI;CAAe,CAAC,CAAC,QAAQ,SAAyB,CAAC,CAAC,IAC3G,CAAC,CAAC,SAAS,SAAS,CAAC,KAAK,MAAM,sCAAsC,GAAG,KAAK,MAAM,uCAAuC,CAAC,CAAC;CAE1I,IAAI,aAAa,UACf,OAAO;EAAC;EAAgE;EAAsD;CAAgE;CAEhM,MAAM,QAAQ;EAAC;EAAiB;EAAwB;EAAY;EAAoB;CAAgB;CACxG,MAAM,QAAQ,IAAI,WAAW,GAAA,CAAI,MAAM,SAAS,CAAC,CAAC,OAAO,OAAO;CAChE,OAAO,MAAM,SAAS,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,IAAI,CAAC,CAAC;AACnE;;AAGA,SAAS,mBAAmB,UAA2B,KAA4C;CACjG,MAAM,OACJ,IAAI,gCACH,aAAa,UAAU,KAAK,IAAI,mBAAmB,QAAQ,GAAG,eAAe,IAAI,aAAa,WAAW,KAAK,QAAQ,GAA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C;CAC9C,OAAO,OAAO,KAAK,IAAI;AACzB;;AClZA,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,KAAK;CACT,KAAK,QAAQ,IAAI;CACjB,KAAK,QAAQ;CACb,SAAS,SAAiB,QAAQ,OAAO,MAAM,IAAI;CACnD,SAAS,SAAiB,QAAQ,OAAO,MAAM,IAAI;AACrD;CACC,KAAK,OAAO,UAAU,YAAY,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,cAAc,gBAAgB,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,OAAO,MAAM,EAAE,EAAA,CAAG,MACtI,SAAS;CACR,QAAQ,WAAW;AACrB,IACC,UAAmB;CAClB,QAAQ,OAAO,MAAM,eAAe,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK,EAAE,GAAG;CAC/G,QAAQ,WAAW;AACrB,CACF"}
package/build/index.d.ts CHANGED
@@ -513,6 +513,79 @@ export declare const TYPESCRIPT_PROBE: RegExp;
513
513
  * that is not only types (an `enum`, a `namespace`) causes an error.
514
514
  */
515
515
  export declare function probeScript(source: string): string;
516
+ /** The schema of a file of data stamps. */
517
+ export declare const DATA_STAMP_SCHEMA = "data-stamp/1";
518
+ /** The largest age of the data of a page, in days, when no newer run is in flight. */
519
+ export declare const MAX_DATA_AGE_DAYS = 3;
520
+ /** The most minor versions that an engine of a run can be behind npm at the start of the run. */
521
+ export declare const MAX_MINORS_BEHIND = 1;
522
+ /** One run that gives the data of a page. */
523
+ interface DataRun {
524
+ readonly id: string;
525
+ readonly url: string;
526
+ /** The ISO time of the start of the run. */
527
+ readonly date: string;
528
+ /** The version of each engine of the run, by its npm name. */
529
+ readonly engines: Readonly<Record<string, string>>;
530
+ }
531
+ /** The stamp of one measured page. */
532
+ interface PageStamp {
533
+ readonly page: string;
534
+ /** Each run that gives data to the page. */
535
+ readonly runs: readonly DataRun[];
536
+ /** The run on newer engines that is in progress. */
537
+ readonly inFlight?: DataRun;
538
+ }
539
+ /** The content of a file of data stamps. */
540
+ interface DataStamps {
541
+ readonly schema: typeof DATA_STAMP_SCHEMA;
542
+ readonly pages: readonly PageStamp[];
543
+ }
544
+ /** The result of `parseDataStamps`. */
545
+ type DataStampsParse = {
546
+ readonly ok: true;
547
+ readonly stamps: DataStamps;
548
+ } | {
549
+ readonly ok: false;
550
+ readonly faults: readonly string[];
551
+ };
552
+ /** The options of `checkFreshness`. */
553
+ interface FreshnessOptions {
554
+ /** The ISO time of the check. */
555
+ readonly now: string;
556
+ /** The publication times of the engines on npm. */
557
+ readonly times: readonly NpmVersionTime[];
558
+ /** The limit of the age. The default is `MAX_DATA_AGE_DAYS`. */
559
+ readonly maxAgeDays?: number;
560
+ /** The limit of the minor versions. The default is `MAX_MINORS_BEHIND`. */
561
+ readonly maxMinorsBehind?: number;
562
+ }
563
+ /** The result of `checkFreshness`. */
564
+ interface FreshnessCheck {
565
+ /** Each break of a rule. One fault fails the gate. */
566
+ readonly faults: readonly string[];
567
+ /** Each rule that the gate could not run, with the reason. */
568
+ readonly notRun: readonly string[];
569
+ }
570
+ /**
571
+ * This function reads the content of a file of data stamps. It gives each fault of the content, so a page with no versions
572
+ * or no run date fails here.
573
+ */
574
+ export declare function parseDataStamps(raw: unknown): DataStampsParse;
575
+ /** This function gives the count of minor versions from `used` to `latest`. A newer major version counts as no limit. */
576
+ export declare function minorsBehind(used: string, latest: string): number;
577
+ /** This function gives the newest stable version of a package on npm at a time, or undefined when npm has none. */
578
+ export declare function latestAt(times: readonly NpmVersionTime[], name: string, date: string): string | undefined;
579
+ /**
580
+ * This function applies the rules of the gate to the stamps.
581
+ *
582
+ * - The data of each page is at most `maxAgeDays` old, or a run on newer engines is in flight.
583
+ * - The engines of the newest run are at most `maxMinorsBehind` behind npm at the start of that run.
584
+ * - A run in flight has the same age limit, so an old stamp does not hold the gate open.
585
+ */
586
+ export declare function checkFreshness(stamps: DataStamps, options: FreshnessOptions): FreshnessCheck;
587
+ /** This function gives the html line of the stamp of a page. A page shows this line with its data. */
588
+ export declare function renderDataStamp(stamp: PageStamp): string;
516
589
  /** An error in the command line. The CLI shows the help and exits with code 2. */
517
590
  export declare class UsageError extends Error {}
518
591
  /** The options of `build`. */
@@ -563,7 +636,7 @@ interface BuildResult {
563
636
  */
564
637
  export declare function build(options: BuildOptions): Promise<BuildResult>;
565
638
  /** The help of the CLI. */
566
- export declare const HELP = "Usage: site-pages build --out <dir> [options]\n\nWrites <out>/data/releases.json, <out>/data/status.json, <out>/releases/index.html\nand <out>/status/index.html. Start it in the repository, after the build of the site.\n\nOptions:\n --out <dir> The built output folder of the site (necessary)\n --repo <owner/name> The GitHub repository (default: $GITHUB_REPOSITORY, else the remote \"origin\")\n --base </name/> The path of the site home (default: \"/<name>/\", or \"/\" for <owner>.github.io)\n --roadmap <file> The roadmap file (default: none, the status page has only the GitHub part)\n --packages <names> npm names or a @scope, separated by commas, for the npm dates\n --changesets <glob> The changelog files (default: packages/*/CHANGELOG.md, else CHANGELOG.md)\n --group <name> The npm name of the package whose changelog gives the versions\n --token <token> A GitHub token with read access (default: $GITHUB_TOKEN)\n --css <file> A CSS file for the pages, after the default CSS\n --site-name <name> The name of the site in the header (default: the repository name)\n --data-only Write only the JSON data, not the pages\n -h, --help Show this help\n\nUsage: site-pages check (--out <dir> | --url <url>) [options]\n\nOpens the pages of the site in a headless Chromium at phone and desktop widths. Start\n\"site-pages check --help\" for its options.\n";
639
+ export declare const HELP = "Usage: site-pages build --out <dir> [options]\n\nWrites <out>/data/releases.json, <out>/data/status.json, <out>/releases/index.html\nand <out>/status/index.html. Start it in the repository, after the build of the site.\n\nOptions:\n --out <dir> The built output folder of the site (necessary)\n --repo <owner/name> The GitHub repository (default: $GITHUB_REPOSITORY, else the remote \"origin\")\n --base </name/> The path of the site home (default: \"/<name>/\", or \"/\" for <owner>.github.io)\n --roadmap <file> The roadmap file (default: none, the status page has only the GitHub part)\n --packages <names> npm names or a @scope, separated by commas, for the npm dates\n --changesets <glob> The changelog files (default: packages/*/CHANGELOG.md, else CHANGELOG.md)\n --group <name> The npm name of the package whose changelog gives the versions\n --token <token> A GitHub token with read access (default: $GITHUB_TOKEN)\n --css <file> A CSS file for the pages, after the default CSS\n --site-name <name> The name of the site in the header (default: the repository name)\n --data-only Write only the JSON data, not the pages\n -h, --help Show this help\n\nUsage: site-pages check (--out <dir> | --url <url>) [options]\n\nOpens the pages of the site in a headless Chromium at phone and desktop widths. Start\n\"site-pages check --help\" for its options.\n\nUsage: site-pages freshness --stamps <file> [options]\n\nExamine the data stamps of the measured pages of a site. See\n\"site-pages freshness --help\" for its options.\n";
567
640
  /** The input and output of `runCli`. A test gives its own values. */
568
641
  interface CliIo {
569
642
  cwd: string;
@@ -584,5 +657,5 @@ export declare function parseBuildArgs(argv: readonly string[], io: Pick<CliIo,
584
657
  * source is not correct, and 2 for an incorrect command line.
585
658
  */
586
659
  export declare function runCli(argv: readonly string[], io: CliIo): Promise<number>;
587
- export { type BoardIssue, type BoardItem, type BoardPullRequest, type BoardSection, type BuildOptions, type BuildResult, type ChangelogEntry, type ChangelogSection, type ChangelogSource, type CheckState, type CliIo, type GitHubOpenWork, type GitHubOptions, type GitHubRelease, type GitHubReleases, type ItemGroup, KPI_FILE, KPI_FORMAT, type KpiEngine, KpiError, type KpiFile, type KpiInput, type KpiMeasure, type Link, type LinkOptions, type MarkdownTable, type NpmOptions, type NpmPublishTimes, type NpmVersionTime, type OpenWorkTotals, type PageOptions, type PageParts, type ParsedVersion, type ReadReleasesOptions, type ReadStatusBoardOptions, type Release, type ReleaseChange, type ReleaseKind, type ReleasePoint, type ReleaseSources, type ReleaseSummary, type StatusBoardData, type StatusBoardInput, type StatusClass, type TagDate, type TagVersion, type TimelineBand, type TimelineLayout, type TimelineMark, type TimelineOptions, kpiFile, kpiProblems, kpiText, readKpi, writeKpi };
660
+ export { type BoardIssue, type BoardItem, type BoardPullRequest, type BoardSection, type BuildOptions, type BuildResult, type ChangelogEntry, type ChangelogSection, type ChangelogSource, type CheckState, type CliIo, type DataRun, type DataStamps, type DataStampsParse, type FreshnessCheck, type FreshnessOptions, type GitHubOpenWork, type GitHubOptions, type GitHubRelease, type GitHubReleases, type ItemGroup, KPI_FILE, KPI_FORMAT, type KpiEngine, KpiError, type KpiFile, type KpiInput, type KpiMeasure, type Link, type LinkOptions, type MarkdownTable, type NpmOptions, type NpmPublishTimes, type NpmVersionTime, type OpenWorkTotals, type PageOptions, type PageParts, type PageStamp, type ParsedVersion, type ReadReleasesOptions, type ReadStatusBoardOptions, type Release, type ReleaseChange, type ReleaseKind, type ReleasePoint, type ReleaseSources, type ReleaseSummary, type StatusBoardData, type StatusBoardInput, type StatusClass, type TagDate, type TagVersion, type TimelineBand, type TimelineLayout, type TimelineMark, type TimelineOptions, kpiFile, kpiProblems, kpiText, readKpi, writeKpi };
588
661
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/versions.ts","../src/data/changelog.ts","../src/data/github.ts","../src/data/npm.ts","../src/data/git.ts","../src/data/glob.ts","../src/data/releases.ts","../src/data/status.ts","../src/render/html.ts","../src/render/dates.ts","../src/render/theme.ts","../src/render/timeline.ts","../src/render/releases.ts","../src/render/status.ts","../src/check/probe.ts","../src/build.ts"],"mappings":";;UAOiB;EACf;EACA;EACA;EACA;;;wBAMc,aAAa,kBAAkB;;;;;;wBAgB/B,gBAAgB,WAAW;;;;;wBA2B3B,OAAO,iBAAiB,kBAAkB;;UASzC;EACf;EACA;;;;;;wBAOc,aAAa,cAAc;;;;;;;UCvE1B;;EAEf;;EAEA;;;UAIe;EACf;;EAEA;EACA,SAAS;;;;;;;;;wBAqBK,cAAc;;;;;;;wBA0Cd,eAAe,mBAAmB;;;;;wBAwClC,mBAAmB,eAAe;;;;;wBAqClC,cAAc;;qBCtJjB;;qBAEA;;UAKI;EACf;EACA;;EAEA;;EAEA,eAAe;;EAEf;;;wBA0Bc,aAAa;EAAU;uBAA6C;;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;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,eAAe;;EAEf;EACA,SAAS;;;UAIM;;EAEf;EACA,UAAU;EACV,QAAQ;;;;;;;;;wBAgBY,MAAM,SAAS,eAAe,QAAQ;;qBA6C/C;;UA0BI;EACf;EACA,KAAK;EACL,SAAS;EACT,SAAS;EACT,eAAe;EACf;;;;;;;wBAQc,eAAe,yBAAyB,IAAI,KAAK,wBAAwB;;;;;wBAiEnE,OAAO,yBAAyB,IAAI,QAAQ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/versions.ts","../src/data/changelog.ts","../src/data/github.ts","../src/data/npm.ts","../src/data/git.ts","../src/data/glob.ts","../src/data/releases.ts","../src/data/status.ts","../src/render/html.ts","../src/render/dates.ts","../src/render/theme.ts","../src/render/timeline.ts","../src/render/releases.ts","../src/render/status.ts","../src/check/probe.ts","../src/check/freshness.ts","../src/render/data-stamp.ts","../src/build.ts"],"mappings":";;UAOiB;EACf;EACA;EACA;EACA;;;wBAMc,aAAa,kBAAkB;;;;;;wBAgB/B,gBAAgB,WAAW;;;;;wBA2B3B,OAAO,iBAAiB,kBAAkB;;UASzC;EACf;EACA;;;;;;wBAOc,aAAa,cAAc;;;;;;;UCvE1B;;EAEf;;EAEA;;;UAIe;EACf;;EAEA;EACA,SAAS;;;;;;;;;wBAqBK,cAAc;;;;;;;wBA0Cd,eAAe,mBAAmB;;;;;wBAwClC,mBAAmB,eAAe;;;;;wBAqClC,cAAc;;qBCtJjB;;qBAEA;;UAKI;EACf;EACA;;EAEA;;EAEA,eAAe;;EAEf;;;wBA0Bc,aAAa;EAAU;uBAA6C;;;;;;wBA4C9D,eAAe,SAAS;EAAkB;EAAmB;IAAmB,QAAQ;;;;;;;;wBAmFxF,eAAe,SAAS;EAAkB;EAAmB;IAAsB,QAAQ;;qBCzKpG;;UAGI;;EAEf;;EAEA,eAAe;EACf;;E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AoB;;;UAGjG;;WAEN;;WAEA,gBAAgB;;WAEhB;;WAEA;;;UAIM;;WAEN;;WAEA;;;;;;wBA0BK,gBAAgB,eAAe;;wBAuB/B,aAAa,cAAc;;wBAS3B,SAAS,gBAAgB,kBAAkB,cAAc;;;;;;;;wBA0BzD,eAAe,QAAQ,YAAY,SAAS,mBAAmB;;wBCzI/D,gBAAgB,OAAO;;qBCA1B,mBAAmB;;UAGf;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,eAAe;;EAEf;EACA,SAAS;;;UAIM;;EAEf;EACA,UAAU;EACV,QAAQ;;;;;;;;;wBAgBY,MAAM,SAAS,eAAe,QAAQ;;qBA6C/C;;UA+BI;EACf;EACA,KAAK;EACL,SAAS;EACT,SAAS;EACT,eAAe;EACf;;;;;;;wBAQc,eAAe,yBAAyB,IAAI,KAAK,wBAAwB;;;;;wBAiEnE,OAAO,yBAAyB,IAAI,QAAQ"}
package/build/index.js CHANGED
@@ -1,3 +1,19 @@
1
- import { $ as checkStateOf, A as safeUrl, B as roadmapItems, C as pageShell, D as utcDay, E as shortDate, F as linksOf, G as mergeReleases, H as statusClassOf, I as markdownTables, J as globFiles, K as readChangelogs, L as parseRoadmap, M as RoadmapParseError, N as STATUS_CLASSES, O as escapeHtml, P as buildStatusBoard, Q as GITHUB_GRAPHQL, R as plainText, S as BASE_CSS, T as longDate, U as DEFAULT_CHANGELOGS, V as splitRow, W as ReleaseDataError, X as npmPublishTimes, Y as NPM_REGISTRY, Z as GITHUB_API, _ as renderReleasesPage, a as runCli, at as releaseBodyEntries, b as releaseSummary, c as STATUS_SCRIPT, ct as parseVersion, d as renderStatusPage, et as githubOpenWork, f as sectionsOf, g as releasesLead, h as RELEASES_SCRIPT, i as parseBuildArgs, it as parseChangelog, j as OPEN_CLASSES, k as inlineMarkdown, l as classCounts, lt as versionOfTag, m as statusLead, n as UsageError, nt as firstSentence, o as TYPESCRIPT_PROBE, ot as compareVersions, p as slugOf, q as readReleases, r as build, rt as headingAnchor, s as probeScript, st as kindOf, t as HELP, tt as githubReleases, u as openGroups, v as laneCenter, w as dayRange, x as timelineLayout, y as oldestFirst, z as readStatusBoard } from "./chunks/build.js";
1
+ import { $ as DEFAULT_CHANGELOGS, A as BASE_CSS, B as safeUrl, C as RELEASES_SCRIPT, D as oldestFirst, E as laneCenter, F as utcDay, G as linksOf, H as RoadmapParseError, I as escapeHtml, J as plainText, K as markdownTables, L as inlineMarkdown, M as dayRange, N as longDate, O as releaseSummary, P as shortDate, Q as statusClassOf, R as link, S as statusLead, T as renderReleasesPage, U as STATUS_CLASSES, V as OPEN_CLASSES, W as buildStatusBoard, X as roadmapItems, Y as readStatusBoard, Z as splitRow, _ as classCounts, _t as kindOf, a as runCli, at as NPM_REGISTRY, b as sectionsOf, c as MAX_MINORS_BEHIND, ct as GITHUB_GRAPHQL, d as minorsBehind, dt as githubReleases, et as ReleaseDataError, f as parseDataStamps, ft as firstSentence, g as STATUS_SCRIPT, gt as compareVersions, h as probeScript, ht as releaseBodyEntries, i as parseBuildArgs, it as globFiles, j as pageShell, k as timelineLayout, l as checkFreshness, lt as checkStateOf, m as TYPESCRIPT_PROBE, mt as parseChangelog, n as UsageError, nt as readChangelogs, o as DATA_STAMP_SCHEMA, ot as npmPublishTimes, pt as headingAnchor, q as parseRoadmap, r as build, rt as readReleases, s as MAX_DATA_AGE_DAYS, st as GITHUB_API, t as HELP, tt as mergeReleases, u as latestAt, ut as githubOpenWork, v as openGroups, vt as parseVersion, w as releasesLead, x as slugOf, y as renderStatusPage, yt as versionOfTag, z as listText } from "./chunks/build.js";
2
2
  import { a as kpiProblems, c as writeKpi, d as headingDate, f as isShallow, i as kpiFile, l as gitTagDates, n as KPI_FORMAT, o as kpiText, p as originRepository, r as KpiError, s as readKpi, t as KPI_FILE, u as headCommit } from "./chunks/kpi.js";
3
- export { BASE_CSS, DEFAULT_CHANGELOGS, GITHUB_API, GITHUB_GRAPHQL, HELP, KPI_FILE, KPI_FORMAT, KpiError, NPM_REGISTRY, OPEN_CLASSES, RELEASES_SCRIPT, ReleaseDataError, RoadmapParseError, STATUS_CLASSES, STATUS_SCRIPT, TYPESCRIPT_PROBE, UsageError, build, buildStatusBoard, checkStateOf, classCounts, compareVersions, dayRange, escapeHtml, firstSentence, gitTagDates, githubOpenWork, githubReleases, globFiles, headCommit, headingAnchor, headingDate, inlineMarkdown, isShallow, kindOf, kpiFile, kpiProblems, kpiText, laneCenter, linksOf, longDate, markdownTables, mergeReleases, npmPublishTimes, oldestFirst, openGroups, originRepository, pageShell, parseBuildArgs, parseChangelog, parseRoadmap, parseVersion, plainText, probeScript, readChangelogs, readKpi, readReleases, readStatusBoard, releaseBodyEntries, releaseSummary, releasesLead, renderReleasesPage, renderStatusPage, roadmapItems, runCli, safeUrl, sectionsOf, shortDate, slugOf, splitRow, statusClassOf, statusLead, timelineLayout, utcDay, versionOfTag, writeKpi };
3
+ // src/render/data-stamp.ts
4
+ /** This function gives an engine and its version in the short form, without the npm scope. */
5
+ function engineText(name, version) {
6
+ return `${name.slice(name.indexOf("/") + 1)} ${version}`;
7
+ }
8
+ /** This function gives the html of one run: a link to the run, the day of its start and each engine. */
9
+ function runHtml(run) {
10
+ const engines = Object.entries(run.engines).map(([name, version]) => escapeHtml(engineText(name, version)));
11
+ return `run ${link(run.url, escapeHtml(run.id))} of ${escapeHtml(run.date.slice(0, 10))}, on ${listText(engines)}`;
12
+ }
13
+ /** This function gives the html line of the stamp of a page. A page shows this line with its data. */
14
+ function renderDataStamp(stamp) {
15
+ return `<p class="data-stamp">${`<span>The data comes from ${listText(stamp.runs.map(runHtml))}.</span>`}${stamp.inFlight === void 0 ? "" : ` <span>A newer run is in flight: ${runHtml(stamp.inFlight)}.</span>`}</p>`;
16
+ }
17
+ export { BASE_CSS, DATA_STAMP_SCHEMA, DEFAULT_CHANGELOGS, GITHUB_API, GITHUB_GRAPHQL, HELP, KPI_FILE, KPI_FORMAT, KpiError, MAX_DATA_AGE_DAYS, MAX_MINORS_BEHIND, NPM_REGISTRY, OPEN_CLASSES, RELEASES_SCRIPT, ReleaseDataError, RoadmapParseError, STATUS_CLASSES, STATUS_SCRIPT, TYPESCRIPT_PROBE, UsageError, build, buildStatusBoard, checkFreshness, checkStateOf, classCounts, compareVersions, dayRange, escapeHtml, firstSentence, gitTagDates, githubOpenWork, githubReleases, globFiles, headCommit, headingAnchor, headingDate, inlineMarkdown, isShallow, kindOf, kpiFile, kpiProblems, kpiText, laneCenter, latestAt, linksOf, longDate, markdownTables, mergeReleases, minorsBehind, npmPublishTimes, oldestFirst, openGroups, originRepository, pageShell, parseBuildArgs, parseChangelog, parseDataStamps, parseRoadmap, parseVersion, plainText, probeScript, readChangelogs, readKpi, readReleases, readStatusBoard, releaseBodyEntries, releaseSummary, releasesLead, renderDataStamp, renderReleasesPage, renderStatusPage, roadmapItems, runCli, safeUrl, sectionsOf, shortDate, slugOf, splitRow, statusClassOf, statusLead, timelineLayout, utcDay, versionOfTag, writeKpi };
18
+
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/render/data-stamp.ts"],"sourcesContent":["/**\n * The line that a measured page shows for its data: the run, its date and its engine versions, and a run in flight.\n */\n\nimport type { DataRun, PageStamp } from \"../check/freshness.ts\";\nimport { escapeHtml, link, listText } from \"./html.ts\";\n\n/** This function gives an engine and its version in the short form, without the npm scope. */\nfunction engineText(name: string, version: string): string {\n return `${name.slice(name.indexOf(\"/\") + 1)} ${version}`;\n}\n\n/** This function gives the html of one run: a link to the run, the day of its start and each engine. */\nfunction runHtml(run: DataRun): string {\n const engines = Object.entries(run.engines).map(([name, version]) => escapeHtml(engineText(name, version)));\n return `run ${link(run.url, escapeHtml(run.id))} of ${escapeHtml(run.date.slice(0, 10))}, on ${listText(engines)}`;\n}\n\n/** This function gives the html line of the stamp of a page. A page shows this line with its data. */\nexport function renderDataStamp(stamp: PageStamp): string {\n const data = `<span>The data comes from ${listText(stamp.runs.map(runHtml))}.</span>`;\n const flight = stamp.inFlight === undefined ? \"\" : ` <span>A newer run is in flight: ${runHtml(stamp.inFlight)}.</span>`;\n return `<p class=\"data-stamp\">${data}${flight}</p>`;\n}\n"],"mappings":";;;;AAQA,SAAS,WAAW,MAAc,SAAyB;CACzD,OAAO,GAAG,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG;AACjD;;AAGA,SAAS,QAAQ,KAAsB;CACrC,MAAM,UAAU,OAAO,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,aAAa,WAAW,WAAW,MAAM,OAAO,CAAC,CAAC;CAC1G,OAAO,OAAO,KAAK,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,EAAE,MAAM,WAAW,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,OAAO,SAAS,OAAO;AACjH;;AAGA,SAAgB,gBAAgB,OAA0B;CAGxD,OAAO,yBAAyB,6BAFU,SAAS,MAAM,KAAK,IAAI,OAAO,CAAC,EAAE,YAC7D,MAAM,aAAa,KAAA,IAAY,KAAK,oCAAoC,QAAQ,MAAM,QAAQ,EAAE,UACjE;AAChD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/site-pages",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "description": "A release timeline page and a live status page for the site of a GitHub repository: JSON data and standalone HTML, made at deploy time.",
6
6
  "keywords": [
7
7
  "github-pages",