@mark1russell7/site-pages 0.6.0 → 0.7.1

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.
@@ -1,4 +1,4 @@
1
- import { _ as listText, g as link, m as escapeHtml } from "./freshness.js";
1
+ import { b as link, v as escapeHtml, x as listText } from "./freshness.js";
2
2
  // src/render/data-stamp.ts
3
3
  const DAY_MS = 864e5;
4
4
  /** This function gives an engine and its version in the short form, without the npm scope. */
@@ -479,6 +479,39 @@ function listText(parts) {
479
479
  if (parts.length <= 1) return parts.join("");
480
480
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
481
481
  }
482
+ // src/render/icon.ts
483
+ /**
484
+ * The icon of a site page.
485
+ *
486
+ * A page with no icon link makes the browser ask for `/favicon.ico`. A project site on GitHub Pages has no such file.
487
+ * Thus the console of each page shows a 404 error, and a check of the page errors counts it.
488
+ */
489
+ /** The SVG of the default icon: a page with a folded corner on a square of the accent color of the pages. */
490
+ const SITE_ICON_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><rect width=\"32\" height=\"32\" rx=\"7\" fill=\"#2346c4\"/><path d=\"M10 7h8l5 5v13H10z\" fill=\"#fff\"/><path d=\"M18 7v5h5z\" fill=\"#e7ecfd\"/></svg>";
491
+ /**
492
+ * The `href` of the default icon: a data URL of `SITE_ICON_SVG`. The icon needs no file and no request.
493
+ *
494
+ * The value is a literal, not a request of `encodeURIComponent` when the module loads. A bundle that does not use the icon
495
+ * then drops it. conventions bundles this package. A request here changes the build of conventions, and then it needs a release.
496
+ * A test checks that the literal is the data URL of `SITE_ICON_SVG`.
497
+ */
498
+ const SITE_ICON_HREF = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2032%2032%22%3E%3Crect%20width%3D%2232%22%20height%3D%2232%22%20rx%3D%227%22%20fill%3D%22%232346c4%22%2F%3E%3Cpath%20d%3D%22M10%207h8l5%205v13H10z%22%20fill%3D%22%23fff%22%2F%3E%3Cpath%20d%3D%22M18%207v5h5z%22%20fill%3D%22%23e7ecfd%22%2F%3E%3C%2Fsvg%3E";
499
+ /**
500
+ * This function tells if an HTML page has an icon link: a `link` element with the word `icon` in its `rel`.
501
+ * `rel="icon"` and `rel="shortcut icon"` count. `rel="apple-touch-icon"` does not count, because a browser that reads only
502
+ * that link still asks for `/favicon.ico`.
503
+ */
504
+ function hasIconLink(html) {
505
+ for (const [tag] of html.matchAll(/<link\b[^>]*>/gi)) {
506
+ const rel = /\srel\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i.exec(tag);
507
+ if ((rel?.[1] ?? rel?.[2] ?? rel?.[3] ?? "").toLowerCase().split(/\s+/).includes("icon")) return true;
508
+ }
509
+ return false;
510
+ }
511
+ /** This function gives the `link` element of an icon, for the `head` of a page. The default is the icon of `SITE_ICON_HREF`. */
512
+ function iconLink(href = SITE_ICON_HREF) {
513
+ return `<link rel="icon" href="${escapeHtml(href)}">`;
514
+ }
482
515
  // src/check/freshness.ts
