trace-avatar-render 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5
4
+
5
+ - **Auto-blur:** personal data is blurred in the page before frames are taken, for guide and director videos alike.
6
+ `autoBlur: { texts?, patterns? }` in `capture()`, `render()` and `direct()`, `blur` on a campaign video, and
7
+ `--blur-text` / `--blur-patterns` on the CLI. `patterns` blurs e-mails, phone numbers and account-like numbers
8
+ (order numbers, dates and prices don't match); `texts` blurs any element whose text holds one. The page is
9
+ watched, so rows that load later are blurred as they appear. `blurScript`, `patternsIn` and `BLUR_PATTERNS` are
10
+ exported. Blurring is tunable: `patterns: ['email', 'phone', 'account']` picks the kinds, and `strength` (2–24 px,
11
+ default 8) sets how strongly (`--blur-kinds`, `--blur-strength`). `blurKinds` and `blurStrength` are exported.
12
+ - **The check:** `checkVideo()` takes frames from a made MP4, flags blank ones in code, and asks an AI about the
13
+ rest with the video's lines beside them. `makeCampaign(c, { check: ai })` runs it per render and writes `check`
14
+ into the made manifest.
15
+ - **Refusing switched-off actions:** `refuse: { pay: true }` (capture, render, direct, a campaign video) stops
16
+ paying while filming. Card fields take no input, a form holding one is never sent, and writes to payment
17
+ addresses (`/checkout`, `/payments/…`, `/payouts/…`; not `/paylinks`) are aborted, which fails the render with
18
+ the reason. `isPayment()` is exported.
19
+ - The frame check (`--qa`, `runQa`) gains `line-mismatch`, and returns the exact `text` it read for `personal-data`.
20
+ Business and product names aren't personal, and blurred areas are never flagged.
21
+
3
22
  ## 0.2.4
4
23
 
5
24
  - `reroute` (in `direct()` and a campaign's `app`): addresses answered by others while filming, with the address bar unchanged, e.g. `{ "https://api.example.com": "https://demo-api.example.com" }` films a live front end against a demo API. Pages and API calls alike; redirects are followed inside (a redirect handed to the browser would reach the real address). Only what the browser fetches is rerouted. `rerouted(url, map)` is exported.
@@ -31,17 +31,18 @@ async function providerOf(spec, env = process.env, o = {}) {
31
31
  }
32
32
  throw new Error(`--ai is gateway, gateway:<provider>[/<model>][,<provider>\u2026], openai:<model>, or a .js file (got "${spec}")`);
33
33
  }
34
- var QA_KINDS = ["error", "empty", "stalled", "personal-data", "wrong-page", "other"];
34
+ var QA_KINDS = ["error", "empty", "stalled", "personal-data", "wrong-page", "line-mismatch", "other"];
35
35
  var QA_SCHEMA = {
36
36
  type: "object",
37
37
  required: ["flags"],
38
38
  properties: { flags: { type: "array", items: { type: "object", required: ["frame", "kind", "note"], properties: {
39
39
  frame: { type: "integer" },
40
40
  kind: { enum: [...QA_KINDS] },
41
- note: { type: "string", maxLength: 200 }
41
+ note: { type: "string", maxLength: 200 },
42
+ text: { type: "string", maxLength: 120 }
42
43
  } } } }
43
44
  };
44
- var QA_INSTRUCTIONS = `You check frames of a GIF/video of an on-screen guide before it is published: a cursor with a name badge walks through a web app. For each numbered frame, flag only real problems a viewer would notice: an error message or toast ("error"), an empty state or blank page where content is expected ("empty"), a "Looking for \u2026" caption meaning the guide got stuck ("stalled"), personal data such as real email addresses, phone numbers, card or account numbers ("personal-data"), or a page that does not fit the step ("wrong-page"). The cursor, the name badge, highlights and captions are part of the guide, not problems. Reply with JSON only: {"flags":[{"frame":1,"kind":"error","note":"\u2026"}]}, an empty list when all is well.`;
45
+ var QA_INSTRUCTIONS = `You check frames of a GIF/video of an on-screen guide before it is published: a cursor with a name badge walks through a web app. For each numbered frame, flag only real problems a viewer would notice: an error message or toast ("error"), an empty state or blank page where content is expected ("empty"), a "Looking for \u2026" caption meaning the guide got stuck ("stalled"), personal data left readable, such as people's names, email addresses, phone numbers, home addresses, card or account numbers ("personal-data", with the exact text you read in "text"), a page that does not fit the step ("wrong-page"), or a spoken line that says something the frame does not show ("line-mismatch"). Business, shop and product names are not personal. Blurred areas are blurred on purpose: never flag them. The cursor, the name badge, highlights, captions, the title card and the end card are part of the video, not problems. Reply with JSON only: {"flags":[{"frame":1,"kind":"error","note":"\u2026"}]}, an empty list when all is well.`;
45
46
  async function runQa(ai, frames, context) {
46
47
  if (!frames.length) return [];
47
48
  const input = { title: context.title, steps: context.steps, frames: frames.map((f, k) => ({ frame: k + 1, at: Math.round(f.at / 100) / 10, shows: f.label })) };
@@ -54,7 +55,8 @@ async function runQa(ai, frames, context) {
54
55
  if (!Number.isInteger(r?.frame) || r.frame < 1 || r.frame > frames.length) continue;
55
56
  const kind = QA_KINDS.includes(r.kind) ? r.kind : "other";
56
57
  const note = typeof r.note === "string" ? r.note.replace(/\s+/g, " ").trim().slice(0, 200) : "";
57
- out.push({ at: frames[r.frame - 1].at, kind, note });
58
+ const text = kind === "personal-data" && typeof r.text === "string" ? String(r.text).replace(/\s+/g, " ").trim().slice(0, 120) : "";
59
+ out.push({ at: frames[r.frame - 1].at, kind, note, ...text ? { text } : {} });
58
60
  }
59
61
  return out.sort((a, b) => a.at - b.at);
60
62
  }
@@ -382,6 +384,121 @@ async function voiceOf(spec, env = process.env, o = {}) {
382
384
  // src/cli.ts
383
385
  import { parseArgs } from "util";
384
386
 
387
+ // src/refuse.ts
388
+ var PAYMENT_PATH = String.raw`(?:^|/)(?:pay|payments?|checkout|charges?|transfers?|withdraw(?:als?)?|payouts?)(?:/|$)`;
389
+ function isPayment(method, url) {
390
+ if (["GET", "HEAD", "OPTIONS"].includes(method.toUpperCase())) return false;
391
+ try {
392
+ return new RegExp(PAYMENT_PATH, "i").test(new URL(url).pathname);
393
+ } catch {
394
+ return false;
395
+ }
396
+ }
397
+ function refuseInPage() {
398
+ const CARD = /card.?(number|no)|cc-?(number|csc|exp)|cvv|cvc|security code|expiry/i;
399
+ const isCard = (el) => {
400
+ const f = el;
401
+ if (!f || f.tagName !== "INPUT") return false;
402
+ const words = [f.getAttribute("autocomplete"), f.name, f.id, f.placeholder, f.getAttribute("aria-label"), f.labels?.[0]?.textContent].join(" ");
403
+ return CARD.test(words);
404
+ };
405
+ const stop = (e) => {
406
+ if (isCard(e.target)) {
407
+ e.preventDefault();
408
+ e.stopImmediatePropagation();
409
+ e.target.value = "";
410
+ }
411
+ };
412
+ for (const t of ["beforeinput", "keydown", "paste", "input"]) document.addEventListener(t, stop, true);
413
+ document.addEventListener("submit", (e) => {
414
+ const form = e.target;
415
+ if (Array.from(form.querySelectorAll("input")).some((i) => isCard(i))) {
416
+ e.preventDefault();
417
+ e.stopImmediatePropagation();
418
+ }
419
+ }, true);
420
+ }
421
+ function refuseScript(spec) {
422
+ return spec?.pay ? `(${refuseInPage.toString()})();` : null;
423
+ }
424
+
425
+ // src/blur.ts
426
+ var BLUR_KINDS = ["email", "phone", "account"];
427
+ var BLUR_STRENGTH = { min: 2, max: 24, default: 8 };
428
+ function blurStrength(n) {
429
+ return typeof n === "number" && Number.isFinite(n) ? Math.min(BLUR_STRENGTH.max, Math.max(BLUR_STRENGTH.min, Math.round(n))) : BLUR_STRENGTH.default;
430
+ }
431
+ function blurKinds(patterns) {
432
+ if (patterns === true) return [...BLUR_KINDS];
433
+ return Array.isArray(patterns) ? BLUR_KINDS.filter((k) => patterns.includes(k)) : [];
434
+ }
435
+ var BLUR_PATTERNS = {
436
+ email: String.raw`[\w.+-]+@[\w-]+(?:\.[\w-]+)+`,
437
+ phone: String.raw`(?:\+234[\s-]?|\b0)[789][01]\d(?:[\s-]?\d){7}\b|\+\d{1,3}[\s-]?\d(?:[\s-]?\d){6,12}\b`,
438
+ account: String.raw`\b\d{10,19}\b|\b\d{4}(?:[\s-]\d{4}){2,4}\b`
439
+ };
440
+ function patternsIn(text) {
441
+ return Object.keys(BLUR_PATTERNS).filter((k) => new RegExp(BLUR_PATTERNS[k]).test(text));
442
+ }
443
+ function blurTexts(texts) {
444
+ if (!Array.isArray(texts)) return [];
445
+ return [...new Set(texts.filter((t) => typeof t === "string").map((t) => t.replace(/\s+/g, " ").trim()).filter((t) => t.length >= 3 && t.length <= 120))].slice(0, 300);
446
+ }
447
+ function blurInPage(spec) {
448
+ if (window.__taBlur) return;
449
+ window.__taBlur = true;
450
+ const res = spec.patterns ? Object.values(spec.patterns).map((p) => new RegExp(p)) : [];
451
+ const texts = spec.texts;
452
+ const personal = (t) => !!t && (res.some((r) => r.test(t)) || texts.some((x) => t.includes(x)));
453
+ const mark = (el) => {
454
+ if (el && !el.hasAttribute("data-trace-blur")) el.setAttribute("data-trace-blur", "");
455
+ };
456
+ const SKIP = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEMPLATE"]);
457
+ const visit = (root) => {
458
+ if (root.nodeType === Node.TEXT_NODE) {
459
+ if (personal(root.textContent ?? "")) mark(root.parentElement);
460
+ return;
461
+ }
462
+ if (root.nodeType !== Node.ELEMENT_NODE || SKIP.has(root.tagName)) return;
463
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
464
+ for (let n = root; n; n = walker.nextNode()) {
465
+ if (n.nodeType === Node.TEXT_NODE) {
466
+ if (personal(n.textContent ?? "")) mark(n.parentElement);
467
+ continue;
468
+ }
469
+ const el = n;
470
+ if ((el.tagName === "INPUT" || el.tagName === "TEXTAREA") && personal(el.value)) mark(el);
471
+ else if (personal(el.getAttribute("title") ?? "") || personal(el.getAttribute("aria-label") ?? "")) mark(el);
472
+ }
473
+ };
474
+ const start = () => {
475
+ const style = document.createElement("style");
476
+ style.setAttribute("data-trace-blur-style", "");
477
+ style.textContent = `[data-trace-blur][data-trace-blur]{filter:blur(${spec.strength}px)!important}`;
478
+ (document.head || document.documentElement).append(style);
479
+ if (document.body) visit(document.body);
480
+ new MutationObserver((list) => {
481
+ for (const m of list) {
482
+ if (m.type === "characterData") visit(m.target);
483
+ else m.addedNodes.forEach((n) => visit(n));
484
+ }
485
+ }).observe(document.documentElement, { childList: true, subtree: true, characterData: true });
486
+ document.addEventListener("input", (e) => {
487
+ const t = e.target;
488
+ if (t && personal(t.value)) mark(t);
489
+ }, true);
490
+ };
491
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start, { once: true });
492
+ else start();
493
+ }
494
+ function blurScript(spec) {
495
+ const texts = blurTexts(spec?.texts);
496
+ const kinds = blurKinds(spec?.patterns);
497
+ if (!texts.length && !kinds.length) return null;
498
+ const patterns = kinds.length ? Object.fromEntries(kinds.map((k) => [k, BLUR_PATTERNS[k]])) : null;
499
+ return `(${blurInPage.toString()})(${JSON.stringify({ texts, patterns, strength: blurStrength(spec?.strength) })});`;
500
+ }
501
+
385
502
  // src/capture.ts
386
503
  import { readFileSync as readFileSync2 } from "fs";
387
504
  import { chromium } from "playwright";
@@ -513,6 +630,19 @@ async function capture(o) {
513
630
  wake();
514
631
  });
