@mark1russell7/site-pages 0.2.7 → 0.2.9

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freshness.js","names":[],"sources":["../../src/data/versions.ts","../../src/data/npm.ts","../../src/data/git.ts","../../src/data/kpi.ts","../../src/render/html.ts","../../src/check/freshness.ts"],"sourcesContent":["/**\n * Versions: the SemVer parser, the sort, the kind of a version and the version of a git tag.\n */\n\nimport type { ReleaseKind } from \"./types.ts\";\n\n/** The parts of a SemVer 2.0.0 version. */\nexport interface ParsedVersion {\n major: number;\n minor: number;\n patch: number;\n prerelease: string[];\n}\n\nconst SEMVER = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\n\n/** This function gives the parts of a version, or null when the text is not a SemVer version. */\nexport function parseVersion(version: string): ParsedVersion | null {\n const match = SEMVER.exec(version);\n if (!match) return null;\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: match[4] ? match[4].split(\".\") : [],\n };\n}\n\n/**\n * This function compares two versions by the SemVer precedence. It gives a negative number when `a`\n * is older, a positive number when `a` is newer, and 0 for the same version. A text that is not a\n * version comes before each version.\n */\nexport function compareVersions(a: string, b: string): number {\n const x = parseVersion(a);\n const y = parseVersion(b);\n if (!x || !y) return x ? 1 : y ? -1 : a.localeCompare(b);\n const core = x.major - y.major || x.minor - y.minor || x.patch - y.patch;\n if (core !== 0) return core;\n // A prerelease comes before its release: 1.0.0-rc.1 < 1.0.0\n if (x.prerelease.length === 0 || y.prerelease.length === 0) return y.prerelease.length - x.prerelease.length;\n for (let index = 0; index < Math.max(x.prerelease.length, y.prerelease.length); index++) {\n const p = x.prerelease[index];\n const q = y.prerelease[index];\n if (p === undefined) return -1;\n if (q === undefined) return 1;\n if (p === q) continue;\n const pNumber = /^\\d+$/.test(p);\n const qNumber = /^\\d+$/.test(q);\n if (pNumber && qNumber) return Number(p) - Number(q);\n if (pNumber !== qNumber) return pNumber ? -1 : 1;\n return p < q ? -1 : 1;\n }\n return 0;\n}\n\n/**\n * This function gives the kind of a version. The oldest version of the list is \"first\". The caller\n * tells if the version is the oldest.\n */\nexport function kindOf(version: string, oldest: boolean): ReleaseKind {\n if (oldest) return \"first\";\n const parsed = parseVersion(version);\n if (!parsed) return \"patch\";\n if (parsed.major > 0 && parsed.minor === 0 && parsed.patch === 0) return \"major\";\n return parsed.patch === 0 ? \"minor\" : \"patch\";\n}\n\n/** The version of a git tag, and the package that the tag names (null for a tag like `v1.2.3`). */\nexport interface TagVersion {\n version: string;\n package: string | null;\n}\n\n/**\n * This function reads the version of a git tag. It knows `1.2.3`, `v1.2.3` and the tags of Changesets:\n * `name@1.2.3` and `@scope/name@1.2.3`. It gives null for another tag.\n */\nexport function versionOfTag(tag: string): TagVersion | null {\n const match = /^(?:(.+)@)?v?(\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.+-]*)?)$/.exec(tag.trim());\n if (!match || match[2] === undefined || !parseVersion(match[2])) return null;\n return { version: match[2], package: match[1] ?? null };\n}\n","/**\n * The npm source: the publication time of each version of some packages. The release data uses\n * these times when git and GitHub give no date for a version.\n */\n\nimport type { NpmPublishTimes, NpmVersionTime } from \"./types.ts\";\n\n/** The public npm registry. */\nexport const NPM_REGISTRY = \"https://registry.npmjs.org\";\n\n/** The options of `npmPublishTimes`. */\nexport interface NpmOptions {\n /** The npm names of the packages, or a scope (for example `@procedures`) for all the packages of the scope. */\n packages: readonly string[];\n /** The `fetch` function. The default is the global `fetch`. */\n fetch?: typeof fetch;\n registry?: string;\n /** The time limit of each request, in milliseconds. The default is 15000. */\n timeoutMs?: number;\n}\n\ntype Json = Record<string, unknown>;\nconst object = (value: unknown): Json => (value !== null && typeof value === \"object\" ? (value as Json) : {});\n\nfunction message(error: unknown): string {\n if (object(error)[\"name\"] === \"TimeoutError\") return \"npm did not answer in time\";\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * This function reads the publication time of each version of the packages from the npm registry.\n * A scope (`@name`) gives each package of the scope. It does not throw. Each failure gives a\n * message in `problems`.\n */\nexport async function npmPublishTimes(options: NpmOptions): Promise<NpmPublishTimes> {\n const { registry = NPM_REGISTRY, timeoutMs = 15_000 } = options;\n const fetcher = options.fetch ?? globalThis.fetch;\n const problems: string[] = [];\n const times: NpmVersionTime[] = [];\n if (typeof fetcher !== \"function\") return { times, problems: [\"this Node has no fetch\"] };\n const get = async (url: string): Promise<unknown> => {\n const response = await fetcher(url, { headers: { accept: \"application/json\" }, signal: AbortSignal.timeout(timeoutMs) });\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n return response.json();\n };\n\n const names = new Set<string>();\n for (const entry of options.packages.map((name) => name.trim()).filter(Boolean)) {\n if (!/^@[^/]+$/.test(entry)) {\n names.add(entry);\n continue;\n }\n try {\n const found = object(await get(`${registry}/-/v1/search?text=scope:${encodeURIComponent(entry.slice(1))}&size=250`));\n const objects = Array.isArray(found[\"objects\"]) ? found[\"objects\"] : [];\n const before = names.size;\n for (const item of objects) {\n const name = object(object(item)[\"package\"])[\"name\"];\n if (typeof name === \"string\" && name.startsWith(`${entry}/`)) names.add(name);\n }\n if (names.size === before) problems.push(`npm has no package in the scope ${entry}`);\n } catch (error) {\n problems.push(`npm did not give the packages of ${entry}: ${message(error)}`);\n }\n }\n\n // Four requests at a time\n const queue = [...names].sort();\n const worker = async (): Promise<void> => {\n for (let name = queue.shift(); name !== undefined; name = queue.shift()) {\n try {\n const packument = object(await get(`${registry}/${name.replaceAll(\"/\", \"%2f\")}`));\n const published = object(packument[\"versions\"]);\n for (const [version, date] of Object.entries(object(packument[\"time\"]))) {\n if (version === \"created\" || version === \"modified\" || typeof date !== \"string\") continue;\n if (!(version in published)) continue;\n times.push({ name, version, date });\n }\n } catch (error) {\n problems.push(`npm did not give the versions of ${name}: ${message(error)}`);\n }\n }\n };\n await Promise.all(Array.from({ length: 4 }, worker));\n times.sort((a, b) => a.name.localeCompare(b.name) || a.date.localeCompare(b.date));\n return { times, problems };\n}\n","/**\n * The git source: the tags with their dates, the commit of the build and the GitHub remote. Each\n * function gives an empty result when git or the repository is not available.\n */\n\nimport { execFileSync } from \"node:child_process\";\n\n/** A git tag and the ISO date of its creation. */\nexport interface TagDate {\n tag: string;\n date: string;\n}\n\n/** This function starts git in a folder and gives its output, or null when git fails. */\nexport function git(repoDir: string, ...args: string[]): string | null {\n try {\n return execFileSync(\"git\", args, { cwd: repoDir, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"], windowsHide: true });\n } catch {\n return null;\n }\n}\n\n/** This function tells if the clone is shallow. A shallow clone has not all the tags and commits. */\nexport function isShallow(repoDir: string): boolean {\n return git(repoDir, \"rev-parse\", \"--is-shallow-repository\")?.trim() === \"true\";\n}\n\n/** This function gives each tag of the repository with its date. An annotated tag has its own date. */\nexport function gitTagDates(repoDir: string): TagDate[] {\n const output = git(repoDir, \"for-each-ref\", \"--format=%(refname:strip=2) %(creatordate:iso-strict)\", \"refs/tags\");\n if (!output) return [];\n const tags: TagDate[] = [];\n for (const line of output.split(/\\r?\\n/)) {\n const match = /^(\\S+) (\\S+)$/.exec(line.trim());\n if (match?.[1] && match[2]) tags.push({ tag: match[1], date: match[2] });\n }\n return tags;\n}\n\n/**\n * This function gives the date of the oldest commit that added a version heading to a changelog,\n * or null. The path of the changelog starts at `repoDir`.\n */\nexport function headingDate(repoDir: string, version: string, file: string): string | null {\n const output = git(repoDir, \"log\", \"--format=%cI\", `-S## ${version}`, \"--\", file);\n const dates = (output ?? \"\").trim().split(/\\r?\\n/).filter(Boolean);\n return dates[dates.length - 1] ?? null;\n}\n\n/** This function gives the full SHA of `HEAD`, or null. */\nexport function headCommit(repoDir: string): string | null {\n const sha = git(repoDir, \"rev-parse\", \"HEAD\")?.trim();\n return sha && /^[0-9a-f]{40}$/.test(sha) ? sha : null;\n}\n\n/** This function gives \"owner/name\" of the GitHub remote \"origin\", or null. */\nexport function originRepository(repoDir: string): string | null {\n const url = git(repoDir, \"remote\", \"get-url\", \"origin\")?.trim() ?? \"\";\n const match = /github\\.com[:/]([^/]+)\\/(.+?)(?:\\.git)?\\/?$/.exec(url);\n return match ? `${match[1]}/${match[2]}` : null;\n}\n","/**\n * The file `kpi.json` at the root of a site, format `kpi/1`. A reader outside the site takes the measures of the project\n * from this file. Thus a number on a progress page comes from a record and not from a person.\n *\n * The field `at` is the time of the data and not the time of the build. Thus the writer has no default for it.\n * A measure can have its own `at` when its data is from another time than the rest of the file.\n */\n\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { KpiEngine, KpiFile, KpiMeasure } from \"./types.ts\";\n\n/** The name of the format. A new format gets a new name, so that an old reader refuses it. */\nexport const KPI_FORMAT = \"kpi/1\";\n\n/** The name of the file at the root of the built site. */\nexport const KPI_FILE = \"kpi.json\";\n\n/** The data of `kpi.json`, without the name of the format. */\nexport type KpiInput = Omit<KpiFile, \"format\">;\n\n/** The form of a project and a measure. A double hyphen separates fields in the file name of a reading. */\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** The form of a time in UTC, with or without seconds. */\nconst UTC_TIME = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?Z$/;\n\n/** The form of a full commit. */\nconst COMMIT = /^[0-9a-f]{40}$/;\n\n/** The clock difference between two computers that the check accepts, in milliseconds. */\nconst CLOCK_MARGIN = 5 * 60 * 1000;\n\n/** An error in the data of `kpi.json`. The field `problems` has one line for each fault. */\nexport class KpiError extends Error {\n readonly problems: readonly string[];\n\n constructor(problems: readonly string[]) {\n super(`${KPI_FILE} is not correct: ${problems.join(\" \")}`);\n this.name = \"KpiError\";\n this.problems = problems;\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isText = (value: unknown): value is string => typeof value === \"string\" && value.trim() !== \"\";\n\n/** This function gives the fault of a time of the data, or an empty list. The name tells which field it is. */\nfunction timeProblems(at: unknown, name: string, now: number): string[] {\n if (typeof at !== \"string\" || !UTC_TIME.test(at) || Number.isNaN(Date.parse(at))) return [`${name} is not a time in UTC.`];\n return Date.parse(at) > now + CLOCK_MARGIN ? [`The time of the data ${at} is after the time of the check.`] : [];\n}\n\n/** This function gives the faults of one measure. */\nfunction measureProblems(value: unknown, index: number, seen: Set<string>, now: number): string[] {\n if (!isRecord(value)) return [`Measure ${index} is not an object.`];\n const { id, value: amount, unit, at } = value;\n const problems: string[] = [];\n if (typeof id !== \"string\" || !SLUG.test(id)) problems.push(`Measure ${index} has no id of lowercase words with single hyphens.`);\n else if (seen.has(id)) problems.push(`The id ${id} occurs two times.`);\n else seen.add(id);\n if (typeof amount !== \"number\" || !Number.isFinite(amount)) problems.push(`Measure ${index} has no finite number as its value.`);\n if (unit !== undefined && !isText(unit)) problems.push(`Measure ${index} has a unit that is not a text.`);\n if (at !== undefined) problems.push(...timeProblems(at, `The field at of measure ${index}`, now));\n return problems;\n}\n\n/** This function gives the faults of the list of engines. */\nfunction engineProblems(value: unknown): string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) return [\"The field engines is not a list.\"];\n return value.flatMap((engine: unknown, index) => (isRecord(engine) && isText(engine[\"name\"]) && isText(engine[\"version\"]) ? [] : [`Engine ${index} has no name and version.`]));\n}\n\n/**\n * This function gives the faults of a parsed `kpi.json`, or an empty list.\n *\n * @param value - The parsed file.\n * @param now - The time of the check, in milliseconds. A time of the data after this time is a fault.\n */\nexport function kpiProblems(value: unknown, now: number = Date.now()): string[] {\n if (!isRecord(value)) return [\"The file is not an object.\"];\n const problems: string[] = [];\n if (value[\"format\"] !== KPI_FORMAT) problems.push(`The format is not ${KPI_FORMAT}.`);\n const { project, at, commit, measures } = value;\n if (typeof project !== \"string\" || !SLUG.test(project)) problems.push(\"The project is not lowercase words with single hyphens.\");\n problems.push(...timeProblems(at, \"The field at\", now));\n if (typeof commit !== \"string\" || !COMMIT.test(commit)) problems.push(\"The commit is not a full commit.\");\n if (!Array.isArray(measures) || measures.length === 0) problems.push(\"The file has no measures.\");\n else {\n const seen = new Set<string>();\n problems.push(...measures.flatMap((measure: unknown, index) => measureProblems(measure, index, seen, now)));\n }\n problems.push(...engineProblems(value[\"engines\"]));\n return problems;\n}\n\n/** This function gives a copy of a measure with only its known fields. */\nfunction cleanMeasure({ id, value, unit, at }: KpiMeasure): KpiMeasure {\n return { id, value, ...(unit === undefined ? {} : { unit }), ...(at === undefined ? {} : { at }) };\n}\n\n/** This function gives a copy of an engine with only its known fields. */\nfunction cleanEngine({ name, version }: KpiEngine): KpiEngine {\n return { name, version };\n}\n\n/**\n * This function gives the checked content of `kpi.json`. The file has only its known fields, in a fixed order.\n *\n * @throws KpiError when the data is not correct\n */\nexport function kpiFile(input: KpiInput, now?: number): KpiFile {\n const problems = kpiProblems({ format: KPI_FORMAT, ...input }, now);\n if (problems.length > 0) throw new KpiError(problems);\n const { project, at, commit, measures, engines } = input;\n const file: KpiFile = { format: KPI_FORMAT, project, at, commit, measures: measures.map(cleanMeasure) };\n return engines === undefined ? file : { ...file, engines: engines.map(cleanEngine) };\n}\n\n/** This function gives the text of `kpi.json`. */\nexport function kpiText(file: KpiFile): string {\n return `${JSON.stringify(file, null, 2)}\\n`;\n}\n\n/**\n * This function reads the text of a `kpi.json`.\n *\n * @throws KpiError when the text is not correct\n */\nexport function readKpi(text: string, now?: number): KpiFile {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch (error) {\n throw new KpiError([`The file is not JSON: ${error instanceof Error ? error.message : String(error)}`]);\n }\n const problems = kpiProblems(value, now);\n if (problems.length > 0) throw new KpiError(problems);\n const { project, at, commit, measures, engines } = value as KpiFile;\n return kpiFile(engines === undefined ? { project, at, commit, measures } : { project, at, commit, measures, engines }, now);\n}\n\n/**\n * This function writes `kpi.json` into the built output folder of a site, and gives the path of the file.\n *\n * @throws KpiError when the data is not correct\n */\nexport function writeKpi(out: string, input: KpiInput, now?: number): string {\n const text = kpiText(kpiFile(input, now));\n mkdirSync(out, { recursive: true });\n const file = join(out, KPI_FILE);\n writeFileSync(file, text);\n return file;\n}\n","/**\n * The HTML helpers of the pages: the escape functions and a small inline Markdown renderer.\n */\n\nconst ESCAPES: Record<string, string> = { \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\", '\"': \"&quot;\", \"'\": \"&#39;\" };\n\n/** This function escapes a text for HTML content and for an attribute value in double quotes. */\nexport function escapeHtml(text: string): string {\n return String(text).replace(/[&<>\"']/g, (char) => ESCAPES[char] ?? char);\n}\n\n/**\n * This function removes the control characters and the spaces (U+0000 to U+0020) at the two ends\n * of a text. A loop does it, because the regular expression `[\\u0000- ]+$` backtracks. For a long\n * run of these characters, its time grows with the square of the length.\n */\nfunction trimControl(text: string): string {\n let start = 0;\n let end = text.length;\n while (start < end && text.charCodeAt(start) <= 0x20) start++;\n while (end > start && text.charCodeAt(end - 1) <= 0x20) end--;\n return text.slice(start, end);\n}\n\n/**\n * This function gives a URL that a link can hold, or null. It accepts `http:`, `https:` and\n * `mailto:` URLs, and relative URLs. It refuses each other scheme, for example `javascript:`.\n *\n * The URL parser of a browser removes each tab and line break, and the control characters and\n * spaces at the two ends. This function removes them before the scheme check, as the browser does.\n * Thus a control character before `javascript:` does not hide the scheme.\n */\nexport function safeUrl(url: string): string | null {\n const trimmed = trimControl(url.trim().replace(/[\\t\\n\\r]/g, \"\"));\n if (/^(?:https?:|mailto:)/i.test(trimmed)) return trimmed;\n // A browser reads \"\\\" as \"/\" in a URL of the page, so \"\\\\host\" and \"/\\host\" go to a different host, as \"//host\" does\n if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || /^[/\\\\]{2}/.test(trimmed)) return null;\n return trimmed;\n}\n\n/** This function gives an `<a>` element, or the escaped text when the URL is not safe. */\nexport function link(url: string, html: string, attributes = \"\"): string {\n const href = safeUrl(url);\n return href === null ? html : `<a href=\"${escapeHtml(href)}\"${attributes ? ` ${attributes}` : \"\"}>${html}</a>`;\n}\n\n/** The emphasis of a text without code spans or links. The text is already escaped. */\nfunction emphasis(escaped: string): string {\n return escaped\n .replace(/\\*\\*([^*]+?)\\*\\*/g, \"<strong>$1</strong>\")\n .replace(/(^|[^\\w*])\\*([^*\\s][^*]*?)\\*(?![\\w*])/g, \"$1<em>$2</em>\")\n .replace(/(^|[^\\w])_([^_\\s][^_]*?)_(?![\\w])/g, \"$1<em>$2</em>\");\n}\n\nconst INLINE = \"`([^`]+)`|\\\\[((?:[^\\\\]`]|`[^`]*`)+)\\\\]\\\\(([^)\\\\s]+)\\\\)\";\n\n/**\n * This function renders inline Markdown as HTML: code spans, links, strong text and emphasis. It\n * escapes all other text, so the result is safe.\n */\nexport function inlineMarkdown(markdown: string): string {\n const text = String(markdown ?? \"\");\n // A new expression for each call: the text of a link is rendered with a recursive call\n const pattern = new RegExp(INLINE, \"g\");\n let html = \"\";\n let last = 0;\n for (let match = pattern.exec(text); match; match = pattern.exec(text)) {\n html += emphasis(escapeHtml(text.slice(last, match.index)));\n if (match[1] !== undefined) html += `<code>${escapeHtml(match[1])}</code>`;\n else html += link(match[3] ?? \"\", inlineMarkdown(match[2] ?? \"\"));\n last = match.index + match[0].length;\n }\n return html + emphasis(escapeHtml(text.slice(last)));\n}\n\n/** This function gives \"1 item\" or \"2 items\". */\nexport function plural(count: number, word: string, many = `${word}s`): string {\n return `${count} ${count === 1 ? word : many}`;\n}\n\n/** This function gives \"a\", \"a and b\" or \"a, b and c\". */\nexport function listText(parts: readonly string[]): string {\n if (parts.length <= 1) return parts.join(\"\");\n return `${parts.slice(0, -1).join(\", \")} and ${parts[parts.length - 1]}`;\n}\n","/**\n * The freshness gate of a measured page. A site keeps a file of data stamps.\n * Each stamp names the page, its runs, their dates and their engine versions.\n * The gate fails on a page with no versions or no run date, and on old data with no newer run in flight.\n * The gate also fails on a run that started behind the engines on npm.\n * A fixed study has no age limit. A page with a longer limit names the reason and the scheduled workflow that meets the limit.\n * This file imports only Node.js and the folder `data`, so `reusable-pages.yml` starts it with no npm release of the package.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { isAbsolute, join } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { npmPublishTimes } from \"../data/npm.ts\";\nimport type { NpmVersionTime } from \"../data/types.ts\";\nimport { compareVersions, parseVersion } from \"../data/versions.ts\";\nimport type { CheckIo } from \"./check.ts\";\n\n/** The schema of a file of data stamps. */\nexport const DATA_STAMP_SCHEMA = \"data-stamp/1\";\n\n/** The largest age of the data of a page, in days, when no newer run is in flight. */\nexport const MAX_DATA_AGE_DAYS = 3;\n\n/** The most minor versions that an engine of a run can be behind npm at the start of the run. */\nexport const MAX_MINORS_BEHIND = 1;\n\n/** The longest limit of a page, in days, with no ruling for that site. */\nexport const MAX_LIMIT_DAYS_WITHOUT_RULING = 14;\n\nconst DAY_MS = 86_400_000;\n\n/** One run that gives the data of a page. */\nexport interface DataRun {\n readonly id: string;\n readonly url: string;\n /** The ISO time of the start of the run. */\n readonly date: string;\n /** The version of each engine of the run, by its npm name. */\n readonly engines: Readonly<Record<string, string>>;\n}\n\n/** The age limit of one page, in place of `MAX_DATA_AGE_DAYS`. */\nexport interface DataLimit {\n /** The largest age of the data, in days. */\n readonly days: number;\n /** The reason for the limit, as one sentence. The page shows it. */\n readonly reason: string;\n /** The path of the workflow from the root of the repository. Its schedule must meet the limit. */\n readonly workflow: string;\n /** The link to the public ruling. A limit over `MAX_LIMIT_DAYS_WITHOUT_RULING` needs it. */\n readonly ruling?: string;\n}\n\n/** The stamp of one measured page. */\nexport interface PageStamp {\n readonly page: string;\n /** Each run that gives data to the page. */\n readonly runs: readonly DataRun[];\n /** The run on newer engines that is in progress. */\n readonly inFlight?: DataRun;\n /** The page shows a fixed study of the versions of its runs, so its data has no age limit. It makes no claim about a newer release. */\n readonly study?: true;\n /** The age limit of this page, in place of the default. */\n readonly limit?: DataLimit;\n}\n\n/** The content of a file of data stamps. */\nexport interface DataStamps {\n readonly schema: typeof DATA_STAMP_SCHEMA;\n readonly pages: readonly PageStamp[];\n}\n\n/** The result of `parseDataStamps`. */\nexport type DataStampsParse = { readonly ok: true; readonly stamps: DataStamps } | { readonly ok: false; readonly faults: readonly string[] };\n\n/** The options of `checkFreshness`. */\nexport interface FreshnessOptions {\n /** The ISO time of the check. */\n readonly now: string;\n /** The publication times of the engines on npm. */\n readonly times: readonly NpmVersionTime[];\n /** The limit of the age. The default is `MAX_DATA_AGE_DAYS`. */\n readonly maxAgeDays?: number;\n /** The limit of the minor versions. The default is `MAX_MINORS_BEHIND`. */\n readonly maxMinorsBehind?: number;\n /** The schedule of each workflow of a limit. A number is the largest gap between its starts in days. A text tells why the gate cannot read it. */\n readonly schedules?: Readonly<Record<string, number | string>>;\n}\n\n/** The result of `checkFreshness`. */\nexport interface FreshnessCheck {\n /** Each break of a rule. One fault fails the gate. */\n readonly faults: readonly string[];\n /** Each rule that the gate could not run, with the reason. */\n readonly notRun: readonly string[];\n}\n\nconst record = (value: unknown): Record<string, unknown> | null => (value !== null && typeof value === \"object\" && !Array.isArray(value) ? (value as Record<string, unknown>) : null);\n\n/** This function gives the faults of one run of a stamp. */\nfunction runFaults(raw: unknown, at: string): string[] {\n const run = record(raw);\n if (run === null) return [`${at}: a run is not an object.`];\n const faults: string[] = [];\n if (typeof run[\"id\"] !== \"string\" || run[\"id\"] === \"\") faults.push(`${at}: a run has no id.`);\n const label = `${at}, run ${String(run[\"id\"])}`;\n if (typeof run[\"url\"] !== \"string\" || !run[\"url\"].startsWith(\"https://\")) faults.push(`${label}: the run has no https link.`);\n if (typeof run[\"date\"] !== \"string\" || !Number.isFinite(Date.parse(run[\"date\"]))) faults.push(`${label}: the run has no date.`);\n const engines = record(run[\"engines\"]);\n if (engines === null || Object.keys(engines).length === 0) return [...faults, `${label}: the run names no engine versions.`];\n for (const [name, version] of Object.entries(engines)) {\n if (typeof version !== \"string\" || parseVersion(version) === null) faults.push(`${label}: the version of ${name} is not a version.`);\n }\n return faults;\n}\n\n/** This function gives the faults of the age limit of one page. */\nfunction limitFaults(raw: unknown, at: string): string[] {\n const limit = record(raw);\n if (limit === null) return [`${at}: the limit is not an object.`];\n const faults: string[] = [];\n const days = limit[\"days\"];\n if (typeof days !== \"number\" || !Number.isFinite(days) || days <= 0) faults.push(`${at}: the limit has no count of days.`);\n if (typeof limit[\"reason\"] !== \"string\" || limit[\"reason\"].trim() === \"\") faults.push(`${at}: the limit has no reason.`);\n if (typeof limit[\"workflow\"] !== \"string\" || limit[\"workflow\"] === \"\") faults.push(`${at}: the limit names no workflow.`);\n const ruling = limit[\"ruling\"];\n if (ruling !== undefined && (typeof ruling !== \"string\" || !ruling.startsWith(\"https://\"))) faults.push(`${at}: the ruling of the limit has no https link.`);\n if (typeof days === \"number\" && days > MAX_LIMIT_DAYS_WITHOUT_RULING && ruling === undefined) {\n faults.push(`${at}: a limit over ${MAX_LIMIT_DAYS_WITHOUT_RULING} days needs a ruling for this site.`);\n }\n return faults;\n}\n\n/** This function gives the faults of the fields of a page that change the age rule. */\nfunction ageRuleFaults(page: Record<string, unknown>, at: string): string[] {\n const faults: string[] = [];\n const study = page[\"study\"];\n if (study !== undefined && study !== true) faults.push(`${at}: the field study is not true.`);\n if (study === true && page[\"limit\"] !== undefined) faults.push(`${at}: a fixed study has no limit.`);\n if (study === true && page[\"inFlight\"] !== undefined) faults.push(`${at}: a fixed study has no run in flight.`);\n if (page[\"limit\"] !== undefined) faults.push(...limitFaults(page[\"limit\"], at));\n return faults;\n}\n\n/**\n * This function reads the content of a file of data stamps. It gives each fault of the content, so a page with no versions\n * or no run date fails here.\n */\nexport function parseDataStamps(raw: unknown): DataStampsParse {\n const file = record(raw);\n if (file === null) return { ok: false, faults: [\"The file is not an object.\"] };\n if (file[\"schema\"] !== DATA_STAMP_SCHEMA) return { ok: false, faults: [`The schema is not ${DATA_STAMP_SCHEMA}.`] };\n const pages = file[\"pages\"];\n if (!Array.isArray(pages) || pages.length === 0) return { ok: false, faults: [\"The file has no pages.\"] };\n const faults: string[] = [];\n for (const item of pages) {\n const page = record(item);\n if (page === null || typeof page[\"page\"] !== \"string\" || page[\"page\"] === \"\") {\n faults.push(\"A stamp has no page.\");\n continue;\n }\n const at = page[\"page\"];\n const runs = page[\"runs\"];\n if (!Array.isArray(runs) || runs.length === 0) faults.push(`${at}: the page names no run.`);\n else for (const run of runs) faults.push(...runFaults(run, at));\n if (page[\"inFlight\"] !== undefined) faults.push(...runFaults(page[\"inFlight\"], `${at}, in flight`));\n faults.push(...ageRuleFaults(page, at));\n }\n return faults.length > 0 ? { ok: false, faults } : { ok: true, stamps: raw as DataStamps };\n}\n\n/** This function gives the count of minor versions from `used` to `latest`. A newer major version counts as no limit. */\nexport function minorsBehind(used: string, latest: string): number {\n const a = parseVersion(used);\n const b = parseVersion(latest);\n if (a === null || b === null) return Number.POSITIVE_INFINITY;\n if (a.major !== b.major) return b.major > a.major ? Number.POSITIVE_INFINITY : 0;\n return Math.max(0, b.minor - a.minor);\n}\n\n/** This function gives the newest stable version of a package on npm at a time, or undefined when npm has none. */\nexport function latestAt(times: readonly NpmVersionTime[], name: string, date: string): string | undefined {\n const limit = Date.parse(date);\n return times\n .filter((t) => t.name === name && Date.parse(t.date) <= limit && parseVersion(t.version)?.prerelease.length === 0)\n .map((t) => t.version)\n .sort(compareVersions)\n .at(-1);\n}\n\nconst ageInDays = (date: string, now: number): number => (now - Date.parse(date)) / DAY_MS;\n\n/** This function gives the values of one field of a cron line, or undefined for a form that it cannot read. */\nfunction cronValues(field: string, low: number, high: number): Set<number> | undefined {\n const values = new Set<number>();\n for (const part of field.split(\",\")) {\n const match = /^(\\*|\\d+(?:-\\d+)?)(?:\\/(\\d+))?$/.exec(part);\n if (match === null) return undefined;\n const [, range = \"\", step = \"1\"] = match;\n const [from = low, to = from] = range === \"*\" ? [low, high] : range.split(\"-\").map(Number);\n const by = Number(step);\n if (by <= 0 || from < low || to > high || from > to) return undefined;\n for (let value = from; value <= to; value += by) values.add(value);\n }\n return values;\n}\n\n/** This function gives the start of each day of a cron line, in a span of two years. It gives undefined for a line that it cannot read. */\nfunction cronDays(line: string, from: number, days: number): number[] | undefined {\n const fields = line.trim().split(/\\s+/);\n if (fields.length !== 5) return undefined;\n const [minute = \"\", hour = \"\", dayOfMonth = \"\", month = \"\", dayOfWeek = \"\"] = fields;\n const minutes = cronValues(minute, 0, 59);\n const hours = cronValues(hour, 0, 23);\n const monthDays = cronValues(dayOfMonth, 1, 31);\n const months = cronValues(month, 1, 12);\n const weekDays = cronValues(dayOfWeek, 0, 6);\n if (minutes === undefined || hours === undefined || monthDays === undefined || months === undefined || weekDays === undefined) return undefined;\n const firstTime = (Math.min(...hours) * 60 + Math.min(...minutes)) * 60_000;\n const starts: number[] = [];\n for (let day = 0; day < days; day += 1) {\n const time = from + day * DAY_MS;\n const date = new Date(time);\n if (!months.has(date.getUTCMonth() + 1)) continue;\n const onMonthDay = monthDays.has(date.getUTCDate());\n const onWeekDay = weekDays.has(date.getUTCDay());\n // A cron line that sets both day fields starts on a day that matches one of them.\n const both = dayOfMonth !== \"*\" && dayOfWeek !== \"*\";\n if (both ? onMonthDay || onWeekDay : onMonthDay && onWeekDay) starts.push(time + firstTime);\n }\n return starts;\n}\n\n/** This function gives the cron text of one line of a workflow in a list, or an empty list for another line. */\nfunction cronLine(line: string): string[] {\n const text = line.trim().replace(/^- */, \"\");\n if (!text.startsWith(\"cron:\")) return [];\n const value = text.slice(\"cron:\".length).split(\"#\")[0]?.trim() ?? \"\";\n return [value.replaceAll('\"', \"\").replaceAll(\"'\", \"\")];\n}\n\n/**\n * This function gives the largest gap between the scheduled starts of a workflow, in days. The gap counts from the first start of a day.\n * It gives a text in place of the gap for a workflow with no schedule, and for a line that it cannot read. The text names the line, and the gate fails on it.\n */\nexport function scheduleGapDays(workflow: string): number | string {\n const lines = workflow.split(\"\\n\").flatMap(cronLine);\n if (lines.length === 0) return \"the workflow has no line `cron:`\";\n const from = Date.UTC(2027, 0, 1);\n const span = 731;\n const starts: number[] = [];\n for (const line of lines) {\n const days = cronDays(line, from, span);\n if (days === undefined) return `the gate cannot read the line \\`cron: ${line}\\``;\n starts.push(...days);\n }\n if (starts.length < 2) return `the lines \\`cron: ${lines.join(\"`, `cron: \")}\\` give fewer than two starts in two years`;\n starts.sort((a, b) => a - b);\n let largest = 0;\n for (let index = 1; index < starts.length; index += 1) largest = Math.max(largest, ((starts[index] ?? 0) - (starts[index - 1] ?? 0)) / DAY_MS);\n return largest;\n}\n\n/** This function tells if a run uses a newer version of an engine than another run. */\nfunction hasNewerEngine(run: DataRun, than: DataRun): boolean {\n return Object.entries(run.engines).some(([name, version]) => {\n const old = than.engines[name];\n return old !== undefined && compareVersions(version, old) > 0;\n });\n}\n\n/**\n * This function applies the rules of the gate to the stamps.\n *\n * - The data of each page is at most `maxAgeDays` old, or a run on newer engines is in flight.\n * - The engines of the newest run are at most `maxMinorsBehind` behind npm at the start of that run.\n * - A run in flight has the same age limit, so an old stamp does not hold the gate open.\n * - A page with its own limit uses that limit, and the schedule of its workflow meets the limit.\n * - A fixed study has no age limit and no limit of the engines, because it tells about the versions that it names.\n */\nexport function checkFreshness(stamps: DataStamps, options: FreshnessOptions): FreshnessCheck {\n const { times, maxAgeDays: defaultAge = MAX_DATA_AGE_DAYS, maxMinorsBehind = MAX_MINORS_BEHIND, schedules = {} } = options;\n const now = Date.parse(options.now);\n const faults: string[] = [];\n const notRun: string[] = [];\n for (const stamp of stamps.pages) {\n for (const run of [...stamp.runs, ...(stamp.inFlight === undefined ? [] : [stamp.inFlight])]) {\n if (ageInDays(run.date, now) < 0) faults.push(`${stamp.page}: the run ${run.id} has a date after the check.`);\n }\n if (stamp.study === true) continue;\n const maxAgeDays = stamp.limit?.days ?? defaultAge;\n if (stamp.limit !== undefined) {\n const gap = schedules[stamp.limit.workflow];\n if (gap === undefined || typeof gap === \"string\") faults.push(`${stamp.page}: the limit of ${maxAgeDays} days has no schedule that the gate can read in ${stamp.limit.workflow}: ${gap ?? \"the check has no read of this workflow\"}.`);\n else if (gap > maxAgeDays) faults.push(`${stamp.page}: the schedule of ${stamp.limit.workflow} has a gap of ${gap.toFixed(1)} days, over the limit of ${maxAgeDays}.`);\n }\n const flight = stamp.inFlight;\n const flying = flight !== undefined && ageInDays(flight.date, now) <= maxAgeDays;\n if (flight !== undefined && !flying) faults.push(`${stamp.page}: the run ${flight.id} is in flight for more than ${maxAgeDays} days.`);\n for (const run of stamp.runs) {\n const age = ageInDays(run.date, now);\n if (age > maxAgeDays && !(flying && hasNewerEngine(flight, run))) {\n faults.push(`${stamp.page}: the run ${run.id} is ${age.toFixed(1)} days old, over the limit of ${maxAgeDays}, and no run on newer engines is in flight.`);\n }\n }\n const newest = flight ?? [...stamp.runs].sort((a, b) => Date.parse(a.date) - Date.parse(b.date)).at(-1);\n if (newest === undefined) continue;\n for (const [name, version] of Object.entries(newest.engines)) {\n const latest = latestAt(times, name, newest.date);\n if (latest === undefined) {\n notRun.push(`${stamp.page}: npm gives no version of ${name} at the start of the run ${newest.id}.`);\n } else if (minorsBehind(version, latest) > maxMinorsBehind) {\n faults.push(`${stamp.page}: the run ${newest.id} used ${name} ${version}, and npm had ${latest} at its start. The limit is ${maxMinorsBehind} minor version behind.`);\n }\n }\n }\n return { faults, notRun };\n}\n\n/** The help of the command `site-pages freshness`. */\nexport const FRESHNESS_HELP: string = `Usage: site-pages freshness --stamps <file> [options]\n\nExamine the data stamps of the measured pages of a site.\n\n --stamps <file> The file of data stamps, schema ${DATA_STAMP_SCHEMA}. (necessary)\n --now <time> The ISO time of the check. The default is the time of the call.\n --help Show this text.\n\nThe exit code is 0 when the stamps pass, 1 for a fault, and 2 for an incorrect command line.\n`;\n\n/** This function gives the largest gap of the schedule in a workflow file. It gives a text for a file that it cannot read. */\nfunction readSchedule(path: string): number | string {\n try {\n return scheduleGapDays(readFileSync(path, \"utf8\"));\n } catch (error) {\n return `the file cannot be read: ${error instanceof Error ? error.message : String(error)}`;\n }\n}\n\n/** This function is the command `site-pages freshness`. The `fetch` option is for a test. */\nexport async function runFreshnessCli(argv: readonly string[], io: CheckIo, fetcher?: typeof fetch): Promise<number> {\n let values: { stamps?: string | undefined; now?: string | undefined; help?: boolean | undefined };\n try {\n ({ values } = parseArgs({ args: [...argv], allowPositionals: false, options: { stamps: { type: \"string\" }, now: { type: \"string\" }, help: { type: \"boolean\" } } }));\n } catch (error) {\n io.stderr(`site-pages freshness: ${error instanceof Error ? error.message : String(error)}\\n\\n${FRESHNESS_HELP}`);\n return 2;\n }\n if (values.help === true) {\n io.stdout(FRESHNESS_HELP);\n return 0;\n }\n if (values.stamps === undefined) {\n io.stderr(`site-pages freshness: --stamps is necessary.\\n\\n${FRESHNESS_HELP}`);\n return 2;\n }\n const path = isAbsolute(values.stamps) ? values.stamps : join(io.cwd, values.stamps);\n let raw: unknown;\n try {\n raw = JSON.parse(readFileSync(path, \"utf8\"));\n } catch (error) {\n io.stderr(`site-pages freshness: the file ${values.stamps} cannot be read: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n const parsed = parseDataStamps(raw);\n if (!parsed.ok) {\n for (const fault of parsed.faults) io.stderr(`${fault}\\n`);\n return 1;\n }\n const engines = parsed.stamps.pages\n .filter((p) => p.study !== true)\n .flatMap((p) => [...p.runs, ...(p.inFlight === undefined ? [] : [p.inFlight])])\n .flatMap((r) => Object.keys(r.engines));\n const schedules: Record<string, number | string> = {};\n for (const page of parsed.stamps.pages) {\n if (page.limit !== undefined) schedules[page.limit.workflow] = readSchedule(join(io.cwd, page.limit.workflow));\n }\n const npm = await npmPublishTimes({ packages: [...new Set(engines)], ...(fetcher === undefined ? {} : { fetch: fetcher }) });\n const result = checkFreshness(parsed.stamps, { now: values.now ?? new Date().toISOString(), times: npm.times, schedules });\n for (const problem of [...npm.problems, ...result.notRun]) io.stdout(`Not run: ${problem}\\n`);\n for (const fault of result.faults) io.stderr(`${fault}\\n`);\n if (result.faults.length > 0) return 1;\n io.stdout(`The data stamps of ${parsed.stamps.pages.length} pages pass.\\n`);\n return 0;\n}\n"],"mappings":";;;;;AAcA,MAAM,SAAS;;AAGf,SAAgB,aAAa,SAAuC;CAClE,MAAM,QAAQ,OAAO,KAAK,OAAO;CACjC,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO;EACL,OAAO,OAAO,MAAM,EAAE;EACtB,OAAO,OAAO,MAAM,EAAE;EACtB,OAAO,OAAO,MAAM,EAAE;EACtB,YAAY,MAAM,KAAK,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;CAChD;AACF;;;;;;AAOA,SAAgB,gBAAgB,GAAW,GAAmB;CAC5D,MAAM,IAAI,aAAa,CAAC;CACxB,MAAM,IAAI,aAAa,CAAC;CACxB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,cAAc,CAAC;CACvD,MAAM,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE;CACnE,IAAI,SAAS,GAAG,OAAO;CAEvB,IAAI,EAAE,WAAW,WAAW,KAAK,EAAE,WAAW,WAAW,GAAG,OAAO,EAAE,WAAW,SAAS,EAAE,WAAW;CACtG,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,IAAI,EAAE,WAAW,QAAQ,EAAE,WAAW,MAAM,GAAG,SAAS;EACvF,MAAM,IAAI,EAAE,WAAW;EACvB,MAAM,IAAI,EAAE,WAAW;EACvB,IAAI,MAAM,KAAA,GAAW,OAAO;EAC5B,IAAI,MAAM,KAAA,GAAW,OAAO;EAC5B,IAAI,MAAM,GAAG;EACb,MAAM,UAAU,QAAQ,KAAK,CAAC;EAC9B,MAAM,UAAU,QAAQ,KAAK,CAAC;EAC9B,IAAI,WAAW,SAAS,OAAO,OAAO,CAAC,IAA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AAO,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG;EACzD,OAAO;CACT;CACA,MAAM,UAAU,OAAO,OAAO,MAC3B,QAAQ,MAAM,EAAE,UAAU,IAAI,CAAC,CAC/B,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,GAAI,EAAE,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAE,CAAC,CAAC,CAC9E,SAAS,MAAM,OAAO,KAAK,EAAE,OAAO,CAAC;CACxC,MAAM,YAA6C,CAAC;CACpD,KAAK,MAAM,QAAQ,OAAO,OAAO,OAC/B,IAAI,KAAK,UAAU,KAAA,GAAW,UAAU,KAAK,MAAM,YAAY,aAAa,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,CAAC;CAE/G,MAAM,MAAM,MAAM,gBAAgB;EAAE,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;EAAG,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,QAAQ;CAAG,CAAC;CAC3H,MAAM,SAAS,eAAe,OAAO,QAAQ;EAAE,KAAK,OAAO,wBAAO,IAAI,KAAK,EAAA,CAAE,YAAY;EAAG,OAAO,IAAI;EAAO;CAAU,CAAC;CACzH,KAAK,MAAM,WAAW,CAAC,GAAG,IAAI,UAAU,GAAG,OAAO,MAAM,GAAG,GAAG,OAAO,YAAY,QAAQ,GAAG;CAC5F,KAAK,MAAM,SAAS,OAAO,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG;CACzD,IAAI,OAAO,OAAO,SAAS,GAAG,OAAO;CACrC,GAAG,OAAO,sBAAsB,OAAO,OAAO,MAAM,OAAO,eAAe;CAC1E,OAAO;AACT"}
package/build/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as runCli, h as probeScript, m as TYPESCRIPT_PROBE, p as runFreshnessCli } from "./chunks/build.js";
2
+ import { l as runFreshnessCli } from "./chunks/freshness.js";
3
+ import { a as runCli, o as TYPESCRIPT_PROBE, s as probeScript } from "./chunks/build.js";
3
4
  import { spawn } from "node:child_process";
