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/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  main,
6
6
  parse,
7
7
  reportOf
8
- } from "./chunk-7N5RZAMS.js";
8
+ } from "./chunk-BWAHD2XE.js";
9
9
  export {
10
10
  USAGE,
11
11
  UsageError,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,50 @@
1
1
  import { Browser, Page, Locator } from 'playwright';
2
2
  import { Ai, preview, Suggestion, Candidate, TextCandidate, applyRaw } from 'trace-avatar/assist';
3
3
 
4
+ /**
5
+ * Actions the owner switched off, refused while filming (websites/docs/TRACE_AVATAR_STUDIO_V3.md §5): the last line,
6
+ * in code, for anything the checks before filming missed. With paying refused, card fields take no input, a form
7
+ * holding one is never sent, and requests that write to a payment address never leave the browser.
8
+ */
9
+ interface RefuseSpec {
10
+ /** Paying: card fields, their forms, and writes to payment addresses. */
11
+ pay?: boolean;
12
+ }
13
+ /** Payment addresses, by path segment (a "pay links" page isn't one; /checkout, /payments/… are). */
14
+ declare const PAYMENT_PATH: string;
15
+ /** Whether a request is a payment, refused when paying is off: a write (not GET, HEAD, OPTIONS) to a payment path. */
16
+ declare function isPayment(method: string, url: string): boolean;
17
+ /** The init script for a spec, or null. */
18
+ declare function refuseScript(spec: RefuseSpec | undefined): string | null;
19
+
20
+ /**
21
+ * Auto-blur (websites/docs/TRACE_AVATAR_STUDIO_V3.md §3): personal data is blurred in the page before frames are
22
+ * taken, so no unblurred frame exists. Code finds contact details and account numbers by pattern; exact texts (names,
23
+ * addresses an AI picked from the page) are blurred wherever they show. The page is watched, so rows that load later
24
+ * are blurred as they appear.
25
+ */
26
+ interface BlurSpec {
27
+ /** Exact texts to blur wherever an element's own text holds one (names, addresses). */
28
+ texts?: string[];
29
+ /** Blur e-mails, phone numbers and long account-like numbers: true for all of them, or a list of the kinds. */
30
+ patterns?: boolean | BlurKind[];
31
+ /** How strongly, in pixels of blur: 2 (light) to 24 (strong). Default 8. */
32
+ strength?: number;
33
+ }
34
+ type BlurKind = 'email' | 'phone' | 'account';
35
+ /**
36
+ * The patterns, as sources (they also run in the page). Phone numbers: Nigerian forms (080…, +234 80…) and any
37
+ * number written with a leading +. Account-like: 10–19 digits in a row, or a card's groups of four. Order numbers,
38
+ * dates and prices don't match: they're shorter runs, or broken by other characters.
39
+ */
40
+ declare const BLUR_PATTERNS: Record<BlurKind, string>;
41
+ /** Which kinds of personal data a text holds, by pattern. */
42
+ declare function patternsIn(text: string): Array<keyof typeof BLUR_PATTERNS>;
43
+ /** The texts kept: trimmed, 3–120 characters, distinct, at most 300. */
44
+ declare function blurTexts(texts: unknown): string[];
45
+ /** The init script for a spec, or null when there's nothing to blur. */
46
+ declare function blurScript(spec: BlurSpec | undefined): string | null;
47
+
4
48
  /** RGBA pixel helpers. PURE. */
5
49
  interface Image {
6
50
  width: number;
@@ -296,6 +340,10 @@ interface CaptureOptions {
296
340
  hide?: string[];
297
341
  /** Selectors blurred before capture, as well as [data-trace-blur]. */
298
342
  blur?: string[];
343
+ /** Personal data blurred in the page as it shows: exact texts and/or contact details by pattern (blur.ts). */
344
+ autoBlur?: BlurSpec;
345
+ /** Actions switched off, refused in the page and on the network (refuse.ts); a refused payment fails the capture. */
346
+ refuse?: RefuseSpec;
299
347
  rate?: number;
300
348
  /** When a step is on another page, load that page (as an app's router would) instead of waiting for it. */
301
349
  navigate?: boolean;
@@ -544,17 +592,19 @@ declare function voiceOf(spec: string, env?: NodeJS.ProcessEnv, o?: {
544
592
  declare function providerOf(spec: string, env?: NodeJS.ProcessEnv, o?: {
545
593
  vision?: string;
546
594
  }): Promise<Ai>;
547
- declare const QA_KINDS: readonly ["error", "empty", "stalled", "personal-data", "wrong-page", "other"];
595
+ declare const QA_KINDS: readonly ["error", "empty", "stalled", "personal-data", "wrong-page", "line-mismatch", "other"];
548
596
  type QaKind = (typeof QA_KINDS)[number];
549
597
  interface QaFrame {
550
598
  at: number;
551
599
  label: string;
552
600
  png: Uint8Array;
553
601
  }
602
+ /** `text`: for personal data, the exact text seen (so it can be blurred next time). */
554
603
  interface QaFlag {
555
604
  at: number;
556
605
  kind: QaKind;
557
606
  note: string;
607
+ text?: string;
558
608
  }
559
609
  /** Ask the model to look at the frames. The answer is checked: unknown frames or kinds are dropped. */
560
610
  declare function runQa(ai: Ai, frames: readonly QaFrame[], context: {
@@ -640,6 +690,10 @@ interface RenderOptions {
640
690
  values?: Record<string, string>;
641
691
  hide?: string[];
642
692
  blur?: string[];
693
+ /** Personal data blurred in the page as it shows: exact texts and/or patterns (blur.ts). */
694
+ autoBlur?: BlurSpec;
695
+ /** Actions switched off, refused while filming (refuse.ts). */
696
+ refuse?: RefuseSpec;
643
697
  rate?: number;
644
698
  /** The player build. Default: TRACE_AVATAR_PLAYER, else the installed trace-avatar's dist/trace-perform.min.js. */
645
699
  player?: string;
@@ -1228,6 +1282,10 @@ interface DirectOptions {
1228
1282
  scale?: number;
1229
1283
  /** Signed in with this session (default: not signed in). */
1230
1284
  session?: Session;
1285
+ /** Personal data blurred in the page as it shows (blur.ts). */
1286
+ autoBlur?: BlurSpec;
1287
+ /** Actions switched off, refused in the page and on the network (refuse.ts). */
1288
+ refuse?: RefuseSpec;
1231
1289
  /** Options for a session function, for the first window (a window of its own can pass others). */
1232
1290
  sessionOptions?: Record<string, unknown>;
1233
1291
  /** Where to save a screenshot of the page when the script fails (to see what it was looking at). */
@@ -1281,6 +1339,29 @@ declare function rerouted(url: string, map: Record<string, string>): string | nu
1281
1339
  /** Make one director video. A script that throws (a failed check) makes nothing. */
1282
1340
  declare function direct(o: DirectOptions): Promise<DirectResult>;
1283
1341
 
1342
+ interface CheckResult {
1343
+ flags: QaFlag[];
1344
+ blank: number[];
1345
+ frames: number;
1346
+ at: string;
1347
+ }
1348
+ /** One colour all over (a white or black frame): the spread of its grey levels is tiny. */
1349
+ declare function isBlank(grey: Uint8Array): boolean;
1350
+ /** The times frames are taken at: evenly through the video, `n` of them. */
1351
+ declare function checkTimes(seconds: number, n: number): number[];
1352
+ /**
1353
+ * Checks a made MP4. `lines` are what it says, in order (shown to the AI as the video's steps). Frames: one per
1354
+ * line plus two, between 4 and 12.
1355
+ */
1356
+ declare function checkVideo(o: {
1357
+ ai: Ai;
1358
+ file: string;
1359
+ seconds: number;
1360
+ ffmpeg: string;
1361
+ title?: string;
1362
+ lines?: string[];
1363
+ }): Promise<CheckResult>;
1364
+
1284
1365
  declare const CAMPAIGN_KINDS: readonly ["intro", "demo", "guide", "onboarding", "pitch", "whats-new", "ad", "docs-gif", "qa", "support"];
1285
1366
  declare const CAMPAIGN_SHAPES: readonly ["16:9", "1:1", "4:5", "9:16"];
1286
1367
  interface CampaignApp {
@@ -1325,6 +1406,10 @@ interface CampaignLook {
1325
1406
  }
1326
1407
  interface CampaignVideo {
1327
1408
  id: string;
1409
+ /** Personal data blurred while filming: exact texts and/or contact details by pattern (STUDIO_V3 §3). */
1410
+ blur?: BlurSpec;
1411
+ /** Actions switched off for filming, refused in the page (STUDIO_V3 §5): { pay: true }. */
1412
+ refuse?: RefuseSpec;
1328
1413
  kind: (typeof CAMPAIGN_KINDS)[number];
1329
1414
  /** A guide id (from app.guides) or a .trace.json path … */
1330
1415
  guide?: string;
@@ -1457,6 +1542,8 @@ interface Made {
1457
1542
  video: string;
1458
1543
  look: string;
1459
1544
  at: string;
1545
+ /** What the check found (STUDIO_V3 §4), when make was given an AI to check with. */
1546
+ check?: CheckResult;
1460
1547
  }
1461
1548
  interface MakeOptions {
1462
1549
  /** Video ids, or render ids (intro--product--phone), to make; default all. */
@@ -1468,6 +1555,8 @@ interface MakeOptions {
1468
1555
  /** The voice (over the campaign's narrator and TRACE_AVATAR_VOICE). '' makes narrated videos without a voice. */
1469
1556
  voice?: string | Voice;
1470
1557
  log?: (m: string) => void;
1558
+ /** Checks each made MP4 with this AI (check.ts): flags and blank frames go into the made manifest. */
1559
+ check?: Ai;
1471
1560
  }
1472
1561
  /** The app serving: already, or started (app.start) and waited for. Returns how to stop what was started. */
1473
1562
  declare function ensureApp(app: CampaignApp, start: boolean, log?: (m: string) => void): Promise<() => void>;
@@ -1482,4 +1571,4 @@ declare function makeCampaign(c: LoadedCampaign, o?: MakeOptions): Promise<{
1482
1571
  */
1483
1572
  declare function saysOf(c: Pick<LoadedCampaign, 'out'>, renderId: string): string[] | null;
1484
1573
 
1485
- export { type Action, type Alias, type Brand, CAMPAIGN_KINDS, CAMPAIGN_SHAPES, CANVASES, CATALOGUE_FORMATS, CATALOGUE_KINDS, CATALOGUE_REQUIRED, CATALOGUE_SHAPES, CATALOGUE_SPEC, CORNERS, type CameraOptions, type Campaign, type CampaignApp, type CampaignLook, type CampaignRender, type CampaignVideo, type Canvas, type CanvasSpec, type Capture, type CaptureOptions, type CapturedFrame, type CardOptions, type Catalogue, type CatalogueCheck, type CatalogueEntry, type CheckOptions, type Corner, type Cue, DEFAULT_BACKGROUND, DEFAULT_MAX_WAIT_MS, DIRECTOR_VIEWPORT, type DirectOptions, type DirectResult, type Director, type DirectorCard, type EditOptions, type FinishOptions, type FrameStyle, GEMINI_TTS, type GifOptions, type GifResult, type GifWriter, type Image, type Layers, type Layout, type LoadedCampaign, type LookOf, type Made, type MakeOptions, type Move, type NarrationPlan, type OutFormat, type OutSpec, type Pcm, type Phase, type PlanOptions, type PlannedLine, type Point, type Progress, type Rect, RenderError, type RenderOptions, type RenderOutput, type RenderResult, type RepairOutcome, type RepairSuggestion, SKIP_KEEP_MS, type Scene, type Script, type Segment, type Session, type Shot, type Span, type Sprite, TRACK_RATE, type TimelineEvent, type Unresolved, type Voice, type Watermark, ZOOM_KINDS, actionsOf, aliasOf, arrowSprite, badgeAt, blank, brandFile, brandOf, cached, cameraKeys, cameraPath, canvasOf, captionCues, capture, cardCaption, cardFrames, cardOf, cardsOf, catalogueId, chapterCues, checkCampaign, checkCatalogue, createGifWriter, createLayers, crop, crossfade, cueAt, cursorAt, dataUri, direct, drawCursor, drawRegion, durationOf, editList, encodeGif, encodeMp4, endsWithOf, ensureApp, filesOf, findFfmpeg, findPlayer, finish, fitWidth, formatOf, frameScale, frameTimes, fromS16le, fromWav, geminiVoice, layoutOf, linesOf, loadCampaign, lookOptions, makeCampaign, mix, mp4Args, mp4Head, msOf, narrationText, openAiVoice, outputAt, overlay, pageAt, paletteOf, parseScript, pathOf, pickFrames, pixel, planNarration, progressOf, providerOf, readCampaign, render, rendersOf, repairGuide, repairScriptOf, rerouted, resample, resize, runQa, sayFrom, sayVoice, saysOf, shapeTag, sourceAt, spansOf, stallInspector, statusOf, stepCues, suggestScript, toVtt, toWav, travelMs, trimSilence, voiceOf, vttEnds, watermarkOf, withCards, withCursor, withHolds };
1574
+ export { type Action, type Alias, BLUR_PATTERNS, type BlurSpec, type Brand, CAMPAIGN_KINDS, CAMPAIGN_SHAPES, CANVASES, CATALOGUE_FORMATS, CATALOGUE_KINDS, CATALOGUE_REQUIRED, CATALOGUE_SHAPES, CATALOGUE_SPEC, CORNERS, type CameraOptions, type Campaign, type CampaignApp, type CampaignLook, type CampaignRender, type CampaignVideo, type Canvas, type CanvasSpec, type Capture, type CaptureOptions, type CapturedFrame, type CardOptions, type Catalogue, type CatalogueCheck, type CatalogueEntry, type CheckOptions, type CheckResult, type Corner, type Cue, DEFAULT_BACKGROUND, DEFAULT_MAX_WAIT_MS, DIRECTOR_VIEWPORT, type DirectOptions, type DirectResult, type Director, type DirectorCard, type EditOptions, type FinishOptions, type FrameStyle, GEMINI_TTS, type GifOptions, type GifResult, type GifWriter, type Image, type Layers, type Layout, type LoadedCampaign, type LookOf, type Made, type MakeOptions, type Move, type NarrationPlan, type OutFormat, type OutSpec, PAYMENT_PATH, type Pcm, type Phase, type PlanOptions, type PlannedLine, type Point, type Progress, type Rect, type RefuseSpec, RenderError, type RenderOptions, type RenderOutput, type RenderResult, type RepairOutcome, type RepairSuggestion, SKIP_KEEP_MS, type Scene, type Script, type Segment, type Session, type Shot, type Span, type Sprite, TRACK_RATE, type TimelineEvent, type Unresolved, type Voice, type Watermark, ZOOM_KINDS, actionsOf, aliasOf, arrowSprite, badgeAt, blank, blurScript, blurTexts, brandFile, brandOf, cached, cameraKeys, cameraPath, canvasOf, captionCues, capture, cardCaption, cardFrames, cardOf, cardsOf, catalogueId, chapterCues, checkCampaign, checkCatalogue, checkTimes, checkVideo, createGifWriter, createLayers, crop, crossfade, cueAt, cursorAt, dataUri, direct, drawCursor, drawRegion, durationOf, editList, encodeGif, encodeMp4, endsWithOf, ensureApp, filesOf, findFfmpeg, findPlayer, finish, fitWidth, formatOf, frameScale, frameTimes, fromS16le, fromWav, geminiVoice, isBlank, isPayment, layoutOf, linesOf, loadCampaign, lookOptions, makeCampaign, mix, mp4Args, mp4Head, msOf, narrationText, openAiVoice, outputAt, overlay, pageAt, paletteOf, parseScript, pathOf, patternsIn, pickFrames, pixel, planNarration, progressOf, providerOf, readCampaign, refuseScript, render, rendersOf, repairGuide, repairScriptOf, rerouted, resample, resize, runQa, sayFrom, sayVoice, saysOf, shapeTag, sourceAt, spansOf, stallInspector, statusOf, stepCues, suggestScript, toVtt, toWav, travelMs, trimSilence, voiceOf, vttEnds, watermarkOf, withCards, withCursor, withHolds };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BLUR_PATTERNS,
2
3
  CAMPAIGN_KINDS,
3
4
  CAMPAIGN_SHAPES,
4
5
  CANVASES,
@@ -12,6 +13,7 @@ import {
12
13
  DEFAULT_MAX_WAIT_MS,
13
14
  DIRECTOR_VIEWPORT,
14
15
  GEMINI_TTS,
16
+ PAYMENT_PATH,
15
17
  RenderError,
16
18
  SKIP_KEEP_MS,
17
19
  TRACK_RATE,
@@ -21,6 +23,8 @@ import {
21
23
  arrowSprite,
22
24
  badgeAt,
23
25
  blank,
26
+ blurScript,
27
+ blurTexts,
24
28
  brandFile,
25
29
  brandOf,
26
30
  cached,
@@ -37,6 +41,8 @@ import {
37
41
  chapterCues,
38
42
  checkCampaign,
39
43
  checkCatalogue,
44
+ checkTimes,
45
+ checkVideo,
40
46
  createGifWriter,
41
47
  createLayers,
42
48
  crop,
@@ -64,6 +70,8 @@ import {
64
70
  fromS16le,
65
71
  fromWav,
66
72
  geminiVoice,
73
+ isBlank,
74
+ isPayment,
67
75
  layoutOf,
68
76
  linesOf,
69
77
  loadCampaign,
@@ -81,12 +89,14 @@ import {
81
89
  paletteOf,
82
90
  parseScript,
83
91
  pathOf,
92
+ patternsIn,
84
93
  pickFrames,
85
94
  pixel,
86
95
  planNarration,
87
96
  progressOf,
88
97
  providerOf,
89
98
  readCampaign,
99
+ refuseScript,
90
100
  render,
91
101
  rendersOf,
92
102
  repairGuide,
@@ -115,8 +125,9 @@ import {
115
125
  withCards,
116
126
  withCursor,
117
127
  withHolds
118
- } from "./chunk-7N5RZAMS.js";
128
+ } from "./chunk-BWAHD2XE.js";
119
129
  export {
130
+ BLUR_PATTERNS,
120
131
  CAMPAIGN_KINDS,
121
132
  CAMPAIGN_SHAPES,
122
133
  CANVASES,
@@ -130,6 +141,7 @@ export {
130
141
  DEFAULT_MAX_WAIT_MS,
131
142
  DIRECTOR_VIEWPORT,
132
143
  GEMINI_TTS,
144
+ PAYMENT_PATH,
133
145
  RenderError,
134
146
  SKIP_KEEP_MS,
135
147
  TRACK_RATE,
@@ -139,6 +151,8 @@ export {
139
151
  arrowSprite,
140
152
  badgeAt,
141
153
  blank,
154
+ blurScript,
155
+ blurTexts,
142
156
  brandFile,
143
157
  brandOf,
144
158
  cached,
@@ -155,6 +169,8 @@ export {
155
169
  chapterCues,
156
170
  checkCampaign,
157
171
  checkCatalogue,
172
+ checkTimes,
173
+ checkVideo,
158
174
  createGifWriter,
159
175
  createLayers,
160
176
  crop,
@@ -182,6 +198,8 @@ export {
182
198
  fromS16le,
183
199
  fromWav,
184
200
  geminiVoice,
201
+ isBlank,
202
+ isPayment,
185
203
  layoutOf,
186
204
  linesOf,
187
205
  loadCampaign,
@@ -199,12 +217,14 @@ export {
199
217
  paletteOf,
200
218
  parseScript,
201
219
  pathOf,
220
+ patternsIn,
202
221
  pickFrames,
203
222
  pixel,
204
223
  planNarration,
205
224
  progressOf,
206
225
  providerOf,
207
226
  readCampaign,
227
+ refuseScript,
208
228
  render,
209
229
  rendersOf,
210
230
  repairGuide,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trace-avatar-render",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Render a trace-avatar guide to a GIF or MP4 by playing it on your real app in headless Chromium.",
5
5
  "type": "module",
6
6
  "bin": {