@antelopejs/tooling-configs 0.2.17 → 0.2.18

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.
Files changed (39) hide show
  1. package/README.md +27 -18
  2. package/dist/bin/api-diff.mjs +25 -14
  3. package/dist/bin/body-check.mjs +3 -3
  4. package/dist/bin/capture.d.mts +1 -0
  5. package/dist/bin/capture.mjs +559 -0
  6. package/dist/bin/check-size.mjs +3 -3
  7. package/dist/bin/checks.mjs +2 -2
  8. package/dist/bin/comment-proof.mjs +3 -3
  9. package/dist/bin/garden.mjs +1 -1
  10. package/dist/bin/ratchet.mjs +146 -100
  11. package/dist/bin/suppressions.mjs +5 -5
  12. package/dist/bin/sync.mjs +115 -169
  13. package/dist/bin/verify.mjs +238 -125
  14. package/dist/capture/index.d.mts +50 -0
  15. package/dist/capture/index.mjs +2 -0
  16. package/dist/{files-Bc036sJW.mjs → files-DJ0TeaTU.mjs} +10 -4
  17. package/dist/formal/index.d.mts +40 -0
  18. package/dist/formal/index.mjs +205 -0
  19. package/dist/oxc/anti-slop/index.mjs +717 -16
  20. package/dist/oxc/fmt.mjs +1 -1
  21. package/dist/oxc/guardrails/index.d.mts +1 -1
  22. package/dist/oxc/guardrails/index.mjs +93 -5
  23. package/dist/oxc/lint.d.mts +9 -0
  24. package/dist/oxc/lint.mjs +14 -3
  25. package/dist/{oxlint-Bltmk8-6.mjs → oxlint-DIV-lLSS.mjs} +7 -3
  26. package/dist/{package-DTxLPNDu.mjs → package-BRTjkzt5.mjs} +26 -1
  27. package/dist/{proof-stamp-w-3j47A-.mjs → proof-stamp-DDDC0J6l.mjs} +3 -3
  28. package/dist/{ratchet-DwRj9h4L.mjs → ratchet-BAcLRYuM.mjs} +194 -21
  29. package/dist/scenes-DZVXkcxS.mjs +104 -0
  30. package/dist/shared-igPpEDpS.mjs +622 -0
  31. package/dist/{size-DNtWruCO.mjs → size-DBatLT-F.mjs} +2 -2
  32. package/dist/{suppression-base-DAfCXwjL.mjs → suppression-base-9L8dlMQK.mjs} +36 -11
  33. package/dist/{suppression-budget-Bd2GqMYb.mjs → suppression-budget-C0SkPO5R.mjs} +56 -19
  34. package/dist/{suppressions-BD_f8f7L.mjs → suppressions-DM60NkvL.mjs} +1 -1
  35. package/dist/templates-CypDm-j9.mjs +121 -0
  36. package/dist/{typescript-BmS5BmrS.mjs → typescript-CM0LrVP7.mjs} +2 -2
  37. package/dist/verify/index.d.mts +6 -1
  38. package/package.json +28 -4
  39. package/dist/shared-CoUt4GUm.mjs +0 -73
