trace-avatar-render 0.2.1 → 0.2.3
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,6 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.2.
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
- A director that fails leaves a screenshot of the page it was on: `failShot` in `direct()`; campaigns write `<out>/<render>.failed.png` (and remove a stale one when the render is made again).
|
|
6
|
+
|
|
7
|
+
## 0.2.2
|
|
8
|
+
|
|
9
|
+
- A director card that shows the product's address (`card(title, { url: true })`) now records its caption with
|
|
10
|
+
the address ("For more info visit acme.com"), so a video's words (`saysOf`, a catalogue entry's `says`) no longer
|
|
11
|
+
end on "visit". Its spoken line, and the captions file (cards have no cue), are unchanged. `cardCaption()` is
|
|
12
|
+
exported.
|
|
13
|
+
- Director videos captured at any size but 1280×800 (phone cuts, and 16:9 when the brand fills it) drew the cursor
|
|
14
|
+
at twice its place: Chrome's screencast sent the frames at 1× though the page was at scale 2. The frame scale is
|
|
15
|
+
now measured from the frames (`frameScale()`, exported), so the cursor and click ring land on what is clicked.
|
|
16
|
+
|
|
17
|
+
## 0.2.1
|
|
4
18
|
|
|
5
19
|
- **`fill`**: a brand's `"fill": ["16:9"]` or `--fill <shape>` makes outputs of that shape fill the picture: no window, no
|
|
6
20
|
safe margins. A capture of the same shape (e.g. `--viewport 1280x720`) fills it exactly; another is fitted inside it.
|
|
@@ -2243,6 +2243,11 @@ function cursorAt(moves, t) {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
return moves[moves.length - 1];
|
|
2245
2245
|
}
|
|
2246
|
+
function frameScale(shots, viewportWidth, fallback = 1) {
|
|
2247
|
+
if (!shots.length || !viewportWidth) return fallback;
|
|
2248
|
+
const p = PNG3.sync.read(shots[0].png);
|
|
2249
|
+
return p.width / viewportWidth;
|
|
2250
|
+
}
|
|
2246
2251
|
function withCursor(shots, moves, clicks, o = {}) {
|
|
2247
2252
|
if (!shots.length) return [];
|
|
2248
2253
|
const sprite = o.sprite ?? arrowSprite((o.scale ?? 1) * CURSOR_SIZE);
|
|
@@ -2332,6 +2337,9 @@ function lookOptions(video, brand, appName = "") {
|
|
|
2332
2337
|
if (title || end) o.cards = { ...title ? { title } : {}, ...end ? { end } : {} };
|
|
2333
2338
|
return o;
|
|
2334
2339
|
}
|
|
2340
|
+
function cardCaption(title, url) {
|
|
2341
|
+
return url ? `${title.trim().replace(/[\s:,]+$/, "")} ${url}` : title;
|
|
2342
|
+
}
|
|
2335
2343
|
function cardsOf(cards, finishCards = {}, appName = "") {
|
|
2336
2344
|
const { title: _t, url, ...look } = finishCards?.end ?? finishCards?.title ?? { sub: appName };
|
|
2337
2345
|
return cards.map((c) => ({ t: c.t, ms: c.ms, step: c.step, card: { ...look, title: c.title, ...c.url && url ? { url } : {} } }));
|
|
@@ -2543,7 +2551,15 @@ async function direct(o) {
|
|
|
2543
2551
|
playAt = Date.now();
|
|
2544
2552
|
events.push({ t: playAt, type: "play", url: path() });
|
|
2545
2553
|
log(`${id}: playing \u2026`);
|
|
2546
|
-
|
|
2554
|
+
try {
|
|
2555
|
+
await script(d);
|
|
2556
|
+
} catch (e) {
|
|
2557
|
+
if (o.failShot) {
|
|
2558
|
+
await d.page.screenshot({ path: o.failShot }).then(() => log(`${id}: the page when it failed: ${o.failShot}`), () => {
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
throw e;
|
|
2562
|
+
}
|
|
2547
2563
|
await sleep3(o.tailMs ?? 800);
|
|
2548
2564
|
moves.push({ t: Date.now(), ...at });
|
|
2549
2565
|
await cdp.send("Page.stopScreencast").catch(() => {
|
|
@@ -2559,10 +2575,16 @@ async function direct(o) {
|
|
|
2559
2575
|
events.push({ t: stopAt, type: "end" });
|
|
2560
2576
|
shots.sort((a, b) => a.t - b.t);
|
|
2561
2577
|
log(`${id}: ${scenes.length} scenes, ${shots.length} screencast frames; drawing the cursor \u2026`);
|
|
2562
|
-
const
|
|
2563
|
-
const
|
|
2578
|
+
const kept = shots.filter((s) => s.t >= playAt - 400);
|
|
2579
|
+
const scale = frameScale(kept, VP.width, DSF);
|
|
2580
|
+
const frames = withCursor(kept, moves, clicks, { scale });
|
|
2581
|
+
const cap = { frames, viewport: { w: VP.width, h: VP.height, scale }, titles, events, playAt, stopAt, endAt: stopAt };
|
|
2564
2582
|
const f = { ...o.look ?? {}, cuts: { maxWaitMs: skipped ? SKIP_KEEP_MS : 0 } };
|
|
2565
|
-
if (cards.length)
|
|
2583
|
+
if (cards.length) {
|
|
2584
|
+
const resolved = cardsOf(cards, f.cards, o.appName);
|
|
2585
|
+
cap.cards = resolved;
|
|
2586
|
+
for (const c of resolved) if (c.card.url && scenes[c.step]) scenes[c.step].caption = cardCaption(c.card.title, c.card.url);
|
|
2587
|
+
}
|
|
2566
2588
|
let narrated = false;
|
|
2567
2589
|
if (o.voice) {
|
|
2568
2590
|
const lines = /* @__PURE__ */ new Map();
|
|
@@ -2898,6 +2920,7 @@ async function makeCampaign(c, o = {}) {
|
|
|
2898
2920
|
const outBase = join4(c.out, r.id);
|
|
2899
2921
|
const firstBase = join4(c.out, outs[0].name.replace(/\.[^.]+$/, ""));
|
|
2900
2922
|
for (const b of [outBase, firstBase]) for (const ext of ["vtt", "chapters.vtt", "png", "scenes.json"]) rmSync3(`${b}.${ext}`, { force: true });
|
|
2923
|
+
rmSync3(join4(c.out, `${r.id}.failed.png`), { force: true });
|
|
2901
2924
|
const look = c.looks[r.look];
|
|
2902
2925
|
const script = v.voice?.[r.look];
|
|
2903
2926
|
const fill = (existsSync5(look.brand) ? brandFile(look.brand).fill : void 0) ?? [];
|
|
@@ -2918,6 +2941,7 @@ async function makeCampaign(c, o = {}) {
|
|
|
2918
2941
|
url: c.app.url,
|
|
2919
2942
|
page: v.page ?? "/",
|
|
2920
2943
|
appName: c.app.name ?? "",
|
|
2944
|
+
failShot: join4(c.out, `${r.id}.failed.png`),
|
|
2921
2945
|
out: outs.map((x) => ({ file: join4(c.out, x.name), format: x.format, ...x.canvas ? { canvas: x.canvas } : {}, ...x.format === "gif" ? { width: v.width ?? 800 } : {} })),
|
|
2922
2946
|
look: lookOptions({ title: v.title, endTitle: v.endTitle, polish: r.polish }, look.brand, c.app.name ?? ""),
|
|
2923
2947
|
...r.phone ? { viewport: tall ? TALL : { width: 390, height: 844 } } : wide ? { viewport: WIDE } : {},
|
|
@@ -3558,11 +3582,13 @@ export {
|
|
|
3558
3582
|
arrowSprite,
|
|
3559
3583
|
drawCursor,
|
|
3560
3584
|
cursorAt,
|
|
3585
|
+
frameScale,
|
|
3561
3586
|
withCursor,
|
|
3562
3587
|
pathOf,
|
|
3563
3588
|
travelMs,
|
|
3564
3589
|
sayFrom,
|
|
3565
3590
|
lookOptions,
|
|
3591
|
+
cardCaption,
|
|
3566
3592
|
cardsOf,
|
|
3567
3593
|
aliasOf,
|
|
3568
3594
|
direct,
|
|
@@ -3586,4 +3612,4 @@ export {
|
|
|
3586
3612
|
makeCampaign,
|
|
3587
3613
|
saysOf
|
|
3588
3614
|
};
|
|
3589
|
-
//# sourceMappingURL=chunk-
|
|
3615
|
+
//# sourceMappingURL=chunk-I4LM2D2B.js.map
|