4
5
  import { appendFileSync, createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
5
6
  import { delimiter, extname, isAbsolute, join, normalize, resolve, sep } from "node:path";
@@ -503,8 +504,11 @@ const LOAD_WATCH = `addEventListener("error", (event) => {
503
504
  if (!(element instanceof HTMLScriptElement || element instanceof HTMLLinkElement)) return;
504
505
  console.error("failed to load " + element.tagName.toLowerCase() + ": " + (element.getAttribute("src") ?? element.getAttribute("href") ?? "(inline)"));
505
506
  }, true);`;
507
+ /** This expression reads the pattern of the paths that other sites of the origin serve. An empty text means no pattern. */
508
+ const OTHER_PATHS = `document.querySelector('meta[name="site-check-other-paths"]')?.content ?? ""`;
506
509
  function watch(page, origin) {
507
510
  let problems = [];
511
+ let refused = [];
508
512
  const urls = /* @__PURE__ */ new Map();
509
513
  const own = (url) => {
510
514
  try {
@@ -528,7 +532,7 @@ function watch(page, origin) {
528
532
  });
529
533
  page.on("Network.responseReceived", (params) => {
530
534
  const response = params["response"];
531
- if (response.status >= 400 && own(response.url)) problems.push(`HTTP ${response.status}: ${response.url}`);
535
+ if (response.status >= 400 && own(response.url)) refused.push(response);
532
536
  });
533
537
  page.on("Network.loadingFailed", (params) => {
534
538
  const url = urls.get(String(params["requestId"])) ?? "";
@@ -537,8 +541,12 @@ function watch(page, origin) {
537
541
  return {
538
542
  reset: () => {
539
543
  problems = [];
544
+ refused = [];
540
545
  },
541
- problems: () => [...new Set(problems)]
546
+ problems: (other) => {
547
+ const shown = refused.filter((response) => other?.test(new URL(response.url).pathname) !== true);
548
+ return [.../* @__PURE__ */ new Set([...problems, ...shown.map((response) => `HTTP ${response.status}: ${response.url}`)])];
549
+ }
542
550
  };
543
551
  }
544
552
  async function checkView(page, events, input) {
@@ -550,6 +558,7 @@ async function checkView(page, events, input) {
550
558
  ok: false,
551
559
  problems: []
552
560
  };
561
+ let other;
553
562
  try {
554
563
  await page.send("Emulation.setDeviceMetricsOverride", {
555
564
  width,
@@ -571,6 +580,8 @@ async function checkView(page, events, input) {
571
580
  await loaded;
572
581
  await page.evaluate("document.fonts ? document.fonts.ready.then(() => true) : true");
573
582
  await new Promise((done) => setTimeout(done, options.settleMs));
583
+ const pattern = await page.evaluate(OTHER_PATHS);
584
+ if (pattern !== "") other = new RegExp(pattern);
574
585
  const measure = await page.evaluate(MEASURE);
575
586
  view.measure = measure;
576
587
  if (measure.scrollWidth > width) view.problems.push(`the page is wider than the screen: ${measure.scrollWidth} > ${width}`);
@@ -604,7 +615,7 @@ async function checkView(page, events, input) {
604
615
  } catch (error) {
605
616
  view.problems.push(error instanceof Error ? error.message : String(error));
606
617
  }
607
- view.problems.push(...events.problems());
618
+ view.problems.push(...events.problems(other));
608
619
  view.ok = view.problems.length === 0;
609
620
  return view;
610
621
  }
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, 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,IA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/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/** This expression reads the pattern of the paths that other sites of the origin serve. An empty text means no pattern. */\nconst OTHER_PATHS = `document.querySelector('meta[name=\"site-check-other-paths\"]')?.content ?? \"\"`;\n\n/** The problems that the events of the page gave, since the last `reset`. */\ninterface Events {\n reset(): void;\n /** This function gives the problems. A refused request to a path that `other` matches is not a problem. */\n problems(other?: RegExp): string[];\n}\n\nfunction watch(page: Page, origin: string): Events {\n let problems: string[] = [];\n let refused: { url: string; status: number }[] = [];\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)) refused.push(response);\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 refused = [];\n },\n problems: (other) => {\n const shown = refused.filter((response) => other?.test(new URL(response.url).pathname) !== true);\n return [...new Set([...problems, ...shown.map((response) => `HTTP ${response.status}: ${response.url}`)])];\n },\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 let other: RegExp | undefined;\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 pattern = await page.evaluate<string>(OTHER_PATHS);\n if (pattern !== \"\") other = new RegExp(pattern);\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(other));\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,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