@open-take/compositor 0.4.4 → 0.5.1

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,163 @@
1
+ import type { SceneBase } from "./launch-types";
2
+
3
+ export type MotionEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out" | "step";
4
+ export type MotionProperty =
5
+ | "x"
6
+ | "y"
7
+ | "opacity"
8
+ | "scaleX"
9
+ | "scaleY"
10
+ | "rotation"
11
+ | "width"
12
+ | "height"
13
+ | "radius"
14
+ | "fill"
15
+ | "stroke"
16
+ | "strokeWidth"
17
+ | "fontSize"
18
+ | "reveal"
19
+ | "end";
20
+ export type MotionKeyframe = { atS: number; value: number | string; easing?: MotionEasing };
21
+ export type MotionTrack = { property: MotionProperty; keyframes: MotionKeyframe[] };
22
+ export type MotionLayerBase = {
23
+ id: string;
24
+ x?: number;
25
+ y?: number;
26
+ opacity?: number;
27
+ scaleX?: number;
28
+ scaleY?: number;
29
+ rotation?: number;
30
+ animations?: MotionTrack[];
31
+ };
32
+ export type MotionShadow = {
33
+ color: string;
34
+ blur: number;
35
+ offsetX?: number;
36
+ offsetY?: number;
37
+ };
38
+ export type MotionGroupLayer = MotionLayerBase & {
39
+ type: "group";
40
+ children: MotionLayer[];
41
+ width?: number;
42
+ height?: number;
43
+ clip?: boolean;
44
+ /** Rounded clip radius. Only meaningful when clip is true. */
45
+ radius?: number;
46
+ };
47
+ export type MotionRectLayer = MotionLayerBase & {
48
+ type: "rect";
49
+ width: number;
50
+ height: number;
51
+ fill?: string;
52
+ stroke?: string;
53
+ strokeWidth?: number;
54
+ radius?: number;
55
+ shadow?: MotionShadow;
56
+ };
57
+ export type MotionEllipseLayer = MotionLayerBase & {
58
+ type: "ellipse";
59
+ width: number;
60
+ height: number;
61
+ fill?: string;
62
+ stroke?: string;
63
+ strokeWidth?: number;
64
+ };
65
+ export type MotionTextLayer = MotionLayerBase & {
66
+ type: "text";
67
+ text: string;
68
+ width: number;
69
+ height: number;
70
+ fontSize: number;
71
+ fontFamily?: string;
72
+ fontWeight?: number;
73
+ fill?: string;
74
+ align?: "left" | "center" | "right";
75
+ /** Line height in design pixels, defaulting to 1.2 * evaluated fontSize. */
76
+ lineHeight?: number;
77
+ reveal?: number;
78
+ };
79
+ export type MotionImageCrop = { x: number; y: number; width: number; height: number };
80
+ export type MotionImageLayer = MotionLayerBase & {
81
+ type: "image";
82
+ asset: string;
83
+ width: number;
84
+ height: number;
85
+ fit?: "contain" | "cover";
86
+ radius?: number;
87
+ crop?: MotionImageCrop;
88
+ shadow?: MotionShadow;
89
+ };
90
+ export type MotionVideoLayer = MotionLayerBase & {
91
+ type: "video";
92
+ asset: string;
93
+ width: number;
94
+ height: number;
95
+ fit?: "contain" | "cover";
96
+ radius?: number;
97
+ /** First source-media second shown by this layer. Defaults to 0. */
98
+ trimStartS?: number;
99
+ /** Scene-local second when playback begins. Defaults to 0. */
100
+ startS?: number;
101
+ /** Source clip span. The first/last frame hold outside this active span. */
102
+ durationS: number;
103
+ shadow?: MotionShadow;
104
+ };
105
+ export type MotionLineLayer = MotionLayerBase & {
106
+ type: "line";
107
+ points: [number, number][];
108
+ stroke?: string;
109
+ strokeWidth?: number;
110
+ end?: number;
111
+ };
112
+ export type MotionLayer =
113
+ | MotionGroupLayer
114
+ | MotionRectLayer
115
+ | MotionEllipseLayer
116
+ | MotionTextLayer
117
+ | MotionImageLayer
118
+ | MotionVideoLayer
119
+ | MotionLineLayer;
120
+ export type MotionScene = SceneBase & {
121
+ type: "motion";
122
+ designSize?: { width: number; height: number };
123
+ layers: MotionLayer[];
124
+ };
125
+
126
+ type EvaluatedBase = {
127
+ x: number;
128
+ y: number;
129
+ opacity: number;
130
+ scaleX: number;
131
+ scaleY: number;
132
+ rotation: number;
133
+ };
134
+ type Evaluated<T> = Omit<T, "animations" | keyof EvaluatedBase> & EvaluatedBase;
135
+ export type EvaluatedMotionLayer =
136
+ | (Omit<Evaluated<MotionGroupLayer>, "children"> & {
137
+ children: EvaluatedMotionLayer[];
138
+ clip: boolean;
139
+ radius: number;
140
+ })
141
+ | (Evaluated<MotionRectLayer> & { radius: number; strokeWidth: number })
142
+ | (Evaluated<MotionEllipseLayer> & { strokeWidth: number })
143
+ | (Evaluated<MotionTextLayer> & {
144
+ fullText: string;
145
+ reveal: number;
146
+ align: "left" | "center" | "right";
147
+ fontWeight: number;
148
+ lineHeight: number;
149
+ })
150
+ | (Evaluated<MotionImageLayer> & { fit: "contain" | "cover"; radius: number })
151
+ | (Evaluated<MotionVideoLayer> & {
152
+ fit: "contain" | "cover";
153
+ radius: number;
154
+ trimStartS: number;
155
+ startS: number;
156
+ /** Unquantized source time; the renderer applies only its final-frame sampling guard. */
157
+ mediaTimeS: number;
158
+ })
159
+ | (Evaluated<MotionLineLayer> & { end: number; strokeWidth: number });
160
+ export type EvaluatedMotionScene = {
161
+ designSize: { width: number; height: number };
162
+ layers: EvaluatedMotionLayer[];
163
+ };
@@ -0,0 +1,400 @@
1
+ import { statSync } from "node:fs";
2
+ import { extname, resolve } from "node:path";
3
+ import type { LaunchIssue } from "./launch-types";
4
+ import { motionGraphemes, parseMotionColor } from "./motion-evaluate";
5
+
6
+ const record = (v: unknown): v is Record<string, unknown> =>
7
+ v !== null && typeof v === "object" && !Array.isArray(v);
8
+ const finite = (v: unknown): v is number => typeof v === "number" && Number.isFinite(v);
9
+ const transforms = ["x", "y", "opacity", "scaleX", "scaleY", "rotation"];
10
+ const fields: Record<string, string[]> = {
11
+ group: ["children", "width", "height", "clip", "radius"],
12
+ rect: ["width", "height", "fill", "stroke", "strokeWidth", "radius", "shadow"],
13
+ ellipse: ["width", "height", "fill", "stroke", "strokeWidth"],
14
+ text: [
15
+ "text",
16
+ "width",
17
+ "height",
18
+ "fontSize",
19
+ "fontFamily",
20
+ "fontWeight",
21
+ "fill",
22
+ "align",
23
+ "lineHeight",
24
+ "reveal",
25
+ ],
26
+ image: ["asset", "width", "height", "fit", "radius", "crop", "shadow"],
27
+ video: [
28
+ "asset",
29
+ "width",
30
+ "height",
31
+ "fit",
32
+ "radius",
33
+ "trimStartS",
34
+ "startS",
35
+ "durationS",
36
+ "shadow",
37
+ ],
38
+ line: ["points", "stroke", "strokeWidth", "end"],
39
+ };
40
+ const animated = new Set([
41
+ ...transforms,
42
+ "width",
43
+ "height",
44
+ "radius",
45
+ "fill",
46
+ "stroke",
47
+ "strokeWidth",
48
+ "fontSize",
49
+ "reveal",
50
+ "end",
51
+ ]);
52
+ const ranges: Record<string, [number, number]> = {
53
+ x: [-1_000_000, 1_000_000],
54
+ y: [-1_000_000, 1_000_000],
55
+ rotation: [-36000, 36000],
56
+ opacity: [0, 1],
57
+ scaleX: [0, 100],
58
+ scaleY: [0, 100],
59
+ reveal: [0, 1],
60
+ end: [0, 1],
61
+ width: [0.001, 32768],
62
+ height: [0.001, 32768],
63
+ radius: [0, 16384],
64
+ strokeWidth: [0, 4096],
65
+ fontSize: [8, 512],
66
+ lineHeight: [8, 4096],
67
+ fontWeight: [100, 1000],
68
+ trimStartS: [0, 86400],
69
+ startS: [0, 86400],
70
+ durationS: [0.001, 86400],
71
+ };
72
+
73
+ /** Structural validation only; media streams, dimensions and clip bounds are probed asynchronously. */
74
+ export function validateMotionScene(value: unknown, path = "$", baseDir?: string): LaunchIssue[] {
75
+ const issues: LaunchIssue[] = [];
76
+ const add = (p: string, message: string) => issues.push({ severity: "error", path: p, message });
77
+ if (!record(value)) return [{ severity: "error", path, message: "must be an object" }];
78
+ const rejectUnknown = (obj: Record<string, unknown>, allowed: string[], p: string) => {
79
+ for (const key of Object.keys(obj))
80
+ if (!allowed.includes(key)) add(`${p}.${key}`, "unsupported field");
81
+ };
82
+ const range = (v: unknown, p: string, min: number, max: number) => {
83
+ if (!finite(v) || v < min || v > max) {
84
+ add(p, `must be finite and between ${min} and ${max}`);
85
+ return false;
86
+ }
87
+ return true;
88
+ };
89
+ const numeric = (v: unknown, p: string, key: string) => range(v, p, ...ranges[key]!);
90
+ const text = (v: unknown, p: string, limit: number) => {
91
+ if (typeof v !== "string" || !v.trim() || v.length > limit) {
92
+ add(p, `must be a non-empty string of at most ${limit} characters`);
93
+ return false;
94
+ }
95
+ return true;
96
+ };
97
+ const enumValue = (v: unknown, p: string, choices: string[]) => {
98
+ if (typeof v !== "string" || !choices.includes(v)) add(p, `must be ${choices.join(", ")}`);
99
+ };
100
+ rejectUnknown(
101
+ value,
102
+ [
103
+ "id",
104
+ "type",
105
+ "durationS",
106
+ "transition",
107
+ "background",
108
+ "colors",
109
+ "motion",
110
+ "designSize",
111
+ "layers",
112
+ ],
113
+ path,
114
+ );
115
+ if (value.type !== "motion") add(`${path}.type`, "must be motion");
116
+ if (!finite(value.durationS) || value.durationS <= 0)
117
+ add(`${path}.durationS`, "must be finite and positive");
118
+ if (value.designSize !== undefined) {
119
+ if (!record(value.designSize)) add(`${path}.designSize`, "must be an object");
120
+ else {
121
+ rejectUnknown(value.designSize, ["width", "height"], `${path}.designSize`);
122
+ for (const key of ["width", "height"])
123
+ range(value.designSize[key], `${path}.designSize.${key}`, 1, 32768);
124
+ }
125
+ }
126
+ const ids = new Set<string>();
127
+ let count = 0,
128
+ videoCount = 0;
129
+ const visit = (rawLayers: unknown, p: string, depth: number): void => {
130
+ if (!Array.isArray(rawLayers)) {
131
+ add(p, "must be an array of layers");
132
+ return;
133
+ }
134
+ for (const [i, raw] of rawLayers.entries()) {
135
+ const q = `${p}[${i}]`;
136
+ if (++count > 256) {
137
+ if (count === 257) add(q, "scene exceeds the 256-layer limit including nested groups");
138
+ return;
139
+ }
140
+ if (!record(raw)) {
141
+ add(q, "must be an object");
142
+ continue;
143
+ }
144
+ const layer = raw;
145
+ if (text(layer.id, `${q}.id`, 200)) {
146
+ const id = layer.id as string;
147
+ if (ids.has(id)) add(`${q}.id`, `duplicate layer id ${JSON.stringify(id)}`);
148
+ ids.add(id);
149
+ }
150
+ if (typeof layer.type !== "string" || !Object.hasOwn(fields, layer.type)) {
151
+ add(`${q}.type`, "unsupported layer type");
152
+ continue;
153
+ }
154
+ const kind = layer.type,
155
+ own = fields[kind]!;
156
+ if (kind === "video" && ++videoCount > 8 && videoCount === 9)
157
+ add(q, "scene exceeds the 8-video layer limit including nested groups");
158
+ rejectUnknown(layer, ["id", "type", "animations", ...transforms, ...own], q);
159
+ for (const key of [...transforms, ...own]) {
160
+ if (ranges[key] && layer[key] !== undefined) numeric(layer[key], `${q}.${key}`, key);
161
+ if (
162
+ (key === "fill" || key === "stroke") &&
163
+ layer[key] !== undefined &&
164
+ !parseMotionColor(layer[key])
165
+ )
166
+ add(`${q}.${key}`, "must be a valid #RRGGBB/#RRGGBBAA/rgb()/rgba() color");
167
+ }
168
+ const extremes = new Map<string, number[]>();
169
+ for (const key of ["width", "height", "fontSize"])
170
+ if (finite(layer[key])) extremes.set(key, [layer[key]]);
171
+ if (layer.animations !== undefined && !Array.isArray(layer.animations))
172
+ add(`${q}.animations`, "must be an array");
173
+ const seen = new Set<string>();
174
+ for (const [j, track] of (Array.isArray(layer.animations)
175
+ ? layer.animations
176
+ : []
177
+ ).entries()) {
178
+ const a = `${q}.animations[${j}]`;
179
+ if (!record(track)) {
180
+ add(a, "must be an object");
181
+ continue;
182
+ }
183
+ rejectUnknown(track, ["property", "keyframes"], a);
184
+ const property = track.property;
185
+ if (
186
+ typeof property !== "string" ||
187
+ !animated.has(property) ||
188
+ (!transforms.includes(property) && !own.includes(property))
189
+ ) {
190
+ add(`${a}.property`, "unsupported animation property for this layer type");
191
+ continue;
192
+ }
193
+ if (kind === "group" && property === "radius" && layer.clip !== true)
194
+ add(`${a}.property`, "group radius animation requires clip: true");
195
+ if (seen.has(property)) add(`${a}.property`, "only one track per property is allowed");
196
+ seen.add(property);
197
+ if (
198
+ !Array.isArray(track.keyframes) ||
199
+ track.keyframes.length < 1 ||
200
+ track.keyframes.length > 128
201
+ ) {
202
+ add(`${a}.keyframes`, "must contain between 1 and 128 keyframes");
203
+ continue;
204
+ }
205
+ let previous = -1;
206
+ for (const [k, frame] of track.keyframes.entries()) {
207
+ const f = `${a}.keyframes[${k}]`;
208
+ if (!record(frame)) {
209
+ add(f, "must be an object");
210
+ continue;
211
+ }
212
+ rejectUnknown(frame, ["atS", "value", "easing"], f);
213
+ if (
214
+ !finite(frame.atS) ||
215
+ frame.atS < 0 ||
216
+ (finite(value.durationS) && frame.atS > value.durationS)
217
+ )
218
+ add(`${f}.atS`, "must be finite and inside the scene duration");
219
+ else {
220
+ if (k === 0 && frame.atS !== 0) add(`${f}.atS`, "first keyframe must be at 0");
221
+ if (frame.atS <= previous) add(`${f}.atS`, "keyframe times must strictly increase");
222
+ previous = frame.atS;
223
+ }
224
+ if (frame.easing !== undefined)
225
+ enumValue(frame.easing, `${f}.easing`, [
226
+ "linear",
227
+ "ease-in",
228
+ "ease-out",
229
+ "ease-in-out",
230
+ "step",
231
+ ]);
232
+ if (property === "fill" || property === "stroke") {
233
+ if (!parseMotionColor(frame.value)) add(`${f}.value`, "must be a supported color");
234
+ } else if (
235
+ numeric(frame.value, `${f}.value`, property) &&
236
+ ["width", "height", "fontSize"].includes(property)
237
+ )
238
+ extremes.set(property, [...(extremes.get(property) ?? []), frame.value as number]);
239
+ }
240
+ }
241
+ if (kind === "group") {
242
+ if (layer.clip !== undefined && typeof layer.clip !== "boolean")
243
+ add(`${q}.clip`, "must be a boolean");
244
+ if (layer.clip !== true && layer.radius !== undefined)
245
+ add(`${q}.radius`, "group radius requires clip: true");
246
+ if (layer.clip === true)
247
+ for (const key of ["width", "height"])
248
+ if (layer[key] === undefined)
249
+ add(`${q}.${key}`, "clipping requires a positive base dimension");
250
+ if (depth >= 8) add(q, "group nesting exceeds the maximum depth of 8");
251
+ else visit(layer.children, `${q}.children`, depth + 1);
252
+ } else if (kind === "line") {
253
+ if (!Array.isArray(layer.points) || layer.points.length < 2 || layer.points.length > 1024)
254
+ add(`${q}.points`, "must contain between 2 and 1024 coordinate pairs");
255
+ else
256
+ for (const [j, point] of layer.points.entries()) {
257
+ if (!Array.isArray(point) || point.length !== 2)
258
+ add(`${q}.points[${j}]`, "must be an [x,y] pair");
259
+ else
260
+ point.forEach((v, k) => {
261
+ range(v, `${q}.points[${j}][${k}]`, -1_000_000, 1_000_000);
262
+ });
263
+ }
264
+ } else {
265
+ for (const key of ["width", "height"])
266
+ if (layer[key] === undefined) add(`${q}.${key}`, "is required and must be positive");
267
+ }
268
+ if (kind === "text") {
269
+ const validText = text(layer.text, `${q}.text`, 4000);
270
+ if (layer.fontSize === undefined) add(`${q}.fontSize`, "is required");
271
+ if (layer.fontFamily !== undefined) text(layer.fontFamily, `${q}.fontFamily`, 300);
272
+ if (layer.align !== undefined)
273
+ enumValue(layer.align, `${q}.align`, ["left", "center", "right"]);
274
+ const width = Math.min(...(extremes.get("width") ?? [NaN])),
275
+ height = Math.min(...(extremes.get("height") ?? [NaN])),
276
+ font = Math.max(...(extremes.get("fontSize") ?? [NaN]));
277
+ if (validText && width > 0 && height > 0 && font >= 8) {
278
+ const lineHeight = finite(layer.lineHeight) ? layer.lineHeight : font * 1.2;
279
+ if (lineHeight < font)
280
+ add(`${q}.lineHeight`, "must not be smaller than the largest animated fontSize");
281
+ if (
282
+ estimateMotionTextLines(layer.text as string, width, font) * lineHeight >
283
+ height + 0.001
284
+ )
285
+ add(
286
+ `${q}.text`,
287
+ "copy cannot fit the text box at its narrowest/smallest dimensions and largest fontSize; enlarge the box or shorten the copy",
288
+ );
289
+ }
290
+ }
291
+ if (kind === "image" || kind === "video") {
292
+ if (text(layer.asset, `${q}.asset`, 4096)) {
293
+ const asset = layer.asset as string;
294
+ const extensions =
295
+ kind === "image" ? [".png", ".jpg", ".jpeg", ".webp"] : [".mp4", ".webm", ".mov"];
296
+ if (
297
+ asset.includes("\0") ||
298
+ (/^[a-z][a-z\d+.-]*:/i.test(asset) && !/^[a-z]:[\\/]/i.test(asset))
299
+ )
300
+ add(
301
+ `${q}.asset`,
302
+ kind === "image"
303
+ ? "must be a local PNG/JPEG/WebP path"
304
+ : "must be a local MP4/WebM/MOV path",
305
+ );
306
+ else if (!extensions.includes(extname(asset).toLowerCase()))
307
+ add(
308
+ `${q}.asset`,
309
+ kind === "image"
310
+ ? "only PNG/JPEG/WebP image assets are supported"
311
+ : "only MP4/WebM/MOV video assets are supported",
312
+ );
313
+ else if (baseDir) {
314
+ try {
315
+ if (!statSync(resolve(baseDir, asset)).isFile())
316
+ add(`${q}.asset`, "asset is not a regular file");
317
+ } catch {
318
+ add(`${q}.asset`, `missing asset: ${asset}`);
319
+ }
320
+ }
321
+ }
322
+ if (layer.fit !== undefined) enumValue(layer.fit, `${q}.fit`, ["contain", "cover"]);
323
+ if (kind === "image" && layer.crop !== undefined) {
324
+ if (!record(layer.crop)) add(`${q}.crop`, "must be an object");
325
+ else {
326
+ rejectUnknown(layer.crop, ["x", "y", "width", "height"], `${q}.crop`);
327
+ for (const key of ["x", "y", "width", "height"]) {
328
+ range(layer.crop[key], `${q}.crop.${key}`, key === "x" || key === "y" ? 0 : 1, 32768);
329
+ if (finite(layer.crop[key]) && !Number.isInteger(layer.crop[key]))
330
+ add(`${q}.crop.${key}`, "must be an integer source-pixel coordinate or size");
331
+ }
332
+ }
333
+ }
334
+ }
335
+ if (kind === "video") {
336
+ if (layer.durationS === undefined)
337
+ add(`${q}.durationS`, "is required and must be positive");
338
+ const start = layer.startS === undefined ? 0 : layer.startS;
339
+ if (finite(start) && finite(value.durationS) && start > value.durationS)
340
+ add(`${q}.startS`, "must be inside the scene duration");
341
+ if (
342
+ finite(start) &&
343
+ finite(layer.durationS) &&
344
+ finite(value.durationS) &&
345
+ start + layer.durationS > value.durationS + 1e-9
346
+ )
347
+ add(
348
+ `${q}.durationS`,
349
+ "video active span (startS + durationS) must stay inside the scene duration",
350
+ );
351
+ }
352
+ if (kind === "rect" || kind === "image" || kind === "video") {
353
+ if (layer.shadow !== undefined) {
354
+ const shadowPath = `${q}.shadow`;
355
+ if (!record(layer.shadow)) add(shadowPath, "must be an object");
356
+ else {
357
+ rejectUnknown(layer.shadow, ["color", "blur", "offsetX", "offsetY"], shadowPath);
358
+ if (!parseMotionColor(layer.shadow.color))
359
+ add(`${shadowPath}.color`, "must be a valid #RRGGBB/#RRGGBBAA/rgb()/rgba() color");
360
+ range(layer.shadow.blur, `${shadowPath}.blur`, 0, 256);
361
+ for (const key of ["offsetX", "offsetY"])
362
+ if (layer.shadow[key] !== undefined)
363
+ range(layer.shadow[key], `${shadowPath}.${key}`, -512, 512);
364
+ }
365
+ }
366
+ }
367
+ }
368
+ };
369
+ if (Array.isArray(value.layers) && !value.layers.length)
370
+ add(`${path}.layers`, "must contain at least one layer");
371
+ visit(value.layers, `${path}.layers`, 0);
372
+ return issues;
373
+ }
374
+
375
+ /** Conservative grapheme-aware wrapping estimate; it never splits a Unicode grapheme. */
376
+ export function estimateMotionTextLines(text: string, width: number, fontSize: number): number {
377
+ let lines = 1,
378
+ used = 0;
379
+ for (const grapheme of motionGraphemes(text)) {
380
+ if (grapheme === "\n" || grapheme === "\r\n") {
381
+ lines++;
382
+ used = 0;
383
+ continue;
384
+ }
385
+ const advance =
386
+ fontSize *
387
+ (grapheme.length === 1 && grapheme.charCodeAt(0) <= 255
388
+ ? /[MW@%]/.test(grapheme)
389
+ ? 0.95
390
+ : 0.62
391
+ : 1);
392
+ if (advance > width) return Infinity;
393
+ if (used + advance > width + 0.001) {
394
+ lines++;
395
+ used = 0;
396
+ }
397
+ used += advance;
398
+ }
399
+ return lines;
400
+ }
@@ -0,0 +1,8 @@
1
+ let renderQueue: Promise<unknown> = Promise.resolve();
2
+
3
+ /** Revideo changes process.cwd(), so all compositor renders share one lock. */
4
+ export function withRenderLock<T>(operation: () => Promise<T>): Promise<T> {
5
+ const run = renderQueue.then(operation, operation);
6
+ renderQueue = run.catch(() => {});
7
+ return run;
8
+ }
package/src/render.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  type TakeComposition,
41
41
  } from "./types";