@@ -0,0 +1,559 @@
1
+ #!/usr/bin/env node
2
+ import { c as object, f as parseJson, m as strings, r as flag, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
3
+ import { n as parseScenes, r as selectScenes } from "../scenes-DZVXkcxS.mjs";
4
+ import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
5
+ import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
6
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { execFileSync, spawn, spawnSync } from "node:child_process";
9
+ import { parse as parse$1, stringify } from "yaml";
10
+ import { pathToFileURL } from "node:url";
11
+ import { tmpdir } from "node:os";
12
+ import { parseArgs } from "node:util";
13
+ import { MongoMemoryServer } from "mongodb-memory-server";
14
+ import { chromium } from "playwright-core";
15
+ import sharp from "sharp";
16
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
17
+ import pixelmatch from "pixelmatch";
18
+ //#region src/capture/demo.ts
19
+ /** The instant the demo and the browser treat as now: 2026-06-15 09:00 UTC, which is 10:00 in Brussels. */
20
+ const DEMO_NOW = "2026-06-15T09:00:00Z";
21
+ const USAGE = "Usage: antelopejs-capture [--check] [--scene <id>] [--demo-ref <ref>]";
22
+ function parseCaptureArgs(args) {
23
+ try {
24
+ const { values } = parseArgs({
25
+ args,
26
+ allowPositionals: false,
27
+ options: {
28
+ check: { type: "boolean" },
29
+ scene: { type: "string" },
30
+ "demo-ref": { type: "string" }
31
+ }
32
+ });
33
+ return {
34
+ check: values.check ?? false,
35
+ scene: values.scene,
36
+ demoRef: values["demo-ref"] ?? "main"
37
+ };
38
+ } catch (error) {
39
+ throw new Error(USAGE, { cause: error });
40
+ }
41
+ }
42
+ /** What the demo's capture start script reads, over the caller's own environment. */
43
+ function demoEnvironment(options) {
44
+ return {
45
+ ...process.env,
46
+ TZ: "UTC",
47
+ HELIO_NOW: DEMO_NOW,
48
+ HELIO_SIMULATORS: "off",
49
+ MONGODB_URL: options.mongoUrl,
50
+ MONGODB_DATABASE: options.database,
51
+ PORT: String(options.port),
52
+ DMS_CLIENT_BASE_URL: `http://localhost:${options.port}`
53
+ };
54
+ }
55
+ function manifestName(dir) {
56
+ try {
57
+ const manifest = object(parseJson(readFileSync(join(dir, "package.json"), "utf8")), "package.json");
58
+ return flag(manifest, "private") ? void 0 : optStr(manifest, "name");
59
+ } catch {
60
+ return;
61
+ }
62
+ }
63
+ /**
64
+ * The pnpm overrides that make a checkout of the demo run the capturing repository's own packages:
65
+ * every published package of `root` (the root itself and each `packages/*` folder) mapped to its folder.
66
+ */
67
+ function packageOverrides(root) {
68
+ const folders = [root];
69
+ try {
70
+ for (const entry of readdirSync(join(root, "packages"), { withFileTypes: true })) if (entry.isDirectory()) folders.push(join(root, "packages", entry.name));
71
+ } catch {
72
+ folders.length = 1;
73
+ }
74
+ const overrides = {};
75
+ for (const folder of folders) {
76
+ const name = manifestName(folder);
77
+ if (name !== void 0) overrides[name] = `file:${folder}`;
78
+ }
79
+ return overrides;
80
+ }
81
+ /**
82
+ * The demo's `pnpm-workspace.yaml` with the overrides and the build allowances added. pnpm 11 reads
83
+ * these settings only there, and pnpm 10.6 and later prefer it over `package.json`, so a setting the
84
+ * demo keeps in `package.json` must be in the workspace file too.
85
+ */
86
+ function workspaceWithOverrides(text, overrides, builds) {
87
+ const existing = text.trim() === "" ? {} : object(parse$1(text), "pnpm-workspace.yaml");
88
+ const settings = {
89
+ ...existing,
90
+ overrides: {
91
+ ...child(existing, "overrides"),
92
+ ...overrides
93
+ }
94
+ };
95
+ const allowed = [...strings(existing, "onlyBuiltDependencies"), ...builds];
96
+ if (allowed.length) settings.onlyBuiltDependencies = [...new Set(allowed)];
97
+ return stringify(settings);
98
+ }
99
+ /**
100
+ * What a checkout of the demo is patched with: the demo's own `pnpm` field and workspace file, plus the
101
+ * overrides for the packages of `root`, which win over a demo override of the same name. Both places get
102
+ * the same settings, because the pnpm that runs the install decides which one it reads.
103
+ */
104
+ function checkoutSettings(pnpm, workspace, root) {
105
+ const overrides = {
106
+ ...child(pnpm, "overrides"),
107
+ ...packageOverrides(root)
108
+ };
109
+ return {
110
+ pnpm: {
111
+ ...pnpm,
112
+ overrides
113
+ },
114
+ workspace: workspaceWithOverrides(workspace, overrides, strings(pnpm, "onlyBuiltDependencies"))
115
+ };
116
+ }
117
+ //#endregion
118
+ //#region src/capture/network.ts
119
+ /** Requests that stay open for as long as the page does, so the network is quiet without them. */
120
+ const STREAMS = /* @__PURE__ */ new Set(["eventsource", "websocket"]);
121
+ /** The media type of a server-sent event stream, which a `fetch` can hold open as long as an EventSource does. */
122
+ const EVENT_STREAM = "text/event-stream";
123
+ /** The requests a page has started and not yet ended, and when one last started or ended. */
124
+ var NetworkLog = class {
125
+ pending = /* @__PURE__ */ new Map();
126
+ last = Date.now();
127
+ /** Records a request the page started, unless its resource type is a stream. */
128
+ start(request, url, resourceType) {
129
+ if (STREAMS.has(resourceType)) return;
130
+ this.pending.set(request, url);
131
+ this.last = Date.now();
132
+ }
133
+ /** Records a response's headers: a request answered with an event stream stops counting, since it never ends. */
134
+ respond(request, contentType) {
135
+ if (contentType?.split(";")[0]?.trim().toLowerCase() === EVENT_STREAM) this.end(request);
136
+ }
137
+ /** Records that a request finished or failed. */
138
+ end(request) {
139
+ if (!this.pending.delete(request)) return;
140
+ this.last = Date.now();
141
+ }
142
+ /** The URLs of the requests started and not yet ended. */
143
+ pendingRequests() {
144
+ return [...this.pending.values()];
145
+ }
146
+ /** When a request last started or ended, as a `Date.now()` instant. */
147
+ lastRequestAt() {
148
+ return this.last;
149
+ }
150
+ };
151
+ //#endregion
152
+ //#region src/capture/ready.ts
153
+ const MAX_NAMED_REQUESTS = 3;
154
+ function networkQuiet(page, quietMs) {
155
+ return page.pendingRequests().length === 0 && Date.now() - page.lastRequestAt() >= quietMs;
156
+ }
157
+ /** Answers what `work` resolves to, or `undefined` when `deadline` comes first. */
158
+ async function within(work, deadline) {
159
+ const controller = new AbortController();
160
+ const late = setTimeout$1(Math.max(0, deadline - Date.now()), void 0, { signal: controller.signal }).catch(() => void 0);
161
+ try {
162
+ return await Promise.race([work, late]);
163
+ } finally {
164
+ controller.abort();
165
+ }
166
+ }
167
+ /** One look at the page: every signal holds, and no request started or ended while they were read. */
168
+ async function settledOnce(page, options, deadline, seen) {
169
+ seen.quiet = networkQuiet(page, options.quietMs);
170
+ if (!seen.quiet) return false;
171
+ const before = page.lastRequestAt();
172
+ seen.app = await within(page.appReady(), deadline) === true;
173
+ if (!seen.app) return false;
174
+ seen.fonts = await within(page.loadFonts().then(() => true), deadline) === true;
175
+ return seen.fonts && page.lastRequestAt() === before;
176
+ }
177
+ function unsettled(page, options, seen) {
178
+ const pending = page.pendingRequests();
179
+ if (pending.length > 0) return `${pending.length} request${pending.length === 1 ? "" : "s"} still in flight: ${pending.slice(0, MAX_NAMED_REQUESTS).join(", ")}`;
180
+ if (!seen.quiet) return `the network was never quiet for ${options.quietMs}ms`;
181
+ if (!seen.app) return "the app never set data-dms-ready on <html>";
182
+ return "the fonts were still loading";
183
+ }
184
+ /**
185
+ * Answers once the page is ready to be shot: the app has mounted, the fonts its text uses are loaded,
186
+ * and no request has started or ended for `quietMs`, all seen in one look. The `load` event comes
187
+ * before the app mounts and before its modules, fonts and data arrive, so a shot at `load` catches the
188
+ * page half way. Fails, naming what was still pending, when the page is not ready within `timeoutMs`.
189
+ */
190
+ async function waitForReady(page, options) {
191
+ const deadline = Date.now() + options.timeoutMs;
192
+ const seen = {
193
+ quiet: false,
194
+ app: false,
195
+ fonts: false
196
+ };
197
+ while (Date.now() < deadline) {
198
+ if (await settledOnce(page, options, deadline, seen)) return;
199
+ await setTimeout$1(options.pollMs);
200
+ }
201
+ throw new Error(`the page did not settle within ${options.timeoutMs / 1e3}s: ${unsettled(page, options, seen)}`);
202
+ }
203
+ //#endregion
204
+ //#region src/capture/browser.ts
205
+ const DEVICE_SCALE_FACTOR = 2;
206
+ const STEP_TIMEOUT_MS = 3e4;
207
+ const READY = {
208
+ timeoutMs: 6e4,
209
+ quietMs: 500,
210
+ pollMs: 50
211
+ };
212
+ /** A browser that opens every scene dark, with the clock frozen on the demo's instant, at 2x. */
213
+ async function openContext(browser, viewport) {
214
+ const context = await browser.newContext({
215
+ viewport,
216
+ deviceScaleFactor: DEVICE_SCALE_FACTOR,
217
+ colorScheme: "dark",
218
+ reducedMotion: "reduce",
219
+ locale: "en-GB",
220
+ timezoneId: "UTC"
221
+ });
222
+ context.setDefaultTimeout(STEP_TIMEOUT_MS);
223
+ await context.clock.setFixedTime(/* @__PURE__ */ new Date(DEMO_NOW));
224
+ return context;
225
+ }
226
+ /** Loads every face the text of the page uses, its form fields included, for the characters it shows. */
227
+ async function loadUsedFonts() {
228
+ const used = /* @__PURE__ */ new Map();
229
+ const add = (element, text) => {
230
+ if (!text.trim()) return;
231
+ const style = getComputedStyle(element);
232
+ const font = `${style.fontStyle} ${style.fontWeight} 16px ${style.fontFamily}`;
233
+ const characters = used.get(font) ?? /* @__PURE__ */ new Set();
234
+ for (const character of text) characters.add(character);
235
+ used.set(font, characters);
236
+ };
237
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
238
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) if (node.parentElement) add(node.parentElement, node.textContent ?? "");
239
+ for (const field of document.querySelectorAll("input, textarea")) if (field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) add(field, `${field.value}${field.placeholder}`);
240
+ await Promise.all([...used].map(([font, characters]) => document.fonts.load(font, [...characters].join(""))));
241
+ await document.fonts.ready;
242
+ }
243
+ /** Follows the page's requests, event streams aside, from now on, so call it before the page navigates. */
244
+ function watchPage(page) {
245
+ const network = new NetworkLog();
246
+ const ended = (request) => {
247
+ network.end(request);
248
+ };
249
+ page.on("request", (request) => {
250
+ network.start(request, request.url(), request.resourceType());
251
+ });
252
+ page.on("response", (response) => {
253
+ network.respond(response.request(), response.headers()["content-type"]);
254
+ });
255
+ page.on("requestfinished", ended);
256
+ page.on("requestfailed", ended);
257
+ return {
258
+ pendingRequests: () => network.pendingRequests(),
259
+ lastRequestAt: () => network.lastRequestAt(),
260
+ appReady: () => page.evaluate(() => document.documentElement.hasAttribute("data-dms-ready")),
261
+ loadFonts: () => page.evaluate(loadUsedFonts)
262
+ };
263
+ }
264
+ async function perform(page, step) {
265
+ switch (step.action) {
266
+ case "click": return page.click(step.selector);
267
+ case "fill": return page.fill(step.selector, step.value);
268
+ case "press": return page.keyboard.press(step.key);
269
+ case "wait": return page.waitForSelector(step.selector);
270
+ }
271
+ }
272
+ /**
273
+ * Opens the scene's route, waits for the page to be ready, runs its steps, waits again, and answers its
274
+ * PNG; a setup scene answers nothing. The `load` event comes before the app mounts, so a step taken then
275
+ * acts on the server-rendered page: the mount drops what it filled, and a click submits its form natively.
276
+ */
277
+ async function playScene(page, scene) {
278
+ await page.open(scene.route);
279
+ await page.ready();
280
+ for (const step of scene.steps) await page.perform(step);
281
+ if (scene.setup) return void 0;
282
+ await page.ready();
283
+ return page.shoot(scene.crop);
284
+ }
285
+ /** Plays the scene on a new page of `context`, at the scene's viewport, and closes the page. */
286
+ async function renderScene(context, baseUrl, scene) {
287
+ const page = await context.newPage();
288
+ const watched = watchPage(page);
289
+ try {
290
+ await page.setViewportSize(scene.viewport);
291
+ return await playScene({
292
+ open: async (route) => {
293
+ await page.goto(new URL(route, baseUrl).href, { waitUntil: "load" });
294
+ },
295
+ perform: async (step) => {
296
+ await perform(page, step);
297
+ },
298
+ ready: () => waitForReady(watched, READY),
299
+ shoot: (crop) => (crop ? page.locator(crop).first() : page).screenshot({
300
+ type: "png",
301
+ animations: "disabled"
302
+ })
303
+ }, scene);
304
+ } finally {
305
+ await page.close();
306
+ }
307
+ }
308
+ /** Lossless WebP, so decoding what was written gives back the pixels that were captured. */
309
+ function encodeWebp(sharp, png) {
310
+ return sharp(png).webp({ lossless: true }).toBuffer();
311
+ }
312
+ async function decode(sharp, image) {
313
+ const { data, info } = await sharp(image).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
314
+ return {
315
+ width: info.width,
316
+ height: info.height,
317
+ data
318
+ };
319
+ }
320
+ //#endregion
321
+ //#region src/capture/compare.ts
322
+ /** The share of pixels that may differ before a capture counts as changed: 0.1%. */
323
+ const MAX_CHANGED_RATIO = .001;
324
+ /** The share of pixels two images differ in, 1 when their sizes differ. */
325
+ function changedRatio(before, after) {
326
+ if (before.width !== after.width || before.height !== after.height) return 1;
327
+ return pixelmatch(before.data, after.data, void 0, before.width, before.height, { threshold: .1 }) / (before.width * before.height);
328
+ }
329
+ function withinTolerance(ratio) {
330
+ return ratio <= MAX_CHANGED_RATIO;
331
+ }
332
+ //#endregion
333
+ //#region src/capture/settle.ts
334
+ /**
335
+ * Settles one capture against the committed file. A write run creates the file, or replaces it when the
336
+ * new capture differs by more than the tolerance, so render noise leaves the committed bytes alone. A
337
+ * `check` run writes nothing and answers how the capture differs, or `undefined` when it is within the
338
+ * tolerance.
339
+ */
340
+ async function settle(sharp, root, check, captured) {
341
+ const target = join(root, captured.output);
342
+ const webp = await encodeWebp(sharp, captured.png);
343
+ if (!existsSync(target)) {
344
+ if (check) return `scene ${captured.scene}: ${captured.output} does not exist; run antelopejs-capture`;
345
+ mkdirSync(dirname(target), { recursive: true });
346
+ writeFileSync(target, webp);
347
+ return;
348
+ }
349
+ const ratio = changedRatio(await decode(sharp, readFileSync(target)), await decode(sharp, webp));
350
+ if (withinTolerance(ratio)) return void 0;
351
+ if (!check) {
352
+ writeFileSync(target, webp);
353
+ return;
354
+ }
355
+ return `scene ${captured.scene}: ${(ratio * 100).toFixed(2)}% of the pixels differ from ${captured.output}`;
356
+ }
357
+ //#endregion
358
+ //#region src/capture/stop.ts
359
+ const POLL_MS = 50;
360
+ function groupAlive(pid) {
361
+ try {
362
+ process.kill(-pid, 0);
363
+ return true;
364
+ } catch {
365
+ return false;
366
+ }
367
+ }
368
+ function signalGroup(started, pid, signal) {
369
+ try {
370
+ process.kill(-pid, signal);
371
+ } catch {
372
+ started.kill(signal);
373
+ }
374
+ }
375
+ async function goneWithin(pid, ms) {
376
+ const deadline = Date.now() + ms;
377
+ while (groupAlive(pid) && Date.now() < deadline) await setTimeout$1(POLL_MS);
378
+ return !groupAlive(pid);
379
+ }
380
+ /**
381
+ * Interrupts a detached child's whole process group and answers once no process of the group is left,
382
+ * so the files it was writing can be removed. A group still alive after `graceMs` is killed, and the
383
+ * stop fails when the group is still there `killWaitMs` after the kill.
384
+ */
385
+ async function stopProcessGroup(started, options) {
386
+ const { pid } = started;
387
+ if (pid === void 0) return;
388
+ signalGroup(started, pid, "SIGINT");
389
+ if (await goneWithin(pid, options.graceMs)) return;
390
+ signalGroup(started, pid, "SIGKILL");
391
+ if (await goneWithin(pid, options.killWaitMs)) return;
392
+ throw new Error(`process group ${pid} was still running ${options.killWaitMs / 1e3}s after SIGKILL`);
393
+ }
394
+ //#endregion
395
+ //#region src/capture/run.ts
396
+ const DEMO_URL = "https://github.com/AntelopeJS/template-dms-demo.git";
397
+ const DEMO_PORT = 3101;
398
+ const READY_TIMEOUT_MS = 9e5;
399
+ const STOP = {
400
+ graceMs: 3e4,
401
+ killWaitMs: 1e4
402
+ };
403
+ const READ_SCENES = "import(process.argv[1]).then((module) => process.stdout.write(JSON.stringify(module.default ?? module.scenes)))";
404
+ /** Reads the scenes in a child Node, which loads `docs/captures.ts` as the file itself declares it, then parses its JSON. */
405
+ function loadScenes(root) {
406
+ const file = join(root, "docs", "captures.ts");
407
+ if (!existsSync(file)) throw new Error("docs/captures.ts does not exist");
408
+ const printed = execFileSync(process.execPath, [
409
+ "--input-type=module",
410
+ "-e",
411
+ READ_SCENES,
412
+ pathToFileURL(file).href
413
+ ], {
414
+ cwd: root,
415
+ encoding: "utf8",
416
+ stdio: [
417
+ "ignore",
418
+ "pipe",
419
+ "inherit"
420
+ ]
421
+ });
422
+ return parseScenes(parseJson(printed));
423
+ }
424
+ function run(command, args, cwd) {
425
+ const result = spawnSync(command, args, {
426
+ cwd,
427
+ encoding: "utf8"
428
+ });
429
+ if (result.status === 0) return;
430
+ const output = `${result.stdout}${result.stderr}`.trim().split("\n");
431
+ throw new Error(`${command} ${args.join(" ")} failed in ${cwd}\n${output.slice(-20).join("\n")}`);
432
+ }
433
+ /** A checkout of the demo whose dependencies on this repository's packages are overridden to the working tree. Never committed: it lives in a throwaway directory. */
434
+ function checkoutDemo(root, ref, into) {
435
+ const demo = join(into, "demo");
436
+ run("git", [
437
+ "clone",
438
+ "--quiet",
439
+ "--depth",
440
+ "1",
441
+ "--branch",
442
+ ref,
443
+ process.env.ANTELOPEJS_CAPTURE_DEMO_URL ?? DEMO_URL,
444
+ demo
445
+ ], into);
446
+ const manifestPath = join(demo, "package.json");
447
+ const manifest = object(parseJson(readFileSync(manifestPath, "utf8")), "package.json");
448
+ const workspacePath = join(demo, "pnpm-workspace.yaml");
449
+ const settings = checkoutSettings(child(manifest, "pnpm"), existsSync(workspacePath) ? readFileSync(workspacePath, "utf8") : "", root);
450
+ const patched = {
451
+ ...manifest,
452
+ pnpm: settings.pnpm
453
+ };
454
+ writeFileSync(manifestPath, `${JSON.stringify(patched, null, 2)}\n`);
455
+ writeFileSync(workspacePath, settings.workspace);
456
+ run("pnpm", ["install", "--no-frozen-lockfile"], demo);
457
+ return demo;
458
+ }
459
+ /** Starts the demo's capture script and resolves with its URL once the script prints `ready <url>`. */
460
+ function startDemo(demo, env) {
461
+ const started = spawn("pnpm", ["run", "capture:start"], {
462
+ cwd: demo,
463
+ env,
464
+ detached: true,
465
+ stdio: [
466
+ "ignore",
467
+ "pipe",
468
+ "pipe"
469
+ ]
470
+ });
471
+ return new Promise((resolve, reject) => {
472
+ let output = "";
473
+ const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`the demo was not ready in ${READY_TIMEOUT_MS / 1e3}s\n${output}`)), READY_TIMEOUT_MS);
474
+ const watch = (chunk) => {
475
+ output += chunk.toString();
476
+ const url = /^ready (\S+)$/m.exec(output)?.[1];
477
+ if (url === void 0) return;
478
+ clearTimeout(timer);
479
+ resolve({
480
+ url,
481
+ process: started
482
+ });
483
+ };
484
+ started.stdout.on("data", watch);
485
+ started.stderr.on("data", watch);
486
+ started.on("exit", (code) => {
487
+ clearTimeout(timer);
488
+ reject(/* @__PURE__ */ new Error(`the demo stopped with exit code ${code}\n${output}`));
489
+ });
490
+ });
491
+ }
492
+ async function captureAll(session, scenes) {
493
+ const failures = [];
494
+ const first = scenes[0];
495
+ const context = await openContext(session.browser, first?.viewport ?? {
496
+ width: 1440,
497
+ height: 900
498
+ });
499
+ for (const scene of scenes) try {
500
+ const png = await renderScene(context, session.url, scene);
501
+ if (png === void 0 || scene.output === void 0) continue;
502
+ const failure = await settle(sharp, session.root, session.check, {
503
+ scene: scene.id,
504
+ output: scene.output,
505
+ png
506
+ });
507
+ if (failure !== void 0) failures.push(failure);
508
+ } catch (error) {
509
+ const reason = error instanceof Error ? error.message : String(error);
510
+ failures.push(`scene ${scene.id}: ${reason.split("\n")[0]}`);
511
+ }
512
+ await context.close();
513
+ return failures;
514
+ }
515
+ /** Runs the scenes against the demo and writes, or with `check` compares, their WebP files. Answers the failures, one line per scene. */
516
+ async function capture(root, args) {
517
+ const scenes = selectScenes(loadScenes(root), args.scene);
518
+ const scratch = mkdtempSync(join(tmpdir(), "antelopejs-capture-"));
519
+ const mongo = await MongoMemoryServer.create();
520
+ let demo;
521
+ try {
522
+ const started = await startDemo(checkoutDemo(root, args.demoRef, scratch), demoEnvironment({
523
+ mongoUrl: mongo.getUri(),
524
+ database: "docs_captures",
525
+ port: DEMO_PORT
526
+ }));
527
+ demo = started.process;
528
+ const browser = await chromium.launch();
529
+ try {
530
+ return await captureAll({
531
+ root,
532
+ browser,
533
+ url: started.url,
534
+ check: args.check
535
+ }, scenes);
536
+ } finally {
537
+ await browser.close();
538
+ }
539
+ } finally {
540
+ try {
541
+ if (demo) await stopProcessGroup(demo, STOP);
542
+ rmSync(scratch, {
543
+ recursive: true,
544
+ force: true
545
+ });
546
+ } finally {
547
+ await mongo.stop();
548
+ }
549
+ }
550
+ }
551
+ //#endregion
552
+ //#region src/bin/capture.ts
553
+ runCliAsync(async () => {
554
+ const failures = await capture(repositoryRoot(), parseCaptureArgs(process.argv.slice(2)));
555
+ for (const failure of failures) process.stderr.write(`${failure}\n`);
556
+ return failures.length ? 1 : 0;
557
+ });
558
+ //#endregion
559
+ export {};
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
- import { a as repositoryPath, o as repositoryRoot, t as authoredSizes } from "../files-Bc036sJW.mjs";
4
- import { l as worktreeSuppressions, o as revisionSuppressions } from "../suppressions-BD_f8f7L.mjs";
5
- import { t as checkSize } from "../size-DNtWruCO.mjs";
3
+ import { c as repositoryRoot, n as authoredSizes, s as repositoryPath } from "../files-DJ0TeaTU.mjs";
4
+ import { l as worktreeSuppressions, o as revisionSuppressions } from "../suppressions-DM60NkvL.mjs";
5
+ import { t as checkSize } from "../size-DBatLT-F.mjs";
6
6
  import { resolve } from "node:path";
