summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/effects/index.ts
blob: 14d06d848d1b6234fa8ae38a4f9974db90c90753 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { generateUUID } from "@/utils/id";
import { getEffect } from "./registry";
import type { Effect, EffectParamValues } from "@/types/effects";
import type { VisualElement } from "@/types/timeline";

export { getEffect, getAllEffects, hasEffect, registerEffect } from "./registry";
export { registerDefaultEffects } from "./definitions";

export const EFFECT_TARGET_ELEMENT_TYPES: VisualElement["type"][] = [
	"video",
	"image",
	"text",
	"sticker",
];

export function buildDefaultEffectInstance({
	effectType,
}: {
	effectType: string;
}): Effect {
	const definition = getEffect({ effectType });

	const params: EffectParamValues = {};
	for (const paramDef of definition.params) {
		params[paramDef.key] = paramDef.default;
	}

	return {
		id: generateUUID(),
		type: effectType,
		params,
		enabled: true,
	};
}