@remotion-studio/sdk 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/README.md +369 -0
- package/dist/runtime/compiler.d.ts +7 -0
- package/dist/runtime/compiler.js +131 -0
- package/dist/runtime/components.d.ts +4 -0
- package/dist/runtime/components.js +48 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +16 -0
- package/dist/sdk/client.d.ts +37 -0
- package/dist/sdk/client.js +413 -0
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +18 -0
- package/dist/sdk/types.d.ts +197 -0
- package/dist/sdk/types.js +2 -0
- package/dist/shared/artifact.d.ts +58 -0
- package/dist/shared/artifact.js +41 -0
- package/dist/shared/sanitize.d.ts +3 -0
- package/dist/shared/sanitize.js +48 -0
- package/package.json +57 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type MotionGraphicsEditType = "tool_edit" | "full_replacement";
|
|
2
|
+
export type MotionGraphicsPresetReference = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
source: "builtin" | "custom";
|
|
6
|
+
};
|
|
7
|
+
export declare const MOTION_GRAPHICS_ARTIFACT_VERSION: 1;
|
|
8
|
+
export declare const MOTION_GRAPHICS_RUNTIME: "remotion-dynamic-v1";
|
|
9
|
+
export declare const DEFAULT_MOTION_GRAPHICS_WIDTH = 1920;
|
|
10
|
+
export declare const DEFAULT_MOTION_GRAPHICS_HEIGHT = 1080;
|
|
11
|
+
export declare const DEFAULT_MOTION_GRAPHICS_FPS = 30;
|
|
12
|
+
export declare const DEFAULT_MOTION_GRAPHICS_DURATION_IN_FRAMES = 180;
|
|
13
|
+
export type MotionGraphicsArtifactV1 = {
|
|
14
|
+
version: typeof MOTION_GRAPHICS_ARTIFACT_VERSION;
|
|
15
|
+
runtime: typeof MOTION_GRAPHICS_RUNTIME;
|
|
16
|
+
code: string;
|
|
17
|
+
composition: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
fps: number;
|
|
21
|
+
durationInFrames: number;
|
|
22
|
+
};
|
|
23
|
+
metadata: {
|
|
24
|
+
model: string;
|
|
25
|
+
skills: string[];
|
|
26
|
+
editType: MotionGraphicsEditType;
|
|
27
|
+
summary: string;
|
|
28
|
+
preset?: MotionGraphicsPresetReference;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type MotionGraphicsArtifact = MotionGraphicsArtifactV1;
|
|
32
|
+
export type MotionGraphicsCompositionProps = {
|
|
33
|
+
artifact: MotionGraphicsArtifact;
|
|
34
|
+
componentProps?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
type CreateMotionGraphicsArtifactParams = {
|
|
37
|
+
code: string;
|
|
38
|
+
summary?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
skills?: string[];
|
|
41
|
+
editType?: MotionGraphicsEditType;
|
|
42
|
+
preset?: MotionGraphicsPresetReference;
|
|
43
|
+
width?: number;
|
|
44
|
+
height?: number;
|
|
45
|
+
fps?: number;
|
|
46
|
+
durationInFrames?: number;
|
|
47
|
+
};
|
|
48
|
+
export declare const createMotionGraphicsArtifact: ({ code, summary, model, skills, editType, preset, width, height, fps, durationInFrames, }: CreateMotionGraphicsArtifactParams) => MotionGraphicsArtifactV1;
|
|
49
|
+
export declare const calculateMotionGraphicsMetadata: ({ props, }: {
|
|
50
|
+
props: MotionGraphicsCompositionProps;
|
|
51
|
+
}) => {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
fps: number;
|
|
55
|
+
durationInFrames: number;
|
|
56
|
+
props: MotionGraphicsCompositionProps;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateMotionGraphicsMetadata = exports.createMotionGraphicsArtifact = exports.DEFAULT_MOTION_GRAPHICS_DURATION_IN_FRAMES = exports.DEFAULT_MOTION_GRAPHICS_FPS = exports.DEFAULT_MOTION_GRAPHICS_HEIGHT = exports.DEFAULT_MOTION_GRAPHICS_WIDTH = exports.MOTION_GRAPHICS_RUNTIME = exports.MOTION_GRAPHICS_ARTIFACT_VERSION = void 0;
|
|
4
|
+
exports.MOTION_GRAPHICS_ARTIFACT_VERSION = 1;
|
|
5
|
+
exports.MOTION_GRAPHICS_RUNTIME = "remotion-dynamic-v1";
|
|
6
|
+
exports.DEFAULT_MOTION_GRAPHICS_WIDTH = 1920;
|
|
7
|
+
exports.DEFAULT_MOTION_GRAPHICS_HEIGHT = 1080;
|
|
8
|
+
exports.DEFAULT_MOTION_GRAPHICS_FPS = 30;
|
|
9
|
+
exports.DEFAULT_MOTION_GRAPHICS_DURATION_IN_FRAMES = 180;
|
|
10
|
+
const createMotionGraphicsArtifact = ({ code, summary = "", model = "unknown", skills = [], editType = "full_replacement", preset, width = exports.DEFAULT_MOTION_GRAPHICS_WIDTH, height = exports.DEFAULT_MOTION_GRAPHICS_HEIGHT, fps = exports.DEFAULT_MOTION_GRAPHICS_FPS, durationInFrames = exports.DEFAULT_MOTION_GRAPHICS_DURATION_IN_FRAMES, }) => {
|
|
11
|
+
return {
|
|
12
|
+
version: exports.MOTION_GRAPHICS_ARTIFACT_VERSION,
|
|
13
|
+
runtime: exports.MOTION_GRAPHICS_RUNTIME,
|
|
14
|
+
code,
|
|
15
|
+
composition: {
|
|
16
|
+
width,
|
|
17
|
+
height,
|
|
18
|
+
fps,
|
|
19
|
+
durationInFrames,
|
|
20
|
+
},
|
|
21
|
+
metadata: {
|
|
22
|
+
model,
|
|
23
|
+
skills,
|
|
24
|
+
editType,
|
|
25
|
+
summary,
|
|
26
|
+
...(preset ? { preset } : {}),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.createMotionGraphicsArtifact = createMotionGraphicsArtifact;
|
|
31
|
+
const calculateMotionGraphicsMetadata = ({ props, }) => {
|
|
32
|
+
const { composition } = props.artifact;
|
|
33
|
+
return {
|
|
34
|
+
width: composition.width,
|
|
35
|
+
height: composition.height,
|
|
36
|
+
fps: composition.fps,
|
|
37
|
+
durationInFrames: composition.durationInFrames,
|
|
38
|
+
props,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.calculateMotionGraphicsMetadata = calculateMotionGraphicsMetadata;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripMarkdownFences = stripMarkdownFences;
|
|
4
|
+
exports.extractComponentCode = extractComponentCode;
|
|
5
|
+
exports.sanitizeGeneratedCode = sanitizeGeneratedCode;
|
|
6
|
+
function stripMarkdownFences(code) {
|
|
7
|
+
let result = code;
|
|
8
|
+
result = result.replace(/^```(?:tsx?|jsx?)?\n?/, "");
|
|
9
|
+
result = result.replace(/\n?```\s*$/, "");
|
|
10
|
+
return result.trim();
|
|
11
|
+
}
|
|
12
|
+
function extractComponentCode(code) {
|
|
13
|
+
const exportMatch = code.match(/export\s+const\s+\w+\s*(?::[\s\S]*?)?=\s*\([\s\S]*?\)\s*=>\s*\{/);
|
|
14
|
+
if (exportMatch && exportMatch.index !== undefined) {
|
|
15
|
+
const declarationStart = exportMatch.index;
|
|
16
|
+
const bodyStart = declarationStart + exportMatch[0].length;
|
|
17
|
+
let braceCount = 1;
|
|
18
|
+
let endIndex = bodyStart;
|
|
19
|
+
for (let i = bodyStart; i < code.length; i++) {
|
|
20
|
+
const char = code[i];
|
|
21
|
+
if (char === "{") {
|
|
22
|
+
braceCount++;
|
|
23
|
+
}
|
|
24
|
+
else if (char === "}") {
|
|
25
|
+
braceCount--;
|
|
26
|
+
if (braceCount === 0) {
|
|
27
|
+
endIndex = i;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (braceCount === 0) {
|
|
33
|
+
let result = code.slice(0, endIndex + 1);
|
|
34
|
+
if (!result.trim().endsWith(";")) {
|
|
35
|
+
result = result.trimEnd() + ";";
|
|
36
|
+
}
|
|
37
|
+
return result.trim();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return code;
|
|
41
|
+
}
|
|
42
|
+
function sanitizeGeneratedCode(code) {
|
|
43
|
+
const withoutFences = stripMarkdownFences(code);
|
|
44
|
+
const firstImport = withoutFences.indexOf("import ");
|
|
45
|
+
const firstExport = withoutFences.indexOf("export const ");
|
|
46
|
+
const startIndex = firstImport >= 0 ? firstImport : firstExport >= 0 ? firstExport : 0;
|
|
47
|
+
return extractComponentCode(withoutFences.slice(startIndex).trim());
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@remotion-studio/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Official Remotion Studio package for generating, editing, playing, and rendering AI-powered Remotion compositions.",
|
|
6
|
+
"packageManager": "bun@1.3.3",
|
|
7
|
+
"homepage": "https://remotionstudio.io",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"remotion",
|
|
10
|
+
"video",
|
|
11
|
+
"animation",
|
|
12
|
+
"motion-graphics",
|
|
13
|
+
"api",
|
|
14
|
+
"mcp",
|
|
15
|
+
"ai",
|
|
16
|
+
"sdk",
|
|
17
|
+
"openai",
|
|
18
|
+
"react",
|
|
19
|
+
"creative-tools",
|
|
20
|
+
"generative-ui"
|
|
21
|
+
],
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/sdk/index.d.ts",
|
|
28
|
+
"import": "./dist/sdk/index.js",
|
|
29
|
+
"require": "./dist/sdk/index.js",
|
|
30
|
+
"default": "./dist/sdk/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./runtime": {
|
|
33
|
+
"types": "./dist/runtime/index.d.ts",
|
|
34
|
+
"import": "./dist/runtime/index.js",
|
|
35
|
+
"require": "./dist/runtime/index.js",
|
|
36
|
+
"default": "./dist/runtime/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@babel/standalone": "^7.28.5",
|
|
44
|
+
"@remotion/lottie": "^4.0.429",
|
|
45
|
+
"@remotion/shapes": "^4.0.429",
|
|
46
|
+
"@remotion/three": "^4.0.429",
|
|
47
|
+
"@remotion/transitions": "^4.0.429",
|
|
48
|
+
"react": "^19.2.1",
|
|
49
|
+
"remotion": "^4.0.429",
|
|
50
|
+
"three": "^0.178.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
54
|
+
"test": "bun test ./test",
|
|
55
|
+
"deploy": "npm publish"
|
|
56
|
+
}
|
|
57
|
+
}
|