@microfox/remotion 1.0.2 → 1.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.
package/dist/index.mjs DELETED
@@ -1,3215 +0,0 @@
1
- // src/core/registry/componentRegistry.ts
2
- var ComponentRegistryManager = class {
3
- constructor() {
4
- this.registry = {};
5
- this.packageRegistry = {};
6
- }
7
- registerComponent(name, component, type, config12 = { displayName: "" }, packageName) {
8
- this.registry[name] = { component, config: config12 };
9
- if (packageName) {
10
- if (!this.packageRegistry[packageName]) {
11
- this.packageRegistry[packageName] = {};
12
- }
13
- this.packageRegistry[packageName][name] = { component, config: config12 };
14
- }
15
- }
16
- registerEffect(name, component, config12 = { displayName: "" }, packageName) {
17
- this.registerComponent(
18
- name?.includes("effect-") ? name : `effect-${name}`,
19
- component,
20
- "layout",
21
- config12,
22
- packageName
23
- );
24
- }
25
- getComponent(name) {
26
- return this.registry[name]?.component;
27
- }
28
- getComponentConfig(name) {
29
- return this.registry[name]?.config;
30
- }
31
- getComponentWithConfig(name) {
32
- return this.registry[name];
33
- }
34
- registerPackage(packageName, components) {
35
- this.packageRegistry[packageName] = components;
36
- Object.entries(components).forEach(([name, { component, config: config12 }]) => {
37
- this.registry[`${packageName}:${name}`] = { component, config: config12 };
38
- });
39
- }
40
- getPackageComponents(packageName) {
41
- return this.packageRegistry[packageName];
42
- }
43
- getAllComponents() {
44
- return { ...this.registry };
45
- }
46
- clear() {
47
- this.registry = {};
48
- this.packageRegistry = {};
49
- }
50
- };
51
- var componentRegistry = new ComponentRegistryManager();
52
- var registerComponent = (name, component, type, config12 = { displayName: "" }, packageName) => {
53
- componentRegistry.registerComponent(
54
- name,
55
- component,
56
- type,
57
- config12,
58
- packageName
59
- );
60
- };
61
- var registerEffect = (name, component, config12 = { displayName: "" }, packageName) => {
62
- componentRegistry.registerEffect(name, component, config12, packageName);
63
- };
64
- var registerPackage = (packageName, components) => {
65
- componentRegistry.registerPackage(packageName, components);
66
- };
67
- var getComponent = (name) => componentRegistry.getComponent(name);
68
- var getComponentConfig = (name) => componentRegistry.getComponentConfig(name);
69
- var getComponentWithConfig = (name) => componentRegistry.getComponentWithConfig(name);
70
-
71
- // src/core/context/CompositionContext.tsx
72
- import React, { createContext, useContext } from "react";
73
- var CompositionContext = createContext(null);
74
- var CompositionProvider = ({ children, value }) => {
75
- return /* @__PURE__ */ React.createElement(CompositionContext.Provider, { value }, children);
76
- };
77
- var useComposition = () => {
78
- const context = useContext(CompositionContext);
79
- if (!context) {
80
- throw new Error("useComposition must be used within a CompositionProvider");
81
- }
82
- return context;
83
- };
84
-
85
- // src/components/base/ComponentRenderer.tsx
86
- import React3, { createContext as createContext2, useContext as useContext2 } from "react";
87
- import { Sequence, Series, useVideoConfig } from "remotion";
88
-
89
- // src/core/utils/timing.ts
90
- var calculateTiming = (type, context, videoConfig) => {
91
- let newTiming;
92
- if (type !== "atom" && context?.timing) {
93
- const { start = 0, duration = 0 } = context.timing;
94
- newTiming = {
95
- startInFrames: Math.round(
96
- context.timing?.startInFrames ? context.timing.startInFrames : type === "scene" ? start * videoConfig.fps : start * videoConfig.fps
97
- ),
98
- durationInFrames: Math.round(
99
- context.timing?.durationInFrames ? context.timing.durationInFrames : type === "scene" ? duration * videoConfig.fps : duration * videoConfig.fps
100
- ),
101
- duration,
102
- start
103
- };
104
- } else {
105
- newTiming = {
106
- startInFrames: context.timing?.startInFrames ? context.timing.startInFrames : context.timing?.start ? Math.round(videoConfig.fps * (context.timing.start || 0)) : 0,
107
- durationInFrames: Math.round(
108
- context.timing?.durationInFrames ? context.timing.durationInFrames : context.timing?.duration ? Math.round(videoConfig.fps * (context.timing.duration || 0)) : 0
109
- ),
110
- duration: context.timing?.duration,
111
- start: context.timing?.start
112
- };
113
- }
114
- return newTiming;
115
- };
116
-
117
- // src/core/utils/hierarchyUtils.ts
118
- var findComponentById = (root, targetId) => {
119
- if (!root) return null;
120
- const search = (components) => {
121
- for (const component of components) {
122
- if (component.id === targetId) {
123
- return component;
124
- }
125
- if (component.childrenData && component.childrenData.length > 0) {
126
- const found = search(component.childrenData);
127
- if (found) return found;
128
- }
129
- }
130
- return null;
131
- };
132
- return search(root);
133
- };
134
- var findParentComponent = (root, targetId) => {
135
- if (!root) return null;
136
- const search = (components, parent) => {
137
- for (const component of components) {
138
- if (component.childrenData && component.childrenData.length > 0) {
139
- const hasTargetChild = component.childrenData.some(
140
- (child) => child.id === targetId
141
- );
142
- if (hasTargetChild) {
143
- return component;
144
- }
145
- const found = search(component.childrenData, component);
146
- if (found) return found;
147
- }
148
- }
149
- return null;
150
- };
151
- return search(root, null);
152
- };
153
- var calculateHierarchy = (root, componentId, currentContext) => {
154
- if (!root) {
155
- return {
156
- depth: (currentContext?.hierarchy?.depth || 0) + 1,
157
- parentIds: [...currentContext?.hierarchy?.parentIds || [], componentId]
158
- };
159
- }
160
- const parentIds = [];
161
- let depth = 0;
162
- const traverse = (components, currentDepth) => {
163
- for (const component of components) {
164
- if (component.id === componentId) {
165
- depth = currentDepth;
166
- return true;
167
- }
168
- if (component.childrenData && component.childrenData.length > 0) {
169
- parentIds.push(component.id);
170
- const found = traverse(component.childrenData, currentDepth + 1);
171
- if (found) return true;
172
- parentIds.pop();
173
- }
174
- }
175
- return false;
176
- };
177
- traverse(root, 0);
178
- return {
179
- depth,
180
- parentIds: [...parentIds]
181
- };
182
- };
183
- var calculateTimingWithInheritance = (component, root, videoConfig) => {
184
- const currentContext = component.context || {};
185
- const baseTiming = calculateTiming(
186
- component.type,
187
- currentContext,
188
- videoConfig
189
- );
190
- if (!baseTiming.durationInFrames || baseTiming.durationInFrames <= 0) {
191
- const findParentWithTiming = (targetId) => {
192
- const parent = findParentComponent(root, targetId);
193
- if (!parent) return null;
194
- const parentContext = parent.context || {};
195
- const parentTiming = calculateTiming(
196
- parent.type,
197
- parentContext,
198
- videoConfig
199
- );
200
- if (parentTiming.durationInFrames && parentTiming.durationInFrames > 0) {
201
- return parentTiming;
202
- }
203
- return findParentWithTiming(parent.id);
204
- };
205
- const inheritedTiming = findParentWithTiming(component.id);
206
- if (inheritedTiming) {
207
- return {
208
- ...baseTiming,
209
- durationInFrames: inheritedTiming.durationInFrames ? inheritedTiming.durationInFrames : inheritedTiming.duration ? inheritedTiming.duration * videoConfig.fps : 0,
210
- duration: inheritedTiming.duration
211
- };
212
- }
213
- }
214
- return baseTiming;
215
- };
216
-
217
- // src/components/base/EffectWrapper.tsx
218
- import React2 from "react";
219
- var EffectWrapper = ({
220
- effects,
221
- children,
222
- context
223
- }) => {
224
- if (!effects || effects.length === 0) {
225
- return children;
226
- }
227
- let wrappedContent = children;
228
- effects.forEach((effect, index) => {
229
- const effectId = typeof effect === "string" ? `effect-${effect}` : `effect-${effect.componentId}`;
230
- const EffectComponent = getComponent(effectId);
231
- if (!EffectComponent) {
232
- console.warn(`Effect component ${effectId} not found in registry`);
233
- return;
234
- }
235
- const effectData = typeof effect === "string" ? {} : effect.data || {};
236
- const effectContext = typeof effect === "string" ? context : effect.context || context;
237
- const effectProps = {
238
- id: typeof effect === "string" ? `effect-${index}` : effect.id,
239
- componentId: effectId,
240
- type: "layout",
241
- // Effects use the same rendering logic as layout
242
- data: effectData,
243
- context: effectContext,
244
- children: wrappedContent
245
- };
246
- wrappedContent = /* @__PURE__ */ React2.createElement(EffectComponent, { ...effectProps });
247
- });
248
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, wrappedContent);
249
- };
250
-
251
- // src/components/base/ComponentRenderer.tsx
252
- var RenderContext = createContext2(null);
253
- var useRenderContext = () => {
254
- const context = useContext2(RenderContext);
255
- if (!context) {
256
- throw new Error("useRenderContext must be used within a ComponentRenderer");
257
- }
258
- return context;
259
- };
260
- var ComponentRenderer = ({
261
- id,
262
- componentId,
263
- type,
264
- data,
265
- childrenData,
266
- context,
267
- effects
268
- }) => {
269
- const videoConfig = useVideoConfig();
270
- const { root } = useComposition();
271
- const defaultContext = {
272
- boundaries: {
273
- left: 0,
274
- top: 0,
275
- width: videoConfig.width,
276
- height: videoConfig.height,
277
- zIndex: 0
278
- },
279
- timing: {
280
- startInFrames: 0,
281
- durationInFrames: videoConfig.durationInFrames
282
- },
283
- hierarchy: {
284
- depth: 0,
285
- parentIds: []
286
- }
287
- };
288
- if (!context) {
289
- context = {};
290
- }
291
- const newHierarchy = calculateHierarchy(root, id, context ?? defaultContext);
292
- const componentData = {
293
- id,
294
- componentId,
295
- type,
296
- data,
297
- childrenData,
298
- context,
299
- effects
300
- };
301
- let newTiming = calculateTimingWithInheritance(componentData, root, videoConfig);
302
- const newContext = {
303
- ...context,
304
- boundaries: context?.boundaries,
305
- hierarchy: newHierarchy,
306
- timing: newTiming
307
- };
308
- const ComponentClass = getComponent(componentId);
309
- if (type === "scene") {
310
- return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Series, null, childrenData?.map((child) => {
311
- const childTiming = calculateTimingWithInheritance(child, root, videoConfig);
312
- return /* @__PURE__ */ React3.createElement(
313
- Series.Sequence,
314
- {
315
- key: child.id,
316
- name: child.componentId + " - " + child.id,
317
- offset: childTiming.startInFrames ?? 0,
318
- durationInFrames: childTiming.durationInFrames ?? 0
319
- },
320
- child.effects && child.effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects: child.effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })) : /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })
321
- );
322
- })));
323
- }
324
- if (!ComponentClass) {
325
- console.warn(`Component type ${id} not found in registry`);
326
- return null;
327
- }
328
- const props = {
329
- id,
330
- componentId,
331
- data,
332
- context
333
- };
334
- if (type === "layout") {
335
- const config12 = getComponentConfig(componentId);
336
- const isInnerSequence = config12?.isInnerSequence;
337
- if (isInnerSequence) {
338
- return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child }))) : childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child }))));
339
- }
340
- return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Sequence, { layout: "none", name: componentId + " - " + id, from: newTiming.startInFrames, durationInFrames: newTiming.durationInFrames }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child }))) : childrenData?.map((child) => /* @__PURE__ */ React3.createElement(ComponentRenderer, { key: child.id, ...child })))));
341
- }
342
- if (type === "atom") {
343
- if (newTiming.durationInFrames && newTiming.durationInFrames > 0) {
344
- return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, /* @__PURE__ */ React3.createElement(Sequence, { layout: "none", name: componentId + " - " + id, from: newTiming.startInFrames, durationInFrames: newTiming.durationInFrames }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props })) : /* @__PURE__ */ React3.createElement(ComponentClass, { ...props })));
345
- }
346
- return /* @__PURE__ */ React3.createElement(RenderContext.Provider, { value: newContext }, effects && effects.length > 0 ? /* @__PURE__ */ React3.createElement(EffectWrapper, { effects, context: newContext }, /* @__PURE__ */ React3.createElement(ComponentClass, { ...props })) : /* @__PURE__ */ React3.createElement(ComponentClass, { ...props }));
347
- }
348
- };
349
-
350
- // src/components/frames/Frame.tsx
351
- import React4 from "react";
352
- import { AbsoluteFill } from "remotion";
353
- var Frame = ({ children, data }) => {
354
- return /* @__PURE__ */ React4.createElement(AbsoluteFill, { style: data?.style }, children);
355
- };
356
-
357
- // src/components/frames/SceneFrame.tsx
358
- import React5 from "react";
359
- import { AbsoluteFill as AbsoluteFill2 } from "remotion";
360
- var SceneFrame = ({ children }) => {
361
- return /* @__PURE__ */ React5.createElement(AbsoluteFill2, null, children);
362
- };
363
-
364
- // src/components/layouts/BaseLayout.tsx
365
- import React6, { Children } from "react";
366
- import { AbsoluteFill as AbsoluteFill3 } from "remotion";
367
- var Layout = ({ id, children, data, context }) => {
368
- const { containerProps, childrenProps } = data || {
369
- containerProps: {},
370
- childrenProps: []
371
- };
372
- const childrenArray = Children.toArray(children);
373
- return (
374
- // @ts-ignore
375
- /* @__PURE__ */ React6.createElement(
376
- AbsoluteFill3,
377
- {
378
- ...containerProps,
379
- style: {
380
- ...context?.boundaries,
381
- ...containerProps.style
382
- }
383
- },
384
- childrenArray.map((child, index) => /* @__PURE__ */ React6.createElement(
385
- "div",
386
- {
387
- key: index,
388
- ...index < childrenProps.length && childrenProps[index]
389
- },
390
- child
391
- ))
392
- )
393
- );
394
- };
395
- var config = {
396
- displayName: "BaseLayout",
397
- type: "layout",
398
- isInnerSequence: false
399
- };
400
-
401
- // src/components/layouts/index.ts
402
- registerComponent(
403
- config.displayName,
404
- Layout,
405
- "layout",
406
- config
407
- );
408
-
409
- // src/components/atoms/ShapeAtom.tsx
410
- import React7 from "react";
411
- import { Easing, interpolate, useCurrentFrame } from "remotion";
412
- var Atom = ({ data }) => {
413
- const frame = useCurrentFrame();
414
- const { shape, color, rotation, style } = data;
415
- const rotationStyle = rotation ? {
416
- transform: `rotate(${interpolate(
417
- frame % rotation.duration,
418
- [0, rotation.duration],
419
- [0, 360],
420
- {
421
- extrapolateLeft: "clamp",
422
- extrapolateRight: "clamp",
423
- easing: Easing.linear
424
- }
425
- )}deg)`
426
- } : {};
427
- const baseStyle = {
428
- width: "100%",
429
- height: "100%",
430
- ...style,
431
- ...rotationStyle
432
- };
433
- switch (shape) {
434
- case "circle":
435
- return /* @__PURE__ */ React7.createElement("div", { style: { ...baseStyle, backgroundColor: color, borderRadius: "50%" } });
436
- case "rectangle":
437
- return /* @__PURE__ */ React7.createElement("div", { style: { ...baseStyle, backgroundColor: color } });
438
- default:
439
- return null;
440
- }
441
- };
442
- var config2 = {
443
- displayName: "ShapeAtom",
444
- type: "atom",
445
- isInnerSequence: false
446
- };
447
-
448
- // src/components/atoms/ImageAtom.tsx
449
- import React8, { useMemo } from "react";
450
- import { Img, staticFile } from "remotion";
451
- var Atom2 = ({ data }) => {
452
- const source = useMemo(() => {
453
- if (data.src.startsWith("http")) {
454
- return data.src;
455
- }
456
- return staticFile(data.src);
457
- }, [data.src]);
458
- return /* @__PURE__ */ React8.createElement(Img, { className: data.className, src: source, style: data.style, crossOrigin: "anonymous" });
459
- };
460
- var config3 = {
461
- displayName: "ImageAtom",
462
- type: "atom",
463
- isInnerSequence: false
464
- };
465
-
466
- // src/components/atoms/TextAtom.tsx
467
- import React9, { useEffect as useEffect2, useState as useState2 } from "react";
468
-
469
- // src/hooks/useFontLoader.ts
470
- import { useState, useEffect, useCallback } from "react";
471
-
472
- // src/utils/fontUtils.ts
473
- import { getAvailableFonts } from "@remotion/google-fonts";
474
- var availableFonts = getAvailableFonts();
475
- var loadedFonts = /* @__PURE__ */ new Map();
476
- var loadGoogleFont = async (fontFamily2, options = {}) => {
477
- if (!fontFamily2 || typeof fontFamily2 !== "string" || fontFamily2 === "") {
478
- console.warn("Invalid fontFamily provided:", fontFamily2);
479
- return "sans-serif";
480
- }
481
- const fontKey = `${fontFamily2}-${JSON.stringify(options)}`;
482
- if (loadedFonts.has(fontKey)) {
483
- return loadedFonts.get(fontKey);
484
- }
485
- try {
486
- console.log("availableFonts", availableFonts);
487
- const thisFont = availableFonts.find(
488
- (font) => font.importName === fontFamily2
489
- );
490
- console.log("thisFont", thisFont);
491
- if (thisFont?.load) {
492
- const fontPackage = await thisFont.load();
493
- const allFontStuff = fontPackage.loadFont("normal", {
494
- subsets: options.subsets || ["latin"],
495
- weights: options.weights || ["400"]
496
- });
497
- console.log("loadedFontFamily", allFontStuff.fontFamily);
498
- await allFontStuff.waitUntilDone();
499
- loadedFonts.set(fontKey, allFontStuff.fontFamily);
500
- return allFontStuff.fontFamily;
501
- } else {
502
- throw new Error(
503
- `Font Package @remotion/google-fonts/${fontFamily2} does not have loadFont method`
504
- );
505
- }
506
- } catch (error) {
507
- console.warn(`Failed to load font ${fontFamily2}:`, error);
508
- try {
509
- const alternativeNames = [
510
- fontFamily2.toLowerCase().replace(/\s+/g, ""),
511
- fontFamily2.toLowerCase().replace(/\s+/g, "-"),
512
- fontFamily2.toLowerCase().replace(/\s+/g, "_")
513
- ];
514
- for (const altName of alternativeNames) {
515
- if (altName === fontFamily2.toLowerCase().replace(/\s+/g, "-")) {
516
- continue;
517
- }
518
- try {
519
- const altFontPackage = await import(`@remotion/google-fonts/${altName}`);
520
- if (altFontPackage.loadFont) {
521
- const { fontFamily: loadedFontFamily } = await altFontPackage.loadFont("normal", {
522
- subsets: options.subsets || ["latin"],
523
- weights: options.weights || ["400"],
524
- display: options.display || "swap",
525
- preload: options.preload !== false
526
- });
527
- loadedFonts.set(fontKey, loadedFontFamily);
528
- return loadedFontFamily;
529
- }
530
- } catch (altError) {
531
- continue;
532
- }
533
- }
534
- } catch (altError) {
535
- }
536
- const fallbackFontFamily = `"${fontFamily2}"`;
537
- loadedFonts.set(fontKey, fallbackFontFamily);
538
- return fallbackFontFamily;
539
- }
540
- };
541
- var loadMultipleFonts = async (fonts) => {
542
- const loadPromises = fonts.map(async ({ family, options }) => {
543
- const fontFamily2 = await loadGoogleFont(family, options);
544
- return { family, fontFamily: fontFamily2 };
545
- });
546
- const results = await Promise.all(loadPromises);
547
- const fontMap = /* @__PURE__ */ new Map();
548
- results.forEach(({ family, fontFamily: fontFamily2 }) => {
549
- fontMap.set(family, fontFamily2);
550
- });
551
- return fontMap;
552
- };
553
- var getLoadedFontFamily = (fontFamily2, options = {}) => {
554
- const fontKey = `${fontFamily2}-${JSON.stringify(options)}`;
555
- return loadedFonts.get(fontKey);
556
- };
557
- var preloadCommonFonts = async () => {
558
- const commonFonts = [
559
- { family: "Inter", options: { weights: ["400", "500", "600", "700"] } },
560
- { family: "Roboto", options: { weights: ["400", "500", "700"] } },
561
- { family: "Open Sans", options: { weights: ["400", "600", "700"] } },
562
- { family: "Lato", options: { weights: ["400", "700"] } }
563
- ];
564
- return await loadMultipleFonts(commonFonts);
565
- };
566
- var isFontLoaded = (fontFamily2, options = {}) => {
567
- const fontKey = `${fontFamily2}-${JSON.stringify(options)}`;
568
- return loadedFonts.has(fontKey);
569
- };
570
- var clearFontCache = () => {
571
- loadedFonts.clear();
572
- };
573
- var getLoadedFonts = () => {
574
- return new Map(loadedFonts);
575
- };
576
- var isFontAvailable = async (fontFamily2) => {
577
- if (!fontFamily2 || typeof fontFamily2 !== "string") {
578
- return false;
579
- }
580
- try {
581
- const normalizedFontName = fontFamily2.trim().replace(/\s+/g, "-").toLowerCase();
582
- const fontPackage = await import(`@remotion/google-fonts/${normalizedFontName}`);
583
- return !!fontPackage.loadFont;
584
- } catch (error) {
585
- return false;
586
- }
587
- };
588
- var getNormalizedFontName = (fontFamily2) => {
589
- if (!fontFamily2 || typeof fontFamily2 !== "string") {
590
- return "";
591
- }
592
- return fontFamily2.trim().replace(/\s+/g, "-").toLowerCase();
593
- };
594
-
595
- // src/hooks/useFontLoader.ts
596
- var useFontLoader = (options = {}) => {
597
- const [state, setState] = useState({
598
- loadedFonts: /* @__PURE__ */ new Map(),
599
- loadingFonts: /* @__PURE__ */ new Set(),
600
- errorFonts: /* @__PURE__ */ new Map()
601
- });
602
- const loadFont2 = useCallback(
603
- async (fontFamily2, fontOptions = {}) => {
604
- const fontKey = `${fontFamily2}-${JSON.stringify(fontOptions)}`;
605
- if (state.loadedFonts.has(fontKey) || state.loadingFonts.has(fontFamily2)) {
606
- return state.loadedFonts.get(fontKey) || `"${fontFamily2}", sans-serif`;
607
- }
608
- setState((prev) => ({
609
- ...prev,
610
- loadingFonts: new Set(prev.loadingFonts).add(fontFamily2)
611
- }));
612
- try {
613
- const cssValue = await loadGoogleFont(fontFamily2, fontOptions);
614
- if (cssValue !== null) {
615
- setState((prev) => ({
616
- ...prev,
617
- loadedFonts: new Map(prev.loadedFonts).set(fontKey, cssValue),
618
- loadingFonts: new Set(
619
- [...prev.loadingFonts].filter((f) => f !== fontFamily2)
620
- )
621
- }));
622
- options.onLoad?.(fontFamily2, cssValue);
623
- return cssValue;
624
- } else {
625
- throw new Error(
626
- `Font Package @remotion/google-fonts/${fontFamily2} not found`
627
- );
628
- }
629
- } catch (error) {
630
- const errorObj = error instanceof Error ? error : new Error(String(error));
631
- setState((prev) => ({
632
- ...prev,
633
- errorFonts: new Map(prev.errorFonts).set(fontFamily2, errorObj),
634
- loadingFonts: new Set(
635
- [...prev.loadingFonts].filter((f) => f !== fontFamily2)
636
- )
637
- }));
638
- options.onError?.(fontFamily2, errorObj);
639
- const fallbackValue = `"${fontFamily2}", sans-serif`;
640
- return fallbackValue;
641
- }
642
- },
643
- [state.loadedFonts, state.loadingFonts, options]
644
- );
645
- const loadMultipleFonts2 = useCallback(
646
- async (fonts) => {
647
- const fontsToLoad = fonts.filter(({ family, options: options2 = {} }) => {
648
- const fontKey = `${family}-${JSON.stringify(options2)}`;
649
- return !state.loadedFonts.has(fontKey) && !state.loadingFonts.has(family);
650
- });
651
- if (fontsToLoad.length === 0) {
652
- return state.loadedFonts;
653
- }
654
- setState((prev) => ({
655
- ...prev,
656
- loadingFonts: /* @__PURE__ */ new Set([
657
- ...prev.loadingFonts,
658
- ...fontsToLoad.map((f) => f.family)
659
- ])
660
- }));
661
- try {
662
- const fontMap = await loadMultipleFonts(fontsToLoad);
663
- const newFontsMap = /* @__PURE__ */ new Map();
664
- fontsToLoad.forEach(({ family, options: options2 = {} }) => {
665
- const fontKey = `${family}-${JSON.stringify(options2)}`;
666
- const cssValue = fontMap.get(family);
667
- if (cssValue) {
668
- newFontsMap.set(fontKey, cssValue);
669
- }
670
- });
671
- setState((prev) => ({
672
- ...prev,
673
- loadedFonts: new Map([...prev.loadedFonts, ...newFontsMap]),
674
- loadingFonts: new Set(
675
- [...prev.loadingFonts].filter(
676
- (f) => !fontsToLoad.some((ftl) => ftl.family === f)
677
- )
678
- )
679
- }));
680
- fontsToLoad.forEach(({ family }) => {
681
- const cssValue = fontMap.get(family);
682
- if (cssValue) {
683
- options.onLoad?.(family, cssValue);
684
- }
685
- });
686
- return fontMap;
687
- } catch (error) {
688
- const errorObj = error instanceof Error ? error : new Error(String(error));
689
- setState((prev) => ({
690
- ...prev,
691
- errorFonts: new Map(prev.errorFonts).set("multiple", errorObj),
692
- loadingFonts: new Set(
693
- [...prev.loadingFonts].filter(
694
- (f) => !fontsToLoad.some((ftl) => ftl.family === f)
695
- )
696
- )
697
- }));
698
- options.onError?.("multiple", errorObj);
699
- return state.loadedFonts;
700
- }
701
- },
702
- [state.loadedFonts, state.loadingFonts, options]
703
- );
704
- const isFontReady = useCallback(
705
- (fontFamily2, options2 = {}) => {
706
- const fontKey = `${fontFamily2}-${JSON.stringify(options2)}`;
707
- return state.loadedFonts.has(fontKey);
708
- },
709
- [state.loadedFonts]
710
- );
711
- const areFontsReady = useCallback(
712
- (fontFamilies) => {
713
- return fontFamilies.every(({ family, options: options2 = {} }) => {
714
- const fontKey = `${family}-${JSON.stringify(options2)}`;
715
- return state.loadedFonts.has(fontKey);
716
- });
717
- },
718
- [state.loadedFonts]
719
- );
720
- const getFontFamily = useCallback(
721
- (fontFamily2, options2 = {}) => {
722
- const fontKey = `${fontFamily2}-${JSON.stringify(options2)}`;
723
- return state.loadedFonts.get(fontKey);
724
- },
725
- [state.loadedFonts]
726
- );
727
- const getFontError = useCallback(
728
- (fontFamily2) => {
729
- return state.errorFonts.get(fontFamily2);
730
- },
731
- [state.errorFonts]
732
- );
733
- const clearErrors = useCallback(() => {
734
- setState((prev) => ({
735
- ...prev,
736
- errorFonts: /* @__PURE__ */ new Map()
737
- }));
738
- }, []);
739
- return {
740
- // State
741
- loadedFonts: state.loadedFonts,
742
- loadingFonts: state.loadingFonts,
743
- errorFonts: state.errorFonts,
744
- // Actions
745
- loadFont: loadFont2,
746
- loadMultipleFonts: loadMultipleFonts2,
747
- isFontReady,
748
- areFontsReady,
749
- getFontFamily,
750
- getFontError,
751
- clearErrors
752
- };
753
- };
754
- var useFont = (fontFamily2, options = {}) => {
755
- const { loadFont: loadFont2, isFontReady, getFontFamily, getFontError, ...rest } = useFontLoader(options);
756
- const [isLoaded, setIsLoaded] = useState(false);
757
- const [error, setError] = useState(null);
758
- const initialFontFamily = getFontFamily(fontFamily2, options) || `"${fontFamily2}", sans-serif`;
759
- const [fontFamilyValue, setFontFamilyValue] = useState(initialFontFamily);
760
- useEffect(() => {
761
- const loadFontAsync = async () => {
762
- try {
763
- const cssValue = await loadFont2(fontFamily2, options);
764
- setFontFamilyValue(cssValue);
765
- setIsLoaded(true);
766
- setError(null);
767
- } catch (err) {
768
- setError(err instanceof Error ? err : new Error(String(err)));
769
- setIsLoaded(false);
770
- }
771
- };
772
- if (!isFontReady(fontFamily2, options)) {
773
- loadFontAsync();
774
- } else {
775
- const cachedValue = getFontFamily(fontFamily2, options);
776
- if (cachedValue) {
777
- setFontFamilyValue(cachedValue);
778
- }
779
- setIsLoaded(true);
780
- }
781
- }, [fontFamily2, loadFont2, isFontReady, getFontFamily, options]);
782
- return {
783
- isLoaded,
784
- error,
785
- isReady: isFontReady(fontFamily2, options),
786
- fontFamily: fontFamilyValue,
787
- ...rest
788
- };
789
- };
790
-
791
- // src/components/atoms/TextAtom.tsx
792
- var Atom3 = ({ data }) => {
793
- const [isFontLoading, setIsFontLoading] = useState2(false);
794
- const { isLoaded, error, isReady, fontFamily: fontFamily2 } = useFont(
795
- data.font?.family || "Inter",
796
- {
797
- weights: data.font?.weights || ["400"],
798
- subsets: data.font?.subsets || ["latin"],
799
- display: data.font?.display || "swap",
800
- preload: data.font?.preload !== false
801
- }
802
- );
803
- useEffect2(() => {
804
- if (data.font?.family) {
805
- setIsFontLoading(true);
806
- if (isReady || isLoaded) {
807
- setIsFontLoading(false);
808
- }
809
- }
810
- }, [data.font, isReady, isLoaded]);
811
- const enhancedStyle = {
812
- fontFamily: fontFamily2,
813
- opacity: isFontLoading ? 0.8 : 1,
814
- // Slight opacity during loading
815
- transition: "opacity 0.2s ease-in-out",
816
- ...data.style
817
- };
818
- if (error) {
819
- console.warn(`Font loading error for ${data.font?.family}:`, error);
820
- }
821
- return /* @__PURE__ */ React9.createElement(
822
- "div",
823
- {
824
- style: enhancedStyle,
825
- className: data.className,
826
- "data-font-loading": isFontLoading,
827
- "data-font-loaded": isReady || isLoaded
828
- },
829
- data.text
830
- );
831
- };
832
- var config4 = {
833
- displayName: "TextAtom",
834
- type: "atom",
835
- isInnerSequence: false
836
- };
837
-
838
- // src/components/atoms/VideoAtom.tsx
839
- import React10, { useMemo as useMemo2 } from "react";
840
- import { staticFile as staticFile2, Video, useCurrentFrame as useCurrentFrame2, useVideoConfig as useVideoConfig2 } from "remotion";
841
- import { z } from "zod";
842
- var VideoAtomDataProps = z.object({
843
- src: z.string(),
844
- // Video source URL
845
- style: z.record(z.string(), z.any()).optional(),
846
- // CSS styles object
847
- className: z.string().optional(),
848
- // CSS class names
849
- startFrom: z.number().optional(),
850
- // Start playback from this time (seconds)
851
- endAt: z.number().optional(),
852
- // End playback at this time (seconds)
853
- playbackRate: z.number().optional(),
854
- // Playback speed multiplier
855
- volume: z.number().optional(),
856
- // Volume level (0-1)
857
- muted: z.boolean().optional(),
858
- // Mute video audio
859
- loop: z.boolean().optional(),
860
- // Whether to loop the video
861
- fit: z.enum(["contain", "cover", "fill", "none", "scale-down"]).optional()
862
- // Object fit style
863
- });
864
- var Atom4 = ({ data }) => {
865
- const { fps } = useVideoConfig2();
866
- const frame = useCurrentFrame2();
867
- const source = useMemo2(() => {
868
- if (data.src.startsWith("http")) {
869
- return data.src;
870
- }
871
- return staticFile2(data.src);
872
- }, [data.src]);
873
- const trimBefore = useMemo2(() => {
874
- return data.startFrom ? data.startFrom * fps : void 0;
875
- }, [data.startFrom, fps]);
876
- const trimAfter = useMemo2(() => {
877
- return data.endAt ? data.endAt * fps : void 0;
878
- }, [data.endAt, fps]);
879
- const combinedStyle = useMemo2(() => {
880
- const baseStyle = data.style || {};
881
- const objectFit = data.fit ? { objectFit: data.fit } : {};
882
- return { ...baseStyle, ...objectFit };
883
- }, [data.style, data.fit]);
884
- return /* @__PURE__ */ React10.createElement(
885
- Video,
886
- {
887
- className: data.className,
888
- src: source,
889
- style: combinedStyle,
890
- trimBefore,
891
- trimAfter,
892
- playbackRate: data.playbackRate,
893
- volume: data.volume,
894
- muted: data.muted,
895
- loop: data.loop
896
- }
897
- );
898
- };
899
- var config5 = {
900
- displayName: "VideoAtom",
901
- type: "atom",
902
- isInnerSequence: false
903
- };
904
-
905
- // src/components/atoms/AudioAtom.tsx
906
- import React11, { useMemo as useMemo3 } from "react";
907
- import { Audio, staticFile as staticFile3, useCurrentFrame as useCurrentFrame3, useVideoConfig as useVideoConfig3 } from "remotion";
908
- import { z as z2 } from "zod";
909
- var AudioAtomMutedRangeProps = z2.object({
910
- type: z2.literal("range"),
911
- values: z2.array(z2.object({
912
- start: z2.number(),
913
- // Start time in seconds
914
- end: z2.number()
915
- // End time in seconds
916
- }))
917
- });
918
- var AudioAtomMutedFullProps = z2.object({
919
- type: z2.literal("full"),
920
- value: z2.boolean()
921
- // true = muted, false = unmuted
922
- });
923
- var AudioAtomDataProps = z2.object({
924
- src: z2.string(),
925
- // Audio source URL
926
- startFrom: z2.number().optional(),
927
- // Start playback from this time (seconds)
928
- endAt: z2.number().optional(),
929
- // End playback at this time (seconds)
930
- volume: z2.number().optional(),
931
- // Volume level (0-1)
932
- playbackRate: z2.number().optional(),
933
- // Playback speed multiplier
934
- muted: z2.union([AudioAtomMutedFullProps, AudioAtomMutedRangeProps]).optional()
935
- // Mute configuration
936
- });
937
- var Atom5 = ({ data }) => {
938
- const { fps } = useVideoConfig3();
939
- const { muted } = data;
940
- const frame = useCurrentFrame3();
941
- const isMuted = useMemo3(() => {
942
- if (muted?.type === "full") {
943
- return muted.value;
944
- }
945
- if (muted?.type === "range") {
946
- return muted?.values.some(
947
- (value) => frame >= value.start * fps && frame <= value.end * fps
948
- );
949
- }
950
- return false;
951
- }, [muted, frame, fps]);
952
- const source = useMemo3(() => {
953
- if (data.src.startsWith("http")) {
954
- return data.src;
955
- }
956
- return staticFile3(data.src);
957
- }, [data.src]);
958
- return (
959
- // @ts-ignore
960
- /* @__PURE__ */ React11.createElement(
961
- Audio,
962
- {
963
- src: source,
964
- trimBefore: data.startFrom ? data.startFrom * fps : void 0,
965
- trimAfter: data.endAt ? data.endAt * fps : void 0,
966
- volume: data.volume,
967
- playbackRate: data.playbackRate,
968
- muted: isMuted
969
- }
970
- )
971
- );
972
- };
973
- var config6 = {
974
- displayName: "AudioAtom",
975
- type: "atom",
976
- isInnerSequence: false
977
- };
978
-
979
- // src/components/atoms/TextAtomWithFonts.tsx
980
- import React12, { useEffect as useEffect3, useState as useState3 } from "react";
981
- var Atom6 = ({ data }) => {
982
- const [isFontLoading, setIsFontLoading] = useState3(false);
983
- const { isLoaded, error, isReady, fontFamily: fontFamily2 } = useFont(
984
- data.font?.family || "Inter",
985
- {
986
- weights: data.font?.weights || ["400"],
987
- subsets: data.font?.subsets || ["latin"],
988
- display: data.font?.display || "swap",
989
- preload: data.font?.preload !== false,
990
- onLoad: (family, cssValue) => {
991
- console.log(`Font ${family} loaded successfully with CSS value: ${cssValue}`);
992
- setIsFontLoading(false);
993
- },
994
- onError: (family, error2) => {
995
- console.warn(`Font ${family} failed to load:`, error2);
996
- setIsFontLoading(false);
997
- }
998
- }
999
- );
1000
- useEffect3(() => {
1001
- if (data.font?.family) {
1002
- if (isReady || isLoaded) {
1003
- setIsFontLoading(false);
1004
- } else if (!isReady && !isLoaded && !error) {
1005
- setIsFontLoading(true);
1006
- }
1007
- }
1008
- }, [data.font, isReady, isLoaded, error]);
1009
- const enhancedStyle = {
1010
- fontFamily: fontFamily2,
1011
- opacity: isFontLoading ? 0.8 : 1,
1012
- transition: "opacity 0.3s ease-in-out, font-family 0.2s ease-in-out",
1013
- ...data.style
1014
- };
1015
- if (isFontLoading && data.loadingState?.showLoadingIndicator) {
1016
- return /* @__PURE__ */ React12.createElement("div", { style: enhancedStyle, className: data.className }, /* @__PURE__ */ React12.createElement("span", { style: data.loadingState.loadingStyle }, data.loadingState.loadingText || "Loading..."));
1017
- }
1018
- if (error && data.errorState?.showErrorIndicator) {
1019
- return /* @__PURE__ */ React12.createElement("div", { style: enhancedStyle, className: data.className }, /* @__PURE__ */ React12.createElement("span", { style: data.errorState.errorStyle }, data.errorState.errorText || data.text));
1020
- }
1021
- return /* @__PURE__ */ React12.createElement(
1022
- "div",
1023
- {
1024
- style: enhancedStyle,
1025
- className: data.className,
1026
- "data-font-loading": isFontLoading,
1027
- "data-font-loaded": isReady || isLoaded,
1028
- "data-font-error": !!error,
1029
- "data-font-family": data.font?.family || "system"
1030
- },
1031
- data.text
1032
- );
1033
- };
1034
- var config7 = {
1035
- displayName: "TextAtomWithFonts",
1036
- type: "atom",
1037
- isInnerSequence: false
1038
- };
1039
-
1040
- // src/components/atoms/index.ts
1041
- registerComponent(
1042
- config2.displayName,
1043
- Atom,
1044
- "atom",
1045
- config2
1046
- );
1047
- registerComponent(
1048
- config3.displayName,
1049
- Atom2,
1050
- "atom",
1051
- config3
1052
- );
1053
- registerComponent(config4.displayName, Atom3, "atom", config4);
1054
- registerComponent(
1055
- config5.displayName,
1056
- Atom4,
1057
- "atom",
1058
- config5
1059
- );
1060
- registerComponent(
1061
- config6.displayName,
1062
- Atom5,
1063
- "atom",
1064
- config6
1065
- );
1066
- registerComponent(
1067
- config7.displayName,
1068
- Atom6,
1069
- "atom",
1070
- config7
1071
- );
1072
-
1073
- // src/components/effects/BlurEffect.tsx
1074
- import React13 from "react";
1075
- var BlurEffect = ({
1076
- data,
1077
- children
1078
- }) => {
1079
- const blurAmount = data?.blur || 5;
1080
- return /* @__PURE__ */ React13.createElement("div", { style: {
1081
- filter: `blur(${blurAmount}px)`,
1082
- width: "100%",
1083
- height: "100%"
1084
- } }, children);
1085
- };
1086
- var config8 = {
1087
- displayName: "blur",
1088
- description: "Applies a blur effect to its children",
1089
- category: "effects",
1090
- props: {
1091
- blur: {
1092
- type: "number",
1093
- description: "Blur amount in pixels",
1094
- default: 5
1095
- }
1096
- }
1097
- };
1098
-
1099
- // src/components/effects/Loop.tsx
1100
- import React14 from "react";
1101
- import { Loop } from "remotion";
1102
- var LoopEffect = ({
1103
- data,
1104
- children,
1105
- context
1106
- }) => {
1107
- const { timing } = context ?? {};
1108
- const loopData = data;
1109
- const durationInFrames = loopData?.durationInFrames || timing?.durationInFrames || 50;
1110
- const times = loopData?.times ?? Infinity;
1111
- const layout = loopData?.layout || "absolute-fill";
1112
- return (
1113
- // @ts-ignore
1114
- /* @__PURE__ */ React14.createElement(
1115
- Loop,
1116
- {
1117
- durationInFrames,
1118
- times,
1119
- layout
1120
- },
1121
- /* @__PURE__ */ React14.createElement(React14.Fragment, null, children)
1122
- )
1123
- );
1124
- };
1125
- var config9 = {
1126
- displayName: "loop",
1127
- type: "layout",
1128
- isInnerSequence: false,
1129
- props: {
1130
- durationInFrames: {
1131
- type: "number",
1132
- description: "How many frames one iteration of the loop should be long",
1133
- default: 50
1134
- },
1135
- times: {
1136
- type: "number",
1137
- description: "How many times to loop the content (defaults to Infinity)",
1138
- default: void 0
1139
- },
1140
- layout: {
1141
- type: "string",
1142
- description: 'Either "absolute-fill" (default) or "none"',
1143
- default: "absolute-fill"
1144
- }
1145
- }
1146
- };
1147
-
1148
- // src/components/effects/Pan.tsx
1149
- import React15, { useMemo as useMemo4 } from "react";
1150
- import { useCurrentFrame as useCurrentFrame4, useVideoConfig as useVideoConfig4, interpolate as interpolate2, spring, Easing as Easing2 } from "remotion";
1151
- var parseDuration = (duration, contextDuration, fps) => {
1152
- if (!duration) return contextDuration;
1153
- if (typeof duration === "number") {
1154
- return duration * fps;
1155
- }
1156
- if (typeof duration === "string" && duration.endsWith("%")) {
1157
- const percentage = parseFloat(duration.replace("%", "")) / 100;
1158
- return Math.floor(contextDuration * percentage);
1159
- }
1160
- return contextDuration;
1161
- };
1162
- var parseDelay = (delay, contextDuration, fps) => {
1163
- if (!delay) return 0;
1164
- if (typeof delay === "number") {
1165
- return delay * fps;
1166
- }
1167
- if (typeof delay === "string" && delay.endsWith("%")) {
1168
- const percentage = parseFloat(delay) / 100;
1169
- return Math.floor(contextDuration * percentage);
1170
- }
1171
- return 0;
1172
- };
1173
- var getPanDistance = (progress, panDistance) => {
1174
- if (typeof panDistance === "number") {
1175
- return panDistance;
1176
- }
1177
- if (Array.isArray(panDistance)) {
1178
- if (panDistance.length === 0) return 0;
1179
- if (panDistance.length === 1) return panDistance[0][1];
1180
- for (let i = 0; i < panDistance.length - 1; i++) {
1181
- const [currentProgress, currentDistance] = panDistance[i];
1182
- const [nextProgress, nextDistance] = panDistance[i + 1];
1183
- if (progress >= currentProgress && progress <= nextProgress) {
1184
- const localProgress = (progress - currentProgress) / (nextProgress - currentProgress);
1185
- return interpolate2(localProgress, [0, 1], [currentDistance, nextDistance]);
1186
- }
1187
- }
1188
- return panDistance[panDistance.length - 1][1];
1189
- }
1190
- return 0;
1191
- };
1192
- var getPosition = (position) => {
1193
- if (!position) return [0.5, 0.5];
1194
- if (Array.isArray(position)) {
1195
- return position;
1196
- }
1197
- const positions = {
1198
- "top-left": [0, 0],
1199
- "top": [0.5, 0],
1200
- "top-right": [1, 0],
1201
- "left": [0, 0.5],
1202
- "center": [0.5, 0.5],
1203
- "right": [1, 0.5],
1204
- "bottom-left": [0, 1],
1205
- "bottom": [0.5, 1],
1206
- "bottom-right": [1, 1]
1207
- };
1208
- return positions[position] || [0.5, 0.5];
1209
- };
1210
- var getEasingFunction = (animationType) => {
1211
- switch (animationType) {
1212
- case "linear":
1213
- return Easing2.linear;
1214
- case "ease-in":
1215
- return Easing2.in(Easing2.ease);
1216
- case "ease-out":
1217
- return Easing2.out(Easing2.ease);
1218
- case "ease-in-out":
1219
- return Easing2.inOut(Easing2.ease);
1220
- default:
1221
- return Easing2.linear;
1222
- }
1223
- };
1224
- var getPanVector = (direction, distance) => {
1225
- switch (direction) {
1226
- case "left":
1227
- return [-distance, 0];
1228
- case "right":
1229
- return [distance, 0];
1230
- case "up":
1231
- return [0, -distance];
1232
- case "down":
1233
- return [0, distance];
1234
- case "diagonal":
1235
- return [distance * 0.707, distance * 0.707];
1236
- // 45-degree diagonal
1237
- default:
1238
- return [0, 0];
1239
- }
1240
- };
1241
- var PanEffect = ({
1242
- data,
1243
- children,
1244
- context
1245
- }) => {
1246
- const frame = useCurrentFrame4();
1247
- const { fps } = useVideoConfig4();
1248
- const panData = data;
1249
- const { timing } = context ?? {};
1250
- const contextDuration = timing?.durationInFrames || 50;
1251
- const effectTiming = panData?.effectTiming || "start";
1252
- const panDuration = parseDuration(panData?.panDuration, contextDuration, fps);
1253
- const panStartDelay = parseDelay(panData?.panStartDelay, contextDuration, fps);
1254
- const panEndDelay = parseDelay(panData?.panEndDelay, contextDuration, fps);
1255
- const panDirection = panData?.panDirection || "right";
1256
- let panDistance = panData?.panDistance || 100;
1257
- const loopTimes = panData?.loopTimes || 0;
1258
- const panStartPosition = getPosition(panData?.panStartPosition);
1259
- const panEndPosition = getPosition(panData?.panEndPosition);
1260
- const animationType = panData?.animationType || "linear";
1261
- if (loopTimes > 0 && typeof panDistance === "number") {
1262
- const loopedPanDistance = [];
1263
- for (let i = 0; i < loopTimes; i++) {
1264
- const loopProgress = i / loopTimes;
1265
- const nextLoopProgress = (i + 1) / loopTimes;
1266
- loopedPanDistance.push([loopProgress, 0]);
1267
- loopedPanDistance.push([loopProgress + (nextLoopProgress - loopProgress) * 0.5, panDistance]);
1268
- loopedPanDistance.push([nextLoopProgress, 0]);
1269
- }
1270
- panDistance = loopedPanDistance;
1271
- }
1272
- let progress;
1273
- if (animationType === "spring") {
1274
- progress = spring({
1275
- frame,
1276
- fps,
1277
- config: {
1278
- stiffness: 100,
1279
- damping: 10,
1280
- mass: 1
1281
- },
1282
- durationInFrames: panDuration,
1283
- delay: effectTiming === "start" ? panStartDelay : contextDuration - panEndDelay - panDuration
1284
- });
1285
- } else {
1286
- let animationFrame;
1287
- if (effectTiming === "start") {
1288
- animationFrame = frame - panStartDelay;
1289
- } else {
1290
- animationFrame = frame - (contextDuration - panEndDelay - panDuration);
1291
- }
1292
- const easing = getEasingFunction(animationType);
1293
- progress = interpolate2(
1294
- animationFrame,
1295
- [0, panDuration],
1296
- [0, 1],
1297
- {
1298
- easing,
1299
- extrapolateLeft: "clamp",
1300
- extrapolateRight: "clamp"
1301
- }
1302
- );
1303
- }
1304
- let panOffset;
1305
- if (panDirection === "custom") {
1306
- const [startX, startY] = panStartPosition;
1307
- const [endX, endY] = panEndPosition;
1308
- const offsetX = (endX - startX) * 100;
1309
- const offsetY = (endY - startY) * 100;
1310
- panOffset = [
1311
- interpolate2(progress, [0, 1], [0, offsetX]),
1312
- interpolate2(progress, [0, 1], [0, offsetY])
1313
- ];
1314
- } else {
1315
- const distance = getPanDistance(progress, panDistance);
1316
- const [vectorX, vectorY] = getPanVector(panDirection, distance);
1317
- panOffset = [vectorX, vectorY];
1318
- }
1319
- const style = useMemo4(() => {
1320
- return {
1321
- width: "100%",
1322
- height: "100%",
1323
- transform: `translate(${panOffset[0]}px, ${panOffset[1]}px)`
1324
- };
1325
- }, [panOffset]);
1326
- return /* @__PURE__ */ React15.createElement("div", { style }, children);
1327
- };
1328
- var config10 = {
1329
- displayName: "pan",
1330
- type: "layout",
1331
- isInnerSequence: false,
1332
- props: {
1333
- effectTiming: {
1334
- type: "string",
1335
- description: 'When the pan effect should occur: "start" or "end"',
1336
- default: "start"
1337
- },
1338
- panDuration: {
1339
- type: "string",
1340
- description: 'Duration of the pan animation in seconds or percentage (e.g., "2" or "50%")',
1341
- default: void 0
1342
- },
1343
- panStart: {
1344
- type: "number",
1345
- description: "Start time of pan in seconds",
1346
- default: 0
1347
- },
1348
- panEnd: {
1349
- type: "number",
1350
- description: "End time of pan in seconds",
1351
- default: void 0
1352
- },
1353
- panStartDelay: {
1354
- type: "string",
1355
- description: "Delay before pan starts in seconds or percentage",
1356
- default: 0
1357
- },
1358
- panEndDelay: {
1359
- type: "string",
1360
- description: "Delay before video ends in seconds or percentage",
1361
- default: 0
1362
- },
1363
- panDirection: {
1364
- type: "string",
1365
- description: 'Direction of pan: "left", "right", "up", "down", "diagonal", or "custom"',
1366
- default: "right"
1367
- },
1368
- panDistance: {
1369
- type: "string",
1370
- description: "Pan distance in pixels or array of [progress, distance] pairs",
1371
- default: 100
1372
- },
1373
- panStartPosition: {
1374
- type: "string",
1375
- description: "Starting position: [x, y] coordinates or position string (top-left, center, etc.)",
1376
- default: "center"
1377
- },
1378
- panEndPosition: {
1379
- type: "string",
1380
- description: "Ending position: [x, y] coordinates or position string (top-left, center, etc.)",
1381
- default: "center"
1382
- },
1383
- animationType: {
1384
- type: "string",
1385
- description: 'Animation curve: "linear", "spring", "ease-in", "ease-out", "ease-in-out"',
1386
- default: "linear"
1387
- }
1388
- }
1389
- };
1390
-
1391
- // src/components/effects/Zoom.tsx
1392
- import React16, { useMemo as useMemo5 } from "react";
1393
- import { useCurrentFrame as useCurrentFrame5, useVideoConfig as useVideoConfig5, interpolate as interpolate3, spring as spring2, Easing as Easing3 } from "remotion";
1394
- var parseDuration2 = (duration, contextDuration, fps) => {
1395
- if (!duration) return contextDuration;
1396
- if (typeof duration === "number") {
1397
- return duration * fps;
1398
- }
1399
- if (typeof duration === "string" && duration.endsWith("%")) {
1400
- const percentage = parseFloat(duration.replace("%", "")) / 100;
1401
- return Math.floor(contextDuration * percentage);
1402
- }
1403
- return contextDuration;
1404
- };
1405
- var parseDelay2 = (delay, contextDuration, fps) => {
1406
- if (!delay) return 0;
1407
- if (typeof delay === "number") {
1408
- return delay * fps;
1409
- }
1410
- if (typeof delay === "string" && delay.endsWith("%")) {
1411
- const percentage = parseFloat(delay) / 100;
1412
- return Math.floor(contextDuration * percentage);
1413
- }
1414
- return 0;
1415
- };
1416
- var getZoomScale = (progress, zoomDepth) => {
1417
- if (typeof zoomDepth === "number") {
1418
- return zoomDepth;
1419
- }
1420
- if (Array.isArray(zoomDepth)) {
1421
- if (zoomDepth.length === 0) return 1;
1422
- if (zoomDepth.length === 1) return zoomDepth[0][1];
1423
- for (let i = 0; i < zoomDepth.length - 1; i++) {
1424
- const [currentProgress, currentScale] = zoomDepth[i];
1425
- const [nextProgress, nextScale] = zoomDepth[i + 1];
1426
- if (progress >= currentProgress && progress <= nextProgress) {
1427
- const localProgress = (progress - currentProgress) / (nextProgress - currentProgress);
1428
- return interpolate3(localProgress, [0, 1], [currentScale, nextScale]);
1429
- }
1430
- }
1431
- return zoomDepth[zoomDepth.length - 1][1];
1432
- }
1433
- return 1;
1434
- };
1435
- var getZoomPosition = (position) => {
1436
- if (!position) return [0.5, 0.5];
1437
- if (Array.isArray(position)) {
1438
- return position;
1439
- }
1440
- const positions = {
1441
- "top-left": [0, 0],
1442
- "top": [0.5, 0],
1443
- "top-right": [1, 0],
1444
- "left": [0, 0.5],
1445
- "center": [0.5, 0.5],
1446
- "right": [1, 0.5],
1447
- "bottom-left": [0, 1],
1448
- "bottom": [0.5, 1],
1449
- "bottom-right": [1, 1]
1450
- };
1451
- return positions[position] || [0.5, 0.5];
1452
- };
1453
- var getEasingFunction2 = (animationType) => {
1454
- switch (animationType) {
1455
- case "linear":
1456
- return Easing3.linear;
1457
- case "ease-in":
1458
- return Easing3.in(Easing3.ease);
1459
- case "ease-out":
1460
- return Easing3.out(Easing3.ease);
1461
- case "ease-in-out":
1462
- return Easing3.inOut(Easing3.ease);
1463
- default:
1464
- return Easing3.linear;
1465
- }
1466
- };
1467
- var ZoomEffect = ({
1468
- data,
1469
- children,
1470
- context
1471
- }) => {
1472
- const frame = useCurrentFrame5();
1473
- const { fps } = useVideoConfig5();
1474
- const zoomData = data;
1475
- const { timing } = context ?? {};
1476
- const contextDuration = timing?.durationInFrames || 50;
1477
- console.log(contextDuration);
1478
- const effectTiming = zoomData?.effectTiming || "start";
1479
- const zoomDuration = parseDuration2(zoomData?.zoomDuration, contextDuration, fps);
1480
- const zoomStartDelay = parseDelay2(zoomData?.zoomStartDelay, contextDuration, fps);
1481
- const zoomEndDelay = parseDelay2(zoomData?.zoomEndDelay, contextDuration, fps);
1482
- const zoomDirection = zoomData?.zoomDirection || "in";
1483
- let zoomDepth = zoomData?.zoomDepth || 1.5;
1484
- const loopTimes = zoomData?.loopTimes || 0;
1485
- if (loopTimes > 1 && Array.isArray(zoomDepth)) {
1486
- const loopedZoomDepth = [];
1487
- for (let i = 0; i < loopTimes; i++) {
1488
- const loopProgress = i / loopTimes;
1489
- const nextLoopProgress = (i + 1) / loopTimes;
1490
- zoomDepth.forEach(([x, y]) => {
1491
- const mappedX = loopProgress + x * (nextLoopProgress - loopProgress);
1492
- loopedZoomDepth.push([mappedX, y]);
1493
- });
1494
- }
1495
- zoomDepth = loopedZoomDepth;
1496
- } else if (loopTimes > 0 && typeof zoomDepth === "number") {
1497
- const loopedZoomDepth = [];
1498
- for (let i = 0; i < loopTimes; i++) {
1499
- const loopProgress = i / loopTimes;
1500
- const nextLoopProgress = (i + 1) / loopTimes;
1501
- loopedZoomDepth.push([loopProgress, 1]);
1502
- loopedZoomDepth.push([loopProgress + (nextLoopProgress - loopProgress) * 0.5, zoomDepth]);
1503
- loopedZoomDepth.push([nextLoopProgress, 1]);
1504
- }
1505
- zoomDepth = loopedZoomDepth;
1506
- }
1507
- const zoomPosition = getZoomPosition(zoomData?.zoomPosition);
1508
- const animationType = zoomData?.animationType || "linear";
1509
- let progress;
1510
- if (animationType === "spring") {
1511
- progress = spring2({
1512
- frame,
1513
- fps,
1514
- config: {
1515
- stiffness: 100,
1516
- damping: 10,
1517
- mass: 1
1518
- },
1519
- durationInFrames: zoomDuration,
1520
- delay: effectTiming === "start" ? zoomStartDelay : contextDuration - zoomEndDelay - zoomDuration
1521
- });
1522
- } else {
1523
- let animationFrame;
1524
- if (effectTiming === "start") {
1525
- animationFrame = frame - zoomStartDelay;
1526
- } else {
1527
- animationFrame = frame - (contextDuration - zoomEndDelay - zoomDuration);
1528
- }
1529
- const easing = getEasingFunction2(animationType);
1530
- progress = interpolate3(
1531
- animationFrame,
1532
- [0, zoomDuration],
1533
- [0, 1],
1534
- {
1535
- easing,
1536
- extrapolateLeft: "clamp",
1537
- extrapolateRight: "clamp"
1538
- }
1539
- );
1540
- }
1541
- let scale;
1542
- if (typeof zoomDepth === "number") {
1543
- const baseScale = zoomDirection === "in" ? 1 : zoomDepth;
1544
- const targetScale = zoomDirection === "in" ? zoomDepth : 1;
1545
- scale = interpolate3(progress, [0, 1], [baseScale, targetScale]);
1546
- } else if (Array.isArray(zoomDepth)) {
1547
- scale = getZoomScale(progress, zoomDepth);
1548
- } else {
1549
- const baseScale = zoomDirection === "in" ? 1 : 1.5;
1550
- const targetScale = zoomDirection === "in" ? 1.5 : 1;
1551
- scale = interpolate3(progress, [0, 1], [baseScale, targetScale]);
1552
- }
1553
- const [originX, originY] = zoomPosition;
1554
- const transformOrigin = `${originX * 100}% ${originY * 100}%`;
1555
- const style = useMemo5(() => {
1556
- return {
1557
- width: "100%",
1558
- height: "100%",
1559
- transform: `scale(${scale})`,
1560
- transformOrigin
1561
- };
1562
- }, [scale, transformOrigin]);
1563
- return /* @__PURE__ */ React16.createElement("div", { style }, children);
1564
- };
1565
- var config11 = {
1566
- displayName: "zoom",
1567
- type: "layout",
1568
- isInnerSequence: false,
1569
- props: {
1570
- effectTiming: {
1571
- type: "string",
1572
- description: 'When the zoom effect should occur: "start" or "end"',
1573
- default: "start"
1574
- },
1575
- zoomDuration: {
1576
- type: "string",
1577
- description: 'Duration of the zoom animation in seconds or percentage (e.g., "2" or "50%")',
1578
- default: void 0
1579
- },
1580
- zoomStart: {
1581
- type: "number",
1582
- description: "Start time of zoom in seconds",
1583
- default: 0
1584
- },
1585
- zoomEnd: {
1586
- type: "number",
1587
- description: "End time of zoom in seconds",
1588
- default: void 0
1589
- },
1590
- zoomStartDelay: {
1591
- type: "string",
1592
- description: "Delay before zoom starts in seconds or percentage",
1593
- default: 0
1594
- },
1595
- zoomEndDelay: {
1596
- type: "string",
1597
- description: "Delay before video ends in seconds or percentage",
1598
- default: 0
1599
- },
1600
- zoomDirection: {
1601
- type: "string",
1602
- description: 'Direction of zoom: "in" or "out"',
1603
- default: "in"
1604
- },
1605
- zoomDepth: {
1606
- type: "string",
1607
- description: "Zoom scale factor or array of [progress, scale] pairs",
1608
- default: 1.5
1609
- },
1610
- zoomPosition: {
1611
- type: "string",
1612
- description: "Zoom anchor point: [x, y] coordinates or position string (top-left, center, etc.)",
1613
- default: "center"
1614
- },
1615
- animationType: {
1616
- type: "string",
1617
- description: 'Animation curve: "linear", "spring", "ease-in", "ease-out", "ease-in-out"',
1618
- default: "linear"
1619
- }
1620
- }
1621
- };
1622
-
1623
- // src/components/effects/index.ts
1624
- registerEffect(config8.displayName, BlurEffect, config8);
1625
- registerEffect(config9.displayName, LoopEffect, config9);
1626
- registerEffect(config10.displayName, PanEffect, config10);
1627
- registerEffect(config11.displayName, ZoomEffect, config11);
1628
-
1629
- // src/hooks/useComponentRegistry.ts
1630
- import { useMemo as useMemo6 } from "react";
1631
- var useComponentRegistry = () => {
1632
- return useMemo6(() => {
1633
- return {
1634
- registerComponent: componentRegistry.registerComponent.bind(componentRegistry),
1635
- registerPackage: componentRegistry.registerPackage.bind(componentRegistry),
1636
- getComponent: componentRegistry.getComponent.bind(componentRegistry),
1637
- getAllComponents: componentRegistry.getAllComponents.bind(componentRegistry)
1638
- };
1639
- }, []);
1640
- };
1641
-
1642
- // src/hooks/useBoundaryCalculation.ts
1643
- import { useMemo as useMemo7 } from "react";
1644
- var useBoundaryCalculation = ({
1645
- parentBoundaries,
1646
- constraints,
1647
- layout
1648
- }) => {
1649
- return useMemo7(() => {
1650
- const { x, y, width, height } = parentBoundaries;
1651
- const calculatedX = typeof constraints.x === "number" ? constraints.x : x;
1652
- const calculatedY = typeof constraints.y === "number" ? constraints.y : y;
1653
- const calculatedWidth = typeof constraints.width === "number" ? constraints.width : width;
1654
- const calculatedHeight = typeof constraints.height === "number" ? constraints.height : height;
1655
- return {
1656
- x: calculatedX,
1657
- y: calculatedY,
1658
- width: calculatedWidth,
1659
- height: calculatedHeight,
1660
- zIndex: constraints.zIndex || 0
1661
- };
1662
- }, [parentBoundaries, constraints, layout]);
1663
- };
1664
-
1665
- // src/hooks/buildTransitionHook.ts
1666
- import { useContext as useContext4 } from "react";
1667
-
1668
- // src/core/types/transition.types.ts
1669
- import { createContext as createContext3, useContext as useContext3 } from "react";
1670
- var LayoutContext = createContext3(null);
1671
-
1672
- // src/hooks/buildTransitionHook.ts
1673
- function buildLayoutHook(schema, defaultValue) {
1674
- return () => {
1675
- const context = useContext4(LayoutContext);
1676
- if (!context) {
1677
- return defaultValue;
1678
- }
1679
- try {
1680
- const validatedData = schema.parse(context);
1681
- return validatedData;
1682
- } catch (error) {
1683
- console.warn("Transition data validation failed, using defaults:", error);
1684
- return defaultValue;
1685
- }
1686
- };
1687
- }
1688
-
1689
- // src/utils/contextUtils.ts
1690
- var createRootContext = (width, height, duration, fps) => {
1691
- return {
1692
- boundaries: {
1693
- left: 0,
1694
- top: 0,
1695
- width,
1696
- height,
1697
- zIndex: 0
1698
- },
1699
- timing: {
1700
- startInFrames: 0,
1701
- durationInFrames: duration
1702
- },
1703
- hierarchy: {
1704
- depth: 0,
1705
- parentIds: []
1706
- }
1707
- };
1708
- };
1709
- var mergeContexts = (parent, child) => {
1710
- return {
1711
- boundaries: {
1712
- ...parent.boundaries,
1713
- ...child.boundaries
1714
- },
1715
- timing: { ...parent.timing, ...child.timing },
1716
- hierarchy: {
1717
- depth: (parent.hierarchy?.depth || 0) + 1,
1718
- parentIds: [...parent.hierarchy?.parentIds || [], "root"]
1719
- }
1720
- };
1721
- };
1722
-
1723
- // src/utils/boundaryUtils.ts
1724
- var calculateGridPosition = (index, columns, cellWidth, cellHeight, spacing) => {
1725
- const row = Math.floor(index / columns);
1726
- const col = index % columns;
1727
- return {
1728
- x: col * (cellWidth + spacing),
1729
- y: row * (cellHeight + spacing),
1730
- width: cellWidth,
1731
- height: cellHeight
1732
- };
1733
- };
1734
- var calculateCircularPosition = (index, total, radius, centerX, centerY) => {
1735
- const angle = index / total * 2 * Math.PI;
1736
- return {
1737
- x: centerX + radius * Math.cos(angle),
1738
- y: centerY + radius * Math.sin(angle)
1739
- };
1740
- };
1741
-
1742
- // src/templates/rings/NextjsLogo.tsx
1743
- import { evolvePath } from "@remotion/paths";
1744
- import React19, { useMemo as useMemo8 } from "react";
1745
- import { interpolate as interpolate4, spring as spring4, useCurrentFrame as useCurrentFrame7, useVideoConfig as useVideoConfig7 } from "remotion";
1746
-
1747
- // src/templates/rings/RippleOutLayout.tsx
1748
- import React18 from "react";
1749
- import { spring as spring3, useCurrentFrame as useCurrentFrame6, useVideoConfig as useVideoConfig6, Sequence as Sequence2, AbsoluteFill as AbsoluteFill4 } from "remotion";
1750
- import { z as z3 } from "zod";
1751
- import { loadFont } from "@remotion/google-fonts/Inter";
1752
- loadFont("normal", {
1753
- subsets: ["latin"],
1754
- weights: ["400", "700"]
1755
- });
1756
- var RippleOutTransitionSchema = z3.object({
1757
- progress: z3.number().min(0).max(1),
1758
- logoOut: z3.number().min(0).max(1)
1759
- });
1760
- var defaultRippleOutData = {
1761
- progress: 0,
1762
- logoOut: 0
1763
- };
1764
- var useRippleOutLayout = buildLayoutHook(
1765
- RippleOutTransitionSchema,
1766
- defaultRippleOutData
1767
- );
1768
- var container = {
1769
- backgroundColor: "white"
1770
- };
1771
- var RippleOutLayout = ({ data, context, children }) => {
1772
- const {
1773
- transitionStart,
1774
- transitionDuration
1775
- } = data || { transitionStart: 2, transitionDuration: 1 };
1776
- const frame = useCurrentFrame6();
1777
- const { fps } = useVideoConfig6();
1778
- const { hierarchy } = useRenderContext();
1779
- const transitionStartFrame = transitionStart * fps;
1780
- const transitionDurationFrames = transitionDuration * fps;
1781
- const logoOut = spring3({
1782
- fps,
1783
- frame,
1784
- config: {
1785
- damping: 200
1786
- },
1787
- durationInFrames: transitionDurationFrames,
1788
- delay: transitionStartFrame
1789
- });
1790
- const transitionData = {
1791
- progress: logoOut,
1792
- logoOut
1793
- };
1794
- const childrenArray = React18.Children.toArray(children).filter(
1795
- (child) => React18.isValidElement(child)
1796
- );
1797
- const [from, to] = childrenArray;
1798
- return /* @__PURE__ */ React18.createElement(LayoutContext.Provider, { value: transitionData }, /* @__PURE__ */ React18.createElement(AbsoluteFill4, { style: {
1799
- ...container,
1800
- ...context?.boundaries
1801
- } }, /* @__PURE__ */ React18.createElement(Sequence2, { name: from.props.componentId + " - " + from.props.id, from: 0, durationInFrames: transitionStartFrame + transitionDurationFrames }, from), /* @__PURE__ */ React18.createElement(Sequence2, { name: to.props.componentId + " - " + to.props.id, from: transitionStartFrame + transitionDurationFrames / 2 }, to)));
1802
- };
1803
- var rippleOutLayoutConfig = {
1804
- displayName: "RippleOutLayout",
1805
- type: "layout",
1806
- isInnerSequence: true
1807
- };
1808
-
1809
- // src/templates/rings/NextjsLogo.tsx
1810
- var mask = {
1811
- maskType: "alpha"
1812
- };
1813
- var nStroke = "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
1814
- var NextjsLogo = () => {
1815
- const { logoOut } = useRippleOutLayout();
1816
- const outProgress = logoOut;
1817
- const { fps } = useVideoConfig7();
1818
- const frame = useCurrentFrame7();
1819
- const evolve1 = spring4({
1820
- fps,
1821
- frame,
1822
- config: {
1823
- damping: 200
1824
- }
1825
- });
1826
- const evolve2 = spring4({
1827
- fps,
1828
- frame: frame - 15,
1829
- config: {
1830
- damping: 200
1831
- }
1832
- });
1833
- const evolve3 = spring4({
1834
- fps,
1835
- frame: frame - 30,
1836
- config: {
1837
- damping: 200,
1838
- mass: 3
1839
- },
1840
- durationInFrames: 30
1841
- });
1842
- const style = useMemo8(() => {
1843
- return {
1844
- height: 140,
1845
- borderRadius: 70,
1846
- scale: String(1 - outProgress)
1847
- };
1848
- }, [outProgress]);
1849
- const firstPath = `M 60.0568 54 v 71.97`;
1850
- const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
1851
- const thirdPath = `M 121 54 L 121 126`;
1852
- const evolution1 = evolvePath(evolve1, firstPath);
1853
- const evolution2 = evolvePath(evolve2, secondPath);
1854
- const evolution3 = evolvePath(
1855
- interpolate4(evolve3, [0, 1], [0, 0.7]),
1856
- thirdPath
1857
- );
1858
- return /* @__PURE__ */ React19.createElement("svg", { style, fill: "none", viewBox: "0 0 180 180" }, /* @__PURE__ */ React19.createElement("mask", { height: "180", id: "mask", style: mask, width: "180", x: "0", y: "0" }, /* @__PURE__ */ React19.createElement("circle", { cx: "90", cy: "90", fill: "black", r: "90" })), /* @__PURE__ */ React19.createElement("mask", { id: "n-mask", style: mask }, /* @__PURE__ */ React19.createElement("path", { d: nStroke, fill: "black" })), /* @__PURE__ */ React19.createElement("g", { mask: "url(#mask)" }, /* @__PURE__ */ React19.createElement("circle", { cx: "90", cy: "90", fill: "black", r: "90" }), /* @__PURE__ */ React19.createElement("g", { stroke: "url(#gradient0)", mask: "url(#n-mask)" }, /* @__PURE__ */ React19.createElement(
1859
- "path",
1860
- {
1861
- strokeWidth: "12.1136",
1862
- d: firstPath,
1863
- strokeDasharray: evolution1.strokeDasharray,
1864
- strokeDashoffset: evolution1.strokeDashoffset
1865
- }
1866
- ), /* @__PURE__ */ React19.createElement(
1867
- "path",
1868
- {
1869
- strokeWidth: 12.1136,
1870
- d: secondPath,
1871
- strokeDasharray: evolution2.strokeDasharray,
1872
- strokeDashoffset: evolution2.strokeDashoffset
1873
- }
1874
- )), /* @__PURE__ */ React19.createElement(
1875
- "path",
1876
- {
1877
- stroke: "url(#gradient1)",
1878
- d: thirdPath,
1879
- strokeDasharray: evolution3.strokeDasharray,
1880
- strokeDashoffset: evolution3.strokeDashoffset,
1881
- strokeWidth: "12"
1882
- }
1883
- )), /* @__PURE__ */ React19.createElement("defs", null, /* @__PURE__ */ React19.createElement(
1884
- "linearGradient",
1885
- {
1886
- gradientUnits: "userSpaceOnUse",
1887
- id: "gradient0",
1888
- x1: "109",
1889
- x2: "144.5",
1890
- y1: "116.5",
1891
- y2: "160.5"
1892
- },
1893
- /* @__PURE__ */ React19.createElement("stop", { stopColor: "white" }),
1894
- /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
1895
- ), /* @__PURE__ */ React19.createElement(
1896
- "linearGradient",
1897
- {
1898
- gradientUnits: "userSpaceOnUse",
1899
- id: "gradient1",
1900
- x1: "121",
1901
- x2: "120.799",
1902
- y1: "54",
1903
- y2: "106.875"
1904
- },
1905
- /* @__PURE__ */ React19.createElement("stop", { stopColor: "white" }),
1906
- /* @__PURE__ */ React19.createElement("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
1907
- )));
1908
- };
1909
- var nextjsLogoConfig = {
1910
- displayName: "NextjsLogo",
1911
- type: "atom",
1912
- isInnerSequence: false
1913
- };
1914
-
1915
- // src/templates/rings/Rings.tsx
1916
- import React20 from "react";
1917
- import { AbsoluteFill as AbsoluteFill5, interpolateColors, useVideoConfig as useVideoConfig8 } from "remotion";
1918
- var RadialGradient = ({ radius, color }) => {
1919
- const height = radius * 2;
1920
- const width = radius * 2;
1921
- return (
1922
- // @ts-ignore
1923
- /* @__PURE__ */ React20.createElement(
1924
- AbsoluteFill5,
1925
- {
1926
- style: {
1927
- justifyContent: "center",
1928
- alignItems: "center"
1929
- }
1930
- },
1931
- /* @__PURE__ */ React20.createElement(
1932
- "div",
1933
- {
1934
- style: {
1935
- height,
1936
- width,
1937
- borderRadius: "50%",
1938
- backgroundColor: color,
1939
- position: "absolute",
1940
- boxShadow: "0 0 100px rgba(0, 0, 0, 0.05)"
1941
- }
1942
- }
1943
- )
1944
- )
1945
- );
1946
- };
1947
- var Rings = ({ context, data }) => {
1948
- const { logoOut } = useRippleOutLayout();
1949
- const outProgress = logoOut;
1950
- const scale = 1 / (1 - outProgress);
1951
- const { height } = useVideoConfig8();
1952
- return (
1953
- // @ts-ignore
1954
- /* @__PURE__ */ React20.createElement(
1955
- AbsoluteFill5,
1956
- {
1957
- style: {
1958
- transform: `scale(${scale})`,
1959
- ...context?.boundaries
1960
- }
1961
- },
1962
- new Array(5).fill(true).map((_, i) => {
1963
- return /* @__PURE__ */ React20.createElement(
1964
- RadialGradient,
1965
- {
1966
- key: i,
1967
- radius: height * 0.3 * i,
1968
- color: interpolateColors(i, [0, 4], ["#fff", "#fff"])
1969
- }
1970
- );
1971
- }).reverse()
1972
- )
1973
- );
1974
- };
1975
- var ringsConfig = {
1976
- displayName: "Rings",
1977
- type: "atom",
1978
- isInnerSequence: false
1979
- };
1980
-
1981
- // src/templates/rings/TextFade.tsx
1982
- import React21, { useMemo as useMemo9 } from "react";
1983
- import {
1984
- AbsoluteFill as AbsoluteFill6,
1985
- interpolate as interpolate5,
1986
- spring as spring5,
1987
- useCurrentFrame as useCurrentFrame8,
1988
- useVideoConfig as useVideoConfig9
1989
- } from "remotion";
1990
- var TextFade = (props) => {
1991
- const { children, context, data } = props;
1992
- const { animation } = data || {
1993
- animation: {
1994
- duration: 1
1995
- }
1996
- };
1997
- const { fps } = useVideoConfig9();
1998
- const frame = useCurrentFrame8();
1999
- const progress = spring5({
2000
- fps,
2001
- frame,
2002
- config: {
2003
- damping: 200
2004
- },
2005
- durationInFrames: animation.duration * fps
2006
- });
2007
- const rightStop = interpolate5(progress, [0, 1], [200, 0]);
2008
- const leftStop = Math.max(0, rightStop - 60);
2009
- const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
2010
- const container2 = useMemo9(() => {
2011
- return {
2012
- width: "100%",
2013
- height: "100%",
2014
- justifyContent: "center",
2015
- alignItems: "center"
2016
- };
2017
- }, []);
2018
- const content = useMemo9(() => {
2019
- return {
2020
- ...context?.boundaries,
2021
- maskImage,
2022
- WebkitMaskImage: maskImage,
2023
- justifyContent: "center",
2024
- alignItems: "center",
2025
- display: "flex"
2026
- };
2027
- }, [maskImage]);
2028
- return (
2029
- // @ts-ignore
2030
- /* @__PURE__ */ React21.createElement(AbsoluteFill6, { style: container2 }, /* @__PURE__ */ React21.createElement("div", { style: content }, children))
2031
- );
2032
- };
2033
- var textFadeConfig = {
2034
- displayName: "TextFade",
2035
- type: "layout",
2036
- isInnerSequence: false
2037
- };
2038
-
2039
- // src/templates/rings/index.ts
2040
- registerComponent(
2041
- nextjsLogoConfig.displayName,
2042
- NextjsLogo,
2043
- "atom",
2044
- nextjsLogoConfig
2045
- );
2046
- registerComponent(
2047
- textFadeConfig.displayName,
2048
- TextFade,
2049
- "layout",
2050
- textFadeConfig
2051
- );
2052
- registerComponent(ringsConfig.displayName, Rings, "atom", ringsConfig);
2053
- registerComponent(
2054
- rippleOutLayoutConfig.displayName,
2055
- RippleOutLayout,
2056
- "layout",
2057
- rippleOutLayoutConfig
2058
- );
2059
-
2060
- // src/templates/waveform/components/WaveformCircle.tsx
2061
- import React23, { useMemo as useMemo11 } from "react";
2062
-
2063
- // src/templates/waveform/Waveform.tsx
2064
- import React22, { createContext as createContext4, useContext as useContext5 } from "react";
2065
- import { useCurrentFrame as useCurrentFrame9, useVideoConfig as useVideoConfig10 } from "remotion";
2066
-
2067
- // src/templates/waveform/hooks/useWaveformData.ts
2068
- import { useMemo as useMemo10 } from "react";
2069
- import {
2070
- useAudioData,
2071
- visualizeAudioWaveform,
2072
- visualizeAudio
2073
- } from "@remotion/media-utils";
2074
- import { staticFile as staticFile4 } from "remotion";
2075
- var isValidPowerOfTwo = (num) => {
2076
- return num > 0 && (num & num - 1) === 0;
2077
- };
2078
- var getClosestPowerOfTwo = (num) => {
2079
- if (num <= 0) return 32;
2080
- let power = 1;
2081
- while (power < num) {
2082
- power *= 2;
2083
- }
2084
- const lower = power / 2;
2085
- const upper = power;
2086
- return Math.abs(num - lower) < Math.abs(num - upper) ? lower : upper;
2087
- };
2088
- var useWaveformData = (config12) => {
2089
- const {
2090
- audioSrc,
2091
- numberOfSamples,
2092
- windowInSeconds,
2093
- dataOffsetInSeconds = 0,
2094
- normalize = false,
2095
- frame,
2096
- fps,
2097
- posterize,
2098
- includeFrequencyData = false,
2099
- minDb = -100,
2100
- maxDb = -30
2101
- } = config12;
2102
- const validatedNumberOfSamples = useMemo10(() => {
2103
- if (!isValidPowerOfTwo(numberOfSamples)) {
2104
- console.warn(
2105
- `numberOfSamples must be a power of 2. Adjusting ${numberOfSamples} to ${getClosestPowerOfTwo(numberOfSamples)}`
2106
- );
2107
- return getClosestPowerOfTwo(numberOfSamples);
2108
- }
2109
- return numberOfSamples;
2110
- }, [numberOfSamples]);
2111
- const source = useMemo10(() => {
2112
- if (audioSrc.startsWith("http")) {
2113
- return audioSrc;
2114
- }
2115
- return staticFile4(audioSrc);
2116
- }, [audioSrc]);
2117
- const audioData = useAudioData(source);
2118
- const adjustedFrame = useMemo10(() => {
2119
- if (posterize && posterize > 1) {
2120
- return Math.round(frame / posterize) * posterize;
2121
- }
2122
- return frame;
2123
- }, [frame, posterize]);
2124
- const waveformData = useMemo10(() => {
2125
- if (!audioData) return null;
2126
- try {
2127
- const waveform = visualizeAudioWaveform({
2128
- fps,
2129
- frame: adjustedFrame,
2130
- audioData,
2131
- numberOfSamples: validatedNumberOfSamples,
2132
- windowInSeconds,
2133
- dataOffsetInSeconds,
2134
- normalize
2135
- });
2136
- return waveform;
2137
- } catch (error2) {
2138
- console.error("Error generating waveform:", error2);
2139
- return null;
2140
- }
2141
- }, [
2142
- audioData,
2143
- adjustedFrame,
2144
- fps,
2145
- validatedNumberOfSamples,
2146
- windowInSeconds,
2147
- dataOffsetInSeconds,
2148
- normalize
2149
- ]);
2150
- const {
2151
- frequencyData,
2152
- amplitudes,
2153
- bass,
2154
- mid,
2155
- treble,
2156
- bassValues,
2157
- midValues,
2158
- trebleValues
2159
- } = useMemo10(() => {
2160
- if (!audioData || !includeFrequencyData) {
2161
- return {
2162
- frequencyData: null,
2163
- amplitudes: null,
2164
- bass: null,
2165
- mid: null,
2166
- treble: null,
2167
- bassValues: null,
2168
- midValues: null,
2169
- trebleValues: null
2170
- };
2171
- }
2172
- try {
2173
- const frequencyData2 = visualizeAudio({
2174
- fps,
2175
- frame: adjustedFrame,
2176
- audioData,
2177
- numberOfSamples: validatedNumberOfSamples
2178
- });
2179
- const { sampleRate } = audioData;
2180
- const bassValues2 = [];
2181
- const midValues2 = [];
2182
- const trebleValues2 = [];
2183
- for (let i = 0; i < frequencyData2.length; i++) {
2184
- const freq = i * sampleRate / (2 * frequencyData2.length);
2185
- const value = frequencyData2[i];
2186
- if (freq >= 0 && freq < 250) {
2187
- bassValues2.push(value * 2.5);
2188
- } else if (freq >= 250 && freq < 4e3) {
2189
- midValues2.push(value * 3);
2190
- midValues2.push(value * 4.5);
2191
- midValues2.push(value * 5);
2192
- } else if (freq >= 4e3 && freq < sampleRate / 2) {
2193
- trebleValues2.push(value * 30);
2194
- }
2195
- }
2196
- const getAverage = (arr) => arr.length > 0 ? arr.reduce((a, b) => a + b, 0) / arr.length : 0;
2197
- const bass2 = getAverage(bassValues2);
2198
- const mid2 = getAverage(midValues2);
2199
- const treble2 = getAverage(trebleValues2);
2200
- const amplitudes2 = frequencyData2.map((value) => {
2201
- const db = 20 * Math.log10(value);
2202
- const scaled = (db - minDb) / (maxDb - minDb);
2203
- return Math.max(0, Math.min(1, scaled));
2204
- });
2205
- return {
2206
- frequencyData: frequencyData2,
2207
- amplitudes: amplitudes2,
2208
- bass: bass2,
2209
- mid: mid2,
2210
- treble: treble2,
2211
- bassValues: bassValues2,
2212
- midValues: midValues2,
2213
- trebleValues: trebleValues2.reverse()
2214
- };
2215
- } catch (error2) {
2216
- console.error("Error generating frequency data:", error2);
2217
- return {
2218
- frequencyData: null,
2219
- amplitudes: null,
2220
- bass: null,
2221
- mid: null,
2222
- treble: null
2223
- };
2224
- }
2225
- }, [
2226
- audioData,
2227
- includeFrequencyData,
2228
- adjustedFrame,
2229
- fps,
2230
- validatedNumberOfSamples,
2231
- windowInSeconds,
2232
- dataOffsetInSeconds,
2233
- minDb,
2234
- maxDb
2235
- ]);
2236
- const isLoading = !audioData;
2237
- const error = audioData === null && !isLoading ? "Failed to load audio data" : null;
2238
- return {
2239
- waveformData,
2240
- frequencyData,
2241
- amplitudes,
2242
- audioData,
2243
- isLoading,
2244
- error,
2245
- bass,
2246
- bassValues,
2247
- mid,
2248
- midValues,
2249
- treble,
2250
- trebleValues
2251
- };
2252
- };
2253
-
2254
- // src/templates/waveform/Waveform.tsx
2255
- var WaveformContext = createContext4(null);
2256
- var useWaveformContext = () => {
2257
- const context = useContext5(WaveformContext);
2258
- if (!context) {
2259
- throw new Error("useWaveformContext must be used within a Waveform component");
2260
- }
2261
- return context;
2262
- };
2263
- var Waveform = ({
2264
- config: config12,
2265
- children,
2266
- className = "",
2267
- style = {}
2268
- }) => {
2269
- const frame = useCurrentFrame9();
2270
- const { width: videoWidth, height: videoHeight, fps } = useVideoConfig10();
2271
- const { waveformData, frequencyData, amplitudes, audioData, bass, mid, treble, bassValues, midValues, trebleValues } = useWaveformData({
2272
- audioSrc: config12.audioSrc,
2273
- numberOfSamples: config12.numberOfSamples || 128,
2274
- windowInSeconds: config12.windowInSeconds || 1 / fps,
2275
- dataOffsetInSeconds: config12.dataOffsetInSeconds || 0,
2276
- normalize: config12.normalize || false,
2277
- frame,
2278
- fps,
2279
- posterize: config12.posterize,
2280
- includeFrequencyData: config12.useFrequencyData || false
2281
- });
2282
- const width = config12.width || videoWidth;
2283
- const height = config12.height || videoHeight;
2284
- const contextValue = {
2285
- waveformData,
2286
- frequencyData,
2287
- amplitudes,
2288
- audioData,
2289
- frame,
2290
- fps,
2291
- config: config12,
2292
- width,
2293
- height,
2294
- bass,
2295
- mid,
2296
- treble,
2297
- bassValues,
2298
- midValues,
2299
- trebleValues
2300
- };
2301
- return /* @__PURE__ */ React22.createElement(WaveformContext.Provider, { value: contextValue }, /* @__PURE__ */ React22.createElement(
2302
- "div",
2303
- {
2304
- className: `relative ${className}`,
2305
- style: {
2306
- width,
2307
- height,
2308
- position: "relative",
2309
- backgroundColor: config12.backgroundColor || "transparent",
2310
- ...style
2311
- }
2312
- },
2313
- children
2314
- ));
2315
- };
2316
-
2317
- // src/templates/waveform/components/WaveformCircle.tsx
2318
- var WaveformCircle = ({ data }) => {
2319
- const {
2320
- config: config12,
2321
- className = "",
2322
- style = {},
2323
- strokeColor = "#FF6B6B",
2324
- strokeWidth = 3,
2325
- fill = "none",
2326
- opacity = 1,
2327
- radius = 80,
2328
- centerX = 50,
2329
- centerY = 50,
2330
- startAngle = 0,
2331
- endAngle = 360,
2332
- amplitude = 1,
2333
- rotationSpeed = 0,
2334
- gradientStartColor,
2335
- gradientEndColor
2336
- } = data;
2337
- return /* @__PURE__ */ React23.createElement(Waveform, { config: config12, className, style }, /* @__PURE__ */ React23.createElement(
2338
- WaveformCircleContent,
2339
- {
2340
- strokeColor,
2341
- strokeWidth,
2342
- fill,
2343
- opacity,
2344
- radius,
2345
- centerX,
2346
- centerY,
2347
- startAngle,
2348
- endAngle,
2349
- amplitude,
2350
- rotationSpeed,
2351
- gradientStartColor,
2352
- gradientEndColor
2353
- }
2354
- ));
2355
- };
2356
- var WaveformCircleContent = ({
2357
- strokeColor,
2358
- strokeWidth,
2359
- fill,
2360
- opacity,
2361
- radius,
2362
- centerX,
2363
- centerY,
2364
- startAngle,
2365
- endAngle,
2366
- amplitude,
2367
- rotationSpeed,
2368
- gradientStartColor,
2369
- gradientEndColor
2370
- }) => {
2371
- const { waveformData, width, height, frame } = useWaveformContext();
2372
- const circleRadius = Math.min(width, height) * (radius || 80) / 100;
2373
- const circleCenterX = width * (centerX || 50) / 100;
2374
- const circleCenterY = height * (centerY || 50) / 100;
2375
- const rotation = frame * (rotationSpeed || 0) % 360;
2376
- const circularPath = useMemo11(() => {
2377
- if (!waveformData) return "";
2378
- const totalAngle = (endAngle || 360) - (startAngle || 0);
2379
- const angleStep = totalAngle / waveformData.length;
2380
- let path = "";
2381
- waveformData.forEach((value, index) => {
2382
- const angle = ((startAngle || 0) + index * angleStep + rotation) * (Math.PI / 180);
2383
- const waveRadius = circleRadius + value * (amplitude || 1) * circleRadius * 0.3;
2384
- const x = circleCenterX + waveRadius * Math.cos(angle);
2385
- const y = circleCenterY + waveRadius * Math.sin(angle);
2386
- if (index === 0) {
2387
- path += `M ${x} ${y}`;
2388
- } else {
2389
- path += ` L ${x} ${y}`;
2390
- }
2391
- });
2392
- if (Math.abs((endAngle || 360) - (startAngle || 0)) >= 360) {
2393
- path += " Z";
2394
- }
2395
- return path;
2396
- }, [waveformData, circleRadius, circleCenterX, circleCenterY, startAngle, endAngle, rotation, amplitude]);
2397
- if (!waveformData) {
2398
- return /* @__PURE__ */ React23.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading circular waveform...");
2399
- }
2400
- const gradientId = "circle-waveform-gradient";
2401
- const hasGradient = gradientStartColor && gradientEndColor;
2402
- return /* @__PURE__ */ React23.createElement(
2403
- "svg",
2404
- {
2405
- width,
2406
- height,
2407
- className: "absolute inset-0",
2408
- style: { pointerEvents: "none" }
2409
- },
2410
- hasGradient && /* @__PURE__ */ React23.createElement("defs", null, /* @__PURE__ */ React23.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%" }, /* @__PURE__ */ React23.createElement("stop", { offset: "0%", stopColor: gradientStartColor }), /* @__PURE__ */ React23.createElement("stop", { offset: "100%", stopColor: gradientEndColor }))),
2411
- /* @__PURE__ */ React23.createElement(
2412
- "path",
2413
- {
2414
- d: circularPath,
2415
- stroke: hasGradient ? `url(#${gradientId})` : strokeColor,
2416
- strokeWidth,
2417
- fill,
2418
- opacity,
2419
- strokeLinecap: "round",
2420
- strokeLinejoin: "round"
2421
- }
2422
- )
2423
- );
2424
- };
2425
-
2426
- // src/templates/waveform/components/WaveformHistogram.tsx
2427
- import React24 from "react";
2428
- var WaveformHistogram = ({ data }) => {
2429
- const {
2430
- config: config12,
2431
- className = "",
2432
- style = {},
2433
- barColor = "#FF6B6B",
2434
- barWidth = 4,
2435
- barSpacing = 2,
2436
- barBorderRadius = 2,
2437
- opacity = 1,
2438
- horizontalSymmetry = true,
2439
- verticalMirror = false,
2440
- histogramStyle = "centered",
2441
- amplitude = 1,
2442
- multiplier = 1,
2443
- gradientStartColor,
2444
- gradientEndColor,
2445
- gradientDirection = "vertical",
2446
- gradientStyle = "normal",
2447
- waveDirection = "right-to-left"
2448
- } = data;
2449
- return /* @__PURE__ */ React24.createElement(Waveform, { config: config12, className, style }, /* @__PURE__ */ React24.createElement(
2450
- WaveformHistogramContent,
2451
- {
2452
- barColor,
2453
- barWidth,
2454
- barSpacing,
2455
- barBorderRadius,
2456
- opacity,
2457
- horizontalSymmetry,
2458
- verticalMirror,
2459
- histogramStyle,
2460
- amplitude,
2461
- gradientStartColor,
2462
- gradientEndColor,
2463
- gradientDirection,
2464
- multiplier,
2465
- gradientStyle,
2466
- waveDirection
2467
- }
2468
- ));
2469
- };
2470
- var WaveformHistogramContent = ({
2471
- barColor,
2472
- barWidth,
2473
- barSpacing,
2474
- barBorderRadius,
2475
- opacity,
2476
- horizontalSymmetry,
2477
- verticalMirror,
2478
- histogramStyle,
2479
- amplitude,
2480
- gradientStartColor,
2481
- gradientEndColor,
2482
- gradientDirection,
2483
- multiplier,
2484
- gradientStyle,
2485
- waveDirection
2486
- }) => {
2487
- const { waveformData, frequencyData, amplitudes, width, height } = useWaveformContext();
2488
- const dataToUse = amplitudes || waveformData;
2489
- if (!dataToUse) {
2490
- return /* @__PURE__ */ React24.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading histogram...");
2491
- }
2492
- let directedData = waveDirection === "left-to-right" ? dataToUse.slice(1).reverse() : dataToUse;
2493
- const frequencies = horizontalSymmetry ? [...directedData, ...directedData.slice(1).reverse()] : Array(multiplier).fill(directedData).flat();
2494
- const Bars = ({ growUpwards }) => {
2495
- const styleGradientProp = gradientStartColor && gradientEndColor ? {
2496
- background: `linear-gradient(${gradientDirection === "horizontal" ? gradientStyle === "mirrored" ? "to right" : growUpwards ? "to right" : "to left" : gradientStyle === "normal" ? growUpwards ? "to top" : "to bottom" : "to bottom"}, ${gradientStartColor}, ${gradientEndColor})`
2497
- } : { backgroundColor: barColor };
2498
- const containerStyle2 = {
2499
- display: "flex",
2500
- flexDirection: "row",
2501
- alignItems: growUpwards ? "flex-end" : "flex-start",
2502
- height: "100%",
2503
- width: "100%",
2504
- ...histogramStyle === "centered" && {
2505
- justifyContent: "center",
2506
- gap: `${barSpacing}px`
2507
- },
2508
- ...histogramStyle === "full-width" && {
2509
- gap: `${barSpacing}px`,
2510
- justifyContent: "space-between"
2511
- },
2512
- opacity: gradientStyle === "mirrored" && !growUpwards ? 0.25 : 1
2513
- };
2514
- return /* @__PURE__ */ React24.createElement("div", { style: containerStyle2 }, frequencies.map((value, index) => /* @__PURE__ */ React24.createElement(
2515
- "div",
2516
- {
2517
- key: index,
2518
- style: {
2519
- ...histogramStyle === "full-width" ? { width: `${barWidth}px` } : { width: `${barWidth}px` },
2520
- ...styleGradientProp,
2521
- height: `${Math.min(
2522
- height / 2,
2523
- Math.abs(value) * (height / 2) * (amplitude || 1)
2524
- )}px`,
2525
- borderRadius: growUpwards ? `${barBorderRadius}px ${barBorderRadius}px 0 0` : `0 0 ${barBorderRadius}px ${barBorderRadius}px`,
2526
- opacity
2527
- }
2528
- }
2529
- )));
2530
- };
2531
- if (verticalMirror) {
2532
- const topHalfStyle = {
2533
- position: "absolute",
2534
- bottom: `calc(100% - ${height / 2}px)`,
2535
- height: `${height / 2}px`,
2536
- width: "100%",
2537
- left: 0
2538
- };
2539
- const bottomHalfStyle = {
2540
- position: "absolute",
2541
- top: `${height / 2}px`,
2542
- height: `${height / 2}px`,
2543
- width: "100%",
2544
- left: 0
2545
- };
2546
- return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement("div", { style: topHalfStyle }, /* @__PURE__ */ React24.createElement(Bars, { growUpwards: true })), /* @__PURE__ */ React24.createElement("div", { style: bottomHalfStyle }, /* @__PURE__ */ React24.createElement(Bars, { growUpwards: false })));
2547
- }
2548
- const containerStyle = {
2549
- width: "100%",
2550
- position: "absolute",
2551
- top: `${height / 2 - height / 4}px`,
2552
- height: `${height / 2}px`,
2553
- left: 0
2554
- };
2555
- return /* @__PURE__ */ React24.createElement("div", { style: containerStyle }, /* @__PURE__ */ React24.createElement(Bars, { growUpwards: true }));
2556
- };
2557
-
2558
- // src/templates/waveform/components/WaveformHistogramRanged.tsx
2559
- import React25 from "react";
2560
- var WaveformHistogramRanged = ({ data }) => {
2561
- const {
2562
- config: config12,
2563
- className = "",
2564
- style = {},
2565
- barColor = "#FF6B6B",
2566
- barWidth = 4,
2567
- barSpacing = 2,
2568
- barBorderRadius = 2,
2569
- opacity = 1,
2570
- verticalMirror = false,
2571
- histogramStyle = "centered",
2572
- amplitude = 1,
2573
- showFrequencyRanges = true,
2574
- rangeDividerColor = "#666",
2575
- rangeLabels = false,
2576
- bassBarColor = "#5DADE2",
2577
- midBarColor = "#58D68D",
2578
- trebleBarColor = "#F5B041",
2579
- gradientStartColor,
2580
- gradientEndColor,
2581
- gradientDirection = "vertical",
2582
- gradientStyle = "normal",
2583
- horizontalSymmetry = false,
2584
- waveDirection = "right-to-left"
2585
- } = data;
2586
- return /* @__PURE__ */ React25.createElement(Waveform, { config: config12, className, style }, /* @__PURE__ */ React25.createElement(
2587
- WaveformHistogramRangedContent,
2588
- {
2589
- barColor,
2590
- barWidth,
2591
- barSpacing,
2592
- barBorderRadius,
2593
- opacity,
2594
- verticalMirror,
2595
- histogramStyle,
2596
- amplitude,
2597
- showFrequencyRanges,
2598
- rangeDividerColor,
2599
- rangeLabels,
2600
- bassBarColor,
2601
- midBarColor,
2602
- trebleBarColor,
2603
- gradientStartColor,
2604
- gradientEndColor,
2605
- gradientDirection,
2606
- gradientStyle,
2607
- horizontalSymmetry,
2608
- waveDirection
2609
- }
2610
- ));
2611
- };
2612
- var WaveformHistogramRangedContent = ({
2613
- barColor,
2614
- barWidth,
2615
- barSpacing,
2616
- barBorderRadius,
2617
- opacity,
2618
- verticalMirror,
2619
- histogramStyle,
2620
- amplitude,
2621
- showFrequencyRanges,
2622
- rangeDividerColor,
2623
- rangeLabels,
2624
- bassBarColor,
2625
- midBarColor,
2626
- trebleBarColor,
2627
- gradientStartColor,
2628
- gradientEndColor,
2629
- gradientDirection,
2630
- gradientStyle,
2631
- horizontalSymmetry,
2632
- waveDirection
2633
- }) => {
2634
- const { amplitudes, bassValues, midValues, trebleValues, height } = useWaveformContext();
2635
- if (!amplitudes || !bassValues || !midValues || !trebleValues) {
2636
- return /* @__PURE__ */ React25.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading frequency data...");
2637
- }
2638
- const bassFrequencies = bassValues;
2639
- const midFrequencies = midValues;
2640
- const trebleFrequencies = trebleValues;
2641
- const allFrequencies = waveDirection === "right-to-left" ? [bassFrequencies, midFrequencies, trebleFrequencies].flat() : [trebleFrequencies, midFrequencies, bassFrequencies].flat();
2642
- const unifiedWaveform = horizontalSymmetry ? [...allFrequencies.slice(1).reverse(), ...allFrequencies] : allFrequencies;
2643
- const Bars = ({ growUpwards }) => {
2644
- const containerStyle2 = {
2645
- display: "flex",
2646
- flexDirection: "row",
2647
- alignItems: growUpwards ? "flex-end" : "flex-start",
2648
- height: "100%",
2649
- width: "100%",
2650
- ...histogramStyle === "centered" && {
2651
- justifyContent: "center",
2652
- gap: `${barSpacing}px`
2653
- },
2654
- ...histogramStyle === "full-width" && {
2655
- gap: `${barSpacing}px`,
2656
- justifyContent: "space-between"
2657
- },
2658
- opacity: gradientStyle === "mirrored" && !growUpwards ? 0.25 : 1
2659
- };
2660
- return /* @__PURE__ */ React25.createElement("div", { style: containerStyle2 }, unifiedWaveform.map((value, index) => {
2661
- const rangeName = index === 0 ? "Bass" : index === 1 ? "Mid" : "Treble";
2662
- const styleGradientProp = gradientStartColor && gradientEndColor ? {
2663
- background: `linear-gradient(${gradientDirection === "horizontal" ? gradientStyle === "mirrored" ? "to right" : growUpwards ? "to right" : "to left" : gradientStyle === "normal" ? growUpwards ? "to top" : "to bottom" : "to bottom"}, ${gradientStartColor}, ${gradientEndColor})`
2664
- } : { backgroundColor: barColor };
2665
- return /* @__PURE__ */ React25.createElement(
2666
- "div",
2667
- {
2668
- key: index,
2669
- style: {
2670
- width: `${barWidth || 4}px`,
2671
- // Wider bars for the three ranges
2672
- ...styleGradientProp,
2673
- height: `${Math.min(
2674
- height / 2,
2675
- Math.abs(value) * (height / 2) * (amplitude || 1)
2676
- )}px`,
2677
- borderRadius: growUpwards ? `${barBorderRadius}px ${barBorderRadius}px 0 0` : `0 0 ${barBorderRadius}px ${barBorderRadius}px`,
2678
- opacity,
2679
- position: "relative"
2680
- },
2681
- title: `${rangeName}: ${(value * 100).toFixed(1)}%`
2682
- },
2683
- rangeLabels && /* @__PURE__ */ React25.createElement("div", { style: {
2684
- position: "absolute",
2685
- bottom: growUpwards ? "-20px" : "auto",
2686
- top: growUpwards ? "auto" : "-20px",
2687
- left: "50%",
2688
- transform: "translateX(-50%)",
2689
- fontSize: "10px",
2690
- color: rangeDividerColor,
2691
- whiteSpace: "nowrap"
2692
- } }, rangeName)
2693
- );
2694
- }));
2695
- };
2696
- if (verticalMirror) {
2697
- const topHalfStyle = {
2698
- position: "absolute",
2699
- bottom: `calc(100% - ${height / 2}px)`,
2700
- height: `${height / 2}px`,
2701
- width: "100%",
2702
- left: 0
2703
- };
2704
- const bottomHalfStyle = {
2705
- position: "absolute",
2706
- top: `${height / 2}px`,
2707
- height: `${height / 2}px`,
2708
- width: "100%",
2709
- left: 0
2710
- };
2711
- return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("div", { style: topHalfStyle }, /* @__PURE__ */ React25.createElement(Bars, { growUpwards: true })), /* @__PURE__ */ React25.createElement("div", { style: bottomHalfStyle }, /* @__PURE__ */ React25.createElement(Bars, { growUpwards: false })));
2712
- }
2713
- const containerStyle = {
2714
- width: "100%",
2715
- position: "absolute",
2716
- top: `${height / 2 - height / 4}px`,
2717
- height: `${height / 2}px`,
2718
- left: 0
2719
- };
2720
- return /* @__PURE__ */ React25.createElement("div", { style: containerStyle }, /* @__PURE__ */ React25.createElement(Bars, { growUpwards: true }));
2721
- };
2722
-
2723
- // src/templates/waveform/components/WaveformLine.tsx
2724
- import React26, { useMemo as useMemo12 } from "react";
2725
- import { createSmoothSvgPath } from "@remotion/media-utils";
2726
- import { useCurrentFrame as useCurrentFrame10, useVideoConfig as useVideoConfig11 } from "remotion";
2727
- var detectBeat = (frequencyData, amplitudes, threshold = 0.7, bpm, frame = 0, fps = 30) => {
2728
- if (!frequencyData || !amplitudes || frequencyData.length === 0) return false;
2729
- if (bpm) {
2730
- const beatInterval = 60 / bpm * fps;
2731
- const beatFrame = Math.round(frame / beatInterval) * beatInterval;
2732
- return Math.abs(frame - beatFrame) < 2;
2733
- }
2734
- const bassFrequencies = amplitudes.slice(0, Math.floor(amplitudes.length * 0.15));
2735
- const midFrequencies = amplitudes.slice(Math.floor(amplitudes.length * 0.15), Math.floor(amplitudes.length * 0.4));
2736
- const bassEnergy = Math.sqrt(bassFrequencies.reduce((sum, val) => sum + val * val, 0) / bassFrequencies.length);
2737
- const midEnergy = Math.sqrt(midFrequencies.reduce((sum, val) => sum + val * val, 0) / midFrequencies.length);
2738
- const bassPeak = Math.max(...bassFrequencies);
2739
- const midPeak = Math.max(...midFrequencies);
2740
- const totalEnergy = bassEnergy * 0.6 + midEnergy * 0.2 + bassPeak * 0.15 + midPeak * 0.05;
2741
- const normalizedEnergy = Math.min(totalEnergy, 1);
2742
- return normalizedEnergy > threshold;
2743
- };
2744
- var easingFunctions = {
2745
- linear: (t) => t,
2746
- "ease-in": (t) => t * t,
2747
- "ease-out": (t) => 1 - (1 - t) * (1 - t),
2748
- "ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2,
2749
- bounce: (t) => {
2750
- if (t < 1 / 2.75) return 7.5625 * t * t;
2751
- if (t < 2 / 2.75) return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;
2752
- if (t < 2.5 / 2.75) return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;
2753
- return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
2754
- }
2755
- };
2756
- var WaveformLine = ({ data }) => {
2757
- const {
2758
- config: config12,
2759
- className = "",
2760
- style = {},
2761
- strokeColor = "#FF6B6B",
2762
- strokeWidth = 3,
2763
- strokeLinecap = "round",
2764
- strokeLinejoin = "round",
2765
- fill = "none",
2766
- opacity = 1,
2767
- centerLine = false,
2768
- centerLineColor = "#666",
2769
- centerLineWidth = 1,
2770
- beatSync = false,
2771
- bpm,
2772
- beatThreshold = 0.7,
2773
- beatAmplitudeMultiplier = 1.2,
2774
- beatAnimationDuration = 30,
2775
- smoothAnimation = true,
2776
- waveSpacing = 0.1,
2777
- waveSegments = 1,
2778
- waveOffset = 0,
2779
- waveDirection = "horizontal",
2780
- amplitudeCurve = "ease-out",
2781
- animationSpeed = 0.5,
2782
- pulseOnBeat = false,
2783
- pulseColor = "#FFD700",
2784
- pulseScale = 1.2
2785
- } = data;
2786
- return /* @__PURE__ */ React26.createElement(Waveform, { config: config12, className, style }, /* @__PURE__ */ React26.createElement(
2787
- WaveformLineContent,
2788
- {
2789
- strokeColor,
2790
- strokeWidth,
2791
- strokeLinecap,
2792
- strokeLinejoin,
2793
- fill,
2794
- opacity,
2795
- centerLine,
2796
- centerLineColor,
2797
- centerLineWidth,
2798
- beatSync,
2799
- bpm,
2800
- beatThreshold,
2801
- beatAmplitudeMultiplier,
2802
- beatAnimationDuration,
2803
- smoothAnimation,
2804
- waveSpacing,
2805
- waveSegments,
2806
- waveOffset,
2807
- waveDirection,
2808
- amplitudeCurve,
2809
- animationSpeed,
2810
- pulseOnBeat,
2811
- pulseColor,
2812
- pulseScale
2813
- }
2814
- ));
2815
- };
2816
- var WaveformLineContent = ({
2817
- strokeColor,
2818
- strokeWidth,
2819
- strokeLinecap,
2820
- strokeLinejoin,
2821
- fill,
2822
- opacity,
2823
- centerLine,
2824
- centerLineColor,
2825
- centerLineWidth,
2826
- beatSync,
2827
- bpm,
2828
- beatThreshold,
2829
- beatAmplitudeMultiplier,
2830
- beatAnimationDuration,
2831
- smoothAnimation,
2832
- waveSpacing,
2833
- waveSegments,
2834
- waveOffset,
2835
- waveDirection,
2836
- amplitudeCurve,
2837
- animationSpeed,
2838
- pulseOnBeat,
2839
- pulseColor,
2840
- pulseScale
2841
- }) => {
2842
- const { waveformData, frequencyData, amplitudes, width, height, config: config12, frame, fps } = useWaveformContext();
2843
- const currentFrame = useCurrentFrame10();
2844
- const videoConfig = useVideoConfig11();
2845
- const isBeat = useMemo12(() => {
2846
- if (!beatSync || !frequencyData || !amplitudes) return false;
2847
- return detectBeat(frequencyData, amplitudes, beatThreshold, bpm, currentFrame, fps);
2848
- }, [beatSync, frequencyData, amplitudes, beatThreshold, bpm, currentFrame, fps]);
2849
- const beatProgress = useMemo12(() => {
2850
- if (!isBeat || !beatAnimationDuration) return 0;
2851
- const beatStartFrame = Math.floor(currentFrame / beatAnimationDuration) * beatAnimationDuration;
2852
- const progress = (currentFrame - beatStartFrame) / beatAnimationDuration;
2853
- const clampedProgress = Math.max(0, Math.min(1, progress));
2854
- if (smoothAnimation) {
2855
- return 1 - Math.pow(1 - clampedProgress, 3);
2856
- }
2857
- return clampedProgress;
2858
- }, [isBeat, currentFrame, beatAnimationDuration, smoothAnimation]);
2859
- const currentBeatMultiplier = useMemo12(() => {
2860
- if (!beatSync || !isBeat || !beatAmplitudeMultiplier || !amplitudeCurve) return 1;
2861
- const easing = easingFunctions[amplitudeCurve];
2862
- const easedProgress = easing(beatProgress);
2863
- return 1 + (beatAmplitudeMultiplier - 1) * (1 - easedProgress);
2864
- }, [beatSync, isBeat, beatProgress, beatAmplitudeMultiplier, amplitudeCurve]);
2865
- const smoothFactor = useMemo12(() => {
2866
- if (!beatSync) {
2867
- return 0.3;
2868
- }
2869
- return smoothAnimation ? 0.7 : 1;
2870
- }, [beatSync, smoothAnimation]);
2871
- const waveformPaths = useMemo12(() => {
2872
- if (!waveformData) return [];
2873
- const paths = [];
2874
- const segments = waveSegments || 1;
2875
- const spacing = waveSpacing || 0.1;
2876
- const offset = waveOffset || 0;
2877
- const speed = animationSpeed || 1;
2878
- const segmentWidth = width / segments;
2879
- const segmentSpacing = segmentWidth * spacing;
2880
- for (let i = 0; i < segments; i++) {
2881
- const segmentStart = i * segmentWidth;
2882
- const segmentEnd = (i + 1) * segmentWidth;
2883
- const segmentDataWidth = segmentEnd - segmentStart;
2884
- const points = waveformData.map((y, index) => {
2885
- const progress = index / (waveformData.length - 1);
2886
- const x = segmentStart + progress * segmentDataWidth + offset;
2887
- let animatedAmplitude = y * (config12.amplitude || 1) * currentBeatMultiplier * speed;
2888
- const baseAmplitude = y * (config12.amplitude || 1) * speed;
2889
- const beatAmplitude = animatedAmplitude - baseAmplitude;
2890
- animatedAmplitude = baseAmplitude + beatAmplitude * smoothFactor;
2891
- const yPos = waveDirection === "horizontal" ? animatedAmplitude * height / 2 + height / 2 : animatedAmplitude * width / 2 + width / 2;
2892
- return waveDirection === "horizontal" ? { x, y: yPos } : { x: yPos, y: x };
2893
- });
2894
- const path = createSmoothSvgPath({ points });
2895
- paths.push({ path, segmentIndex: i });
2896
- }
2897
- return paths;
2898
- }, [waveformData, width, height, config12.amplitude, currentBeatMultiplier, animationSpeed, waveSegments, waveSpacing, waveOffset, waveDirection, smoothFactor]);
2899
- if (!waveformData) {
2900
- return /* @__PURE__ */ React26.createElement("div", { className: "flex items-center justify-center w-full h-full text-gray-500" }, "Loading waveform...");
2901
- }
2902
- return /* @__PURE__ */ React26.createElement(
2903
- "svg",
2904
- {
2905
- width,
2906
- height,
2907
- className: "absolute inset-0",
2908
- style: { pointerEvents: "none" }
2909
- },
2910
- centerLine && /* @__PURE__ */ React26.createElement(
2911
- "line",
2912
- {
2913
- x1: waveDirection === "horizontal" ? 0 : width / 2,
2914
- y1: waveDirection === "horizontal" ? height / 2 : 0,
2915
- x2: waveDirection === "horizontal" ? width : width / 2,
2916
- y2: waveDirection === "horizontal" ? height / 2 : height,
2917
- stroke: centerLineColor,
2918
- strokeWidth: centerLineWidth,
2919
- opacity: 0.3
2920
- }
2921
- ),
2922
- waveformPaths.map(({ path, segmentIndex }) => /* @__PURE__ */ React26.createElement("g", { key: segmentIndex }, pulseOnBeat && isBeat && /* @__PURE__ */ React26.createElement(
2923
- "path",
2924
- {
2925
- d: path,
2926
- stroke: pulseColor,
2927
- strokeWidth: (strokeWidth || 3) * (pulseScale || 1.2),
2928
- strokeLinecap,
2929
- strokeLinejoin,
2930
- fill: "none",
2931
- opacity: (opacity || 1) * (1 - beatProgress)
2932
- }
2933
- ), /* @__PURE__ */ React26.createElement(
2934
- "path",
2935
- {
2936
- d: path,
2937
- stroke: strokeColor,
2938
- strokeWidth,
2939
- strokeLinecap,
2940
- strokeLinejoin,
2941
- fill,
2942
- opacity
2943
- }
2944
- )))
2945
- );
2946
- };
2947
-
2948
- // src/templates/waveform/utils.ts
2949
- var WaveformPresets = {
2950
- stopgapLine: (props) => {
2951
- return {
2952
- componentId: "WaveformLine",
2953
- type: "atom",
2954
- data: {
2955
- strokeColor: "#58C4DC",
2956
- strokeWidth: 8,
2957
- strokeLinecap: "round",
2958
- opacity: 1,
2959
- amplitudeCurve: "ease-in-out",
2960
- animationSpeed: 0.15,
2961
- smoothAnimation: true,
2962
- ...props,
2963
- config: {
2964
- numberOfSamples: 64,
2965
- // Increased for better frequency resolution
2966
- windowInSeconds: 1 / 30,
2967
- amplitude: 4,
2968
- height: 300,
2969
- width: 1920 * 3,
2970
- posterize: 4,
2971
- ...props.config
2972
- }
2973
- }
2974
- };
2975
- }
2976
- };
2977
-
2978
- // src/templates/waveform/index.ts
2979
- registerComponent("WaveformLine", WaveformLine, "atom", {
2980
- displayName: "WaveformLine"
2981
- });
2982
- registerComponent("WaveformHistogram", WaveformHistogram, "atom", {
2983
- displayName: "WaveformHistogram"
2984
- });
2985
- registerComponent("WaveformHistogramRanged", WaveformHistogramRanged, "atom", {
2986
- displayName: "WaveformHistogramRanged"
2987
- });
2988
- registerComponent("WaveformCircle", WaveformCircle, "atom", {
2989
- displayName: "WaveformCircle"
2990
- });
2991
-
2992
- // src/components/Composition.tsx
2993
- import React27 from "react";
2994
- import { AbsoluteFill as AbsoluteFill7, Composition as RemotionComposition } from "remotion";
2995
-
2996
- // src/core/context/timing.ts
2997
- import { ALL_FORMATS, Input, UrlSource } from "mediabunny";
2998
- var findMatchingComponents = (childrenData, targetIds) => {
2999
- const matches = [];
3000
- const searchRecursively = (components) => {
3001
- for (const component of components) {
3002
- if (targetIds.includes(component.id)) {
3003
- matches.push(component);
3004
- }
3005
- if (component.childrenData && component.childrenData.length > 0) {
3006
- searchRecursively(component.childrenData);
3007
- }
3008
- }
3009
- };
3010
- searchRecursively(childrenData);
3011
- return matches;
3012
- };
3013
- var calculateDuration = async (childrenData, config12) => {
3014
- let calculatedDuration = void 0;
3015
- const targetIds = Array.isArray(config12.fitDurationTo) ? config12.fitDurationTo : [config12.fitDurationTo];
3016
- const matchingComponents = findMatchingComponents(
3017
- childrenData || [],
3018
- targetIds
3019
- );
3020
- if (matchingComponents.length === 1) {
3021
- if (matchingComponents[0].type === "atom" && (matchingComponents[0].componentId === "AudioAtom" || matchingComponents[0].componentId === "VideoAtom")) {
3022
- const src = matchingComponents[0].data.src;
3023
- if (src.startsWith("http")) {
3024
- const audioInput = new Input({
3025
- formats: ALL_FORMATS,
3026
- source: new UrlSource(src)
3027
- });
3028
- calculatedDuration = await audioInput.computeDuration();
3029
- } else {
3030
- }
3031
- }
3032
- }
3033
- return calculatedDuration;
3034
- };
3035
- var setDurationsInContext = async (root) => {
3036
- const iterateRecursively = async (components) => {
3037
- const updatedComponents = [];
3038
- for (const component of components) {
3039
- let updatedComponent = { ...component };
3040
- if (component.context?.timing?.fitDurationTo?.length > 0) {
3041
- const duration = await calculateDuration(component.childrenData, {
3042
- fitDurationTo: component.context?.timing?.fitDurationTo
3043
- });
3044
- updatedComponent = {
3045
- ...component,
3046
- context: {
3047
- ...component.context,
3048
- timing: {
3049
- ...component.context.timing,
3050
- duration
3051
- }
3052
- }
3053
- };
3054
- }
3055
- if (component.childrenData && component.childrenData.length > 0) {
3056
- updatedComponent.childrenData = await iterateRecursively(
3057
- component.childrenData
3058
- );
3059
- }
3060
- updatedComponents.push(updatedComponent);
3061
- }
3062
- return updatedComponents;
3063
- };
3064
- const updatedChildrenData = await iterateRecursively(root.childrenData);
3065
- return {
3066
- ...root,
3067
- childrenData: updatedChildrenData
3068
- };
3069
- };
3070
-
3071
- // src/components/Composition.tsx
3072
- var CompositionLayout = ({ childrenData, style, config: config12 }) => {
3073
- return /* @__PURE__ */ React27.createElement(
3074
- CompositionProvider,
3075
- {
3076
- value: {
3077
- root: childrenData,
3078
- duration: config12.duration
3079
- }
3080
- },
3081
- /* @__PURE__ */ React27.createElement(AbsoluteFill7, { style }, childrenData?.map((component) => /* @__PURE__ */ React27.createElement(
3082
- ComponentRenderer,
3083
- {
3084
- key: component.id,
3085
- ...component
3086
- }
3087
- )))
3088
- );
3089
- };
3090
- var calculateCompositionLayoutMetadata = async ({ props, defaultProps, abortSignal, isRendering }) => {
3091
- let calculatedDuration = void 0;
3092
- if (props.config?.fitDurationTo?.length > 0) {
3093
- calculatedDuration = await calculateDuration(props.childrenData, {
3094
- fitDurationTo: props.config.fitDurationTo
3095
- });
3096
- }
3097
- const duration = calculatedDuration ?? props.config.duration ?? defaultProps.config.duration;
3098
- const fps = props.config.fps ?? defaultProps.config.fps;
3099
- const durationInFrames = Math.round(duration * fps);
3100
- const updatedProps = await setDurationsInContext(props);
3101
- return {
3102
- // Change the metadata
3103
- durationInFrames,
3104
- // or transform some props
3105
- props: updatedProps,
3106
- // // or add per-composition default codec
3107
- // defaultCodec: 'h264',
3108
- // // or add per-composition default video image format
3109
- // defaultVideoImageFormat: 'png',
3110
- // // or add per-composition default pixel format
3111
- // defaultPixelFormat: 'yuv420p',
3112
- width: props.config?.width || defaultProps.config.width,
3113
- height: props.config?.height || defaultProps.config.height,
3114
- fps,
3115
- duration
3116
- };
3117
- };
3118
- var Composition = ({
3119
- id,
3120
- childrenData,
3121
- config: config12,
3122
- style
3123
- }) => {
3124
- return /* @__PURE__ */ React27.createElement(
3125
- RemotionComposition,
3126
- {
3127
- id,
3128
- component: CompositionLayout,
3129
- durationInFrames: Math.round(config12.duration * config12.fps),
3130
- fps: config12.fps,
3131
- defaultProps: { childrenData, style, config: config12 },
3132
- calculateMetadata: calculateCompositionLayoutMetadata
3133
- }
3134
- );
3135
- };
3136
- export {
3137
- Atom5 as AudioAtom,
3138
- config6 as AudioAtomConfig,
3139
- Layout as BaseLayout,
3140
- config as BaseLayoutConfig,
3141
- BlurEffect,
3142
- config8 as BlurEffectConfig,
3143
- ComponentRenderer,
3144
- Composition,
3145
- CompositionLayout,
3146
- CompositionProvider,
3147
- Frame,
3148
- Atom2 as ImageAtom,
3149
- config3 as ImageAtomConfig,
3150
- LoopEffect,
3151
- config9 as LoopEffectConfig,
3152
- NextjsLogo,
3153
- PanEffect,
3154
- config10 as PanEffectConfig,
3155
- Rings,
3156
- RippleOutLayout,
3157
- SceneFrame,
3158
- Atom as ShapeAtom,
3159
- config2 as ShapeAtomConfig,
3160
- Atom3 as TextAtom,
3161
- config4 as TextAtomConfig,
3162
- Atom6 as TextAtomWithFonts,
3163
- config7 as TextAtomWithFontsConfig,
3164
- TextFade,
3165
- Atom4 as VideoAtom,
3166
- config5 as VideoAtomConfig,
3167
- Waveform,
3168
- WaveformCircle,
3169
- WaveformHistogram,
3170
- WaveformHistogramRanged,
3171
- WaveformLine,
3172
- WaveformPresets,
3173
- ZoomEffect,
3174
- config11 as ZoomEffectConfig,
3175
- buildLayoutHook,
3176
- calculateCircularPosition,
3177
- calculateCompositionLayoutMetadata,
3178
- calculateGridPosition,
3179
- calculateHierarchy,
3180
- calculateTimingWithInheritance,
3181
- clearFontCache,
3182
- componentRegistry,
3183
- createRootContext,
3184
- findComponentById,
3185
- findParentComponent,
3186
- getComponent,
3187
- getComponentConfig,
3188
- getComponentWithConfig,
3189
- getLoadedFontFamily,
3190
- getLoadedFonts,
3191
- getNormalizedFontName,
3192
- isFontAvailable,
3193
- isFontLoaded,
3194
- loadGoogleFont,
3195
- loadMultipleFonts,
3196
- mergeContexts,
3197
- nextjsLogoConfig,
3198
- preloadCommonFonts,
3199
- registerComponent,
3200
- registerEffect,
3201
- registerPackage,
3202
- ringsConfig,
3203
- rippleOutLayoutConfig,
3204
- textFadeConfig,
3205
- useBoundaryCalculation,
3206
- useComponentRegistry,
3207
- useComposition,
3208
- useFont,
3209
- useFontLoader,
3210
- useRenderContext,
3211
- useRippleOutLayout,
3212
- useWaveformContext,
3213
- useWaveformData
3214
- };
3215
- //# sourceMappingURL=index.mjs.map