483
516
  /**
484
517
  * The freshness gate of a measured page. A site keeps a file of data stamps.
@@ -872,6 +905,6 @@ async function runFreshnessCli(argv, io, fetcher) {
872
905
  } else io.stdout(`Failing case at ${at}: ${fault}\n`);
873
906
  return held ? 0 : 1;
874
907
  }
875
- export { headCommit as A, versionOfTag as B, kpiFile as C, writeKpi as D, readKpi as E, NPM_REGISTRY as F, npmPublishTimes as I, compareVersions as L, isShallow as M, originRepository as N, git as O, versionCommitTime as P, kindOf as R, KpiError as S, kpiText as T, listText as _, MAX_MINORS_BEHIND as a, KPI_FILE as b, cronLines as c, minorsBehind as d, parseDataStamps as f, link as g, inlineMarkdown as h, MAX_LIMIT_DAYS_WITHOUT_RULING as i, headingDate as j, gitTagDates as k, failingCases as l, escapeHtml as m, LAST_LIMIT_START as n, MAX_STUDY_LIMIT_DAYS as o, runFreshnessCli as p, MAX_DATA_AGE_DAYS as r, checkFreshness as s, DATA_STAMP_SCHEMA as t, latestAt as u, plural as v, kpiProblems as w, KPI_FORMAT as x, safeUrl as y, parseVersion as z };
908
+ export { readKpi as A, npmPublishTimes as B, safeUrl as C, kpiFile as D, KpiError as E, headingDate as F, kindOf as H, isShallow as I, originRepository as L, git as M, gitTagDates as N, kpiProblems as O, headCommit as P, versionCommitTime as R, plural as S, KPI_FORMAT as T, parseVersion as U, compareVersions as V, versionOfTag as W, iconLink as _, MAX_MINORS_BEHIND as a, link as b, cronLines as c, minorsBehind as d, parseDataStamps as f, hasIconLink as g, SITE_ICON_SVG as h, MAX_LIMIT_DAYS_WITHOUT_RULING as i, writeKpi as j, kpiText as k, failingCases as l, SITE_ICON_HREF as m, LAST_LIMIT_START as n, MAX_STUDY_LIMIT_DAYS as o, runFreshnessCli as p, MAX_DATA_AGE_DAYS as r, checkFreshness as s, DATA_STAMP_SCHEMA as t, latestAt as u, escapeHtml as v, KPI_FILE as w, listText as x, inlineMarkdown as y, NPM_REGISTRY as z };
876
909
 
877
910
  //# sourceMappingURL=freshness.js.map
@@ -1 +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/**\n * This function gives the ISO time of the last commit that changed the `version` line of a `package.json`, or null. The\n * path of the file starts at `repoDir`. A shallow clone can give a later commit, so use the full history. A change of\n * only the comma of that line also counts as a change of the line.\n */\nexport function versionCommitTime(repoDir: string, file: string): string | null {\n return git(repoDir, \"log\", \"-1\", \"--format=%cI\", '-G^\\\\s*\"version\":', \"HEAD\", \"--\", file)?.trim() || 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 the date of a target. */\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\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 tells if a text is a real calendar date in the form `YYYY-MM-DD`. */\nfunction isDate(value: unknown): value is string {\n if (typeof value !== \"string\" || !DATE.test(value)) return false;\n const time = Date.parse(`${value}T00:00:00Z`);\n return !Number.isNaN(time) && new Date(time).toISOString().slice(0, 10) === value;\n}\n\n/** This function gives the faults of the targets of one measure. Each date comes after the date before it. */\nfunction targetProblems(value: unknown, index: number): string[] {\n if (!Array.isArray(value) || value.length === 0) return [`Measure ${index} has a field targets that is not a list with a target.`];\n const problems: string[] = [];\n let last: string | undefined;\n value.forEach((target: unknown, at) => {\n const name = `Target ${at} of measure ${index}`;\n if (!isRecord(target)) {\n problems.push(`${name} is not an object.`);\n return;\n }\n const { value: amount, by } = target;\n if (typeof amount !== \"number\" || !Number.isFinite(amount) || amount < 0) problems.push(`${name} has no finite value of 0 or more.`);\n if (!isDate(by)) problems.push(`${name} has no date of the form YYYY-MM-DD in its field by.`);\n else {\n if (last !== undefined && by <= last) problems.push(`${name} has the date ${by}, which is not after the date ${last} before it.`);\n last = by;\n }\n });\n return problems;\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, notCounted, targets } = 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 if (notCounted !== undefined && !isText(notCounted)) problems.push(`Measure ${index} has a field notCounted that is not a text.`);\n if (targets !== undefined) problems.push(...targetProblems(targets, index));\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, notCounted, targets }: KpiMeasure): KpiMeasure {\n return {\n id,\n value,\n ...(unit === undefined ? {} : { unit }),\n ...(at === undefined ? {} : { at }),\n ...(notCounted === undefined ? {} : { notCounted }),\n ...(targets === undefined ? {} : { targets: targets.map(({ value: planned, by }) => ({ value: planned, by })) }),\n };\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 study has an age limit and a scheduled workflow, or it says why it needs no limit. A page with a longer limit names the reason and the workflow.\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\n/** The longest limit of a study, in days, also with a ruling. A study over `MAX_LIMIT_DAYS_WITHOUT_RULING` also needs a ruling. */\nexport const MAX_STUDY_LIMIT_DAYS = 30;\n\n/** The last time at which a limit can start. A limit turns on at this time if its site did not turn it on before. */\nexport const LAST_LIMIT_START = \"2026-12-07T00:00:00Z\";\n\nconst DAY_MS = 86_400_000;\n\n/** The form of a full commit. */\nconst FULL_COMMIT = /^[0-9a-f]{40}$/;\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 /** The words for data that no CI run made, for example `lab run` or `hand count`. The page shows them in place of `run`. */\n readonly method?: string;\n /** The full commit of the code that ran. It is not the commit that added a copy of the data. A study with a limit in force needs it. */\n readonly commit?: 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 /** The ISO time at which the age rule and the commit rule start, at most `LAST_LIMIT_START`. A site removes this field at the first green read of its workflow. */\n readonly startsAt?: string;\n}\n\n/** The two statements of a study with no age limit. The page shows both. */\nexport interface NoAgeLimit {\n /** The reason that no run of the current code can reproduce the numbers. */\n readonly reproduce: string;\n /** The reason that the page claims nothing about today. */\n readonly today: 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 study of the versions of its runs. A study has a `limit` or the field `noLimit`, and the rule of the engines does not apply to it. */\n readonly study?: true;\n /** The age limit of this page, in place of the default. */\n readonly limit?: DataLimit;\n /** The statements of a study with no age limit. */\n readonly noLimit?: NoAgeLimit;\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/** The form of a two-part image tag, for example `7.4`. A fixed study can name it, because no check compares the versions of a study. */\nconst IMAGE_TAG = /^\\d+\\.\\d+$/;\n\n/** This function gives the faults of one run of a stamp. */\nfunction runFaults(raw: unknown, at: string, study = false): 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 if (run[\"method\"] !== undefined && (typeof run[\"method\"] !== \"string\" || run[\"method\"].trim() === \"\")) faults.push(`${label}: the method of the run is not text.`);\n if (run[\"commit\"] !== undefined && (typeof run[\"commit\"] !== \"string\" || !FULL_COMMIT.test(run[\"commit\"]))) faults.push(`${label}: the commit of the run is not a full commit.`);\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 const known = typeof version === \"string\" && (parseVersion(version) !== null || (study && IMAGE_TAG.test(version)));\n if (!known) 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, study: boolean): 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 if (study && typeof days === \"number\" && days > MAX_STUDY_LIMIT_DAYS) faults.push(`${at}: the limit of a study is at most ${MAX_STUDY_LIMIT_DAYS} days.`);\n const startsAt = limit[\"startsAt\"];\n if (startsAt !== undefined) {\n if (typeof startsAt !== \"string\" || !Number.isFinite(Date.parse(startsAt))) faults.push(`${at}: the start of the limit has no date.`);\n else if (Date.parse(startsAt) > Date.parse(LAST_LIMIT_START)) faults.push(`${at}: the start of the limit is after ${LAST_LIMIT_START.slice(0, 10)}.`);\n }\n return faults;\n}\n\n/** This function gives the faults of the statements of a study with no age limit. */\nfunction noLimitFaults(raw: unknown, at: string): string[] {\n const statements = record(raw);\n if (statements === null) return [`${at}: the field noLimit is not an object.`];\n const faults: string[] = [];\n const said = (value: unknown): boolean => typeof value === \"string\" && value.trim() !== \"\";\n if (!said(statements[\"reproduce\"])) faults.push(`${at}: the field noLimit does not say why no run of the current code can reproduce the numbers.`);\n if (!said(statements[\"today\"])) faults.push(`${at}: the field noLimit does not say why the page claims nothing about today.`);\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 const limit = page[\"limit\"];\n const noLimit = page[\"noLimit\"];\n if (study === true && limit === undefined && noLimit === undefined) faults.push(`${at}: a study needs a limit, or the field noLimit.`);\n if (limit !== undefined && noLimit !== undefined) faults.push(`${at}: a page has a limit or the field noLimit, not both.`);\n if (study !== true && noLimit !== undefined) faults.push(`${at}: only a study has the field noLimit.`);\n if (study === true && page[\"inFlight\"] !== undefined) faults.push(`${at}: a study has no run in flight.`);\n if (limit !== undefined) faults.push(...limitFaults(limit, at, study === true));\n if (noLimit !== undefined) faults.push(...noLimitFaults(noLimit, 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, page[\"study\"] === true));\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/** One schedule of a workflow. */\nexport interface CronLine {\n /** The number of the line in the file, from 1. */\n readonly line: number;\n /** The cron text, with no quotes and no comment. */\n readonly cron: string;\n}\n\n/**\n * This function gives each line `cron:` of a workflow. It is the one reader of these lines: the freshness gate and the rule `runner-budget` of conventions use it.\n * It skips a comment line. It reads a quoted key, a list item, a quoted value and a comment at the end of the line.\n */\nexport function cronLines(workflow: string): CronLine[] {\n return workflow.split(/\\r?\\n/).flatMap((raw, index) => {\n const text = raw.trim().replace(/^- */, \"\");\n const key = [\"cron:\", '\"cron\":', \"'cron':\"].find((form) => text.startsWith(form));\n if (key === undefined) return [];\n // YAML starts a comment at a \"#\" after a space or a tab.\n const rest = text.slice(key.length);\n const comment = rest.search(/\\s#/);\n const value = (comment >= 0 ? rest.slice(0, comment) : rest).trim();\n const quote = value.charAt(0);\n const quoted = value.length >= 2 && (quote === '\"' || quote === \"'\") && value.endsWith(quote);\n return [{ line: index + 1, cron: quoted ? value.slice(1, -1).trim() : value }];\n });\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 = cronLines(workflow).map((item) => item.cron);\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 study has no limit of the engines, because it tells about the versions that it names.\n * - A study with a limit in force names the commit of each run. A study with no limit has no age rule.\n * - A limit with `startsAt` applies the age rule and the commit rule from that time. The schedule rule applies at once.\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 && stamp.limit === undefined) continue;\n const maxAgeDays = stamp.limit?.days ?? defaultAge;\n const startsAt = stamp.limit?.startsAt;\n const inForce = startsAt === undefined || Date.parse(startsAt) <= now;\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 (inForce && 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 if (stamp.study === true) {\n if (inForce) for (const run of stamp.runs) if (run.commit === undefined) faults.push(`${stamp.page}: the run ${run.id} names no commit.`);\n continue;\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/** A time at which the gate must fail for a page, and what the gate says at that time. */\nexport interface FailingCase {\n /** The path of the page. */\n readonly page: string;\n /** The ISO time of the case. */\n readonly at: string;\n /** The first fault at that time. A case with no fault tells that the gate does not hold the page. */\n readonly fault?: string;\n}\n\n/**\n * This function gives one failing case for each page, from the stamps of the site itself. A measured page must fail one\n * day after its limit, from `options.now` or the start of the limit. A study with no limit must fail before the date of its run.\n * Stamps that pass and give a case with no fault tell that the gate does not examine that page.\n */\nexport function failingCases(stamps: DataStamps, options: FreshnessOptions): readonly FailingCase[] {\n return stamps.pages.map((stamp) => {\n const dates = [...stamp.runs, ...(stamp.inFlight === undefined ? [] : [stamp.inFlight])].map((run) => Date.parse(run.date));\n const days = stamp.limit?.days ?? options.maxAgeDays ?? MAX_DATA_AGE_DAYS;\n const from = Math.max(Date.parse(options.now), Date.parse(stamp.limit?.startsAt ?? options.now));\n const time = stamp.study === true && stamp.limit === undefined ? Math.min(...dates) - DAY_MS : from + (days + 1) * DAY_MS;\n const at = new Date(time).toISOString();\n const [fault] = checkFreshness({ schema: stamps.schema, pages: [stamp] }, { ...options, now: at }).faults;\n return { page: stamp.page, at, ...(fault === undefined ? {} : { fault }) };\n });\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.\nStamps that pass also show one failing case for each page. A page with no failing case is a fault.\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 options: FreshnessOptions = { now: values.now ?? new Date().toISOString(), times: npm.times, schedules };\n const result = checkFreshness(parsed.stamps, options);\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} ${parsed.stamps.pages.length === 1 ? \"page\" : \"pages\"} pass.\\n`);\n let held = true;\n for (const { page, at, fault } of failingCases(parsed.stamps, options)) {\n if (fault === undefined) {\n io.stderr(`${page}: the gate does not fail at ${at}, so it does not hold this page.\\n`);\n held = false;\n } else {\n io.stdout(`Failing case at ${at}: ${fault}\\n`);\n }\n }\n return held ? 0 : 1;\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,E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AAI;AACpB"}
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/render/icon.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/**\n * This function gives the ISO time of the last commit that changed the `version` line of a `package.json`, or null. The\n * path of the file starts at `repoDir`. A shallow clone can give a later commit, so use the full history. A change of\n * only the comma of that line also counts as a change of the line.\n */\nexport function versionCommitTime(repoDir: string, file: string): string | null {\n return git(repoDir, \"log\", \"-1\", \"--format=%cI\", '-G^\\\\s*\"version\":', \"HEAD\", \"--\", file)?.trim() || 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 the date of a target. */\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\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 tells if a text is a real calendar date in the form `YYYY-MM-DD`. */\nfunction isDate(value: unknown): value is string {\n if (typeof value !== \"string\" || !DATE.test(value)) return false;\n const time = Date.parse(`${value}T00:00:00Z`);\n return !Number.isNaN(time) && new Date(time).toISOString().slice(0, 10) === value;\n}\n\n/** This function gives the faults of the targets of one measure. Each date comes after the date before it. */\nfunction targetProblems(value: unknown, index: number): string[] {\n if (!Array.isArray(value) || value.length === 0) return [`Measure ${index} has a field targets that is not a list with a target.`];\n const problems: string[] = [];\n let last: string | undefined;\n value.forEach((target: unknown, at) => {\n const name = `Target ${at} of measure ${index}`;\n if (!isRecord(target)) {\n problems.push(`${name} is not an object.`);\n return;\n }\n const { value: amount, by } = target;\n if (typeof amount !== \"number\" || !Number.isFinite(amount) || amount < 0) problems.push(`${name} has no finite value of 0 or more.`);\n if (!isDate(by)) problems.push(`${name} has no date of the form YYYY-MM-DD in its field by.`);\n else {\n if (last !== undefined && by <= last) problems.push(`${name} has the date ${by}, which is not after the date ${last} before it.`);\n last = by;\n }\n });\n return problems;\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, notCounted, targets } = 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 if (notCounted !== undefined && !isText(notCounted)) problems.push(`Measure ${index} has a field notCounted that is not a text.`);\n if (targets !== undefined) problems.push(...targetProblems(targets, index));\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, notCounted, targets }: KpiMeasure): KpiMeasure {\n return {\n id,\n value,\n ...(unit === undefined ? {} : { unit }),\n ...(at === undefined ? {} : { at }),\n ...(notCounted === undefined ? {} : { notCounted }),\n ...(targets === undefined ? {} : { targets: targets.map(({ value: planned, by }) => ({ value: planned, by })) }),\n };\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 icon of a site page.\n *\n * A page with no icon link makes the browser ask for `/favicon.ico`. A project site on GitHub Pages has no such file.\n * Thus the console of each page shows a 404 error, and a check of the page errors counts it.\n */\nimport { escapeHtml } from \"./html.ts\";\n\n/** The SVG of the default icon: a page with a folded corner on a square of the accent color of the pages. */\nexport const SITE_ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><rect width=\"32\" height=\"32\" rx=\"7\" fill=\"#2346c4\"/><path d=\"M10 7h8l5 5v13H10z\" fill=\"#fff\"/><path d=\"M18 7v5h5z\" fill=\"#e7ecfd\"/></svg>';\n\n/**\n * The `href` of the default icon: a data URL of `SITE_ICON_SVG`. The icon needs no file and no request.\n *\n * The value is a literal, not a request of `encodeURIComponent` when the module loads. A bundle that does not use the icon\n * then drops it. conventions bundles this package. A request here changes the build of conventions, and then it needs a release.\n * A test checks that the literal is the data URL of `SITE_ICON_SVG`.\n */\nexport const SITE_ICON_HREF: string =\n \"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2032%2032%22%3E%3Crect%20width%3D%2232%22%20height%3D%2232%22%20rx%3D%227%22%20fill%3D%22%232346c4%22%2F%3E%3Cpath%20d%3D%22M10%207h8l5%205v13H10z%22%20fill%3D%22%23fff%22%2F%3E%3Cpath%20d%3D%22M18%207v5h5z%22%20fill%3D%22%23e7ecfd%22%2F%3E%3C%2Fsvg%3E\";\n\n/**\n * This function tells if an HTML page has an icon link: a `link` element with the word `icon` in its `rel`.\n * `rel=\"icon\"` and `rel=\"shortcut icon\"` count. `rel=\"apple-touch-icon\"` does not count, because a browser that reads only\n * that link still asks for `/favicon.ico`.\n */\nexport function hasIconLink(html: string): boolean {\n for (const [tag] of html.matchAll(/<link\\b[^>]*>/gi)) {\n const rel = /\\srel\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'>]+))/i.exec(tag);\n const words = (rel?.[1] ?? rel?.[2] ?? rel?.[3] ?? \"\").toLowerCase().split(/\\s+/);\n if (words.includes(\"icon\")) return true;\n }\n return false;\n}\n\n/** This function gives the `link` element of an icon, for the `head` of a page. The default is the icon of `SITE_ICON_HREF`. */\nexport function iconLink(href: string = SITE_ICON_HREF): string {\n return `<link rel=\"icon\" href=\"${escapeHtml(href)}\">`;\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 study has an age limit and a scheduled workflow, or it says why it needs no limit. A page with a longer limit names the reason and the workflow.\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\n/** The longest limit of a study, in days, also with a ruling. A study over `MAX_LIMIT_DAYS_WITHOUT_RULING` also needs a ruling. */\nexport const MAX_STUDY_LIMIT_DAYS = 30;\n\n/** The last time at which a limit can start. A limit turns on at this time if its site did not turn it on before. */\nexport const LAST_LIMIT_START = \"2026-12-07T00:00:00Z\";\n\nconst DAY_MS = 86_400_000;\n\n/** The form of a full commit. */\nconst FULL_COMMIT = /^[0-9a-f]{40}$/;\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 /** The words for data that no CI run made, for example `lab run` or `hand count`. The page shows them in place of `run`. */\n readonly method?: string;\n /** The full commit of the code that ran. It is not the commit that added a copy of the data. A study with a limit in force needs it. */\n readonly commit?: 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 /** The ISO time at which the age rule and the commit rule start, at most `LAST_LIMIT_START`. A site removes this field at the first green read of its workflow. */\n readonly startsAt?: string;\n}\n\n/** The two statements of a study with no age limit. The page shows both. */\nexport interface NoAgeLimit {\n /** The reason that no run of the current code can reproduce the numbers. */\n readonly reproduce: string;\n /** The reason that the page claims nothing about today. */\n readonly today: 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 study of the versions of its runs. A study has a `limit` or the field `noLimit`, and the rule of the engines does not apply to it. */\n readonly study?: true;\n /** The age limit of this page, in place of the default. */\n readonly limit?: DataLimit;\n /** The statements of a study with no age limit. */\n readonly noLimit?: NoAgeLimit;\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/** The form of a two-part image tag, for example `7.4`. A fixed study can name it, because no check compares the versions of a study. */\nconst IMAGE_TAG = /^\\d+\\.\\d+$/;\n\n/** This function gives the faults of one run of a stamp. */\nfunction runFaults(raw: unknown, at: string, study = false): 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 if (run[\"method\"] !== undefined && (typeof run[\"method\"] !== \"string\" || run[\"method\"].trim() === \"\")) faults.push(`${label}: the method of the run is not text.`);\n if (run[\"commit\"] !== undefined && (typeof run[\"commit\"] !== \"string\" || !FULL_COMMIT.test(run[\"commit\"]))) faults.push(`${label}: the commit of the run is not a full commit.`);\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 const known = typeof version === \"string\" && (parseVersion(version) !== null || (study && IMAGE_TAG.test(version)));\n if (!known) 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, study: boolean): 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 if (study && typeof days === \"number\" && days > MAX_STUDY_LIMIT_DAYS) faults.push(`${at}: the limit of a study is at most ${MAX_STUDY_LIMIT_DAYS} days.`);\n const startsAt = limit[\"startsAt\"];\n if (startsAt !== undefined) {\n if (typeof startsAt !== \"string\" || !Number.isFinite(Date.parse(startsAt))) faults.push(`${at}: the start of the limit has no date.`);\n else if (Date.parse(startsAt) > Date.parse(LAST_LIMIT_START)) faults.push(`${at}: the start of the limit is after ${LAST_LIMIT_START.slice(0, 10)}.`);\n }\n return faults;\n}\n\n/** This function gives the faults of the statements of a study with no age limit. */\nfunction noLimitFaults(raw: unknown, at: string): string[] {\n const statements = record(raw);\n if (statements === null) return [`${at}: the field noLimit is not an object.`];\n const faults: string[] = [];\n const said = (value: unknown): boolean => typeof value === \"string\" && value.trim() !== \"\";\n if (!said(statements[\"reproduce\"])) faults.push(`${at}: the field noLimit does not say why no run of the current code can reproduce the numbers.`);\n if (!said(statements[\"today\"])) faults.push(`${at}: the field noLimit does not say why the page claims nothing about today.`);\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 const limit = page[\"limit\"];\n const noLimit = page[\"noLimit\"];\n if (study === true && limit === undefined && noLimit === undefined) faults.push(`${at}: a study needs a limit, or the field noLimit.`);\n if (limit !== undefined && noLimit !== undefined) faults.push(`${at}: a page has a limit or the field noLimit, not both.`);\n if (study !== true && noLimit !== undefined) faults.push(`${at}: only a study has the field noLimit.`);\n if (study === true && page[\"inFlight\"] !== undefined) faults.push(`${at}: a study has no run in flight.`);\n if (limit !== undefined) faults.push(...limitFaults(limit, at, study === true));\n if (noLimit !== undefined) faults.push(...noLimitFaults(noLimit, 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, page[\"study\"] === true));\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/** One schedule of a workflow. */\nexport interface CronLine {\n /** The number of the line in the file, from 1. */\n readonly line: number;\n /** The cron text, with no quotes and no comment. */\n readonly cron: string;\n}\n\n/**\n * This function gives each line `cron:` of a workflow. It is the one reader of these lines: the freshness gate and the rule `runner-budget` of conventions use it.\n * It skips a comment line. It reads a quoted key, a list item, a quoted value and a comment at the end of the line.\n */\nexport function cronLines(workflow: string): CronLine[] {\n return workflow.split(/\\r?\\n/).flatMap((raw, index) => {\n const text = raw.trim().replace(/^- */, \"\");\n const key = [\"cron:\", '\"cron\":', \"'cron':\"].find((form) => text.startsWith(form));\n if (key === undefined) return [];\n // YAML starts a comment at a \"#\" after a space or a tab.\n const rest = text.slice(key.length);\n const comment = rest.search(/\\s#/);\n const value = (comment >= 0 ? rest.slice(0, comment) : rest).trim();\n const quote = value.charAt(0);\n const quoted = value.length >= 2 && (quote === '\"' || quote === \"'\") && value.endsWith(quote);\n return [{ line: index + 1, cron: quoted ? value.slice(1, -1).trim() : value }];\n });\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 = cronLines(workflow).map((item) => item.cron);\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 study has no limit of the engines, because it tells about the versions that it names.\n * - A study with a limit in force names the commit of each run. A study with no limit has no age rule.\n * - A limit with `startsAt` applies the age rule and the commit rule from that time. The schedule rule applies at once.\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 && stamp.limit === undefined) continue;\n const maxAgeDays = stamp.limit?.days ?? defaultAge;\n const startsAt = stamp.limit?.startsAt;\n const inForce = startsAt === undefined || Date.parse(startsAt) <= now;\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 (inForce && 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 if (stamp.study === true) {\n if (inForce) for (const run of stamp.runs) if (run.commit === undefined) faults.push(`${stamp.page}: the run ${run.id} names no commit.`);\n continue;\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/** A time at which the gate must fail for a page, and what the gate says at that time. */\nexport interface FailingCase {\n /** The path of the page. */\n readonly page: string;\n /** The ISO time of the case. */\n readonly at: string;\n /** The first fault at that time. A case with no fault tells that the gate does not hold the page. */\n readonly fault?: string;\n}\n\n/**\n * This function gives one failing case for each page, from the stamps of the site itself. A measured page must fail one\n * day after its limit, from `options.now` or the start of the limit. A study with no limit must fail before the date of its run.\n * Stamps that pass and give a case with no fault tell that the gate does not examine that page.\n */\nexport function failingCases(stamps: DataStamps, options: FreshnessOptions): readonly FailingCase[] {\n return stamps.pages.map((stamp) => {\n const dates = [...stamp.runs, ...(stamp.inFlight === undefined ? [] : [stamp.inFlight])].map((run) => Date.parse(run.date));\n const days = stamp.limit?.days ?? options.maxAgeDays ?? MAX_DATA_AGE_DAYS;\n const from = Math.max(Date.parse(options.now), Date.parse(stamp.limit?.startsAt ?? options.now));\n const time = stamp.study === true && stamp.limit === undefined ? Math.min(...dates) - DAY_MS : from + (days + 1) * DAY_MS;\n const at = new Date(time).toISOString();\n const [fault] = checkFreshness({ schema: stamps.schema, pages: [stamp] }, { ...options, now: at }).faults;\n return { page: stamp.page, at, ...(fault === undefined ? {} : { fault }) };\n });\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.\nStamps that pass also show one failing case for each page. A page with no failing case is a fault.\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 options: FreshnessOptions = { now: values.now ?? new Date().toISOString(), times: npm.times, schedules };\n const result = checkFreshness(parsed.stamps, options);\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} ${parsed.stamps.pages.length === 1 ? \"page\" : \"pages\"} pass.\\n`);\n let held = true;\n for (const { page, at, fault } of failingCases(parsed.stamps, options)) {\n if (fault === undefined) {\n io.stderr(`${page}: the gate does not fail at ${at}, so it does not hold this page.\\n`);\n held = false;\n } else {\n io.stdout(`Failing case at ${at}: ${f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CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { m as escapeHtml, p as runFreshnessCli, y as safeUrl } from "./chunks/freshness.js";
2
+ import { C as safeUrl, p as runFreshnessCli, v as escapeHtml } from "./chunks/freshness.js";
3
3
  import { a as runCli, o as TYPESCRIPT_PROBE, s as probeScript } from "./chunks/build.js";
4
4
  import { spawn } from "node:child_process";
5
5
  import { appendFileSync, createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -61,6 +61,10 @@ export interface SiteConfig {
61
61
  readonly "site-check-probe": string;
62
62
  /** The Playwright version of the site check. */
63
63
  readonly "site-check-playwright": string;
64
+ /** The Playwright browsers of the build, with spaces between them. The action `setup-playwright` installs them before the build. */
65
+ readonly "playwright-browsers": string;
66
+ /** The command that runs the Playwright CLI of the repository, for the install of `playwright-browsers`. */
67
+ readonly "playwright-command": string;
64
68
  /** `true` gives each page the bar of the site. */
65
69
  readonly "site-bar": boolean;
66
70
  /** The pages of the bar, with commas between them. */
@@ -1 +1 @@
1
- {"version":3,"file":"site-config.d.ts","names":[],"sources":["../../src/config/site-config.ts"],"mappings":";;;;;;;;;;;;;;qBAea;;YAGD;;iBAGK;;WAEN;;WAEA;;WAEA,KAAK,SAAS;;WAEd;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,sBAAsB;;iBAGjB,kBAAkB;WACxB,MAAM;WACN,SAAS;;;qBAIP,8BAA8B,KAAK,gBAAgB,kBAAkB,WAAW;;iBA+B5E;;WAEN;;WAEA;;WAEA,QAAQ,SAAS;;WAEjB;;;YAIC;WAA8B,QAAQ;WAAqB;;WAAyC;;;wBAKhG,eAAe,eAAe;;;;;wBA4B9B,YAAY,QAAQ,SAAS,2BAA2B;;;;;wBAaxD,kBAAkB,OAAO,kBAAkB"}
1
+ {"version":3,"file":"site-config.d.ts","names":[],"sources":["../../src/config/site-config.ts"],"mappings":";;;;;;;;;;;;;;qBAea;;YAGD;;iBAGK;;WAEN;;WAEA;;WAEA,KAAK,SAAS;;WAEd;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,sBAAsB;;iBAGjB,kBAAkB;WACxB,MAAM;WACN,SAAS;;;qBAIP,8BAA8B,KAAK,gBAAgB,kBAAkB,WAAW;;iBAiC5E;;WAEN;;WAEA;;WAEA,QAAQ,SAAS;;WAEjB;;;YAIC;WAA8B,QAAQ;WAAqB;;WAAyC;;;wBAKhG,eAAe,eAAe;;;;;wBA4B9B,YAAY,QAAQ,SAAS,2BAA2B;;;;;wBAaxD,kBAAkB,OAAO,kBAAkB"}
@@ -104,6 +104,14 @@ const SITE_CONFIG_KEYS = {
104
104
  kind: "string",
105
105
  default: "1.64.1"
106
106
  },
107
+ "playwright-browsers": {
108
+ kind: "string",
109
+ default: ""
110
+ },
111
+ "playwright-command": {
112
+ kind: "string",
113
+ default: "npx --no-install playwright"
114
+ },
107
115
  "site-bar": {
108
116
  kind: "boolean",
109
117
  default: false
@@ -1 +1 @@
1
- {"version":3,"file":"site-config.js","names":[],"sources":["../../src/config/site-config.ts"],"sourcesContent":["/**\n * The site config of a repository: the one home of the inputs of its site build (CI.md, \"The site config\").\n *\n * The file `.github/site.json` of the repository holds them. `reusable-pages.yml` (build and deploy) and\n * `reusable-pages-check.yml` (the check of a pull request) read it with `main.ts` of this folder. Thus the two\n * workflows build the same site, and each value has one home. The rules of `@mark1russell7/conventions` read it too.\n *\n * A repository with no file gives the old inputs of `reusable-pages.yml`, and the resolver takes them. Thus an old\n * caller keeps its site. A repository that has the file and also gives a site input gets an error.\n *\n * In each string value, `{owner}` is the owner of the repository and `{repo}` is its name. This file imports nothing,\n * so the workflow starts it from the template commit with no install.\n */\n\n/** The path of the site config in a repository. */\nexport const SITE_CONFIG_PATH = \".github/site.json\";\n\n/** The type of a key: a string, a boolean or a map of environment variables. */\nexport type SiteConfigKind = \"string\" | \"boolean\" | \"env\";\n\n/** The site config: a value for each key. CI.md tells each key. */\nexport interface SiteConfig {\n /** The command that builds the site. It is the one necessary key, with `out`. */\n readonly build: string;\n /** The folder of the built site. */\n readonly out: string;\n /** The environment variables of the build. `{owner}` and `{repo}` change in each value. */\n readonly env: Readonly<Record<string, string>>;\n /** `true` gives the build the token of the job as `GITHUB_TOKEN`. */\n readonly \"github-token\": boolean;\n /** The Node.js version of the build. */\n readonly \"node-version\": string;\n /** A file with the Node.js version, for example `.nvmrc`. It replaces `node-version`. */\n readonly \"node-version-file\": string;\n /** `true` adds the Releases page and the Status page. */\n readonly \"site-pages\": boolean;\n /** The npm version of site-pages for its pages. Empty uses the template commit. */\n readonly \"site-pages-version\": string;\n /** The roadmap file of the Status page, for example `docs/ROADMAP.md`. */\n readonly roadmap: string;\n /** The base path of the site, for example `/{repo}/`. */\n readonly base: string;\n /** The npm packages of the Releases page, with commas between them. */\n readonly packages: string;\n /** The folder of the changesets of the Status page. */\n readonly changesets: string;\n /** The group of the pages of the site. */\n readonly group: string;\n /** A style file of the site for the pages of site-pages. */\n readonly css: string;\n /** The name of the site in the bar and in the titles. */\n readonly \"site-name\": string;\n /** `true` writes only the data files of the pages, with no HTML. */\n readonly \"data-only\": boolean;\n /** A file of data stamps, for the freshness gate. */\n readonly \"data-stamps\": string;\n /** `true` checks the pages in a browser at each width. */\n readonly \"site-check\": boolean;\n /** The pages of the site check, with commas between them. */\n readonly \"site-check-pages\": string;\n /** The widths of the site check, with commas between them. */\n readonly \"site-check-widths\": string;\n /** A probe script of the site check. */\n readonly \"site-check-probe\": string;\n /** The Playwright version of the site check. */\n readonly \"site-check-playwright\": string;\n /** `true` gives each page the bar of the site. */\n readonly \"site-bar\": boolean;\n /** The pages of the bar, with commas between them. */\n readonly \"site-bar-pages\": string;\n /** The npm name of the package of the site, for the npm link of the bar. */\n readonly \"site-bar-npm\": string;\n /** `true` gives each code block the scroll cue. */\n readonly \"scroll-cue\": boolean;\n /** A key of IndexNow. After each deploy that is not scheduled, the URLs go to the engines. */\n readonly \"indexnow-key\": string;\n}\n\n/** A key of the site config. */\nexport type SiteConfigKey = keyof SiteConfig;\n\n/** The type and the default of one key. The defaults are those of the inputs of `reusable-pages.yml`. */\nexport interface SiteConfigKeySpec<T> {\n readonly kind: SiteConfigKind;\n readonly default: T;\n}\n\n/** The keys of the site config, with their types and their defaults. */\nexport const SITE_CONFIG_KEYS: { readonly [K in SiteConfigKey]: SiteConfigKeySpec<SiteConfig[K]> } = {\n build: { kind: \"string\", default: \"\" },\n out: { kind: \"string\", default: \"\" },\n env: { kind: \"env\", default: {} },\n \"github-token\": { kind: \"boolean\", default: false },\n \"node-version\": { kind: \"string\", default: \"26\" },\n \"node-version-file\": { kind: \"string\", default: \"\" },\n \"site-pages\": { kind: \"boolean\", default: true },\n \"site-pages-version\": { kind: \"string\", default: \"\" },\n roadmap: { kind: \"string\", default: \"\" },\n base: { kind: \"string\", default: \"\" },\n packages: { kind: \"string\", default: \"\" },\n changesets: { kind: \"string\", default: \"\" },\n group: { kind: \"string\", default: \"\" },\n css: { kind: \"string\", default: \"\" },\n \"site-name\": { kind: \"string\", default: \"\" },\n \"data-only\": { kind: \"boolean\", default: false },\n \"data-stamps\": { kind: \"string\", default: \"\" },\n \"site-check\": { kind: \"boolean\", default: false },\n \"site-check-pages\": { kind: \"string\", default: \"\" },\n \"site-check-widths\": { kind: \"string\", default: \"\" },\n \"site-check-probe\": { kind: \"string\", default: \"\" },\n \"site-check-playwright\": { kind: \"string\", default: \"1.64.1\" },\n \"site-bar\": { kind: \"boolean\", default: false },\n \"site-bar-pages\": { kind: \"string\", default: \"\" },\n \"site-bar-npm\": { kind: \"string\", default: \"\" },\n \"scroll-cue\": { kind: \"boolean\", default: true },\n \"indexnow-key\": { kind: \"string\", default: \"\" },\n};\n\n/** The input of {@link resolveSiteConfig}. */\nexport interface SiteConfigInput {\n /** The text of .github/site.json, or undefined when the repository has no such file. */\n readonly file: string | undefined;\n /** The path of the file, for the messages. */\n readonly path: string;\n /** The inputs of the workflow (toJSON(inputs)), or undefined when the workflow has no old inputs. */\n readonly inputs: Readonly<Record<string, unknown>> | undefined;\n /** The repository, \"owner/name\". */\n readonly repository: string;\n}\n\n/** The site config and its source, or an error. */\nexport type SiteConfigResult = { readonly config: SiteConfig; readonly source: \"file\" | \"inputs\" } | { readonly error: string };\n\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** This function puts the owner and the name of the repository in for {owner} and {repo}. */\nexport function fillRepository(value: string, repository: string): string {\n const [owner = \"\", repo = \"\"] = repository.split(\"/\");\n return value.replaceAll(\"{owner}\", owner).replaceAll(\"{repo}\", repo);\n}\n\n/** This function checks one value against the type of its key, and gives the value or an error. */\nfunction check(key: SiteConfigKey, value: unknown, where: string, repository: string): { value: SiteConfig[SiteConfigKey] } | { error: string } {\n const kind: SiteConfigKind = SITE_CONFIG_KEYS[key].kind;\n if (kind === \"boolean\") {\n return typeof value === \"boolean\" ? { value } : { error: `${where}: \"${key}\" must be true or false.` };\n }\n if (kind === \"string\") {\n return typeof value === \"string\" ? { value: fillRepository(value, repository) } : { error: `${where}: \"${key}\" must be a string.` };\n }\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return { error: `${where}: \"env\" must be an object of strings.` };\n const env: Record<string, string> = {};\n for (const [name, text] of Object.entries(value)) {\n if (!NAME.test(name)) return { error: `${where}: \"${name}\" of \"env\" is not a name of an environment variable.` };\n if (typeof text !== \"string\") return { error: `${where}: the value of \"${name}\" of \"env\" must be a string.` };\n env[name] = fillRepository(text, repository);\n }\n return { value: env };\n}\n\n/**\n * This function gives the keys of the site config that the inputs of a workflow give with a value other than the default.\n * The input `env` of `reusable-pages.yml` is a JSON string, and `\"{}\"` or an empty string is its default.\n */\nexport function inputsGiven(inputs: Readonly<Record<string, unknown>>): SiteConfigKey[] {\n return (Object.keys(SITE_CONFIG_KEYS) as SiteConfigKey[]).filter((key) => {\n const value = inputs[key];\n if (value === undefined) return false;\n if (key === \"env\") return !(value === \"\" || (typeof value === \"string\" && value.replace(/\\s/g, \"\") === \"{}\"));\n return value !== SITE_CONFIG_KEYS[key].default;\n });\n}\n\n/**\n * This function gives the site config of a repository from its file, or from the old inputs when it has no file. The\n * workflow uses only the file. Thus a repository with the file gets an error for a site input that is not its default.\n */\nexport function resolveSiteConfig(input: SiteConfigInput): SiteConfigResult {\n const config = Object.fromEntries(Object.entries(SITE_CONFIG_KEYS).map(([key, spec]) => [key, spec.default])) as Record<SiteConfigKey, unknown>;\n let source: \"file\" | \"inputs\";\n if (input.file !== undefined) {\n const given = input.inputs === undefined ? [] : inputsGiven(input.inputs);\n if (given.length > 0) {\n return { error: `The repository has ${input.path} and the workflow also gives the inputs ${given.join(\", \")}. Give the site values only in ${input.path}.` };\n }\n let data: unknown;\n try {\n data = JSON.parse(input.file);\n } catch (error) {\n return { error: `${input.path} is not JSON: ${(error as Error).message}` };\n }\n if (data === null || typeof data !== \"object\" || Array.isArray(data)) return { error: `${input.path} must be a JSON object.` };\n for (const [key, value] of Object.entries(data)) {\n if (key === \"$schema\" || key === \"$comment\") continue;\n if (!Object.hasOwn(SITE_CONFIG_KEYS, key)) return { error: `${input.path}: \"${key}\" is not a key of the site config. CI.md tells the keys.` };\n const checked = check(key as SiteConfigKey, value, input.path, input.repository);\n if (\"error\" in checked) return checked;\n config[key as SiteConfigKey] = checked.value;\n }\n source = \"file\";\n } else if (input.inputs !== undefined) {\n for (const key of Object.keys(SITE_CONFIG_KEYS) as SiteConfigKey[]) {\n let value = input.inputs[key];\n if (value === undefined) continue;\n // The input env of reusable-pages.yml is a JSON string, and an empty string means no variables.\n if (key === \"env\") {\n if (value === \"\") continue;\n try {\n value = JSON.parse(String(value));\n } catch (error) {\n return { error: `The input env is not JSON: ${(error as Error).message}` };\n }\n }\n const checked = check(key, value, \"the inputs\", input.repository);\n if (\"error\" in checked) return checked;\n config[key] = checked.value;\n }\n source = \"inputs\";\n } else {\n return { error: `The repository has no ${input.path}. The check of the site needs the file (CI.md, \"The site config\").` };\n }\n for (const key of [\"build\", \"out\"] as const) {\n if (config[key] === \"\") {\n const home = source === \"file\" ? input.path : \"the inputs of the workflow\";\n return { error: `${home} gives no \"${key}\". The site config needs \"build\" and \"out\".` };\n }\n }\n return { config: config as SiteConfig, source };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,mBAAmB;;AAyEhC,MAAa,mBAAwF;CACnG,OAAO;EAAE,MAAM;EAAU,SAAS;CAAG;CACrC,KAAK;EAAE,MAAM;EAAU,SAAS;CAAG;CACnC,KAAK;EAAE,MAAM;EAAO,SAAS,CAAC;CAAE;CAChC,gBAAgB;EAAE,MAAM;EAAW,SAAS;CAAM;CAClD,gBAAgB;EAAE,MAAM;EAAU,SAAS;CAAK;CAChD,qBAAqB;EAAE,MAAM;EAAU,SAAS;CAAG;CACnD,cAAc;EAAE,MAAM;EAAW,SAAS;CAAK;CAC/C,sBAAsB;EAAE,MAAM;EAAU,SAAS;CAAG;CACpD,SAAS;EAAE,MAAM;EAAU,SAAS;CAAG;CACvC,MAAM;EAAE,MAAM;EAAU,SAAS;CAAG;CACpC,UAAU;EAAE,MAAM;EAAU,SAAS;CAAG;CACxC,YAAY;EAAE,MAAM;EAAU,SAAS;CAAG;CAC1C,OAAO;EAAE,MAAM;EAAU,SAAS;CAAG;CACrC,KAAK;EAAE,MAAM;EAAU,SAAS;CAAG;CACnC,aAAa;EAAE,MAAM;EAAU,SAAS;CAAG;CAC3C,aAAa;EAAE,MAAM;EAAW,SAAS;CAAM;CAC/C,eAAe;EAAE,MAAM;EAAU,SAAS;CAAG;CAC7C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IAAI,QAAQ,aAAa,QAAQ,YAAY;GAC7C,IAAI,CAAC,OAAO,OAAO,kBAAkB,GAAG,GAAG,OAAO,EAAE,OAAO,GAAG,MAAM,KAAK,KAAK,IAAI,0DAA0D;GAC5I,MAAM,UAAU,MAAM,KAAsB,OAAO,MAAM,MAAM,MAAM,UAAU;GAC/E,IAAI,WAAW,SAAS,OAAO;GAC/B,OAAO,OAAwB,QAAQ;EACzC;EACA,SAAS;CACX,OAAO,IAAI,MAAM,WAAW,KAAA,GAAW;EACrC,KAAK,MAAM,OAAO,OAAO,KAAK,gBAAgB,GAAsB;GAClE,IAAI,QAAQ,MAAM,OAAO;GACzB,IAAI,UAAU,KAAA,GAAW;GAEzB,IAAI,QAAQ,OAAO;IACjB,IAAI,UAAU,IAAI;IAClB,IAAI;KACF,QAAQ,KAAK,MAAM,OAAO,KAAK,CAAC;IAClC,SAAS,OAAO;KACd,OAAO,EAAE,OAAO,8BAA+B,MAAgB,UAAU;IAC3E;GACF;GACA,MAAM,UAAU,MAAM,KAAK,OAAO,cAAc,MAAM,UAAU;GAChE,IAAI,WAAW,SAAS,OAAO;GAC/B,OAAO,OAAO,QAAQ;EACxB;EACA,SAAS;CACX,OACE,OAAO,EAAE,OAAO,yBAAyB,MAAM,KAAK,oEAAoE;CAE1H,KAAK,MAAM,OAAO,CAAC,SAAS,KAAK,GAC/B,IAAI,OAAO,SAAS,IAElB,OAAO,EAAE,OAAO,GADH,WAAW,SAAS,MAAM,OAAO,6BACtB,aAAa,IAAI,6CAA6C;CAG1F,OAAO;EAAU;EAAsB;CAAO;AAChD"}
1
+ {"version":3,"file":"site-config.js","names":[],"sources":["../../src/config/site-config.ts"],"sourcesContent":["/**\n * The site config of a repository: the one home of the inputs of its site build (CI.md, \"The site config\").\n *\n * The file `.github/site.json` of the repository holds them. `reusable-pages.yml` (build and deploy) and\n * `reusable-pages-check.yml` (the check of a pull request) read it with `main.ts` of this folder. Thus the two\n * workflows build the same site, and each value has one home. The rules of `@mark1russell7/conventions` read it too.\n *\n * A repository with no file gives the old inputs of `reusable-pages.yml`, and the resolver takes them. Thus an old\n * caller keeps its site. A repository that has the file and also gives a site input gets an error.\n *\n * In each string value, `{owner}` is the owner of the repository and `{repo}` is its name. This file imports nothing,\n * so the workflow starts it from the template commit with no install.\n */\n\n/** The path of the site config in a repository. */\nexport const SITE_CONFIG_PATH = \".github/site.json\";\n\n/** The type of a key: a string, a boolean or a map of environment variables. */\nexport type SiteConfigKind = \"string\" | \"boolean\" | \"env\";\n\n/** The site config: a value for each key. CI.md tells each key. */\nexport interface SiteConfig {\n /** The command that builds the site. It is the one necessary key, with `out`. */\n readonly build: string;\n /** The folder of the built site. */\n readonly out: string;\n /** The environment variables of the build. `{owner}` and `{repo}` change in each value. */\n readonly env: Readonly<Record<string, string>>;\n /** `true` gives the build the token of the job as `GITHUB_TOKEN`. */\n readonly \"github-token\": boolean;\n /** The Node.js version of the build. */\n readonly \"node-version\": string;\n /** A file with the Node.js version, for example `.nvmrc`. It replaces `node-version`. */\n readonly \"node-version-file\": string;\n /** `true` adds the Releases page and the Status page. */\n readonly \"site-pages\": boolean;\n /** The npm version of site-pages for its pages. Empty uses the template commit. */\n readonly \"site-pages-version\": string;\n /** The roadmap file of the Status page, for example `docs/ROADMAP.md`. */\n readonly roadmap: string;\n /** The base path of the site, for example `/{repo}/`. */\n readonly base: string;\n /** The npm packages of the Releases page, with commas between them. */\n readonly packages: string;\n /** The folder of the changesets of the Status page. */\n readonly changesets: string;\n /** The group of the pages of the site. */\n readonly group: string;\n /** A style file of the site for the pages of site-pages. */\n readonly css: string;\n /** The name of the site in the bar and in the titles. */\n readonly \"site-name\": string;\n /** `true` writes only the data files of the pages, with no HTML. */\n readonly \"data-only\": boolean;\n /** A file of data stamps, for the freshness gate. */\n readonly \"data-stamps\": string;\n /** `true` checks the pages in a browser at each width. */\n readonly \"site-check\": boolean;\n /** The pages of the site check, with commas between them. */\n readonly \"site-check-pages\": string;\n /** The widths of the site check, with commas between them. */\n readonly \"site-check-widths\": string;\n /** A probe script of the site check. */\n readonly \"site-check-probe\": string;\n /** The Playwright version of the site check. */\n readonly \"site-check-playwright\": string;\n /** The Playwright browsers of the build, with spaces between them. The action `setup-playwright` installs them before the build. */\n readonly \"playwright-browsers\": string;\n /** The command that runs the Playwright CLI of the repository, for the install of `playwright-browsers`. */\n readonly \"playwright-command\": string;\n /** `true` gives each page the bar of the site. */\n readonly \"site-bar\": boolean;\n /** The pages of the bar, with commas between them. */\n readonly \"site-bar-pages\": string;\n /** The npm name of the package of the site, for the npm link of the bar. */\n readonly \"site-bar-npm\": string;\n /** `true` gives each code block the scroll cue. */\n readonly \"scroll-cue\": boolean;\n /** A key of IndexNow. After each deploy that is not scheduled, the URLs go to the engines. */\n readonly \"indexnow-key\": string;\n}\n\n/** A key of the site config. */\nexport type SiteConfigKey = keyof SiteConfig;\n\n/** The type and the default of one key. The defaults are those of the inputs of `reusable-pages.yml`. */\nexport interface SiteConfigKeySpec<T> {\n readonly kind: SiteConfigKind;\n readonly default: T;\n}\n\n/** The keys of the site config, with their types and their defaults. */\nexport const SITE_CONFIG_KEYS: { readonly [K in SiteConfigKey]: SiteConfigKeySpec<SiteConfig[K]> } = {\n build: { kind: \"string\", default: \"\" },\n out: { kind: \"string\", default: \"\" },\n env: { kind: \"env\", default: {} },\n \"github-token\": { kind: \"boolean\", default: false },\n \"node-version\": { kind: \"string\", default: \"26\" },\n \"node-version-file\": { kind: \"string\", default: \"\" },\n \"site-pages\": { kind: \"boolean\", default: true },\n \"site-pages-version\": { kind: \"string\", default: \"\" },\n roadmap: { kind: \"string\", default: \"\" },\n base: { kind: \"string\", default: \"\" },\n packages: { kind: \"string\", default: \"\" },\n changesets: { kind: \"string\", default: \"\" },\n group: { kind: \"string\", default: \"\" },\n css: { kind: \"string\", default: \"\" },\n \"site-name\": { kind: \"string\", default: \"\" },\n \"data-only\": { kind: \"boolean\", default: false },\n \"data-stamps\": { kind: \"string\", default: \"\" },\n \"site-check\": { kind: \"boolean\", default: false },\n \"site-check-pages\": { kind: \"string\", default: \"\" },\n \"site-check-widths\": { kind: \"string\", default: \"\" },\n \"site-check-probe\": { kind: \"string\", default: \"\" },\n \"site-check-playwright\": { kind: \"string\", default: \"1.64.1\" },\n \"playwright-browsers\": { kind: \"string\", default: \"\" },\n \"playwright-command\": { kind: \"string\", default: \"npx --no-install playwright\" },\n \"site-bar\": { kind: \"boolean\", default: false },\n \"site-bar-pages\": { kind: \"string\", default: \"\" },\n \"site-bar-npm\": { kind: \"string\", default: \"\" },\n \"scroll-cue\": { kind: \"boolean\", default: true },\n \"indexnow-key\": { kind: \"string\", default: \"\" },\n};\n\n/** The input of {@link resolveSiteConfig}. */\nexport interface SiteConfigInput {\n /** The text of .github/site.json, or undefined when the repository has no such file. */\n readonly file: string | undefined;\n /** The path of the file, for the messages. */\n readonly path: string;\n /** The inputs of the workflow (toJSON(inputs)), or undefined when the workflow has no old inputs. */\n readonly inputs: Readonly<Record<string, unknown>> | undefined;\n /** The repository, \"owner/name\". */\n readonly repository: string;\n}\n\n/** The site config and its source, or an error. */\nexport type SiteConfigResult = { readonly config: SiteConfig; readonly source: \"file\" | \"inputs\" } | { readonly error: string };\n\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** This function puts the owner and the name of the repository in for {owner} and {repo}. */\nexport function fillRepository(value: string, repository: string): string {\n const [owner = \"\", repo = \"\"] = repository.split(\"/\");\n return value.replaceAll(\"{owner}\", owner).replaceAll(\"{repo}\", repo);\n}\n\n/** This function checks one value against the type of its key, and gives the value or an error. */\nfunction check(key: SiteConfigKey, value: unknown, where: string, repository: string): { value: SiteConfig[SiteConfigKey] } | { error: string } {\n const kind: SiteConfigKind = SITE_CONFIG_KEYS[key].kind;\n if (kind === \"boolean\") {\n return typeof value === \"boolean\" ? { value } : { error: `${where}: \"${key}\" must be true or false.` };\n }\n if (kind === \"string\") {\n return typeof value === \"string\" ? { value: fillRepository(value, repository) } : { error: `${where}: \"${key}\" must be a string.` };\n }\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return { error: `${where}: \"env\" must be an object of strings.` };\n const env: Record<string, string> = {};\n for (const [name, text] of Object.entries(value)) {\n if (!NAME.test(name)) return { error: `${where}: \"${name}\" of \"env\" is not a name of an environment variable.` };\n if (typeof text !== \"string\") return { error: `${where}: the value of \"${name}\" of \"env\" must be a string.` };\n env[name] = fillRepository(text, repository);\n }\n return { value: env };\n}\n\n/**\n * This function gives the keys of the site config that the inputs of a workflow give with a value other than the default.\n * The input `env` of `reusable-pages.yml` is a JSON string, and `\"{}\"` or an empty string is its default.\n */\nexport function inputsGiven(inputs: Readonly<Record<string, unknown>>): SiteConfigKey[] {\n return (Object.keys(SITE_CONFIG_KEYS) as SiteConfigKey[]).filter((key) => {\n const value = inputs[key];\n if (value === undefined) return false;\n if (key === \"env\") return !(value === \"\" || (typeof value === \"string\" && value.replace(/\\s/g, \"\") === \"{}\"));\n return value !== SITE_CONFIG_KEYS[key].default;\n });\n}\n\n/**\n * This function gives the site config of a repository from its file, or from the old inputs when it has no file. The\n * workflow uses only the file. Thus a repository with the file gets an error for a site input that is not its default.\n */\nexport function resolveSiteConfig(input: SiteConfigInput): SiteConfigResult {\n const config = Object.fromEntries(Object.entries(SITE_CONFIG_KEYS).map(([key, spec]) => [key, spec.default])) as Record<SiteConfigKey, unknown>;\n let source: \"file\" | \"inputs\";\n if (input.file !== undefined) {\n const given = input.inputs === undefined ? [] : inputsGiven(input.inputs);\n if (given.length > 0) {\n return { error: `The repository has ${input.path} and the workflow also gives the inputs ${given.join(\", \")}. Give the site values only in ${input.path}.` };\n }\n let data: unknown;\n try {\n data = JSON.parse(input.file);\n } catch (error) {\n return { error: `${input.path} is not JSON: ${(error as Error).message}` };\n }\n if (data === null || typeof data !== \"object\" || Array.isArray(data)) return { error: `${input.path} must be a JSON object.` };\n for (const [key, value] of Object.entries(data)) {\n if (key === \"$schema\" || key === \"$comment\") continue;\n if (!Object.hasOwn(SITE_CONFIG_KEYS, key)) return { error: `${input.path}: \"${key}\" is not a key of the site config. CI.md tells the keys.` };\n const checked = check(key as SiteConfigKey, value, input.path, input.repository);\n if (\"error\" in checked) return checked;\n config[key as SiteConfigKey] = checked.value;\n }\n source = \"file\";\n } else if (input.inputs !== undefined) {\n for (const key of Object.keys(SITE_CONFIG_KEYS) as SiteConfigKey[]) {\n let value = input.inputs[key];\n if (value === undefined) continue;\n // The input env of reusable-pages.yml is a JSON string, and an empty string means no variables.\n if (key === \"env\") {\n if (value === \"\") continue;\n try {\n value = JSON.parse(String(value));\n } catch (error) {\n return { error: `The input env is not JSON: ${(error as Error).message}` };\n }\n }\n const checked = check(key, value, \"the inputs\", input.repository);\n if (\"error\" in checked) return checked;\n config[key] = checked.value;\n }\n source = \"inputs\";\n } else {\n return { error: `The repository has no ${input.path}. The check of the site needs the file (CI.md, \"The site config\").` };\n }\n for (const key of [\"build\", \"out\"] as const) {\n if (config[key] === \"\") {\n const home = source === \"file\" ? input.path : \"the inputs of the workflow\";\n return { error: `${home} gives no \"${key}\". The site config needs \"build\" and \"out\".` };\n }\n }\n return { config: config as SiteConfig, source };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,mBAAmB;;AA6EhC,MAAa,mBAAwF;CACnG,OAAO;EAAE,MAAM;EAAU,SAAS;CAAG;CACrC,KAAK;EAAE,MAAM;EAAU,SAAS;CAAG;CACnC,KAAK;EAAE,MAAM;EAAO,SAAS,CAAC;CAAE;CAChC,gBAAgB;EAAE,MAAM;EAAW,SAAS;CAAM;CAClD,gBAAgB;EAAE,MAAM;EAAU,SAAS;CAAK;CAChD,qBAAqB;EAAE,MAAM;EAAU,SAAS;CAAG;CACnD,cAAc;EAAE,MAAM;EAAW,SAAS;CAAK;CAC/C,sBAAsB;EAAE,MAAM;EAAU,SAAS;CAAG;CACpD,SAAS;EAAE,MAAM;EAAU,SAAS;CAAG;CACvC,MAAM;EAAE,MAAM;EAAU,SAAS;CAAG;CACpC,UAAU;EAAE,MAAM;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AS,IAElB,OAAO,EAAE,OAAO,GADH,WAAW,SAAS,MAAM,OAAO,6BACtB,aAAa,IAAI,6CAA6C;CAG1F,OAAO;EAAU;EAAsB;CAAO;AAChD"}
package/build/index.d.ts CHANGED
@@ -535,6 +535,24 @@ export declare function safeUrl(url: string): string | null;
535
535
  * escapes all other text, so the result is safe.
536
536
  */
537
537
  export declare function inlineMarkdown(markdown: string): string;
538
+ /** The SVG of the default icon: a page with a folded corner on a square of the accent color of the pages. */
539
+ export declare const SITE_ICON_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><rect width=\"32\" height=\"32\" rx=\"7\" fill=\"#2346c4\"/><path d=\"M10 7h8l5 5v13H10z\" fill=\"#fff\"/><path d=\"M18 7v5h5z\" fill=\"#e7ecfd\"/></svg>";
540
+ /**
541
+ * The `href` of the default icon: a data URL of `SITE_ICON_SVG`. The icon needs no file and no request.
542
+ *
543
+ * The value is a literal, not a request of `encodeURIComponent` when the module loads. A bundle that does not use the icon
544
+ * then drops it. conventions bundles this package. A request here changes the build of conventions, and then it needs a release.
545
+ * A test checks that the literal is the data URL of `SITE_ICON_SVG`.
546
+ */
547
+ export declare const SITE_ICON_HREF: string;
548
+ /**
549
+ * This function tells if an HTML page has an icon link: a `link` element with the word `icon` in its `rel`.
550
+ * `rel="icon"` and `rel="shortcut icon"` count. `rel="apple-touch-icon"` does not count, because a browser that reads only
551
+ * that link still asks for `/favicon.ico`.
552
+ */
553
+ export declare function hasIconLink(html: string): boolean;
554
+ /** This function gives the `link` element of an icon, for the `head` of a page. The default is the icon of `SITE_ICON_HREF`. */
555
+ export declare function iconLink(href?: string): string;
538
556
  /** This function gives the start of the UTC day of a time. */
539
557
  export declare function utcDay(time: number): number;
540
558
  /** This function gives "Oct 18": the UTC day of a time or of an ISO date. */
@@ -557,6 +575,8 @@ interface PageOptions {
557
575
  generatedAt: string;
558
576
  /** The commit of the build, or null. */
559
577
  commit: string | null;
578
+ /** The `href` of the icon of the page. The default is `SITE_ICON_HREF`. */
579
+ icon?: string | undefined;
560
580
  }
561
581
  /** The default CSS of the pages: the variables, the light and dark themes, and the parts of both pages. */
562
582
  export declare const BASE_CSS: string;