7
7
  import { parseArgs } from "node:util";
8
8
  //#region src/guardrails/directives.ts
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import "../ceilings-B7KayYIG.mjs";
3
+ import { i as parseManifest, r as packageManager } from "../package-BRTjkzt5.mjs";
3
4
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
- import { o as repositoryRoot } from "../files-Bc036sJW.mjs";
5
- import { i as parseManifest, r as packageManager } from "../package-DTxLPNDu.mjs";
5
+ import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
6
6
  import { existsSync, readFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import { spawnSync } from "node:child_process";
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
- import { o as repositoryRoot } from "../files-Bc036sJW.mjs";
4
- import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-w-3j47A-.mjs";
5
- import { o as packagesAt, t as emitPackage } from "../typescript-BmS5BmrS.mjs";
3
+ import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
+ import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-DDDC0J6l.mjs";
5
+ import { o as packagesAt, t as emitPackage } from "../typescript-CM0LrVP7.mjs";
6
6
  import { copyFileSync, mkdirSync } from "node:fs";
7
7
  import { dirname, join, relative } from "node:path";
8
8
  //#region src/guardrails/comment-proof.ts
@@ -5,8 +5,8 @@ import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as C
5
5
  import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
7
  import { execFileSync, spawnSync } from "node:child_process";
8
- import { parseArgs } from "node:util";
9
8
  import { homedir, tmpdir } from "node:os";
9
+ import { parseArgs } from "node:util";
10
10
  import { inflateRawSync } from "node:zlib";
11
11
  //#region src/garden/api.ts
12
12
  /** A GitHub or npm answer that is not a success. */