@softure-ai/marketing-kit 0.25.0 → 0.27.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 (79) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +8 -1
  3. package/dist/footage/brand-style.d.ts +57 -0
  4. package/dist/footage/brand-style.d.ts.map +1 -0
  5. package/dist/footage/brand-style.js +49 -0
  6. package/dist/footage/brand-style.js.map +1 -0
  7. package/dist/footage/compose.d.ts +5 -0
  8. package/dist/footage/compose.d.ts.map +1 -1
  9. package/dist/footage/compose.js +10 -3
  10. package/dist/footage/compose.js.map +1 -1
  11. package/dist/footage/draft-boxes.d.ts +32 -0
  12. package/dist/footage/draft-boxes.d.ts.map +1 -0
  13. package/dist/footage/draft-boxes.js +28 -0
  14. package/dist/footage/draft-boxes.js.map +1 -0
  15. package/dist/footage/draft-overlays.d.ts +22 -0
  16. package/dist/footage/draft-overlays.d.ts.map +1 -1
  17. package/dist/footage/draft-overlays.js +39 -9
  18. package/dist/footage/draft-overlays.js.map +1 -1
  19. package/dist/footage/draft-text-width.d.ts +19 -0
  20. package/dist/footage/draft-text-width.d.ts.map +1 -0
  21. package/dist/footage/draft-text-width.js +59 -0
  22. package/dist/footage/draft-text-width.js.map +1 -0
  23. package/dist/footage/draft.d.ts +11 -0
  24. package/dist/footage/draft.d.ts.map +1 -1
  25. package/dist/footage/draft.js +63 -15
  26. package/dist/footage/draft.js.map +1 -1
  27. package/dist/footage/edl.d.ts +7 -0
  28. package/dist/footage/edl.d.ts.map +1 -1
  29. package/dist/footage/edl.js +1 -1
  30. package/dist/footage/edl.js.map +1 -1
  31. package/dist/footage/overlay-html.d.ts +2 -0
  32. package/dist/footage/overlay-html.d.ts.map +1 -1
  33. package/dist/footage/overlay-html.js +16 -5
  34. package/dist/footage/overlay-html.js.map +1 -1
  35. package/dist/footage/overlay-schema.d.ts +10 -0
  36. package/dist/footage/overlay-schema.d.ts.map +1 -1
  37. package/dist/footage/overlay-schema.js +7 -0
  38. package/dist/footage/overlay-schema.js.map +1 -1
  39. package/dist/footage/overlays.d.ts +11 -1
  40. package/dist/footage/overlays.d.ts.map +1 -1
  41. package/dist/footage/overlays.js +45 -5
  42. package/dist/footage/overlays.js.map +1 -1
  43. package/dist/footage/pipeline.d.ts +6 -0
  44. package/dist/footage/pipeline.d.ts.map +1 -1
  45. package/dist/footage/pipeline.js +1 -0
  46. package/dist/footage/pipeline.js.map +1 -1
  47. package/dist/index.d.ts +3 -1
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +3 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/og/character-map.d.ts +2 -0
  52. package/dist/og/character-map.d.ts.map +1 -1
  53. package/dist/og/character-map.js +12 -8
  54. package/dist/og/character-map.js.map +1 -1
  55. package/dist/og/index.d.ts +1 -0
  56. package/dist/og/index.d.ts.map +1 -1
  57. package/dist/og/index.js +1 -0
  58. package/dist/og/index.js.map +1 -1
  59. package/dist/og/photo-cover.d.ts +6 -0
  60. package/dist/og/photo-cover.d.ts.map +1 -1
  61. package/dist/og/photo-cover.js +12 -3
  62. package/dist/og/photo-cover.js.map +1 -1
  63. package/package.json +1 -1
  64. package/schema/edl.schema.json +12 -1
  65. package/src/footage/brand-style.ts +77 -0
  66. package/src/footage/compose.ts +13 -3
  67. package/src/footage/draft-boxes.ts +60 -0
  68. package/src/footage/draft-overlays.ts +43 -10
  69. package/src/footage/draft-text-width.ts +67 -0
  70. package/src/footage/draft.ts +111 -16
  71. package/src/footage/edl.ts +1 -1
  72. package/src/footage/overlay-html.ts +16 -6
  73. package/src/footage/overlay-schema.ts +9 -0
  74. package/src/footage/overlays.ts +44 -5
  75. package/src/footage/pipeline.ts +7 -0
  76. package/src/index.ts +23 -0
  77. package/src/og/character-map.ts +12 -6
  78. package/src/og/index.ts +1 -0
  79. package/src/og/photo-cover.ts +18 -3
