trace-avatar-render 0.2.3 → 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-I4LM2D2B.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). */
@@ -1237,6 +1295,12 @@ interface DirectOptions {
1237
1295
  alias?: Alias | string;
1238
1296
  /** Folders served at a path of the app's own address (props the app doesn't have): { '/__terminal': 'dir' }. */
1239
1297
  routes?: Record<string, string>;
1298
+ /**
1299
+ * Addresses answered by others while filming, the address bar unchanged: { 'https://api.example.com':
1300
+ * 'https://demo-api.example.com' } films a live front end against a demo API. Only what the browser fetches is
1301
+ * rerouted; a page its own server builds still asks that server's API.
1302
+ */
1303
+ reroute?: Record<string, string>;
1240
1304
  /** Narrate with this voice. */
1241
1305
  voice?: Voice;
1242
1306
  /** The spoken lines by scene (instead of each caption): a script or its path. */
@@ -1270,9 +1334,34 @@ declare function aliasOf(url: string, alias?: Alias | string): {
1270
1334
  localApi?: string;
1271
1335
  rewrite: string[];
1272
1336
  };
1337
+ /** Where a request goes under a reroute map: the same path and query at the other origin, or null. */
1338
+ declare function rerouted(url: string, map: Record<string, string>): string | null;
1273
1339
  /** Make one director video. A script that throws (a failed check) makes nothing. */
1274
1340
  declare function direct(o: DirectOptions): Promise<DirectResult>;
1275
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
+
1276
1365
  declare const CAMPAIGN_KINDS: readonly ["intro", "demo", "guide", "onboarding", "pitch", "whats-new", "ad", "docs-gif", "qa", "support"];
1277
1366
  declare const CAMPAIGN_SHAPES: readonly ["16:9", "1:1", "4:5", "9:16"];
1278
1367
  interface CampaignApp {
@@ -1306,6 +1395,8 @@ interface CampaignApp {
1306
1395
  alias?: string | Alias;
1307
1396
  /** Folders served at a path of the app's own address, for director videos: { "/__props": "props" }. */
1308
1397
  routes?: Record<string, string>;
1398
+ /** Addresses answered by others while filming (director videos): { "https://api.x.com": "https://demo-api.x.com" }. */
1399
+ reroute?: Record<string, string>;
1309
1400
  }
1310
1401
  interface CampaignLook {
1311
1402
  /** A brand file (--brand): frame, background, cards, watermark … */
@@ -1315,6 +1406,10 @@ interface CampaignLook {
1315
1406
  }
1316
1407
  interface CampaignVideo {
1317
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;
1318
1413
  kind: (typeof CAMPAIGN_KINDS)[number];
1319
1414
  /** A guide id (from app.guides) or a .trace.json path … */
1320
1415
  guide?: string;
@@ -1447,6 +1542,8 @@ interface Made {
1447
1542
  video: string;
1448
1543
  look: string;
1449
1544
  at: string;
1545
+ /** What the check found (STUDIO_V3 §4), when make was given an AI to check with. */
1546
+ check?: CheckResult;
1450
1547
  }
1451
1548
  interface MakeOptions {
1452
1549
  /** Video ids, or render ids (intro--product--phone), to make; default all. */
@@ -1458,6 +1555,8 @@ interface MakeOptions {
1458
1555
  /** The voice (over the campaign's narrator and TRACE_AVATAR_VOICE). '' makes narrated videos without a voice. */
1459
1556
  voice?: string | Voice;
1460
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;
1461
1560
  }
1462
1561
  /** The app serving: already, or started (app.start) and waited for. Returns how to stop what was started. */
1463
1562
  declare function ensureApp(app: CampaignApp, start: boolean, log?: (m: string) => void): Promise<() => void>;
@@ -1472,4 +1571,4 @@ declare function makeCampaign(c: LoadedCampaign, o?: MakeOptions): Promise<{
1472
1571
  */
1473
1572
  declare function saysOf(c: Pick<LoadedCampaign, 'out'>, renderId: string): string[] | null;
1474
1573
 
1475
- 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, 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,16 +89,19 @@ 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,
93
103
  repairScriptOf,
104
+ rerouted,
94
105
  resample,
95
106
  resize,
96
107
  runQa,
@@ -114,8 +125,9 @@ import {
114
125
  withCards,
115
126
  withCursor,
116
127
  withHolds
117
- } from "./chunk-I4LM2D2B.js";
128
+ } from "./chunk-BWAHD2XE.js";
118
129
  export {
130
+ BLUR_PATTERNS,
119
131
  CAMPAIGN_KINDS,
120
132
  CAMPAIGN_SHAPES,
121
133
  CANVASES,
@@ -129,6 +141,7 @@ export {
129
141
  DEFAULT_MAX_WAIT_MS,
130
142
  DIRECTOR_VIEWPORT,
131
143
  GEMINI_TTS,
144
+ PAYMENT_PATH,
132
145
  RenderError,
133
146
  SKIP_KEEP_MS,
134
147
  TRACK_RATE,
@@ -138,6 +151,8 @@ export {
138
151
  arrowSprite,
139
152
  badgeAt,
140
153
  blank,
154
+ blurScript,
155
+ blurTexts,
141
156
  brandFile,
142
157
  brandOf,
143
158
  cached,
@@ -154,6 +169,8 @@ export {
154
169
  chapterCues,
155
170
  checkCampaign,
156
171
  checkCatalogue,
172
+ checkTimes,
173
+ checkVideo,
157
174
  createGifWriter,
158
175
  createLayers,
159
176
  crop,
@@ -181,6 +198,8 @@ export {
181
198
  fromS16le,
182
199
  fromWav,
183
200
  geminiVoice,
201
+ isBlank,
202
+ isPayment,
184
203
  layoutOf,
185
204
  linesOf,
186
205
  loadCampaign,
@@ -198,16 +217,19 @@ export {
198
217
  paletteOf,
199
218
  parseScript,
200
219
  pathOf,
220
+ patternsIn,
201
221
  pickFrames,
202
222
  pixel,
203
223
  planNarration,
204
224
  progressOf,
205
225
  providerOf,
206
226
  readCampaign,
227
+ refuseScript,
207
228
  render,
208
229
  rendersOf,
209
230
  repairGuide,
210
231
  repairScriptOf,
232
+ rerouted,
211
233
  resample,
212
234
  resize,
213
235
  runQa,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trace-avatar-render",
3
- "version": "0.2.3",
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": {