@mark1russell7/api-report 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/build/cli.js +1 -1
- package/build/index.d.ts +10 -26
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/{run-BX1npfID.js → run-Czt-_0nW.js} +29 -137
- package/build/run-Czt-_0nW.js.map +1 -0
- package/package.json +4 -1
- package/build/run-BX1npfID.js.map +0 -1
package/README.md
CHANGED
|
@@ -135,6 +135,25 @@ A library with many exports can keep each name on a page that the report makes.
|
|
|
135
135
|
- The file has a section for each entry, with an import of its names and their declarations. It has no comments, because the report has none.
|
|
136
136
|
- The hand-written pages explain the main calls. The first rule above does not apply to them, because the file shows each export. The rules for imports and declarations still apply. The list `pages` can be empty.
|
|
137
137
|
|
|
138
|
+
A site can need more fields in the front matter of the page, for example an `order` for its menu. The field `frontmatter` gives them. A field `title` or `description` replaces the default text.
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"apiReport": {
|
|
143
|
+
"pages": [
|
|
144
|
+
{
|
|
145
|
+
"package": "packages/lib",
|
|
146
|
+
"pages": [],
|
|
147
|
+
"reference": "packages/site/content/docs/each-export.mdx",
|
|
148
|
+
"frontmatter": { "order": 42 }
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Each value is a text, a number or a boolean. The field `frontmatter` needs the field `reference`.
|
|
156
|
+
|
|
138
157
|
## Library
|
|
139
158
|
|
|
140
159
|
The package also exports the functions of the tool:
|
|
@@ -143,7 +162,7 @@ The package also exports the functions of the tool:
|
|
|
143
162
|
- `packageReport(folder)` and `apiReport(name, root, entries)` give the text of one report.
|
|
144
163
|
- `entriesOf(manifest, folder)`, `publishedManifest(manifest)` and `binsOf(manifest)` read a `package.json`.
|
|
145
164
|
- `parseDeclarations(text)` and `statementsOf(text)` read a declaration file.
|
|
146
|
-
- `packageFolders(root, globs)`, `globFolders(root, glob)`, `globToRegExp(glob)` and `workspaceGlobs(root)` find the packages.
|
|
165
|
+
- `packageFolders(root, globs)`, `globFolders(root, glob)`, `globToRegExp(glob)` and `workspaceGlobs(root)` find the packages. They come from `@mark1russell7/conventions/workspace`.
|
|
147
166
|
- `diffLines(before, after)` and `unifiedDiff(before, after)` give a line diff.
|
|
148
167
|
- `pageFaults(report, packageName, pages, except, complete)` and `reportEntries(report)` hold a hand-written page against a report.
|
|
149
|
-
- `referencePage(report, packageName)` gives the Markdown of the page of each export.
|
|
168
|
+
- `referencePage(report, packageName, frontmatter)` gives the Markdown of the page of each export. The argument `frontmatter` is optional.
|
package/build/cli.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { globFolders, globToRegExp, packageFolders, workspaceGlobs } from "@mark1russell7/conventions/workspace";
|
|
1
2
|
/**
|
|
2
3
|
* The reader of the text of a declaration file. TypeScript 7 has no stable compiler API, so this
|
|
3
4
|
* module reads the `.d.ts` files as text. The declaration emit of `tsc` and of `tsdown` is regular,
|
|
@@ -149,6 +150,8 @@ export declare function targetOf(value: unknown): string | null | undefined;
|
|
|
149
150
|
export declare function entriesOf(manifest: Manifest, root: string): Entry[];
|
|
150
151
|
/** This function gives the commands of the `bin` field, in name order. A string `bin` has the name of the package without its scope. */
|
|
151
152
|
export declare function binsOf(manifest: Manifest): Bin[];
|
|
153
|
+
/** The value of one field of the front matter of the page of each export. */
|
|
154
|
+
type FrontmatterValue = string | number | boolean;
|
|
152
155
|
/** One package and the pages that tell its API: an item of the field `pages` of `apiReport`. */
|
|
153
156
|
interface ApiPage {
|
|
154
157
|
/** The folder of the package, relative to the root. */
|
|
@@ -157,6 +160,8 @@ interface ApiPage {
|
|
|
157
160
|
readonly pages: readonly string[];
|
|
158
161
|
/** The file of a page of each export, relative to the root. The command `update` writes it from the report, and the command `check` compares it. */
|
|
159
162
|
readonly reference?: string;
|
|
163
|
+
/** The fields that the page of each export adds to its front matter, for example the `order` of a site. A field `title` or `description` replaces the default. */
|
|
164
|
+
readonly frontmatter?: Readonly<Record<string, FrontmatterValue>>;
|
|
160
165
|
/** The names that the check does not examine, each with its reason. */
|
|
161
166
|
readonly except?: Readonly<Record<string, string>>;
|
|
162
167
|
}
|
|
@@ -176,8 +181,11 @@ export declare function pageFaults(report: string, packageName: string, pages: r
|
|
|
176
181
|
* names. A declaration shows one time, in the first entry that reaches it. A comment tells the name of an
|
|
177
182
|
* export when the source gave the declaration a different name. A name from a bundler does not show. A
|
|
178
183
|
* comment also tells the package of an external name.
|
|
184
|
+
*
|
|
185
|
+
* The fields of `frontmatter` go into the front matter, after the title and the description. A field `title` or
|
|
186
|
+
* `description` replaces the default.
|
|
179
187
|
*/
|
|
180
|
-
export declare function referencePage(report: string, packageName: string): string;
|
|
188
|
+
export declare function referencePage(report: string, packageName: string, frontmatter?: Readonly<Record<string, FrontmatterValue>>): string;
|
|
181
189
|
/** The command that the header of a report names, when the options give no other command. */
|
|
182
190
|
export declare const DEFAULT_TOOL = "api-report";
|
|
183
191
|
/** The options of a report. */
|
|
@@ -288,29 +296,5 @@ interface CliIo {
|
|
|
288
296
|
export declare const USAGE: string;
|
|
289
297
|
/** This function starts the bin with the arguments `args`, and gives its exit code. */
|
|
290
298
|
export declare function runCli(args: readonly string[], io: CliIo): number;
|
|
291
|
-
|
|
292
|
-
* This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path
|
|
293
|
-
* segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of
|
|
294
|
-
* its parts. The function escapes each other special character.
|
|
295
|
-
*/
|
|
296
|
-
export declare function globToRegExp(glob: string): RegExp;
|
|
297
|
-
/**
|
|
298
|
-
* This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,
|
|
299
|
-
* in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.
|
|
300
|
-
*/
|
|
301
|
-
export declare function globFolders(root: string, glob: string): string[];
|
|
302
|
-
/**
|
|
303
|
-
* This function gives the globs of the workspace at `root`: the `packages` list of
|
|
304
|
-
* `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when
|
|
305
|
-
* the repository has no workspace.
|
|
306
|
-
*/
|
|
307
|
-
export declare function workspaceGlobs(root: string): string[] | undefined;
|
|
308
|
-
/**
|
|
309
|
-
* This function gives the package folders of the repository at `root`: the folders of the globs
|
|
310
|
-
* that have a `package.json` file. A glob that starts with `!` removes folders. Without globs, the
|
|
311
|
-
* function reads the globs of the workspace, and a repository with no workspace is one package.
|
|
312
|
-
* The result has absolute paths, in the order of the code units.
|
|
313
|
-
*/
|
|
314
|
-
export declare function packageFolders(root: string, globs?: readonly string[] | undefined): string[];
|
|
315
|
-
export type { ApiPage, ApiReportConfig, Bin, CliIo, DeclarationInfo, DiffLine, Entry, EntryFile, ImportBinding, LocalExport, Manifest, Mode, PackageReportOptions, PackageResult, Reexport, ReportOptions, RunOptions, RunResult, UnifiedDiffOptions };
|
|
299
|
+
export { type ApiPage, type ApiReportConfig, type Bin, type CliIo, type DeclarationInfo, type DiffLine, type Entry, type EntryFile, type FrontmatterValue, type ImportBinding, type LocalExport, type Manifest, type Mode, type PackageReportOptions, type PackageResult, type Reexport, type ReportOptions, type RunOptions, type RunResult, type UnifiedDiffOptions, globFolders, globToRegExp, packageFolders, workspaceGlobs };
|
|
316
300
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/declarations.ts","../src/diff.ts","../src/entries.ts","../src/page.ts","../src/reference.ts","../src/report.ts","../src/run.ts"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/declarations.ts","../src/diff.ts","../src/entries.ts","../src/page.ts","../src/reference.ts","../src/report.ts","../src/run.ts"],"mappings":";;;;;;;UAOiB;;WAEN;;W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UAGK,mBAAmB;WACzB,MAAM;;WAEN;;WAEA;;;UAIM;;WAEN;;WAEA;;;;;;;WAOA;;WAEA;WACA;;WAEA;;WAEA;;;UAIM;WACN,MAAM;WACN,mBAAmB;;WAEnB;;;;;;;;wBASK,WAAW,eAAe;;;;;;;wBAkI1B,WAAW,SAAS,aAAa;;wBAiGjC,aAAa,QAAQ,WAAW;;wBA6BhC,gBAAgB,QAAQ;;UAavB;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBAqBG,OAAO,yBAAyB,IAAI"}
|
package/build/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as diffLines, E as statementsOf, S as targetOf, T as parseDeclarations, _ as byCode, a as runCli, b as patternMatch, c as DEFAULT_TOOL, d as packageReport, f as referencePage, g as binsOf, h as PUBLISH_CONFIG_FIELDS, i as readConfig, l as HEADER_LINES, m as reportEntries, n as USAGE, o as runReports, p as pageFaults, r as formatResult, s as summaryMarkdown, t as REPORT_FILE, u as apiReport, v as declarationPathOf, w as unifiedDiff, x as publishedManifest, y as entriesOf } from "./run-Czt-_0nW.js";
|
|
2
|
+
import { globFolders, globToRegExp, packageFolders, workspaceGlobs } from "@mark1russell7/conventions/workspace";
|
|
3
|
+
export { DEFAULT_TOOL, HEADER_LINES, PUBLISH_CONFIG_FIELDS, REPORT_FILE, USAGE, apiReport, binsOf, byCode, declarationPathOf, diffLines, entriesOf, formatResult, globFolders, globToRegExp, packageFolders, packageReport, pageFaults, parseDeclarations, patternMatch, publishedManifest, readConfig, referencePage, reportEntries, runCli, runReports, statementsOf, summaryMarkdown, targetOf, unifiedDiff, workspaceGlobs };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { globFolders, packageFolders, workspaceGlobs } from "@mark1russell7/conventions/workspace";
|
|
3
4
|
// src/declarations.ts
|
|
4
5
|
const BLOCK_HEADER = /^(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:abstract\s+class|class|interface|const\s+enum|enum|namespace|module|global)\b/;
|
|
5
6
|
const NAME_START = String.raw`[\p{ID_Start}$_]`;
|
|
@@ -896,14 +897,21 @@ function withExportNames(code, items) {
|
|
|
896
897
|
* names. A declaration shows one time, in the first entry that reaches it. A comment tells the name of an
|
|
897
898
|
* export when the source gave the declaration a different name. A name from a bundler does not show. A
|
|
898
899
|
* comment also tells the package of an external name.
|
|
900
|
+
*
|
|
901
|
+
* The fields of `frontmatter` go into the front matter, after the title and the description. A field `title` or
|
|
902
|
+
* `description` replaces the default.
|
|
899
903
|
*/
|
|
900
|
-
function referencePage(report, packageName) {
|
|
904
|
+
function referencePage(report, packageName, frontmatter = {}) {
|
|
901
905
|
const { entries, declarations } = readReport(report);
|
|
906
|
+
const fields = {
|
|
907
|
+
title: `Each export of ${packageName}`,
|
|
908
|
+
description: `Each entry point of ${packageName}, with its exports and their declarations.`,
|
|
909
|
+
...frontmatter
|
|
910
|
+
};
|
|
902
911
|
const out = [
|
|
903
912
|
"---",
|
|
904
913
|
"# The command `api-report update` writes this file from the report of the package. Do not edit it.",
|
|
905
|
-
|
|
906
|
-
`description: ${JSON.stringify(`Each entry point of ${packageName}, with its exports and their declarations.`)}`,
|
|
914
|
+
...Object.entries(fields).map(([key, value]) => `${key}: ${JSON.stringify(value)}`),
|
|
907
915
|
"---",
|
|
908
916
|
"",
|
|
909
917
|
"The report of the API of the package makes this page, so the page and the package have the same names. Each section is one entry point. A declaration shows one time, in the first section that has it."
|
|
@@ -1236,134 +1244,6 @@ function packageReport(dir, options = {}) {
|
|
|
1236
1244
|
...options.tool === void 0 ? {} : { tool: options.tool }
|
|
1237
1245
|
});
|
|
1238
1246
|
}
|
|
1239
|
-
// src/workspace.ts
|
|
1240
|
-
/**
|
|
1241
|
-
* The package folders of a repository: the folders that the globs of the workspace name, with a
|
|
1242
|
-
* `package.json` file.
|
|
1243
|
-
*/
|
|
1244
|
-
/** The characters that have a meaning in a regular expression. */
|
|
1245
|
-
const SPECIAL = /* @__PURE__ */ new Set([..."\\^$.|+()[]{}*?/"]);
|
|
1246
|
-
/**
|
|
1247
|
-
* This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path
|
|
1248
|
-
* segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of
|
|
1249
|
-
* its parts. The function escapes each other special character.
|
|
1250
|
-
*/
|
|
1251
|
-
function globToRegExp(glob) {
|
|
1252
|
-
let source = "";
|
|
1253
|
-
let braces = 0;
|
|
1254
|
-
for (let index = 0; index < glob.length; index++) {
|
|
1255
|
-
const char = glob.charAt(index);
|
|
1256
|
-
if (char === "/" && glob.slice(index + 1) === "**") {
|
|
1257
|
-
source += "(?:/.*)?";
|
|
1258
|
-
break;
|
|
1259
|
-
}
|
|
1260
|
-
if (char === "*" && glob.charAt(index + 1) === "*") {
|
|
1261
|
-
const atStart = index === 0 || glob.charAt(index - 1) === "/";
|
|
1262
|
-
const after = glob.charAt(index + 2);
|
|
1263
|
-
if (atStart && after === "/") {
|
|
1264
|
-
source += "(?:[^/]+/)*";
|
|
1265
|
-
index += 2;
|
|
1266
|
-
} else if (atStart && after === "") {
|
|
1267
|
-
source += ".*";
|
|
1268
|
-
index += 1;
|
|
1269
|
-
} else {
|
|
1270
|
-
source += "[^/]*";
|
|
1271
|
-
index += 1;
|
|
1272
|
-
}
|
|
1273
|
-
} else if (char === "*") source += "[^/]*";
|
|
1274
|
-
else if (char === "?") source += "[^/]";
|
|
1275
|
-
else if (char === "{") {
|
|
1276
|
-
braces++;
|
|
1277
|
-
source += "(?:";
|
|
1278
|
-
} else if (char === "}" && braces > 0) {
|
|
1279
|
-
braces--;
|
|
1280
|
-
source += ")";
|
|
1281
|
-
} else if (char === "," && braces > 0) source += "|";
|
|
1282
|
-
else if (SPECIAL.has(char)) source += `\\${char}`;
|
|
1283
|
-
else source += char;
|
|
1284
|
-
}
|
|
1285
|
-
if (braces > 0) throw new Error(`A glob with a "{" that has no "}": ${glob}`);
|
|
1286
|
-
return new RegExp(`^${source}$`);
|
|
1287
|
-
}
|
|
1288
|
-
/** The characters that make a path segment a pattern. */
|
|
1289
|
-
const GLOB_CHARS = /[*?{]/;
|
|
1290
|
-
/** This function removes the `/` characters at the end of a path, with a loop in place of a regular expression. */
|
|
1291
|
-
function trimEndSlashes(path) {
|
|
1292
|
-
let end = path.length;
|
|
1293
|
-
while (end > 0 && path.charAt(end - 1) === "/") end -= 1;
|
|
1294
|
-
return path.slice(0, end);
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
|
-
* This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,
|
|
1298
|
-
* in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.
|
|
1299
|
-
*/
|
|
1300
|
-
function globFolders(root, glob) {
|
|
1301
|
-
const clean = trimEndSlashes(glob.startsWith("./") ? glob.slice(2) : glob);
|
|
1302
|
-
const segments = clean.split("/");
|
|
1303
|
-
const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));
|
|
1304
|
-
if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];
|
|
1305
|
-
const base = segments.slice(0, firstPattern).join("/");
|
|
1306
|
-
const depth = clean.includes("**") ? Number.POSITIVE_INFINITY : segments.length - firstPattern;
|
|
1307
|
-
const pattern = globToRegExp(clean);
|
|
1308
|
-
const start = join(root, base);
|
|
1309
|
-
if (!existsSync(start)) return [];
|
|
1310
|
-
const found = [];
|
|
1311
|
-
const walk = (folder, level) => {
|
|
1312
|
-
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
|
1313
|
-
if (!entry.isDirectory() || entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
1314
|
-
const path = join(folder, entry.name);
|
|
1315
|
-
if (pattern.test(relativePath(root, path))) found.push(relativePath(root, path));
|
|
1316
|
-
if (level < depth) walk(path, level + 1);
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
if (base !== "" && pattern.test(base)) found.push(base);
|
|
1320
|
-
walk(start, 1);
|
|
1321
|
-
return found.sort(byCode);
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* This function gives the globs of the workspace at `root`: the `packages` list of
|
|
1325
|
-
* `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when
|
|
1326
|
-
* the repository has no workspace.
|
|
1327
|
-
*/
|
|
1328
|
-
function workspaceGlobs(root) {
|
|
1329
|
-
const yaml = join(root, "pnpm-workspace.yaml");
|
|
1330
|
-
if (existsSync(yaml)) {
|
|
1331
|
-
const lines = readFileSync(yaml, "utf8").split(/\r?\n/);
|
|
1332
|
-
const start = lines.findIndex((line) => /^packages\s*:/.test(line));
|
|
1333
|
-
if (start >= 0) {
|
|
1334
|
-
const unquote = (text) => text.replace(/\s+#.*$/, "").trim().replace(/^["']|["']$/g, "");
|
|
1335
|
-
const inline = /^packages\s*:\s*\[(.*)\]/.exec(lines[start] ?? "");
|
|
1336
|
-
if (inline) return (inline[1] ?? "").split(",").map(unquote).filter(Boolean);
|
|
1337
|
-
const globs = [];
|
|
1338
|
-
for (const line of lines.slice(start + 1)) {
|
|
1339
|
-
if (/^\s*(#.*)?$/.test(line)) continue;
|
|
1340
|
-
const item = /^\s+-\s+(.+)$/.exec(line);
|
|
1341
|
-
if (!item) break;
|
|
1342
|
-
globs.push(unquote(item[1] ?? ""));
|
|
1343
|
-
}
|
|
1344
|
-
return globs;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
const manifestFile = join(root, "package.json");
|
|
1348
|
-
if (existsSync(manifestFile)) {
|
|
1349
|
-
const { workspaces } = JSON.parse(readFileSync(manifestFile, "utf8"));
|
|
1350
|
-
if (Array.isArray(workspaces)) return workspaces.filter((glob) => typeof glob === "string");
|
|
1351
|
-
if (typeof workspaces === "object" && workspaces !== null && "packages" in workspaces && Array.isArray(workspaces.packages)) return workspaces.packages.filter((glob) => typeof glob === "string");
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* This function gives the package folders of the repository at `root`: the folders of the globs
|
|
1356
|
-
* that have a `package.json` file. A glob that starts with `!` removes folders. Without globs, the
|
|
1357
|
-
* function reads the globs of the workspace, and a repository with no workspace is one package.
|
|
1358
|
-
* The result has absolute paths, in the order of the code units.
|
|
1359
|
-
*/
|
|
1360
|
-
function packageFolders(root, globs = workspaceGlobs(root)) {
|
|
1361
|
-
if (globs === void 0) return existsSync(join(root, "package.json")) ? [root] : [];
|
|
1362
|
-
const included = /* @__PURE__ */ new Set();
|
|
1363
|
-
for (const glob of globs.filter((item) => !item.startsWith("!"))) for (const folder of globFolders(root, glob)) included.add(folder);
|
|
1364
|
-
for (const glob of globs.filter((item) => item.startsWith("!"))) for (const folder of globFolders(root, glob.slice(1))) included.delete(folder);
|
|
1365
|
-
return [...included].filter((folder) => existsSync(join(root, folder, "package.json"))).sort(byCode).map((folder) => join(root, folder));
|
|
1366
|
-
}
|
|
1367
1247
|
// src/run.ts
|
|
1368
1248
|
/**
|
|
1369
1249
|
* The commands `check` and `update` of the bin `api-report`, as functions. `runReports` compares or
|
|
@@ -1421,15 +1301,18 @@ function readPages(value) {
|
|
|
1421
1301
|
return value.map((item, index) => {
|
|
1422
1302
|
const at = `apiReport.pages[${index}]`;
|
|
1423
1303
|
if (typeof item !== "object" || item === null || Array.isArray(item)) throw new Error(`${at} must be an object.`);
|
|
1424
|
-
const { package: folder, pages, except, reference } = item;
|
|
1304
|
+
const { package: folder, pages, except, reference, frontmatter } = item;
|
|
1425
1305
|
if (typeof folder !== "string" || folder === "") throw new Error(`${at}.package must be a string.`);
|
|
1426
1306
|
if (reference !== void 0 && (typeof reference !== "string" || !isRootPath(reference))) throw new Error(`${at}.reference must be a path in the repository.`);
|
|
1427
1307
|
const emptyOk = reference !== void 0;
|
|
1428
1308
|
if (!Array.isArray(pages) || pages.length === 0 && !emptyOk || !pages.every((page) => typeof page === "string")) throw new Error(`${at}.pages must be an array of paths.`);
|
|
1309
|
+
if (frontmatter !== void 0 && reference === void 0) throw new Error(`${at}.frontmatter needs the field reference.`);
|
|
1310
|
+
const fields = frontmatter === void 0 ? void 0 : readFrontmatter(frontmatter, `${at}.frontmatter`);
|
|
1429
1311
|
const named = {
|
|
1430
1312
|
package: folder,
|
|
1431
1313
|
pages,
|
|
1432
|
-
...reference === void 0 ? {} : { reference }
|
|
1314
|
+
...reference === void 0 ? {} : { reference },
|
|
1315
|
+
...fields === void 0 ? {} : { frontmatter: fields }
|
|
1433
1316
|
};
|
|
1434
1317
|
if (except === void 0) return named;
|
|
1435
1318
|
if (typeof except !== "object" || except === null || Array.isArray(except) || !Object.values(except).every((reason) => typeof reason === "string")) throw new Error(`${at}.except must be an object of names and reasons.`);
|
|
@@ -1439,6 +1322,15 @@ function readPages(value) {
|
|
|
1439
1322
|
};
|
|
1440
1323
|
});
|
|
1441
1324
|
}
|
|
1325
|
+
/** This function reads the field `frontmatter` of an item of `pages`: names of fields, each with a text, a number or a boolean. */
|
|
1326
|
+
function readFrontmatter(value, at) {
|
|
1327
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${at} must be an object of fields.`);
|
|
1328
|
+
for (const [key, field] of Object.entries(value)) {
|
|
1329
|
+
if (!/^[A-Za-z_][\w-]*$/.test(key)) throw new Error(`${at} has a field name that is not a plain name: ${JSON.stringify(key)}.`);
|
|
1330
|
+
if (!(typeof field === "string" || typeof field === "boolean" || typeof field === "number")) throw new Error(`${at}.${key} must be a text, a number or a boolean.`);
|
|
1331
|
+
}
|
|
1332
|
+
return value;
|
|
1333
|
+
}
|
|
1442
1334
|
/** This function is true for a relative path with no `..`. */
|
|
1443
1335
|
function isRootPath(path) {
|
|
1444
1336
|
const clean = path.replaceAll("\\", "/");
|
|
@@ -1453,7 +1345,7 @@ function faultsOfPages(root, entry, report, packageName) {
|
|
|
1453
1345
|
const missing = entry.pages.filter((page) => !existsSync(resolve(root, page)));
|
|
1454
1346
|
if (missing.length > 0) return missing.map((page) => `${page}: the page does not exist.`);
|
|
1455
1347
|
const faults = [];
|
|
1456
|
-
if (entry.reference !== void 0 && textOf(resolve(root, entry.reference)) !== referencePage(report, packageName)) faults.push(`${entry.reference}: the page differs from the report. Start the command update, and commit the page.`);
|
|
1348
|
+
if (entry.reference !== void 0 && textOf(resolve(root, entry.reference)) !== referencePage(report, packageName, entry.frontmatter)) faults.push(`${entry.reference}: the page differs from the report. Start the command update, and commit the page.`);
|
|
1457
1349
|
const pages = entry.pages.map((page) => readFileSync(resolve(root, page), "utf8"));
|
|
1458
1350
|
return [...faults, ...pageFaults(report, packageName, pages, entry.except, entry.reference !== void 0)];
|
|
1459
1351
|
}
|
|
@@ -1461,7 +1353,7 @@ function faultsOfPages(root, entry, report, packageName) {
|
|
|
1461
1353
|
function writeReference(root, entry, report, packageName) {
|
|
1462
1354
|
if (entry.reference === void 0) return [];
|
|
1463
1355
|
const file = resolve(root, entry.reference);
|
|
1464
|
-
const text = referencePage(report, packageName);
|
|
1356
|
+
const text = referencePage(report, packageName, entry.frontmatter);
|
|
1465
1357
|
if (textOf(file) === text) return [];
|
|
1466
1358
|
mkdirSync(dirname(file), { recursive: true });
|
|
1467
1359
|
writeFileSync(file, text);
|
|
@@ -1747,6 +1639,6 @@ function runCli(args, io) {
|
|
|
1747
1639
|
}
|
|
1748
1640
|
return result.failed ? 1 : 0;
|
|
1749
1641
|
}
|
|
1750
|
-
export {
|
|
1642
|
+
export { diffLines as C, statementsOf as E, targetOf as S, parseDeclarations as T, byCode as _, runCli as a, patternMatch as b, DEFAULT_TOOL as c, packageReport as d, referencePage as f, binsOf as g, PUBLISH_CONFIG_FIELDS as h, readConfig as i, HEADER_LINES as l, reportEntries as m, USAGE as n, runReports as o, pageFaults as p, formatResult as r, summaryMarkdown as s, REPORT_FILE as t, apiReport as u, declarationPathOf as v, unifiedDiff as w, publishedManifest as x, entriesOf as y };
|
|
1751
1643
|
|
|
1752
|
-
//# sourceMappingURL=run-
|
|
1644
|
+
//# sourceMappingURL=run-Czt-_0nW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-Czt-_0nW.js","names":[],"sources":["../src/declarations.ts","../src/diff.ts","../src/entries.ts","../src/page.ts","../src/reference.ts","../src/report.ts","../src/run.ts"],"sourcesContent":["/**\n * The reader of the text of a declaration file. TypeScript 7 has no stable compiler API, so this\n * module reads the `.d.ts` files as text. The declaration emit of `tsc` and of `tsdown` is regular,\n * and an unknown form of statement throws.\n */\n\n/** An import of a declaration file, by its local name. */\nexport interface ImportBinding {\n /** The module specifier. */\n readonly from: string;\n /** The imported name, or `default`, `export=` or `*`. */\n readonly imported: string;\n readonly typeOnly: boolean;\n}\n\n/** A name that a module exports from its own scope. */\nexport interface LocalExport {\n /** The local name of the exported name. */\n readonly local: string;\n readonly typeOnly: boolean;\n}\n\n/** A part of an `export { a as b } from \"x\"` statement. */\nexport interface Reexport {\n readonly imported: string;\n readonly exported: string;\n readonly typeOnly: boolean;\n readonly from: string;\n}\n\n/** The statements of one declaration file, sorted by their kind. */\nexport interface DeclarationInfo {\n /** The declarations of the module by name, exported or not. */\n readonly locals: Map<string, string[]>;\n /** The names that the module exports from its own scope, by the exported name. */\n readonly exported: Map<string, LocalExport>;\n /** The `export { a as b } from \"x\"` parts. */\n readonly reexports: Reexport[];\n /** The `export * from \"x\"` statements. */\n readonly stars: { readonly from: string; readonly typeOnly: boolean }[];\n /** The `export * as name from \"x\"` statements. */\n readonly namespaces: { readonly name: string; readonly from: string; readonly typeOnly: boolean }[];\n /** The imports by local name. */\n readonly imports: Map<string, ImportBinding>;\n /** The ambient declarations by label: `declare module \"x\"`, `declare global`, `export as namespace X`. */\n readonly ambient: Map<string, string[]>;\n /** Each module specifier that the file names: the files that it reaches. */\n readonly references: Set<string>;\n}\n\n/** A mode of the reader of a template literal. */\ntype Mode = { readonly kind: \"template\" } | { readonly kind: \"part\"; readonly depth: number };\n\nconst BLOCK_HEADER = /^(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+class|class|interface|const\\s+enum|enum|namespace|module|global)\\b/;\n\n// A name of the ECMAScript grammar: a start letter, then continue letters. The letters include the letters that are not ASCII.\nconst NAME_START = String.raw`[\\p{ID_Start}$_]`;\nconst NAME_PART = String.raw`[\\p{ID_Continue}$]`;\nconst NAME = `${NAME_START}${NAME_PART}*`;\n\n/** This tag makes a pattern with the flag `u` from raw text. The `\\p{...}` classes of a name need that flag. */\nfunction unicode(strings: TemplateStringsArray, ...parts: string[]): RegExp {\n return new RegExp(String.raw({ raw: strings.raw }, ...parts), \"u\");\n}\n\nconst SPECIFIER = unicode`^(type\\s+)?(${NAME})(?:\\s+as\\s+(${NAME}|\"[^\"]*\"))?$`;\nconst PRIVATE_MEMBER = unicode`^\\s+(?:private\\s+(?:static\\s+)?(?:readonly\\s+)?${NAME}\\??;|#private;)$`;\nconst DEFAULT_IMPORT = unicode`^(${NAME})\\s*(?:,|$)`;\nconst NAMESPACE_IMPORT = unicode`^\\* as (${NAME})$`;\nconst IMPORT_REQUIRE = unicode`^(export )?import (type )?(${NAME}) = require\\([\"']([^\"']+)[\"']\\);?$`;\nconst IMPORT_ALIAS = unicode`^(export )?import (${NAME}) = ${NAME}(?:\\.${NAME})*;?$`;\nconst NAMESPACE_EXPORT = unicode`^export (type )?\\* as (${NAME}) from [\"']([^\"']+)[\"'];?$`;\nconst EXPORT_ASSIGNMENT = unicode`^export = (${NAME});?$`;\nconst EXPORT_AS_NAMESPACE = unicode`^export as namespace (${NAME});?$`;\nconst DEFAULT_NAME = unicode`^export default (${NAME});?$`;\n// The negative lookahead stops `classX` as a keyword. The name is empty for a default function or class without a name.\nconst NAMELESS_DEFAULT = unicode`^export default (?:declare )?(?:abstract )?(?:class|function\\*?)(?!${NAME_PART})\\s*((?:${NAME})?)`;\nconst DECLARATOR = unicode`^\\s*(${NAME})`;\nconst DECLARATION = unicode`^(export )?(default )?(?:declare )?(?:abstract )?(?:const (?=enum))?(?:function|class|interface|type|enum|namespace|module) (${NAME})`;\n\n/**\n * This function splits the text of a declaration file into its top-level statements. It removes the\n * comments, the blank lines and the spaces at the ends of the lines.\n */\nexport function statementsOf(source: string): string[] {\n // The declarations of a bin file keep its `#!` line\n const text = source.replace(/\\r\\n?/g, \"\\n\").replace(/^#![^\\n]*\\n?/, \"\");\n const statements: string[] = [];\n let current = \"\";\n let depth = 0;\n // The depth of the type arguments at the top level: `class A<T = {}> {` has a brace in them\n let angle = 0;\n // True when the body of a class, an interface, an enum or a namespace is open\n let body = false;\n // The template literals and their `${ }` parts, from the outside in\n const modes: Mode[] = [];\n\n const finish = (): void => {\n const lines = current\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .filter((line) => line.trim() !== \"\");\n if (lines.length > 0) statements.push(lines.join(\"\\n\"));\n current = \"\";\n angle = 0;\n body = false;\n };\n\n let index = 0;\n while (index < text.length) {\n const char = text.charAt(index);\n const next = text.charAt(index + 1);\n const mode = modes.at(-1);\n if (mode?.kind === \"template\") {\n if (char === \"\\\\\") {\n current += char + next;\n index += 2;\n } else if (char === \"`\") {\n modes.pop();\n current += char;\n index++;\n } else if (char === \"$\" && next === \"{\") {\n modes.push({ kind: \"part\", depth });\n current += \"${\";\n index += 2;\n } else {\n current += char;\n index++;\n }\n continue;\n }\n if (char === \"/\" && next === \"/\") {\n while (index < text.length && text.charAt(index) !== \"\\n\") index++;\n continue;\n }\n if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end < 0 ? text.length : end + 2;\n current += \" \";\n continue;\n }\n if (char === '\"' || char === \"'\") {\n let end = index + 1;\n while (end < text.length && text.charAt(end) !== char) end += text.charAt(end) === \"\\\\\" ? 2 : 1;\n current += text.slice(index, end + 1);\n index = end + 1;\n continue;\n }\n if (char === \"`\") {\n modes.push({ kind: \"template\" });\n current += char;\n index++;\n continue;\n }\n if (modes.length === 0 && depth === 0) {\n // The `>` of an arrow `=>` closes nothing\n if (char === \"<\") angle++;\n else if (char === \">\" && text.charAt(index - 1) !== \"=\") angle = Math.max(0, angle - 1);\n else if (char === \"{\" && angle === 0 && !body && BLOCK_HEADER.test(current.trim())) body = true;\n }\n if (char === \"{\" || char === \"(\" || char === \"[\") depth++;\n if (char === \"}\" || char === \")\" || char === \"]\") {\n if (char === \"}\" && mode?.kind === \"part\" && depth === mode.depth) {\n modes.pop();\n current += char;\n index++;\n continue;\n }\n depth--;\n }\n current += char;\n index++;\n if (modes.length > 0 || depth !== 0) continue;\n if (char === \";\" || (char === \"}\" && body)) finish();\n }\n finish();\n return statements;\n}\n\n/** This function splits `text` at each comma outside brackets, type arguments and strings. */\nfunction splitTopLevel(text: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let index = 0; index < text.length; index++) {\n const char = text.charAt(index);\n if (char === '\"' || char === \"'\" || char === \"`\") {\n let end = index + 1;\n while (end < text.length && text.charAt(end) !== char) end += text.charAt(end) === \"\\\\\" ? 2 : 1;\n index = end;\n } else if (char === \"(\" || char === \"[\" || char === \"{\" || char === \"<\") depth++;\n else if (char === \")\" || char === \"]\" || char === \"}\" || (char === \">\" && text.charAt(index - 1) !== \"=\")) depth--;\n else if (char === \",\" && depth === 0) {\n parts.push(text.slice(start, index));\n start = index + 1;\n }\n }\n parts.push(text.slice(start));\n return parts;\n}\n\n/** The names of an export or import list: `a, type b, c as d`. */\nfunction specifiersOf(list: string, typeOnly: boolean): { imported: string; exported: string; typeOnly: boolean }[] {\n return list\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part !== \"\")\n .map((part) => {\n const match = SPECIFIER.exec(part);\n if (!match?.[2]) throw new Error(`An export list part that the report does not know: ${part}`);\n return { imported: match[2], exported: match[3] ?? match[2], typeOnly: typeOnly || match[1] !== undefined };\n });\n}\n\n/** This function removes the private members of a class: they are not part of the API. */\nfunction withoutPrivateMembers(statement: string): string {\n return statement\n .split(\"\\n\")\n .filter((line) => !PRIVATE_MEMBER.test(line))\n .join(\"\\n\");\n}\n\n/** A capture group of a match that the pattern always sets. */\nconst group = (match: RegExpExecArray, index: number): string => match[index] ?? \"\";\n\n/**\n * This function sorts the statements of the text of one declaration file by their kind. `file`\n * names the file in the errors. An unknown form of statement throws.\n */\nexport function parseDeclarations(source: string, file = \"<text>\"): DeclarationInfo {\n const info: DeclarationInfo = {\n locals: new Map(),\n exported: new Map(),\n reexports: [],\n stars: [],\n namespaces: [],\n imports: new Map(),\n ambient: new Map(),\n references: new Set(),\n };\n const addLocal = (name: string, statement: string): void => {\n info.locals.set(name, [...(info.locals.get(name) ?? []), statement]);\n };\n const addAmbient = (label: string, statement: string): void => {\n info.ambient.set(label, [...(info.ambient.get(label) ?? []), statement]);\n };\n for (const statement of statementsOf(source)) {\n const flat = statement.replace(/\\s+/g, \" \");\n for (const found of flat.matchAll(/\\bimport\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/g)) info.references.add(found[1] ?? \"\");\n let match: RegExpExecArray | null;\n if ((match = /^import (type )?(.+?) from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n const typeOnly = match[1] !== undefined;\n const from = group(match, 3);\n info.references.add(from);\n let clause = group(match, 2).trim();\n const defaultName = DEFAULT_IMPORT.exec(clause);\n if (defaultName) {\n info.imports.set(group(defaultName, 1), { from, imported: \"default\", typeOnly });\n clause = clause.slice(defaultName[0].length).trim();\n }\n const namespace = NAMESPACE_IMPORT.exec(clause);\n if (namespace) info.imports.set(group(namespace, 1), { from, imported: \"*\", typeOnly });\n const braces = /^\\{(.*)\\}$/.exec(clause);\n if (braces) {\n for (const specifier of specifiersOf(group(braces, 1), typeOnly)) {\n info.imports.set(specifier.exported, { from, imported: specifier.imported, typeOnly: specifier.typeOnly });\n }\n }\n continue;\n }\n if ((match = /^import [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n info.references.add(group(match, 1));\n continue;\n }\n // `import x = require(\"y\")`: the name is the `export =` of the module\n if ((match = IMPORT_REQUIRE.exec(flat))) {\n const name = group(match, 3);\n info.references.add(group(match, 4));\n info.imports.set(name, { from: group(match, 4), imported: \"export=\", typeOnly: match[2] !== undefined });\n if (match[1] !== undefined) info.exported.set(name, { local: name, typeOnly: false });\n continue;\n }\n // `import A = N.B`: an alias of a name of a namespace\n if ((match = IMPORT_ALIAS.exec(flat))) {\n const name = group(match, 2);\n addLocal(name, statement);\n if (match[1] !== undefined) info.exported.set(name, { local: name, typeOnly: false });\n continue;\n }\n if ((match = NAMESPACE_EXPORT.exec(flat))) {\n info.references.add(group(match, 3));\n info.namespaces.push({ name: group(match, 2), from: group(match, 3), typeOnly: match[1] !== undefined });\n continue;\n }\n if ((match = /^export (type )?\\* from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n info.references.add(group(match, 2));\n info.stars.push({ from: group(match, 2), typeOnly: match[1] !== undefined });\n continue;\n }\n if ((match = /^export (type )?\\{(.*)\\} from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n const from = group(match, 3);\n info.references.add(from);\n for (const specifier of specifiersOf(group(match, 2), match[1] !== undefined)) info.reexports.push({ ...specifier, from });\n continue;\n }\n if ((match = /^export (type )?\\{(.*)\\};?$/.exec(flat))) {\n for (const specifier of specifiersOf(group(match, 2), match[1] !== undefined)) {\n info.exported.set(specifier.exported, { local: specifier.imported, typeOnly: specifier.typeOnly });\n }\n continue;\n }\n // `export = X`: the module is the value X (CommonJS)\n if ((match = EXPORT_ASSIGNMENT.exec(flat))) {\n info.exported.set(\"export=\", { local: group(match, 1), typeOnly: false });\n continue;\n }\n if (/^export = /.test(flat)) {\n addLocal(\"export=\", statement);\n info.exported.set(\"export=\", { local: \"export=\", typeOnly: false });\n continue;\n }\n if ((match = /^(?:export )?declare module ([\"'][^\"']+[\"'])/.exec(flat))) {\n addAmbient(`declare module ${group(match, 1).replaceAll(\"'\", '\"')}`, statement);\n continue;\n }\n if (/^(?:export )?(?:declare )?global \\{/.test(flat)) {\n addAmbient(\"declare global\", statement);\n continue;\n }\n if ((match = EXPORT_AS_NAMESPACE.exec(flat))) {\n addAmbient(`export as namespace ${group(match, 1)}`, statement);\n continue;\n }\n // `export default x`: the default export is a name of the module\n if ((match = DEFAULT_NAME.exec(flat))) {\n info.exported.set(\"default\", { local: group(match, 1), typeOnly: false });\n continue;\n }\n // A default function or class without a name\n match = NAMELESS_DEFAULT.exec(flat);\n if (match && (match[1] === \"\" || match[1] === \"extends\" || match[1] === \"implements\")) {\n addLocal(\"default\", withoutPrivateMembers(statement));\n info.exported.set(\"default\", { local: \"default\", typeOnly: false });\n continue;\n }\n // `const a: A, b: B` declares two names\n if ((match = /^(export )?(?:declare )?(?:const|let|var) (?!enum\\b)(.*?);?$/.exec(flat))) {\n const exported = match[1] !== undefined;\n for (const part of splitTopLevel(group(match, 2))) {\n const name = DECLARATOR.exec(part);\n if (!name) throw new Error(`A declaration that the report does not know, in ${file}:\\n${statement}`);\n addLocal(group(name, 1), statement);\n if (exported) info.exported.set(group(name, 1), { local: group(name, 1), typeOnly: false });\n }\n continue;\n }\n match = DECLARATION.exec(flat);\n if (match) {\n const name = group(match, 3);\n addLocal(name, withoutPrivateMembers(statement));\n if (match[1] !== undefined) info.exported.set(match[2] !== undefined ? \"default\" : name, { local: name, typeOnly: false });\n continue;\n }\n // `export default <expression>`\n if (/^export default /.test(flat)) {\n addLocal(\"default\", statement);\n info.exported.set(\"default\", { local: \"default\", typeOnly: false });\n continue;\n }\n throw new Error(`A statement that the report does not know, in ${file}:\\n${statement}`);\n }\n return info;\n}\n","/** A line diff (the algorithm of Myers) and its text in the unified format of `diff -u` and git. */\n\n/** An operation of a line diff: a kept line, a removed line or an added line. */\nexport interface DiffLine {\n readonly kind: \" \" | \"-\" | \"+\";\n readonly text: string;\n}\n\n/** Above this number of changes, the diff replaces the whole changed part, so the memory stays small. */\nconst MAX_EDITS = 2000;\n\n/** This function gives the shortest edit script that changes the lines `before` into the lines `after`. */\nexport function diffLines(before: readonly string[], after: readonly string[]): DiffLine[] {\n // The common start and end need no search\n let start = 0;\n while (start < before.length && start < after.length && before[start] === after[start]) start++;\n let end = 0;\n while (end < before.length - start && end < after.length - start && before[before.length - 1 - end] === after[after.length - 1 - end]) end++;\n const a = before.slice(start, before.length - end);\n const b = after.slice(start, after.length - end);\n const kept = (lines: readonly string[]): DiffLine[] => lines.map((text) => ({ kind: \" \", text }));\n return [...kept(before.slice(0, start)), ...middle(a, b), ...kept(before.slice(before.length - end))];\n}\n\n/** This function gives the edit script of two lists that have different first lines and different last lines. */\nfunction middle(a: readonly string[], b: readonly string[]): DiffLine[] {\n const n = a.length;\n const m = b.length;\n const replace = (): DiffLine[] => [...a.map((text): DiffLine => ({ kind: \"-\", text })), ...b.map((text): DiffLine => ({ kind: \"+\", text }))];\n if (n === 0 || m === 0) return replace();\n const max = Math.min(n + m, MAX_EDITS);\n const offset = max + 1;\n const v = new Int32Array(2 * max + 3);\n // trace[d] holds v[-d..d] before the step d\n const trace: Int32Array[] = [];\n for (let d = 0; d <= max; d++) {\n trace.push(v.slice(offset - d, offset + d + 1));\n for (let k = -d; k <= d; k += 2) {\n const down = k === -d || (k !== d && (v[offset + k - 1] ?? 0) < (v[offset + k + 1] ?? 0));\n let x = down ? (v[offset + k + 1] ?? 0) : (v[offset + k - 1] ?? 0) + 1;\n let y = x - k;\n while (x < n && y < m && a[x] === b[y]) {\n x++;\n y++;\n }\n v[offset + k] = x;\n if (x >= n && y >= m) return backtrack(a, b, trace);\n }\n }\n return replace();\n}\n\n/** This function follows the trace of the search back from the end, and gives the operations in order. */\nfunction backtrack(a: readonly string[], b: readonly string[], trace: readonly Int32Array[]): DiffLine[] {\n const result: DiffLine[] = [];\n let x = a.length;\n let y = b.length;\n for (let d = trace.length - 1; d >= 0; d--) {\n const v = trace[d] ?? new Int32Array(0);\n const at = (k: number): number => v[k + d] ?? 0;\n const k = x - y;\n const down = k === -d || (k !== d && at(k - 1) < at(k + 1));\n const previousK = down ? k + 1 : k - 1;\n const previousX = d === 0 ? 0 : at(previousK);\n const previousY = d === 0 ? 0 : previousX - previousK;\n while (x > previousX && y > previousY) {\n result.push({ kind: \" \", text: a[x - 1] ?? \"\" });\n x--;\n y--;\n }\n if (d === 0) break;\n if (down) result.push({ kind: \"+\", text: b[y - 1] ?? \"\" });\n else result.push({ kind: \"-\", text: a[x - 1] ?? \"\" });\n x = previousX;\n y = previousY;\n }\n return result.reverse();\n}\n\n/** The options of a unified diff. */\nexport interface UnifiedDiffOptions {\n /** The number of kept lines around each change. The default is 3. */\n readonly context?: number;\n /** The name of the file before the change, after `---`. */\n readonly from?: string;\n /** The name of the file after the change, after `+++`. */\n readonly to?: string;\n}\n\n/**\n * This function gives the change from the text `before` to the text `after` in the unified format.\n * The result is an empty string when the texts are the same.\n */\nexport function unifiedDiff(before: string, after: string, options: UnifiedDiffOptions = {}): string {\n const split = (text: string): string[] => (text === \"\" ? [] : text.replace(/\\n$/, \"\").split(\"\\n\"));\n const ops = diffLines(split(before), split(after));\n const context = options.context ?? 3;\n // The position of each operation in the two texts\n const positions: { a: number; b: number }[] = [];\n let a = 0;\n let b = 0;\n for (const op of ops) {\n positions.push({ a, b });\n if (op.kind !== \"+\") a++;\n if (op.kind !== \"-\") b++;\n }\n const changes = ops.flatMap((op, index) => (op.kind === \" \" ? [] : [index]));\n if (changes.length === 0) return \"\";\n const lines = [`--- ${options.from ?? \"before\"}`, `+++ ${options.to ?? \"after\"}`];\n let index = 0;\n while (index < changes.length) {\n const first = changes[index] ?? 0;\n let last = first;\n while (index + 1 < changes.length && (changes[index + 1] ?? 0) - last <= 2 * context) last = changes[++index] ?? last;\n index++;\n const from = Math.max(0, first - context);\n const to = Math.min(ops.length - 1, last + context);\n const hunk = ops.slice(from, to + 1);\n const start = positions[from] ?? { a: 0, b: 0 };\n const countA = hunk.filter((op) => op.kind !== \"+\").length;\n const countB = hunk.filter((op) => op.kind !== \"-\").length;\n // As in diff -u, an empty side starts at the line before the hunk\n const range = (line: number, count: number): string => `${count === 0 ? line : line + 1}${count === 1 ? \"\" : `,${count}`}`;\n lines.push(`@@ -${range(start.a, countA)} +${range(start.b, countB)} @@`);\n for (const op of hunk) lines.push(`${op.kind}${op.text}`);\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * The entries of a package for its report: the subpaths of the `exports` field (or `types` and\n * `main`), each with its declaration file, and the bins.\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { join, relative, resolve, sep } from \"node:path\";\n\n/** The fields of a `package.json` file that the report reads. */\nexport interface Manifest {\n readonly name?: string;\n readonly private?: boolean;\n readonly exports?: unknown;\n readonly imports?: unknown;\n readonly types?: unknown;\n readonly typings?: unknown;\n readonly main?: unknown;\n readonly bin?: unknown;\n readonly publishConfig?: Readonly<Record<string, unknown>>;\n readonly [field: string]: unknown;\n}\n\n/** A file that an entry without a declaration file exports: the subpath and the path of the file. */\nexport interface EntryFile {\n /** The subpath that a consumer imports, for example `./tsconfig/base.json`. */\n readonly subpath: string;\n /** The file, relative to the package folder, for example `./tsconfig/base.json`. */\n readonly path: string;\n}\n\n/** An entry of a package: a subpath and its declaration file, or a note when it has none. */\nexport interface Entry {\n /** The subpath of the `exports` field, for example `.` or `./client`. */\n readonly subpath: string;\n /** The declaration file, relative to the package folder, for example `./build/index.d.ts`. */\n readonly types?: string;\n /** This text tells why the entry has no declaration file. */\n readonly note?: string;\n /** The files that an entry without a declaration file exports, in the order of the subpaths. A removed file changes the report. */\n readonly files?: readonly EntryFile[];\n}\n\n/** A command of the `bin` field of a package. */\nexport interface Bin {\n readonly name: string;\n readonly path: string;\n}\n\n/** The conditions of the `exports` field that a TypeScript consumer can use, in no order. */\nconst CONDITIONS = new Set([\"types\", \"import\", \"node\", \"default\", \"require\"]);\n\n/**\n * The fields of `publishConfig` that pnpm puts in the published `package.json`. A source package of\n * the template has `main: ./src/index.ts`, and its `publishConfig` gives the built entries.\n */\nexport const PUBLISH_CONFIG_FIELDS: readonly string[] = [\"bin\", \"main\", \"module\", \"exports\", \"imports\", \"types\", \"typings\", \"typesVersions\", \"browser\"];\n\n/** The order of the code units: the same on each machine, with no locale. */\nexport const byCode = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** This function gives a path relative to `root`, with `/`. */\nexport const relativePath = (root: string, file: string): string => relative(root, file).split(sep).join(\"/\");\n\n/** This function gives the manifest as pnpm publishes it: the fields of `publishConfig` replace the fields of the source. */\nexport function publishedManifest(manifest: Manifest): Manifest {\n const config = manifest.publishConfig;\n if (!config) return manifest;\n const result: Record<string, unknown> = { ...manifest };\n for (const field of PUBLISH_CONFIG_FIELDS) if (config[field] !== undefined) result[field] = config[field];\n return result;\n}\n\n/**\n * This function gives the declaration file of a JavaScript or declaration path: `a.js` gives\n * `a.d.ts`, and `a.mjs` gives `a.d.mts`. The result is undefined for a file of another kind.\n */\nexport function declarationPathOf(path: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(path)) return path;\n const js = /\\.([mc]?)js$/.exec(path);\n if (js) return `${path.slice(0, -js[0].length)}.d.${js[1] ?? \"\"}ts`;\n return undefined;\n}\n\n/** This function matches `subpath` with the key `pattern` of an `exports` or `imports` field. It gives the part of the `*`. */\nexport function patternMatch(pattern: string, subpath: string): string | undefined {\n const star = pattern.indexOf(\"*\");\n if (star < 0) return pattern === subpath ? \"\" : undefined;\n const prefix = pattern.slice(0, star);\n const suffix = pattern.slice(star + 1);\n if (subpath.length < prefix.length + suffix.length || !subpath.startsWith(prefix) || !subpath.endsWith(suffix)) return undefined;\n return subpath.slice(prefix.length, subpath.length - suffix.length);\n}\n\n/**\n * This function gives the target of an `exports` value for a TypeScript consumer: the first known\n * condition, in the order of the object. The result is `null` for an excluded subpath, and undefined\n * when no condition fits.\n */\nexport function targetOf(value: unknown): string | null | undefined {\n if (value === null) return null;\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n for (const item of value) {\n const target = targetOf(item);\n if (typeof target === \"string\") return target;\n }\n return undefined;\n }\n if (typeof value === \"object\") {\n for (const [condition, inner] of Object.entries(value)) {\n if (!CONDITIONS.has(condition)) continue;\n const target = targetOf(inner);\n if (target !== undefined) return target;\n }\n }\n return undefined;\n}\n\n/** This function gives the `exports` field as a map of subpaths. */\nfunction subpathMap(exportsField: unknown): Record<string, unknown> {\n if (typeof exportsField !== \"object\" || Array.isArray(exportsField) || exportsField === null) return { \".\": exportsField };\n const keys = Object.keys(exportsField);\n if (keys.length > 0 && keys.every((key) => !key.startsWith(\".\"))) return { \".\": exportsField };\n return exportsField as Record<string, unknown>;\n}\n\n/** This function gives each file under `dir`, relative to `root` with `/`, without `node_modules`. */\nfunction filesUnder(root: string, dir: string): string[] {\n const start = join(root, dir);\n if (!existsSync(start) || !statSync(start).isDirectory()) return [];\n const found: string[] = [];\n const walk = (folder: string): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (entry.name === \"node_modules\" || entry.name === \".git\") continue;\n const path = join(folder, entry.name);\n if (entry.isDirectory()) walk(path);\n else found.push(relativePath(root, path));\n }\n };\n walk(start);\n return found.sort(byCode);\n}\n\n/**\n * This function gives each file under `root` that the target pattern `target` of the subpath\n * pattern `subpath` matches. Each file has its subpath, in the order of the subpaths. The function\n * skips each subpath that `isExcluded` excludes.\n */\nfunction patternFiles(root: string, subpath: string, target: string, isExcluded: (subpath: string) => boolean): EntryFile[] {\n const pattern = target.replace(/^\\.\\//, \"\");\n const folder = pattern.slice(0, pattern.indexOf(\"*\")).replace(/[^/]*$/, \"\");\n const matched: EntryFile[] = [];\n for (const file of filesUnder(root, folder)) {\n const part = patternMatch(pattern, file);\n if (part === undefined) continue;\n const expanded = subpath.split(\"*\").join(part);\n if (!isExcluded(expanded)) matched.push({ subpath: expanded, path: `./${file}` });\n }\n return matched.sort((a, b) => byCode(a.subpath, b.subpath) || byCode(a.path, b.path));\n}\n\n/** This function gives an entry without a declaration file, with the files that it exports. */\nfunction fileEntry(subpath: string, note: string, files: readonly EntryFile[]): Entry {\n return files.length > 0 ? { subpath, note, files } : { subpath, note };\n}\n\n/**\n * This function gives the entries of a package, in the order of the `exports` field. The\n * `./package.json` entry is not part of the API. A subpath pattern (`./*`) gives one entry for each\n * declaration file that it matches. An entry without a declaration file (for example a JSON or CSS\n * file) lists the files that it exports. `root` is the package folder.\n */\nexport function entriesOf(manifest: Manifest, root: string): Entry[] {\n const entries: Entry[] = [];\n const exists = (path: string): boolean => existsSync(resolve(root, path));\n if (manifest.exports === undefined) {\n // No `exports` field: TypeScript reads `types`, `typings`, then the declaration of `main`\n const field = manifest.types ?? manifest.typings;\n if (typeof field === \"string\") return [{ subpath: \".\", types: field }];\n const main = typeof manifest.main === \"string\" ? manifest.main : \"./index.js\";\n const types = declarationPathOf(main);\n if (types && exists(types)) return [{ subpath: \".\", types }];\n if (typeof manifest.main === \"string\") return [{ subpath: \".\", note: `no declaration file for main ${manifest.main}` }];\n return [];\n }\n const map = subpathMap(manifest.exports);\n const excluded = Object.entries(map)\n .filter(([, value]) => value === null)\n .map(([key]) => key);\n const isExcluded = (subpath: string): boolean => excluded.some((pattern) => patternMatch(pattern, subpath) !== undefined);\n for (const [subpath, value] of Object.entries(map)) {\n if (subpath === \"./package.json\" || value === null) continue;\n const target = targetOf(value);\n if (typeof target !== \"string\") {\n entries.push({ subpath, note: \"no condition for a TypeScript consumer\" });\n continue;\n }\n const declared = declarationPathOf(target);\n const own = (path: string): EntryFile[] => (exists(path) ? [{ subpath, path }] : []);\n if (!subpath.includes(\"*\")) {\n if (isExcluded(subpath)) continue;\n if (!declared) entries.push(fileEntry(subpath, `no declaration file for ${target}`, own(target)));\n // A JavaScript file without a declaration file has no types. A missing build throws later.\n else if (declared !== target && !exists(declared) && exists(target)) entries.push(fileEntry(subpath, `no declaration file for ${target}`, own(target)));\n else entries.push({ subpath, types: declared });\n continue;\n }\n if (!declared?.includes(\"*\")) {\n // A pattern of files that are not declarations, for example `./tsconfig/*.json`\n const files = target.includes(\"*\") ? patternFiles(root, subpath, target, isExcluded) : [];\n const note = files.length === 0 && target.includes(\"*\") ? `no file matches ${target}` : `no declaration pattern for ${target}`;\n entries.push(fileEntry(subpath, note, files));\n continue;\n }\n const matched = patternFiles(root, subpath, declared, isExcluded).map((file): Entry => ({ subpath: file.subpath, types: file.path }));\n if (matched.length === 0) entries.push({ subpath, note: `no file matches ${declared}` });\n entries.push(...matched);\n }\n return entries;\n}\n\n/** This function gives the commands of the `bin` field, in name order. A string `bin` has the name of the package without its scope. */\nexport function binsOf(manifest: Manifest): Bin[] {\n const { bin } = manifest;\n if (typeof bin === \"string\") return [{ name: (manifest.name ?? \"\").replace(/^@[^/]+\\//, \"\"), path: bin }];\n if (typeof bin !== \"object\" || bin === null) return [];\n return Object.entries(bin)\n .filter((entry): entry is [string, string] => typeof entry[1] === \"string\")\n .map(([name, path]) => ({ name, path }))\n .sort((a, b) => byCode(a.name, b.name));\n}\n","/**\n * The check of a hand-written page of an API against the report of its package. A page can explain each\n * call, and the check holds its names. Each export shows in the code of the page. The page gives no name\n * as an export that the package does not have.\n */\nimport { byCode } from \"./entries.ts\";\n\n/** The value of one field of the front matter of the page of each export. */\nexport type FrontmatterValue = string | number | boolean;\n\n/** One package and the pages that tell its API: an item of the field `pages` of `apiReport`. */\nexport interface ApiPage {\n /** The folder of the package, relative to the root. */\n readonly package: string;\n /** The Markdown or MDX files of the page, relative to the root. Together they tell the API. The list can be empty when `reference` is present. */\n readonly pages: readonly string[];\n /** The file of a page of each export, relative to the root. The command `update` writes it from the report, and the command `check` compares it. */\n readonly reference?: string;\n /** The fields that the page of each export adds to its front matter, for example the `order` of a site. A field `title` or `description` replaces the default. */\n readonly frontmatter?: Readonly<Record<string, FrontmatterValue>>;\n /** The names that the check does not examine, each with its reason. */\n readonly except?: Readonly<Record<string, string>>;\n}\n\n/** This function gives the names of each entry of a report, by the subpath of the entry. The members of a namespace are not in the result. */\nexport function reportEntries(report: string): ReadonlyMap<string, ReadonlySet<string>> {\n const entries = new Map<string, Set<string>>();\n let current: Set<string> | null = null;\n for (const line of report.split(\"\\n\")) {\n if (line.startsWith(\"## \")) {\n const subpath = /^## (\\.\\S*?)(?: \\(.*\\))?: /.exec(line)?.[1];\n current = null;\n if (subpath !== undefined) {\n const names = new Set<string>();\n entries.set(subpath, names);\n if (line.endsWith(\" names\")) current = names;\n }\n continue;\n }\n const name = /^(?:type )?([^\\s:]+): /.exec(line)?.[1];\n if (current !== null && name !== undefined && name !== \"ambient\" && !name.includes(\".\")) current.add(name);\n }\n return entries;\n}\n\n/** This function gives the code blocks and the code spans of a Markdown text. */\nfunction codeOf(text: string): { readonly blocks: readonly string[]; readonly spans: readonly string[] } {\n const blocks: string[] = [];\n const prose: string[] = [];\n let fence: string | null = null;\n let block: string[] = [];\n for (const line of text.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")) {\n const mark = /^\\s*(`{3,}|~{3,})/.exec(line)?.[1];\n if (fence === null) {\n if (mark === undefined) prose.push(line);\n else {\n fence = mark;\n block = [];\n }\n } else if (mark !== undefined && mark[0] === fence[0] && mark.length >= fence.length) {\n blocks.push(block.join(\"\\n\"));\n fence = null;\n } else block.push(line);\n }\n if (fence !== null) blocks.push(block.join(\"\\n\"));\n const spans = [...prose.join(\"\\n\").matchAll(/(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/g)].map((match) => match[2] ?? \"\");\n return { blocks, spans };\n}\n\n/** This function is true if the code has `name` as a whole word. */\nfunction hasWord(code: string, name: string): boolean {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`(?<![\\\\w$])${escaped}(?![\\\\w$])`).test(code);\n}\n\n/**\n * This function gives the faults of the pages of a package against its report.\n *\n * An export must show in a code block or a code span of a page. An import from the package in a code block\n * must name an export of that entry. A signature, an `interface` or a `type` in a code block must be an\n * export of an entry. An exception needs a reason, and an exception that removes no fault is also a fault.\n * When `complete` is true, a different page shows each export, so the first rule does not apply.\n */\nexport function pageFaults(report: string, packageName: string, pages: readonly string[], except: Readonly<Record<string, string>> = {}, complete = false): string[] {\n const entries = reportEntries(report);\n const all = new Set([...entries.values()].flatMap((names) => [...names]));\n const code = pages.map(codeOf);\n const blocks = code.flatMap((item) => item.blocks);\n const text = [...blocks, ...code.flatMap((item) => item.spans)].join(\"\\n\");\n const faults = new Map<string, string>();\n const used = new Set<string>();\n const fault = (name: string, words: string): void => {\n if (Object.hasOwn(except, name)) used.add(name);\n else if (!faults.has(name)) faults.set(name, `${name}: ${words}`);\n };\n\n if (!complete) {\n for (const name of all) {\n if (!hasWord(text, name)) fault(name, \"the package exports this name, and no code on the page shows it.\");\n }\n }\n for (const block of blocks) {\n for (const match of block.matchAll(/import\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const source = match[2] ?? \"\";\n if (source !== packageName && !source.startsWith(`${packageName}/`)) continue;\n const names = entries.get(`.${source.slice(packageName.length)}`);\n if (names === undefined) {\n fault(source, \"the page imports from this path, and the package has no such entry.\");\n continue;\n }\n for (const part of (match[1] ?? \"\").split(\",\")) {\n const name = part.replace(/^\\s*type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim() ?? \"\";\n if (name !== \"\" && name !== \"default\" && !names.has(name)) fault(name, `the page imports this name from ${source}, and that entry does not export it.`);\n }\n }\n for (const line of block.split(\"\\n\")) {\n const name =\n /^\\s*(?:export\\s+)?(?:declare\\s+)?function\\s+([\\w$]+)\\s*[<(].*;\\s*(?:\\/\\/.*)?$/.exec(line)?.[1] ??\n /^\\s*(?:export\\s+)?(?:declare\\s+)?(?:interface|type)\\s+([\\w$]+)/.exec(line)?.[1];\n if (name !== undefined && !all.has(name)) fault(name, \"the page gives the declaration of this name, and the package does not export it.\");\n }\n }\n for (const [name, reason] of Object.entries(except)) {\n if (reason.trim() === \"\") faults.set(name, `${name}: the exception has no reason.`);\n else if (!used.has(name)) faults.set(name, `${name}: the exception removes no fault, so remove it.`);\n }\n return [...faults.entries()].sort(([a], [b]) => byCode(a, b)).map(([, words]) => words);\n}\n","/**\n * A page of each export of a package, from its report. A library with many exports keeps each name on this\n * page, and a hand-written page explains the main calls. The report has the names and the declarations, so\n * this page has the same text as the report in each build.\n */\nimport type { FrontmatterValue } from \"./page.ts\";\n\n/** One line of an entry of a report. */\ninterface ReportItem {\n readonly name: string;\n readonly key: string;\n readonly isType: boolean;\n readonly kind: \"declaration\" | \"namespace\" | \"external\" | \"ambient\";\n}\n\n/** One entry of a report: its subpath and its lines. */\ninterface ReportEntry {\n readonly subpath: string;\n readonly items: readonly ReportItem[];\n}\n\n/** This function gives the entries of a report and the text of each declaration. */\nfunction readReport(report: string): { readonly entries: readonly ReportEntry[]; readonly declarations: ReadonlyMap<string, string> } {\n const entries: ReportEntry[] = [];\n const declarations = new Map<string, string>();\n let items: ReportItem[] | null = null;\n let key: string | null = null;\n let body: string[] = [];\n const close = (): void => {\n if (key !== null) declarations.set(key, body.join(\"\\n\").trimEnd());\n };\n let inDeclarations = false;\n for (const line of report.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")) {\n if (inDeclarations) {\n const next = /^### (.+)$/.exec(line)?.[1];\n if (next === undefined) body.push(line);\n else {\n close();\n key = next;\n body = [];\n }\n continue;\n }\n if (line.startsWith(\"## \")) {\n inDeclarations = line === \"## Declarations\";\n const subpath = /^## (\\.\\S*?)(?: \\(.*\\))?: /.exec(line)?.[1];\n items = null;\n if (subpath !== undefined) {\n const lines: ReportItem[] = [];\n entries.push({ subpath, items: lines });\n if (line.endsWith(\" names\")) items = lines;\n }\n continue;\n }\n if (items === null) continue;\n const match = /^(type )?(.+?): (\\S+)(?: \\((namespace|external)\\))?$/.exec(line);\n if (match === null) continue;\n const name = match[2] ?? \"\";\n const kind = name === \"ambient\" ? \"ambient\" : ((match[4] as \"namespace\" | \"external\" | undefined) ?? \"declaration\");\n items.push({ name, key: match[3] ?? \"\", isType: match[1] !== undefined, kind });\n }\n close();\n return { entries, declarations };\n}\n\n/** This function gives a fenced block of TypeScript. The fence is longer than each run of backticks in the code. */\nfunction fenced(code: string): string {\n const longest = Math.max(2, ...[...code.matchAll(/`+/g)].map((match) => match[0].length));\n const fence = \"`\".repeat(longest + 1);\n return `${fence}ts\\n${code}\\n${fence}`;\n}\n\n/** The most characters of a line of an import list. */\nconst IMPORT_WIDTH = 100;\n\n/** This function gives an import of `names` from `path`, with a line break at `IMPORT_WIDTH`. */\nfunction importOf(names: readonly string[], path: string): string {\n const lines: string[] = [];\n let line = \" \";\n for (const name of names) {\n if (line.length + name.length + 2 > IMPORT_WIDTH) {\n lines.push(line);\n line = \" \";\n }\n line += ` ${name},`;\n }\n lines.push(line);\n return `import {\\n${lines.join(\"\\n\")}\\n} from ${JSON.stringify(path)};`;\n}\n\n/** This function removes the words `export` and `declare` from the start of each statement of a declaration. `declare global` and `declare module` keep the word. */\nfunction plain(declaration: string): string {\n return declaration.replace(/^(?:export )?(?:declare (?!global\\b|module\\b))?/gm, \"\");\n}\n\n/** This pattern finds a name that a bundler changed, to keep two declarations apart: `grid$1`. */\nconst BUNDLER_NAME = /\\$\\d+$/;\n\n/** This function gives the name of the declaration of a line of a report. */\nfunction localName(item: ReportItem): string {\n return item.key.slice(item.key.lastIndexOf(\"#\") + 1);\n}\n\n/** This function puts the name of each export of `items` in `code`, where a bundler changed that name. */\nfunction withExportNames(code: string, items: readonly ReportItem[]): string {\n let text = code;\n for (const item of items) {\n const local = localName(item);\n if (!BUNDLER_NAME.test(local) || item.name.includes(\".\") || item.kind !== \"declaration\") continue;\n const word = new RegExp(`(?<![\\\\w$])${local.replace(/[\\\\^$.*+?()[\\]{}|]/g, \"\\\\$&\")}(?![\\\\w$])`, \"g\");\n text = text.replace(word, () => item.name);\n }\n return text;\n}\n\n/**\n * This function gives the Markdown of the page of each export of a package. Each entry has an import with its\n * names. A declaration shows one time, in the first entry that reaches it. A comment tells the name of an\n * export when the source gave the declaration a different name. A name from a bundler does not show. A\n * comment also tells the package of an external name.\n *\n * The fields of `frontmatter` go into the front matter, after the title and the description. A field `title` or\n * `description` replaces the default.\n */\nexport function referencePage(report: string, packageName: string, frontmatter: Readonly<Record<string, FrontmatterValue>> = {}): string {\n const { entries, declarations } = readReport(report);\n const fields: Record<string, FrontmatterValue> = {\n title: `Each export of ${packageName}`,\n description: `Each entry point of ${packageName}, with its exports and their declarations.`,\n ...frontmatter,\n };\n const out = [\n \"---\",\n \"# The command `api-report update` writes this file from the report of the package. Do not edit it.\",\n ...Object.entries(fields).map(([key, value]) => `${key}: ${JSON.stringify(value)}`),\n \"---\",\n \"\",\n \"The report of the API of the package makes this page, so the page and the package have the same names. Each section is one entry point. A declaration shows one time, in the first section that has it.\",\n ];\n const seen = new Set<string>();\n for (const entry of entries) {\n const path = `${packageName}${entry.subpath.slice(1)}`;\n out.push(\"\", `## \\`${path}\\``, \"\");\n if (entry.items.length === 0) {\n out.push(\"This entry has no declarations.\");\n continue;\n }\n const top = entry.items.filter((item) => item.kind !== \"ambient\" && !item.name.includes(\".\") && !item.name.startsWith(\"* \"));\n const blocks = top.length > 0 ? [fenced(importOf(top.map((item) => `${item.isType ? \"type \" : \"\"}${item.name === \"default\" ? \"default as defaultExport\" : item.name}`), path))] : [];\n const parts: string[] = [];\n for (const item of entry.items) {\n if (seen.has(`${item.name} ${item.key}`)) continue;\n seen.add(`${item.name} ${item.key}`);\n if (item.kind === \"external\") {\n const from = item.key.slice(0, item.key.lastIndexOf(\"#\"));\n parts.push(`// ${item.name} comes from the package ${from}.`);\n continue;\n }\n const text = declarations.get(item.key);\n if (text === undefined || seen.has(item.key)) continue;\n seen.add(item.key);\n const local = localName(item);\n const label = item.kind === \"ambient\" || local === item.name || BUNDLER_NAME.test(local) ? \"\" : `// The export ${item.name}:\\n`;\n parts.push(`${label}${plain(text)}`);\n }\n if (parts.length > 0) blocks.push(fenced(withExportNames(parts.join(\"\\n\\n\"), entry.items)));\n out.push(blocks.join(\"\\n\\n\"));\n }\n return `${out.join(\"\\n\")}\\n`;\n}\n","/**\n * The report of the public API of a package, from its built `.d.ts` files.\n *\n * The report lists the names that each entry of the `exports` field gives, and the declaration of\n * each name. It follows `export *`, `export { a as b } from`, `export * as ns` and the imports that\n * a module exports again. It also lists the ambient declarations of each file that an entry reaches,\n * and the bins. An entry without a declaration file (for example a JSON file) lists its files. The\n * report has no comments and no private members. Thus a change of a comment or of a private field\n * does not change it.\n *\n * A bundler gives a shared chunk a hash in its name, and the hash changes with the bundler and with\n * private code. The report gives each such file a label without the hash, so an update of a tool does\n * not change the report. A changed declaration in a chunk still changes the report.\n *\n * The heading of an entry does not give a count of names. Two pull requests that each add a name\n * change different lines, so they do not conflict on a count.\n *\n * The text is the same on Windows and on Linux. The line ends\n * are LF, the paths use `/`, and the sort does not use the locale.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { parseDeclarations, type DeclarationInfo } from \"./declarations.ts\";\nimport { binsOf, byCode, declarationPathOf, entriesOf, patternMatch, publishedManifest, relativePath, targetOf, type Entry, type Manifest } from \"./entries.ts\";\n\n/** The command that the header of a report names, when the options give no other command. */\nexport const DEFAULT_TOOL = \"api-report\";\n\n/** The options of a report. */\nexport interface ReportOptions {\n /** The manifest of the package: the report reads its `imports` and `bin` fields. */\n readonly manifest?: Manifest;\n /** The command that the header names, for example `api-report` or `node scripts/api-report.mjs`. */\n readonly tool?: string;\n}\n\n/**\n * The name of a chunk of a bundler: a stem, a hyphen, a hash of 8 characters and the extension of a\n * declaration file. For example `html-o5bDHjNi.d.mts`.\n */\nconst CHUNK_NAME = /^(.+)-([A-Za-z0-9_-]{8})(\\.d\\.[cm]?ts)$/;\n\n/** A hash of a module path in a text, before its extension. It only sorts chunks that have one stem. */\nconst HASH_IN_TEXT = /-[A-Za-z0-9_-]{8}(?=\\.(?:d\\.)?[cm]?[jt]s\\b)/g;\n\n/**\n * This function gives the stem and the extension of the name of a chunk, or null. A tail of small\n * letters and hyphens is a word (`route-resolver.d.ts`), so the name stays. The hash of a chunk has only\n * such characters in approximately 1 of 1,000 builds: then the report shows that hash until the next build.\n */\nfunction chunkOf(name: string): { readonly stem: string; readonly extension: string } | null {\n const match = CHUNK_NAME.exec(name);\n if (match === null || /^[a-z-]+$/.test(match[2] ?? \"\")) return null;\n return { stem: match[1] ?? \"\", extension: match[3] ?? \"\" };\n}\n\n/** This function gives the name of a declaration file without its extension: a module path holds that part. */\nconst chunkStem = (file: string): string => basename(file).replace(/\\.d\\.[cm]?ts$/, \"\");\n\n/**\n * This function gives the label of each chunk in `files`, by its path: `html.chunk.d.mts`, and then\n * `html.chunk2.d.mts` for a second chunk of that stem. Chunks of one stem sort by their text without\n * hashes, so the order does not depend on a hash. A file in `kept` is an entry, and keeps its name. A\n * label does not take the name of a file that exists.\n */\nfunction chunkLabels(files: readonly string[], kept: ReadonlySet<string>): ReadonlyMap<string, string> {\n const groups = new Map<string, { readonly file: string; readonly stem: string; readonly extension: string; readonly text: string }[]>();\n for (const file of files) {\n const chunk = kept.has(file) ? null : chunkOf(basename(file));\n if (chunk === null) continue;\n const key = join(dirname(file), `${chunk.stem}${chunk.extension}`);\n const text = readFileSync(file, \"utf8\").replace(HASH_IN_TEXT, \"\");\n groups.set(key, [...(groups.get(key) ?? []), { file, ...chunk, text }]);\n }\n const labels = new Map<string, string>();\n for (const [, group] of [...groups].sort(([a], [b]) => byCode(a, b))) {\n let number = 1;\n for (const { file, stem, extension } of group.sort((a, b) => byCode(a.text, b.text) || byCode(a.file, b.file))) {\n let label: string;\n do {\n label = join(dirname(file), `${stem}.chunk${number === 1 ? \"\" : number}${extension}`);\n number += 1;\n } while (existsSync(label));\n labels.set(file, label);\n }\n }\n return labels;\n}\n\n/** The binding of an exported name. */\ntype Binding =\n | { readonly kind: \"declaration\"; readonly file: string; readonly local: string; readonly typeOnly: boolean }\n | { readonly kind: \"namespace\"; readonly file: string; readonly typeOnly: boolean }\n | { readonly kind: \"external\"; readonly module: string; readonly name: string; readonly typeOnly: boolean };\n\n/** The reader of the declaration files of one package. */\nclass Reader {\n readonly #infos = new Map<string, DeclarationInfo>();\n readonly #bindings = new Map<string, Map<string, Binding>>();\n readonly #visiting = new Set<string>();\n readonly #root: string;\n readonly #manifest: Manifest;\n\n constructor(root: string, manifest: Manifest) {\n this.#root = root;\n this.#manifest = manifest;\n }\n\n info(file: string): DeclarationInfo {\n let info = this.#infos.get(file);\n if (!info) {\n info = parseDeclarations(readFileSync(file, \"utf8\"), relativePath(this.#root, file));\n this.#infos.set(file, info);\n }\n return info;\n }\n\n /** This method gives the candidate declaration files of a module path. */\n #candidates(base: string): string[] {\n const declared = declarationPathOf(base);\n if (declared) return [declared];\n const source = /\\.([mc]?)ts$/.exec(base);\n if (source) return [`${base.slice(0, -source[0].length)}.d.${source[1] ?? \"\"}ts`];\n return [`${base}.d.ts`, join(base, \"index.d.ts\")];\n }\n\n /**\n * This method gives the declaration file of a module specifier of `from`: a relative path, or a\n * `#` name of the `imports` field. The result is undefined for a module of a different package. A\n * missing file throws, or gives `null` when `soft` is true.\n */\n fileOf(from: string, specifier: string, soft = false): string | null | undefined {\n let base: string | undefined;\n if (specifier.startsWith(\".\")) base = resolve(dirname(from), specifier);\n else if (specifier.startsWith(\"#\") && typeof this.#manifest.imports === \"object\" && this.#manifest.imports !== null) {\n for (const [pattern, value] of Object.entries(this.#manifest.imports)) {\n const part = patternMatch(pattern, specifier);\n const target = part === undefined ? undefined : targetOf(value);\n if (part !== undefined && typeof target === \"string\" && target.startsWith(\".\")) {\n base = resolve(this.#root, target.split(\"*\").join(part));\n break;\n }\n }\n if (base === undefined) return undefined;\n } else return undefined;\n const file = this.#candidates(base).find((candidate) => existsSync(candidate));\n if (file) return file;\n if (soft) return null;\n throw new Error(`No declaration file for \"${specifier}\" from ${relativePath(this.#root, from)}`);\n }\n\n /** This method gives the binding of `imported` in the module `specifier` of `from`. */\n #bindingIn(from: string, specifier: string, imported: string, typeOnly: boolean): Binding {\n const file = this.fileOf(from, specifier);\n if (!file) return { kind: \"external\", module: specifier, name: imported, typeOnly };\n if (imported === \"*\") return { kind: \"namespace\", file, typeOnly };\n const binding = this.exportsOf(file).get(imported);\n if (!binding) throw new Error(`\"${specifier}\" from ${relativePath(this.#root, from)} does not export ${imported}`);\n return typeOnly ? { ...binding, typeOnly: true } : binding;\n }\n\n /** This method gives the names that a module exports, and their bindings. */\n exportsOf(file: string): Map<string, Binding> {\n const known = this.#bindings.get(file);\n if (known) return known;\n if (this.#visiting.has(file)) return new Map();\n this.#visiting.add(file);\n const info = this.info(file);\n const result = new Map<string, Binding>();\n for (const [name, { local, typeOnly }] of info.exported) {\n const imported = info.imports.get(local);\n if (info.locals.has(local)) result.set(name, { kind: \"declaration\", file, local, typeOnly });\n else if (imported) result.set(name, this.#bindingIn(file, imported.from, imported.imported, typeOnly || imported.typeOnly));\n else throw new Error(`${relativePath(this.#root, file)} exports ${local}, and has no declaration or import of it`);\n }\n for (const reexport of info.reexports) result.set(reexport.exported, this.#bindingIn(file, reexport.from, reexport.imported, reexport.typeOnly));\n for (const namespace of info.namespaces) result.set(namespace.name, this.#bindingIn(file, namespace.from, \"*\", namespace.typeOnly));\n // A name of `export *` never replaces an explicit export, and `default` does not pass\n const explicit = new Set(result.keys());\n for (const { from: star, typeOnly } of info.stars) {\n const target = this.fileOf(file, star);\n if (!target) {\n // The names of a different package are not in this package: the report names the package\n const name = `* from \"${star}\"`;\n if (!result.has(name)) result.set(name, { kind: \"external\", module: star, name: \"*\", typeOnly });\n continue;\n }\n // `export type *` gives each name as a type only\n for (const [name, binding] of this.exportsOf(target)) {\n if (name !== \"default\" && !explicit.has(name) && !result.has(name)) result.set(name, typeOnly ? { ...binding, typeOnly: true } : binding);\n }\n }\n this.#visiting.delete(file);\n this.#bindings.set(file, result);\n return result;\n }\n\n /**\n * This method gives each declaration file of the package that `file` reaches through its module\n * specifiers, and `file`. A file outside the package folder or in `node_modules` is not part of it.\n */\n reached(file: string): string[] {\n const seen = new Set<string>();\n const pending = [file];\n for (let next = pending.pop(); next !== undefined; next = pending.pop()) {\n if (seen.has(next)) continue;\n seen.add(next);\n for (const specifier of this.info(next).references) {\n const target = this.fileOf(next, specifier, true);\n if (!target) continue;\n const path = relativePath(this.#root, target);\n if (path.startsWith(\"../\") || path.split(\"/\").includes(\"node_modules\")) continue;\n pending.push(target);\n }\n }\n return [...seen];\n }\n}\n\n/** This function gives the lines of the header of a report. */\nfunction header(packageName: string, tool: string): string[] {\n return [\n `# The public API of ${packageName}`,\n \"#\",\n \"# The names of each entry of the exports field, and the declaration of each name, without comments\",\n `# and private members. The command \\`${tool} check\\` compares this file with the built .d.ts files.`,\n `# To accept a change of the API, start the build, then \\`${tool} update\\`, and review the diff.`,\n ];\n}\n\n/** The number of lines of the header of a report. */\nexport const HEADER_LINES = 5;\n\n/**\n * This function gives the report of the public API of a package. `entries` gives the subpath and\n * the declaration file of each entry, relative to `root`. The report has the exported names of each\n * entry, the bins of the manifest, and then the declaration of each name.\n */\nexport function apiReport(packageName: string, root: string, entries: readonly Entry[], options: ReportOptions = {}): string {\n const manifest = options.manifest ?? {};\n const reader = new Reader(root, manifest);\n const entryFiles = entries.flatMap((entry) => (entry.types === undefined ? [] : [resolve(root, entry.types)])).filter((file) => existsSync(file));\n const labels = chunkLabels([...new Set(entryFiles.flatMap((file) => reader.reached(file)))], new Set(entryFiles));\n const path = (file: string): string => relativePath(root, labels.get(file) ?? file);\n /** This function replaces the name of each chunk in a text with its label: a declaration can name a chunk in `import(\"./x\")`. */\n const plain = (text: string): string => {\n let result = text;\n for (const [file, label] of labels) result = result.replaceAll(chunkStem(file), chunkStem(label));\n return result;\n };\n const keyOf = (binding: Binding): string =>\n binding.kind === \"declaration\" ? `${path(binding.file)}#${binding.local}` : binding.kind === \"namespace\" ? `${path(binding.file)}#*` : `${binding.module}#${binding.name}`;\n const declarations = new Map<string, string>();\n const lines = header(packageName, options.tool ?? DEFAULT_TOOL);\n if (entries.every((entry) => entry.types === undefined)) {\n lines.push(\"\", \"This package has no type declarations: no entry of its package.json gives a .d.ts file.\");\n }\n\n /** The lines of the names of a module, and the names of each namespace in it, with `prefix`. */\n const names = (bindings: Map<string, Binding>, prefix: string, parents: ReadonlySet<string>, typeOnly: boolean): void => {\n for (const [name, binding] of [...bindings].sort(([a], [b]) => byCode(a, b))) {\n const key = keyOf(binding);\n const isType = typeOnly || binding.typeOnly;\n lines.push(`${isType ? \"type \" : \"\"}${prefix}${name}: ${key}${binding.kind === \"declaration\" ? \"\" : ` (${binding.kind})`}`);\n if (binding.kind === \"declaration\" && !declarations.has(key)) {\n declarations.set(key, plain((reader.info(binding.file).locals.get(binding.local) ?? []).join(\"\\n\")));\n }\n // The names of a namespace are part of the API: `ns.name`\n if (binding.kind === \"namespace\" && !parents.has(binding.file)) {\n names(reader.exportsOf(binding.file), `${prefix}${name}.`, new Set([...parents, binding.file]), isType);\n }\n }\n };\n\n for (const entry of entries) {\n if (entry.types === undefined) {\n lines.push(\"\", `## ${entry.subpath}: ${entry.note ?? \"no declaration file\"}`);\n // The files of an entry without declarations: a removed file changes the report\n const files = entry.files ?? [];\n if (files.length > 0) lines.push(\"\", ...files.map((file) => `file ${file.subpath}: ${file.path.replace(/^\\.\\//, \"\")}`));\n continue;\n }\n const file = resolve(root, entry.types);\n if (!existsSync(file)) throw new Error(`${entry.subpath}: ${entry.types} is missing. Build the package first.`);\n const bindings = reader.exportsOf(file);\n lines.push(\"\", `## ${entry.subpath} (${path(file)}): names`, \"\");\n names(bindings, \"\", new Set([file]), false);\n // The ambient declarations of each file that the entry reaches\n const ambient: string[] = [];\n for (const reached of reader.reached(file)) {\n for (const [label, statements] of reader.info(reached).ambient) {\n const key = plain(`${path(reached)}#${label}`);\n ambient.push(key);\n if (!declarations.has(key)) declarations.set(key, plain(statements.join(\"\\n\")));\n }\n }\n for (const key of ambient.sort(byCode)) lines.push(`ambient: ${key}`);\n }\n const bins = binsOf(manifest);\n if (bins.length > 0) {\n lines.push(\"\", `## bin: ${bins.length} commands`, \"\");\n for (const bin of bins) lines.push(`${bin.name}: ${bin.path}`);\n }\n if (declarations.size > 0 || entries.some((entry) => entry.types !== undefined)) {\n lines.push(\"\", \"## Declarations\");\n for (const key of [...declarations.keys()].sort(byCode)) lines.push(\"\", `### ${key}`, declarations.get(key) ?? \"\");\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\n/** The options of the report of a package folder. */\nexport interface PackageReportOptions {\n /** The command that the header names. */\n readonly tool?: string;\n /** When true (the default), the fields of `publishConfig` replace the fields of the source, as pnpm publishes them. */\n readonly publishConfig?: boolean;\n}\n\n/** This function gives the report of the package in the folder `dir`. */\nexport function packageReport(dir: string, options: PackageReportOptions = {}): string {\n const source = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as Manifest;\n const manifest = options.publishConfig === false ? source : publishedManifest(source);\n const name = typeof manifest.name === \"string\" ? manifest.name : basename(dir);\n return apiReport(name, dir, entriesOf(manifest, dir), { manifest, ...(options.tool === undefined ? {} : { tool: options.tool }) });\n}\n","/**\n * The commands `check` and `update` of the bin `api-report`, as functions. `runReports` compares or\n * writes the reports of each package, and `runCli` reads the arguments and writes the result.\n */\nimport { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { unifiedDiff } from \"./diff.ts\";\nimport { byCode, relativePath, type Manifest } from \"./entries.ts\";\nimport { pageFaults, type ApiPage, type FrontmatterValue } from \"./page.ts\";\nimport { referencePage } from \"./reference.ts\";\nimport { DEFAULT_TOOL, packageReport } from \"./report.ts\";\nimport { globFolders, packageFolders, workspaceGlobs } from \"@mark1russell7/conventions/workspace\";\n\n/** The path of the report in a package folder, when the configuration gives no other path. */\nexport const REPORT_FILE = \"test/api/public-api.txt\";\n\n/** The configuration of the reports: the field `apiReport` of the root `package.json`, or the options of the CLI. */\nexport interface ApiReportConfig {\n /** The globs of the package folders, relative to the root. A glob that starts with `!` removes folders. The default is the globs of the workspace. */\n readonly packages?: readonly string[];\n /** The path of the report in each package folder. The default is `test/api/public-api.txt`. */\n readonly report?: string;\n /** When true, each private package also gets a report. The default is false. */\n readonly includePrivate?: boolean;\n /** When false, the report reads the fields of `package.json` without `publishConfig`. The default is true. */\n readonly publishConfig?: boolean;\n /** The command that the header of each report names. The default is `api-report`. */\n readonly tool?: string;\n /** The pages of an API. The command `check` holds their names against the report of each package. */\n readonly pages?: readonly ApiPage[];\n}\n\n/** The command: `check` compares the reports, and `update` writes them. */\nexport type Mode = \"check\" | \"update\";\n\n/** The options of `runReports`. */\nexport interface RunOptions extends ApiReportConfig {\n readonly mode: Mode;\n /** The root of the repository. */\n readonly root: string;\n /** The package folders to examine. They replace the globs, and a named private package gets a report. */\n readonly folders?: readonly string[];\n}\n\n/** The result of one package. */\nexport interface PackageResult {\n /** The package folder, relative to the root, with `/`. */\n readonly folder: string;\n /** The report file, relative to the root, with `/`. */\n readonly file: string;\n /**\n * `same`: the report is current. `changed` and `new`: the report differs or is missing (`check`),\n * or the command wrote it (`update`). `stale`: a folder has a report, and the run does not read\n * the package: it is private, excluded by a `!` glob, or removed. `private`: the package has no\n * report. `error`: the command did not make the report.\n */\n readonly status: \"same\" | \"changed\" | \"new\" | \"stale\" | \"private\" | \"error\";\n /** The change from the committed report to the new report, in the unified format. */\n readonly diff?: string;\n readonly error?: string;\n /** The faults of the hand-written pages of this package against its report. */\n readonly pageFaults?: readonly string[];\n /** The pages of each export that the command `update` wrote. */\n readonly writtenPages?: readonly string[];\n}\n\n/** The result of `runReports`. */\nexport interface RunResult {\n readonly mode: Mode;\n readonly packages: readonly PackageResult[];\n /** True when the command fails: an error, or (`check` only) a report that is not current. */\n readonly failed: boolean;\n}\n\n/**\n * This function reads the field `apiReport` of the `package.json` file at `root`. The result is an\n * empty configuration when the field does not exist.\n *\n * @throws Error when the field is not an object, or a value has the wrong type\n */\nexport function readConfig(root: string): ApiReportConfig {\n const file = join(root, \"package.json\");\n if (!existsSync(file)) return {};\n const value = (JSON.parse(readFileSync(file, \"utf8\")) as Manifest)[\"apiReport\"];\n if (value === undefined) return {};\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new Error(\"The field apiReport of package.json must be an object.\");\n const config = value as Record<string, unknown>;\n const result: { -readonly [K in keyof ApiReportConfig]: ApiReportConfig[K] } = {};\n const packages = config[\"packages\"];\n if (packages !== undefined) {\n if (!Array.isArray(packages) || !packages.every((glob) => typeof glob === \"string\")) throw new Error(\"apiReport.packages must be an array of globs.\");\n result.packages = packages;\n }\n for (const key of [\"report\", \"tool\"] as const) {\n const item = config[key];\n if (item === undefined) continue;\n if (typeof item !== \"string\" || item === \"\") throw new Error(`apiReport.${key} must be a string.`);\n result[key] = item;\n }\n for (const key of [\"includePrivate\", \"publishConfig\"] as const) {\n const item = config[key];\n if (item === undefined) continue;\n if (typeof item !== \"boolean\") throw new Error(`apiReport.${key} must be true or false.`);\n result[key] = item;\n }\n const pages = config[\"pages\"];\n if (pages !== undefined) result.pages = readPages(pages);\n const unknown = Object.keys(config).filter((key) => ![\"packages\", \"report\", \"tool\", \"includePrivate\", \"publishConfig\", \"pages\"].includes(key));\n if (unknown.length > 0) throw new Error(`apiReport has unknown fields: ${unknown.join(\", \")}.`);\n return result;\n}\n\n/** This function reads the field `pages` of `apiReport`. */\nfunction readPages(value: unknown): readonly ApiPage[] {\n if (!Array.isArray(value)) throw new Error(\"apiReport.pages must be an array.\");\n return value.map((item: unknown, index): ApiPage => {\n const at = `apiReport.pages[${index}]`;\n if (typeof item !== \"object\" || item === null || Array.isArray(item)) throw new Error(`${at} must be an object.`);\n const { package: folder, pages, except, reference, frontmatter } = item as Record<string, unknown>;\n if (typeof folder !== \"string\" || folder === \"\") throw new Error(`${at}.package must be a string.`);\n if (reference !== undefined && (typeof reference !== \"string\" || !isRootPath(reference))) throw new Error(`${at}.reference must be a path in the repository.`);\n const emptyOk = reference !== undefined;\n if (!Array.isArray(pages) || (pages.length === 0 && !emptyOk) || !pages.every((page) => typeof page === \"string\")) throw new Error(`${at}.pages must be an array of paths.`);\n if (frontmatter !== undefined && reference === undefined) throw new Error(`${at}.frontmatter needs the field reference.`);\n const fields = frontmatter === undefined ? undefined : readFrontmatter(frontmatter, `${at}.frontmatter`);\n const named = {\n package: folder,\n pages: pages as string[],\n ...(reference === undefined ? {} : { reference: reference as string }),\n ...(fields === undefined ? {} : { frontmatter: fields }),\n };\n if (except === undefined) return named;\n if (typeof except !== \"object\" || except === null || Array.isArray(except) || !Object.values(except).every((reason) => typeof reason === \"string\")) {\n throw new Error(`${at}.except must be an object of names and reasons.`);\n }\n return { ...named, except: except as Record<string, string> };\n });\n}\n\n/** This function reads the field `frontmatter` of an item of `pages`: names of fields, each with a text, a number or a boolean. */\nfunction readFrontmatter(value: unknown, at: string): Readonly<Record<string, FrontmatterValue>> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new Error(`${at} must be an object of fields.`);\n for (const [key, field] of Object.entries(value)) {\n if (!/^[A-Za-z_][\\w-]*$/.test(key)) throw new Error(`${at} has a field name that is not a plain name: ${JSON.stringify(key)}.`);\n const ok = typeof field === \"string\" || typeof field === \"boolean\" || typeof field === \"number\";\n if (!ok) throw new Error(`${at}.${key} must be a text, a number or a boolean.`);\n }\n return value as Record<string, FrontmatterValue>;\n}\n\n/** This function is true for a relative path with no `..`. */\nfunction isRootPath(path: string): boolean {\n const clean = path.replaceAll(\"\\\\\", \"/\");\n return clean !== \"\" && !isAbsolute(path) && !clean.split(\"/\").includes(\"..\");\n}\n\n/** This function gives the text of a file with `\\n` line ends, or undefined when the file does not exist. */\nfunction textOf(file: string): string | undefined {\n return existsSync(file) ? readFileSync(file, \"utf8\").replace(/\\r\\n/g, \"\\n\") : undefined;\n}\n\n/** This function gives the faults of the pages of one package. A file that does not exist is a fault, and so is a page of each export that differs from the report. */\nfunction faultsOfPages(root: string, entry: ApiPage, report: string, packageName: string): string[] {\n const missing = entry.pages.filter((page) => !existsSync(resolve(root, page)));\n if (missing.length > 0) return missing.map((page) => `${page}: the page does not exist.`);\n const faults: string[] = [];\n if (entry.reference !== undefined && textOf(resolve(root, entry.reference)) !== referencePage(report, packageName, entry.frontmatter)) {\n faults.push(`${entry.reference}: the page differs from the report. Start the command update, and commit the page.`);\n }\n const pages = entry.pages.map((page) => readFileSync(resolve(root, page), \"utf8\"));\n return [...faults, ...pageFaults(report, packageName, pages, entry.except, entry.reference !== undefined)];\n}\n\n/** This function writes the page of each export of one package, and gives its path when the text changes. */\nfunction writeReference(root: string, entry: ApiPage, report: string, packageName: string): string[] {\n if (entry.reference === undefined) return [];\n const file = resolve(root, entry.reference);\n const text = referencePage(report, packageName, entry.frontmatter);\n if (textOf(file) === text) return [];\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, text);\n return [entry.reference];\n}\n\n/** This function makes sure that the path of a report stays in its package folder. */\nfunction checkReportPath(report: string): string {\n const clean = report.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\//, \"\");\n if (clean === \"\" || isAbsolute(report) || clean.split(\"/\").includes(\"..\")) throw new Error(`The path of a report must be relative to the package folder, with no \"..\": ${report}`);\n return clean;\n}\n\n/**\n * This function gives the folders that the globs name, as absolute paths, in the order of the code\n * units. It ignores the `!` globs and needs no `package.json` file, so the result also has the\n * excluded folders and the folders of removed packages.\n */\nfunction globbedFolders(root: string, globs: readonly string[] | undefined): string[] {\n const found = new Set<string>();\n for (const glob of (globs ?? workspaceGlobs(root) ?? []).filter((item) => !item.startsWith(\"!\"))) {\n for (const folder of globFolders(root, glob)) found.add(folder);\n }\n return [...found].sort(byCode).map((folder) => join(root, folder));\n}\n\n/**\n * This function compares (`check`) or writes (`update`) the report of each package. It writes nothing\n * in `check` mode. Without named folders, a run that finds no package fails: it examined nothing,\n * and that is not a pass. A repository of private packages passes: it has no public API to report.\n * A report in a folder that the run does not read is `stale`.\n */\nexport function runReports(options: RunOptions): RunResult {\n const root = resolve(options.root);\n const report = checkReportPath(options.report ?? REPORT_FILE);\n const named = options.folders !== undefined && options.folders.length > 0;\n const folders = named ? (options.folders ?? []).map((folder) => resolve(root, folder)) : packageFolders(root, options.packages);\n const results: PackageResult[] = [];\n const skipped = new Set<string>();\n for (const folder of folders) {\n const shown = relativePath(root, folder) || \".\";\n const file = join(folder, report);\n const shownFile = relativePath(root, file);\n const manifestFile = join(folder, \"package.json\");\n if (!existsSync(manifestFile)) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: \"no package.json\" });\n continue;\n }\n // A CRLF checkout gives the same text\n const current = existsSync(file) ? readFileSync(file, \"utf8\").replace(/\\r\\n/g, \"\\n\") : undefined;\n let manifest: Manifest;\n try {\n manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as Manifest;\n } catch (error) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: error instanceof Error ? error.message : String(error) });\n continue;\n }\n // A private package has no public API. A named folder gets a report all the same.\n if (manifest.private === true && !named && options.includePrivate !== true) {\n skipped.add(folder);\n if (current === undefined) results.push({ folder: shown, file: shownFile, status: \"private\" });\n else {\n if (options.mode === \"update\") rmSync(file);\n results.push({ folder: shown, file: shownFile, status: \"stale\" });\n }\n continue;\n }\n let text: string;\n try {\n text = packageReport(folder, {\n tool: options.tool ?? DEFAULT_TOOL,\n ...(options.publishConfig === undefined ? {} : { publishConfig: options.publishConfig }),\n });\n } catch (error) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: error instanceof Error ? error.message : String(error) });\n continue;\n }\n const ownPages = (options.pages ?? []).filter((entry) => resolve(root, entry.package) === folder);\n const written = options.mode === \"update\" ? ownPages.flatMap((entry) => writeReference(root, entry, text, manifest.name ?? \"\")) : [];\n const faults = ownPages.flatMap((entry) => faultsOfPages(root, entry, text, manifest.name ?? \"\"));\n const onPages = {\n ...(options.mode === \"check\" && faults.length > 0 ? { pageFaults: faults } : {}),\n ...(written.length > 0 ? { writtenPages: written } : {}),\n };\n if (current === text) {\n results.push({ folder: shown, file: shownFile, status: \"same\", ...onPages });\n continue;\n }\n if (options.mode === \"update\") {\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, text);\n }\n const diff = unifiedDiff(current ?? \"\", text, { from: current === undefined ? \"/dev/null\" : `a/${shownFile}`, to: `b/${shownFile}` });\n results.push({ folder: shown, file: shownFile, status: current === undefined ? \"new\" : \"changed\", diff, ...onPages });\n }\n if (!named) {\n const read = new Set(folders);\n for (const entry of options.pages ?? []) {\n const pageFolder = resolve(root, entry.package);\n if (read.has(pageFolder) && !skipped.has(pageFolder)) continue;\n results.push({ folder: entry.package, file: entry.pages[0] ?? entry.reference ?? \"\", status: \"error\", error: \"the field pages names a package that the command does not read\" });\n }\n for (const folder of globbedFolders(root, options.packages)) {\n const file = join(folder, report);\n if (read.has(folder) || !existsSync(file)) continue;\n if (options.mode === \"update\") rmSync(file);\n results.push({ folder: relativePath(root, folder), file: relativePath(root, file), status: \"stale\" });\n }\n if (results.every((result) => result.status === \"stale\")) {\n results.push({ folder: \".\", file: report, status: \"error\", error: \"no package. The command read the globs of the workspace, or a package.json file in the root.\" });\n }\n }\n const failed = results.some(\n (result) => (result.pageFaults?.length ?? 0) > 0 || result.status === \"error\" || (options.mode === \"check\" && (result.status === \"changed\" || result.status === \"new\" || result.status === \"stale\")),\n );\n return { mode: options.mode, packages: results, failed };\n}\n\n/** The most lines of the diff of one package in the output. */\nconst MAX_DIFF_LINES = 400;\n\n/** This function shortens a diff to `MAX_DIFF_LINES` lines. */\nfunction shortDiff(diff: string): string {\n const lines = diff.replace(/\\n$/, \"\").split(\"\\n\");\n if (lines.length <= MAX_DIFF_LINES) return `${lines.join(\"\\n\")}\\n`;\n return `${lines.slice(0, MAX_DIFF_LINES).join(\"\\n\")}\\n... ${lines.length - MAX_DIFF_LINES} more lines. Start the command update and read the diff in git.\\n`;\n}\n\n/** This function gives the text of a result for a terminal or a CI log. */\nexport function formatResult(result: RunResult, tool: string = DEFAULT_TOOL): string {\n const by = (status: PackageResult[\"status\"]): PackageResult[] => result.packages.filter((item) => item.status === status);\n const reports = result.packages.filter((item) => item.status !== \"private\" && item.status !== \"stale\" && item.status !== \"error\").length;\n const out: string[] = [`${reports} public packages with a report of the API, ${by(\"private\").length} private packages without a report.`];\n const list = (title: string, items: readonly PackageResult[], line: (item: PackageResult) => string): void => {\n if (items.length === 0) return;\n out.push(`${title}:`);\n for (const item of items) out.push(` ${line(item)}`);\n };\n const update = result.mode === \"update\";\n list(update ? \"Written\" : \"The report differs from the built .d.ts files\", by(\"changed\"), (item) => item.file);\n list(update ? \"Written (new)\" : \"No report\", by(\"new\"), (item) => (update ? item.file : `${item.folder} (${item.file})`));\n list(update ? \"Removed (the command does not read the package)\" : \"A report of a package that the command does not read\", by(\"stale\"), (item) => item.file);\n list(\"Written (the page of each export)\", result.packages.filter((item) => (item.writtenPages?.length ?? 0) > 0), (item) => (item.writtenPages ?? []).join(\", \"));\n list(\"Errors\", by(\"error\"), (item) => `${item.folder}: ${item.error ?? \"unknown error\"}`);\n for (const item of result.packages) {\n if ((item.pageFaults?.length ?? 0) > 0) out.push(`The page of the API of ${item.folder} differs from its report:`, ...(item.pageFaults ?? []).map((fault) => ` ${fault}`));\n }\n let text = `${out.join(\"\\n\")}\\n`;\n if (!update) {\n for (const item of by(\"changed\")) text += `\\n${shortDiff(item.diff ?? \"\")}`;\n if (by(\"changed\").length + by(\"new\").length + by(\"stale\").length > 0) {\n text += `\\nTo accept a change of the API, start the build, then \\`${tool} update\\`, review the diff, and commit the reports.\\n`;\n }\n }\n return text;\n}\n\n/** This function gives the result as Markdown for the summary of a GitHub Actions run. It gives an empty string when all reports are current. */\nexport function summaryMarkdown(result: RunResult): string {\n const changed = result.packages.filter((item) => item.status === \"changed\" || item.status === \"new\");\n const other = result.packages.filter((item) => item.status === \"stale\" || item.status === \"error\");\n const pages = result.packages.flatMap((item) => (item.pageFaults ?? []).map((fault) => `- \\`${item.folder}\\`: ${fault}`));\n if (changed.length === 0 && other.length === 0 && pages.length === 0) return \"\";\n const out = [\"### Public API reports\", \"\"];\n for (const item of changed) out.push(`<details><summary><code>${item.file}</code> (${item.status})</summary>`, \"\", \"```diff\", shortDiff(item.diff ?? \"\").replace(/\\n$/, \"\"), \"```\", \"\", \"</details>\", \"\");\n for (const item of other) out.push(`- \\`${item.file}\\`: ${item.status === \"stale\" ? \"a report of a package that the command does not read\" : (item.error ?? \"error\")}`);\n out.push(...pages);\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** The input and output of `runCli`. */\nexport interface CliIo {\n readonly cwd: string;\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/** The help text of the bin. */\nexport const USAGE: string = `Usage: api-report <check | update> [options] [<package folder>...]\n\n check Compare each report with the built .d.ts files. Exit code 1 when a report differs, is missing or has no\n package that the command reads, or when the command finds no package.\n update Write each report again, and each page of the field reference. Remove each report of a package that the\n command does not read.\n\n --root <folder> The root of the repository. The default is the current folder.\n --packages <glob> A glob of package folders. Use it again for more globs. The default is the globs of the workspace.\n --report <path> The path of the report in each package folder. The default is ${REPORT_FILE}.\n --include-private Also make a report for each private package.\n --no-publish-config Read the fields of package.json without publishConfig.\n -h, --help Show this text.\n\nThe field \"apiReport\" of the root package.json can set packages, report, includePrivate, publishConfig, tool and pages.\n`;\n\n/** An error of the arguments: exit code 2 and the help text. */\nclass UsageError extends Error {}\n\n/** This function starts the bin with the arguments `args`, and gives its exit code. */\nexport function runCli(args: readonly string[], io: CliIo): number {\n let mode: Mode | undefined;\n let root = io.cwd;\n const packages: string[] = [];\n const folders: string[] = [];\n const flags: { report?: string; includePrivate?: boolean; publishConfig?: boolean } = {};\n for (let index = 0; index < args.length; index++) {\n const arg = args[index] ?? \"\";\n const value = (): string => {\n const next = args[++index];\n if (next === undefined || next.startsWith(\"-\")) throw new UsageError(`The option ${arg} needs a value.`);\n return next;\n };\n try {\n if (arg === \"check\" || arg === \"--check\") mode = \"check\";\n else if (arg === \"update\" || arg === \"--update\") mode = \"update\";\n else if (arg === \"--root\") root = resolve(io.cwd, value());\n else if (arg === \"--packages\") packages.push(value());\n else if (arg === \"--report\") flags.report = value();\n else if (arg === \"--include-private\") flags.includePrivate = true;\n else if (arg === \"--no-publish-config\") flags.publishConfig = false;\n else if (arg === \"--help\" || arg === \"-h\") {\n io.stdout(USAGE);\n return 0;\n } else if (arg.startsWith(\"-\")) throw new UsageError(`An unknown option: ${arg}`);\n else folders.push(arg);\n } catch (error) {\n if (!(error instanceof UsageError)) throw error;\n io.stderr(`api-report: ${error.message}\\n\\n${USAGE}`);\n return 2;\n }\n }\n if (mode === undefined) {\n io.stderr(`api-report: give the command check or update.\\n\\n${USAGE}`);\n return 2;\n }\n let result: RunResult;\n let tool: string;\n try {\n const config = readConfig(root);\n tool = config.tool ?? DEFAULT_TOOL;\n result = runReports({\n ...config,\n ...flags,\n ...(packages.length > 0 ? { packages } : {}),\n mode,\n root,\n folders: folders.map((folder) => resolve(io.cwd, folder)),\n });\n } catch (error) {\n io.stderr(`api-report: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n io.stdout(formatResult(result, tool));\n const summary = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (summary && mode === \"check\") {\n const markdown = summaryMarkdown(result);\n if (markdown !== \"\") appendFileSync(summary, markdown);\n }\n return result.failed ? 1 : 0;\n}\n"],"mappings":";;;;AAqDA,MAAM,eAAe;AAGrB,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAM,YAAY,OAAO,GAAG;AAC5B,MAAM,OAAO,GAAG,aAAa,UAAU;;AAGvC,SAAS,QAAQ,SAA+B,GAAG,OAAyB;CAC1E,OAAO,IAAI,OAAO,OAAO,IAAI,EAAE,KAAK,QAAQ,IAAI,GAAG,GAAG,KAAK,GAAG,GAAG;AACnE;AAEA,MAAM,YAAY,OAAO,eAAe,KAAK,eAAe,KAAK;AACjE,MAAM,iBAAiB,OAAO,kDAAkD,KAAK;AACrF,MAAM,iBAAiB,OAAO,KAAK,KAAK;AACxC,MAAM,mBAAmB,OAAO,WAAW,KAAK;AAChD,MAAM,iBAAiB,OAAO,8BAA8B,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IAAI,CAAC;CACpC,MAAM,UAAU,GAAG,IAAI;CACvB,IAAI,WAAW,SAAS,SAAS;EAC/B,MAAM,WAAW,gBAAgB,MAAM;EACvC,IAAI,aAAa,IAAI,eAAe,SAAS,QAAQ;CACvD;CACA,OAAO,OAAO,SAAS,IAAI;AAC7B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/api-report",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"description": "A report of the public API of each package of a workspace, from its built .d.ts files: a check in CI shows each change of the API in the pull request.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"api-report",
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=22"
|
|
41
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@mark1russell7/conventions": "^0.38.1"
|
|
44
|
+
},
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@mark1russell7/cue": "^2.0.0",
|
|
44
47
|
"@types/node": "^26.6.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-BX1npfID.js","names":[],"sources":["../src/declarations.ts","../src/diff.ts","../src/entries.ts","../src/page.ts","../src/reference.ts","../src/report.ts","../src/workspace.ts","../src/run.ts"],"sourcesContent":["/**\n * The reader of the text of a declaration file. TypeScript 7 has no stable compiler API, so this\n * module reads the `.d.ts` files as text. The declaration emit of `tsc` and of `tsdown` is regular,\n * and an unknown form of statement throws.\n */\n\n/** An import of a declaration file, by its local name. */\nexport interface ImportBinding {\n /** The module specifier. */\n readonly from: string;\n /** The imported name, or `default`, `export=` or `*`. */\n readonly imported: string;\n readonly typeOnly: boolean;\n}\n\n/** A name that a module exports from its own scope. */\nexport interface LocalExport {\n /** The local name of the exported name. */\n readonly local: string;\n readonly typeOnly: boolean;\n}\n\n/** A part of an `export { a as b } from \"x\"` statement. */\nexport interface Reexport {\n readonly imported: string;\n readonly exported: string;\n readonly typeOnly: boolean;\n readonly from: string;\n}\n\n/** The statements of one declaration file, sorted by their kind. */\nexport interface DeclarationInfo {\n /** The declarations of the module by name, exported or not. */\n readonly locals: Map<string, string[]>;\n /** The names that the module exports from its own scope, by the exported name. */\n readonly exported: Map<string, LocalExport>;\n /** The `export { a as b } from \"x\"` parts. */\n readonly reexports: Reexport[];\n /** The `export * from \"x\"` statements. */\n readonly stars: { readonly from: string; readonly typeOnly: boolean }[];\n /** The `export * as name from \"x\"` statements. */\n readonly namespaces: { readonly name: string; readonly from: string; readonly typeOnly: boolean }[];\n /** The imports by local name. */\n readonly imports: Map<string, ImportBinding>;\n /** The ambient declarations by label: `declare module \"x\"`, `declare global`, `export as namespace X`. */\n readonly ambient: Map<string, string[]>;\n /** Each module specifier that the file names: the files that it reaches. */\n readonly references: Set<string>;\n}\n\n/** A mode of the reader of a template literal. */\ntype Mode = { readonly kind: \"template\" } | { readonly kind: \"part\"; readonly depth: number };\n\nconst BLOCK_HEADER = /^(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+class|class|interface|const\\s+enum|enum|namespace|module|global)\\b/;\n\n// A name of the ECMAScript grammar: a start letter, then continue letters. The letters include the letters that are not ASCII.\nconst NAME_START = String.raw`[\\p{ID_Start}$_]`;\nconst NAME_PART = String.raw`[\\p{ID_Continue}$]`;\nconst NAME = `${NAME_START}${NAME_PART}*`;\n\n/** This tag makes a pattern with the flag `u` from raw text. The `\\p{...}` classes of a name need that flag. */\nfunction unicode(strings: TemplateStringsArray, ...parts: string[]): RegExp {\n return new RegExp(String.raw({ raw: strings.raw }, ...parts), \"u\");\n}\n\nconst SPECIFIER = unicode`^(type\\s+)?(${NAME})(?:\\s+as\\s+(${NAME}|\"[^\"]*\"))?$`;\nconst PRIVATE_MEMBER = unicode`^\\s+(?:private\\s+(?:static\\s+)?(?:readonly\\s+)?${NAME}\\??;|#private;)$`;\nconst DEFAULT_IMPORT = unicode`^(${NAME})\\s*(?:,|$)`;\nconst NAMESPACE_IMPORT = unicode`^\\* as (${NAME})$`;\nconst IMPORT_REQUIRE = unicode`^(export )?import (type )?(${NAME}) = require\\([\"']([^\"']+)[\"']\\);?$`;\nconst IMPORT_ALIAS = unicode`^(export )?import (${NAME}) = ${NAME}(?:\\.${NAME})*;?$`;\nconst NAMESPACE_EXPORT = unicode`^export (type )?\\* as (${NAME}) from [\"']([^\"']+)[\"'];?$`;\nconst EXPORT_ASSIGNMENT = unicode`^export = (${NAME});?$`;\nconst EXPORT_AS_NAMESPACE = unicode`^export as namespace (${NAME});?$`;\nconst DEFAULT_NAME = unicode`^export default (${NAME});?$`;\n// The negative lookahead stops `classX` as a keyword. The name is empty for a default function or class without a name.\nconst NAMELESS_DEFAULT = unicode`^export default (?:declare )?(?:abstract )?(?:class|function\\*?)(?!${NAME_PART})\\s*((?:${NAME})?)`;\nconst DECLARATOR = unicode`^\\s*(${NAME})`;\nconst DECLARATION = unicode`^(export )?(default )?(?:declare )?(?:abstract )?(?:const (?=enum))?(?:function|class|interface|type|enum|namespace|module) (${NAME})`;\n\n/**\n * This function splits the text of a declaration file into its top-level statements. It removes the\n * comments, the blank lines and the spaces at the ends of the lines.\n */\nexport function statementsOf(source: string): string[] {\n // The declarations of a bin file keep its `#!` line\n const text = source.replace(/\\r\\n?/g, \"\\n\").replace(/^#![^\\n]*\\n?/, \"\");\n const statements: string[] = [];\n let current = \"\";\n let depth = 0;\n // The depth of the type arguments at the top level: `class A<T = {}> {` has a brace in them\n let angle = 0;\n // True when the body of a class, an interface, an enum or a namespace is open\n let body = false;\n // The template literals and their `${ }` parts, from the outside in\n const modes: Mode[] = [];\n\n const finish = (): void => {\n const lines = current\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .filter((line) => line.trim() !== \"\");\n if (lines.length > 0) statements.push(lines.join(\"\\n\"));\n current = \"\";\n angle = 0;\n body = false;\n };\n\n let index = 0;\n while (index < text.length) {\n const char = text.charAt(index);\n const next = text.charAt(index + 1);\n const mode = modes.at(-1);\n if (mode?.kind === \"template\") {\n if (char === \"\\\\\") {\n current += char + next;\n index += 2;\n } else if (char === \"`\") {\n modes.pop();\n current += char;\n index++;\n } else if (char === \"$\" && next === \"{\") {\n modes.push({ kind: \"part\", depth });\n current += \"${\";\n index += 2;\n } else {\n current += char;\n index++;\n }\n continue;\n }\n if (char === \"/\" && next === \"/\") {\n while (index < text.length && text.charAt(index) !== \"\\n\") index++;\n continue;\n }\n if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end < 0 ? text.length : end + 2;\n current += \" \";\n continue;\n }\n if (char === '\"' || char === \"'\") {\n let end = index + 1;\n while (end < text.length && text.charAt(end) !== char) end += text.charAt(end) === \"\\\\\" ? 2 : 1;\n current += text.slice(index, end + 1);\n index = end + 1;\n continue;\n }\n if (char === \"`\") {\n modes.push({ kind: \"template\" });\n current += char;\n index++;\n continue;\n }\n if (modes.length === 0 && depth === 0) {\n // The `>` of an arrow `=>` closes nothing\n if (char === \"<\") angle++;\n else if (char === \">\" && text.charAt(index - 1) !== \"=\") angle = Math.max(0, angle - 1);\n else if (char === \"{\" && angle === 0 && !body && BLOCK_HEADER.test(current.trim())) body = true;\n }\n if (char === \"{\" || char === \"(\" || char === \"[\") depth++;\n if (char === \"}\" || char === \")\" || char === \"]\") {\n if (char === \"}\" && mode?.kind === \"part\" && depth === mode.depth) {\n modes.pop();\n current += char;\n index++;\n continue;\n }\n depth--;\n }\n current += char;\n index++;\n if (modes.length > 0 || depth !== 0) continue;\n if (char === \";\" || (char === \"}\" && body)) finish();\n }\n finish();\n return statements;\n}\n\n/** This function splits `text` at each comma outside brackets, type arguments and strings. */\nfunction splitTopLevel(text: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let index = 0; index < text.length; index++) {\n const char = text.charAt(index);\n if (char === '\"' || char === \"'\" || char === \"`\") {\n let end = index + 1;\n while (end < text.length && text.charAt(end) !== char) end += text.charAt(end) === \"\\\\\" ? 2 : 1;\n index = end;\n } else if (char === \"(\" || char === \"[\" || char === \"{\" || char === \"<\") depth++;\n else if (char === \")\" || char === \"]\" || char === \"}\" || (char === \">\" && text.charAt(index - 1) !== \"=\")) depth--;\n else if (char === \",\" && depth === 0) {\n parts.push(text.slice(start, index));\n start = index + 1;\n }\n }\n parts.push(text.slice(start));\n return parts;\n}\n\n/** The names of an export or import list: `a, type b, c as d`. */\nfunction specifiersOf(list: string, typeOnly: boolean): { imported: string; exported: string; typeOnly: boolean }[] {\n return list\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part !== \"\")\n .map((part) => {\n const match = SPECIFIER.exec(part);\n if (!match?.[2]) throw new Error(`An export list part that the report does not know: ${part}`);\n return { imported: match[2], exported: match[3] ?? match[2], typeOnly: typeOnly || match[1] !== undefined };\n });\n}\n\n/** This function removes the private members of a class: they are not part of the API. */\nfunction withoutPrivateMembers(statement: string): string {\n return statement\n .split(\"\\n\")\n .filter((line) => !PRIVATE_MEMBER.test(line))\n .join(\"\\n\");\n}\n\n/** A capture group of a match that the pattern always sets. */\nconst group = (match: RegExpExecArray, index: number): string => match[index] ?? \"\";\n\n/**\n * This function sorts the statements of the text of one declaration file by their kind. `file`\n * names the file in the errors. An unknown form of statement throws.\n */\nexport function parseDeclarations(source: string, file = \"<text>\"): DeclarationInfo {\n const info: DeclarationInfo = {\n locals: new Map(),\n exported: new Map(),\n reexports: [],\n stars: [],\n namespaces: [],\n imports: new Map(),\n ambient: new Map(),\n references: new Set(),\n };\n const addLocal = (name: string, statement: string): void => {\n info.locals.set(name, [...(info.locals.get(name) ?? []), statement]);\n };\n const addAmbient = (label: string, statement: string): void => {\n info.ambient.set(label, [...(info.ambient.get(label) ?? []), statement]);\n };\n for (const statement of statementsOf(source)) {\n const flat = statement.replace(/\\s+/g, \" \");\n for (const found of flat.matchAll(/\\bimport\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/g)) info.references.add(found[1] ?? \"\");\n let match: RegExpExecArray | null;\n if ((match = /^import (type )?(.+?) from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n const typeOnly = match[1] !== undefined;\n const from = group(match, 3);\n info.references.add(from);\n let clause = group(match, 2).trim();\n const defaultName = DEFAULT_IMPORT.exec(clause);\n if (defaultName) {\n info.imports.set(group(defaultName, 1), { from, imported: \"default\", typeOnly });\n clause = clause.slice(defaultName[0].length).trim();\n }\n const namespace = NAMESPACE_IMPORT.exec(clause);\n if (namespace) info.imports.set(group(namespace, 1), { from, imported: \"*\", typeOnly });\n const braces = /^\\{(.*)\\}$/.exec(clause);\n if (braces) {\n for (const specifier of specifiersOf(group(braces, 1), typeOnly)) {\n info.imports.set(specifier.exported, { from, imported: specifier.imported, typeOnly: specifier.typeOnly });\n }\n }\n continue;\n }\n if ((match = /^import [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n info.references.add(group(match, 1));\n continue;\n }\n // `import x = require(\"y\")`: the name is the `export =` of the module\n if ((match = IMPORT_REQUIRE.exec(flat))) {\n const name = group(match, 3);\n info.references.add(group(match, 4));\n info.imports.set(name, { from: group(match, 4), imported: \"export=\", typeOnly: match[2] !== undefined });\n if (match[1] !== undefined) info.exported.set(name, { local: name, typeOnly: false });\n continue;\n }\n // `import A = N.B`: an alias of a name of a namespace\n if ((match = IMPORT_ALIAS.exec(flat))) {\n const name = group(match, 2);\n addLocal(name, statement);\n if (match[1] !== undefined) info.exported.set(name, { local: name, typeOnly: false });\n continue;\n }\n if ((match = NAMESPACE_EXPORT.exec(flat))) {\n info.references.add(group(match, 3));\n info.namespaces.push({ name: group(match, 2), from: group(match, 3), typeOnly: match[1] !== undefined });\n continue;\n }\n if ((match = /^export (type )?\\* from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n info.references.add(group(match, 2));\n info.stars.push({ from: group(match, 2), typeOnly: match[1] !== undefined });\n continue;\n }\n if ((match = /^export (type )?\\{(.*)\\} from [\"']([^\"']+)[\"'];?$/.exec(flat))) {\n const from = group(match, 3);\n info.references.add(from);\n for (const specifier of specifiersOf(group(match, 2), match[1] !== undefined)) info.reexports.push({ ...specifier, from });\n continue;\n }\n if ((match = /^export (type )?\\{(.*)\\};?$/.exec(flat))) {\n for (const specifier of specifiersOf(group(match, 2), match[1] !== undefined)) {\n info.exported.set(specifier.exported, { local: specifier.imported, typeOnly: specifier.typeOnly });\n }\n continue;\n }\n // `export = X`: the module is the value X (CommonJS)\n if ((match = EXPORT_ASSIGNMENT.exec(flat))) {\n info.exported.set(\"export=\", { local: group(match, 1), typeOnly: false });\n continue;\n }\n if (/^export = /.test(flat)) {\n addLocal(\"export=\", statement);\n info.exported.set(\"export=\", { local: \"export=\", typeOnly: false });\n continue;\n }\n if ((match = /^(?:export )?declare module ([\"'][^\"']+[\"'])/.exec(flat))) {\n addAmbient(`declare module ${group(match, 1).replaceAll(\"'\", '\"')}`, statement);\n continue;\n }\n if (/^(?:export )?(?:declare )?global \\{/.test(flat)) {\n addAmbient(\"declare global\", statement);\n continue;\n }\n if ((match = EXPORT_AS_NAMESPACE.exec(flat))) {\n addAmbient(`export as namespace ${group(match, 1)}`, statement);\n continue;\n }\n // `export default x`: the default export is a name of the module\n if ((match = DEFAULT_NAME.exec(flat))) {\n info.exported.set(\"default\", { local: group(match, 1), typeOnly: false });\n continue;\n }\n // A default function or class without a name\n match = NAMELESS_DEFAULT.exec(flat);\n if (match && (match[1] === \"\" || match[1] === \"extends\" || match[1] === \"implements\")) {\n addLocal(\"default\", withoutPrivateMembers(statement));\n info.exported.set(\"default\", { local: \"default\", typeOnly: false });\n continue;\n }\n // `const a: A, b: B` declares two names\n if ((match = /^(export )?(?:declare )?(?:const|let|var) (?!enum\\b)(.*?);?$/.exec(flat))) {\n const exported = match[1] !== undefined;\n for (const part of splitTopLevel(group(match, 2))) {\n const name = DECLARATOR.exec(part);\n if (!name) throw new Error(`A declaration that the report does not know, in ${file}:\\n${statement}`);\n addLocal(group(name, 1), statement);\n if (exported) info.exported.set(group(name, 1), { local: group(name, 1), typeOnly: false });\n }\n continue;\n }\n match = DECLARATION.exec(flat);\n if (match) {\n const name = group(match, 3);\n addLocal(name, withoutPrivateMembers(statement));\n if (match[1] !== undefined) info.exported.set(match[2] !== undefined ? \"default\" : name, { local: name, typeOnly: false });\n continue;\n }\n // `export default <expression>`\n if (/^export default /.test(flat)) {\n addLocal(\"default\", statement);\n info.exported.set(\"default\", { local: \"default\", typeOnly: false });\n continue;\n }\n throw new Error(`A statement that the report does not know, in ${file}:\\n${statement}`);\n }\n return info;\n}\n","/** A line diff (the algorithm of Myers) and its text in the unified format of `diff -u` and git. */\n\n/** An operation of a line diff: a kept line, a removed line or an added line. */\nexport interface DiffLine {\n readonly kind: \" \" | \"-\" | \"+\";\n readonly text: string;\n}\n\n/** Above this number of changes, the diff replaces the whole changed part, so the memory stays small. */\nconst MAX_EDITS = 2000;\n\n/** This function gives the shortest edit script that changes the lines `before` into the lines `after`. */\nexport function diffLines(before: readonly string[], after: readonly string[]): DiffLine[] {\n // The common start and end need no search\n let start = 0;\n while (start < before.length && start < after.length && before[start] === after[start]) start++;\n let end = 0;\n while (end < before.length - start && end < after.length - start && before[before.length - 1 - end] === after[after.length - 1 - end]) end++;\n const a = before.slice(start, before.length - end);\n const b = after.slice(start, after.length - end);\n const kept = (lines: readonly string[]): DiffLine[] => lines.map((text) => ({ kind: \" \", text }));\n return [...kept(before.slice(0, start)), ...middle(a, b), ...kept(before.slice(before.length - end))];\n}\n\n/** This function gives the edit script of two lists that have different first lines and different last lines. */\nfunction middle(a: readonly string[], b: readonly string[]): DiffLine[] {\n const n = a.length;\n const m = b.length;\n const replace = (): DiffLine[] => [...a.map((text): DiffLine => ({ kind: \"-\", text })), ...b.map((text): DiffLine => ({ kind: \"+\", text }))];\n if (n === 0 || m === 0) return replace();\n const max = Math.min(n + m, MAX_EDITS);\n const offset = max + 1;\n const v = new Int32Array(2 * max + 3);\n // trace[d] holds v[-d..d] before the step d\n const trace: Int32Array[] = [];\n for (let d = 0; d <= max; d++) {\n trace.push(v.slice(offset - d, offset + d + 1));\n for (let k = -d; k <= d; k += 2) {\n const down = k === -d || (k !== d && (v[offset + k - 1] ?? 0) < (v[offset + k + 1] ?? 0));\n let x = down ? (v[offset + k + 1] ?? 0) : (v[offset + k - 1] ?? 0) + 1;\n let y = x - k;\n while (x < n && y < m && a[x] === b[y]) {\n x++;\n y++;\n }\n v[offset + k] = x;\n if (x >= n && y >= m) return backtrack(a, b, trace);\n }\n }\n return replace();\n}\n\n/** This function follows the trace of the search back from the end, and gives the operations in order. */\nfunction backtrack(a: readonly string[], b: readonly string[], trace: readonly Int32Array[]): DiffLine[] {\n const result: DiffLine[] = [];\n let x = a.length;\n let y = b.length;\n for (let d = trace.length - 1; d >= 0; d--) {\n const v = trace[d] ?? new Int32Array(0);\n const at = (k: number): number => v[k + d] ?? 0;\n const k = x - y;\n const down = k === -d || (k !== d && at(k - 1) < at(k + 1));\n const previousK = down ? k + 1 : k - 1;\n const previousX = d === 0 ? 0 : at(previousK);\n const previousY = d === 0 ? 0 : previousX - previousK;\n while (x > previousX && y > previousY) {\n result.push({ kind: \" \", text: a[x - 1] ?? \"\" });\n x--;\n y--;\n }\n if (d === 0) break;\n if (down) result.push({ kind: \"+\", text: b[y - 1] ?? \"\" });\n else result.push({ kind: \"-\", text: a[x - 1] ?? \"\" });\n x = previousX;\n y = previousY;\n }\n return result.reverse();\n}\n\n/** The options of a unified diff. */\nexport interface UnifiedDiffOptions {\n /** The number of kept lines around each change. The default is 3. */\n readonly context?: number;\n /** The name of the file before the change, after `---`. */\n readonly from?: string;\n /** The name of the file after the change, after `+++`. */\n readonly to?: string;\n}\n\n/**\n * This function gives the change from the text `before` to the text `after` in the unified format.\n * The result is an empty string when the texts are the same.\n */\nexport function unifiedDiff(before: string, after: string, options: UnifiedDiffOptions = {}): string {\n const split = (text: string): string[] => (text === \"\" ? [] : text.replace(/\\n$/, \"\").split(\"\\n\"));\n const ops = diffLines(split(before), split(after));\n const context = options.context ?? 3;\n // The position of each operation in the two texts\n const positions: { a: number; b: number }[] = [];\n let a = 0;\n let b = 0;\n for (const op of ops) {\n positions.push({ a, b });\n if (op.kind !== \"+\") a++;\n if (op.kind !== \"-\") b++;\n }\n const changes = ops.flatMap((op, index) => (op.kind === \" \" ? [] : [index]));\n if (changes.length === 0) return \"\";\n const lines = [`--- ${options.from ?? \"before\"}`, `+++ ${options.to ?? \"after\"}`];\n let index = 0;\n while (index < changes.length) {\n const first = changes[index] ?? 0;\n let last = first;\n while (index + 1 < changes.length && (changes[index + 1] ?? 0) - last <= 2 * context) last = changes[++index] ?? last;\n index++;\n const from = Math.max(0, first - context);\n const to = Math.min(ops.length - 1, last + context);\n const hunk = ops.slice(from, to + 1);\n const start = positions[from] ?? { a: 0, b: 0 };\n const countA = hunk.filter((op) => op.kind !== \"+\").length;\n const countB = hunk.filter((op) => op.kind !== \"-\").length;\n // As in diff -u, an empty side starts at the line before the hunk\n const range = (line: number, count: number): string => `${count === 0 ? line : line + 1}${count === 1 ? \"\" : `,${count}`}`;\n lines.push(`@@ -${range(start.a, countA)} +${range(start.b, countB)} @@`);\n for (const op of hunk) lines.push(`${op.kind}${op.text}`);\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * The entries of a package for its report: the subpaths of the `exports` field (or `types` and\n * `main`), each with its declaration file, and the bins.\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { join, relative, resolve, sep } from \"node:path\";\n\n/** The fields of a `package.json` file that the report reads. */\nexport interface Manifest {\n readonly name?: string;\n readonly private?: boolean;\n readonly exports?: unknown;\n readonly imports?: unknown;\n readonly types?: unknown;\n readonly typings?: unknown;\n readonly main?: unknown;\n readonly bin?: unknown;\n readonly publishConfig?: Readonly<Record<string, unknown>>;\n readonly [field: string]: unknown;\n}\n\n/** A file that an entry without a declaration file exports: the subpath and the path of the file. */\nexport interface EntryFile {\n /** The subpath that a consumer imports, for example `./tsconfig/base.json`. */\n readonly subpath: string;\n /** The file, relative to the package folder, for example `./tsconfig/base.json`. */\n readonly path: string;\n}\n\n/** An entry of a package: a subpath and its declaration file, or a note when it has none. */\nexport interface Entry {\n /** The subpath of the `exports` field, for example `.` or `./client`. */\n readonly subpath: string;\n /** The declaration file, relative to the package folder, for example `./build/index.d.ts`. */\n readonly types?: string;\n /** This text tells why the entry has no declaration file. */\n readonly note?: string;\n /** The files that an entry without a declaration file exports, in the order of the subpaths. A removed file changes the report. */\n readonly files?: readonly EntryFile[];\n}\n\n/** A command of the `bin` field of a package. */\nexport interface Bin {\n readonly name: string;\n readonly path: string;\n}\n\n/** The conditions of the `exports` field that a TypeScript consumer can use, in no order. */\nconst CONDITIONS = new Set([\"types\", \"import\", \"node\", \"default\", \"require\"]);\n\n/**\n * The fields of `publishConfig` that pnpm puts in the published `package.json`. A source package of\n * the template has `main: ./src/index.ts`, and its `publishConfig` gives the built entries.\n */\nexport const PUBLISH_CONFIG_FIELDS: readonly string[] = [\"bin\", \"main\", \"module\", \"exports\", \"imports\", \"types\", \"typings\", \"typesVersions\", \"browser\"];\n\n/** The order of the code units: the same on each machine, with no locale. */\nexport const byCode = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** This function gives a path relative to `root`, with `/`. */\nexport const relativePath = (root: string, file: string): string => relative(root, file).split(sep).join(\"/\");\n\n/** This function gives the manifest as pnpm publishes it: the fields of `publishConfig` replace the fields of the source. */\nexport function publishedManifest(manifest: Manifest): Manifest {\n const config = manifest.publishConfig;\n if (!config) return manifest;\n const result: Record<string, unknown> = { ...manifest };\n for (const field of PUBLISH_CONFIG_FIELDS) if (config[field] !== undefined) result[field] = config[field];\n return result;\n}\n\n/**\n * This function gives the declaration file of a JavaScript or declaration path: `a.js` gives\n * `a.d.ts`, and `a.mjs` gives `a.d.mts`. The result is undefined for a file of another kind.\n */\nexport function declarationPathOf(path: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(path)) return path;\n const js = /\\.([mc]?)js$/.exec(path);\n if (js) return `${path.slice(0, -js[0].length)}.d.${js[1] ?? \"\"}ts`;\n return undefined;\n}\n\n/** This function matches `subpath` with the key `pattern` of an `exports` or `imports` field. It gives the part of the `*`. */\nexport function patternMatch(pattern: string, subpath: string): string | undefined {\n const star = pattern.indexOf(\"*\");\n if (star < 0) return pattern === subpath ? \"\" : undefined;\n const prefix = pattern.slice(0, star);\n const suffix = pattern.slice(star + 1);\n if (subpath.length < prefix.length + suffix.length || !subpath.startsWith(prefix) || !subpath.endsWith(suffix)) return undefined;\n return subpath.slice(prefix.length, subpath.length - suffix.length);\n}\n\n/**\n * This function gives the target of an `exports` value for a TypeScript consumer: the first known\n * condition, in the order of the object. The result is `null` for an excluded subpath, and undefined\n * when no condition fits.\n */\nexport function targetOf(value: unknown): string | null | undefined {\n if (value === null) return null;\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n for (const item of value) {\n const target = targetOf(item);\n if (typeof target === \"string\") return target;\n }\n return undefined;\n }\n if (typeof value === \"object\") {\n for (const [condition, inner] of Object.entries(value)) {\n if (!CONDITIONS.has(condition)) continue;\n const target = targetOf(inner);\n if (target !== undefined) return target;\n }\n }\n return undefined;\n}\n\n/** This function gives the `exports` field as a map of subpaths. */\nfunction subpathMap(exportsField: unknown): Record<string, unknown> {\n if (typeof exportsField !== \"object\" || Array.isArray(exportsField) || exportsField === null) return { \".\": exportsField };\n const keys = Object.keys(exportsField);\n if (keys.length > 0 && keys.every((key) => !key.startsWith(\".\"))) return { \".\": exportsField };\n return exportsField as Record<string, unknown>;\n}\n\n/** This function gives each file under `dir`, relative to `root` with `/`, without `node_modules`. */\nfunction filesUnder(root: string, dir: string): string[] {\n const start = join(root, dir);\n if (!existsSync(start) || !statSync(start).isDirectory()) return [];\n const found: string[] = [];\n const walk = (folder: string): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (entry.name === \"node_modules\" || entry.name === \".git\") continue;\n const path = join(folder, entry.name);\n if (entry.isDirectory()) walk(path);\n else found.push(relativePath(root, path));\n }\n };\n walk(start);\n return found.sort(byCode);\n}\n\n/**\n * This function gives each file under `root` that the target pattern `target` of the subpath\n * pattern `subpath` matches. Each file has its subpath, in the order of the subpaths. The function\n * skips each subpath that `isExcluded` excludes.\n */\nfunction patternFiles(root: string, subpath: string, target: string, isExcluded: (subpath: string) => boolean): EntryFile[] {\n const pattern = target.replace(/^\\.\\//, \"\");\n const folder = pattern.slice(0, pattern.indexOf(\"*\")).replace(/[^/]*$/, \"\");\n const matched: EntryFile[] = [];\n for (const file of filesUnder(root, folder)) {\n const part = patternMatch(pattern, file);\n if (part === undefined) continue;\n const expanded = subpath.split(\"*\").join(part);\n if (!isExcluded(expanded)) matched.push({ subpath: expanded, path: `./${file}` });\n }\n return matched.sort((a, b) => byCode(a.subpath, b.subpath) || byCode(a.path, b.path));\n}\n\n/** This function gives an entry without a declaration file, with the files that it exports. */\nfunction fileEntry(subpath: string, note: string, files: readonly EntryFile[]): Entry {\n return files.length > 0 ? { subpath, note, files } : { subpath, note };\n}\n\n/**\n * This function gives the entries of a package, in the order of the `exports` field. The\n * `./package.json` entry is not part of the API. A subpath pattern (`./*`) gives one entry for each\n * declaration file that it matches. An entry without a declaration file (for example a JSON or CSS\n * file) lists the files that it exports. `root` is the package folder.\n */\nexport function entriesOf(manifest: Manifest, root: string): Entry[] {\n const entries: Entry[] = [];\n const exists = (path: string): boolean => existsSync(resolve(root, path));\n if (manifest.exports === undefined) {\n // No `exports` field: TypeScript reads `types`, `typings`, then the declaration of `main`\n const field = manifest.types ?? manifest.typings;\n if (typeof field === \"string\") return [{ subpath: \".\", types: field }];\n const main = typeof manifest.main === \"string\" ? manifest.main : \"./index.js\";\n const types = declarationPathOf(main);\n if (types && exists(types)) return [{ subpath: \".\", types }];\n if (typeof manifest.main === \"string\") return [{ subpath: \".\", note: `no declaration file for main ${manifest.main}` }];\n return [];\n }\n const map = subpathMap(manifest.exports);\n const excluded = Object.entries(map)\n .filter(([, value]) => value === null)\n .map(([key]) => key);\n const isExcluded = (subpath: string): boolean => excluded.some((pattern) => patternMatch(pattern, subpath) !== undefined);\n for (const [subpath, value] of Object.entries(map)) {\n if (subpath === \"./package.json\" || value === null) continue;\n const target = targetOf(value);\n if (typeof target !== \"string\") {\n entries.push({ subpath, note: \"no condition for a TypeScript consumer\" });\n continue;\n }\n const declared = declarationPathOf(target);\n const own = (path: string): EntryFile[] => (exists(path) ? [{ subpath, path }] : []);\n if (!subpath.includes(\"*\")) {\n if (isExcluded(subpath)) continue;\n if (!declared) entries.push(fileEntry(subpath, `no declaration file for ${target}`, own(target)));\n // A JavaScript file without a declaration file has no types. A missing build throws later.\n else if (declared !== target && !exists(declared) && exists(target)) entries.push(fileEntry(subpath, `no declaration file for ${target}`, own(target)));\n else entries.push({ subpath, types: declared });\n continue;\n }\n if (!declared?.includes(\"*\")) {\n // A pattern of files that are not declarations, for example `./tsconfig/*.json`\n const files = target.includes(\"*\") ? patternFiles(root, subpath, target, isExcluded) : [];\n const note = files.length === 0 && target.includes(\"*\") ? `no file matches ${target}` : `no declaration pattern for ${target}`;\n entries.push(fileEntry(subpath, note, files));\n continue;\n }\n const matched = patternFiles(root, subpath, declared, isExcluded).map((file): Entry => ({ subpath: file.subpath, types: file.path }));\n if (matched.length === 0) entries.push({ subpath, note: `no file matches ${declared}` });\n entries.push(...matched);\n }\n return entries;\n}\n\n/** This function gives the commands of the `bin` field, in name order. A string `bin` has the name of the package without its scope. */\nexport function binsOf(manifest: Manifest): Bin[] {\n const { bin } = manifest;\n if (typeof bin === \"string\") return [{ name: (manifest.name ?? \"\").replace(/^@[^/]+\\//, \"\"), path: bin }];\n if (typeof bin !== \"object\" || bin === null) return [];\n return Object.entries(bin)\n .filter((entry): entry is [string, string] => typeof entry[1] === \"string\")\n .map(([name, path]) => ({ name, path }))\n .sort((a, b) => byCode(a.name, b.name));\n}\n","/**\n * The check of a hand-written page of an API against the report of its package. A page can explain each\n * call, and the check holds its names. Each export shows in the code of the page. The page gives no name\n * as an export that the package does not have.\n */\nimport { byCode } from \"./entries.ts\";\n\n/** One package and the pages that tell its API: an item of the field `pages` of `apiReport`. */\nexport interface ApiPage {\n /** The folder of the package, relative to the root. */\n readonly package: string;\n /** The Markdown or MDX files of the page, relative to the root. Together they tell the API. The list can be empty when `reference` is present. */\n readonly pages: readonly string[];\n /** The file of a page of each export, relative to the root. The command `update` writes it from the report, and the command `check` compares it. */\n readonly reference?: string;\n /** The names that the check does not examine, each with its reason. */\n readonly except?: Readonly<Record<string, string>>;\n}\n\n/** This function gives the names of each entry of a report, by the subpath of the entry. The members of a namespace are not in the result. */\nexport function reportEntries(report: string): ReadonlyMap<string, ReadonlySet<string>> {\n const entries = new Map<string, Set<string>>();\n let current: Set<string> | null = null;\n for (const line of report.split(\"\\n\")) {\n if (line.startsWith(\"## \")) {\n const subpath = /^## (\\.\\S*?)(?: \\(.*\\))?: /.exec(line)?.[1];\n current = null;\n if (subpath !== undefined) {\n const names = new Set<string>();\n entries.set(subpath, names);\n if (line.endsWith(\" names\")) current = names;\n }\n continue;\n }\n const name = /^(?:type )?([^\\s:]+): /.exec(line)?.[1];\n if (current !== null && name !== undefined && name !== \"ambient\" && !name.includes(\".\")) current.add(name);\n }\n return entries;\n}\n\n/** This function gives the code blocks and the code spans of a Markdown text. */\nfunction codeOf(text: string): { readonly blocks: readonly string[]; readonly spans: readonly string[] } {\n const blocks: string[] = [];\n const prose: string[] = [];\n let fence: string | null = null;\n let block: string[] = [];\n for (const line of text.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")) {\n const mark = /^\\s*(`{3,}|~{3,})/.exec(line)?.[1];\n if (fence === null) {\n if (mark === undefined) prose.push(line);\n else {\n fence = mark;\n block = [];\n }\n } else if (mark !== undefined && mark[0] === fence[0] && mark.length >= fence.length) {\n blocks.push(block.join(\"\\n\"));\n fence = null;\n } else block.push(line);\n }\n if (fence !== null) blocks.push(block.join(\"\\n\"));\n const spans = [...prose.join(\"\\n\").matchAll(/(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/g)].map((match) => match[2] ?? \"\");\n return { blocks, spans };\n}\n\n/** This function is true if the code has `name` as a whole word. */\nfunction hasWord(code: string, name: string): boolean {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`(?<![\\\\w$])${escaped}(?![\\\\w$])`).test(code);\n}\n\n/**\n * This function gives the faults of the pages of a package against its report.\n *\n * An export must show in a code block or a code span of a page. An import from the package in a code block\n * must name an export of that entry. A signature, an `interface` or a `type` in a code block must be an\n * export of an entry. An exception needs a reason, and an exception that removes no fault is also a fault.\n * When `complete` is true, a different page shows each export, so the first rule does not apply.\n */\nexport function pageFaults(report: string, packageName: string, pages: readonly string[], except: Readonly<Record<string, string>> = {}, complete = false): string[] {\n const entries = reportEntries(report);\n const all = new Set([...entries.values()].flatMap((names) => [...names]));\n const code = pages.map(codeOf);\n const blocks = code.flatMap((item) => item.blocks);\n const text = [...blocks, ...code.flatMap((item) => item.spans)].join(\"\\n\");\n const faults = new Map<string, string>();\n const used = new Set<string>();\n const fault = (name: string, words: string): void => {\n if (Object.hasOwn(except, name)) used.add(name);\n else if (!faults.has(name)) faults.set(name, `${name}: ${words}`);\n };\n\n if (!complete) {\n for (const name of all) {\n if (!hasWord(text, name)) fault(name, \"the package exports this name, and no code on the page shows it.\");\n }\n }\n for (const block of blocks) {\n for (const match of block.matchAll(/import\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*[\"']([^\"']+)[\"']/g)) {\n const source = match[2] ?? \"\";\n if (source !== packageName && !source.startsWith(`${packageName}/`)) continue;\n const names = entries.get(`.${source.slice(packageName.length)}`);\n if (names === undefined) {\n fault(source, \"the page imports from this path, and the package has no such entry.\");\n continue;\n }\n for (const part of (match[1] ?? \"\").split(\",\")) {\n const name = part.replace(/^\\s*type\\s+/, \"\").split(/\\s+as\\s+/)[0]?.trim() ?? \"\";\n if (name !== \"\" && name !== \"default\" && !names.has(name)) fault(name, `the page imports this name from ${source}, and that entry does not export it.`);\n }\n }\n for (const line of block.split(\"\\n\")) {\n const name =\n /^\\s*(?:export\\s+)?(?:declare\\s+)?function\\s+([\\w$]+)\\s*[<(].*;\\s*(?:\\/\\/.*)?$/.exec(line)?.[1] ??\n /^\\s*(?:export\\s+)?(?:declare\\s+)?(?:interface|type)\\s+([\\w$]+)/.exec(line)?.[1];\n if (name !== undefined && !all.has(name)) fault(name, \"the page gives the declaration of this name, and the package does not export it.\");\n }\n }\n for (const [name, reason] of Object.entries(except)) {\n if (reason.trim() === \"\") faults.set(name, `${name}: the exception has no reason.`);\n else if (!used.has(name)) faults.set(name, `${name}: the exception removes no fault, so remove it.`);\n }\n return [...faults.entries()].sort(([a], [b]) => byCode(a, b)).map(([, words]) => words);\n}\n","/**\n * A page of each export of a package, from its report. A library with many exports keeps each name on this\n * page, and a hand-written page explains the main calls. The report has the names and the declarations, so\n * this page has the same text as the report in each build.\n */\n\n/** One line of an entry of a report. */\ninterface ReportItem {\n readonly name: string;\n readonly key: string;\n readonly isType: boolean;\n readonly kind: \"declaration\" | \"namespace\" | \"external\" | \"ambient\";\n}\n\n/** One entry of a report: its subpath and its lines. */\ninterface ReportEntry {\n readonly subpath: string;\n readonly items: readonly ReportItem[];\n}\n\n/** This function gives the entries of a report and the text of each declaration. */\nfunction readReport(report: string): { readonly entries: readonly ReportEntry[]; readonly declarations: ReadonlyMap<string, string> } {\n const entries: ReportEntry[] = [];\n const declarations = new Map<string, string>();\n let items: ReportItem[] | null = null;\n let key: string | null = null;\n let body: string[] = [];\n const close = (): void => {\n if (key !== null) declarations.set(key, body.join(\"\\n\").trimEnd());\n };\n let inDeclarations = false;\n for (const line of report.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")) {\n if (inDeclarations) {\n const next = /^### (.+)$/.exec(line)?.[1];\n if (next === undefined) body.push(line);\n else {\n close();\n key = next;\n body = [];\n }\n continue;\n }\n if (line.startsWith(\"## \")) {\n inDeclarations = line === \"## Declarations\";\n const subpath = /^## (\\.\\S*?)(?: \\(.*\\))?: /.exec(line)?.[1];\n items = null;\n if (subpath !== undefined) {\n const lines: ReportItem[] = [];\n entries.push({ subpath, items: lines });\n if (line.endsWith(\" names\")) items = lines;\n }\n continue;\n }\n if (items === null) continue;\n const match = /^(type )?(.+?): (\\S+)(?: \\((namespace|external)\\))?$/.exec(line);\n if (match === null) continue;\n const name = match[2] ?? \"\";\n const kind = name === \"ambient\" ? \"ambient\" : ((match[4] as \"namespace\" | \"external\" | undefined) ?? \"declaration\");\n items.push({ name, key: match[3] ?? \"\", isType: match[1] !== undefined, kind });\n }\n close();\n return { entries, declarations };\n}\n\n/** This function gives a fenced block of TypeScript. The fence is longer than each run of backticks in the code. */\nfunction fenced(code: string): string {\n const longest = Math.max(2, ...[...code.matchAll(/`+/g)].map((match) => match[0].length));\n const fence = \"`\".repeat(longest + 1);\n return `${fence}ts\\n${code}\\n${fence}`;\n}\n\n/** The most characters of a line of an import list. */\nconst IMPORT_WIDTH = 100;\n\n/** This function gives an import of `names` from `path`, with a line break at `IMPORT_WIDTH`. */\nfunction importOf(names: readonly string[], path: string): string {\n const lines: string[] = [];\n let line = \" \";\n for (const name of names) {\n if (line.length + name.length + 2 > IMPORT_WIDTH) {\n lines.push(line);\n line = \" \";\n }\n line += ` ${name},`;\n }\n lines.push(line);\n return `import {\\n${lines.join(\"\\n\")}\\n} from ${JSON.stringify(path)};`;\n}\n\n/** This function removes the words `export` and `declare` from the start of each statement of a declaration. `declare global` and `declare module` keep the word. */\nfunction plain(declaration: string): string {\n return declaration.replace(/^(?:export )?(?:declare (?!global\\b|module\\b))?/gm, \"\");\n}\n\n/** This pattern finds a name that a bundler changed, to keep two declarations apart: `grid$1`. */\nconst BUNDLER_NAME = /\\$\\d+$/;\n\n/** This function gives the name of the declaration of a line of a report. */\nfunction localName(item: ReportItem): string {\n return item.key.slice(item.key.lastIndexOf(\"#\") + 1);\n}\n\n/** This function puts the name of each export of `items` in `code`, where a bundler changed that name. */\nfunction withExportNames(code: string, items: readonly ReportItem[]): string {\n let text = code;\n for (const item of items) {\n const local = localName(item);\n if (!BUNDLER_NAME.test(local) || item.name.includes(\".\") || item.kind !== \"declaration\") continue;\n const word = new RegExp(`(?<![\\\\w$])${local.replace(/[\\\\^$.*+?()[\\]{}|]/g, \"\\\\$&\")}(?![\\\\w$])`, \"g\");\n text = text.replace(word, () => item.name);\n }\n return text;\n}\n\n/**\n * This function gives the Markdown of the page of each export of a package. Each entry has an import with its\n * names. A declaration shows one time, in the first entry that reaches it. A comment tells the name of an\n * export when the source gave the declaration a different name. A name from a bundler does not show. A\n * comment also tells the package of an external name.\n */\nexport function referencePage(report: string, packageName: string): string {\n const { entries, declarations } = readReport(report);\n const out = [\n \"---\",\n \"# The command `api-report update` writes this file from the report of the package. Do not edit it.\",\n `title: ${JSON.stringify(`Each export of ${packageName}`)}`,\n `description: ${JSON.stringify(`Each entry point of ${packageName}, with its exports and their declarations.`)}`,\n \"---\",\n \"\",\n \"The report of the API of the package makes this page, so the page and the package have the same names. Each section is one entry point. A declaration shows one time, in the first section that has it.\",\n ];\n const seen = new Set<string>();\n for (const entry of entries) {\n const path = `${packageName}${entry.subpath.slice(1)}`;\n out.push(\"\", `## \\`${path}\\``, \"\");\n if (entry.items.length === 0) {\n out.push(\"This entry has no declarations.\");\n continue;\n }\n const top = entry.items.filter((item) => item.kind !== \"ambient\" && !item.name.includes(\".\") && !item.name.startsWith(\"* \"));\n const blocks = top.length > 0 ? [fenced(importOf(top.map((item) => `${item.isType ? \"type \" : \"\"}${item.name === \"default\" ? \"default as defaultExport\" : item.name}`), path))] : [];\n const parts: string[] = [];\n for (const item of entry.items) {\n if (seen.has(`${item.name} ${item.key}`)) continue;\n seen.add(`${item.name} ${item.key}`);\n if (item.kind === \"external\") {\n const from = item.key.slice(0, item.key.lastIndexOf(\"#\"));\n parts.push(`// ${item.name} comes from the package ${from}.`);\n continue;\n }\n const text = declarations.get(item.key);\n if (text === undefined || seen.has(item.key)) continue;\n seen.add(item.key);\n const local = localName(item);\n const label = item.kind === \"ambient\" || local === item.name || BUNDLER_NAME.test(local) ? \"\" : `// The export ${item.name}:\\n`;\n parts.push(`${label}${plain(text)}`);\n }\n if (parts.length > 0) blocks.push(fenced(withExportNames(parts.join(\"\\n\\n\"), entry.items)));\n out.push(blocks.join(\"\\n\\n\"));\n }\n return `${out.join(\"\\n\")}\\n`;\n}\n","/**\n * The report of the public API of a package, from its built `.d.ts` files.\n *\n * The report lists the names that each entry of the `exports` field gives, and the declaration of\n * each name. It follows `export *`, `export { a as b } from`, `export * as ns` and the imports that\n * a module exports again. It also lists the ambient declarations of each file that an entry reaches,\n * and the bins. An entry without a declaration file (for example a JSON file) lists its files. The\n * report has no comments and no private members. Thus a change of a comment or of a private field\n * does not change it.\n *\n * A bundler gives a shared chunk a hash in its name, and the hash changes with the bundler and with\n * private code. The report gives each such file a label without the hash, so an update of a tool does\n * not change the report. A changed declaration in a chunk still changes the report.\n *\n * The heading of an entry does not give a count of names. Two pull requests that each add a name\n * change different lines, so they do not conflict on a count.\n *\n * The text is the same on Windows and on Linux. The line ends\n * are LF, the paths use `/`, and the sort does not use the locale.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { parseDeclarations, type DeclarationInfo } from \"./declarations.ts\";\nimport { binsOf, byCode, declarationPathOf, entriesOf, patternMatch, publishedManifest, relativePath, targetOf, type Entry, type Manifest } from \"./entries.ts\";\n\n/** The command that the header of a report names, when the options give no other command. */\nexport const DEFAULT_TOOL = \"api-report\";\n\n/** The options of a report. */\nexport interface ReportOptions {\n /** The manifest of the package: the report reads its `imports` and `bin` fields. */\n readonly manifest?: Manifest;\n /** The command that the header names, for example `api-report` or `node scripts/api-report.mjs`. */\n readonly tool?: string;\n}\n\n/**\n * The name of a chunk of a bundler: a stem, a hyphen, a hash of 8 characters and the extension of a\n * declaration file. For example `html-o5bDHjNi.d.mts`.\n */\nconst CHUNK_NAME = /^(.+)-([A-Za-z0-9_-]{8})(\\.d\\.[cm]?ts)$/;\n\n/** A hash of a module path in a text, before its extension. It only sorts chunks that have one stem. */\nconst HASH_IN_TEXT = /-[A-Za-z0-9_-]{8}(?=\\.(?:d\\.)?[cm]?[jt]s\\b)/g;\n\n/**\n * This function gives the stem and the extension of the name of a chunk, or null. A tail of small\n * letters and hyphens is a word (`route-resolver.d.ts`), so the name stays. The hash of a chunk has only\n * such characters in approximately 1 of 1,000 builds: then the report shows that hash until the next build.\n */\nfunction chunkOf(name: string): { readonly stem: string; readonly extension: string } | null {\n const match = CHUNK_NAME.exec(name);\n if (match === null || /^[a-z-]+$/.test(match[2] ?? \"\")) return null;\n return { stem: match[1] ?? \"\", extension: match[3] ?? \"\" };\n}\n\n/** This function gives the name of a declaration file without its extension: a module path holds that part. */\nconst chunkStem = (file: string): string => basename(file).replace(/\\.d\\.[cm]?ts$/, \"\");\n\n/**\n * This function gives the label of each chunk in `files`, by its path: `html.chunk.d.mts`, and then\n * `html.chunk2.d.mts` for a second chunk of that stem. Chunks of one stem sort by their text without\n * hashes, so the order does not depend on a hash. A file in `kept` is an entry, and keeps its name. A\n * label does not take the name of a file that exists.\n */\nfunction chunkLabels(files: readonly string[], kept: ReadonlySet<string>): ReadonlyMap<string, string> {\n const groups = new Map<string, { readonly file: string; readonly stem: string; readonly extension: string; readonly text: string }[]>();\n for (const file of files) {\n const chunk = kept.has(file) ? null : chunkOf(basename(file));\n if (chunk === null) continue;\n const key = join(dirname(file), `${chunk.stem}${chunk.extension}`);\n const text = readFileSync(file, \"utf8\").replace(HASH_IN_TEXT, \"\");\n groups.set(key, [...(groups.get(key) ?? []), { file, ...chunk, text }]);\n }\n const labels = new Map<string, string>();\n for (const [, group] of [...groups].sort(([a], [b]) => byCode(a, b))) {\n let number = 1;\n for (const { file, stem, extension } of group.sort((a, b) => byCode(a.text, b.text) || byCode(a.file, b.file))) {\n let label: string;\n do {\n label = join(dirname(file), `${stem}.chunk${number === 1 ? \"\" : number}${extension}`);\n number += 1;\n } while (existsSync(label));\n labels.set(file, label);\n }\n }\n return labels;\n}\n\n/** The binding of an exported name. */\ntype Binding =\n | { readonly kind: \"declaration\"; readonly file: string; readonly local: string; readonly typeOnly: boolean }\n | { readonly kind: \"namespace\"; readonly file: string; readonly typeOnly: boolean }\n | { readonly kind: \"external\"; readonly module: string; readonly name: string; readonly typeOnly: boolean };\n\n/** The reader of the declaration files of one package. */\nclass Reader {\n readonly #infos = new Map<string, DeclarationInfo>();\n readonly #bindings = new Map<string, Map<string, Binding>>();\n readonly #visiting = new Set<string>();\n readonly #root: string;\n readonly #manifest: Manifest;\n\n constructor(root: string, manifest: Manifest) {\n this.#root = root;\n this.#manifest = manifest;\n }\n\n info(file: string): DeclarationInfo {\n let info = this.#infos.get(file);\n if (!info) {\n info = parseDeclarations(readFileSync(file, \"utf8\"), relativePath(this.#root, file));\n this.#infos.set(file, info);\n }\n return info;\n }\n\n /** This method gives the candidate declaration files of a module path. */\n #candidates(base: string): string[] {\n const declared = declarationPathOf(base);\n if (declared) return [declared];\n const source = /\\.([mc]?)ts$/.exec(base);\n if (source) return [`${base.slice(0, -source[0].length)}.d.${source[1] ?? \"\"}ts`];\n return [`${base}.d.ts`, join(base, \"index.d.ts\")];\n }\n\n /**\n * This method gives the declaration file of a module specifier of `from`: a relative path, or a\n * `#` name of the `imports` field. The result is undefined for a module of a different package. A\n * missing file throws, or gives `null` when `soft` is true.\n */\n fileOf(from: string, specifier: string, soft = false): string | null | undefined {\n let base: string | undefined;\n if (specifier.startsWith(\".\")) base = resolve(dirname(from), specifier);\n else if (specifier.startsWith(\"#\") && typeof this.#manifest.imports === \"object\" && this.#manifest.imports !== null) {\n for (const [pattern, value] of Object.entries(this.#manifest.imports)) {\n const part = patternMatch(pattern, specifier);\n const target = part === undefined ? undefined : targetOf(value);\n if (part !== undefined && typeof target === \"string\" && target.startsWith(\".\")) {\n base = resolve(this.#root, target.split(\"*\").join(part));\n break;\n }\n }\n if (base === undefined) return undefined;\n } else return undefined;\n const file = this.#candidates(base).find((candidate) => existsSync(candidate));\n if (file) return file;\n if (soft) return null;\n throw new Error(`No declaration file for \"${specifier}\" from ${relativePath(this.#root, from)}`);\n }\n\n /** This method gives the binding of `imported` in the module `specifier` of `from`. */\n #bindingIn(from: string, specifier: string, imported: string, typeOnly: boolean): Binding {\n const file = this.fileOf(from, specifier);\n if (!file) return { kind: \"external\", module: specifier, name: imported, typeOnly };\n if (imported === \"*\") return { kind: \"namespace\", file, typeOnly };\n const binding = this.exportsOf(file).get(imported);\n if (!binding) throw new Error(`\"${specifier}\" from ${relativePath(this.#root, from)} does not export ${imported}`);\n return typeOnly ? { ...binding, typeOnly: true } : binding;\n }\n\n /** This method gives the names that a module exports, and their bindings. */\n exportsOf(file: string): Map<string, Binding> {\n const known = this.#bindings.get(file);\n if (known) return known;\n if (this.#visiting.has(file)) return new Map();\n this.#visiting.add(file);\n const info = this.info(file);\n const result = new Map<string, Binding>();\n for (const [name, { local, typeOnly }] of info.exported) {\n const imported = info.imports.get(local);\n if (info.locals.has(local)) result.set(name, { kind: \"declaration\", file, local, typeOnly });\n else if (imported) result.set(name, this.#bindingIn(file, imported.from, imported.imported, typeOnly || imported.typeOnly));\n else throw new Error(`${relativePath(this.#root, file)} exports ${local}, and has no declaration or import of it`);\n }\n for (const reexport of info.reexports) result.set(reexport.exported, this.#bindingIn(file, reexport.from, reexport.imported, reexport.typeOnly));\n for (const namespace of info.namespaces) result.set(namespace.name, this.#bindingIn(file, namespace.from, \"*\", namespace.typeOnly));\n // A name of `export *` never replaces an explicit export, and `default` does not pass\n const explicit = new Set(result.keys());\n for (const { from: star, typeOnly } of info.stars) {\n const target = this.fileOf(file, star);\n if (!target) {\n // The names of a different package are not in this package: the report names the package\n const name = `* from \"${star}\"`;\n if (!result.has(name)) result.set(name, { kind: \"external\", module: star, name: \"*\", typeOnly });\n continue;\n }\n // `export type *` gives each name as a type only\n for (const [name, binding] of this.exportsOf(target)) {\n if (name !== \"default\" && !explicit.has(name) && !result.has(name)) result.set(name, typeOnly ? { ...binding, typeOnly: true } : binding);\n }\n }\n this.#visiting.delete(file);\n this.#bindings.set(file, result);\n return result;\n }\n\n /**\n * This method gives each declaration file of the package that `file` reaches through its module\n * specifiers, and `file`. A file outside the package folder or in `node_modules` is not part of it.\n */\n reached(file: string): string[] {\n const seen = new Set<string>();\n const pending = [file];\n for (let next = pending.pop(); next !== undefined; next = pending.pop()) {\n if (seen.has(next)) continue;\n seen.add(next);\n for (const specifier of this.info(next).references) {\n const target = this.fileOf(next, specifier, true);\n if (!target) continue;\n const path = relativePath(this.#root, target);\n if (path.startsWith(\"../\") || path.split(\"/\").includes(\"node_modules\")) continue;\n pending.push(target);\n }\n }\n return [...seen];\n }\n}\n\n/** This function gives the lines of the header of a report. */\nfunction header(packageName: string, tool: string): string[] {\n return [\n `# The public API of ${packageName}`,\n \"#\",\n \"# The names of each entry of the exports field, and the declaration of each name, without comments\",\n `# and private members. The command \\`${tool} check\\` compares this file with the built .d.ts files.`,\n `# To accept a change of the API, start the build, then \\`${tool} update\\`, and review the diff.`,\n ];\n}\n\n/** The number of lines of the header of a report. */\nexport const HEADER_LINES = 5;\n\n/**\n * This function gives the report of the public API of a package. `entries` gives the subpath and\n * the declaration file of each entry, relative to `root`. The report has the exported names of each\n * entry, the bins of the manifest, and then the declaration of each name.\n */\nexport function apiReport(packageName: string, root: string, entries: readonly Entry[], options: ReportOptions = {}): string {\n const manifest = options.manifest ?? {};\n const reader = new Reader(root, manifest);\n const entryFiles = entries.flatMap((entry) => (entry.types === undefined ? [] : [resolve(root, entry.types)])).filter((file) => existsSync(file));\n const labels = chunkLabels([...new Set(entryFiles.flatMap((file) => reader.reached(file)))], new Set(entryFiles));\n const path = (file: string): string => relativePath(root, labels.get(file) ?? file);\n /** This function replaces the name of each chunk in a text with its label: a declaration can name a chunk in `import(\"./x\")`. */\n const plain = (text: string): string => {\n let result = text;\n for (const [file, label] of labels) result = result.replaceAll(chunkStem(file), chunkStem(label));\n return result;\n };\n const keyOf = (binding: Binding): string =>\n binding.kind === \"declaration\" ? `${path(binding.file)}#${binding.local}` : binding.kind === \"namespace\" ? `${path(binding.file)}#*` : `${binding.module}#${binding.name}`;\n const declarations = new Map<string, string>();\n const lines = header(packageName, options.tool ?? DEFAULT_TOOL);\n if (entries.every((entry) => entry.types === undefined)) {\n lines.push(\"\", \"This package has no type declarations: no entry of its package.json gives a .d.ts file.\");\n }\n\n /** The lines of the names of a module, and the names of each namespace in it, with `prefix`. */\n const names = (bindings: Map<string, Binding>, prefix: string, parents: ReadonlySet<string>, typeOnly: boolean): void => {\n for (const [name, binding] of [...bindings].sort(([a], [b]) => byCode(a, b))) {\n const key = keyOf(binding);\n const isType = typeOnly || binding.typeOnly;\n lines.push(`${isType ? \"type \" : \"\"}${prefix}${name}: ${key}${binding.kind === \"declaration\" ? \"\" : ` (${binding.kind})`}`);\n if (binding.kind === \"declaration\" && !declarations.has(key)) {\n declarations.set(key, plain((reader.info(binding.file).locals.get(binding.local) ?? []).join(\"\\n\")));\n }\n // The names of a namespace are part of the API: `ns.name`\n if (binding.kind === \"namespace\" && !parents.has(binding.file)) {\n names(reader.exportsOf(binding.file), `${prefix}${name}.`, new Set([...parents, binding.file]), isType);\n }\n }\n };\n\n for (const entry of entries) {\n if (entry.types === undefined) {\n lines.push(\"\", `## ${entry.subpath}: ${entry.note ?? \"no declaration file\"}`);\n // The files of an entry without declarations: a removed file changes the report\n const files = entry.files ?? [];\n if (files.length > 0) lines.push(\"\", ...files.map((file) => `file ${file.subpath}: ${file.path.replace(/^\\.\\//, \"\")}`));\n continue;\n }\n const file = resolve(root, entry.types);\n if (!existsSync(file)) throw new Error(`${entry.subpath}: ${entry.types} is missing. Build the package first.`);\n const bindings = reader.exportsOf(file);\n lines.push(\"\", `## ${entry.subpath} (${path(file)}): names`, \"\");\n names(bindings, \"\", new Set([file]), false);\n // The ambient declarations of each file that the entry reaches\n const ambient: string[] = [];\n for (const reached of reader.reached(file)) {\n for (const [label, statements] of reader.info(reached).ambient) {\n const key = plain(`${path(reached)}#${label}`);\n ambient.push(key);\n if (!declarations.has(key)) declarations.set(key, plain(statements.join(\"\\n\")));\n }\n }\n for (const key of ambient.sort(byCode)) lines.push(`ambient: ${key}`);\n }\n const bins = binsOf(manifest);\n if (bins.length > 0) {\n lines.push(\"\", `## bin: ${bins.length} commands`, \"\");\n for (const bin of bins) lines.push(`${bin.name}: ${bin.path}`);\n }\n if (declarations.size > 0 || entries.some((entry) => entry.types !== undefined)) {\n lines.push(\"\", \"## Declarations\");\n for (const key of [...declarations.keys()].sort(byCode)) lines.push(\"\", `### ${key}`, declarations.get(key) ?? \"\");\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\n/** The options of the report of a package folder. */\nexport interface PackageReportOptions {\n /** The command that the header names. */\n readonly tool?: string;\n /** When true (the default), the fields of `publishConfig` replace the fields of the source, as pnpm publishes them. */\n readonly publishConfig?: boolean;\n}\n\n/** This function gives the report of the package in the folder `dir`. */\nexport function packageReport(dir: string, options: PackageReportOptions = {}): string {\n const source = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as Manifest;\n const manifest = options.publishConfig === false ? source : publishedManifest(source);\n const name = typeof manifest.name === \"string\" ? manifest.name : basename(dir);\n return apiReport(name, dir, entriesOf(manifest, dir), { manifest, ...(options.tool === undefined ? {} : { tool: options.tool }) });\n}\n","/**\n * The package folders of a repository: the folders that the globs of the workspace name, with a\n * `package.json` file.\n */\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { byCode, relativePath } from \"./entries.ts\";\n\n/** The characters that have a meaning in a regular expression. */\nconst SPECIAL = new Set([...\"\\\\^$.|+()[]{}*?/\"]);\n\n/**\n * This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path\n * segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of\n * its parts. The function escapes each other special character.\n */\nexport function globToRegExp(glob: string): RegExp {\n let source = \"\";\n let braces = 0;\n for (let index = 0; index < glob.length; index++) {\n const char = glob.charAt(index);\n if (char === \"/\" && glob.slice(index + 1) === \"**\") {\n // `a/**` matches `a` and each path under it\n source += \"(?:/.*)?\";\n break;\n }\n if (char === \"*\" && glob.charAt(index + 1) === \"*\") {\n const atStart = index === 0 || glob.charAt(index - 1) === \"/\";\n const after = glob.charAt(index + 2);\n if (atStart && after === \"/\") {\n // `**/` matches zero or more whole segments\n source += \"(?:[^/]+/)*\";\n index += 2;\n } else if (atStart && after === \"\") {\n source += \".*\";\n index += 1;\n } else {\n source += \"[^/]*\";\n index += 1;\n }\n } else if (char === \"*\") source += \"[^/]*\";\n else if (char === \"?\") source += \"[^/]\";\n else if (char === \"{\") {\n braces++;\n source += \"(?:\";\n } else if (char === \"}\" && braces > 0) {\n braces--;\n source += \")\";\n } else if (char === \",\" && braces > 0) source += \"|\";\n else if (SPECIAL.has(char)) source += `\\\\${char}`;\n else source += char;\n }\n if (braces > 0) throw new Error(`A glob with a \"{\" that has no \"}\": ${glob}`);\n return new RegExp(`^${source}$`);\n}\n\n/** The characters that make a path segment a pattern. */\nconst GLOB_CHARS = /[*?{]/;\n\n/** This function removes the `/` characters at the end of a path, with a loop in place of a regular expression. */\nfunction trimEndSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path.charAt(end - 1) === \"/\") end -= 1;\n return path.slice(0, end);\n}\n\n/**\n * This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,\n * in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.\n */\nexport function globFolders(root: string, glob: string): string[] {\n const clean = trimEndSlashes(glob.startsWith(\"./\") ? glob.slice(2) : glob);\n const segments = clean.split(\"/\");\n const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));\n if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];\n const base = segments.slice(0, firstPattern).join(\"/\");\n const depth = clean.includes(\"**\") ? Number.POSITIVE_INFINITY : segments.length - firstPattern;\n const pattern = globToRegExp(clean);\n const start = join(root, base);\n if (!existsSync(start)) return [];\n const found: string[] = [];\n const walk = (folder: string, level: number): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const path = join(folder, entry.name);\n if (pattern.test(relativePath(root, path))) found.push(relativePath(root, path));\n if (level < depth) walk(path, level + 1);\n }\n };\n // `a/**` also names `a`\n if (base !== \"\" && pattern.test(base)) found.push(base);\n walk(start, 1);\n return found.sort(byCode);\n}\n\n/**\n * This function gives the globs of the workspace at `root`: the `packages` list of\n * `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when\n * the repository has no workspace.\n */\nexport function workspaceGlobs(root: string): string[] | undefined {\n const yaml = join(root, \"pnpm-workspace.yaml\");\n if (existsSync(yaml)) {\n const lines = readFileSync(yaml, \"utf8\").split(/\\r?\\n/);\n const start = lines.findIndex((line) => /^packages\\s*:/.test(line));\n if (start >= 0) {\n const unquote = (text: string): string =>\n text\n .replace(/\\s+#.*$/, \"\")\n .trim()\n .replace(/^[\"']|[\"']$/g, \"\");\n const inline = /^packages\\s*:\\s*\\[(.*)\\]/.exec(lines[start] ?? \"\");\n if (inline) return (inline[1] ?? \"\").split(\",\").map(unquote).filter(Boolean);\n const globs: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (/^\\s*(#.*)?$/.test(line)) continue;\n const item = /^\\s+-\\s+(.+)$/.exec(line);\n if (!item) break;\n globs.push(unquote(item[1] ?? \"\"));\n }\n return globs;\n }\n }\n const manifestFile = join(root, \"package.json\");\n if (existsSync(manifestFile)) {\n const { workspaces } = JSON.parse(readFileSync(manifestFile, \"utf8\")) as { workspaces?: unknown };\n if (Array.isArray(workspaces)) return workspaces.filter((glob): glob is string => typeof glob === \"string\");\n if (typeof workspaces === \"object\" && workspaces !== null && \"packages\" in workspaces && Array.isArray(workspaces.packages)) {\n return workspaces.packages.filter((glob): glob is string => typeof glob === \"string\");\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the package folders of the repository at `root`: the folders of the globs\n * that have a `package.json` file. A glob that starts with `!` removes folders. Without globs, the\n * function reads the globs of the workspace, and a repository with no workspace is one package.\n * The result has absolute paths, in the order of the code units.\n */\nexport function packageFolders(root: string, globs: readonly string[] | undefined = workspaceGlobs(root)): string[] {\n if (globs === undefined) return existsSync(join(root, \"package.json\")) ? [root] : [];\n const included = new Set<string>();\n // As in pnpm, a `!` glob removes its folders in each position of the list\n for (const glob of globs.filter((item) => !item.startsWith(\"!\"))) for (const folder of globFolders(root, glob)) included.add(folder);\n for (const glob of globs.filter((item) => item.startsWith(\"!\"))) for (const folder of globFolders(root, glob.slice(1))) included.delete(folder);\n return [...included]\n .filter((folder) => existsSync(join(root, folder, \"package.json\")))\n .sort(byCode)\n .map((folder) => join(root, folder));\n}\n","/**\n * The commands `check` and `update` of the bin `api-report`, as functions. `runReports` compares or\n * writes the reports of each package, and `runCli` reads the arguments and writes the result.\n */\nimport { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { unifiedDiff } from \"./diff.ts\";\nimport { byCode, relativePath, type Manifest } from \"./entries.ts\";\nimport { pageFaults, type ApiPage } from \"./page.ts\";\nimport { referencePage } from \"./reference.ts\";\nimport { DEFAULT_TOOL, packageReport } from \"./report.ts\";\nimport { globFolders, packageFolders, workspaceGlobs } from \"./workspace.ts\";\n\n/** The path of the report in a package folder, when the configuration gives no other path. */\nexport const REPORT_FILE = \"test/api/public-api.txt\";\n\n/** The configuration of the reports: the field `apiReport` of the root `package.json`, or the options of the CLI. */\nexport interface ApiReportConfig {\n /** The globs of the package folders, relative to the root. A glob that starts with `!` removes folders. The default is the globs of the workspace. */\n readonly packages?: readonly string[];\n /** The path of the report in each package folder. The default is `test/api/public-api.txt`. */\n readonly report?: string;\n /** When true, each private package also gets a report. The default is false. */\n readonly includePrivate?: boolean;\n /** When false, the report reads the fields of `package.json` without `publishConfig`. The default is true. */\n readonly publishConfig?: boolean;\n /** The command that the header of each report names. The default is `api-report`. */\n readonly tool?: string;\n /** The pages of an API. The command `check` holds their names against the report of each package. */\n readonly pages?: readonly ApiPage[];\n}\n\n/** The command: `check` compares the reports, and `update` writes them. */\nexport type Mode = \"check\" | \"update\";\n\n/** The options of `runReports`. */\nexport interface RunOptions extends ApiReportConfig {\n readonly mode: Mode;\n /** The root of the repository. */\n readonly root: string;\n /** The package folders to examine. They replace the globs, and a named private package gets a report. */\n readonly folders?: readonly string[];\n}\n\n/** The result of one package. */\nexport interface PackageResult {\n /** The package folder, relative to the root, with `/`. */\n readonly folder: string;\n /** The report file, relative to the root, with `/`. */\n readonly file: string;\n /**\n * `same`: the report is current. `changed` and `new`: the report differs or is missing (`check`),\n * or the command wrote it (`update`). `stale`: a folder has a report, and the run does not read\n * the package: it is private, excluded by a `!` glob, or removed. `private`: the package has no\n * report. `error`: the command did not make the report.\n */\n readonly status: \"same\" | \"changed\" | \"new\" | \"stale\" | \"private\" | \"error\";\n /** The change from the committed report to the new report, in the unified format. */\n readonly diff?: string;\n readonly error?: string;\n /** The faults of the hand-written pages of this package against its report. */\n readonly pageFaults?: readonly string[];\n /** The pages of each export that the command `update` wrote. */\n readonly writtenPages?: readonly string[];\n}\n\n/** The result of `runReports`. */\nexport interface RunResult {\n readonly mode: Mode;\n readonly packages: readonly PackageResult[];\n /** True when the command fails: an error, or (`check` only) a report that is not current. */\n readonly failed: boolean;\n}\n\n/**\n * This function reads the field `apiReport` of the `package.json` file at `root`. The result is an\n * empty configuration when the field does not exist.\n *\n * @throws Error when the field is not an object, or a value has the wrong type\n */\nexport function readConfig(root: string): ApiReportConfig {\n const file = join(root, \"package.json\");\n if (!existsSync(file)) return {};\n const value = (JSON.parse(readFileSync(file, \"utf8\")) as Manifest)[\"apiReport\"];\n if (value === undefined) return {};\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new Error(\"The field apiReport of package.json must be an object.\");\n const config = value as Record<string, unknown>;\n const result: { -readonly [K in keyof ApiReportConfig]: ApiReportConfig[K] } = {};\n const packages = config[\"packages\"];\n if (packages !== undefined) {\n if (!Array.isArray(packages) || !packages.every((glob) => typeof glob === \"string\")) throw new Error(\"apiReport.packages must be an array of globs.\");\n result.packages = packages;\n }\n for (const key of [\"report\", \"tool\"] as const) {\n const item = config[key];\n if (item === undefined) continue;\n if (typeof item !== \"string\" || item === \"\") throw new Error(`apiReport.${key} must be a string.`);\n result[key] = item;\n }\n for (const key of [\"includePrivate\", \"publishConfig\"] as const) {\n const item = config[key];\n if (item === undefined) continue;\n if (typeof item !== \"boolean\") throw new Error(`apiReport.${key} must be true or false.`);\n result[key] = item;\n }\n const pages = config[\"pages\"];\n if (pages !== undefined) result.pages = readPages(pages);\n const unknown = Object.keys(config).filter((key) => ![\"packages\", \"report\", \"tool\", \"includePrivate\", \"publishConfig\", \"pages\"].includes(key));\n if (unknown.length > 0) throw new Error(`apiReport has unknown fields: ${unknown.join(\", \")}.`);\n return result;\n}\n\n/** This function reads the field `pages` of `apiReport`. */\nfunction readPages(value: unknown): readonly ApiPage[] {\n if (!Array.isArray(value)) throw new Error(\"apiReport.pages must be an array.\");\n return value.map((item: unknown, index): ApiPage => {\n const at = `apiReport.pages[${index}]`;\n if (typeof item !== \"object\" || item === null || Array.isArray(item)) throw new Error(`${at} must be an object.`);\n const { package: folder, pages, except, reference } = item as Record<string, unknown>;\n if (typeof folder !== \"string\" || folder === \"\") throw new Error(`${at}.package must be a string.`);\n if (reference !== undefined && (typeof reference !== \"string\" || !isRootPath(reference))) throw new Error(`${at}.reference must be a path in the repository.`);\n const emptyOk = reference !== undefined;\n if (!Array.isArray(pages) || (pages.length === 0 && !emptyOk) || !pages.every((page) => typeof page === \"string\")) throw new Error(`${at}.pages must be an array of paths.`);\n const named = { package: folder, pages: pages as string[], ...(reference === undefined ? {} : { reference: reference as string }) };\n if (except === undefined) return named;\n if (typeof except !== \"object\" || except === null || Array.isArray(except) || !Object.values(except).every((reason) => typeof reason === \"string\")) {\n throw new Error(`${at}.except must be an object of names and reasons.`);\n }\n return { ...named, except: except as Record<string, string> };\n });\n}\n\n/** This function is true for a relative path with no `..`. */\nfunction isRootPath(path: string): boolean {\n const clean = path.replaceAll(\"\\\\\", \"/\");\n return clean !== \"\" && !isAbsolute(path) && !clean.split(\"/\").includes(\"..\");\n}\n\n/** This function gives the text of a file with `\\n` line ends, or undefined when the file does not exist. */\nfunction textOf(file: string): string | undefined {\n return existsSync(file) ? readFileSync(file, \"utf8\").replace(/\\r\\n/g, \"\\n\") : undefined;\n}\n\n/** This function gives the faults of the pages of one package. A file that does not exist is a fault, and so is a page of each export that differs from the report. */\nfunction faultsOfPages(root: string, entry: ApiPage, report: string, packageName: string): string[] {\n const missing = entry.pages.filter((page) => !existsSync(resolve(root, page)));\n if (missing.length > 0) return missing.map((page) => `${page}: the page does not exist.`);\n const faults: string[] = [];\n if (entry.reference !== undefined && textOf(resolve(root, entry.reference)) !== referencePage(report, packageName)) {\n faults.push(`${entry.reference}: the page differs from the report. Start the command update, and commit the page.`);\n }\n const pages = entry.pages.map((page) => readFileSync(resolve(root, page), \"utf8\"));\n return [...faults, ...pageFaults(report, packageName, pages, entry.except, entry.reference !== undefined)];\n}\n\n/** This function writes the page of each export of one package, and gives its path when the text changes. */\nfunction writeReference(root: string, entry: ApiPage, report: string, packageName: string): string[] {\n if (entry.reference === undefined) return [];\n const file = resolve(root, entry.reference);\n const text = referencePage(report, packageName);\n if (textOf(file) === text) return [];\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, text);\n return [entry.reference];\n}\n\n/** This function makes sure that the path of a report stays in its package folder. */\nfunction checkReportPath(report: string): string {\n const clean = report.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\//, \"\");\n if (clean === \"\" || isAbsolute(report) || clean.split(\"/\").includes(\"..\")) throw new Error(`The path of a report must be relative to the package folder, with no \"..\": ${report}`);\n return clean;\n}\n\n/**\n * This function gives the folders that the globs name, as absolute paths, in the order of the code\n * units. It ignores the `!` globs and needs no `package.json` file, so the result also has the\n * excluded folders and the folders of removed packages.\n */\nfunction globbedFolders(root: string, globs: readonly string[] | undefined): string[] {\n const found = new Set<string>();\n for (const glob of (globs ?? workspaceGlobs(root) ?? []).filter((item) => !item.startsWith(\"!\"))) {\n for (const folder of globFolders(root, glob)) found.add(folder);\n }\n return [...found].sort(byCode).map((folder) => join(root, folder));\n}\n\n/**\n * This function compares (`check`) or writes (`update`) the report of each package. It writes nothing\n * in `check` mode. Without named folders, a run that finds no package fails: it examined nothing,\n * and that is not a pass. A repository of private packages passes: it has no public API to report.\n * A report in a folder that the run does not read is `stale`.\n */\nexport function runReports(options: RunOptions): RunResult {\n const root = resolve(options.root);\n const report = checkReportPath(options.report ?? REPORT_FILE);\n const named = options.folders !== undefined && options.folders.length > 0;\n const folders = named ? (options.folders ?? []).map((folder) => resolve(root, folder)) : packageFolders(root, options.packages);\n const results: PackageResult[] = [];\n const skipped = new Set<string>();\n for (const folder of folders) {\n const shown = relativePath(root, folder) || \".\";\n const file = join(folder, report);\n const shownFile = relativePath(root, file);\n const manifestFile = join(folder, \"package.json\");\n if (!existsSync(manifestFile)) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: \"no package.json\" });\n continue;\n }\n // A CRLF checkout gives the same text\n const current = existsSync(file) ? readFileSync(file, \"utf8\").replace(/\\r\\n/g, \"\\n\") : undefined;\n let manifest: Manifest;\n try {\n manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as Manifest;\n } catch (error) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: error instanceof Error ? error.message : String(error) });\n continue;\n }\n // A private package has no public API. A named folder gets a report all the same.\n if (manifest.private === true && !named && options.includePrivate !== true) {\n skipped.add(folder);\n if (current === undefined) results.push({ folder: shown, file: shownFile, status: \"private\" });\n else {\n if (options.mode === \"update\") rmSync(file);\n results.push({ folder: shown, file: shownFile, status: \"stale\" });\n }\n continue;\n }\n let text: string;\n try {\n text = packageReport(folder, {\n tool: options.tool ?? DEFAULT_TOOL,\n ...(options.publishConfig === undefined ? {} : { publishConfig: options.publishConfig }),\n });\n } catch (error) {\n results.push({ folder: shown, file: shownFile, status: \"error\", error: error instanceof Error ? error.message : String(error) });\n continue;\n }\n const ownPages = (options.pages ?? []).filter((entry) => resolve(root, entry.package) === folder);\n const written = options.mode === \"update\" ? ownPages.flatMap((entry) => writeReference(root, entry, text, manifest.name ?? \"\")) : [];\n const faults = ownPages.flatMap((entry) => faultsOfPages(root, entry, text, manifest.name ?? \"\"));\n const onPages = {\n ...(options.mode === \"check\" && faults.length > 0 ? { pageFaults: faults } : {}),\n ...(written.length > 0 ? { writtenPages: written } : {}),\n };\n if (current === text) {\n results.push({ folder: shown, file: shownFile, status: \"same\", ...onPages });\n continue;\n }\n if (options.mode === \"update\") {\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, text);\n }\n const diff = unifiedDiff(current ?? \"\", text, { from: current === undefined ? \"/dev/null\" : `a/${shownFile}`, to: `b/${shownFile}` });\n results.push({ folder: shown, file: shownFile, status: current === undefined ? \"new\" : \"changed\", diff, ...onPages });\n }\n if (!named) {\n const read = new Set(folders);\n for (const entry of options.pages ?? []) {\n const pageFolder = resolve(root, entry.package);\n if (read.has(pageFolder) && !skipped.has(pageFolder)) continue;\n results.push({ folder: entry.package, file: entry.pages[0] ?? entry.reference ?? \"\", status: \"error\", error: \"the field pages names a package that the command does not read\" });\n }\n for (const folder of globbedFolders(root, options.packages)) {\n const file = join(folder, report);\n if (read.has(folder) || !existsSync(file)) continue;\n if (options.mode === \"update\") rmSync(file);\n results.push({ folder: relativePath(root, folder), file: relativePath(root, file), status: \"stale\" });\n }\n if (results.every((result) => result.status === \"stale\")) {\n results.push({ folder: \".\", file: report, status: \"error\", error: \"no package. The command read the globs of the workspace, or a package.json file in the root.\" });\n }\n }\n const failed = results.some(\n (result) => (result.pageFaults?.length ?? 0) > 0 || result.status === \"error\" || (options.mode === \"check\" && (result.status === \"changed\" || result.status === \"new\" || result.status === \"stale\")),\n );\n return { mode: options.mode, packages: results, failed };\n}\n\n/** The most lines of the diff of one package in the output. */\nconst MAX_DIFF_LINES = 400;\n\n/** This function shortens a diff to `MAX_DIFF_LINES` lines. */\nfunction shortDiff(diff: string): string {\n const lines = diff.replace(/\\n$/, \"\").split(\"\\n\");\n if (lines.length <= MAX_DIFF_LINES) return `${lines.join(\"\\n\")}\\n`;\n return `${lines.slice(0, MAX_DIFF_LINES).join(\"\\n\")}\\n... ${lines.length - MAX_DIFF_LINES} more lines. Start the command update and read the diff in git.\\n`;\n}\n\n/** This function gives the text of a result for a terminal or a CI log. */\nexport function formatResult(result: RunResult, tool: string = DEFAULT_TOOL): string {\n const by = (status: PackageResult[\"status\"]): PackageResult[] => result.packages.filter((item) => item.status === status);\n const reports = result.packages.filter((item) => item.status !== \"private\" && item.status !== \"stale\" && item.status !== \"error\").length;\n const out: string[] = [`${reports} public packages with a report of the API, ${by(\"private\").length} private packages without a report.`];\n const list = (title: string, items: readonly PackageResult[], line: (item: PackageResult) => string): void => {\n if (items.length === 0) return;\n out.push(`${title}:`);\n for (const item of items) out.push(` ${line(item)}`);\n };\n const update = result.mode === \"update\";\n list(update ? \"Written\" : \"The report differs from the built .d.ts files\", by(\"changed\"), (item) => item.file);\n list(update ? \"Written (new)\" : \"No report\", by(\"new\"), (item) => (update ? item.file : `${item.folder} (${item.file})`));\n list(update ? \"Removed (the command does not read the package)\" : \"A report of a package that the command does not read\", by(\"stale\"), (item) => item.file);\n list(\"Written (the page of each export)\", result.packages.filter((item) => (item.writtenPages?.length ?? 0) > 0), (item) => (item.writtenPages ?? []).join(\", \"));\n list(\"Errors\", by(\"error\"), (item) => `${item.folder}: ${item.error ?? \"unknown error\"}`);\n for (const item of result.packages) {\n if ((item.pageFaults?.length ?? 0) > 0) out.push(`The page of the API of ${item.folder} differs from its report:`, ...(item.pageFaults ?? []).map((fault) => ` ${fault}`));\n }\n let text = `${out.join(\"\\n\")}\\n`;\n if (!update) {\n for (const item of by(\"changed\")) text += `\\n${shortDiff(item.diff ?? \"\")}`;\n if (by(\"changed\").length + by(\"new\").length + by(\"stale\").length > 0) {\n text += `\\nTo accept a change of the API, start the build, then \\`${tool} update\\`, review the diff, and commit the reports.\\n`;\n }\n }\n return text;\n}\n\n/** This function gives the result as Markdown for the summary of a GitHub Actions run. It gives an empty string when all reports are current. */\nexport function summaryMarkdown(result: RunResult): string {\n const changed = result.packages.filter((item) => item.status === \"changed\" || item.status === \"new\");\n const other = result.packages.filter((item) => item.status === \"stale\" || item.status === \"error\");\n const pages = result.packages.flatMap((item) => (item.pageFaults ?? []).map((fault) => `- \\`${item.folder}\\`: ${fault}`));\n if (changed.length === 0 && other.length === 0 && pages.length === 0) return \"\";\n const out = [\"### Public API reports\", \"\"];\n for (const item of changed) out.push(`<details><summary><code>${item.file}</code> (${item.status})</summary>`, \"\", \"```diff\", shortDiff(item.diff ?? \"\").replace(/\\n$/, \"\"), \"```\", \"\", \"</details>\", \"\");\n for (const item of other) out.push(`- \\`${item.file}\\`: ${item.status === \"stale\" ? \"a report of a package that the command does not read\" : (item.error ?? \"error\")}`);\n out.push(...pages);\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** The input and output of `runCli`. */\nexport interface CliIo {\n readonly cwd: string;\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/** The help text of the bin. */\nexport const USAGE: string = `Usage: api-report <check | update> [options] [<package folder>...]\n\n check Compare each report with the built .d.ts files. Exit code 1 when a report differs, is missing or has no\n package that the command reads, or when the command finds no package.\n update Write each report again, and each page of the field reference. Remove each report of a package that the\n command does not read.\n\n --root <folder> The root of the repository. The default is the current folder.\n --packages <glob> A glob of package folders. Use it again for more globs. The default is the globs of the workspace.\n --report <path> The path of the report in each package folder. The default is ${REPORT_FILE}.\n --include-private Also make a report for each private package.\n --no-publish-config Read the fields of package.json without publishConfig.\n -h, --help Show this text.\n\nThe field \"apiReport\" of the root package.json can set packages, report, includePrivate, publishConfig, tool and pages.\n`;\n\n/** An error of the arguments: exit code 2 and the help text. */\nclass UsageError extends Error {}\n\n/** This function starts the bin with the arguments `args`, and gives its exit code. */\nexport function runCli(args: readonly string[], io: CliIo): number {\n let mode: Mode | undefined;\n let root = io.cwd;\n const packages: string[] = [];\n const folders: string[] = [];\n const flags: { report?: string; includePrivate?: boolean; publishConfig?: boolean } = {};\n for (let index = 0; index < args.length; index++) {\n const arg = args[index] ?? \"\";\n const value = (): string => {\n const next = args[++index];\n if (next === undefined || next.startsWith(\"-\")) throw new UsageError(`The option ${arg} needs a value.`);\n return next;\n };\n try {\n if (arg === \"check\" || arg === \"--check\") mode = \"check\";\n else if (arg === \"update\" || arg === \"--update\") mode = \"update\";\n else if (arg === \"--root\") root = resolve(io.cwd, value());\n else if (arg === \"--packages\") packages.push(value());\n else if (arg === \"--report\") flags.report = value();\n else if (arg === \"--include-private\") flags.includePrivate = true;\n else if (arg === \"--no-publish-config\") flags.publishConfig = false;\n else if (arg === \"--help\" || arg === \"-h\") {\n io.stdout(USAGE);\n return 0;\n } else if (arg.startsWith(\"-\")) throw new UsageError(`An unknown option: ${arg}`);\n else folders.push(arg);\n } catch (error) {\n if (!(error instanceof UsageError)) throw error;\n io.stderr(`api-report: ${error.message}\\n\\n${USAGE}`);\n return 2;\n }\n }\n if (mode === undefined) {\n io.stderr(`api-report: give the command check or update.\\n\\n${USAGE}`);\n return 2;\n }\n let result: RunResult;\n let tool: string;\n try {\n const config = readConfig(root);\n tool = config.tool ?? DEFAULT_TOOL;\n result = runReports({\n ...config,\n ...flags,\n ...(packages.length > 0 ? { packages } : {}),\n mode,\n root,\n folders: folders.map((folder) => resolve(io.cwd, folder)),\n });\n } catch (error) {\n io.stderr(`api-report: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n io.stdout(formatResult(result, tool));\n const summary = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (summary && mode === \"check\") {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