@softure-ai/marketing-kit 0.28.0 → 0.31.0
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 +35 -0
- package/README.md +23 -3
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +1 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +6 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/footage/caption-highlight.d.ts +23 -3
- package/dist/footage/caption-highlight.d.ts.map +1 -1
- package/dist/footage/caption-highlight.js +23 -2
- package/dist/footage/caption-highlight.js.map +1 -1
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +15 -6
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/draft-boxes.d.ts +3 -1
- package/dist/footage/draft-boxes.d.ts.map +1 -1
- package/dist/footage/draft-boxes.js +3 -2
- package/dist/footage/draft-boxes.js.map +1 -1
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +191 -41
- package/dist/footage/draft-overlays.js.map +1 -1
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +40 -5
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/edl.d.ts +27 -0
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/film.d.ts +15 -3
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +7 -2
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/overlay-html.d.ts +8 -0
- package/dist/footage/overlay-html.d.ts.map +1 -1
- package/dist/footage/overlay-html.js +127 -29
- package/dist/footage/overlay-html.js.map +1 -1
- package/dist/footage/overlay-motion.d.ts +107 -0
- package/dist/footage/overlay-motion.d.ts.map +1 -0
- package/dist/footage/overlay-motion.js +129 -0
- package/dist/footage/overlay-motion.js.map +1 -0
- package/dist/footage/overlay-schema.d.ts +63 -2
- package/dist/footage/overlay-schema.d.ts.map +1 -1
- package/dist/footage/overlay-schema.js +70 -5
- package/dist/footage/overlay-schema.js.map +1 -1
- package/dist/footage/overlays.d.ts +16 -1
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +43 -12
- package/dist/footage/overlays.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schema/edl.schema.json +82 -1
- package/schema/marketing.schema.json +12 -2
- package/src/config/config.ts +1 -0
- package/src/config/schema.ts +6 -2
- package/src/footage/caption-highlight.ts +27 -5
- package/src/footage/compose.ts +15 -5
- package/src/footage/draft-boxes.ts +7 -3
- package/src/footage/draft-overlays.ts +224 -42
- package/src/footage/draft.ts +52 -6
- package/src/footage/film.ts +17 -3
- package/src/footage/overlay-html.ts +148 -27
- package/src/footage/overlay-motion.ts +157 -0
- package/src/footage/overlay-schema.ts +90 -5
- package/src/footage/overlays.ts +70 -16
- package/src/index.ts +28 -0
|
@@ -46,12 +46,37 @@ export const OVERLAY_ALIGNED_KINDS: readonly OverlayKind[] = ["hook_title", "pla
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* How an overlay enters: `fade` in place, `slide` up into place, `type` letter by letter (text kinds), `none` (it is
|
|
49
|
-
* simply there)
|
|
49
|
+
* simply there), `pop` (grows from 92 % to 100 % while it fades in, eased out, never past its size), `rise` (up from
|
|
50
|
+
* 5 % of the frame's height while it fades in), `blur` (from a slight blur to sharp) or `wipe` (its card revealed from
|
|
51
|
+
* the left in the accent colour, then its text). Without one, the kind's own entrance. Never a bounce or an overshoot:
|
|
52
|
+
* the reel stays natural (`overlay-motion.ts`).
|
|
50
53
|
*/
|
|
51
|
-
export const OVERLAY_ENTRANCES = ["fade", "slide", "type", "none"] as const;
|
|
54
|
+
export const OVERLAY_ENTRANCES = ["fade", "slide", "type", "none", "pop", "rise", "blur", "wipe"] as const;
|
|
52
55
|
|
|
53
56
|
export type OverlayEntrance = (typeof OVERLAY_ENTRANCES)[number];
|
|
54
57
|
|
|
58
|
+
/**
|
|
59
|
+
* How an overlay leaves over its last moment: `auto` mirrors its entrance (a pop shrinks a little as it fades, a rise
|
|
60
|
+
* sinks, a blur blurs, a wipe is wiped off to the right; the kind's own exit without an entrance), `fade`, `slide`
|
|
61
|
+
* (down and out) or `none` (gone at its end).
|
|
62
|
+
*/
|
|
63
|
+
export const OVERLAY_EXITS = ["auto", "fade", "slide", "none"] as const;
|
|
64
|
+
|
|
65
|
+
export type OverlayExit = (typeof OVERLAY_EXITS)[number];
|
|
66
|
+
|
|
67
|
+
/** The curve of an overlay's entrance and exit: `smooth` (the default, a soft ease-out) or `snappy` (quicker, sharper). */
|
|
68
|
+
export const OVERLAY_EASINGS = ["smooth", "snappy"] as const;
|
|
69
|
+
|
|
70
|
+
export type OverlayEasing = (typeof OVERLAY_EASINGS)[number];
|
|
71
|
+
|
|
72
|
+
/** A place card's pin above its title: `none`, `static` (there with the card) or `drop` (falls a little and stops). */
|
|
73
|
+
export const OVERLAY_PINS = ["none", "static", "drop"] as const;
|
|
74
|
+
|
|
75
|
+
export type OverlayPin = (typeof OVERLAY_PINS)[number];
|
|
76
|
+
|
|
77
|
+
/** The longest a place card's subtitle waits after its title, in seconds. */
|
|
78
|
+
export const MAX_OVERLAY_SUBTITLE_DELAY = 0.6;
|
|
79
|
+
|
|
55
80
|
/** The shortest an overlay stays on screen: shorter does not read. */
|
|
56
81
|
export const MIN_OVERLAY_SECONDS = 1;
|
|
57
82
|
/** The longest an overlay stays on screen (a `hook_title` may stay up to `MAX_HOOK_TITLE_SECONDS`). */
|
|
@@ -121,6 +146,18 @@ export interface EdlOverlayStyle {
|
|
|
121
146
|
align?: OverlayAlign;
|
|
122
147
|
/** A place card's subtitle size: `s`, `m` (about 55 % of the title, the default) or `l`. */
|
|
123
148
|
subtitle_size?: OverlaySize;
|
|
149
|
+
/** How it leaves (`auto` without it: mirrors the entrance). */
|
|
150
|
+
exit?: OverlayExit;
|
|
151
|
+
/** The curve of its entrance and exit (`smooth` without it). */
|
|
152
|
+
easing?: OverlayEasing;
|
|
153
|
+
/** A list's points come in one by one (on their `item_words` when given, else spaced automatically). */
|
|
154
|
+
stagger?: boolean;
|
|
155
|
+
/** Seconds a place card's subtitle waits after its title (0 to `MAX_OVERLAY_SUBTITLE_DELAY`). */
|
|
156
|
+
subtitle_delay?: number;
|
|
157
|
+
/** A place card's accent pin above its title. */
|
|
158
|
+
pin?: OverlayPin;
|
|
159
|
+
/** A keyword's accent bar drawn under the word after it enters. */
|
|
160
|
+
underline?: boolean;
|
|
124
161
|
}
|
|
125
162
|
|
|
126
163
|
export interface EdlOverlay {
|
|
@@ -135,6 +172,10 @@ export interface EdlOverlay {
|
|
|
135
172
|
text?: string;
|
|
136
173
|
/** The `list` points (2 to 4). */
|
|
137
174
|
items?: string[];
|
|
175
|
+
/** A `list`'s words its points come in on, one per point (they come in one by one); give this or `item_at`. */
|
|
176
|
+
item_words?: EdlOverlayWord[];
|
|
177
|
+
/** A `list`'s film seconds its points come in at, one per point; give this or `item_words`. */
|
|
178
|
+
item_at?: number[];
|
|
138
179
|
/** The `arrow` point or the `highlight` rectangle. */
|
|
139
180
|
anchor?: EdlOverlayAnchor;
|
|
140
181
|
/** The place label of a `hook_title` (with a pin) or a `date_stamp`. */
|
|
@@ -201,8 +242,8 @@ export const OVERLAY_POSITIONS_BY_KIND: Partial<Record<OverlayKind, readonly Ove
|
|
|
201
242
|
counter: ["top", "middle", "bottom"],
|
|
202
243
|
};
|
|
203
244
|
|
|
204
|
-
const TEXT_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "type", "none"];
|
|
205
|
-
const BLOCK_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "none"];
|
|
245
|
+
const TEXT_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "type", "none", "pop", "rise", "blur", "wipe"];
|
|
246
|
+
const BLOCK_ENTRANCES: readonly OverlayEntrance[] = ["fade", "slide", "none", "pop", "rise", "blur", "wipe"];
|
|
206
247
|
|
|
207
248
|
/** The entrances a kind may take (none listed: it takes no entrance). */
|
|
208
249
|
export const OVERLAY_ENTRANCES_BY_KIND: Record<OverlayKind, readonly OverlayEntrance[]> = {
|
|
@@ -242,6 +283,15 @@ function checkOverlayFields(overlay: EdlOverlay, issue: (path: string[], message
|
|
|
242
283
|
const limit = TEXT_LIMITS[kind];
|
|
243
284
|
if (limit !== undefined && overlay.text !== undefined && overlay.text.length > limit) issue(["text"], `is longer than ${limit} characters`);
|
|
244
285
|
if (fields.items && overlay.items === undefined) issue(["items"], "a list needs 2 to 4 points");
|
|
286
|
+
if (overlay.item_words !== undefined) {
|
|
287
|
+
if (kind !== "list") issue(["item_words"], `${article(kind)} has no points; leave item_words out`);
|
|
288
|
+
else if (overlay.items !== undefined && overlay.item_words.length !== overlay.items.length) issue(["item_words"], `gives ${overlay.item_words.length} words for ${overlay.items.length} points; one word per point`);
|
|
289
|
+
}
|
|
290
|
+
if (overlay.item_at !== undefined) {
|
|
291
|
+
if (kind !== "list") issue(["item_at"], `${article(kind)} has no points; leave item_at out`);
|
|
292
|
+
else if (overlay.item_words !== undefined) issue(["item_at"], "give item_words or item_at, not both");
|
|
293
|
+
else if (overlay.items !== undefined && overlay.item_at.length !== overlay.items.length) issue(["item_at"], `gives ${overlay.item_at.length} seconds for ${overlay.items.length} points; one second per point`);
|
|
294
|
+
}
|
|
245
295
|
if (!fields.items && overlay.items !== undefined) issue(["items"], `${article(kind)} draws no points; leave them out`);
|
|
246
296
|
if (fields.anchor === "none" && overlay.anchor !== undefined) issue(["anchor"], `${article(kind)} has no anchor; leave it out`);
|
|
247
297
|
if (fields.anchor !== "none" && overlay.anchor === undefined) issue(["anchor"], `${article(kind)} needs its anchor`);
|
|
@@ -274,6 +324,11 @@ function checkOverlayStyle(overlay: EdlOverlay, issue: (path: string[], message:
|
|
|
274
324
|
if (style.corner_radius !== undefined && (kind === "punch_in" || kind === "arrow" || kind === "highlight")) issue(["style", "corner_radius"], `${article(kind)} draws no card; leave corner_radius out`);
|
|
275
325
|
if (style.align !== undefined && !OVERLAY_ALIGNED_KINDS.includes(kind)) issue(["style", "align"], "only a hook_title or a place_card aligns its lines; leave align out");
|
|
276
326
|
if (style.subtitle_size !== undefined && kind !== "place_card") issue(["style", "subtitle_size"], "only a place_card has a subtitle; leave subtitle_size out");
|
|
327
|
+
if (style.subtitle_delay !== undefined && kind !== "place_card") issue(["style", "subtitle_delay"], "only a place_card has a subtitle; leave subtitle_delay out");
|
|
328
|
+
if (style.pin !== undefined && kind !== "place_card") issue(["style", "pin"], "only a place_card draws a pin; leave pin out");
|
|
329
|
+
if (style.stagger !== undefined && kind !== "list") issue(["style", "stagger"], "only a list has points to stagger; leave stagger out");
|
|
330
|
+
if (style.underline !== undefined && kind !== "keyword") issue(["style", "underline"], "only a keyword is underlined; leave underline out");
|
|
331
|
+
if ((style.exit !== undefined || style.easing !== undefined) && kind === "punch_in") issue(["style", style.exit === undefined ? "easing" : "exit"], "a punch_in eases the picture itself; leave exit and easing out");
|
|
277
332
|
if (style.colors === undefined) return;
|
|
278
333
|
if (kind === "punch_in") issue(["style", "colors"], "a punch_in draws nothing to colour; leave colors out");
|
|
279
334
|
if ((kind === "arrow" || kind === "highlight") && (style.colors.card !== undefined || style.colors.text !== undefined)) {
|
|
@@ -310,6 +365,23 @@ export const overlaySchema = z
|
|
|
310
365
|
.max(4, "a list needs 2 to 4 points")
|
|
311
366
|
.optional()
|
|
312
367
|
.describe(`The list's points: 2 to 4, up to ${MAX_OVERLAY_LIST_ITEM_LENGTH} characters each.`),
|
|
368
|
+
item_words: z
|
|
369
|
+
.array(
|
|
370
|
+
z.strictObject({
|
|
371
|
+
text: overlayText.describe("The word as the transcript has it; compared without case and punctuation."),
|
|
372
|
+
occurrence: z.number().int().min(1).optional().describe("Which time the film says it (1 the first, the default)."),
|
|
373
|
+
}),
|
|
374
|
+
)
|
|
375
|
+
.min(2)
|
|
376
|
+
.max(4)
|
|
377
|
+
.optional()
|
|
378
|
+
.describe("A list only: the word each point comes in on, one per point in order; the points come in one by one."),
|
|
379
|
+
item_at: z
|
|
380
|
+
.array(z.number().min(0))
|
|
381
|
+
.min(2)
|
|
382
|
+
.max(4)
|
|
383
|
+
.optional()
|
|
384
|
+
.describe("A list only, in place of item_words: the film second each point comes in at, one per point in order."),
|
|
313
385
|
anchor: z
|
|
314
386
|
.strictObject({
|
|
315
387
|
x: z.number().min(0).describe("Px from the frame's left edge."),
|
|
@@ -344,7 +416,11 @@ export const overlaySchema = z
|
|
|
344
416
|
entrance: z
|
|
345
417
|
.enum(OVERLAY_ENTRANCES)
|
|
346
418
|
.optional()
|
|
347
|
-
.describe(
|
|
419
|
+
.describe(
|
|
420
|
+
"fade, slide, type (text typed in letter by letter), none, pop (92 % to 100 %, no overshoot), rise (up from 5 % of the height), blur (blurred to sharp) or wipe (card revealed from the left in the accent, then the text); without it the kind's own. Never a bounce.",
|
|
421
|
+
),
|
|
422
|
+
exit: z.enum(OVERLAY_EXITS).optional().describe("auto (the default: mirrors the entrance), fade, slide (down and out) or none."),
|
|
423
|
+
easing: z.enum(OVERLAY_EASINGS).optional().describe("smooth (the default) or snappy: the curve of the entrance and the exit."),
|
|
348
424
|
typing_speed: z
|
|
349
425
|
.number()
|
|
350
426
|
.min(MIN_OVERLAY_TYPING_SPEED)
|
|
@@ -365,6 +441,15 @@ export const overlaySchema = z
|
|
|
365
441
|
.describe("The card's corner: none, s, m, l or pill; the brand style's without it (no punch_in, arrow or highlight)."),
|
|
366
442
|
align: z.enum(OVERLAY_ALIGNS).optional().describe("center (the default) or left: how a hook_title's or a place_card's lines sit in their card."),
|
|
367
443
|
subtitle_size: z.enum(OVERLAY_SIZES).optional().describe("s, m (the default, about 55 % of the title) or l: a place_card's subtitle size."),
|
|
444
|
+
stagger: z.boolean().optional().describe("A list only: its points come in one by one (on item_words when given, else spaced automatically)."),
|
|
445
|
+
subtitle_delay: z
|
|
446
|
+
.number()
|
|
447
|
+
.min(0)
|
|
448
|
+
.max(MAX_OVERLAY_SUBTITLE_DELAY)
|
|
449
|
+
.optional()
|
|
450
|
+
.describe(`A place_card only: seconds its subtitle waits after its title (0-${MAX_OVERLAY_SUBTITLE_DELAY}).`),
|
|
451
|
+
pin: z.enum(OVERLAY_PINS).optional().describe("A place_card only: none (the default), static or drop (an accent pin above the title that falls a little and stops)."),
|
|
452
|
+
underline: z.boolean().optional().describe("A keyword only: an accent bar drawn under the word after it enters."),
|
|
368
453
|
})
|
|
369
454
|
.optional()
|
|
370
455
|
.describe("The overlay's look: size, side, position, entrance, typing speed and colours; fonts are the brand's."),
|
package/src/footage/overlays.ts
CHANGED
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
type EdlOverlay,
|
|
11
11
|
type EdlOverlayColors,
|
|
12
12
|
type OverlayAlign,
|
|
13
|
+
type OverlayEasing,
|
|
13
14
|
type OverlayEntrance,
|
|
15
|
+
type OverlayExit,
|
|
14
16
|
type OverlayKind,
|
|
15
17
|
type OverlayPosition,
|
|
16
18
|
type OverlaySide,
|
|
@@ -18,6 +20,7 @@ import {
|
|
|
18
20
|
} from "./overlay-schema.js";
|
|
19
21
|
import { getSegmentZoomEases } from "./compose.js";
|
|
20
22
|
import { normalizeWord } from "./words.js";
|
|
23
|
+
import { getListItemStarts } from "./overlay-motion.js";
|
|
21
24
|
import { STYLE_PADDING_SCALES, type BrandStyle, type CornerRadius } from "./brand-style.js";
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -127,6 +130,10 @@ export interface OverlayLook {
|
|
|
127
130
|
cornerRadius?: CornerRadius | null;
|
|
128
131
|
/** Its card's padding in `OVERLAY_PADDING_EM`s: the brand style's `padding` (`STYLE_PADDING_SCALES`); absent: 1. */
|
|
129
132
|
padScale?: number;
|
|
133
|
+
/** How it leaves (`style.exit`); absent: `auto`, mirroring its entrance. */
|
|
134
|
+
exit?: OverlayExit;
|
|
135
|
+
/** The curve of its entrance and exit (`style.easing`); absent: `smooth`. */
|
|
136
|
+
easing?: OverlayEasing;
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
type Drawn = OverlayBase & OverlayLook;
|
|
@@ -137,14 +144,26 @@ type Drawn = OverlayBase & OverlayLook;
|
|
|
137
144
|
*/
|
|
138
145
|
export type ResolvedOverlay =
|
|
139
146
|
| (OverlayBase & { kind: "punch_in"; scale: number; ease: number })
|
|
140
|
-
| (Drawn & { kind: "keyword"; text: string; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
147
|
+
| (Drawn & { kind: "keyword"; text: string; fontSize: number; side: OverlaySide; box: OverlayBox; underline?: boolean })
|
|
141
148
|
| (Drawn & { kind: "lower_third"; text: string; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
142
|
-
| (Drawn & { kind: "list"; items: string[]; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
149
|
+
| (Drawn & { kind: "list"; items: string[]; fontSize: number; side: OverlaySide; box: OverlayBox; itemStarts?: number[] })
|
|
143
150
|
| (Drawn & { kind: "arrow"; from: OverlayPoint; to: OverlayPoint })
|
|
144
151
|
| (Drawn & { kind: "highlight"; rect: OverlayBox })
|
|
145
152
|
| (Drawn & { kind: "hook_title"; lines: string[]; place: string | null; fontSize: number; placeFontSize: number; align?: OverlayAlign; box: OverlayBox })
|
|
146
153
|
| (Drawn & { kind: "search_bar"; text: string; fontSize: number; box: OverlayBox })
|
|
147
|
-
| (Drawn & {
|
|
154
|
+
| (Drawn & {
|
|
155
|
+
kind: "place_card";
|
|
156
|
+
lines: string[];
|
|
157
|
+
subtitle: string | null;
|
|
158
|
+
fontSize: number;
|
|
159
|
+
subtitleFontSize: number;
|
|
160
|
+
align?: OverlayAlign;
|
|
161
|
+
box: OverlayBox;
|
|
162
|
+
/** Its accent pin above the title (`style.pin`); absent: none. */
|
|
163
|
+
pin?: "static" | "drop";
|
|
164
|
+
/** Seconds its subtitle waits after its title (`style.subtitle_delay`); absent: none. */
|
|
165
|
+
subtitleDelay?: number;
|
|
166
|
+
})
|
|
148
167
|
| (Drawn & { kind: "counter"; value: number; from: number; decimals: number; unit: string | null; fontSize: number; unitFontSize: number; box: OverlayBox })
|
|
149
168
|
| (Drawn & { kind: "date_stamp"; text: string; place: string | null; fontSize: number; placeFontSize: number; side: OverlaySide; box: OverlayBox });
|
|
150
169
|
|
|
@@ -181,14 +200,18 @@ function getCaptionBand(input: ResolveOverlaysInput, segment: number): { top: nu
|
|
|
181
200
|
/** The film second an overlay starts at, or the reason its word cannot be found. */
|
|
182
201
|
function findOverlayStart(overlay: EdlOverlay, words: TimedWord[]): { ok: true; start: number } | { ok: false; error: string } {
|
|
183
202
|
if (overlay.at !== undefined) return { ok: true, start: overlay.at };
|
|
184
|
-
|
|
203
|
+
return findWordStart(overlay.at_word as NonNullable<EdlOverlay["at_word"]>, words, "at_word");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The film second a word of the transcript starts at, or why it is not there (`field` names it in the reason). */
|
|
207
|
+
function findWordStart(wanted: NonNullable<EdlOverlay["at_word"]>, words: TimedWord[], field: string): { ok: true; start: number } | { ok: false; error: string } {
|
|
185
208
|
const key = normalizeWord(wanted.text);
|
|
186
209
|
const occurrence = wanted.occurrence ?? 1;
|
|
187
210
|
const matches = words.filter((word) => normalizeWord(word.text) === key);
|
|
188
211
|
const word = matches[occurrence - 1];
|
|
189
212
|
if (word === undefined) {
|
|
190
213
|
const said = matches.length === 0 ? "the film never says it" : `the film says it ${matches.length} time${matches.length === 1 ? "" : "s"}`;
|
|
191
|
-
return { ok: false, error:
|
|
214
|
+
return { ok: false, error: `${field}: no word "${wanted.text}"${occurrence > 1 ? ` (occurrence ${occurrence})` : ""} in the cut; ${said}` };
|
|
192
215
|
}
|
|
193
216
|
return { ok: true, start: word.start };
|
|
194
217
|
}
|
|
@@ -353,6 +376,16 @@ export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlay
|
|
|
353
376
|
problems.push(`${at}: ${placed.error}`);
|
|
354
377
|
return;
|
|
355
378
|
}
|
|
379
|
+
if (placed.overlay.kind === "list" && (overlay.style?.stagger === true || overlay.item_words !== undefined || overlay.item_at !== undefined)) {
|
|
380
|
+
const said = (overlay.item_words ?? []).map((word, item) => findWordStart(word, input.words, `item_words[${item}]`));
|
|
381
|
+
const missing = said.flatMap((word) => (word.ok ? [] : [word.error]));
|
|
382
|
+
if (missing.length > 0) {
|
|
383
|
+
problems.push(...missing.map((error) => `${at}.${error}`));
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const times = overlay.item_at ?? (overlay.item_words === undefined ? undefined : said.map((word) => (word as { start: number }).start));
|
|
387
|
+
placed.overlay.itemStarts = getListItemStarts({ start, end, count: placed.overlay.items.length, ...(times === undefined ? {} : { words: times }) });
|
|
388
|
+
}
|
|
356
389
|
if (placed.overlay.kind === "punch_in") {
|
|
357
390
|
if (edl.segments[segment]?.motion === "kenburns") {
|
|
358
391
|
problems.push(`${at}: segment "${segmentId}" has a Ken Burns zoom, which owns the picture's scale; put the punch-in on a still segment`);
|
|
@@ -442,11 +475,14 @@ function getPositionTop(region: { top: number; bottom: number }, position: Overl
|
|
|
442
475
|
}
|
|
443
476
|
|
|
444
477
|
function getLook(overlay: EdlOverlay): OverlayLook {
|
|
478
|
+
const style = overlay.style ?? {};
|
|
445
479
|
return {
|
|
446
|
-
entrance:
|
|
447
|
-
typing: isTypedOverlay(overlay) ? (
|
|
448
|
-
colors: { ...
|
|
449
|
-
cornerRadius:
|
|
480
|
+
entrance: style.entrance ?? null,
|
|
481
|
+
typing: isTypedOverlay(overlay) ? (style.typing_speed ?? DEFAULT_OVERLAY_TYPING_SPEED) : null,
|
|
482
|
+
colors: { ...style.colors },
|
|
483
|
+
cornerRadius: style.corner_radius ?? null,
|
|
484
|
+
...(style.exit === undefined || style.exit === "auto" ? {} : { exit: style.exit }),
|
|
485
|
+
...(style.easing === undefined || style.easing === "smooth" ? {} : { easing: style.easing }),
|
|
450
486
|
};
|
|
451
487
|
}
|
|
452
488
|
|
|
@@ -508,7 +544,8 @@ function placeSideText(overlay: EdlOverlay & { kind: "keyword" | "lower_third" |
|
|
|
508
544
|
const box = { left: zone.left + margin, top, width: frame.width - zone.left - zone.right - 2 * margin, height };
|
|
509
545
|
if (overlay.kind === "list") return { ok: true, overlay: { ...drawn, kind: "list", items: overlay.items ?? [], fontSize, side, box } };
|
|
510
546
|
const fields = { text: overlay.text ?? "", fontSize, side, box };
|
|
511
|
-
|
|
547
|
+
if (overlay.kind === "lower_third") return { ok: true, overlay: { ...drawn, kind: "lower_third", ...fields } };
|
|
548
|
+
return { ok: true, overlay: { ...drawn, kind: "keyword", ...fields, ...(overlay.style?.underline === true ? { underline: true } : {}) } };
|
|
512
549
|
}
|
|
513
550
|
|
|
514
551
|
type CardKind = "hook_title" | "search_bar" | "place_card" | "counter" | "date_stamp";
|
|
@@ -584,22 +621,35 @@ type TitleOverlay = Extract<ResolvedOverlay, { kind: "hook_title" | "place_card"
|
|
|
584
621
|
* its pin, the subtitle, each title line) and its height. Its card is this plus the padding, so the draft and the
|
|
585
622
|
* render find the block's left edge and top inside the card from it whatever the title's fitted size.
|
|
586
623
|
*/
|
|
587
|
-
export function getTitleContentSize(input: { kind: TitleOverlay["kind"]; lines: readonly string[]; fontSize: number; second: string | null; secondSize: number
|
|
624
|
+
export function getTitleContentSize(input: { kind: TitleOverlay["kind"]; lines: readonly string[]; fontSize: number; second: string | null; secondSize: number; pin?: boolean }): {
|
|
625
|
+
width: number;
|
|
626
|
+
height: number;
|
|
627
|
+
} {
|
|
588
628
|
const { kind, lines, fontSize, second, secondSize } = input;
|
|
589
629
|
const isHook = kind === "hook_title";
|
|
590
630
|
const secondWidth = second === null ? 0 : estimateTextWidth(second, secondSize) + (isHook ? Math.round(secondSize * 1.1) : 0);
|
|
591
631
|
const lineHeight = isHook ? OVERLAY_LINE_HEIGHT : OVERLAY_TITLE_LINE_HEIGHT;
|
|
592
632
|
return {
|
|
593
|
-
width: Math.max(secondWidth, ...lines.map((line) => estimateTextWidth(line, fontSize))),
|
|
594
|
-
height: lines.length * fontSize * lineHeight + (second === null ? 0 : secondSize * 1.3 + fontSize * 0.12),
|
|
633
|
+
width: Math.max(secondWidth, input.pin === true ? getPlaceCardPinSize(fontSize) : 0, ...lines.map((line) => estimateTextWidth(line, fontSize))),
|
|
634
|
+
height: lines.length * fontSize * lineHeight + (second === null ? 0 : secondSize * 1.3 + fontSize * 0.12) + (input.pin === true ? getPlaceCardPinRow(fontSize) : 0),
|
|
595
635
|
};
|
|
596
636
|
}
|
|
597
637
|
|
|
638
|
+
/** A place card's pin height (and width), in px: half its title's size. */
|
|
639
|
+
export function getPlaceCardPinSize(fontSize: number): number {
|
|
640
|
+
return Math.round(fontSize * 0.5);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/** The row a place card's pin takes above its title: the pin and a small gap. */
|
|
644
|
+
export function getPlaceCardPinRow(fontSize: number): number {
|
|
645
|
+
return getPlaceCardPinSize(fontSize) + Math.round(fontSize * 0.1);
|
|
646
|
+
}
|
|
647
|
+
|
|
598
648
|
/** A resolved title's text block inside its card: its left edge and top, in px of the frame. */
|
|
599
649
|
export function getTitleContentBox(overlay: TitleOverlay): OverlayBox {
|
|
600
650
|
const second = overlay.kind === "hook_title" ? overlay.place : overlay.subtitle;
|
|
601
651
|
const secondSize = overlay.kind === "hook_title" ? overlay.placeFontSize : overlay.subtitleFontSize;
|
|
602
|
-
const size = getTitleContentSize({ kind: overlay.kind, lines: overlay.lines, fontSize: overlay.fontSize, second, secondSize });
|
|
652
|
+
const size = getTitleContentSize({ kind: overlay.kind, lines: overlay.lines, fontSize: overlay.fontSize, second, secondSize, pin: overlay.kind === "place_card" && overlay.pin !== undefined });
|
|
603
653
|
const { box } = overlay;
|
|
604
654
|
return { left: box.left + (box.width - size.width) / 2, top: box.top + (box.height - size.height) / 2, width: size.width, height: size.height };
|
|
605
655
|
}
|
|
@@ -620,11 +670,15 @@ function measureTitle(overlay: EdlOverlay & { kind: "hook_title" | "place_card"
|
|
|
620
670
|
const secondWidth = second === null ? 0 : estimateTextWidth(second, secondSize) + (isHook ? Math.round(secondSize * 1.1) : 0);
|
|
621
671
|
if (secondWidth > room) return tooWide(metrics, isHook ? "place label" : "subtitle");
|
|
622
672
|
const align = overlay.style?.align ?? "center";
|
|
673
|
+
const pin = !isHook && overlay.style?.pin !== undefined && overlay.style.pin !== "none" ? overlay.style.pin : undefined;
|
|
674
|
+
const delay = !isHook && second !== null && overlay.style?.subtitle_delay !== undefined && overlay.style.subtitle_delay > 0 ? overlay.style.subtitle_delay : undefined;
|
|
623
675
|
return {
|
|
624
676
|
ok: true,
|
|
625
677
|
content: {
|
|
626
|
-
...getTitleContentSize({ kind: overlay.kind, lines, fontSize, second, secondSize }),
|
|
627
|
-
fields: isHook
|
|
678
|
+
...getTitleContentSize({ kind: overlay.kind, lines, fontSize, second, secondSize, pin: pin !== undefined }),
|
|
679
|
+
fields: isHook
|
|
680
|
+
? { kind: "hook_title", lines, place: second, fontSize, placeFontSize: secondSize, align }
|
|
681
|
+
: { kind: "place_card", lines, subtitle: second, fontSize, subtitleFontSize: secondSize, align, ...(pin === undefined ? {} : { pin }), ...(delay === undefined ? {} : { subtitleDelay: delay }) },
|
|
628
682
|
},
|
|
629
683
|
};
|
|
630
684
|
}
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,10 @@ export {
|
|
|
63
63
|
CAPTION_HIGHLIGHT_BOX_PADDING_EM,
|
|
64
64
|
CAPTION_HIGHLIGHT_BOX_RADIUS,
|
|
65
65
|
CAPTION_HIGHLIGHT_SECONDS,
|
|
66
|
+
CAPTION_ENTRANCE_SECONDS,
|
|
67
|
+
CAPTION_POP_FROM_SCALE,
|
|
68
|
+
CAPTION_UNDERLINE_EM,
|
|
69
|
+
getCaptionEntranceTween,
|
|
66
70
|
getCaptionHighlight,
|
|
67
71
|
getCaptionHighlightContrast,
|
|
68
72
|
type CaptionHighlightColors,
|
|
@@ -90,8 +94,12 @@ export {
|
|
|
90
94
|
MIN_OVERLAY_TYPING_SPEED,
|
|
91
95
|
OVERLAY_ALIGNED_KINDS,
|
|
92
96
|
OVERLAY_ALIGNS,
|
|
97
|
+
OVERLAY_EASINGS,
|
|
93
98
|
OVERLAY_ENTRANCES,
|
|
94
99
|
OVERLAY_ENTRANCES_BY_KIND,
|
|
100
|
+
OVERLAY_EXITS,
|
|
101
|
+
OVERLAY_PINS,
|
|
102
|
+
MAX_OVERLAY_SUBTITLE_DELAY,
|
|
95
103
|
OVERLAY_KINDS,
|
|
96
104
|
OVERLAY_POSITIONS,
|
|
97
105
|
OVERLAY_POSITIONS_BY_KIND,
|
|
@@ -105,8 +113,11 @@ export {
|
|
|
105
113
|
type EdlOverlayStyle,
|
|
106
114
|
type EdlOverlayWord,
|
|
107
115
|
type OverlayAlign,
|
|
116
|
+
type OverlayEasing,
|
|
108
117
|
type OverlayEntrance,
|
|
118
|
+
type OverlayExit,
|
|
109
119
|
type OverlayKind,
|
|
120
|
+
type OverlayPin,
|
|
110
121
|
type OverlayPosition,
|
|
111
122
|
type OverlaySide,
|
|
112
123
|
type OverlaySize,
|
|
@@ -146,6 +157,8 @@ export {
|
|
|
146
157
|
getDrawnOverlayCard,
|
|
147
158
|
getOverlayBounds,
|
|
148
159
|
getOverlayPadding,
|
|
160
|
+
getPlaceCardPinRow,
|
|
161
|
+
getPlaceCardPinSize,
|
|
149
162
|
getTitleContentBox,
|
|
150
163
|
getTitleContentSize,
|
|
151
164
|
wrapOverlayTitle,
|
|
@@ -160,6 +173,19 @@ export {
|
|
|
160
173
|
type ResolvedOverlay,
|
|
161
174
|
type ResolvedOverlaysResult,
|
|
162
175
|
} from "./footage/overlays.js";
|
|
176
|
+
export {
|
|
177
|
+
OVERLAY_EASES,
|
|
178
|
+
POP_FROM_SCALE,
|
|
179
|
+
RISE_FROM_HEIGHT,
|
|
180
|
+
getEntranceMotion,
|
|
181
|
+
getEntranceScaleAt,
|
|
182
|
+
getExitMotion,
|
|
183
|
+
getListItemStarts,
|
|
184
|
+
type OverlayEase,
|
|
185
|
+
type OverlayEntranceMotion,
|
|
186
|
+
type OverlayExitMotion,
|
|
187
|
+
type OverlayMotionOffset,
|
|
188
|
+
} from "./footage/overlay-motion.js";
|
|
163
189
|
export { resolveBrandColors, type BrandColorsResult } from "./config/brand.js";
|
|
164
190
|
export { readCssColors } from "./config/css-colors.js";
|
|
165
191
|
export { readDesignJsonColors } from "./config/design-json.js";
|
|
@@ -334,6 +360,7 @@ export {
|
|
|
334
360
|
CAPTION_PRESETS,
|
|
335
361
|
CAPTION_STYLES,
|
|
336
362
|
CAPTION_HIGHLIGHT_STYLES,
|
|
363
|
+
CAPTION_ENTRANCES,
|
|
337
364
|
DEFAULT_EDIT,
|
|
338
365
|
DEFAULT_END_CARD_SECONDS,
|
|
339
366
|
DEFAULT_LOGO_END_CARD_FADE_SECONDS,
|
|
@@ -346,6 +373,7 @@ export {
|
|
|
346
373
|
type CaptionPreset,
|
|
347
374
|
type CaptionStyle,
|
|
348
375
|
type CaptionHighlightStyle,
|
|
376
|
+
type CaptionEntrance,
|
|
349
377
|
type FootageEdit,
|
|
350
378
|
type ClipFit,
|
|
351
379
|
type ClipRole,
|