@mevdragon/vidfarm-devcli 0.2.8 → 0.2.9

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 (98) hide show
  1. package/.env.example +9 -0
  2. package/GETTING_STARTED.developers.md +1 -26
  3. package/README.md +3 -0
  4. package/SKILL.developer.md +327 -4
  5. package/auto-create-templates/AUTO_CREATE_TEMPLATES.md +475 -0
  6. package/auto-create-templates/extractor-system-prompt.md +113 -0
  7. package/auto-create-templates/production-graph.schema.json +276 -0
  8. package/auto-create-templates/runbook.md +140 -0
  9. package/auto-create-templates/template-plan.schema.json +230 -0
  10. package/auto-create-templates/template-planner-prompt.md +75 -0
  11. package/dist/src/account-pages-legacy.js +9064 -0
  12. package/dist/src/account-pages.js +41 -620
  13. package/dist/src/app.js +6627 -244
  14. package/dist/src/cli.js +386 -26
  15. package/dist/src/config.js +12 -2
  16. package/dist/src/context.js +35 -35
  17. package/dist/src/db.js +1016 -53
  18. package/dist/src/dev-app-legacy.js +693 -0
  19. package/dist/src/dev-app.js +4 -904
  20. package/dist/src/domain.js +1 -1
  21. package/dist/src/editor-chat-history.js +72 -0
  22. package/dist/src/editor-chat.js +202 -0
  23. package/dist/src/frontend/flockposter-cache-store.js +116 -0
  24. package/dist/src/frontend/homepage-client.js +114 -0
  25. package/dist/src/frontend/homepage-shared.js +3 -0
  26. package/dist/src/frontend/homepage-store.js +27 -0
  27. package/dist/src/frontend/homepage-view.js +147 -0
  28. package/dist/src/frontend/page-runtime-client.js +100 -0
  29. package/dist/src/frontend/page-runtime-store.js +8 -0
  30. package/dist/src/frontend/template-editor-chat.js +2261 -0
  31. package/dist/src/homepage.js +695 -371
  32. package/dist/src/lib/template-style-options.js +95 -15
  33. package/dist/src/page-runtime.js +1 -0
  34. package/dist/src/page-shell.js +941 -0
  35. package/dist/src/primitive-context.js +163 -0
  36. package/dist/src/primitive-registry.js +340 -0
  37. package/dist/src/primitive-sdk.js +3 -0
  38. package/dist/src/primitives/remotion/html-image.js +28 -0
  39. package/dist/src/react-page-shell.js +34 -0
  40. package/dist/src/ready-post-schedule-component.js +1514 -0
  41. package/dist/src/registry.js +36 -17
  42. package/dist/src/runtime.js +6 -1
  43. package/dist/src/services/api-call-history.js +245 -0
  44. package/dist/src/services/auth.js +25 -3
  45. package/dist/src/services/billing.js +248 -9
  46. package/dist/src/services/chat-threads.js +88 -0
  47. package/dist/src/services/job-logs.js +14 -7
  48. package/dist/src/services/jobs.js +13 -2
  49. package/dist/src/services/providers.js +552 -133
  50. package/dist/src/services/rate-limits.js +236 -0
  51. package/dist/src/services/remotion.js +143 -16
  52. package/dist/src/services/storage.js +10 -8
  53. package/dist/src/services/template-certification.js +11 -2
  54. package/dist/src/services/template-loader.js +3 -1
  55. package/dist/src/services/template-sources.js +68 -3
  56. package/dist/src/template-editor-pages.js +2309 -0
  57. package/dist/src/template-editor-shell.js +1507 -0
  58. package/dist/src/worker.js +120 -22
  59. package/package.json +27 -4
  60. package/public/assets/homepage-app.js +54 -0
  61. package/public/assets/homepage-client-app.js +54 -0
  62. package/public/assets/page-runtime-client-app.js +68 -0
  63. package/dist/templates/vidfarm_template_0000/src/lib/images.js +0 -202
  64. package/dist/templates/vidfarm_template_0000/src/remotion/Root.js +0 -34
  65. package/dist/templates/vidfarm_template_0000/src/remotion/index.js +0 -3
  66. package/dist/templates/vidfarm_template_0000/src/sdk.js +0 -3
  67. package/dist/templates/vidfarm_template_0000/src/style-options.js +0 -51
  68. package/dist/templates/vidfarm_template_0000/src/template-dna.js +0 -9
  69. package/dist/templates/vidfarm_template_0000/src/template.js +0 -1447
  70. package/templates/vidfarm_template_0000/README.md +0 -100
  71. package/templates/vidfarm_template_0000/SKILL.md +0 -225
  72. package/templates/vidfarm_template_0000/assets/Abel-Regular.ttf +0 -0
  73. package/templates/vidfarm_template_0000/assets/DMSerifDisplay-Regular.ttf +0 -0
  74. package/templates/vidfarm_template_0000/assets/Montserrat[wght].ttf +0 -0
  75. package/templates/vidfarm_template_0000/assets/SourceCodePro[wght].ttf +0 -0
  76. package/templates/vidfarm_template_0000/assets/TikTokSans-SemiBold.ttf +0 -0
  77. package/templates/vidfarm_template_0000/assets/Yesteryear-Regular.ttf +0 -0
  78. package/templates/vidfarm_template_0000/composition.json +0 -11
  79. package/templates/vidfarm_template_0000/package.json +0 -27
  80. package/templates/vidfarm_template_0000/research/preview/.gitkeep +0 -1
  81. package/templates/vidfarm_template_0000/research/source_notes.md +0 -7
  82. package/templates/vidfarm_template_0000/src/lib/images.js +0 -202
  83. package/templates/vidfarm_template_0000/src/lib/images.ts +0 -241
  84. package/templates/vidfarm_template_0000/src/remotion/Root.js +0 -33
  85. package/templates/vidfarm_template_0000/src/remotion/Root.tsx +0 -75
  86. package/templates/vidfarm_template_0000/src/remotion/index.js +0 -3
  87. package/templates/vidfarm_template_0000/src/remotion/index.tsx +0 -4
  88. package/templates/vidfarm_template_0000/src/sdk.js +0 -3
  89. package/templates/vidfarm_template_0000/src/sdk.ts +0 -140
  90. package/templates/vidfarm_template_0000/src/style-options.js +0 -51
  91. package/templates/vidfarm_template_0000/src/style-options.ts +0 -60
  92. package/templates/vidfarm_template_0000/src/template-dna.js +0 -9
  93. package/templates/vidfarm_template_0000/src/template-dna.ts +0 -15
  94. package/templates/vidfarm_template_0000/src/template.js +0 -1447
  95. package/templates/vidfarm_template_0000/src/template.ts +0 -2049
  96. package/templates/vidfarm_template_0000/template.config.json +0 -21
  97. package/templates/vidfarm_template_0000/tmp/solobacterium-moorei-slideshow.request.json +0 -31
  98. package/templates/vidfarm_template_0000/tsconfig.json +0 -19