package/src/index.ts CHANGED
@@ -108,11 +108,34 @@ export {
108
108
  type OverlaySide,
109
109
  type OverlaySize,
110
110
  } from "./footage/overlay-schema.js";
111
+ export {
112
+ CORNER_RADII,
113
+ CORNER_RADIUS_PX,
114
+ STYLE_BORDER_PX,
115
+ STYLE_BORDERS,
116
+ STYLE_PADDING_SCALES,
117
+ STYLE_PADDINGS,
118
+ STYLE_SHADOW,
119
+ STYLE_SHADOWS,
120
+ getCaptionCornerRadius,
121
+ getCornerRadiusCss,
122
+ getCornerRadiusPx,
123
+ getStyleBorderCss,
124
+ getStylePadding,
125
+ getStyleShadowCss,
126
+ type BrandStyle,
127
+ type CornerRadius,
128
+ type StyleBorder,
129
+ type StylePadding,
130
+ type StyleShadow,
131
+ } from "./footage/brand-style.js";
132
+ export { createDraftTextMeasure, wrapDraftLine, type DraftTextMeasure } from "./footage/draft-text-width.js";
111
133
  export {
112
134
  OVERLAY_FONT_ROLES,
113
135
  OVERLAY_FONT_SIZES,
114
136
  PUNCH_IN_EASE_SECONDS,
115
137
  PUNCH_IN_SCALES,
138
+ findShotBreak,
116
139
  formatOverlayNumber,
117
140
  getDrawnOverlayCard,
118
141
  getOverlayBounds,
@@ -10,6 +10,8 @@ import { err, ok, type OgResult } from "./result.js";
10
10
  */
11
11
  export interface CharacterMap {
12
12
  has(codePoint: number): boolean;
13
+ /** The glyph the code point maps to; 0 (`.notdef`) when the font lacks it or the table is broken there. */
14
+ getGlyph(codePoint: number): number;
13
15
  }
14
16
 
15
17
  /** The raw `cmap` table of a font file, or a reason it has none. */
@@ -70,14 +72,18 @@ function readCmap(table: Buffer): OgResult<CharacterMap> {
70
72
  const format = readUint16(table, start);
71
73
  if (format !== 4 && format !== 12) return err(`the font's character map has format ${format}; Satori reads formats 4 and 12`);
72
74
  const getGlyph = format === 4 ? getFormat4Glyph : getFormat12Glyph;
75
+ const findGlyph = (codePoint: number): number => {
76
+ try {
77
+ return getGlyph(table, start, codePoint);
78
+ } catch (error) {
79
+ if (error instanceof OutOfBounds) return 0;
80
+ throw error;
81
+ }
82
+ };
73
83
  return ok({
84
+ getGlyph: findGlyph,
74
85
  has(codePoint) {
75
- try {
76
- return getGlyph(table, start, codePoint) !== 0;
77
- } catch (error) {
78
- if (error instanceof OutOfBounds) return false;
79
- throw error;
80
- }
86
+ return findGlyph(codePoint) !== 0;
81
87
  },
82
88
  });
83
89
  }
package/src/og/index.ts CHANGED
@@ -79,3 +79,4 @@ export {
79
79
  type HeadlineCtaData,
80
80
  } from "./templates/schemas.js";
81
81
  export { loadMarketingConfig, type LoadConfigResult, type MarketingConfig } from "../config/config.js";
82
+ export { CORNER_RADII, type CornerRadius } from "../footage/brand-style.js";
@@ -12,6 +12,7 @@ import { describeCharacter, findMissingGlyphs } from "./glyphs.js";
12
12
  import { toOpaqueHex, withAlpha } from "./palette.js";
13
13
  import { getCoverCrop, getOrientationMatrix, getOrientedSize, readPhotoInfo, type FocusPoint } from "./photo.js";
14
14
  import { err, ok, type OgResult } from "./result.js";
15
+ import { CORNER_RADII, CORNER_RADIUS_PX, type CornerRadius } from "../footage/brand-style.js";
15
16
 
16
17
  /**
17
18
  * A publish-ready cover for a vertical video from a photo the owner picks: the photo scaled to cover the frame and
@@ -120,6 +121,7 @@ const coverOptionsSchema = z.object({
120
121
  tone: z.enum(["light", "dark"]).optional(),
121
122
  accent: z.boolean().optional(),
122
123
  accentStyle: z.enum(PHOTO_COVER_ACCENT_STYLES).optional(),
124
+ cornerRadius: z.enum(CORNER_RADII).optional(),
123
125
  quality: z.number().int().min(1).max(100).default(PHOTO_COVER_QUALITY),
124
126
  });
125
127
 
@@ -150,6 +152,11 @@ export interface PhotoCoverInput {
150
152
  colors: BrandColors;
151
153
  /** The brand's fonts (`loadOgFonts`); the text is set in the heading (display) family. */
152
154
  fonts: OgFonts;
155
+ /**
156
+ * The brand style's corner (`BrandStyle.cornerRadius`) for the `pill` box and the kicker's accent box, in px of a
157
+ * 1080 px wide band; each layout's own corner by default.
158
+ */
159
+ cornerRadius?: CornerRadius;
153
160
  /** JPEG quality, 1-100; 90 by default. */
154
161
  quality?: number;
155
162
  /** Names the cover in errors, e.g. the video's id. */
@@ -313,6 +320,13 @@ interface TextLayout {
313
320
  text: CoverText;
314
321
  fonts: OgFonts;
315
322
  ink: CoverInk;
323
+ cornerRadius?: CornerRadius;
324
+ }
325
+
326
+ /** A box's corner on the cover: the style's token (a pill as 999 px, which Satori keeps to half the height), else `own`. */
327
+ function getCoverRadius(token: CornerRadius | undefined, own: number, scale: number): number {
328
+ if (token === undefined) return Math.round(own * scale);
329
+ return token === "pill" ? 999 : Math.round(CORNER_RADIUS_PX[token] * scale);
316
330
  }
317
331
 
318
332
  /** Where the text block sits: its foot above the band's lower edge, its head below the band's top, or centred in the middle third. */
@@ -346,7 +360,7 @@ function buildTextTree(layout: TextLayout): OgNode {
346
360
  display: "flex",
347
361
  maxWidth: "100%",
348
362
  padding: `${String(Math.round(PILL_PADDING[0] * scale))}px ${String(Math.round(PILL_PADDING[1] * scale))}px`,
349
- borderRadius: Math.round(PILL_SIZE * scale),
363
+ borderRadius: getCoverRadius(layout.cornerRadius, PILL_SIZE, scale),
350
364
  backgroundColor: withAlpha(ink.pill.box, ink.pill.alpha),
351
365
  textAlign: "center",
352
366
  wordBreak: "break-word",
@@ -371,7 +385,7 @@ function buildTextTree(layout: TextLayout): OgNode {
371
385
  display: "flex",
372
386
  maxWidth: "100%",
373
387
  padding: `${String(Math.round(KICKER_BOX_PADDING[0] * scale))}px ${String(Math.round(KICKER_BOX_PADDING[1] * scale))}px`,
374
- borderRadius: Math.round(KICKER_BOX_RADIUS * scale),
388
+ borderRadius: getCoverRadius(layout.cornerRadius, KICKER_BOX_RADIUS, scale),
375
389
  backgroundColor: ink.kickerBox,
376
390
  textAlign: "center",
377
391
  wordBreak: "break-word",
@@ -523,6 +537,7 @@ export async function renderPhotoCover(input: PhotoCoverInput): Promise<OgResult
523
537
  tone: input.tone,
524
538
  accent: input.accent,
525
539
  accentStyle: input.accentStyle,
540
+ cornerRadius: input.cornerRadius,
526
541
  quality: input.quality,
527
542
  });
528
543
  if (!parsed.success) {
@@ -542,7 +557,7 @@ export async function renderPhotoCover(input: PhotoCoverInput): Promise<OgResult
542
557
  const band = getCoverBand(size);
543
558
  const ink = getCoverInk(input.colors, { tone: options.tone ?? "light", layout: text.value?.layout ?? null, accent: options.accent ?? false, accentStyle: options.accentStyle ?? "text" });
544
559
  if (!ink.ok) return err(`${name}: ${ink.error}.`);
545
- const drawn = text.value === null ? null : await layOutText({ size, band, text: text.value, fonts: input.fonts, ink: ink.value });
560
+ const drawn = text.value === null ? null : await layOutText({ size, band, text: text.value, fonts: input.fonts, ink: ink.value, ...(options.cornerRadius === undefined ? {} : { cornerRadius: options.cornerRadius }) });
546
561
  if (drawn !== null && !drawn.ok) return err(`${name}: ${drawn.error}.`);
547
562
 
548
563
  const oriented = getOrientedSize(info.value);