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