515
632
  await context.addInitScript({ content });
633
+ const blurring = blurScript(o.autoBlur);
634
+ if (blurring) await context.addInitScript({ content: blurring });
635
+ const refusing = refuseScript(o.refuse);
636
+ const refused = [];
637
+ if (refusing) {
638
+ await context.addInitScript({ content: refusing });
639
+ await context.route("**/*", (route) => {
640
+ const r = route.request();
641
+ if (!isPayment(r.method(), r.url())) return route.fallback();
642
+ refused.push(`${r.method()} ${new URL(r.url()).pathname}`);
643
+ return route.abort("blockedbyclient");
644
+ });
645
+ }
516
646
  const page = await context.newPage();
517
647
  const cdp = await context.newCDPSession(page);
518
648
  const frames = [];
@@ -577,6 +707,7 @@ async function capture(o) {
577
707
  const titles = {};
578
708
  for (const e of events) if (e.url && e.title && !titles[e.url]) titles[e.url] = e.title;
579
709
  for (const e of events) delete e.title;
710
+ if (refused.length) throw new RenderError(`It needs paying, which is switched off for filming: refused ${refused[0]}`);
580
711
  return { frames, events, playAt, stopAt, endAt: done.type === "end" ? done.t : null, viewport: { ...o.viewport, scale: o.scale ?? 1 }, titles };
581
712
  } finally {
582
713
  await browser.close();
@@ -1617,6 +1748,8 @@ async function render(o) {
1617
1748
  hide: o.hide,
1618
1749
  blur: o.blur,
1619
1750
  rate: o.rate,
1751
+ ...o.autoBlur ? { autoBlur: o.autoBlur } : {},
1752
+ ...o.refuse ? { refuse: o.refuse } : {},
1620
1753
  timeoutMs: o.timeoutMs,
1621
1754
  headless: o.headless,
1622
1755
  leadMs: LEAD_MS,
@@ -1831,7 +1964,7 @@ async function finish(cap, outs, o = {}) {
1831
1964
  last = { key, img: dst };
1832
1965
  return dst;
1833
1966
  };
1834
- const frameAt = (m) => {
1967
+ const frameAt2 = (m) => {
1835
1968
  if (m < nTitle) {
1836
1969
  const left = nTitle - m;
1837
1970
  return left <= nFade ? crossfade(art.title, content(0), 1 - (left - 1) / nFade) : art.title;
@@ -1842,16 +1975,16 @@ async function finish(cap, outs, o = {}) {
1842
1975
  return e < nFade ? crossfade(content(picks.length - 1), art.end, (e + 1) / nFade) : art.end;
1843
1976
  };
1844
1977
  if (out.format === "gif") {
1845
- const samples = Array.from({ length: Math.min(12, total) }, (_, s) => copy(frameAt(Math.floor(s * total / Math.min(12, total)))));
1978
+ const samples = Array.from({ length: Math.min(12, total) }, (_, s) => copy(frameAt2(Math.floor(s * total / Math.min(12, total)))));
1846
1979
  last = null;
1847
1980
  const w = createGifWriter({ width: layout.width, height: layout.height, fps, palette: paletteOf(samples, samples.length) });
1848
- for (let m = 0; m < total; m += 1) w.add(frameAt(m));
1981
+ for (let m = 0; m < total; m += 1) w.add(frameAt2(m));
1849
1982
  const gif = w.finish();
1850
1983
  writeFileSync2(out.file, gif.bytes);
1851
1984
  outputs.push({ file: out.file, format: "gif", width: layout.width, height: layout.height, fps, frames: total, bytes: gif.bytes.length, durationMs: gif.durationMs });
1852
1985
  } else {
1853
1986
  const all = function* () {
1854
- for (let m = 0; m < total; m += 1) yield frameAt(m).data;
1987
+ for (let m = 0; m < total; m += 1) yield frameAt2(m).data;
1855
1988
  };
1856
1989
  let audio;
1857
1990
  if (narr && said && tmp) {
@@ -2453,6 +2586,7 @@ async function direct(o) {
2453
2586
  const cards = [];
2454
2587
  let playAt = 0;
2455
2588
  let skipped = false;
2589
+ const refused = [];
2456
2590
  try {
2457
2591
  const windowOf = async (opts) => {
2458
2592
  const signedIn = opts.signedIn !== false;
@@ -2463,7 +2597,19 @@ async function direct(o) {
2463
2597
  permissions: ["clipboard-read", "clipboard-write"],
2464
2598
  ...state ? { storageState: state } : {}
2465
2599
  });
2600
+ const blurring = blurScript(o.autoBlur);
2601
+ if (blurring) await context2.addInitScript({ content: blurring });
2466
2602
  await routeAlias(context2, alias);
2603
+ const refusing = refuseScript(o.refuse);
2604
+ if (refusing) {
2605
+ await context2.addInitScript({ content: refusing });
2606
+ await context2.route("**/*", (route) => {
2607
+ const r2 = route.request();
2608
+ if (!isPayment(r2.method(), r2.url())) return route.fallback();
2609
+ refused.push(`${r2.method()} ${new URL(r2.url()).pathname}`);
2610
+ return route.abort("blockedbyclient");
2611
+ });
2612
+ }
2467
2613
  if (o.reroute) await routeReroute(context2, o.reroute);
2468
2614
  if (o.routes) await routeFolders(context2, url, o.routes);
2469
2615
  const page2 = await context2.newPage();
@@ -2639,6 +2785,7 @@ async function direct(o) {
2639
2785
  f.narration = { lines };
2640
2786
  narrated = lines.size > 0;
2641
2787
  }
2788
+ if (refused.length) throw new Error(`${id}: it needs paying, which is switched off for filming: refused ${refused[0]}`);
2642
2789
  for (const x of o.out) mkdirSync3(dirname4(x.file), { recursive: true });
2643
2790
  if (f.poster === true) f.poster = o.out[0].file.replace(/\.[^./]+$/, ".png");
2644
2791
  const r = await finish(cap, o.out, f);
@@ -2647,6 +2794,44 @@ async function direct(o) {
2647
2794
  return { ...r, narrated, scenes };
2648
2795
  }
2649
2796
 
2797
+ // src/check.ts
2798
+ import { spawnSync as spawnSync3 } from "child_process";
2799
+ function frameAt(ffmpeg, file, s) {
2800
+ const grab = (vf, codec) => spawnSync3(ffmpeg, ["-v", "error", "-ss", s.toFixed(2), "-i", file, "-frames:v", "1", "-vf", vf, ...codec, "-"], { maxBuffer: 20 * 1024 * 1024 });
2801
+ const png = grab("scale=960:-2", ["-f", "image2pipe", "-vcodec", "png"]);
2802
+ const grey = grab("scale=32:18", ["-f", "rawvideo", "-pix_fmt", "gray"]);
2803
+ if (png.status !== 0 || !png.stdout?.length || grey.status !== 0 || grey.stdout?.length !== 576) return null;
2804
+ return { png: png.stdout, grey: grey.stdout };
2805
+ }
2806
+ function isBlank(grey) {
2807
+ let sum = 0;
2808
+ for (const v of grey) sum += v;
2809
+ const mean = sum / grey.length;
2810
+ let sq = 0;
2811
+ for (const v of grey) sq += (v - mean) ** 2;
2812
+ return Math.sqrt(sq / grey.length) < 2;
2813
+ }
2814
+ function checkTimes(seconds, n) {
2815
+ return Array.from({ length: n }, (_, k) => Math.round(seconds * ((k + 0.5) / n) * 100) / 100);
2816
+ }
2817
+ async function checkVideo(o) {
2818
+ const lines = o.lines ?? [];
2819
+ const n = Math.min(12, Math.max(4, lines.length + 2));
2820
+ const frames = [];
2821
+ const blank2 = [];
2822
+ for (const t of checkTimes(o.seconds, n)) {
2823
+ const f = frameAt(o.ffmpeg, o.file, t);
2824
+ if (!f) continue;
2825
+ if (isBlank(f.grey)) {
2826
+ blank2.push(t);
2827
+ continue;
2828
+ }
2829
+ frames.push({ at: Math.round(t * 1e3), label: `at ${t.toFixed(1)} s`, png: f.png });
2830
+ }
2831
+ const flags = frames.length ? await runQa(o.ai, frames, { ...o.title ? { title: o.title } : {}, steps: lines.map((say, i) => ({ n: i + 1, type: "line", say })) }) : [];
2832
+ return { flags, blank: blank2, frames: frames.length + blank2.length, at: (/* @__PURE__ */ new Date()).toISOString() };
2833
+ }
2834
+
2650
2835
  // src/campaign.ts
2651
2836
  var CAMPAIGN_KINDS = CATALOGUE_KINDS;
2652
2837
  var CAMPAIGN_SHAPES = CATALOGUE_SHAPES;
@@ -2733,6 +2918,9 @@ function checkCampaign(c, o = {}) {
2733
2918
  if (v.mode !== void 0 && v.mode !== "overlay" && v.mode !== "perform") problems.push(`${at} mode is overlay or perform`);
2734
2919
  if (v.director && v.mode) problems.push(`${at} a director video has no mode`);
2735
2920
  if (!v.alt?.trim()) problems.push(`${at} no alt text (what it shows)`);
2921
+ if (v.blur !== void 0 && (typeof v.blur !== "object" || v.blur === null || v.blur.texts !== void 0 && (!Array.isArray(v.blur.texts) || v.blur.texts.some((t) => typeof t !== "string")) || v.blur.patterns !== void 0 && typeof v.blur.patterns !== "boolean" && !(Array.isArray(v.blur.patterns) && v.blur.patterns.every((k) => ["email", "phone", "account"].includes(k))) || v.blur.strength !== void 0 && !(typeof v.blur.strength === "number" && v.blur.strength >= 2 && v.blur.strength <= 24))) {
2922
+ problems.push(`${at} blur is { texts?: [text\u2026], patterns?: true | ["email", "phone", "account"], strength?: 2\u201324 }`);
2923
+ }
2736
2924
  const looks = v.looks ?? lookNames.slice(0, 1);
2737
2925
  if (!looks.length || looks.some((l) => !lookNames.includes(l))) problems.push(`${at} looks are some of ${lookNames.join(", ") || "(none defined)"}`);
2738
2926
  if (v.kind === "docs-gif") {
@@ -2968,6 +3156,7 @@ async function makeCampaign(c, o = {}) {
2968
3156
  let height;
2969
3157
  let seconds;
2970
3158
  let spoke = false;
3159
+ let said = [];
2971
3160
  if (v.director) {
2972
3161
  const res = await direct({
2973
3162
  id: r.id,
@@ -2980,6 +3169,8 @@ async function makeCampaign(c, o = {}) {
2980
3169
  look: lookOptions({ title: v.title, endTitle: v.endTitle, polish: r.polish }, look.brand, c.app.name ?? ""),
2981
3170
  ...r.phone ? { viewport: tall ? TALL : { width: 390, height: 844 } } : wide ? { viewport: WIDE } : {},
2982
3171
  ...session ? { session } : c.app.storageState ? { session: c.app.storageState } : {},
3172
+ ...v.blur ? { autoBlur: v.blur } : {},
3173
+ ...v.refuse ? { refuse: v.refuse } : {},
2983
3174
  ...v.session ? { sessionOptions: v.session } : {},
2984
3175
  ...v.signedIn === false ? { signedOut: true } : {},
2985
3176
  ...c.app.alias ? { alias: c.app.alias } : {},
@@ -3020,7 +3211,8 @@ async function makeCampaign(c, o = {}) {
3020
3211
  if (speak && script) args.push("--voice", "given", "--script", script);
3021
3212
  for (const x of outs) args.push("--out", `${join4(c.out, x.name)}${x.canvas ? `@${x.canvas}` : ""}`);
3022
3213
  const p = parse(args);
3023
- const res = await render({ ...p.options, ...speak ? { voice } : {} });
3214
+ const res = await render({ ...p.options, ...speak ? { voice } : {}, ...v.blur ? { autoBlur: v.blur } : {}, ...v.refuse ? { refuse: v.refuse } : {} });
3215
+ said = (g.trace.steps ?? []).map((st) => String(st.say ?? "").trim()).filter(Boolean);
3024
3216
  ({ width, height } = res.outputs[0]);
3025
3217
  seconds = Math.round(res.durationMs / 100) / 10;
3026
3218
  spoke = !!res.narration?.lines.length;
@@ -3030,7 +3222,14 @@ async function makeCampaign(c, o = {}) {
3030
3222
  for (const x of outs) files[x.key] = x.name;
3031
3223
  if (existsSync5(`${firstBase}.png`)) files.poster = `${outs[0].name.replace(/\.[^.]+$/, "")}.png`;
3032
3224
  if (existsSync5(`${firstBase}.vtt`)) files.vtt = `${outs[0].name.replace(/\.[^.]+$/, "")}.vtt`;
3033
- made[r.id] = { files, width, height, seconds, narrated: spoke, video: v.id, look: r.look, at: (/* @__PURE__ */ new Date()).toISOString() };
3225
+ let check;
3226
+ const mp4 = outs.find((x) => x.format === "mp4");
3227
+ if (o.check && mp4 && seconds) {
3228
+ if (v.director) said = saysOf(c, r.id) ?? [];
3229
+ check = await checkVideo({ ai: o.check, file: join4(c.out, mp4.name), seconds, ffmpeg: findFfmpeg(), ...v.title ? { title: v.title } : {}, lines: said });
3230
+ log(`${r.id}: checked ${check.frames} frame(s): ${check.flags.length || check.blank.length ? [...check.flags.map((f) => `${f.kind} at ${(f.at / 1e3).toFixed(1)} s (${f.note})`), ...check.blank.map((t) => `blank at ${t} s`)].join("; ") : "nothing found"}`);
3231
+ }
3232
+ made[r.id] = { files, width, height, seconds, narrated: spoke, video: v.id, look: r.look, at: (/* @__PURE__ */ new Date()).toISOString(), ...check ? { check } : {} };
3034
3233
  writeFileSync4(manifest, `${JSON.stringify(made, null, 2)}
3035
3234
  `);
3036
3235
  log(`${r.id}: \u2713 ${Object.values(files).join(", ")}`);
@@ -3071,6 +3270,10 @@ var USAGE = `Usage: trace-avatar-render <trace.json> --url <page> --out <file.gi
3071
3270
  --max-wait <ms> waits longer than this are cut to it (default 800, 0 keeps them)
3072
3271
  --hide <selector> hidden before capture; repeatable
3073
3272
  --blur <selector> blurred before capture (as well as [data-trace-blur]); repeatable
3273
+ --blur-text <text> blur any element whose text holds this (a name, an address); repeatable
3274
+ --blur-patterns blur e-mails, phone numbers and account-like numbers wherever they show
3275
+ --blur-kinds <list> only these patterns: email,phone,account
3276
+ --blur-strength <px> how strongly: 2 (light) to 24 (strong); default 8
3074
3277
  --allow-stall render a stalled guide anyway instead of failing
3075
3278
  --navigate a step on another page: load that page, as the app's router would (without it, a
3076
3279
  Show me guide that crosses pages waits on "Open \u2026 to continue")
@@ -3173,6 +3376,10 @@ function parse(argv) {
3173
3376
  "max-wait": { type: "string" },
3174
3377
  hide: { type: "string", multiple: true },
3175
3378
  blur: { type: "string", multiple: true },
3379
+ "blur-text": { type: "string", multiple: true },
3380
+ "blur-patterns": { type: "boolean" },
3381
+ "blur-kinds": { type: "string" },
3382
+ "blur-strength": { type: "string" },
3176
3383
  "allow-stall": { type: "boolean" },
3177
3384
  navigate: { type: "boolean" },
3178
3385
  security: { type: "string" },
@@ -3295,6 +3502,11 @@ function parse(argv) {
3295
3502
  ...maxWait !== void 0 ? { cuts: { maxWaitMs: maxWait } } : {},
3296
3503
  ...values.hide ? { hide: values.hide } : {},
3297
3504
  ...values.blur ? { blur: values.blur } : {},
3505
+ ...values["blur-text"] || values["blur-patterns"] || values["blur-kinds"] ? { autoBlur: {
3506
+ ...values["blur-text"] ? { texts: values["blur-text"] } : {},
3507
+ ...values["blur-kinds"] ? { patterns: String(values["blur-kinds"]).split(",").map((k) => k.trim()) } : values["blur-patterns"] ? { patterns: true } : {},
3508
+ ...values["blur-strength"] ? { strength: Number(values["blur-strength"]) } : {}
3509
+ } } : {},
3298
3510
  allowStall: !!values["allow-stall"],
3299
3511
  ...values.navigate ? { navigate: true } : {},
3300
3512
  ...security !== void 0 ? { security } : {},
@@ -3529,6 +3741,13 @@ export {
3529
3741
  ZOOM_KINDS,
3530
3742
  cameraKeys,
3531
3743
  cameraPath,
3744
+ PAYMENT_PATH,
3745
+ isPayment,
3746
+ refuseScript,
3747
+ BLUR_PATTERNS,
3748
+ patternsIn,
3749
+ blurTexts,
3750
+ blurScript,
3532
3751
  RenderError,
3533
3752
  capture,
3534
3753
  findPlayer,
@@ -3633,6 +3852,9 @@ export {
3633
3852
  reportOf,
3634
3853
  UsageError,
3635
3854
  main,
3855
+ isBlank,
3856
+ checkTimes,
3857
+ checkVideo,
3636
3858
  CAMPAIGN_KINDS,
3637
3859
  CAMPAIGN_SHAPES,
3638
3860
  loadCampaign,
@@ -3648,4 +3870,4 @@ export {
3648
3870
  makeCampaign,
3649
3871
  saysOf
3650
3872
  };
3651
- //# sourceMappingURL=chunk-7N5RZAMS.js.map
3873
+ //# sourceMappingURL=chunk-BWAHD2XE.js.map