trace-avatar-render 0.1.7 → 0.2.1
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 +34 -1
- package/README.md +55 -0
- package/dist/{chunk-PPVNEPXF.js → chunk-MC2ZHX5Z.js} +1997 -599
- package/dist/chunk-MC2ZHX5Z.js.map +1 -0
- package/dist/cli.js +6 -448
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +437 -11
- package/dist/index.js +55 -1
- package/package.json +13 -1
- package/dist/chunk-PPVNEPXF.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Browser, Page } from 'playwright';
|
|
1
|
+
import { Browser, Page, Locator } from 'playwright';
|
|
2
2
|
import { Ai, preview, Suggestion, Candidate, TextCandidate, applyRaw } from 'trace-avatar/assist';
|
|
3
3
|
|
|
4
4
|
/** RGBA pixel helpers. PURE. */
|
|
@@ -97,6 +97,8 @@ declare function watermarkOf(v: string | Watermark): Watermark;
|
|
|
97
97
|
/** What a brand file may set: the polish options, nothing about what is played. */
|
|
98
98
|
interface Brand {
|
|
99
99
|
canvas?: CanvasSpec;
|
|
100
|
+
/** Shapes that fill the picture (no window, no margins), e.g. ["16:9"]; the others keep `frame`. */
|
|
101
|
+
fill?: CanvasSpec[];
|
|
100
102
|
watermark?: string | Watermark;
|
|
101
103
|
frame?: 'none' | 'browser';
|
|
102
104
|
background?: string;
|
|
@@ -135,7 +137,7 @@ interface Layout {
|
|
|
135
137
|
* The output size for a capture of srcW×srcH shown `width` wide (default: the capture's width, never
|
|
136
138
|
* upscaled), with or without a browser window around it.
|
|
137
139
|
*/
|
|
138
|
-
declare function layoutOf(srcW: number, srcH: number, width: number | undefined, frame?: FrameStyle, canvas?: Canvas): Layout;
|
|
140
|
+
declare function layoutOf(srcW: number, srcH: number, width: number | undefined, frame?: FrameStyle, canvas?: Canvas, fill?: boolean): Layout;
|
|
139
141
|
|
|
140
142
|
/**
|
|
141
143
|
* The parts of a frame that have text in them (the window's title bar, burned-in captions, title and end
|
|
@@ -668,6 +670,9 @@ interface RenderOptions {
|
|
|
668
670
|
/** Compose onto a picture of this shape: '9:16' (1080×1920), '4:5', '1:1', '16:9', 'WxH' or { width, height }.
|
|
669
671
|
* The app is placed between safe margins on the background; an output's width scales the whole canvas. */
|
|
670
672
|
canvas?: CanvasSpec;
|
|
673
|
+
/** Shapes whose outputs fill the picture: no window, no margins (e.g. ['16:9']). The other outputs keep `frame`.
|
|
674
|
+
* Capture at the same shape (e.g. --viewport 1280x720 for 16:9) and nothing is cropped or padded. */
|
|
675
|
+
fill?: CanvasSpec[];
|
|
671
676
|
/** A small badge on every frame, cards included: its text, or { text, at, opacity, logo }. */
|
|
672
677
|
watermark?: string | Watermark;
|
|
673
678
|
/** The AI for qa and alt (see trace-avatar/assist). Without it nothing calls a model. */
|
|
@@ -692,7 +697,7 @@ interface RenderOptions {
|
|
|
692
697
|
repairVision?: boolean;
|
|
693
698
|
}
|
|
694
699
|
/** What finish() takes besides the capture: the composing options, with the cards resolved. */
|
|
695
|
-
type FinishOptions = Pick<RenderOptions, 'cuts' | 'timeline' | 'frame' | 'background' | 'camera' | 'captions' | 'captionsAt' | 'poster' | 'canvas' | 'watermark'> & {
|
|
700
|
+
type FinishOptions = Pick<RenderOptions, 'cuts' | 'timeline' | 'frame' | 'background' | 'camera' | 'captions' | 'captionsAt' | 'poster' | 'canvas' | 'fill' | 'watermark'> & {
|
|
696
701
|
cards?: {
|
|
697
702
|
title?: CardOptions;
|
|
698
703
|
end?: CardOptions;
|
|
@@ -819,14 +824,13 @@ declare function createGifWriter(o: {
|
|
|
819
824
|
|
|
820
825
|
/**
|
|
821
826
|
* MP4 (H.264) through the system ffmpeg: composed RGBA frames are piped in at a steady fps.
|
|
822
|
-
*
|
|
823
|
-
|
|
824
|
-
/** The ffmpeg to use, or null. `FFMPEG` overrides the PATH. */
|
|
825
|
-
declare function findFfmpeg(env?: NodeJS.ProcessEnv): string | null;
|
|
826
|
-
/**
|
|
827
|
-
* The ffmpeg arguments for raw RGBA frames of width×height piped in (the renderer composes them), and an
|
|
828
|
-
* optional audio track (a WAV as long as the video). Exported for tests.
|
|
827
|
+
* The ffmpeg is FFMPEG, else one on the PATH, else ffmpeg-static (an optional dependency, installed with the
|
|
828
|
+
* package where its platform has a build). Without any, MP4 output fails with a clear message.
|
|
829
829
|
*/
|
|
830
|
+
/** The ffmpeg to use, or null. `FFMPEG` is used as given (no fallback); else the PATH's; else ffmpeg-static's. */
|
|
831
|
+
declare function findFfmpeg(env?: NodeJS.ProcessEnv, o?: {
|
|
832
|
+
bundled?: () => string | null;
|
|
833
|
+
}): string | null;
|
|
830
834
|
declare function mp4Args(file: string, fps: number, size: {
|
|
831
835
|
width: number;
|
|
832
836
|
height: number;
|
|
@@ -1037,4 +1041,426 @@ interface CheckOptions {
|
|
|
1037
1041
|
/** Check a catalogue against trace-avatar-catalogue/1. With `fetch`, its links too. */
|
|
1038
1042
|
declare function checkCatalogue(doc: unknown, o?: CheckOptions): Promise<CatalogueCheck>;
|
|
1039
1043
|
|
|
1040
|
-
|
|
1044
|
+
declare const DIRECTOR_VIEWPORT: {
|
|
1045
|
+
width: number;
|
|
1046
|
+
height: number;
|
|
1047
|
+
};
|
|
1048
|
+
/** How much of a skipped stretch a video keeps (ms). */
|
|
1049
|
+
declare const SKIP_KEEP_MS = 1600;
|
|
1050
|
+
interface Sprite {
|
|
1051
|
+
width: number;
|
|
1052
|
+
height: number;
|
|
1053
|
+
data: Uint8Array;
|
|
1054
|
+
ox: number;
|
|
1055
|
+
oy: number;
|
|
1056
|
+
}
|
|
1057
|
+
interface Rgba {
|
|
1058
|
+
width: number;
|
|
1059
|
+
height: number;
|
|
1060
|
+
data: Uint8Array;
|
|
1061
|
+
}
|
|
1062
|
+
interface Point {
|
|
1063
|
+
x: number;
|
|
1064
|
+
y: number;
|
|
1065
|
+
}
|
|
1066
|
+
interface Move extends Point {
|
|
1067
|
+
t: number;
|
|
1068
|
+
}
|
|
1069
|
+
/** The arrow as an RGBA sprite (white with a dark edge), 4× supersampled; `ox, oy` is the tip. */
|
|
1070
|
+
declare function arrowSprite(scale?: number): Sprite;
|
|
1071
|
+
/** Draw the arrow with its tip at (x, y) and, while a click is fresh, a ring that grows and fades. */
|
|
1072
|
+
declare function drawCursor(img: Rgba, sprite: Sprite, x: number, y: number, ring?: (Point & {
|
|
1073
|
+
p: number;
|
|
1074
|
+
}) | null): void;
|
|
1075
|
+
/** Where the cursor is at time t, from the moves; before the first, at the first. */
|
|
1076
|
+
declare function cursorAt(moves: readonly Move[], t: number): Point | null;
|
|
1077
|
+
interface Shot {
|
|
1078
|
+
t: number;
|
|
1079
|
+
png: Buffer;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* The frames finish() gets: each screencast frame, and one every 1/30 s while the cursor moves or a click ring shows,
|
|
1083
|
+
* all with the cursor drawn. A still page with a still cursor needs no more frames.
|
|
1084
|
+
*/
|
|
1085
|
+
declare function withCursor(shots: readonly Shot[], moves: readonly Move[], clicks: readonly Move[], o?: {
|
|
1086
|
+
scale?: number;
|
|
1087
|
+
sprite?: Sprite;
|
|
1088
|
+
}): Shot[];
|
|
1089
|
+
/** A human path from a to b: eased, with a slight arc, ~ 60 points a second. */
|
|
1090
|
+
declare function pathOf(a: Point, b: Point, ms: number): Point[];
|
|
1091
|
+
/** How long a person takes to reach something this far away (ms). */
|
|
1092
|
+
declare const travelMs: (d: number) => number;
|
|
1093
|
+
/**
|
|
1094
|
+
* A narration script's lines by scene number ({ lines: [{ n, text }] }, as --script). A line for a scene the video
|
|
1095
|
+
* doesn't have is refused, so a script can't drift from its director script unseen.
|
|
1096
|
+
*/
|
|
1097
|
+
declare function sayFrom(script: {
|
|
1098
|
+
lines?: Array<{
|
|
1099
|
+
n: number;
|
|
1100
|
+
text?: string;
|
|
1101
|
+
}>;
|
|
1102
|
+
} | null | undefined, count: number, id?: string): Map<number, string>;
|
|
1103
|
+
/** A video's own polish (renderer flags: --frame, --captions, --title-card …) and titles, over its look. */
|
|
1104
|
+
interface LookOf {
|
|
1105
|
+
title?: string;
|
|
1106
|
+
endTitle?: string;
|
|
1107
|
+
polish?: readonly string[];
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* finish() options for a director video: the look (a brand file, or one already read) first, the video's flags over
|
|
1111
|
+
* it. A card the video asks for (--title-card / --end-card), else the brand's; the video's title wins over both, and
|
|
1112
|
+
* a brand's card object keeps its url, logo and colour. `appName` is the cards' small line.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function lookOptions(video: LookOf, brand?: string | Brand, appName?: string): FinishOptions;
|
|
1115
|
+
interface DirectorCard {
|
|
1116
|
+
t: number;
|
|
1117
|
+
ms: number;
|
|
1118
|
+
title: string;
|
|
1119
|
+
url?: boolean;
|
|
1120
|
+
step: number;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* A director's cards for finish(): each in the look of the video's end card (its logo and colour, else the title
|
|
1124
|
+
* card's), with its own title; the product's address only on those that ask for it.
|
|
1125
|
+
*/
|
|
1126
|
+
declare function cardsOf(cards: readonly DirectorCard[], finishCards?: FinishOptions['cards'], appName?: string): {
|
|
1127
|
+
t: number;
|
|
1128
|
+
ms: number;
|
|
1129
|
+
step: number;
|
|
1130
|
+
card: {
|
|
1131
|
+
url?: string | undefined;
|
|
1132
|
+
title: string;
|
|
1133
|
+
sub?: string;
|
|
1134
|
+
color?: string;
|
|
1135
|
+
logo?: string;
|
|
1136
|
+
};
|
|
1137
|
+
}[];
|
|
1138
|
+
/** The app served under its public name: https://<host> answered by the local server (nothing leaves the machine). */
|
|
1139
|
+
interface Alias {
|
|
1140
|
+
/** The public host, e.g. acme.com. */
|
|
1141
|
+
host: string;
|
|
1142
|
+
/** The app's local API, served as https://api.<host>. */
|
|
1143
|
+
api?: string;
|
|
1144
|
+
/** App paths whose text has the local API's address replaced by the public one (a runtime config, /config.js). */
|
|
1145
|
+
rewrite?: string[];
|
|
1146
|
+
}
|
|
1147
|
+
/** What a session is: a storageState file, or a function of the app's address and the window's options. */
|
|
1148
|
+
type Session = string | ((url: string, o: Record<string, unknown>) => unknown | Promise<unknown>);
|
|
1149
|
+
interface Director {
|
|
1150
|
+
[prop: string]: unknown;
|
|
1151
|
+
page: Page;
|
|
1152
|
+
/** Playwright's expect (needs @playwright/test installed). */
|
|
1153
|
+
expect: (...a: unknown[]) => any;
|
|
1154
|
+
/** The app's address as the video shows it. */
|
|
1155
|
+
url: string;
|
|
1156
|
+
/** Where the app really runs. */
|
|
1157
|
+
local: string;
|
|
1158
|
+
open(path: string): Promise<void>;
|
|
1159
|
+
window(path: string, o?: Record<string, unknown>): Promise<void>;
|
|
1160
|
+
read(ms?: number): Promise<void>;
|
|
1161
|
+
hover(locator: Locator, o?: {
|
|
1162
|
+
ms?: number;
|
|
1163
|
+
rest?: number;
|
|
1164
|
+
timeout?: number;
|
|
1165
|
+
}): Promise<void>;
|
|
1166
|
+
click(locator: Locator, o?: {
|
|
1167
|
+
ms?: number;
|
|
1168
|
+
aim?: number;
|
|
1169
|
+
rest?: number;
|
|
1170
|
+
timeout?: number;
|
|
1171
|
+
}): Promise<void>;
|
|
1172
|
+
type(locator: Locator, text: string, o?: {
|
|
1173
|
+
delay?: number;
|
|
1174
|
+
rest?: number;
|
|
1175
|
+
clear?: boolean;
|
|
1176
|
+
ms?: number;
|
|
1177
|
+
timeout?: number;
|
|
1178
|
+
}): Promise<void>;
|
|
1179
|
+
press(key: string, o?: {
|
|
1180
|
+
rest?: number;
|
|
1181
|
+
}): Promise<void>;
|
|
1182
|
+
skip(fn: () => Promise<void>): Promise<void>;
|
|
1183
|
+
card(title: string, o?: {
|
|
1184
|
+
ms?: number;
|
|
1185
|
+
say?: string;
|
|
1186
|
+
url?: boolean;
|
|
1187
|
+
}): Promise<void>;
|
|
1188
|
+
scene(caption: string, fn: () => Promise<void>, o?: {
|
|
1189
|
+
hold?: number;
|
|
1190
|
+
say?: string;
|
|
1191
|
+
}): Promise<void>;
|
|
1192
|
+
}
|
|
1193
|
+
interface Scene {
|
|
1194
|
+
index: number;
|
|
1195
|
+
caption: string;
|
|
1196
|
+
say: string;
|
|
1197
|
+
from: number;
|
|
1198
|
+
to: number;
|
|
1199
|
+
card?: boolean;
|
|
1200
|
+
}
|
|
1201
|
+
interface DirectOptions {
|
|
1202
|
+
/** The script: a module path (its default export) or the function itself. */
|
|
1203
|
+
script: string | ((d: Director) => Promise<void>);
|
|
1204
|
+
/** Where the app runs, e.g. http://127.0.0.1:3000. */
|
|
1205
|
+
url: string;
|
|
1206
|
+
/** The first page (default /). */
|
|
1207
|
+
page?: string;
|
|
1208
|
+
/** The files to write. */
|
|
1209
|
+
out: Array<OutSpec & {
|
|
1210
|
+
format: OutFormat;
|
|
1211
|
+
}>;
|
|
1212
|
+
/** finish() options (the look: lookOptions()). */
|
|
1213
|
+
look?: FinishOptions;
|
|
1214
|
+
/** The cards' small line (the app's name). */
|
|
1215
|
+
appName?: string;
|
|
1216
|
+
/** Page size (default 1280×800). Captured at 2× unless it's the desktop size. */
|
|
1217
|
+
viewport?: {
|
|
1218
|
+
width: number;
|
|
1219
|
+
height: number;
|
|
1220
|
+
};
|
|
1221
|
+
scale?: number;
|
|
1222
|
+
/** Signed in with this session (default: not signed in). */
|
|
1223
|
+
session?: Session;
|
|
1224
|
+
/** Options for a session function, for the first window (a window of its own can pass others). */
|
|
1225
|
+
sessionOptions?: Record<string, unknown>;
|
|
1226
|
+
/** Open the first window signed out (default false). */
|
|
1227
|
+
signedOut?: boolean;
|
|
1228
|
+
alias?: Alias | string;
|
|
1229
|
+
/** Folders served at a path of the app's own address (props the app doesn't have): { '/__terminal': 'dir' }. */
|
|
1230
|
+
routes?: Record<string, string>;
|
|
1231
|
+
/** Narrate with this voice. */
|
|
1232
|
+
voice?: Voice;
|
|
1233
|
+
/** The spoken lines by scene (instead of each caption): a script or its path. */
|
|
1234
|
+
voiceScript?: string | {
|
|
1235
|
+
lines: Array<{
|
|
1236
|
+
n: number;
|
|
1237
|
+
text: string;
|
|
1238
|
+
}>;
|
|
1239
|
+
};
|
|
1240
|
+
/** Write <scenes>: each scene's caption, spoken line and length (JSON). */
|
|
1241
|
+
scenesFile?: string;
|
|
1242
|
+
headless?: boolean;
|
|
1243
|
+
launchArgs?: string[];
|
|
1244
|
+
/** Kept after the script ends (ms, default 800). */
|
|
1245
|
+
tailMs?: number;
|
|
1246
|
+
/** More on `d` for the script's own use (e.g. { app: { dir } }). */
|
|
1247
|
+
props?: Record<string, unknown>;
|
|
1248
|
+
/** An id for messages. */
|
|
1249
|
+
id?: string;
|
|
1250
|
+
log?: (m: string) => void;
|
|
1251
|
+
}
|
|
1252
|
+
interface DirectResult extends RenderResult {
|
|
1253
|
+
narrated: boolean;
|
|
1254
|
+
scenes: Scene[];
|
|
1255
|
+
}
|
|
1256
|
+
/** The alias as its addresses: the public url, the local server, and the API's both. */
|
|
1257
|
+
declare function aliasOf(url: string, alias?: Alias | string): {
|
|
1258
|
+
url: string;
|
|
1259
|
+
local: string | null;
|
|
1260
|
+
api?: string;
|
|
1261
|
+
localApi?: string;
|
|
1262
|
+
rewrite: string[];
|
|
1263
|
+
};
|
|
1264
|
+
/** Make one director video. A script that throws (a failed check) makes nothing. */
|
|
1265
|
+
declare function direct(o: DirectOptions): Promise<DirectResult>;
|
|
1266
|
+
|
|
1267
|
+
declare const CAMPAIGN_KINDS: readonly ["intro", "demo", "guide", "onboarding", "pitch", "whats-new", "ad", "docs-gif", "qa", "support"];
|
|
1268
|
+
declare const CAMPAIGN_SHAPES: readonly ["16:9", "1:1", "4:5", "9:16"];
|
|
1269
|
+
interface CampaignApp {
|
|
1270
|
+
/** Its name, on the cards. */
|
|
1271
|
+
name?: string;
|
|
1272
|
+
/** Where it serves while videos are made, e.g. http://127.0.0.1:3000. */
|
|
1273
|
+
url: string;
|
|
1274
|
+
/** Its checkout (for start, guides, storageState, session). Default: the campaign's folder. */
|
|
1275
|
+
dir?: string;
|
|
1276
|
+
/** How to start it (with --start), run in `dir`. */
|
|
1277
|
+
start?: string[];
|
|
1278
|
+
/** A path that answers once it's ready (default /). */
|
|
1279
|
+
ready?: string;
|
|
1280
|
+
/** Or: a line its start prints once it's ready. */
|
|
1281
|
+
readyText?: string;
|
|
1282
|
+
/** Its guides: { guides: [{ id, trace, pages? }] }. A video's `guide` can be a .trace.json path instead. */
|
|
1283
|
+
guides?: string;
|
|
1284
|
+
/** A signed-in session (Playwright storageState): guides play with it. */
|
|
1285
|
+
storageState?: string;
|
|
1286
|
+
/** A module whose `storageStateFor(url, options)` gives one: director windows use it (a video's `session` is the
|
|
1287
|
+
* first window's options; `d.window(path, options)` passes others), and guides when there is no storageState. */
|
|
1288
|
+
session?: string;
|
|
1289
|
+
/** Put the app back to a known state before each video: POST this (body: the video's `reset`), or run this. */
|
|
1290
|
+
reset?: {
|
|
1291
|
+
post: string;
|
|
1292
|
+
body?: Record<string, unknown>;
|
|
1293
|
+
} | {
|
|
1294
|
+
run: string[];
|
|
1295
|
+
};
|
|
1296
|
+
/** Show it under its public name (https://<host>, answered locally). */
|
|
1297
|
+
alias?: string | Alias;
|
|
1298
|
+
/** Folders served at a path of the app's own address, for director videos: { "/__props": "props" }. */
|
|
1299
|
+
routes?: Record<string, string>;
|
|
1300
|
+
}
|
|
1301
|
+
interface CampaignLook {
|
|
1302
|
+
/** A brand file (--brand): frame, background, cards, watermark … */
|
|
1303
|
+
brand: string;
|
|
1304
|
+
/** What its last card says, for the catalogue. Default: the brand's end card (title and url), else its watermark. */
|
|
1305
|
+
endsWith?: string;
|
|
1306
|
+
}
|
|
1307
|
+
interface CampaignVideo {
|
|
1308
|
+
id: string;
|
|
1309
|
+
kind: (typeof CAMPAIGN_KINDS)[number];
|
|
1310
|
+
/** A guide id (from app.guides) or a .trace.json path … */
|
|
1311
|
+
guide?: string;
|
|
1312
|
+
/** … or a director script (.mjs). */
|
|
1313
|
+
director?: string;
|
|
1314
|
+
/** Guides: overlay (Show me) or perform (Do it for me: clicks and types for real). */
|
|
1315
|
+
mode?: 'overlay' | 'perform';
|
|
1316
|
+
/** Perform: values to type, by field name or label. */
|
|
1317
|
+
values?: Record<string, string>;
|
|
1318
|
+
/** The page it starts on (default: the guide's first page, else /). */
|
|
1319
|
+
page?: string;
|
|
1320
|
+
title?: string;
|
|
1321
|
+
endTitle?: string;
|
|
1322
|
+
/** The looks it's made in (default the first in `looks`). */
|
|
1323
|
+
looks?: string[];
|
|
1324
|
+
/** Its shapes; none for a docs-gif. */
|
|
1325
|
+
shapes?: string[];
|
|
1326
|
+
/** Narrated: a script per look ({ lines: [{ n, text }] }). */
|
|
1327
|
+
voice?: Record<string, string>;
|
|
1328
|
+
/** More renderer flags (--title-card, --camera, --captions-at top …). */
|
|
1329
|
+
polish?: string[];
|
|
1330
|
+
/** What it shows, plainly. */
|
|
1331
|
+
alt: string;
|
|
1332
|
+
/** The body of the app's reset for this video. */
|
|
1333
|
+
reset?: Record<string, unknown>;
|
|
1334
|
+
/** The session function's options for this video. */
|
|
1335
|
+
session?: Record<string, unknown>;
|
|
1336
|
+
/** Start signed out. */
|
|
1337
|
+
signedIn?: boolean;
|
|
1338
|
+
/** A docs-gif's width (default 800). */
|
|
1339
|
+
width?: number;
|
|
1340
|
+
/** Director: a real window (some captures can't run headless). */
|
|
1341
|
+
headed?: boolean;
|
|
1342
|
+
launchArgs?: string[];
|
|
1343
|
+
tailMs?: number;
|
|
1344
|
+
}
|
|
1345
|
+
interface Campaign {
|
|
1346
|
+
product: string;
|
|
1347
|
+
site: string;
|
|
1348
|
+
language?: string;
|
|
1349
|
+
/** The voice for narrated videos (voiceOf: gateway, openai:…, say:…, a .js); --voice wins. */
|
|
1350
|
+
narrator?: string;
|
|
1351
|
+
/** Where files go (default out/<product> beside the file). */
|
|
1352
|
+
out?: string;
|
|
1353
|
+
app: CampaignApp;
|
|
1354
|
+
looks: Record<string, CampaignLook>;
|
|
1355
|
+
videos: CampaignVideo[];
|
|
1356
|
+
[more: string]: unknown;
|
|
1357
|
+
}
|
|
1358
|
+
/** A campaign as loaded: its paths absolute, its file and folder known. */
|
|
1359
|
+
interface LoadedCampaign extends Campaign {
|
|
1360
|
+
file: string;
|
|
1361
|
+
base: string;
|
|
1362
|
+
out: string;
|
|
1363
|
+
}
|
|
1364
|
+
/** One render: a video in one look, desktop or phone. */
|
|
1365
|
+
interface CampaignRender {
|
|
1366
|
+
id: string;
|
|
1367
|
+
video: CampaignVideo;
|
|
1368
|
+
look: string;
|
|
1369
|
+
phone: boolean;
|
|
1370
|
+
shapes: string[];
|
|
1371
|
+
format: OutFormat;
|
|
1372
|
+
polish: string[];
|
|
1373
|
+
}
|
|
1374
|
+
/** Read a campaign file, its paths made absolute. Problems are found by checkCampaign. */
|
|
1375
|
+
declare function loadCampaign(file?: string): LoadedCampaign;
|
|
1376
|
+
/** Every problem in a campaign, at once. `files: false` skips what needs the app's checkout (guides, sessions). */
|
|
1377
|
+
declare function checkCampaign(c: LoadedCampaign, o?: {
|
|
1378
|
+
files?: boolean;
|
|
1379
|
+
}): string[];
|
|
1380
|
+
/** A campaign, loaded and checked: every problem named at once. */
|
|
1381
|
+
declare function readCampaign(file?: string, o?: {
|
|
1382
|
+
files?: boolean;
|
|
1383
|
+
}): LoadedCampaign;
|
|
1384
|
+
/**
|
|
1385
|
+
* The renders a campaign makes: per video and look, one for the desktop shapes (one capture, a file each) and one for
|
|
1386
|
+
* 9:16 (a phone-sized capture). Their ids are <video>--<look>[--phone].
|
|
1387
|
+
*/
|
|
1388
|
+
declare function rendersOf(c: Campaign): CampaignRender[];
|
|
1389
|
+
/** A shape's file tag: '16:9' → '16x9'. */
|
|
1390
|
+
declare const shapeTag: (shape: string) => string;
|
|
1391
|
+
/** What a render writes: [{ key, name, canvas? }]; key is what made.json calls it ('mp4@1:1', 'gif'). */
|
|
1392
|
+
declare function filesOf(r: CampaignRender): Array<{
|
|
1393
|
+
key: string;
|
|
1394
|
+
name: string;
|
|
1395
|
+
format: OutFormat;
|
|
1396
|
+
canvas?: string;
|
|
1397
|
+
}>;
|
|
1398
|
+
/** What a look's videos end with: its own words, else the brand's end card, else its watermark. */
|
|
1399
|
+
declare function endsWithOf(look: CampaignLook, endTitle?: string): string | null;
|
|
1400
|
+
interface Progress {
|
|
1401
|
+
ids: string[];
|
|
1402
|
+
started: string;
|
|
1403
|
+
done: Record<string, string>;
|
|
1404
|
+
failed: Record<string, string>;
|
|
1405
|
+
current: {
|
|
1406
|
+
id: string;
|
|
1407
|
+
n: number;
|
|
1408
|
+
of: number;
|
|
1409
|
+
since: string;
|
|
1410
|
+
} | null;
|
|
1411
|
+
finished: string | null;
|
|
1412
|
+
resumed?: string;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* A run's progress, kept beside its files (<out>/progress.json) so it can be read while it runs, and a run stopped
|
|
1416
|
+
* part way carries on. A run of the same renders that did not finish keeps its done ones, unless `fresh`.
|
|
1417
|
+
*/
|
|
1418
|
+
declare function progressOf(out: string, ids: string[], o?: {
|
|
1419
|
+
fresh?: boolean;
|
|
1420
|
+
}): {
|
|
1421
|
+
file: string;
|
|
1422
|
+
resumed: boolean;
|
|
1423
|
+
isDone: (id: string) => boolean;
|
|
1424
|
+
start(id: string, n: number, of: number): void;
|
|
1425
|
+
done(id: string): void;
|
|
1426
|
+
fail(id: string, why: string): void;
|
|
1427
|
+
finish(): void;
|
|
1428
|
+
readonly state: Progress;
|
|
1429
|
+
};
|
|
1430
|
+
/** A make run's progress in words: what's done, what failed, what it's on now. */
|
|
1431
|
+
declare function statusOf(c: Pick<LoadedCampaign, 'product' | 'out'>, now?: number): string;
|
|
1432
|
+
interface Made {
|
|
1433
|
+
files: Record<string, string>;
|
|
1434
|
+
width?: number;
|
|
1435
|
+
height?: number;
|
|
1436
|
+
seconds?: number;
|
|
1437
|
+
narrated: boolean;
|
|
1438
|
+
video: string;
|
|
1439
|
+
look: string;
|
|
1440
|
+
at: string;
|
|
1441
|
+
}
|
|
1442
|
+
interface MakeOptions {
|
|
1443
|
+
/** Video ids, or render ids (intro--product--phone), to make; default all. */
|
|
1444
|
+
only?: string[];
|
|
1445
|
+
/** Start the app (app.start) if it isn't serving. */
|
|
1446
|
+
start?: boolean;
|
|
1447
|
+
/** Start over instead of carrying on a stopped run. */
|
|
1448
|
+
fresh?: boolean;
|
|
1449
|
+
/** The voice (over the campaign's narrator and TRACE_AVATAR_VOICE). '' makes narrated videos without a voice. */
|
|
1450
|
+
voice?: string | Voice;
|
|
1451
|
+
log?: (m: string) => void;
|
|
1452
|
+
}
|
|
1453
|
+
/** The app serving: already, or started (app.start) and waited for. Returns how to stop what was started. */
|
|
1454
|
+
declare function ensureApp(app: CampaignApp, start: boolean, log?: (m: string) => void): Promise<() => void>;
|
|
1455
|
+
/** Make a campaign's videos (all, or the ids given): files and <out>/made.json. */
|
|
1456
|
+
declare function makeCampaign(c: LoadedCampaign, o?: MakeOptions): Promise<{
|
|
1457
|
+
made: Record<string, Made>;
|
|
1458
|
+
failed: string[];
|
|
1459
|
+
}>;
|
|
1460
|
+
/**
|
|
1461
|
+
* What a render's video says, in order: each scene's caption (narrated: the spoken line) and its cards' lines, from its
|
|
1462
|
+
* <id>.scenes.json (director videos). null when it has none.
|
|
1463
|
+
*/
|
|
1464
|
+
declare function saysOf(c: Pick<LoadedCampaign, 'out'>, renderId: string): string[] | null;
|
|
1465
|
+
|
|
1466
|
+
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, 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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CAMPAIGN_KINDS,
|
|
3
|
+
CAMPAIGN_SHAPES,
|
|
2
4
|
CANVASES,
|
|
3
5
|
CATALOGUE_FORMATS,
|
|
4
6
|
CATALOGUE_KINDS,
|
|
@@ -8,11 +10,15 @@ import {
|
|
|
8
10
|
CORNERS,
|
|
9
11
|
DEFAULT_BACKGROUND,
|
|
10
12
|
DEFAULT_MAX_WAIT_MS,
|
|
13
|
+
DIRECTOR_VIEWPORT,
|
|
11
14
|
GEMINI_TTS,
|
|
12
15
|
RenderError,
|
|
16
|
+
SKIP_KEEP_MS,
|
|
13
17
|
TRACK_RATE,
|
|
14
18
|
ZOOM_KINDS,
|
|
15
19
|
actionsOf,
|
|
20
|
+
aliasOf,
|
|
21
|
+
arrowSprite,
|
|
16
22
|
badgeAt,
|
|
17
23
|
blank,
|
|
18
24
|
brandFile,
|
|
@@ -25,20 +31,28 @@ import {
|
|
|
25
31
|
capture,
|
|
26
32
|
cardFrames,
|
|
27
33
|
cardOf,
|
|
34
|
+
cardsOf,
|
|
28
35
|
catalogueId,
|
|
29
36
|
chapterCues,
|
|
37
|
+
checkCampaign,
|
|
30
38
|
checkCatalogue,
|
|
31
39
|
createGifWriter,
|
|
32
40
|
createLayers,
|
|
33
41
|
crop,
|
|
34
42
|
crossfade,
|
|
35
43
|
cueAt,
|
|
44
|
+
cursorAt,
|
|
36
45
|
dataUri,
|
|
46
|
+
direct,
|
|
47
|
+
drawCursor,
|
|
37
48
|
drawRegion,
|
|
38
49
|
durationOf,
|
|
39
50
|
editList,
|
|
40
51
|
encodeGif,
|
|
41
52
|
encodeMp4,
|
|
53
|
+
endsWithOf,
|
|
54
|
+
ensureApp,
|
|
55
|
+
filesOf,
|
|
42
56
|
findFfmpeg,
|
|
43
57
|
findPlayer,
|
|
44
58
|
finish,
|
|
@@ -50,6 +64,9 @@ import {
|
|
|
50
64
|
geminiVoice,
|
|
51
65
|
layoutOf,
|
|
52
66
|
linesOf,
|
|
67
|
+
loadCampaign,
|
|
68
|
+
lookOptions,
|
|
69
|
+
makeCampaign,
|
|
53
70
|
mix,
|
|
54
71
|
mp4Args,
|
|
55
72
|
mp4Head,
|
|
@@ -61,32 +78,44 @@ import {
|
|
|
61
78
|
pageAt,
|
|
62
79
|
paletteOf,
|
|
63
80
|
parseScript,
|
|
81
|
+
pathOf,
|
|
64
82
|
pickFrames,
|
|
65
83
|
pixel,
|
|
66
84
|
planNarration,
|
|
85
|
+
progressOf,
|
|
67
86
|
providerOf,
|
|
87
|
+
readCampaign,
|
|
68
88
|
render,
|
|
89
|
+
rendersOf,
|
|
69
90
|
repairGuide,
|
|
70
91
|
repairScriptOf,
|
|
71
92
|
resample,
|
|
72
93
|
resize,
|
|
73
94
|
runQa,
|
|
95
|
+
sayFrom,
|
|
74
96
|
sayVoice,
|
|
97
|
+
saysOf,
|
|
98
|
+
shapeTag,
|
|
75
99
|
sourceAt,
|
|
76
100
|
spansOf,
|
|
77
101
|
stallInspector,
|
|
102
|
+
statusOf,
|
|
78
103
|
stepCues,
|
|
79
104
|
suggestScript,
|
|
80
105
|
toVtt,
|
|
81
106
|
toWav,
|
|
107
|
+
travelMs,
|
|
82
108
|
trimSilence,
|
|
83
109
|
voiceOf,
|
|
84
110
|
vttEnds,
|
|
85
111
|
watermarkOf,
|
|
86
112
|
withCards,
|
|
113
|
+
withCursor,
|
|
87
114
|
withHolds
|
|
88
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-MC2ZHX5Z.js";
|
|
89
116
|
export {
|
|
117
|
+
CAMPAIGN_KINDS,
|
|
118
|
+
CAMPAIGN_SHAPES,
|
|
90
119
|
CANVASES,
|
|
91
120
|
CATALOGUE_FORMATS,
|
|
92
121
|
CATALOGUE_KINDS,
|
|
@@ -96,11 +125,15 @@ export {
|
|
|
96
125
|
CORNERS,
|
|
97
126
|
DEFAULT_BACKGROUND,
|
|
98
127
|
DEFAULT_MAX_WAIT_MS,
|
|
128
|
+
DIRECTOR_VIEWPORT,
|
|
99
129
|
GEMINI_TTS,
|
|
100
130
|
RenderError,
|
|
131
|
+
SKIP_KEEP_MS,
|
|
101
132
|
TRACK_RATE,
|
|
102
133
|
ZOOM_KINDS,
|
|
103
134
|
actionsOf,
|
|
135
|
+
aliasOf,
|
|
136
|
+
arrowSprite,
|
|
104
137
|
badgeAt,
|
|
105
138
|
blank,
|
|
106
139
|
brandFile,
|
|
@@ -113,20 +146,28 @@ export {
|
|
|
113
146
|
capture,
|
|
114
147
|
cardFrames,
|
|
115
148
|
cardOf,
|
|
149
|
+
cardsOf,
|
|
116
150
|
catalogueId,
|
|
117
151
|
chapterCues,
|
|
152
|
+
checkCampaign,
|
|
118
153
|
checkCatalogue,
|
|
119
154
|
createGifWriter,
|
|
120
155
|
createLayers,
|
|
121
156
|
crop,
|
|
122
157
|
crossfade,
|
|
123
158
|
cueAt,
|
|
159
|
+
cursorAt,
|
|
124
160
|
dataUri,
|
|
161
|
+
direct,
|
|
162
|
+
drawCursor,
|
|
125
163
|
drawRegion,
|
|
126
164
|
durationOf,
|
|
127
165
|
editList,
|
|
128
166
|
encodeGif,
|
|
129
167
|
encodeMp4,
|
|
168
|
+
endsWithOf,
|
|
169
|
+
ensureApp,
|
|
170
|
+
filesOf,
|
|
130
171
|
findFfmpeg,
|
|
131
172
|
findPlayer,
|
|
132
173
|
finish,
|
|
@@ -138,6 +179,9 @@ export {
|
|
|
138
179
|
geminiVoice,
|
|
139
180
|
layoutOf,
|
|
140
181
|
linesOf,
|
|
182
|
+
loadCampaign,
|
|
183
|
+
lookOptions,
|
|
184
|
+
makeCampaign,
|
|
141
185
|
mix,
|
|
142
186
|
mp4Args,
|
|
143
187
|
mp4Head,
|
|
@@ -149,29 +193,39 @@ export {
|
|
|
149
193
|
pageAt,
|
|
150
194
|
paletteOf,
|
|
151
195
|
parseScript,
|
|
196
|
+
pathOf,
|
|
152
197
|
pickFrames,
|
|
153
198
|
pixel,
|
|
154
199
|
planNarration,
|
|
200
|
+
progressOf,
|
|
155
201
|
providerOf,
|
|
202
|
+
readCampaign,
|
|
156
203
|
render,
|
|
204
|
+
rendersOf,
|
|
157
205
|
repairGuide,
|
|
158
206
|
repairScriptOf,
|
|
159
207
|
resample,
|
|
160
208
|
resize,
|
|
161
209
|
runQa,
|
|
210
|
+
sayFrom,
|
|
162
211
|
sayVoice,
|
|
212
|
+
saysOf,
|
|
213
|
+
shapeTag,
|
|
163
214
|
sourceAt,
|
|
164
215
|
spansOf,
|
|
165
216
|
stallInspector,
|
|
217
|
+
statusOf,
|
|
166
218
|
stepCues,
|
|
167
219
|
suggestScript,
|
|
168
220
|
toVtt,
|
|
169
221
|
toWav,
|
|
222
|
+
travelMs,
|
|
170
223
|
trimSilence,
|
|
171
224
|
voiceOf,
|
|
172
225
|
vttEnds,
|
|
173
226
|
watermarkOf,
|
|
174
227
|
withCards,
|
|
228
|
+
withCursor,
|
|
175
229
|
withHolds
|
|
176
230
|
};
|
|
177
231
|
//# sourceMappingURL=index.js.map
|