@depths/waves 0.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/LICENSE +22 -0
- package/README.md +435 -0
- package/dist/chunk-TGAL5RQN.mjs +404 -0
- package/dist/chunk-WGQITADJ.mjs +284 -0
- package/dist/cli.d.mts +3 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +1107 -0
- package/dist/cli.mjs +440 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +728 -0
- package/dist/index.mjs +40 -0
- package/dist/registry-hVIyqwS6.d.mts +355 -0
- package/dist/registry-hVIyqwS6.d.ts +355 -0
- package/dist/remotion/index.d.mts +11 -0
- package/dist/remotion/index.d.ts +11 -0
- package/dist/remotion/index.js +468 -0
- package/dist/remotion/index.mjs +58 -0
- package/package.json +79 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/remotion/index.ts
|
|
31
|
+
var remotion_exports = {};
|
|
32
|
+
__export(remotion_exports, {
|
|
33
|
+
WavesComposition: () => WavesComposition,
|
|
34
|
+
globalRegistry: () => globalRegistry,
|
|
35
|
+
registerBuiltInComponents: () => registerBuiltInComponents
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(remotion_exports);
|
|
38
|
+
|
|
39
|
+
// src/remotion/WavesComposition.tsx
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var import_remotion = require("remotion");
|
|
42
|
+
|
|
43
|
+
// src/utils/errors.ts
|
|
44
|
+
var WavesError = class _WavesError extends Error {
|
|
45
|
+
constructor(message, context) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.context = context;
|
|
48
|
+
this.name = "WavesError";
|
|
49
|
+
Object.setPrototypeOf(this, _WavesError.prototype);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var WavesRenderError = class _WavesRenderError extends WavesError {
|
|
53
|
+
constructor(message, context) {
|
|
54
|
+
super(message, context);
|
|
55
|
+
this.name = "WavesRenderError";
|
|
56
|
+
Object.setPrototypeOf(this, _WavesRenderError.prototype);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/remotion/WavesComposition.tsx
|
|
61
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
+
var WavesComposition = ({ ir, registry }) => {
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ir.scenes.map((scene) => renderComponent(scene, registry)) });
|
|
64
|
+
};
|
|
65
|
+
var getProps = (component) => {
|
|
66
|
+
return component.props ?? {};
|
|
67
|
+
};
|
|
68
|
+
var getChildren = (component) => {
|
|
69
|
+
return component.children;
|
|
70
|
+
};
|
|
71
|
+
function renderComponent(component, registry) {
|
|
72
|
+
const registration = registry.get(component.type);
|
|
73
|
+
if (!registration) {
|
|
74
|
+
throw new WavesRenderError("Unknown component type", { type: component.type });
|
|
75
|
+
}
|
|
76
|
+
const propsValidation = registry.validateProps(component.type, getProps(component));
|
|
77
|
+
if (!propsValidation.success) {
|
|
78
|
+
throw new WavesRenderError("Component props validation failed", {
|
|
79
|
+
type: component.type,
|
|
80
|
+
issues: propsValidation.error.issues
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const parsedProps = propsValidation.data;
|
|
84
|
+
if (!parsedProps || typeof parsedProps !== "object") {
|
|
85
|
+
throw new WavesRenderError("Component props must be an object", { type: component.type });
|
|
86
|
+
}
|
|
87
|
+
const children = component.type === "Scene" && getChildren(component)?.length ? getChildren(component).map((child) => renderComponent(child, registry)) : null;
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_remotion.Sequence,
|
|
90
|
+
{
|
|
91
|
+
from: component.timing.from,
|
|
92
|
+
durationInFrames: component.timing.durationInFrames,
|
|
93
|
+
children: import_react.default.createElement(
|
|
94
|
+
registration.component,
|
|
95
|
+
{
|
|
96
|
+
...parsedProps,
|
|
97
|
+
__wavesDurationInFrames: component.timing.durationInFrames
|
|
98
|
+
},
|
|
99
|
+
children
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
component.id
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/utils/json-schema.ts
|
|
107
|
+
var import_zod = require("zod");
|
|
108
|
+
function zodSchemaToJsonSchema(schema) {
|
|
109
|
+
return import_zod.z.toJSONSchema(schema);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/core/registry.ts
|
|
113
|
+
var ComponentRegistry = class {
|
|
114
|
+
components = /* @__PURE__ */ new Map();
|
|
115
|
+
register(registration) {
|
|
116
|
+
if (this.components.has(registration.type)) {
|
|
117
|
+
throw new Error(`Component type "${registration.type}" is already registered`);
|
|
118
|
+
}
|
|
119
|
+
this.components.set(registration.type, registration);
|
|
120
|
+
}
|
|
121
|
+
get(type) {
|
|
122
|
+
return this.components.get(type);
|
|
123
|
+
}
|
|
124
|
+
getTypes() {
|
|
125
|
+
return Array.from(this.components.keys());
|
|
126
|
+
}
|
|
127
|
+
has(type) {
|
|
128
|
+
return this.components.has(type);
|
|
129
|
+
}
|
|
130
|
+
getJSONSchemaForLLM() {
|
|
131
|
+
const schemas = {};
|
|
132
|
+
for (const [type, registration] of this.components) {
|
|
133
|
+
schemas[type] = {
|
|
134
|
+
schema: zodSchemaToJsonSchema(registration.propsSchema),
|
|
135
|
+
metadata: registration.metadata
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return schemas;
|
|
139
|
+
}
|
|
140
|
+
validateProps(type, props) {
|
|
141
|
+
const registration = this.components.get(type);
|
|
142
|
+
if (!registration) {
|
|
143
|
+
throw new Error(`Unknown component type: ${type}`);
|
|
144
|
+
}
|
|
145
|
+
const result = registration.propsSchema.safeParse(props);
|
|
146
|
+
if (result.success) {
|
|
147
|
+
return { success: true, data: result.data };
|
|
148
|
+
}
|
|
149
|
+
return { success: false, error: result.error };
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var globalRegistry = new ComponentRegistry();
|
|
153
|
+
|
|
154
|
+
// src/components/primitives/Audio.tsx
|
|
155
|
+
var import_remotion2 = require("remotion");
|
|
156
|
+
var import_zod2 = require("zod");
|
|
157
|
+
|
|
158
|
+
// src/utils/assets.ts
|
|
159
|
+
function isRemoteAssetPath(assetPath) {
|
|
160
|
+
return assetPath.startsWith("http://") || assetPath.startsWith("https://");
|
|
161
|
+
}
|
|
162
|
+
function staticFileInputFromAssetPath(assetPath) {
|
|
163
|
+
if (isRemoteAssetPath(assetPath)) {
|
|
164
|
+
throw new Error("Remote asset paths must not be passed to staticFile()");
|
|
165
|
+
}
|
|
166
|
+
return assetPath.startsWith("/") ? assetPath.slice(1) : assetPath;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/components/primitives/Audio.tsx
|
|
170
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
171
|
+
var AudioPropsSchema = import_zod2.z.object({
|
|
172
|
+
src: import_zod2.z.string(),
|
|
173
|
+
volume: import_zod2.z.number().min(0).max(1).default(1),
|
|
174
|
+
startFrom: import_zod2.z.number().int().min(0).default(0),
|
|
175
|
+
fadeIn: import_zod2.z.number().int().min(0).default(0),
|
|
176
|
+
fadeOut: import_zod2.z.number().int().min(0).default(0)
|
|
177
|
+
});
|
|
178
|
+
var Audio = ({
|
|
179
|
+
src,
|
|
180
|
+
volume,
|
|
181
|
+
startFrom,
|
|
182
|
+
fadeIn,
|
|
183
|
+
fadeOut,
|
|
184
|
+
__wavesDurationInFrames
|
|
185
|
+
}) => {
|
|
186
|
+
const frame = (0, import_remotion2.useCurrentFrame)();
|
|
187
|
+
const durationInFrames = __wavesDurationInFrames ?? Number.POSITIVE_INFINITY;
|
|
188
|
+
const fadeInFactor = fadeIn > 0 ? (0, import_remotion2.interpolate)(frame, [0, fadeIn], [0, 1], {
|
|
189
|
+
extrapolateLeft: "clamp",
|
|
190
|
+
extrapolateRight: "clamp"
|
|
191
|
+
}) : 1;
|
|
192
|
+
const fadeOutStart = durationInFrames - fadeOut;
|
|
193
|
+
const fadeOutFactor = fadeOut > 0 ? (0, import_remotion2.interpolate)(frame, [fadeOutStart, durationInFrames], [1, 0], {
|
|
194
|
+
extrapolateLeft: "clamp",
|
|
195
|
+
extrapolateRight: "clamp"
|
|
196
|
+
}) : 1;
|
|
197
|
+
const resolvedSrc = isRemoteAssetPath(src) ? src : (0, import_remotion2.staticFile)(staticFileInputFromAssetPath(src));
|
|
198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
199
|
+
import_remotion2.Audio,
|
|
200
|
+
{
|
|
201
|
+
src: resolvedSrc,
|
|
202
|
+
trimBefore: startFrom,
|
|
203
|
+
volume: volume * fadeInFactor * fadeOutFactor
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
var AudioComponentMetadata = {
|
|
208
|
+
category: "primitive",
|
|
209
|
+
description: "Plays an audio file with optional trimming and fade in/out",
|
|
210
|
+
llmGuidance: "Use for background music or sound effects. Prefer short clips for SFX. Use fadeIn/fadeOut (in frames) for smoother audio starts/ends."
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// src/components/primitives/Scene.tsx
|
|
214
|
+
var import_remotion3 = require("remotion");
|
|
215
|
+
var import_zod4 = require("zod");
|
|
216
|
+
|
|
217
|
+
// src/ir/schema.ts
|
|
218
|
+
var import_zod3 = require("zod");
|
|
219
|
+
var TimingSpecSchema = import_zod3.z.object({
|
|
220
|
+
from: import_zod3.z.number().int().min(0).describe("Start frame (0-indexed)"),
|
|
221
|
+
durationInFrames: import_zod3.z.number().int().positive().describe("Duration in frames")
|
|
222
|
+
});
|
|
223
|
+
var AssetPathSchema = import_zod3.z.string().refine(
|
|
224
|
+
(path) => path.startsWith("/") || path.startsWith("http://") || path.startsWith("https://"),
|
|
225
|
+
"Asset path must be absolute (starting with /) or a full URL"
|
|
226
|
+
).describe("Path to asset file, either absolute path or URL");
|
|
227
|
+
var BackgroundSpecSchema = import_zod3.z.discriminatedUnion("type", [
|
|
228
|
+
import_zod3.z.object({
|
|
229
|
+
type: import_zod3.z.literal("color"),
|
|
230
|
+
value: import_zod3.z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Must be valid hex color")
|
|
231
|
+
}),
|
|
232
|
+
import_zod3.z.object({
|
|
233
|
+
type: import_zod3.z.literal("image"),
|
|
234
|
+
value: AssetPathSchema
|
|
235
|
+
}),
|
|
236
|
+
import_zod3.z.object({
|
|
237
|
+
type: import_zod3.z.literal("video"),
|
|
238
|
+
value: AssetPathSchema
|
|
239
|
+
})
|
|
240
|
+
]);
|
|
241
|
+
var BaseComponentIRSchema = import_zod3.z.object({
|
|
242
|
+
id: import_zod3.z.string().min(1).max(100).describe("Unique component instance ID"),
|
|
243
|
+
type: import_zod3.z.string().min(1).describe("Component type identifier"),
|
|
244
|
+
timing: TimingSpecSchema,
|
|
245
|
+
metadata: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional().describe("Optional metadata")
|
|
246
|
+
});
|
|
247
|
+
var TextComponentIRSchema = BaseComponentIRSchema.extend({
|
|
248
|
+
type: import_zod3.z.literal("Text"),
|
|
249
|
+
props: import_zod3.z.object({
|
|
250
|
+
content: import_zod3.z.string().min(1).max(1e3),
|
|
251
|
+
fontSize: import_zod3.z.number().int().min(12).max(200).default(48),
|
|
252
|
+
color: import_zod3.z.string().regex(/^#[0-9A-Fa-f]{6}$/).default("#FFFFFF"),
|
|
253
|
+
position: import_zod3.z.enum(["top", "center", "bottom", "left", "right"]).default("center"),
|
|
254
|
+
animation: import_zod3.z.enum(["none", "fade", "slide", "zoom"]).default("fade")
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
var AudioComponentIRSchema = BaseComponentIRSchema.extend({
|
|
258
|
+
type: import_zod3.z.literal("Audio"),
|
|
259
|
+
props: import_zod3.z.object({
|
|
260
|
+
src: AssetPathSchema,
|
|
261
|
+
volume: import_zod3.z.number().min(0).max(1).default(1),
|
|
262
|
+
startFrom: import_zod3.z.number().int().min(0).default(0).describe("Start playback from frame N"),
|
|
263
|
+
fadeIn: import_zod3.z.number().int().min(0).default(0).describe("Fade in duration in frames"),
|
|
264
|
+
fadeOut: import_zod3.z.number().int().min(0).default(0).describe("Fade out duration in frames")
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
function getComponentIRSchema() {
|
|
268
|
+
return ComponentIRSchema;
|
|
269
|
+
}
|
|
270
|
+
var SceneComponentIRSchema = BaseComponentIRSchema.extend({
|
|
271
|
+
type: import_zod3.z.literal("Scene"),
|
|
272
|
+
props: import_zod3.z.object({
|
|
273
|
+
background: BackgroundSpecSchema
|
|
274
|
+
}),
|
|
275
|
+
children: import_zod3.z.lazy(() => import_zod3.z.array(getComponentIRSchema())).optional()
|
|
276
|
+
});
|
|
277
|
+
var ComponentIRSchema = import_zod3.z.discriminatedUnion("type", [
|
|
278
|
+
SceneComponentIRSchema,
|
|
279
|
+
TextComponentIRSchema,
|
|
280
|
+
AudioComponentIRSchema
|
|
281
|
+
]);
|
|
282
|
+
var VideoIRSchema = import_zod3.z.object({
|
|
283
|
+
version: import_zod3.z.literal("1.0").describe("IR schema version"),
|
|
284
|
+
video: import_zod3.z.object({
|
|
285
|
+
id: import_zod3.z.string().default("main"),
|
|
286
|
+
width: import_zod3.z.number().int().min(360).max(7680),
|
|
287
|
+
height: import_zod3.z.number().int().min(360).max(4320),
|
|
288
|
+
fps: import_zod3.z.number().int().min(1).max(120).default(30),
|
|
289
|
+
durationInFrames: import_zod3.z.number().int().positive()
|
|
290
|
+
}),
|
|
291
|
+
audio: import_zod3.z.object({
|
|
292
|
+
background: AssetPathSchema.optional(),
|
|
293
|
+
volume: import_zod3.z.number().min(0).max(1).default(0.5)
|
|
294
|
+
}).optional(),
|
|
295
|
+
scenes: import_zod3.z.array(SceneComponentIRSchema).min(1)
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// src/components/primitives/Scene.tsx
|
|
299
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
300
|
+
var ScenePropsSchema = import_zod4.z.object({
|
|
301
|
+
background: BackgroundSpecSchema
|
|
302
|
+
});
|
|
303
|
+
var resolveAsset = (value) => {
|
|
304
|
+
return isRemoteAssetPath(value) ? value : (0, import_remotion3.staticFile)(staticFileInputFromAssetPath(value));
|
|
305
|
+
};
|
|
306
|
+
var Scene = ({ background, children }) => {
|
|
307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_remotion3.AbsoluteFill, { children: [
|
|
308
|
+
background.type === "color" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion3.AbsoluteFill, { style: { backgroundColor: background.value } }) : background.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
309
|
+
import_remotion3.Img,
|
|
310
|
+
{
|
|
311
|
+
src: resolveAsset(background.value),
|
|
312
|
+
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
313
|
+
}
|
|
314
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
315
|
+
import_remotion3.Video,
|
|
316
|
+
{
|
|
317
|
+
src: resolveAsset(background.value),
|
|
318
|
+
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion3.AbsoluteFill, { children })
|
|
322
|
+
] });
|
|
323
|
+
};
|
|
324
|
+
var SceneComponentMetadata = {
|
|
325
|
+
category: "primitive",
|
|
326
|
+
description: "Scene container with a background and nested children",
|
|
327
|
+
llmGuidance: "Use Scene to define a segment of the video. Scene timings must be sequential with no gaps. Put Text and Audio as children."
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/components/primitives/Text.tsx
|
|
331
|
+
var import_remotion4 = require("remotion");
|
|
332
|
+
var import_zod5 = require("zod");
|
|
333
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
334
|
+
var TextPropsSchema = import_zod5.z.object({
|
|
335
|
+
content: import_zod5.z.string(),
|
|
336
|
+
fontSize: import_zod5.z.number().default(48),
|
|
337
|
+
color: import_zod5.z.string().default("#FFFFFF"),
|
|
338
|
+
position: import_zod5.z.enum(["top", "center", "bottom", "left", "right"]).default("center"),
|
|
339
|
+
animation: import_zod5.z.enum(["none", "fade", "slide", "zoom"]).default("fade")
|
|
340
|
+
});
|
|
341
|
+
var getPositionStyles = (position) => {
|
|
342
|
+
const base = {
|
|
343
|
+
display: "flex",
|
|
344
|
+
justifyContent: "center",
|
|
345
|
+
alignItems: "center"
|
|
346
|
+
};
|
|
347
|
+
switch (position) {
|
|
348
|
+
case "top":
|
|
349
|
+
return { ...base, alignItems: "flex-start", paddingTop: 60 };
|
|
350
|
+
case "bottom":
|
|
351
|
+
return { ...base, alignItems: "flex-end", paddingBottom: 60 };
|
|
352
|
+
case "left":
|
|
353
|
+
return { ...base, justifyContent: "flex-start", paddingLeft: 60 };
|
|
354
|
+
case "right":
|
|
355
|
+
return { ...base, justifyContent: "flex-end", paddingRight: 60 };
|
|
356
|
+
default:
|
|
357
|
+
return base;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var getAnimationStyle = (frame, animation) => {
|
|
361
|
+
const animDuration = 30;
|
|
362
|
+
switch (animation) {
|
|
363
|
+
case "fade": {
|
|
364
|
+
const opacity = (0, import_remotion4.interpolate)(frame, [0, animDuration], [0, 1], {
|
|
365
|
+
extrapolateLeft: "clamp",
|
|
366
|
+
extrapolateRight: "clamp"
|
|
367
|
+
});
|
|
368
|
+
return { opacity };
|
|
369
|
+
}
|
|
370
|
+
case "slide": {
|
|
371
|
+
const translateY = (0, import_remotion4.interpolate)(frame, [0, animDuration], [50, 0], {
|
|
372
|
+
extrapolateLeft: "clamp",
|
|
373
|
+
extrapolateRight: "clamp"
|
|
374
|
+
});
|
|
375
|
+
const opacity = (0, import_remotion4.interpolate)(frame, [0, animDuration], [0, 1], {
|
|
376
|
+
extrapolateLeft: "clamp",
|
|
377
|
+
extrapolateRight: "clamp"
|
|
378
|
+
});
|
|
379
|
+
return { transform: `translateY(${translateY}px)`, opacity };
|
|
380
|
+
}
|
|
381
|
+
case "zoom": {
|
|
382
|
+
const scale = (0, import_remotion4.interpolate)(frame, [0, animDuration], [0.8, 1], {
|
|
383
|
+
extrapolateLeft: "clamp",
|
|
384
|
+
extrapolateRight: "clamp"
|
|
385
|
+
});
|
|
386
|
+
const opacity = (0, import_remotion4.interpolate)(frame, [0, animDuration], [0, 1], {
|
|
387
|
+
extrapolateLeft: "clamp",
|
|
388
|
+
extrapolateRight: "clamp"
|
|
389
|
+
});
|
|
390
|
+
return { transform: `scale(${scale})`, opacity };
|
|
391
|
+
}
|
|
392
|
+
default:
|
|
393
|
+
return {};
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var Text = ({ content, fontSize, color, position, animation }) => {
|
|
397
|
+
const frame = (0, import_remotion4.useCurrentFrame)();
|
|
398
|
+
const positionStyles = getPositionStyles(position);
|
|
399
|
+
const animationStyles = getAnimationStyle(frame, animation);
|
|
400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_remotion4.AbsoluteFill, { style: positionStyles, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
401
|
+
"div",
|
|
402
|
+
{
|
|
403
|
+
style: {
|
|
404
|
+
fontSize,
|
|
405
|
+
color,
|
|
406
|
+
fontWeight: 600,
|
|
407
|
+
textAlign: "center",
|
|
408
|
+
...animationStyles
|
|
409
|
+
},
|
|
410
|
+
children: content
|
|
411
|
+
}
|
|
412
|
+
) });
|
|
413
|
+
};
|
|
414
|
+
var TextComponentMetadata = {
|
|
415
|
+
category: "primitive",
|
|
416
|
+
description: "Displays animated text with positioning and animation options",
|
|
417
|
+
llmGuidance: 'Use for titles, subtitles, captions. Keep content under 100 characters for readability. Position "center" works best for titles.',
|
|
418
|
+
examples: [
|
|
419
|
+
{
|
|
420
|
+
content: "Welcome to Waves",
|
|
421
|
+
fontSize: 72,
|
|
422
|
+
color: "#FFFFFF",
|
|
423
|
+
position: "center",
|
|
424
|
+
animation: "fade"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
content: "Building the future of video",
|
|
428
|
+
fontSize: 36,
|
|
429
|
+
color: "#CCCCCC",
|
|
430
|
+
position: "bottom",
|
|
431
|
+
animation: "slide"
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// src/components/registry.ts
|
|
437
|
+
function registerBuiltInComponents() {
|
|
438
|
+
if (!globalRegistry.has("Scene")) {
|
|
439
|
+
globalRegistry.register({
|
|
440
|
+
type: "Scene",
|
|
441
|
+
component: Scene,
|
|
442
|
+
propsSchema: ScenePropsSchema,
|
|
443
|
+
metadata: SceneComponentMetadata
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
if (!globalRegistry.has("Text")) {
|
|
447
|
+
globalRegistry.register({
|
|
448
|
+
type: "Text",
|
|
449
|
+
component: Text,
|
|
450
|
+
propsSchema: TextPropsSchema,
|
|
451
|
+
metadata: TextComponentMetadata
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
if (!globalRegistry.has("Audio")) {
|
|
455
|
+
globalRegistry.register({
|
|
456
|
+
type: "Audio",
|
|
457
|
+
component: Audio,
|
|
458
|
+
propsSchema: AudioPropsSchema,
|
|
459
|
+
metadata: AudioComponentMetadata
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
464
|
+
0 && (module.exports = {
|
|
465
|
+
WavesComposition,
|
|
466
|
+
globalRegistry,
|
|
467
|
+
registerBuiltInComponents
|
|
468
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WavesRenderError,
|
|
3
|
+
globalRegistry,
|
|
4
|
+
registerBuiltInComponents
|
|
5
|
+
} from "../chunk-TGAL5RQN.mjs";
|
|
6
|
+
|
|
7
|
+
// src/remotion/WavesComposition.tsx
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { Sequence } from "remotion";
|
|
10
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
11
|
+
var WavesComposition = ({ ir, registry }) => {
|
|
12
|
+
return /* @__PURE__ */ jsx(Fragment, { children: ir.scenes.map((scene) => renderComponent(scene, registry)) });
|
|
13
|
+
};
|
|
14
|
+
var getProps = (component) => {
|
|
15
|
+
return component.props ?? {};
|
|
16
|
+
};
|
|
17
|
+
var getChildren = (component) => {
|
|
18
|
+
return component.children;
|
|
19
|
+
};
|
|
20
|
+
function renderComponent(component, registry) {
|
|
21
|
+
const registration = registry.get(component.type);
|
|
22
|
+
if (!registration) {
|
|
23
|
+
throw new WavesRenderError("Unknown component type", { type: component.type });
|
|
24
|
+
}
|
|
25
|
+
const propsValidation = registry.validateProps(component.type, getProps(component));
|
|
26
|
+
if (!propsValidation.success) {
|
|
27
|
+
throw new WavesRenderError("Component props validation failed", {
|
|
28
|
+
type: component.type,
|
|
29
|
+
issues: propsValidation.error.issues
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const parsedProps = propsValidation.data;
|
|
33
|
+
if (!parsedProps || typeof parsedProps !== "object") {
|
|
34
|
+
throw new WavesRenderError("Component props must be an object", { type: component.type });
|
|
35
|
+
}
|
|
36
|
+
const children = component.type === "Scene" && getChildren(component)?.length ? getChildren(component).map((child) => renderComponent(child, registry)) : null;
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
Sequence,
|
|
39
|
+
{
|
|
40
|
+
from: component.timing.from,
|
|
41
|
+
durationInFrames: component.timing.durationInFrames,
|
|
42
|
+
children: React.createElement(
|
|
43
|
+
registration.component,
|
|
44
|
+
{
|
|
45
|
+
...parsedProps,
|
|
46
|
+
__wavesDurationInFrames: component.timing.durationInFrames
|
|
47
|
+
},
|
|
48
|
+
children
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
component.id
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
WavesComposition,
|
|
56
|
+
globalRegistry,
|
|
57
|
+
registerBuiltInComponents
|
|
58
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depths/waves",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Type-safe video generation engine for converting JSON IR to rendered videos using Remotion",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"waves": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"import": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./remotion": {
|
|
17
|
+
"types": "./dist/remotion/index.d.ts",
|
|
18
|
+
"require": "./dist/remotion/index.js",
|
|
19
|
+
"import": "./dist/remotion/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup src/index.ts src/remotion/index.ts src/cli.ts --format cjs,esm --dts --clean && node scripts/add-shebang.mjs dist/cli.js",
|
|
30
|
+
"dev": "tsup src/index.ts src/remotion/index.ts src/cli.ts --format cjs,esm --dts --watch",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"lint": "eslint",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"prepublishOnly": "npm run build && npm run test && npm run typecheck"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"remotion",
|
|
39
|
+
"video",
|
|
40
|
+
"generation",
|
|
41
|
+
"llm",
|
|
42
|
+
"json",
|
|
43
|
+
"ir",
|
|
44
|
+
"typescript",
|
|
45
|
+
"zod"
|
|
46
|
+
],
|
|
47
|
+
"author": "Depths AI",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/depths-ai/waves.git"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.11.0 <25.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": "^19.0.0",
|
|
58
|
+
"remotion": "4.0.407"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@remotion/bundler": "4.0.407",
|
|
62
|
+
"@remotion/cli": "4.0.407",
|
|
63
|
+
"@remotion/renderer": "4.0.407",
|
|
64
|
+
"zod": "^4.3.5"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/node": "^22.10.5",
|
|
68
|
+
"@types/react": "^19.0.6",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
70
|
+
"@typescript-eslint/parser": "^8.21.0",
|
|
71
|
+
"eslint": "^9.18.0",
|
|
72
|
+
"react": "^19.0.0",
|
|
73
|
+
"remotion": "4.0.407",
|
|
74
|
+
"tsup": "^8.4.0",
|
|
75
|
+
"typescript": "^5.9.0",
|
|
76
|
+
"typescript-eslint": "^8.21.0",
|
|
77
|
+
"vitest": "^4.0.18"
|
|
78
|
+
}
|
|
79
|
+
}
|