@@ -1,202 +0,0 @@
1
- import sharp from "sharp";
2
- export async function normalizeToPortraitFrame(input, target = { width: 1080, height: 1920 }) {
3
- const buffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
4
- const oriented = sharp(buffer, { density: 144 }).rotate();
5
- const trimmed = await trimFlatBorders(oriented);
6
- const targetAspect = target.width / target.height;
7
- const shouldPreserveFraming = await isCloseToAspect(trimmed, targetAspect, 0.025);
8
- const cropped = shouldPreserveFraming ? trimmed : await cropToActiveImageRegion(trimmed);
9
- const normalized = await resizeWithBlurredContain(cropped, target, targetAspect);
10
- return {
11
- bytes: normalized,
12
- contentType: "image/png",
13
- width: target.width,
14
- height: target.height
15
- };
16
- }
17
- async function resizeWithBlurredContain(image, target, targetAspect) {
18
- const metadata = await image.metadata();
19
- const width = metadata.width ?? 0;
20
- const height = metadata.height ?? 0;
21
- if (!width || !height) {
22
- return image
23
- .resize(target.width, target.height, {
24
- fit: "cover",
25
- position: sharp.strategy.attention
26
- })
27
- .png()
28
- .toBuffer();
29
- }
30
- const aspect = width / height;
31
- if (Math.abs(aspect - targetAspect) <= 0.015) {
32
- return image
33
- .resize(target.width, target.height, {
34
- fit: "fill"
35
- })
36
- .png()
37
- .toBuffer();
38
- }
39
- const foreground = await image
40
- .clone()
41
- .resize(target.width, target.height, {
42
- fit: "contain",
43
- background: { r: 0, g: 0, b: 0, alpha: 0 }
44
- })
45
- .png()
46
- .toBuffer();
47
- const background = await image
48
- .clone()
49
- .resize(target.width, target.height, {
50
- fit: "cover",
51
- position: sharp.strategy.attention
52
- })
53
- .blur(20)
54
- .modulate({ brightness: 0.92, saturation: 0.9 })
55
- .png()
56
- .toBuffer();
57
- return sharp(background)
58
- .composite([{ input: foreground }])
59
- .png()
60
- .toBuffer();
61
- }
62
- async function isCloseToAspect(image, targetAspect, tolerance) {
63
- const metadata = await image.metadata();
64
- const width = metadata.width ?? 0;
65
- const height = metadata.height ?? 0;
66
- if (!width || !height) {
67
- return false;
68
- }
69
- return Math.abs(width / height - targetAspect) <= tolerance;
70
- }
71
- async function trimFlatBorders(image) {
72
- const metadata = await image.metadata();
73
- const sourceWidth = metadata.width ?? 0;
74
- const sourceHeight = metadata.height ?? 0;
75
- if (!sourceWidth || !sourceHeight || sourceWidth < 3 || sourceHeight < 3) {
76
- return image;
77
- }
78
- const { data, info } = await image
79
- .clone()
80
- .trim({ threshold: 16 })
81
- .png()
82
- .toBuffer({ resolveWithObject: true });
83
- const widthRatio = info.width / sourceWidth;
84
- const heightRatio = info.height / sourceHeight;
85
- if (widthRatio > 0.985 && heightRatio > 0.985) {
86
- return image;
87
- }
88
- return sharp(data).rotate();
89
- }
90
- async function cropToActiveImageRegion(image) {
91
- const metadata = await image.metadata();
92
- const sourceWidth = metadata.width ?? 0;
93
- const sourceHeight = metadata.height ?? 0;
94
- if (!sourceWidth || !sourceHeight) {
95
- return image;
96
- }
97
- const sampleWidth = 96;
98
- const sampleHeight = 170;
99
- const sample = await image
100
- .clone()
101
- .resize(sampleWidth, sampleHeight, { fit: "fill" })
102
- .grayscale()
103
- .raw()
104
- .toBuffer();
105
- const bounds = detectActiveBounds(sample, sampleWidth, sampleHeight);
106
- if (!bounds) {
107
- return image;
108
- }
109
- const left = Math.max(0, Math.floor((bounds.left / sampleWidth) * sourceWidth));
110
- const top = Math.max(0, Math.floor((bounds.top / sampleHeight) * sourceHeight));
111
- const width = Math.min(sourceWidth - left, Math.max(1, Math.ceil((bounds.width / sampleWidth) * sourceWidth)));
112
- const height = Math.min(sourceHeight - top, Math.max(1, Math.ceil((bounds.height / sampleHeight) * sourceHeight)));
113
- return image.extract({ left, top, width, height });
114
- }
115
- function detectActiveBounds(sample, width, height) {
116
- const rowActivity = new Array(height).fill(0);
117
- const colActivity = new Array(width).fill(0);
118
- for (let y = 0; y < height; y += 1) {
119
- for (let x = 0; x < width; x += 1) {
120
- const index = y * width + x;
121
- const current = sample[index] ?? 0;
122
- const left = x > 0 ? sample[index - 1] ?? current : current;
123
- const up = y > 0 ? sample[index - width] ?? current : current;
124
- const right = x < width - 1 ? sample[index + 1] ?? current : current;
125
- const down = y < height - 1 ? sample[index + width] ?? current : current;
126
- const energy = Math.abs(current - left) +
127
- Math.abs(current - right) +
128
- Math.abs(current - up) +
129
- Math.abs(current - down);
130
- rowActivity[y] += energy;
131
- colActivity[x] += energy;
132
- }
133
- }
134
- const smoothedRows = smoothSeries(rowActivity.map((value) => value / width), 9);
135
- const smoothedCols = smoothSeries(colActivity.map((value) => value / height), 7);
136
- const rowBounds = findActiveRange(smoothedRows, Math.round(height * 0.18));
137
- const colBounds = findActiveRange(smoothedCols, Math.round(width * 0.16));
138
- if (!rowBounds || !colBounds) {
139
- return null;
140
- }
141
- const topMargin = rowBounds.start / height;
142
- const bottomMargin = (height - rowBounds.end - 1) / height;
143
- const leftMargin = colBounds.start / width;
144
- const rightMargin = (width - colBounds.end - 1) / width;
145
- const croppedWidth = colBounds.end - colBounds.start + 1;
146
- const croppedHeight = rowBounds.end - rowBounds.start + 1;
147
- const croppedAreaRatio = (croppedWidth * croppedHeight) / (width * height);
148
- const significantMargins = topMargin > 0.11 || bottomMargin > 0.11 || leftMargin > 0.08 || rightMargin > 0.08;
149
- if (!significantMargins && croppedAreaRatio > 0.9) {
150
- return null;
151
- }
152
- return {
153
- left: colBounds.start,
154
- top: rowBounds.start,
155
- width: croppedWidth,
156
- height: croppedHeight
157
- };
158
- }
159
- function findActiveRange(values, minSpan) {
160
- const mean = values.reduce((sum, value) => sum + value, 0) / Math.max(values.length, 1);
161
- const max = values.reduce((best, value) => Math.max(best, value), 0);
162
- if (max <= 0) {
163
- return null;
164
- }
165
- const threshold = mean + (max - mean) * 0.18;
166
- let start = 0;
167
- while (start < values.length && values[start] < threshold) {
168
- start += 1;
169
- }
170
- let end = values.length - 1;
171
- while (end >= 0 && values[end] < threshold) {
172
- end -= 1;
173
- }
174
- if (start >= end) {
175
- return null;
176
- }
177
- const desiredSpan = Math.max(minSpan, end - start + 1);
178
- const extra = desiredSpan - (end - start + 1);
179
- const expandStart = Math.floor(extra / 2);
180
- const expandEnd = extra - expandStart;
181
- start = Math.max(0, start - expandStart - 4);
182
- end = Math.min(values.length - 1, end + expandEnd + 4);
183
- return { start, end };
184
- }
185
- function smoothSeries(values, radius) {
186
- return values.map((_, index) => {
187
- let total = 0;
188
- let count = 0;
189
- for (let offset = -radius; offset <= radius; offset += 1) {
190
- const value = values[index + offset];
191
- if (value === undefined) {
192
- continue;
193
- }
194
- total += value;
195
- count += 1;
196
- }
197
- return total / Math.max(count, 1);
198
- });
199
- }
200
- function clamp(value, min, max) {
201
- return Math.min(Math.max(value, min), max);
202
- }
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from "react";
3
- import { AbsoluteFill, Composition, Img, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
4
- export const RemotionRoot = () => {
5
- return (_jsx(Composition, { id: "template-0000", component: TemplateVideo, width: 1080, height: 1920, fps: 30, durationInFrames: 120, defaultProps: { slides: [] }, calculateMetadata: ({ props }) => ({
6
- width: 1080,
7
- height: 1920,
8
- durationInFrames: Math.max(1, sumSlideFrames(props.slides, 30))
9
- }) }));
10
- };
11
- const TemplateVideo = ({ slides }) => {
12
- const { fps } = useVideoConfig();
13
- let currentFrame = 0;
14
- return (_jsx(AbsoluteFill, { style: { backgroundColor: "#120f0b" }, children: slides.map((slide, index) => {
15
- const durationInFrames = msToFrames(slide.durationMs, fps);
16
- const sequence = (_jsx(Sequence, { from: currentFrame, durationInFrames: durationInFrames, children: _jsx(SlideFrame, { slide: slide }) }, `${slide.imageUrl}-${index}`));
17
- currentFrame += durationInFrames;
18
- return sequence;
19
- }) }));
20
- };
21
- const SlideFrame = ({ slide }) => {
22
- const frame = useCurrentFrame();
23
- const { fps } = useVideoConfig();
24
- const entrance = spring({ fps, frame, config: { damping: 200, stiffness: 140 } });
25
- const opacity = interpolate(entrance, [0, 1], [0.35, 1]);
26
- const lift = interpolate(entrance, [0, 1], [22, 0]);
27
- return (_jsxs(AbsoluteFill, { children: [_jsx(AbsoluteFill, { style: { opacity, transform: `translateY(${lift}px)` }, children: _jsx(Img, { src: slide.imageUrl, style: { width: "100%", height: "100%", objectFit: "fill" } }) }), _jsx(AbsoluteFill, { style: { background: "linear-gradient(180deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.06) 36%, rgba(0,0,0,0.34) 100%)" } })] }));
28
- };
29
- function msToFrames(durationMs, fps) {
30
- return Math.max(1, Math.round((durationMs / 1000) * fps));
31
- }
32
- function sumSlideFrames(slides, fps) {
33
- return slides.reduce((total, slide) => total + msToFrames(slide.durationMs, fps), 0);
34
- }
@@ -1,3 +0,0 @@
1
- import { registerRoot } from "remotion";
2
- import { RemotionRoot } from "./Root.js";
3
- registerRoot(RemotionRoot);
@@ -1,3 +0,0 @@
1
- export function defineTemplate(definition) {
2
- return definition;
3
- }
@@ -1,51 +0,0 @@
1
- export const TEMPLATE_FONT_OPTIONS = [
2
- {
3
- id: "source_code_pro",
4
- label: "Source Code Pro",
5
- family: "Source Code Pro",
6
- assetFile: "SourceCodePro[wght].ttf"
7
- },
8
- {
9
- id: "montserrat",
10
- label: "Montserrat",
11
- family: "Montserrat",
12
- assetFile: "Montserrat[wght].ttf"
13
- },
14
- {
15
- id: "yesteryear",
16
- label: "Yesteryear",
17
- family: "Yesteryear",
18
- assetFile: "Yesteryear-Regular.ttf"
19
- },
20
- {
21
- id: "dm_serif_display",
22
- label: "DM Serif Display",
23
- family: "DM Serif Display",
24
- assetFile: "DMSerifDisplay-Regular.ttf"
25
- },
26
- {
27
- id: "abel",
28
- label: "Abel",
29
- family: "Abel",
30
- assetFile: "Abel-Regular.ttf"
31
- }
32
- ];
33
- export const TEMPLATE_TEXT_BACKGROUND_COLOR_OPTIONS = [
34
- { id: "black", label: "Black", hex: "#000000" },
35
- { id: "red", label: "Red", hex: "#EA403F" },
36
- { id: "orange", label: "Orange", hex: "#FF933D" },
37
- { id: "yellow", label: "Yellow", hex: "#F2CD46" },
38
- { id: "lime_green", label: "Lime Green", hex: "#78C25E" },
39
- { id: "teal", label: "Teal", hex: "#77C8A6" },
40
- { id: "light_blue", label: "Light Blue", hex: "#3496F0" },
41
- { id: "dark_blue", label: "Dark Blue", hex: "#3496F0" },
42
- { id: "violet", label: "Violet", hex: "#5756D4" },
43
- { id: "pink", label: "Pink", hex: "#F7D7E9" },
44
- { id: "brown", label: "Brown", hex: "#A3895B" },
45
- { id: "dark_green", label: "Dark Green", hex: "#32523B" },
46
- { id: "blue_gray", label: "Blue Gray", hex: "#2F688C" },
47
- { id: "light_gray", label: "Light Gray", hex: "#92979E" },
48
- { id: "dark_gray", label: "Dark Gray", hex: "#333333" }
49
- ];
50
- export const TEMPLATE_FONT_IDS = TEMPLATE_FONT_OPTIONS.map((option) => option.id);
51
- export const TEMPLATE_TEXT_BACKGROUND_COLOR_IDS = TEMPLATE_TEXT_BACKGROUND_COLOR_OPTIONS.map((option) => option.id);
@@ -1,9 +0,0 @@
1
- // Generated by `vidfarm analyze-viral-dna` and `vidfarm analyze-visual-dna`.
2
- // Keep source notes in `research/source_notes.md` and reference media in `research/preview/`.
3
- export const templateLinkToOriginal = "";
4
- export const templateSourceNotesPath = "research/source_notes.md";
5
- export const templatePreviewMediaRelativePaths = [];
6
- export const templateViralDna = "Run `vidfarm analyze-viral-dna --template-dir .` after adding source notes and preview media.";
7
- export const templateVisualDna = "Run `vidfarm analyze-visual-dna --template-dir .` after adding source notes and preview media.";
8
- export const templateViralDnaAnalysis = null;
9
- export const templateVisualDnaAnalysis = null;