@softure-ai/marketing-kit 0.40.0 → 0.42.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +9 -1
  3. package/dist/compose/timeline.d.ts +6 -0
  4. package/dist/compose/timeline.d.ts.map +1 -1
  5. package/dist/compose/timeline.js +9 -1
  6. package/dist/compose/timeline.js.map +1 -1
  7. package/dist/footage/compose.d.ts.map +1 -1
  8. package/dist/footage/compose.js +3 -3
  9. package/dist/footage/compose.js.map +1 -1
  10. package/dist/footage/draft-overlays.d.ts +10 -0
  11. package/dist/footage/draft-overlays.d.ts.map +1 -1
  12. package/dist/footage/draft-overlays.js +45 -15
  13. package/dist/footage/draft-overlays.js.map +1 -1
  14. package/dist/footage/draft-text-width.d.ts +30 -0
  15. package/dist/footage/draft-text-width.d.ts.map +1 -1
  16. package/dist/footage/draft-text-width.js +51 -1
  17. package/dist/footage/draft-text-width.js.map +1 -1
  18. package/dist/footage/draft.d.ts +22 -1
  19. package/dist/footage/draft.d.ts.map +1 -1
  20. package/dist/footage/draft.js +56 -29
  21. package/dist/footage/draft.js.map +1 -1
  22. package/dist/footage/overlay-html.d.ts.map +1 -1
  23. package/dist/footage/overlay-html.js +6 -5
  24. package/dist/footage/overlay-html.js.map +1 -1
  25. package/dist/footage/overlay-schema.d.ts +6 -1
  26. package/dist/footage/overlay-schema.d.ts.map +1 -1
  27. package/dist/footage/overlay-schema.js +8 -2
  28. package/dist/footage/overlay-schema.js.map +1 -1
  29. package/dist/footage/overlays.d.ts +10 -0
  30. package/dist/footage/overlays.d.ts.map +1 -1
  31. package/dist/footage/overlays.js +12 -1
  32. package/dist/footage/overlays.js.map +1 -1
  33. package/dist/index.d.ts +5 -5
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +5 -5
  36. package/dist/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/schema/edl.schema.json +1 -1
  39. package/src/compose/timeline.ts +12 -1
  40. package/src/footage/compose.ts +3 -3
  41. package/src/footage/draft-overlays.ts +61 -15
  42. package/src/footage/draft-text-width.ts +69 -1
  43. package/src/footage/draft.ts +81 -31
  44. package/src/footage/overlay-html.ts +6 -4
  45. package/src/footage/overlay-schema.ts +13 -3
  46. package/src/footage/overlays.ts +12 -0
  47. package/src/index.ts +18 -1
@@ -1,5 +1,6 @@
1
1
  import type { BrandColors } from "../config/colors.js";
2
2
  import { escapeHtml } from "../compose/html.js";
3
+ import { toCssEm } from "../compose/timeline.js";
3
4
  import { getCornerRadiusCss, getStyleBorderCss, getStyleShadowCss, type BrandStyle } from "./brand-style.js";
4
5
  import type { OverlayEntrance } from "./overlay-schema.js";
5
6
  import { HAND_FONT } from "./hand-font.js";
@@ -24,6 +25,7 @@ import {
24
25
  } from "./overlay-motion.js";