42
42
  import { type CompositionIssue, formatIssues, validateComposition } from "./validate";
43
+ import { withRenderLock } from "./render-lock";
43
44
 
44
45
  // dist/index.js -> package root
45
46
  const PKG_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
@@ -296,15 +297,8 @@ async function prepareScratch(composition: TakeComposition, videoPath: string):
296
297
  // concurrently no matter how isolated their directories are — the scratch dirs
297
298
  // remove the shared STATE, this removes the interleaving. (True parallelism
298
299
  // needs the renderer off cwd, or one child process per render.)
299
- let renderQueue: Promise<unknown> = Promise.resolve();
300
-
301
300
  export async function renderTake(opts: RenderTakeOpts): Promise<RenderTakeResult> {
302
- const run = renderQueue.then(
303
- () => renderTakeExclusive(opts),
304
- () => renderTakeExclusive(opts),
305
- );
306
- renderQueue = run.catch(() => {});
307
- return run;
301
+ return withRenderLock(() => renderTakeExclusive(opts));
308
302
  }
309
303
 
310
304
  async function renderTakeExclusive(opts: RenderTakeOpts): Promise<RenderTakeResult> {
@@ -0,0 +1,11 @@
1
+ import { makeProject } from "@revideo/core";
2
+ import scene from "./launch-scene";
3
+ import comp from "./.launch-composition.json";
4
+
5
+ export default makeProject({
6
+ scenes: [scene],
7
+ settings: {
8
+ shared: { size: { x: comp.output.width, y: comp.output.height } },
9
+ rendering: { fps: comp.output.fps },
10
+ },
11
+ });