@contractspec/example.video-marketing-clip 2.1.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.
@@ -0,0 +1,79 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Generate Marketing Clip -- End-to-end video generation from a content brief
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import type { ContentBrief } from '@contractspec/lib.content-gen/types';
6
+ import { VideoGenerator } from '@contractspec/lib.video-gen/generators';
7
+ import { VIDEO_FORMATS } from '@contractspec/lib.video-gen/design/layouts';
8
+ import type {
9
+ VideoBrief,
10
+ VideoFormat,
11
+ } from '@contractspec/lib.video-gen/types';
12
+ import type { VideoProject } from '@contractspec/lib.video-gen/types';
13
+
14
+ /** Supported social format keys. */
15
+ export type SocialFormat = 'landscape' | 'square' | 'portrait';
16
+
17
+ const FORMAT_MAP: Record<SocialFormat, VideoFormat> = {
18
+ landscape: VIDEO_FORMATS.landscape,
19
+ square: VIDEO_FORMATS.square,
20
+ portrait: VIDEO_FORMATS.portrait,
21
+ };
22
+
23
+ /**
24
+ * Generate a marketing video project from a content brief.
25
+ *
26
+ * This is the main handler demonstrating the deterministic video-gen pipeline:
27
+ * 1. Wrap the ContentBrief in a VideoBrief with format + duration config
28
+ * 2. Use VideoGenerator (no LLM) to plan scenes and assemble the project
29
+ * 3. Return the VideoProject (scene graph ready for rendering)
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { generateMarketingClip } from "@contractspec/example.video-marketing-clip/generate-clip";
34
+ * import { productLaunchBrief } from "@contractspec/example.video-marketing-clip/briefs";
35
+ *
36
+ * const project = await generateMarketingClip(productLaunchBrief, "landscape");
37
+ * console.log(project.scenes.length); // 5
38
+ * ```
39
+ */
40
+ export async function generateMarketingClip(
41
+ brief: ContentBrief,
42
+ format: SocialFormat = 'landscape',
43
+ targetDurationSeconds?: number
44
+ ): Promise<VideoProject> {
45
+ const generator = new VideoGenerator({ fps: 30 });
46
+
47
+ const videoBrief: VideoBrief = {
48
+ content: brief,
49
+ format: FORMAT_MAP[format],
50
+ targetDurationSeconds,
51
+ };
52
+
53
+ return generator.generate(videoBrief);
54
+ }
55
+
56
+ /**
57
+ * Generate video projects for all three social formats from a single brief.
58
+ *
59
+ * Returns landscape, square, and portrait variants -- useful for
60
+ * cross-platform social media campaigns.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const variants = await generateAllFormats(productLaunchBrief, 30);
65
+ * // variants.landscape, variants.square, variants.portrait
66
+ * ```
67
+ */
68
+ export async function generateAllFormats(
69
+ brief: ContentBrief,
70
+ targetDurationSeconds?: number
71
+ ): Promise<Record<SocialFormat, VideoProject>> {
72
+ const [landscape, square, portrait] = await Promise.all([
73
+ generateMarketingClip(brief, 'landscape', targetDurationSeconds),
74
+ generateMarketingClip(brief, 'square', targetDurationSeconds),
75
+ generateMarketingClip(brief, 'portrait', targetDurationSeconds),
76
+ ]);
77
+
78
+ return { landscape, square, portrait };
79
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './briefs';
2
+ export * from './generate-clip';
3
+
4
+ export { default as example } from './example';
5
+
6
+ import './docs';
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@contractspec/tool.typescript/react-library.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules", "dist"],
5
+ "compilerOptions": {
6
+ "rootDir": "src",
7
+ "outDir": "dist"
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ import { moduleLibrary } from '@contractspec/tool.bun';
2
+
3
+ export default { ...moduleLibrary };