25
26
  import {
26
27
  NOTE_LINE_HEIGHT,
28
+ OVERLAY_LETTER_SPACING_EM,
27
29
  OVERLAY_LINE_HEIGHT,
28
30
  OVERLAY_LIST_LINE_HEIGHT,
29
31
  OVERLAY_PADDING_EM,
@@ -108,7 +110,7 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
108
110
  `.ov{position:absolute;display:flex;pointer-events:none}`,
109
111
  `.ov.right{justify-content:flex-end}`,
110
112
  `.ov.center{justify-content:center}`,
111
- `.ov-card{display:flex;align-items:center;gap:.45em;padding:${OVERLAY_PADDING_EM.y}em ${OVERLAY_PADDING_EM.x}em;border-radius:.42em;background:${colors.background};color:${colors.foreground};box-shadow:0 14px 44px rgba(0,0,0,.35);line-height:${OVERLAY_LINE_HEIGHT};font-family:${fonts.interface};font-weight:700;letter-spacing:-.015em;max-width:100%;overflow-wrap:anywhere;transform-origin:0% 100%}`,
113
+ `.ov-card{display:flex;align-items:center;gap:.45em;padding:${OVERLAY_PADDING_EM.y}em ${OVERLAY_PADDING_EM.x}em;border-radius:.42em;background:${colors.background};color:${colors.foreground};box-shadow:0 14px 44px rgba(0,0,0,.35);line-height:${OVERLAY_LINE_HEIGHT};font-family:${fonts.interface};font-weight:700;letter-spacing:${toCssEm(OVERLAY_LETTER_SPACING_EM.card)};max-width:100%;overflow-wrap:anywhere;transform-origin:0% 100%}`,
112
114
  `.ov.right .ov-card{transform-origin:100% 100%}`,
113
115
  `.ov-keyword .ov-card{font-family:${fonts.heading};border-bottom:.12em solid ${colors.accent}}`,
114
116
  `.ov-dot{flex:none;width:.36em;height:.36em;border-radius:50%;background:${colors.accent}}`,
@@ -137,10 +139,10 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
137
139
  `.ov-stack.left .ov-place{justify-content:flex-start}`,
138
140
  `.ov-line{min-height:1lh}`,
139
141
  `.ty .ov-stack:not(.left) .ch{display:none}`,
140
- `.ov-hook-title .ov-line{font-family:${fonts.heading};font-weight:800;letter-spacing:-.02em}`,
142
+ `.ov-hook-title .ov-line{font-family:${fonts.heading};font-weight:800;letter-spacing:${toCssEm(OVERLAY_LETTER_SPACING_EM.hookTitle)}}`,
141
143
  `.ov-place{display:flex;align-items:center;justify-content:center;gap:.25em;font-weight:650;opacity:.92;margin-bottom:.12em}`,
142
144
  `.ov-pin{flex:none;width:1.05em;height:1.05em}`,
143
- `.ov-place-card .ov-line{font-family:${fonts.heading};font-weight:800;line-height:${OVERLAY_TITLE_LINE_HEIGHT};letter-spacing:-.025em}`,
145
+ `.ov-place-card .ov-line{font-family:${fonts.heading};font-weight:800;line-height:${OVERLAY_TITLE_LINE_HEIGHT};letter-spacing:${toCssEm(OVERLAY_LETTER_SPACING_EM.placeTitle)}}`,
144
146
  `.ov-sub{font-weight:600;opacity:.88;margin-top:.12em}`,
145
147
  `.ov-search{width:100%;border-radius:999px;padding:${SEARCH_BAR_PADDING_EM.y}em ${SEARCH_BAR_PADDING_EM.x}em;gap:.5em;font-weight:600;letter-spacing:0;justify-content:flex-start;transform-origin:50% 50%}`,
146
148
  `.ov-glass{flex:none;width:1em;height:1em}`,
@@ -172,7 +174,7 @@ function getOverlayCss(colors: OverlayColors, fonts: { heading: string; interfac
172
174
  `.ov-note .nt{position:absolute;white-space:nowrap;line-height:${NOTE_LINE_HEIGHT}}`,
173
175
  `.ov-note .nw{opacity:0}`,
174
176
  `.ov-note .tick{position:absolute;inset:0;overflow:visible}`,
175
- `.ov-strip .nt{font-family:${fonts.heading};font-weight:800;letter-spacing:.02em}`,
177
+ `.ov-strip .nt{font-family:${fonts.heading};font-weight:800;letter-spacing:${toCssEm(OVERLAY_LETTER_SPACING_EM.strip)}}`,
176
178
  `.ov-hand{font-family:"${HAND_FONT.family}",cursive;font-weight:400}`,
177
179
  `.ov-endword{white-space:nowrap;line-height:${OVERLAY_LINE_HEIGHT};text-shadow:0 3px 10px rgba(0,0,0,.45)}`,
178
180
  // The brand's style (after the kinds' own rules, so it wins over them; the search bar stays a pill).
@@ -220,7 +220,10 @@ export interface EdlOverlay {
220
220
  at_word?: EdlOverlayWord;
221
221
  /** The film second it starts at; give this or `at_word`. */
222
222
  at?: number;
223
- /** Seconds on screen (`MIN_OVERLAY_SECONDS` to `MAX_OVERLAY_SECONDS`; a `hook_title` up to `MAX_HOOK_TITLE_SECONDS`). */
223
+ /**
224
+ * Seconds on screen (`MIN_OVERLAY_SECONDS` to `MAX_OVERLAY_SECONDS`; a `hook_title` up to `MAX_HOOK_TITLE_SECONDS`; a
225
+ * list with `item_words` or `item_at` up to `MAX_OVERLAY_SECONDS` after its last point).
226
+ */
224
227
  duration: number;
225
228
  /** The text of a `keyword`, `lower_third`, `hook_title`, `search_bar`, `place_card` (its title), `date_stamp`, `note` or `end_word`. */
226
229
  text?: string;
@@ -333,6 +336,11 @@ const article = (kind: OverlayKind): string => (/^[aeiou]/.test(kind) ? `an ${ki
333
336
  const hasTwoDecimals = (value: number): boolean => Math.abs(Math.round(value * 100) - value * 100) < 1e-6;
334
337
  const counterNumber = z.number().min(0).max(MAX_OVERLAY_COUNTER_VALUE).refine(hasTwoDecimals, "has more than two decimals");
335
338
 
339
+ /** Whether an overlay is a list whose points come in on their own words (`item_words`) or seconds (`item_at`). */
340
+ export function hasTimedPoints(overlay: Pick<EdlOverlay, "kind" | "item_words" | "item_at">): boolean {
341
+ return overlay.kind === "list" && (overlay.item_words !== undefined || overlay.item_at !== undefined);
342
+ }
343
+
336
344
  /** Every issue of one overlay's fields against its kind. */
337
345
  function checkOverlayFields(overlay: EdlOverlay, issue: (path: string[], message: string) => void): void {
338
346
  const { kind } = overlay;
@@ -342,7 +350,9 @@ function checkOverlayFields(overlay: EdlOverlay, issue: (path: string[], message
342
350
  // Below MIN_END_WORD_SECONDS the field's own minimum refuses it.
343
351
  if (overlay.duration > MAX_END_WORD_SECONDS) issue(["duration"], `an end_word stays ${MIN_END_WORD_SECONDS} to ${MAX_END_WORD_SECONDS} s`);
344
352
  } else if (overlay.duration < MIN_OVERLAY_SECONDS) issue(["duration"], `${article(kind)} stays at least ${MIN_OVERLAY_SECONDS} s (only an end_word stays shorter)`);
345
- else if (kind !== "hook_title" && overlay.duration > MAX_OVERLAY_SECONDS) issue(["duration"], `${article(kind)} stays at most ${MAX_OVERLAY_SECONDS} s (only a hook_title stays longer)`);
353
+ // A list whose points come in on their words or seconds stays up to MAX_OVERLAY_SECONDS after its last point, which
354
+ // only the resolution knows (`resolveEdlOverlays`); every other overlay but a hook title from its start.
355
+ else if (kind !== "hook_title" && !hasTimedPoints(overlay) && overlay.duration > MAX_OVERLAY_SECONDS) issue(["duration"], `${article(kind)} stays at most ${MAX_OVERLAY_SECONDS} s (only a hook_title stays longer)`);
346
356
  if (fields.text === "required" && overlay.text === undefined) issue(["text"], `${article(kind)} needs its text`);
347
357
  if (fields.text === "none" && overlay.text !== undefined) issue(["text"], `${article(kind)} draws no text; leave it out`);
348
358
  const limit = TEXT_LIMITS[kind];
@@ -428,7 +438,7 @@ export const overlaySchema = z
428
438
  .number()
429
439
  .min(MIN_END_WORD_SECONDS)
430
440
  .max(MAX_HOOK_TITLE_SECONDS)
431
- .describe(`Seconds on screen (${MIN_OVERLAY_SECONDS}-${MAX_OVERLAY_SECONDS}; a hook_title up to ${MAX_HOOK_TITLE_SECONDS}; an end_word ${MIN_END_WORD_SECONDS}-${MAX_END_WORD_SECONDS}).`),
441
+ .describe(`Seconds on screen (${MIN_OVERLAY_SECONDS}-${MAX_OVERLAY_SECONDS}; a hook_title up to ${MAX_HOOK_TITLE_SECONDS}; an end_word ${MIN_END_WORD_SECONDS}-${MAX_END_WORD_SECONDS}; a list with item_words or item_at up to ${MAX_OVERLAY_SECONDS} after its last point).`),
432
442
  text: overlayText
433
443
  .optional()
434
444
  .describe(
@@ -6,6 +6,7 @@ import { getFootageEdit, type FootageFilm } from "./film.js";
6
6
  import { FOOTAGE_FPS } from "./normalize.js";
7
7
  import {
8
8
  DEFAULT_OVERLAY_TYPING_SPEED,
9
+ MAX_OVERLAY_SECONDS,
9
10
  isTypedOverlay,
10
11
  type EdlOverlay,
11
12
  type EdlOverlayColors,
@@ -106,6 +107,11 @@ export const LIST_CHIP_MIN_FONT_SIZE = 36;
106
107
  export const LIST_CHIP_CENTRED_MIN_FONT_SIZE = 32;
107
108
  /** A place card title's line height, tighter for its big type. */
108
109
  export const OVERLAY_TITLE_LINE_HEIGHT = 1.05;
110
+ /**
111
+ * The render's letter spacing, in em: every card's text (`card`), a hook title's and a place card's title lines, and a
112
+ * paper strip's capitals. The draft spaces its letters the same (`\\fsp`) and measures its lines with it.
113
+ */
114
+ export const OVERLAY_LETTER_SPACING_EM = { card: -0.015, hookTitle: -0.02, placeTitle: -0.025, strip: 0.02 } as const;
109
115
  export const OVERLAY_PADDING_EM = { x: 0.6, y: 0.35 } as const;
110
116
  /** The search field's padding round its query, in font sizes (its height is the line plus twice this). */
111
117
  export const SEARCH_BAR_PADDING_EM = { x: 0.7, y: 0.55 } as const;
@@ -603,6 +609,12 @@ export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlay
603
609
  return;
604
610
  }
605
611
  const times = overlay.item_at ?? (overlay.item_words === undefined ? undefined : said.map((word) => (word as { start: number }).start));
612
+ // A list with timed points stays at most MAX_OVERLAY_SECONDS after its last point is said (RV-187 of an adopting app).
613
+ const lastPoint = times === undefined ? null : r3(Math.max(start, ...times));
614
+ if (lastPoint !== null && end - lastPoint > MAX_OVERLAY_SECONDS + 0.001) {
615
+ problems.push(`${at}: a list stays at most ${MAX_OVERLAY_SECONDS} s after its last point (said at ${lastPoint} s); it ends at ${end} s, ${r1(end - lastPoint)} s after it`);
616
+ return;
617
+ }
606
618
  // The first point comes in with the card, so the card never stands empty (RV-144 of an adopting app).
607
619
  placed.overlay.itemStarts = getListItemStarts({ start, end, count: placed.overlay.items.length, ...(times === undefined ? {} : { words: times }) }).map((at, item) => (item === 0 ? start : at));
608
620
  }
package/src/index.ts CHANGED
@@ -116,6 +116,7 @@ export {
116
116
  OVERLAY_SIDES,
117
117
  OVERLAY_SIZES,
118
118
  isTypedOverlay,
119
+ hasTimedPoints,
119
120
  type EdlOverlay,
120
121
  type EdlOverlayAnchor,
121
122
  type EdlOverlayColors,
@@ -156,11 +157,22 @@ export {
156
157
  type StylePadding,
157
158
  type StyleShadow,
158
159
  } from "./footage/brand-style.js";
159
- export { createDraftTextMeasure, wrapDraftLine, type DraftTextMeasure } from "./footage/draft-text-width.js";
160
+ export {
161
+ createDraftFont,
162
+ createDraftTextMeasure,
163
+ getSpacingWidth,
164
+ toDraftAssSize,
165
+ toDraftSpacing,
166
+ withLetterSpacing,
167
+ wrapDraftLine,
168
+ type DraftFont,
169
+ type DraftTextMeasure,
170
+ } from "./footage/draft-text-width.js";
160
171
  export { HAND_FONT } from "./footage/hand-font.js";
161
172
  export {
162
173
  OVERLAY_FONT_ROLES,
163
174
  OVERLAY_FONT_SIZES,
175
+ OVERLAY_LETTER_SPACING_EM,
164
176
  OVERLAY_SUBTITLE_SCALES,
165
177
  MIN_OVERLAY_SUBTITLE_PX,
166
178
  OVERLAY_TITLE_SHRINK,
@@ -277,7 +289,10 @@ export { describeVoiceoverBatch, produceVoiceovers, type VoiceoverBatchItem, typ
277
289
  export { getPlaceholderKey, isPlaceholderKey, makePlaceholderWords, writePlaceholderVoiceover, type PlaceholderPace, type WritePlaceholderOptions } from "./voice/placeholder.js";
278
290
  export {
279
291
  BROWSER_BAR_HEIGHT,
292
+ CAPTION_LETTER_SPACING_EM,
280
293
  CAPTION_LINE_HEIGHT,
294
+ CAPTION_RIBBON_LETTER_SPACING_EM,
295
+ toCssEm,
281
296
  CAPTION_PILL_PADDING,
282
297
  DEVICE_KINDS,
283
298
  LAYOUTS,
@@ -686,6 +701,8 @@ export {
686
701
  FOOTAGE_DRAFT_OVERLAY_COLORS,
687
702
  FOOTAGE_DRAFT_FONT,
688
703
  FOOTAGE_DRAFT_WIDTH,
704
+ loadFootageDraftFonts,
705
+ type FootageDraftFonts,
689
706
  buildFootageDraftArgs,
690
707
  buildFootageDraftCaptions,
691
708
  buildFootageDraftJoinArgs,